Structs, enums, and constants

Structs

Action

struct Action {
bytes32 protocolAdapterName;
ActionType actionType;
TokenAmount[] tokenAmounts;
bytes data;
}

protocolAdapterName — protocol adapter name converted to hex

actionType — type of action to be executed

tokenAmounts — array of tokens' addresses to be deposited/withdrawn

data — additional data required for the action (depends on actionType, adapterIndex, and protocolName).

  1. Parameter of type address[] (or address for 1 element) encoded as bytes and corresponding values. web3.eth.abi.encodeParameter(type, value) should be used with the following parameters:

    • UNISWAP_EXCHANGE_ADAPTER

      • ACTION_DEPOSIT

        • type: address[]

        • value: path

    • UNISWAP_ADAPTER_ASSET

      • ACTION_DEPOSIT

        • type: address

        • value: pairAddress

    • BALANCER_ASSET_ADAPTER

      • ACTION_DEPOSIT

        • type: address

        • value: poolAddress

      • ACTION_WITHDRAW

        • type: address

        • value: underlyingTokenAddress

    • CURVE_ASSET_ADAPTER

      • ACTION_DEPOSIT

        • type: address

        • value: poolAddress

      • ACTION_WITHDRAW

        • type: address

        • value: underlyingTokenAddress

  2. All other cases: EMPTY_BYTES

TokenAmount

struct TokenAmount {
address token;
uint256 amount;
AmountType amountType;
}

token — address of token used for input

amount — token amount for input (absolute or relative)

  • absolute amount is passed in wei

  • relative amount is passed in share (e.g. 0.5 for 50%) multiplied by 1e18 (eventually, it's 5e17 for 50%)

amountType — indicator whether amount is absolute or relative

AbsoluteTokenAmount

struct AbsoluteTokenAmount {
address token;
uint256 amount;
}

token — address of token

amount — token amount (always absolute)

Fee

struct Fee {
uint256 share;
address beneficiary;
}

share — fee share scaled by 1e18

beneficiry — receiver of the fee

Constants

actionType

ACTION_DEPOSIT = 1 // buy uni tokens, buy token sets, exchange with fixed input
ACTION_WITHDRAW = 2 // sell uni tokens, sell token sets, exchange with fixed output

protocolAdapterName

WETH_ASSET_ADAPTER = '0x5765746800000000000000000000000000000000000000000000000000000001'
UNISWAP_ASSET_ADAPTER = '0x556e697377617020563200000000000000000000000000000000000000000001'
UNISWAP_EXCHANGE_ADAPTER = '0x556e697377617020563200000000000000000000000000000000000000000003'
CURVE_ASSET_ADAPTER = '0x4375727665000000000000000000000000000000000000000000000000000001'
CURVE_EXCHANGE_ADAPTER = '0x4375727665000000000000000000000000000000000000000000000000000003'
TOKENSET_ASSET_ADAPTER = '0x546f6b656e536574000000000000000000000000000000000000000000000001'
BALANCER_ASSET_ADAPTER = '0x42616c616e636572000000000000000000000000000000000000000000000001'
COMPOUND_ASSET_ADAPTER = '0x436f6d706f756e64000000000000000000000000000000000000000000000001'
ONESPLIT_EXCHANGE_ADAPTER = '0x4f6e6553706c6974000000000000000000000000000000000000000000000003'

amountType

AMOUNT_RELATIVE = 1 // the corresponding amount is relative
AMOUNT_ABSOLUTE = 2 // the corresponding amount is absolute