Skip to content

FLO-25: Dex Price Susceptible to Sandwich Attacks in Liquidation #234

Open

Description

@liobrasil

Severity: Low

Files Affected

  • cadence/contracts/FlowALPv1.cdc

Description

In the manualLiquidation() function, the DEX quote is fetched and compared in the same transaction. A sandwich attack can be executed where:

  • Front-run: Manipulate DEX pool to worsen its price.
  • Liquidation executes: DEX quote is artificially bad, so the liquidator's offer appears "better than DEX".
  • Back-run: Reverse manipulation for profit.

Recommendation

Use TWAP instead of spot quote, or use oracle price as the primary benchmark.


Parent Issue: #209

Activity

  1. holyfuchs commented on Mar 13, 2026

    @holyfuchs
    Contributor

    The oracle we are adding ensures the spread between sources (including the DEX) isn't too high; otherwise, it won't return a price. It also ensures short-term volatility isn't too high.

    Additionally, there is another assert in the function:

    assert(
    FlowALPMath.dexOraclePriceDeviationInRange(dexPrice: Pcd_dex, oraclePrice: Pcd_oracle, maxDeviationBps: self.config.getDexOracleDeviationBps()),
    message: "DEX/oracle price deviation too large. Dex price: \(Pcd_dex), Oracle price: \(Pcd_oracle)")

    A small sandwich attack is always possible. I don't think we should make any changes.

  2. self-assigned this
    on Mar 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions