Instadapp / instadapp-fluid
Fluid DEX protocol is a novel protocol that is built on top of the Liquidity Layer and introduces Smart Debt and Smart Collateral. By enabling the debt as trading liquidity, Fluid DEX generates up to $39 in DEX LP per $1 in TVL, making it the most capital-efficient and scalable decentralized exchange.
Range Order
The DEX protocol will be similar to a combination of Uniswap v2 and Uniswap v3 — single auto rebalancing range order UX like Uniswap v2 and concentration like Uniswap v3.
Pool aka “range order” can be of any size, have any fee, and any proportion. For example, for pairs like ETH-wstETH, 80% of liquidity can be in ETH and 20% in wstETH, for pairs like ETH-WBTC, 50% of liquidity can be in ETH & 50% can be in WBTC, etc.
Smart Collateral
Smart Collateral is a single range order that enables users to multipurpose their capital, using it as collateral to borrow against it, lend it, and deploy it as AMM liquidity on the DEX to earn trading and lending fees simultaneously.
Smart Debt
Smart Debt allows the debt to be turned into a productive asset by using debt as trading liquidity, therefore earning trading fees that offset the cost of capital incurred by borrowing (APR). Smart debt can be considered as the inverse of any AMM pool.
For a more detailed insight into the DEX protocol, here’s the announcement thread on X.
For the understanding of the overall protocol here.
Derivation of DEX formulas here.
Prize distribution and scoring
-
Total Prize Pool: $250,000
-
Primary Prize Pool: $240,000
-
The prize distribution has 2 possible triggers:
- If one or more valid medium severity findings are found, the total pot size is $50,000
- If one or more valid high severity findings are found, the total pot size is $250,000
-
$10,000 of the prize pot is reserved for Low Severity findings. These reports are judged based on quality and reviewers are then ranked from 1st to 5th for the purpose of prize allocation.
- 1st: $5k
- 2nd: $2.5k
- 3rd: $1.5k
- 4th: $650
- 5th: $650
-
Scoring described in the competition scoring page.
-
Findings Severities described in detail on our docs page.
Documentation
Scope
- Repository: https://github.com/Instadapp/fluid-contracts-public/tree/main/contracts/protocols/dex/poolT1
- Commit:
91d584268bc05d4d73d51c167ed5de87c03d52b2
Contracts
Smart contract | Blank | Comment | Code |
---|---|---|---|
contracts/protocols/dex/poolT1/coreModule/main.sol | 354 | 443 | 1297 |
contracts/protocols/dex/poolT1/coreModule/helpers.sol | 153 | 577 | 666 |
contracts/protocols/dex/poolT1/adminModule/main.sol | 114 | 114 | 517 |
contracts/protocols/dex/poolT1/adminModule/structs.sol | 16 | 1 | 130 |
contracts/protocols/dex/poolT1/coreModule/immutableVariables.sol | 24 | 13 | 79 |
contracts/protocols/dex/poolT1/common/constantVariables.sol | 15 | 9 | 57 |
contracts/protocols/dex/poolT1/adminModule/events.sol | 19 | 61 | 44 |
contracts/protocols/dex/poolT1/coreModule/structs.sol | 4 | 32 | 34 |
contracts/protocols/dex/poolT1/coreModule/events.sol | 13 | 49 | 15 |
contracts/protocols/dex/poolT1/common/variables.sol | 12 | 103 | 13 |
contracts/protocols/dex/poolT1/coreModule/interfaces.sol | 6 | 16 | 7 |
Build Instructions
npm i forge install forge test \--match-path test/foundry/dex/poolT1/poc.t.sol
Out of scope
- Issues described in-code comments.
- Issues related to the pool being inactive. No swap for more than 12hrs.
- Excess rebalancing of center price without regular swaps might result in losses for LP.
- Main scope for DEX will be Ethereum mainnet. For other EVM chains, severity should be considered low/medium.
- Issues related to governance/admin settings, configs are all set through adminModule/main.sol, including but not limited to:
- Small time for range change.
- Small time for threshold change.
- Center price rebalancing configs.
- Setting small withdrawal/borrowing percents
- Huge withdrawal/borrowing limit time shift
- Lack of initial shares minting upon pool initialization.
- Wrong address set for center price or hook.
- Center price min/max limits.
- Issues related to non-standard tokens and their behaviors (i.e. weird-tokens).
- Tokens whose balances increase over time, such as stETH or eETH, will not be listed in DEX.
- Fees in case of improper actions: deposit(), withdraw(), borrow(), payback(), withdrawInOneToken(), paybackInOneToken() is charged on the whole amount rather than only to the amount which is swapped.
- Smart collateral & smart debt will be used via Vault Type 2, 3 & 4, currently on the public repo on Vault Type 1 is live here. Vault Type 1 is live on prod for many months: https://fluid.instadapp.io/vaults/1. Other vault types will use the exact same algorithm with the update related to DEX interaction (in place of liquidity layer interaction). Vaults are as follows:
- Vault Type 1: Normal collateral, normal debt.
- Vault Type 2: Smart collateral, normal debt.
- Vault Type 3: Normal collateral, smart debt.
- Vault Type 4: Smart collateral, smart debt.
- Smallest fee that a pool can have is 0.0001% and the pool will always be set with a fee. Cases will fee as 0% should be considered under low severity.
- Last stored price after swap & current pool price before swap can be slightly different due to rebalancing or interest accrual.
- Automated findings by Lightchaser
Contact Us
For any issues or concerns regarding this competition, please reach out to the Cantina core team through the Cantina Discord.
Summary
Status
CompletedTotal reward:
$250,000
Findings submitted:
209
Start date:
11 Sep 2024 6:00pm (local time)
End date:
2 Oct 2024 8:00pm (local time)