Set Documentation
Search…
Via Uniswap V2 or Sushiswap

Getting the Trade Calldata from Uniswap or Sushiswap:

In order to execute a rebalance using Uniswap or Sushiswap, input the parameters into the trade function. If no data is provided, the adapter will attempt to trade directly on a pool between the two assets. This is rarely the highest liquidity path.
For example, your Set currently has a position for KNC and you wish to trade for WBTC. The KNC/WBTC pool is not very deep so trading against it will result in high slippage. The optimal trade path involves trading through the KNC/WETH and WETH/WBTC pairs. To specify this, you must pass in the custom path encoded in bytes into the _data field. To generate the bytes, you can use use an ABI coder.
If no _data is provided, it will automatically trade against the pool specified by the _sendTokenAddress and _receiveTokenAddress.
If you do not know or are unsure, drop in our Discord and ask us a question. Incorrectly supplying trade data can result in significant loss for your Set.
Sample ABI coder from ethers.js for generating a trade path:
1
import { defaultAbiCoder } from "ethers/lib/utils";
2
​
3
const path = [
4
"0xdd974d5c2e2928dea5f71b9825b8b646686bd200",
5
"0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
6
"0x2260fac5e5542a773aa44fbcfedf7c193bc2c599"
7
];
8
const tradeData = defaultAbiCoder.encode(
9
["address[]"],
10
[path]
11
);
12
​
13
// Sample return data:
14
// tradeData = 0x00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000003000000000000000000000000dd974d5c2e2928dea5f71b9825b8b646686bd200000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c599
Copied!
Sample ABI coder online:
Alternatively, you can use an ABI encoder online.

Convenience API:

We have provided a quick API for querying for a Uniswap or Sushiswap trade quote. This will trade through the most common pairs including USDC, USDT, DAI, WETH, and WBTC.
We assume no responsibility for any usage of the API. Always verify trade parameters returned by the API before use. Incorrect usage can result in significant losses.
get
https://
api.tokensets.com/public/v2/trade_quotes/:set_address
Fetch Trade Quote (Uniswap or Sushiswap)
Last modified 6mo ago