Skip to main content

IBosonFundsHandler

View Source: contracts/interfaces/handlers/IBosonFundsHandler.sol

↗ Extends: IBosonFundsEvents, IBosonFundsLibEvents ↘ Derived Contracts: FundsHandlerFacet

IBosonFundsHandler

Handles custody and withdrawal of buyer and seller funds within the protocol.
The ERC-165 identifier for this interface is: 0x18834247

Functions

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

NameTypeDescription
_sellerIduint256id of the seller that will be credited
_tokenAddressaddresscontract address of token that is being deposited (0 for native currency)
_amountuint256amount 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

NameTypeDescription
_entityIduint256id of entity for which funds should be withdrawn
_tokenListaddress[]list of contract addresses of tokens that are being withdrawn
_tokenAmountsuint256[]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

NameTypeDescription
_tokenListaddress[]list of contract addresses of tokens that are being withdrawn
_tokenAmountsuint256[]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

NameTypeDescription
_entityIduint256id of entity for which availability of funds should be checked

Returns

NameTypeDescription
availableFundsBosonTypes.Funds[]list of token addresses, token names and amount that can be used as a seller deposit or be withdrawn