Skip to content

minor optimisations#11

Open
0xbyte0 wants to merge 3 commits intoLlamaLend:masterfrom
0xbyte0:dev/0xosas
Open

minor optimisations#11
0xbyte0 wants to merge 3 commits intoLlamaLend:masterfrom
0xbyte0:dev/0xosas

Conversation

@0xbyte0
Copy link
Copy Markdown

@0xbyte0 0xbyte0 commented Nov 8, 2022

Minor changes were made that would save some gas. It's not much, but it's honest work.

function emergencyShutdown(address[] calldata pools) external onlyOwner {
for(uint i = 0; i < pools.length; i++){
LendingPool(pools[i]).emergencyShutdown();
uint length = pools.length;
Copy link
Copy Markdown
Collaborator

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

Comment thread contracts/ListNfts.sol
balance
);
if (tokenId >= start && tokenId < end) {
if (tokenId < end && tokenId >= start) {
Copy link
Copy Markdown
Collaborator

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

Comment thread contracts/LendingPool.sol

function calculateInterest(uint priceOfNextItems) internal view returns (uint interest) {
uint borrowed = priceOfNextItems/2 + totalBorrowed;
uint borrowed = (priceOfNextItems >> 1) + totalBorrowed;
Copy link
Copy Markdown
Collaborator

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?

Copy link
Copy Markdown
Author

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.

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