Decoders

Decoders

The decoder smart-contracts allows to parse and validate the raw calldata that is passed to the AspisPool.execute function to interact with trading protocols like 1inch, Uniswap and Odos. The contracts allow to extract information like input and output tokens, trade amount, recipient, etc.

The calldata contains an encoded swap function with parameters. For example it might contain an encoded IAggregationRouterV6.swap call to 1inch router.

There are three decoders for each exchange that Aspis is integrated with:

  1. UniswapUniversalDecoder.sol - for Uniswap Universal Router calls
  2. OneInchV6Decoder.sol - for 1inch V6 Router calls
  3. OdosV2Decoder.sol - for Odos V2 Router calls

All decoders must implement the following function:

decodeExchangeInput

Decodes the calldata and returns it’s elements.

function decodeExchangeInput(
    uint256 value,
    bytes calldata inputData
) public view override returns (address, address, uint256, uint256, address)

value - the ether value passed to the Aspis Pool.

inputData - the encoded swap call to the exchange router.

Return values:

  1. Input token address
  2. Output token address
  3. Input amount
  4. Minimal return amount
  5. Receiver address