• Stars
    star
    741
  • Rank 61,194 (Top 2 %)
  • Language
    Rust
  • License
    GNU General Publi...
  • Created about 5 years ago
  • Updated about 2 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Acala - cross-chain DeFi hub and stablecoin based on Substrate for Polkadot and Kusama.

GitHub Workflow Status GitHub tag (latest by date) Substrate version codecov License
Twitter URL Discord Telegram Discourse Medium

1. Introduction

This project is initiated and facilitated by the Acala Foundation. Acala Foundation nurtures applications in the fields of decentralized finance protocols, particularly those that serve as open finance infrastructures such as stable currency and staking liquidity. The Acala Foundation is founded by Laminar and Polkawallet, participants and contributors to the Polkadot ecosystem. The Acala Foundation welcomes more industry participants as it progresses.

2. Overview

The significance of cross-chain communication to the blockchain is like that of the internet to the intranet. Polkadot empowers a network of public, consortium and private blockchains, and enables true interoperability, economic and transactional scalability. A cross-chain stablecoin system will:

  1. Create a sound, stable currency for low cost, borderless value transfer for all chains in the network
  2. Enable commercial lending with predictable risk
  3. Serve as a building block for more open finance services

The Acala Dollar stablecoin (ticker: aUSD) is a multi-collateral-backed cryptocurrency, with value stable against US Dollar (aka. 1:1 aUSD to USD soft peg). It is completely decentralized, that it can be created using assets from blockchains connected to the Polkadot network including Ethereum and Bitcoin as collaterals, and can be used by any chains (or digital jurisdictions) within the Polkadot network and applications on those chains.

By this nature, it is essential that the Acala Network eventually become community-owned with an economic model that can sustain its development and participation in the Polkadot network, as well as ensure its stability and security. The following section will provide a high-level overview of the following topics:

  • aUSD and the Honzon stablecoin protocol
  • the economic model and initial parachain offering

2.1. aUSD and the Honzon stablecoin protocol

Every aUSD is backed in excess by a crypto asset, the mechanism of which is known as an over-collateralized debt position (or CDP). Together with a set of incentives, supply & demand balancing, and risk management mechanisms, as the core components of the Honzon stablecoin protocol on the Acala Network, the stability of the aUSD is ensured. The CDP mechanism design is inspired by the first decentralized stablecoin project MakerDAO, which has become the DeFi building block in the Ethereum ecosystem. Besides, the Honzon protocol enables many unique features - native multi-asset support, cross-chain stablecoin capability, automatic liquidation to increase responsiveness to risk, and pluggable oracle and auction house to improve modularity, just to name a few.

The Honzon protocol contains the following components

  • Multi Collateral Type
  • Collateral Adapter
  • Oracle and Prices
  • Auction and Auction Manager
  • CDP and CDP Engine
  • Emergency shutdown
  • Governance
  • Honzon as an interface to other components

Note: This section is still work in progress, we will update more information as we progress. Refer to the Github Wiki for more details.

2.2. Acala Network Economic Model

The Acala Network Token (ACA) features the following utilities, and the value of ACA token will accrue with the increased usage of the network and revenue from stability fees and liquidation penalties

  1. As Network Utility Token: to pay for network fees and stability fees
  2. As Governance Token: to vote for/against risk parameters and network change proposals
  3. As Economic Capital: in case of liquidation without sufficient collaterals

To enable cross-chain functionality, the Acala Network will connect to the Polkadot in one of the three ways:

  1. as parathread - pay-as-you-go connection to Polkadot
  2. as parachain - permanent connection for a given period
  3. as an independent chain with a bridge back to Polkadot

Becoming a parachain would be an ideal option to bootstrap the Acala Network, and maximize its benefits and reach to other chains and applications on the Polkadot network. To secure a parachain slot, the Acala Network will require supportive DOT holders to lock their DOTs to bid for a slot collectively - a process known as the Initial Parachain Offering (IPO). ACA tokens will be offered as a reward for those who participated in the IPO, as compensation for their opportunity cost of staking the DOTs.

Note: This section is still work in progress, we will update more information as we progress. Refer to the token economy working paper for more details.

3. Building

NOTE

To connect on the "Mandala TC6" network, you will want the version ~0.7.10 code which is in this repo.

Install Rust:

curl https://sh.rustup.rs -sSf | sh

You may need additional dependencies, checkout substrate.io for more info

sudo apt-get install -y git clang curl make libssl-dev llvm libudev-dev protobuf-compiler

Make sure you have submodule.recurse set to true to make life with submodule easier.

git config --global submodule.recurse true

Install required tools and install git hooks:

make init

Build Mandala TC native code:

make build-full

4. Run

You can start a development chain with:

make run

5. Development

To type check:

make check-all

To purge old chain data:

make purge

To purge old chain data and run

make restart

Update ORML

make update

Note: All build command from Makefile are designed for local development purposes and hence have SKIP_WASM_BUILD enabled to speed up build time and use --execution native to only run use native execution mode.

6. Bug Bounty πŸ›

The Bug Bounty Program includes only on-chain vulnerabilities that can lead to significant economic loss or instability of the network. You check details of the Bug Bounty or Submit a vulnerability here: https://immunefi.com/bounty/acala/

7. Bench Bot

Bench bot can take care of syncing branch with master and generating WeightInfos for module or runtime.

Generate module weights

Comment on a PR /bench module <module_name> i.e.: module_currencies

Bench bot will do the benchmarking, generate weights.rs file and push changes into your branch.

Generate runtime weights

Comment on a PR /bench runtime <runtime> <module_name> i.e.: /bench runtime mandala module_currencies.

To generate weights for all modules just pass * as module_name i.e: /bench runtime mandala *

Bench bot will do the benchmarking, generate weights file and push changes into your branch.

Bench Acala EVM+

Comment on a PR /bench evm to benchmark Acala EVM+ and bench bot will generate precompile weights and GasToWeight ratio.

8. Migration testing runtime

If modify the storage, should test the data migration before upgrade the runtime.

Try testing runtime

try-runtime on karura

# Use a live chain to run the migration test.
# Add `-p module_name` can specify the module.
make try-runtime-karura

# Create a state snapshot to run the migration test.
# Add `--pallet module_name` can specify the module.
cargo run --features with-karura-runtime --features try-runtime -- try-runtime --runtime existing create-snapshot --uri wss://karura.api.onfinality.io:443/public-ws karura-latest.snap

# Use a state snapshot to run the migration test.
./target/release/acala try-runtime --runtime ./target/release/wbuild/karura-runtime/karura_runtime.compact.compressed.wasm --chain=karura-dev on-runtime-upgrade snap -s karura-latest.snap

try-runtime on acala

# Use a live chain to run the migration test.
# Add `--pallet module_name` can specify the module.
make try-runtime-acala

# Create a state snapshot to run the migration test.
# Add `-palet module_name` can specify the module.
cargo run --features with-acala-runtime --features try-runtime -- try-runtime --runtime existing create-snapshot --uri wss://acala.api.onfinality.io:443/public-ws acala-latest.snap

# Use a state snapshot to run the migration test.
./target/release/acala try-runtime --runtime ./target/release/wbuild/acala-runtime/acala_runtime.compact.compressed.wasm --chain=acala-dev on-runtime-upgrade snap -s acala-latest.snap

9. Run local testnet with parachain-launch

Build RelayChain and Parachain local testnet to develop.

cd launch

# install dependencies
yarn

# generate docker-compose.yml and genesis
# NOTE: If the docker image is not the latest, need to download it manually.
# e.g.: docker pull acala/karura-node:latest
# karura testnet:
yarn start generate
# karura-bifrost testnet:
yarn start generate --config=karura-bifrost.yml

# start relaychain and parachain
cd output
# NOTE: If regenerate the output directory, need to rebuild the images.
docker-compose up -d --build

# list all of the containers.
docker ps -a

# track container logs
docker logs -f [container_id/container_name]

# stop all of the containers.
docker-compose stop

# remove all of the containers.
docker-compose rm

# NOTE: If you want to clear the data and restart, you need to clear the volumes.
# remove volume
docker volume ls
docker volume rm [volume_name]
# prune all volumes
docker volume prune

10. Build For Release

For release artifacts, a more optimized build config is used. This config takes around 2x to 3x longer to build, but produces a more optimized binary to run.

make build-release

11. Setup Local EVM+ Test Environment

To set up a basic local network you need two things running locally, a node and the eth-rpc-adapter. Setup each service in their respective terminals and then you are free to use your favorite EVM tools locally! (ex: hardhat)

Setting up local node

Compile the node from source code:

make run

Note: You may need normal block production for certain workflow, use command below to run node without instant-sealing flag

cargo run --features with-mandala-runtime -- --dev -lruntime=debug

Run node using docker:

docker run -it --rm -p 9944:9944 -p 9933:9933 ghcr.io/acalanetwork/mandala-node:master --dev --ws-external --rpc-port=9933 --rpc-external --rpc-cors=all --rpc-methods=unsafe --tmp -levm=debug --instant-sealing

Setting up eth-rpc-adapter

npx @acala-network/eth-rpc-adapter -l 1

Note: If your use case needs eth_getLogs rpc call, then you need to have a subquery instance to index the local chain. For this case, follow the tutorial found here: Local Network Tutorial

More Repositories

1

acala-evm-dev-docs

269
star
2

chopsticks

Create parallel reality of your Substrate network.
TypeScript
134
star
3

Acala-white-paper

Acala Network whitepapers
99
star
4

subway

Rust
68
star
5

acala.js

TypeScript
59
star
6

bodhi.js

TypeScript
32
star
7

acala-wiki

Acala GitBook Wiki, https://wiki.acala.network
24
star
8

e2e-tests

TypeScript
20
star
9

predeploy-contracts

Solidity
19
star
10

acala-subql

TypeScript
10
star
11

Acala-Grants-Program

Acala Foundation Grants Program
9
star
12

hardhat-tutorials

TypeScript
9
star
13

acala-js-example

TypeScript
8
star
14

evm-examples

TypeScript
8
star
15

parachain-utilities

A set of tools to improve the life quality of parachain developers.
TypeScript
7
star
16

evm-provider

TypeScript
4
star
17

polkawallet_plugin_karura

Karura network plugin for Polkawallet.
Dart
4
star
18

polakdot-hello-world-acala

Gitcoin Polkadot Hello World Hackathon.
3
star
19

collateral-auction-bot-example

TypeScript
3
star
20

ecosystem-template

Rust
3
star
21

e2e

TypeScript
3
star
22

AcalaBounties

3
star
23

token-resources

resources include token and network
JavaScript
3
star
24

scripts

TypeScript
3
star
25

evm-playground

TypeScript
3
star
26

Euphrates

Solidity
3
star
27

txwrapper

TypeScript
2
star
28

truffle-tutorials

JavaScript
2
star
29

acala-utils

TypeScript
2
star
30

wormhole-relayer

TypeScript
2
star
31

evm-dapp-collection

Good place to submit information of Acala EVM Dapps.
2
star
32

issue-collection

Good place to submit BUGs.
2
star
33

cdp-bot-template

Template for deploying on Heroku using the "Deploy on Heroku" button
JavaScript
2
star
34

karura-whitepaper

2
star
35

auction-bot

TypeScript
2
star
36

karura-dashboard

1
star
37

polka-defi-website

TypeScript
1
star
38

acala-homa-subql

JavaScript
1
star
39

product-feedback

1
star
40

translation

1
star
41

acala-loan-subql

JavaScript
1
star
42

acala-evm-indexer-examples

TypeScript
1
star
43

acala-trace

TypeScript
1
star
44

karura-website

JavaScript
1
star
45

acala-evm-tests

TypeScript
1
star
46

bodhi-examples

some examples to use bodhi sdk
TypeScript
1
star
47

acala-subql-services

TypeScript
1
star
48

karura-testnet

Dockerfile
1
star
49

evm-tests

Rust
1
star
50

lucky-running-nodes

JavaScript
1
star
51

acala-test-utils

some utils for test acala network
HTML
1
star
52

guardian-bot-heroku-template

Template for deploying on Heroku using the "Deploy on Heroku" button
JavaScript
1
star
53

waffle-tutorials

TypeScript
1
star