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: 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 reverting with InvalidAmount if amount calculated is 0 and 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). Minor gas savings as contract size as result.t0DebtInAuctionChange != 0 is now performed only once
Issue 2: fix invariant failure due to inconsistent LUP calculation in PoolInfoUtils by updating addQuoteToken handler to use wdiv when calculating debt
Issue 3: fix invariant reserves failure on bucket take where first take penalty was applied to current borrower debt instead borrower t0 debt
Description of change
High level
Issue 1: bug in updating
t0DebtInAuction
when auction settled withrepayDebt
(A1
invariant violation)t0debtInAuction
accumulator wasn't updated, leaving it in an inconsistent stateInvalidAmount
if amount calculated is 0 and by always updatingt0debtInAuction
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). Minor gas savings as contract size asresult.t0DebtInAuctionChange != 0
is now performed only onceIssue 2: fix invariant failure due to inconsistent LUP calculation in PoolInfoUtils by updating
addQuoteToken
handler to usewdiv
when calculating debtIssue 3: fix invariant reserves failure on bucket take where first take penalty was applied to current borrower debt instead borrower t0 debt
Contract size
Pre Change
Post Change
Gas usage
Pre Change
Post Change