Factory Module
Creates and manages trading pairs
Structs
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
Events
InitFactoryEvent
struct InitFactoryEvent has copy, drop {
pairs_id: ID,
}
Emitted: When factory is initialized
CreatePairEvent
struct CreatePairEvent has copy, drop {
pair_id: ID,
bin_step: u16,
coin_type_a: String,
coin_type_b: String,
active_id: u32,
}
Emitted: When new trading pair is created
Core Functions
Pair Creation
create_pair<X, Y>
: Creates a new trading pairValidates 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 keypool_simple_info
: Retrieves pair informationindex
: Gets total number of pairs created
Last updated