VaultBridgeToken

Git Source

Inherits: Initializable, AccessControlUpgradeable, PausableUpgradeable, ReentrancyGuardTransientUpgradeable, IERC4626, ERC20PermitUpgradeable, ERC20PermitUser, Versioned

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

A vbToken is an ERC-20 token, ERC-4626 vault, and LxLy Bridge extension, enabling deposits and bridging of select assets, such as WBTC, WETH, USDT, USDC, and USDS, while putting the assets to work to produce yield.

A base contract used to create vbTokens.

@note IMPORTANT: In order to not drive the complexity of the Vault Bridge protocol up, vbToken MUST NOT have transfer, deposit, or withdrawal fees. The underlying token on Layer X MUST NOT have a transfer fee; this contract will revert if it detects a transfer fee. The underlying token and Custom Token on Layer Ys MAY have transfer fees. The yield vault SHOULD NOT have deposit and/or withdrawal fees; however, it is expected that produced yield will offset any costs incurred when depositing to and withdrawing from the yield vault for the purpose of producing yield or rebalancing the internal reserve. The price of the yield vault's shares MUST NOT decrease (e.g., no bad debt realization); still, this contract implements solvency checks for protection with a configurable slippage parameter. Additionally, the underlying token MUST NOT be a rebasing token, and MUST NOT have transfer hooks (i.e., does not enable reentrancy/crossentrancy).

State Variables

REBALANCER_ROLE

bytes32 public constant REBALANCER_ROLE = keccak256("REBALANCER_ROLE");

YIELD_COLLECTOR_ROLE

bytes32 public constant YIELD_COLLECTOR_ROLE = keccak256("YIELD_COLLECTOR_ROLE");

PAUSER_ROLE

bytes32 public constant PAUSER_ROLE = keccak256("PAUSER_ROLE");

_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

onlyYieldRecipient

Checks if the sender is the yield recipient.

modifier onlyYieldRecipient();

onlyLxLyBridge

Checks if the sender is LxLy Bridge.

modifier onlyLxLyBridge();

onlyMigrationManager

Checks if the sender is Migration Manager.

modifier onlyMigrationManager();

onlySelf

Checks if the sender is the vbToken itself.

modifier onlySelf();

delegatedToPart2

Delegates the call to VaultBridgeTokenPart2.

modifier delegatedToPart2();

__VaultBridgeToken_init

function __VaultBridgeToken_init(address initializer_, InitializationParameters calldata initParams)
    internal
    onlyInitializing;

Parameters

NameTypeDescription
initializer_addressThe address of VaultBridgeTokenInitializer.
initParamsInitializationParametersPlease refer to InitializationParameters for more information.

underlyingToken

The underlying token that backs vbToken.

function underlyingToken() public view returns (IERC20);

decimals

The number of decimals of vbToken.

The number of decimals is the same as that of the underlying token, or 18 if the underlying token reverted on decimals.

function decimals() public view override(ERC20Upgradeable, IERC20Metadata) returns (uint8);

minimumReservePercentage

vbTokens can maintain an internal reserve of the underlying token for serving withdrawals from first (as opposed to staking all assets).

The owner can rebalance the reserve by calling rebalanceReserve when it is below or above the minimumReservePercentage. The reserve may also be rebalanced automatically on deposits and withdrawals.

function minimumReservePercentage() public view returns (uint256);

Returns

NameTypeDescription
<none>uint2561e18 is 100%.

reservedAssets

vbTokens can maintain an internal reserve of the underlying token for serving withdrawals from first (as opposed to staking all assets).

How much of the underlying token is in the internal reserve.

function reservedAssets() public view returns (uint256);

yieldVault

An external, ERC-4246 compliant vault into which the underlying token is deposited to produce yield.

function yieldVault() public view returns (IERC4626);

yieldRecipient

The address that receives yield produced by the yield vault.

The yield collector collects yield, while the yield recipient receives it.

function yieldRecipient() public view returns (address);

lxlyId

The LxLy ID of this network.

function lxlyId() public view returns (uint32);

lxlyBridge

LxLy Bridge, which connects AggLayer networks.

function lxlyBridge() public view returns (ILxLyBridge);

migrationFeesFund

A dedicated fund for covering any fees on Layer Y during a migration of backing to Layer X. Please refer to completeMigration for more information.

function migrationFeesFund() public view returns (uint256);

minimumYieldVaultDeposit

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

Amounts below this value will be reserved regardless of the reserve percentage, in order to save gas for users.

The limit does not apply when rebalancing the reserve.

function minimumYieldVaultDeposit() public view returns (uint256);

migrationManager

The address of Migration Manager. Please refer to MigrationManager.sol for more information.

function migrationManager() public view returns (address);

yieldVaultMaximumSlippagePercentage

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

function yieldVaultMaximumSlippagePercentage() public view returns (uint256);

Returns

NameTypeDescription
<none>uint2561e18 is 100%.

_getVaultBridgeTokenStorage

Returns a pointer to the ERC-7201 storage namespace.

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

asset

The underlying token that backs vbToken.

function asset() public view returns (address assetTokenAddress);

totalAssets

The total backing of vbToken in the underlying token in real-time.

function totalAssets() public view returns (uint256 totalManagedAssets);

convertToShares

Tells how much a specific amount of underlying token is worth in vbToken.

The underlying token backs vbToken 1:1.

function convertToShares(uint256 assets) public pure returns (uint256 shares);

convertToAssets

Tells how much a specific amount of vbToken is worth in the underlying token.

vbToken is backed by the underlying token 1:1.

function convertToAssets(uint256 shares) public pure returns (uint256 assets);

maxDeposit

How much underlying token can deposited for a specific user right now. (Depositing the underlying token mints vbToken).

function maxDeposit(address) external view returns (uint256 maxAssets);

previewDeposit

How much vbToken would be minted if a specific amount of the underlying token were deposited right now.

function previewDeposit(uint256 assets) external view whenNotPaused returns (uint256 shares);

deposit

Deposit a specific amount of the underlying token and mint vbToken.

function deposit(uint256 assets, address receiver) external whenNotPaused nonReentrant returns (uint256 shares);

depositAndBridge

Deposit a specific amount of the underlying token, and bridge minted vbToken to another network.

The receiver in the ERC-4626 Deposit event will be this contract.

function depositAndBridge(uint256 assets, address receiver, uint32 destinationNetworkId, bool forceUpdateGlobalExitRoot)
    external
    whenNotPaused
    nonReentrant
    returns (uint256 shares);

_deposit

Locks the underlying token, mints vbToken, and optionally bridges it to another network.

If bridging to another network, the receiver in the ERC-4626 Deposit event will be this contract.

function _deposit(
    uint256 assets,
    uint32 destinationNetworkId,
    address receiver,
    bool forceUpdateGlobalExitRoot,
    uint256 maxShares
) internal returns (uint256 shares, uint256 spentAssets);

Parameters

NameTypeDescription
assetsuint256
destinationNetworkIduint32
receiveraddress
forceUpdateGlobalExitRootbool
maxSharesuint256Caps the amount of vbToken that is minted. Unused underlying token will be refunded to the sender. Set to 0 to disable.

_depositUsingCustomReceivingFunction

Locks the underlying token, mints vbToken, and optionally bridges it to another network.

If bridging to another network, the receiver in the ERC-4626 Deposit event will be this contract.

function _depositUsingCustomReceivingFunction(
    function(address, uint256) internal receiveUnderlyingToken,
    uint256 assets,
    uint32 destinationNetworkId,
    address receiver,
    bool forceUpdateGlobalExitRoot,
    uint256 maxShares
) internal returns (uint256 shares, uint256 spentAssets);

Parameters

NameTypeDescription
receiveUnderlyingTokenfunction (address, uint256) internalA custom function to use for receiving the underlying token from the sender. @note CAUTION! This function MUST NOT introduce reentrancy/crossentrancy vulnerabilities. @note IMPORTANT: The function MUST detect and revert if there was a transfer fee.
assetsuint256
destinationNetworkIduint32
receiveraddress
forceUpdateGlobalExitRootbool
maxSharesuint256Caps the amount of vbToken that is minted. Unused underlying token will be refunded to the sender. Set to 0 to disable.

depositWithPermit

Deposit a specific amount of the underlying token and mint vbToken.

Uses EIP-2612 permit to transfer the underlying token from the sender to self.

function depositWithPermit(uint256 assets, address receiver, bytes calldata permitData)
    external
    whenNotPaused
    nonReentrant
    returns (uint256 shares);

depositWithPermitAndBridge

Deposit a specific amount of the underlying token, and bridge minted vbToken to another network.

Uses EIP-2612 permit to transfer the underlying token from the sender to self.

The receiver in the ERC-4626 Deposit event will be this contract.

function depositWithPermitAndBridge(
    uint256 assets,
    address receiver,
    uint32 destinationNetworkId,
    bool forceUpdateGlobalExitRoot,
    bytes calldata permitData
) external whenNotPaused nonReentrant returns (uint256 shares);

_depositWithPermit

Locks the underlying token, mints vbToken, and optionally bridges it to another network.

Uses EIP-2612 permit to transfer the underlying token from the sender to self.

function _depositWithPermit(
    uint256 assets,
    bytes calldata permitData,
    uint32 destinationNetworkId,
    address receiver,
    bool forceUpdateGlobalExitRoot,
    uint256 maxShares
) internal returns (uint256 shares, uint256 spentAssets);

Parameters

NameTypeDescription
assetsuint256
permitDatabytes
destinationNetworkIduint32
receiveraddress
forceUpdateGlobalExitRootbool
maxSharesuint256Caps the amount of vbToken that is minted. Unused underlying token will be refunded to the sender. Set to 0 to disable.

maxMint

How much vbToken can be minted to a specific user right now. (Minting vbToken locks the underlying token).

function maxMint(address) external view returns (uint256 maxShares);

previewMint

How much underlying token would be required to mint a specific amount of vbToken right now.

function previewMint(uint256 shares) external view whenNotPaused returns (uint256 assets);

mint

Mint a specific amount of vbToken by locking the required amount of the underlying token.

function mint(uint256 shares, address receiver) external whenNotPaused nonReentrant returns (uint256 assets);

maxWithdraw

How much underlying token can be withdrawn from a specific user right now. (Withdrawing the underlying token burns vbToken).

function maxWithdraw(address owner) external view returns (uint256 maxAssets);

previewWithdraw

How much vbToken would be burned if a specific amount of the underlying token were withdrawn right now.

function previewWithdraw(uint256 assets) external view whenNotPaused returns (uint256 shares);

_simulateWithdraw

Calculates the amount of the underlying token that could be withdrawn right now.

This function is used for estimation purposes only.

@note IMPORTANT: reservedAssets must be up-to-date before using this function!

function _simulateWithdraw(uint256 assets, bool force) internal view returns (uint256 withdrawnAssets);

Parameters

NameTypeDescription
assetsuint256The maximum amount of the underlying token to simulate a withdrawal for.
forceboolWhether to revert if the all of the assets would not be withdrawn.

withdraw

Withdraw a specific amount of the underlying token by burning the required amount of vbToken.

function withdraw(uint256 assets, address receiver, address owner)
    external
    whenNotPaused
    nonReentrant
    returns (uint256 shares);

_withdraw

Withdraw a specific amount of the underlying token by burning the required amount of vbToken.

function _withdraw(uint256 assets, address receiver, address owner) internal returns (uint256 shares);

maxRedeem

How much vbToken can be redeemed for a specific user. (Redeeming vbToken burns it and unlocks the underlying token).

function maxRedeem(address owner) external view returns (uint256 maxShares);

previewRedeem

How much underlying token would be unlocked if a specific amount of vbToken were redeemed and burned right now.

function previewRedeem(uint256 shares) external view whenNotPaused returns (uint256 assets);

redeem

Burn a specific amount of vbToken and unlock the respective amount of the underlying token.

function redeem(uint256 shares, address receiver, address owner)
    external
    whenNotPaused
    nonReentrant
    returns (uint256 assets);

claimAndRedeem

Claim vbToken from LxLy Bridge and redeem it.

function claimAndRedeem(
    bytes32[32] calldata smtProofLocalExitRoot,
    bytes32[32] calldata smtProofRollupExitRoot,
    uint256 globalIndex,
    bytes32 mainnetExitRoot,
    bytes32 rollupExitRoot,
    address destinationAddress,
    uint256 amount,
    address receiver,
    bytes calldata metadata
) external whenNotPaused nonReentrant returns (uint256 assets);

transfer

Pausable ERC-20 transfer function.

function transfer(address to, uint256 value) public override(ERC20Upgradeable, IERC20) whenNotPaused returns (bool);

transferFrom

Pausable ERC-20 transferFrom function.

function transferFrom(address from, address to, uint256 value)
    public
    override(ERC20Upgradeable, IERC20)
    whenNotPaused
    returns (bool);

approve

Pausable ERC-20 approve function.

function approve(address spender, uint256 value)
    public
    override(ERC20Upgradeable, IERC20)
    whenNotPaused
    returns (bool);

permit

Pausable ERC-20 Permit permit function.

function permit(address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s)
    public
    override
    whenNotPaused;

stakedAssets

The amount of the underlying token in the yield vault, as reported by the yield vault in real-time.

function stakedAssets() public view returns (uint256);

reservePercentage

The reserve percentage in real-time.

The reserve is based on the total supply of vbToken, and does not account for uncompleted migrations of backing from Layer Ys to Layer X. Please refer to completeMigration for more information.

function reservePercentage() public view returns (uint256);

yield

The amount of yield available for collection.

function yield() public view returns (uint256);

backingDifference

The difference between the total assets and the minimum assets required to back the total supply of vbToken in real-time.

function backingDifference() public view returns (bool positive, uint256 difference);

rebalanceReserve

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

This function can be called by a rebalancer only.

Delegates the call to VaultBridgeTokenPart2.

@note (ATTENTION) The virtual modifier allows VaultBridgeTokenPart2 to override this function. Do not override the function yourself.

function rebalanceReserve() external virtual delegatedToPart2;

_rebalanceReserve

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

function _rebalanceReserve(bool force, bool allowRebalanceDown) internal;

Parameters

NameTypeDescription
forceboolWhether to revert if the reserve cannot be rebalanced.
allowRebalanceDownboolWhether to allow the reserve to be rebalanced down (by depositing into the yield vault).

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.

This function can be called by a yield collector only.

Increases the net collected yield.

Delegates the call to VaultBridgeTokenPart2.

@note (ATTENTION) The virtual modifier allows VaultBridgeTokenPart2 to override this function. Do not override the function yourself.

function collectYield() external virtual delegatedToPart2;

burn

Burns a specific amount of vbToken.

This function can be used if the yield recipient has collected an unrealistic amount of yield over time.

This function can be called by the yield recipient only.

Decreases the net collected yield.

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

Delegates the call to VaultBridgeTokenPart2.

@note (ATTENTION) The virtual modifier allows VaultBridgeTokenPart2 to override this function. Do not override the function yourself.

function burn(uint256 shares) external virtual delegatedToPart2;

donateAsYield

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

This function can be used to restore backing difference by donating the underlying token.

This function can be called by anyone.

Delegates the call to VaultBridgeTokenPart2.

@note (ATTENTION) The virtual modifier allows VaultBridgeTokenPart2 to override this function. Do not override the function yourself.

function donateAsYield(uint256 assets) external virtual delegatedToPart2;

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.

@note (ATTENTION) The virtual modifier allows VaultBridgeTokenPart2 to override this function. Do not override the function yourself.

function donateForCompletingMigration(uint256 assets) external virtual delegatedToPart2;

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.

Anyone can trigger the execution of this function by claiming the asset and message on LxLy Bridge. Please refer to NativeConverter.sol for more information.

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

When Native Converter migrates backing, it calls both bridgeAsset and bridgeMessage on LxLy Bridge to migrateBackingToLayerX.

The asset must be claimed before the message on LxLy Bridge.

The message tells vbToken how much Custom Token must be backed by vbToken, which is minted and bridged to address zero on the respective Layer Y. This action provides liquidity when bridging Custom Token to from Layer Ys to Layer X and increments the pessimistic proof.

This function can be called by Migraton Manager only.

Delegates the call to VaultBridgeTokenPart2.

@note (ATTENTION) The virtual modifier allows VaultBridgeTokenPart2 to override this function. Do not override the function yourself.

function completeMigration(uint32 originNetwork, uint256 shares, uint256 assets) external virtual delegatedToPart2;

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).

drainYieldVault

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

This function may utilize availabe yield to ensure successful draining if there is larger slippage. Consider collecting yield before calling this function to disable this behavior.

This function can be called by the owner only.

Delegates the call to VaultBridgeTokenPart2.

@note (ATTENTION) The virtual modifier allows VaultBridgeTokenPart2 to override this function. Do not override the function yourself.

function drainYieldVault(uint256 shares, bool exact) external virtual delegatedToPart2;

Parameters

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

setMinimumReservePercentage

Sets the minimum reserve percentage.

@note (ATTENTION) Automatic reserve rebalancing will be disabled for values greater than 1e18 (100%).

This function can be called by the owner only.

Delegates the call to VaultBridgeTokenPart2.

@note (ATTENTION) The virtual modifier allows VaultBridgeTokenPart2 to override this function. Do not override the function yourself.

function setMinimumReservePercentage(uint256 minimumReservePercentage_) external virtual delegatedToPart2;

Parameters

NameTypeDescription
minimumReservePercentage_uint2561e18 is 100%.

setYieldVault

Sets the yield vault.

@note CAUTION! Use drainYieldVault to drain the current yield vault completely before changing it. Any yield vault shares that are not redeemed will not count toward the underlying token backing after changing the yield vault.

This function can be called by the owner only.

Delegates the call to VaultBridgeTokenPart2.

@note (ATTENTION) The virtual modifier allows VaultBridgeTokenPart2 to override this function. Do not override the function yourself.

function setYieldVault(address yieldVault_) external virtual delegatedToPart2;

setYieldRecipient

Sets the yield recipient.

Yield will be collected before changing the recipient.

This function can be called by the owner only.

Delegates the call to VaultBridgeTokenPart2.

@note (ATTENTION) The virtual modifier allows VaultBridgeTokenPart2 to override this function. Do not override the function yourself.

function setYieldRecipient(address yieldRecipient_) external virtual delegatedToPart2;

setMinimumYieldVaultDeposit

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

Amounts below this value will be reserved regardless of the reserve percentage, in order to save gas for users.

The limit does not apply when rebalancing the reserve.

This function can be called by the owner only.

Delegates the call to VaultBridgeTokenPart2.

@note (ATTENTION) The virtual modifier allows VaultBridgeTokenPart2 to override this function. Do not override the function yourself.

function setMinimumYieldVaultDeposit(uint256 minimumYieldVaultDeposit_) external virtual delegatedToPart2;

Parameters

NameTypeDescription
minimumYieldVaultDeposit_uint256Set to 0 to disable.

setYieldVaultMaximumSlippagePercentage

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

@note IMPORTANT: Any losses incurred due to slippage (and not fully covered by produced yield) will need to be covered by whomever is responsible for this contract.

Delegates the call to VaultBridgeTokenPart2.

@note (ATTENTION) The virtual modifier allows VaultBridgeTokenPart2 to override this function. Do not override the function yourself.

function setYieldVaultMaximumSlippagePercentage(uint256 maximumSlippagePercentage) external virtual delegatedToPart2;

Parameters

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

_calculateAmountToReserve

Calculates the amount of assets to reserve (as opposed to depositing into the yield vault) based on the current and minimum reserve percentages.

@note (ATTENTION) reservedAssets must be up-to-date before using this function.

function _calculateAmountToReserve(uint256 assets, uint256 nonMintedShares)
    internal
    view
    returns (uint256 assetsToReserve);

Parameters

NameTypeDescription
assetsuint256The amount of the underlying token being deposited.
nonMintedSharesuint256The amount of vbToken that will be minted after using this function as a result of the deposit. (Set to 0 if you have already minted all the shares).

_depositIntoYieldVault

Deposit a specific amount of the underlying token into the yield vault.

function _depositIntoYieldVault(uint256 assets, bool exact) internal returns (uint256 nonDepositedAssets);

Parameters

NameTypeDescription
assetsuint256The amount of the underlying token to deposit into the yield vault.
exactboolWhether to revert if the exact amount of the underlying token could not be deposited into the yield vault.

Returns

NameTypeDescription
nonDepositedAssetsuint256The amount of the underlying token that could not be deposited into the yield vault. The value will be 0 if exact is set to true.

performReversibleYieldVaultDeposit

Enables infinte deposits regardless of the behavior of the yield vault.

This function can be called by the this contract only.

This function reverts if the yield vault deposit fails, or the solvency check does not pass with revert data ABI-encoded in the following format: abi.encode(depositSucceeded, depositData, solvencyCheckPassed), which can be decoded in another function.

function performReversibleYieldVaultDeposit(uint256 assets) external whenNotPaused onlySelf;

_withdrawFromYieldVault

Withdraws a specific amount of the underlying token from the yield vault.

function _withdrawFromYieldVault(
    uint256 assets,
    bool exact,
    address receiver,
    uint256 originalTotalSupply,
    uint256 originalUncollectedYield,
    uint256 originalReservedAssets
) internal returns (uint256 nonWithdrawnAssets, uint256 receivedAssets);

Parameters

NameTypeDescription
assetsuint256The amount of the underlying token to withdraw from the yield vault.
exactboolWhether to revert if the exact amount of the underlying token could not be withdrawn from the yield vault.
receiveraddressThe address to withdraw the underlying token to.
originalTotalSupplyuint256The total supply of vbToken before burning the required amount of vbToken or updating the reserve. Used for the solvency check.
originalUncollectedYielduint256The uncollected yield before burning the required amount of vbToken or updating the reserve. Used for the solvency check.
originalReservedAssetsuint256

Returns

NameTypeDescription
nonWithdrawnAssetsuint256The amount of the underlying token that could not be withdrawn from the yield vault. The value will be 0 if exact is set to true.
receivedAssetsuint256The amount of the underlying token actually received (e.g., after any fees). The value will be 0 if receiver is not address(this).

_receiveUnderlyingToken

Transfers the underlying token from an external account to self.

@note CAUTION! This function MUST NOT introduce reentrancy/crossentrancy vulnerabilities.

function _receiveUnderlyingToken(address from, uint256 value) internal;

_sendUnderlyingToken

Transfers the underlying token to an external account.

@note CAUTION! This function MUST NOT introduce reentrancy/crossentrancy vulnerabilities.

function _sendUnderlyingToken(address to, uint256 value) internal;

pause

Prevents usage of functions with the whenNotPaused modifier.

This function can be called by a pauser only.

Delegates the call to VaultBridgeTokenPart2.

@note (ATTENTION) The virtual modifier allows VaultBridgeTokenPart2 to override this function. Do not override the function yourself.

function pause() external virtual delegatedToPart2;

unpause

Allows usage of functions with the whenNotPaused modifier.

This function can be called by the owner only.

Delegates the call to VaultBridgeTokenPart2.

@note (ATTENTION) The virtual modifier allows VaultBridgeTokenPart2 to override this function. Do not override the function yourself.

function unpause() external virtual delegatedToPart2;

_delegateToPart2

Delegates the call to VaultBridgeTokenPart2.

function _delegateToPart2() private;

Events

ReserveRebalanced

event ReserveRebalanced(uint256 oldReservedAssets, uint256 newReservedAssets, uint256 reservePercentage);

YieldCollected

event YieldCollected(address indexed yieldRecipient, uint256 vbTokenAmount);

Burned

event Burned(uint256 vbTokenAmount);

DonatedAsYield

event DonatedAsYield(address indexed who, uint256 assets);

DonatedForCompletingMigration

event DonatedForCompletingMigration(address indexed who, uint256 assets);

MigrationCompleted

event MigrationCompleted(
    uint32 indexed originNetwork, uint256 indexed shares, uint256 indexed assets, uint256 migrationFeesFundUtilization
);

YieldRecipientSet

event YieldRecipientSet(address indexed yieldRecipient);

MinimumReservePercentageSet

event MinimumReservePercentageSet(uint256 minimumReservePercentage);

YieldVaultDrained

event YieldVaultDrained(uint256 redeemedShares, uint256 receivedAssets);

YieldVaultSet

event YieldVaultSet(address yieldVault);

YieldVaultMaximumSlippagePercentageSet

event YieldVaultMaximumSlippagePercentageSet(uint256 slippagePercentage);

Errors

Unauthorized

error Unauthorized();

InvalidInitializer

error InvalidInitializer();

InvalidOwner

error InvalidOwner();

InvalidName

error InvalidName();

InvalidSymbol

error InvalidSymbol();

InvalidUnderlyingToken

error InvalidUnderlyingToken();

InvalidMinimumReservePercentage

error InvalidMinimumReservePercentage();

InvalidYieldVault

error InvalidYieldVault();

InvalidYieldRecipient

error InvalidYieldRecipient();

InvalidLxLyBridge

error InvalidLxLyBridge();

InvalidMigrationManager

error InvalidMigrationManager();

InvalidYieldVaultMaximumSlippagePercentage

error InvalidYieldVaultMaximumSlippagePercentage();

InvalidVaultBridgeTokenPart2

error InvalidVaultBridgeTokenPart2();

InvalidAssets

error InvalidAssets();

InvalidDestinationNetworkId

error InvalidDestinationNetworkId();

InvalidReceiver

error InvalidReceiver();

InvalidPermitData

error InvalidPermitData();

InvalidShares

error InvalidShares();

IncorrectAmountOfSharesMinted

error IncorrectAmountOfSharesMinted(uint256 mintedShares, uint256 requiredShares);

AssetsTooLarge

error AssetsTooLarge(uint256 availableAssets, uint256 requestedAssets);

IncorrectAmountOfSharesRedeemed

error IncorrectAmountOfSharesRedeemed(uint256 redeemedShares, uint256 requiredShares);

CannotRebalanceReserve

error CannotRebalanceReserve();

NoNeedToRebalanceReserve

error NoNeedToRebalanceReserve();

NoYield

error NoYield();

InvalidOriginNetwork

error InvalidOriginNetwork();

CannotCompleteMigration

error CannotCompleteMigration(uint256 requiredAssets, uint256 receivedAssets, uint256 assetsInMigrationFund);

YieldVaultRedemptionFailed

error YieldVaultRedemptionFailed(uint256 sharesToRedeem, uint256 redemptionLimit);

MinimumYieldVaultDepositNotMet

error MinimumYieldVaultDepositNotMet(uint256 assetsToDeposit, uint256 minimumYieldVaultDeposit);

YieldVaultDepositFailed

error YieldVaultDepositFailed(uint256 assetsToDeposit, uint256 depositLimit);

InsufficientYieldVaultSharesMinted

error InsufficientYieldVaultSharesMinted(uint256 depositedAssets, uint256 mintedShares);

UnknownError

error UnknownError(bytes data);

YieldVaultWithdrawalFailed

error YieldVaultWithdrawalFailed(uint256 assetsToWithdraw, uint256 withdrawalLimit);

ExcessiveYieldVaultSharesBurned

error ExcessiveYieldVaultSharesBurned(uint256 burnedShares, uint256 withdrawnAssets);

InsufficientUnderlyingTokenReceived

error InsufficientUnderlyingTokenReceived(uint256 receivedAssets, uint256 requestedAssets);

UnknownFunction

error UnknownFunction(bytes4 functionSelector);

Structs

VaultBridgeTokenStorage

Storage of Vault Bridge Token contract.

It's implemented on a custom ERC-7201 namespace to reduce the risk of storage collisions when using with upgradeable contracts.

Note: storage-location: erc7201:agglayer.vault-bridge.VaultBridgeToken.storage

struct VaultBridgeTokenStorage {
    IERC20 underlyingToken;
    uint8 decimals;
    uint256 minimumReservePercentage;
    uint256 reservedAssets;
    IERC4626 yieldVault;
    address yieldRecipient;
    uint256 _netCollectedYield;
    uint32 lxlyId;
    ILxLyBridge lxlyBridge;
    uint256 migrationFeesFund;
    uint256 minimumYieldVaultDeposit;
    address migrationManager;
    uint256 yieldVaultMaximumSlippagePercentage;
    address _vaultBridgeTokenPart2;
}

InitializationParameters

Parameters for initializing Vault Bridge Token contract.

@note (ATTENTION) decimals will match the underlying token. Defaults to 18 decimals if the underlying token reverts on decimals.

struct InitializationParameters {
    address owner;
    string name;
    string symbol;
    address underlyingToken;
    uint256 minimumReservePercentage;
    address yieldVault;
    address yieldRecipient;
    address lxlyBridge;
    uint256 minimumYieldVaultDeposit;
    address migrationManager;
    uint256 yieldVaultMaximumSlippagePercentage;
    address vaultBridgeTokenPart2;
}

Properties

NameTypeDescription
owneraddress(ATTENTION) This address will be granted the DEFAULT_ADMIN_ROLE, as well as all basic roles. Roles can be modified at any time.
namestring
symbolstring
underlyingTokenaddress
minimumReservePercentageuint256vbTokens can maintain an internal reserve of the underlying token for serving withdrawals from first (as opposed to staking all assets). 1e18 is 100%. @note (ATTENTION) Automatic reserve rebalancing will be disabled for values greater than 1e18 (100%).
yieldVaultaddressAn external, ERC-4246 compliant vault into which the underlying token is deposited to produce yield.
yieldRecipientaddressThe address that receives yield produced by the yield vault. The yield collector collects yield, while the yield recipient receives it.
lxlyBridgeaddress
minimumYieldVaultDeposituint256The minimum amount of the underlying token that triggers a yield vault deposit. Amounts below this value will be reserved regardless of the reserve percentage, in order to save gas for users. The limit does not apply when rebalancing the reserve. Set to 0 to disable.
migrationManageraddress
yieldVaultMaximumSlippagePercentageuint256The maximum slippage percentage when depositing into or withdrawing from the yield vault. @note IMPORTANT: Any losses incurred due to slippage (and not fully covered by produced yield) will need to be covered by whomever is responsible for this contract. 1e18 is 100%. The recommended value is 0.01e18 (1%).
vaultBridgeTokenPart2address