Search…
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

Name
Type
Description
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

Rust
JSON
1
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
2
pub struct InitMsg {
3
pub token_code_id: u64,
4
pub base_denom: String,
5
pub distribution_schedule: Vec<(u64, u64, Uint128)>, // [[start_time, end_time, distribution_amount], [], ...]
6
}
Copied!
1
{
2
"token_code_id": 8,
3
"base_denom": "uusd",
4
"distribution_schedule": [
5
[3600, 7200, "1000000"],
6
[7200, 10800, "1000000"]
7
]
8
}
Copied!
Key
Type
Description
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.
Rust
JSON
1
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
2
#[serde(rename_all = "snake_case")]
3
pub enum HandleMsg {
4
PostInitialize {
5
commission_collector: HumanAddr,
6
mint_contract: HumanAddr,
7
mirror_token: HumanAddr,
8
oracle_contract: HumanAddr,
9
owner: HumanAddr,
10
staking_contract: HumanAddr,
11
terraswap_factory: HumanAddr,
12
}
13
}
Copied!
1
{
2
"post_initialize": {
3
"commission_collector": "terra1...",
4
"mint_contract": "terra1...",
5
"mirror_token": "terra1...",
6
"oracle_contract": "terra1...",
7
"owner": "terra1...",
8
"staking_contract": "terra1...",
9
"terraswap_factory": "terra1..."
10
}
11
}
Copied!
Key
Type
Description
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.
Rust
JSON
1
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
2
#[serde(rename_all = "snake_case")]
3
pub enum HandleMsg {
4
UpdateConfig {
5
owner: Option<HumanAddr>,
6
token_code_id: Option<u64>,
7
distribution_schedule: Option<Vec<(u64, u64, Uint128)>>
8
}
9
}
Copied!
1
{
2
"update_config": {
3
"owner": "terra1...",
4
"token_code_id": 8,
5
"distribution_schedule": [
6
[3600, 7200, "1000000"],
7
[7200, 10800, "1000000"]
8
]
9
}
10
}
Copied!
Key
Type
Description
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.
Rust
JSON
1
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
2
#[serde(rename_all = "snake_case")]
3
pub enum HandleMsg {
4
UpdateWeight {
5
asset_token: HumanAddr,
6
weight: u32,
7
}
Copied!
1
{
2
"update_weight": {
3
"asset_token": "terra1...",
4
"weight": 8
5
}
6
}
Copied!
Name
Type
Description
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 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
Rust
JSON
1
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
2
#[serde(rename_all = "snake_case")]
3
pub enum HandleMsg {
4
Whitelist {
5
name: String,
6
oracle_feeder: HumanAddr,
7
params: Params,
8
symbol: String,
9
}
10
}
11
12
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
13
#[serde(rename_all = "snake_case")]
14
pub struct Params {
15
pub auction_discount: Decimal,
16
pub min_collateral_ratio: Decimal,
17
pub weight: Option<u32>,
18
pub mint_period: Option<u64>,
19
pub min_collateral_ratio_after_ipo: Option<Decimal>,
20
pub pre_ipo_price: Option<Decimal>,
21
}
Copied!
1
{
2
"whitelist": {
3
"name": "Mirrored Apple Derivative",
4
"oracle_feeder": "terra1...",
5
"params": {
6
"auction_discount": "0.2",
7
"min_collateral_ratio": "1.5",
8
},
9
"symbol": "mAAPL"
10
}
11
}
Copied!
Key
Type
Description
name
String
Name of new asset to be whitelisted
oracle_feeder
HumanAddr
Address of Oracle Feeder for mAsset
params
Params
mAsset parameters to be registered
symbol
String
mAsset symbol (ex: mAAPL)

mAsset Params

Key
Type
Description
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
Rust
JSON
1
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
2
#[serde(rename_all = "snake_case")]
3
pub enum HandleMsg {
4
TokenCreationHook {
5
oracle_feeder: HumanAddr,
6
}
7
}
Copied!
1
{
2
"token_creation_hook": {
3
"oracle_feeder": "terra1..."
4
}
5
}
Copied!
Key
Type
Description
oracle_feeder
HumanAddr
Address of Oracle Feeder for mAsset

TerraswapCreationHook

(INTERNAL)
Called after mAsset token contract is created in the Whitelist process.
Rust
JSON
1
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
2
#[serde(rename_all = "snake_case")]
3
pub struct enum HandleMsg {
4
TerraswapCreationHook {
5
asset_token: HumanAddr,
6
}
7
}
Copied!
1
{
2
"terraswap_creation_hook": {
3
"asset_token": "terra1..."
4
}
5
}
Copied!
Key
Type
Description
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.
Rust
JSON
1
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
2
#[serde(rename_all = "snake_case")]
3
pub enum HandleMsg {
4
PassCommand {
5
contract_addr: HumanAddr,
6
msg: Binary,
7
}
8
}
Copied!
1
{
2
"pass_command": {
3
"contract_addr": "terra1...",
4
"msg": "eyAiZXhlY3V0ZV9tc2ciOiAiYmxhaCBibGFoIiB9"
5
}
6
}
Copied!
Key
Type
Description
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.
Rust
JSON
1
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
2
#[serde(rename_all = "snake_case")]
3
pub enum HandleMsg {
4
Distribute {}
5
}
Copied!
1
{
2
"distribute": {}
3
}
Copied!

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
Rust
JSON
1
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
2
#[serde(rename_all = "snake_case")]
3
pub enum HandleMsg {
4
RevokeAsset {
5
asset_token: HumanAddr,
6
end_price: Decimal,
7
}
Copied!
1
{
2
"revoke_asset": {
3
"asset_token": "terra1...",
4
"end_price": "123.456789"
5
}
6
}
Copied!
Name
Type
Description
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.
Rust
JSON
1
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
2
#[serde(rename_all = "snake_case")]
3
pub enum HandleMsg {
4
MigrateAsset {
5
end_price: Decimal,
6
from_token: HumanAddr,
7
name: String,
8
symbol: String,
9
}
10
}
Copied!
1
{
2
"migrate_asset": {
3
"end_price": "123.456789",
4
"asset_token": "terra1...",
5
"name": "...",
6
"symbol": "..."
7
}
8
}
Copied!
Key
Type
Description
end_price
Decimal
Freezes the oracle price of mAsset at this value (Denominated in UST)
from_token
HumanAddr
Contract address of mAsset to migrate
name
String
Name of the new asset post-migration
symbol
String
Symbol for the new asset post-migration

QueryMsg

Config

Get the Mirror Factory configuration.
Rust
JSON
1
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
2
#[serde(rename_all = "snake_case")]
3
pub enum QueryMsg {
4
Config {}
5
}
Copied!

Response

1
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
2
pub struct ConfigResponse {
3
pub owner: HumanAddr,
4
pub mirror_token: HumanAddr,
5
pub mint_contract: HumanAddr,
6
pub staking_contract: HumanAddr,
7
pub commission_collector: HumanAddr,
8
pub oracle_contract: HumanAddr,
9
pub terraswap_factory: HumanAddr,
10
pub token_code_id: u64,
11
pub base_denom: String,
12
pub genesis_time: u64,
13
pub distribution_schedule: Vec<(u64, u64, Uint128)>,
14
}
Copied!
Key
Type
Description
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].
1
{
2
"config": {}
3
}
Copied!

Response

1
{
2
"config_response": {
3
"owner": "terra1..."
4
"mirror_token": "terra1...",
5
"mint_contract": "terra1...",
6
"staking_contract": "terra1...",
7
"commission_collector": "terra1...",
8
"oracle_contract": "terra1...",
9
"terraswap_factory": "terra1...",
10
"token_code_id": 8,
11
"base_denom": "uusd",
12
"genesis_time": 1000000,
13
"distribution_schedule": [
14
[3600, 7200, "1000000"],
15
[7200, 10800, "1000000"]
16
]
17
}
18
}
Copied!
Key
Type
Description
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.
Rust
JSON
1
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
2
#[serde(rename_all = "snake_case")]
3
pub enum QueryMsg {
4
DistributionInfo {}
5
}
Copied!
Key
Type
Description
asset_token
HumanAddr
Contract address of asset token

Response

1
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
2
pub struct DistributionInfoResponse {
3
pub weights: Vec<(HumanAddr, u32)>,
4
pub last_distributed: u64,
5
}
Copied!
Key
Type
Description
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
1
{
2
"distribution_info": {}
3
}
Copied!
Key
Type
Description
asset_token
HumanAddr
Contract address of asset token

Response

1
{
2
"distribution_info_response": {
3
"weights": [
4
["terra1...", 8],
5
["terra1...", 8]
6
],
7
"last_distributed": 3600
8
}
9
}
Copied!
Key
Type
Description
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 modified 4mo ago