Use proxy clones to create Synths & LPTokens #21
Labels
bug
Something isn't working
G (Gas Optimization)
LPWrapper
sponsor acknowledged
Technically the issue is correct, but we're not going to resolve it for XYZ reasons
SynthFactory
Handle
nathaniel
Vulnerability details
Impact
In SynthFactory, the number of Synths will likely be equal to the number of unique foreign tokens in the protocol. Using proxy clones instead of deploying the entire contract can greatly reduce gas fees (~860,000 -> ~150,000 by my estimate testing with Remix). The change is as follows:
initialize
function.createSynth
, leverage openZeppelins proxy clone to clone the Synth contract and then immediately run the initializer on the clonesynthClone.initialize(token)
The same pattern could be implemented for LPTokens.
Proof of Concept
https://github.com/code-423n4/2021-11-vader/blob/main/contracts/dex-v2/synths/SynthFactory.sol#L31
https://github.com/code-423n4/2021-11-vader/blob/main/contracts/dex-v2/wrapper/LPWrapper.sol#L29
https://docs.openzeppelin.com/contracts/4.x/api/proxy#Clones
Tools Used
manual review
The text was updated successfully, but these errors were encountered: