Documentation
¶
Overview ¶
Package dex provides the DEX L2 subnet adapter for the indexer. Handles orderbook, trades, liquidity pools, and swap operations. The DEX is a standalone L2 subnet (see ~/work/lux/dex), not a native chain.
Index ¶
- Constants
- type Adapter
- func (a *Adapter) GetRecentVertices(ctx context.Context, limit int) ([]json.RawMessage, error)
- func (a *Adapter) GetStats(ctx context.Context, store storage.Store) (map[string]interface{}, error)
- func (a *Adapter) GetVertexByID(ctx context.Context, id string) (json.RawMessage, error)
- func (a *Adapter) InitSchema(ctx context.Context, store storage.Store) error
- func (a *Adapter) ParseVertex(data json.RawMessage) (*dag.Vertex, error)
- func (a *Adapter) StoreLiquidityEvent(ctx context.Context, db *sql.DB, e LiquidityEvent) error
- func (a *Adapter) StoreOrder(ctx context.Context, db *sql.DB, o Order) error
- func (a *Adapter) StorePool(ctx context.Context, db *sql.DB, p LiquidityPool) error
- func (a *Adapter) StoreSwap(ctx context.Context, db *sql.DB, s Swap) error
- func (a *Adapter) StoreTrade(ctx context.Context, db *sql.DB, t Trade) error
- func (a *Adapter) StoreVertex(ctx context.Context, db *sql.DB, v *dag.Vertex) error
- func (a *Adapter) UpdateExtendedStats(ctx context.Context, db *sql.DB) error
- type LiquidityEvent
- type LiquidityPool
- type Order
- type OrderSide
- type OrderStatus
- type OrderType
- type Swap
- type Trade
Constants ¶
const ( // DefaultPort for DEX L2 indexer API DefaultPort = 4800 // DefaultDatabase name DefaultDatabase = "explorer_dchain" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Adapter ¶
type Adapter struct {
// contains filtered or unexported fields
}
Adapter implements the DAG adapter interface for DEX L2
func (*Adapter) GetRecentVertices ¶
GetRecentVertices fetches recent vertices from DEX L2 RPC
func (*Adapter) GetStats ¶
func (a *Adapter) GetStats(ctx context.Context, store storage.Store) (map[string]interface{}, error)
GetStats returns DEX L2 specific statistics using unified storage
func (*Adapter) GetVertexByID ¶
GetVertexByID fetches a specific vertex by ID
func (*Adapter) InitSchema ¶
InitSchema creates DEX L2 specific database tables using unified storage
func (*Adapter) ParseVertex ¶
ParseVertex parses DEX L2 vertex data
func (*Adapter) StoreLiquidityEvent ¶
StoreLiquidityEvent stores a liquidity event
func (*Adapter) StoreOrder ¶
StoreOrder stores an order
func (*Adapter) StoreTrade ¶
StoreTrade stores a trade
func (*Adapter) StoreVertex ¶
StoreVertex stores vertex data
type LiquidityEvent ¶
type LiquidityEvent struct {
ID string `json:"id"`
PoolID string `json:"poolId"`
Provider string `json:"provider"`
Type string `json:"type"` // "add" or "remove"
Amount0 string `json:"amount0"`
Amount1 string `json:"amount1"`
LPTokens string `json:"lpTokens"`
Timestamp time.Time `json:"timestamp"`
}
LiquidityEvent represents add/remove liquidity
type LiquidityPool ¶
type LiquidityPool struct {
ID string `json:"id"`
Token0 string `json:"token0"`
Token1 string `json:"token1"`
Reserve0 string `json:"reserve0"`
Reserve1 string `json:"reserve1"`
LPSupply string `json:"lpSupply"`
Fee uint32 `json:"fee"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
}
LiquidityPool represents an AMM pool
type Order ¶
type Order struct {
ID string `json:"id"`
Owner string `json:"owner"`
Symbol string `json:"symbol"`
Side OrderSide `json:"side"`
Type OrderType `json:"type"`
Price uint64 `json:"price"`
Quantity uint64 `json:"quantity"`
FilledQty uint64 `json:"filledQty"`
TimeInForce string `json:"timeInForce"`
PostOnly bool `json:"postOnly"`
ReduceOnly bool `json:"reduceOnly"`
Status OrderStatus `json:"status"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
}
Order represents a DEX order
type OrderStatus ¶
type OrderStatus string
OrderStatus represents order lifecycle state
const ( OrderStatusOpen OrderStatus = "open" OrderStatusFilled OrderStatus = "filled" OrderStatusCancelled OrderStatus = "cancelled" OrderStatusPartial OrderStatus = "partial" OrderStatusExpired OrderStatus = "expired" )
type Swap ¶
type Swap struct {
ID string `json:"id"`
PoolID string `json:"poolId"`
Sender string `json:"sender"`
TokenIn string `json:"tokenIn"`
TokenOut string `json:"tokenOut"`
AmountIn string `json:"amountIn"`
AmountOut string `json:"amountOut"`
Fee string `json:"fee"`
Timestamp time.Time `json:"timestamp"`
}
Swap represents a pool swap
type Trade ¶
type Trade struct {
ID string `json:"id"`
Symbol string `json:"symbol"`
MakerID string `json:"makerId"`
TakerID string `json:"takerId"`
Maker string `json:"maker"`
Taker string `json:"taker"`
Side OrderSide `json:"side"`
Price uint64 `json:"price"`
Quantity uint64 `json:"quantity"`
Volume uint64 `json:"volume"`
Fee uint64 `json:"fee"`
Timestamp time.Time `json:"timestamp"`
}
Trade represents a completed trade