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

InstantiateMsg

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub struct InstantiateMsg {
    pub owner: String, 
    pub collateral_token: String,
    pub overseer_contract: String,
    pub market_contract: String,
    pub reward_contract: String,
    pub liquidation_contract: String,
    pub stable_denom: String, 
    pub basset_info: BAssetInfo, 
}

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
pub struct BAssetInfo {
    pub name: String,
    pub symbol: String,
    pub decimals: u8,
}

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.

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum ExecuteMsg {
    Receive {
        sender: String, 
        amount: Uint128, 
        msg: Binary, 
    }
}

UpdateConfig

Updates the configuration of the Custody contract.

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum ExecuteMsg {
    UpdateConfig {
        owner: Option<String>, 
        liquidation_contract: Option<String>, 
    }
}

* = 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.

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum ExecuteMsg {
    LockCollateral {
        borrower: String, 
        amount: Uint256, 
    }
}

[Internal] UnlockCollateral

Unlocks borrower's collateral from their loan position, increasing the amount of spendable collateral. Can only be issued by Overseer.

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum ExecuteMsg {
    UnlockCollateral {
        borrower: String, 
        amount: Uint256, 
    }
}

[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.

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum ExecuteMsg {
    DistributeRewards {}
}

[Internal] LiquidateCollateral

Liquidates specified amount of locked collateral. Can only be issued by Overseer.

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum ExecuteMsg {
    LiquidateCollateral {
        liquidator: String, 
        borrower: String, 
        amount: Uint256, 
    }
}

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.

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum ExecuteMsg {
    WithdrawCollateral {
        amount: Option<Uint256>, 
    }
}

* = 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.

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum Cw20HookMsg {
    DepositCollateral {}
}

QueryMsg

Config

Gets the contract configuration of the Custody contract.

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum QueryMsg {
    Config {}
}

ConfigResponse

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
pub struct ConfigResponse {
    pub owner: String, 
    pub collateral_token: String, 
    pub overseer_contract: String, 
    pub market_contract: String, 
    pub reward_contract: String, 
    pub liquidation_contract: String, 
    pub stable_denom: String, 
    pub basset_info: BAssetInfo, 
}

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
pub struct BAssetInfo {
    pub name: String,
    pub symbol: String,
    pub decimals: u8,
}

Borrower

Gets the collateral balance of the specified borrower.

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum QueryMsg {
    Borrower {
        address: String, 
    }
}

BorrowerResponse

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
pub struct BorrowerResponse {
    pub borrower: String, 
    pub balance: Uint256, 
    pub spendable: Uint256, 
}

Borrowers

Get the collateral balance of all borrowers.

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum QueryMsg {
    Borrowers {
        start_after: Option<String>, 
        limit: Option<u32>, 
    }
}

* = optional

BorrowersResponse

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
pub struct BorrowersResponse {
    pub borrowers: Vec<BorrowerResponse>, 
}

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
pub struct BorrowerResponse {
    pub borrower: String, 
    pub balance: Uint256, 
    pub spendable: Uint256, 
}

Last updated