Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Epic] Slippage #242

Closed
4 tasks done
brozorec opened this issue Jan 11, 2023 · 1 comment
Closed
4 tasks done

[Epic] Slippage #242

brozorec opened this issue Jan 11, 2023 · 1 comment

Comments

@brozorec
Copy link
Contributor

brozorec commented Jan 11, 2023

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

  • [SC] on xReceive, amounts in DEPOSIT and PAYBACK actions will be different than the actual received amount that makes calls to the vault fail @daigarocota : Refer to ConnextRouter bridging slippage #253
  • [Design] Adapt borrow and manage position forms to include control of the slippage and ideally the price impact @Markoyw
  • [SDK] Include methods for calculating the slippage and the price impact @brozorec
  • [FE] Implement the designs above and make changes to some of the SDK methods: Refer to Borrow: Slippage settings #336

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
Copy link
Contributor Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants