ContractMatching

type ContractBuilder

type ContractBuilder struct {
    AccountId    AccountId
    SubAccountId SubAccountId
    SlotId       SlotId
    Nonce        Nonce
    PairId       PairId
    Size         BigUint
    Price        BigUint
    Direction    bool
    TakerFeeRate uint8
    MakerFeeRate uint8
    HasSubsidy   bool
}

Builder used to build Contract

type Contract

The Contract struct of taker and maker in perpetual contract, it's a opaque data type.

func NewContract

func NewContract(builder ContractBuilder) *Contract

Create a new Contract.

func (*Contract) IsLong

func (*Contract) IsLong() bool

Return true if the contract opens a long position.

func (*Contract) IsShort

func (*Contract) IsShort() bool

Return true if the contract opens a short position.

func (*Contract) GetSignature

func (_self *Contract) GetSignature() ZkLinkSignature

Get the L3 signature of the contract.

func (*Contract) IsSignatureValid

func (*Contract) IsSignatureValid() bool

Check if the signature is valid or not.

func (*Contract) GetBytes

func (*Contract) GetBytes() []uint8 

Get the encoded bytes that used to create the L3 signature.

func (*Contract) CreateSignedContract

func (*Contract) CreateSignedContract(zklinkSigner *ZkLinkSigner) (*Contract, error)

Create a new contract with L3 signature.

input:

type ContractMatchingBuilder

type ContractMatchingBuilder struct {
    AccountId    AccountId
    SubAccountId SubAccountId
    Taker        *Contract
    Maker        []*Contract
    Fee          BigUint
    FeeToken     TokenId
}

type ContractMatching

The ContractMatching transaction in perpetual contract, it's a opaque data type.

NewContractMatching(builder ContractMatchingBuilder)

func NewContractMatching(builder ContractMatchingBuilder) *ContractMatching

Create a new ContractMatching transaction.

func (*ContractMatching) GetBytes

func (_self *ContractMatching) GetBytes() []uint8

Get the encoded bytes that used to create the L3 signature. See more in Private Key and Signature.

func (*ContractMatching) TxHash

func (*ContractMatching) TxHash() []uint8

Get the transaction hash of the transaction.

func (*ContractMatching) JsonStr

func (*ContractMatching) JsonStr() string

Get the json string of the the transaction.

func (*ContractMatching) IsValid

func (*ContractMatching) IsValid() bool

Check if the transaction is valid or not.

func (*ContractMatching) CreateSignedTx

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

Create a new transaction with L3 signature.

input:

func (*ContractMatching) GetSignature

func (*ContractMatching) GetSignature() ZkLinkSignature

Get the L3 signature of the transaction.

func (*ContractMatching) IsSignatureValid

func (*ContractMatching) IsSignatureValid() bool

Check if the inside L3 signature is valid or not.

func (*ContractMatching) ToZklinkTx

func (*ContractMatching) ToZklinkTx() ZkLinkTx

Change the transaction to the ZkLinkTx

Last updated