State

Genesis state defines the initial state of the module to be used to setup the module.

// GenesisState defines the exchange module's genesis state.
type GenesisState struct {
	// params defines all the parameters of related to exchange.
	Params Params
	// accounts is an array containing the genesis trade pairs
	SpotMarkets []*SpotMarket
	// accounts is an array containing the genesis derivative markets
	DerivativeMarkets []*DerivativeMarket
	// spot_orderbook defines the spot exchange limit orderbook active at genesis.
	SpotOrderbook []SpotOrderBook
	// derivative_orderbook defines the derivative exchange limit orderbook active at genesis.
	DerivativeOrderbook []DerivativeOrderBook
	// balances defines the exchange users balances active at genesis.
	Balances []Balance
	// positions defines the exchange derivative positions at genesis
	Positions []DerivativePosition
	// subaccount_trade_nonces defines the subaccount trade nonces for the subaccounts at genesis
	SubaccountTradeNonces []SubaccountNonce
	// expiry_futures_market_info defines the market info for the expiry futures markets at genesis
	ExpiryFuturesMarketInfoState []ExpiryFuturesMarketInfoState
	// perpetual_market_info defines the market info for the perpetual derivative markets at genesis
	PerpetualMarketInfo []PerpetualMarketInfo
	// perpetual_market_funding_state defines the funding state for the perpetual derivative markets at genesis
	PerpetualMarketFundingState []PerpetualMarketFundingState
	// derivative_market_settlement_scheduled defines the scheduled markets for settlement at genesis
	DerivativeMarketSettlementScheduled []DerivativeMarketSettlementInfo
	// sets spot markets as enabled
	IsSpotExchangeEnabled               bool
	// sets derivative markets as enabled
	IsDerivativesExchangeEnabled        bool
	// the current trading reward campaign info
	TradingRewardCampaignInfo           *TradingRewardCampaignInfo
	// the current and upcoming trading reward campaign pools
	TradingRewardPoolCampaignSchedule   []*CampaignRewardPool
	// the current and upcoming trading reward account points
	TradingRewardCampaignAccountPoints  []*TradingRewardCampaignAccountPoints
	// the current and upcoming trading reward campaign pending pools
	PendingTradingRewardPoolCampaignSchedule []*CampaignRewardPool
	// the pending trading reward account points
	PendingTradingRewardCampaignAccountPoints []*TradingRewardCampaignAccountPendingPoints
	// the fee discount schedule
	FeeDiscountSchedule                 *FeeDiscountSchedule
	// the cached fee discount account tiers with TTL
	FeeDiscountAccountTierTtl           []*FeeDiscountAccountTierTTL
	// the fee discount paid by accounts in all buckets
	FeeDiscountBucketFeesPaidAccounts   []*FeeDiscountBucketFeesPaidAccounts
	// sets the first fee cycle as finished
	IsFirstFeeCycleFinished             bool
}

Params

Params is a module-wide configuration that stores system parameters and defines overall functioning of the exchange module. This configuration is modifiable by governance using params update proposal natively supported by gov module.

It defines default fee objects to be used for spot and derivative markets and funding parameters for derivative markets and instant listing fees.

Protobuf interface for the exchange module params store.

Balance

Balance is to manage balances of accounts. The module is storing the whole balance in the module account, while the balance of each account is managed just as a record.

The Balance object is stored by subaccount_id and denom.

SubaccountNonce

SubaccountNonce is used to express unique order hashes.

Order

There are a number of structures used to store the orders into the store.

SpotMarket

SpotMarket is the structure to store all the required information and state for a spot market. Spot markets are stored by hash of the market to query the market efficiently.

SpotOrderBook

SpotOrderBook is a structure to store spot limit orders for a specific market. Two objects are created, one for buy orders and one for sell orders.

DerivativeMarket

DerivativeMarket is the structure to store all the required information and state for a derivative market. Derivative markets are stored by hash of the market to query the market efficiently.

DerivativeOrderBook

DerivativeOrderBook is a structure to store derivative limit orders for a specific market. Two objects are created, one for buy orders and one for sell orders.

DerivativePosition

DerivativePosition is a structure to store derivative positions for a subaccount on a specific market.

Note: Derivative orders represent intent while positions represent possession.

ExpiryFuturesMarketInfo

ExpiryFuturesMarketInfo is a structure to keep the information of expiry futures market. It is stored by the id of the market.

PerpetualMarketInfo

PerpetualMarketInfo is a structure to keep the information of perpetual market.

PerpetualMarketFunding

PerpetualMarketFunding is a structure to manage perpetual market fundings info.

Trading Rewards

CampaignRewardPool

CampaignRewardPool is a structure to be used for getting the upcoming trading reward pools.

TradingRewardCampaignInfo

TradingRewardCampaignInfo is a structure to be used for getting the trading reward campaign info.

FeeDiscountProposal

FeeDiscountProposal is a structure to be used for proposing a new fee discount schedule and durations.

DerivativeMarketSettlementInfo

DerivativeMarketSettlementInfo is a structure to be used for the scheduled markets for settlement.

TradeLog

Trade logs are emitted in events to track the trading history.

Enums

Enums are used to describe the order types, execution types and market status.

GrantAuthorization

GrantAuthorization is used to track the grantee's address and amount of the granted stake that has been authorized by the granter for trading fee discounts.

ActiveGrant

ActiveGrant is used to track the granter's address and amount of the granted stake (for trading fee discounts) in the grant that has been activated by the grantee.

EffectiveGrant

EffectiveGrant is used to track the total amount of stake a granter has authorized in stake grants for trading fee discounts.

Last updated