Implements flow limit logic for interchain token transfers.
This contract implements low-level assembly for optimization purposes.
uint256 FLOW_LIMIT_SLOT
uint256 PREFIX_FLOW_OUT_AMOUNT
uint256 PREFIX_FLOW_IN_AMOUNT
function epochTime() internal view virtual returns (uint256)
Returns the epoch duration for which the flow limit is applied
Name | Type | Description |
---|---|---|
[0] | uint256 | The epoch time |
function flowLimit() public view returns (uint256 flowLimit_)
Returns the current flow limit.
Name | Type | Description |
---|---|---|
flowLimit_ | uint256 | The current flow limit value. |
function _setFlowLimit(uint256 flowLimit_, bytes32 tokenId) internal
Internal function to set the flow limit.
Name | Type | Description |
---|---|---|
flowLimit_ | uint256 | The value to set the flow limit to. |
tokenId | bytes32 | The id of the token to set the flow limit for. |
function _getFlowOutSlot(uint256 epoch) internal pure returns (uint256 slot)
Returns the slot which is used to get the flow out amount for a specific epoch.
Name | Type | Description |
---|---|---|
epoch | uint256 | The epoch to get the flow out amount for. |
Name | Type | Description |
---|---|---|
slot | uint256 | The slot to get the flow out amount from. |
function _getFlowInSlot(uint256 epoch) internal pure returns (uint256 slot)
Returns the slot which is used to get the flow in amount for a specific epoch.
Name | Type | Description |
---|---|---|
epoch | uint256 | The epoch to get the flow in amount for. |
Name | Type | Description |
---|---|---|
slot | uint256 | The slot to get the flow in amount from. |
function flowOutAmount() external view returns (uint256 flowOutAmount_)
Returns the current flow out amount.
Name | Type | Description |
---|---|---|
flowOutAmount_ | uint256 | The current flow out amount. |
function flowInAmount() external view returns (uint256 flowInAmount_)
Returns the current flow in amount.
Name | Type | Description |
---|---|---|
flowInAmount_ | uint256 | The current flow in amount. |
function _addFlow(uint256 flowSlot, uint256 reverseFlowSlot, uint256 flowAmount, uint256 flowLimit_) internal
Adds flow amount in the specified direction (in/out) for a token, and applies the flow limit.
_Reverts if:
uint256::MAX
Net flow (difference between in and out) exceeds the flow limit, i.e. | flow - reverse_flow | > flow_limit_ |
Name | Type | Description |
---|---|---|
flowSlot | uint256 | The storage slot for the current direction’s flow (in or out). |
reverseFlowSlot | uint256 | The storage slot for the opposite direction’s flow. |
flowAmount | uint256 | The amount of flow to add. |
flowLimit_ | uint256 | The allowed maximum net flow during the epoch. |
function _addFlowOut(uint256 flowOutAmount_) internal
Adds a flow out amount.
Name | Type | Description |
---|---|---|
flowOutAmount_ | uint256 | The flow out amount to add. |
function _addFlowIn(uint256 flowInAmount_) internal
Adds a flow in amount.
Name | Type | Description |
---|---|---|
flowInAmount_ | uint256 | The flow in amount to add. |