Skip to main content

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​

NameTypeDescription
mintAmount_uint256The 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​

NameTypeDescription
chainId_uint256The 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​

NameTypeDescription
params_struct IOverlayerWrapDefs.ConstructorParamsA 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​

NameTypeDescription
user_addressThe address of the user to whitelist or remove
status_boolTrue 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​

NameTypeDescription
to_addressRecipient address
amount_uint256Amount 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​

NameTypeDescription
maxMintPerBlock_uint256The 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​

NameTypeDescription
amountCollateral_uint256The amount to supply of collateral
amountACollateral_uint256The 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​

NameTypeDescription
collateral_struct OverlayerWrapCoreTypes.StableCoinConfiguration for the main collateral token
aCollateral_struct OverlayerWrapCoreTypes.StableCoinConfiguration for the associated collateral token
admin_addressAddress of the contract administrator
maxMintPerBlock_uint256Maximum amount that can be minted per block
maxRedeemPerBlock_uint256Maximum amount that can be redeemed per block
hubChainId_uint256The 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​

NameTypeDescription
order_struct OverlayerWrapCoreTypes.OrderOrder 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​

NameTypeDescription
order_struct OverlayerWrapCoreTypes.OrderOrder details containing mint parameters

_managerRedeem​

function _managerRedeem(struct OverlayerWrapCoreTypes.Order order_) internal returns (uint256 amountToBurn, uint256 back)

Redeem stablecoins for assets

Parameters​

NameTypeDescription
order_struct OverlayerWrapCoreTypes.OrderStruct 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​

NameTypeDescription
amount_uint256The amount of OverlayerWrap to burn
wantCollateral_addressThe wanted collateral to withdraw

Return Values​

NameTypeDescription
checkedBurnAmountuint256The checked amount to burn
backuint256The 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​

NameTypeDescription
beneficiary_addressThe redeem beneficiary
asset_addressThe redeemed asset
amount_uint256The 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​

NameTypeDescription
amount_uint256The amount to be transfered
asset_addressThe asset to be transfered
recipient_addressThe destination address

_setMaxMintPerBlock​

function _setMaxMintPerBlock(uint256 maxMintPerBlock_) internal

Sets the max mintPerBlock limit

Parameters​

NameTypeDescription
maxMintPerBlock_uint256The 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​

NameTypeDescription
from_addressThe address to debit tokens from
amountLD_uint256The amount to send in local decimals
minAmountLD_uint256The minimum amount to send in local decimals
dstEid_uint32The destination endpoint ID

Return Values​

NameTypeDescription
amountSentLDuint256The amount sent in local decimals
amountReceivedLDuint256The 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​

NameTypeDescription
to_addressThe address to credit tokens to
amountLD_uint256The amount to credit in local decimals
srcEid_uint32The source endpoint ID

Return Values​

NameTypeDescription
amountReceivedLDuint256The amount received in local decimals

_setMaxRedeemPerBlock​

function _setMaxRedeemPerBlock(uint256 maxRedeemPerBlock_) internal

Sets the max redeemPerBlock limit

Parameters​

NameTypeDescription
maxRedeemPerBlock_uint256The new max value