code-423n4 / 2021-12-vader-findings

0 stars 0 forks source link

Functions to calculate synth name/symbol should live in factory to reduce bytecode #58

Open code423n4 opened 2 years ago

code423n4 commented 2 years ago

Handle

TomFrenchBlockchain

Vulnerability details

Impact

Gas costs

Proof of Concept

These functions are only necessary for creating the synth's name + symbol and are therefore only necessary on deployment.

https://github.com/code-423n4/2021-12-vader/blob/fd2787013608438beae361ce1bb6d9ffba466c45/contracts/dex-v2/synths/Synth.sol#L21-L43

If these functions lived in the factory, it could calculate the proper name and symbol for the synth and then pass it in on deployment. Deploying a synth would be cheaper as it doesn't need to store the code for these functions in its bytecode.

Recommended Mitigation Steps

Move these functions to factory and pass in results at synth deployment time