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 depositToken

address of the deposit token (USDC)

avoFactory

contract IAvoFactory avoFactory

address of the AvoFactory (proxy)

AvoDepositManagerStructs

WithdrawRequest

struct WithdrawRequest {
  address to;
  uint256 amount;
}

AvoDepositManagerVariables

systemWithdrawAddress

address systemWithdrawAddress

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

systemWithdrawLimit

uint96 systemWithdrawLimit

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

withdrawFee

uint96 withdrawFee

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

minWithdrawAmount

uint96 minWithdrawAmount

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

auths

mapping(address => uint256) auths

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

withdrawRequests

mapping(bytes32 => struct AvoDepositManagerStructs.WithdrawRequest) withdrawRequests

withdraw 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

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_) external

Sets new system withdraw limit. Only callable by owner.

Parameters

NameTypeDescription
systemWithdrawLimit_uint96new value

setSystemWithdrawAddress

function setSystemWithdrawAddress(address systemWithdrawAddress_) external

Sets new system withdraw address. Only callable by owner.

Parameters

NameTypeDescription
systemWithdrawAddress_addressnew value

setWithdrawFee

function setWithdrawFee(uint96 withdrawFee_) external

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

Parameters

NameTypeDescription
withdrawFee_uint96new value

setMinWithdrawAmount

function setMinWithdrawAmount(uint96 minWithdrawAmount_) external

Sets new min withdraw amount. Only callable by owner.

Parameters

NameTypeDescription
minWithdrawAmount_uint96new value

setAuth

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

function unpause() external

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

AvoDepositManagerAuthsActions

processWithdraw

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

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

function systemWithdraw() external

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

AvoDepositManager

constructor

constructor(contract IAvoFactory avoFactory_, contract IAvoConfigV1 avoConfigV1_) public

initialize

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

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_) 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

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

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

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

renounceOwnership

function renounceOwnership() public view

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