The Vault

Use the Router for swap, add liquidity and remove liquidity operations

The Router is the primary entry-point for the Balancer Protocol. It exposes developer friendly interfaces for complex protocol interactions.

Interacting with the Vault on-chain

The Ethereum Virtual Machine (EVM) imposes bytecode restrictions that limit the size of deployed contracts. In order to achieve the desired functionality, the Vault exceeds the bytecode limit of 24.576 kb. To overcome this, the Vault inherits from OpenZeppelin's Proxy contract and leverages delegate calls, allowing for the vault to utilize the functionality of more than one deployed smart contract.

When interacting with the Balancer Vault via solidity, it is recommended to cast the Vaults address to an IVault. You can find the interface hereopen in new window.

Vault Explorer

Because of the constraints imposed by the Proxy pattern, the Vault contract itself doesn't expose much to blockchain explorers like Etherscan. You can see the extended functions by visiting the VaultExtension and VaultAdmin contracts, but any direct call on those contracts will revert.

To provide access to the Vault through Etherscan in a user-friendly manner, there is a Vault "wrapper" contract called the VaultExplorer. This contract allows calling all permissionless Vault functions (e.g., getPoolTokens) through Etherscan.

Transient accounting

unlock

function unlock(bytes calldata data) external returns (bytes memory result);

This Vault function creates a context for a sequence of operations, effectively "unlocking" the Vault. It performs a callback on msg.sender with arguments provided in data. The callback is transient, meaning all balances for the caller have to be settled at the end.

Parameters:

NameTypeDescription
databytesContains function signature and args to be passed to the msg.sender

Returns:

NameTypeDescription
resultbytesResulting data from the call

settle

function settle(IERC20 token, uint256 amountHint) external returns (uint256 credit);

This Vault function settles deltas for a token. This operation must be successful for the current lock to be released. It returns the credit supplied by the Vault, which can be calculated as min(reserveDifference, amountHint), where the reserve difference equals current balance of the token minus existing reserves of the token when the function is called.

The purpose of the hint is to protect against "donation DDoS attacks," where someone sends extra tokens to the Vault during the transaction (e.g., using reentrancy), which otherwise would cause settlement to fail. If the reserveDifference > amountHint, any "extra" tokens will simply be absorbed by the Vault (and reflected in the reserves), and not affect settlement. (The tokens will not be recoverable, as in V2.)

Parameters:

NameTypeDescription
tokenIERC20Token's address
amountHintuint256Amount the caller expects to be credited

Returns:

NameTypeDescription
credituint256Amount credited to the caller for settlement

sendTo

function sendTo(IERC20 token, address to, uint256 amount) external;

This Vault function sends tokens to a recipient. There is no inverse operation for this function. To cancel debts, transfer funds to the Vault and call settle.

Parameters:

NameTypeDescription
tokenIERC20Token's address
toaddressRecipient's address
amountuint256Amount of tokens to send

isUnlocked

function isUnlocked() external view returns (bool);

This VaultExtension function returns True if the Vault is unlocked, false otherwise.

Returns:

NameTypeDescription
boolTrue if the Vault is unlocked, false otherwise

getNonzeroDeltaCount

function getNonzeroDeltaCount() external view returns (uint256);

This VaultExtension function returns the count of non-zero deltas.

Returns:

NameTypeDescription
uint256The current value of _nonzeroDeltaCount

getTokenDelta

function getTokenDelta(IERC20 token) external view returns (int256);

This VaultExtension function retrieves the token delta for a specific user and token.

Parameters:

NameTypeDescription
tokenIERC20The token for which the delta is being fetched

Returns:

NameTypeDescription
int256The delta of the specified token for the specified user

getReservesOf

function getReservesOf(IERC20 token) external view returns (uint256);

This VaultExtension function retrieves the reserve (i.e., total Vault balance) of a given token.

Parameters:

NameTypeDescription
tokenIERC20The token for which to retrieve the reserve

Returns:

NameTypeDescription
uint256The amount of reserves for the given token

Swaps

swap

function swap(
    SwapParams memory params
) external returns (uint256 amountCalculatedRaw, uint256 amountInRaw, uint256 amountOutRaw);

This Vault function swaps tokens based on provided parameters. All parameters are given in raw token decimal encoding.

Parameters:

NameTypeDescription
paramsSwapParamsParameters for the swap operation

Returns:

NameTypeDescription
amountCalculatedRawuint256Calculated swap amount
amountInRawuint256Amount of input tokens for the swap
amountOutRawuint256Amount of output tokens from the swap

Add Liquidity

addLiquidity

function addLiquidity(
    AddLiquidityParams memory params
) external returns (uint256[] memory amountsIn, uint256 bptAmountOut, bytes memory returnData);

This Vault function adds liquidity to a pool. Caution should be exercised when adding liquidity because the Vault has the capability to transfer tokens from any user, given that it holds all allowances. It returns the actual amounts of input tokens, the output pool token amount, and optional data with an encoded response from the pool.

Parameters:

NameTypeDescription
paramsAddLiquidityParamsParameters for the add liquidity operation

Returns:

NameTypeDescription
amountsInuint256[]Actual amounts of input tokens
bptAmountOutuint256Output pool token amount
returnDatabytesArbitrary (optional) data with encoded response from the pool

Remove liquidity

removeLiquidity

function removeLiquidity(
    RemoveLiquidityParams memory params
) external returns (uint256 bptAmountIn, uint256[] memory amountsOut, bytes memory returnData);

This Vault function removes liquidity from a pool. Trusted routers can burn pool tokens belonging to any user and require no prior approval from the user. Untrusted routers require prior approval from the user. This is the only function allowed to call _queryModeBalanceIncrease (and only in a query context).

Parameters:

NameTypeDescription
paramsRemoveLiquidityParamsParameters for the remove liquidity operation

Returns:

NameTypeDescription
bptAmountInuint256Actual amount of BPT burnt
amountsOutuint256[]Actual amounts of output tokens
returnDatabytesArbitrary (optional) data with encoded response from the pool

Pool information

getPoolTokenCountAndIndexOfToken

function getPoolTokenCountAndIndexOfToken(address pool, IERC20 token) external view returns (uint256, uint256);

This Vault function gets the index of a token in a given pool. It reverts if the pool is not registered, or if the token does not belong to the pool.

Parameters:

NameTypeDescription
pooladdressAddress of the pool
tokenIERC20Address of the token

Returns:

NameTypeDescription
tokenCountuint256Number of tokens in the pool
indexuint256Index corresponding to the given token in the pool's token list

isPoolInitialized

function isPoolInitialized(address pool) external view returns (bool);

This VaultExtension function checks whether a pool is initialized.

Parameters:

NameTypeDescription
pooladdressAddress of the pool to check

Returns:

NameTypeDescription
boolTrue if the pool is initialized, false otherwise

getPoolTokens

function getPoolTokens(address pool) external view returns (IERC20[] memory);

This VaultExtension function gets the tokens registered to a pool.

Parameters:

NameTypeDescription
pooladdressAddress of the pool

Returns:

NameTypeDescription
tokensIERC20[]List of tokens in the pool

getPoolTokenRates

function getPoolTokenRates(address pool) external view returns (uint256[] memory);

This VaultExtension function retrieves the scaling factors from a pool's rate providers. Tokens without rate providers will always return FixedPoint.ONE (1e18).

Parameters:

NameTypeDescription
pooladdressThe address of the pool

Returns:

NameTypeDescription
uint256[]The rate scaling factors from the pool's rate providers

getPoolData

function getPoolData(address pool) external view returns (PoolData memory);

This VaultExtension function retrieves a PoolData structure, containing comprehensive information about the pool, including the PoolConfig, tokens, tokenInfo, balances, rates and scaling factors.

Parameters:

NameTypeDescription
pooladdressThe address of the pool

Returns:

NameTypeDescription
PoolDataA struct with data describing the current state of the pool

getPoolTokenInfo

function getPoolTokenInfo(
    address pool
)
    external
    view
    returns (
        IERC20[] memory tokens,
        TokenInfo[] memory tokenInfo,
        uint256[] memory balancesRaw,
        uint256[] memory lastLiveBalances
    );

This function gets the raw data for a pool: tokens, raw and last live balances.

Parameters:

NameTypeDescription
pooladdressAddress of the pool

Returns:

NameTypeDescription
tokensIERC20[]The pool tokens, sorted in registration order
tokenInfoTokenInfo[]Token info, sorted in token registration order
balancesRawuint256[]Raw balances, sorted in token registration order
lastLiveBalancesuint256[]Last saved live balances, sorted in token registration order

getCurrentLiveBalances

function getCurrentLiveBalances(address pool) external view returns (uint256[] memory balancesLiveScaled18);

This VaultExtension function retrieves the current live balances: i.e., token balances after paying yield fees, applying decimal scaling and rates.

Parameters:

NameTypeDescription
pooladdressThe address of the pool

Returns:

NameTypeDescription
balancesLiveScaled18uint256[]Current live balances, sorted in token registration order

getPoolConfig

function getPoolConfig(address pool) external view returns (PoolConfig memory);

This VaultExtension function gets the configuration parameters of a pool.

Parameters:

NameTypeDescription
pooladdressAddress of the pool

Returns:

NameTypeDescription
PoolConfigPool configuration

getHooksConfig

function getHooksConfig(address pool) external view returns (HooksConfig memory);

This VaultExtension function gets the hooks configuration parameters of a pool.

Parameters:

NameTypeDescription
pooladdressAddress of the pool

Returns:

NameTypeDescription
HooksConfigHooks configuration

getBptRate

function getBptRate(address pool) external view returns (uint256 rate);

This VaultExtension function gets the current bpt rate of a pool, by dividing the current invariant by the total supply of BPT.

Parameters:

NameTypeDescription
pooladdressAddress of the pool

Returns:

NameTypeDescription
rateuint256BPT rate

ERC4626 Buffers

erc4626BufferWrapOrUnwrap

function erc4626BufferWrapOrUnwrap(
    BufferWrapOrUnwrapParams memory params
) external returns (uint256 amountCalculatedRaw, uint256 amountInRaw, uint256 amountOutRaw);

This Vault function wraps/unwraps tokens based on provided parameters, using the buffer of the wrapped token when it has enough liquidity to avoid external calls. All parameters are given in raw token decimal encoding.

Parameters:

NameTypeDescription
paramsBufferWrapOrUnwrapParamsParameters for the wrap/unwrap operation

Returns:

NameTypeDescription
amountCalculatedRawuint256Calculated swap amount
amountInRawuint256Amount of input tokens for the swap
amountOutRawuint256Amount of output tokens from the swap

pauseVaultBuffers

function pauseVaultBuffers() external;

This VaultAdmin function pauses native vault buffers globally. When buffers are paused, it's not possible to add liquidity or wrap/unwrap tokens using Vault's erc4626BufferWrapOrUnwrap primitive. However, it's still possible to remove liquidity. Currently it's not possible to pause vault buffers individually. This is a permissioned call.

unpauseVaultBuffers

function unpauseVaultBuffers() external;

This VaultAdmin function unpauses native vault buffers globally. When buffers are paused, it's not possible to add liquidity or wrap/unwrap tokens using Vault's erc4626BufferWrapOrUnwrap primitive. However, it's still possible to remove liquidity. This is a permissioned call.

initializeBuffer

function initializeBuffer(
    IERC4626 wrappedToken,
    uint256 amountUnderlyingRaw,
    uint256 amountWrappedRaw,
    address sharesOwner
) external returns (uint256 issuedShares);

This VaultAdmin function adds liquidity to an internal ERC4626 buffer in the Vault for the first time. And operations involving the buffer will revert until it is initialized.

Parameters:

NameTypeDescription
wrappedTokenIERC4626Address of the wrapped token that implements IERC4626
amountUnderlyingRawuint256Amount of underlying tokens that will be deposited into the buffer
amountWrappedRawuint256Amount of wrapped tokens that will be deposited into the buffer
sharesOwneraddressAddress of the contract that will own the liquidity. Only this contract will be able to remove liquidity from the buffer

addLiquidityToBuffer

function addLiquidityToBuffer(
    IERC4626 wrappedToken,
    uint256 amountUnderlyingRaw,
    uint256 amountWrappedRaw,
    address sharesOwner
) external returns (uint256 issuedShares);

This VaultAdmin function adds liquidity to an internal ERC4626 buffer in the Vault. Reverts if the buffer has not been initialized.

Parameters:

NameTypeDescription
wrappedTokenIERC4626Address of the wrapped token that implements IERC4626
amountUnderlyingRawuint256Amount of underlying tokens that will be deposited into the buffer
amountWrappedRawuint256Amount of wrapped tokens that will be deposited into the buffer
sharesOwneraddressAddress of the contract that will own the liquidity. Only this contract will be able to remove liquidity from the buffer

removeLiquidityFromBuffer

function removeLiquidityFromBuffer(
    IERC4626 wrappedToken,
    uint256 sharesToRemove
) external returns (uint256 removedUnderlyingBalanceRaw, uint256 removedWrappedBalanceRaw);

This VaultAdmin function removes liquidity from an internal ERC4626 buffer in the Vault. Only proportional exits are supported. Note that the sharesOnwer here is the msg.sender; unlike initialize, add, and other buffer operations, the entrypoint for this function is the Vault itself.

Parameters:

NameTypeDescription
wrappedTokenIERC4626Address of the wrapped token that implements IERC4626
sharesToRemoveuint256Amount of shares to remove from the buffer. Cannot be greater than sharesOwner total shares

getBufferOwnerShares

function getBufferOwnerShares(
    IERC20 wrappedToken,
    address liquidityOwner
) external view returns (uint256 ownerShares);

This VaultAdmin function returns the shares (internal buffer BPT) of a liquidity owner: a user that deposited assets in the buffer.

Parameters:

NameTypeDescription
wrappedTokenIERC20Address of the wrapped token that implements IERC4626
liquidityOwneraddressAddress of the user that owns liquidity in the wrapped token's buffer

getBufferTotalShares

function getBufferTotalShares(IERC20 wrappedToken) external view returns (uint256 bufferShares);

This VaultAdmin function returns the supply shares (internal buffer BPT) of the ERC4626 buffer.

Parameters:

NameTypeDescription
wrappedTokenIERC20Address of the wrapped token that implements IERC4626

getBufferBalance

function getBufferBalance(
    IERC20 wrappedToken
) external view returns (uint256 underlyingBalanceRaw, uint256 wrappedBalanceRaw);

This VaultAdmin function returns the amount of underlying and wrapped tokens deposited in the internal buffer of the vault.

Parameters:

NameTypeDescription
wrappedTokenIERC20Address of the wrapped token that implements IERC4626

Authentication

getAuthorizer

function getAuthorizer() external view returns (IAuthorizer);

This Vault function returns the Vault's Authorizer. It is in the main Vault for performance reasons.

Returns:

NameTypeDescription
IAuthorizerAddress of the authorizer

setAuthorizer

function setAuthorizer(IAuthorizer newAuthorizer) external;

This VaultAdmin function sets a new Authorizer for the Vault. This is a permissioned call. It emits an AuthorizerChanged event.

Parameters:

NameTypeDescription
newAuthorizerIAuthorizerThe new Authorizer for the Vault

Pool registration

registerPool

function registerPool(
    address pool,
    TokenConfig[] memory tokenConfig,
    uint256 swapFeePercentage,
    uint32 pauseWindowEndTime,
    bool protocolFeeExempt,
    PoolRoleAccounts calldata roleAccounts,
    address poolHooksContract,
    LiquidityManagement calldata liquidityManagement
) external;

This VaultExtension function registers a pool, associating it with its factory and the tokens it manages.

Parameters:

NameTypeDescription
pooladdressThe address of the pool being registered
tokenConfigTokenConfig[]An array of descriptors for the tokens the pool will manage
swapFeePercentageuint256The initial static swap fee percentage of the pool
pauseWindowEndTimeuint32The timestamp after which it is no longer possible to pause the pool
protocolFeeExemptboolIf true, the pool's initial aggregate fees will be set to 0
roleAccountsPoolRoleAccountsAddresses the Vault will allow to change certain pool settings
poolHooksContractaddressContract that implements the hooks for the pool
liquidityManagementLiquidityManagementLiquidity management flags with implemented methods

isPoolRegistered

function isPoolRegistered(address pool) external view returns (bool);

This VaultExtension function checks whether a pool is registered.

Parameters:

NameTypeDescription
pooladdressAddress of the pool to check

Returns:

NameTypeDescription
boolTrue if the pool is registered, false otherwise

initialize

function initialize(
    address pool,
    address to,
    IERC20[] memory tokens,
    uint256[] memory exactAmountsIn,
    uint256 minBptAmountOut,
    bytes memory userData
) external returns (uint256 bptAmountOut);

This VaultExtension function initializes a registered pool by adding liquidity; mints BPT tokens for the first time in exchange.

Parameters:

NameTypeDescription
pooladdressAddress of the pool to initialize
toaddressAddress that will receive the output BPT
tokensIERC20[]Tokens used to seed the pool (must match the registered tokens)
exactAmountsInuint256[]Exact amounts of input tokens
minBptAmountOutuint256Minimum amount of output pool tokens
userDatabytesAdditional (optional) data required for adding initial liquidity

Returns:

NameTypeDescription
bptAmountOutuint256Output pool token amount

Balancer Pool tokens

totalSupply

function totalSupply(address token) external view returns (uint256);

This VaultExtension function gets the total supply of a given ERC20 token.

Parameters:

NameTypeDescription
tokenaddressToken's address

Returns:

NameTypeDescription
uint256Total supply of the token

balanceOf

function balanceOf(address token, address account) external view returns (uint256);

This VaultExtension function gets the balance of an account for a given ERC20 token.

Parameters:

NameTypeDescription
tokenaddressToken's address
accountaddressAccount's address

Returns:

NameTypeDescription
uint256Balance of the account for the token

allowance

function allowance(address token, address owner, address spender) external view returns (uint256);

This VaultExtension function gets the allowance of a spender for a given ERC20 token and owner.

Parameters:

NameTypeDescription
tokenaddressToken's address
owneraddressOwner's address
spenderaddressSpender's address

Returns:

NameTypeDescription
uint256Amount of tokens the spender is allowed to spend

approve

function approve(address owner, address spender, uint256 amount) external returns (bool);

This VaultExtension function approves a spender to spend pool tokens on behalf of sender.

Parameters:

NameTypeDescription
owneraddressOwner's address
spenderaddressSpender's address
amountuint256Amount of tokens to approve

Returns:

NameTypeDescription
boolTrue if successful, false otherwise

transfer

function transfer(address owner, address to, uint256 amount) external returns (bool);

This VaultExtension function transfers pool token from owner to a recipient.

Parameters:

NameTypeDescription
owneraddressOwner's address
toaddressRecipient's address
amountuint256Amount of tokens to transfer

Returns:

NameTypeDescription
boolTrue if successful, false otherwise

transferFrom

function transferFrom(address spender, address from, address to, uint256 amount) external returns (bool);

This VaultExtension function transfers pool token from a sender to a recipient using an allowance.

Parameters:

NameTypeDescription
spenderaddressAddress allowed to perform the transfer
fromaddressSender's address
toaddressRecipient's address
amountuint256Amount of tokens to transfer

Returns:

NameTypeDescription
boolTrue if successful, false otherwise

pool pausing

isPoolPaused

function isPoolPaused(address pool) external view returns (bool);

This VaultExtension function indicates whether a pool is paused.

Parameters:

NameTypeDescription
pooladdressThe pool to be checked

Returns:

NameTypeDescription
boolTrue if the pool is paused

getPoolPausedState

function getPoolPausedState(address pool) external view returns (bool, uint32, uint32, address);

This VaultExtension function returns the paused status, and end times of the Pool's pause window and buffer period.

Parameters:

NameTypeDescription
pooladdressThe pool whose data is requested

Returns:

NameTypeDescription
pausedboolTrue if the Pool is paused
poolPauseWindowEndTimeuint32The timestamp of the end of the Pool's pause window
poolBufferPeriodEndTimeuint32The timestamp after which the Pool unpauses itself (if paused)
pauseManageraddressThe pause manager, or the zero address

Fees

getAggregateSwapFeeAmount

function getAggregateSwapFeeAmount(address pool, IERC20 token) external view returns (uint256);

This VaultExtension function returns the accumulated swap fees (including aggregate fees) in token collected by the pool.

Parameters:

NameTypeDescription
pooladdressThe address of the pool for which aggregate fees have been collected
tokenIERC20The address of the token in which fees have been accumulated

Returns:

NameTypeDescription
uint256The total amount of fees accumulated in the specified token

getAggregateYieldFeeAmount

function getAggregateYieldFeeAmount(address pool, IERC20 token) external view returns (uint256);

This VaultExtension function returns the accumulated yield fees (including aggregate fees) in token collected by the pool.

Parameters:

NameTypeDescription
pooladdressThe address of the pool for which aggregate fees have been collected
tokenIERC20The address of the token in which fees have been accumulated

Returns:

NameTypeDescription
uint256The total amount of fees accumulated in the specified token

getStaticSwapFeePercentage

function getStaticSwapFeePercentage(address pool) external view returns (uint256);

This VaultExtension function fetches the static swap fee percentage for a given pool.

Parameters:

NameTypeDescription
pooladdressThe address of the pool whose static swap fee percentage is being queried

Returns:

NameTypeDescription
uint256The current static swap fee percentage for the specified pool

getPoolRoleAccounts

function getPoolRoleAccounts(address pool) external view returns (PoolRoleAccounts memory);

This VaultExtension function fetches the role accounts for a given pool (pause manager, swap manager, pool creator).

Parameters:

NameTypeDescription
pooladdressThe address of the pool whose roles are being queried

Returns:

NameTypeDescription
roleAccountsPoolRoleAccountsA struct containing the role accounts for the pool (or 0 if unassigned)

computeDynamicSwapFee

function computeDynamicSwapFee(
    address pool,
    PoolSwapParams memory swapParams
) external view returns (bool, uint256);

This VaultExtension function queries the current dynamic swap fee of a pool, given a set of swap parameters.

Parameters:

NameTypeDescription
pooladdressThe pool
swapParamsPoolSwapParamsThe swap parameters used to compute the fee

Returns:

NameTypeDescription
successboolTrue if the pool has a dynamic swap fee and it can be successfully computed
dynamicSwapFeeuint256The dynamic swap fee percentage

getProtocolFeeController

function getProtocolFeeController() external view returns (IProtocolFeeController);

This VaultExtension function returns the Protocol Fee Controller address.

Returns:

NameTypeDescription
IProtocolFeeControllerAddress of the ProtocolFeeController

setStaticSwapFeePercentage

function setStaticSwapFeePercentage(address pool, uint256 swapFeePercentage) external;

This VaultAdmin function assigns a new static swap fee percentage to the specified pool. This is a permissioned function, disabled if the pool is paused. The swap fee percentage must be within the bounds specified by the pool's implementation of ISwapFeePercentageBounds.

Parameters:

NameTypeDescription
pooladdressThe address of the pool for which the static swap fee will be changed
swapFeePercentageuint256The new swap fee percentage to apply to the pool

updateAggregateSwapFeePercentage

function updateAggregateSwapFeePercentage(address pool, uint256 newAggregateSwapFeePercentage) external;

This VaultAdmin function updates an aggregate swap fee percentage. Can only be called by the current protocol fee controller.

Parameters:

NameTypeDescription
pooladdressThe pool whose fee will be updated
newAggregateSwapFeePercentageuint256The new aggregate swap fee percentage

updateAggregateYieldFeePercentage

function updateAggregateYieldFeePercentage(address pool, uint256 newAggregateYieldFeePercentage) external;

This VaultAdmin function updates an aggregate yield fee percentage. Can only be called by the current protocol fee controller.

Parameters:

NameTypeDescription
pooladdressThe pool whose fee will be updated
newAggregateYieldFeePercentageuint256The new aggregate yield fee percentage

setProtocolFeeController

function setProtocolFeeController(IProtocolFeeController newProtocolFeeController) external;

This VaultAdmin function sets a new Protocol Fee Controller for the Vault. This is a permissioned call.

Parameters:

NameTypeDescription
newProtocolFeeControllerIProtocolFeeControllerThe new Protocol Fee Controller for the Vault

Recovery mode

isPoolInRecoveryMode

function isPoolInRecoveryMode(address pool) external view returns (bool);

This VaultExtension function checks whether a pool is in recovery mode.

Parameters:

NameTypeDescription
pooladdressAddress of the pool to check

Returns:

NameTypeDescription
boolTrue if the pool is initialized, false otherwise

removeLiquidityRecovery

function removeLiquidityRecovery(
    address pool,
    address from,
    uint256 exactBptAmountIn
) external returns (uint256[] memory amountsOut);

This VaultExtension function removes liquidity from a pool specifying exact pool tokens in, with proportional token amounts out. The request is implemented by the Vault without any interaction with the pool, ensuring that it works the same for all pools, and cannot be disabled by a new pool type.

Parameters:

NameTypeDescription
pooladdressAddress of the pool
fromaddressAddress of user to burn pool tokens from
exactBptAmountInuint256Input pool token amount

Returns:

NameTypeDescription
amountsOutuint256[]Actual calculated amounts of output tokens, sorted in token registration order

enableRecoveryMode

function enableRecoveryMode(address pool) external;

This VaultAdmin function enables recovery mode for a pool. This is a permissioned function.

Parameters:

NameTypeDescription
pooladdressThe pool

disableRecoveryMode

function disableRecoveryMode(address pool) external;

This VaultAdmin function disables recovery mode for a pool. This is a permissioned function.

Parameters:

NameTypeDescription
pooladdressThe pool

Queries

quote

function quote(bytes calldata data) external returns (bytes memory result);

This VaultExtension function performs a callback on msg.sender with arguments provided in data. It is used to query a set of operations on the Vault. Only off-chain eth_call are allowed, anything else will revert. Also note that it is non-payable, as the Vault does not allow ETH.

Parameters:

NameTypeDescription
databytesContains function signature and args to be passed to the msg.sender

Returns:

NameTypeDescription
resultbytesResulting data from the call

quoteAndRevert

function quoteAndRevert(bytes calldata data) external;

This VaultExtension function performs a callback on msg.sender with arguments provided in data. It is used to query a set of operations on the Vault. Only off-chain eth_call are allowed, anything else will revert. This call always reverts, returning the result in the revert reason. Also note that it is non-payable, as the Vault does not allow ETH.

Parameters:

NameTypeDescription
databytesContains function signature and args to be passed to the msg.sender

isQueryDisabled

function isQueryDisabled() external view returns (bool);

This VaultExtension function checks if the queries are enabled on the Vault.

Returns:

NameTypeDescription
boolIf true, then queries are disabled

calculateBufferAmounts

function calculateBufferAmounts(
    SwapKind kind,
    IERC4626 wrappedToken,
    uint256 amountGiven
) external returns (uint256 amountCalculated, uint256 amountInUnderlying, uint256 amountOutWrapped);

This VaultExtension function calculates the buffer amounts for a given swap kind, wrapped token, and given amount.

Parameters:

NameTypeDescription
kindSwapKindThe kind of swap (in or out)
wrappedTokenIERC4626The wrapped token involved in the swap
amountGivenuint256The amount given for the swap

Returns:

NameTypeDescription
amountCalculateduint256The calculated amount for the swap
amountInUnderlyinguint256The amount in the underlying token
amountOutWrappeduint256The amount in the wrapped token

disableQuery

function disableQuery() external;

This VaultAdmin function disables queries functionality on the Vault. It can only be called by governance.

Constants

getPauseWindowEndTime

function getPauseWindowEndTime() external view returns (uint32);

This VaultAdmin function returns Vault's pause window end time.

Returns:

NameTypeDescription
uint32The end time of the Vault's pause window

getBufferPeriodDuration

function getBufferPeriodDuration() external view returns (uint32);

This VaultAdmin function returns Vault's buffer period duration.

Returns:

NameTypeDescription
uint32The duration of the Vault's buffer period

getBufferPeriodEndTime

function getBufferPeriodEndTime() external view returns (uint32);

This VaultAdmin function returns Vault's buffer period end time.

Returns:

NameTypeDescription
uint32The end time of the Vault's buffer period

getMinimumPoolTokens

function getMinimumPoolTokens() external pure returns (uint256);

This VaultAdmin function gets the minimum number of tokens in a pool.

Returns:

NameTypeDescription
uint256The token count of a minimal pool

getMaximumPoolTokens

function getMaximumPoolTokens() external pure returns (uint256);

This VaultAdmin function gets the maximum number of tokens in a pool.

Returns:

NameTypeDescription
uint256The token count of a maximal pool

vault

function vault() external view returns (IVault);

This function (defined on both VaultExtension and VaultAdmin) returns the main Vault address.

Returns:

NameTypeDescription
IVaultThe main Vault address

Vault pausing

isVaultPaused

function isVaultPaused() external view returns (bool);

This VaultAdmin function indicates whether the Vault is paused.

Returns:

NameTypeDescription
boolTrue if the Vault is paused

getVaultPausedState

function getVaultPausedState() external view returns (bool, uint32, uint32);

This VaultAdmin function returns the paused status, and end times of the Vault's pause window and buffer period.

Returns:

NameTypeDescription
pausedboolTrue if the Vault is paused
vaultPauseWindowEndTimeuint32The timestamp of the end of the Vault's pause window
vaultBufferPeriodEndTimeuint32The timestamp of the end of the Vault's buffer period

pauseVault

function pauseVault() external;

This VaultAdmin function pauses the Vault: an emergency action which disables all operational state-changing functions. This is a permissioned function that will only work during the Pause Window set during deployment.

unpauseVault

function unpauseVault() external;

This VaultAdmin function reverses a pause operation, and restores the Vault to normal functionality. This is a permissioned function that will only work on a paused Vault within the Buffer Period set during deployment. Note that the Vault will automatically unpause after the Buffer Period expires.

Pool pausing

pausePool

function pausePool(address pool) external;

This VaultAdmin function pauses the Pool: an emergency action which disables all pool functions. This is a permissioned function that will only work during the Pause Window set during pool factory deployment.

Parameters:

NameTypeDescription
pooladdressThe address of the pool

unpausePool

function unpausePool(address pool) external;

This VaultAdmin function reverses a pause operation, and restores the Pool to normal functionality. This is a permissioned function that will only work on a paused Pool within the Buffer Period set during deployment. Note that the Pool will automatically unpause after the Buffer Period expires.

Parameters:

NameTypeDescription
pooladdressThe address of the pool

Miscellaneous

getVaultExtension

function getVaultExtension() external view returns (address);

This Vault function returns the Vault Extension address.

Returns:

NameTypeDescription
addressAddress of the VaultExtension

getVaultAdmin

function getVaultAdmin() external view returns (address);

This VaultExtension function returns the Vault Admin contract address.

Returns:

NameTypeDescription
addressThe address of the Vault Admin contract