-
Notifications
You must be signed in to change notification settings - Fork 23
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
minor optimisations #11
base: master
Are you sure you want to change the base?
Conversation
@@ -29,8 +29,13 @@ contract LlamaLendFactory is Ownable { | |||
} | |||
|
|||
function emergencyShutdown(address[] calldata pools) external onlyOwner { | |||
for(uint i = 0; i < pools.length; i++){ | |||
LendingPool(pools[i]).emergencyShutdown(); | |||
uint length = pools.length; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i expect to never call this method, and if i call it will be one-off so gas doesnt matter much
@@ -40,7 +40,7 @@ contract ListNfts { | |||
owner, | |||
balance | |||
); | |||
if (tokenId >= start && tokenId < end) { | |||
if (tokenId < end && tokenId >= start) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this contract is never called on-chain
@@ -101,7 +101,7 @@ contract LendingPool is OwnableUpgradeable, ERC721Upgradeable, Clone { | |||
} | |||
|
|||
function calculateInterest(uint priceOfNextItems) internal view returns (uint interest) { | |||
uint borrowed = priceOfNextItems/2 + totalBorrowed; | |||
uint borrowed = (priceOfNextItems >> 1) + totalBorrowed; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good point, does this have any side effects?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DIV
operator costs 5 gas while SHR
costs 3 gas, so that saves 2 gas. And if that's called multiple times it'd sure amount to much.
Minor changes were made that would save some gas. It's not much, but it's honest work.