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
The Contract struct of taker and maker in perpetual contract, it's a opaque data type.
func NewContract(builder ContractBuilder) *Contract
Create a new Contract.
func (*Contract) IsLong() bool
Return true if the contract opens a long position.
func (*Contract) IsShort() bool
Return true if the contract opens a short position.
func (_self *Contract) GetSignature() ZkLinkSignature
Get the L3 signature of the contract.
func (*Contract) IsSignatureValid() bool
Check if the signature is valid or not.
func (*Contract) GetBytes() []uint8
Get the encoded bytes that used to create the L3 signature.
func (*Contract) CreateSignedContract(zklinkSigner *ZkLinkSigner) (*Contract, error)
Create a new contract with L3 signature.
input:
- zklinkSigner: zklinkSigner
type ContractMatchingBuilder struct {
AccountId AccountId
SubAccountId SubAccountId
Taker *Contract
Maker []*Contract
Fee BigUint
FeeToken TokenId
}
The ContractMatching transaction in perpetual contract, it's a opaque data type.
func NewContractMatching(builder ContractMatchingBuilder) *ContractMatching
Create a new ContractMatching transaction.
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() []uint8
Get the transaction hash of the transaction.
func (*ContractMatching) JsonStr() string
Get the json string of the the transaction.
func (*ContractMatching) IsValid() bool
Check if the transaction is valid or not.
func (*ContractMatching) CreateSignedTx(signer *ZkLinkSigner) (*ContractMatching, error)
Create a new transaction with L3 signature.
input:
- signer: ZkLinkSigner
func (*ContractMatching) GetSignature() ZkLinkSignature
Get the L3 signature of the transaction.
func (*ContractMatching) IsSignatureValid() bool
Check if the inside L3 signature is valid or not.
func (*ContractMatching) ToZklinkTx() ZkLinkTx
Change the transaction to the ZkLinkTx