Skip to content
This repository has been archived by the owner on Aug 26, 2024. It is now read-only.

Swap hub #24

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Swap hub #24

wants to merge 3 commits into from

Conversation

dglowinski
Copy link
Contributor

  1. Execute all swaps on the new swap-hub module
  2. Use back-end deployed Uniswap Auto Router in place of FE integration
  3. Fix combined quotes failing and improve max amounts on repay with deposits.

Ad 1. All swaps are now performed through SwapHub and Uni Auto Router and 1inch handlers without any functional changes in UI. Test all possible combinations of swaps, swap and repay, short. Use token with varying decimals as input and output. Use 1inch / Uni protocols. In the latter case both exact input and output. SwapHub should also remove all issues around swapping stETH specifically on both protocols.

Ad 2. Instead of including the auto router through npm in FE, a new route is deployed in API providing the uni quotes. No extra items to test.

Ad 3. Fixes an issue with caclulating swap quotes when price impact is much larger on Uniswap than 1Inch, in which case 5 iterations of 1inch quoting in fetchCombinedQuote might not be enough to arrive at the solution. The fix is to first try swapping 1 unit of token on 1inch instead of the full amount and use the result as a price.

red coloring on available deposit if it is less than the amount required by the swap

when repaying using deposit, when the value of the deposit selected for a swap is less than the value of debt, the max button on the slider will set a full amount of the deposit to be used for repay. Under the hood, instead of calling swapAndRepay function, in this scenario a swap and burn max are added to the batch.
Edge case: the debt is self collateralized. In this case burn max would not only burn the amount received through the swap, but also as much of self collateral as possible (depending on the size of the debt). To avoid this, in case of self-collateralized debt, the swapAndRepay function is called as usual, but the max value on the slider is only approximated (vs used exactly) to match the value of available deposit.

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

Successfully merging this pull request may close these issues.

1 participant