Code Monkey home page Code Monkey logo

Comments (6)

RusseII avatar RusseII commented on May 27, 2024 3

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!)

image

i believe so

Great! Let's use it!

from v1-core.

luckyrobot avatar luckyrobot commented on May 27, 2024 2

image

What are the tradeoffs between using clone factory and regular factory?

almost none that i could find

  1. someone mentioned clones could be bad for high volume contracts, but didn't go into why (source)

  2. 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.

Pet3ris avatar Pet3ris commented on May 27, 2024 1

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.

RusseII avatar RusseII commented on May 27, 2024

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.

RusseII avatar RusseII commented on May 27, 2024

@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.

luckyrobot avatar luckyrobot commented on May 27, 2024

found a cool resource https://soliditydeveloper.com/clonefactory

from v1-core.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.