kujira_orca/
lib.rs

1//! [Kujira's](https://orca.kujira.app/) plug-and-play liquidation queue contract
2//! for all CosmWASM compatible Blockchains.
3//!
4//! Designed to create a backstop of solvency against liquidations on your Protocol, a liquidation
5//! queue provides a community-focused and decentralized way of bidding for at-risk collateral. At the same time the
6//! gamification of the bidding process creates competition between bidders, allowing market forces to determine
7//! a discount percentage.
8//!
9//! If you're interested in deploying a liquidation queue for your Protocol and having it listed on Orca in front of
10//! 50,000+ bidders, reach out in our [Telegragm Group](https://t.me/team_kujira).
11//!
12//! # Features
13//! ### Direct Orca Integration
14//! Any contract initialized with this interface can be integrated into the Orca UI at <https://orca.kujira.app/>.
15//!
16//! The easiest way to do this is by using one of the Code IDs from the deployed contract list below.
17//!
18//! ### Configurable Pools
19//! Full control over the discounts available for bidders. Set the number of pools, and the incremental amount
20//! of discount per-pool.
21//!
22//! ### Closable Pools
23//! Optionally close off specific pools from new bids. This can be useful when bootstrapping liquidity in a new
24//! liquidation queue, for example, where you close lower percentage pools for a fixed period of time,
25//! guaranteeing bidders a minimum discount percentage on liquidations in that time.
26//!
27//! ### Custom Swappers
28//! Allow bidders to place bids in a different asset to the one your Protocol requires repayment in.
29//! On Terra we use these for example to support native aUST bidding, where a market requires repayment
30//! in UST. The bids can be denominated in yield-bearing aUST right up until the point that the liquidation
31//! ocurrs and the market is repaid.
32//!
33//! ### Delegated Activation
34//! No more missed liquidations! When you submit a bid, you can optionally include a delegate address,
35//! which is permitted to activate the bid on your behalf. Kujira will have a bot that liquidation queues can
36//! be registered with, so that bidders can have their bids automatically activated as soon as the wait_end
37//! period expires.
38//!
39//! # Getting Started
40//! ## Deploy A Contract
41//! The easiest way to get up and running to to instantiate our own audited contract with the code IDs below.
42//! Here is a sample JSON-encoded init message, where the bid denomination is Terra's aUST, and the collateral
43//! that is being bid on is the Native Luna, and fees connected to Kujira's [sKUJI Protocol Revenue Pool](https://blue.kujira.app/).
44//! ```json
45//!  {
46//!    "owner": "terra123...",
47//!    "market": "terra123...",
48//!    "bid_denom": {
49//!      "cw20": "terra1ajt556dpzvjwl0kl5tzku3fc3p3knkg9mkv8jl"
50//!    },
51//!    "collateral_denom": {
52//!      "native": "uluna"
53//!    },
54//!    "bid_threshold": "10000000",
55//!    "max_slot": 15,
56//!    "premium_rate_per_slot": "0.01",
57//!    "waiting_period": 600,
58//!    "liquidation_fee": "0.01",
59//!    "withdrawal_fee": "0.005",
60//!    "fee_address": "terra1vvj874nwtmxk0u0spj83d364xyhqk2e652jrck"
61//!  }
62
63//! ```
64//!
65//! ## Integrating your Market
66//!
67//! 1. Add the package to Cargo.toml
68//!
69//! `kujira = "0.2.1"`
70//!
71//! 2. Extend your contract config to store the address of your new liquidation queue
72//! ```rust ignore
73//! pub struct Config {
74//!   liquidation_contract: Addr,
75//!   ..,
76//! }
77//! ```
78//! 3. Transfer funds to the liquidation queue at the point of liquidation
79//! ```rust ignore
80//! fn liquidate_collateral(deps: DepsMut, ..) -> StdResult<Response> {
81//!   // ..
82//!   let msg = CosmosMsg::Wasm(WasmMsg::Execute {
83//!     contract: config.liquidation_contract,
84//!     msg: to_json_binary(&kujira::orca::ExecuteMsg::ExecuteLiquidation {
85//!       exchange_rate,
86//!       repay_denom: Denom::Cw20("terra1ajt556dpzvjwl0kl5tzku3fc3p3knkg9mkv8jl"),
87//!     }),
88//!     funds: coins(collateral_amount, "uluna")
89//!   });
90//!
91//!   Ok(Response::default().add_message(msg))
92//! }
93//! ```
94//!
95//! ### Terra
96//! - Mainnet: Code ID `3541`
97//! - Testnet: Code ID `52750`
98
99pub mod execute;
100pub mod instantiate;
101pub mod query;
102
103pub use {execute::*, instantiate::*, query::*};