This repository contains the full source code for the first version of the Nebula Protocol smart contracts deployed on Terra.
These contracts hold the core logic of the base protocol.
Contract | Description |
---|---|
nebula-airdrop |
Logic for NEB airdrop to LUNA stakers |
nebula-cluster |
Logic for mechanisms of individual clusters |
nebula-cluster-factory |
Defines procedure for creating new Clusters |
nebula-collector |
Collects protocol fees and distributes it as rewards to NEB governance stakers |
nebula-community |
Controls the funds in the governance-controlled community pool |
nebula-gov |
Manages the decentralized governance functions of Nebula protocol |
nebula-lp-staking |
Manages NEB rewards for Cluster Token liquidity providers (LP) |
Some parts of Nebula such as a Cluster's penalty function or NEB incentive campaigns are also implemented using contracts but are not considered part of the protocol. Nebula ships with a couple default ones, and their code is here.
Contract | Description |
---|---|
nebula-penalty |
Implementation of a Cluster Penalty Function, used by default |
nebula-incentives |
Implementation of a NEB incentive scheme for Astroport arbitrage |
nebula-incentives-custody |
Custody contract for NEB incentive scheme |
nebula-oracle |
Price oracle contract used by the Nebula Protocol |
- Rust v.1.57.0
wasm32-unknown-unknown
target- Docker
- Install
rustup
- Run the following
rustup default 1.57.0
rustup target add wasm32-unknown-unknown
- Make sure Docker is installed on your machine
Each contract contains Rust unit tests embedded within the contract source directories. You can run
cargo unit-test
Go to the contract directory and run
After making sure tests pass, you can compile each contract with the following
RUSTFLAGS='-C link-arg=-s' cargo wasm
cp ../../target/wasm32-unknown-unknown/release/<CONTRACT_NAME>.wasm .
ls -l <CONTRACT_NAME>.wasm
sha256sum <CONTRACT_NAME>.wasm
For production builds, run the following:
docker run --rm -v "$(pwd)":/code \
--mount type=volume,source="$(basename "$(pwd)")_cache",target=/code/target \
--mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \
cosmwasm/workspace-optimizer:0.12.5
or
chmod +x build_release.sh
sh build_release.sh
This performs several optimizations which can significantly reduce the final size of the contract binaries, which will be available inside the artifacts/
directory.
Make sure you run rustfmt
before creating a PR to the repo. You need to install the nightly
version of rustfmt
.
rustup toolchain install nightly
To run rustfmt
,
cargo fmt
You should run clippy
also. This is a lint tool for rust. It suggests more efficient/readable code. You can see the clippy document for more information. You need to install nightly
version of clippy
.
rustup toolchain install nightly
cargo clippy -- -D warnings
Developers are strongly encouraged to write unit tests for new code, and to submit new unit tests for old code. Unit tests can be compiled and run with: cargo test --all
. For more details, please reference Unit Tests.
The contracts in this repo are included in a bug bounty program.
contract | address |
---|---|
NEB Token | terra1mpq5zkkm39nmjrjg9raknpfrfmcfwv0nh0whvn |
Airdrop | terra1wjqsy2q3xzn3rxv5drutfysvg24pqwsg3nmv0y |
Governance | terra1gsq7p9a8uu6wdr78rk9cthz57tzkfzrejhdknf |
Community | terra1g5py2hu8kpenqetv6xjas5z5gtaszhsuk8yn7n |