Documentation
¶
Overview ¶
Package txs defines transaction types for the DEX VM.
Index ¶
Constants ¶
This section is empty.
Variables ¶
Functions ¶
This section is empty.
Types ¶
type AddLiquidityTx ¶
type AddLiquidityTx struct {
BaseTx
PoolID ids.ID `json:"poolId"`
Token0Amount uint64 `json:"token0Amount"`
Token1Amount uint64 `json:"token1Amount"`
MinLPTokens uint64 `json:"minLPTokens"`
Deadline int64 `json:"deadline"`
}
AddLiquidityTx represents adding liquidity to a pool.
func NewAddLiquidityTx ¶
func NewAddLiquidityTx( from ids.ShortID, nonce uint64, poolID ids.ID, token0Amount, token1Amount, minLPTokens uint64, ) *AddLiquidityTx
NewAddLiquidityTx creates a new add liquidity transaction.
func (*AddLiquidityTx) Verify ¶
func (tx *AddLiquidityTx) Verify() error
type BaseTx ¶
type BaseTx struct {
TxID ids.ID `json:"id"`
TxType TxType `json:"type"`
From ids.ShortID `json:"from"`
Nonce uint64 `json:"nonce"`
GasPrice uint64 `json:"gasPrice"`
GasLimit uint64 `json:"gasLimit"`
CreatedAt int64 `json:"createdAt"`
Signature []byte `json:"signature"`
// contains filtered or unexported fields
}
BaseTx contains common fields for all transactions.
type CancelOrderTx ¶
CancelOrderTx represents a cancel order transaction.
func NewCancelOrderTx ¶
NewCancelOrderTx creates a new cancel order transaction.
func (*CancelOrderTx) Verify ¶
func (tx *CancelOrderTx) Verify() error
type CreatePoolTx ¶
type CreatePoolTx struct {
BaseTx
Token0 ids.ID `json:"token0"`
Token1 ids.ID `json:"token1"`
PoolType uint8 `json:"poolType"` // 0 = ConstantProduct, 1 = StableSwap, 2 = Concentrated
SwapFeeBps uint16 `json:"swapFeeBps"`
InitialToken0 uint64 `json:"initialToken0"`
InitialToken1 uint64 `json:"initialToken1"`
// For concentrated liquidity
TickLower int32 `json:"tickLower"`
TickUpper int32 `json:"tickUpper"`
}
CreatePoolTx represents creating a new liquidity pool.
func NewCreatePoolTx ¶
func NewCreatePoolTx( from ids.ShortID, nonce uint64, token0, token1 ids.ID, poolType uint8, swapFeeBps uint16, initialToken0, initialToken1 uint64, ) *CreatePoolTx
NewCreatePoolTx creates a new create pool transaction.
func (*CreatePoolTx) Verify ¶
func (tx *CreatePoolTx) Verify() error
type CrossChainSwapTx ¶
type CrossChainSwapTx struct {
BaseTx
SourceChain ids.ID `json:"sourceChain"`
DestChain ids.ID `json:"destChain"`
TokenIn ids.ID `json:"tokenIn"`
TokenOut ids.ID `json:"tokenOut"`
AmountIn uint64 `json:"amountIn"`
MinAmountOut uint64 `json:"minAmountOut"`
Recipient ids.ShortID `json:"recipient"`
WarpMessageID ids.ID `json:"warpMessageId"`
Deadline int64 `json:"deadline"`
}
CrossChainSwapTx represents a cross-chain atomic swap via Warp.
func (*CrossChainSwapTx) Verify ¶
func (tx *CrossChainSwapTx) Verify() error
type CrossChainTransferTx ¶
type CrossChainTransferTx struct {
BaseTx
SourceChain ids.ID `json:"sourceChain"`
DestChain ids.ID `json:"destChain"`
Token ids.ID `json:"token"`
Amount uint64 `json:"amount"`
Recipient ids.ShortID `json:"recipient"`
WarpMessageID ids.ID `json:"warpMessageId"`
}
CrossChainTransferTx represents a cross-chain token transfer via Warp.
func (*CrossChainTransferTx) Verify ¶
func (tx *CrossChainTransferTx) Verify() error
type PlaceOrderTx ¶
type PlaceOrderTx struct {
BaseTx
Symbol string `json:"symbol"`
Side uint8 `json:"side"` // 0 = Buy, 1 = Sell
OrderType uint8 `json:"orderType"` // 0 = Limit, 1 = Market, etc.
Price uint64 `json:"price"`
Quantity uint64 `json:"quantity"`
StopPrice uint64 `json:"stopPrice"`
PostOnly bool `json:"postOnly"`
ReduceOnly bool `json:"reduceOnly"`
TimeInForce string `json:"timeInForce"` // GTC, IOC, FOK
ExpiresAt int64 `json:"expiresAt"`
}
PlaceOrderTx represents a place order transaction.
func NewPlaceOrderTx ¶
func NewPlaceOrderTx( from ids.ShortID, nonce uint64, symbol string, side uint8, orderType uint8, price, quantity uint64, timeInForce string, ) *PlaceOrderTx
NewPlaceOrderTx creates a new place order transaction.
func (*PlaceOrderTx) Verify ¶
func (tx *PlaceOrderTx) Verify() error
type RemoveLiquidityTx ¶
type RemoveLiquidityTx struct {
BaseTx
PoolID ids.ID `json:"poolId"`
LPTokenAmount uint64 `json:"lpTokenAmount"`
MinToken0 uint64 `json:"minToken0"`
MinToken1 uint64 `json:"minToken1"`
Deadline int64 `json:"deadline"`
}
RemoveLiquidityTx represents removing liquidity from a pool.
func NewRemoveLiquidityTx ¶
func NewRemoveLiquidityTx( from ids.ShortID, nonce uint64, poolID ids.ID, lpTokenAmount, minToken0, minToken1 uint64, ) *RemoveLiquidityTx
NewRemoveLiquidityTx creates a new remove liquidity transaction.
func (*RemoveLiquidityTx) Verify ¶
func (tx *RemoveLiquidityTx) Verify() error
type SwapTx ¶
type SwapTx struct {
BaseTx
PoolID ids.ID `json:"poolId"`
TokenIn ids.ID `json:"tokenIn"`
TokenOut ids.ID `json:"tokenOut"`
AmountIn uint64 `json:"amountIn"`
MinAmountOut uint64 `json:"minAmountOut"`
MaxSlippage uint16 `json:"maxSlippage"` // In basis points
Deadline int64 `json:"deadline"`
}
SwapTx represents an AMM swap transaction.
type Tx ¶
type Tx interface {
// ID returns the unique identifier for this transaction.
ID() ids.ID
// Type returns the transaction type.
Type() TxType
// Sender returns the sender's address.
Sender() ids.ShortID
// Timestamp returns when the transaction was created.
Timestamp() int64
// Bytes returns the serialized transaction.
Bytes() []byte
// Verify validates the transaction.
Verify() error
}
Tx is the interface for all DEX transactions.