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

Sherlock-104: `PoolCommons._calculateInterestRate` make decrease rate condition inline with increase condition #903

Closed grandizzy closed 1 year ago

grandizzy commented 1 year ago

Description of change

High level

Contract size

Pre Change

PoolCommons              -   9,082B  (36.95%)

Post Change

PoolCommons              -   9,086B  (36.97%)

Gas usage

Pre Change

| updateInterest                       | 57081           | 122919 | 112150 | 413480 | 284     |
| updateInterest                         | 138992          | 193642 | 147298 | 417497   | 14      |

Post Change

| updateInterest                       | 57081           | 122919 | 112150 | 413480 | 284     |
| updateInterest                         | 138992          | 193642 | 147298 | 417497   | 14      |
grandizzy commented 1 year ago

I agree that the proposed change matches how we are performing an increase. Am curious to know the reason behind this change or the why.

Is it because this code was not inline with the spec?

this was changed in order to allow greater values / avoid overflow for the if clause with https://github.com/ajna-finance/contracts/commit/23e74852ffde8e32d2f490d5787bf7f899fc6966#diff-f180a783f7f398e0540bb5a9fee461cbec2f970bdd423c904b5e12c6ec69c325R286 but not for the else clause

grandizzy commented 1 year ago

I agree that the proposed change matches how we are performing an increase. Am curious to know the reason behind this change or the why.

Is it because this code was not inline with the spec?

updated