# 1Inch

These connectors can be used to utilize 1INCH Dex services; you can calculate gas costs on-chain or calculate orders off-chain to save some gas.

#### Sell via On-Chain DEXs <a href="#sell-via-on-chain-dexs" id="sell-via-on-chain-dexs"></a>

Swap tokens from exchanges like kyber, uniswap etc. Calculation is done on-chain, with *high gas cost*.Copy

```
spells.add({
  connector: "oneInch",
  method: "sell",
  args: [buyAddr, sellAddr, sellAmt, unitAmt, getId, setId]
});
```

| Parameter  | Type    | Description                                 |
| ---------- | ------- | ------------------------------------------- |
| `buyAddr`  | address | The address of the token to buy.            |
| `sellAddr` | address | The address of the token to sell.           |
| `sellAmt`  | number  | The amount of the token to sell.            |
| `unitAmt`  | number  | The amount of buyAmt/sellAmt with slippage. |
| `getId`    | number  | ID fetches the amount of token to deposit.  |
| `setId`    | number  | ID stores the amount of token deposited.    |

#### Sell via DEXs with Off-Chain Calculation <a href="#sell-via-dexs-with-off-chain-calculation" id="sell-via-dexs-with-off-chain-calculation"></a>

Swap tokens from exchanges like kyber, uniswap etc, but with the calculation done off-chain, thus, with a lower gas cost.Copy

```
spells.add({
  connector: "oneInch",
  method: "sellTwo",
  args: [buyAddr, sellAddr, sellAmt, unitAmt, distribution, disableDexes, getId, setId]
});
```

| Parameter      | Type    | Description                                     |
| -------------- | ------- | ----------------------------------------------- |
| `buyAddr`      | address | The address of the token to buy.                |
| `sellAddr`     | address | The address of the token to sell.               |
| `sellAmt`      | number  | The amount of the token to sell.                |
| `unitAmt`      | number  | The amount of buyAmt/sellAmt with slippage.     |
| `distribution` | array   | The distribution of swap across different DEXs. |
| `disableDexes` | number  | To disable a dex. (To disable none: 0)          |
| `getId`        | number  | ID fetches the amount of token to deposit.      |
| `setId`        | number  | ID stores the amount of token deposited.        |

#### Sell via On-Chain and Off-Chain Exchanges <a href="#sell-via-on-chain-and-off-chain-exchanges" id="sell-via-on-chain-and-off-chain-exchanges"></a>

Swap tokens from exchanges like kyber, 0x etc, with calculation done off-chain.Copy

```
spells.add({
  connector: "oneInch",
  method: "sellThree",
  args: [buyAddr, sellAddr, sellAmt, unitAmt, callData, getId, setId]
});
```

| Parameter  | Type    | Description                                 |
| ---------- | ------- | ------------------------------------------- |
| `buyAddr`  | address | The address of the token to buy.            |
| `sellAddr` | address | The address of the token to sell.           |
| `sellAmt`  | number  | The amount of the token to sell.            |
| `unitAmt`  | number  | The amount of buyAmt/sellAmt with slippage. |
| `callData` | number  | This is the data from the 1inch API.        |
| `getId`    | number  | ID fetches the amount of token to deposit.  |
| `setId`    | number  | ID stores the amount of token deposited.    |
