MCPcopy Index your code
hub / github.com/Mirror-Protocol/mirror-contracts

github.com/Mirror-Protocol/mirror-contracts @v2.2.0

Chat with this repo
repository ↗ · DeepWiki ↗ · release v2.2.0 ↗ · + Follow
796 symbols 2,980 edges 123 files 88 documented · 11% updated 4y agov2.2.0 · 2022-04-01★ 1346 open issues
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Mirror Core Contracts

This monorepository contains the source code for the core smart contracts implementing Mirror Protocol on the Terra blockchain.

You can find information about the architecture, usage, and function of the smart contracts on the official Mirror documentation site.

Dependencies

Mirror depends on Terraswap and uses its implementation of the CW20 token specification.

Contracts

Contract Reference Description
mirror_collector doc Gathers protocol fees incurred from CDP withdrawals and liquidations and sends to Gov
mirror_community doc Manages the commuinty pool fund
mirror_factory doc Central directory that organizes the various component contracts of Mirror
mirror_gov doc Allows other Mirror contracts to be controlled by decentralized governance, distributes MIR received from Collector to MIR stakers
mirror_mint doc Handles CDP creation, management and liquidation
mirror_oracle doc Provides interface for oracle feeders to post prices for mAssets
mirror_staking doc Distributes MIR rewards from block reward to LP stakers
mirror_lock doc Locks the UST obtained from selling mAssets on shorting positions
mirror_collateral_oracle doc Directory of whitelisted collateral assets, acts as a proxy to different price sources on the Terra ecosystem
mirror_limit_order doc Provides a limit order intrface for bidders and arbitrage opportunities for market makers
mirror_short_reward doc Implements the calculations to obtain the reward portion given to sLP stakers

Development

Environment Setup

  • 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
  1. Make sure Docker is installed

Unit / Integration Tests

Each contract contains Rust unit tests embedded within the contract source directories. You can run:

cargo unit-test

Compiling

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

Production

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.11.3

This performs several optimizations which can significantly reduce the final size of the contract binaries, which will be available inside the artifacts/ directory.

License

Copyright 2020 Mirror Protocol

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0. Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

See the License for the specific language governing permissions and limitations under the License.

Core symbols most depended-on inside this repo

as_ref
called by 185
contracts/mirror_factory/src/response.rs
execute
called by 180
contracts/mirror_gov/src/contract.rs
execute
called by 98
contracts/mirror_mint/src/contract.rs
mock_dependencies
called by 73
contracts/mirror_gov/src/testing/mock_querier.rs
execute
called by 69
contracts/mirror_staking/src/contract.rs
with_token_balances
called by 62
contracts/mirror_gov/src/testing/mock_querier.rs
query
called by 39
contracts/mirror_gov/src/contract.rs
execute
called by 36
contracts/mirror_factory/src/contract.rs

Shape

Function 536
Class 137
Method 76
Enum 47

Languages

Rust100%

Modules by API surface

contracts/mirror_gov/src/testing/tests.rs55 symbols
contracts/mirror_factory/src/response.rs31 symbols
contracts/mirror_gov/src/state.rs28 symbols
contracts/mirror_gov/src/contract.rs27 symbols
contracts/mirror_mint/src/state.rs23 symbols
packages/mirror_protocol/src/gov.rs22 symbols
contracts/mirror_factory/src/state.rs19 symbols
contracts/mirror_factory/src/contract.rs19 symbols
contracts/mirror_mint/src/testing/mock_querier.rs18 symbols
contracts/mirror_factory/src/testing/mock_querier.rs15 symbols
contracts/mirror_collector/src/testing/mock_querier.rs15 symbols
contracts/mirror_collateral_oracle/src/testing/mock_querier.rs15 symbols

For agents

$ claude mcp add mirror-contracts \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page