@reyaxyz/common 0.261.1 → 0.262.1
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/rest/helpers/constants.js +16 -10
- package/dist/rest/helpers/constants.js.map +1 -1
- package/dist/trading-api-types.js.map +1 -1
- package/dist/types/rest/helpers/constants.d.ts +1 -1
- package/dist/types/rest/helpers/constants.d.ts.map +1 -1
- package/dist/types/trading-api-types.d.ts +320 -360
- package/dist/types/trading-api-types.d.ts.map +1 -1
- package/dist/types/types.d.ts +3 -3
- package/dist/types/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/package.json +2 -2
- package/src/rest/helpers/constants.ts +30 -11
- package/src/trading-api-types.ts +414 -341
- package/src/types.ts +5 -3
package/README.md
CHANGED
|
@@ -6,5 +6,5 @@
|
|
|
6
6
|
|
|
7
7
|
| Statements | Branches | Functions | Lines |
|
|
8
8
|
| --------------------------- | ----------------------- | ------------------------- | ----------------- |
|
|
9
|
-
|  |  |  |  |
|
|
10
10
|
|
|
@@ -3,6 +3,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.API_CLIENT_CONFIGS = void 0;
|
|
4
4
|
var utils_1 = require("../../utils");
|
|
5
5
|
var types_1 = require("../../types");
|
|
6
|
+
var getEnvVar = function (name, fallback) {
|
|
7
|
+
if (typeof process !== 'undefined' && process.env && process.env[name]) {
|
|
8
|
+
return process.env[name];
|
|
9
|
+
}
|
|
10
|
+
return fallback;
|
|
11
|
+
};
|
|
6
12
|
exports.API_CLIENT_CONFIGS = {
|
|
7
13
|
local: {
|
|
8
14
|
chain: types_1.ReyaChainId.reyaCronos,
|
|
@@ -14,25 +20,25 @@ exports.API_CLIENT_CONFIGS = {
|
|
|
14
20
|
},
|
|
15
21
|
production: {
|
|
16
22
|
chain: types_1.ReyaChainId.reyaNetwork,
|
|
17
|
-
apiEndpoint: 'https://api.reya.xyz',
|
|
18
|
-
webSocketEndpoint: 'wss://websocket.reya.xyz',
|
|
19
|
-
environment: 'production',
|
|
23
|
+
apiEndpoint: getEnvVar('REYA_API_ENDPOINT', 'https://api.reya.xyz'),
|
|
24
|
+
webSocketEndpoint: getEnvVar('REYA_WEBSOCKET_ENDPOINT', 'wss://websocket.reya.xyz'),
|
|
25
|
+
environment: getEnvVar('REYA_ENVIRONMENT', 'production'),
|
|
20
26
|
timeout: utils_1.API_TIMEOUT,
|
|
21
27
|
logging: false,
|
|
22
28
|
},
|
|
23
|
-
|
|
29
|
+
staging: {
|
|
24
30
|
chain: types_1.ReyaChainId.reyaNetwork,
|
|
25
|
-
apiEndpoint: 'https://api-
|
|
26
|
-
webSocketEndpoint: 'wss://websocket.reya.xyz',
|
|
27
|
-
environment: '
|
|
31
|
+
apiEndpoint: getEnvVar('REYA_API_ENDPOINT', 'https://api-staging.reya.xyz'),
|
|
32
|
+
webSocketEndpoint: getEnvVar('REYA_WEBSOCKET_ENDPOINT', 'wss://websocket-staging.reya.xyz'),
|
|
33
|
+
environment: getEnvVar('REYA_ENVIRONMENT', 'staging'),
|
|
28
34
|
timeout: utils_1.API_TIMEOUT,
|
|
29
35
|
logging: false,
|
|
30
36
|
},
|
|
31
37
|
test: {
|
|
32
38
|
chain: types_1.ReyaChainId.reyaCronos,
|
|
33
|
-
apiEndpoint: 'https://api-cronos.reya.xyz',
|
|
34
|
-
webSocketEndpoint: 'wss://websocket-testnet.reya.xyz',
|
|
35
|
-
environment: 'test',
|
|
39
|
+
apiEndpoint: getEnvVar('REYA_API_ENDPOINT', 'https://api-cronos.reya.xyz'),
|
|
40
|
+
webSocketEndpoint: getEnvVar('REYA_WEBSOCKET_ENDPOINT', 'wss://websocket-testnet.reya.xyz'),
|
|
41
|
+
environment: getEnvVar('REYA_ENVIRONMENT', 'test'),
|
|
36
42
|
timeout: utils_1.API_TIMEOUT,
|
|
37
43
|
logging: true,
|
|
38
44
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"/","sources":["rest/helpers/constants.ts"],"names":[],"mappings":";;;AAAA,qCAA0C;AAC1C,qCAA0C;
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"/","sources":["rest/helpers/constants.ts"],"names":[],"mappings":";;;AAAA,qCAA0C;AAC1C,qCAA0C;AAY1C,IAAM,SAAS,GAAG,UAAC,IAAY,EAAE,QAAgB;IAC/C,IAAI,OAAO,OAAO,KAAK,WAAW,IAAI,OAAO,CAAC,GAAG,IAAI,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;QACvE,OAAO,OAAO,CAAC,GAAG,CAAC,IAAI,CAAW,CAAC;IACrC,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC,CAAC;AAEW,QAAA,kBAAkB,GAA8C;IAC3E,KAAK,EAAE;QACL,KAAK,EAAE,mBAAW,CAAC,UAAU;QAC7B,WAAW,EAAE,uBAAuB;QACpC,iBAAiB,EAAE,qBAAqB;QACxC,WAAW,EAAE,OAAO;QACpB,OAAO,EAAE,mBAAW;QACpB,OAAO,EAAE,IAAI;KACd;IACD,UAAU,EAAE;QACV,KAAK,EAAE,mBAAW,CAAC,WAAW;QAC9B,WAAW,EAAE,SAAS,CAAC,mBAAmB,EAAE,sBAAsB,CAAC;QACnE,iBAAiB,EAAE,SAAS,CAC1B,yBAAyB,EACzB,0BAA0B,CAC3B;QACD,WAAW,EAAE,SAAS,CACpB,kBAAkB,EAClB,YAAY,CACS;QACvB,OAAO,EAAE,mBAAW;QACpB,OAAO,EAAE,KAAK;KACf;IACD,OAAO,EAAE;QACP,KAAK,EAAE,mBAAW,CAAC,WAAW;QAC9B,WAAW,EAAE,SAAS,CAAC,mBAAmB,EAAE,8BAA8B,CAAC;QAC3E,iBAAiB,EAAE,SAAS,CAC1B,yBAAyB,EACzB,kCAAkC,CACnC;QACD,WAAW,EAAE,SAAS,CAAC,kBAAkB,EAAE,SAAS,CAAuB;QAC3E,OAAO,EAAE,mBAAW;QACpB,OAAO,EAAE,KAAK;KACf;IACD,IAAI,EAAE;QACJ,KAAK,EAAE,mBAAW,CAAC,UAAU;QAC7B,WAAW,EAAE,SAAS,CAAC,mBAAmB,EAAE,6BAA6B,CAAC;QAC1E,iBAAiB,EAAE,SAAS,CAC1B,yBAAyB,EACzB,kCAAkC,CACnC;QACD,WAAW,EAAE,SAAS,CAAC,kBAAkB,EAAE,MAAM,CAAuB;QACxE,OAAO,EAAE,mBAAW;QACpB,OAAO,EAAE,IAAI;KACd;CACF,CAAC","sourcesContent":["import { API_TIMEOUT } from '../../utils';\nimport { ReyaChainId } from '../../types';\n\nexport type ServiceEnvironment = 'production' | 'staging' | 'test' | 'local';\nexport interface ServiceConfig {\n chain: ReyaChainId;\n apiEndpoint: string;\n webSocketEndpoint: string;\n environment: ServiceEnvironment; // Configuration for SDK, such as base URL for the REST API\n timeout: number; // Optional timeout for API requests\n logging: boolean;\n}\n\nconst getEnvVar = (name: string, fallback: string): string => {\n if (typeof process !== 'undefined' && process.env && process.env[name]) {\n return process.env[name] as string;\n }\n return fallback;\n};\n\nexport const API_CLIENT_CONFIGS: Record<ServiceEnvironment, ServiceConfig> = {\n local: {\n chain: ReyaChainId.reyaCronos,\n apiEndpoint: 'http://localhost:8000',\n webSocketEndpoint: 'ws://localhost:8080',\n environment: 'local',\n timeout: API_TIMEOUT,\n logging: true,\n },\n production: {\n chain: ReyaChainId.reyaNetwork,\n apiEndpoint: getEnvVar('REYA_API_ENDPOINT', 'https://api.reya.xyz'),\n webSocketEndpoint: getEnvVar(\n 'REYA_WEBSOCKET_ENDPOINT',\n 'wss://websocket.reya.xyz',\n ),\n environment: getEnvVar(\n 'REYA_ENVIRONMENT',\n 'production',\n ) as ServiceEnvironment,\n timeout: API_TIMEOUT,\n logging: false,\n },\n staging: {\n chain: ReyaChainId.reyaNetwork,\n apiEndpoint: getEnvVar('REYA_API_ENDPOINT', 'https://api-staging.reya.xyz'),\n webSocketEndpoint: getEnvVar(\n 'REYA_WEBSOCKET_ENDPOINT',\n 'wss://websocket-staging.reya.xyz',\n ),\n environment: getEnvVar('REYA_ENVIRONMENT', 'staging') as ServiceEnvironment,\n timeout: API_TIMEOUT,\n logging: false,\n },\n test: {\n chain: ReyaChainId.reyaCronos,\n apiEndpoint: getEnvVar('REYA_API_ENDPOINT', 'https://api-cronos.reya.xyz'),\n webSocketEndpoint: getEnvVar(\n 'REYA_WEBSOCKET_ENDPOINT',\n 'wss://websocket-testnet.reya.xyz',\n ),\n environment: getEnvVar('REYA_ENVIRONMENT', 'test') as ServiceEnvironment,\n timeout: API_TIMEOUT,\n logging: true,\n },\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"trading-api-types.js","sourceRoot":"/","sources":["trading-api-types.ts"],"names":[],"mappings":";;;AAwBa,QAAA,mBAAmB,GAAG;IACjC,IAAI,EAAE,MAAM;IACZ,MAAM,EAAE,QAAQ;CACjB,CAAC","sourcesContent":["import { ParamsDictionary, Query } from 'express-serve-static-core';\ntype Digit = '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9';\ntype OnlyDigits<T extends string> = T extends `${Digit}${infer Rest}`\n ? Rest extends ''\n ? T\n : OnlyDigits<Rest>\n : never;\n\nexport type PaginatedQueryParams = {\n before: OnlyDigits<string>;\n after: OnlyDigits<string>;\n limit: OnlyDigits<string>;\n direction: 'asc' | 'desc';\n};\n\nexport type PaginatedQueryMeta = {\n limit: number;\n count: number;\n before: bigint | null | undefined;\n after: bigint | null | undefined;\n};\n\nexport type Decimal = 'fake-decimal';\n\nexport const AccountStatusValues = {\n OPEN: 'OPEN',\n CLOSED: 'CLOSED',\n};\n\nexport type AccountStatus =\n (typeof AccountStatusValues)[keyof typeof AccountStatusValues];\n\ntype Order = {\n id: string;\n market_id: Decimal | null;\n account_id: Decimal | null;\n order_base: Decimal | null;\n fee: Decimal | null;\n price: Decimal | null;\n type: string;\n processed: boolean;\n transaction_hash: string;\n r_pnl: Decimal | null;\n price_variation_pnl: Decimal | null;\n funding_pnl: Decimal | null;\n average_entry_price: Decimal | null;\n block_timestamp: Decimal | null;\n block_number: Decimal;\n source: string | null;\n unique_id: bigint | null;\n created_at: Date;\n};\n\nexport type TradingApiSource = {\n PoolBalance: {\n params: {\n poolId?: string;\n };\n query: never;\n response: {\n id: number;\n timestamp: bigint;\n pool_id: number;\n value: Decimal;\n apy: Decimal;\n share_price: Decimal;\n share_price_index: Decimal;\n } | null;\n };\n Leverages: {\n params: {\n address: string;\n };\n query: never;\n response: {\n accountId: Decimal;\n marketId: Decimal;\n leverage: number;\n createdAt: Date;\n updatedAt: Date;\n }[];\n };\n MarketsConfiguration: {\n params: never;\n query: never;\n response: {\n market_id: Decimal;\n risk_matrix_index: Decimal | null;\n max_open_base: Decimal | null;\n velocity_multiplier: Decimal | null;\n minimum_order_base: Decimal | null;\n base_spacing: Decimal | null;\n price_spacing: Decimal | null;\n oracle_node_id: string | null;\n mtm_window: Decimal | null;\n dutch_config_lambda: Decimal | null;\n dutch_config_min_base: Decimal | null;\n slippage_params_phi: Decimal | null;\n slippage_params_beta: Decimal | null;\n depth_factor: Decimal | null;\n max_exposure_factor: Decimal | null;\n max_p_slippage: Decimal | null;\n price_spread: Decimal | null;\n volatility_index_multiplier: Decimal | null;\n block_timestamp: Decimal | null;\n block_number: Decimal;\n unique_id: bigint | null;\n }[];\n };\n MarketsStorage: {\n params: never;\n query: never;\n response: {\n market_id: Decimal;\n quote_collateral: string | null;\n instrument_address: string | null;\n name: string | null;\n risk_block_id: Decimal | null;\n collateral_pool_id: Decimal | null;\n block_timestamp: Decimal | null;\n block_number: Decimal;\n unique_id: bigint | null;\n }[];\n };\n MarketsTracker: {\n params: never;\n query: never;\n response: {\n market_data_id: Decimal;\n passive_pool_id: Decimal | null;\n pool_account_id: Decimal | null;\n quote_token: string | null;\n quote_token_decimals: Decimal | null;\n last_funding_velocity: Decimal | null;\n last_funding_timestamp: Decimal | null;\n last_mtm_price: Decimal | null;\n last_mtm_timestamp: Decimal | null;\n long_trackers_funding_value: Decimal | null;\n last_funding_rate: Decimal | null;\n long_trackers_base_multiplier: Decimal | null;\n long_trackers_adl_unwind_price: Decimal | null;\n short_trackers_funding_value: Decimal | null;\n short_trackers_base_multiplier: Decimal | null;\n short_trackers_adl_unwind_price: Decimal | null;\n open_interest: Decimal | null;\n block_timestamp: Decimal | null;\n block_number: Decimal;\n unique_id: bigint | null;\n }[];\n };\n Positions: {\n params: {\n address: string;\n };\n query: never;\n response: {\n market_id: Decimal;\n account_id: Decimal;\n base: Decimal | null;\n realized_pnl: Decimal | null;\n realized_pnl_latest_snapshot: Decimal | null;\n average_entry_price_off_chain_tracker: Decimal | null;\n funding_value_off_chain_tracker: Decimal | null;\n last_price: Decimal | null;\n position_data_last_price_data_timestamp: Decimal | null;\n funding_value: Decimal | null;\n base_multiplier: Decimal | null;\n adl_unwind_price: Decimal | null;\n transaction_hash: string;\n block_timestamp: Decimal | null;\n block_number: Decimal;\n unique_id: bigint | null;\n }[];\n };\n ConditionalOrders: {\n params: {\n address: string;\n };\n query: never;\n response: {\n id: string;\n account_id: Decimal;\n market_id: Decimal;\n order_type: string;\n is_long: boolean;\n trigger_price: number;\n order_base: Decimal;\n exchange_id: bigint;\n inputs: string;\n counterparty_account_id: bigint;\n reya_chain_id: bigint;\n deadline: bigint;\n signer_address: string;\n nonce: Decimal;\n signature: string;\n status: string;\n creation_timestamp_ms: bigint;\n last_update_timestamp_ms: bigint;\n transaction_hash: string | null;\n }[];\n };\n Assets: {\n params: never;\n query: never;\n response: {\n address: string;\n name: string;\n short: string;\n createdAt: Date;\n updatedAt: Date;\n asset_price_contract_id: string | null;\n asset_price_usdc_contract_id: string | null;\n decimals: number;\n }[];\n };\n Prices: {\n params: never;\n query: never;\n response: {\n block_number: Decimal;\n unique_id: bigint | null;\n contract_id: string;\n price: Decimal | null;\n round_id: Decimal | null;\n timestamp: Decimal;\n }[];\n };\n Accounts: {\n params: {\n address: string;\n };\n query: never;\n response: {\n account_id: Decimal;\n name: string;\n status: AccountStatus;\n updated_timestamp_ms: Decimal;\n source: string | null;\n }[];\n };\n AccountsBalances: {\n params: {\n address: string;\n };\n query: never;\n response: {\n account_id: number;\n collateral: string;\n balance: string;\n }[];\n };\n AutoExchange: {\n params: {\n address: string;\n };\n query: PaginatedQueryParams;\n response: {\n data: {\n id: string;\n liquidated_account_id: Decimal | null;\n liquidator_account_id: Decimal | null;\n requested_quote_amount: Decimal | null;\n collateral_out_address: string | null;\n collateral_in_address: string | null;\n collateral_amount_to_liquidator: Decimal | null;\n quote_amount_to_insurance_fund: Decimal | null;\n quote_amount_to_account: Decimal | null;\n block_timestamp: Decimal | null;\n block_number: Decimal;\n transaction_hash: string;\n unique_id: bigint | null;\n }[];\n meta: PaginatedQueryMeta;\n };\n };\n Swaps: {\n params: {\n address: string;\n };\n query: PaginatedQueryParams;\n response: {\n data: {\n id: string;\n account_id: Decimal;\n token_in: string;\n token_out: string;\n amount_in: Decimal;\n amount_out: Decimal;\n executed_amount_out: Decimal;\n transaction_hash: string;\n block_timestamp: Decimal;\n block_number: Decimal;\n unique_id: bigint | null;\n }[];\n meta: PaginatedQueryMeta;\n };\n };\n MarketOrders: {\n params: {\n marketId: string;\n type?: string;\n };\n query: PaginatedQueryParams;\n response: {\n data: Order[];\n meta: PaginatedQueryMeta;\n };\n };\n AccountOrders: {\n params: {\n accountId: string;\n type?: string;\n };\n query: PaginatedQueryParams;\n response: {\n data: Order[];\n meta: PaginatedQueryMeta;\n };\n };\n WalletBalanceHistory: {\n params: {\n address: string;\n timestamp?: string;\n };\n query: never;\n response: {\n timestamp: number;\n balance: number;\n }[];\n };\n WalletOrders: {\n params: {\n address: string;\n type?: string;\n };\n query: PaginatedQueryParams;\n response: {\n data: Order[];\n meta: PaginatedQueryMeta;\n };\n };\n RiskMatrices: {\n params: {\n poolId: string;\n };\n query: never;\n response: {\n blockId: Decimal;\n matrix: string[][];\n }[];\n };\n Markets: {\n params: never;\n query: never;\n response: {\n id: Decimal;\n ticker: string;\n markPrice: number;\n isActive: boolean;\n maxLeverage: number;\n volume24H: number;\n priceChange24H: number;\n longOI: number;\n shortOI: number;\n availableLong: number;\n availableShort: number;\n marketPriceDeviation: number;\n riskBlockId: number;\n rootCollateralPoolId: number;\n description: string;\n name: string;\n quoteTokenId: string;\n tickSizeDecimals: number;\n underlyingAssetId: string;\n priceChange24HPercentage: number;\n openInterest: number;\n fundingRate: number;\n priority: number;\n }[];\n };\n TierFees: {\n params: never;\n query: never;\n response: {\n market_id: Decimal;\n tier_id: Decimal;\n fee_parameter: Decimal | null;\n }[];\n };\n AccountsTiers: {\n params: {\n address: string;\n };\n query: never;\n response: {\n market_id: Decimal;\n account_id: Decimal;\n tier_id: Decimal;\n }[];\n };\n CollateralConfiguration: {\n params: never;\n query: never;\n response: {\n collateral_pool_id: Decimal;\n collateral_address: string;\n price_haircut: Decimal | null;\n auto_exchange_discount: Decimal | null;\n oracle_node_id: string | null;\n block_timestamp: Decimal | null;\n block_number: Decimal;\n unique_id: bigint | null;\n }[];\n };\n};\n\nexport type Stringified<T, D = Decimal> = T extends D | bigint | Date\n ? string\n : T extends (infer U)[]\n ? Stringified<U, D>[]\n : { [K in keyof T]: Stringified<T[K], D> };\n\nexport type Req<P = ParamsDictionary, ReqQuery = Query> = {\n params: P;\n query: ReqQuery;\n};\n\n/*\n\nSame as infered type \n\nexport type TradingApi = {\n [K in keyof typeof TradingQueries as K extends `get${infer R}` ? R : K]: {\n params: Parameters<ReturnType<(typeof TradingQueries)[K]>>[0] extends Req\n ? Parameters<ReturnType<(typeof TradingQueries)[K]>>[0]['params']\n : never;\n query: Parameters<ReturnType<(typeof TradingQueries)[K]>>[0] extends Req\n ? Parameters<ReturnType<(typeof TradingQueries)[K]>>[0]['query']\n : never;\n response: Stringified<\n Awaited<ReturnType<ReturnType<(typeof TradingQueries)[K]>>>\n >;\n\n*/\n\nexport type TradingApi = {\n [K in keyof TradingApiSource as K]: {\n params: TradingApiSource[K]['params'];\n query: TradingApiSource[K]['query'];\n response: Stringified<TradingApiSource[K]['response']>;\n };\n};\n"]}
|
|
1
|
+
{"version":3,"file":"trading-api-types.js","sourceRoot":"/","sources":["trading-api-types.ts"],"names":[],"mappings":";;;AAwBa,QAAA,mBAAmB,GAAG;IACjC,IAAI,EAAE,MAAM;IACZ,MAAM,EAAE,QAAQ;CACjB,CAAC","sourcesContent":["import { ParamsDictionary, Query } from 'express-serve-static-core';\ntype Digit = '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9';\ntype OnlyDigits<T extends string> = T extends `${Digit}${infer Rest}`\n ? Rest extends ''\n ? T\n : OnlyDigits<Rest>\n : never;\n\nexport type PaginatedQueryParams = {\n before: OnlyDigits<string>;\n after: OnlyDigits<string>;\n limit: OnlyDigits<string>;\n direction: 'asc' | 'desc';\n};\n\nexport type PaginatedQueryMeta = {\n limit: number;\n count: number;\n before: bigint | null | undefined;\n after: bigint | null | undefined;\n};\n\nexport type Decimal = 'fake-decimal';\n\nexport const AccountStatusValues = {\n OPEN: 'OPEN',\n CLOSED: 'CLOSED',\n};\n\nexport type AccountStatus =\n (typeof AccountStatusValues)[keyof typeof AccountStatusValues];\n\ntype Order = {\n id: string;\n market_id: Decimal | null;\n account_id: Decimal | null;\n order_base: Decimal | null;\n fee: Decimal | null;\n price: Decimal | null;\n type: string;\n processed: boolean;\n transaction_hash: string;\n r_pnl: Decimal | null;\n price_variation_pnl: Decimal | null;\n funding_pnl: Decimal | null;\n average_entry_price: Decimal | null;\n block_timestamp: Decimal | null;\n block_number: Decimal;\n source: string | null;\n unique_id: bigint | null;\n created_at: Date;\n};\n\ntype Position = {\n market_id: Decimal;\n account_id: Decimal;\n base: Decimal | null;\n realized_pnl: Decimal | null;\n realized_pnl_latest_snapshot: Decimal | null;\n average_entry_price_off_chain_tracker: Decimal | null;\n funding_value_off_chain_tracker: Decimal | null;\n last_price: Decimal | null;\n position_data_last_price_data_timestamp: Decimal | null;\n funding_value: Decimal | null;\n base_multiplier: Decimal | null;\n adl_unwind_price: Decimal | null;\n transaction_hash: string;\n block_timestamp: Decimal | null;\n block_number: Decimal;\n unique_id: bigint | null;\n};\n\ntype ConditionalOrder = {\n id: string;\n account_id: Decimal;\n market_id: Decimal;\n order_type: string;\n is_long: boolean;\n trigger_price: number;\n order_base: Decimal;\n exchange_id: bigint;\n inputs: string;\n counterparty_account_id: bigint;\n reya_chain_id: bigint;\n deadline: bigint;\n signer_address: string;\n nonce: Decimal;\n signature: string;\n status: string;\n creation_timestamp_ms: bigint;\n last_update_timestamp_ms: bigint;\n transaction_hash: string | null;\n};\n\ntype Swap = {\n id: string;\n account_id: Decimal;\n token_in: string;\n token_out: string;\n amount_in: Decimal;\n amount_out: Decimal;\n executed_amount_out: Decimal;\n transaction_hash: string;\n block_timestamp: Decimal;\n block_number: Decimal;\n unique_id: bigint | null;\n};\n\ntype Market = {\n id: Decimal;\n ticker: string;\n markPrice: number;\n isActive: boolean;\n maxLeverage: number;\n volume24H: number;\n priceChange24H: number;\n longOI: number;\n shortOI: number;\n availableLong: number;\n availableShort: number;\n marketPriceDeviation: number;\n riskBlockId: number;\n rootCollateralPoolId: number;\n description: string;\n name: string;\n quoteTokenId: string;\n tickSizeDecimals: number;\n underlyingAssetId: string;\n priceChange24HPercentage: number;\n openInterest: number;\n fundingRate: number;\n priority: number;\n};\n\ntype Account = {\n account_id: Decimal;\n name: string;\n status: AccountStatus;\n updated_timestamp_ms: Decimal;\n source: string | null;\n};\n\ntype Price = {\n block_number: Decimal;\n unique_id: bigint | null;\n contract_id: string;\n price: Decimal | null;\n round_id: Decimal | null;\n timestamp: Decimal;\n};\n\ntype AccountBalance = {\n account_id: number | null;\n collateral: string | null;\n balance?: string | null;\n delta?: string | null;\n};\n\ntype AutoExchange = {\n id: string;\n liquidated_account_id: Decimal | null;\n liquidator_account_id: Decimal | null;\n requested_quote_amount: Decimal | null;\n collateral_out_address: string | null;\n collateral_in_address: string | null;\n collateral_amount_to_liquidator: Decimal | null;\n quote_amount_to_insurance_fund: Decimal | null;\n quote_amount_to_account: Decimal | null;\n block_timestamp: Decimal | null;\n block_number: Decimal;\n transaction_hash: string;\n unique_id: bigint | null;\n};\n\ntype Leverage = {\n accountId: Decimal;\n marketId: Decimal;\n leverage: number;\n createdAt: Date;\n updatedAt: Date;\n};\n\nexport type TradingApiEndpoint<\n Response,\n Params,\n ReplicationTable extends ReplicationModel = never,\n Replication = Response,\n Query = never,\n> = {\n params: Params;\n query: Query;\n response: Response;\n replication: GenericReplicationMessage<Replication, ReplicationTable>;\n};\n\nexport type TradingApiListEndpoint<\n Response,\n Params = never,\n ReplicationTable extends ReplicationModel = never,\n Replication = Response,\n Query = never,\n> = {\n params: Params;\n query: Query;\n response: Response[];\n replication: GenericReplicationMessage<Replication, ReplicationTable>;\n};\n\nexport type TradingApiInfiniteListEndpointResponse<Response> = {\n data: Response[];\n meta: PaginatedQueryMeta;\n};\n\nexport type TradingApiInfiniteListEndpoint<\n Response,\n Params = never,\n ReplicationTable extends ReplicationModel = never,\n Replication = Response,\n Query = PaginatedQueryParams,\n> = {\n params: Params;\n query: Query;\n response: TradingApiInfiniteListEndpointResponse<Response>;\n replication: GenericReplicationMessage<Replication, ReplicationTable>;\n};\n\ntype AddressParam = {\n address: string;\n};\n\nexport type TradingApiSource = {\n 'poolBalance/:poolId?': TradingApiEndpoint<\n {\n id: number;\n timestamp: bigint;\n pool_id: number;\n value: Decimal;\n apy: Decimal;\n share_price: Decimal;\n share_price_index: Decimal;\n } | null,\n {\n poolId?: string;\n }\n >;\n 'wallet/:address/leverages': TradingApiListEndpoint<\n Leverage,\n { address: string },\n 'accountLeveragePerMarket'\n >;\n 'markets/configuration': TradingApiListEndpoint<{\n market_id: Decimal;\n risk_matrix_index: Decimal | null;\n max_open_base: Decimal | null;\n velocity_multiplier: Decimal | null;\n minimum_order_base: Decimal | null;\n base_spacing: Decimal | null;\n price_spacing: Decimal | null;\n oracle_node_id: string | null;\n mtm_window: Decimal | null;\n dutch_config_lambda: Decimal | null;\n dutch_config_min_base: Decimal | null;\n slippage_params_phi: Decimal | null;\n slippage_params_beta: Decimal | null;\n depth_factor: Decimal | null;\n max_exposure_factor: Decimal | null;\n max_p_slippage: Decimal | null;\n price_spread: Decimal | null;\n volatility_index_multiplier: Decimal | null;\n block_timestamp: Decimal | null;\n block_number: Decimal;\n unique_id: bigint | null;\n }>;\n 'markets/storage': TradingApiListEndpoint<{\n market_id: Decimal;\n quote_collateral: string | null;\n instrument_address: string | null;\n name: string | null;\n risk_block_id: Decimal | null;\n collateral_pool_id: Decimal | null;\n block_timestamp: Decimal | null;\n block_number: Decimal;\n unique_id: bigint | null;\n }>;\n 'markets/trackers': TradingApiListEndpoint<{\n market_data_id: Decimal;\n passive_pool_id: Decimal | null;\n pool_account_id: Decimal | null;\n quote_token: string | null;\n quote_token_decimals: Decimal | null;\n last_funding_velocity: Decimal | null;\n last_funding_timestamp: Decimal | null;\n last_mtm_price: Decimal | null;\n last_mtm_timestamp: Decimal | null;\n long_trackers_funding_value: Decimal | null;\n last_funding_rate: Decimal | null;\n long_trackers_base_multiplier: Decimal | null;\n long_trackers_adl_unwind_price: Decimal | null;\n short_trackers_funding_value: Decimal | null;\n short_trackers_base_multiplier: Decimal | null;\n short_trackers_adl_unwind_price: Decimal | null;\n open_interest: Decimal | null;\n block_timestamp: Decimal | null;\n block_number: Decimal;\n unique_id: bigint | null;\n }>;\n 'wallet/:address/positions': TradingApiListEndpoint<\n Position,\n AddressParam,\n 'position_raw'\n >;\n 'wallet/:address/conditionalOrders': TradingApiListEndpoint<\n ConditionalOrder,\n AddressParam,\n 'ConditionalOrders'\n >;\n assets: TradingApiListEndpoint<{\n address: string;\n name: string;\n short: string;\n createdAt: Date;\n updatedAt: Date;\n asset_price_contract_id: string | null;\n asset_price_usdc_contract_id: string | null;\n decimals: number;\n }>;\n prices: TradingApiListEndpoint<Price>;\n 'wallet/:address/accounts': TradingApiListEndpoint<\n Account,\n AddressParam,\n 'accountProfile'\n >;\n 'wallet/:address/accounts/tiers': TradingApiListEndpoint<\n {\n market_id: Decimal;\n account_id: Decimal;\n tier_id: Decimal;\n },\n AddressParam\n >;\n 'wallet/:address/accounts/balances': TradingApiListEndpoint<\n AccountBalance,\n AddressParam,\n 'account_balances'\n >;\n 'wallet/:address/autoExchange': TradingApiInfiniteListEndpoint<\n AutoExchange,\n AddressParam,\n 'auto_exchange'\n >;\n 'wallet/:address/swaps': TradingApiInfiniteListEndpoint<\n Swap,\n AddressParam,\n 'swaps'\n >;\n 'market/:marketId/orders': TradingApiInfiniteListEndpoint<\n Order,\n {\n marketId: string;\n type?: string;\n },\n 'order_history'\n >;\n 'account/:accountId/orders': TradingApiInfiniteListEndpoint<\n Order,\n {\n accountId: string;\n type?: string;\n },\n 'order_history'\n >;\n 'wallet/:address/balanceHistory/:timestamp?': TradingApiListEndpoint<\n {\n timestamp: number;\n balance: number;\n },\n {\n address: string;\n timestamp?: string;\n }\n >;\n 'wallet/:address/orders/:type?': TradingApiInfiniteListEndpoint<\n Order,\n {\n address: string;\n type?: string;\n },\n 'order_history'\n >;\n 'riskMatrices/:poolId?': TradingApiListEndpoint<\n {\n blockId: Decimal;\n matrix: string[][];\n },\n {\n poolId: string;\n }\n >;\n markets: TradingApiListEndpoint<Market>;\n tierFees: TradingApiListEndpoint<{\n market_id: Decimal;\n tier_id: Decimal;\n fee_parameter: Decimal | null;\n }>;\n collateralConfiguration: TradingApiListEndpoint<{\n collateral_pool_id: Decimal;\n collateral_address: string;\n price_haircut: Decimal | null;\n auto_exchange_discount: Decimal | null;\n oracle_node_id: string | null;\n block_timestamp: Decimal | null;\n block_number: Decimal;\n unique_id: bigint | null;\n }>;\n candles: TradingApiEndpoint<\n {\n t: number[];\n o: number[];\n h: number[];\n l: number[];\n c: number[];\n },\n never,\n never,\n never,\n {\n from: number;\n to: number;\n resolution: 1 | 5 | 15 | 30 | 60 | 240 | '1D';\n symbol: string;\n }\n >;\n};\n\nexport type Stringified<T, D = Decimal> = T extends D | bigint | Date\n ? string\n : T extends (infer U)[]\n ? Stringified<U, D>[]\n : { [K in keyof T]: Stringified<T[K], D> };\n\nexport type Req<P = ParamsDictionary, ReqQuery = Query> = {\n params: P;\n query: ReqQuery;\n};\n\n/*\n\nSame as infered type \n\nexport type TradingApi = {\n [K in keyof typeof TradingQueries as K extends `get${infer R}` ? R : K]: {\n params: Parameters<ReturnType<(typeof TradingQueries)[K]>>[0] extends Req\n ? Parameters<ReturnType<(typeof TradingQueries)[K]>>[0]['params']\n : never;\n query: Parameters<ReturnType<(typeof TradingQueries)[K]>>[0] extends Req\n ? Parameters<ReturnType<(typeof TradingQueries)[K]>>[0]['query']\n : never;\n response: Stringified<\n Awaited<ReturnType<ReturnType<(typeof TradingQueries)[K]>>>\n >;\n\n*/\n\nexport type TradingApi = {\n [K in keyof TradingApiSource as K]: {\n params: TradingApiSource[K]['params'];\n query: TradingApiSource[K]['query'];\n response: Stringified<TradingApiSource[K]['response']>;\n replication: Stringified<TradingApiSource[K]['replication']>;\n };\n};\n\ntype ReplicationModel = string | never;\n\nexport type GenericReplicationMessage<T, model extends ReplicationModel> =\n | {\n model: model;\n result: T;\n operation: 'create' | 'update' | 'upsert' | 'delete';\n }\n | {\n model: model;\n result: T[];\n operation: 'updateMany';\n };\n\ntype account_collateral_balance_entries = {\n id: string;\n account_id: Decimal | null;\n collateral: string | null;\n amount: Decimal | null;\n transaction_hash: string;\n block_timestamp: Decimal | null;\n block_number: Decimal;\n unique_id: bigint | null;\n};\n\ntype account_owner_updated_snapshot = {\n account_id: Decimal;\n transaction_hash: string;\n new_owner: string | null;\n block_timestamp: Decimal | null;\n block_number: Decimal;\n unique_id: bigint | null;\n};\n\nexport type ReplicationMessage =\n | GenericReplicationMessage<Order, 'order_history'>\n | GenericReplicationMessage<ConditionalOrder, 'ConditionalOrders'>\n | GenericReplicationMessage<Swap, 'swaps'>\n | GenericReplicationMessage<AutoExchange, 'auto_exchange'>\n | GenericReplicationMessage<Position, 'position_raw'>\n | GenericReplicationMessage<Price, 'asset_price'>\n | GenericReplicationMessage<Account, 'accountProfile'>\n | GenericReplicationMessage<Leverage, 'accountLeveragePerMarket'>\n | GenericReplicationMessage<\n account_owner_updated_snapshot,\n 'account_owner_updated_snapshot'\n >\n | GenericReplicationMessage<\n account_collateral_balance_entries,\n 'account_collateral_balance_entries'\n >\n | GenericReplicationMessage<AccountBalance, 'account_balances'>\n | GenericReplicationMessage<Market, 'Market'>;\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ReyaChainId } from '../../types';
|
|
2
|
-
export type ServiceEnvironment = 'production' | '
|
|
2
|
+
export type ServiceEnvironment = 'production' | 'staging' | 'test' | 'local';
|
|
3
3
|
export interface ServiceConfig {
|
|
4
4
|
chain: ReyaChainId;
|
|
5
5
|
apiEndpoint: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"/","sources":["rest/helpers/constants.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE1C,MAAM,MAAM,kBAAkB,GAAG,YAAY,GAAG,
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"/","sources":["rest/helpers/constants.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE1C,MAAM,MAAM,kBAAkB,GAAG,YAAY,GAAG,SAAS,GAAG,MAAM,GAAG,OAAO,CAAC;AAC7E,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,WAAW,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,WAAW,EAAE,kBAAkB,CAAC;IAChC,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,OAAO,CAAC;CAClB;AASD,eAAO,MAAM,kBAAkB,EAAE,MAAM,CAAC,kBAAkB,EAAE,aAAa,CA6CxE,CAAC"}
|