Skip to main content

Factory

The factory contract handles the creation and management of the pair contract. You can think of it as its parent contract. It will spawn new pairs for every new pair.

InstantiateMsg

For instantiation, we need to provide the source code id of halo_pair contract and cw-20 base contract for halo-factory contract like shown below.

instantiate
{
"pair_code_id": 123,
"token_code_id": 123
}

ExecuteMsg

Below are the available ExecuteMsg (write) methods for the factory contract.

UpdateConfig

The update_config ExecuteMsg allows for updating the core values used within. It can be called as shown below.

update_config
{
"update_config": {
"owner": "aura...",
"token_code_id": 321,
"pair_code_id": 321
}
}

Where:

  • owner is the address of the owner of the factory contract.
  • token_code_id is the new source code id of cw-20 base contract.
  • pair_code_id is the new source code id of halo-pair contract.

CreatePair

The parameters in requirements include the whitelisted users who can provide liquidity for the first time when pair is empty and the minimum amount of assets that users must provide in the first time. It can be called as shown below.

note

To create a new pool in the factory contract, users must provide a whitelist address(es) and a minimum amount for each asset when when creating a pool for the first time using add_liquidity with the pair contract.

create_pair
{
"create_pair": {
"asset_infos": [
{
"token": {
"contract_addr": "aura..."
}
},
{
"native_token": {
"denom": "uaura"
}
}
],
"requirements": {
"whitelist": [
"aura...",
"aura..."
],
"first_asset_minimum": 10000,
"second_asset_minimum": 20000
},
"commission_rate": "0.003",
"lp_token_info": {
"lp_token_name": "AURA_HALO_LP",
"lp_token_symbol": "AURA_HALO_LP",
}
},
}

Where:

  • asset_infos is the information of both assets in the pair.
  • requirements is the whitelist wallet address list and requirements for providing liquidity for the first time.
  • commission_rate is the commission rate of the pair.
  • lp_token_info is the information of the LP token.

AddNativeTokenDecimals

Before a native token can be added to a pair, you need to specify their decimals and denom. It can be called like shown below.

add_native_token_decimals
{
"add_native_token_decimals": {
"denom": "uaura",
"decimals": 6,
}
}

Where:

  • denom is the denom of the native token.
  • decimals is the decimals of the native token.

QueryMsg

Below are the available QueryMsg (read) queries for the factory contract.

Config

Displays the current configuration values for the contract. This query returns a ConfigResponse response type. It can be queried as shown below.

config
{
"config": {}
}

Pair

Returns the details for any token pair contract created by the factory contract. This query returns a PairInfo response type.

pair
{
"pair": {
"asset_infos": [
{
"token": {
"contract_addr": "aura..."
}
},
{
"native_token": {
"denom": "uaura"
}
}
]
}
}

Pairs

Returns a list of the pair contracts instantiated by the factory contract. Returns a PairsResponse response type. It can be queried as shown below.

pairs
{
"pairs": { }
}

NativeTokenDecimals

Returns the native token decimals. Returns a NativeTokenDecimals response type. It can be queried as shown below.

native_token_decimals
{
"native_token_decimals": {
"denom": "uaura",
},
}