@nadohq/engine-client 0.1.0-alpha.3 → 0.1.0-alpha.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/EngineBaseClient.cjs +8 -7
- package/dist/EngineBaseClient.cjs.map +1 -1
- package/dist/EngineBaseClient.d.cts +1 -2
- package/dist/EngineBaseClient.d.ts +1 -2
- package/dist/EngineBaseClient.js +7 -5
- package/dist/EngineBaseClient.js.map +1 -1
- package/dist/EngineClient.d.cts +1 -2
- package/dist/EngineClient.d.ts +1 -2
- package/dist/EngineExecuteBuilder.cjs +23 -51
- package/dist/EngineExecuteBuilder.cjs.map +1 -1
- package/dist/EngineExecuteBuilder.d.cts +6 -17
- package/dist/EngineExecuteBuilder.d.ts +6 -17
- package/dist/EngineExecuteBuilder.js +13 -41
- package/dist/EngineExecuteBuilder.js.map +1 -1
- package/dist/EngineExecuteClient.cjs +6 -10
- package/dist/EngineExecuteClient.cjs.map +1 -1
- package/dist/EngineExecuteClient.d.cts +3 -4
- package/dist/EngineExecuteClient.d.ts +3 -4
- package/dist/EngineExecuteClient.js +6 -10
- package/dist/EngineExecuteClient.js.map +1 -1
- package/dist/EngineQueryClient.cjs +28 -53
- package/dist/EngineQueryClient.cjs.map +1 -1
- package/dist/EngineQueryClient.d.cts +2 -13
- package/dist/EngineQueryClient.d.ts +2 -13
- package/dist/EngineQueryClient.js +6 -31
- package/dist/EngineQueryClient.js.map +1 -1
- package/dist/EngineWebClient.cjs +0 -2
- package/dist/EngineWebClient.cjs.map +1 -1
- package/dist/EngineWebClient.d.cts +1 -2
- package/dist/EngineWebClient.d.ts +1 -2
- package/dist/EngineWebClient.js +0 -2
- package/dist/EngineWebClient.js.map +1 -1
- package/dist/endpoints.cjs +6 -6
- package/dist/endpoints.cjs.map +1 -1
- package/dist/endpoints.d.cts +1 -1
- package/dist/endpoints.d.ts +1 -1
- package/dist/endpoints.js +6 -6
- package/dist/endpoints.js.map +1 -1
- package/dist/index.d.cts +5 -6
- package/dist/index.d.ts +5 -6
- package/dist/types/EngineServerFailureError.cjs +1 -1
- package/dist/types/EngineServerFailureError.cjs.map +1 -1
- package/dist/types/EngineServerFailureError.d.cts +2 -2
- package/dist/types/EngineServerFailureError.d.ts +2 -2
- package/dist/types/EngineServerFailureError.js +1 -1
- package/dist/types/EngineServerFailureError.js.map +1 -1
- package/dist/types/clientExecuteTypes.cjs.map +1 -1
- package/dist/types/clientExecuteTypes.d.cts +4 -12
- package/dist/types/clientExecuteTypes.d.ts +4 -12
- package/dist/types/clientQueryTypes.cjs.map +1 -1
- package/dist/types/clientQueryTypes.d.cts +12 -23
- package/dist/types/clientQueryTypes.d.ts +12 -23
- package/dist/types/index.d.cts +5 -6
- package/dist/types/index.d.ts +5 -6
- package/dist/types/serverExecuteTypes.cjs.map +1 -1
- package/dist/types/serverExecuteTypes.d.cts +6 -14
- package/dist/types/serverExecuteTypes.d.ts +6 -14
- package/dist/types/serverQueryModelTypes.cjs.map +1 -1
- package/dist/types/serverQueryModelTypes.d.cts +1 -1
- package/dist/types/serverQueryModelTypes.d.ts +1 -1
- package/dist/types/serverQueryTypes.cjs.map +1 -1
- package/dist/types/serverQueryTypes.d.cts +3 -13
- package/dist/types/serverQueryTypes.d.ts +3 -13
- package/dist/types/serverSubscriptionEventTypes.d.cts +1 -1
- package/dist/types/serverSubscriptionEventTypes.d.ts +1 -1
- package/dist/utils/index.d.cts +1 -2
- package/dist/utils/index.d.ts +1 -2
- package/dist/utils/productEngineTypeMappers.cjs +5 -5
- package/dist/utils/productEngineTypeMappers.cjs.map +1 -1
- package/dist/utils/productEngineTypeMappers.d.cts +1 -1
- package/dist/utils/productEngineTypeMappers.d.ts +1 -1
- package/dist/utils/productEngineTypeMappers.js +1 -1
- package/dist/utils/productEngineTypeMappers.js.map +1 -1
- package/dist/utils/queryDataMappers.cjs +79 -90
- package/dist/utils/queryDataMappers.cjs.map +1 -1
- package/dist/utils/queryDataMappers.d.cts +1 -2
- package/dist/utils/queryDataMappers.d.ts +1 -2
- package/dist/utils/queryDataMappers.js +7 -19
- package/dist/utils/queryDataMappers.js.map +1 -1
- package/package.json +3 -4
- package/src/EngineBaseClient.ts +5 -3
- package/src/EngineExecuteBuilder.ts +14 -54
- package/src/EngineExecuteClient.ts +7 -15
- package/src/EngineQueryClient.ts +6 -35
- package/src/EngineWebClient.ts +0 -2
- package/src/endpoints.ts +4 -5
- package/src/types/EngineServerFailureError.ts +2 -2
- package/src/types/clientExecuteTypes.ts +5 -17
- package/src/types/clientQueryTypes.ts +18 -32
- package/src/types/serverExecuteTypes.ts +7 -18
- package/src/types/serverQueryModelTypes.ts +1 -1
- package/src/types/serverQueryTypes.ts +2 -16
- package/src/utils/productEngineTypeMappers.ts +1 -1
- package/src/utils/queryDataMappers.ts +7 -20
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/types/serverQueryTypes.ts"],"sourcesContent":["import { HealthStatus } from '@nadohq/contracts';\nimport {\n EngineServerHealthBreakdown,\n EngineServerPerpBalance,\n EngineServerPerpProduct,\n EngineServerProductType,\n EngineServerSpotBalance,\n EngineServerSpotProduct,\n} from './serverQueryModelTypes';\n\nexport interface EngineServerNoncesParams {\n address: string;\n}\n\nexport interface EngineServerSubaccountInfoQueryParams {\n subaccount: string;\n txns?: Array<{\n apply_delta: {\n product_id: number;\n subaccount: string;\n amount_delta: string;\n v_quote_delta: string;\n };\n }>;\n}\n\nexport interface EngineServerIsolatedPositionsQueryParams {\n subaccount: string;\n}\n\nexport interface EngineServerSymbolsQueryParams {\n product_type?: EngineServerProductType;\n product_ids?: number[];\n}\n\nexport interface EngineServerMarketPriceQueryParams {\n product_id: number;\n}\n\nexport interface EngineServerMarketPricesQueryParams {\n product_ids: number[];\n}\n\nexport interface EngineServerGetOrderQueryParams {\n product_id: number;\n digest: string;\n}\n\nexport interface EngineServerValidateOrderQueryParams {\n product_id: number;\n // Bytes for order, does not need to be signed\n order: string;\n}\n\nexport interface EngineServerOrdersQueryParams {\n sender: string;\n product_ids: number[];\n}\n\nexport interface EngineServerSubaccountOrdersQueryParams {\n sender: string;\n product_id: number;\n}\n\nexport interface EngineServerSubaccountFeeRatesParams {\n sender: string;\n}\n\nexport interface EngineServerMarketLiquidityQueryParams {\n product_id: number;\n depth: number;\n}\n\nexport interface EngineServerMaxWithdrawableQueryParams {\n sender: string;\n product_id: number;\n // If not given, engine defaults to true (leverage/borrow enabled)\n spot_leverage: string | null;\n}\n\nexport interface EngineServerMaxOrderSizeQueryParams {\n sender: string;\n product_id: number;\n price_x18: string;\n // Note: When `reduce_only` is true, `direction` must be opposite of the current position, otherwise it returns 0.\n direction: 'long' | 'short';\n // If not given, engine defaults to true (leverage/borrow enabled)\n spot_leverage: string | null;\n // If not given, engine defaults to false. If true, the max order size will be capped to the subaccount's current position size;\n // If no position exists, it will return 0.\n reduce_only: string | null;\n}\n\nexport interface EngineServerLinkedSignerParams {\n subaccount: string;\n}\n\nexport interface EngineServerMaxMintNlpQueryParams {\n sender: string;\n // If not given, engine defaults to true (leverage/borrow enabled)\n spot_leverage: string | null;\n}\n\nexport interface EngineServerQueryRequestByType {\n all_products: Record<string, never>;\n contracts: Record<string, never>;\n edge_all_products: Record<string, never>;\n fee_rates: EngineServerSubaccountFeeRatesParams;\n health_groups: Record<string, never>;\n insurance: Record<string, never>;\n isolated_positions: EngineServerIsolatedPositionsQueryParams;\n linked_signer: EngineServerLinkedSignerParams;\n market_liquidity: EngineServerMarketLiquidityQueryParams;\n market_price: EngineServerMarketPriceQueryParams;\n market_prices: EngineServerMarketPricesQueryParams;\n max_nlp_mintable: EngineServerMaxMintNlpQueryParams;\n max_order_size: EngineServerMaxOrderSizeQueryParams;\n max_withdrawable: EngineServerMaxWithdrawableQueryParams;\n min_deposit_rates: Record<string, never>;\n nonces: EngineServerNoncesParams;\n order: EngineServerGetOrderQueryParams;\n orders: EngineServerOrdersQueryParams;\n status: Record<string, never>;\n subaccount_info: Omit<EngineServerSubaccountInfoQueryParams, 'txns'> & {\n // JSON serialized txns\n txns?: string;\n };\n subaccount_orders: EngineServerSubaccountOrdersQueryParams;\n symbols: EngineServerSymbolsQueryParams;\n validate_order: EngineServerValidateOrderQueryParams;\n}\n\nexport type EngineServerQueryRequestType = keyof EngineServerQueryRequestByType;\n\nexport type EngineServerQueryRequest<\n TRequestType extends EngineServerQueryRequestType,\n> = {\n type: TRequestType;\n} & EngineServerQueryRequestByType[TRequestType];\n\nexport interface EngineServerContractsResponse {\n chain_id: string;\n endpoint_addr: string;\n // Index is product ID\n book_addrs: string[];\n}\n\n// Unless in active state, engine is not fully operational\nexport type EngineServerStatusResponse =\n | 'started'\n | 'active'\n | 'stopping'\n | 'syncing'\n | 'live_syncing'\n | 'failed';\n\nexport interface EngineServerNoncesResponse {\n order_nonce: string;\n tx_nonce: string;\n}\n\nexport interface EngineServerSubaccountInfoResponse {\n exists: boolean;\n subaccount: string;\n healths: [\n initial: EngineServerHealthBreakdown,\n maintenance: EngineServerHealthBreakdown,\n unweighted: EngineServerHealthBreakdown,\n ];\n // First index is product ID, each subarray is of length 3 [initial, maintenance, unweighted]\n health_contributions: string[][];\n spot_count: number;\n perp_count: number;\n spot_balances: EngineServerSpotBalance[];\n perp_balances: EngineServerPerpBalance[];\n spot_products: EngineServerSpotProduct[];\n perp_products: EngineServerPerpProduct[];\n}\n\nexport interface EngineServerIsolatedPosition {\n subaccount: string;\n healths: [\n initial: HealthStatus,\n maintenance: HealthStatus,\n unweighted: HealthStatus,\n ];\n quote_healths: [initial: string, maintenance: string, unweighted: string];\n base_healths: [initial: string, maintenance: string, unweighted: string];\n quote_balance: EngineServerSpotBalance;\n base_balance: EngineServerPerpBalance;\n quote_product: EngineServerSpotProduct;\n base_product: EngineServerPerpProduct;\n}\n\nexport type EngineServerIsolatedPositionsResponse = {\n isolated_positions: EngineServerIsolatedPosition[];\n};\n\nexport interface EngineServerSymbol {\n type: EngineServerProductType;\n product_id: number;\n symbol: string;\n price_increment_x18: string;\n size_increment: string;\n min_size: string;\n min_depth_x18: string;\n max_spread_rate_x18: string;\n maker_fee_rate_x18: string;\n taker_fee_rate_x18: string;\n long_weight_initial_x18: string;\n long_weight_maintenance_x18: string;\n}\n\nexport interface EngineServerSymbolsResponse {\n symbols: Record<string, EngineServerSymbol>;\n}\n\nexport interface EngineServerAllProductsResponse {\n spot_products: EngineServerSpotProduct[];\n perp_products: EngineServerPerpProduct[];\n}\n\nexport interface EngineServerHealthGroupsResponse {\n health_groups: [spotProductId: number, perpProductId: number][];\n}\n\n// Price, liquidity pairs\nexport type EngineServerPriceTickLiquidity = [\n priceX18: string,\n liquidity: string,\n];\n\nexport interface EngineServerMarketLiquidityResponse {\n bids: EngineServerPriceTickLiquidity[];\n asks: EngineServerPriceTickLiquidity[];\n}\n\nexport interface EngineServerSubaccountOrders {\n sender: string;\n product_id: number;\n orders: EngineServerOrder[];\n}\n\nexport type EngineServerSubaccountOrdersResponse = EngineServerSubaccountOrders;\n\nexport interface EngineServerProductOrdersResponse {\n sender: string;\n product_orders: EngineServerSubaccountOrders[];\n}\n\nexport interface EngineServerFeeRatesResponse {\n liquidation_sequencer_fee: string;\n health_check_sequencer_fee: string;\n taker_sequencer_fee: string;\n // Product ID is the index\n withdraw_sequencer_fees: string[];\n taker_fee_rates_x18: string[];\n maker_fee_rates_x18: string[];\n}\n\nexport interface EngineServerMarketPrice {\n product_id: number;\n bid_x18: string;\n ask_x18: string;\n}\n\nexport type EngineServerMarketPriceResponse = EngineServerMarketPrice;\n\nexport interface EngineServerMarketPricesResponse {\n market_prices: EngineServerMarketPrice[];\n}\n\nexport interface EngineServerOrder {\n product_id: number;\n sender: string;\n price_x18: string;\n amount: string;\n expiration: string;\n nonce: string;\n unfilled_amount: string;\n digest: string;\n placed_at: number;\n order_type: string;\n margin: string | null;\n}\n\nexport type EngineServerOrderResponse = EngineServerOrder;\n\nexport interface EngineServerValidateOrderResponse {\n product_id: number;\n order: string;\n valid: boolean;\n}\n\nexport interface EngineServerMaxOrderSizeResponse {\n max_order_size: string;\n}\n\nexport interface EngineServerMaxWithdrawableResponse {\n max_withdrawable: string;\n}\n\nexport type EngineServerTimeResponse = number;\n\nexport interface EngineServerIpBlockResponse {\n blocked: boolean;\n reason: string;\n}\n\nexport interface EngineServerLinkedSignerResponse {\n linked_signer: string;\n}\n\nexport interface EngineInsuranceResponse {\n insurance: string;\n}\n\nexport interface EngineServerMinDepositRate {\n product_id: number;\n min_deposit_rate_x18: string;\n}\n\nexport interface EngineServerMinDepositRatesResponse {\n // product_id -> EngineServerMinDepositRate\n min_deposit_rates: Record<number, EngineServerMinDepositRate>;\n}\n\nexport interface EngineServerEdgeAllProductsResponse {\n // chain_id -> EngineServerAllProductsResponse\n edge_all_products: Record<number, EngineServerAllProductsResponse>;\n}\n\nexport interface EngineServerMaxMintNlpResponse {\n max_quote_amount: string;\n}\n\nexport interface EngineServerQueryResponseByType {\n all_products: EngineServerAllProductsResponse;\n contracts: EngineServerContractsResponse;\n edge_all_products: EngineServerEdgeAllProductsResponse;\n fee_rates: EngineServerFeeRatesResponse;\n health_groups: EngineServerHealthGroupsResponse;\n insurance: EngineInsuranceResponse;\n isolated_positions: EngineServerIsolatedPositionsResponse;\n linked_signer: EngineServerLinkedSignerResponse;\n market_liquidity: EngineServerMarketLiquidityResponse;\n market_price: EngineServerMarketPriceResponse;\n market_prices: EngineServerMarketPricesResponse;\n max_nlp_mintable: EngineServerMaxMintNlpResponse;\n max_order_size: EngineServerMaxOrderSizeResponse;\n max_withdrawable: EngineServerMaxWithdrawableResponse;\n min_deposit_rates: EngineServerMinDepositRatesResponse;\n nonces: EngineServerNoncesResponse;\n order: EngineServerOrderResponse;\n orders: EngineServerProductOrdersResponse;\n status: EngineServerStatusResponse;\n subaccount_info: EngineServerSubaccountInfoResponse;\n subaccount_orders: EngineServerSubaccountOrdersResponse;\n symbols: EngineServerSymbolsResponse;\n validate_order: EngineServerValidateOrderResponse;\n}\n\nexport interface EngineServerQuerySuccessResponse<\n TQueryType extends\n keyof EngineServerQueryResponseByType = EngineServerQueryRequestType,\n> {\n status: 'success';\n data: EngineServerQueryResponseByType[TQueryType];\n}\n\nexport interface EngineServerQueryFailureResponse {\n status: 'failure';\n error: string;\n error_code: number;\n}\n\nexport type EngineServerQueryResponse<\n TQueryType extends\n keyof EngineServerQueryResponseByType = EngineServerQueryRequestType,\n> =\n | EngineServerQuerySuccessResponse<TQueryType>\n | EngineServerQueryFailureResponse;\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/types/serverQueryTypes.ts"],"sourcesContent":["import { HealthStatus } from '@nadohq/shared';\nimport {\n EngineServerHealthBreakdown,\n EngineServerPerpBalance,\n EngineServerPerpProduct,\n EngineServerProductType,\n EngineServerSpotBalance,\n EngineServerSpotProduct,\n} from './serverQueryModelTypes';\n\nexport interface EngineServerNoncesParams {\n address: string;\n}\n\nexport interface EngineServerSubaccountInfoQueryParams {\n subaccount: string;\n txns?: Array<{\n apply_delta: {\n product_id: number;\n subaccount: string;\n amount_delta: string;\n v_quote_delta: string;\n };\n }>;\n}\n\nexport interface EngineServerIsolatedPositionsQueryParams {\n subaccount: string;\n}\n\nexport interface EngineServerSymbolsQueryParams {\n product_type?: EngineServerProductType;\n product_ids?: number[];\n}\n\nexport interface EngineServerMarketPriceQueryParams {\n product_id: number;\n}\n\nexport interface EngineServerMarketPricesQueryParams {\n product_ids: number[];\n}\n\nexport interface EngineServerGetOrderQueryParams {\n product_id: number;\n digest: string;\n}\n\nexport interface EngineServerValidateOrderQueryParams {\n product_id: number;\n // Bytes for order, does not need to be signed\n order: string;\n}\n\nexport interface EngineServerOrdersQueryParams {\n sender: string;\n product_ids: number[];\n}\n\nexport interface EngineServerSubaccountOrdersQueryParams {\n sender: string;\n product_id: number;\n}\n\nexport interface EngineServerSubaccountFeeRatesParams {\n sender: string;\n}\n\nexport interface EngineServerMarketLiquidityQueryParams {\n product_id: number;\n depth: number;\n}\n\nexport interface EngineServerMaxWithdrawableQueryParams {\n sender: string;\n product_id: number;\n // If not given, engine defaults to true (leverage/borrow enabled)\n spot_leverage: string | null;\n}\n\nexport interface EngineServerMaxOrderSizeQueryParams {\n sender: string;\n product_id: number;\n price_x18: string;\n // Note: When `reduce_only` is true, `direction` must be opposite of the current position, otherwise it returns 0.\n direction: 'long' | 'short';\n // If not given, engine defaults to true (leverage/borrow enabled)\n spot_leverage: string | null;\n // If not given, engine defaults to false. If true, the max order size will be capped to the subaccount's current position size;\n // If no position exists, it will return 0.\n reduce_only: string | null;\n}\n\nexport interface EngineServerLinkedSignerParams {\n subaccount: string;\n}\n\nexport interface EngineServerMaxMintNlpQueryParams {\n sender: string;\n // If not given, engine defaults to true (leverage/borrow enabled)\n spot_leverage: string | null;\n}\n\nexport interface EngineServerQueryRequestByType {\n all_products: Record<string, never>;\n contracts: Record<string, never>;\n edge_all_products: Record<string, never>;\n fee_rates: EngineServerSubaccountFeeRatesParams;\n health_groups: Record<string, never>;\n insurance: Record<string, never>;\n isolated_positions: EngineServerIsolatedPositionsQueryParams;\n linked_signer: EngineServerLinkedSignerParams;\n market_liquidity: EngineServerMarketLiquidityQueryParams;\n market_price: EngineServerMarketPriceQueryParams;\n market_prices: EngineServerMarketPricesQueryParams;\n max_nlp_mintable: EngineServerMaxMintNlpQueryParams;\n max_order_size: EngineServerMaxOrderSizeQueryParams;\n max_withdrawable: EngineServerMaxWithdrawableQueryParams;\n nonces: EngineServerNoncesParams;\n order: EngineServerGetOrderQueryParams;\n orders: EngineServerOrdersQueryParams;\n status: Record<string, never>;\n subaccount_info: Omit<EngineServerSubaccountInfoQueryParams, 'txns'> & {\n // JSON serialized txns\n txns?: string;\n };\n subaccount_orders: EngineServerSubaccountOrdersQueryParams;\n symbols: EngineServerSymbolsQueryParams;\n validate_order: EngineServerValidateOrderQueryParams;\n}\n\nexport type EngineServerQueryRequestType = keyof EngineServerQueryRequestByType;\n\nexport type EngineServerQueryRequest<\n TRequestType extends EngineServerQueryRequestType,\n> = {\n type: TRequestType;\n} & EngineServerQueryRequestByType[TRequestType];\n\nexport interface EngineServerContractsResponse {\n chain_id: string;\n endpoint_addr: string;\n}\n\n// Unless in active state, engine is not fully operational\nexport type EngineServerStatusResponse =\n | 'started'\n | 'active'\n | 'stopping'\n | 'syncing'\n | 'live_syncing'\n | 'failed';\n\nexport interface EngineServerNoncesResponse {\n order_nonce: string;\n tx_nonce: string;\n}\n\nexport interface EngineServerSubaccountInfoResponse {\n exists: boolean;\n subaccount: string;\n healths: [\n initial: EngineServerHealthBreakdown,\n maintenance: EngineServerHealthBreakdown,\n unweighted: EngineServerHealthBreakdown,\n ];\n // First index is product ID, each subarray is of length 3 [initial, maintenance, unweighted]\n health_contributions: string[][];\n spot_count: number;\n perp_count: number;\n spot_balances: EngineServerSpotBalance[];\n perp_balances: EngineServerPerpBalance[];\n spot_products: EngineServerSpotProduct[];\n perp_products: EngineServerPerpProduct[];\n}\n\nexport interface EngineServerIsolatedPosition {\n subaccount: string;\n healths: [\n initial: HealthStatus,\n maintenance: HealthStatus,\n unweighted: HealthStatus,\n ];\n quote_healths: [initial: string, maintenance: string, unweighted: string];\n base_healths: [initial: string, maintenance: string, unweighted: string];\n quote_balance: EngineServerSpotBalance;\n base_balance: EngineServerPerpBalance;\n quote_product: EngineServerSpotProduct;\n base_product: EngineServerPerpProduct;\n}\n\nexport type EngineServerIsolatedPositionsResponse = {\n isolated_positions: EngineServerIsolatedPosition[];\n};\n\nexport interface EngineServerSymbol {\n type: EngineServerProductType;\n product_id: number;\n symbol: string;\n price_increment_x18: string;\n size_increment: string;\n min_size: string;\n min_depth_x18: string;\n max_spread_rate_x18: string;\n maker_fee_rate_x18: string;\n taker_fee_rate_x18: string;\n long_weight_initial_x18: string;\n long_weight_maintenance_x18: string;\n}\n\nexport interface EngineServerSymbolsResponse {\n symbols: Record<string, EngineServerSymbol>;\n}\n\nexport interface EngineServerAllProductsResponse {\n spot_products: EngineServerSpotProduct[];\n perp_products: EngineServerPerpProduct[];\n}\n\nexport interface EngineServerHealthGroupsResponse {\n health_groups: [spotProductId: number, perpProductId: number][];\n}\n\n// Price, liquidity pairs\nexport type EngineServerPriceTickLiquidity = [\n priceX18: string,\n liquidity: string,\n];\n\nexport interface EngineServerMarketLiquidityResponse {\n bids: EngineServerPriceTickLiquidity[];\n asks: EngineServerPriceTickLiquidity[];\n}\n\nexport interface EngineServerSubaccountOrders {\n sender: string;\n product_id: number;\n orders: EngineServerOrder[];\n}\n\nexport type EngineServerSubaccountOrdersResponse = EngineServerSubaccountOrders;\n\nexport interface EngineServerProductOrdersResponse {\n sender: string;\n product_orders: EngineServerSubaccountOrders[];\n}\n\nexport interface EngineServerFeeRatesResponse {\n liquidation_sequencer_fee: string;\n health_check_sequencer_fee: string;\n taker_sequencer_fee: string;\n // Product ID is the index\n withdraw_sequencer_fees: string[];\n taker_fee_rates_x18: string[];\n maker_fee_rates_x18: string[];\n}\n\nexport interface EngineServerMarketPrice {\n product_id: number;\n bid_x18: string;\n ask_x18: string;\n}\n\nexport type EngineServerMarketPriceResponse = EngineServerMarketPrice;\n\nexport interface EngineServerMarketPricesResponse {\n market_prices: EngineServerMarketPrice[];\n}\n\nexport interface EngineServerOrder {\n product_id: number;\n sender: string;\n price_x18: string;\n amount: string;\n expiration: string;\n nonce: string;\n unfilled_amount: string;\n digest: string;\n placed_at: number;\n order_type: string;\n appendix: string;\n}\n\nexport type EngineServerOrderResponse = EngineServerOrder;\n\nexport interface EngineServerValidateOrderResponse {\n product_id: number;\n order: string;\n valid: boolean;\n}\n\nexport interface EngineServerMaxOrderSizeResponse {\n max_order_size: string;\n}\n\nexport interface EngineServerMaxWithdrawableResponse {\n max_withdrawable: string;\n}\n\nexport type EngineServerTimeResponse = number;\n\nexport interface EngineServerIpBlockResponse {\n blocked: boolean;\n reason: string;\n}\n\nexport interface EngineServerLinkedSignerResponse {\n linked_signer: string;\n}\n\nexport interface EngineInsuranceResponse {\n insurance: string;\n}\n\nexport interface EngineServerEdgeAllProductsResponse {\n // chain_id -> EngineServerAllProductsResponse\n edge_all_products: Record<number, EngineServerAllProductsResponse>;\n}\n\nexport interface EngineServerMaxMintNlpResponse {\n max_quote_amount: string;\n}\n\nexport interface EngineServerQueryResponseByType {\n all_products: EngineServerAllProductsResponse;\n contracts: EngineServerContractsResponse;\n edge_all_products: EngineServerEdgeAllProductsResponse;\n fee_rates: EngineServerFeeRatesResponse;\n health_groups: EngineServerHealthGroupsResponse;\n insurance: EngineInsuranceResponse;\n isolated_positions: EngineServerIsolatedPositionsResponse;\n linked_signer: EngineServerLinkedSignerResponse;\n market_liquidity: EngineServerMarketLiquidityResponse;\n market_price: EngineServerMarketPriceResponse;\n market_prices: EngineServerMarketPricesResponse;\n max_nlp_mintable: EngineServerMaxMintNlpResponse;\n max_order_size: EngineServerMaxOrderSizeResponse;\n max_withdrawable: EngineServerMaxWithdrawableResponse;\n nonces: EngineServerNoncesResponse;\n order: EngineServerOrderResponse;\n orders: EngineServerProductOrdersResponse;\n status: EngineServerStatusResponse;\n subaccount_info: EngineServerSubaccountInfoResponse;\n subaccount_orders: EngineServerSubaccountOrdersResponse;\n symbols: EngineServerSymbolsResponse;\n validate_order: EngineServerValidateOrderResponse;\n}\n\nexport interface EngineServerQuerySuccessResponse<\n TQueryType extends\n keyof EngineServerQueryResponseByType = EngineServerQueryRequestType,\n> {\n status: 'success';\n data: EngineServerQueryResponseByType[TQueryType];\n}\n\nexport interface EngineServerQueryFailureResponse {\n status: 'failure';\n error: string;\n error_code: number;\n}\n\nexport type EngineServerQueryResponse<\n TQueryType extends\n keyof EngineServerQueryResponseByType = EngineServerQueryRequestType,\n> =\n | EngineServerQuerySuccessResponse<TQueryType>\n | EngineServerQueryFailureResponse;\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { HealthStatus } from '@nadohq/
|
|
1
|
+
import { HealthStatus } from '@nadohq/shared';
|
|
2
2
|
import { EngineServerProductType, EngineServerSpotProduct, EngineServerPerpProduct, EngineServerSpotBalance, EngineServerPerpBalance, EngineServerHealthBreakdown } from './serverQueryModelTypes.cjs';
|
|
3
3
|
|
|
4
4
|
interface EngineServerNoncesParams {
|
|
@@ -86,7 +86,6 @@ interface EngineServerQueryRequestByType {
|
|
|
86
86
|
max_nlp_mintable: EngineServerMaxMintNlpQueryParams;
|
|
87
87
|
max_order_size: EngineServerMaxOrderSizeQueryParams;
|
|
88
88
|
max_withdrawable: EngineServerMaxWithdrawableQueryParams;
|
|
89
|
-
min_deposit_rates: Record<string, never>;
|
|
90
89
|
nonces: EngineServerNoncesParams;
|
|
91
90
|
order: EngineServerGetOrderQueryParams;
|
|
92
91
|
orders: EngineServerOrdersQueryParams;
|
|
@@ -105,7 +104,6 @@ type EngineServerQueryRequest<TRequestType extends EngineServerQueryRequestType>
|
|
|
105
104
|
interface EngineServerContractsResponse {
|
|
106
105
|
chain_id: string;
|
|
107
106
|
endpoint_addr: string;
|
|
108
|
-
book_addrs: string[];
|
|
109
107
|
}
|
|
110
108
|
type EngineServerStatusResponse = 'started' | 'active' | 'stopping' | 'syncing' | 'live_syncing' | 'failed';
|
|
111
109
|
interface EngineServerNoncesResponse {
|
|
@@ -215,7 +213,7 @@ interface EngineServerOrder {
|
|
|
215
213
|
digest: string;
|
|
216
214
|
placed_at: number;
|
|
217
215
|
order_type: string;
|
|
218
|
-
|
|
216
|
+
appendix: string;
|
|
219
217
|
}
|
|
220
218
|
type EngineServerOrderResponse = EngineServerOrder;
|
|
221
219
|
interface EngineServerValidateOrderResponse {
|
|
@@ -240,13 +238,6 @@ interface EngineServerLinkedSignerResponse {
|
|
|
240
238
|
interface EngineInsuranceResponse {
|
|
241
239
|
insurance: string;
|
|
242
240
|
}
|
|
243
|
-
interface EngineServerMinDepositRate {
|
|
244
|
-
product_id: number;
|
|
245
|
-
min_deposit_rate_x18: string;
|
|
246
|
-
}
|
|
247
|
-
interface EngineServerMinDepositRatesResponse {
|
|
248
|
-
min_deposit_rates: Record<number, EngineServerMinDepositRate>;
|
|
249
|
-
}
|
|
250
241
|
interface EngineServerEdgeAllProductsResponse {
|
|
251
242
|
edge_all_products: Record<number, EngineServerAllProductsResponse>;
|
|
252
243
|
}
|
|
@@ -268,7 +259,6 @@ interface EngineServerQueryResponseByType {
|
|
|
268
259
|
max_nlp_mintable: EngineServerMaxMintNlpResponse;
|
|
269
260
|
max_order_size: EngineServerMaxOrderSizeResponse;
|
|
270
261
|
max_withdrawable: EngineServerMaxWithdrawableResponse;
|
|
271
|
-
min_deposit_rates: EngineServerMinDepositRatesResponse;
|
|
272
262
|
nonces: EngineServerNoncesResponse;
|
|
273
263
|
order: EngineServerOrderResponse;
|
|
274
264
|
orders: EngineServerProductOrdersResponse;
|
|
@@ -289,4 +279,4 @@ interface EngineServerQueryFailureResponse {
|
|
|
289
279
|
}
|
|
290
280
|
type EngineServerQueryResponse<TQueryType extends keyof EngineServerQueryResponseByType = EngineServerQueryRequestType> = EngineServerQuerySuccessResponse<TQueryType> | EngineServerQueryFailureResponse;
|
|
291
281
|
|
|
292
|
-
export type { EngineInsuranceResponse, EngineServerAllProductsResponse, EngineServerContractsResponse, EngineServerEdgeAllProductsResponse, EngineServerFeeRatesResponse, EngineServerGetOrderQueryParams, EngineServerHealthGroupsResponse, EngineServerIpBlockResponse, EngineServerIsolatedPosition, EngineServerIsolatedPositionsQueryParams, EngineServerIsolatedPositionsResponse, EngineServerLinkedSignerParams, EngineServerLinkedSignerResponse, EngineServerMarketLiquidityQueryParams, EngineServerMarketLiquidityResponse, EngineServerMarketPrice, EngineServerMarketPriceQueryParams, EngineServerMarketPriceResponse, EngineServerMarketPricesQueryParams, EngineServerMarketPricesResponse, EngineServerMaxMintNlpQueryParams, EngineServerMaxMintNlpResponse, EngineServerMaxOrderSizeQueryParams, EngineServerMaxOrderSizeResponse, EngineServerMaxWithdrawableQueryParams, EngineServerMaxWithdrawableResponse,
|
|
282
|
+
export type { EngineInsuranceResponse, EngineServerAllProductsResponse, EngineServerContractsResponse, EngineServerEdgeAllProductsResponse, EngineServerFeeRatesResponse, EngineServerGetOrderQueryParams, EngineServerHealthGroupsResponse, EngineServerIpBlockResponse, EngineServerIsolatedPosition, EngineServerIsolatedPositionsQueryParams, EngineServerIsolatedPositionsResponse, EngineServerLinkedSignerParams, EngineServerLinkedSignerResponse, EngineServerMarketLiquidityQueryParams, EngineServerMarketLiquidityResponse, EngineServerMarketPrice, EngineServerMarketPriceQueryParams, EngineServerMarketPriceResponse, EngineServerMarketPricesQueryParams, EngineServerMarketPricesResponse, EngineServerMaxMintNlpQueryParams, EngineServerMaxMintNlpResponse, EngineServerMaxOrderSizeQueryParams, EngineServerMaxOrderSizeResponse, EngineServerMaxWithdrawableQueryParams, EngineServerMaxWithdrawableResponse, EngineServerNoncesParams, EngineServerNoncesResponse, EngineServerOrder, EngineServerOrderResponse, EngineServerOrdersQueryParams, EngineServerPriceTickLiquidity, EngineServerProductOrdersResponse, EngineServerQueryFailureResponse, EngineServerQueryRequest, EngineServerQueryRequestByType, EngineServerQueryRequestType, EngineServerQueryResponse, EngineServerQueryResponseByType, EngineServerQuerySuccessResponse, EngineServerStatusResponse, EngineServerSubaccountFeeRatesParams, EngineServerSubaccountInfoQueryParams, EngineServerSubaccountInfoResponse, EngineServerSubaccountOrders, EngineServerSubaccountOrdersQueryParams, EngineServerSubaccountOrdersResponse, EngineServerSymbol, EngineServerSymbolsQueryParams, EngineServerSymbolsResponse, EngineServerTimeResponse, EngineServerValidateOrderQueryParams, EngineServerValidateOrderResponse };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { HealthStatus } from '@nadohq/
|
|
1
|
+
import { HealthStatus } from '@nadohq/shared';
|
|
2
2
|
import { EngineServerProductType, EngineServerSpotProduct, EngineServerPerpProduct, EngineServerSpotBalance, EngineServerPerpBalance, EngineServerHealthBreakdown } from './serverQueryModelTypes.js';
|
|
3
3
|
|
|
4
4
|
interface EngineServerNoncesParams {
|
|
@@ -86,7 +86,6 @@ interface EngineServerQueryRequestByType {
|
|
|
86
86
|
max_nlp_mintable: EngineServerMaxMintNlpQueryParams;
|
|
87
87
|
max_order_size: EngineServerMaxOrderSizeQueryParams;
|
|
88
88
|
max_withdrawable: EngineServerMaxWithdrawableQueryParams;
|
|
89
|
-
min_deposit_rates: Record<string, never>;
|
|
90
89
|
nonces: EngineServerNoncesParams;
|
|
91
90
|
order: EngineServerGetOrderQueryParams;
|
|
92
91
|
orders: EngineServerOrdersQueryParams;
|
|
@@ -105,7 +104,6 @@ type EngineServerQueryRequest<TRequestType extends EngineServerQueryRequestType>
|
|
|
105
104
|
interface EngineServerContractsResponse {
|
|
106
105
|
chain_id: string;
|
|
107
106
|
endpoint_addr: string;
|
|
108
|
-
book_addrs: string[];
|
|
109
107
|
}
|
|
110
108
|
type EngineServerStatusResponse = 'started' | 'active' | 'stopping' | 'syncing' | 'live_syncing' | 'failed';
|
|
111
109
|
interface EngineServerNoncesResponse {
|
|
@@ -215,7 +213,7 @@ interface EngineServerOrder {
|
|
|
215
213
|
digest: string;
|
|
216
214
|
placed_at: number;
|
|
217
215
|
order_type: string;
|
|
218
|
-
|
|
216
|
+
appendix: string;
|
|
219
217
|
}
|
|
220
218
|
type EngineServerOrderResponse = EngineServerOrder;
|
|
221
219
|
interface EngineServerValidateOrderResponse {
|
|
@@ -240,13 +238,6 @@ interface EngineServerLinkedSignerResponse {
|
|
|
240
238
|
interface EngineInsuranceResponse {
|
|
241
239
|
insurance: string;
|
|
242
240
|
}
|
|
243
|
-
interface EngineServerMinDepositRate {
|
|
244
|
-
product_id: number;
|
|
245
|
-
min_deposit_rate_x18: string;
|
|
246
|
-
}
|
|
247
|
-
interface EngineServerMinDepositRatesResponse {
|
|
248
|
-
min_deposit_rates: Record<number, EngineServerMinDepositRate>;
|
|
249
|
-
}
|
|
250
241
|
interface EngineServerEdgeAllProductsResponse {
|
|
251
242
|
edge_all_products: Record<number, EngineServerAllProductsResponse>;
|
|
252
243
|
}
|
|
@@ -268,7 +259,6 @@ interface EngineServerQueryResponseByType {
|
|
|
268
259
|
max_nlp_mintable: EngineServerMaxMintNlpResponse;
|
|
269
260
|
max_order_size: EngineServerMaxOrderSizeResponse;
|
|
270
261
|
max_withdrawable: EngineServerMaxWithdrawableResponse;
|
|
271
|
-
min_deposit_rates: EngineServerMinDepositRatesResponse;
|
|
272
262
|
nonces: EngineServerNoncesResponse;
|
|
273
263
|
order: EngineServerOrderResponse;
|
|
274
264
|
orders: EngineServerProductOrdersResponse;
|
|
@@ -289,4 +279,4 @@ interface EngineServerQueryFailureResponse {
|
|
|
289
279
|
}
|
|
290
280
|
type EngineServerQueryResponse<TQueryType extends keyof EngineServerQueryResponseByType = EngineServerQueryRequestType> = EngineServerQuerySuccessResponse<TQueryType> | EngineServerQueryFailureResponse;
|
|
291
281
|
|
|
292
|
-
export type { EngineInsuranceResponse, EngineServerAllProductsResponse, EngineServerContractsResponse, EngineServerEdgeAllProductsResponse, EngineServerFeeRatesResponse, EngineServerGetOrderQueryParams, EngineServerHealthGroupsResponse, EngineServerIpBlockResponse, EngineServerIsolatedPosition, EngineServerIsolatedPositionsQueryParams, EngineServerIsolatedPositionsResponse, EngineServerLinkedSignerParams, EngineServerLinkedSignerResponse, EngineServerMarketLiquidityQueryParams, EngineServerMarketLiquidityResponse, EngineServerMarketPrice, EngineServerMarketPriceQueryParams, EngineServerMarketPriceResponse, EngineServerMarketPricesQueryParams, EngineServerMarketPricesResponse, EngineServerMaxMintNlpQueryParams, EngineServerMaxMintNlpResponse, EngineServerMaxOrderSizeQueryParams, EngineServerMaxOrderSizeResponse, EngineServerMaxWithdrawableQueryParams, EngineServerMaxWithdrawableResponse,
|
|
282
|
+
export type { EngineInsuranceResponse, EngineServerAllProductsResponse, EngineServerContractsResponse, EngineServerEdgeAllProductsResponse, EngineServerFeeRatesResponse, EngineServerGetOrderQueryParams, EngineServerHealthGroupsResponse, EngineServerIpBlockResponse, EngineServerIsolatedPosition, EngineServerIsolatedPositionsQueryParams, EngineServerIsolatedPositionsResponse, EngineServerLinkedSignerParams, EngineServerLinkedSignerResponse, EngineServerMarketLiquidityQueryParams, EngineServerMarketLiquidityResponse, EngineServerMarketPrice, EngineServerMarketPriceQueryParams, EngineServerMarketPriceResponse, EngineServerMarketPricesQueryParams, EngineServerMarketPricesResponse, EngineServerMaxMintNlpQueryParams, EngineServerMaxMintNlpResponse, EngineServerMaxOrderSizeQueryParams, EngineServerMaxOrderSizeResponse, EngineServerMaxWithdrawableQueryParams, EngineServerMaxWithdrawableResponse, EngineServerNoncesParams, EngineServerNoncesResponse, EngineServerOrder, EngineServerOrderResponse, EngineServerOrdersQueryParams, EngineServerPriceTickLiquidity, EngineServerProductOrdersResponse, EngineServerQueryFailureResponse, EngineServerQueryRequest, EngineServerQueryRequestByType, EngineServerQueryRequestType, EngineServerQueryResponse, EngineServerQueryResponseByType, EngineServerQuerySuccessResponse, EngineServerStatusResponse, EngineServerSubaccountFeeRatesParams, EngineServerSubaccountInfoQueryParams, EngineServerSubaccountInfoResponse, EngineServerSubaccountOrders, EngineServerSubaccountOrdersQueryParams, EngineServerSubaccountOrdersResponse, EngineServerSymbol, EngineServerSymbolsQueryParams, EngineServerSymbolsResponse, EngineServerTimeResponse, EngineServerValidateOrderQueryParams, EngineServerValidateOrderResponse };
|
package/dist/utils/index.d.cts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
export { mapEngineMarketPrice, mapEngineServerBalanceHealthContributions, mapEngineServerIsolatedPositions, mapEngineServerOrder, mapEngineServerPerpProduct, mapEngineServerSpotProduct, mapEngineServerSymbol, mapEngineServerSymbols, mapEngineServerTickLiquidity, mapSubaccountSummary } from './queryDataMappers.cjs';
|
|
2
|
-
import '@nadohq/
|
|
2
|
+
import '@nadohq/shared';
|
|
3
3
|
import '../types/clientQueryTypes.cjs';
|
|
4
|
-
import '@nadohq/utils';
|
|
5
4
|
import '../types/serverQueryTypes.cjs';
|
|
6
5
|
import '../types/serverQueryModelTypes.cjs';
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
export { mapEngineMarketPrice, mapEngineServerBalanceHealthContributions, mapEngineServerIsolatedPositions, mapEngineServerOrder, mapEngineServerPerpProduct, mapEngineServerSpotProduct, mapEngineServerSymbol, mapEngineServerSymbols, mapEngineServerTickLiquidity, mapSubaccountSummary } from './queryDataMappers.js';
|
|
2
|
-
import '@nadohq/
|
|
2
|
+
import '@nadohq/shared';
|
|
3
3
|
import '../types/clientQueryTypes.js';
|
|
4
|
-
import '@nadohq/utils';
|
|
5
4
|
import '../types/serverQueryTypes.js';
|
|
6
5
|
import '../types/serverQueryModelTypes.js';
|
|
@@ -24,21 +24,21 @@ __export(productEngineTypeMappers_exports, {
|
|
|
24
24
|
mapProductEngineType: () => mapProductEngineType
|
|
25
25
|
});
|
|
26
26
|
module.exports = __toCommonJS(productEngineTypeMappers_exports);
|
|
27
|
-
var
|
|
27
|
+
var import_shared = require("@nadohq/shared");
|
|
28
28
|
function mapProductEngineType(productEngineType) {
|
|
29
29
|
switch (productEngineType) {
|
|
30
|
-
case
|
|
30
|
+
case import_shared.ProductEngineType.SPOT:
|
|
31
31
|
return "spot";
|
|
32
|
-
case
|
|
32
|
+
case import_shared.ProductEngineType.PERP:
|
|
33
33
|
return "perp";
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
36
|
function mapEngineServerProductType(productEngineServerType) {
|
|
37
37
|
switch (productEngineServerType) {
|
|
38
38
|
case "spot":
|
|
39
|
-
return
|
|
39
|
+
return import_shared.ProductEngineType.SPOT;
|
|
40
40
|
case "perp":
|
|
41
|
-
return
|
|
41
|
+
return import_shared.ProductEngineType.PERP;
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
44
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utils/productEngineTypeMappers.ts"],"sourcesContent":["import { ProductEngineType } from '@nadohq/
|
|
1
|
+
{"version":3,"sources":["../../src/utils/productEngineTypeMappers.ts"],"sourcesContent":["import { ProductEngineType } from '@nadohq/shared';\nimport { EngineServerProductType } from '../types';\n\nexport function mapProductEngineType(\n productEngineType: ProductEngineType,\n): EngineServerProductType {\n switch (productEngineType) {\n case ProductEngineType.SPOT:\n return 'spot';\n case ProductEngineType.PERP:\n return 'perp';\n }\n}\n\nexport function mapEngineServerProductType(\n productEngineServerType: EngineServerProductType,\n): ProductEngineType {\n switch (productEngineServerType) {\n case 'spot':\n return ProductEngineType.SPOT;\n case 'perp':\n return ProductEngineType.PERP;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAAkC;AAG3B,SAAS,qBACd,mBACyB;AACzB,UAAQ,mBAAmB;AAAA,IACzB,KAAK,gCAAkB;AACrB,aAAO;AAAA,IACT,KAAK,gCAAkB;AACrB,aAAO;AAAA,EACX;AACF;AAEO,SAAS,2BACd,yBACmB;AACnB,UAAQ,yBAAyB;AAAA,IAC/B,KAAK;AACH,aAAO,gCAAkB;AAAA,IAC3B,KAAK;AACH,aAAO,gCAAkB;AAAA,EAC7B;AACF;","names":[]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ProductEngineType } from '@nadohq/
|
|
1
|
+
import { ProductEngineType } from '@nadohq/shared';
|
|
2
2
|
import { EngineServerProductType } from '../types/serverQueryModelTypes.cjs';
|
|
3
3
|
|
|
4
4
|
declare function mapProductEngineType(productEngineType: ProductEngineType): EngineServerProductType;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ProductEngineType } from '@nadohq/
|
|
1
|
+
import { ProductEngineType } from '@nadohq/shared';
|
|
2
2
|
import { EngineServerProductType } from '../types/serverQueryModelTypes.js';
|
|
3
3
|
|
|
4
4
|
declare function mapProductEngineType(productEngineType: ProductEngineType): EngineServerProductType;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utils/productEngineTypeMappers.ts"],"sourcesContent":["import { ProductEngineType } from '@nadohq/
|
|
1
|
+
{"version":3,"sources":["../../src/utils/productEngineTypeMappers.ts"],"sourcesContent":["import { ProductEngineType } from '@nadohq/shared';\nimport { EngineServerProductType } from '../types';\n\nexport function mapProductEngineType(\n productEngineType: ProductEngineType,\n): EngineServerProductType {\n switch (productEngineType) {\n case ProductEngineType.SPOT:\n return 'spot';\n case ProductEngineType.PERP:\n return 'perp';\n }\n}\n\nexport function mapEngineServerProductType(\n productEngineServerType: EngineServerProductType,\n): ProductEngineType {\n switch (productEngineServerType) {\n case 'spot':\n return ProductEngineType.SPOT;\n case 'perp':\n return ProductEngineType.PERP;\n }\n}\n"],"mappings":";AAAA,SAAS,yBAAyB;AAG3B,SAAS,qBACd,mBACyB;AACzB,UAAQ,mBAAmB;AAAA,IACzB,KAAK,kBAAkB;AACrB,aAAO;AAAA,IACT,KAAK,kBAAkB;AACrB,aAAO;AAAA,EACX;AACF;AAEO,SAAS,2BACd,yBACmB;AACnB,UAAQ,yBAAyB;AAAA,IAC/B,KAAK;AACH,aAAO,kBAAkB;AAAA,IAC3B,KAAK;AACH,aAAO,kBAAkB;AAAA,EAC7B;AACF;","names":[]}
|
|
@@ -32,73 +32,62 @@ __export(queryDataMappers_exports, {
|
|
|
32
32
|
mapSubaccountSummary: () => mapSubaccountSummary
|
|
33
33
|
});
|
|
34
34
|
module.exports = __toCommonJS(queryDataMappers_exports);
|
|
35
|
-
var
|
|
36
|
-
var import_utils = require("@nadohq/utils");
|
|
35
|
+
var import_shared = require("@nadohq/shared");
|
|
37
36
|
var import_productEngineTypeMappers = require("./productEngineTypeMappers.cjs");
|
|
38
37
|
function mapEngineServerTickLiquidity(tick) {
|
|
39
38
|
return {
|
|
40
|
-
price: (0,
|
|
41
|
-
liquidity: (0,
|
|
39
|
+
price: (0, import_shared.removeDecimals)(tick[0]),
|
|
40
|
+
liquidity: (0, import_shared.toBigDecimal)(tick[1])
|
|
42
41
|
};
|
|
43
42
|
}
|
|
44
43
|
function mapEngineServerOrder(order) {
|
|
45
|
-
const subaccount = (0,
|
|
44
|
+
const subaccount = (0, import_shared.subaccountFromHex)(order.sender);
|
|
46
45
|
return {
|
|
47
46
|
digest: order.digest,
|
|
48
|
-
expiration: (
|
|
47
|
+
expiration: Number(order.expiration),
|
|
49
48
|
nonce: order.nonce,
|
|
50
|
-
price: (0,
|
|
49
|
+
price: (0, import_shared.removeDecimals)(order.price_x18),
|
|
51
50
|
productId: order.product_id,
|
|
52
51
|
subaccountOwner: subaccount.subaccountOwner,
|
|
53
52
|
subaccountName: subaccount.subaccountName,
|
|
54
|
-
totalAmount: (0,
|
|
55
|
-
unfilledAmount: (0,
|
|
56
|
-
margin: order.margin ? (0, import_utils.toBigDecimal)(order.margin) : null,
|
|
57
|
-
// Standardizes from hex
|
|
58
|
-
// toFixed is required as toString gives values with `e`
|
|
59
|
-
orderParams: {
|
|
60
|
-
amount: (0, import_utils.toIntegerString)(order.amount),
|
|
61
|
-
expiration: (0, import_utils.toIntegerString)(order.expiration),
|
|
62
|
-
nonce: order.nonce,
|
|
63
|
-
price: (0, import_utils.toIntegerString)((0, import_utils.removeDecimals)(order.price_x18)),
|
|
64
|
-
subaccountOwner: subaccount.subaccountOwner,
|
|
65
|
-
subaccountName: subaccount.subaccountName
|
|
66
|
-
},
|
|
53
|
+
totalAmount: (0, import_shared.toBigDecimal)(order.amount),
|
|
54
|
+
unfilledAmount: (0, import_shared.toBigDecimal)(order.unfilled_amount),
|
|
67
55
|
placementTime: order.placed_at,
|
|
68
|
-
|
|
56
|
+
appendix: (0, import_shared.unpackOrderAppendix)(order.appendix)
|
|
69
57
|
};
|
|
70
58
|
}
|
|
71
59
|
function mapEngineServerSpotProduct(product) {
|
|
72
60
|
return {
|
|
73
|
-
type:
|
|
61
|
+
type: import_shared.ProductEngineType.SPOT,
|
|
74
62
|
productId: product.product_id,
|
|
75
|
-
minSize: (0,
|
|
76
|
-
priceIncrement: (0,
|
|
77
|
-
sizeIncrement: (0,
|
|
63
|
+
minSize: (0, import_shared.toBigDecimal)(product.book_info.min_size),
|
|
64
|
+
priceIncrement: (0, import_shared.removeDecimals)(product.book_info.price_increment_x18),
|
|
65
|
+
sizeIncrement: (0, import_shared.toBigDecimal)(product.book_info.size_increment),
|
|
78
66
|
product: {
|
|
79
67
|
productId: product.product_id,
|
|
80
|
-
type:
|
|
81
|
-
totalBorrowed: (0,
|
|
68
|
+
type: import_shared.ProductEngineType.SPOT,
|
|
69
|
+
totalBorrowed: (0, import_shared.calcTotalBorrowed)(
|
|
82
70
|
product.state.total_borrows_normalized,
|
|
83
71
|
product.state.cumulative_borrows_multiplier_x18
|
|
84
72
|
),
|
|
85
|
-
totalDeposited: (0,
|
|
73
|
+
totalDeposited: (0, import_shared.calcTotalDeposited)(
|
|
86
74
|
product.state.total_deposits_normalized,
|
|
87
75
|
product.state.cumulative_deposits_multiplier_x18
|
|
88
76
|
),
|
|
89
|
-
oraclePrice: (0,
|
|
90
|
-
interestFloor: (0,
|
|
91
|
-
interestInflectionUtil: (0,
|
|
77
|
+
oraclePrice: (0, import_shared.removeDecimals)(product.oracle_price_x18),
|
|
78
|
+
interestFloor: (0, import_shared.removeDecimals)(product.config.interest_floor_x18),
|
|
79
|
+
interestInflectionUtil: (0, import_shared.removeDecimals)(
|
|
92
80
|
product.config.interest_inflection_util_x18
|
|
93
81
|
),
|
|
94
|
-
interestLargeCap: (0,
|
|
95
|
-
interestSmallCap: (0,
|
|
96
|
-
|
|
97
|
-
|
|
82
|
+
interestLargeCap: (0, import_shared.removeDecimals)(product.config.interest_large_cap_x18),
|
|
83
|
+
interestSmallCap: (0, import_shared.removeDecimals)(product.config.interest_small_cap_x18),
|
|
84
|
+
minDepositRate: (0, import_shared.removeDecimals)(product.config.min_deposit_rate_x18),
|
|
85
|
+
longWeightInitial: (0, import_shared.removeDecimals)(product.risk.long_weight_initial_x18),
|
|
86
|
+
longWeightMaintenance: (0, import_shared.removeDecimals)(
|
|
98
87
|
product.risk.long_weight_maintenance_x18
|
|
99
88
|
),
|
|
100
|
-
shortWeightInitial: (0,
|
|
101
|
-
shortWeightMaintenance: (0,
|
|
89
|
+
shortWeightInitial: (0, import_shared.removeDecimals)(product.risk.short_weight_initial_x18),
|
|
90
|
+
shortWeightMaintenance: (0, import_shared.removeDecimals)(
|
|
102
91
|
product.risk.short_weight_maintenance_x18
|
|
103
92
|
),
|
|
104
93
|
tokenAddr: product.config.token
|
|
@@ -107,28 +96,28 @@ function mapEngineServerSpotProduct(product) {
|
|
|
107
96
|
}
|
|
108
97
|
function mapEngineServerPerpProduct(product) {
|
|
109
98
|
return {
|
|
110
|
-
type:
|
|
99
|
+
type: import_shared.ProductEngineType.PERP,
|
|
111
100
|
productId: product.product_id,
|
|
112
|
-
minSize: (0,
|
|
113
|
-
priceIncrement: (0,
|
|
114
|
-
sizeIncrement: (0,
|
|
101
|
+
minSize: (0, import_shared.toBigDecimal)(product.book_info.min_size),
|
|
102
|
+
priceIncrement: (0, import_shared.removeDecimals)(product.book_info.price_increment_x18),
|
|
103
|
+
sizeIncrement: (0, import_shared.toBigDecimal)(product.book_info.size_increment),
|
|
115
104
|
product: {
|
|
116
105
|
productId: product.product_id,
|
|
117
|
-
type:
|
|
118
|
-
oraclePrice: (0,
|
|
119
|
-
longWeightInitial: (0,
|
|
120
|
-
longWeightMaintenance: (0,
|
|
106
|
+
type: import_shared.ProductEngineType.PERP,
|
|
107
|
+
oraclePrice: (0, import_shared.removeDecimals)(product.oracle_price_x18),
|
|
108
|
+
longWeightInitial: (0, import_shared.removeDecimals)(product.risk.long_weight_initial_x18),
|
|
109
|
+
longWeightMaintenance: (0, import_shared.removeDecimals)(
|
|
121
110
|
product.risk.long_weight_maintenance_x18
|
|
122
111
|
),
|
|
123
|
-
shortWeightInitial: (0,
|
|
124
|
-
shortWeightMaintenance: (0,
|
|
112
|
+
shortWeightInitial: (0, import_shared.removeDecimals)(product.risk.short_weight_initial_x18),
|
|
113
|
+
shortWeightMaintenance: (0, import_shared.removeDecimals)(
|
|
125
114
|
product.risk.short_weight_maintenance_x18
|
|
126
115
|
),
|
|
127
|
-
openInterest: (0,
|
|
128
|
-
cumulativeFundingLong: (0,
|
|
116
|
+
openInterest: (0, import_shared.toBigDecimal)(product.state.open_interest),
|
|
117
|
+
cumulativeFundingLong: (0, import_shared.removeDecimals)(
|
|
129
118
|
product.state.cumulative_funding_long_x18
|
|
130
119
|
),
|
|
131
|
-
cumulativeFundingShort: (0,
|
|
120
|
+
cumulativeFundingShort: (0, import_shared.removeDecimals)(
|
|
132
121
|
product.state.cumulative_funding_short_x18
|
|
133
122
|
)
|
|
134
123
|
}
|
|
@@ -136,9 +125,9 @@ function mapEngineServerPerpProduct(product) {
|
|
|
136
125
|
}
|
|
137
126
|
function mapEngineServerBalanceHealthContributions(healthContributionsForBalance) {
|
|
138
127
|
return {
|
|
139
|
-
initial: (0,
|
|
140
|
-
maintenance: (0,
|
|
141
|
-
unweighted: (0,
|
|
128
|
+
initial: (0, import_shared.toBigDecimal)(healthContributionsForBalance[0]),
|
|
129
|
+
maintenance: (0, import_shared.toBigDecimal)(healthContributionsForBalance[1]),
|
|
130
|
+
unweighted: (0, import_shared.toBigDecimal)(healthContributionsForBalance[2])
|
|
142
131
|
};
|
|
143
132
|
}
|
|
144
133
|
function mapSubaccountSummary(baseResponse) {
|
|
@@ -151,7 +140,7 @@ function mapSubaccountSummary(baseResponse) {
|
|
|
151
140
|
throw Error(`Could not find product ${spotBalance.product_id}`);
|
|
152
141
|
}
|
|
153
142
|
balances.push({
|
|
154
|
-
amount: (0,
|
|
143
|
+
amount: (0, import_shared.toBigDecimal)(spotBalance.balance.amount),
|
|
155
144
|
healthContributions: mapEngineServerBalanceHealthContributions(
|
|
156
145
|
baseResponse.health_contributions[spotBalance.product_id]
|
|
157
146
|
),
|
|
@@ -166,8 +155,8 @@ function mapSubaccountSummary(baseResponse) {
|
|
|
166
155
|
throw Error(`Could not find product ${perpBalance.product_id}`);
|
|
167
156
|
}
|
|
168
157
|
balances.push({
|
|
169
|
-
amount: (0,
|
|
170
|
-
vQuoteBalance: (0,
|
|
158
|
+
amount: (0, import_shared.toBigDecimal)(perpBalance.balance.amount),
|
|
159
|
+
vQuoteBalance: (0, import_shared.toBigDecimal)(perpBalance.balance.v_quote_balance),
|
|
171
160
|
healthContributions: mapEngineServerBalanceHealthContributions(
|
|
172
161
|
baseResponse.health_contributions[perpBalance.product_id]
|
|
173
162
|
),
|
|
@@ -179,19 +168,19 @@ function mapSubaccountSummary(baseResponse) {
|
|
|
179
168
|
exists: baseResponse.exists,
|
|
180
169
|
health: {
|
|
181
170
|
initial: {
|
|
182
|
-
health: (0,
|
|
183
|
-
assets: (0,
|
|
184
|
-
liabilities: (0,
|
|
171
|
+
health: (0, import_shared.toBigDecimal)(baseResponse.healths[0].health),
|
|
172
|
+
assets: (0, import_shared.toBigDecimal)(baseResponse.healths[0].assets),
|
|
173
|
+
liabilities: (0, import_shared.toBigDecimal)(baseResponse.healths[0].liabilities)
|
|
185
174
|
},
|
|
186
175
|
maintenance: {
|
|
187
|
-
health: (0,
|
|
188
|
-
assets: (0,
|
|
189
|
-
liabilities: (0,
|
|
176
|
+
health: (0, import_shared.toBigDecimal)(baseResponse.healths[1].health),
|
|
177
|
+
assets: (0, import_shared.toBigDecimal)(baseResponse.healths[1].assets),
|
|
178
|
+
liabilities: (0, import_shared.toBigDecimal)(baseResponse.healths[1].liabilities)
|
|
190
179
|
},
|
|
191
180
|
unweighted: {
|
|
192
|
-
health: (0,
|
|
193
|
-
assets: (0,
|
|
194
|
-
liabilities: (0,
|
|
181
|
+
health: (0, import_shared.toBigDecimal)(baseResponse.healths[2].health),
|
|
182
|
+
assets: (0, import_shared.toBigDecimal)(baseResponse.healths[2].assets),
|
|
183
|
+
liabilities: (0, import_shared.toBigDecimal)(baseResponse.healths[2].liabilities)
|
|
195
184
|
}
|
|
196
185
|
}
|
|
197
186
|
};
|
|
@@ -201,29 +190,29 @@ function mapEngineServerIsolatedPositions(baseResponse) {
|
|
|
201
190
|
const perpBalance = position.base_balance;
|
|
202
191
|
const quoteBalance = position.quote_balance;
|
|
203
192
|
return {
|
|
204
|
-
subaccount: (0,
|
|
193
|
+
subaccount: (0, import_shared.subaccountFromHex)(position.subaccount),
|
|
205
194
|
healths: {
|
|
206
|
-
initial: (0,
|
|
207
|
-
maintenance: (0,
|
|
208
|
-
unweighted: (0,
|
|
195
|
+
initial: (0, import_shared.toBigDecimal)(position.healths[0].health),
|
|
196
|
+
maintenance: (0, import_shared.toBigDecimal)(position.healths[1].health),
|
|
197
|
+
unweighted: (0, import_shared.toBigDecimal)(position.healths[2].health)
|
|
209
198
|
},
|
|
210
199
|
baseBalance: {
|
|
211
|
-
amount: (0,
|
|
212
|
-
vQuoteBalance: (0,
|
|
200
|
+
amount: (0, import_shared.toBigDecimal)(perpBalance.balance.amount),
|
|
201
|
+
vQuoteBalance: (0, import_shared.toBigDecimal)(perpBalance.balance.v_quote_balance),
|
|
213
202
|
// Health contributions === healths for an isolated position
|
|
214
203
|
healthContributions: {
|
|
215
|
-
initial: (0,
|
|
216
|
-
maintenance: (0,
|
|
217
|
-
unweighted: (0,
|
|
204
|
+
initial: (0, import_shared.toBigDecimal)(position.base_healths[0]),
|
|
205
|
+
maintenance: (0, import_shared.toBigDecimal)(position.base_healths[1]),
|
|
206
|
+
unweighted: (0, import_shared.toBigDecimal)(position.base_healths[2])
|
|
218
207
|
},
|
|
219
208
|
...mapEngineServerPerpProduct(position.base_product).product
|
|
220
209
|
},
|
|
221
210
|
quoteBalance: {
|
|
222
|
-
amount: (0,
|
|
211
|
+
amount: (0, import_shared.toBigDecimal)(quoteBalance.balance.amount),
|
|
223
212
|
healthContributions: {
|
|
224
|
-
initial: (0,
|
|
225
|
-
maintenance: (0,
|
|
226
|
-
unweighted: (0,
|
|
213
|
+
initial: (0, import_shared.toBigDecimal)(position.quote_healths[0]),
|
|
214
|
+
maintenance: (0, import_shared.toBigDecimal)(position.quote_healths[1]),
|
|
215
|
+
unweighted: (0, import_shared.toBigDecimal)(position.quote_healths[2])
|
|
227
216
|
},
|
|
228
217
|
...mapEngineServerSpotProduct(position.quote_product).product
|
|
229
218
|
}
|
|
@@ -231,7 +220,7 @@ function mapEngineServerIsolatedPositions(baseResponse) {
|
|
|
231
220
|
});
|
|
232
221
|
}
|
|
233
222
|
function mapEngineServerSymbols(baseResponse) {
|
|
234
|
-
const symbols = (0,
|
|
223
|
+
const symbols = (0, import_shared.mapValues)(
|
|
235
224
|
baseResponse.symbols,
|
|
236
225
|
mapEngineServerSymbol
|
|
237
226
|
);
|
|
@@ -244,25 +233,25 @@ function mapEngineServerSymbol(engineServerSymbol) {
|
|
|
244
233
|
type: (0, import_productEngineTypeMappers.mapEngineServerProductType)(engineServerSymbol.type),
|
|
245
234
|
productId: engineServerSymbol.product_id,
|
|
246
235
|
symbol: engineServerSymbol.symbol,
|
|
247
|
-
priceIncrement: (0,
|
|
248
|
-
sizeIncrement: (0,
|
|
249
|
-
minSize: (0,
|
|
250
|
-
minDepth: (0,
|
|
251
|
-
maxSpreadRate: (0,
|
|
252
|
-
makerFeeRate: (0,
|
|
253
|
-
takerFeeRate: (0,
|
|
254
|
-
longWeightInitial: (0,
|
|
236
|
+
priceIncrement: (0, import_shared.removeDecimals)(engineServerSymbol.price_increment_x18),
|
|
237
|
+
sizeIncrement: (0, import_shared.toBigDecimal)(engineServerSymbol.size_increment),
|
|
238
|
+
minSize: (0, import_shared.toBigDecimal)(engineServerSymbol.min_size),
|
|
239
|
+
minDepth: (0, import_shared.removeDecimals)(engineServerSymbol.min_depth_x18),
|
|
240
|
+
maxSpreadRate: (0, import_shared.removeDecimals)(engineServerSymbol.max_spread_rate_x18),
|
|
241
|
+
makerFeeRate: (0, import_shared.removeDecimals)(engineServerSymbol.maker_fee_rate_x18),
|
|
242
|
+
takerFeeRate: (0, import_shared.removeDecimals)(engineServerSymbol.taker_fee_rate_x18),
|
|
243
|
+
longWeightInitial: (0, import_shared.removeDecimals)(
|
|
255
244
|
engineServerSymbol.long_weight_initial_x18
|
|
256
245
|
),
|
|
257
|
-
longWeightMaintenance: (0,
|
|
246
|
+
longWeightMaintenance: (0, import_shared.removeDecimals)(
|
|
258
247
|
engineServerSymbol.long_weight_maintenance_x18
|
|
259
248
|
)
|
|
260
249
|
};
|
|
261
250
|
}
|
|
262
251
|
function mapEngineMarketPrice(baseResponse) {
|
|
263
252
|
return {
|
|
264
|
-
ask: (0,
|
|
265
|
-
bid: (0,
|
|
253
|
+
ask: (0, import_shared.removeDecimals)(baseResponse.ask_x18),
|
|
254
|
+
bid: (0, import_shared.removeDecimals)(baseResponse.bid_x18),
|
|
266
255
|
productId: baseResponse.product_id
|
|
267
256
|
};
|
|
268
257
|
}
|