Giter Site home page Giter Site logo

ciberexplosion / rupay-protocol Goto Github PK

View Code? Open in Web Editor NEW

This project forked from yam-finance/yam-protocol

0.0 1.0 1.0 10.04 MB

A stablizing reserve currency protocol

JavaScript 50.96% Solidity 18.08% Shell 0.34% Python 0.46% HTML 0.52% TypeScript 29.58% CSS 0.07%

rupay-protocol's Introduction

🍠 RUPAY Protocol 🍠

The Protocol

RUPAY is an experimental protocol building upon the most exciting innovations in programmable money and forked from YAM PROTOCOL.

At its core, RUPAY is an elastic supply cryptocurrency, which expands and contracts its supply in response to market conditions, initially targeting 1 RUPEES per RPY. This stability mechanism includes one key addition to existing elastic supply models such as Ampleforth: a portion of each supply expansion is used to buy yCurve (a high-yield USD-denominated stablecoin) and add it to the RUPAY treasury.

The Token

The core RPY token uses yCRV as the reserve currency, which is roughly a $1 peg. Each supply expansion (referred to as an inflating rebase), a portion of tokens is minted and used to build up the treasury.

Rebases

Rebases are controlled by an external contract called the Rebaser. This is comparable to Ampleforth's monetaryPolicy contract. It dictates how large the rebase is and what happens on the rebase. The YAM token just changes the supply based on what this contract provides it.

There are a requirements before rebases are active:
• Liquid YAM/yCRV market
init_twap()
activate_rebasing()

Following the launch of the second pool, rebasing can begin its activation phase. This begins with init_twap() on the rebaser contract. Anyone can call this at anytime once there is a YAM/yCRV Uniswap V2 market. The oracle is designed to be 12 hours between checkpoints. Given that, 12 hours after init_twap() is called, anyone can call activate_rebasing(). This turns rebasing on, permanently. Now anyone can call rebase() when inRebaseWindow() == true;.

In a rebase, the order of operations are:
• ensure in rebase window
• calculate how far off-price is from the peg
• dampen the rebase by the rebaseLag
• if positive calculate protocol mint amount
• change scaling factor, (in/de)flating the supply
• sync uniswap, mint, sell to uniswap, transfer excess YAM and bought yCRV to reserves
• call any extra functions governance adds in the future (i.e. Balancer gulps)

Development

Building

This repo uses truffle. Ensure that you have truffle installed. Given the composability aspect of this

Then, to build the contracts run:

$ truffle compile

To run tests, run against a single test package, i.e.:

$ sh startBlockchain.sh
$ truffle migrate --network distribution
$ python scripts/clean.py
$ cd jsLib
$ jest deployment
$ jest token
$ jest rebase

The need to run one-by-one seems to be a limitation of jest + ganache.

The distribution tests require specific tokens. These are acquired by using the ganache unlock_account function. If you receive fails, the owner likely decreased their ownership of that token. Just replace any instances of that address with another holder of the token.

Note: some governance tests require a different ganache setup. You will encounter a warning (but not a failed test) if the wrong type of ganache is setup. To run the correct one:

$ sh startBlockchainMining.sh
$ truffle migrate --network distribution
$ python scripts/clean.py
$ cd jsLib
$ jest governance

Attributions

Much of this codebase is modified from existing works, including:

YAM

rupay-protocol's People

Contributors

brockelmore avatar clintonbembryjr avatar ciberexplosion avatar 0xclem avatar jaytoday avatar junhoyeo avatar chezhe avatar zer0cache avatar

Watchers

 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.