AvoDepositManager
AvoDepositManager_V1
Handles deposits in a deposit token (e.g. USDC). Note: user balances are tracked off-chain through events by the Avocado infrastructure.
Upgradeable through AvoDepositManagerProxy
AvoDepositManagerErrors
AvoDepositManager__Unauthorized
error AvoDepositManager__Unauthorized()thrown when msg.sender is not authorized to access requested functionality
AvoDepositManager__InvalidParams
error AvoDepositManager__InvalidParams()thrown when invalid params for a method are submitted, e.g. zero address as input param
AvoDepositManager__RequestAlreadyExist
error AvoDepositManager__RequestAlreadyExist()thrown when a withdraw request already exists
AvoDepositManager__RequestNotExist
error AvoDepositManager__RequestNotExist()thrown when a withdraw request does not exist
AvoDepositManager__MinWithdraw
error AvoDepositManager__MinWithdraw()thrown when a withdraw request does not at least request minWithdrawAmount
AvoDepositManager__FeeNotCovered
error AvoDepositManager__FeeNotCovered()thrown when a withdraw request amount does not cover the withdraw fee at processing time
AvoDepositManager__Unsupported
error AvoDepositManager__Unsupported()thrown when an unsupported method is called (e.g. renounceOwnership)
AvoDepositManagerConstants
depositToken
contract IERC20 depositTokenaddress of the deposit token (USDC)
avoFactory
contract IAvoFactory avoFactoryaddress of the AvoFactory (proxy)
AvoDepositManagerStructs
WithdrawRequest
struct WithdrawRequest {
address to;
uint256 amount;
}AvoDepositManagerVariables
systemWithdrawAddress
address systemWithdrawAddressaddress to which funds can be systemWithdrawn to. Configurable by owner.
systemWithdrawLimit
uint96 systemWithdrawLimitminimum amount which must stay in contract and can not be systemWithdrawn. Configurable by owner.
withdrawFee
uint96 withdrawFeestatic withdraw fee charged when a withdrawRequest is processed. Configurable by owner.
minWithdrawAmount
uint96 minWithdrawAmountminimum withdraw amount that a user must request to withdraw. Configurable by owner.
auths
mapping(address => uint256) authsallowed auths list (1 = allowed) that can confirm withdraw requests. Configurable by owner.
withdrawRequests
mapping(bytes32 => struct AvoDepositManagerStructs.WithdrawRequest) withdrawRequestswithdraw requests. unique id -> WithdrawRequest (amount and receiver)
AvoDepositManagerEvents
Deposit
event Deposit(address sender, address avocado, uint256 amount)emitted when a deposit occurs through depositOnBehalf()
WithdrawRequested
event WithdrawRequested(bytes32 id, address avocado, uint256 amount)emitted when a user requests a withdrawal
WithdrawProcessed
event WithdrawProcessed(bytes32 id, address user, uint256 amount, uint256 fee)emitted when a withdraw request is executed
WithdrawRemoved
event WithdrawRemoved(bytes32 id)emitted when a withdraw request is removed
SourceWithdrawRequested
event SourceWithdrawRequested(bytes32 id, address user, uint256 amount)emitted when someone requests a source withdrawal
ReferralWithdrawRequested
event ReferralWithdrawRequested(bytes32 id, address user, uint256 amount)emitted when someone requests a referral withdrawal
SetSystemWithdrawLimit
event SetSystemWithdrawLimit(uint96 systemWithdrawLimit)emitted when the withdrawLimit is modified by owner
SetSystemWithdrawAddress
event SetSystemWithdrawAddress(address systemWithdrawAddress)emitted when the withdrawAddress is modified by owner
SetWithdrawFee
event SetWithdrawFee(uint96 withdrawFee)emitted when the withdrawFee is modified by owner
SetMinWithdrawAmount
event SetMinWithdrawAmount(uint96 minWithdrawAmount)emitted when the minWithdrawAmount is modified by owner
SetAuth
event SetAuth(address auth, bool allowed)emitted when the auths are modified by owner
AvoDepositManagerCore
AvoDepositManagerOwnerActions
setSystemWithdrawLimit
function setSystemWithdrawLimit(uint96 systemWithdrawLimit_) externalSets new system withdraw limit. Only callable by owner.
Parameters
| Name | Type | Description |
|---|---|---|
| systemWithdrawLimit_ | uint96 | new value |
setSystemWithdrawAddress
function setSystemWithdrawAddress(address systemWithdrawAddress_) externalSets new system withdraw address. Only callable by owner.
Parameters
| Name | Type | Description |
|---|---|---|
| systemWithdrawAddress_ | address | new value |
setWithdrawFee
function setWithdrawFee(uint96 withdrawFee_) externalSets new withdraw fee (in absolute amount). Only callable by owner.
Parameters
| Name | Type | Description |
|---|---|---|
| withdrawFee_ | uint96 | new value |
setMinWithdrawAmount
function setMinWithdrawAmount(uint96 minWithdrawAmount_) externalSets new min withdraw amount. Only callable by owner.
Parameters
| Name | Type | Description |
|---|---|---|
| minWithdrawAmount_ | uint96 | new value |
setAuth
function setAuth(address auth_, bool allowed_) externalSets an address as allowed auth or not. Only callable by owner.
Parameters
| Name | Type | Description |
|---|---|---|
| auth_ | address | address to set auth value for |
| allowed_ | bool | bool flag for whether address is allowed as auth or not |
unpause
function unpause() externalunpauses the contract, re-enabling withdraw requests and processing. Only callable by owner.
AvoDepositManagerAuthsActions
processWithdraw
function processWithdraw(bytes32 withdrawId_) externalAuthorizes and processes a withdraw request. Only callable by auths & owner.
Parameters
| Name | Type | Description |
|---|---|---|
| withdrawId_ | bytes32 | unique withdraw request id as created in requestWithdraw() |
pause
function pause() externalpauses the contract, temporarily blocking withdraw requests and processing. Only callable by auths & owner. Unpausing can only be triggered by owner.
systemWithdraw
function systemWithdraw() externalWithdraws balance of deposit token down to systemWithdrawLimit to the configured systemWithdrawAddress
AvoDepositManager
constructor
constructor(contract IAvoFactory avoFactory_, contract IAvoConfigV1 avoConfigV1_) publicinitialize
function initialize(address owner_, address systemWithdrawAddress_, uint96 systemWithdrawLimit_, uint96 minWithdrawAmount_, uint96 withdrawFee_) publicinitializes the contract for owner_ as owner, and various config values regarding withdrawals. Starts the contract in paused state.
Parameters
| Name | Type | Description |
|---|---|---|
| owner_ | address | address of owner authorized to withdraw funds and set config values, auths etc. |
| systemWithdrawAddress_ | address | address to which funds can be system withdrawn to |
| systemWithdrawLimit_ | uint96 | minimum amount which must stay in contract and can not be system withdrawn |
| minWithdrawAmount_ | uint96 | static withdraw fee charged when a withdrawRequest is processed |
| withdrawFee_ | uint96 | minimum withdraw amount that a user must request to withdraw |
isAuth
function isAuth(address auth_) external view returns (bool)checks if a certain address auth_ is an allowed auth
depositOnBehalf
function depositOnBehalf(address receiver_, uint256 amount_) externalDeposits amount_ of deposit token to this contract and emits the Deposit event, with receiver_ address used for off-chain tracking
Parameters
| Name | Type | Description |
|---|---|---|
| receiver_ | address | address receiving funds via indirect off-chain tracking |
| amount_ | uint256 | amount to deposit |
removeWithdrawRequest
function removeWithdrawRequest(bytes32 withdrawId_) externalremoves a withdraw request, essentially denying it or retracting it. Only callable by auths or withdraw request receiver.
Parameters
| Name | Type | Description |
|---|---|---|
| withdrawId_ | bytes32 | unique withdraw request id as created in requestWithdraw() |
requestWithdraw
function requestWithdraw(uint256 amount_) external returns (bytes32 uniqueId_)Requests withdrawal of amount_ of gas balance. Only callable by Avocado smart wallets.
Parameters
| Name | Type | Description |
|---|---|---|
| amount_ | uint256 | amount to withdraw |
Return Values
| Name | Type | Description |
|---|---|---|
| uniqueId_ | bytes32 | the unique withdraw request id used to trigger processing |
requestSourceWithdraw
function requestSourceWithdraw(uint256 amount_) external returns (bytes32 uniqueId_)same as requestWithdraw() but anyone can request withdrawal of funds, not just Avocado smart wallets. Used for the Revenue sharing program.
Parameters
| Name | Type | Description |
|---|---|---|
| amount_ | uint256 | amount to withdraw |
Return Values
| Name | Type | Description |
|---|---|---|
| uniqueId_ | bytes32 | the unique withdraw request id used to trigger processing |
requestReferralWithdraw
function requestReferralWithdraw(uint256 amount_) external returns (bytes32 uniqueId_)same as requestWithdraw() but anyone can request withdrawal of funds, not just Avocado smart wallets. Used for the Referral sharing program.
Parameters
| Name | Type | Description |
|---|---|---|
| amount_ | uint256 | amount to withdraw |
Return Values
| Name | Type | Description |
|---|---|---|
| uniqueId_ | bytes32 | the unique withdraw request id used to trigger processing |
renounceOwnership
function renounceOwnership() public viewoverride renounce ownership as it could leave the contract in an unwanted state if called by mistake.