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

optimizooor #7

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open

optimizooor #7

wants to merge 5 commits into from

Conversation

Nemusonaneko
Copy link

No description provided.

@0xngmi
Copy link
Member

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

uint40 lastUpdateDailyBorrows;
mapping(address => bool) public liquidators;
mapping(address => uint) public liquidators;
Copy link
Member

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()

contracts/LendingPool.sol Outdated Show resolved Hide resolved
contracts/LendingPool.sol Outdated Show resolved Hide resolved
contracts/LendingPool.sol Outdated Show resolved Hide resolved
@Nemusonaneko Nemusonaneko marked this pull request as ready for review October 13, 2022 04:05
@@ -72,7 +72,11 @@ contract LendingPool is OwnableUpgradeable, ERC721Upgradeable, Clone {
if(toReduce > currentDailyBorrows){
currentDailyBorrows = toAdd;
} else {
currentDailyBorrows = uint216(currentDailyBorrows - toReduce) + toAdd;
unchecked {
// Resulting daily borrow has to be over 10^47 ETH
Copy link
Member

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