Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation
TCR-11 In the Sigma Prime audit report listed numerous gas saving changes that should be made.
Changes
LeveragedPool
uint256(
castfunction getUpkeepInformation() external view override returns (int256 _latestPrice, uint256 _lastPriceTimestamp, uint256 _updateInterval)
PoolKeeper
to avoid three separate external callsgetOraclePrice
external
PoolCommitter
LeveragedPool.tokens
locally, to save external calls on these.setQuoteAndPool
is called.executeAllCommitments
,nextEarliestCommitUnexecuted
was always being set to equali
at the start of each iteration. May as well just removei
.SLOAD
oflatestCommitUnexecuted
each loop (it is checked inside thefor
statement, and used inside the block). This was removed and justSLOAD
'ed once at the start of the function.getCommit
externalPoolFactory
pairTokenBase
andpoolBase
immutable.pool.initialize(initialization);
abovepoolCommitter.setQuoteAndPool
so thatLeveragedPool.tokens
is initialised beforesetQuoteAndPool
, allowing this function to saveLeveragedPool.tokens
.PoolKeeper
LeveragedPool.getOraclePrice
innewPool
instead of 1) fetching oracleWrapper then 2) fetching price from oracleWrappergetUpkeepInformation
inperformUpkeepSinglePool
.PoolSwapLibrary
getBalancesAfterFees
andcalculatePriceChange
external.getLossMultiplier
, a Ternary can be used to save from confusing logic and extra mathematical operations.calculatePriceChange
, A line can be removed which setstotalFeeAmount
right before setting it again two lines below.hardhat.config.ts