# TradeModule

The Trade Module is a module that enables SetTokens to perform atomic trades using DEXs such as Uniswap, Sushiswap and 1inch. Integrations mappings are stored on the IntegrationRegistry contract.

### Select Methods <a href="#select-methods" id="select-methods"></a>

#### trade() <a href="#trade" id="trade"></a>

`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() <a href="#initialize" id="initialize"></a>

`function initialize(ISetToken _setToken)`**Manager only.** Initializes this module to the SetToken.

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


---

# Agent Instructions: 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:

```
GET https://vingt-io.gitbook.io/vingt.io/technical-guide/visp-technical-foundation/contract-functions/trademodule.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
