Skip to main content

What is tokenIn and tokenOut?

tokenIn is the asset or position you spend. tokenOut is the destination asset or position the route should deliver. Both can be tokens or tokenized DeFi positions.

J
Written by Javier Diaz

tokenIn is the asset or position you spend. tokenOut is the destination asset or position the route should deliver. The Route API finds a path between those two positions.

Definition

A routing request names what you start with and what you want to end with. Those values can be ordinary ERC-20s, the native asset, LP tokens, vault shares, or other tokenized positions.

How it works

  • Pass tokenIn and tokenOut as addresses (arrays on the Route API).

  • For a chain’s native asset on EVM, docs use 0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee.

  • amountIn is the size of the input, in the token’s smallest unit, as a decimal string.

  • The response describes the selected path in route and the expected output in amountOut.

How Enso does this

POST https://api.enso.build/api/v1/shortcuts/route calculates a path between any two DeFi positions expressed as tokenIn and tokenOut, including same-chain and cross-chain requests when you also set destinationChainId. See DeFi and Swap Routing. For a non-tokenized destination, use the nontokenized endpoint with positionOut instead of a tokenized tokenOut.

FAQ

Can tokenOut be a vault or position token?

Yes. The Route docs say tokenIn and tokenOut can be ERC-20 tokens, LP tokens, vault shares, or yield positions.

Is tokenOut the same as receiver?

No. tokenOut is the asset. receiver is the address that should receive the final output.

Related articles

  • What is amountIn vs amountOut?

  • How do I handle native token inputs?

  • How do I call the Route API with curl?

  • What is a route path?

  • Tokenized route vs nontokenized route

Sources

Did this answer your question?