Factory

The Factory contract is Mirror Protocol's central directory and organizes information related to mAssets and the Mirror Token (MIR). It is also responsible for minting new MIR tokens each block and distributing them to the Staking Contract for rewarding LP &sLP Token stakers.

After the initial bootstrapping of Mirror Protocol contracts, the Factory is assigned to be the owner for the Mint, Oracle, Staking, and Collector contracts. The Factory is owned by the Gov Contract.

Config

NameTypeDescription

mirror_token

HumanAddr

Contract address of Mirror Token (MIR)

mint_contract

HumanAddr

Contract address of Mirror Mint

oracle_contract

HumanAddr

Contract address of Mirror Oracle

terraswap_factory

HumanAddr

Contract address of Terraswap Factory

staking_contract

HumanAddr

Contract address of Mirror Staking

commission_collector

HumanAddr

Contract address of Mirror Collector

mint_per_block

Uint128

Amount of new MIR tokens to mint per block

token_code_id

u64

Code ID for CW20 contract for generating new mAssets

base_denom

String

Native token denom for Terraswap pairs (TerraUSD)

InitMsg

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
pub struct InitMsg {
    pub token_code_id: u64,
    pub base_denom: String,
    pub distribution_schedule: Vec<(u64, u64, Uint128)>, // [[start_time, end_time, distribution_amount], [], ...]
}
KeyTypeDescription

token_code_id

u64

Code ID for CW20 contract for generating new mAssets

base_denom

String

Native token denom for Terraswap pairs (TerraUSD)

distribution_schedule

Vec

Distribution schedule for the minting of new MIR tokens. Each entry consists of:

  • start time (seconds)

  • end time (seconds)

  • distribution amount for the interval

Determines the total amount of new MIR tokens minted as rewards for LP stakers over the interval [start time, end time].

HandleMsg

PostInitialize

Issued by the Factory contract's owner after bootstrapping to initialize the contract's configuration.

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum HandleMsg {
    PostInitialize {
        commission_collector: HumanAddr,
        mint_contract: HumanAddr,
        mirror_token: HumanAddr,
        oracle_contract: HumanAddr,
        owner: HumanAddr,
        staking_contract: HumanAddr,
        terraswap_factory: HumanAddr,
    }
}
KeyTypeDescription

commission_collector

HumanAddr

Contract address of Mirror Collector

mint_contract

HumanAddr

Contract address of Mirror Mint

mirror_token

HumanAddr

Contract address of Mirror Token (MIR)

oracle_contract

HumanAddr

Contract address of Mirror Oracle

**owner

HumanAddr

Address of the owner of Mirror Factory

staking_contract

HumanAddr

Contract address of Mirror Staking

terraswap_factory

HumanAddr

Contract address of Terraswap Factory

UpdateConfig

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

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum HandleMsg {
    UpdateConfig {
        owner: Option<HumanAddr>,
        token_code_id: Option<u64>,
        distribution_schedule: Option<Vec<(u64, u64, Uint128)>>
    }
}
KeyTypeDescription

owner*

HumanAddr

Address of the owner of Mirror Factory

token_code_id*

u64

Code ID for CW20 contract for generating new mAssets

**distribution_schedule*

Vec<(u64, u64, Uint128)>

New distribution schedule

* = optional

UpdateWeight

Updates the weight parameter of a specific token.

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum HandleMsg {
 UpdateWeight {
        asset_token: HumanAddr,
        weight: u32,
    }
NameTypeDescription

asset_token

HumanAddr

Contract address of mAsset token

weight

u32

Ratio of MIR token reward received by this asset in comparison to other tokens

Whitelist

Introduces a new mAsset to the protocol and creates markets on Terraswap. This process will:

  • Instantiate the mAsset contract as a new Terraswap CW20 token

  • Register the mAsset with Oracle Hub and Mirror Mint

  • Create a new Terraswap Pair for the new mAsset against TerraUSD

  • Instantiate the LP Token contract associated with the pool as a new Terraswap CW20 token

  • Register the LP token with the Mirror Staking contract

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum HandleMsg {
    Whitelist {
        name: String,
        oracle_proxy: HumanAddr,
        params: Params,
        symbol: String,
    }
}

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub struct Params {
    pub auction_discount: Decimal,
    pub min_collateral_ratio: Decimal,
    pub weight: Option<u32>,
    pub mint_period: Option<u64>,
    pub min_collateral_ratio_after_ipo: Option<Decimal>,
    pub pre_ipo_price: Option<Decimal>,
}
KeyTypeDescription

name

String

Name of new asset to be whitelisted

oracle_proxy

HumanAddr

Address of the oracle proxy contract that provides prices for this asset

params

Params

mAsset parameters to be registered

symbol

String

mAsset symbol (ex: AAPL)

mAsset Params

KeyTypeDescription

auction_discount

Decimal

Liquidation discount for purchasing CDP's collateral

min_collateral_ratio

Decimal

Minimum C-ratio for CDPs that mint the mAsset

weight*

u32

Ratio of MIR token reward received by this asset in comparison to other tokens

mint_period*

u64

Time period after asset creation in which minting is enabled (Seconds)

min_collateral_ratio_after_ipo*

Decimal

min_collateral_ratio to be applied to this asset after IPO

pre_ipo_price*

Decimal

Fixed price used to mint Pre-IPO asset during mint_period

*= optional (Only added for Pre-IPO asset whitelisting)

TokenCreationHook

(INTERNAL)

Called after mAsset token contract is created in the Whitelist process. **Why this is necessary

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum HandleMsg {
    TokenCreationHook {
        oracle_feeder: HumanAddr,
    }
}
KeyTypeDescription

oracle_feeder

HumanAddr

Address of Oracle Feeder for mAsset

TerraswapCreationHook

(INTERNAL)

Called after mAsset token contract is created in the Whitelist process.

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub struct enum HandleMsg {
    TerraswapCreationHook {
        asset_token: HumanAddr,
    }
}
KeyTypeDescription

asset_token

HumanAddr

Contract address of mAsset token

PassCommand

Calls the contract specified with the message to execute. Used for invoking functions on other Mirror Contracts since Mirror Factory is defined to be the owner. To be controlled through governance.

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum HandleMsg {
    PassCommand {
        contract_addr: HumanAddr,
        msg: Binary,
    }
}
KeyTypeDescription

contract_addr

HumanAddr

Contract address of contract to call

msg

Binary

Base64-encoded JSON of ExecuteMsg

Distribute

Mints the appropriate amount of new MIR tokens as reward for LP stakers by sends the newly minted tokens to the Mirror Staking contract to be distributed to its stakers. Can be called by anyone at any time to trigger block reward distribution for LP stakers.

The contract keeps track of the last height at which Distribute was called for a specific asset, and uses it to calculate the amount of new assets to mint for the blocks occurred in the interval between.

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

RevokeAsset

(Feeder Operation) Used when delisting occurs for a specific mAsset.

  • mAsset is unregistered from MIR reward pool

  • Fixes the oracle price at end_price for mint contract operation

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum HandleMsg {
    RevokeAsset {
        asset_token: HumanAddr,
        end_price: Decimal,
    }
NameTypeDescription

asset_token

HumanAddr

Contract address of mAsset token

end_price

Decimal

Final price to freeze revoked mAsset

MigrateAsset

Can be issued by the oracle feeder of an mAsset to trigger the mAsset migration procedure.

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum ExecuteMsg {
    MigrateAsset {
        name: String,
        symbol: String,
        oracle_proxy: String,
        from_token: String,
    },
KeyTypeDescription

name

String

Name of the new asset post-migration

symbol

String

Symbol for the new asset post-migration

oracle_proxy

String

Address of the oracle proxy contract that will provide prices for this asset after asset migration takes place

from_token

String

Contract address of mAsset to migrate

QueryMsg

Config

Get the Mirror Factory configuration.

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

Response

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
pub struct ConfigResponse {
    pub owner: HumanAddr,
    pub mirror_token: HumanAddr,
    pub mint_contract: HumanAddr,
    pub staking_contract: HumanAddr,
    pub commission_collector: HumanAddr,
    pub oracle_contract: HumanAddr,
    pub terraswap_factory: HumanAddr,
    pub token_code_id: u64,
    pub base_denom: String,
    pub genesis_time: u64,
    pub distribution_schedule: Vec<(u64, u64, Uint128)>,
}
KeyTypeDescription

owner

HumanAddr

Contract address of mAsset token

mirror_token

HumanAddr

Final price to freeze revoked mAsset

mint_contract

HumanAddr

Contract address of Mirror Mint

staking_contract

HumanAddr

Contract address of Mirror Oracle

commission_collector

HumanAddr

Contract address of Mirror Collector

oracle_contract

HumanAddr

Contract address of Mirror Oracle

terraswap_factory

HumanAddr

Contract address of Terraswap Factory

token_code_id

u64

Code ID for CW20 contract for generating new mAssets

base_denom

String

Native token denom for Terraswaap pairs (TerraUSD)

genesis_time

u64

Block height which the Factory contract was instantiated

distribution_schedule

Vec<(u64, u64, Uint128)>

Distribution schedule for the minting of new MIR tokens. Each entry consists of: - start time (seconds) - end time (seconds) distribution amount for the interval Determines the total amount of new MIR tokens minted as rewards for LP stakers over the interval [start time, end time].

DistributionInfo

Get the distribution schedules for MIR token.

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

asset_token

HumanAddr

Contract address of asset token

Response

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
pub struct DistributionInfoResponse {
    pub weights: Vec<(HumanAddr, u32)>,
    pub last_distributed: u64,
}
KeyTypeDescription

weights

Vec<(HumanAddr, u32)>

List of reward weight assigned to each mAsset. Each entry consists of: - Token contract address - weight

last_distributed

u64

Block height of the most recent reward distribution

Last updated