Custody [bLUNA]
The Custody contract is where supplied bAsset collaterals are managed. Users can make collateral deposits and withdrawals to and from this contract. The Custody contract is also responsible for claiming bAsset rewards and converting them to Terra stablecoins, which is then sent to the Overseer contract for eventual distribution.

Config

Key
Type
Description
owner
CanonicalAddr
Address of contract owner
collateral_token
CanonicalAddr
Contract address of bLuna Token
overseer_contract
CanonicalAddr
Contract address of Overseer
market_contract
CanonicalAddr
Contract address of Market
reward_contract
CanonicalAddr
Contract address of bLuna Reward
liquidation_contract
CanonicalAddr
Contract address of Liquidation Contract
stable_denom
String
Native token denomination for stablecoin
basset_info
BAssetInfo
bAsset token information

InstantiateMsg

Rust
JSON
1
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
2
#[serde(rename_all = "snake_case")]
3
pub struct InstantiateMsg {
4
pub owner: String,
5
pub collateral_token: String,
6
pub overseer_contract: String,
7
pub market_contract: String,
8
pub reward_contract: String,
9
pub liquidation_contract: String,
10
pub stable_denom: String,
11
pub basset_info: BAssetInfo,
12
}
13
14
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
15
pub struct BAssetInfo {
16
pub name: String,
17
pub symbol: String,
18
pub decimals: u8,
19
}
Copied!
1
{
2
"owner": "terra1...",
3
"collateral_token": "terra1...",
4
"overseer_contract": "terra1...",
5
"market_contract": "terra1...",
6
"reward_contract": "terra1...",
7
"liquidation_contract": "terra1...",
8
"stable_denom": "uusd",
9
"basset_info": {
10
"name": "bonded luna",
11
"symbol": "ubluna",
12
"decimals": 6
13
}
14
}
Copied!
Key
Type
Description
owner
String
Address of contract owner
collateral_token
String
Contract address of bLuna Token
overseer_contract
String
Contract address of Overseer
market_contract
String
Contract address of Market
reward_contract
String
Contract address of bLuna Reward
liquidation_contract
String
Contract address of Liquidation Contract
stable_denom
String
Native token denomination for stablecoin
basset_info
BAssetInfo
bAsset token information
Key
Type
Description
name
String
Name of bAsset
symbol
String
Symbol of bAsset
decimals
u8
Number of decimals of bAsset token

ExecuteMsg

Receive

Can be called during a Cw20 token transfer when the Mint contract is the recipient. Allows the token transfer to execute a Receive Hook as a subsequent action within the same transaction.
Rust
JSON
1
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
2
#[serde(rename_all = "snake_case")]
3
pub enum ExecuteMsg {
4
Receive {
5
sender: String,
6
amount: Uint128,
7
msg: Binary,
8
}
9
}
Copied!
1
{
2
"receive": {
3
"sender": "terra1...",
4
"amount": "10000000",
5
"msg": "eyAiZXhlY3V0ZV9tc2ciOiAiYmluYXJ5IiB9"
6
}
7
}
Copied!
Key
Type
Description
sender
String
Sender of the token transfer
amount
Uint128
Amount of tokens received
msg
Binary
Base64-encoded string of JSON of Receive Hook

UpdateConfig

Updates the configuration of the Custody contract.
Rust
JSON
1
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
2
#[serde(rename_all = "snake_case")]
3
pub enum ExecuteMsg {
4
UpdateConfig {
5
owner: Option<String>,
6
liquidation_contract: Option<String>,
7
}
8
}
Copied!
1
{
2
"update_config": {
3
"owner": "terra1...",
4
"liquidation_contract": "terra1..."
5
}
6
}
Copied!
Key
Type
Description
owner*
String
New address of contract owner
liquidation_contract*
String
New contract address of Liquidation Contract
* = optional

[Internal] LockCollateral

Locks borrower's collateral to be used in their loan position, decreasing the amount of spendable collateral. Can only be issued by Overseer.
Rust
JSON
1
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
2
#[serde(rename_all = "snake_case")]
3
pub enum ExecuteMsg {
4
LockCollateral {
5
borrower: String,
6
amount: Uint256,
7
}
8
}
Copied!
1
{
2
"lock_collateral": {
3
"borrower": "terra1...",
4
"amount": "10000000"
5
}
6
}
Copied!
Key
Type
Description
borrower
String
Address of borrower locking collateral
amount
Uint256
Amount of collateral to lock

[Internal] UnlockCollateral

Unlocks borrower's collateral from their loan position, increasing the amount of spendable collateral. Can only be issued by Overseer.
Rust
JSON
1
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
2
#[serde(rename_all = "snake_case")]
3
pub enum ExecuteMsg {
4
UnlockCollateral {
5
borrower: String,
6
amount: Uint256,
7
}
8
}
Copied!
1
{
2
"unlock_collateral": {
3
"borrower": "terra1...",
4
"amount": "10000000"
5
}
6
}
Copied!
Key
Type
Description
borrower
String
Address of borrower unlocking collateral
amount
Uint256
Amount of collateral to unlock

[Internal] DistributeRewards

Withdraws accrued rewards from the bLuna Contract, swaps rewards to the appropriate stablecoin denomination. Can only be issued by Overseer.
Afterwards, distributes swapped rewards to depositors by sending swapped rewards to Market. If the deposit rate during the last epoch is above the target deposit rate, then a portion of the rewards are set aside as a yield reserve, which are sent to Overseer.
Rust
JSON
1
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
2
#[serde(rename_all = "snake_case")]
3
pub enum ExecuteMsg {
4
DistributeRewards {}
5
}
Copied!
1
{
2
"distribute_rewards": {}
3
}
Copied!
Key
Type
Description

[Internal] LiquidateCollateral

Liquidates specified amount of locked collateral. Can only be issued by Overseer.
Rust
JSON
1
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
2
#[serde(rename_all = "snake_case")]
3
pub enum ExecuteMsg {
4
LiquidateCollateral {
5
liquidator: String,
6
borrower: String,
7
amount: Uint256,
8
}
9
}
Copied!
1
{
2
"liquidate_collateral": {
3
"liquidator": "terra1...",
4
"borrower": "terra1...",
5
"amount": "100000000"
6
}
7
}
Copied!
Key
Type
Description
liquidator
String
Address of user that triggered liquidations
borrower
String
Address of borrower being liquidated
amount
Uint256
Amount of collateral to liquidate

WithdrawCollateral

Collaterals have to be first unlocked in the Overseer before they can be withdrawn by the user.
Withdraws specified amount of spendable collateral. Withdraws all spendable collateral if the amount field is not filled.
Rust
JSON
1
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
2
#[serde(rename_all = "snake_case")]
3
pub enum ExecuteMsg {
4
WithdrawCollateral {
5
amount: Option<Uint256>,
6
}
7
}
Copied!
1
{
2
"withdraw_collateral": {
3
"amount": "10000000"
4
}
5
}
Copied!
Key
Type
Description
amount*
Uint256
Amount of collateral to withdraw
* = optional

Receive Hooks

DepositCollateral

Deposited collaterals have to be locked in the Overseer before they can be utilized in a loan position.
Deposits collateral. Issued when a user sends bAsset tokens to the Custody contract.
Rust
JSON
1
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
2
#[serde(rename_all = "snake_case")]
3
pub enum Cw20HookMsg {
4
DepositCollateral {}
5
}
Copied!
1
{
2
"deposit_collateral": {}
3
}
Copied!
Key
Type
Description

QueryMsg

Config

Gets the contract configuration of the Custody contract.
Rust
JSON
1
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
2
#[serde(rename_all = "snake_case")]
3
pub enum QueryMsg {
4
Config {}
5
}
Copied!
1
{
2
"config": {}
3
}
Copied!
Key
Type
Description

ConfigResponse

Rust
JSON
1
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
2
pub struct ConfigResponse {
3
pub owner: String,
4
pub collateral_token: String,
5
pub overseer_contract: String,
6
pub market_contract: String,
7
pub reward_contract: String,
8
pub liquidation_contract: String,
9
pub stable_denom: String,
10
pub basset_info: BAssetInfo,
11
}
12
13
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
14
pub struct BAssetInfo {
15
pub name: String,
16
pub symbol: String,
17
pub decimals: u8,
18
}
Copied!
1
{
2
"owner": "terra1...",
3
"collateral_token": "terra1...",
4
"overseer_contract": "terra1...",
5
"market_contract": "terra1...",
6
"reward_contract": "terra1...",
7
"liquidation_contract": "terra1...",
8
"stable_denom": "uusd",
9
"basset_info": {
10
"name": "bonded luna",
11
"symbol": "ubluna",
12
"decimals": 6
13
}
14
}
Copied!
Key
Type
Description
owner
String
Address of contract owner
collateral_token
String
Contract address of bLuna Token
overseer_contract
String
Contract address of Overseer
market_contract
String
Contract address of Market
reward_contract
String
Contract address bLuna Reward
liquidation_contract
String
Contract address of Liquidation Contract
stable_denom
String
Native token denomination for stablecoin
basset_info
BAssetInfo
bAsset token information
Key
Type
Description
name
String
Name of bAsset token
symbol
String
Symbol of bAsset token
decimals
u8
Number of decimals of bAsset Token

Borrower

Gets the collateral balance of the specified borrower.
Rust
JSON
1
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
2
#[serde(rename_all = "snake_case")]
3
pub enum QueryMsg {
4
Borrower {
5
address: String,
6
}
7
}
Copied!
1
{
2
"borrower": {
3
"address": "terra1..."
4
}
5
}
Copied!
Key
Type
Description
address
String
Address of borrower that deposited collateral

BorrowerResponse

Rust
JSON
1
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
2
pub struct BorrowerResponse {
3
pub borrower: String,
4
pub balance: Uint256,
5
pub spendable: Uint256,
6
}
Copied!
1
{
2
"borrower": "terra1...",
3
"balance": "1000000000",
4
"spendable": "100000000"
5
}
Copied!
Key
Type
Description
borrower
String
Address of borrower that deposited collateral
balance
Uint256
Total amount of deposited collateral
spendable
Uint256
Amount of spendable collateral

Borrowers

Get the collateral balance of all borrowers.
Rust
JSON
1
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
2
#[serde(rename_all = "snake_case")]
3
pub enum QueryMsg {
4
Borrowers {
5
start_after: Option<String>,
6
limit: Option<u32>,
7
}
8
}
Copied!
1
{
2
"borrowers": {
3
"start_after": "terra1...",
4
"limit": 10
5
}
6
}
Copied!
Key
Type
Description
start_after*
String
Borrower address to start query
limit*
u32
Maximum number of query entries
* = optional

BorrowersResponse

Rust
JSON
1
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
2
pub struct BorrowersResponse {
3
pub borrowers: Vec<BorrowerResponse>,
4
}
5
6
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
7
pub struct BorrowerResponse {
8
pub borrower: String,
9
pub balance: Uint256,
10
pub spendable: Uint256,
11
}
Copied!
1
{
2
"borrowers": [
3
{
4
"borrower": "terra1...",
5
"balance": "2389476982",
6
"spendable": "2837492"
7
},
8
{
9
"borrower": "terra1...",
10
"balance": "2389476982",
11
"spendable": "2837492"
12
}
13
]
14
}
Copied!
Key
Type
Description
borrowers
Vec<BorrowerResponse>
Collateral balance information of borrowers
Key
Type
Description
borrower
String
Address of borrower that deposited collateral
balance
Uint256
Total amount of deposited collateral
spendable
Uint256
Amount of spendable collateral
Last modified 17d ago