Instadapp / instadapp-fluid

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

Contracts

Smart contractBlankCommentCode
contracts/protocols/dex/poolT1/coreModule/main.sol3544431297
contracts/protocols/dex/poolT1/coreModule/helpers.sol153577666
contracts/protocols/dex/poolT1/adminModule/main.sol114114517
contracts/protocols/dex/poolT1/adminModule/structs.sol161130
contracts/protocols/dex/poolT1/coreModule/immutableVariables.sol241379
contracts/protocols/dex/poolT1/common/constantVariables.sol15957
contracts/protocols/dex/poolT1/adminModule/events.sol196144
contracts/protocols/dex/poolT1/coreModule/structs.sol43234
contracts/protocols/dex/poolT1/coreModule/events.sol134915
contracts/protocols/dex/poolT1/common/variables.sol1210313
contracts/protocols/dex/poolT1/coreModule/interfaces.sol6167

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.

Contact Us

For any issues or concerns regarding this competition, please reach out to the Cantina core team through the Cantina Discord.

Summary

Status

Completed

Total reward:

$250,000

Findings submitted:

209

Start date:

11 Sep 2024 6:00pm (local time)

End date:

2 Oct 2024 8:00pm (local time)