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.
Issue 1 : LUP index calculated in PoolUtils can differ from the Pool calculated LUP index, due to inconsistent rounding. Also, the Debt calculated in contracts was inconsistent in terms of roundup and round to nearest. This caused mismatched values in the PoolInfoUtils and invariants.
Fixed by updating all debt calculations to always round up.
Issue 2: Fixing issue 1 in PR #876 uncovered bug in updating t0DebtInAuction when auction settled with repayDebt (A1 invariant violation)
auction was settled but the quote token amount calculated to repay was rounded down to 0
since t0 debt in auction accumulator was updated only when token amount to repay was not 0, the t0debtInAuction accumulator wasn't updated, leaving it in an inconsistent state
Fixed by always updating t0debtInAuction accumulator when there's a t0 auction debt change and not constrained by the amount of quote tokens to be paid (same applied in case of pledged collateral too): 07e81d5
Description of change
High level
Issue 1 :
LUP
index calculated inPoolUtils
can differ from thePool
calculatedLUP
index, due to inconsistent rounding. Also, the Debt calculated in contracts was inconsistent in terms of roundup and round to nearest. This caused mismatched values in thePoolInfoUtils
andinvariants
.Issue 2: Fixing issue 1 in PR #876 uncovered bug in updating
t0DebtInAuction
when auction settled withrepayDebt
(A1
invariant violation)t0debtInAuction
accumulator wasn't updated, leaving it in an inconsistent statet0debtInAuction
accumulator when there's a t0 auction debt change and not constrained by the amount of quote tokens to be paid (same applied in case of pledged collateral too): 07e81d5Contract size
Pre Change
Post Change