@reyaxyz/common 0.273.0 → 0.274.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.
Files changed (34) hide show
  1. package/README.md +1 -1
  2. package/dist/rest/helpers/constants.js +2 -2
  3. package/dist/rest/helpers/constants.js.map +1 -1
  4. package/dist/trading-api-types.js.map +1 -1
  5. package/dist/transactions/contractAddresses.js +0 -3
  6. package/dist/transactions/contractAddresses.js.map +1 -1
  7. package/dist/transactions/executeTransaction.js +4 -3
  8. package/dist/transactions/executeTransaction.js.map +1 -1
  9. package/dist/transactions/routerCommands.js +1 -5
  10. package/dist/transactions/routerCommands.js.map +1 -1
  11. package/dist/types/trading-api-types.d.ts +36 -43
  12. package/dist/types/trading-api-types.d.ts.map +1 -1
  13. package/dist/types/transactions/contractAddresses.d.ts +0 -1
  14. package/dist/types/transactions/contractAddresses.d.ts.map +1 -1
  15. package/dist/types/transactions/executeTransaction.d.ts +0 -3
  16. package/dist/types/transactions/executeTransaction.d.ts.map +1 -1
  17. package/dist/types/transactions/routerCommands.d.ts +1 -2
  18. package/dist/types/transactions/routerCommands.d.ts.map +1 -1
  19. package/dist/types/types.d.ts +15 -30
  20. package/dist/types/types.d.ts.map +1 -1
  21. package/dist/types/utils/network.d.ts +0 -1
  22. package/dist/types/utils/network.d.ts.map +1 -1
  23. package/dist/types.js +5 -1
  24. package/dist/types.js.map +1 -1
  25. package/dist/utils/network.js +3 -4
  26. package/dist/utils/network.js.map +1 -1
  27. package/package.json +2 -2
  28. package/src/rest/helpers/constants.ts +2 -2
  29. package/src/trading-api-types.ts +55 -53
  30. package/src/transactions/contractAddresses.ts +0 -5
  31. package/src/transactions/executeTransaction.ts +2 -1
  32. package/src/transactions/routerCommands.ts +0 -4
  33. package/src/types.ts +21 -34
  34. package/src/utils/network.ts +1 -2
@@ -1,5 +1,5 @@
1
1
  import { ParamsDictionary, Query } from 'express-serve-static-core';
2
- import { AssetPair } from './types';
2
+ import { AssetPair, CollateralPrice, MarketPrice } from './types';
3
3
 
4
4
  export type PaginatedQueryParams = {
5
5
  before: string;
@@ -99,43 +99,14 @@ type ConditionalOrder = {
99
99
  transaction_hash: string | null;
100
100
  };
101
101
 
102
- type Swap = {
103
- id: string;
104
- account_id: Decimal;
105
- token_in: string;
106
- token_out: string;
107
- amount_in: Decimal;
108
- amount_out: Decimal;
109
- executed_amount_out: Decimal;
110
- transaction_hash: string;
111
- block_timestamp: Decimal;
112
- block_number: Decimal;
113
- unique_id: bigint | null;
114
- };
115
-
116
102
  type Market = {
117
103
  id: Decimal;
118
104
  ticker: string;
119
- markPrice: number;
120
105
  isActive: boolean;
121
106
  maxLeverage: number;
122
- volume24H: number;
123
- priceChange24H: number;
124
- longOI: number;
125
- shortOI: number;
126
- availableLong: number;
127
- availableShort: number;
128
- marketPriceDeviation: number;
129
- riskBlockId: number;
130
- rootCollateralPoolId: number;
131
107
  description: string;
132
108
  name: string;
133
- quoteTokenId: string;
134
109
  tickSizeDecimals: number;
135
- underlyingAssetId: string;
136
- priceChange24HPercentage: number;
137
- openInterest: number;
138
- fundingRate: number;
139
110
  priority: number;
140
111
  };
141
112
 
@@ -147,15 +118,6 @@ type Account = {
147
118
  source: string | null;
148
119
  };
149
120
 
150
- type Price = {
151
- block_number: Decimal;
152
- unique_id: bigint | null;
153
- contract_id: string;
154
- price: Decimal | null;
155
- round_id: Decimal | null;
156
- timestamp: Decimal;
157
- };
158
-
159
121
  type AccountBalance = {
160
122
  account_id: number | null;
161
123
  collateral: string | null;
@@ -191,6 +153,27 @@ type WalletStats = {
191
153
  volume_14d: Decimal;
192
154
  };
193
155
 
156
+ type MarketData = {
157
+ marketId: string;
158
+ updatedAt: number;
159
+ longOI: number;
160
+ shortOI: number;
161
+ longSkewPercentage: number;
162
+ shortSkewPercentage: number;
163
+ openInterest?: number;
164
+ fundingRate?: number;
165
+ last24hVolume: number;
166
+ priceChange24H?: number;
167
+ priceChange24HPercentage?: number;
168
+ maxAmountBaseLong?: number;
169
+ maxAmountSizeLong?: number;
170
+ maxAmountBaseShort?: number;
171
+ maxAmountSizeShort?: number;
172
+ oraclePrice?: number;
173
+ poolPrice?: number;
174
+ pricesUpdatedAt?: number;
175
+ };
176
+
194
177
  export type TradingApiEndpoint<
195
178
  Response,
196
179
  Params,
@@ -265,6 +248,8 @@ export type TradingApiSource = {
265
248
  { address: string },
266
249
  'accountLeveragePerMarket'
267
250
  >;
251
+ markets: TradingApiListEndpoint<Market>;
252
+ 'markets/data': TradingApiListEndpoint<MarketData, never, 'marketData'>;
268
253
  'markets/configuration': TradingApiListEndpoint<{
269
254
  market_id: Decimal;
270
255
  risk_matrix_index: Decimal | null;
@@ -321,6 +306,26 @@ export type TradingApiSource = {
321
306
  block_number: Decimal;
322
307
  unique_id: bigint | null;
323
308
  }>;
309
+ 'market/:marketId': TradingApiEndpoint<
310
+ Market,
311
+ {
312
+ marketId: string;
313
+ }
314
+ >;
315
+ 'market/:marketId/data': TradingApiEndpoint<
316
+ MarketData,
317
+ {
318
+ marketId: string;
319
+ },
320
+ 'marketData'
321
+ >;
322
+ 'market/:marketId/orders': TradingApiInfiniteListEndpoint<
323
+ Order,
324
+ {
325
+ marketId: string;
326
+ },
327
+ 'order_history'
328
+ >;
324
329
  'wallet/:address/positions': TradingApiListEndpoint<
325
330
  Position,
326
331
  AddressParam,
@@ -341,7 +346,17 @@ export type TradingApiSource = {
341
346
  asset_price_usdc_contract_id: string | null;
342
347
  decimals: number;
343
348
  }>;
344
- prices: TradingApiListEndpoint<Price>;
349
+ prices: TradingApiEndpoint<
350
+ Partial<Record<AssetPair, MarketPrice | CollateralPrice>>,
351
+ never
352
+ >;
353
+ 'prices/:assetPairId': TradingApiEndpoint<
354
+ MarketPrice | CollateralPrice | undefined,
355
+ {
356
+ assetPairId: string;
357
+ },
358
+ 'price'
359
+ >;
345
360
  'wallet/:address/accounts': TradingApiListEndpoint<
346
361
  Account,
347
362
  AddressParam,
@@ -365,18 +380,6 @@ export type TradingApiSource = {
365
380
  AddressParam,
366
381
  'auto_exchange'
367
382
  >;
368
- 'wallet/:address/swaps': TradingApiInfiniteListEndpoint<
369
- Swap,
370
- AddressParam,
371
- 'swaps'
372
- >;
373
- 'market/:marketId/orders': TradingApiInfiniteListEndpoint<
374
- Order,
375
- {
376
- marketId: string;
377
- },
378
- 'order_history'
379
- >;
380
383
  'wallet/:address/balanceHistory/:timestamp': TradingApiListEndpoint<
381
384
  {
382
385
  timestamp: number;
@@ -411,7 +414,6 @@ export type TradingApiSource = {
411
414
  poolId: string;
412
415
  }
413
416
  >;
414
- markets: TradingApiListEndpoint<Market>;
415
417
  tierFees: TradingApiListEndpoint<{
416
418
  market_id: Decimal;
417
419
  tier_id: Decimal;
@@ -8,7 +8,6 @@ export enum ContractType {
8
8
  PASSIVE_PERP_PROXY = 'passive_perp_proxy',
9
9
  ORACLE_ADAPTERS_PROXY = 'oracle_adapters_proxy',
10
10
  MULTICALL = 'multicall',
11
- CAMELOT_YAK_ROUTER = 'camelot_yak_router',
12
11
  REYA_SBTS = 'reya_sbts',
13
12
  }
14
13
 
@@ -26,8 +25,6 @@ const addresses: Record<ReyaChainId, Record<ContractType, Address>> = {
26
25
  [ContractType.ORACLE_ADAPTERS_PROXY]:
27
26
  '0xc501a2356703cd351703d68963c6f4136120f7cf',
28
27
  [ContractType.MULTICALL]: '0x5abde4f0af8eaf3c9967f7fa126e59a103357b5c',
29
- [ContractType.CAMELOT_YAK_ROUTER]:
30
- '0x2b59eb03865d18d8b62a5956bbbfae352fc1c148',
31
28
  [ContractType.REYA_SBTS]: '0xc0092ea9179ace93b0cd8910958e335575562722',
32
29
  },
33
30
  [ReyaChainId.reyaNetwork]: {
@@ -43,8 +40,6 @@ const addresses: Record<ReyaChainId, Record<ContractType, Address>> = {
43
40
  [ContractType.ORACLE_ADAPTERS_PROXY]:
44
41
  '0x32edabc058c1207fe0ec5f8557643c28e4ff379e',
45
42
  [ContractType.MULTICALL]: '0xed28d27dfca47ad2513c9f2e2d3c098c2ea5a47f',
46
- [ContractType.CAMELOT_YAK_ROUTER]:
47
- '0x2b59eb03865d18d8b62a5956bbbfae352fc1c148',
48
43
  [ContractType.REYA_SBTS]: '0x14d7c1efc024e118df70b241afbd2447d37f1ed6',
49
44
  },
50
45
  };
@@ -14,7 +14,7 @@ import { getGasBuffer } from './txHelpers';
14
14
  import { getPublicRpcUrlsOrThrow } from '../utils';
15
15
  import { Interface } from 'ethers';
16
16
 
17
- export const reyaChainIdRPCMapper: { [key: number]: string } = {
17
+ const reyaChainIdRPCMapper: { [key: number]: string } = {
18
18
  [ReyaChainId.reyaNetwork]:
19
19
  'https://rpc.reya.network/263e76b89da84d478fd2b6e8783a1cfe',
20
20
  [ReyaChainId.reyaCronos]:
@@ -53,6 +53,7 @@ export async function estimateGas(
53
53
  );
54
54
  }
55
55
 
56
+ // TODO: deprecate this when /executeGelato is gone
56
57
  export async function estimateGasGivenAddress(
57
58
  accountAddress: string,
58
59
  data: string,
@@ -12,7 +12,6 @@ export enum CommandType {
12
12
  DUTCH_LIQUIDATION,
13
13
  MATCH_ORDER,
14
14
  TRANSFER_MARGIN_ACCOUNT,
15
- CAMELOT_SWAP,
16
15
  MANAGE_POOL_STAKE,
17
16
  }
18
17
 
@@ -22,9 +21,6 @@ const ABI_DEFINITION: { [key in CommandType]: string[] } = {
22
21
  [CommandType.MATCH_ORDER]: ['uint128[]', 'bytes'],
23
22
  [CommandType.DUTCH_LIQUIDATION]: ['tuple(uint128,address,uint128[],bytes[])'],
24
23
  [CommandType.TRANSFER_MARGIN_ACCOUNT]: ['tuple(uint128,address,uint256)'],
25
- [CommandType.CAMELOT_SWAP]: [
26
- 'tuple(uint256,uint256,address[],address[],address[])',
27
- ],
28
24
  [CommandType.MANAGE_POOL_STAKE]: ['uint8', 'bytes'],
29
25
  };
30
26
 
package/src/types.ts CHANGED
@@ -45,29 +45,6 @@ export type MarketEntity = {
45
45
  availableShort: number;
46
46
  };
47
47
 
48
- export type SpotMarketEntity = {
49
- id: number;
50
- ticker: string;
51
- underlyingAsset: {
52
- short: string;
53
- address: string;
54
- price: number;
55
- };
56
- quoteToken: {
57
- short: string;
58
- address: string;
59
- price: number;
60
- };
61
- price: number;
62
- isActive: boolean;
63
- liquidity: number;
64
- volume24H: number;
65
- decimalsFrom: number;
66
- decimalsTo: number;
67
- tickSizeDecimals: number;
68
- yield: number;
69
- };
70
-
71
48
  export enum ReyaChainId {
72
49
  reyaNetwork = 1729,
73
50
  reyaCronos = 89346162,
@@ -295,9 +272,7 @@ export type MarginAccountTransactionHistoryType =
295
272
  | 'withdrawal'
296
273
  | 'transfer'
297
274
  | 'auto_exchange_deposit'
298
- | 'auto_exchange_withdrawal'
299
- | 'swap_in'
300
- | 'swap_out';
275
+ | 'auto_exchange_withdrawal';
301
276
 
302
277
  export type MarginAccountTransactionStatus = 'confirmed' | 'pending';
303
278
 
@@ -963,13 +938,6 @@ export interface CandleMessage {
963
938
  version: string;
964
939
  }
965
940
 
966
- export interface SpotCandleMessage {
967
- contents: string;
968
- clobPairId: string;
969
- resolution: string;
970
- version: string;
971
- }
972
-
973
941
  export interface PriceMessage {
974
942
  contents: string;
975
943
  assetPairId: string;
@@ -1004,7 +972,7 @@ export type TransactionExecutionMetadata = {
1004
972
  accountId?: number;
1005
973
  marketId?: number;
1006
974
  destinationType?: 'pool' | 'account';
1007
- action?: 'matchOrder' | 'closeOrder' | 'createAccount' | 'swap';
975
+ action?: 'matchOrder' | 'closeOrder' | 'createAccount';
1008
976
  tradeSource?: 'reya' | 'rage' | 'other';
1009
977
  sender?: string;
1010
978
  matchOrder?: {
@@ -1368,3 +1336,22 @@ export type AssetPair =
1368
1336
  export type DerivedAssetPair = 'SDEUSDUSD';
1369
1337
 
1370
1338
  export type ContractId = string;
1339
+
1340
+ export type MarketPrice = {
1341
+ marketId: number;
1342
+ price: string;
1343
+ oraclePrice: string;
1344
+ poolPrice: string;
1345
+ updatedAt: number;
1346
+ };
1347
+
1348
+ export type CollateralPrice = {
1349
+ address: string;
1350
+ oraclePrice: string;
1351
+ updatedAt: number;
1352
+ };
1353
+
1354
+ export const isMarketPrice = (
1355
+ price: MarketPrice | CollateralPrice,
1356
+ ): price is MarketPrice =>
1357
+ Object.prototype.hasOwnProperty.call(price, 'marketId');
@@ -55,8 +55,7 @@ export const chainIdToExplorerURL: {
55
55
  [ReyaChainId.reyaCronos]: 'https://reya-cronos.blockscout.com',
56
56
  };
57
57
 
58
- // TODO: make this non-export
59
- export const ChainRpcUrls: Record<MoneyInOutChainId | ReyaChainId, string[]> = {
58
+ const ChainRpcUrls: Record<MoneyInOutChainId | ReyaChainId, string[]> = {
60
59
  [ReyaChainId.reyaNetwork]: [
61
60
  'https://rpc.reya.network/263e76b89da84d478fd2b6e8783a1cfe',
62
61
  ],