Git Product home page Git Product logo

ravikantcool2023 / origin-dollar Goto Github PK

View Code? Open in Web Editor NEW

This project forked from originprotocol/origin-dollar

1.0 1.0 0.0 23.17 MB

OUSD and OETH are stablecoins that passively accrue yield while you are holding it

Home Page: https://originprotocol.com

License: MIT License

Shell 0.51% JavaScript 71.65% Ruby 0.63% Python 9.20% TypeScript 0.02% CSS 0.60% HTML 0.02% Dockerfile 0.01% Solidity 16.97% Svelte 0.40% Procfile 0.01%

origin-dollar's Introduction

Origin Dollar

OUSD is a new kind of stablecoin that passively accrues yield while you are holding it. Checkout our docs for more details about the product.

Branch CI/CD Status
master Origin DeFi
staging Origin DeFi
stable Origin DeFi

Requirements

  • Node Version
    • ^16.0.0 >= node <=^18.0.0
    • Recommended: ^18.0.0
  • Web3 Wallet

Installation

# Clone the origin-dollar project
git clone [email protected]:OriginProtocol/origin-dollar.git
cd origin-dollar

Description

The origin-dollar project is a mono repo that hosts both the smart contracts and dapp code bases. In order to run this project locally, you will need to run both the Eth node and the dapp in separate processes or terminals.

Eth Node

The smart contracts and all of their associated code are located in the <project-root>/contracts directory. The Ethereum tests and the local Ethereum EVM node are managed by Hardhat.

A variety of Hardhat tasks are available to interact with the contracts. Additional information can be found by running npx hardhat from the contracts/ directory.

dapp (Decentralized Application)

The code for dapp is located under the /dapp directory.


Running the node

The dapp interacts with many 3rd party contracts (Uniswap, Curve, Sushiswap) and it would be too cumbersome to initialize all those contracts in a fresh node environment and set them to a state that mimics the Mainnet. For that reason we are using Hardhat's forked mode. By setting the BLOCK_NUMBER environment variable, the node will download part of the mainnet state that it requires to fulfill the requests. It is less reliable since the node isn't as stable in forked mode (and sometimes requires restarts), but mimicking the mainnet is a huge benefit. We used to develop with fresh state node, but the behavior discrepancies between fresh node and mainnet have started to become too large. For that reason, we have deprecated the fresh state development.

Rename contracts/dev.env to .env and set PROVIDER_URL to a valid one (Sign up for a free Alchemy or Infura account, create a new API key, and use the URL they provide). If you would like the forked net to mimic a more recent state of mainnet update the BLOCK_NUMBER to a more recent Ethereum block. Also add your mainnet testing account(s) (if more than one, comma separate them) under the ACCOUNTS_TO_FUND. After the node starts up, the script will transfer 100k of USDT, OUSD and DAI to those accounts. Open a separate terminal to run the hardhat node in.

Run the node:

# Enter the smart contracts dir
cd contracts

# Install the dependencies
yarn install

# Run the node in forked mode
yarn run node

Minting Stablecoins via hardhat task

This is an option, but a simpler way is to use the ACCOUNTS_TO_FUND setting described above.

# Mint 1000 worth of each supported stablecoin to each account defined in the mnemonic
npx hardhat fund --amount 1000 --network localhost
Requirements
  • You will need your web3 wallet configured before you can interact with the dapp. Make sure that you have one - refer to this section for Metamask instructions.
  • You will also need the dapp to be running. Refer to this section for instructions.

Configure Web3 Wallet

You will need a web3 wallet to interact with the dapp and sign transactions. Below are the instructions to setup Metamask to interact with the dapp running locally.

  • Install Metamask Chrome extension HERE
  • Create/Open Metamask wallet
  • Add a custom RPC endpoint
    • Name: origin - just an example
    • URL: http://localhost:8545
    • Chain ID: 1337

Add Accounts to Metamask

Forked mode

Just use the account(s) you normally use on mainnet.

Standalone mode

You can get all the accounts for the locally running node and their associated private keys by running the command

# For Standalone mode
npx hardhat accounts --network localhost

Choose a test account past index 3 (accounts 0-3 are reserved). Copy the private key and import it into Metamask as follows:

  • Click the current account icon in the upper right corner of Metamask
  • Select Import Account => paste private key => Click Import

Make sure that you select your newly created RPC endpoint in the networks dropdown and use your newly imported account in Metamask. You should now be setup to use Metamask to interact with the dApp.

Note: If you want to add all the accounts via a new Metamask wallet and import the mnemonic it is located in contracts/hardhat.config.js. Make sure that you use Account 4 and up for test accounts as 0-3 are reserved.

Running the dapp

Open a separate terminal to run the dapp in.

# Enter the smart dapp dir (or oeth-dapp)
cd dapp

# Install the dependencies
yarn install

# Start the dapp
yarn run start

If you see a Runtime Error: underlying network changed, then rename dapp/dev.env to .env and restart yarn

If you see an error resembling digital envelope routines::unsupported, you are likely using an incompatible Node.js version. At last check, v16.20.2 is good.

Troubleshooting

When freshly starting a node it is usually necessary to also reset Metamask Account being used:

  • Metamask => Settings => Advanced => Reset Account

    This will reset the nonce number that is incorrect if you have submitted any transactions in previous runs of the ethereum node. (Wallet has a too high nonce number comparing to the nonce state on the node)

If you get an error Command "husky-run" not found. type of error: Go to root of the project and run npx husky install


(Core Contributors) Running dapp in Production/Staging Mode Locally

There may be a time that you will need to run the dapp in production/staging mode to test out a certain feature or do verification before a deploy. In this case there is no need for a local node as you will connect directly to the mainnet/testnet.

Requirements

  • Google Cloud CLI tool installed as explained HERE
  • Permission to the Origin GCP Account to decrypt *.secrets.enc and deploy infrastructure

Login to Google Cloud

# Login to GCP
gcloud auth login

Staging

# Decrypt staging secrets to local
yarn run decrypt-secrets:staging

# Start local dapp in Staging mode
yarn run start:staging

Production

# Decrypt staging secrets to local
yarn run decrypt-secrets:production

# Start local dapp in Production mode
yarn run start:production

Running Smoke Tests

Smoke tests can be run in 2 modes:

  • Run scripts/test/smokeTest.sh to launch interactive mode. All the "before contract changes" parts of tests will execute and wait for the user to manually using a console performs contract changes. Once those are done, hit "Enter" in the smoke test console and the second part of the tests shall be run that validate that contract changes haven't broken basic functionality.
  • Run scripts/test/smokeTest.sh --deployid [numeric_id_of_deploy] will run smoke tests against a specific deployment validating that basic functionality didn't break.


Fork Tests

Head over to contracts/fork-test.md


Contributing

Want to contribute to OUSD? Awesome!

OUSD is an Open Source project and we welcome contributions of all sorts. There are many ways to help, from reporting issues, contributing to the code, and helping us improve our community.

The best way to get involved is to join the Origin Protocol discord server and head over to the channel named ORIGIN DOLLAR & DEFI

origin-dollar's People

Contributors

sparrowdom avatar tomlinton avatar danielvf avatar franckc avatar micahalcorn avatar shahthepro avatar crazybuster avatar rolandpo avatar naddison36 avatar snyk-bot avatar smitch88 avatar joshfraser avatar iam-hussain avatar cipherzzz avatar dependabot[bot] avatar ivanzhelyazkov avatar wonjun-opensource avatar mikeshultz avatar kurogewashu avatar jonathansnow avatar evgenyboxer avatar 0xcodercrane avatar apexearth avatar jastroud avatar rafaelugolini avatar defigods avatar alfredlouisw8 avatar smart-hunter avatar tomhirst avatar rappie avatar

Stargazers

Ravikant avatar

Watchers

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