Comments (6)
someone mentioned clones could be bad for high volume contracts, but didn't go into why (source)
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!)
i believe so
Great! Let's use it!
from v1-core.
What are the tradeoffs between using clone factory and regular factory?
almost none that i could find
-
someone mentioned clones could be bad for high volume contracts, but didn't go into why (source)
-
another one is that if the parent contract self destructs, all previously deployed contracts would stop working
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
from v1-core.
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
https://docs.openzeppelin.com/contracts/4.x/api/proxy#Clones
https://blog.openzeppelin.com/workshop-recap-cheap-contract-deployment-through-clones/
from v1-core.
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
oh this is actually what you are looking at with optionality
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
from v1-core.
@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:
- What are the tradeoffs between using clone factory and regular factory?
- Gas usage difference between the two? (answer: a new clone is 10x cheaper)
- Does it make sense for us to use clone factory over normal factory?
- Can the clones be interacted with like normal tokens?
- Is it easy to interact with the methods on the bond?
- Can the bonds created from the cloanfactory be sent like normal erc20 tokens?
- Can the cloans be used as-is on Uniswap or another platform that supports erc20 tokens?
from v1-core.
found a cool resource https://soliditydeveloper.com/clonefactory
from v1-core.
Related Issues (20)
- Mainnet runthrough HOT 2
- update BondBeforeGracePeriodAndPaid error naming
- Revert on a sweep to a token with 0 balance
- Deploy to Mainnet HOT 1
- Use internal _burn methods and add role tests HOT 1
- Study spearbit changes for possible regression issues HOT 1
- Should we be using paymentBalance more places? HOT 1
- Create architecture diagram for explaining our system
- Volt Code Review Takeaways HOT 7
- Fix failing tests without .env
- Setup ImmuneFi bug bounty
- Deploy Contracts with Multisig
- Improve tests HOT 1
- Improve Resiliency HOT 2
- Mainnet Deployment HOT 2
- Look into OTC
- Create Testnet USDC Faucet HOT 3
- Improve documentation with e2e examples
- Create Events Bot HOT 1
- Feature request to enable fully trustless credit default insurance products
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from v1-core.