Buffer Router API

The Buffer Router can be used to interact with Balancer onchain for buffer operations.

ERC4626 Buffers

initializeBuffer

function initializeBuffer(
    IERC4626 wrappedToken,
    uint256 exactAmountUnderlyingIn,
    uint256 exactAmountWrappedIn,
    uint256 minIssuedShares
) external returns (uint256 issuedShares);

Adds liquidity for the first time to one of the Vault's internal ERC4626 buffers. Buffer operations will revert until the buffer is initialized. To avoid unexpected behavior, always initialize buffers before creating or initializing any pools that contain the wrapped tokens to be used with them.

Parameters:

NameTypeDescription
wrappedTokenIERC4626Address of the wrapped token that implements IERC4626
exactAmountUnderlyingInuint256Amount of underlying tokens that will be deposited into the buffer
exactAmountWrappedInuint256Amount of wrapped tokens that will be deposited into the buffer
minIssuedSharesuint256Minimum amount of shares to receive, in underlying token native decimals
Returns:
NameTypeDescription
issuedSharesuint256The amount of tokens sharesOwner has in the buffer, denominated in underlying tokens (This is the BPT of an internal ERC4626 token buffer)

addLiquidityToBuffer

function addLiquidityToBuffer(
    IERC4626 wrappedToken,
    uint256 maxAmountUnderlyingIn,
    uint256 maxAmountWrappedIn,
    uint256 exactSharesToIssue,
) external returns (uint256 amountUnderlyingRaw, uint256 amountWrappedRaw);

Adds liquidity proportionally to a yield-bearing buffer (one of the Vault's internal ERC4626 token buffers). This limitation is necessary to avoid having multiple "wrap/unwrap" paths.

Parameters:

NameTypeDescription
wrappedTokenIERC4626Address of the wrapped token that implements IERC4626
maxAmountUnderlyingInuint256Maximum amount of underlying tokens to add to the buffer. It is expressed in underlying token native decimals
maxAmountWrappedInuint256Maximum amount of wrapped tokens to add to the buffer. It is expressed in wrapped token native decimals
exactSharesToIssueuint256The value in underlying tokens that sharesOwner wants to add to the buffer, in underlying token decimals

Returns:

NameTypeDescription
amountUnderlyingRawuint256Amount of underlying tokens deposited into the buffer
amountWrappedRawuint256Amount of wrapped tokens deposited into the buffer

Queries

queryInitializeBuffer

function initializeBuffer(
    IERC4626 wrappedToken,
    uint256 exactAmountUnderlyingIn,
    uint256 exactAmountWrappedIn
) external returns (uint256 issuedShares);

Query an initializeBuffer operation without actually executing it.

Parameters:

NameTypeDescription
wrappedTokenIERC4626Address of the wrapped token that implements IERC4626
exactAmountUnderlyingInuint256Amount of underlying tokens that will be deposited into the buffer
exactAmountWrappedInuint256Amount of wrapped tokens that will be deposited into the buffer

Returns:

NameTypeDescription
issuedSharesuint256The amount of tokens sharesOwner has in the buffer, denominated in underlying tokens (This is the BPT of an internal ERC4626 token buffer)

queryAddLiquidityToBuffer

function addLiquidityToBuffer(
    IERC4626 wrappedToken,
    uint256 exactSharesToIssue,
) external returns (uint256 amountUnderlyingRaw, uint256 amountWrappedRaw);

Query an addLiquidityToBuffer operation without actually executing it.

Parameters:

NameTypeDescription
wrappedTokenIERC4626Address of the wrapped token that implements IERC4626
maxAmountUnderlyingInuint256Maximum amount of underlying tokens to add to the buffer. It is expressed in underlying token native decimals
maxAmountWrappedInuint256Maximum amount of wrapped tokens to add to the buffer. It is expressed in wrapped token native decimals
exactSharesToIssueuint256The value in underlying tokens that sharesOwner wants to add to the buffer, in underlying token decimals

Returns:

NameTypeDescription
amountUnderlyingRawuint256Amount of underlying tokens deposited into the buffer
amountWrappedRawuint256Amount of wrapped tokens deposited into the buffer

queryRemoveLiquidityFromBuffer

function queryRemoveLiquidityFromBuffer(
    IERC4626 wrappedToken,
    uint256 exactSharesToRemove,
) external returns (uint256 removedUnderlyingBalanceOut, uint256 removedWrappedBalanceOut);

Query an removeLiquidityToBuffer operation without actually executing it.

Parameters:

NameTypeDescription
wrappedTokenIERC4626Address of the wrapped token that implements IERC4626
exactSharesToRemoveuint256The amount of shares that would be burned, in underlying token decimals

Returns:

NameTypeDescription
removedUnderlyingBalanceOutuint256Amount of underlying tokens that would be removed from the buffer
removedWrappedBalanceOutuint256Amount of wrapped tokens that would be removed from the buffer