Skip to content

optimizooor#7

Open
Nemusonaneko wants to merge 5 commits intoLlamaLend:masterfrom
Nemusonaneko:master
Open

optimizooor#7
Nemusonaneko wants to merge 5 commits intoLlamaLend:masterfrom
Nemusonaneko:master

Conversation

@Nemusonaneko
Copy link

No description provided.

@0xngmi
Copy link
Collaborator

0xngmi commented Oct 11, 2022

can you run a comparison of gas usage before and after your optimizations?

npm test test/lendingPool.js should give you gas costs

uint216 currentDailyBorrows; // would have to borrow more eth than will ever exist daily to break
uint40 lastUpdateDailyBorrows;
mapping(address => bool) public liquidators;
mapping(address => uint) public liquidators;
Copy link
Collaborator

Choose a reason for hiding this comment

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

have you verified that this is in fact cheaper? i think it should be but havent verified it

Copy link
Author

Choose a reason for hiding this comment

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

Saves 16168 gas on deployment and a whopping 12 gas on addLiquidator()

@Nemusonaneko Nemusonaneko marked this pull request as ready for review October 13, 2022 04:05
} else {
currentDailyBorrows = uint216(currentDailyBorrows - toReduce) + toAdd;
unchecked {
// Resulting daily borrow has to be over 10^47 ETH
Copy link
Collaborator

Choose a reason for hiding this comment

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

this is safu because we know toReduce <= currentDailyBorrows, so (currentDailyBorrows - toReduce) >= 0

Copy link
Author

Choose a reason for hiding this comment

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

llama agrees

@Nemusonaneko
Copy link
Author

wen merge

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants