Documentation
SocialsStatisticsLaunch App
  • Welcome to Mars Protocol
  • Getting Started
    • How to set up a Wallet
    • Connect your wallet
    • Using a Credit Account
  • Credit Accounts
  • Perpetual Futures (Perps)
    • Perps Vault (Counterparty Vault)
    • Funding Rate Mechanism
    • Price Impact
    • Open Interest Caps
    • Vault Solvency Protection
    • Health Factor
    • Liquidations
  • Spot & Margin Trading
  • Lending & Borrowing
  • Leveraged Yield Farming
  • High Leverage Strategies
  • Managed Vaults
    • Creating a Vault
      • How to Resume Vault Creation After Failed Transaction
    • Managing a Vault
    • Depositing into Vault
  • Risk Methodology
    • Asset Listing
    • Protocol Risk Framework
    • Perps Risk Framework
      • Maximum Leverage & LTVs
      • SkewScale
      • Open Interest Caps
      • Maximum Funding Velocity
      • Mitigating Risks of Static Parameters
    • Deposit Caps Risk Framework
  • Governance
    • MARS Token
  • Smart Contracts
    • Address Provider
    • Account NFT
    • Credit Manager
    • Health
    • Incentives
    • Oracle
    • Params
    • Red Bank
    • Rewards Collector
    • Swapper
    • Zapper
    • Perps
  • Brand kit
    • The Mars Brand
  • Legal
    • Mars FUD Bible
    • Terms of Service
    • Privacy Policy
    • Cookie Policy
Powered by GitBook
On this page
  • Deployments
  • Types
  • Queries
  • Methods
Edit on GitHub
Export as PDF
  1. Smart Contracts

Red Bank

The Red Bank Contract is the heart of the Mars Protocol's Money Market. It holds all assets deposited to Mars and provides the v1 market interactions through the user's wallet.

Last updated 25 days ago

Deployments

Neutron:

Osmosis:


Types

The types of the Incentives Contract can be found .

For reference on the Queries and Methods:

Base Types
type Decimal = string
type Uint128 = string

Queries

config

Returns the Contracts configuration.

Query message
    config: {}    
}
Return output
{
    data: {
        address_provider: string
        owner?: string | null
        proposed_new_owner?: string | null
    }
}

market (outdated)

Query message
{      
    market: {
        denom: string
    }
}
Return output
{
    data: {
        borrow_index: Decimal
        borrow_rate: Decimal
        collateral_total_scaled: Uint128
        debt_total_scaled: Uint128
        denom: string
        indexes_last_updated: number
        interest_rate_model: {
            base: Decimal
            optimal_utilization_rate: Decimal
            slope_1: Decimal
            slope_2: Decimal
        }
        liquidity_index: Decimal
        liquidity_rate: Decimal
        reserve_factor: Decimal
    }
}

market_v2

Query message
{
    market_v2: {
        denom: string
    }
}
Return output
{
    data: {
        borrow_index: Decimal
        borrow_rate: Decimal
        collateral_total_amount: Uint128
        collateral_total_scaled: Uint128
        debt_total_amount: Uint128
        debt_total_scaled: Uint128
        denom: string
        indexes_last_updated: number
        interest_rate_model: {
            base: Decimal
            optimal_utilization_rate: Decimal
            slope_1: Decimal
            slope_2: Decimal
        }
        liquidity_index: Decimal
        liquidity_rate: Decimal
        reserve_factor: Decimal
        utilization_rate: Decimal
    }
}

markets (outdated)

Query message
{
    markets: {
        limit?: number | null
        start_after?: string | null
    }
}
Return output
{
    data: {
        data: [
            {
                borrow_index: Decimal
                borrow_rate: Decimal
                collateral_total_scaled: Uint128
                debt_total_scaled: Uint128
                denom: string
                indexes_last_updated: number
                interest_rate_model: {
                    base: Decimal
                    optimal_utilization_rate: Decimal
                    slope_1: Decimal
                    slope_2: Decimal
                }
                liquidity_index: Decimal
                liquidity_rate: Decimal
                reserve_factor: Decimal
            },
            ...
        ]
    }
}

markets_v2

Query message
{
    markets_v2: {
        limit?: number | null
        start_after?: string | null
    }
}
Return output
{
    data: {
        data: [
            {
                borrow_index: Decimal
                borrow_rate: Decimal
                collateral_total_amount: Uint128
                collateral_total_scaled: Uint128
                debt_total_amount: Uint128
                debt_total_scaled: Uint128
                denom: string
                indexes_last_updated: number
                interest_rate_model: {
                    base: Decimal
                    optimal_utilization_rate: Decimal
                    slope_1: Decimal
                    slope_2: Decimal
                }
                liquidity_index: Decimal
                liquidity_rate: Decimal
                reserve_factor: Decimal
            },
            ...
        ]
        meta_data: {
            has_more: boolean
        }
    }
}

scaled_debt_amount

Query message
{
    scaled_debt_amount: {
        amount: Uint128
        denom: string
    }
}
Return output
{
    data: Uint123
}

scaled_liquidity_amount

Query message
{
    scaled_liquidity_amount: {
        amount: Uint128
        denom: string
    }
}
Return output
{
    data: Uint123
}

underlying_debt_amount

Query message
{
    underlying_debt_amount: {
        amount_scaled: Uint128
        denom: string
    }
}
Return output
{
    data: Uint123
}

underlying_liquidity_amount

Query message
{
    underlying_liquidity_amount: {
        amount_scaled: Uint128
        denom: string
    }
}
Return output
{
    data: Uint123
}

user_collateral

Query message
{
    user_collateral: {
        account_id?: string | null
        denom: string
        user: string
    }
}
Return output
{
    data: {
        amount: Uint128
        amount_scaled: Uint128
        denom: string
        enabled: boolean
    }
}

user_collaterals (outdated)

Query message
{
    user_collaterals: {
        account_id?: string | null
        limit?: number | null
        start_after?: string | null
        user: string
    }
}
Return output
{
    data: [
        {
            account_id?: string | null
            limit?: number | null
            start_after?: string | null
            user: string
        },
        ...
    ]    
}

user_collaterals_v2

Query message
{
    user_collaterals_v2: {
        account_id?: string | null
        limit?: number | null
        start_after?: string | null
        user: string
    }
}
Return output
{
    data: {
        data: [
            {
                account_id?: string | null
                limit?: number | null
                start_after?: string | null
                user: string
            },
            ...
        ]
        meta_data: {
            has_more: boolean
        }
    }
}

user_debt

Query message
{
    user_debt: {
        denom: string
        user: string
    }
}
Return output
{
    data: {
        amount: Uint128
        amount_scaled: Uint128
        denom: string
        uncollateralized: boolean
    }
}

user_debts

Query message
{
    user_debts: {
        limit?: number | null
        start_after?: string | null
        user: string
    }
}
Return output
{
    data: [
        {
            amount: Uint128
            amount_scaled: Uint128
            denom: string
            uncollateralized: boolean
        },
        ...
    ]
}

user_position

Query message
{
    user_position: {
        account_id?: string | null
        user: string
    }
}
Return output
{
    data: {
        health_status: 'not_borrowing' | {
            borrowing: {
                liq_threshold_hf: Decimal
                max_ltv_hf: Decimal
            }
        }
        total_collateralized_debt: Uint128
        total_enabled_collateral: Uint128
        weighted_liquidation_threshold_collateral: Uint128
        weighted_max_ltv_collateral: Uint128
    }
}

user_position_liquidation_pricing

Query message
{
    user_position_liquidation_pricing: {
        account_id?: string | null
        user: string
    }
}
Return output
{
    data: {
        health_status: 'not_borrowing' | {
            borrowing: {
                liq_threshold_hf: Decimal
                max_ltv_hf: Decimal
            }
        }
        total_collateralized_debt: Uint128
        total_enabled_collateral: Uint128
        weighted_liquidation_threshold_collateral: Uint128
        weighted_max_ltv_collateral: Uint128
    }
}

Methods

borrow

Execution message
{
      borrow: {
            amount: Uint128
            denom: string
            recipient?: string | null
      }
}

deposit

Execution message
{
    deposit: {
        account_id?: string | null
        on_behalf_of?: string | null
    }
}

liquidate

Execution message
{
    liquidate: {
        collateral_denom: string
        recipient?: string | null
        user: string
    }
}

repay

Execution message
{
    repay: {
        on_behalf_of?: string | null
    }
}

withdraw

Execution message
{
    withdraw: {
        account_id?: string | null
        amount?: Uint128 | null
        denom: string
        liquidation_related?: boolean | null
        recipient?: string | null
    }
}
neutron1n97wnm7q6d2hrcna3rqlnyqw2we6k0l8uqvmyqq6gsml92epdu7quugyph
osmo1c3ljch9dfw5kf52nfwpxd2zmj2ese7agnx0p9tenkrryasrle5sqf3ftpg
here