Git Product home page Git Product logo

contracts-v2's People

Contributors

adrian10016 avatar drahrealm avatar kphed avatar neverdefined avatar realkinando avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

contracts-v2's Issues

xBond.sol

  • Review current implementation
  • Read Code from Olympus Bonds, v1/v2 Bonds, assess parts to use
  • Lock interfaces with Mariposa.sol

Vesting Token

  • Review Sablier Stream code
  • Other implementations of Vesting Contracts
  • Easiest Way to set this up ~50 addresses and different vesting formats

V1 token to V2 token

  • is token migration really necessary? (use the same token as before)
  • If necicarry :
  • Industry standard migartions
  • their pitfalls
  • The best lessons

Feedback from KP

King @realkinando is back, hyped for V2 ๐Ÿ‘€ . Here's my feedback from looking at the contracts in v2-core

Mariposa.sol

  • State variables
    • cap doesn't seem to be changed after it's set in the constructor. You can make it immutable
      • Also, is reaching the cap an issue? Will we need a method that can raise/lower it?
  • Constructor
    • epochSeconds_ is never set, which would cause distribute to always revert since it'd never be greater than lastEpoch (which also never seems to be set)
  • For integer types, specify the number of bits so we can do variable packing (e.g. uint8/16/32/.../256)
  • Should use a formatter so our code is consistent visually
  • Add checks for all params unless it's obviously redundant/unnecessary (e.g. would be worth it for this constructor's params since it's cheaper to check to do the checks than redeploy because human error - unless there's a setter method we can use)
  • Optimization example of this for loop
    • Outer loop header
      • There's no need to initialize the control variable with 0 as it's already the default value
      • The loop condition is evaluated on each iteration so it'd be more efficient to assign the result of currentEpoch - lastEpoch to a variable and use that (vs. doing the calculation on each iteration)
    • Inner loop header
      • Use j <= collectionCount instead of j < collectionCount + 1 (otherwise it'll do the calculation on every iteration, similar to the point above)
    • Inner loop body
      • Assign repeatedly accessed values to a variable (e.g. Collection storage c = getCollection[j])
      • May help with readability if the logic for conditionally setting some of the struct members
  • distribute may run out of gas if there are too many collections in the future

RevenueDistributor

  • Mariposa feedback applies here
  • State variables
    • lockToken can be immutable - never re-assigned outside of constructor
    • offset can be immutable - never re-assigned outside of constructor
  • Need to use SafeTransferLib if dealing with potentially untrustworthy tokens
  • The internal methods below (and ones like it - there are many) should be made public or external (if they don't need to be called internally) and the redundant external methods can be removed:
    function _getCurrentRound() internal view returns (uint round){
        round = (block.timestamp + (offset * 1 weeks)) / (4 * 1 weeks);
    }

    function getCurrentRound() external view returns (uint round){
        round = _getCurrentRound();
    }

    function _getTimestampFromRound(uint round) internal view returns (uint timestamp){
        timestamp = ((round * 4) + offset) * 1 weeks;
    }

    function getTimestampFromRound(uint round) external view returns (uint timestamp){
        timestamp = _getTimestampFromRound(round);
    }

    function _getRewardHash(address token, bool conviction) internal view returns(bytes32 rewardHash){
        rewardHash = keccak256(abi.encode(token,conviction));
    }

    function getRewardHash(address token, bool conviction) external view returns(bytes32 rewardHash){
        rewardHash = _getRewardHash(token, conviction);
    }
  • Remove this redundant call since rewardRoundHash is the same thing

I'll update this again when I go through the other contracts.

Sub Protocol Incentives

  • how minting budget/rewards interface with sub-projects
  • Standard incentives Setup Scripts
  • Associate with contract or call data (to determine if action is incentivized)

LockToken.sol

  • Assess Other implementations (ie Convex, why lock token)
  • Should this be an NFT? compare with pirex lock token implementation

Testing Mariposa And Bugs

taking over branch: #14
Requirements:

  • Accounting Contract that allows Contracts/Addresses mint btrfly up to an allowance.
  • Allowance can be set and changed by the contract owner.
  • Max-supply should be respected
  • should track current allowances.
  • should track minters
  • should track

Already Done:

  • Contract with set interfaces

Need to be done:

  • Testing (look at ./tests/RLocker.ts)
  • Fuzzing if necessary.

Mariposa.sol

  • Review Contract
  • Asses Best Way to Allocate minting Privileges
  • Asses Best Way for Policy to Move Allocations to contracts
  • Asses Best way to Determine Minting Budgets

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.