@reyaxyz/common 0.362.0 → 0.363.0
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/README.md +1 -1
- package/dist/commands/exposure/command.js +8 -22
- package/dist/commands/exposure/command.js.map +1 -1
- package/dist/incentives-api-types.js.map +1 -1
- package/dist/services/getNativeToken.js +1 -0
- package/dist/services/getNativeToken.js.map +1 -1
- package/dist/services/getSocketAddresses.js +1 -0
- package/dist/services/getSocketAddresses.js.map +1 -1
- package/dist/trading-api-types.js.map +1 -1
- package/dist/transactions/abis/Errors.json +1638 -34
- package/dist/transactions/abis/OrdersGateway.json +729 -123
- package/dist/transactions/abis/PassivePerpProxy.json +542 -0
- package/dist/transactions/buildMulticallTx.js.map +1 -1
- package/dist/transactions/consts.js +1 -2
- package/dist/transactions/consts.js.map +1 -1
- package/dist/transactions/contractAddresses.js +45 -5
- package/dist/transactions/contractAddresses.js.map +1 -1
- package/dist/transactions/sign.js +237 -111
- package/dist/transactions/sign.js.map +1 -1
- package/dist/types/commands/exposure/command.d.ts +8 -7
- package/dist/types/commands/exposure/command.d.ts.map +1 -1
- package/dist/types/incentives-api-types.d.ts +61 -5
- package/dist/types/incentives-api-types.d.ts.map +1 -1
- package/dist/types/services/getNativeToken.d.ts.map +1 -1
- package/dist/types/services/getSocketAddresses.d.ts.map +1 -1
- package/dist/types/trading-api-types.d.ts +200 -32
- package/dist/types/trading-api-types.d.ts.map +1 -1
- package/dist/types/transactions/buildMulticallTx.d.ts +1 -0
- package/dist/types/transactions/buildMulticallTx.d.ts.map +1 -1
- package/dist/types/transactions/consts.d.ts +0 -1
- package/dist/types/transactions/consts.d.ts.map +1 -1
- package/dist/types/transactions/contractAddresses.d.ts +0 -1
- package/dist/types/transactions/contractAddresses.d.ts.map +1 -1
- package/dist/types/transactions/sign.d.ts +113 -9
- package/dist/types/transactions/sign.d.ts.map +1 -1
- package/dist/types/types.d.ts +62 -63
- package/dist/types/types.d.ts.map +1 -1
- package/dist/types/utils/calculate.d.ts.map +1 -1
- package/dist/types/utils/consts.d.ts +2 -2
- package/dist/types/utils/consts.d.ts.map +1 -1
- package/dist/types/utils/error-sanitizer.d.ts +15 -0
- package/dist/types/utils/error-sanitizer.d.ts.map +1 -0
- package/dist/types/utils/index.d.ts +3 -0
- package/dist/types/utils/index.d.ts.map +1 -1
- package/dist/types/utils/network.d.ts.map +1 -1
- package/dist/types/utils/number.d.ts +5 -0
- package/dist/types/utils/number.d.ts.map +1 -1
- package/dist/types/utils/realized-balance.d.ts +54 -0
- package/dist/types/utils/realized-balance.d.ts.map +1 -0
- package/dist/types/utils/throttled-error.d.ts +42 -0
- package/dist/types/utils/throttled-error.d.ts.map +1 -0
- package/dist/types/utils/token/normalize.d.ts +2 -1
- package/dist/types/utils/token/normalize.d.ts.map +1 -1
- package/dist/types/utils/token/token-info-getters.d.ts.map +1 -1
- package/dist/types/utils/token/token-info.d.ts.map +1 -1
- package/dist/types.js +25 -11
- package/dist/types.js.map +1 -1
- package/dist/utils/calculate.js +18 -9
- package/dist/utils/calculate.js.map +1 -1
- package/dist/utils/consts.js +2 -7
- package/dist/utils/consts.js.map +1 -1
- package/dist/utils/error-sanitizer.js +135 -0
- package/dist/utils/error-sanitizer.js.map +1 -0
- package/dist/utils/index.js +3 -0
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/network.js +4 -0
- package/dist/utils/network.js.map +1 -1
- package/dist/utils/number.js +96 -1
- package/dist/utils/number.js.map +1 -1
- package/dist/utils/realized-balance.js +126 -0
- package/dist/utils/realized-balance.js.map +1 -0
- package/dist/utils/throttled-error.js +60 -0
- package/dist/utils/throttled-error.js.map +1 -0
- package/dist/utils/token/normalize.js +2 -2
- package/dist/utils/token/normalize.js.map +1 -1
- package/dist/utils/token/token-info-getters.js +80 -5
- package/dist/utils/token/token-info-getters.js.map +1 -1
- package/dist/utils/token/token-info.js +11 -0
- package/dist/utils/token/token-info.js.map +1 -1
- package/package.json +3 -3
- package/src/commands/exposure/command.ts +8 -38
- package/src/incentives-api-types.ts +60 -5
- package/src/services/getNativeToken.ts +1 -0
- package/src/services/getSocketAddresses.ts +1 -0
- package/src/trading-api-types.ts +258 -39
- package/src/transactions/abis/Errors.json +5478 -3874
- package/src/transactions/abis/OrdersGateway.json +730 -124
- package/src/transactions/abis/PassivePerpProxy.json +542 -0
- package/src/transactions/buildMulticallTx.ts +4 -0
- package/src/transactions/consts.ts +0 -1
- package/src/transactions/contractAddresses.ts +42 -7
- package/src/transactions/sign.ts +306 -150
- package/src/types.ts +102 -82
- package/src/utils/calculate.ts +21 -8
- package/src/utils/consts.ts +4 -16
- package/src/utils/error-sanitizer.ts +137 -0
- package/src/utils/index.ts +3 -0
- package/src/utils/network.ts +4 -0
- package/src/utils/number.ts +110 -0
- package/src/utils/realized-balance.ts +163 -0
- package/src/utils/throttled-error.ts +85 -0
- package/src/utils/token/normalize.ts +6 -1
- package/src/utils/token/token-info-getters.ts +104 -6
- package/src/utils/token/token-info.ts +78 -0
package/src/trading-api-types.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ParamsDictionary, Query } from 'express-serve-static-core';
|
|
2
|
-
import { Address, AssetPair } from './types';
|
|
2
|
+
import { Address, AssetPair, CollateralPrice, MarketPrice } from './types';
|
|
3
3
|
import {
|
|
4
4
|
AddressParam,
|
|
5
5
|
ApiEndpoint,
|
|
@@ -30,7 +30,7 @@ type Candle = {
|
|
|
30
30
|
resolution: CandleResolution;
|
|
31
31
|
};
|
|
32
32
|
|
|
33
|
-
//
|
|
33
|
+
// Database-shaped perp execution row exposed by provider and API types.
|
|
34
34
|
type Order = {
|
|
35
35
|
id: string;
|
|
36
36
|
market_id: Decimal | null;
|
|
@@ -40,6 +40,7 @@ type Order = {
|
|
|
40
40
|
price: Decimal | null;
|
|
41
41
|
is_match_order: boolean | null;
|
|
42
42
|
liquidation_type: Decimal | null;
|
|
43
|
+
execution_type: number | null;
|
|
43
44
|
transaction_hash: string;
|
|
44
45
|
block_timestamp: Decimal | null;
|
|
45
46
|
block_number: Decimal;
|
|
@@ -55,6 +56,12 @@ type Order = {
|
|
|
55
56
|
counterparty_funding_value: Decimal | null;
|
|
56
57
|
counterparty_last_price: Decimal | null;
|
|
57
58
|
counterparty_last_price_timestamp: Decimal | null;
|
|
59
|
+
counterparty_previous_adl_unwind_price: Decimal | null;
|
|
60
|
+
counterparty_previous_average_entry_funding_value: Decimal | null;
|
|
61
|
+
counterparty_previous_base_multiplier: Decimal | null;
|
|
62
|
+
counterparty_previous_funding_value: Decimal | null;
|
|
63
|
+
counterparty_previous_last_price: Decimal | null;
|
|
64
|
+
counterparty_previous_realized_pnl: Decimal | null;
|
|
58
65
|
counterparty_realized_pnl: Decimal | null;
|
|
59
66
|
counterparty_session: Decimal | null;
|
|
60
67
|
position_adl_unwind_price: Decimal | null;
|
|
@@ -74,6 +81,16 @@ type Order = {
|
|
|
74
81
|
position_session: Decimal | null;
|
|
75
82
|
referrer_account_id: Decimal | null;
|
|
76
83
|
referrer_fee_credit: Decimal | null;
|
|
84
|
+
// V3 fields
|
|
85
|
+
protocol_fee_credit: Decimal | null;
|
|
86
|
+
taker_rebate_credit: Decimal | null;
|
|
87
|
+
pool_fee_credit: Decimal | null;
|
|
88
|
+
exchange_fee_credit: Decimal | null;
|
|
89
|
+
maker_fee_credit: Decimal | null;
|
|
90
|
+
maker_fee_debit: Decimal | null;
|
|
91
|
+
account_order_id: bigint | null;
|
|
92
|
+
counterparty_order_id: bigint | null;
|
|
93
|
+
me_nonce: Decimal | null;
|
|
77
94
|
};
|
|
78
95
|
|
|
79
96
|
type Position = {
|
|
@@ -100,30 +117,12 @@ type Position = {
|
|
|
100
117
|
adl_realized_pnl: Decimal | null;
|
|
101
118
|
};
|
|
102
119
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
trigger_price: number;
|
|
110
|
-
order_base: Decimal;
|
|
111
|
-
status: string;
|
|
112
|
-
creation_timestamp_ms: bigint;
|
|
113
|
-
last_update_timestamp_ms: bigint;
|
|
114
|
-
transaction_hash: string | null;
|
|
115
|
-
};
|
|
116
|
-
|
|
117
|
-
type ConditionalOrderSensitive = ConditionalOrder & {
|
|
118
|
-
exchange_id: bigint;
|
|
119
|
-
inputs: string;
|
|
120
|
-
counterparty_account_id: bigint;
|
|
121
|
-
reya_chain_id: bigint;
|
|
122
|
-
deadline: bigint;
|
|
123
|
-
signer_address: string;
|
|
124
|
-
nonce: Decimal;
|
|
125
|
-
signature: string;
|
|
126
|
-
};
|
|
120
|
+
// PRO-126 Bug 7: `ConditionalOrder` + `ConditionalOrderSensitive`
|
|
121
|
+
// trading-api-types retired with the rest of the legacy
|
|
122
|
+
// `ConditionalOrders` DB pipeline. They modeled the legacy row shape
|
|
123
|
+
// for the dead V1 `/wallet/:address/openOrders` endpoint + the dead
|
|
124
|
+
// `replication:ConditionalOrdersSensitive` broadcast channel; both
|
|
125
|
+
// callers have been removed.
|
|
127
126
|
|
|
128
127
|
type Account = {
|
|
129
128
|
account_id: Decimal;
|
|
@@ -143,11 +142,15 @@ type AccountBalance = {
|
|
|
143
142
|
type spot_execution = {
|
|
144
143
|
account_id: Decimal;
|
|
145
144
|
counterparty_account_id: Decimal;
|
|
146
|
-
|
|
145
|
+
// Order attribution is absent for auto-exchange executions: there is no
|
|
146
|
+
// matched order, so the chain emits no exchange/order ids and the DB
|
|
147
|
+
// columns are NULL. Matches the `spot_executions` Prisma model.
|
|
148
|
+
exchange_id: Decimal | null;
|
|
147
149
|
executed_base: Decimal;
|
|
148
150
|
price: Decimal;
|
|
149
|
-
account_order_id: bigint;
|
|
150
|
-
counterparty_order_id: bigint;
|
|
151
|
+
account_order_id: bigint | null;
|
|
152
|
+
counterparty_order_id: bigint | null;
|
|
153
|
+
me_nonce: Decimal | null;
|
|
151
154
|
spot_market_id: Decimal;
|
|
152
155
|
is_auto_exchange: boolean;
|
|
153
156
|
is_long: boolean;
|
|
@@ -172,6 +175,17 @@ type account_real_balance = {
|
|
|
172
175
|
transaction_hash: string;
|
|
173
176
|
};
|
|
174
177
|
|
|
178
|
+
// `Leverage` is still referenced by the `wallet/:address/leverages`
|
|
179
|
+
// endpoint below, so it is kept; `AutoExchange` (a dead legacy type with
|
|
180
|
+
// no remaining references) was removed in #2713/#2710.
|
|
181
|
+
type Leverage = {
|
|
182
|
+
accountId: Decimal;
|
|
183
|
+
marketId: Decimal;
|
|
184
|
+
leverage: number;
|
|
185
|
+
createdAt: Date;
|
|
186
|
+
updatedAt: Date;
|
|
187
|
+
};
|
|
188
|
+
|
|
175
189
|
type WalletStats = {
|
|
176
190
|
volume_14d: Decimal;
|
|
177
191
|
lookback_volume: Decimal;
|
|
@@ -197,8 +211,19 @@ type MarketData = {
|
|
|
197
211
|
maxAmountSizeLong?: number;
|
|
198
212
|
maxAmountBaseShort?: number;
|
|
199
213
|
maxAmountSizeShort?: number;
|
|
214
|
+
/** ME mark price, despite the name. Surfaced as v2 `MarketSummary.markPrice`. */
|
|
200
215
|
oraclePrice?: number;
|
|
216
|
+
/**
|
|
217
|
+
* Orderbook mid. Absent on an empty or one-sided book
|
|
218
|
+
*/
|
|
201
219
|
poolPrice?: number;
|
|
220
|
+
/**
|
|
221
|
+
* Stork index price, rUSD-quoted (divided by USDCUSD, like the collateral
|
|
222
|
+
* feeds). Surfaced as v2 `MarketSummary.oraclePrice` — the name differs
|
|
223
|
+
* because the v1 `oraclePrice` above is already taken by the mark price.
|
|
224
|
+
* Absent when the index feed has no fresh tick.
|
|
225
|
+
*/
|
|
226
|
+
indexPrice?: number;
|
|
202
227
|
pricesUpdatedAt?: number;
|
|
203
228
|
longBaseMultiplier?: number;
|
|
204
229
|
shortBaseMultiplier?: number;
|
|
@@ -215,7 +240,14 @@ type SpotMarketData = {
|
|
|
215
240
|
updatedAt: number;
|
|
216
241
|
volume24h: number;
|
|
217
242
|
pxChange24h?: number;
|
|
243
|
+
/** Stork price for the base token, rUSD-quoted (divided by USDCUSD). */
|
|
218
244
|
oraclePrice?: number;
|
|
245
|
+
/**
|
|
246
|
+
* Spot orderbook mid, read from the ME `{depth}:bbo:<id>` key. Absent on an
|
|
247
|
+
* empty or one-sided book — spot has no mark price to fall back to, unlike
|
|
248
|
+
* the perp `poolPrice` above.
|
|
249
|
+
*/
|
|
250
|
+
throttledMidPrice?: number;
|
|
219
251
|
};
|
|
220
252
|
|
|
221
253
|
type MarketTrackers = {
|
|
@@ -242,6 +274,10 @@ type MarketTrackers = {
|
|
|
242
274
|
price_spread: Decimal | null;
|
|
243
275
|
depth_factor: Decimal | null;
|
|
244
276
|
log_price_multiplier: Decimal | null;
|
|
277
|
+
mark_price: Decimal | null;
|
|
278
|
+
mark_price_timestamp: Decimal | null;
|
|
279
|
+
funding_rate: Decimal | null;
|
|
280
|
+
funding_rate_timestamp: Decimal | null;
|
|
245
281
|
};
|
|
246
282
|
|
|
247
283
|
export type TradingApiReplication<
|
|
@@ -302,6 +338,11 @@ export type TradingApiSource = {
|
|
|
302
338
|
{ timestampInMs: number; apy: number }[],
|
|
303
339
|
{ timeframeMs: string; granularity: string }
|
|
304
340
|
>;
|
|
341
|
+
'wallet/:address/leverages': TradingApiListEndpoint<
|
|
342
|
+
Leverage,
|
|
343
|
+
{ address: string },
|
|
344
|
+
'accountLeveragePerMarket'
|
|
345
|
+
>;
|
|
305
346
|
'markets/data': TradingApiListEndpoint<MarketData, never, 'marketData'>;
|
|
306
347
|
'spotMarkets/data': TradingApiListEndpoint<
|
|
307
348
|
SpotMarketData,
|
|
@@ -367,10 +408,31 @@ export type TradingApiSource = {
|
|
|
367
408
|
'position',
|
|
368
409
|
Omit<Position, 'adjusted_base' | 'adl_realized_pnl'>
|
|
369
410
|
>;
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
411
|
+
// PRO-126 Bug 7: V1 `/wallet/:address/openOrders` endpoint type
|
|
412
|
+
// retired. The route+controller were removed in trading.router.ts +
|
|
413
|
+
// trading.controller.ts. V2 callers should use
|
|
414
|
+
// `/v2/wallet/:address/openOrders` which serves both spot and perp
|
|
415
|
+
// orders from the unified ME stream via AccountOrdersMap.
|
|
416
|
+
assets: TradingApiListEndpoint<{
|
|
417
|
+
address: string;
|
|
418
|
+
name: string;
|
|
419
|
+
short: string;
|
|
420
|
+
createdAt: Date;
|
|
421
|
+
updatedAt: Date;
|
|
422
|
+
asset_price_contract_id: string | null;
|
|
423
|
+
asset_price_usdc_contract_id: string | null;
|
|
424
|
+
decimals: number;
|
|
425
|
+
}>;
|
|
426
|
+
prices: TradingApiEndpoint<
|
|
427
|
+
Partial<Record<AssetPair, MarketPrice | CollateralPrice>>,
|
|
428
|
+
never
|
|
429
|
+
>;
|
|
430
|
+
'prices/:assetPairId': TradingApiEndpoint<
|
|
431
|
+
MarketPrice | CollateralPrice | undefined,
|
|
432
|
+
{
|
|
433
|
+
assetPairId: string;
|
|
434
|
+
},
|
|
435
|
+
'price'
|
|
374
436
|
>;
|
|
375
437
|
// Bridge deposits and withdrawals for a wallet. Rows are registered by the
|
|
376
438
|
// Reya app when it broadcasts the source-chain transaction, and reconciled
|
|
@@ -419,6 +481,26 @@ export type TradingApiSource = {
|
|
|
419
481
|
'storkPriceCandle',
|
|
420
482
|
Candle
|
|
421
483
|
>;
|
|
484
|
+
'candles/:assetPairId/:resolution': TradingApiEndpoint<
|
|
485
|
+
{
|
|
486
|
+
t: number[];
|
|
487
|
+
o: number[];
|
|
488
|
+
h: number[];
|
|
489
|
+
l: number[];
|
|
490
|
+
c: number[];
|
|
491
|
+
},
|
|
492
|
+
{
|
|
493
|
+
resolution: CandleResolution;
|
|
494
|
+
assetPairId: AssetPair;
|
|
495
|
+
},
|
|
496
|
+
never,
|
|
497
|
+
never,
|
|
498
|
+
{
|
|
499
|
+
to: string;
|
|
500
|
+
from: string;
|
|
501
|
+
countBack?: string;
|
|
502
|
+
}
|
|
503
|
+
>;
|
|
422
504
|
feeTierParameters: TradingApiListEndpoint<{
|
|
423
505
|
tier_id: Decimal;
|
|
424
506
|
taker_fee: Decimal;
|
|
@@ -429,7 +511,6 @@ export type TradingApiSource = {
|
|
|
429
511
|
{
|
|
430
512
|
og_discount: Decimal;
|
|
431
513
|
vltz_discount: Decimal;
|
|
432
|
-
spread_discount: Decimal;
|
|
433
514
|
referee_discount: Decimal;
|
|
434
515
|
referrer_rebate: Decimal;
|
|
435
516
|
affiliate_referrer_rebate: Decimal;
|
|
@@ -567,8 +648,141 @@ type account_owner_updated_snapshot = {
|
|
|
567
648
|
block_timestamp: Decimal | null;
|
|
568
649
|
block_number: Decimal;
|
|
569
650
|
unique_id: bigint | null;
|
|
651
|
+
event_sequence_number: bigint | null;
|
|
570
652
|
};
|
|
571
653
|
|
|
654
|
+
export interface OrdersGatewayPermissionUpdatedStreamResult {
|
|
655
|
+
owner: string;
|
|
656
|
+
delegate: string;
|
|
657
|
+
permission_state: boolean;
|
|
658
|
+
event_sequence_number: string;
|
|
659
|
+
block_number: string;
|
|
660
|
+
block_timestamp: string;
|
|
661
|
+
transaction_hash: string | null;
|
|
662
|
+
}
|
|
663
|
+
|
|
664
|
+
export interface PerpTradeStreamPosition {
|
|
665
|
+
account_id: Decimal;
|
|
666
|
+
base: Decimal;
|
|
667
|
+
base_multiplier: Decimal;
|
|
668
|
+
funding_value: Decimal;
|
|
669
|
+
adl_unwind_price: Decimal;
|
|
670
|
+
last_price: Decimal;
|
|
671
|
+
last_price_timestamp: Decimal;
|
|
672
|
+
realized_pnl: Decimal;
|
|
673
|
+
average_entry_funding_value: Decimal;
|
|
674
|
+
session: Decimal;
|
|
675
|
+
}
|
|
676
|
+
|
|
677
|
+
export interface PerpTradeStreamResult {
|
|
678
|
+
id: string;
|
|
679
|
+
event_sequence_number: Decimal;
|
|
680
|
+
me_nonce: Decimal;
|
|
681
|
+
market_id: Decimal;
|
|
682
|
+
account_id: Decimal;
|
|
683
|
+
counterparty_account_id: Decimal;
|
|
684
|
+
executed_base: Decimal;
|
|
685
|
+
fee: Decimal;
|
|
686
|
+
price: Decimal;
|
|
687
|
+
is_match_order: boolean;
|
|
688
|
+
liquidation_type: Decimal;
|
|
689
|
+
execution_type: number;
|
|
690
|
+
protocol_fee_credit: Decimal;
|
|
691
|
+
taker_rebate_credit: Decimal;
|
|
692
|
+
pool_fee_credit: Decimal;
|
|
693
|
+
exchange_fee_credit: null;
|
|
694
|
+
maker_fee_credit: null;
|
|
695
|
+
maker_fee_debit: null;
|
|
696
|
+
account_order_id: Decimal;
|
|
697
|
+
counterparty_order_id: Decimal;
|
|
698
|
+
position_previous_average_entry_funding_value: Decimal;
|
|
699
|
+
position_previous_adl_unwind_price: Decimal;
|
|
700
|
+
position_previous_base_multiplier: Decimal;
|
|
701
|
+
position_previous_funding_value: Decimal;
|
|
702
|
+
position_previous_last_price: Decimal;
|
|
703
|
+
position_previous_realized_pnl: Decimal;
|
|
704
|
+
counterparty_previous_average_entry_funding_value: Decimal;
|
|
705
|
+
counterparty_previous_adl_unwind_price: Decimal;
|
|
706
|
+
counterparty_previous_base_multiplier: Decimal;
|
|
707
|
+
counterparty_previous_funding_value: Decimal;
|
|
708
|
+
counterparty_previous_last_price: Decimal;
|
|
709
|
+
counterparty_previous_realized_pnl: Decimal;
|
|
710
|
+
block_timestamp: Decimal;
|
|
711
|
+
block_number: Decimal;
|
|
712
|
+
transaction_hash: string;
|
|
713
|
+
unique_id: bigint;
|
|
714
|
+
exchange_id: Decimal;
|
|
715
|
+
referrer_account_id: Decimal;
|
|
716
|
+
referrer_fee_credit: Decimal;
|
|
717
|
+
account: PerpTradeStreamPosition;
|
|
718
|
+
counterparty: PerpTradeStreamPosition;
|
|
719
|
+
}
|
|
720
|
+
|
|
721
|
+
export type PerpTradeStreamMessage = GenericReplicationMessage<
|
|
722
|
+
PerpTradeStreamResult,
|
|
723
|
+
'trade'
|
|
724
|
+
>;
|
|
725
|
+
|
|
726
|
+
export interface BalanceStreamSide {
|
|
727
|
+
account_id: Decimal;
|
|
728
|
+
balance: Decimal;
|
|
729
|
+
/** Lowercased owner address (address(0) for account 0); part of the ledger enrichment. */
|
|
730
|
+
owner?: string;
|
|
731
|
+
}
|
|
732
|
+
|
|
733
|
+
/**
|
|
734
|
+
* One built leg of a Transfers event. The account ledger fields (PRO-852,
|
|
735
|
+
* design §3.2) label and link the leg the same way its account_transfers row
|
|
736
|
+
* is: `type` from command type and leg position, `fill_id` (ME nonce) and
|
|
737
|
+
* `market_id` for perp fills settled after reya-network#752,
|
|
738
|
+
* `spot_execution_sequence_number` / `spot_market_id` for spot trades and
|
|
739
|
+
* auto-exchanges. Consumers that only track balances ignore them.
|
|
740
|
+
*/
|
|
741
|
+
export interface BalanceStreamTransfer {
|
|
742
|
+
transfer_event_sequence_number: Decimal;
|
|
743
|
+
collateral: string;
|
|
744
|
+
from: BalanceStreamSide;
|
|
745
|
+
to: BalanceStreamSide;
|
|
746
|
+
// The ledger enrichment (PRO-852), included on all newly published legs;
|
|
747
|
+
// a leg without it feeds the balances rail and nothing else.
|
|
748
|
+
/** Position of the leg in the event's array. */
|
|
749
|
+
leg_index?: number;
|
|
750
|
+
/** Amount moved (`netDepositsDelta`), raw token units, always positive. */
|
|
751
|
+
amount?: Decimal;
|
|
752
|
+
/** TransferType label; OTHER when the leg is not recognised. */
|
|
753
|
+
type?: string;
|
|
754
|
+
fill_id?: Decimal | null;
|
|
755
|
+
market_id?: Decimal | null;
|
|
756
|
+
spot_execution_sequence_number?: Decimal | null;
|
|
757
|
+
spot_market_id?: Decimal | null;
|
|
758
|
+
}
|
|
759
|
+
|
|
760
|
+
/** A leg as published while the ledger is on: every enrichment field present. */
|
|
761
|
+
export type EnrichedBalanceStreamTransfer = Required<
|
|
762
|
+
Omit<BalanceStreamTransfer, 'from' | 'to'>
|
|
763
|
+
> & {
|
|
764
|
+
from: Required<BalanceStreamSide>;
|
|
765
|
+
to: Required<BalanceStreamSide>;
|
|
766
|
+
};
|
|
767
|
+
|
|
768
|
+
export interface BalanceStreamResult {
|
|
769
|
+
event_sequence_number: Decimal;
|
|
770
|
+
block_timestamp: Decimal;
|
|
771
|
+
block_number: Decimal;
|
|
772
|
+
transaction_hash: string;
|
|
773
|
+
command_type: Decimal;
|
|
774
|
+
me_nonce: Decimal | null;
|
|
775
|
+
spot_market_id: Decimal | null;
|
|
776
|
+
account_id: Decimal | null;
|
|
777
|
+
counterparty_account_id: Decimal | null;
|
|
778
|
+
transfers: BalanceStreamTransfer[];
|
|
779
|
+
}
|
|
780
|
+
|
|
781
|
+
export type BalanceStreamMessage = GenericReplicationMessage<
|
|
782
|
+
BalanceStreamResult,
|
|
783
|
+
'transfers'
|
|
784
|
+
>;
|
|
785
|
+
|
|
572
786
|
type positions_migration = {
|
|
573
787
|
market_id: Decimal;
|
|
574
788
|
account_id: Decimal;
|
|
@@ -591,13 +805,15 @@ type positions_migration = {
|
|
|
591
805
|
referrer_fee_credit: Decimal | null;
|
|
592
806
|
};
|
|
593
807
|
|
|
594
|
-
type
|
|
808
|
+
type execution_bust = {
|
|
595
809
|
event_sequence_number: bigint;
|
|
596
|
-
|
|
810
|
+
market_id: Decimal;
|
|
811
|
+
market_type: string;
|
|
597
812
|
account_id: Decimal;
|
|
598
813
|
counterparty_account_id: Decimal;
|
|
599
814
|
account_order_id: bigint;
|
|
600
815
|
counterparty_order_id: bigint;
|
|
816
|
+
me_nonce: Decimal | null;
|
|
601
817
|
exchange_id: Decimal;
|
|
602
818
|
failed_base: Decimal;
|
|
603
819
|
price: Decimal;
|
|
@@ -641,17 +857,20 @@ type ReplicationMessage =
|
|
|
641
857
|
>
|
|
642
858
|
| GenericReplicationMessage<account_real_balance, 'account_real_balances'>
|
|
643
859
|
| GenericReplicationMessage<
|
|
644
|
-
|
|
645
|
-
'
|
|
860
|
+
OrdersGatewayPermissionUpdatedStreamResult,
|
|
861
|
+
'orders_gateway_permission'
|
|
646
862
|
>
|
|
863
|
+
// PRO-126 Bug 7: `ConditionalOrdersSensitive` replication channel
|
|
864
|
+
// retired with the rest of the `ConditionalOrders` DB pipeline.
|
|
865
|
+
// Order data flows through the ME's `{orders}:changes` stream.
|
|
647
866
|
| GenericReplicationMessage<
|
|
648
867
|
// Todo: remove after migration
|
|
649
868
|
positions_migration,
|
|
650
869
|
'positions_migration'
|
|
651
870
|
>
|
|
652
871
|
| GenericReplicationMessage<spot_execution, 'spot_executions'>
|
|
653
|
-
| GenericReplicationMessage<spot_execution_bust, 'spot_execution_busts'>
|
|
654
872
|
| GenericReplicationMessage<Order, 'orders'>
|
|
873
|
+
| GenericReplicationMessage<execution_bust, 'execution_busts'>
|
|
655
874
|
| GenericReplicationMessage<
|
|
656
875
|
bridge_transactions_margin_account,
|
|
657
876
|
'BridgeTransactionsMarginAccount'
|