Platform: Code4rena
Start Date: 24/02/2022
End Date: 09/03/2022
Period: 14 days
Status: Completed
Pot Size: $170,000 UST
Participants: 16
Reporter: liveactionllama
Judge: Albert Chon
Id: 82
League: COSMOS
cmichel | 1/16 | $34,330.99 | 7 | 1 | 0 | 5 | 4 | - | 0 | 0 |
WatchPug | 2/16 | $28,522.98 | 6 | 1 | 1 | 3 | 1 | - | - | 0 |
jmak | 3/16 | $18,202.54 | 1 | 1 | 1 | 0 | 0 | 0 | 0 | 0 |
csanuragjain | 4/16 | $12,853.92 | 3 | 1 | 0 | 1 | 0 | 0 | - | 0 |
BondiPestControl | 5/16 | $9,341.57 | 4 | 0 | 0 | 3 | 1 | - | 0 | 0 |
defsec | 6/16 | $7,905.18 | 4 | 0 | 0 | 2 | 1 | - | - | 0 |
hubble | 7/16 | $7,300.23 | 2 | 0 | 0 | 1 | 1 | - | 0 | 0 |
broccoli | 8/16 | $7,144.35 | 3 | 0 | 0 | 2 | 1 | - | 0 | 0 |
hickuphh3 | 9/16 | $4,319.20 | 2 | 0 | 0 | 0 | 0 | - | - | 0 |
gzeon | 10/16 | $1,766.75 | 2 | 0 | 0 | 0 | 0 | - | - | 0 |
Auditor per page
Anchor is a decentralized savings protocol offering low-volatile yields on Terra stablecoin deposits. The Anchor rate is powered by a diversified stream of staking rewards from major proof-of-stake blockchains, and therefore can be expected to be much more stable than money market interest rates. The Anchor community believes that a stable, reliable source of yield in Anchor has the opportunity to become the reference interest rate in crypto. The Anchor protocol defines a money market between a lender, looking to earn stable yields on their stablecoins, and a borrower, looking to borrow stablecoins on stakeable assets. To borrow stablecoins, the borrower locks up Bonded Assets (bAssets) as collateral, and borrows stablecoins below the protocol-defined borrowing ratio. The diversified stream of staking rewards accruing to the global pool of collateral then gets converted to stablecoin, and then conferred to the lender in the form of a stable yield.
Deposited stablecoins are represented by Anchor Terra (aTerra). aTerra tokens are redeemable for the initial deposit along with accrued interest, allowing interest collection to be done just by holding on to them. Anchor is structured to provide depositors with: *High, stable deposit yields powered by rewards of bAsset collaterals *Instant withdrawals through pooled lending of stablecoin deposits *Principal protection via liquidation of loans in risk of undercollateralization
Anchor is an open, permissionless savings protocol, meaning that any third-party application is free to connect and earn interest without restrictions. Through Anchor Earn, Anchor.js or EthAnchor, developers can interact with Anchor using just a few lines of code. Further documentation of the Anchor Protocol is provided in the following pages.
For more info see https://docs.anchorprotocol.com/
This monorepository contains the source code for the smart contracts implementing bAsset Protocol on the Terra blockchain.
You can find information about the architecture, usage, and function of the smart contracts on the official Anchor documentation site.
Contract | Reference | Description |
---|---|---|
anchor_basset_hub | doc | Manages minted bLunas and bonded Lunas |
anchor_basset_reward | doc | Manages the distribution of delegation rewards |
anchor_basset_token | doc | CW20 compliance |
anchor_airdrop_registery | doc | Manages message fabricators for MIR and ANC airdrops |
wasm32-unknown-unknown
targetInstall rustup
via https://rustup.rs/
Run the following:
rustup default stable rustup target add wasm32-unknown-unknown
Each contract contains Rust unit tests embedded within the contract source directories. You can run:
cargo test unit-test cargo test 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/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.
This monorepository contains the source code for the smart contracts implementing bEth on the Terra blockchain.
You can find information about the architecture, usage, and function of the smart contracts on the official Anchor documentation site.
wasm32-unknown-unknown
targetInstall rustup
via https://rustup.rs/
Run the following:
rustup default stable rustup target add wasm32-unknown-unknown
Each contract contains Rust unit tests embedded within the contract source directories. You can run:
cargo test unit-test cargo test 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/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.
Copyright 2021 Anchor 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.
This monorepository contains the source code for the Money Market smart contracts implementing Anchor Protocol on the Terra blockchain.
You can find information about the architecture, usage, and function of the smart contracts on the official Anchor documentation site.
Anchor Token depends on Terraswap and uses its implementation of the CW20 token specification.
Contract | Reference | Description |
---|---|---|
airdrop | doc | Holds ANC tokens which are to be used Luna staker incentives |
collector | doc | Accumulates protocol fees, converts them to ANC and distributes to ANC stakers |
community | doc | Manages ANC community grants |
distributor | doc | Holds ANC tokens which are to be used as borrower incentives |
gov | doc | Handles Anchor Governance and reward distribution to ANC stakers |
staking | doc | Handles ANC-UST pair LP token staking |
vesting | doc | Holds ANC tokens which are to be used ANC token allocation vesting |
wasm32-unknown-unknown
targetInstall rustup
via https://rustup.rs/
Run the following:
rustup default stable rustup target add wasm32-unknown-unknown
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/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.
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.
Money Market has dependencies on Anchor Token Contracts and bAsset 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 |
custody_beth | doc | Handles bEth 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 |
wasm32-unknown-unknown
targetInstall rustup
via https://rustup.rs/
Run the following:
rustup default stable rustup target add wasm32-unknown-unknown
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/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.
This repository is licensed under the Apache 2.0 license. See LICENSE for full disclosure.
© 2021 Anchor Protocol.
Terra contract deployed to represent some cross-chain address Interfaces with anchor contracts directly
Takes all the user facing messages that anchor takes, except they also include information about the cross-chain sender Proxies messages to the appropriate AddressProxy
Receives data and wrapped tokens from various bridges Parses data into messages readable by Core, and forwards---
npm run compile_eth npm run compile_terra
env.json
contains all relevant information for a testnet deployment. To deploy xAnchor to testnet:
npm run deploy
This will also rewrite the contract addresses in env.json
with the most recently deployed set
npm run test
This will run tests against the deployed contracts in env.json
Deploying everything takes a while. Since both of ETH and Terra side contracts are upgradable, we can update them in place to speed up our iteration time.
npm run migrate_terra npm run migrate_eth
Opcodes are specified as 8-bit unsigned integers. We split the opcode into two parts:
We have the following flags defined:
0b10
: FLAG_INCOMING_TRANSFER
0b01
: FLAG_OUTGOING_TRANSFER
0b11
: FLAG_BOTH_TRANSFERS
0b00
: FLAG_NO_ASSC_TRANSFERS
We have the following opcodes:
Opcode | Flags | Full Opcode | Decimal |
---|---|---|---|
Deposit Stable | FLAG_BOTH_TRANSFERS | 0b110000 | 192 |
Redeem Stable | FLAG_BOTH_TRANSFERS | 0b110001 | 193 |
Repay Stable | FLAG_INCOMING_TRANSFER | 0b1000000 | 64 |
Lock Collateral | FLAG_INCOMING_TRANSFER | 0b1000001 | 65 |
Unlock Collateral | FLAG_OUTGOING_TRANSFER | 0b0100000 | 32 |
Borrow Stable | FlAG_OUTGOING_TRANSFER | 0b0100001 | 33 |
Claim Rewards | FLAG_OUTGOING_TRANSFER | 0b0100010 | 34 |