Fujicracy / fuji-v2

Cross-chain money market aggregator
https://fuji-v2-frontend.vercel.app
15 stars 10 forks source link

[Epic] Slippage #242

Closed brozorec closed 1 year ago

brozorec commented 1 year ago

Context

When bridging assets over Connext, there's a high chance the user doesn't receive the exact amount they inputted. This is due to the slippage, as Connext uses a stableswap AMM internally.

Here's what happens in the background when a user wants to bridge USDC:

User USDC -> srcChain AMM (USDC/nextUSDC) -> bridge nextUSDC -> destChain AMM (nextUSDC/USDC) -> User USDC

The slippage occurs when we swap from USDC to nextUSDC.

How does this affect us?

While designing the smart contracts and the UI, we assumed that the user would get the exact amount on the destination chain. Now we have to consider the slippage. We need to explicitly inform the user about the slippage and allow them to control it.

Btw, the slippage shouldn't surprise any DeFi user, as this is a common situation, mostly when performing swaps.

Todo

Explanations

More info on slippage and price impact in AMMs: https://academy.shrimpy.io/post/what-is-slippage-how-to-avoid-slippage-on-defi-exchanges

brozorec commented 1 year ago

Do not allow near liquidation deposit-and-borrow operation.

If the user has a higher slippage tolerance and borrows close to the liquidation threshold (inputs near max LTV borrowing position), this may result in a situation of immediate liquidation. We should avoid such possibilities at least from "ordinary-front-end" user interactions.

A possible solution could be that we display a warning pop-up before submitting the tx.