Skip to content

[BUG] UniswapV3SwapConnectors applies unexpected additional slippage on top of user-specified minimum #61

@liobrasil

Description

@liobrasil

Current Behavior

The _swapExactIn() function in UniswapV3SwapConnectors applies an additional hardcoded 1% slippage reduction on top of the amountOutMin parameter that callers already provide.

Code location: Lines ~651 in UniswapV3SwapConnectors.cdc

// Slippage/min out on EVM units (adjust factor to your policy)
let slippage = 0.01 // 1%
let minOutUint = FlowEVMBridgeUtils.convertCadenceAmountToERC20Amount(
    amountOutMin * (1.0 - slippage),
    erc20Address: outToken
)

Expected Behavior

The function should respect the amountOutMin parameter as provided by the caller without applying additional slippage. Callers are responsible for calculating their own acceptable slippage tolerance.

Problem

This creates double slippage protection:

Example Scenario

  1. User queries swap: 100 USDC → ~50 FLOW
  2. User accepts 2% slippage: minAcceptable = 50.0 * 0.98 = 49.0 FLOW
  3. User calls swap() with amountOutMin = 49.0
  4. Contract applies extra 1%: 49.0 * 0.99 = 48.51 FLOW
  5. Result: Total slippage is ~2.98% instead of the user's intended 2%

What are you currently working on that this is blocking?

No response

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions