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

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], [], ...]
}

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

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

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

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

mAsset Params

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

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

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

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

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

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

DistributionInfo

Get the distribution schedules for MIR token.

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

Response

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

Last updated