Nexera-FiAdapters & DeFi ProtocolsMaverick

MaverickAdapter

Git Source

Extends: BaseAdapter

The MaverickAdapter is designed to interact with the Maverick Protocol.

This adapter enables users to harness the power of Maverick's AMM features and integrate them into their financial strategies.

Custom Errors

WRONG_OPERATION

Raised when an invalid operation is requested.

 error WRONG_OPERATION();

WRONG_ADDRESS

Raised when an invalid address is provided.

error WRONG_ADDRESS();

WRONG_LENGTH

Raised when array input arguments do not match the expected length required for the respective operation.

error WRONG_LENGTH();

WRONG_AMOUNT

Raised when the amount specified in input or output token compositions is wrong with respect to the requested operation.

This can include situations where the amount is either 0 or exceeds MAX_UINT128 value.

error WRONG_AMOUNT();

Enums

DepositOperation

Defines the actions available with respect to Deposit Operation:

  • GET_OR_CREATE_POOL_AND_ADD_LIQUIDITY: Add liquidity to an existing pool or create a new pool & add liquidity to it
  • ADD_LIQUIDITY_TO_POOL: Add liquidity to an existing pool
  • ADD_LIQUIDITY_WITH_TICK_LIMITS: Add liquidity to an existing pool with active tick limits
  • CREATE_POOL_POSITION_AND_ADD_LIQUIDITY: Create a new pool position (PP) and add liquidity to it
  • ADD_LIQUIDITY_TO_POOL_POSITION_WITH_ADD_PARAMS: Add liquidity to an existing pool position (PP) with values computed offchain
  • ADD_LIQUIDITY_TO_POOL_POSITION: Add liquidity to an existing pool position (PP)
enum DepositOperation {
    GET_OR_CREATE_POOL_AND_ADD_LIQUIDITY,
    ADD_LIQUIDITY_TO_POOL,
    ADD_LIQUIDITY_WITH_TICK_LIMITS,
    CREATE_POOL_POSITION_AND_ADD_LIQUIDITY,
    ADD_LIQUIDITY_TO_POOL_POSITION_WITH_ADD_PARAMS,
    ADD_LIQUIDITY_TO_POOL_POSITION
}

WithdrawOperation

Defines the actions available with respect to Withdraw Operation:

  • REMOVE_LIQUIDITY: Remove liquidity from a pool and receive WETH if one of the tokens is WETH
  • REMOVE_LIQUIDITY_FROM_POOL_POSITION: Remove liquidity from a pool position (PP)
enum WithdrawOperation {
    REMOVE_LIQUIDITY,
    REMOVE_LIQUIDITY_FROM_POOL_POSITION
}

SwapOperation

Defines the actions available with respect to Swap Operation:

  • EXACT_INPUT: Perform a multi-hop swap along a specified path, exchanging a designated amount of one token into the maximum possible amount of another token
  • EXACT_OUTPUT: Perform a reverse multi-hop swap along a specified path, exchanging the smallest possible quantity of one token for a designated amount of another token
  • EXACT_INPUT_SINGLE: Swap a designated amount of one token for the maximum possible amount of another token
  • EXACT_OUTPUT_SINGLE: Swap as little as possible of one token for a designated amount of another token
enum SwapOperation {
    EXACT_INPUT,
    EXACT_OUTPUT,
    EXACT_INPUT_SINGLE,
    EXACT_OUTPUT_SINGLE
}

Structs

DepositExtraData

Used to indicate the appropriate action of a Deposit Operation.

struct DepositExtraData {
    DepositOperation depositOperation;
    GeneralDepositData extraDepositData;
}

Members

NameTypeDescription
depositOperationDepositOperationThe action to conduct
extraDepositDataGeneralDepositDataExtra data required for the action

GeneralDepositData

Defines the necessary data required for performing deposit-wise actions such as:

  • Creating a pool and adding liquidity
  • Adding liquidity to a pool
  • Creating a pool position and adding liqudity
  • Adding liquidity to an existing pool position
struct GeneralDepositData {
    uint256 tokenAAmount; 
    uint256 tokenBAmount;
    uint256 deadline;
    bytes operationData;
}

Members

NameTypeDescription
tokenAAmountuint256The amount of tokenA to add as liquidity
tokenBAmountuint256The amount of tokenB to add as liquidity
deadlineuint256The deadline epoch timestamp (in seconds) until which the action can be executed
operationDatabytesAdditional ABI encoded data related to the operation ( a , b , c , d , e , f )

GetOrCreatePoolAndAddLiquidityData

Defines the necessary data for invoking the getOrCreatePoolAndAddLiquidity() function of the Router contract, used for interacting with Maverick's AMM Pools. It encapsulates the necessary data for creating a new pool or adding liquidity to an existing one.

Note: This structure serves as the non-encoded operation data within the broader GeneralDepositData struct.

struct GetOrCreatePoolAndAddLiquidityData {
    uint256 tokenId;
    IRouter.PoolParams poolParams;
    IPool.AddLiquidityParams[] addParams;
}

Members

NameTypeDescription
tokenIduint256The ID of NFT LP token that holds the lp balance. Use 0 to mint a new LP token.
poolParamsIRouter.PoolParamsParameters defining the properties and characteristics of the pool, such as fees and associated tokens
addParamsIPool.AddLiquidityParams[]Parameters of liquidity addition

AddLiquidityToPoolData

Defines the necessary data for invoking the addLiquidityToPool() function of the Router contract, used for interacting with Maverick's AMM Pools. It encapsulates the necessary data for adding liquidity to a specific pool.

Note: This structure serves as the non-encoded operation data within the broader GeneralDepositData struct.

struct AddLiquidityToPoolData {
    uint256 tokenId;
    IPool pool;
    IPool.AddLiquidityParams[] addParams;
}

Members

NameTypeDescription
tokenIduint256The ID of NFT LP token that holds the lp balance. Use 0 to mint a new LP token.
poolIPoolThe pool to which liquidity will be added
addParamsIPool.AddLiquidityParams[]Parameters for each bin that will get new liquidity

AddLiquidityWithTickLimitsData

Defines the necessary data for invoking the addLiquidityWTickLimits() function of the Router contract, used for interacting with Maverick's AMM Pools. It encapsulates the necessary data for adding liquidity to a specific pool with active tick limits.

Note: This structure serves as the non-encoded operation data within the broader GeneralDepositData struct.

struct AddLiquidityWithTickLimitsData {
    uint256 tokenId;
    IPool pool;
    int32 minActiveTick;
    int32 maxActiveTick;
    IPool.AddLiquidityParams[] addParams;
}

Members

NameTypeDescription
tokenIduint256The ID of NFT LP token that holds the lp balance. Use 0 to mint a new LP token.
poolIPoolThe pool to which liquidity will be added
minActiveTickint32Lowest activeTick (inclusive) of the pool that will permit the transaction
maxActiveTickint32Highest activeTick (inclusive) of the pool that will permit the transaction
addParamsIPool.AddLiquidityParams[]Parameters for each bin that will get new liquidity

CreatePoolPositionAndAddLiquidityData

Defines the necessary data for invoking the createPoolPositionAndAddLiquidity() function of the PoolPositionManager contract. It encapsulates the necessary data for creating a pool position and adding liquidity to it.

Note: This structure serves as the non-encoded operation data within the broader GeneralDepositData struct.

struct CreatePoolPositionAndAddLiquidityData {
    IPool pool;
    bool isStatic;
    bool stakeInReward;
    IPool.AddLiquidityParams[] addParams;
}

Members

NameTypeDescription
poolIPoolPool factory used to create position
isStaticboolTrue if all bins in the Pool Position (PP) are static, false otherwise
stakeInRewardboolTrue to stake new pool position in reward contract, false otherwise
addParamsIPool.AddLiquidityParams[]Parameters of liquidity addition

AddLiquidityToPoolPositionWithAddParamsData

Defines the necessary data for invoking the addLiquidityToPoolPositionWithAddParams() function of the PoolPositionManager contract. It encapsulates the necessary data for adding liquidity to an existing pool position with values computed offchain.

Note: This structure serves as the non-encoded operation data within the broader GeneralDepositData struct.

struct AddLiquidityToPoolPositionWithAddParamsData {
    IPoolPositionSlim poolPositionContract;
    uint256 minLpTokenAmount;
    bool stakeInReward;
    uint256 bin0LpAmount;
    IPool.AddLiquidityParams[] addParams;
}

Members

NameTypeDescription
poolPositionContractIPoolPositionSlimThe Pool Position (PP) to which liquidity will be added
minLpTokenAmountuint256The miniumum accepted amount of ERC-20 PP LP tokens to mint
stakeInRewardboolTrue to stake pool position in reward contract, false otherwise
bin0LpAmountuint256The bin0 LP amount used for minting. Amount minted is the minimum of bin0LpAmount and the amount added to bin zero
addParamsIPool.AddLiquidityParams[]Parameters of liquidity addition

AddLiquidityToPoolPositionData

Defines the necessary data for invoking the addLiquidityToPoolPosition() function of the PoolPositionManager contract. It encapsulates the necessary data for adding liquidity to an existing pool position.

Note: This structure serves as the non-encoded operation data within the broader GeneralDepositData struct.

struct AddLiquidityToPoolPositionData {
    IPoolPositionSlim poolPositionContract;
    uint256 desiredLpTokenAmount;
    uint256 minLpTokenAmount;
    bool stakeInReward;
}

Members

NameTypeDescription
poolPositionContractIPoolPositionSlimThe Pool Position (PP) to which liquidity will be added
desiredLpTokenAmountuint256The target amount of ERC-20 PP LP tokens to mint
minLpTokenAmountuint256The miniumum accepted amount of ERC-20 PP LP tokens to mint
stakeInRewardboolTrue to stake pool position in reward contract, false otherwise

WithdrawExtraData

Used to indicate the appropriate action of a Withdraw Operation.

struct WithdrawExtraData {
    WithdrawOperation withdrawOperation;
    GeneralWithdrawData extraWithdrawData;
}

Members

NameTypeDescription
withdrawOperationWithdrawOperationThe action to conduct
extraWithdrawDataGeneralWithdrawDataExtra data required for the action

GeneralWithdrawData

Defines the necessary data required for performing withdrawal-wise actions such as:

  • Decreasing liquidity from a pool
  • Decreasing liquidity from a pool position
struct GeneralWithdrawData {
    uint256 deadline;
    bytes operationData;
}

Members

NameTypeDescription
deadlineuint256The deadline epoch timestamp (in seconds) until which the action can be executed
operationDatabytesAdditional ABI encoded data related to the operation ( a )

RemoveLiquidityData

Defines the necessary data for invoking the removeLiquidity() function of the Router contract, used for interacting with Maverick's AMM Pools. It encapsulates the necessary data for removing liquidity from a specific pool.

Note: This structure serves as the non-encoded operation data within the broader GeneralWithdrawData struct.

struct RemoveLiquidityData {
    address pool;
    uint256 tokenId;
    uint128[] binIds;
}

Members

NameTypeDescription
pooladdressThe address of the target pool to remove liquidity from
tokenIduint256The ID of position NFT that holds liquidity
binIdsuint128[]Array with the target bin IDs

SwapExtraData

Used to indicate the appropriate action of a Swap Operation.

struct SwapExtraData {
    SwapOperation swapOperation;
    GeneralSwapData extraSwapData;
}

Members

NameTypeDescription
swapOperationSwapOperationThe action to conduct
extraSwapDataGeneralSwapDataExtra data required for the action

GeneralSwapData

Defines the necessary data required for performing swap-wise actions such as:

  • exactInputSingle
  • exactOutputSingle
  • exactInput
struct GeneralSwapData {
    uint256 deadline;
    bytes operationData;
}

Members

NameTypeDescription
deadlineuint256The deadline epoch timestamp (in seconds) until which the swap can be executed
operationDatabytesAdditional ABI encoded data related to the operation ( a , b , c )

ExactInputSingleData

Defines the necessary data for invoking the exactInputSingle() function of the Router contract, used for interacting with Maverick's AMM Pools. It encapsulates the necessary data for performing the exactInputSingle swap.

Note: This structure serves as the non-encoded operation data within the broader GeneralSwapData struct.

struct ExactInputSingleData {
    IPool pool;
    uint256 sqrtPriceLimitD18;
}

Members

NameTypeDescription
poolIPoolThe target pool to perform the swap against
sqrtPriceLimitD18uint256The square root of the price limit for the swap, represented with 18 decimal places

ExactOutputSingleData

Defines the necessary data for invoking the exactOutputSingle() function of the Router contract, used for interacting with Maverick's AMM Pools. It encapsulates the necessary data for performing the exactOutputSingle swap.

Note: This structure serves as the non-encoded operation data within the broader GeneralSwapData struct.

struct ExactOutputSingleData {
    IPool pool;
}

Members

NameTypeDescription
poolIPoolThe target pool to perform the swap against

ExactData

Defines the necessary data for invoking the exactInput() and exactOutput() functions of the Router contract, used for interacting with Maverick's AMM Pools. It encapsulates the necessary data for performing multi-hop path-specific swaps.

Note: This structure serves as the non-encoded operation data within the broader GeneralSwapData struct.

struct ExactData {
    bytes path;
}

Members

NameTypeDescription
pathbytesA bytes string representing the path of tokens to swap

OperateExtraData

Defines the necessary data for invoking the migrateBinsUpstack() function of the Router contract, used for interacting with Maverick's AMM Pools.

struct OperateExtraData {
    IPool pool;
    uint128[] binIds;
    uint32 maxRecursion;
    uint256 deadline;
}

Members

NameTypeDescription
poolIPoolThe taget pool
binIdsuint128[]Array of bin IDs to migrate
maxRecursionuint32Maximum recursion depth before returning, 0 indicates no limit
deadlineuint256The deadline epoch timestamp (in seconds) until which the migration can be executed

CollectExtraData

Defines the necessary data for invoking the overloaded getReward() function of a Reward contract.

struct CollectExtraData {
    IReward rewardContract;
    uint8[] rewardTokenIndices;
}

Members

NameTypeDescription
rewardContractIRewardThe target Reward contract from which rewards will be collected
rewardTokenIndicesuint8[]Array with the indices of reward tokens to collect. If the array is a singleton, then the single one is invoked, otherwise the multiple one is invoked.

Layout

Used to store crucial data for the Adapter's functionality in a specific storage slot.

struct Layout {
    IRouter router;
    IPoolPositionManager poolPositionManager;
    address nativeToken;
}

Members

NameTypeDescription
routerIRouterThe interface representing the Router contract instance
poolPositionManagerIPoolPositionManagerThe interface representing the PoolPositionManager contract instance
nativeTokenaddressThe address of the wrapped native token address

State Variables

MAX_UINT128

Defines the maximum amount for adding/removing liquidity in Maverick's AMMs.

uint256 private constant MAX_UINT128 = type(uint128).max;

STORAGE_SLOT

Unique identifier for the storage slot where the Layout struct is stored.

bytes32 internal immutable STORAGE_SLOT;

Constructor

Sets the value of the STORAGE_SLOT state variable.

The value is computed as the keccak256 hash of the abi encoding of:

  • The Nexera-FI.MaverickAdapter string literal
  • The address of this contract (MaverickAdapter)
constructor();

Functions

initialize

Initializes the Adapter.

function initialize(bytes calldata initData_) external override;

Parameters

NameTypeDescription
initData_bytesThe ABI encoded Layout data

_deposit

Internal function for handling Deposit Operations.

This function is responsible for adding liquidity into Maverick protocol.

Called by executeAction function.

function _deposit(
    IAdapter.TokenAmount[] calldata out,
    IAdapter.TokenAmount[] calldata,
    bytes calldata extraData
) internal override;

Parameters

NameTypeDescription
outIAdapter.TokenAmount[]Array of TokenAmount structs defining the token compositions to send
expectedInIAdapter.TokenAmount[]Array of TokenAmount structs defining the expected token compositions to receive (LP tokens). To guarantee that a minimum quantity of LP tokens is received, the LP token address and the desired minimum amount should be included in this parameter. Subsequently, this information will be verified by the BaseAdapter.
extraDatabytesABI encoded data of type DepositExtraData indicating the action. All data needed for the deposit operations are included in this parameter.

_withdraw

Internal function for handling Withdraw Operations.

This function is responsible for removing liquidity from Maverick protocol.

Called by executeAction function.

function _withdraw(
    IAdapter.TokenAmount[] calldata out,
    IAdapter.TokenAmount[] calldata expectedIn,
    bytes calldata extraData
) internal override;

Parameters

NameTypeDescription
outIAdapter.TokenAmount[]Array of TokenAmount structs defining the token compositions to send (LP tokens)
expectedInIAdapter.TokenAmount[]Array of TokenAmount structs defining the expected token compositions to receive (tokenA & tokenB). The length of the array must equal to 2, else the function raises a WRONG_LENGTH error. In this array : - expectedIn[0] should include the address and minimum amount for tokenA - expectedIn[1] should include the address and minimum amount for tokenB
extraDatabytesABI encoded data of type WithdrawExtraData indicating the action

_swap

Internal function for handling Swap Operations.

This function facilitates the swapping of assets into the Maverick protocol.

Called by executeAction function.

function _swap(
    IAdapter.TokenAmount[] calldata out,
    IAdapter.TokenAmount[] calldata expectedIn,
    bytes calldata extraData
) internal override;

Parameters

NameTypeDescription
outIAdapter.TokenAmount[]Array of TokenAmount structs defining the token compositions to send. The length of the array must equal to 1, else the function raises a WRONG_LENGTH error. For exactInput and exactInputSingle actions, it should contain the amount to be provided. For exactOutput and exactOutputSingle actions, it should contain the maximum amount to be provided.
expectedInIAdapter.TokenAmount[]Array of TokenAmount structs defining the expected token compositions to receive. The length of the array must equal to 1, else the function raises a WRONG_LENGTH error. For exactInput and exactInputSingle actions, it should contain the minimum amount to be received. For exactOutput and exactOutputSingle actions, it should contain the specific amount to be received.
extraDatabytesABI encoded data of type SwapExtraData indicating the action

_operate

Internal function for handling Operate Operations.

This function is used for migrating bins within the Maverick Protocol.

Called by executeAction function.

function _operate(
    IAdapter.TokenAmount[] calldata,
    IAdapter.TokenAmount[] calldata,
    bytes calldata extraData
) internal override;

Parameters

NameTypeDescription
<none>IAdapter.TokenAmount[]Array of TokenAmount structs defining the token compositions to send. Not used in this context.
<none>IAdapter.TokenAmount[]Array of TokenAmount structs defining the expected token compositions to receive. Not used in this context.
extraDatabytesABI encoded data of type OperateExtraData

_collect

Internal function for handling Collect Operations.

This function is employed to retrieve rewards from Reward contracts associated with boosted positions.

Called by executeAction function.

function _collect(
    IAdapter.TokenAmount[] calldata,
    IAdapter.TokenAmount[] calldata,
    bytes calldata extraData
) internal override;

Parameters

NameTypeDescription
<none>IAdapter.TokenAmount[]Array of TokenAmount structs defining the token compositions to send. Not used in this context.
<none>IAdapter.TokenAmount[]Array of TokenAmount structs defining the expected token compositions to receive. Not used in this context.
extraDatabytesABI encoded data of type CollectExtraData

_getOrCreatePoolAndAddLiquidity

Adds liquidity to an existing pool or creates a new pool and adds liquidity to it.

Called by _deposit function.

function _getOrCreatePoolAndAddLiquidity(
    IAdapter.TokenAmount[] calldata out,
    GeneralDepositData memory data
) internal;

Parameters

NameTypeDescription
outIAdapter.TokenAmount[]Array of TokenAmount structs defining the token compositions to send (tokenA & tokenB)
dataGeneralDepositDataOperation data required for the action

_addLiquidityToPool

Adds liquidity to an existing pool.

Called by _deposit function.

function _addLiquidityToPool(
    IAdapter.TokenAmount[] calldata out,
    GeneralDepositData memory data
) internal;

Parameters

NameTypeDescription
outIAdapter.TokenAmount[]Array of TokenAmount structs defining the token compositions to send (tokenA & tokenB)
dataGeneralDepositDataOperation data required for the action

_addLiquidityWTickLimits

Adds liquidity to an existing pool with active tick limits.

Called by _deposit function.

function _addLiquidityWTickLimits(
    IAdapter.TokenAmount[] calldata out,
    GeneralDepositData memory data
) internal;

Parameters

NameTypeDescription
outIAdapter.TokenAmount[]Array of TokenAmount structs defining the token compositions to send (tokenA & tokenB)
dataGeneralDepositDataOperation data required for the action

_createPoolPositionAndAddLiquidity

Creates a new pool position and adds liquidity to it.

Called by _deposit function.

function _createPoolPositionAndAddLiquidity(
    IAdapter.TokenAmount[] calldata out,
    GeneralDepositData memory data
) internal;

Parameters

NameTypeDescription
outIAdapter.TokenAmount[]Array of TokenAmount structs defining the token compositions to send (tokenA & tokenB)
dataGeneralDepositDataOperation data required for the action

_addLiquidityToPoolPositionWithAddParams

Adds liquidity to an existing pool position with values computed offchain.

Called by _deposit function.

function _addLiquidityToPoolPositionWithAddParams(
    IAdapter.TokenAmount[] calldata out,
    GeneralDepositData memory data
) internal;

Parameters

NameTypeDescription
outIAdapter.TokenAmount[]Array of TokenAmount structs defining the token compositions to send (tokenA & tokenB)
dataGeneralDepositDataOperation data required for the action

_addLiquidityToPoolPosition

Adds liquidity to an existing pool position.

Called by _deposit function.

function _addLiquidityToPoolPosition(
    IAdapter.TokenAmount[] calldata out,
    GeneralDepositData memory data
) internal;

Parameters

NameTypeDescription
outIAdapter.TokenAmount[]Array of TokenAmount structs defining the token compositions to send (tokenA & tokenB)
dataGeneralDepositDataOperation data required for the action

_removeLiquidity

Removes liquidity from a pool and receives WETH if one of the tokens (tokenA or tokenB) is WETH.

Called by _withdraw function.

function _removeLiquidity(
    IAdapter.TokenAmount[] calldata out,
    IAdapter.TokenAmount[] calldata expectedIn,
    GeneralWithdrawData memory data
) internal;

Parameters

NameTypeDescription
outIAdapter.TokenAmount[]Array of TokenAmount structs defining the token compositions to send (LP tokens to burn)
expectedInIAdapter.TokenAmount[]Array of TokenAmount structs defining the expected minimum amount of token compositions (tokenA & tokenB) to receive
dataGeneralWithdrawDataOperation data required for the action

_removeLiquidityFromPoolPosition

Removes liquidity from a Pool Position (PP).

Called by _withdraw function.

function _removeLiquidityFromPoolPosition(
    IAdapter.TokenAmount[] calldata out,
    IAdapter.TokenAmount[] calldata expectedIn,
    GeneralWithdrawData memory data
) internal;

Parameters

NameTypeDescription
outIAdapter.TokenAmount[]Array of TokenAmount structs defining the token compositions to send (PP LP token to burn)
expectedInIAdapter.TokenAmount[]Array of TokenAmount structs defining the expected token compositions to receive (tokenA & tokenB)
dataGeneralWithdrawDataOperation data required for the action

_swapExactInputSingle

Swaps a designated amount of one token for the maximum possible amount of another token.

Called by _swap function.

function _swapExactInputSingle(
    IAdapter.TokenAmount[] calldata out,
    IAdapter.TokenAmount[] calldata expectedIn,
    GeneralSwapData memory data
) internal;

Parameters

NameTypeDescription
outIAdapter.TokenAmount[]Array of TokenAmount structs defining the token compositions to send. The length of the array must equal to 1 and contain the address and the exact amount to be exchanged.
expectedInIAdapter.TokenAmount[]Array of TokenAmount structs defining the expected token compositions to receive. The length of the array must equal to 1 and contain the address and the minimum expected amount to be received.
dataGeneralSwapDataOperation data required for the action

_swapExactOutputSingle

Swaps as little as possible of one token for a designated amount of another token.

Called by _swap function.

function _swapExactOutputSingle(
    IAdapter.TokenAmount[] calldata out,
    IAdapter.TokenAmount[] calldata expectedIn,
    GeneralSwapData memory data
) internal;

Parameters

NameTypeDescription
outIAdapter.TokenAmount[]Array of TokenAmount structs defining the token compositions to send. The length of the array must equal to 1 and contain the address and the maximum amount to be exchanged.
expectedInIAdapter.TokenAmount[]Array of TokenAmount structs defining the expected token compositions to receive. The length of the array must equal to 1 and contain the address and the exact amount to be received.
dataGeneralSwapDataOperation data required for the action

_swapExactInput

Performs a multi-hop swap along a specified path, exchanging a designated amount of one token into the maximum possible amount of another token.

Called by _swap function.

function _swapExactInput(
    IAdapter.TokenAmount[] calldata out,
    IAdapter.TokenAmount[] calldata expectedIn,
    GeneralSwapData memory data
) internal;

Parameters

NameTypeDescription
outIAdapter.TokenAmount[]Array of TokenAmount structs defining the token compositions to send. The length of the array must equal to 1 and contain the address and the exact amount to be exchanged.
expectedInIAdapter.TokenAmount[]Array of TokenAmount structs defining the expected token compositions to receive. The length of the array must equal to 1 and contain the address and the minimum amount to be received.
dataGeneralSwapDataOperation data required for the action

_swapExactOutput

Performs a reverse multi-hop swap along a specified path, exchanging the smallest possible quantity of one token for a designated amount of another token.

Called by _swap function.

function _swapExactOutput(
    IAdapter.TokenAmount[] calldata out,
    IAdapter.TokenAmount[] calldata expectedIn,
    GeneralSwapData memory data
) internal;

Parameters

NameTypeDescription
outIAdapter.TokenAmount[]Array of TokenAmount structs defining the token compositions to send. The length of the array must equal to 1 and contain the address and the maximum amount to be exchanged.
expectedInIAdapter.TokenAmount[]Array of TokenAmount structs defining the expected token compositions to receive. The length of the array must equal to 1 and contain the address and the exact amount to be received.
dataGeneralSwapDataOperation data required for the action

_checkAndApprove

Internal helper function responsible for checking and setting allowances for token transfers to a designated receiver.

Called by the following functions:

function _checkAndApprove(
    address token,
    address receiver
) internal;

Parameters

NameTypeDescription
tokenaddressThe address of the token for which the allowance is being set.
receiveraddressThe address of the receiver to whom the allowance is granted.

layout

Retrieves a reference to the Layout struct stored at a specified storage slot.

function layout() internal view returns (Layout storage l);