A Rust and CosmWasm implementation of the Capapult Protocol money market on the Terra blockchain.
Contract | Reference | Description |
---|---|---|
oracle |
smart-contracts/money-market/oracle | Provides a price feed for LSD collaterals |
liquidation_queue |
smart-contracts/money-market/liquidation_queue | Provides a queue for LSD collateral liquidations |
custody_cw20 |
smart-contracts/money-market/custody_bluna | Handles cw20 collaterals deposits and withdrawals |
market |
smart-contracts/money-market/market) | Handles SOLID borrows and repay |
overseer |
smart-contracts/money-market/overseer | Manages money market overalls, stores borrower information |
flowchart LR
subgraph MONEY MARKET
direction LR
subgraph users [Users]
borrower[Borrower]
liquidator[Liquidator]
end
subgraph custody[Custody]
deposit[Deposit]
withdraw[Withdraw]
c_lock_collateral[Lock Collateral]
c_unlock_collateral[Unlock Collateral]
distribute_rewards[Distribute Rewards]
end
subgraph market[Market]
borrow[Borrow]
repay[Repay]
end
subgraph overseer[Overseer]
epoch_operations[Execute Epoch Operations]
liquidate[Liquidate Collateral]
lock_collateral[Lock Collateral]
unlock_collateral[Unlock Collateral]
end
subgraph liquidation_contract[Liquidation Contract]
l_liquidate[Liquidate Collateral]
end
subgraph interest_model[Interest Model]
compute_interest[Compute Interest]
end
subgraph collateral[Collateral]
unbond[Unbond]
end
subgraph interest_model[Interest Model]
compute_interest[Compute Interest]
end
subgraph collector[Collector]
compute_interest[Compute Interest]
end
subgraph gov[Governance]
stake[Stake]
claim_rewards[Claim Rewards]
end
subgraph astroport_pair[Astroport Pair]
swap[Swap]
end
subgraph team[Team]
end
borrower ---> | 1. Send LunaX | deposit
borrower ---> | 2. Lock Collateral | lock_collateral
lock_collateral ---> | 2.1. Lock Collateral | c_lock_collateral
borrower ---> | 3. Mint Solid | borrow
borrower ---> | 4. Burn Solid | repay
repay ---> | 4.1. Compute Interest | compute_interest
borrower ---> | 5. Unlock Collateral | unlock_collateral
unlock_collateral ---> | 6.1 Unlock Collateral | c_unlock_collateral
borrower ---> | 7. Withdraw Collateral | withdraw
liquidator ---> | 3. Liquidate Collateral | liquidate
liquidate ---> | 3.1. Liquidate Collateral | l_liquidate
epoch_operations ---> | 8 Compute Rewards | distribute_rewards
distribute_rewards ---> | 8.1 Unbond Rewards | unbond
distribute_rewards ---> | 8.2 Swap Luna | swap
distribute_rewards ---> | 8.3 Send Solid | collector
collector ---> | 8.4 Send Solid | team
collector ---> | 8.4 Send Solid | gov
end
- 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
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/workspace-optimizer:0.12.6
This performs several optimizations which can significantly reduce the final size of the contract binaries, which will be available inside the artifacts/
directory.
This repository is licensed under the Apache 2.0 license. See LICENSE for full disclosure.