@cubexch/client
Advanced tools
Comparing version 1.1.21 to 1.2.0
export declare const protobufPackage = "market_data"; | ||
/** | ||
* This schema defines the Protobuf messages used for communication with the | ||
* Cube Market Data Service (Mendelev, MD). | ||
* Cube Market Data Service (Mendelev, MD). The `proto` definition file can be | ||
* found [here](https://github.com/cubexch/ws-api/blob/main/schema/market_data.proto). | ||
* | ||
@@ -9,3 +10,4 @@ * ### Order Book Data | ||
* The market data service exposes a websocket endpoint for order book data for | ||
* a given market at `/book/:market_id`. The order book can be consumed by both | ||
* a given market at `wss://api.cube.exchange/md/book/:market_id`. The order | ||
* book can be consumed by both | ||
* price level through the Market by Price (MBP) and order-by-order through the | ||
@@ -19,4 +21,4 @@ * Market by Order (MBO). In addition, clients can subscribe to the trade stream | ||
* The market data service exposes a websocket endpoint for aggregated | ||
* tops-of-book for all markets at `/tops`. Client should process | ||
* [`AggMessage`](#aggmessage). | ||
* tops-of-book for all markets at `wss://api.cube.exchange/md/tops`. Client | ||
* should process [`AggMessage`](#aggmessage). | ||
* | ||
@@ -53,3 +55,30 @@ * ### Heartbeats | ||
} | ||
/** The per-market matching engine state. Affects order-entry. */ | ||
export declare enum MarketState { | ||
/** UNSPECIFIED - Sentinel */ | ||
UNSPECIFIED = 0, | ||
/** | ||
* NORMAL_OPERATION - The market is in its normal operating state. All order operations are | ||
* supported. | ||
*/ | ||
NORMAL_OPERATION = 1, | ||
/** | ||
* CANCEL_ONLY - The market is in cancel-only mode. Existing orders are not automatically | ||
* canceled, and may be filled when the market transitions back to | ||
* normal-operation. | ||
*/ | ||
CANCEL_ONLY = 2 | ||
} | ||
/** | ||
* The side of the aggressing order. This also indicates if the aggressing order | ||
* was an implied order (i.e aggressed into a different market and executed into | ||
* this one through implieds) | ||
*/ | ||
export declare enum AggressingSide { | ||
AGGRESSING_BID = 0, | ||
AGGRESSING_ASK = 1, | ||
AGGRESSING_IMPLIED_BID = 2, | ||
AGGRESSING_IMPLIED_ASK = 3 | ||
} | ||
/** | ||
* The side of the rate update. Given a `BASE` rate of `r`, the `QUOTE` rate is | ||
@@ -85,2 +114,5 @@ * `1 / r`, and vice versa. | ||
kline?: Kline | undefined; | ||
marketStatus?: MarketStatus | undefined; | ||
/** The market ID that this message is for. Null for `MdMessage.Heartbeat`. */ | ||
marketId?: bigint | undefined; | ||
} | ||
@@ -216,2 +248,6 @@ /** | ||
} | ||
export interface MarketStatus { | ||
transactTime: bigint; | ||
marketState: MarketState; | ||
} | ||
/** | ||
@@ -234,3 +270,3 @@ * Trades since the latest `Trades` message. The result of the trades will also | ||
/** The side of the aggressing order. */ | ||
aggressingSide: Side; | ||
aggressingSide: AggressingSide; | ||
/** | ||
@@ -332,2 +368,7 @@ * The [Exchange order ID](./websocket-trade-api.md#exchange-order-id) of | ||
rolling24hPrice?: bigint | undefined; | ||
impliedBidPrice?: bigint | undefined; | ||
impliedBidQuantity?: bigint | undefined; | ||
impliedAskPrice?: bigint | undefined; | ||
impliedAskQuantity?: bigint | undefined; | ||
marketState: MarketState; | ||
} | ||
@@ -386,2 +427,4 @@ /** | ||
klines: KlineInterval[]; | ||
/** Market's to subscribe to. Limit 3. */ | ||
marketIds: bigint[]; | ||
} |
"use strict"; | ||
/* eslint-disable */ | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.MarketByOrderDiff_DiffOp = exports.MarketByPriceDiff_DiffOp = exports.RateUpdateSide = exports.KlineInterval = exports.Side = exports.protobufPackage = void 0; | ||
exports.MarketByOrderDiff_DiffOp = exports.MarketByPriceDiff_DiffOp = exports.RateUpdateSide = exports.AggressingSide = exports.MarketState = exports.KlineInterval = exports.Side = exports.protobufPackage = void 0; | ||
exports.protobufPackage = "market_data"; | ||
/** | ||
* This schema defines the Protobuf messages used for communication with the | ||
* Cube Market Data Service (Mendelev, MD). | ||
* Cube Market Data Service (Mendelev, MD). The `proto` definition file can be | ||
* found [here](https://github.com/cubexch/ws-api/blob/main/schema/market_data.proto). | ||
* | ||
@@ -13,3 +14,4 @@ * ### Order Book Data | ||
* The market data service exposes a websocket endpoint for order book data for | ||
* a given market at `/book/:market_id`. The order book can be consumed by both | ||
* a given market at `wss://api.cube.exchange/md/book/:market_id`. The order | ||
* book can be consumed by both | ||
* price level through the Market by Price (MBP) and order-by-order through the | ||
@@ -23,4 +25,4 @@ * Market by Order (MBO). In addition, clients can subscribe to the trade stream | ||
* The market data service exposes a websocket endpoint for aggregated | ||
* tops-of-book for all markets at `/tops`. Client should process | ||
* [`AggMessage`](#aggmessage). | ||
* tops-of-book for all markets at `wss://api.cube.exchange/md/tops`. Client | ||
* should process [`AggMessage`](#aggmessage). | ||
* | ||
@@ -59,3 +61,32 @@ * ### Heartbeats | ||
})(KlineInterval = exports.KlineInterval || (exports.KlineInterval = {})); | ||
/** The per-market matching engine state. Affects order-entry. */ | ||
var MarketState; | ||
(function (MarketState) { | ||
/** UNSPECIFIED - Sentinel */ | ||
MarketState[MarketState["UNSPECIFIED"] = 0] = "UNSPECIFIED"; | ||
/** | ||
* NORMAL_OPERATION - The market is in its normal operating state. All order operations are | ||
* supported. | ||
*/ | ||
MarketState[MarketState["NORMAL_OPERATION"] = 1] = "NORMAL_OPERATION"; | ||
/** | ||
* CANCEL_ONLY - The market is in cancel-only mode. Existing orders are not automatically | ||
* canceled, and may be filled when the market transitions back to | ||
* normal-operation. | ||
*/ | ||
MarketState[MarketState["CANCEL_ONLY"] = 2] = "CANCEL_ONLY"; | ||
})(MarketState = exports.MarketState || (exports.MarketState = {})); | ||
/** | ||
* The side of the aggressing order. This also indicates if the aggressing order | ||
* was an implied order (i.e aggressed into a different market and executed into | ||
* this one through implieds) | ||
*/ | ||
var AggressingSide; | ||
(function (AggressingSide) { | ||
AggressingSide[AggressingSide["AGGRESSING_BID"] = 0] = "AGGRESSING_BID"; | ||
AggressingSide[AggressingSide["AGGRESSING_ASK"] = 1] = "AGGRESSING_ASK"; | ||
AggressingSide[AggressingSide["AGGRESSING_IMPLIED_BID"] = 2] = "AGGRESSING_IMPLIED_BID"; | ||
AggressingSide[AggressingSide["AGGRESSING_IMPLIED_ASK"] = 3] = "AGGRESSING_IMPLIED_ASK"; | ||
})(AggressingSide = exports.AggressingSide || (exports.AggressingSide = {})); | ||
/** | ||
* The side of the rate update. Given a `BASE` rate of `r`, the `QUOTE` rate is | ||
@@ -62,0 +93,0 @@ * `1 / r`, and vice versa. |
@@ -1,2 +0,2 @@ | ||
import { Side, KlineInterval, RateUpdateSide, MdMessage, MarketByPrice, MarketByPrice_Level, MarketByPriceDiff, MarketByPriceDiff_DiffOp, MarketByPriceDiff_Diff, MarketByOrder, MarketByOrder_Order, MarketByOrderDiff, MarketByOrderDiff_DiffOp, MarketByOrderDiff_Diff, Trades, Trades_Trade, Summary, Kline, Heartbeat, MdMessages, AggMessage, TopOfBook, TopOfBooks, RateUpdate, RateUpdates, ClientMessage, Config } from '../market_data'; | ||
import { Side, KlineInterval, MarketState, AggressingSide, RateUpdateSide, MdMessage, MarketByPrice, MarketByPrice_Level, MarketByPriceDiff, MarketByPriceDiff_DiffOp, MarketByPriceDiff_Diff, MarketByOrder, MarketByOrder_Order, MarketByOrderDiff, MarketByOrderDiff_DiffOp, MarketByOrderDiff_Diff, MarketStatus, Trades, Trades_Trade, Summary, Kline, Heartbeat, MdMessages, AggMessage, TopOfBook, TopOfBooks, RateUpdate, RateUpdates, ClientMessage, Config } from '../market_data'; | ||
import * as _m0 from "protobufjs/minimal"; | ||
@@ -7,2 +7,6 @@ export declare function sideFromJSON(object: any): Side; | ||
export declare function klineIntervalToJSON(object: KlineInterval): string; | ||
export declare function marketStateFromJSON(object: any): MarketState; | ||
export declare function marketStateToJSON(object: MarketState): string; | ||
export declare function aggressingSideFromJSON(object: any): AggressingSide; | ||
export declare function aggressingSideToJSON(object: AggressingSide): string; | ||
export declare function rateUpdateSideFromJSON(object: any): RateUpdateSide; | ||
@@ -68,2 +72,8 @@ export declare function rateUpdateSideToJSON(object: RateUpdateSide): string; | ||
}; | ||
export declare const MarketStatusMethods: { | ||
encode(message: MarketStatus, writer?: _m0.Writer): _m0.Writer; | ||
decode(input: _m0.Reader | Uint8Array, length?: number): MarketStatus; | ||
fromJSON(object: any): MarketStatus; | ||
toJSON(message: MarketStatus): unknown; | ||
}; | ||
export declare const TradesMethods: { | ||
@@ -70,0 +80,0 @@ encode(message: Trades, writer?: _m0.Writer): _m0.Writer; |
@@ -1,2 +0,2 @@ | ||
import { Side, TimeInForce, OrderType, SelfTradePrevention, PostOnly, FixedPointDecimal, Credentials, OrderRequest, NewOrder, CancelOrder, ModifyOrder, MassCancel, Heartbeat, OrderResponse, NewOrderAck, CancelOrderAck, CancelOrderAck_Reason, ModifyOrderAck, MassCancelAck, MassCancelAck_Reason, NewOrderReject, NewOrderReject_Reason, CancelOrderReject, CancelOrderReject_Reason, ModifyOrderReject, ModifyOrderReject_Reason, Fill, AssetPosition, RawUnits, Bootstrap, RestingOrders, AssetPositions, Done, RestingOrder } from '../trade'; | ||
import { Side, TimeInForce, OrderType, SelfTradePrevention, PostOnly, ConnectionStatus, Credentials, OrderRequest, NewOrder, CancelOrder, ModifyOrder, MassCancel, Heartbeat, OrderResponse, NewOrderAck, CancelOrderAck, CancelOrderAck_Reason, ModifyOrderAck, MassCancelAck, MassCancelAck_Reason, NewOrderReject, NewOrderReject_Reason, CancelOrderReject, CancelOrderReject_Reason, ModifyOrderReject, ModifyOrderReject_Reason, Fill, FixedPointDecimal, AssetPosition, RawUnits, Bootstrap, RestingOrders, AssetPositions, Done, TradingStatus, RestingOrder } from '../trade'; | ||
import * as _m0 from "protobufjs/minimal"; | ||
@@ -13,2 +13,4 @@ export declare function sideFromJSON(object: any): Side; | ||
export declare function postOnlyToJSON(object: PostOnly): string; | ||
export declare function connectionStatusFromJSON(object: any): ConnectionStatus; | ||
export declare function connectionStatusToJSON(object: ConnectionStatus): string; | ||
export declare function cancelOrderAck_ReasonFromJSON(object: any): CancelOrderAck_Reason; | ||
@@ -24,8 +26,2 @@ export declare function cancelOrderAck_ReasonToJSON(object: CancelOrderAck_Reason): string; | ||
export declare function modifyOrderReject_ReasonToJSON(object: ModifyOrderReject_Reason): string; | ||
export declare const FixedPointDecimalMethods: { | ||
encode(message: FixedPointDecimal, writer?: _m0.Writer): _m0.Writer; | ||
decode(input: _m0.Reader | Uint8Array, length?: number): FixedPointDecimal; | ||
fromJSON(object: any): FixedPointDecimal; | ||
toJSON(message: FixedPointDecimal): unknown; | ||
}; | ||
export declare const CredentialsMethods: { | ||
@@ -127,2 +123,8 @@ encode(message: Credentials, writer?: _m0.Writer): _m0.Writer; | ||
}; | ||
export declare const FixedPointDecimalMethods: { | ||
encode(message: FixedPointDecimal, writer?: _m0.Writer): _m0.Writer; | ||
decode(input: _m0.Reader | Uint8Array, length?: number): FixedPointDecimal; | ||
fromJSON(object: any): FixedPointDecimal; | ||
toJSON(message: FixedPointDecimal): unknown; | ||
}; | ||
export declare const AssetPositionMethods: { | ||
@@ -164,2 +166,8 @@ encode(message: AssetPosition, writer?: _m0.Writer): _m0.Writer; | ||
}; | ||
export declare const TradingStatusMethods: { | ||
encode(message: TradingStatus, writer?: _m0.Writer): _m0.Writer; | ||
decode(input: _m0.Reader | Uint8Array, length?: number): TradingStatus; | ||
fromJSON(object: any): TradingStatus; | ||
toJSON(message: TradingStatus): unknown; | ||
}; | ||
export declare const RestingOrderMethods: { | ||
@@ -166,0 +174,0 @@ encode(message: RestingOrder, writer?: _m0.Writer): _m0.Writer; |
export declare const protobufPackage = "trade"; | ||
/** | ||
* This schema defines the Protobuf messages used for communication with the | ||
* Cube Order Service (Osmium, OS). | ||
* Cube Order Service (Osmium, OS). The base URL for channels described in this | ||
* page is `wss://api.cube.exchange/os`. The `proto` definition file can be found | ||
* [here](https://github.com/cubexch/ws-api/blob/main/schema/trade.proto). | ||
* | ||
@@ -41,3 +43,3 @@ * ### Connection | ||
* / (10^18 WEI / ETH) | ||
* = 230 ETH | ||
* = 0.230 ETH | ||
* | ||
@@ -211,11 +213,10 @@ * 6300 quote lots / base lot | ||
/** | ||
* A fixed-point decimal number. | ||
* Matches the representation preferred by the FIX protocol, | ||
* except that the exponent is int32 since Protobuf does not have an int8 type. | ||
* The value is computed as `mantissa * 10^exponent`; | ||
* for example, `mantissa = 1234` and `exponent = -2` is `12.34`. | ||
* Indicates which operations are allowed on this connection. | ||
* The ConnectionStatus may change during a single connection's lifetime. | ||
*/ | ||
export interface FixedPointDecimal { | ||
mantissa: bigint; | ||
exponent: number; | ||
export declare enum ConnectionStatus { | ||
/** READ_ONLY - This connection may query balances and see resting orders but may not create, modify, or cancel orders e.g. */ | ||
READ_ONLY = 0, | ||
/** READ_WRITE - There are no restrictions imposed by this connection (though restrictions may apply from elsewhere in the system). */ | ||
READ_WRITE = 1 | ||
} | ||
@@ -231,3 +232,3 @@ /** | ||
* | ||
* Implementation notes: | ||
* ### Implementation notes: | ||
* - The signature is base-64 encoded with the 'standard' alphabet and | ||
@@ -243,5 +244,17 @@ * padding. | ||
* | ||
* If the credentials provided are incorrect, the server will drop the connection with a close code of 4401. | ||
* | ||
* ### Examples | ||
* | ||
* In the following examples, replace "cafecafecafe..." with your secret key. | ||
* When calculated for: | ||
* secret key: "cafecafecafecafecafecafecafecafecafecafecafecafecafecafecafecafe" | ||
* timestamp: 1706546268 | ||
* ...the resulting signature should be: | ||
* "tmtSP4NIzTLXyVUHIOfinotGnPWyfM8JefxivBdSjc8=" | ||
* | ||
* #### Rust | ||
* | ||
* ```rust compile_fail | ||
* // With crates hmac, base64, hex: | ||
* use base64::Engine; | ||
@@ -251,3 +264,3 @@ * use hmac::{Hmac, Mac, NewMac}; | ||
* | ||
* let secret_key = [...]; | ||
* let secret_key = hex::decode("cafecafecafecafecafecafecafecafecafecafecafecafecafecafecafecafe").expect("secret key valid hex").as_slice(); | ||
* | ||
@@ -433,2 +446,3 @@ * let timestamp: u64 = SystemTime::now().duration_since(SystemTime::UNIX_EPOCH).unwrap().as_secs(); | ||
massCancelAck?: MassCancelAck | undefined; | ||
tradingStatus?: TradingStatus | undefined; | ||
} | ||
@@ -717,12 +731,28 @@ /** | ||
exchangeOrderId: bigint; | ||
/** The price that this trade occured at. */ | ||
/** | ||
* The price at which this trade occured. | ||
* In the case of an implied fill, this price may be fractional, | ||
* and will be truncated in that case. | ||
* To determine the exact amount of the assets exchanged in the fill, | ||
* use the fill_quantity and quote_quantity fields. | ||
*/ | ||
fillPrice: bigint; | ||
/** The quantity that was traded in this fill. */ | ||
/** | ||
* The quantity of the base asset that was traded in this fill, | ||
* expressed in lots of the base asset. | ||
*/ | ||
fillQuantity: bigint; | ||
/** The remaining quantity for this order after the fill is applied. */ | ||
/** The remaining base quantity for this order after the fill is applied. */ | ||
leavesQuantity: bigint; | ||
/** | ||
* The quantity of the quote asset that was traded in this fill, | ||
* expressed in lots of the quote asset. | ||
* This will generally be the same as the base fill_quantity * fill_price, | ||
* but may be different in the case of an implied fill. | ||
*/ | ||
fillQuoteQuantity: bigint; | ||
/** [Transact time](#transact-time) */ | ||
transactTime: bigint; | ||
subaccountId: bigint; | ||
/** The cumulative filled quantity for this order after the fill is applied. */ | ||
/** The cumulative filled base quantity for this order after the fill is applied. */ | ||
cumulativeQuantity: bigint; | ||
@@ -743,2 +773,13 @@ side: Side; | ||
/** | ||
* A fixed-point decimal number. | ||
* Matches the representation preferred by the FIX protocol, | ||
* except that the exponent is int32 since Protobuf does not have an int8 type. | ||
* The value is computed as `mantissa * 10^exponent`; | ||
* for example, `mantissa = 1234` and `exponent = -2` is `12.34`. | ||
*/ | ||
export interface FixedPointDecimal { | ||
mantissa: bigint; | ||
exponent: number; | ||
} | ||
/** | ||
* The user's underlying asset position. These are sent asynchronously as | ||
@@ -771,5 +812,5 @@ * positions are updated and broadcast through internal position channels. They | ||
* A bootstrap message sent after Credentials authentication. | ||
* Client resting and pending orders used to bootstrap state. Sent as the first | ||
* message(s) after initialization. Bootstrap is complete after a message tagged | ||
* `Done` is received and every message after that will be an `OrderResponse`. | ||
* Client resting and pending orders used to bootstrap state. | ||
* Sent as the first message(s) after initialization. | ||
* A message containing the `Done` variant indicates that the Bootstrap is complete. | ||
* Multiple messages may be received for `RestingOrders` and `AssetPositions` | ||
@@ -782,2 +823,3 @@ * and these should be concatenated. | ||
position?: AssetPositions | undefined; | ||
tradingStatus?: TradingStatus | undefined; | ||
} | ||
@@ -796,4 +838,17 @@ /** A chunk of resting orders. Sent on bootstrap. */ | ||
latestTransactTime: bigint; | ||
/** | ||
* DEPRECATED: will be removed in a future version; | ||
* read the "connection_status" field in the "Bootstrap.TradingStatus" message | ||
* that arrives before the "Done" message | ||
*/ | ||
readOnly: boolean; | ||
} | ||
/** | ||
* Indicates the scope of the ability to trade via this connection. | ||
* This message will be sent each time that scope changes. | ||
*/ | ||
export interface TradingStatus { | ||
/** Indicates which operations are available through this connection as of this message. */ | ||
connectionStatus: ConnectionStatus; | ||
} | ||
/** A resting order. Sent on bootstrap in `RestingOrders`. */ | ||
@@ -800,0 +855,0 @@ export interface RestingOrder { |
"use strict"; | ||
/* eslint-disable */ | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.ModifyOrderReject_Reason = exports.CancelOrderReject_Reason = exports.NewOrderReject_Reason = exports.MassCancelAck_Reason = exports.CancelOrderAck_Reason = exports.PostOnly = exports.SelfTradePrevention = exports.OrderType = exports.TimeInForce = exports.Side = exports.protobufPackage = void 0; | ||
exports.ModifyOrderReject_Reason = exports.CancelOrderReject_Reason = exports.NewOrderReject_Reason = exports.MassCancelAck_Reason = exports.CancelOrderAck_Reason = exports.ConnectionStatus = exports.PostOnly = exports.SelfTradePrevention = exports.OrderType = exports.TimeInForce = exports.Side = exports.protobufPackage = void 0; | ||
exports.protobufPackage = "trade"; | ||
/** | ||
* This schema defines the Protobuf messages used for communication with the | ||
* Cube Order Service (Osmium, OS). | ||
* Cube Order Service (Osmium, OS). The base URL for channels described in this | ||
* page is `wss://api.cube.exchange/os`. The `proto` definition file can be found | ||
* [here](https://github.com/cubexch/ws-api/blob/main/schema/trade.proto). | ||
* | ||
@@ -45,3 +47,3 @@ * ### Connection | ||
* / (10^18 WEI / ETH) | ||
* = 230 ETH | ||
* = 0.230 ETH | ||
* | ||
@@ -219,2 +221,13 @@ * 6300 quote lots / base lot | ||
})(PostOnly = exports.PostOnly || (exports.PostOnly = {})); | ||
/** | ||
* Indicates which operations are allowed on this connection. | ||
* The ConnectionStatus may change during a single connection's lifetime. | ||
*/ | ||
var ConnectionStatus; | ||
(function (ConnectionStatus) { | ||
/** READ_ONLY - This connection may query balances and see resting orders but may not create, modify, or cancel orders e.g. */ | ||
ConnectionStatus[ConnectionStatus["READ_ONLY"] = 0] = "READ_ONLY"; | ||
/** READ_WRITE - There are no restrictions imposed by this connection (though restrictions may apply from elsewhere in the system). */ | ||
ConnectionStatus[ConnectionStatus["READ_WRITE"] = 1] = "READ_WRITE"; | ||
})(ConnectionStatus = exports.ConnectionStatus || (exports.ConnectionStatus = {})); | ||
var CancelOrderAck_Reason; | ||
@@ -221,0 +234,0 @@ (function (CancelOrderAck_Reason) { |
{ | ||
"name": "@cubexch/client", | ||
"version": "1.1.21", | ||
"version": "1.2.0", | ||
"scripts": { | ||
@@ -12,4 +12,2 @@ "build": "tsc" | ||
], | ||
"dependencies": { | ||
}, | ||
"devDependencies": { | ||
@@ -19,3 +17,4 @@ "@types/debug": "^4.1.7", | ||
"typescript": "^4.9.4" | ||
} | ||
}, | ||
"packageManager": "yarn@3.6.1" | ||
} |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
419412
10238