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) and factory.getPair(tokenAddress, wavaxAddress) in LaunchEvent#createPair()
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)
相同, see code at github or code at avascanIJoeFactory(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