Market

The Market contract acts as the point of interaction for all lending and borrowing related activities. New stablecoin deposits are added to this contract's balance, while borrows are subtracted from the contract balance.

Config

InstantiateMsg

Instantiates the money market Market contract. Requires the owner to make an initial deposit of 1 Terra stablecoin and mints 1 aTerra to the Market contract (inaccessible). The creator's initial stablecoin deposit ensures the aTerra supply to always be a high enough value to prevent rounding errors in the aTerra exchange rate calculation.

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub struct InstantiateMsg {
    pub owner_addr: String, 
    pub stable_denom: String, 
    pub aterra_code_id: u64, 
    pub anc_emission_rate: Decimal256, 
    pub max_borrow_factor: Decimal256, 
}

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,
    }
}

RegisterContracts

Registers the addresses of other Money Market contracts. Can only be issued by the owner.

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum ExecuteMsg {
    RegisterContracts {
        overseer_contract: String, 
        interest_model: String, 
        distribution_model: String, 
        collector_contract: String, 
        distributor_contract: String, 
    }
}

[Internal] RegisterATerra

Registers the contract address of aTerra Cw20 Token contract. Issued by aTerra after initialization.

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

UpdateConfig

Updates the configuration of the contract. Can be only issued by the owner.

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

* = optional

[Internal] RepayStableFromLiquidation

Repays a liquidated loan using stablecoins gained from liquidated collaterals. Can only be issued by Overseer.

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

[Internal] ExecuteEpochOperations

Adjusts the borrower ANC emission rate and sends accumulated ANC excess yield reserves to Overseer. Can only be issued by Overseer.

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum ExecuteMsg {
    ExecuteEpochOperations {
        deposit_rate: Decimal256, 
        target_deposit_rate: Decimal256, 
        threshold_deposit_rate: Decimal256, 
        distributed_interest: Uint256, 
    }
}

DepositStable

Deposits stablecoins to Anchor. Requires stablecoins to be sent with the message.

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

BorrowStable

Borrows stablecoins from Anchor.

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

* = optional

RepayStable

Repays previous stablecoin liability. Requires stablecoins to be sent with the message.

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

ClaimRewards

Claims accrued ANC rewards. Can designate an optional recipient. Sends rewards to message sender if to is not specified.

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

* = optional

Receive Hooks

RedeemStable

Redeems aTerra to their underlying stablecoins.

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

QueryMsg

Config

Gets the Market contract configuration.

#[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_addr: String, 
    pub aterra_contract: String, 
    pub interest_model: String, 
    pub distribution_model: String, 
    pub overseer_contract: String, 
    pub collector_contract: String, 
    pub distributor_contract: String, 
    pub stable_denom: String, 
    pub max_borrow_factor: Decimal256, 
}

State

Gets state information of Market. Returns an interest-accrued value if block_height field is filled. Returns the stored (no interest accrued) state if not filled.

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum QueryMsg {
    State {
        block_height: Option<u64>, 
    }
}

* = optional

StateResponse

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
pub struct State {
    pub total_liabilites: Decimal256, 
    pub total_reserves: Decimal256, 
    pub last_interest_updated: u64, 
    pub last_reward_updated: u64, 
    pub global_interest_index: Decimal256, 
    pub global_reward_index: Decimal256, 
    pub anc_emission_rate: Decimal256, 
    pub prev_aterra_supply: Uint256, 
    pub prev_exchange_rate: Decimal256, 
}

EpochState

Gets state information related to epoch operations. Returns an interest-accrued value if block_height field is filled. Returns the stored (no interest accrued) state if not filled.

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum QueryMsg {
    EpochState {
        block_height: Option<u64>, 
        distributed_interest: Option<Uint256>, 
    }
}

* = optional

EpochStateResponse

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
pub struct EpochStateResponse {
    pub exchange_rate: Decimal256, 
    pub aterra_supply: Uint256, 
}

BorrowerInfo

Gets information for the specified borrower. Returns an interest-and-reward-accrued value if block_height field is filled. Returns the stored (no interest / reward accrued) state if not filled.

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum QueryMsg {
    BorrowerInfo {
        borrower: String, 
        block_height: Option<u64>, 
    }
}

* = optional

BorrowerInfoResponse

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
pub struct BorrowInfoResponse {
    pub borrower: String, 
    pub interest_index: Decimal256, 
    pub reward_index: Decimal256, 
    pub loan_amount: Uint256, 
    pub pending_rewards: Decimal256, 
}

BorrowInfos

Gets information for all borrowers.

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

* = optional

BorrowerInfosResponse

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
pub struct BorrowerInfosResponse {
    pub borrower_infos: Vec<BorrowerInfoResponse>, 
}

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
pub struct BorrowInfoResponse {
    pub borrower: String, 
    pub interest_index: Decimal256, 
    pub reward_index: Decimal256, 
    pub loan_amount: Uint256, 
    pub pending_rewards: Decimal256, 
}

Last updated