MezoAllocator
IMezoPortal
Interface for the Mezo's Portal contract connected to dispatcher.
DepositInfo
DepositInfo keeps track of the deposit balance and unlock time. Each deposit is tracked separately and associated with a specific token. Some tokens can be deposited but can not be locked - in that case the unlockAt is the block timestamp of when the deposit was created. The same is true for tokens that can be locked but the depositor decided not to lock them. Some deposits can mint a receipt tokens against them: receiptMinted is the amount of receipt tokens minted against a deposit, while feeOwed is the fee owed by the deposit to Portal, and the lastFeeIntegral is the last updated value of the fee integral.
deposit
Deposit and optionally lock tokens for the given period.
Lock period will be normalized to weeks. If non-zero, it must not be shorter than the minimum lock period and must not be longer than the maximum lock period.
Parameters
Name | Type | Description |
---|---|---|
token | address | token address to deposit |
amount | uint96 | amount of tokens to deposit |
lockPeriod | uint32 | lock period in seconds, 0 to not lock the deposit |
withdraw
Withdraws all deposited tokens.
Parameters
Name | Type | Description |
---|---|---|
token | address | deposited token address |
depositId | uint256 | id of the deposit |
withdrawPartially
Withdraws part of the deposited tokens.
Parameters
Name | Type | Description |
---|---|---|
token | address | deposited token address |
depositId | uint256 | id of the deposit |
amount | uint96 | the amount to be withdrawn |
depositCount
The number of deposits created. Includes the deposits that were fully withdrawn. This is also the identifier of the most recently created deposit.
getDeposit
Get the balance and unlock time of a given deposit.
Parameters
Name | Type | Description |
---|---|---|
depositor | address | depositor address |
token | address | token address to get the balance |
depositId | uint256 | id of the deposit |
MezoAllocator
MezoAllocator routes tBTC to/from MezoPortal.
mezoPortal
Address of the MezoPortal contract.
tbtc
tBTC token contract.
stbtc
stBTC token vault contract.
isMaintainer
Keeps track of the addresses that are allowed to trigger deposit allocations.
maintainers
List of maintainers.
depositId
keeps track of the latest deposit ID assigned in Mezo Portal.
depositBalance
Keeps track of the total amount of tBTC allocated to MezoPortal.
DepositAllocated
Emitted when tBTC is deposited to MezoPortal.
DepositWithdrawn
Emitted when tBTC is withdrawn from MezoPortal.
MaintainerAdded
Emitted when the maintainer address is updated.
MaintainerRemoved
Emitted when the maintainer address is updated.
DepositReleased
Emitted when tBTC is released from MezoPortal.
CallerNotMaintainer
Reverts if the caller is not a maintainer.
CallerNotStbtc
Reverts if the caller is not the stBTC contract.
MaintainerNotRegistered
Reverts if the maintainer is not registered.
MaintainerAlreadyRegistered
Reverts if the maintainer has been already registered.
onlyMaintainer
constructor
initialize
Initializes the MezoAllocator contract.
Parameters
Name | Type | Description |
---|---|---|
_mezoPortal | address | Address of the MezoPortal contract. |
_tbtc | address | Address of the tBTC token contract. |
_stbtc | address |
allocate
Allocate tBTC to MezoPortal. Each allocation creates a new "rolling" deposit meaning that the previous Acre's deposit is fully withdrawn before a new deposit with added amount is created. This mimics a "top up" functionality with the difference that a new deposit id is created and the previous deposit id is no longer in use.
This function can be invoked periodically by a maintainer.
withdraw
Withdraws tBTC from MezoPortal and transfers it to stBTC. This function can withdraw partial or a full amount of tBTC from MezoPortal for a given deposit id.
Parameters
Name | Type | Description |
---|---|---|
amount | uint256 | Amount of tBTC to withdraw. |
releaseDeposit
Releases deposit in full from MezoPortal.
This is a special function that can be used to migrate funds during allocator upgrade or in case of emergencies.
addMaintainer
Adds a new maintainer address.
Parameters
Name | Type | Description |
---|---|---|
maintainerToAdd | address | Address of the new maintainer. |
removeMaintainer
Removes the maintainer address.
Parameters
Name | Type | Description |
---|---|---|
maintainerToRemove | address | Address of the maintainer to remove. |
totalAssets
Returns the total amount of tBTC allocated to MezoPortal including the amount that is currently hold by this contract.
getMaintainers
Returns the list of maintainers.
Last updated