Reserve
The Reserve contract provides historical lookups of a token balance increase during a target time range. As the Reserve contract transfers OUT tokens, the withdrawal accumulator is increased. When tokens are transferred IN new checkpoint can be created if checkpoint()
is called after transferring tokens. By using the reserve and withdrawal accumulators to create a new checkpoint, any contract or account can look up the balance increase of the reserve for a target time range. By calculating the total held tokens in a specific time range, contracts that require knowledge of captured interest during a draw period, can easily call into the Reserve and deterministically determine the newly acquired tokens for that time range.
Write methods description
initialize()
Allows to initialize the contract during the deployment. Constructs Reserve with passed parameters.
Parameters:
Name | Type | Description |
---|---|---|
_owner | address | Address that will become the new owner of the contract. |
_token | address | ERC20 address that will be used in the reserve. |
checkpoint()
Create observation checkpoint in ring buffer. Calculates total deposited tokens since last checkpoint and creates a new accumulator checkpoint.
withdrawTo()
Transfer Reserve token balance to recipient address. Creates checkpoint before token transfer. Increments withdrawAccumulator
with amount.
Parameters:
Name | Type | Description |
---|---|---|
_recipient | address | Account address. |
_amount | uint256 | Transfer amount. |
claimOwnership()
Allows the pendingOwner
address to claim the owner role. This function is only callable by the pendingOwner
.
renounceOwnership()
Leaves the contract without owner. It will not be possible to call the owner's functions anymore. Can only be called by the current owner. The method does not take any parameters. Renouncing ownership will leave the contract without an owner, thereby removing any functionality that is only available to the owner.
transferOwnership()
Transfers ownership of the contract to a _pendingOwner
. Can only be called by the current owner.
Parameters:
Name | Type | Description |
---|---|---|
_newOwner | address | An account that will become the |
setManager()
Allows the owner to give the manager role to an address. The manager role has access to the functions with the modified onlyManager
or onlyManagerOrOwner
.
Parameters:
Name | Type | Description |
---|---|---|
_newManager | address | An account that will become the new manager. |
Read methods description
getReserveAccumulatedBetween()
Calculate token accumulation between timestamp range. Search the ring buffer for two checkpoint observations and diffs accumulator amount.
Parameters:
Name | Type | Description |
---|---|---|
_startTimestamp | uint32 | Start timestamp. |
_endTimestamp | uint32 | End timestamp. |
Return:
Name | Type | Description |
---|---|---|
_amount | uint224 | Accumulated between input timestamps. |
getToken()
Read global token value. It is the token that the reserve will accept.
withdrawAccumulator()
Total withdrawal amount from reserve.
owner()
An account that is the owner of the contract. It has access to the functions that use the modified onlyOwner
.
pendingOwner()
Address that can claim the owner role. It is used to transfer the owner.
manager()
Manager role that can be granted exclusive access to specific functions with the modifier onlyManager
or onlyManagerOrOwner
.
Last updated