This repository contains the source code for the first version of Prism Protocol smart contracts running on Terra blockchain.
Contract | Reference | Description |
---|---|---|
gov |
doc | Governance contract for Prism Protocol, manages xPRISM minting and rewards |
airdrop-registry |
doc | Manages message fabricators for airdrop claims |
collector |
doc | Gathers protocol fees and distributes to xPRISM holders, manages reward swap logic |
launch-pool |
doc | yLuna staking pool event |
lp-staking |
doc | Staking contract for PRISM LP tokens |
vault |
doc | Manages luna delegations and yLuna/pLuna minting |
yasset-staking |
doc | Staking contract for yLuna tokens, stakers receiver all delegated luna rewards and airdrops |
xprism-boost |
doc | Allows users to lock xPRISM to farm AMPS |
There is an active bug bounty program for Prism Smart Contracts on Inmunefi.
- Rust v1.44.1+
wasm32-unknown-unknown
target- Docker
-
Install
rustup
via https://rustup.rs/ -
Run the following:
rustup default stable
rustup target add wasm32-unknown-unknown
- Make sure Docker is installed
Each contract contains Rust unit and integration tests embedded within the contract source directories. You can run:
cargo unit-test
cargo integration-test
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/cw1_subkeys.wasm .
ls -l cw1_subkeys.wasm
sha256sum cw1_subkeys.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/rust-optimizer:0.11.5
or
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 --all --all-targets -- -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.