Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Jun 28, 2023

Conversation

grandizzy
Copy link
Contributor

@grandizzy grandizzy commented Jun 21, 2023

Description of change

High level

(4 * (tu - mau) > 1e18 - ((tu + mau - 1e18) ** 2) / 1e18)

change to

(4 * (tu - mau) > 1e18 - ((tu + mau - 1e18) / 1e9) ** 2)

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 grandizzy changed the title Bug fix: Make decrease rate condition inline with increase condition Bug fix: PoolCommons._calculateInterestRate make decrease rate condition inline with increase condition Jun 21, 2023
@grandizzy grandizzy marked this pull request as ready for review June 21, 2023 15:07
Copy link
Contributor

@ith-harvey ith-harvey left a comment

Choose a reason for hiding this comment

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

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?

@grandizzy
Copy link
Contributor Author

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 23e7485#diff-f180a783f7f398e0540bb5a9fee461cbec2f970bdd423c904b5e12c6ec69c325R286 but not for the else clause

@grandizzy grandizzy changed the title Bug fix: PoolCommons._calculateInterestRate make decrease rate condition inline with increase condition Sherlock-104: PoolCommons._calculateInterestRate make decrease rate condition inline with increase condition Jun 24, 2023
Copy link
Contributor

@ith-harvey ith-harvey left a comment

Choose a reason for hiding this comment

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

LGTM

The links that summarize the issue may die... please copy and paste the issue into the description directly

@grandizzy
Copy link
Contributor Author

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

Copy link
Contributor

@EdNoepel EdNoepel left a comment

Choose a reason for hiding this comment

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

Reviewed the original change to line 294, scaling before squaring, to prevent overflow. This appears consistent with that change, as stated.

@grandizzy grandizzy merged commit 7228f92 into develop Jun 28, 2023
@grandizzy grandizzy deleted the interest-rate-calc branch July 12, 2023 13:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants