VaultBridgeTokenPart2

Git Source

Inherits: VaultBridgeToken

Author: See https://github.com/agglayer/vault-bridge

This contract exists because of the contract size limit of the EVM.

State Variables

_VAULT_BRIDGE_TOKEN_STORAGE

The storage slot at which Vault Bridge Token storage starts, following the EIP-7201 standard.

Calculated as keccak256(abi.encode(uint256(keccak256("agglayer.vault-bridge.VaultBridgeToken.storage")) - 1)) & ~bytes32(uint256(0xff)).

bytes32 private constant _VAULT_BRIDGE_TOKEN_STORAGE =
    hex"f082fbc4cfb4d172ba00d34227e208a31ceb0982bc189440d519185302e44700";

Functions

fallback

fallback() external;

constructor

constructor();

__getVaultBridgeTokenStorage

Returns a pointer to the ERC-7201 storage namespace.

function __getVaultBridgeTokenStorage() private pure returns (VaultBridgeTokenStorage storage $);

rebalanceReserve

Rebalances the internal reserve by withdrawing the underlying token from, or depositing the underlying token into, the yield vault.

Delegates the call to VaultBridgeTokenPart2.

function rebalanceReserve() external override whenNotPaused onlyRole(REBALANCER_ROLE) nonReentrant;

collectYield

Transfers yield produced by the yield vault to the yield recipient in the form of vbToken.

Increases the net collected yield.

function collectYield() external override onlyRole(YIELD_COLLECTOR_ROLE) nonReentrant;

_collectYield

Transfers yield produced by the yield vault to the yield recipient in the form of vbToken.

Does not rebalance the reserve after collecting yield to allow usage while the contract is paused.

function _collectYield(bool force) internal;

Parameters

NameTypeDescription
forceboolWhether to revert if no yield can be collected.

burn

Burns a specific amount of vbToken.

Decreases the net collected yield.

function burn(uint256 shares) external override onlyYieldRecipient nonReentrant;

donateAsYield

Adds a specific amount of the underlying token to the reserve by transferring it from the sender.

Delegates the call to VaultBridgeTokenPart2.

function donateAsYield(uint256 assets) external override nonReentrant;

completeMigration

Completes a migration of backing from a Layer Y to Layer X by minting and locking the required amount of vbToken in LxLy Bridge.

Backing for Custom Token minted by Native Converter on Layer Ys can be migrated to Layer X.

function completeMigration(uint32 originNetwork, uint256 shares, uint256 assets)
    external
    override
    whenNotPaused
    onlyMigrationManager
    nonReentrant;

Parameters

NameTypeDescription
originNetworkuint32The LxLy ID of Layer Y the backing is being migrated from.
sharesuint256The amount of vbToken required to mint and lock up in LxLy Bridge. Assets from a dedicated migration fees fund may be used to offset any fees incurred on Layer Y during the process. If a migration cannot be completed due to insufficient assets, anyone can donate the underlying token to the migration fees fund. Please refer to donateForCompletingMigration for more information.
assetsuint256The amount of the underlying token migrated from Layer Y (after any fees on Layer Y).

donateForCompletingMigration

Adds a specific amount of the underlying token to a dedicated fund for covering any fees on Layer Y during a migration of backing to Layer X by transferring it from the sender. Please refer to completeMigration for more information.

Delegates the call to VaultBridgeTokenPart2.

function donateForCompletingMigration(uint256 assets) external override whenNotPaused nonReentrant;

setYieldRecipient

Sets the yield recipient.

Delegates the call to VaultBridgeTokenPart2.

function setYieldRecipient(address yieldRecipient_)
    external
    override
    whenNotPaused
    onlyRole(DEFAULT_ADMIN_ROLE)
    nonReentrant;

setMinimumReservePercentage

Sets the minimum reserve percentage.

Delegates the call to VaultBridgeTokenPart2.

function setMinimumReservePercentage(uint256 minimumReservePercentage_)
    external
    override
    onlyRole(DEFAULT_ADMIN_ROLE)
    nonReentrant;

Parameters

NameTypeDescription
minimumReservePercentage_uint2561e18 is 100%.

drainYieldVault

Drains the yield vault by redeeming yield vault shares. Assets will be put into the internal reserve.

This function can be called by the owner only.

function drainYieldVault(uint256 shares, bool exact) external override onlyRole(DEFAULT_ADMIN_ROLE) nonReentrant;

Parameters

NameTypeDescription
sharesuint256The amount of the yield vault shares to redeem.
exactboolWhether to revert if the exact amount of shares could not be redeemed.

setYieldVault

Sets the yield vault.

Delegates the call to VaultBridgeTokenPart2.

function setYieldVault(address yieldVault_) external override onlyRole(DEFAULT_ADMIN_ROLE) nonReentrant;

setMinimumYieldVaultDeposit

The minimum amount of the underlying token that triggers a yield vault deposit.

Delegates the call to VaultBridgeTokenPart2.

function setMinimumYieldVaultDeposit(uint256 minimumYieldVaultDeposit_)
    external
    override
    onlyRole(DEFAULT_ADMIN_ROLE)
    nonReentrant;

Parameters

NameTypeDescription
minimumYieldVaultDeposit_uint256Set to 0 to disable.

setYieldVaultMaximumSlippagePercentage

The maximum slippage percentage when depositing into or withdrawing from the yield vault.

Delegates the call to VaultBridgeTokenPart2.

function setYieldVaultMaximumSlippagePercentage(uint256 maximumSlippagePercentage)
    external
    override
    onlyRole(DEFAULT_ADMIN_ROLE)
    nonReentrant;

Parameters

NameTypeDescription
maximumSlippagePercentageuint2561e18 is 100%. The recommended value is 0.01e18 (1%).

pause

Prevents usage of functions with the whenNotPaused modifier.

Delegates the call to VaultBridgeTokenPart2.

function pause() external override onlyRole(PAUSER_ROLE) nonReentrant;

unpause

Allows usage of functions with the whenNotPaused modifier.

Delegates the call to VaultBridgeTokenPart2.

function unpause() external override onlyRole(DEFAULT_ADMIN_ROLE) nonReentrant;