Liquidation Contract
The Liquidation Contract enables users to submit Terra stablecoin bids for a Cw20-compliant token. Bidders can specify the rate of premium they will receive on bid execution, and the maximum premium rate is set at 30%.
Upon execution of a bid, Cw20 tokens are sent to the bidder, while the bidder's Terra stablecoins are sent to the repay address (if not specified, sent to message sender). The oracle contract is responsible for providing the relevant Cw20 token prices.
Additionally, the Liquidation Contract serves as the point of calculation for partial collateral liquidations, where a loan position is liquidated until it reaches a safe borrow_amount / borrow_limit
ratio. The required liquidation amount for each collateral is calculated based on the fed-in loan position's attributes.
Price data from the Oracle contract are only valid for 60 seconds (price_timeframe
). The Liquidation contract disables bid executions until new price data is fed-in to the Oracle contract.
Config
Key | Type | Description |
| CanonicalAddr | Address of contract owner that can update config |
| CanonicalAddr | Contract address of Oracle |
| String | Native token denomination for bids |
| Decimal256 | A liability / borrow limit ratio of a loan deemed safe |
| Decimal256 | Fee rate applied to all executed bids |
| Decimal256 | Maximum rate of commission given to bidder of an executed bid |
| Uint256 | Threshold collateral value for partial collateral liquidations |
| u64 | Window of time before oracle price data is considered outdated [seconds] |
InstantiateMsg
Key | Type | Description |
| String | Address of contract owner that can update config |
| String | Contract address of Oracle |
| String | Native token denomination for bids |
| Decimal256 | A liability / borrow limit ratio of a loan deemed safe |
| Decimal256 | Fee rate applied to executed bids |
| Decimal256 | Maximum rate of commission given to the bidder of an executed bid |
| Uint256 | Threshold collateral value for triggering partial collateral liquidations |
| u64 | Window of time before oracle price data is considered outdated [seconds] |
ExecuteMsg
Receive
Receive
Can be called during a CW20 token transfer when the Liquidation Contract is the recipient. Allows the token transfer to execute a Receive Hook as a subsequent action within the same transaction.
Key | Type | Description |
| String | Sender of the token transfer |
| Uint128 | Amount of tokens received |
| Binary | Base64-encoded string of JSON of Receive Hook |
UpdateConfig
UpdateConfig
Updates the Liquidation Contract's configuration. Can only be issued by the owner.
Key | Type | Description |
| String | Address of new owner |
| String | New oracle contract address |
| String | New native token denomination for bids |
| Decimal256 | New liability / borrow limit of a loan deemed safe |
| Decimal256 | New fee rate applied to executed bids |
| Decimal256 | New maximum rate of commission given to the bidder of an executed bid |
| Uint256 | New threshold collateral value for triggering partial collateral liquidations |
| u64 | New window of time before price data is considered outdated [seconds] |
* = optional
SubmitBid
SubmitBid
Submits a new bid for the specified Cw20 collateral with the specified premium rate. Requires Terra stablecoins to be sent beforehand.
Key | Type | Description |
| String | Cw20 token contract address of bidding collateral |
| Decimal256 | Rate of commission on executing this bid |
RetractBid
RetractBid
Withdraws specified amount of stablecoins from the bid for the specified collateral. Withdraws the entire bid for the specified collateral if the amount
field is not filled.
Key | Type | Description |
| String | Cw20 token contract address of bidding collateral |
| Uint256 | Amount of stablecoins remove from bid |
* = optional
Receive Hooks
ExecuteBid
ExecuteBid
Liquidates collateral by executing an existing bid for the received collateral. Requires the liquidator
to have an existing bid. For Usage in Anchor, Custody
issues this message with fee_address
as Overseer
's contract address and repay_address
as Market
's contract address, where stablecoins from the bid is sent to the Market contract to repay a borrower's loan and fees are sent to the Overseer contract to be added to the interest buffer.
Key | Type | Description |
| String | Address of collateral liquidator |
| String | Address to receive |
| String | Address to receive bid stablecoins from liquidation |
* = optional
QueryMsg
Config
Config
Gets the Liquidation Contract's configuration.
Key | Type | Description |
ConfigResponse
ConfigResponse
Key | Type | Description |
| String | Address of contract owner that can update config |
| String | Contract address of Oracle |
| String | Native token denomination for bids |
| Decimal256 | A liability / borrow limit ratio of a loan deemed safe |
| Decimal256 | Fee rate applied to all executed bids |
| Decimal256 | Maximum rate of commission given to bidder of an executed bid |
| Uint256 | Threshold collateral value for partial collateral liquidations |
| u64 | Window of time before price data is considered outdated [seconds] |
LiquidationAmount
LiquidationAmount
Gets the amount of collaterals that needs to be liquidated in order for the borrower's loan to reach safe_ratio
, based on the fed in borrower's status.
Key | Type | Description |
| Uint256 | Liability of borrower |
| Uint256 | Borrow limit of borrower |
| TokensHuman | Held collaterals and locked amounts |
| Vec<Decimal> | Vector of collateral prices |
Key | Type | Description |
| Vec<(String, Uint256)> | Vector of (Collateral's token address, Amount of collateral locked by borrower) |
LiquidationAmountResponse
LiquidationAmountResponse
Key | Type | Description |
| TokensHuman | Calculated amount of collaterals to liquidate |
Key | Type | Description |
| Vec<(String, Uint256)> | Vector of (Collateral's token address, Amount that has to be liquidated) |
Bid
Bid
Gets information about the specified bidder's bid for the specified collateral.
Key | Type | Description |
| String | Token contract address of bidding collateral |
| String | Address of bidder |
BidResponse
BidResponse
Key | Type | Description |
| String | Token contract address of bidding collateral |
| String | Address of bidder |
| Uint256 | Amount of stablecoins put up in bid |
| Decimal256 | Rate of commission taken by bidder upon bid execution |
BidsByUser
BidsByUser
Gets information for all bids submitted by the specified bidder
Key | Type | Description |
| String | Address of bidder |
| String | Token contract address of collateral to start query |
| u32 | Maximum number of query entries |
BidsByUserResponse
BidsByUserResponse
Key | Type | Description |
| Vec<BidResponse> | Vector of user's bid information |
Key | Type | Description |
| String | Token contract address of bidding collateral |
| String | Address of bidder |
| Uint256 | Amount of stablecoins put up in bid |
| Decimal256 | Rate of commission taken by bidder upon bid execution |
BidsByCollateral
BidsByCollateral
Gets bid information for all bids submitted for the specified collateral.
Key | Type | Description |
| String | Token contract address of collateral |
| String | Token contract address of collateral to start query |
| u32 | Maximum number of query entries |
* = optional
BidsByCollateralResponse
BidsByCollateralResponse
Key | Type | Description |
| Vec<BidResponse> | Vector of user's bid information |
Key | Type | Description |
| String | Token contract address of bidding collateral |
| String | Address of bidder |
| Uint256 | Amount of stablecoins put up in bid |
| Decimal256 | Rate of commission taken by bidder upon bid execution |
Last updated