-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Research clone factory to deploy erc20 bond contracts #15
Comments
If you want an audited and more recent version of this, use Clones: https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/proxy/Clones.sol |
From @StuartH1 one potential implementation you could look into is EIP 1167 https://eips.ethereum.org/EIPS/eip-1167, https://blog.openzeppelin.com/deep-dive-into-the-minimal-proxy-contract/. It would be a increase in complexity though Here is a more up to date github https://github.com/OpenZeppelin/openzeppelin-contracts/blob/4a9cc8b4918ef3736229a5cc5a310bdc17bf759f/contracts/proxy/Clones.sol Instadapp uses this implementation in production, https://github.com/Instadapp/dsa-contracts/blob/master/contracts/registry/index.sol Here is an old account of mine when I was testing it out - https://polygonscan.com/address/0x8eeaf1fc93d8c3d57b5931bf81aadebd24b7bb53 here is the tx when I created my account https://polygonscan.com/tx/0xcb540447d5583e97539ca1d95518d9dcd3ffc4f714f405c21366daf7194c478d |
@luckyrobot what we learn from this issue will be used to determine the answer to #29 - so if you're able to work on this one relatively soon that'd be great! Also Stu shared some more info/examples around this in the advisor channel The answers we are trying to figure out are:
|
found a cool resource https://soliditydeveloper.com/clonefactory |
What are the tradeoffs between using clone factory and regular factory?almost none that i could find
Gas usage difference between the two? (answer: a new clone is 10x cheaper)clone is much cheaper, depending on contract. here's an example contract ·-------------------------------------------|----------------------------|-------------|----------------------------·
| Solc version: 0.6.11+commit.5ef660b1 · Optimizer enabled: true · Runs: 200 · Block limit: 6721975 gas │
············································|····························|·············|·····························
| Methods │
·························|··················|··············|·············|·············|··············|··············
| Contract · Method · Min · Max · Avg · # calls · eur (avg) │
·························|··················|··············|·············|·············|··············|··············
| MetaCoinCloneFactory · createMetaCoin · 94539 · 109527 · 95039 · 30 · 0.68 │
·························|··················|··············|·············|·············|··············|··············
| MetaCoinFactory · createMetaCoin · 208441 · 212653 · 212513 · 30 · 1.53 │
·-------------------------------------------|--------------|-------------|-------------|--------------|-------------· Does it make sense for us to use clone factory over normal factory?i believe so Can the clones be interacted with like normal tokens?yes, can use transfer and such. they each get an address Is it easy to interact with the methods on the bond?yea same interaction as previously Can the bonds created from the cloanfactory be sent like normal erc20 tokens?in the unit tests the answer seemed to be yes. can transfer in and out of different wallets on different bond token contracts Can the cloans be used as-is on Uniswap or another platform that supports erc20 tokens?this says it can be used on erc20 platforms https://forum.openzeppelin.com/t/workshop-recap-cheap-contract-deployment-through-clones/6068 |
I think they were just saying to get it audited if contract has high volume. Seems like one of the cons of using the cloneFactory is some small overhead on each of the transactions interacting with the cloned contract. Seems to be about 800 gas of overhead between native contract and cloaned contract. Uniswaps factory does not use clones for this reason. (Should be fine for us tho!)
Great! Let's use it! |
We are leaning towards using a BondFactory to deploy a new ERC20 bond token before each gnosis auction and using the bond token as the
auctioningToken
https://ropsten.etherscan.io/tx/0x387efb77e56e0b3f6066c8a853464c9a4b1b24ffbf0d49a0063793168f058638
2,271,956 gas to deploy current bond contract
https://ropsten.etherscan.io/tx/0xc164917ff5f918aec456e8d9912bd40ea9fc2715a69177093b421a93c6d2c498
1,154,924 gas to deploy very basic erc20 token
@ 100 gwei
100k gas = .01 eth
1m gas = .1 eth
10m gas = 1 eth
So ~ .2eth ($500) to deploy a bond contract - This seems like a lot but might be negligible to the DAOs issuing debt
Are there ways we can reduce these costs significantly?
https://github.com/optionality/clone-factory - would something like this be an option? Repo is quite old
The text was updated successfully, but these errors were encountered: