Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ws ob / trade docs #14

Merged
merged 6 commits into from
Jan 19, 2024
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
114 changes: 114 additions & 0 deletions source/includes/_orderbook_dlobserver.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,32 @@ Each market currently requires its own subscribe message. The two examples below
}
`

#### Response
soundsonacid marked this conversation as resolved.
Show resolved Hide resolved
#### Response
| Field | Description |
|---------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------|
| channel | Identifies the type of data being streamed. `orderbook_perp_0` indicates data for perpetual market 0 order book (SOL-PERP). |
| data | Contains the actual order book data in JSON format. This field is a JSON string that needs to be parsed. |
| bids | A list of bid orders in the order book, each representing an offer to buy. |
| asks | A list of ask orders in the order book, each representing an offer to sell. |
| price | The price at which the bid or ask is made. |
| size | The size of the bid or ask, indicating the quantity of the asset the buyer or seller wishes to transact. |
| sources | Indicates the origin or source of the bid or ask, such as `vamm` (Virtual Automated Market Maker) or `dlob` (Decentralized Limit Order Book). |
| marketName | Name of the market, e.g., `SOL-PERP`. |
| marketType | Type of the market, e.g., `perp` for perpetual. |
| marketIndex | Index of the market, used to identify specific markets within a market type. |
| slot | A unique identifier for the state of the blockchain at the time the order book snapshot was taken. |
| oracle | The reported price from the oracle for this market. |
| oracleData | Contains detailed information from the oracle, including price, slot, confidence, etc. |
| oracleData.price | The price reported by the oracle. |
| oracleData.slot | The slot number associated with the oracle data. |
| oracleData.confidence | The confidence interval for the oracle price. |
| oracleData.hasSufficientNumberOfDataPoints | Indicates whether the oracle has sufficient data points for reliability. |
| oracleData.twap | The time-weighted average price as reported by the oracle. |
| oracleData.twapConfidence | The confidence interval for the time-weighted average price. |
| marketSlot | Slot number associated with the market data. |


#### Spot markets
`
{
Expand All @@ -80,6 +106,30 @@ Each market currently requires its own subscribe message. The two examples below
}
`

#### Response
#### Response
soundsonacid marked this conversation as resolved.
Show resolved Hide resolved
| Field | Description |
|--------------|-----------------------------------------------------------------------------------------------------------------------------------|
| channel | Identifies the type of data being streamed. i.e `orderbook_spot_1` indicates data for the spot market order book (SOL/USDC). |
| data | Contains the actual order book data in JSON format. This field is a JSON string that needs to be parsed. |
| bids | A list of bid orders in the order book, each representing an offer to buy. |
| asks | A list of ask orders in the order book, each representing an offer to sell. |
| price | The price at which the bid or ask is made. |
| size | The size of the bid or ask, indicating the quantity of the asset the buyer or seller wishes to transact. |
| sources | Indicates the origin or source of the bid or ask, such as `phoenix` or `serum`, representing different liquidity providers. |
soundsonacid marked this conversation as resolved.
Show resolved Hide resolved
| slot | A unique identifier for the state of the blockchain at the time the order book snapshot was taken. |
soundsonacid marked this conversation as resolved.
Show resolved Hide resolved
| marketName | Name of the market, e.g., `SOL`. |
| marketType | Type of the market, e.g., `spot`. |
| marketIndex | Index of the market, used to identify specific markets within a market type. |
| oracle | The reported price from the oracle for this market. |
| oracleData | Contains detailed information from the oracle, including price, slot, confidence, etc. |
| oracleData.price | The price reported by the oracle. |
| oracleData.slot | The slot number associated with the oracle data. |
| oracleData.confidence | The confidence interval for the oracle price. |
| oracleData.hasSufficientNumberOfDataPoints | Indicates whether the oracle has sufficient data points for reliability. |
| oracleData.twap | The time-weighted average price as reported by the oracle. |
| oracleData.twapConfidence | The confidence interval for the time-weighted average price. |

```typescript

import WebSocket from 'ws';
Expand Down Expand Up @@ -167,6 +217,37 @@ Trades feed subscribe messages take a similar form to orderbook data, just chang
}
`

#### Response
| Field | Description |
|--------------------------------------------|---------------------------------------------------------------------------------------------------------------------|
| channel | Identifies the type of data being streamed. `trades_perp_0` indicates data for trades in perp market 0. (SOL-PERP) |
| ts | Timestamp of the trade. |
| marketIndex | Index of the market where the trade occurred. |
| marketType | Type of the market, here it's `perp` for perpetual. |
| filler | The address or identifier of the filler (taker) in the trade. |
| takerFee | Fee paid by the taker in the trade. |
| makerFee | Fee paid or received by the maker in the trade. |
| quoteAssetAmountSurplus | Surplus amount in quote asset. |
| baseAssetAmountFilled | The amount of the base asset that was filled in this trade. |
| quoteAssetAmountFilled | The amount of the quote asset that was filled in this trade. |
| takerOrderId | Order ID of the taker's order, if available. |
| takerOrderBaseAssetAmount | Base asset amount specified in the taker's order. |
| takerOrderCumulativeBaseAssetAmountFilled | Cumulative base asset amount filled in the taker's order. |
| takerOrderCumulativeQuoteAssetAmountFilled | Cumulative quote asset amount filled in the taker's order. |
| maker | The address or identifier of the maker in the trade. |
| makerOrderId | Order ID of the maker's order. |
| makerOrderDirection | Direction of the maker's order (e.g., 'short' or 'long'). |
| makerOrderBaseAssetAmount | Base asset amount specified in the maker's order. |
| makerOrderCumulativeBaseAssetAmountFilled | Cumulative base asset amount filled in the maker's order. |
| makerOrderCumulativeQuoteAssetAmountFilled | Cumulative quote asset amount filled in the maker's order. |
| oraclePrice | The oracle price at the time of the trade. |
| txSig | Transaction signature. |
| slot | Slot number in which the trade occurred. |
| action | Type of action that occurred (e.g., 'fill'). |
soundsonacid marked this conversation as resolved.
Show resolved Hide resolved
| actionExplanation | Explanation of the action (e.g., 'orderFilledWithAmm' indicating order filled with Automated Market Maker). |
| referrerReward | Reward amount for the referrer, if applicable. |


#### Spot markets
`
{
Expand All @@ -177,6 +258,39 @@ Trades feed subscribe messages take a similar form to orderbook data, just chang
}
`

#### Response
| Field | Description |
|--------------------------------------------|--------------------------------------------------------------------------------------------------------------------------|
| channel | Identifies the type of data being streamed. `trades_spot_1` indicates data for trades in spot market 1 (SOL/USDC). |
| ts | Timestamp of the trade. |
| marketIndex | Index of the market where the trade occurred. |
| marketType | Type of the market, here it's `spot`. |
| filler | The address or identifier of the filler (taker) in the trade. |
| takerFee | Fee paid by the taker in the trade. |
| makerFee | Fee paid or received by the maker in the trade. |
| quoteAssetAmountSurplus | Surplus amount in quote asset. |
| baseAssetAmountFilled | The amount of the base asset that was filled in this trade. |
| quoteAssetAmountFilled | The amount of the quote asset that was filled in this trade. |
| taker | The address or identifier of the taker in the trade. |
| takerOrderId | Order ID of the taker's order, if available. |
| takerOrderDirection | Direction of the taker's order (e.g., 'long'). |
| takerOrderBaseAssetAmount | Base asset amount specified in the taker's order. |
| takerOrderCumulativeBaseAssetAmountFilled | Cumulative base asset amount filled in the taker's order. |
| takerOrderCumulativeQuoteAssetAmountFilled | Cumulative quote asset amount filled in the taker's order. |
| maker | The address or identifier of the maker in the trade. |
| makerOrderId | Order ID of the maker's order. |
| makerOrderDirection | Direction of the maker's order (e.g., 'short'). |
| makerOrderBaseAssetAmount | Base asset amount specified in the maker's order. |
| makerOrderCumulativeBaseAssetAmountFilled | Cumulative base asset amount filled in the maker's order. |
| makerOrderCumulativeQuoteAssetAmountFilled | Cumulative quote asset amount filled in the maker's order. |
| oraclePrice | The oracle price at the time of the trade. |
| txSig | Transaction signature. |
| slot | Slot number in which the trade occurred. |
| action | Type of action that occurred (e.g., 'fill'). |
| actionExplanation | Explanation of the action (e.g., 'orderFilledWithMatch' indicating order filled with a matching order). |
| referrerReward | Reward amount for the referrer, if applicable. |


## Websocket - Unsubscribing

To unsubscribe to a channel, send a subscribe-like message, with the message type set to `unsubscribe`. Unsubscribe requests to channels not previously subscribed to will have no impact.
Expand Down
Loading