Notice: For Sets created before June 2022 using TokenSets UI and not migrated to the Batch Trading system, please refer to the Trading section on how to execute trades manually via Etherscan
What is the BatchTradingExtension:
The BatchTradingExtension .
Initializing the BatchTradingExtension:
Note: You MUST have TradeModule initialized and the Set Manager set to your DelegatedManager address to use the BatchTradingExtension.
Due to the complexities of initializing, if you have not initialized the batch trading extension already, we recommend using the TradeModule directly
Batch Trading:
Only the operator will be able to trade. Call the trade function with inputs as follows:
Important: sendQuantityand_minReceiveQuantityare 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.
struct TradeInfo { string exchangeName; // Human readable name of the exchange in the integrations registry address sendToken; // Address of the token to be sent to the exchange uint256 sendQuantity; // Max units of `sendToken` sent to the exchange address receiveToken; // Address of the token that will be received from the exchange uint256 receiveQuantity; // Min units of `receiveToken` to be received from the exchange bytes data; // Arbitrary bytes to be used to construct trade call data}/** * ONLY OPERATOR: Executes a batch of trades on a supported DEX. If any individual trades fail, events are emitted. * @dev Although the SetToken units are passed in for the send and receive quantities, the total quantity * sent and received is the quantity of component units multiplied by the SetToken totalSupply. * * @param _setToken Instance of the SetToken to trade * @param _trades Array of TradeInfo structs containing information about trades */functionbatchTrade( ISetToken _setToken, TradeInfo[] memory _trades)
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.
Batch Trading on Etherscan using 0x
Notice: For Sets created before June 2022 using TokenSets UI and not migrated to the Batch Trading system, please refer to the Trading section on how to execute trades manually via Etherscan
Navigate to the BatchTradingExtension (Ethereum, Polygon) that you have already initialized on your Set
Connect your web3 wallet
Fill in the batchTrade() details and click submit
The TradeInfo struct looks exactly like the inputs into the TradeModule directly. You can format the struct like this in etherscan