Skip to content

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 ​

solidity
error AvoDepositManager__Unauthorized()

thrown when msg.sender is not authorized to access requested functionality

AvoDepositManager__InvalidParams ​

solidity
error AvoDepositManager__InvalidParams()

thrown when invalid params for a method are submitted, e.g. zero address as input param

AvoDepositManager__RequestAlreadyExist ​

solidity
error AvoDepositManager__RequestAlreadyExist()

thrown when a withdraw request already exists

AvoDepositManager__RequestNotExist ​

solidity
error AvoDepositManager__RequestNotExist()

thrown when a withdraw request does not exist

AvoDepositManager__MinWithdraw ​

solidity
error AvoDepositManager__MinWithdraw()

thrown when a withdraw request does not at least request minWithdrawAmount

AvoDepositManager__FeeNotCovered ​

solidity
error AvoDepositManager__FeeNotCovered()

thrown when a withdraw request amount does not cover the withdraw fee at processing time

AvoDepositManager__Unsupported ​

solidity
error AvoDepositManager__Unsupported()

thrown when an unsupported method is called (e.g. renounceOwnership)

AvoDepositManagerConstants ​

depositToken ​

solidity
contract IERC20 depositToken

address of the deposit token (USDC)

avoFactory ​

solidity
contract IAvoFactory avoFactory

address of the AvoFactory (proxy)

AvoDepositManagerStructs ​

WithdrawRequest ​

solidity
struct WithdrawRequest {
  address to;
  uint256 amount;
}

AvoDepositManagerVariables ​

systemWithdrawAddress ​

solidity
address systemWithdrawAddress

address to which funds can be systemWithdrawn to. Configurable by owner.

systemWithdrawLimit ​

solidity
uint96 systemWithdrawLimit

minimum amount which must stay in contract and can not be systemWithdrawn. Configurable by owner.

withdrawFee ​

solidity
uint96 withdrawFee

static withdraw fee charged when a withdrawRequest is processed. Configurable by owner.

minWithdrawAmount ​

solidity
uint96 minWithdrawAmount

minimum withdraw amount that a user must request to withdraw. Configurable by owner.

auths ​

solidity
mapping(address => uint256) auths

allowed auths list (1 = allowed) that can confirm withdraw requests. Configurable by owner.

withdrawRequests ​

solidity
mapping(bytes32 => struct AvoDepositManagerStructs.WithdrawRequest) withdrawRequests

withdraw requests. unique id -> WithdrawRequest (amount and receiver)

AvoDepositManagerEvents ​

Deposit ​

solidity
event Deposit(address sender, address avocado, uint256 amount)

emitted when a deposit occurs through depositOnBehalf()

WithdrawRequested ​

solidity
event WithdrawRequested(bytes32 id, address avocado, uint256 amount)

emitted when a user requests a withdrawal

WithdrawProcessed ​

solidity
event WithdrawProcessed(bytes32 id, address user, uint256 amount, uint256 fee)

emitted when a withdraw request is executed

WithdrawRemoved ​

solidity
event WithdrawRemoved(bytes32 id)

emitted when a withdraw request is removed

SourceWithdrawRequested ​

solidity
event SourceWithdrawRequested(bytes32 id, address user, uint256 amount)

emitted when someone requests a source withdrawal

ReferralWithdrawRequested ​

solidity
event ReferralWithdrawRequested(bytes32 id, address user, uint256 amount)

emitted when someone requests a referral withdrawal

SetSystemWithdrawLimit ​

solidity
event SetSystemWithdrawLimit(uint96 systemWithdrawLimit)

emitted when the withdrawLimit is modified by owner

SetSystemWithdrawAddress ​

solidity
event SetSystemWithdrawAddress(address systemWithdrawAddress)

emitted when the withdrawAddress is modified by owner

SetWithdrawFee ​

solidity
event SetWithdrawFee(uint96 withdrawFee)

emitted when the withdrawFee is modified by owner

SetMinWithdrawAmount ​

solidity
event SetMinWithdrawAmount(uint96 minWithdrawAmount)

emitted when the minWithdrawAmount is modified by owner

SetAuth ​

solidity
event SetAuth(address auth, bool allowed)

emitted when the auths are modified by owner

AvoDepositManagerCore ​

AvoDepositManagerOwnerActions ​

setSystemWithdrawLimit ​

solidity
function setSystemWithdrawLimit(uint96 systemWithdrawLimit_) external

Sets new system withdraw limit. Only callable by owner.

Parameters ​

NameTypeDescription
systemWithdrawLimit_uint96new value

setSystemWithdrawAddress ​

solidity
function setSystemWithdrawAddress(address systemWithdrawAddress_) external

Sets new system withdraw address. Only callable by owner.

Parameters ​

NameTypeDescription
systemWithdrawAddress_addressnew value

setWithdrawFee ​

solidity
function setWithdrawFee(uint96 withdrawFee_) external

Sets new withdraw fee (in absolute amount). Only callable by owner.

Parameters ​

NameTypeDescription
withdrawFee_uint96new value

setMinWithdrawAmount ​

solidity
function setMinWithdrawAmount(uint96 minWithdrawAmount_) external

Sets new min withdraw amount. Only callable by owner.

Parameters ​

NameTypeDescription
minWithdrawAmount_uint96new value

setAuth ​

solidity
function setAuth(address auth_, bool allowed_) external

Sets an address as allowed auth or not. Only callable by owner.

Parameters ​

NameTypeDescription
auth_addressaddress to set auth value for
allowed_boolbool flag for whether address is allowed as auth or not

unpause ​

solidity
function unpause() external

unpauses the contract, re-enabling withdraw requests and processing. Only callable by owner.

AvoDepositManagerAuthsActions ​

processWithdraw ​

solidity
function processWithdraw(bytes32 withdrawId_) external

Authorizes and processes a withdraw request. Only callable by auths & owner.

Parameters ​

NameTypeDescription
withdrawId_bytes32unique withdraw request id as created in requestWithdraw()

pause ​

solidity
function pause() external

pauses the contract, temporarily blocking withdraw requests and processing. Only callable by auths & owner. Unpausing can only be triggered by owner.

systemWithdraw ​

solidity
function systemWithdraw() external

Withdraws balance of deposit token down to systemWithdrawLimit to the configured systemWithdrawAddress

AvoDepositManager ​

constructor ​

solidity
constructor(contract IAvoFactory avoFactory_, contract IAvoConfigV1 avoConfigV1_) public

initialize ​

solidity
function initialize(address owner_, address systemWithdrawAddress_, uint96 systemWithdrawLimit_, uint96 minWithdrawAmount_, uint96 withdrawFee_) public

initializes the contract for owner_ as owner, and various config values regarding withdrawals. Starts the contract in paused state.

Parameters ​

NameTypeDescription
owner_addressaddress of owner authorized to withdraw funds and set config values, auths etc.
systemWithdrawAddress_addressaddress to which funds can be system withdrawn to
systemWithdrawLimit_uint96minimum amount which must stay in contract and can not be system withdrawn
minWithdrawAmount_uint96static withdraw fee charged when a withdrawRequest is processed
withdrawFee_uint96minimum withdraw amount that a user must request to withdraw

isAuth ​

solidity
function isAuth(address auth_) external view returns (bool)

checks if a certain address auth_ is an allowed auth

depositOnBehalf ​

solidity
function depositOnBehalf(address receiver_, uint256 amount_) external

Deposits amount_ of deposit token to this contract and emits the Deposit event, with receiver_ address used for off-chain tracking

Parameters ​

NameTypeDescription
receiver_addressaddress receiving funds via indirect off-chain tracking
amount_uint256amount to deposit

removeWithdrawRequest ​

solidity
function removeWithdrawRequest(bytes32 withdrawId_) external

removes a withdraw request, essentially denying it or retracting it. Only callable by auths or withdraw request receiver.

Parameters ​

NameTypeDescription
withdrawId_bytes32unique withdraw request id as created in requestWithdraw()

requestWithdraw ​

solidity
function requestWithdraw(uint256 amount_) external returns (bytes32 uniqueId_)

Requests withdrawal of amount_ of gas balance. Only callable by Avocado smart wallets.

Parameters ​

NameTypeDescription
amount_uint256amount to withdraw

Return Values ​

NameTypeDescription
uniqueId_bytes32the unique withdraw request id used to trigger processing

requestSourceWithdraw ​

solidity
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 ​

NameTypeDescription
amount_uint256amount to withdraw

Return Values ​

NameTypeDescription
uniqueId_bytes32the unique withdraw request id used to trigger processing

requestReferralWithdraw ​

solidity
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 ​

NameTypeDescription
amount_uint256amount to withdraw

Return Values ​

NameTypeDescription
uniqueId_bytes32the unique withdraw request id used to trigger processing

renounceOwnership ​

solidity
function renounceOwnership() public view

override renounce ownership as it could leave the contract in an unwanted state if called by mistake.