MCPcopy Index your code
hub / github.com/Anchor-Protocol/money-market-contracts

github.com/Anchor-Protocol/money-market-contracts @v0.3.1

Chat with this repo
repository ↗ · DeepWiki ↗ · release v0.3.1 ↗ · + Follow
612 symbols 2,537 edges 106 files 62 documented · 10%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

codecov

Anchor Money Market Contracts

A Rust and CosmWasm implementation of the Anchor Protocol money market on the Terra blockchain.

You can find information about the architecture, usage, and function of the smart contracts in the documentation.

Dependencies

Money Market has dependencies on Anchor Token Contracts and bAsset Contracts.

Contracts

Contract Reference Description
overseer doc Manages money market overalls, stores borrower information
market doc Handles Terra stablecoin deposits and borrows, ANC distribution to borrowers
custody_bluna doc Handles bLuna collateral deposits and withdrawals
interest_model doc Calculates the current borrow interest rate based on the market situation
distribution_model doc Calculates the borrower ANC emission rate based on the previous emission rate
oracle doc Provides a price feed for bAsset collaterals
liquidation doc OTC exchange contract for bAsset collateral liquidations

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 and integration tests embedded within the contract source directories. You can run:

cargo unit-test
cargo integration-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.5

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

License

This repository is licensed under the Apache 2.0 license. See LICENSE for full disclosure.

© 2021 Anchor Protocol.

Extension points exported contracts — how you extend this code

TokensMath (Interface)
(no doc) [1 implementers]
packages/moneymarket/src/tokens.rs
TokensToHuman (Interface)
(no doc) [1 implementers]
packages/moneymarket/src/tokens.rs
TokensToRaw (Interface)
(no doc) [1 implementers]
packages/moneymarket/src/tokens.rs

Core symbols most depended-on inside this repo

execute
called by 286
contracts/liquidation_queue/src/contract.rs
as_ref
called by 170
contracts/market/src/response.rs
execute
called by 49
contracts/market/src/contract.rs
instantiate
called by 46
contracts/liquidation_queue/src/contract.rs
mock_dependencies
called by 46
contracts/liquidation_queue/src/testing/mock_querier.rs
with_collateral_max_ltv
called by 44
contracts/liquidation_queue/src/testing/mock_querier.rs
query
called by 39
contracts/liquidation_queue/src/contract.rs
with_tax
called by 39
contracts/liquidation_queue/src/testing/mock_querier.rs

Shape

Function 398
Class 94
Method 81
Enum 36
Interface 3

Languages

Rust100%

Modules by API surface

contracts/market/src/response.rs31 symbols
contracts/liquidation_queue/src/state.rs24 symbols
contracts/overseer/src/testing/mock_querier.rs21 symbols
contracts/market/src/testing/mock_querier.rs19 symbols
contracts/liquidation_queue/src/testing/query_liq_amount_tests.rs19 symbols
contracts/liquidation_queue/src/testing/mock_querier.rs15 symbols
contracts/overseer/src/state.rs14 symbols
contracts/custody_bluna/src/testing/mock_querier.rs14 symbols
contracts/custody_beth/src/testing/mock_querier.rs14 symbols
contracts/liquidation_queue/src/testing/bid_pools_tests.rs13 symbols
contracts/market/src/contract.rs12 symbols
contracts/market/src/borrow.rs12 symbols

For agents

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

⬇ download graph artifact

Ask about this repo answers extend the page