Code Monkey home page Code Monkey logo

stable-asset's Introduction

NUTS Stable Asset Pallet

Overview

There are vastly emerging assets in the Polkadot ecosystem, including both Polkadot native assets and assets bridged from other blockchains such as Ethereum and EOS. These assets introduce diversity in architecture and business model, but also fragmentizes the ecosystem since applications need to build separate markets for each of these assets. For example, stables coins can be divided into three categories: fiat-backed, crypto-backed and algorithmic stable coins, and on Ethereum each category has more than ten stable coin protocols. DEX benefits from such asset diversification but other protocols such as lending and options find it difficult to accommodate all these various assets.

Asset synthesis is a common approach to unify asset values and hedge asset risks. One approach is to synthesize several mainstream assets or assets belonging to the same niche so that the synthetic assets represents the general trend of the underlying assets. In this approach the synthetic assets acts similiar to an index fund, and how to fairly price and adopt the synthetic assets becomes a new question. The second approach is to synthetize several assets of the same value peg such as BTC, ETH or USD. The synthetic asset has the same value peg, and it could simplifies financial application development since only one synthetic asset needs to be supported for each peg type.

Stable Asset is an asset synthetic protocol of the second approach. It is also built with integrated swap and saving functionalities using the basket of assets.

Installation

Make sure you have done all steps described in Installation page of the Substrate Developer Hub.

To build project run:

cargo build

Tests

To run unit tests type:

cargo test

In case you want run code coverage tool, please follow instructions to install tarpaulin.

To create code coverage report run:

cargo tarpaulin -v

Running the Node

First of all please ensure that your development chain's state is empty:

cargo run --bin node purge-chain --dev

Now you can start the development chain:

cargo run --bin node --dev

Use Docker

You can build the docker image using docker build -t stable-asset .. Then run with docker run -p 9944:9944 stable-asset.

Connecting to the Node

Polkadot.js Explorer

It can be very useful to connect UI to the node you just started.

To do this open https://polkadot.js.org/apps/#/explorer in your browser first.

Follow these steps to register required custom types:

  • In the main menu choose Settings tab;
  • In the Settings submenu choose Developer tab;
  • Copy content of the custom-types.json file into text box on the page;
  • Press Save button.

Example Client

Example client connects to the clean dev node and performs various operations with nutsfinance-stable-asset pallet. See this readme for details.

Using the Pallet

  • See Client API for how to use the pallet from the client perspective.

Development Roadmap

Milestone # Description
1 Implement core Stable Swap algorithm to maintain balance of the basket, e.g.
computeD
computeDy
computeSwapAmount
swap.
Part of the algorithm is implemented in Solidity in acBTC's ACoconutSwap contract
2 Implement core functionalities for Stable Asset, which includes both how Stable Asset is minted/redeemed, e.g.
getMintAmount
mint
getRedeemProportionAmount
redeemProportion
getRedeemSingleAmount
redeemSingle
getRedeemMultiAmount
redeemMulti,
and how the basket assets are managed. The first part is partly implemented in Solidity in acBTC's ACoconutSwap contract

License

NUTS Stable Asset is Apache 2.0 licensed.

stable-asset's People

Contributors

nuts-finance-dev avatar xlc avatar shengda avatar zqhxuyuan avatar ukby1234 avatar zjb0807 avatar syan095 avatar alxs avatar semuelle avatar ferrell-code 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.