From 76cf591d285ce033b2bc79b181db15cb46dd8397 Mon Sep 17 00:00:00 2001 From: 0xosas Date: Tue, 8 Nov 2022 19:29:47 +0100 Subject: [PATCH 1/3] change to loop convention --- contracts/LlamaLendFactory.sol | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/contracts/LlamaLendFactory.sol b/contracts/LlamaLendFactory.sol index 31daa68..249276f 100644 --- a/contracts/LlamaLendFactory.sol +++ b/contracts/LlamaLendFactory.sol @@ -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; + uint i = 0; + while(i < length){ + LendingPool(pools[i]).emergencyShutdown(); + unchecked { + i++; + } } } @@ -51,4 +56,4 @@ contract LlamaLendFactory is Ownable { } receive() external payable {} -} \ No newline at end of file +} From db692119aec0320f391053a754d5d90136ce4f7b Mon Sep 17 00:00:00 2001 From: 0xosas Date: Tue, 8 Nov 2022 19:36:49 +0100 Subject: [PATCH 2/3] short-circuiting :zap: --- contracts/ListNfts.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contracts/ListNfts.sol b/contracts/ListNfts.sol index 97ee53b..abd1c55 100644 --- a/contracts/ListNfts.sol +++ b/contracts/ListNfts.sol @@ -40,7 +40,7 @@ contract ListNfts { owner, balance ); - if (tokenId >= start && tokenId < end) { + if (tokenId < end && tokenId >= start) { nfts[length] = tokenId; unchecked { // unchecked: always less than end minus start From 50f07ab2e7e7ad18ea9d1ab6ec7dd3e3a54e1680 Mon Sep 17 00:00:00 2001 From: 0xosas Date: Tue, 8 Nov 2022 19:44:52 +0100 Subject: [PATCH 3/3] minor optimization :zap: --- contracts/LendingPool.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contracts/LendingPool.sol b/contracts/LendingPool.sol index ce2bd0b..f68a544 100644 --- a/contracts/LendingPool.sol +++ b/contracts/LendingPool.sol @@ -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; uint variableRate = (borrowed * maxVariableInterestPerEthPerSecond) / (address(this).balance + totalBorrowed); return minimumInterest + variableRate; }