7 releases (3 stable)

1.3.0 Jun 25, 2024
1.1.0 May 18, 2024
1.0.0 Mar 26, 2024
0.8.3 Jan 30, 2024
0.8.0 Apr 15, 2023

#5 in #kujira

Download history 206/week @ 2024-07-20 216/week @ 2024-07-27 74/week @ 2024-08-03 188/week @ 2024-08-10 39/week @ 2024-08-17 82/week @ 2024-08-24 209/week @ 2024-08-31 69/week @ 2024-09-07 88/week @ 2024-09-14 101/week @ 2024-09-21 47/week @ 2024-09-28 13/week @ 2024-10-05 41/week @ 2024-10-12 21/week @ 2024-10-19 18/week @ 2024-10-26 22/week @ 2024-11-02

102 downloads per month
Used in 5 crates (2 directly)

Apache-2.0

59KB
1.5K SLoC

Kujira's plug-and-play liquidation queue contract for all CosmWASM compatible Blockchains.

Designed to create a backstop of solvency against liquidations on your Protocol, a liquidation queue provides a community-focused and decentralized way of bidding for at-risk collateral. At the same time the gamification of the bidding process creates competition between bidders, allowing market forces to determine a discount percentage.

If you're interested in deploying a liquidation queue for your Protocol and having it listed on Orca in front of 50,000+ bidders, reach out in our Telegragm Group.

Features

Direct Orca Integration

Any contract initialized with this interface can be integrated into the Orca UI at https://orca.kujira.app/.

The easiest way to do this is by using one of the Code IDs from the deployed contract list below.

Configurable Pools

Full control over the discounts available for bidders. Set the number of pools, and the incremental amount of discount per-pool.

Closable Pools

Optionally close off specific pools from new bids. This can be useful when bootstrapping liquidity in a new liquidation queue, for example, where you close lower percentage pools for a fixed period of time, guaranteeing bidders a minimum discount percentage on liquidations in that time.

Custom Swappers

Allow bidders to place bids in a different asset to the one your Protocol requires repayment in. On Terra we use these for example to support native aUST bidding, where a market requires repayment in UST. The bids can be denominated in yield-bearing aUST right up until the point that the liquidation ocurrs and the market is repaid.

Delegated Activation

No more missed liquidations! When you submit a bid, you can optionally include a delegate address, which is permitted to activate the bid on your behalf. Kujira will have a bot that liquidation queues can be registered with, so that bidders can have their bids automatically activated as soon as the wait_end period expires.

Getting Started

Deploy A Contract

The easiest way to get up and running to to instantiate our own audited contract with the code IDs below. Here is a sample JSON-encoded init message, where the bid denomination is Terra's aUST, and the collateral that is being bid on is the Native Luna, and fees connected to Kujira's sKUJI Protocol Revenue Pool.

 {
   "owner": "terra123...",
   "market": "terra123...",
   "bid_denom": {
     "cw20": "terra1ajt556dpzvjwl0kl5tzku3fc3p3knkg9mkv8jl"
   },
   "collateral_denom": {
     "native": "uluna"
   },
   "bid_threshold": "10000000",
   "max_slot": 15,
   "premium_rate_per_slot": "0.01",
   "waiting_period": 600,
   "liquidation_fee": "0.01",
   "withdrawal_fee": "0.005",
   "fee_address": "terra1vvj874nwtmxk0u0spj83d364xyhqk2e652jrck"
 }

Integrating your Market

  1. Add the package to Cargo.toml

kujira = "0.2.1"

  1. Extend your contract config to store the address of your new liquidation queue
pub struct Config {
  liquidation_contract: Addr,
  ..,
}
  1. Transfer funds to the liquidation queue at the point of liquidation
fn liquidate_collateral(deps: DepsMut, ..) -> StdResult<Response> {
  // ..
  let msg = CosmosMsg::Wasm(WasmMsg::Execute {
    contract: config.liquidation_contract,
    msg: to_json_binary(&kujira::orca::ExecuteMsg::ExecuteLiquidation {
      exchange_rate,
      repay_denom: Denom::Cw20("terra1ajt556dpzvjwl0kl5tzku3fc3p3knkg9mkv8jl"),
    }),
    funds: coins(collateral_amount, "uluna")
  });

  Ok(Response::default().add_message(msg))
}

Terra

  • Mainnet: Code ID 3541
  • Testnet: Code ID 52750

Dependencies

~4–7.5MB
~152K SLoC