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

Fix/engine lending #103

Merged
merged 3 commits into from Jun 28, 2021
Merged

Fix/engine lending #103

merged 3 commits into from Jun 28, 2021

Conversation

Alexangelj
Copy link
Contributor

Changelog:

  • Removes balanceRisky and balanceStable from Position.Data struct. This is because, our debt value is also our balanceRisky. And balanceStable was never used. This saves 50% gas.
  • Adds price impact checks to borrow function. Borrow function has a maxPremium parameter, which is important, because it will make sure a user does not overpay for their options, which can happen if the LP composition changes while their order is pending. The price impact check will guarantee a maxPremium to be paid, and revert otherwise.
  • Adds the return parameter premium to borrow. The premium is the difference between the amount of lp shares borrowed, and the risky tokens released from removing liquidity.
  • Refactors the Borrow and Repay functions in the Engine, by re-arranging how state changes take place.
  • Adds unit tests (mostly fail cases) for borrow. Need to add a unit test file for repay.

Note: State changes in these functions are critical, they should be analyzed further.

@Alexangelj Alexangelj requested a review from kinrezC June 28, 2021 03:26
@Alexangelj Alexangelj merged commit 43ef720 into develop Jun 28, 2021
@clemlak clemlak deleted the fix/engine-lending branch June 29, 2021 13:07
Alexangelj added a commit that referenced this pull request Mar 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant