OrderMatching

ContractPrice

type ContractPrice struct {
    PairId      PairId
    MarketPrice BigUint
}
  • PairId: The contract pair id defined by zkLink.

  • MarketPrice: The market price of the contract pair

SpotPrice

type SpotPriceInfo struct {
	TokenId TokenId
	Price   BigUint
}
  • TokenId: The token id defined by zkLink.

  • price: The spot price of the token.

type Order

The spot order type of taker and maker. it's a opaque data type.

func NewOrder

Create a new Order.

input:

  • accountId: the user account id

  • subAccountId: the user sub account id

  • slotId: the slot id of order

  • nonce: the nonce of user account

  • baseTokenId: the token id of the base token of trade pair, for example, "BTC" token id of "BTCUSDT" pair

  • quoteTokenId: the token id of the quote token of trade pari, for example, "USDT" token id of "BTCUSDT" pair

  • amount: the amount of base token

  • price: the price of base token

  • isSell: sell token or not

  • hasSubsidy: subsidy only works for maker and makerFeeRate

  • makeFeeRate: the fee maker rate, 100 means 1%, max is 2.56%

  • takerFeeRate: the fee taker rate, 100 means 1%, max is 2.56%

  • signature: optional, the L3 signature of the Order

func (*Order) GetSignature

Get the L3 signature of the Order

func (*Order) GetSignature

Get the Order signature.

func (*Order) GetBytes

Get the encoded bytes to create the L3 signature.

func *Order) JsonStr

Get the json string of the Order.

func (*Order) IsValid

Check if the Order is valid or not.

func (*Order) IsSignatureValid

Check if the L3 signature is valid or not.

func (*Order) CreateSignedOrder

Returns a new order with L3 signature.

input:

OrderMatchingBuilder

The builder is used to bo build OrderMatching transaction.

type OrderMatching

OrderMatching transaction type, it's a opaque data type.

func NewOrderMatching

Create a new OrderMatching transaction.

func (*OrderMatching) GetBytes

Get the encoded bytes used to create the L3 signature.

func (*OrderMatching) TxHash() []uint8

Get the transaction hash of OrderMatching transaction.

func (*OrderMatching) JsonStr

Get the json string of the OrderMatching transaction.

func (*OrderMatching) IsValid() bool

Check if all the fields in OrderMatching are valid. For example, if the ChainId is exceeded the maximum ChainId, it will return false.

func (*OrderMatching) CreateSignedTx

Sign the Transfer transaction with the ZkLinkSigner, L1 signature and L3 signature will be created.

input:

func (*OrderMatching) GetSignature

Get the L3 signature of OrderMatching transaction.

func (*OrderMatching) IsSignatureValid

Check if the L3 signature in the transaction is valid or not.

func (*OrderMatching) ToZklinkTx

Change the transaction to the ZkLinkTx

Last updated

Was this helpful?