Factory
Overview
The factory contract can create new Astroport pair contracts (and associated LP token contracts) which are tracked in a registry and used as a directory for all pairs. The default pair types are constant product and stableswap but governance may decide to add custom pools that can have any implementation.
Links
- Contract Address: terra14x9fr055x5hvr48hzy2t4q7kvjvfttsvxusa4xsdcy702mnzsvuqprer8r
- Testnet Address: terra1z3y69xas85r7egusa0c7m5sam0yk97gsztqmh8f2cc6rr4s4anysudp7k0
- Contract Repo: https://github.com/astroport-fi/astroport-core/tree/main/contracts/factory
- contract.rs: https://github.com/astroport-fi/astroport-core/blob/main/contracts/factory/src/contract.rs
- factory.rs: https://github.com/astroport-fi/astroport-core/blob/main/packages/astroport/src/factory.rs
- Tests: https://github.com/astroport-fi/astroport-core/blob/main/contracts/factory/tests/integration.rs
InstantiateMsg
The instantiation message takes in the token code ID for the token type supported on Astroport. It also takes in the fee_address
that collects fees for governance, the contract owner
, the Generator contract address and the initial pair types available to create.
Params | Type | Description |
---|---|---|
pair_configs | Vec<PairConfig> | IDs of contracts that are allowed to instantiate pairs |
token_code_id | u64 | CW20 token contract code identifier |
fee_address | Option<String> | Contract address to send governance fees to (the Maker) |
generator_address | Option<String> | Address of contract that is used to auto_stake LP tokens once someone provides liquidity in a pool |
owner | String | Address of owner that is allowed to change factory contract parameters |
whitelist_code_id | u64 | CW1 whitelist contract code id used to store 3rd party rewards for staking Astroport LP tokens |
PairConfig
This struct stores a pair type's configuration.
Params | Type | Description |
---|---|---|
code_id | u64 | ID of contract which is allowed to create pairs of this type |
pair_type | PairType | The pair type (provided in a [PairType ]) |
total_fee_bps | u16 | The total fees (in bps) charged by a pair of this type |
maker_fee_bps | u16 | The amount of fees (in bps) collected by the Maker contract from this pair type |
is_disabled | bool | Whether a pair type is disabled or not. If it is disabled, new pairs cannot be created, but existing ones can still read the pair configuration |
is_generator_disabled | bool | Setting this to true means that pairs of this type will not be able to get an ASTRO generator |
PairType
This enum describes available pair types.
Variants | Description |
---|---|
Xyk | XYK pair type |
Stable | Stable pair type |
Custom | Custom pair type |
ExecuteMsg
update_config
Updates contract variables, namely the code ID of the token implementation used in Astroport, the address that receives governance fees and the Generator contract address.
Params | Type | Description |
---|---|---|
token_code_id | u64 | CW20 token contract code identifier |
fee_address | Option<String> | Contract address to send governance fees to (the Maker) |
generator_address | Option<String> | Address of contract that is used to auto_stake LP tokens once someone provides liquidity in a pool |
whitelist_code_id | u64 | CW1 whitelist contract code id used to store 3rd party rewards for staking Astroport LP tokens |
update_pair_config
This function can be used to:
- Update the code ID used to instantiate new pairs of a specific type
- Change the fee structure for a pair
- Disable the pair type so no other pairs can be instantiated
Note that all fields are optional.
The fee structure for a pair is set up as follows:
total_fee_bps
is the total amount of fees (in bps) that are charged on each swapmaker_fee_bps
is the percentage of fees out oftotal_fee_bps
that is sent to governance. 100% is 10,000
As an example, let's say a pool charged 30bps (total_fee_bps
is 30) and we want 1/3r of the fees to go to governance. In this case, maker_fee_bps
should be 3333 because 3333 / 10,000 * 30 / 100 = 0.1%
Params | Type | Description |
---|---|---|
config | PairConfig | New [PairConfig ] settings for a pair type |
create_pair
Anyone can execute this function to create an Astroport pair. CreatePair
creates both a Pair
contract and a LP(liquidity provider)
token contract. The account that instantiates the pair must specify the pair type they want as well as the assets for which the pool is created.
Custom pool types may also need extra parameters which can be packed in init_params
.
Params | Type | Description |
---|---|---|
pair_type | PairType | The pair type (exposed in [PairType ]) |
asset_infos | Vec<AssetInfo> | The assets to create the pool for |
init_params | Option<Binary> | Optional binary serialised parameters for custom pool types |
deregister
Deregisters an already registered pair. This allows someone else to create a new pair (of any type) for the tokens that don't have a registered pair anymore. This is how pairs can be "upgraded".
Params | Type | Description |
---|---|---|
asset_infos | Vec<AssetInfo> | The assets for which we deregister a pool |
propose_new_owner
Creates an offer to change the contract ownership. The validity period of the offer is set in the expires_in
variable. After expires_in
seconds pass, the proposal expires and cannot be accepted anymore.
Params | Type | Description |
---|---|---|
owner | String | Newly proposed contract owner |
expires_in | u64 | The date after which this proposal expires |
drop_ownership_proposal
Removes an existing offer to change the contract owner.
claim_ownership
Used to claim contract ownership.
mark_as_migrated
Mark pairs as migrated.
Params | Type | Description |
---|---|---|
pairs | Vec<String> | Migrated pairs |
QueryMsg
All query messages are described below. A custom struct is defined for each query response.
config
Queries general factory parameters (owner, token code ID, pair type configurations).
ConfigResponse
Params | Type | Description |
---|---|---|
owner | Addr | Addres of owner that is allowed to change contract parameters |
pair_configs | Vec<PairConfig> | IDs of contracts which are allowed to create pairs |
token_code_id | u64 | CW20 token contract code identifier |
fee_address | Option<Addr> | Address of contract to send governance fees to (the Maker) |
generator_address | Option<Addr> | Address of contract used to auto_stake LP tokens for Astroport pairs that are incentivized |
whitelist_code_id | u64 | CW1 whitelist contract code id used to store 3rd party rewards for staking Astroport LP tokens |
pair
Queries information about a specific pair.
Params | Type | Description |
---|---|---|
asset_infos | Vec<AssetInfo> | The assets in the pair |
Returns a PairInfo
response struct.
pairs
Queries information about multiple pairs (the result is paginated). The function starts returning pair information starting after the pair start_after
. The function returns maximum limit
pairs.
Params | Type | Description |
---|---|---|
start_after | Option<Vec<AssetInfo>> | The pair item to start reading from. It is an [Option ] type that accepts [AssetInfo ] elements |
limit | Option<u32> | The number of pairs to read and return. It is an [Option ] type |
PairsResponse
Params | Type | Description |
---|---|---|
pairs | Vec<PairInfo> | Arrays of structs containing information about multiple pairs |
fee_info
Queries fee information for a specific pair type (total_fee_bps
and maker_fee_bps
).
Params | Type | Description |
---|---|---|
pair_type | PairType | The pair type for which we return fee information. Pair type is a [PairType ] struct |
FeeInfoResponse
Params | Type | Description |
---|---|---|
fee_address | Option<Addr> | Contract address to send governance fees to |
total_fee_bps | u16 | Total amount of fees (in bps) charged on a swap |
maker_fee_bps | u16 | Amount of fees (in bps) sent to the Maker contract |
blacklisted_pair_types
Returns a vector that contains blacklisted pair types.
blacklisted_pair_types
returns a Vec<PairType>
pairs_to_migrate
Returns a vector that contains pair addresses that are not migrated.