---
# System prepended metadata

title: 'Fluid Dex: Liquidity source integration'

---

# Fluid Dex: Liquidity source integration

**Proposal Title:**
Integrating Fluid Dex swaps as a Liquidity Source on CoW Swap

**Author:** **Instadapp*,* [dev@instadapp.io](mailto:dev@instadapp.io)

**Simple summary**
We propose integrating Fluid Dex swaps as a new liquidity source for CoW Swap.

**Motivation**
Adding Fluid Dex swaps as a liquidity source to CoW Swap offers several benefits:

1. Best liquidity: On launch (by Oct 29), we will have wstETH-ETH, USDC-USDT, and cbBTC-WBTC pools. Within one week of launch, we expect to take over 20-40% of trading market shares among these pairs, with more DEX pools coming soon. We will have the deepest liquidity for the wstETH-ETH pool right on launch.
2. Easy Integration: Simple contract calls and payload building process through our resolver contracts.
3. Gas Efficiency: Swaps cost approximately 90k to 145k gas.
4. Arbitrage Opportunities: Can be leveraged with other DEXes for arbitrage setups.
5. Mathematical Consistency: Fluid Dex utilizes the x * y = k constant product formula (similar to Uniswap v2)

**Specification**
1. Liquidity Fetching: DexResolver or DexReservesResolver provides each pool's reserves amounts.
2. Price estimation: DexResolver provides `estimate()` methods for all types of swaps. Alternatively, we have Fluid Dex math logic replication libraries for JS, TS, and Golang. 
3. On-chain settlement: execute the `swapIn()` (or `swapOut`) method at the respective Dex pool. 

Resolver addresses (Dex is mainnet only for now):
- DexResolver: `0x7af0C11F5c787632e567e6418D74e5832d8FFd4c`
- DexReservesResolver: `0xE8a07a32489BD9d5a00f01A55749Cf5cB854Fd13`

Triggers for liquidity fetching should be:
1. events: either _any_ event at a pool OR the LogOperate event at the Liquidity Layer (`0x52Aa899454998Be5b000Ad077a46Bbe360F4e497`) filtered by user == pool addresses.
2. in addition also trigger if no event happened in the last 5 to max 10 minutes at a pool (otherwise there is some important internal pricing logic not accounted for)

Additional references:
- Public repo: [https://github.com/Instadapp/fluid-contracts-public/tree/main/contracts/protocols/dex](https://github.com/Instadapp/fluid-contracts-public/tree/main/contracts/protocols/dex). - Resolvers in public repo: [https://github.com/Instadapp/fluid-contracts-public/blob/main/contracts/periphery/resolvers/dexReserves/main.sol](https://github.com/Instadapp/fluid-contracts-public/blob/main/contracts/periphery/resolvers/dexReserves/main.sol) 
- Reference implementation Kyber: [https://github.com/KyberNetwork/kyberswap-dex-lib/tree/main/pkg/liquidity-source/fluid/dex-t1](https://github.com/KyberNetwork/kyberswap-dex-lib/tree/main/pkg/liquidity-source/fluid/dex-t1) (includes Golang code for replicating Fluid Dex Math) 
- Reference implementation Paraswap: [https://github.com/paraswap/paraswap-dex-lib/tree/master/src/dex/fluid-dex](https://github.com/paraswap/paraswap-dex-lib/tree/master/src/dex/fluid-dex) (includes TS code for replicating the Fluid Dex Math) 
- general Fluid docs: [https://docs.fluid.instadapp.io/introduction/contracts-overview](https://docs.fluid.instadapp.io/introduction/contracts-overview) 
- Dex blog post: [https://blog.instadapp.io/fluid-dex/](https://blog.instadapp.io/fluid-dex/) 
- Dex math derivations [https://app.excalidraw.com/l/12EMdhpNZfV/1jzaWnLnu4H](https://app.excalidraw.com/l/12EMdhpNZfV/1jzaWnLnu4H)

**Additional details***[Information about potential integration grants, if applicable]*

**Contact:** Discord ****[https://discord.com/invite/C76CeZc](https://discord.com/invite/C76CeZc)