> ## Documentation Index
> Fetch the complete documentation index at: https://docs.eco.com/llms.txt
> Use this file to discover all available pages before exploring further.

# 1inch (oneinch)

> DEX aggregator that routes swaps across multiple liquidity sources. Supports limit orders and Fusion mode for gasless swaps.

> [!NOTE]
>
> Archived documentation for `@eco-incorp/sauce@0.99.16`. Install this release with `npm install --save-exact @eco-incorp/sauce@0.99.16`. Links to guides outside this tab open current documentation.

DEX aggregator that routes swaps across multiple liquidity sources. Supports limit orders and Fusion mode for gasless swaps.

| Fact | Value |
| - | - |
| Category | Aggregators |
| Family | none |
| Namespace | `Oneinch` on ethereum, optimism, bsc, polygon, base, arbitrum, avalanche |
| Chains | ethereum, optimism, bsc, polygon, base, arbitrum, avalanche |

## When to use it

* An aggregator: its router fills a swap across many venues along a route its off-chain API
  quotes. Use it for a route the program does not want to choose itself.

## Pitfalls for a program

* The calldata is quoted for one sender, amount and moment: quote it for the Pot (the swap's
  sender) and send it soon.
* Approve the router for exactly `amountIn`, and clear the allowance after.
* The calldata's own minimum is not yours: check the output as a balance delta against your
  `minOut`.

## In a Sauce program

Forward a 1inch quote for the Pot, checked by the WETH received:

```ts theme={null}
function main(amountIn: Uint256, minOut: Uint256, call: bytes, recipient: Address) {
  const before = WETH.balanceOf(pot);
  USDC.approve(Oneinch.AggregationRouterV6, amountIn);
  evm.call(Oneinch.AggregationRouterV6, 0, call);
  const out = WETH.balanceOf(pot) - before;
  require(out >= minOut, "below minOut");
  USDC.approve(Oneinch.AggregationRouterV6, 0);
  WETH.transfer(recipient, out);
}
```

## What it offers

* **unoswap**: Single-source optimized swap via AggregationRouter
* **swap**: Multi-source aggregated swap with custom routing

## Notes

* Same contract address across all 7 chains
* V6 router is the latest version
* unoswap is gas-efficient for single-pool swaps; swap handles complex multi-hop routes
* `dex` in unoswap packs the pool address with its protocol and swap-direction flags in the high bits
* Fusion mode enables gasless swaps via order matching (off-chain, not in ABI)
* Approve srcToken to aggregationRouterV6 before swapping

## Its names in a program

On Ethereum, `Oneinch` is a namespace: its contracts need no import.

```ts theme={null}
function main() {
  // Ethereum's aggregationRouterV6, `0x111111125421cA6dc452d289314280a0f8842A65`.
  require(Oneinch.AggregationRouterV6 != 0);
}
```

## Deployments

| Chain | Contract | Address | In a program |
| - | - | - | - |
| [Ethereum](https://docs.eco.com/sauce-versions/0.99.16/sauce-sdk/reference/chains/ethereum.md) | aggregationRouterV6 | `0x111111125421cA6dc452d289314280a0f8842A65` | `Oneinch.AggregationRouterV6` |
| [Optimism](https://docs.eco.com/sauce-versions/0.99.16/sauce-sdk/reference/chains/optimism.md) | aggregationRouterV6 | `0x111111125421cA6dc452d289314280a0f8842A65` | `Oneinch.AggregationRouterV6` |
| [BNB Chain](https://docs.eco.com/sauce-versions/0.99.16/sauce-sdk/reference/chains/bsc.md) | aggregationRouterV6 | `0x111111125421cA6dc452d289314280a0f8842A65` | `Oneinch.AggregationRouterV6` |
| [Polygon](https://docs.eco.com/sauce-versions/0.99.16/sauce-sdk/reference/chains/polygon.md) | aggregationRouterV6 | `0x111111125421cA6dc452d289314280a0f8842A65` | `Oneinch.AggregationRouterV6` |
| [Base](https://docs.eco.com/sauce-versions/0.99.16/sauce-sdk/reference/chains/base.md) | aggregationRouterV6 | `0x111111125421cA6dc452d289314280a0f8842A65` | `Oneinch.AggregationRouterV6` |
| [Arbitrum One](https://docs.eco.com/sauce-versions/0.99.16/sauce-sdk/reference/chains/arbitrum.md) | aggregationRouterV6 | `0x111111125421cA6dc452d289314280a0f8842A65` | `Oneinch.AggregationRouterV6` |
| [Avalanche C-Chain](https://docs.eco.com/sauce-versions/0.99.16/sauce-sdk/reference/chains/avalanche.md) | aggregationRouterV6 | `0x111111125421cA6dc452d289314280a0f8842A65` | `Oneinch.AggregationRouterV6` |

## ABI

### `AggregationRouterV6ABI`

`import AggregationRouterV6ABI from "./protocols/oneinch/AggregationRouterV6ABI.json";` Speaks for: aggregationRouterV6.

* `swap(address executor, (address srcToken, address dstToken, address srcReceiver, address dstReceiver, uint256 amount, uint256 minReturnAmount, uint256 flags) desc, bytes data) payable returns (uint256 returnAmount, uint256 spentAmount)`
* `unoswap(uint256 token, uint256 amount, uint256 minReturn, uint256 dex) returns (uint256 returnAmount)`

## Next steps

* [Protocols](https://docs.eco.com/sauce-versions/0.99.16/sauce-sdk/reference/protocols.md): the other protocols, by what they do.
* [Protocols and tokens](https://docs.eco.com/sauce-versions/0.99.16/sauce/names.md): calling a contract by its namespace, or through its ABI.
* [Glossary](https://docs.eco.com/sauce-versions/0.99.16/sauce/glossary.md): the words these pages use, in plain terms.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.