OverlayerWrapCore
This contract mints and redeems the OverlayerWrap contract that inherits this contract
mintedPerBlock
mapping(uint256 => uint256) mintedPerBlock
OverlayerWrap minted per block
redeemedPerBlock
mapping(uint256 => uint256) redeemedPerBlock
OverlayerWrap redeemed per block
maxRedeemWhitelist
mapping(address => bool) maxRedeemWhitelist
Whitelist users from max redeem / block
maxMintPerBlock
uint256 maxMintPerBlock
Max minted OverlayerWrap allowed per block
maxRedeemPerBlock
uint256 maxRedeemPerBlock
@notice Max redeemed OverlayerWrap allowed per block
minValmaxRedeemPerBlock
uint256 minValmaxRedeemPerBlock
@notice Max redeemed OverlayerWrap allowed per block minimum value
proposedRedeemChangeTime
uint256 proposedRedeemChangeTime
Timestamp at which a change was proposed
proposedMaxRedeemPerBlock
uint256 proposedMaxRedeemPerBlock
Value proposed for maxRedeemPerBlock
hubChainId
uint256 hubChainId
Hub chain id
totalBridgedOut
uint256 totalBridgedOut
Cumulative amount of tokens debited via OFT cross-chain transfers (not yet credited back)
belowMaxMintPerBlock
modifier belowMaxMintPerBlock(uint256 mintAmount_)
Ensure that the already minted OverlayerWrap in the actual block plus the amount to be minted is below the maxMintPerBlock
Parameters
| Name | Type | Description |
|---|---|---|
| mintAmount_ | uint256 | The OverlayerWrap amount to be minted |
onlyHubChain
modifier onlyHubChain(uint256 chainId_)
Restricts the execution of a function to only be callable by the hubChain address.
Parameters
| Name | Type | Description |
|---|---|---|
| chainId_ | uint256 | The current chain id |
constructor
constructor(struct IOverlayerWrapDefs.ConstructorParams params_) internal
Initializes the OverlayerWrapCore contract with the provided parameters
Sets up the OFT, ERC20Permit, and Ownable functionality
Parameters
| Name | Type | Description |
|---|---|---|
| params_ | struct IOverlayerWrapDefs.ConstructorParams | A struct containing initialization parameters. |
owner
function owner() public view returns (address)
We resolve the multiple inheritance of {Ownable} and {SingleAdminAccessControl}
by returning the owner defined in {SingleAdminAccessControl}.
receive
receive() external payable
Fallback function to receive ether
whitelistMaxRedeemPerBlockUser
function whitelistMaxRedeemPerBlockUser(address user_, bool status_) external
Whitelist or remove a user from the maxRedeemPerBlock exemption list
Only callable by an account with the DEFAULT_ADMIN_ROLE
Parameters
| Name | Type | Description |
|---|---|---|
| user_ | address | The address of the user to whitelist or remove |
| status_ | bool | True to whitelist the user (exempt from maxRedeemPerBlock), false to remove |
rescueNative
function rescueNative(address to_, uint256 amount_) external
Rescue native tokens (ETH) accidentally sent to this contract
Parameters
| Name | Type | Description |
|---|---|---|
| to_ | address | Recipient address |
| amount_ | uint256 | Amount of native token to transfer |
approveCollateral
function approveCollateral() external
Approve an external spender.
The spender is handled by the CollateralSpenderManager contract Normally this function is not used as the approval is managed by the acceptance flow
setMaxMintPerBlock
function setMaxMintPerBlock(uint256 maxMintPerBlock_) external
Sets the max mintPerBlock limit
Parameters
| Name | Type | Description |
|---|---|---|
| maxMintPerBlock_ | uint256 | The new max value |
proposeMaxRedeemPerBlock
function proposeMaxRedeemPerBlock(uint256 newMaxRedeemPerBlock_) external
Propose a new maxRedeemPerBlock, starts the 15-day delay
executeMaxRedeemPerBlockChange
function executeMaxRedeemPerBlockChange() external
Execute the previously proposed change after REDEEM_CHANGE_DELAY days
cancelProposedMaxRedeemPerBlock
function cancelProposedMaxRedeemPerBlock() external
Cancel a pending maxRedeemPerBlock proposal
disableMint
function disableMint() external
Disables minting by setting maxMintPerBlock to zero
pause
function pause() external
Pause the contract
This call is used only to lock the supplyToBacking public call
unpause
function unpause() external
Unpause the contract
supplyToBacking
function supplyToBacking(uint256 amountCollateral_, uint256 amountACollateral_) external
Supply funds to the active backing contract (aka approvedCollateralSpender)
The approveCollateralSpender will collect the funds, as the only entity allowed to do so
Parameters
| Name | Type | Description |
|---|---|---|
| amountCollateral_ | uint256 | The amount to supply of collateral |
| amountACollateral_ | uint256 | The amount to supply of aCollateral |
_initialize
function _initialize(struct OverlayerWrapCoreTypes.StableCoin collateral_, struct OverlayerWrapCoreTypes.StableCoin aCollateral_, address admin_, uint256 maxMintPerBlock_, uint256 maxRedeemPerBlock_, uint256 hubChainId_) internal
Initialize the contract with base parameters
Parameters
| Name | Type | Description |
|---|---|---|
| collateral_ | struct OverlayerWrapCoreTypes.StableCoin | Configuration for the main collateral token |
| aCollateral_ | struct OverlayerWrapCoreTypes.StableCoin | Configuration for the associated collateral token |
| admin_ | address | Address of the contract administrator |
| maxMintPerBlock_ | uint256 | Maximum amount that can be minted per block |
| maxRedeemPerBlock_ | uint256 | Maximum amount that can be redeemed per block |
| hubChainId_ | uint256 | The parent chain id |
_validateInputTokens
function _validateInputTokens(struct OverlayerWrapCoreTypes.Order order_) internal view
Validate the collateral tokens in an order
Reverts if the collateral token is not valid Reverts if the collateral amount is not valid Given the precision of the collateral and the overlayer wrap, the collateral amount must be scaled to the overlayer wrap amount
Parameters
| Name | Type | Description |
|---|---|---|
| order_ | struct OverlayerWrapCoreTypes.Order | Order parameters to validate |
_managerMint
function _managerMint(struct OverlayerWrapCoreTypes.Order order_) internal
Internal function to handle minting operations
Updates minted amount per block and transfers collateral
Parameters
| Name | Type | Description |
|---|---|---|
| order_ | struct OverlayerWrapCoreTypes.Order | Order details containing mint parameters |
_managerRedeem
function _managerRedeem(struct OverlayerWrapCoreTypes.Order order_) internal returns (uint256 amountToBurn, uint256 back)
Redeem stablecoins for assets
Parameters
| Name | Type | Description |
|---|---|---|
| order_ | struct OverlayerWrapCoreTypes.Order | Struct containing order details |
_pow10
function _pow10(uint256 n) internal pure returns (uint256 r)
_withdrawFromProtocol
function _withdrawFromProtocol(uint256 amount_, address wantCollateral_) internal returns (uint256 checkedBurnAmount, uint256 back)
Redeem collateral from the protocol
It will trigger the backing contract (aka approvedCollateralSpender) withdraw method if the collateral is not sufficient Dust amount will be ignored. Burn amount is rounded to the collateral decimals value
Parameters
| Name | Type | Description |
|---|---|---|
| amount_ | uint256 | The amount of OverlayerWrap to burn |
| wantCollateral_ | address | The wanted collateral to withdraw |
Return Values
| Name | Type | Description |
|---|---|---|
| checkedBurnAmount | uint256 | The checked amount to burn |
| back | uint256 | The amount of the underlying or their aToken version returned to user |
_transferToBeneficiary
function _transferToBeneficiary(address beneficiary_, address asset_, uint256 amount_) internal
Transfer supported asset to beneficiary address
This contract needs to have available funds Asset validation has to be performed by the caller
Parameters
| Name | Type | Description |
|---|---|---|
| beneficiary_ | address | The redeem beneficiary |
| asset_ | address | The redeemed asset |
| amount_ | uint256 | The redeemed amount |
_transferCollateral
function _transferCollateral(uint256 amount_, address asset_, address recipient_) internal
Transfer supported asset to target addresses
User must have approved this contract for allowance Asset validation has to be performed by the caller
Parameters
| Name | Type | Description |
|---|---|---|
| amount_ | uint256 | The amount to be transfered |
| asset_ | address | The asset to be transfered |
| recipient_ | address | The destination address |
_setMaxMintPerBlock
function _setMaxMintPerBlock(uint256 maxMintPerBlock_) internal
Sets the max mintPerBlock limit
Parameters
| Name | Type | Description |
|---|---|---|
| maxMintPerBlock_ | uint256 | The new max value |
_debit
function _debit(address from_, uint256 amountLD_, uint256 minAmountLD_, uint32 dstEid_) internal virtual returns (uint256 amountSentLD, uint256 amountReceivedLD)
Tracks tokens leaving the hub chain so AaveHandler accounting remains correct
OFT burns on the source chain during sends. On the hub only, increments totalBridgedOut so totalSupply() + totalBridgedOut reflects effective supply for backing. Satellite debits do not update this counter.
Parameters
| Name | Type | Description |
|---|---|---|
| from_ | address | The address to debit tokens from |
| amountLD_ | uint256 | The amount to send in local decimals |
| minAmountLD_ | uint256 | The minimum amount to send in local decimals |
| dstEid_ | uint32 | The destination endpoint ID |
Return Values
| Name | Type | Description |
|---|---|---|
| amountSentLD | uint256 | The amount sent in local decimals |
| amountReceivedLD | uint256 | The amount received in local decimals on the destination |
_credit
function _credit(address to_, uint256 amountLD_, uint32 srcEid_) internal virtual returns (uint256 amountReceivedLD)
Tracks tokens returning to the hub chain from cross-chain transfers
On the hub only, decrements totalBridgedOut so totalSupply() + totalBridgedOut matches collateral accounting (AaveHandler). On satellite chains, totalBridgedOut is unused.
Parameters
| Name | Type | Description |
|---|---|---|
| to_ | address | The address to credit tokens to |
| amountLD_ | uint256 | The amount to credit in local decimals |
| srcEid_ | uint32 | The source endpoint ID |
Return Values
| Name | Type | Description |
|---|---|---|
| amountReceivedLD | uint256 | The amount received in local decimals |
_setMaxRedeemPerBlock
function _setMaxRedeemPerBlock(uint256 maxRedeemPerBlock_) internal
Sets the max redeemPerBlock limit
Parameters
| Name | Type | Description |
|---|---|---|
| maxRedeemPerBlock_ | uint256 | The new max value |