ajna-finance / ajna-core

The Ajna protocol is a non-custodial, peer-to-peer, permissionless lending, borrowing and trading system that requires no governance or external price feeds to function.
https://www.ajna.finance/
Other
31 stars 11 forks source link

Include 1.04 COLLATERALIZATION_FACTOR #1021

Closed mattcushman closed 11 months ago

mattcushman commented 11 months ago

in neutral price used in kicks

Description

Include the COLLATERALIZATION_FACTOR in the computation of the neutral price.

Purpose

Resolves observation from Kirill that there are inconsistencies in how threshold price and derived quantities are computed. In particular, the neutral price was still be computed off the "raw" threshold price, meaning debt-to-collateral without the COLLATERALIZATION_FACTOR of 1.04 included. This resulted in unintentionally low neutral prices. This commit updates the toNpTpRatio to include that factor.

Impact

Gas

_kick: increase of 10K gas kickerInfo: increase of 400 borrowerInfo: increase of 100 gas

Tasks

ith-harvey commented 11 months ago

So the Loan.thresholdPrice still contains the unadjusted TP. I don't see any places where it's externally exposed, but the naming is confusing. Maybe it's worth renaming it to something like unadjustedThresholdPrice or similar, so it's harder to confuse it with all other things called TP in the code.

Same thing about Liquidation.thresholdPrice. It's exposed outside in auctionInfo and auctionStatus, so the same naming in NatSpec will also confuse integrators.

Apart from naming, LGTM

I second Kirill's concern... if we have the same naming convention but have a different equation applied to the value on the back end it is likely we may miss something.

mattcushman commented 11 months ago

How about renaming these debtToCollateral or similar?