Skip to content

Conversation

@Ryang-21
Copy link
Collaborator

  • Implement search for minimum auction size that results in targeted user health factor

@Ryang-21 Ryang-21 requested a review from mootz12 April 30, 2025 17:54
Copy link
Contributor

@mootz12 mootz12 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good - mostly picky comments and a few additional test cases that would be helpful

Comment on lines 147 to 149
// The factor by which we can reduce the liabilities
let liabilityReductionFactor = avgLF * 1.06 - avgCF * estIncentive;
let totalRemoveableLiabilities = liabilityReductionFactor * positions.totalBorrowed;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

liabilitiesToReduce -> excessBorrowed
liabilityReductionFactor -> borrowLimitFactor
totalRemoveableLiabilities -> totalBorrowLimitRecovered

might be clearer names?

if (liqPercent === 0) {
let nextLiability = effectiveLiabilities.shift();
if (nextLiability === undefined) {
// No more collaterals to liquidate
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we just make the assumption here that the full position needs to be liquidated?

If we have included all the liabilities and the liq percent is complaining that we still don't have enough liabilities to liquidate, the whole position can be liquidated at 100% right?

FWIW this is probably a code path that is never really hit, given the collateral would get flagged as not being sufficient first, and return a 101 liq percent.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think that assumption can be made because an asset with a low cf can be added which then increases the reduction factor and could make the liquidation possible

userEstimate.totalSupplied = 2000;
const result = calculateLiquidationPercent(userEstimate);
expect(Number(result)).toBe(56);
it('should find auction subset with partial auction', () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should add a test for the 1 to 1 happy path at both a partial percentage and the full percentage

@mootz12 mootz12 self-requested a review May 2, 2025 14:28
@Ryang-21 Ryang-21 merged commit da71c8e into main May 4, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants