Coder Social home page Coder Social logo

edwardmadi / loop-prelaunch-contracts Goto Github PK

View Code? Open in Web Editor NEW

This project forked from loopfi/loop-prelaunch-contracts

0.0 0.0 0.0 3.34 MB

Prelaunch points system for LoopFi

Shell 0.24% JavaScript 30.53% Ruby 6.02% Python 0.69% TypeScript 0.23% Nix 0.01% Makefile 0.07% Solidity 62.22%

loop-prelaunch-contracts's Introduction

LoopFi Prelaunch Point Contracts

Description

Epoch 1:

Users can lock ETH, WETH and wrapped LRTs into this contract, which will emit events tracked on a backed to calculate their corresponding amount of points. When staking, users can use a referral code encoded as bytes32 that will give the referral extra points. User can withdraw freely during this first epoch, but they will be penalized in the points accounting.

When Loop contracts are launched, the owner of the contract can call only once setLoopAddresses to set the lpETH contract as well as the staking vault for this token. This activation date is stored at loopActivation.

Once these addresses are set, users have 7 days to detected a malicious contract being set and withdraw their tokens.

Epoch 2:

After these 7 days the owner can call convertAllETH, that converts all ETH in the contract for lpETH. This conversion has the timestamp startClaimDate. The conversion for WETH and LRTs happens on each claim by using 0x API. This is triggered by each user. After startClaimDate all deposits and withdrawals are disabled and users can only claim lpETH.

After the global ETH conversion, users can start claiming their lpETH or claiming and staking them in a vault for extra rewards. The amount of lpETH they receive is proportional to their locked ETH amount or the amount given by the conversion by 0x API. The minimum amount to receive is determined offchain and controlled by a slippage parameter in the frontend dApp.

Notes:

  • On deployment the variable loopActivation is set to be 120 days into the future. If owner does not set the Loop contracts before this date, the contract becomes unusable by the owner and users can withdraw their ETH and other locked tokens from this contract.
  • There is an emergency mode that allows users to withdraw without any time restriction. If ETH was converted already users can call claim instead. This mode ensures that LRTs are not locked in the contract in case 0x stops working as intended.

Initialization

To compile the contracts run

forge build

To run the unit tests

forge test

To run the integration tests with 0x API, first create and fill a .env file with the keys of .env.example. Then, run

yarn hardhat test

Deployment

First, set your environment variables in a .env file as in .env.example. To load these variables run

source .env

To deploy and verify the PrelaunchPoints contract run

forge script script/PrelaunchPoints.s.sol --rpc-url $RPC_URL --broadcast --verify

Audit metrics

To get some metrics pre audit, run

yarn solidity-code-metrics src/PrelaunchPoints.sol > metrics.md

References

loop-prelaunch-contracts's People

Contributors

0xd4n1el avatar danieljcss avatar edwardmadi avatar

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.