Documentation ΒΆ
Index ΒΆ
- Constants
- Variables
- func IFuturesABIPack(fnName FuturesFunctionName, args ...interface{}) (data []byte, err error)
- func OrdersToTrimmed(orders []*SignedOrder) []wrappers.Order
- func WrapTxToEIP712(cdc codectypes.AnyUnpacker, chainID uint64, msg cosmtypes.Msg, data []byte, ...) (typeddata.TypedData, error)
- type ContractEvent
- type CoordinatorApproval
- type ECSignature
- type EIP712Domain
- type EthRPCSigner
- type FeeDelegationOptions
- type FuturesFunctionName
- type LocalKeystoreSigner
- type LocalSigner
- type Order
- type OrderEvent
- type OrderEventEndState
- type OrderStatus
- type Permyriad
- type SignatureType
- type SignedCoordinatorApproval
- type SignedOrder
- type SignedOrderJSON
- type SignedSpotOrder
- type SignedTransaction
- type Signer
- type SpotOrder
- type Transaction
- type TrimmedOrderJSON
- type ZeroExTransactionData
Constants ΒΆ
const ( // ESInvalid is an event that is never emitted. It is here to discern between a declared but uninitialized OrderEventEndState ESInvalid = OrderEventEndState("INVALID") // ESOrderAdded means an order was successfully added to the Mesh node ESOrderAdded = OrderEventEndState("ADDED") // ESOrderFilled means an order was filled for a partial amount ESOrderFilled = OrderEventEndState("FILLED") // ESOrderFullyFilled means an order was fully filled such that it's remaining fillableTakerAssetAmount is 0 ESOrderFullyFilled = OrderEventEndState("FULLY_FILLED") // ESOrderCancelled means an order was cancelled on-chain ESOrderCancelled = OrderEventEndState("CANCELLED") // ESOrderExpired means an order expired according to the latest block timestamp ESOrderExpired = OrderEventEndState("EXPIRED") // ESOrderUnexpired means an order is no longer expired. This can happen if a block re-org causes the latest // block timestamp to decline below the order's expirationTimestamp (rare and usually short-lived) ESOrderUnexpired = OrderEventEndState("UNEXPIRED") // ESOrderBecameUnfunded means an order has become unfunded. This happens if the maker transfers the balance / // changes their allowance backing an order ESOrderBecameUnfunded = OrderEventEndState("UNFUNDED") // ESOrderFillabilityIncreased means the fillability of an order has increased. Fillability for an order can // increase if a previously processed fill event gets reverted, or if a maker tops up their balance/allowance // backing an order ESOrderFillabilityIncreased = OrderEventEndState("FILLABILITY_INCREASED") // ESStoppedWatching means an order is potentially still valid but was removed for a different reason (e.g. // the database is full or the peer that sent the order was misbehaving). The order will no longer be watched // and no further events for this order will be emitted. In some cases, the order may be re-added in the // future. ESStoppedWatching = OrderEventEndState("STOPPED_WATCHING") )
OrderEventEndState values
Variables ΒΆ
var BatchFillFnNames = map[FuturesFunctionName]bool{ BatchFillOrders: true, BatchFillOrKillOrders: true, BatchFillOrdersNoThrow: true, }
var BatchMatchOrderFnNames = map[FuturesFunctionName]bool{ BatchMatchOrders: true, BatchMatchOrdersWithMaximalFill: true, }
var MarketFillFnNames = map[FuturesFunctionName]bool{ MarketBuyOrdersFillOrKill: true, MarketSellOrdersFillOrKill: true, MarketBuyOrdersNoThrow: true, MarketSellOrdersNoThrow: true, }
var MatchOrderFnNames = map[FuturesFunctionName]bool{ MatchOrders: true, MatchOrdersWithMaximalFill: true, }
var SingleFillFnNames = map[FuturesFunctionName]bool{ FillOrder: true, FillOrKillOrder: true, }
Functions ΒΆ
func IFuturesABIPack ΒΆ
func IFuturesABIPack(fnName FuturesFunctionName, args ...interface{}) (data []byte, err error)
func OrdersToTrimmed ΒΆ
func OrdersToTrimmed(orders []*SignedOrder) []wrappers.Order
func WrapTxToEIP712 ΒΆ
func WrapTxToEIP712( cdc codectypes.AnyUnpacker, chainID uint64, msg cosmtypes.Msg, data []byte, feeDelegation *FeeDelegationOptions, ) (typeddata.TypedData, error)
WrapTxToEIP712 is an ultimate method that wraps Amino-encoded Cosmos Tx JSON data into an EIP712-compatible request. All messages must be of the same type.
Types ΒΆ
type ContractEvent ΒΆ
type ContractEvent struct { BlockHash common.Hash TxHash common.Hash TxIndex uint LogIndex uint IsRemoved bool Address common.Address Kind string Parameters interface{} }
ContractEvent is an event emitted by a smart contract
func (ContractEvent) MarshalJSON ΒΆ
func (c ContractEvent) MarshalJSON() ([]byte, error)
MarshalJSON implements a custom JSON marshaller for the ContractEvent type
type CoordinatorApproval ΒΆ
type CoordinatorApproval struct { TxOrigin common.Address `json:"txOrigin"` TransactionHash common.Hash `json:"txHash"` TransactionSignature []byte `json:"txSignature"` Domain EIP712Domain `json:"domain"` // contains filtered or unexported fields }
func (*CoordinatorApproval) ComputeApprovalHash ΒΆ
func (a *CoordinatorApproval) ComputeApprovalHash() (common.Hash, error)
ComputeApprovalHash computes a hash of 0x coordinator approval
func (*CoordinatorApproval) CoordinatorDomain ΒΆ
func (a *CoordinatorApproval) CoordinatorDomain() typeddata.TypedDataDomain
type ECSignature ΒΆ
ECSignature contains the parameters of an elliptic curve signature
func (ECSignature) Bytes ΒΆ
func (ecSignature ECSignature) Bytes() []byte
Bytes generates 0x EthSign Signature (append the signature type byte) data
type EIP712Domain ΒΆ
type EthRPCSigner ΒΆ
type EthRPCSigner struct {
// contains filtered or unexported fields
}
EthRPCSigner is a signer that uses a call to Ethereum JSON-RPC method `eth_call` to produce a signature
func (*EthRPCSigner) EthSign ΒΆ
func (e *EthRPCSigner) EthSign(message []byte, signerAddress common.Address) (*ECSignature, error)
EthSign signs a message via the `eth_sign` Ethereum JSON-RPC call
type FeeDelegationOptions ΒΆ
type FeeDelegationOptions struct {
FeePayer cosmtypes.AccAddress
}
type FuturesFunctionName ΒΆ
type FuturesFunctionName string
const ( ClosePositionMetaTransaction FuturesFunctionName = "closePositionMetaTransaction" ClosePosition FuturesFunctionName = "closePosition" LiquidatePosition FuturesFunctionName = "liquidatePosition" VaporizePosition FuturesFunctionName = "vaporizePosition" BatchCheckFunding FuturesFunctionName = "batchCheckFunding" WithdrawForSubAccount FuturesFunctionName = "withdrawForSubAccount" DepositForSubaccount FuturesFunctionName = "depositForSubaccount" Deposit FuturesFunctionName = "deposit" CreateMarketWithFixedMarketId FuturesFunctionName = "createMarketWithFixedMarketId" BatchCancelOrders FuturesFunctionName = "batchCancelOrders" AddMarginIntoPosition FuturesFunctionName = "addMarginIntoPosition" SettleExpiryFuturesPosition FuturesFunctionName = "settleExpiryFuturesPosition" BatchSettleExpiryFuturesPosition FuturesFunctionName = "batchSettleExpiryFuturesPosition" TransferPosition FuturesFunctionName = "transferPosition" ApproveForReceiving FuturesFunctionName = "approveForReceiving" SetReceiptApprovalForMarket FuturesFunctionName = "setReceiptApprovalForMarket" SetReceiptApprovalForAll FuturesFunctionName = "setReceiptApprovalForAll" Approve FuturesFunctionName = "approve" SetApprovalForMarket FuturesFunctionName = "setApprovalForMarket" SetApprovalForAll FuturesFunctionName = "setApprovalForAll" )
const ( //BatchCancelOrders FuturesFunctionName = "batchCancelOrders" BatchExecuteTransactions FuturesFunctionName = "batchExecuteTransactions" BatchFillOrKillOrders FuturesFunctionName = "batchFillOrKillOrders" BatchFillOrders FuturesFunctionName = "batchFillOrders" BatchFillOrdersNoThrow FuturesFunctionName = "batchFillOrdersNoThrow" BatchMatchOrders FuturesFunctionName = "batchMatchOrders" BatchMatchOrdersWithMaximalFill FuturesFunctionName = "batchMatchOrdersWithMaximalFill" CancelOrder FuturesFunctionName = "cancelOrder" CancelOrdersUpTo FuturesFunctionName = "cancelOrdersUpTo" ExecuteTransaction FuturesFunctionName = "executeTransaction" FillOrKillOrder FuturesFunctionName = "fillOrKillOrder" FillOrder FuturesFunctionName = "fillOrder" FillOrderNoThrow FuturesFunctionName = "fillOrderNoThrow" MarketBuyOrdersNoThrow FuturesFunctionName = "marketBuyOrdersNoThrow" MarketSellOrdersNoThrow FuturesFunctionName = "marketSellOrdersNoThrow" MarketBuyOrdersFillOrKill FuturesFunctionName = "marketBuyOrdersFillOrKill" MarketSellOrdersFillOrKill FuturesFunctionName = "marketSellOrdersFillOrKill" MatchOrders FuturesFunctionName = "matchOrders" MatchOrdersWithMaximalFill FuturesFunctionName = "matchOrdersWithMaximalFill" PreSign FuturesFunctionName = "preSign" RegisterAssetProxy FuturesFunctionName = "registerAssetProxy" SetSignatureValidatorApproval FuturesFunctionName = "setSignatureValidatorApproval" SimulateDispatchTransferFromCalls FuturesFunctionName = "simulateDispatchTransferFromCalls" TransferOwnership FuturesFunctionName = "transferOwnership" SetProtocolFeeMultiplier FuturesFunctionName = "setProtocolFeeMultiplier" SetProtocolFeeCollectorAddress FuturesFunctionName = "setProtocolFeeCollectorAddress" DetachProtocolFeeCollector FuturesFunctionName = "detachProtocolFeeCollector" )
func (FuturesFunctionName) HasPart ΒΆ
func (e FuturesFunctionName) HasPart(part string) bool
type LocalKeystoreSigner ΒΆ
type LocalKeystoreSigner struct {
// contains filtered or unexported fields
}
LocalKeystoreSigner is a signer that produces an `eth_sign`-compatible signature locally using a private key
func (*LocalKeystoreSigner) EthSign ΒΆ
func (l *LocalKeystoreSigner) EthSign(message []byte, signerAddress common.Address) (*ECSignature, error)
type LocalSigner ΒΆ
type LocalSigner struct {
// contains filtered or unexported fields
}
LocalSigner is a signer that produces an `eth_sign`-compatible signature locally using a private key
func (*LocalSigner) EthSign ΒΆ
func (l *LocalSigner) EthSign(message []byte, signerAddress common.Address) (*ECSignature, error)
EthSign mimicks the signing of `eth_sign` locally its supplied private key
func (*LocalSigner) GetSignerAddress ΒΆ
func (l *LocalSigner) GetSignerAddress() common.Address
GetSignerAddress returns the signerAddress corresponding to LocalSigner's private key
type Order ΒΆ
type Order struct { ChainID *big.Int `json:"chainId"` ExchangeAddress common.Address `json:"exchangeAddress"` MakerAddress common.Address `json:"makerAddress"` MakerAssetData []byte `json:"makerAssetData"` MakerFeeAssetData []byte `json:"makerFeeAssetData"` MakerAssetAmount *big.Int `json:"makerAssetAmount"` MakerFee *big.Int `json:"makerFee"` TakerAddress common.Address `json:"takerAddress"` TakerAssetData []byte `json:"takerAssetData"` TakerFeeAssetData []byte `json:"takerFeeAssetData"` TakerAssetAmount *big.Int `json:"takerAssetAmount"` TakerFee *big.Int `json:"takerFee"` SenderAddress common.Address `json:"senderAddress"` FeeRecipientAddress common.Address `json:"feeRecipientAddress"` ExpirationTimeSeconds *big.Int `json:"expirationTimeSeconds"` Salt *big.Int `json:"salt"` // contains filtered or unexported fields }
Order represents an unsigned 0x order
func FromTrimmedOrder ΒΆ
func (*Order) ComputeOrderHash ΒΆ
ComputeOrderHash computes a 0x order hash
func (*Order) ComputeSubaccountID ΒΆ
func (*Order) MarshalIntoTrimmedOrderJSON ΒΆ
MarshalJSON implements a custom JSON marshaller for the Order type into Trimmed Order
type OrderEvent ΒΆ
type OrderEvent struct { // Timestamp is an order event timestamp that can be used for bookkeeping purposes. // If the OrderEvent represents a Mesh-specific event (e.g., ADDED, STOPPED_WATCHING), // the timestamp is when the event was generated. If the event was generated after // re-validating an order at the latest block height (e.g., FILLED, UNFUNDED, CANCELED), // then it is set to the latest block timestamp at which the order was re-validated. Timestamp time.Time `json:"timestamp"` // OrderHash is the EIP712 hash of the 0x order OrderHash common.Hash `json:"orderHash"` // SignedOrder is the signed 0x order struct SignedOrder *SignedOrder `json:"signedOrder"` // EndState is the end state of this order at the time this event was generated EndState OrderEventEndState `json:"endState"` // FillableTakerAssetAmount is the amount for which this order is still fillable FillableTakerAssetAmount *big.Int `json:"fillableTakerAssetAmount"` // ContractEvents contains all the contract events that triggered this orders re-evaluation. // They did not all necessarily cause the orders state change itself, only it's re-evaluation. // Since it's state _did_ change, at least one of them did cause the actual state change. ContractEvents []*ContractEvent `json:"contractEvents"` }
OrderEvent is the order event emitted by Mesh nodes on the "orders" topic when calling JSON-RPC method `mesh_subscribe`
func (OrderEvent) MarshalJSON ΒΆ
func (o OrderEvent) MarshalJSON() ([]byte, error)
MarshalJSON implements a custom JSON marshaller for the OrderEvent type
type OrderEventEndState ΒΆ
type OrderEventEndState string
OrderEventEndState enumerates all the possible order event types. An OrderEventEndState describes the end state of a 0x order after revalidation
type OrderStatus ΒΆ
type OrderStatus uint8
OrderStatus represents the status of an order as returned from the 0x smart contracts as part of OrderInfo
const ( OSInvalid OrderStatus = iota OSInvalidMakerAssetAmount OSInvalidTakerAssetAmount OSFillable OSExpired OSFullyFilled OSCancelled OSSignatureInvalid OSInvalidMakerAssetData OSInvalidTakerAssetData )
OrderStatus values
type SignatureType ΒΆ
type SignatureType uint8
SignatureType represents the type of 0x signature encountered
const ( IllegalSignature SignatureType = iota InvalidSignature EIP712Signature EthSignSignature WalletSignature ValidatorSignature PreSignedSignature EIP1271WalletSignature NSignatureTypesSignature )
SignatureType values
type SignedCoordinatorApproval ΒΆ
type SignedCoordinatorApproval struct { CoordinatorApproval Signature []byte `json:"signature"` }
func SignCoordinatorApproval ΒΆ
func SignCoordinatorApproval( coordinatorFrom common.Address, ethSigner Signer, approval *CoordinatorApproval, ) (*SignedCoordinatorApproval, error)
SignCoordinatorApproval signs the 0x coordinator approval with the supplied Signer
type SignedOrder ΒΆ
SignedOrder represents a signed 0x order
func SignOrder ΒΆ
func SignOrder(signer Signer, order *Order) (*SignedOrder, error)
SignOrder signs the 0x order with the supplied Signer.
func (SignedOrder) MarshalJSON ΒΆ
func (s SignedOrder) MarshalJSON() ([]byte, error)
MarshalJSON implements a custom JSON marshaller for the SignedOrder type
func (*SignedOrder) Trim ΒΆ
func (s *SignedOrder) Trim() wrappers.Order
Trim converts the order to a TrimmedOrder, which is the format expected by our smart contracts. It removes the ChainID and ExchangeAddress fields.
func (*SignedOrder) UnmarshalJSON ΒΆ
func (s *SignedOrder) UnmarshalJSON(data []byte) error
UnmarshalJSON implements a custom JSON unmarshaller for the SignedOrder type
type SignedOrderJSON ΒΆ
type SignedOrderJSON struct { ChainID int64 `json:"chainId"` ExchangeAddress string `json:"exchangeAddress"` MakerAddress string `json:"makerAddress"` MakerAssetData string `json:"makerAssetData"` MakerFeeAssetData string `json:"makerFeeAssetData"` MakerAssetAmount string `json:"makerAssetAmount"` MakerFee string `json:"makerFee"` TakerAddress string `json:"takerAddress"` TakerAssetData string `json:"takerAssetData"` TakerFeeAssetData string `json:"takerFeeAssetData"` TakerAssetAmount string `json:"takerAssetAmount"` TakerFee string `json:"takerFee"` SenderAddress string `json:"senderAddress"` FeeRecipientAddress string `json:"feeRecipientAddress"` ExpirationTimeSeconds string `json:"expirationTimeSeconds"` Salt string `json:"salt"` Signature string `json:"signature"` }
SignedOrderJSON is an unmodified JSON representation of a SignedOrder
type SignedSpotOrder ΒΆ
SignedSpotOrder represents a signed Injective Spot order
func SignSpotOrder ΒΆ
func SignSpotOrder(signer Signer, order *SpotOrder) (*SignedSpotOrder, error)
SignSpotOrder signs the Injective Spot order with the supplied Signer.
func (*SignedSpotOrder) ComputeSpotPrice ΒΆ
func (s *SignedSpotOrder) ComputeSpotPrice() *decimal.Decimal
type SignedTransaction ΒΆ
type SignedTransaction struct { Transaction Signature []byte `json:"signature"` }
func SignTransaction ΒΆ
func SignTransaction( sender common.Address, ethSigner Signer, tx *Transaction, ) (*SignedTransaction, error)
SignTransaction signs the 0x transaction with the supplied Signer
type Signer ΒΆ
type Signer interface { EthSign(message []byte, signerAddress common.Address) (*ECSignature, error) EcRecover(message []byte, sig []byte) (common.Address, error) }
Signer defines the methods needed to act as a elliptic curve signer
func NewEthRPCSigner ΒΆ
NewEthRPCSigner instantiates a new EthRPCSigner
func NewLocalKeystoreSigner ΒΆ
NewLocalKeystoreSigner instantiates a new LocalKeystoreSigner
func NewLocalSigner ΒΆ
func NewLocalSigner(privateKey *ecdsa.PrivateKey) Signer
NewLocalSigner instantiates a new LocalSigner
type SpotOrder ΒΆ
type SpotOrder struct { ChainID int64 `json:"chainId"` SubaccountID common.Hash `json:"subaccountID"` Sender common.Address `json:"sender"` FeeRecipient common.Address `json:"feeRecipient"` Expiry uint64 `json:"expiry"` MarketID common.Hash `json:"marketID"` SupplyAmount *big.Int `json:"supplyAmount"` DemandAmount *big.Int `json:"demandAmount"` Salt uint64 `json:"salt"` OrderType uint8 `json:"orderType"` TriggerPrice *big.Int `json:"triggerPrice"` // contains filtered or unexported fields }
SpotOrder represents an unsigned Injective Spot order
func (*SpotOrder) ComputeOrderHash ΒΆ
ComputeOrderHash computes a Injective Spot Order hash
func (*SpotOrder) GetMakerAddressAndNonce ΒΆ
type Transaction ΒΆ
type Transaction struct { Salt *big.Int `json:"salt"` SignerAddress common.Address `json:"signerAddress"` Data []byte `json:"data"` ExpirationTimeSeconds *big.Int `json:"expirationTimeSeconds"` GasPrice *big.Int `json:"gasPrice"` Domain EIP712Domain `json:"domain"` // contains filtered or unexported fields }
func (*Transaction) ComputeTransactionHash ΒΆ
func (tx *Transaction) ComputeTransactionHash() (common.Hash, error)
ComputeTransactionHash computes a 0x transaction hash
func (*Transaction) DecodeTransactionData ΒΆ
func (tx *Transaction) DecodeTransactionData() (*ZeroExTransactionData, error)
func (*Transaction) ExchangeDomain ΒΆ
func (tx *Transaction) ExchangeDomain() typeddata.TypedDataDomain
type TrimmedOrderJSON ΒΆ
type TrimmedOrderJSON struct { MakerAddress string `json:"makerAddress"` MakerAssetData string `json:"makerAssetData"` MakerFeeAssetData string `json:"makerFeeAssetData"` MakerAssetAmount string `json:"makerAssetAmount"` MakerFee string `json:"makerFee"` TakerAddress string `json:"takerAddress"` TakerAssetData string `json:"takerAssetData"` TakerFeeAssetData string `json:"takerFeeAssetData"` TakerAssetAmount string `json:"takerAssetAmount"` TakerFee string `json:"takerFee"` SenderAddress string `json:"senderAddress"` FeeRecipientAddress string `json:"feeRecipientAddress"` ExpirationTimeSeconds string `json:"expirationTimeSeconds"` Salt string `json:"salt"` }
TrimmedOrderJSON is an unmodified JSON representation of a Trimmed Order
type ZeroExTransactionData ΒΆ
type ZeroExTransactionData struct { FunctionName FuturesFunctionName Orders []*Order MarketIDs []common.Hash SubAccountID common.Hash ExchangeAddress common.Address CloseQuantity *big.Int SubaccountID common.Hash Signatures [][]byte PositionID *big.Int Quantity *big.Int BaseCurrency common.Address Amount *big.Int IsRevertingOnPartialFills bool // market specific parameters Ticker string Oracle common.Address InitialMarginRatio Permyriad MaintenanceMarginRatio Permyriad FundingInterval *big.Int ExpirationTime *big.Int MakerTxFee Permyriad TakerTxFee Permyriad RelayerFeePercentage Permyriad MarketID common.Hash // parameters from 0x LeftOrders []*Order RightOrders []*Order TakerAssetFillAmounts []*big.Int MakerAssetFillAmount *big.Int TakerAssetFillAmount *big.Int LeftSignatures [][]byte RightSignatures [][]byte }
func DecodeFromTransactionData ΒΆ
func DecodeFromTransactionData(data []byte) (txData *ZeroExTransactionData, err error)
func (*ZeroExTransactionData) ValidateAssetFillAmounts ΒΆ
func (data *ZeroExTransactionData) ValidateAssetFillAmounts() error
Source Files ΒΆ
Directories ΒΆ
Path | Synopsis |
---|---|
bandchain
|
|
chain
|
|
auction/types
Package types is a reverse proxy.
|
Package types is a reverse proxy. |
erc20bridge/types
Package types is a reverse proxy.
|
Package types is a reverse proxy. |
insurance/types
Package types is a reverse proxy.
|
Package types is a reverse proxy. |
oracle/types
Package types is a reverse proxy.
|
Package types is a reverse proxy. |
ethereum
|
|
exchange
|
|