serum

package
v0.0.0-...-f6559f2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 9, 2022 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Overview

Code generated by rice embed-go; DO NOT EDIT.

Copyright 2021 github.com/gagliardetto This file has been modified by github.com/gagliardetto

Copyright 2020 dfuse Platform Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

View Source
const (
	SelfTradeBehaviorDecrementTake = iota
	SelfTradeBehaviorCancelProvide

	SelfTradeBehaviorAbortTransaction
)
View Source
const (
	OrderTypeLimit = OrderType(iota)
	OrderTypeImmediateOrCancel
	OrderTypePostOnly
)
View Source
const (
	RequestFlagNewOrder = RequestFlag(1 << iota)
	RequestFlagCancelOrder
	RequestFlagBid
	RequestFlagPostOnly
	RequestFlagImmediateOrCancel
	RequestFlagDecrementTakeOnSelfTrade
)
View Source
const (
	EventFlagFill  = 0x1
	EventFlagOut   = 0x2
	EventFlagBid   = 0x4
	EventFlagMaker = 0x8

	EventFlagReleaseFunds = 0x10
)
View Source
const (
	AccountFlagInitialized = AccountFlag(1 << iota)
	AccountFlagMarket
	AccountFlagOpenOrders
	AccountFlagRequestQueue
	AccountFlagEventQueue
	AccountFlagBids
	AccountFlagAsks
	AccountFlagDisabled
)
View Source
const (
	SideBid = iota
	SideAsk
)
View Source
const EVENT_BYTE_SIZE = uint(88)

Variables

View Source
var DEXProgramIDV2 = solana.MustPublicKeyFromBase58("EUqojwWA2rd19FZrzeBncJsm38Jm1hEhE3zsmX3bRc2o")

DEXProgramIDV2 represents the fixed address on which the Serum DEX v2 smart contract is deployed

View Source
var DEXProgramIDV3 = solana.MustPublicKeyFromBase58("9xQeWvG816bUx9EPjHmaT23yvVM2ZWbrrpZb9PusVFin")
View Source
var InstructionDefVariant = bin.NewVariantDefinition(bin.Uint32TypeIDEncoding, []bin.VariantType{
	{Name: "initialize_market", Type: (*InstructionInitializeMarket)(nil)},
	{Name: "new_order", Type: (*InstructionNewOrder)(nil)},
	{Name: "match_orders", Type: (*InstructionMatchOrder)(nil)},
	{Name: "consume_events", Type: (*InstructionConsumeEvents)(nil)},
	{Name: "cancel_order", Type: (*InstructionCancelOrder)(nil)},
	{Name: "settle_funds", Type: (*InstructionSettleFunds)(nil)},
	{Name: "cancel_order_by_client_id", Type: (*InstructionCancelOrderByClientId)(nil)},
	{Name: "disable_market", Type: (*InstructionDisableMarketAccounts)(nil)},
	{Name: "sweep_fees", Type: (*InstructionSweepFees)(nil)},
	{Name: "new_order_v2", Type: (*InstructionNewOrderV2)(nil)},

	{Name: "new_order_v3", Type: (*InstructionNewOrderV3)(nil)},
	{Name: "cancel_order_v2", Type: (*InstructionCancelOrderV2)(nil)},
	{Name: "cancel_order_by_client_id_v2", Type: (*InstructionCancelOrderByClientIdV2)(nil)},
	{Name: "send_take", Type: (*InstructionSendTake)(nil)},
})
View Source
var SlabFactoryImplDef = bin.NewVariantDefinition(bin.Uint32TypeIDEncoding, []bin.VariantType{
	{Name: "uninitialized", Type: (*SlabUninitialized)(nil)},
	{Name: "inner_node", Type: (*SlabInnerNode)(nil)},
	{Name: "leaf_node", Type: (*SlabLeafNode)(nil)},
	{Name: "free_node", Type: (*SlabFreeNode)(nil)},
	{Name: "last_free_node", Type: (*SlabLastFreeNode)(nil)},
})

Functions

func F

func F() *big.Float

func GetSeqNum

func GetSeqNum(orderId string, side Side) (uint64, error)

func Has

func Has(b, flag uint8) bool

func I

func I() *big.Int

func IsBitZero

func IsBitZero(v bin.Uint128, bitIndex uint32) (bool, error)

func PriceLotsToNumber

func PriceLotsToNumber(price, baseLotSize, quoteLotSize, baseDecimals, quoteDecimals uint64) *big.Float

func StreamOpenOrders

func StreamOpenOrders(client *ws.Client) error

Types

type AccountFlag

type AccountFlag uint64

func (*AccountFlag) Is

func (a *AccountFlag) Is(flag AccountFlag) bool

func (*AccountFlag) String

func (a *AccountFlag) String() string

type CancelOrderAccounts

type CancelOrderAccounts struct {
	Market       *solana.AccountMeta `text:"linear,notype"`
	OpenOrders   *solana.AccountMeta `text:"linear,notype"`
	RequestQueue *solana.AccountMeta `text:"linear,notype"`
	Owner        *solana.AccountMeta `text:"linear,notype"`
}

type CancelOrderByClientIdAccounts

type CancelOrderByClientIdAccounts struct {
	Market       *solana.AccountMeta `text:"linear,notype"`
	OpenOrders   *solana.AccountMeta `text:"linear,notype"`
	RequestQueue *solana.AccountMeta `text:"linear,notype"`
	Owner        *solana.AccountMeta `text:"linear,notype"`
}

type CancelOrderByClientIdV2Accounts

type CancelOrderByClientIdV2Accounts struct {
	Market     *solana.AccountMeta `text:"linear,notype"` // 0. `[writable]` market
	Bids       *solana.AccountMeta `text:"linear,notype"` // 1. `[writable]` bids
	Asks       *solana.AccountMeta `text:"linear,notype"` // 2. `[writable]` asks
	OpenOrders *solana.AccountMeta `text:"linear,notype"` // 3. `[writable]` OpenOrders
	Owner      *solana.AccountMeta `text:"linear,notype"` // 4. `[signer]` the OpenOrders owner
	EventQueue *solana.AccountMeta `text:"linear,notype"` // 5. `[writable]` event_q
}

type CancelOrderV2Accounts

type CancelOrderV2Accounts struct {
	Market     *solana.AccountMeta `text:"linear,notype"` // 0. `[writable]` market
	Bids       *solana.AccountMeta `text:"linear,notype"` // 1. `[writable]` bids
	Asks       *solana.AccountMeta `text:"linear,notype"` // 2. `[writable]` asks
	OpenOrders *solana.AccountMeta `text:"linear,notype"` // 3. `[writable]` OpenOrders
	Owner      *solana.AccountMeta `text:"linear,notype"` // 4. `[signer]` the OpenOrders owner
	EventQueue *solana.AccountMeta `text:"linear,notype"` // 5. `[writable]` event_q
}

type ConsumeEventsAccounts

type ConsumeEventsAccounts struct {
	OpenOrders        []*solana.AccountMeta `text:"linear,notype"`
	Market            *solana.AccountMeta   `text:"linear,notype"`
	EventQueue        *solana.AccountMeta   `text:"linear,notype"`
	CoinFeeReceivable *solana.AccountMeta   `text:"linear,notype"`
	PCFeeReceivable   *solana.AccountMeta   `text:"linear,notype"`
}

type DisableMarketAccounts

type DisableMarketAccounts struct {
	Market           *solana.AccountMeta `text:"linear,notype"`
	DisableAuthority *solana.AccountMeta `text:"linear,notype"`
}

type Event

type Event struct {
	Flag              EventFlag
	OwnerSlot         uint8
	FeeTier           uint8
	Padding           [5]uint8
	NativeQtyReleased uint64 // the amount you should release (free to settle)
	NativeQtyPaid     uint64 // The amount out of your account
	NativeFeeOrRebate uint64 // maker etc...
	OrderID           OrderID
	Owner             solana.PublicKey // OpenOrder Account address NOT trader
	ClientOrderID     uint64
}

func (*Event) Equal

func (e *Event) Equal(other *Event) bool

ASK: Buying PC paying in COIN

func (*Event) Filled

func (e *Event) Filled() bool

func (*Event) Side

func (e *Event) Side() Side

type EventFlag

type EventFlag uint8

func (EventFlag) IsBid

func (e EventFlag) IsBid() bool

func (EventFlag) IsFill

func (e EventFlag) IsFill() bool

func (EventFlag) IsMaker

func (e EventFlag) IsMaker() bool

func (EventFlag) IsOut

func (e EventFlag) IsOut() bool

func (EventFlag) IsReleaseFunds

func (e EventFlag) IsReleaseFunds() bool

func (EventFlag) String

func (e EventFlag) String() string

type EventQueue

type EventQueue struct {
	SerumPadding [5]byte `json:"-"`

	AccountFlags AccountFlag
	Head         bin.Uint64 `bin:"sliceoffsetof=Events,88"`
	Count        bin.Uint64 `bin:"sizeof=Events"`
	SeqNum       bin.Uint64
	Events       []*Event

	EndPadding [7]byte `json:"-"`
}

-> 262144 + 12 bytes -> 12 bytes of serum padding -> 262144 -> 262144 = HEADER + RING-BUFFER -> HEADER = 32 bytes -> RING BUFF = (262144 - 32) 262112 -> ring buf (262144 - 32) -> 262112 -> max number of event

func (*EventQueue) Decode

func (q *EventQueue) Decode(data []byte) error

func (EventQueue) MarshalWithEncoder

func (q EventQueue) MarshalWithEncoder(encoder *bin.Encoder) error

TODO: fill up later

func (*EventQueue) UnmarshalWithDecoder

func (q *EventQueue) UnmarshalWithDecoder(decoder *bin.Decoder) (err error)

type InitializeMarketAccounts

type InitializeMarketAccounts struct {
	Market        *solana.AccountMeta `text:"linear,notype"`
	SPLCoinToken  *solana.AccountMeta `text:"linear,notype"`
	SPLPriceToken *solana.AccountMeta `text:"linear,notype"`
	CoinMint      *solana.AccountMeta `text:"linear,notype"`
	PriceMint     *solana.AccountMeta `text:"linear,notype"`
}

type Instruction

type Instruction struct {
	bin.BaseVariant
	Version uint8
}

func DecodeInstruction

func DecodeInstruction(accounts []*solana.AccountMeta, data []byte) (*Instruction, error)

func (Instruction) MarshalWithEncoder

func (i Instruction) MarshalWithEncoder(encoder *bin.Encoder) error

func (*Instruction) TextEncode

func (i *Instruction) TextEncode(encoder *text.Encoder, option *text.Option) error

func (*Instruction) UnmarshalWithDecoder

func (i *Instruction) UnmarshalWithDecoder(decoder *bin.Decoder) (err error)

type InstructionCancelOrder

type InstructionCancelOrder struct {
	Side          Side
	OrderID       bin.Uint128
	OpenOrders    solana.PublicKey
	OpenOrderSlot uint8

	Accounts *CancelOrderAccounts `bin:"-"`
}

InstructionCancelOrder seems to be unused after DEX v3 (unconfirmed claim)

func (*InstructionCancelOrder) SetAccounts

func (i *InstructionCancelOrder) SetAccounts(accounts []*solana.AccountMeta) error

type InstructionCancelOrderByClientId

type InstructionCancelOrderByClientId struct {
	ClientID uint64

	Accounts *CancelOrderByClientIdAccounts `bin:"-"`
}

InstructionCancelOrderByClientId seems to be unused after DEX v3 (unconfirmed claim)

func (*InstructionCancelOrderByClientId) SetAccounts

func (i *InstructionCancelOrderByClientId) SetAccounts(accounts []*solana.AccountMeta) error

type InstructionCancelOrderByClientIdV2

type InstructionCancelOrderByClientIdV2 struct {
	ClientID uint64

	Accounts *CancelOrderByClientIdV2Accounts `bin:"-"`
}

func (*InstructionCancelOrderByClientIdV2) SetAccounts

func (i *InstructionCancelOrderByClientIdV2) SetAccounts(accounts []*solana.AccountMeta) error

type InstructionCancelOrderV2

type InstructionCancelOrderV2 struct {
	Side    Side
	OrderID bin.Uint128

	Accounts *CancelOrderV2Accounts `bin:"-"`
}

func (*InstructionCancelOrderV2) SetAccounts

func (i *InstructionCancelOrderV2) SetAccounts(accounts []*solana.AccountMeta) error

type InstructionConsumeEvents

type InstructionConsumeEvents struct {
	Limit uint16

	Accounts *ConsumeEventsAccounts `bin:"-"`
}

func (*InstructionConsumeEvents) SetAccounts

func (i *InstructionConsumeEvents) SetAccounts(accounts []*solana.AccountMeta) error

type InstructionDisableMarketAccounts

type InstructionDisableMarketAccounts struct {
	Accounts *DisableMarketAccounts `bin:"-"`
}

func (*InstructionDisableMarketAccounts) SetAccounts

func (i *InstructionDisableMarketAccounts) SetAccounts(accounts []*solana.AccountMeta) error

type InstructionInitializeMarket

type InstructionInitializeMarket struct {
	BaseLotSize        uint64
	QuoteLotSize       uint64
	FeeRateBps         uint16
	VaultSignerNonce   uint64
	QuoteDustThreshold uint64

	Accounts *InitializeMarketAccounts `bin:"-"`
}

func (*InstructionInitializeMarket) SetAccounts

func (i *InstructionInitializeMarket) SetAccounts(accounts []*solana.AccountMeta) error

type InstructionMatchOrder

type InstructionMatchOrder struct {
	Limit uint16

	Accounts *MatchOrderAccounts `bin:"-"`
}

InstructionMatchOrder seems to be unused after DEX v3 (unconfirmed claim)

func (*InstructionMatchOrder) SetAccounts

func (i *InstructionMatchOrder) SetAccounts(accounts []*solana.AccountMeta) error

type InstructionNewOrder

type InstructionNewOrder struct {
	Side        Side
	LimitPrice  uint64
	MaxQuantity uint64
	OrderType   OrderType
	ClientID    uint64

	Accounts *NewOrderAccounts `bin:"-"`
}

InstructionNewOrder seems to be unused after DEX v3 (unconfirmed claim)

func (*InstructionNewOrder) SetAccounts

func (i *InstructionNewOrder) SetAccounts(accounts []*solana.AccountMeta) error

type InstructionNewOrderV2

type InstructionNewOrderV2 struct {
	Side              Side
	LimitPrice        uint64
	MaxQuantity       uint64
	OrderType         OrderType
	ClientID          uint64
	SelfTradeBehavior SelfTradeBehavior

	Accounts *NewOrderV2Accounts `bin:"-"`
}

InstructionNewOrderV2 seems to be unused after DEX v3 (unconfirmed claim)

func (*InstructionNewOrderV2) SetAccounts

func (i *InstructionNewOrderV2) SetAccounts(accounts []*solana.AccountMeta) error

type InstructionNewOrderV3

type InstructionNewOrderV3 struct {
	Side                             Side
	LimitPrice                       uint64
	MaxCoinQuantity                  uint64
	MaxNativePCQuantityIncludingFees uint64
	SelfTradeBehavior                SelfTradeBehavior
	OrderType                        OrderType
	ClientOrderID                    uint64
	Limit                            uint16

	Accounts *NewOrderV3Accounts `bin:"-"`
}

func (*InstructionNewOrderV3) SetAccounts

func (i *InstructionNewOrderV3) SetAccounts(accounts []*solana.AccountMeta) error

type InstructionSendTake

type InstructionSendTake struct {
	Side                             Side
	LimitPrice                       uint64
	MaxCoinQuantity                  uint64
	MaxNativePCQuantityIncludingFees uint64
	MinCoinQuantity                  uint64
	MinNativePCQuantity              uint64
	Limit                            uint16

	Accounts *InstructionSendTakeAccounts `bin:"-"`
}

func (*InstructionSendTake) SetAccounts

func (i *InstructionSendTake) SetAccounts(accounts []*solana.AccountMeta) error

type InstructionSendTakeAccounts

type InstructionSendTakeAccounts struct {
	Market     *solana.AccountMeta `text:"linear,notype"` // 0. `[writable]` market
	Bids       *solana.AccountMeta `text:"linear,notype"` // 1. `[writable]` bids
	Asks       *solana.AccountMeta `text:"linear,notype"` // 2. `[writable]` asks
	OpenOrders *solana.AccountMeta `text:"linear,notype"` // 3. `[writable]` OpenOrders
	Owner      *solana.AccountMeta `text:"linear,notype"` // 4. `[]`
}

InstructionSendTakeAccounts defined from comment in serum-dex contract code, was never able to validate it's correct

type InstructionSettleFunds

type InstructionSettleFunds struct {
	Accounts *SettleFundsAccounts `bin:"-"`
}

func (*InstructionSettleFunds) SetAccounts

func (i *InstructionSettleFunds) SetAccounts(accounts []*solana.AccountMeta) error

type InstructionSweepFees

type InstructionSweepFees struct {
	Accounts *SweepFeesAccounts `bin:"-"`
}

func (*InstructionSweepFees) SetAccounts

func (i *InstructionSweepFees) SetAccounts(accounts []*solana.AccountMeta) error

type MarketMeta

type MarketMeta struct {
	Address    solana.PublicKey `json:"address"`
	Name       string           `json:"name"`
	Deprecated bool             `json:"deprecated"`
	QuoteMint  token.Mint
	BaseMint   token.Mint

	MarketV2 MarketV2
}

func FetchMarket

func FetchMarket(ctx context.Context, rpcCli *rpc.Client, marketAddr solana.PublicKey) (*MarketMeta, error)

func KnownMarket

func KnownMarket() ([]*MarketMeta, error)

TODO: hit the chain and

func (*MarketMeta) BaseSizeLotsToNumber

func (m *MarketMeta) BaseSizeLotsToNumber(size *big.Int) *big.Float

func (*MarketMeta) PriceLotsToNumber

func (m *MarketMeta) PriceLotsToNumber(price *big.Int) *big.Float

func (*MarketMeta) PriceNumberToLots

func (m *MarketMeta) PriceNumberToLots(price *big.Int) *big.Float

type MarketV2

type MarketV2 struct {
	SerumPadding           [5]byte `json:"-"`
	AccountFlags           AccountFlag
	OwnAddress             solana.PublicKey
	VaultSignerNonce       bin.Uint64
	BaseMint               solana.PublicKey
	QuoteMint              solana.PublicKey
	BaseVault              solana.PublicKey
	BaseDepositsTotal      bin.Uint64
	BaseFeesAccrued        bin.Uint64
	QuoteVault             solana.PublicKey
	QuoteDepositsTotal     bin.Uint64
	QuoteFeesAccrued       bin.Uint64
	QuoteDustThreshold     bin.Uint64
	RequestQueue           solana.PublicKey
	EventQueue             solana.PublicKey
	Bids                   solana.PublicKey
	Asks                   solana.PublicKey
	BaseLotSize            bin.Uint64
	QuoteLotSize           bin.Uint64
	FeeRateBPS             bin.Uint64
	ReferrerRebatesAccrued bin.Uint64
	EndPadding             [7]byte `json:"-"`
}

func (*MarketV2) Decode

func (m *MarketV2) Decode(in []byte) error

type MatchOrderAccounts

type MatchOrderAccounts struct {
	Market            *solana.AccountMeta `text:"linear,notype"`
	RequestQueue      *solana.AccountMeta `text:"linear,notype"`
	EventQueue        *solana.AccountMeta `text:"linear,notype"`
	Bids              *solana.AccountMeta `text:"linear,notype"`
	Asks              *solana.AccountMeta `text:"linear,notype"`
	CoinFeeReceivable *solana.AccountMeta `text:"linear,notype"`
	PCFeeReceivable   *solana.AccountMeta `text:"linear,notype"`
}

type NewOrderAccounts

type NewOrderAccounts struct {
	Market             *solana.AccountMeta `text:"linear,notype"`
	OpenOrders         *solana.AccountMeta `text:"linear,notype"`
	RequestQueue       *solana.AccountMeta `text:"linear,notype"`
	Payer              *solana.AccountMeta `text:"linear,notype"`
	Owner              *solana.AccountMeta `text:"linear,notype"` // The owner of the open orders, i.e. the trader
	CoinVault          *solana.AccountMeta `text:"linear,notype"`
	PCVault            *solana.AccountMeta `text:"linear,notype"`
	SPLTokenProgram    *solana.AccountMeta `text:"linear,notype"`
	Rent               *solana.AccountMeta `text:"linear,notype"`
	SRMDiscountAccount *solana.AccountMeta `text:"linear,notype"`
}

type NewOrderV2Accounts

type NewOrderV2Accounts struct {
	Market          *solana.AccountMeta `text:"linear,notype"` // the market
	OpenOrders      *solana.AccountMeta `text:"linear,notype"` // the OpenOrders account to use
	RequestQueue    *solana.AccountMeta `text:"linear,notype"` // the request queue
	Payer           *solana.AccountMeta `text:"linear,notype"` // the (coin or price currency) account paying for the order
	Owner           *solana.AccountMeta `text:"linear,notype"` // owner of the OpenOrders account
	CoinVault       *solana.AccountMeta `text:"linear,notype"` // coin vault
	PCVault         *solana.AccountMeta `text:"linear,notype"` // pc vault
	SPLTokenProgram *solana.AccountMeta `text:"linear,notype"` // spl token program
	RentSysvar      *solana.AccountMeta `text:"linear,notype"` // the rent sysvar
	FeeDiscount     *solana.AccountMeta `text:"linear,notype"` // (optional) the (M)SRM account used for fee discounts
}

type NewOrderV3Accounts

type NewOrderV3Accounts struct {
	Market          *solana.AccountMeta `text:"linear,notype"` // the market
	OpenOrders      *solana.AccountMeta `text:"linear,notype"` // the OpenOrders account to use
	RequestQueue    *solana.AccountMeta `text:"linear,notype"` // the request queue
	EventQueue      *solana.AccountMeta `text:"linear,notype"` // the event queue
	Bidder          *solana.AccountMeta `text:"linear,notype"` // bids
	Asker           *solana.AccountMeta `text:"linear,notype"` // asks
	Payer           *solana.AccountMeta `text:"linear,notype"` // the (coin or price currency) account paying for the order
	Owner           *solana.AccountMeta `text:"linear,notype"` // owner of the OpenOrders account
	CoinVault       *solana.AccountMeta `text:"linear,notype"` // coin vault
	PCVault         *solana.AccountMeta `text:"linear,notype"` // pc vault
	SPLTokenProgram *solana.AccountMeta `text:"linear,notype"` // spl token program
	RentSysvar      *solana.AccountMeta `text:"linear,notype"` // the rent sysvar
	FeeDiscount     *solana.AccountMeta `text:"linear,notype"` // (optional) the (M)SRM account used for fee discounts
}

type OpenOrders

type OpenOrders struct {
	SerumPadding           [5]byte `json:"-"`
	AccountFlags           AccountFlag
	Market                 solana.PublicKey
	Owner                  solana.PublicKey
	NativeBaseTokenFree    bin.Uint64
	NativeBaseTokenTotal   bin.Uint64
	NativeQuoteTokenFree   bin.Uint64
	NativeQuoteTokenTotal  bin.Uint64
	FreeSlotBits           bin.Uint128
	IsBidBits              bin.Uint128 // Bids is 1,  Ask is 0
	Orders                 [128]OrderID
	ClientOrderIDs         [128]bin.Uint64
	ReferrerRebatesAccrued bin.Uint64
	EndPadding             [7]byte `json:"-"`
}

func (*OpenOrders) Decode

func (o *OpenOrders) Decode(in []byte) error

func (*OpenOrders) GetOrder

func (o *OpenOrders) GetOrder(index uint32) *Order

type OpenOrdersMeta

type OpenOrdersMeta struct {
	OpenOrders OpenOrders
}

func FetchOpenOrders

func FetchOpenOrders(ctx context.Context, rpcCli *rpc.Client, openOrdersAddr solana.PublicKey) (*OpenOrdersMeta, error)

type Order

type Order struct {
	ID   OrderID
	Side Side
}

func (*Order) Price

func (o *Order) Price() uint64

func (*Order) SeqNum

func (o *Order) SeqNum() uint64

type OrderID

type OrderID bin.Uint128

func NewOrderID

func NewOrderID(orderID string) (OrderID, error)

func (OrderID) HexString

func (o OrderID) HexString(withPrefix bool) string

func (OrderID) Price

func (o OrderID) Price() uint64

func (OrderID) SeqNum

func (o OrderID) SeqNum(side Side) uint64

type OrderType

type OrderType uint32

type Orderbook

type Orderbook struct {
	SerumPadding [5]byte `json:"-"`
	AccountFlags AccountFlag
	BumpIndex    uint32  `bin:"sizeof=Nodes"`
	ZeroPaddingA [4]byte `json:"-"`
	FreeListLen  uint32
	ZeroPaddingB [4]byte `json:"-"`
	FreeListHead uint32
	Root         uint32
	LeafCount    uint32
	ZeroPaddingC [4]byte `json:"-"`
	Nodes        []*Slab
}

func (*Orderbook) Items

func (o *Orderbook) Items(descending bool, f func(node *SlabLeafNode) error) error

type Request

type Request struct {
	RequestFlags         RequestFlag
	OwnerSlot            uint8
	FeeTier              uint8
	SelfTradeBehavior    uint8
	Padding              [4]byte    `json:"-"`
	MaxCoinQtyOrCancelId bin.Uint64 //the max amount you wish to buy or sell
	NativePCQtyLocked    bin.Uint64
	OrderID              bin.Uint128
	OpenOrders           [4]bin.Uint64 // this is the openOrder address
	ClientOrderID        bin.Uint64
}

Size 80 byte

func (*Request) Equal

func (r *Request) Equal(other *Request) bool

type RequestFlag

type RequestFlag uint8

func (RequestFlag) IsBid

func (r RequestFlag) IsBid() bool

func (RequestFlag) IsCancelOrder

func (r RequestFlag) IsCancelOrder() bool

func (RequestFlag) IsDecrementTakeOnSelfTrade

func (r RequestFlag) IsDecrementTakeOnSelfTrade() bool

func (RequestFlag) IsImmediateOrCancel

func (r RequestFlag) IsImmediateOrCancel() bool

func (RequestFlag) IsNewOrder

func (r RequestFlag) IsNewOrder() bool

func (RequestFlag) IsPostOnly

func (r RequestFlag) IsPostOnly() bool

func (RequestFlag) String

func (f RequestFlag) String() string

type RequestQueue

type RequestQueue struct {
	SerumPadding [5]byte `json:"-"`

	AccountFlags AccountFlag
	Head         bin.Uint64 `bin:"sliceoffsetof=Requests,80"`

	Count      bin.Uint64 `bin:"sizeof=Requests"`
	NextSeqNum bin.Uint64
	Requests   []*Request

	EndPadding [7]byte `json:"-"`
}

func (*RequestQueue) Decode

func (r *RequestQueue) Decode(data []byte) error

func (RequestQueue) MarshalWithEncoder

func (q RequestQueue) MarshalWithEncoder(encoder *bin.Encoder) error

TODO: fill up later

func (*RequestQueue) UnmarshalWithDecoder

func (q *RequestQueue) UnmarshalWithDecoder(decoder *bin.Decoder) (err error)

type SelfTradeBehavior

type SelfTradeBehavior uint32

type SettleFundsAccounts

type SettleFundsAccounts struct {
	Market           *solana.AccountMeta `text:"linear,notype"`
	OpenOrders       *solana.AccountMeta `text:"linear,notype"`
	Owner            *solana.AccountMeta `text:"linear,notype"`
	CoinVault        *solana.AccountMeta `text:"linear,notype"`
	PCVault          *solana.AccountMeta `text:"linear,notype"`
	CoinWallet       *solana.AccountMeta `text:"linear,notype"`
	PCWallet         *solana.AccountMeta `text:"linear,notype"`
	Signer           *solana.AccountMeta `text:"linear,notype"`
	SPLTokenProgram  *solana.AccountMeta `text:"linear,notype"`
	ReferrerPCWallet *solana.AccountMeta `text:"linear,notype"`
}

type Side

type Side uint32

type SideLayout

type SideLayout uint32

type SideLayoutType

type SideLayoutType string
const (
	SideLayoutTypeUnknown SideLayoutType = "UNKNOWN"
	SideLayoutTypeBid     SideLayoutType = "BID"
	SideLayoutTypeAsk     SideLayoutType = "ASK"
)

type Slab

type Slab struct {
	bin.BaseVariant
}

func (Slab) MarshalWithEncoder

func (s Slab) MarshalWithEncoder(encoder *bin.Encoder) error

func (*Slab) UnmarshalWithDecoder

func (s *Slab) UnmarshalWithDecoder(decoder *bin.Decoder) error

type SlabFreeNode

type SlabFreeNode struct {
	Next    uint32
	Padding [64]byte `json:"-"` // ensure variant is 68 bytes
}

type SlabInnerNode

type SlabInnerNode struct {
	PrefixLen uint32
	Key       bin.Uint128
	Children  [2]uint32
	Padding   [40]byte `json:"-"` // ensure variant is 68 bytes
}

type SlabLastFreeNode

type SlabLastFreeNode struct {
	Padding  [4]byte  `json:"-"`
	PaddingA [64]byte `json:"-"` // ensure variant is 68 bytes
}

type SlabLeafNode

type SlabLeafNode struct {
	OwnerSlot     uint8
	FeeTier       uint8
	Padding       [2]byte `json:"-"`
	Key           bin.Uint128
	Owner         solana.PublicKey
	Quantity      bin.Uint64
	ClientOrderId bin.Uint64
}

func (*SlabLeafNode) GetPrice

func (s *SlabLeafNode) GetPrice() *big.Int

type SlabUninitialized

type SlabUninitialized struct {
	Padding  [4]byte  `json:"-"`
	PaddingA [64]byte `json:"-"` // ensure variant is 68 bytes
}

type SweepFeesAccounts

type SweepFeesAccounts struct {
	Market               *solana.AccountMeta `text:"linear,notype"`
	PCVault              *solana.AccountMeta `text:"linear,notype"`
	FeeSweepingAuthority *solana.AccountMeta `text:"linear,notype"`
	FeeReceivableAccount *solana.AccountMeta `text:"linear,notype"`
	VaultSigner          *solana.AccountMeta `text:"linear,notype"`
	SPLTokenProgram      *solana.AccountMeta `text:"linear,notype"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL