Bank

The bank serves as (i) a safe for the DAO's assets (ii) a ledger to keep accounting entries.

Accounts

Accounts keep track of assets owned by users of the DAO. However, they are only for accounting purposes, as the assets are in reality owned by the DAO and stored in their respective ERC20 contracts under the DAO's contract address.

All members have an account with the bank, allowing them to interact financially with the DAO.

Also, there are 3 reserved special accounts:

  • guild: the mutual fund, holding assets shared by members.

  • escrow: a temporary account used to lock assets while waiting for proposals to be closed.

  • total: the sum of guild and escrow.

Accounts information are stored onchain in the following storage var:

userTokenBalances (storage_var)

Arguments:

  • userAddress (felt): the user's address. The guild has a special reserved address, as well as the escrow and the total.

  • tokenAddress (felt): the token address.

Returns:

  • amount (felt): the number of token owned by the user.

Whitelisting Tokens

The bank can accept only whitelisted token addresses. This regulation measure provides members' security against infected tokens.

Tokens can be whitelisted through a proposal. The DAO stores a list of whitelisted tokens:

whitelistedTokensLength (storage_var)

Returns: (felt) the number of whitelisted tokens

whitelistedTokensIndexes (storage_var)

The list of whitelisted tokens' address

Arguments:

  • index (felt): positional index of the token

Returns:

  • tokenAddress (felt)

For convenience, it also stores a mapping of addresses to boolean.

whitelistedTokens (storage_var)

Whether a given address has been whitelisted

Arguments:

  • tokenAddress (felt)

Returns:

  • whitelisted (felt): whether the token is whitelisted

Transactions

A member can deposit/withdraw tokens to his/her account at any time through the following external functions:

deposit (external function)

Transfer ERC20 tokens from the caller's address to the bank's address

Arguments:

  • tokenAddress (felt)

  • amount (felt)

Returns:

  • success (felt): whether the transfert was successful

withdraw (external function)

Transfer tokens from the bank's address to the caller's address.

Arguments:

  • tokenAddress (felt)

  • amount (felt)

Returns:

  • sucess (felt): whether the transfer was successful

Last updated