Skip to main content

Market Contract Execute

Execute a market contract interaction.

Lend(Cw20HookMsg::Lend) can be called with coins attached to lend the attached amount and earn lending annual percentage yield (APY).

When lending out an asset, the lender receives cw20 tokens, called the "receipt tokens". Lent assets are redeemed by sending the receipt tokens back to the market contract with Cw20HookMsg::Redeem message attached.

DepositCollateral(Cw20HookMsg::DepositCollateral) can be called with coins attached to deposit the amount as collateral to an account to then be able to borrow against the deposited collateral.

WithdrawCollateral can be called to withdraw the deposited collateral.

Borrow can be called to borrow assets against the deposited collateral.

Return(Cw20HookMsg::Return) can be called to return the borrowed assets plus accumulated interest.

Liquidate can be called to liquidate an account with an account_health below 1.0. Account health is calculated as account_health = total_scaled_collateral_value / total_debt_value. A liquidation allows the liquidator to receive a reward.

Note: some of the actions available for coins (native to Cosmos chains), can also be performed with cw20 tokens by sending tokens to the market with an attached Cw20HookMsg.

Execute Messages

Receive (Cw20ReceiveMsg)

Cw20HookMsg allows Cw20 tokens to be sent with a specific execution instructions.

RUST
pub enum ExecuteMsg {
    /// Receive hook for Cw20 Send messages
    Receive(Cw20ReceiveMsg),
}

Lend { .. }
RUST
pub enum ExecuteMsg {
    /// Provide assets to be lent
    Lend {},
}

DepositCollateral { .. }
RUST
pub enum ExecuteMsg {
    /// Deposit collateral to borrow against
    DepositCollateral { account_index: u8 },
}

WithdrawCollateral { .. }
RUST
pub enum ExecuteMsg {
    /// Remove collateral that was previously deposited
    WithdrawCollateral { shares: Uint256, asset_info: AssetInfo, account_index: u8 },
}

Borrow { .. }
RUST
pub enum ExecuteMsg {
    /// Borrow an asset from the market
    Borrow { amount: Uint256, asset_info: AssetInfo, account_index: u8 },
}

Return { .. }
RUST
pub enum ExecuteMsg {
    /// Return an asset that you previously borrowed
    Return { account_index: u8 },
}

Liquidate { .. }

See Liquidation Guide for more information

RUST
pub enum ExecuteMsg {
    /// Liquidate an account/s using provided liquidity
    Liquidate {
        liquidation_operations: Vec<LiquidationOperation>,
        recipient:              Option<Addr>,
        tokens_sent:            AssetMap<Uint256>,
}

Where, LiquidationOperation is defined below in this Common Data Type.

LiquidationOperation
RUST
pub struct LiquidationOperation {
    pub account_addr:  Addr,
    pub account_index: u8,
    pub ask_assets:    AssetMap<LiquidationAmounts>,
    pub offer_assets:  AssetMap<Uint256>,
}

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.