You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The Bank contract holds the casino's funds, whitelist the games betting tokens, define the max bet amount based on a risk, payout the bet profit to user and collect the loss bet amount from the game's contract, split and allocate the house edge taken from each bet (won or loss). The admin role is transfered to a Timelock that execute administrative tasks, only the Games could payout the bet profit from the bank, and send the loss bet amount to the bank.
All rates are in basis point.
Methods
DEFAULT_ADMIN_ROLE
function DEFAULT_ADMIN_ROLE() externalviewreturns (bytes32)
Returns
Name
Type
Description
_0
bytes32
undefined
GAME_ROLE
function GAME_ROLE() externalviewreturns (bytes32)
Role associated to Games smart contracts.
Returns
Name
Type
Description
_0
bytes32
undefined
HARVESTER_ROLE
function HARVESTER_ROLE() externalviewreturns (bytes32)
Role associated to harvester smart contract.
Returns
Name
Type
Description
_0
bytes32
undefined
addToken
function addToken(addresstoken) external nonpayable
Adds a new token that'll be enabled for the games' betting. Token shouldn't exist yet.
Parameters
Name
Type
Description
token
address
Address of the token.
cashIn
function cashIn(addresstokenAddress, uint256amount, uint256fees) externalpayable
Accounts a loss bet.
In case of an ERC20, the bet amount should be transfered prior to this tx.In case of the gas token, the bet amount is sent along with this tx.
Parameters
Name
Type
Description
tokenAddress
address
Address of the token.
amount
uint256
Loss bet amount.
fees
uint256
Bet amount and bet profit fees amount.
checkUpkeep
function checkUpkeep(bytescheckData) externalviewreturns (boolupkeepNeeded, bytesperformData)
Runs by Chainlink Keepers at every block to determine if performUpkeep should be called.
checkData and performData are encoded with types (uint8, address).
Parameters
Name
Type
Description
checkData
bytes
Fixed and specified at Upkeep registration.
Returns
Name
Type
Description
upkeepNeeded
bool
Boolean that when True will trigger the on-chain performUpkeep call.
performData
bytes
Bytes that will be used as input parameter when calling performUpkeep.
deposit
function deposit(addresstoken, uint256amount) externalpayable
Deposit funds in the bank to allow gamers to win more. ERC20 token allowance should be given prior to deposit.
Parameters
Name
Type
Description
token
address
Address of the token.
amount
uint256
Number of tokens.
getBalance
function getBalance(addresstoken) externalviewreturns (uint256)
Gets the token's balance. The token's house edge allocation amounts are subtracted from the balance.
Parameters
Name
Type
Description
token
address
Address of the token.
Returns
Name
Type
Description
_0
uint256
The amount of token available for profits.
getMaxBetAmount
function getMaxBetAmount(addresstoken, uint256multiplier) externalviewreturns (uint256)
Calculates the max bet amount based on the token balance, the balance risk, and the game multiplier.
The multiplier should be at least 10000.
Parameters
Name
Type
Description
token
address
Address of the token.
multiplier
uint256
The bet amount leverage determines the user's profit amount. 10000 = 100% = no profit.
Returns
Name
Type
Description
_0
uint256
Maximum bet amount for the token.
getMinBetAmount
function getMinBetAmount(addresstoken) externalviewreturns (uint256minBetAmount)
Gets the token's min bet amount.
The min bet amount should be at least 10000 cause of the getMaxBetAmount calculation.
Parameters
Name
Type
Description
token
address
Address of the token.
Returns
Name
Type
Description
minBetAmount
uint256
Min bet amount.
getRoleAdmin
function getRoleAdmin(bytes32role) externalviewreturns (bytes32)
Returns the admin role that controls role. See {grantRole} and {revokeRole}. To change a role's admin, use {_setRoleAdmin}.
Parameters
Name
Type
Description
role
bytes32
undefined
Returns
Name
Type
Description
_0
bytes32
undefined
getRoleMember
function getRoleMember(bytes32role, uint256index) externalviewreturns (address)
Returns one of the accounts that have role. index must be a value between 0 and {getRoleMemberCount}, non-inclusive. Role bearers are not sorted in any particular way, and their ordering may change at any point. WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure you perform all queries on the same block. See the following https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post] for more information.
Parameters
Name
Type
Description
role
bytes32
undefined
index
uint256
undefined
Returns
Name
Type
Description
_0
address
undefined
getRoleMemberCount
function getRoleMemberCount(bytes32role) externalviewreturns (uint256)
Returns the number of accounts that have role. Can be used together with {getRoleMember} to enumerate all bearers of a role.
Parameters
Name
Type
Description
role
bytes32
undefined
Returns
Name
Type
Description
_0
uint256
undefined
getTokenOwner
function getTokenOwner(addresstoken) externalviewreturns (address)
Gets the token's owner.
Parameters
Name
Type
Description
token
address
Address of the token.
Returns
Name
Type
Description
_0
address
Address of the owner.
getTokens
function getTokens() externalviewreturns (struct Bank.TokenMetadata[])
For the front-end
Returns
Name
Type
Description
_0
Bank.TokenMetadata[]
undefined
getVRFSubId
function getVRFSubId(addresstoken) externalviewreturns (uint64)
Gets the token's Chainlink VRF v2 Subscription ID.
Parameters
Name
Type
Description
token
address
Address of the token.
Returns
Name
Type
Description
_0
uint64
Chainlink VRF v2 Subscription ID.
grantRole
function grantRole(bytes32role, addressaccount) external nonpayable
Grants role to account. If account had not been already granted role, emits a {RoleGranted} event. Requirements: - the caller must have role's admin role. May emit a {RoleGranted} event.
Parameters
Name
Type
Description
role
bytes32
undefined
account
address
undefined
harvestDividends
function harvestDividends() external nonpayable
Harvests tokens dividends.
hasRole
function hasRole(bytes32role, addressaccount) externalviewreturns (bool)
Returns true if account has been granted role.
Parameters
Name
Type
Description
role
bytes32
undefined
account
address
undefined
Returns
Name
Type
Description
_0
bool
undefined
isAllowedToken
function isAllowedToken(addresstokenAddress) externalviewreturns (bool)
Gets the token's allow status used on the games smart contracts.
Parameters
Name
Type
Description
tokenAddress
address
Address of the token.
Returns
Name
Type
Description
_0
bool
Whether the token is enabled for bets.
multicall
function multicall(bytes[] data) external nonpayable returns (bytes[] results)
Receives and executes a batch of function calls on this contract.
Parameters
Name
Type
Description
data
bytes[]
undefined
Returns
Name
Type
Description
results
bytes[]
undefined
payout
function payout(addressuser, addresstoken, uint256profit, uint256fees) externalpayable
Payouts a winning bet, and allocate the house edge fee.
Parameters
Name
Type
Description
user
address
Address of the gamer.
token
address
Address of the token.
profit
uint256
Number of tokens to be sent to the gamer.
fees
uint256
Bet amount and bet profit fees amount.
performUpkeep
function performUpkeep(bytesperformData) external nonpayable
Executed by Chainlink Keepers when upkeepNeeded is true.
Parameters
Name
Type
Description
performData
bytes
Data which was passed back from checkUpkeep.
renounceRole
function renounceRole(bytes32role, addressaccount) external nonpayable
Revokes role from the calling account. Roles are often managed via {grantRole} and {revokeRole}: this function's purpose is to provide a mechanism for accounts to lose their privileges if they are compromised (such as when a trusted device is misplaced). If the calling account had been revoked role, emits a {RoleRevoked} event. Requirements: - the caller must be account. May emit a {RoleRevoked} event.
Parameters
Name
Type
Description
role
bytes32
undefined
account
address
undefined
revokeRole
function revokeRole(bytes32role, addressaccount) external nonpayable
Revokes role from account. If account had been granted role, emits a {RoleRevoked} event. Requirements: - the caller must have role's admin role. May emit a {RoleRevoked} event.
Parameters
Name
Type
Description
role
bytes32
undefined
account
address
undefined
setAllowedToken
function setAllowedToken(addresstoken, boolallowed) external nonpayable
Changes the token's bet permission.
Parameters
Name
Type
Description
token
address
Address of the token.
allowed
bool
Whether the token is enabled for bets.
setBalanceRisk
function setBalanceRisk(addresstoken, uint16balanceRisk) external nonpayable
Sets the new token balance risk.
Parameters
Name
Type
Description
token
address
Address of the token.
balanceRisk
uint16
Risk rate.
setHouseEdgeSplit
function setHouseEdgeSplit(addresstoken, uint16bank, uint16dividend, uint16partner, uint16_treasury, uint16team) external nonpayable
Sets the token's house edge allocations for bet payout.
bank, dividend, _treasury and team rates sum must equals 10000.
Parameters
Name
Type
Description
token
address
Address of the token.
bank
uint16
Rate to be allocated to the bank, on bet payout.
dividend
uint16
Rate to be allocated as staking rewards, on bet payout.
partner
uint16
Rate to be allocated to the partner, on bet payout.
_treasury
uint16
Rate to be allocated to the treasury, on bet payout.
team
uint16
Rate to be allocated to the team, on bet payout.
setMinHouseEdgeWithdrawAmount
function setMinHouseEdgeWithdrawAmount(addresstoken, uint256minHouseEdgeWithdrawAmount) external nonpayable
Changes the token's Upkeep min transfer amount.
Parameters
Name
Type
Description
token
address
Address of the token.
minHouseEdgeWithdrawAmount
uint256
Minimum amount of token to allow transfer.
setPausedToken
function setPausedToken(addresstoken, boolpaused) external nonpayable
Changes the token's paused status.
Parameters
Name
Type
Description
token
address
Address of the token.
paused
bool
Whether the token is paused.
setTeamWallet
function setTeamWallet(address_teamWallet) external nonpayable
Sets the new team wallet.
Parameters
Name
Type
Description
_teamWallet
address
The team wallet address.
setTokenMinBetAmount
function setTokenMinBetAmount(addresstoken, uint256tokenMinBetAmount) external nonpayable
Sets the minimum bet amount for a specific token.
Parameters
Name
Type
Description
token
address
Address of the token.
tokenMinBetAmount
uint256
Minimum bet amount.
setTokenPartner
function setTokenPartner(addresstoken, addresspartner) external nonpayable
Changes the token's partner address. It withdraw the available balance, the partner allocation, and the games' VRF fees.
Parameters
Name
Type
Description
token
address
Address of the token.
partner
address
Address of the partner.
setTokenVRFSubId
function setTokenVRFSubId(addresstoken, uint64subId) external nonpayable
Sets the Chainlink VRF subscription ID for a specific token.
Parameters
Name
Type
Description
token
address
Address of the token.
subId
uint64
Subscription ID.
supportsInterface
function supportsInterface(bytes4interfaceId) externalviewreturns (bool)
See {IERC165-supportsInterface}.
Parameters
Name
Type
Description
interfaceId
bytes4
undefined
Returns
Name
Type
Description
_0
bool
undefined
teamWallet
function teamWallet() externalviewreturns (address)