@0xmonaco/core 1.1.5-develop.129b2c6 → 1.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api/applications/api.d.ts +5 -5
- package/dist/api/applications/api.js +5 -5
- package/dist/api/buildercodes/api.d.ts +11 -18
- package/dist/api/buildercodes/api.js +15 -31
- package/dist/api/index.d.ts +0 -1
- package/dist/api/index.js +0 -1
- package/dist/api/orderbook/api.d.ts +1 -4
- package/dist/api/orderbook/api.js +0 -2
- package/dist/api/perp/routes.d.ts +0 -55
- package/dist/api/perp/routes.js +0 -18
- package/dist/api/trading/api.d.ts +2 -2
- package/dist/api/trading/api.js +6 -6
- package/dist/api/websocket/websocket.js +38 -601
- package/dist/coverage.d.ts +0 -16
- package/dist/coverage.js +0 -16
- package/dist/sdk.d.ts +1 -2
- package/dist/sdk.js +0 -4
- package/package.json +3 -3
- package/dist/api/analytics/api.d.ts +0 -40
- package/dist/api/analytics/api.js +0 -107
- package/dist/api/analytics/index.d.ts +0 -1
- package/dist/api/analytics/index.js +0 -1
- package/dist/api/websocket/local-book.d.ts +0 -112
- package/dist/api/websocket/local-book.js +0 -423
package/dist/coverage.d.ts
CHANGED
|
@@ -68,22 +68,6 @@ export declare const COVERED: {
|
|
|
68
68
|
get_fee_schedule: string;
|
|
69
69
|
get_pulse: string;
|
|
70
70
|
get_region_status: string;
|
|
71
|
-
get_protocol_totals: string;
|
|
72
|
-
get_protocol_series: string;
|
|
73
|
-
list_market_volumes: string;
|
|
74
|
-
get_treasury_net_fees: string;
|
|
75
|
-
list_builders: string;
|
|
76
|
-
get_builder: string;
|
|
77
|
-
get_builder_totals: string;
|
|
78
|
-
get_builder_series: string;
|
|
79
|
-
list_builder_leaderboard: string;
|
|
80
|
-
list_wallet_leaderboard: string;
|
|
81
|
-
get_wallet_summary: string;
|
|
82
|
-
list_wallet_liquidations: string;
|
|
83
|
-
list_token_custody: string;
|
|
84
|
-
get_token_custody: string;
|
|
85
|
-
list_vault_deposits: string;
|
|
86
|
-
list_vault_withdrawals: string;
|
|
87
71
|
list_managed_market_assignments: string;
|
|
88
72
|
claim_managed_market_lease: string;
|
|
89
73
|
refresh_managed_market_quotes: string;
|
package/dist/coverage.js
CHANGED
|
@@ -68,22 +68,6 @@ export const COVERED = {
|
|
|
68
68
|
get_fee_schedule: "getFeeSchedule",
|
|
69
69
|
get_pulse: "pulse.getPulse",
|
|
70
70
|
get_region_status: "compliance.getRegionStatus",
|
|
71
|
-
get_protocol_totals: "analytics.getProtocolTotals",
|
|
72
|
-
get_protocol_series: "analytics.getProtocolSeries",
|
|
73
|
-
list_market_volumes: "analytics.listMarketVolumes",
|
|
74
|
-
get_treasury_net_fees: "analytics.getTreasuryNetFees",
|
|
75
|
-
list_builders: "analytics.listBuilders",
|
|
76
|
-
get_builder: "analytics.getBuilder",
|
|
77
|
-
get_builder_totals: "analytics.getBuilderTotals",
|
|
78
|
-
get_builder_series: "analytics.getBuilderSeries",
|
|
79
|
-
list_builder_leaderboard: "analytics.listBuilderLeaderboard",
|
|
80
|
-
list_wallet_leaderboard: "analytics.listWalletLeaderboard",
|
|
81
|
-
get_wallet_summary: "analytics.getWalletSummary",
|
|
82
|
-
list_wallet_liquidations: "analytics.listWalletLiquidations",
|
|
83
|
-
list_token_custody: "analytics.listTokenCustody",
|
|
84
|
-
get_token_custody: "analytics.getTokenCustody",
|
|
85
|
-
list_vault_deposits: "analytics.listVaultDeposits",
|
|
86
|
-
list_vault_withdrawals: "analytics.listVaultWithdrawals",
|
|
87
71
|
list_managed_market_assignments: "managedMarkets.listAssignments",
|
|
88
72
|
claim_managed_market_lease: "managedMarkets.claimLease",
|
|
89
73
|
refresh_managed_market_quotes: "managedMarkets.refreshQuotes",
|
package/dist/sdk.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ApplicationsAPI, AuthAPI, AuthState, BuildercodesAPI, ComplianceAPI, CopyTradingAPI, DelegatedAgentsAPI, FaucetAPI, FeesAPI, ManagedMarketsAPI, MarginAccountsAPI, MarketAPI, MonacoSDK, Network, PortfolioAPI, PositionsAPI, ProfileAPI, PulseAPI, RfqAPI, SDKConfig, SubAccountsAPI, SweeperAPI, TraderCodesAPI, TradingAPI, VaultAPI, WithdrawalsAPI } from "@0xmonaco/types";
|
|
2
2
|
import { type Address, type PublicClient, type TransactionReceipt, type WalletClient } from "viem";
|
|
3
3
|
import { type MonacoWebSocket, OrderbookAPIImpl, TradesAPIImpl } from "./api";
|
|
4
4
|
export declare class MonacoSDKImpl implements MonacoSDK {
|
|
@@ -24,7 +24,6 @@ export declare class MonacoSDKImpl implements MonacoSDK {
|
|
|
24
24
|
profile: ProfileAPI;
|
|
25
25
|
pulse: PulseAPI;
|
|
26
26
|
compliance: ComplianceAPI;
|
|
27
|
-
analytics: AnalyticsAPI;
|
|
28
27
|
orderbook: OrderbookAPIImpl;
|
|
29
28
|
trades: TradesAPIImpl;
|
|
30
29
|
ws: MonacoWebSocket;
|
package/dist/sdk.js
CHANGED
|
@@ -2,7 +2,6 @@ import { StatusCodes } from "http-status-codes";
|
|
|
2
2
|
import { createPublicClient, http } from "viem";
|
|
3
3
|
import { sei, seiTestnet } from "viem/chains";
|
|
4
4
|
import { ApplicationsAPIImpl, createMonacoWebSocket, OrderbookAPIImpl, TradesAPIImpl } from "./api";
|
|
5
|
-
import { AnalyticsAPIImpl } from "./api/analytics";
|
|
6
5
|
import { AuthAPIImpl } from "./api/auth";
|
|
7
6
|
import { BuildercodesAPIImpl } from "./api/buildercodes";
|
|
8
7
|
import { ComplianceAPIImpl } from "./api/compliance";
|
|
@@ -67,7 +66,6 @@ export class MonacoSDKImpl {
|
|
|
67
66
|
profile;
|
|
68
67
|
pulse;
|
|
69
68
|
compliance;
|
|
70
|
-
analytics;
|
|
71
69
|
orderbook;
|
|
72
70
|
trades;
|
|
73
71
|
ws;
|
|
@@ -102,7 +100,6 @@ export class MonacoSDKImpl {
|
|
|
102
100
|
this.managedMarkets.setSessionKeypair(credentials);
|
|
103
101
|
this.pulse.setSessionKeypair(credentials);
|
|
104
102
|
this.compliance.setSessionKeypair(credentials);
|
|
105
|
-
this.analytics.setSessionKeypair(credentials);
|
|
106
103
|
this.profile.setSessionKeypair(credentials);
|
|
107
104
|
this.orderbook.setSessionKeypair(credentials);
|
|
108
105
|
this.trades.setSessionKeypair(credentials);
|
|
@@ -174,7 +171,6 @@ export class MonacoSDKImpl {
|
|
|
174
171
|
this.managedMarkets = configureSigning(new ManagedMarketsAPIImpl(apiUrl));
|
|
175
172
|
this.pulse = configureSigning(new PulseAPIImpl(apiUrl));
|
|
176
173
|
this.compliance = configureSigning(new ComplianceAPIImpl(apiUrl));
|
|
177
|
-
this.analytics = configureSigning(new AnalyticsAPIImpl(apiUrl));
|
|
178
174
|
this.auth = configureSigning(new AuthAPIImpl(this.walletClient, this.chain, apiUrl));
|
|
179
175
|
this.delegatedAgents = configureSigning(new DelegatedAgentsAPIImpl(apiUrl));
|
|
180
176
|
this.fees = configureSigning(new FeesAPIImpl(apiUrl));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@0xmonaco/core",
|
|
3
|
-
"version": "1.1.5
|
|
3
|
+
"version": "1.1.5",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"homepage": "https://docs.0xmonaco.com/sdk/typescript",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -19,8 +19,8 @@
|
|
|
19
19
|
"viem": "^2.45.2"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@0xmonaco/contracts": "1.1.5
|
|
23
|
-
"@0xmonaco/types": "1.1.5
|
|
22
|
+
"@0xmonaco/contracts": "1.1.5",
|
|
23
|
+
"@0xmonaco/types": "1.1.5",
|
|
24
24
|
"@noble/curves": "^2.4.0",
|
|
25
25
|
"@noble/hashes": "^2.4.0",
|
|
26
26
|
"http-status-codes": "^2.3.0"
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Analytics API Implementation
|
|
3
|
-
*
|
|
4
|
-
* The public explorer analytics: protocol totals and series over a window,
|
|
5
|
-
* per-market volume, the treasury's all-time net fees, and the builder
|
|
6
|
-
* directory, figures and leaderboard; wallets, token custody and the vault
|
|
7
|
-
* deposit and withdrawal feeds. Volume, trade
|
|
8
|
-
* counts and the spot/perp split count the builders the explorer displays;
|
|
9
|
-
* fees, active takers, new traders and market volume count every trade.
|
|
10
|
-
* Public — no authentication required; each client IP has a read budget.
|
|
11
|
-
*
|
|
12
|
-
* @example
|
|
13
|
-
* ```typescript
|
|
14
|
-
* const week = await sdk.analytics.getProtocolTotals({ window: "7d" });
|
|
15
|
-
* // Both window ends are inclusive, so the previous window ends 1 ms before
|
|
16
|
-
* // this one starts; ending at `startTime` itself would count a bucket twice
|
|
17
|
-
* // whenever the start falls on a bucket boundary.
|
|
18
|
-
* const previous = await sdk.analytics.getProtocolTotals({ window: "7d", endTime: week.window.startTime - 1 });
|
|
19
|
-
* ```
|
|
20
|
-
*/
|
|
21
|
-
import type { AnalyticsAPI, AnalyticsWindowParams, GetBuilderResponse, GetBuilderSeriesResponse, GetBuilderTotalsResponse, GetProtocolSeriesResponse, GetProtocolTotalsResponse, GetTokenCustodyResponse, GetTreasuryNetFeesResponse, GetWalletSummaryResponse, ListBuilderLeaderboardParams, ListBuilderLeaderboardResponse, ListBuildersResponse, ListMarketVolumesParams, ListMarketVolumesResponse, ListTokenCustodyResponse, ListVaultDepositsResponse, ListVaultWithdrawalsResponse, ListWalletLeaderboardParams, ListWalletLeaderboardResponse, ListWalletLiquidationsParams, ListWalletLiquidationsResponse, VaultFeedParams } from "@0xmonaco/types";
|
|
22
|
-
import { BaseAPI } from "../base";
|
|
23
|
-
export declare class AnalyticsAPIImpl extends BaseAPI implements AnalyticsAPI {
|
|
24
|
-
getProtocolTotals(params?: AnalyticsWindowParams): Promise<GetProtocolTotalsResponse>;
|
|
25
|
-
getProtocolSeries(params?: AnalyticsWindowParams): Promise<GetProtocolSeriesResponse>;
|
|
26
|
-
listMarketVolumes(params?: ListMarketVolumesParams): Promise<ListMarketVolumesResponse>;
|
|
27
|
-
getTreasuryNetFees(): Promise<GetTreasuryNetFeesResponse>;
|
|
28
|
-
listBuilders(): Promise<ListBuildersResponse>;
|
|
29
|
-
getBuilder(builder: string): Promise<GetBuilderResponse>;
|
|
30
|
-
getBuilderTotals(builder: string, params?: AnalyticsWindowParams): Promise<GetBuilderTotalsResponse>;
|
|
31
|
-
getBuilderSeries(builder: string, params?: AnalyticsWindowParams): Promise<GetBuilderSeriesResponse>;
|
|
32
|
-
listBuilderLeaderboard(params?: ListBuilderLeaderboardParams): Promise<ListBuilderLeaderboardResponse>;
|
|
33
|
-
listWalletLeaderboard(params?: ListWalletLeaderboardParams): Promise<ListWalletLeaderboardResponse>;
|
|
34
|
-
getWalletSummary(wallet: string): Promise<GetWalletSummaryResponse>;
|
|
35
|
-
listWalletLiquidations(wallet: string, params?: ListWalletLiquidationsParams): Promise<ListWalletLiquidationsResponse>;
|
|
36
|
-
listTokenCustody(): Promise<ListTokenCustodyResponse>;
|
|
37
|
-
getTokenCustody(token: string): Promise<GetTokenCustodyResponse>;
|
|
38
|
-
listVaultDeposits(params?: VaultFeedParams): Promise<ListVaultDepositsResponse>;
|
|
39
|
-
listVaultWithdrawals(params?: VaultFeedParams): Promise<ListVaultWithdrawalsResponse>;
|
|
40
|
-
}
|
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Analytics API Implementation
|
|
3
|
-
*
|
|
4
|
-
* The public explorer analytics: protocol totals and series over a window,
|
|
5
|
-
* per-market volume, the treasury's all-time net fees, and the builder
|
|
6
|
-
* directory, figures and leaderboard; wallets, token custody and the vault
|
|
7
|
-
* deposit and withdrawal feeds. Volume, trade
|
|
8
|
-
* counts and the spot/perp split count the builders the explorer displays;
|
|
9
|
-
* fees, active takers, new traders and market volume count every trade.
|
|
10
|
-
* Public — no authentication required; each client IP has a read budget.
|
|
11
|
-
*
|
|
12
|
-
* @example
|
|
13
|
-
* ```typescript
|
|
14
|
-
* const week = await sdk.analytics.getProtocolTotals({ window: "7d" });
|
|
15
|
-
* // Both window ends are inclusive, so the previous window ends 1 ms before
|
|
16
|
-
* // this one starts; ending at `startTime` itself would count a bucket twice
|
|
17
|
-
* // whenever the start falls on a bucket boundary.
|
|
18
|
-
* const previous = await sdk.analytics.getProtocolTotals({ window: "7d", endTime: week.window.startTime - 1 });
|
|
19
|
-
* ```
|
|
20
|
-
*/
|
|
21
|
-
import { BaseAPI } from "../base";
|
|
22
|
-
import { perpRoutes } from "../perp/routes";
|
|
23
|
-
export class AnalyticsAPIImpl extends BaseAPI {
|
|
24
|
-
async getProtocolTotals(params) {
|
|
25
|
-
return await this.makePublicRequest(perpRoutes.analytics.protocolTotals(params), { method: "GET" });
|
|
26
|
-
}
|
|
27
|
-
async getProtocolSeries(params) {
|
|
28
|
-
const response = await this.makePublicRequest(perpRoutes.analytics.protocolSeries(params), { method: "GET" });
|
|
29
|
-
return { ...response, points: response.points ?? [] };
|
|
30
|
-
}
|
|
31
|
-
async listMarketVolumes(params) {
|
|
32
|
-
const response = await this.makePublicRequest(perpRoutes.analytics.marketVolumes(params), { method: "GET" });
|
|
33
|
-
return { ...response, markets: response.markets ?? [] };
|
|
34
|
-
}
|
|
35
|
-
async getTreasuryNetFees() {
|
|
36
|
-
return await this.makePublicRequest(perpRoutes.analytics.treasuryNetFees(), { method: "GET" });
|
|
37
|
-
}
|
|
38
|
-
async listBuilders() {
|
|
39
|
-
const response = await this.makePublicRequest(perpRoutes.analytics.builders(), { method: "GET" });
|
|
40
|
-
return { builders: (response.builders ?? []).map(withApplications) };
|
|
41
|
-
}
|
|
42
|
-
async getBuilder(builder) {
|
|
43
|
-
const response = await this.makePublicRequest(perpRoutes.analytics.builder(builder), { method: "GET" });
|
|
44
|
-
return { builder: withApplications(response.builder) };
|
|
45
|
-
}
|
|
46
|
-
async getBuilderTotals(builder, params) {
|
|
47
|
-
const response = await this.makePublicRequest(perpRoutes.analytics.builderTotals(builder, params), {
|
|
48
|
-
method: "GET",
|
|
49
|
-
});
|
|
50
|
-
return { ...response, builder: withApplications(response.builder) };
|
|
51
|
-
}
|
|
52
|
-
async getBuilderSeries(builder, params) {
|
|
53
|
-
const response = await this.makePublicRequest(perpRoutes.analytics.builderSeries(builder, params), { method: "GET" });
|
|
54
|
-
return { ...response, builder: withApplications(response.builder), points: response.points ?? [] };
|
|
55
|
-
}
|
|
56
|
-
async listBuilderLeaderboard(params) {
|
|
57
|
-
const response = await this.makePublicRequest(perpRoutes.analytics.builderLeaderboard(params), { method: "GET" });
|
|
58
|
-
return { ...response, rows: (response.rows ?? []).map((row) => ({ ...row, builder: withApplications(row.builder) })) };
|
|
59
|
-
}
|
|
60
|
-
async listWalletLeaderboard(params) {
|
|
61
|
-
const response = await this.makePublicRequest(perpRoutes.analytics.walletLeaderboard(params), {
|
|
62
|
-
method: "GET",
|
|
63
|
-
});
|
|
64
|
-
return { wallets: response.wallets ?? [] };
|
|
65
|
-
}
|
|
66
|
-
async getWalletSummary(wallet) {
|
|
67
|
-
const response = await this.makePublicRequest(perpRoutes.analytics.walletSummary(wallet), { method: "GET" });
|
|
68
|
-
// Absent optionals and an empty repeated field are omitted on the wire.
|
|
69
|
-
return {
|
|
70
|
-
...response,
|
|
71
|
-
totals: response.totals ?? null,
|
|
72
|
-
builders: (response.builders ?? []).map((row) => ({ ...row, builder: withApplications(row.builder) })),
|
|
73
|
-
unattributed: response.unattributed ?? null,
|
|
74
|
-
};
|
|
75
|
-
}
|
|
76
|
-
async listWalletLiquidations(wallet, params) {
|
|
77
|
-
const response = await this.makePublicRequest(perpRoutes.analytics.walletLiquidations(wallet, params), { method: "GET" });
|
|
78
|
-
return { ...response, events: response.events ?? [], nextPageToken: response.nextPageToken ?? "" };
|
|
79
|
-
}
|
|
80
|
-
async listTokenCustody() {
|
|
81
|
-
const response = await this.makePublicRequest(perpRoutes.analytics.tokenCustody(), { method: "GET" });
|
|
82
|
-
return { ...response, tokens: response.tokens ?? [] };
|
|
83
|
-
}
|
|
84
|
-
async getTokenCustody(token) {
|
|
85
|
-
return await this.makePublicRequest(perpRoutes.analytics.tokenCustodyDetail(token), { method: "GET" });
|
|
86
|
-
}
|
|
87
|
-
async listVaultDeposits(params) {
|
|
88
|
-
const response = await this.makePublicRequest(perpRoutes.analytics.vaultDeposits(params), { method: "GET" });
|
|
89
|
-
return {
|
|
90
|
-
...response,
|
|
91
|
-
deposits: (response.deposits ?? []).map((row) => ({ ...row, builder: row.builder ? withApplications(row.builder) : null })),
|
|
92
|
-
nextPageToken: response.nextPageToken ?? "",
|
|
93
|
-
};
|
|
94
|
-
}
|
|
95
|
-
async listVaultWithdrawals(params) {
|
|
96
|
-
const response = await this.makePublicRequest(perpRoutes.analytics.vaultWithdrawals(params), { method: "GET" });
|
|
97
|
-
return {
|
|
98
|
-
...response,
|
|
99
|
-
withdrawals: (response.withdrawals ?? []).map((row) => ({ ...row, builder: row.builder ? withApplications(row.builder) : null })),
|
|
100
|
-
nextPageToken: response.nextPageToken ?? "",
|
|
101
|
-
};
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
/** A builder with its application list present, empty when the wire omitted it. */
|
|
105
|
-
function withApplications(builder) {
|
|
106
|
-
return { ...builder, applications: builder.applications ?? [] };
|
|
107
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { AnalyticsAPIImpl } from "./api";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { AnalyticsAPIImpl } from "./api";
|
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Local depth book and BBO state for the market-data `depth` / `bbo`
|
|
3
|
-
* WebSocket channels (0XM-3551).
|
|
4
|
-
*
|
|
5
|
-
* Handoff rules (the server enforces them; the client checks defensively):
|
|
6
|
-
* - A Snapshot replaces the local state, including mid-stream.
|
|
7
|
-
* - A frame with `book_seq <=` the current sequence is stale or a duplicate
|
|
8
|
-
* and is dropped.
|
|
9
|
-
* - Every kept frame must have `prev_book_seq <=` the current sequence (the
|
|
10
|
-
* snapshot's for the first frame, else the last applied frame's): a delta
|
|
11
|
-
* restates every level changed since its link, so it may link below the
|
|
12
|
-
* previous frame. A frame that links above it means a lost frame: rebuild
|
|
13
|
-
* from a new snapshot.
|
|
14
|
-
* - A BBO frame carries the whole top of book, so any frame newer than the
|
|
15
|
-
* state applies without a link check.
|
|
16
|
-
* - Frames that arrive before the snapshot are buffered and replayed through
|
|
17
|
-
* the same rules once it lands.
|
|
18
|
-
* - On a side whose snapshot was not complete, levels beyond its deepest
|
|
19
|
-
* returned level are unknown, so the book keeps only levels at or better
|
|
20
|
-
* than that boundary.
|
|
21
|
-
*
|
|
22
|
-
* Sequences are u64 durable-log positions, held as decimal strings and
|
|
23
|
-
* compared as `BigInt`.
|
|
24
|
-
*/
|
|
25
|
-
import type { Bbo, BboEvent, BboSnapshot, DepthBook, DepthDelta, DepthSnapshot } from "@0xmonaco/types";
|
|
26
|
-
/**
|
|
27
|
-
* Quote the market-data sequence numbers in a raw frame before `JSON.parse`,
|
|
28
|
-
* so a u64 above `Number.MAX_SAFE_INTEGER` survives exactly. Only the
|
|
29
|
-
* unescaped `"book_seq":` / `"prev_book_seq":` keys followed by an integer are
|
|
30
|
-
* touched; inside a JSON string those quotes would be escaped.
|
|
31
|
-
*/
|
|
32
|
-
export declare function quoteSequenceNumbers(raw: string): string;
|
|
33
|
-
/**
|
|
34
|
-
* {@link readSequence} that leaves an absent or malformed value `undefined`
|
|
35
|
-
* instead of throwing. A JSON number counts only while it is still exact (a
|
|
36
|
-
* quoted integer always does), so a rounded u64 never passes for a precise one.
|
|
37
|
-
*/
|
|
38
|
-
export declare function tryReadSequence(data: Record<string, unknown>, key: string): string | undefined;
|
|
39
|
-
export declare function parseDepthSnapshot(raw: unknown): DepthSnapshot;
|
|
40
|
-
export declare function parseDepthDelta(raw: unknown): DepthDelta;
|
|
41
|
-
export declare function parseBboSnapshot(raw: unknown): BboSnapshot;
|
|
42
|
-
export declare function parseBboEvent(raw: unknown): BboEvent;
|
|
43
|
-
/** Compare two non-negative decimal strings numerically. */
|
|
44
|
-
export declare function compareDecimal(a: string, b: string): number;
|
|
45
|
-
/** The result of offering a frame to the local state. */
|
|
46
|
-
export type FrameOutcome =
|
|
47
|
-
/** Applied; the state moved forward. */
|
|
48
|
-
"applied"
|
|
49
|
-
/** Held until the snapshot arrives. */
|
|
50
|
-
| "buffered"
|
|
51
|
-
/** Stale or a duplicate. */
|
|
52
|
-
| "dropped"
|
|
53
|
-
/** Did not link: a frame was lost. */
|
|
54
|
-
| "gap"
|
|
55
|
-
/** Applied, but a side whose snapshot was incomplete is now empty: its remainder is unknown. */
|
|
56
|
-
| "truncated";
|
|
57
|
-
/** The result of applying a snapshot (with any buffered frames replayed). */
|
|
58
|
-
export type SnapshotOutcome = "applied" | "gap" | "truncated";
|
|
59
|
-
/**
|
|
60
|
-
* The sequence guard shared by `depth` and `bbo`: snapshot replaces, stale
|
|
61
|
-
* frames drop, a frame linking above the current sequence is a gap, frames
|
|
62
|
-
* before the snapshot buffer.
|
|
63
|
-
*/
|
|
64
|
-
declare abstract class SequencedState<Snapshot extends {
|
|
65
|
-
bookSeq: string;
|
|
66
|
-
}, Frame extends {
|
|
67
|
-
bookSeq: string;
|
|
68
|
-
prevBookSeq: string;
|
|
69
|
-
}> {
|
|
70
|
-
private current;
|
|
71
|
-
private buffered;
|
|
72
|
-
/**
|
|
73
|
-
* Whether a frame must link to the current state. Depth deltas carry only
|
|
74
|
-
* changed levels, so a frame past a lost one is a gap; a BBO frame carries
|
|
75
|
-
* the whole top of book, so any newer one is complete on its own.
|
|
76
|
-
*/
|
|
77
|
-
protected readonly checksLinks: boolean;
|
|
78
|
-
/** Whether a snapshot has been applied since the last reset. */
|
|
79
|
-
get ready(): boolean;
|
|
80
|
-
protected abstract resetFrom(snapshot: Snapshot): void;
|
|
81
|
-
protected abstract applyFrame(frame: Frame): void;
|
|
82
|
-
/** Whether the state can no longer be trusted past its known levels (see `"truncated"`). */
|
|
83
|
-
protected truncated(): boolean;
|
|
84
|
-
/** Replace the state with `snapshot`, then replay buffered frames. Returns `"gap"` if a buffered frame does not link. */
|
|
85
|
-
applySnapshot(snapshot: Snapshot): SnapshotOutcome;
|
|
86
|
-
/** Offer a live frame. */
|
|
87
|
-
offer(frame: Frame): FrameOutcome;
|
|
88
|
-
/** Discard everything; the next snapshot starts over. */
|
|
89
|
-
reset(): void;
|
|
90
|
-
}
|
|
91
|
-
/** The local depth book for one `depth` channel. */
|
|
92
|
-
export declare class LocalDepthBook extends SequencedState<DepthSnapshot, DepthDelta> {
|
|
93
|
-
private readonly bids;
|
|
94
|
-
private readonly asks;
|
|
95
|
-
private header;
|
|
96
|
-
protected resetFrom(snapshot: DepthSnapshot): void;
|
|
97
|
-
protected applyFrame(frame: DepthDelta): void;
|
|
98
|
-
protected truncated(): boolean;
|
|
99
|
-
reset(): void;
|
|
100
|
-
/** The current book, or `null` before a snapshot. */
|
|
101
|
-
view(): DepthBook | null;
|
|
102
|
-
}
|
|
103
|
-
/** The local top of book for one `bbo` channel. */
|
|
104
|
-
export declare class LocalBbo extends SequencedState<BboSnapshot, BboEvent> {
|
|
105
|
-
protected readonly checksLinks = false;
|
|
106
|
-
private state;
|
|
107
|
-
protected resetFrom(snapshot: BboSnapshot): void;
|
|
108
|
-
protected applyFrame(frame: BboEvent): void;
|
|
109
|
-
reset(): void;
|
|
110
|
-
view(): Bbo | null;
|
|
111
|
-
}
|
|
112
|
-
export {};
|