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 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.
Name | Type | Description |
| HumanAddr | Contract address of Mirror Token (MIR) |
| HumanAddr | Contract address of Mirror Mint |
| HumanAddr | Contract address of Mirror Oracle |
| HumanAddr | Contract address of Terraswap Factory |
| HumanAddr | Contract address of Mirror Staking |
| HumanAddr | Contract address of Mirror Collector |
| Uint128 | Amount of new MIR tokens to mint per block |
| u64 | Code ID for CW20 contract for generating new mAssets |
| String | Native token denom for Terraswap pairs (TerraUSD) |
#[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], [], ...]}
{"token_code_id": 8,"base_denom": "uusd","distribution_schedule": [[3600, 7200, "1000000"],[7200, 10800, "1000000"]]}
Key | Type | Description |
| u64 | Code ID for CW20 contract for generating new mAssets |
| String | Native token denom for Terraswap pairs (TerraUSD) |
| Vec | Distribution schedule for the minting of new MIR tokens. Each entry consists of:
Determines the total amount of new MIR tokens minted as rewards for LP stakers over the interval [start time, end time]. |
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,}}
{"post_initialize": {"commission_collector": "terra1...","mint_contract": "terra1...","mirror_token": "terra1...","oracle_contract": "terra1...","owner": "terra1...","staking_contract": "terra1...","terraswap_factory": "terra1..."}}
Key | Type | Description |
| HumanAddr | Contract address of Mirror Collector |
| HumanAddr | Contract address of Mirror Mint |
| HumanAddr | Contract address of Mirror Token (MIR) |
| HumanAddr | Contract address of Mirror Oracle |
| HumanAddr | Address of the owner of Mirror Factory |
| HumanAddr | Contract address of Mirror Staking |
| HumanAddr | Contract address of Terraswap Factory |
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)>>}}
{"update_config": {"owner": "terra1...","token_code_id": 8,"distribution_schedule": [[3600, 7200, "1000000"],[7200, 10800, "1000000"]]}}
Key | Type | Description |
| HumanAddr | Address of the owner of Mirror Factory |
| u64 | Code ID for CW20 contract for generating new mAssets |
| Vec<(u64, u64, Uint128)> | New distribution schedule |
* = optional
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 Mirror Oracle 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_feeder: 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,}
{"whitelist": {"name": "Mirrored Apple Derivative","oracle_feeder": "terra1...","params": {"auction_discount": "0.2","min_collateral_ratio": "1.5",},"symbol": "mAAPL"}}
Key | Type | Description |
| String | Name of new asset to be whitelisted |
| HumanAddr | Address of Oracle Feeder for mAsset |
| Params | mAsset parameters |
| String | mAsset symbol (ex: |
Key | Type | Description |
| Decimal | Liquidation discount for purchasing CDP's collateral |
| Decimal | Minimum C-ratio for CDPs that mint the mAsset |
(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,}}
{"token_creation_hook": {"oracle_feeder": "terra1..."}}
Key | Type | Description |
| HumanAddr | Address of Oracle Feeder for mAsset |
(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,}}
{"terraswap_creation_hook": {"asset_token": "terra1..."}}
Key | Type | Description |
| HumanAddr | Contract address of mAsset token |
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,}}
{"pass_command": {"contract_addr": "terra1...","msg": "eyAiZXhlY3V0ZV9tc2ciOiAiYmxhaCBibGFoIiB9"}}
Key | Type | Description |
| HumanAddr | Contract address of contract to call |
| Binary | Base64-encoded JSON of ExecuteMsg |
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 {}}
{"distribute": {}}
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 HandleMsg {MigrateAsset {end_price: Decimal,from_token: HumanAddr,name: String,symbol: String,}}
{"migrate_asset": {"end_price": "123.456789","asset_token": "terra1...","name": "...","symbol": "..."}}
Key | Type | Description |
| Decimal | Freezes the oracle price of mAsset at this value |
| HumanAddr | Contract address of mAsset to migrate |
| String | Name of the new asset post-migration |
| String | Symbol for the new asset post-migration |
Get the Mirror Factory configuration.
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]#[serde(rename_all = "snake_case")]pub enum QueryMsg {Config {}}
{"config": {}}
Key | Type | Description |
Get the distribution schedules for MIR token.
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]#[serde(rename_all = "snake_case")]pub enum QueryMsg {DistributionInfo {}}
{"distribution_info": {}}
Key | Type | Description |
| HumanAddr | Contract address of asset token |