Structs, enums, and constants

Structs

Action

struct Action {
bytes32 protocolAdapterName;
ActionType actionType; // uint8 for external integrations
address[] tokens;
uint256[] amounts;
AmountType[] amountTypes; // uint8[] for external integrations
bytes data;
}

actionType — type of action to be executed

protocolAdapterName — protocol adapter name converted to hex

adapterIndex — index of the adapter to interact with

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

amounts — array of tokens' amounts (relative or absolute) to be deposited/withdrawn

  • 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%)

amountTypes — array of indicators whether amount is absolute or relative (for every amount in amounts array)

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

    • ONESPLIT_EXCHANGE_ADAPTER

      • ACTION_DEPOSIT

        • type: address

        • value: toTokenAddress

    • TOKENSET_ASSET_ADAPTER

      • ACTION_DEPOSIT

        • type: address

        • value: setAddress

    • 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

Input

struct Input {
address token;
uint256 amount;
AmountType amountType; // uint8 for external integrations
uint256 fee;
address beneficiary;
}

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

fee — beneficiary fee (always 0 for Zerion)

beneficiary — beneficiary address (always ZERO_ADDRESS for Zerion)

Output

struct Output {
address token;
uint256 amount;
}

token — address of token

amount — token amount (always absolute)

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