> For the complete documentation index, see [llms.txt](https://docs.indexcoop.com/index-coop-community-handbook/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.indexcoop.com/index-coop-community-handbook/protocol/index-protocol/modules/trade-module.md).

# Trade Module

The **TradeModule** ([Etherscan](https://etherscan.io/address/0xfaab3f8f3678f68aa0d307b66e71b636f82c28bf)) is a module that enables [SetTokens](/index-coop-community-handbook/protocol/index-protocol/core-contracts/set-token.md) to perform atomic trades using DEXs and DEX aggregators such as Uniswap, Curve, Balancer and 0x. Integrations mappings are stored on the [IntegrationRegistry](/index-coop-community-handbook/protocol/index-protocol/core-contracts/integration-registry.md) contract.

## Select Methods

### trade()

`function trade(ISetToken _setToken, string memory _exchangeName, address _sendToken, uint256 _sendQuantity, address _receiveToken, uint256 _minReceiveQuantity, bytes memory _data)`

**Manager only**. Executes a trade on a supported DEX. Only callable by the SetToken's manager. Although the SetToken units are passed in for the send and receive quantities, the total quantity sent and received is the quantity of SetToken units multiplied by the SetToken `totalSupply`.

| Parameter Name       | Type      | Description                                                      |
| -------------------- | --------- | ---------------------------------------------------------------- |
| \_setToken           | ISetToken | Instance of the SetToken                                         |
| \_exchangeName       | string    | Human readable name of the exchange in the integrations registry |
| \_sendToken          | address   | Address of the token to be sent to the exchange                  |
| \_sendQuantity       | uint256   | Units of token in SetToken sent to the exchange                  |
| \_receiveToken       | address   | Address of the token that will be received from the exchange     |
| \_minReceiveQuantity | uint256   | Min units of token in SetToken to be received from the exchange  |
| \_data               | bytes     | Arbitrary bytes to be used to construct trade call data          |

### initialize()

`function initialize(ISetToken _setToken)`

**Manager only.** Initializes this module to the SetToken.

| Parameter Name | Type      | Description             |
| -------------- | --------- | ----------------------- |
| \_setToken     | ISetToken | Address of the SetToken |


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.indexcoop.com/index-coop-community-handbook/protocol/index-protocol/modules/trade-module.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
