IBosonFundsHandler
View Source: contracts/interfaces/handlers/IBosonFundsHandler.sol
↗ Extends: IBosonFundsEvents, IBosonFundsLibEvents
IBosonFundsHandler
Handles custody and withdrawal of buyer and seller funds within the protocol.
The ERC-165 identifier for this interface is: 0x18834247
Functions
- depositFunds(uint256 _sellerId, address _tokenAddress, uint256 _amount)
- withdrawFunds(uint256 _entityId, address[] _tokenList, uint256[] _tokenAmounts)
- withdrawProtocolFees(address[] _tokenList, uint256[] _tokenAmounts)
- getAvailableFunds(uint256 _entityId)
depositFunds
Receives funds from the caller, maps funds to the seller id and stores them so they can be used during the commitToOffer.
Emits FundsDeposited event if successful.
Reverts if:
- The funds region of protocol is paused
- Seller id does not exist
- It receives some native currency (e.g. ETH), but token address is not zero
- It receives some native currency (e.g. ETH), and the amount does not match msg.value
- Contract at token address does not support ERC20 function transferFrom
- Calling transferFrom on token fails for some reason (e.g. protocol is not approved to transfer)
- Received ERC20 token amount differs from the expected value
function depositFunds(uint256 _sellerId,
address _tokenAddress,
uint256 _amount)
external
payable
Arguments
Name | Type | Description |
---|---|---|
_sellerId | uint256 | id of the seller that will be credited |
_tokenAddress | address | contract address of token that is being deposited (0 for native currency) |
_amount | uint256 | amount to be credited |
withdrawFunds
Withdraws the specified funds. Can be called for seller, buyer or agent.
Emits FundsWithdrawn event if successful.
Reverts if:
- The funds region of protocol is paused
- Caller is not associated with the entity id
- Token list length does not match amount list length
- Token list length exceeds the maximum allowed number of tokens
- Caller tries to withdraw more that they have in available funds
- There is nothing to withdraw
- Transfer of funds is not successful
function withdrawFunds(uint256 _entityId,
address[] _tokenList,
uint256[] _tokenAmounts)
external
Arguments
Name | Type | Description |
---|---|---|
_entityId | uint256 | id of entity for which funds should be withdrawn |
_tokenList | address[] | list of contract addresses of tokens that are being withdrawn |
_tokenAmounts | uint256[] | list of amounts to be withdrawn, corresponding to tokens in tokenList |
withdrawProtocolFees
Withdraws the protocol fees.Can only be called by the FEE_COLLECTOR role.
Emits FundsWithdrawn event if successful.
Reverts if:
- The funds region of protocol is paused
- Caller does not have the FEE_COLLECTOR role
- Token list length does not match amount list length
- Token list length exceeds the maximum allowed number of tokens
- Caller tries to withdraw more that they have in available funds
- There is nothing to withdraw
- Transfer of funds is not successful
function withdrawProtocolFees(address[] _tokenList,
uint256[] _tokenAmounts)
external
Arguments
Name | Type | Description |
---|---|---|
_tokenList | address[] | list of contract addresses of tokens that are being withdrawn |
_tokenAmounts | uint256[] | list of amounts to be withdrawn, corresponding to tokens in tokenList |
getAvailableFunds
Returns the information about the funds that an entity can use as a sellerDeposit and/or withdraw from the protocol.
function getAvailableFunds(uint256 _entityId)
external
view
returns(BosonTypes.Funds[] memory availableFunds)
Arguments
Name | Type | Description |
---|---|---|
_entityId | uint256 | id of entity for which availability of funds should be checked |
Returns
Name | Type | Description |
---|---|---|
availableFunds | BosonTypes.Funds[] | list of token addresses, token names and amount that can be used as a seller deposit or be withdrawn |