Cache external call results can save gas #236
Labels
bug
Something isn't working
G (Gas Optimization)
sponsor confirmed
Sponsor agrees this is a problem and intends to fix it (OK to use w/ "disagree with severity")
Handle
WatchPug
Vulnerability details
Every call to an external contract costs a decent amount of gas. For optimization of gas usage, external call results should be cached if they are being used for more than one time.
For example:
factory.getPair(wavaxAddress, tokenAddress)
andfactory.getPair(tokenAddress, wavaxAddress)
inLaunchEvent#createPair()
https://github.com/code-423n4/2022-01-trader-joe/blob/a1579f6453bc4bf9fb0db9c627beaa41135438ed/contracts/LaunchEvent.sol#L377-L435
note:
factory.getPair(a, b)
与factory.getPair(b, a)
相同, seecode at github
or
code at avascan
IJoeFactory(factory).getPair(_token, wavax)
inRocketJoeFactory#createRJLaunchEvent()
https://github.com/code-423n4/2022-01-trader-joe/blob/a1579f6453bc4bf9fb0db9c627beaa41135438ed/contracts/RocketJoeFactory.sol#L122-L128
token.decimals()
inLaunchEvent#createPair()
https://github.com/code-423n4/2022-01-trader-joe/blob/a1579f6453bc4bf9fb0db9c627beaa41135438ed/contracts/LaunchEvent.sol#L395-L405
The text was updated successfully, but these errors were encountered: