zkLink X Documentaion
HomeGitHubBlogExplorer
  • 🙂Welcome
    • Introduction
  • ⚖️Architecture
    • Overview
    • Settlement Layer
      • Working Principal of A Multi-Chain ZK-Rollup
      • Nexus: Settlement on ETH L2s
      • Origin: Settlement on ETH and Alt-L1s
      • Multi-Chain State Synchronization
        • In-Detail: Nexus Multi-Chain State Synchronization
      • Supported Networks of zkLink Nexus and Origin
      • Security Assumptions of zkLink Nexus and Origin
    • Execution Layer
      • TS-zkVM for App Rollup
    • Sequencing Layer
    • DA Layer
  • 🛠️Developer
    • Developer Overview
    • Get Started
    • Examples
      • Base Demo
    • JSON RPC & Websocket & Kafka
      • JSON-RPC API
      • JSON-RPC Errors
      • Websocket
      • Kafka
    • Transactions
      • Basic Types
      • State Update
      • Transaction
        • Deposit
        • FullExit
        • ChangePubKey
        • Withdraw
        • Transfer
        • ForcedExit
        • OrderMatching
        • AutoDeleveraging
        • ContractMatching
        • Funding
        • Liquidation
        • UpdateGlobalVar
      • Private Key & Signature
        • Algorithm
        • ChangePubKey
        • Withdraw
        • Transfer
        • ForcedExit
        • OrderMatching
        • ContractMatching
        • Funding
        • Liquidation
        • AutoDeleveraging
        • UpdateGlobalVar
    • SDK
      • Go
        • Types
        • Signature
        • Utils
        • Transactions
          • ChangePubKey
          • Withdraw
          • Transfer
          • ForcedExit
          • OrderMatching
          • ContractMatching
          • AutoDeleveraging
          • Funding
          • Liquidation
          • UpdateGlobalVar
      • Js
        • Signature
        • Utils
        • Transactions
          • ChangePubKey
          • Withdraw
          • Transfer
          • ForcedExit
          • OrderMatching
          • ContractMatching
          • AutoDeleveraging
          • Funding
          • Liquidation
          • UpdateGlobalVar
      • Dart
        • Signature
        • Utils
        • Transactions
          • ChangePubKey
          • Withdraw
          • Transfer
          • ForcedExit
          • OrderMatching
          • ContractMatching
          • AutoDeleveraging
          • Funding
          • Liquidation
          • UpdateGlobalVar
  • ⚙️Network Information
    • Connected Networks
      • Mainnet
      • Testnet
    • DApps & Deployment Addresses
      • Mainnet
      • Testnet
  • Wallet & User Fund Streamline
    • Withdraw
    • Wallet Integration & AA Wallet
    • Deposit
  • Integration Cases
    • Heavyweight Integration (Multi-Chain Derivatives & Spot Exchange)
    • Simple Integration (Multi-Chain Spot Exchange)
  • Appendix
    • Audits
    • FAQ
    • glossary
Powered by GitBook
On this page
  • ContractPrice
  • SpotPrice
  • type Order
  • OrderMatchingBuilder
  • type OrderMatching

Was this helpful?

  1. Developer
  2. SDK
  3. Go
  4. Transactions

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

func NewOrder(
    accountId AccountId,
    subAccountId SubAccountId,
    slotId SlotId,
    nonce Nonce,
    baseTokenId TokenId,
    quoteTokenId TokenId,
    amount BigUint,
    price BigUint,
    isSell bool,
    hasSubsidy bool,
    makerFeeRate uint8,
    takerFeeRate uint8,
    signature *ZkLinkSignature
) *Order

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

func (*Order) GetSignature() ZkLinkSignature

Get the L3 signature of the Order

func (*Order) GetSignature

func (*Order) GetSignature() ZkLinkSignature {

Get the Order signature.

func (*Order) GetBytes

func (*Order) GetBytes() []uint8

Get the encoded bytes to create the L3 signature.

func *Order) JsonStr

func (*Order) JsonStr() string

Get the json string of the Order.

func (*Order) IsValid

func (*Order) IsValid() bool

Check if the Order is valid or not.

func (*Order) IsSignatureValid

func (*Order) IsSignatureValid() bool

Check if the L3 signature is valid or not.

func (*Order) CreateSignedOrder

func (*Order) CreateSignedOrder(zklinkSigner *ZkLinkSigner) (*Order, error)

Returns a new order with L3 signature.

input:

OrderMatchingBuilder

type OrderMatchingBuilder struct {
    AccountId         AccountId
    SubAccountId      SubAccountId
    Taker             *Order
    Maker             *Order
    Fee               BigUint
    FeeToken          TokenId
    ContractPrices    []ContractPrice
    MarginPrices      []SpotPriceInfo
    ExpectBaseAmount  BigUint
    ExpectQuoteAmount BigUint
}

type OrderMatching

func NewOrderMatching

func NewOrderMatching(builder OrderMatchingBuilder) *OrderMatching

func (*OrderMatching) GetBytes

func (*OrderMatching) GetBytes() []uint8

Get the encoded bytes used to create the L3 signature.

func (*OrderMatching) TxHash() []uint8

func (*OrderMatching) TxHash() []uint8

func (*OrderMatching) JsonStr

func (*OrderMatching) JsonStr() string

func (*OrderMatching) IsValid() bool

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

func (*OrderMatching) CreateSignedTx(signer *ZkLinkSigner) (*OrderMatching, error)

input:

func (*OrderMatching) GetSignature

func (*OrderMatching) GetSignature() ZkLinkSignature

Get the L3 signature of OrderMatching transaction.

func (*OrderMatching) IsSignatureValid

func (*OrderMatching) IsSignatureValid() bool

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

func (*OrderMatching) ToZklinkTx

func (*OrderMatching) ToZklinkTx() ZkLinkTx
PreviousForcedExitNextContractMatching

Last updated 1 year ago

Was this helpful?

zklinkSigner:

The builder is used to bo build transaction.

transaction type, it's a opaque data type.

Create a new transaction.

Get the transaction hash of transaction.

Get the json string of the transaction.

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

signer:

Change the transaction to the

🛠️
OrderMatching
OrderMatching
OrderMatching
OrderMatching
OrderMatching
ZkLinkTx
zkLinkSigner
ZkLinkSigner
ZkLinkSigner