This repository contains the source code for the core smart contracts of Mars Protocol. Smart contracts are meant to be compiled to .wasm
files and uploaded to the Cosmos chains.
See reports for red-bank and rover here.
A bug bounty is currently open for these contracts. See details here.
-
Install Osmosisd
-
Get the wasm binary executable on your local machine.
git clone https://github.com/mars-protocol/contracts.git git checkout <commit-id> cargo make rust-optimizer
Note: Intel/Amd 64-bit processor is required. While there is experimental ARM support for CosmWasm/rust-optimizer, it's discouraged to use in production and the wasm bytecode will not match up to an Intel compiled wasm file.
-
Download the wasm from the chain.
osmosisd query wasm code $CODEID -- $NODE download.wasm
-
Verify that the diff is empty between them. If any value is returned, then the wasm files differ.
diff artifacts/$CONTRACTNAME.wasm download.wasm
-
Alternatively, compare the wasm files' checksums:
sha256sum artifacts/$CONTRACTNAME.wasm download.wasm
-
Install cargo-make
cargo install --force cargo-make
-
Install rust
cargo make install-stable
-
Install Docker
-
Install Node.js v16
-
Install Yarn
-
Create the build folder:
cd scripts yarn yarn build
-
Compile all contracts:
cargo make rust-optimizer
-
Formatting:
cd scripts yarn format yarn lint
This compiles and optimizes all contracts, storing them in /artifacts
directory along with checksum.txt
which contains sha256 hashes of each of the .wasm
files (The script just uses CosmWasm's rust-optimizer).
Note: Intel/Amd 64-bit processor is required. While there is experimental ARM support for CosmWasm/rust-optimizer, it's discouraged to use in production.
When the deployment scripts run for the first time, it will upload code IDs for each contract, instantiate each contract, initialize assets, and set oracles. If you want to redeploy, you must locally delete the file with .json
extension (e.g. devnet-deployer-owner.json
) in the artifacts directory.
Everything related to deployment must be ran from the scripts
directory.
Each outpost has a config file for its respective deployment and assets.
For Osmosis:
cd scripts
# for devnet deployment with deployerAddr set as owner & admin:
yarn deploy:osmosis-devnet
# for mainnet deployment:
yarn deploy:osmosis-mainnet
cargo make --makefile Makefile.toml generate-all-schemas
Creates JSON schema files for relevant contract calls, queries and query responses (See: cosmwams-schema).
rustfmt
is used to format any Rust source code:
cargo make fmt
clippy
is used as a linting tool:
cargo make clippy
Install Go. It is used by osmosis-test-tube dependency.
Integration tests (task integration-test
or test
) use .wasm
files. They have to be generated with cargo make build
.
Run unit tests:
cargo make unit-test
Run integration tests:
cargo make integration-test
Run all tests:
cargo make test
Contract | Address | Tag |
---|---|---|
mars-address-provider | osmo1g677w7mfvn78eeudzwylxzlyz69fsgumqrscj6tekhdvs8fye3asufmvxr |
v2.0.0 |
mars-account-nft | osmo1450hrg6dv2l58c0rvdwx8ec2a0r6dd50hn4frk370tpvqjhy8khqw7sw09 |
v2.0.0 |
mars-credit-manager | osmo1f2m24wktq0sw3c0lexlg7fv4kngwyttvzws3a3r3al9ld2s2pvds87jqvf |
v2.0.5 |
mars-health | osmo1pdc49qlyhpkzx4j24uuw97kk6hv7e9xvrdjlww8qj6al53gmu49sge4g79 |
v2.0.0 |
mars-incentives | osmo1nkahswfr8shg8rlxqwup0vgahp0dk4x8w6tkv3rra8rratnut36sk22vrm |
v2.0.0 |
mars-oracle | osmo1mhznfr60vjdp2gejhyv2gax9nvyyzhd3z0qcwseyetkfustjauzqycsy2g |
v2.0.1 |
mars-params | osmo1nlmdxt9ctql2jr47qd4fpgzg84cjswxyw6q99u4y4u4q6c2f5ksq7ysent |
v2.0.3 |
mars-red-bank | osmo1c3ljch9dfw5kf52nfwpxd2zmj2ese7agnx0p9tenkrryasrle5sqf3ftpg |
v2.0.5 |
mars-rewards-collector | osmo1urvqe5mw00ws25yqdd4c4hlh8kdyf567mpcml7cdve9w08z0ydcqvsrgdy |
v2.0.4 |
mars-swapper | osmo1wee0z8c7tcawyl647eapqs4a88q8jpa7ddy6nn2nrs7t47p2zhxswetwla |
v2.0.7 |
mars-zapper | osmo17qwvc70pzc9mudr8t02t3pl74hhqsgwnskl734p4hug3s8mkerdqzduf7c |
v2.0.0 |
See repo: core-contracts
Module Account | Address |
---|---|
fee_collector |
mars17xpfvakm2amg962yls6f84z3kell8c5ldy6e7x |
safety |
mars1s4hgh56can3e33e0zqpnjxh0t5wdf7u3pze575 |
Contents of this repository are open source under GNU General Public License v3 or later.