-
Notifications
You must be signed in to change notification settings - Fork 2
[DRAFT] Implement manual liquidation path #77
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
base: main
Are you sure you want to change the base?
Conversation
|
|
||
| // Ensure liquidation amounts don't exceed position amounts | ||
| let Nc = positionView.trueBalance(ofToken: seizeType) // number of collateral tokens (true balance) | ||
| let Nd = positionView.trueBalance(ofToken: debtType) // number of debt tokens (true balance) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
trueBalance always uses the snapshot's creditIndex. Should this use the debitIndex here?
| self.creditInterestIndex = FlowCreditMarketMath.one // TODO: hard-coded to 1? | ||
| self.debitInterestIndex = FlowCreditMarketMath.one // TODO: hard-coded to 1? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here and below: FlowCreditMarketMath.one is deprecated, just use the literal:
| self.creditInterestIndex = FlowCreditMarketMath.one // TODO: hard-coded to 1? | |
| self.debitInterestIndex = FlowCreditMarketMath.one // TODO: hard-coded to 1? | |
| self.creditInterestIndex = 1.0 | |
| self.debitInterestIndex = 1.0 |
| let trueBalance = FlowCreditMarket.scaledBalanceToTrueBalance( | ||
| balance.scaledBalance, | ||
| interestIndex: tokenSnapshot.creditIndex | ||
| ) | ||
| return trueBalance |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| let trueBalance = FlowCreditMarket.scaledBalanceToTrueBalance( | |
| balance.scaledBalance, | |
| interestIndex: tokenSnapshot.creditIndex | |
| ) | |
| return trueBalance | |
| return FlowCreditMarket.scaledBalanceToTrueBalance( | |
| balance.scaledBalance, | |
| interestIndex: tokenSnapshot.creditIndex | |
| ) |
Also see below: Maybe there should be two functions, or make it more obvious in the function name that the creditIndex is used and not debitIndex
Closes: #???
Description
Implements a manual liquidation path. Anyone is allowed to perform a liquidation under the following circumstances:
Notes for reviewers while in draft state
The skeleton of the implementation is largely complete, but this lacks tests, and proper documentation in some places.
SwapperProviderto represent a DEX. We need to add an implementation of SwapperProvider that can be used.manualLiquidationand_doLiquidationFor contributor use:
masterbranchFiles changedin the Github PR explorer