Module nash_protocol::protocol [−][src]
Expand description
Implementation of Nash protocol. Most modules contain submodules for request and response
logic. The types.rs
submodule is a good place to start to understand any given protocol
request. All protocol requests follow logic described by the NashProtocol
or
NashProtocolSubscription
traits.
Modules
Retrieve current asset nonces from Nash server. Asset nonces allow the smart contract to reason about whether a payload such as a sync state or fill order request is valid in relation to previous activity. Generally, only payloads with a higher nonce than the last seen nonce for an asset are considered valid. For fill order payloads, the nonce must equal the current nonce.
Cancel all open orders across markets for the account associated with current session
Cancel a single open order by order id. Must be an order placed by the account associated with the current session
Cancel multiple orders.
Retrieve pool of R-values to use for requests that require signing with threshold signatures
Lookup information associated with an order via id
Get market ticker. Contains information about recent trade prices, liquidity at order book tip, and market volume
Get assets balances associated with the current account session. Returns balances in the account’s personal wallet and funds pending and at rest in the Nash state channels.
List orders associated with the current account session
Get trades associated with the current account session
Get exchange candle data
Get list of current markets running on Nash, as well as associated data.
Get exchange trades data
Multiple requests
Get orderbook data
Place orders
Place multiple orders.
State signing manages the user signing of current account balances in the Nash state channel, as well as re-signing open orders (recycled orders)
Structs
Inner wrapper on valid GraphQL response data
Inner wrapper on error GraphQL response data
Inner wrapper on error GraphQL response data
This signature format is used for GraphQL request payload signatures Data is SHA256 hashed and signed with a secp256k1 ECDSA key
Client state shared across the protocol.
Enums
An enum wrapping all the different protocol requests
Captures and protocol request or pipeline that can be executed in a run_before
or run_after
hook for the NashProtocol
and NashProtocolPipeline
traits.
Wrapper type to account for GraphQL errors
Constants
Traits
Trait that all Nash protocol elements implement. Enforces transformation to GraphQL as well as state changes on response processing.
Trait to abstract over a series of linked protocol requests. For example we use this to abstract over repeated calls to sign_state until there are no more states to sign.
Trait that defines subscriptions over the Nash protocol. The main difference is that
the transformation of response data to SubscriptionResponse
must occur on every
incoming subscription event. Similarly, the subscription is able to modify client state
on every incoming event. This last property is important for a subscription that updates
asset nonces once that is available on the backend.
Similar to TryFrom, but threads additional State in as context that is necessary to perform the conversion
Functions
Given an operation name, unstructured JSON object under the payload key (common to all mutations that require signatures) and list of fields to remove, return a canonical string representation for signing the mutation
Helper to convert JSON to a response or error
Helper to convert data corresponding to raw GraphQL types (B) into nicer library managed types A when failure is possible
Helper to convert data corresponding to raw GraphQL types (B) into nicer library managed types A when failure is possible