Factory Module
Creates and manages trading pairs
Last updated
Creates and manages trading pairs
Pairs
struct Pairs has key, store {
id: UID,
list: LinkedTable<ID, PairSimpleInfo>,
index: u64,
}Purpose: Global registry of all trading pairs
Access: Shared object accessible by all users
PairSimpleInfo
struct PairSimpleInfo has copy, drop, store {
pair_id: ID,
pair_key: ID,
bin_step: u16,
coin_type_a: TypeName,
coin_type_b: TypeName
}Purpose: Basic information about a trading pair
InitFactoryEvent
Emitted: When factory is initialized
CreatePairEvent
Emitted: When new trading pair is created
Pair Creation
create_pair<X, Y>: Creates a new trading pair
Validates token types and whitelist status
Initializes pair with specified parameters
Registers pair in global registry
Emits creation event
Pair Management
set_static_fee_parameters: Updates fee structure (admin only)
force_decay: Forces volatility decay (admin only)
pause_pair: Pauses/unpauses trading (admin only)
increase_oracle_length: Expands price oracle capacity (admin only)
View Functions
new_pair_key<X, Y>: Generates deterministic pair key
pool_simple_info: Retrieves pair information
index: Gets total number of pairs created
Last updated
struct InitFactoryEvent has copy, drop {
pairs_id: ID,
}struct CreatePairEvent has copy, drop {
pair_id: ID,
bin_step: u16,
coin_type_a: String,
coin_type_b: String,
active_id: u32,
}