Trading
Notice: For Sets created after June 2022 using TokenSets UI, please refer to the Batch Trading section on how to execute trades manually via Etherscan
What is the TradeModule:
The Trade Module enables managers of SetTokens to perform atomic trades using aggregators such as 0x and 1inch, and decentralized exchanges such as Sushiswap and Uniswap. This rebalances the Set for all Set holders.
Initializing the TradeModule:
All modules need to be added to the SetToken as the first step. Learn how to add a module to your SetToken by referring to the Adding a Module guide.
Once you have added the TradeModule to the SetToken, you must initialize the SetToken on the TradeModule:
Trading:
Only the manager will be able to trade. Call the trade
function with inputs as follows:
Important: sendQuantity
and _minReceiveQuantity
are denominated in position units and not the notional quantity. For example, if 1 SetToken contains 1 WETH, and there are 10 supply of SetTokens (10 WETH locked in total), trading 100% of the ETH to DAI requires passing in 1 (more accurately 10**18) into the sendQuantity
.
The exchange name is a string specifying which exchange adapter to execute the trade. The exchange name is registered in the IntegrationRegistry contract. Exchanges and aggregators currently supported by the TradeModule are:
Contract | Exchange Name |
0x | ZeroExApiAdapterV4 |
1Inch | OneInchExchangeAdapter |
Uniswap V2 | UniswapV2ExchangeAdapter |
SushiSwap | SushiswapExchangeAdapter |
Kyber | KyberExchangeAdapter |
Uniswap V3 | UniswapV3ExchangeAdapter |
Kyber DMM | KyberV3ExchangeAdapter |
AMMSplitter | AMMSplitterExchangeAdapter |
The _data
parameter is optional on some exchanges and required for others. For example, you will need to input the trade calldata
fetched from the 0x API or 1inch API to execute an 1Inch trade or custom path to route the trade through Uniswap or Sushiswap. For information on how to generate the custom _data
parameter, check out the next few sections.
Trading on Etherscan using 0x
Note: For Sets created after June 2022, please refer to the Batch Trading section on how to execute trades manually via Etherscan
Navigate to the TradeModule (Ethereum, Polygon) that you have already initialized on your Set. If you have not, refer to the Add a Module section
Connect your web3 wallet
Fill in the trade() details and click submit
tradeData is pulled from the data field from 0x API. Refer to 0x API section to fetch a quote
Last updated