QA Report #150
Labels
bug
Something isn't working
QA (Quality Assurance)
Assets are not at risk. State handling, function incorrect as to spec, issues with clarity, syntax
Low risk findings:
1.
tokenURI
pass in the wrong parameter forgetPremium
It should accept a
vaultId
, but here the code pass inpremiumId
This will make the NFT showing the wrong trait.
P.S. I suggested changing the input parameter of
getPremium
fromvaultId
topremiumIndex
, as described below (gas optimization #2)2. wrong revert message in
createVault
This revert message:
should instead be
reserve strike too high
.Gas optimizations
1. pack variables
feeRate
andprotocolUnclaimedFees
together to save gas on exercise.Because these 2 variables are used together in
exercise
function, (reading feeRate and updating protocolUnclaimedFees), packing them into the same storage slot will save you one more SLOAD if feeRate > 0. on average this saves around 2000 gas. (49k -> 47K)2. change getPremium input to premiumIndex.
As it currently is, getPremium function receive vaultId read the vault from storage again and than get the premiumIndex. This will cause an extra SLOAD to load the vault from storage.
This can be avoided if we just pass in
premiumIndex
, as all 2 functions that call this already have their vault instance in memory.This makes average cost of
buyOption
drops from 75.7K -> 74.8.3. pack
currentStrike
anddutchAuctionReserveStrike
into a single storage slot.Since packing variables is highly used in the vault struct, i suggest also pack
dutchAuctionReserveStrike
andcurrentStrike
touint128
to save 1 SLOAD and SSTORE from read and write.The gas saving from running the benchmark is 74.8K -> 73.5K
The text was updated successfully, but these errors were encountered: