@nadohq/engine-client 0.1.0-alpha.36 → 0.1.0-alpha.38

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.
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/types/clientQueryTypes.ts"],"sourcesContent":["import {\n BalanceHealthContributions,\n BalanceSide,\n BalanceWithProduct,\n BigDecimal,\n EIP712OrderParams,\n HealthGroup,\n HealthStatusByType,\n MarketWithProduct,\n OrderAppendix,\n PerpBalanceWithProduct,\n ProductEngineType,\n SignedEIP712OrderParams,\n SpotBalanceWithProduct,\n Subaccount,\n} from '@nadohq/shared';\nimport {\n EngineServerNoncesParams,\n EngineServerTimeResponse,\n} from './serverQueryTypes';\n\nexport interface GetEngineSubaccountSummaryResponse {\n exists: boolean;\n balances: BalanceWithProduct[];\n health: HealthStatusByType;\n}\n\nexport type GetEngineSubaccountSummaryParams = Subaccount;\n\nexport type GetEngineIsolatedPositionsParams = Subaccount;\n\nexport interface SubaccountIsolatedPosition {\n subaccount: Subaccount;\n healths: BalanceHealthContributions;\n quoteBalance: SpotBalanceWithProduct;\n baseBalance: PerpBalanceWithProduct;\n}\n\nexport type GetEngineIsolatedPositionsResponse = SubaccountIsolatedPosition[];\n\nexport type SubaccountTx = {\n type: 'apply_delta';\n tx: SubaccountProductDeltaTx;\n};\n\nexport interface SubaccountProductDeltaTx {\n productId: number;\n amountDelta: BigDecimal;\n vQuoteDelta: BigDecimal;\n}\n\nexport interface GetEngineContractsResponse {\n chainId: number;\n endpointAddr: string;\n}\n\nexport type GetEngineEstimatedSubaccountSummaryParams = Subaccount & {\n txs: SubaccountTx[];\n};\n\nexport type GetEngineNoncesParams = EngineServerNoncesParams;\n\nexport interface GetEngineNoncesResponse {\n orderNonce: string;\n txNonce: string;\n}\n\nexport interface GetEngineSymbolsParams {\n productType?: ProductEngineType;\n productIds?: number[];\n}\n\nexport interface EngineSymbolsResponse {\n // mapping of product symbol to symbols info\n symbols: Record<string, EngineSymbol>;\n}\n\nexport interface EngineSymbol {\n type: ProductEngineType;\n productId: number;\n symbol: string;\n priceIncrement: BigDecimal;\n sizeIncrement: BigDecimal;\n minSize: BigDecimal;\n minDepth: BigDecimal;\n maxSpreadRate: BigDecimal;\n makerFeeRate: BigDecimal;\n takerFeeRate: BigDecimal;\n longWeightInitial: BigDecimal;\n longWeightMaintenance: BigDecimal;\n}\n\nexport type GetEngineAllMarketsResponse = MarketWithProduct[];\n\nexport interface GetEngineHealthGroupsResponse {\n healthGroups: HealthGroup[];\n}\n\nexport interface GetEngineOrderParams {\n productId: number;\n digest: string;\n}\n\nexport interface EngineOrder extends Subaccount {\n productId: number;\n price: BigDecimal;\n // Amount initially requested\n totalAmount: BigDecimal;\n // Amount still unfilled\n unfilledAmount: BigDecimal;\n expiration: number;\n nonce: string;\n digest: string;\n placementTime: number;\n appendix: OrderAppendix;\n}\n\nexport type GetEngineOrderResponse = EngineOrder;\n\nexport interface ValidateSignedEngineOrderParams {\n productId: number;\n signedOrder: SignedEIP712OrderParams;\n}\n\nexport interface ValidateEngineOrderParams {\n productId: number;\n chainId: number;\n order: EIP712OrderParams;\n}\n\nexport interface ValidateEngineOrderResponse {\n productId: number;\n valid: boolean;\n}\n\nexport interface GetEngineSubaccountOrdersParams extends Subaccount {\n productId: number;\n}\n\nexport interface EngineSubaccountOrders {\n productId: number;\n orders: EngineOrder[];\n}\n\nexport type GetEngineSubaccountOrdersResponse = EngineSubaccountOrders;\n\nexport interface GetEngineSubaccountProductOrdersParams extends Subaccount {\n productIds: number[];\n}\n\nexport interface GetEngineSubaccountProductOrdersResponse {\n productOrders: EngineSubaccountOrders[];\n}\n\nexport type GetEngineSubaccountFeeRatesParams = Subaccount;\n\nexport interface SubaccountOrderFeeRates {\n maker: BigDecimal;\n taker: BigDecimal;\n}\n\nexport interface GetEngineSubaccountFeeRatesResponse {\n // By Product ID\n orders: Record<number, SubaccountOrderFeeRates>;\n withdrawal: Record<number, BigDecimal>;\n liquidationSequencerFee: BigDecimal;\n healthCheckSequencerFee: BigDecimal;\n takerSequencerFee: BigDecimal;\n feeTier: number;\n}\n\nexport interface EnginePriceTickLiquidity {\n price: BigDecimal;\n liquidity: BigDecimal;\n}\n\nexport interface GetEngineMarketLiquidityParams {\n productId: number;\n // The minimum depth in base price ticks (i.e. per side\n depth: number;\n}\n\nexport interface GetEngineMarketLiquidityResponse {\n bids: EnginePriceTickLiquidity[];\n asks: EnginePriceTickLiquidity[];\n}\n\nexport interface GetEngineMarketPriceParams {\n productId: number;\n}\n\nexport interface EngineMarketPrice {\n productId: number;\n bid: BigDecimal;\n ask: BigDecimal;\n}\n\nexport type GetEngineMarketPriceResponse = EngineMarketPrice;\n\nexport interface GetEngineMarketPricesParams {\n productIds: number[];\n}\n\nexport interface GetEngineMarketPricesResponse {\n marketPrices: EngineMarketPrice[];\n}\n\nexport interface GetEngineMaxOrderSizeParams extends Subaccount {\n price: BigDecimal;\n productId: number;\n // Note: When `reduceOnly` is true, `side` must be opposite of the current position, otherwise it returns 0.\n side: BalanceSide;\n // If not given, engine defaults to true (leverage/borrow enabled) for spot\n // Do not pass this for perp products\n spotLeverage?: boolean;\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 reduceOnly?: boolean;\n isolated?: boolean;\n // If not given, engine defaults to true (do not borrow margin for isolated orders)\n // Max order size query for `isolated` includes available transfer from the cross subaccount\n isoBorrowMargin?: boolean;\n}\n\nexport type GetEngineMaxOrderSizeResponse = BigDecimal;\n\nexport interface GetEngineMaxWithdrawableParams extends Subaccount {\n productId: number;\n // If not given, engine defaults to true (leverage/borrow enabled)\n spotLeverage?: boolean;\n}\n\nexport type GetEngineMaxWithdrawableResponse = BigDecimal;\n\nexport type GetEngineTimeResponse = EngineServerTimeResponse;\n\nexport type GetEngineLinkedSignerParams = Subaccount;\n\nexport interface GetEngineLinkedSignerResponse {\n signer: string;\n}\n\nexport type GetEngineInsuranceResponse = BigDecimal;\n\n/**\n * Given an IP, backend will either:\n * - Allow queries only through archive / engine (query_only)\n * - Block all requests (blocked)\n * - Allow all requests (null)\n */\nexport type GetEngineIpBlockStatusResponse = 'query_only' | 'blocked' | null;\n\nexport interface GetEngineMaxMintNlpAmountParams extends Subaccount {\n // If not given, engine defaults to true (leverage/borrow enabled)\n spotLeverage?: boolean;\n}\n\nexport type GetEngineMaxMintNlpAmountResponse = BigDecimal;\n\nexport type GetEngineMaxBurnNlpAmountParams = Subaccount;\n\nexport type GetEngineMaxBurnNlpAmountResponse = BigDecimal;\n\nexport type GetEngineNlpLockedBalancesParams = Subaccount;\n\nexport interface EngineNlpBalance {\n productId: number;\n balance: BigDecimal;\n}\n\nexport interface EngineNlpLockedBalance extends EngineNlpBalance {\n unlockedAt: number;\n}\n\nexport interface GetEngineNlpLockedBalancesResponse {\n lockedBalances: EngineNlpLockedBalance[];\n balanceLocked: EngineNlpBalance;\n balanceUnlocked: EngineNlpBalance;\n}\n\nexport interface NlpPool {\n poolId: number;\n subaccountHex: string;\n ownerAddress: string;\n balanceWeight: BigDecimal;\n subaccountInfo: GetEngineSubaccountSummaryResponse;\n openOrders: EngineOrder[];\n}\n\nexport interface GetEngineNlpPoolInfoResponse {\n nlpPools: NlpPool[];\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
1
+ {"version":3,"sources":["../../src/types/clientQueryTypes.ts"],"sourcesContent":["import {\n BalanceHealthContributions,\n BalanceSide,\n BalanceWithProduct,\n BigDecimal,\n EIP712OrderParams,\n HealthGroup,\n HealthStatusByType,\n MarketWithProduct,\n OrderAppendix,\n PerpBalanceWithProduct,\n ProductEngineType,\n SignedEIP712OrderParams,\n SpotBalanceWithProduct,\n Subaccount,\n} from '@nadohq/shared';\nimport {\n EngineServerNoncesParams,\n EngineServerTimeResponse,\n} from './serverQueryTypes';\n\nexport interface GetEngineSubaccountSummaryResponse {\n exists: boolean;\n balances: BalanceWithProduct[];\n health: HealthStatusByType;\n}\n\nexport type GetEngineSubaccountSummaryParams = Subaccount;\n\nexport type GetEngineIsolatedPositionsParams = Subaccount;\n\nexport interface SubaccountIsolatedPosition {\n subaccount: Subaccount;\n healths: BalanceHealthContributions;\n quoteBalance: SpotBalanceWithProduct;\n baseBalance: PerpBalanceWithProduct;\n}\n\nexport type GetEngineIsolatedPositionsResponse = SubaccountIsolatedPosition[];\n\nexport type SubaccountTx = {\n type: 'apply_delta';\n tx: SubaccountProductDeltaTx;\n};\n\nexport interface SubaccountProductDeltaTx {\n productId: number;\n amountDelta: BigDecimal;\n vQuoteDelta: BigDecimal;\n}\n\nexport interface GetEngineContractsResponse {\n chainId: number;\n endpointAddr: string;\n}\n\nexport type GetEngineEstimatedSubaccountSummaryParams = Subaccount & {\n txs: SubaccountTx[];\n};\n\nexport type GetEngineNoncesParams = EngineServerNoncesParams;\n\nexport interface GetEngineNoncesResponse {\n orderNonce: string;\n txNonce: string;\n}\n\nexport interface GetEngineSymbolsParams {\n productType?: ProductEngineType;\n productIds?: number[];\n}\n\nexport interface EngineSymbolsResponse {\n // mapping of product symbol to symbols info\n symbols: Record<string, EngineSymbol>;\n}\n\nexport interface EngineSymbol {\n type: ProductEngineType;\n productId: number;\n symbol: string;\n priceIncrement: BigDecimal;\n sizeIncrement: BigDecimal;\n minSize: BigDecimal;\n makerFeeRate: BigDecimal;\n takerFeeRate: BigDecimal;\n longWeightInitial: BigDecimal;\n longWeightMaintenance: BigDecimal;\n // undefined when there is no max open interest limit (always undefined for spot products)\n maxOpenInterest: BigDecimal | undefined;\n}\n\nexport type GetEngineAllMarketsResponse = MarketWithProduct[];\n\nexport interface GetEngineHealthGroupsResponse {\n healthGroups: HealthGroup[];\n}\n\nexport interface GetEngineOrderParams {\n productId: number;\n digest: string;\n}\n\nexport interface EngineOrder extends Subaccount {\n productId: number;\n price: BigDecimal;\n // Amount initially requested\n totalAmount: BigDecimal;\n // Amount still unfilled\n unfilledAmount: BigDecimal;\n expiration: number;\n nonce: string;\n digest: string;\n placementTime: number;\n appendix: OrderAppendix;\n}\n\nexport type GetEngineOrderResponse = EngineOrder;\n\nexport interface ValidateSignedEngineOrderParams {\n productId: number;\n signedOrder: SignedEIP712OrderParams;\n}\n\nexport interface ValidateEngineOrderParams {\n productId: number;\n chainId: number;\n order: EIP712OrderParams;\n}\n\nexport interface ValidateEngineOrderResponse {\n productId: number;\n valid: boolean;\n}\n\nexport interface GetEngineSubaccountOrdersParams extends Subaccount {\n productId: number;\n}\n\nexport interface EngineSubaccountOrders {\n productId: number;\n orders: EngineOrder[];\n}\n\nexport type GetEngineSubaccountOrdersResponse = EngineSubaccountOrders;\n\nexport interface GetEngineSubaccountProductOrdersParams extends Subaccount {\n productIds: number[];\n}\n\nexport interface GetEngineSubaccountProductOrdersResponse {\n productOrders: EngineSubaccountOrders[];\n}\n\nexport type GetEngineSubaccountFeeRatesParams = Subaccount;\n\nexport interface SubaccountOrderFeeRates {\n maker: BigDecimal;\n taker: BigDecimal;\n}\n\nexport interface GetEngineSubaccountFeeRatesResponse {\n // By Product ID\n orders: Record<number, SubaccountOrderFeeRates>;\n withdrawal: Record<number, BigDecimal>;\n liquidationSequencerFee: BigDecimal;\n healthCheckSequencerFee: BigDecimal;\n takerSequencerFee: BigDecimal;\n feeTier: number;\n}\n\nexport interface EnginePriceTickLiquidity {\n price: BigDecimal;\n liquidity: BigDecimal;\n}\n\nexport interface GetEngineMarketLiquidityParams {\n productId: number;\n // The minimum depth in base price ticks (i.e. per side\n depth: number;\n}\n\nexport interface GetEngineMarketLiquidityResponse {\n bids: EnginePriceTickLiquidity[];\n asks: EnginePriceTickLiquidity[];\n}\n\nexport interface GetEngineMarketPriceParams {\n productId: number;\n}\n\nexport interface EngineMarketPrice {\n productId: number;\n bid: BigDecimal;\n ask: BigDecimal;\n}\n\nexport type GetEngineMarketPriceResponse = EngineMarketPrice;\n\nexport interface GetEngineMarketPricesParams {\n productIds: number[];\n}\n\nexport interface GetEngineMarketPricesResponse {\n marketPrices: EngineMarketPrice[];\n}\n\nexport interface GetEngineMaxOrderSizeParams extends Subaccount {\n price: BigDecimal;\n productId: number;\n // Note: When `reduceOnly` is true, `side` must be opposite of the current position, otherwise it returns 0.\n side: BalanceSide;\n // If not given, engine defaults to true (leverage/borrow enabled) for spot\n // Do not pass this for perp products\n spotLeverage?: boolean;\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 reduceOnly?: boolean;\n isolated?: boolean;\n // If not given, engine defaults to true (do not borrow margin for isolated orders)\n // Max order size query for `isolated` includes available transfer from the cross subaccount\n isoBorrowMargin?: boolean;\n}\n\nexport type GetEngineMaxOrderSizeResponse = BigDecimal;\n\nexport interface GetEngineMaxWithdrawableParams extends Subaccount {\n productId: number;\n // If not given, engine defaults to true (leverage/borrow enabled)\n spotLeverage?: boolean;\n}\n\nexport type GetEngineMaxWithdrawableResponse = BigDecimal;\n\nexport type GetEngineTimeResponse = EngineServerTimeResponse;\n\nexport type GetEngineLinkedSignerParams = Subaccount;\n\nexport interface GetEngineLinkedSignerResponse {\n signer: string;\n}\n\nexport type GetEngineInsuranceResponse = BigDecimal;\n\n/**\n * Given an IP, backend will either:\n * - Allow queries only through archive / engine (query_only)\n * - Block all requests (blocked)\n * - Allow all requests (null)\n */\nexport type GetEngineIpBlockStatusResponse = 'query_only' | 'blocked' | null;\n\nexport interface GetEngineMaxMintNlpAmountParams extends Subaccount {\n // If not given, engine defaults to true (leverage/borrow enabled)\n spotLeverage?: boolean;\n}\n\nexport type GetEngineMaxMintNlpAmountResponse = BigDecimal;\n\nexport type GetEngineMaxBurnNlpAmountParams = Subaccount;\n\nexport type GetEngineMaxBurnNlpAmountResponse = BigDecimal;\n\nexport type GetEngineNlpLockedBalancesParams = Subaccount;\n\nexport interface EngineNlpBalance {\n productId: number;\n balance: BigDecimal;\n}\n\nexport interface EngineNlpLockedBalance extends EngineNlpBalance {\n unlockedAt: number;\n}\n\nexport interface GetEngineNlpLockedBalancesResponse {\n lockedBalances: EngineNlpLockedBalance[];\n balanceLocked: EngineNlpBalance;\n balanceUnlocked: EngineNlpBalance;\n}\n\nexport interface NlpPool {\n poolId: number;\n subaccountHex: string;\n ownerAddress: string;\n balanceWeight: BigDecimal;\n subaccountInfo: GetEngineSubaccountSummaryResponse;\n openOrders: EngineOrder[];\n}\n\nexport interface GetEngineNlpPoolInfoResponse {\n nlpPools: NlpPool[];\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
@@ -51,12 +51,11 @@ interface EngineSymbol {
51
51
  priceIncrement: BigDecimal;
52
52
  sizeIncrement: BigDecimal;
53
53
  minSize: BigDecimal;
54
- minDepth: BigDecimal;
55
- maxSpreadRate: BigDecimal;
56
54
  makerFeeRate: BigDecimal;
57
55
  takerFeeRate: BigDecimal;
58
56
  longWeightInitial: BigDecimal;
59
57
  longWeightMaintenance: BigDecimal;
58
+ maxOpenInterest: BigDecimal | undefined;
60
59
  }
61
60
  type GetEngineAllMarketsResponse = MarketWithProduct[];
62
61
  interface GetEngineHealthGroupsResponse {
@@ -51,12 +51,11 @@ interface EngineSymbol {
51
51
  priceIncrement: BigDecimal;
52
52
  sizeIncrement: BigDecimal;
53
53
  minSize: BigDecimal;
54
- minDepth: BigDecimal;
55
- maxSpreadRate: BigDecimal;
56
54
  makerFeeRate: BigDecimal;
57
55
  takerFeeRate: BigDecimal;
58
56
  longWeightInitial: BigDecimal;
59
57
  longWeightMaintenance: BigDecimal;
58
+ maxOpenInterest: BigDecimal | undefined;
60
59
  }
61
60
  type GetEngineAllMarketsResponse = MarketWithProduct[];
62
61
  interface GetEngineHealthGroupsResponse {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/types/serverQueryTypes.ts"],"sourcesContent":["import { HealthStatus } from '@nadohq/shared';\nimport {\n EngineServerHealthBreakdown,\n EngineServerNlpBalance,\n EngineServerNlpLockedBalance,\n EngineServerOrder,\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 isolated: string | null;\n // For isolated, max order size includes available collateral to transfer from parent cross subaccount\n // If not given, engine defaults to true (borrow enabled)\n borrow_margin: 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 EngineServerMaxBurnNlpQueryParams {\n sender: string;\n}\n\nexport interface EngineServerNlpLockedBalancesQueryParams {\n subaccount: string;\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_burnable: EngineServerMaxBurnNlpQueryParams;\n max_nlp_mintable: EngineServerMaxMintNlpQueryParams;\n max_order_size: EngineServerMaxOrderSizeQueryParams;\n nlp_locked_balances: EngineServerNlpLockedBalancesQueryParams;\n nlp_pool_info: Record<string, never>;\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 fee_tier: number;\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 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 EngineServerMaxBurnNlpResponse {\n max_nlp_amount: string;\n}\n\nexport interface EngineServerMaxMintNlpResponse {\n max_quote_amount: string;\n}\n\nexport interface EngineServerNlpLockedBalancesResponse {\n balance_locked: EngineServerNlpBalance;\n balance_unlocked: EngineServerNlpBalance;\n locked_balances: EngineServerNlpLockedBalance[];\n}\n\nexport interface EngineServerNlpPool {\n pool_id: number;\n subaccount: string;\n owner: string;\n balance_weight_x18: string;\n subaccount_info: EngineServerSubaccountInfoResponse;\n open_orders: EngineServerOrder[];\n}\n\nexport interface EngineServerNlpPoolInfoResponse {\n nlp_pools: EngineServerNlpPool[];\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_burnable: EngineServerMaxBurnNlpResponse;\n max_nlp_mintable: EngineServerMaxMintNlpResponse;\n max_order_size: EngineServerMaxOrderSizeResponse;\n nlp_locked_balances: EngineServerNlpLockedBalancesResponse;\n nlp_pool_info: EngineServerNlpPoolInfoResponse;\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
+ {"version":3,"sources":["../../src/types/serverQueryTypes.ts"],"sourcesContent":["import { HealthStatus } from '@nadohq/shared';\nimport {\n EngineServerHealthBreakdown,\n EngineServerNlpBalance,\n EngineServerNlpLockedBalance,\n EngineServerOrder,\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 isolated: string | null;\n // For isolated, max order size includes available collateral to transfer from parent cross subaccount\n // If not given, engine defaults to true (borrow enabled)\n borrow_margin: 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 EngineServerMaxBurnNlpQueryParams {\n sender: string;\n}\n\nexport interface EngineServerNlpLockedBalancesQueryParams {\n subaccount: string;\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_burnable: EngineServerMaxBurnNlpQueryParams;\n max_nlp_mintable: EngineServerMaxMintNlpQueryParams;\n max_order_size: EngineServerMaxOrderSizeQueryParams;\n nlp_locked_balances: EngineServerNlpLockedBalancesQueryParams;\n nlp_pool_info: Record<string, never>;\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 maker_fee_rate_x18: string;\n taker_fee_rate_x18: string;\n long_weight_initial_x18: string;\n long_weight_maintenance_x18: string;\n // undefined when there is no max open interest limit (always undefined for spot products)\n max_open_interest_x18: string | undefined;\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 fee_tier: number;\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 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 EngineServerMaxBurnNlpResponse {\n max_nlp_amount: string;\n}\n\nexport interface EngineServerMaxMintNlpResponse {\n max_quote_amount: string;\n}\n\nexport interface EngineServerNlpLockedBalancesResponse {\n balance_locked: EngineServerNlpBalance;\n balance_unlocked: EngineServerNlpBalance;\n locked_balances: EngineServerNlpLockedBalance[];\n}\n\nexport interface EngineServerNlpPool {\n pool_id: number;\n subaccount: string;\n owner: string;\n balance_weight_x18: string;\n subaccount_info: EngineServerSubaccountInfoResponse;\n open_orders: EngineServerOrder[];\n}\n\nexport interface EngineServerNlpPoolInfoResponse {\n nlp_pools: EngineServerNlpPool[];\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_burnable: EngineServerMaxBurnNlpResponse;\n max_nlp_mintable: EngineServerMaxMintNlpResponse;\n max_order_size: EngineServerMaxOrderSizeResponse;\n nlp_locked_balances: EngineServerNlpLockedBalancesResponse;\n nlp_pool_info: EngineServerNlpPoolInfoResponse;\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":[]}
@@ -161,12 +161,11 @@ interface EngineServerSymbol {
161
161
  price_increment_x18: string;
162
162
  size_increment: string;
163
163
  min_size: string;
164
- min_depth_x18: string;
165
- max_spread_rate_x18: string;
166
164
  maker_fee_rate_x18: string;
167
165
  taker_fee_rate_x18: string;
168
166
  long_weight_initial_x18: string;
169
167
  long_weight_maintenance_x18: string;
168
+ max_open_interest_x18: string | undefined;
170
169
  }
171
170
  interface EngineServerSymbolsResponse {
172
171
  symbols: Record<string, EngineServerSymbol>;
@@ -161,12 +161,11 @@ interface EngineServerSymbol {
161
161
  price_increment_x18: string;
162
162
  size_increment: string;
163
163
  min_size: string;
164
- min_depth_x18: string;
165
- max_spread_rate_x18: string;
166
164
  maker_fee_rate_x18: string;
167
165
  taker_fee_rate_x18: string;
168
166
  long_weight_initial_x18: string;
169
167
  long_weight_maintenance_x18: string;
168
+ max_open_interest_x18: string | undefined;
170
169
  }
171
170
  interface EngineServerSymbolsResponse {
172
171
  symbols: Record<string, EngineServerSymbol>;
@@ -238,8 +238,6 @@ function mapEngineServerSymbol(engineServerSymbol) {
238
238
  priceIncrement: (0, import_shared.removeDecimals)(engineServerSymbol.price_increment_x18),
239
239
  sizeIncrement: (0, import_shared.toBigDecimal)(engineServerSymbol.size_increment),
240
240
  minSize: (0, import_shared.toBigDecimal)(engineServerSymbol.min_size),
241
- minDepth: (0, import_shared.removeDecimals)(engineServerSymbol.min_depth_x18),
242
- maxSpreadRate: (0, import_shared.removeDecimals)(engineServerSymbol.max_spread_rate_x18),
243
241
  makerFeeRate: (0, import_shared.removeDecimals)(engineServerSymbol.maker_fee_rate_x18),
244
242
  takerFeeRate: (0, import_shared.removeDecimals)(engineServerSymbol.taker_fee_rate_x18),
245
243
  longWeightInitial: (0, import_shared.removeDecimals)(
@@ -247,7 +245,8 @@ function mapEngineServerSymbol(engineServerSymbol) {
247
245
  ),
248
246
  longWeightMaintenance: (0, import_shared.removeDecimals)(
249
247
  engineServerSymbol.long_weight_maintenance_x18
250
- )
248
+ ),
249
+ maxOpenInterest: (0, import_shared.removeDecimals)(engineServerSymbol.max_open_interest_x18)
251
250
  };
252
251
  }
253
252
  function mapEngineMarketPrice(baseResponse) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utils/queryDataMappers.ts"],"sourcesContent":["import {\n BalanceHealthContributions,\n calcTotalBorrowed,\n calcTotalDeposited,\n mapValues,\n PerpMarket,\n ProductEngineType,\n removeDecimals,\n SpotMarket,\n subaccountFromHex,\n toBigDecimal,\n unpackOrderAppendix,\n} from '@nadohq/shared';\nimport {\n EngineMarketPrice,\n EngineNlpLockedBalance,\n EngineOrder,\n EnginePriceTickLiquidity,\n EngineServerIsolatedPositionsResponse,\n EngineServerMarketPrice,\n EngineServerNlpLockedBalancesResponse,\n EngineServerNlpPoolInfoResponse,\n EngineServerOrderResponse,\n EngineServerPerpProduct,\n EngineServerPriceTickLiquidity,\n EngineServerSpotProduct,\n EngineServerSubaccountInfoResponse,\n EngineServerSymbol,\n EngineServerSymbolsResponse,\n EngineSymbol,\n EngineSymbolsResponse,\n GetEngineIsolatedPositionsResponse,\n GetEngineNlpLockedBalancesResponse,\n GetEngineNlpPoolInfoResponse,\n GetEngineSubaccountSummaryResponse,\n} from '../types';\nimport { mapEngineServerProductType } from './productEngineTypeMappers';\n\nexport function mapEngineServerTickLiquidity(\n tick: EngineServerPriceTickLiquidity,\n): EnginePriceTickLiquidity {\n return {\n price: removeDecimals(tick[0]),\n liquidity: toBigDecimal(tick[1]),\n };\n}\n\nexport function mapEngineServerOrder(\n order: EngineServerOrderResponse,\n): EngineOrder {\n const subaccount = subaccountFromHex(order.sender);\n return {\n digest: order.digest,\n expiration: Number(order.expiration),\n nonce: order.nonce,\n price: removeDecimals(order.price_x18),\n productId: order.product_id,\n subaccountOwner: subaccount.subaccountOwner,\n subaccountName: subaccount.subaccountName,\n totalAmount: toBigDecimal(order.amount),\n unfilledAmount: toBigDecimal(order.unfilled_amount),\n placementTime: order.placed_at,\n appendix: unpackOrderAppendix(order.appendix),\n };\n}\n\nexport function mapEngineServerSpotProduct(\n product: EngineServerSpotProduct,\n): SpotMarket {\n return {\n type: ProductEngineType.SPOT,\n productId: product.product_id,\n minSize: toBigDecimal(product.book_info.min_size),\n priceIncrement: removeDecimals(product.book_info.price_increment_x18),\n sizeIncrement: toBigDecimal(product.book_info.size_increment),\n product: {\n productId: product.product_id,\n type: ProductEngineType.SPOT,\n totalBorrowed: calcTotalBorrowed(\n product.state.total_borrows_normalized,\n product.state.cumulative_borrows_multiplier_x18,\n ),\n totalDeposited: calcTotalDeposited(\n product.state.total_deposits_normalized,\n product.state.cumulative_deposits_multiplier_x18,\n ),\n oraclePrice: removeDecimals(product.oracle_price_x18),\n interestFloor: removeDecimals(product.config.interest_floor_x18),\n interestInflectionUtil: removeDecimals(\n product.config.interest_inflection_util_x18,\n ),\n interestLargeCap: removeDecimals(product.config.interest_large_cap_x18),\n interestSmallCap: removeDecimals(product.config.interest_small_cap_x18),\n minDepositRate: removeDecimals(product.config.min_deposit_rate_x18),\n longWeightInitial: removeDecimals(product.risk.long_weight_initial_x18),\n longWeightMaintenance: removeDecimals(\n product.risk.long_weight_maintenance_x18,\n ),\n shortWeightInitial: removeDecimals(product.risk.short_weight_initial_x18),\n shortWeightMaintenance: removeDecimals(\n product.risk.short_weight_maintenance_x18,\n ),\n tokenAddr: product.config.token,\n },\n };\n}\n\nexport function mapEngineServerPerpProduct(\n product: EngineServerPerpProduct,\n): PerpMarket {\n return {\n type: ProductEngineType.PERP,\n productId: product.product_id,\n minSize: toBigDecimal(product.book_info.min_size),\n priceIncrement: removeDecimals(product.book_info.price_increment_x18),\n sizeIncrement: toBigDecimal(product.book_info.size_increment),\n product: {\n productId: product.product_id,\n type: ProductEngineType.PERP,\n oraclePrice: removeDecimals(product.oracle_price_x18),\n longWeightInitial: removeDecimals(product.risk.long_weight_initial_x18),\n longWeightMaintenance: removeDecimals(\n product.risk.long_weight_maintenance_x18,\n ),\n shortWeightInitial: removeDecimals(product.risk.short_weight_initial_x18),\n shortWeightMaintenance: removeDecimals(\n product.risk.short_weight_maintenance_x18,\n ),\n openInterest: toBigDecimal(product.state.open_interest),\n cumulativeFundingLong: removeDecimals(\n product.state.cumulative_funding_long_x18,\n ),\n cumulativeFundingShort: removeDecimals(\n product.state.cumulative_funding_short_x18,\n ),\n },\n };\n}\n\nexport function mapEngineServerBalanceHealthContributions(\n healthContributionsForBalance: string[],\n): BalanceHealthContributions {\n return {\n initial: toBigDecimal(healthContributionsForBalance[0]),\n maintenance: toBigDecimal(healthContributionsForBalance[1]),\n unweighted: toBigDecimal(healthContributionsForBalance[2]),\n };\n}\n\nexport function mapSubaccountSummary(\n baseResponse: EngineServerSubaccountInfoResponse,\n): GetEngineSubaccountSummaryResponse {\n const balances: GetEngineSubaccountSummaryResponse['balances'] = [];\n\n baseResponse.spot_balances.forEach((spotBalance) => {\n const product = baseResponse.spot_products.find(\n (product) => product.product_id === spotBalance.product_id,\n );\n if (!product) {\n throw Error(`Could not find product ${spotBalance.product_id}`);\n }\n\n balances.push({\n amount: toBigDecimal(spotBalance.balance.amount),\n healthContributions: mapEngineServerBalanceHealthContributions(\n baseResponse.health_contributions[spotBalance.product_id],\n ),\n ...mapEngineServerSpotProduct(product).product,\n });\n });\n\n baseResponse.perp_balances.forEach((perpBalance) => {\n const product = baseResponse.perp_products.find(\n (product) => product.product_id === perpBalance.product_id,\n );\n if (!product) {\n throw Error(`Could not find product ${perpBalance.product_id}`);\n }\n\n balances.push({\n amount: toBigDecimal(perpBalance.balance.amount),\n vQuoteBalance: toBigDecimal(perpBalance.balance.v_quote_balance),\n healthContributions: mapEngineServerBalanceHealthContributions(\n baseResponse.health_contributions[perpBalance.product_id],\n ),\n ...mapEngineServerPerpProduct(product).product,\n });\n });\n\n return {\n balances: balances,\n exists: baseResponse.exists,\n health: {\n initial: {\n health: toBigDecimal(baseResponse.healths[0].health),\n assets: toBigDecimal(baseResponse.healths[0].assets),\n liabilities: toBigDecimal(baseResponse.healths[0].liabilities),\n },\n maintenance: {\n health: toBigDecimal(baseResponse.healths[1].health),\n assets: toBigDecimal(baseResponse.healths[1].assets),\n liabilities: toBigDecimal(baseResponse.healths[1].liabilities),\n },\n unweighted: {\n health: toBigDecimal(baseResponse.healths[2].health),\n assets: toBigDecimal(baseResponse.healths[2].assets),\n liabilities: toBigDecimal(baseResponse.healths[2].liabilities),\n },\n },\n };\n}\n\nexport function mapEngineServerIsolatedPositions(\n baseResponse: EngineServerIsolatedPositionsResponse,\n): GetEngineIsolatedPositionsResponse {\n return baseResponse.isolated_positions.map((position) => {\n const perpBalance = position.base_balance;\n const quoteBalance = position.quote_balance;\n\n return {\n subaccount: subaccountFromHex(position.subaccount),\n healths: {\n initial: toBigDecimal(position.healths[0].health),\n maintenance: toBigDecimal(position.healths[1].health),\n unweighted: toBigDecimal(position.healths[2].health),\n },\n baseBalance: {\n amount: toBigDecimal(perpBalance.balance.amount),\n vQuoteBalance: toBigDecimal(perpBalance.balance.v_quote_balance),\n // Health contributions === healths for an isolated position\n healthContributions: {\n initial: toBigDecimal(position.base_healths[0]),\n maintenance: toBigDecimal(position.base_healths[1]),\n unweighted: toBigDecimal(position.base_healths[2]),\n },\n ...mapEngineServerPerpProduct(position.base_product).product,\n },\n quoteBalance: {\n amount: toBigDecimal(quoteBalance.balance.amount),\n healthContributions: {\n initial: toBigDecimal(position.quote_healths[0]),\n maintenance: toBigDecimal(position.quote_healths[1]),\n unweighted: toBigDecimal(position.quote_healths[2]),\n },\n ...mapEngineServerSpotProduct(position.quote_product).product,\n },\n };\n });\n}\n\nexport function mapEngineServerSymbols(\n baseResponse: EngineServerSymbolsResponse,\n): EngineSymbolsResponse {\n const symbols: Record<string, EngineSymbol> = mapValues(\n baseResponse.symbols,\n mapEngineServerSymbol,\n );\n\n return {\n symbols,\n };\n}\n\nexport function mapEngineServerSymbol(\n engineServerSymbol: EngineServerSymbol,\n): EngineSymbol {\n return {\n type: mapEngineServerProductType(engineServerSymbol.type),\n productId: engineServerSymbol.product_id,\n symbol: engineServerSymbol.symbol,\n priceIncrement: removeDecimals(engineServerSymbol.price_increment_x18),\n sizeIncrement: toBigDecimal(engineServerSymbol.size_increment),\n minSize: toBigDecimal(engineServerSymbol.min_size),\n minDepth: removeDecimals(engineServerSymbol.min_depth_x18),\n maxSpreadRate: removeDecimals(engineServerSymbol.max_spread_rate_x18),\n makerFeeRate: removeDecimals(engineServerSymbol.maker_fee_rate_x18),\n takerFeeRate: removeDecimals(engineServerSymbol.taker_fee_rate_x18),\n longWeightInitial: removeDecimals(\n engineServerSymbol.long_weight_initial_x18,\n ),\n longWeightMaintenance: removeDecimals(\n engineServerSymbol.long_weight_maintenance_x18,\n ),\n };\n}\n\nexport function mapEngineMarketPrice(\n baseResponse: EngineServerMarketPrice,\n): EngineMarketPrice {\n return {\n ask: removeDecimals(baseResponse.ask_x18),\n bid: removeDecimals(baseResponse.bid_x18),\n productId: baseResponse.product_id,\n };\n}\n\nexport function mapEngineServerNlpLockedBalances(\n baseResponse: EngineServerNlpLockedBalancesResponse,\n): GetEngineNlpLockedBalancesResponse {\n const lockedBalances: EngineNlpLockedBalance[] =\n baseResponse.locked_balances.map((lockedBalance) => ({\n productId: lockedBalance.balance.product_id,\n balance: toBigDecimal(lockedBalance.balance.balance.amount),\n unlockedAt: lockedBalance.unlocked_at,\n }));\n\n return {\n lockedBalances,\n balanceLocked: {\n productId: baseResponse.balance_locked.product_id,\n balance: toBigDecimal(baseResponse.balance_locked.balance.amount),\n },\n balanceUnlocked: {\n productId: baseResponse.balance_unlocked.product_id,\n balance: toBigDecimal(baseResponse.balance_unlocked.balance.amount),\n },\n };\n}\n\nexport function mapEngineServerNlpPoolInfo(\n baseResponse: EngineServerNlpPoolInfoResponse,\n): GetEngineNlpPoolInfoResponse {\n return {\n nlpPools: baseResponse.nlp_pools.map((pool) => ({\n poolId: pool.pool_id,\n subaccountHex: pool.subaccount,\n ownerAddress: pool.owner,\n balanceWeight: removeDecimals(pool.balance_weight_x18),\n subaccountInfo: mapSubaccountSummary(pool.subaccount_info),\n openOrders: pool.open_orders.map(mapEngineServerOrder),\n })),\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAYO;AAwBP,sCAA2C;AAEpC,SAAS,6BACd,MAC0B;AAC1B,SAAO;AAAA,IACL,WAAO,8BAAe,KAAK,CAAC,CAAC;AAAA,IAC7B,eAAW,4BAAa,KAAK,CAAC,CAAC;AAAA,EACjC;AACF;AAEO,SAAS,qBACd,OACa;AACb,QAAM,iBAAa,iCAAkB,MAAM,MAAM;AACjD,SAAO;AAAA,IACL,QAAQ,MAAM;AAAA,IACd,YAAY,OAAO,MAAM,UAAU;AAAA,IACnC,OAAO,MAAM;AAAA,IACb,WAAO,8BAAe,MAAM,SAAS;AAAA,IACrC,WAAW,MAAM;AAAA,IACjB,iBAAiB,WAAW;AAAA,IAC5B,gBAAgB,WAAW;AAAA,IAC3B,iBAAa,4BAAa,MAAM,MAAM;AAAA,IACtC,oBAAgB,4BAAa,MAAM,eAAe;AAAA,IAClD,eAAe,MAAM;AAAA,IACrB,cAAU,mCAAoB,MAAM,QAAQ;AAAA,EAC9C;AACF;AAEO,SAAS,2BACd,SACY;AACZ,SAAO;AAAA,IACL,MAAM,gCAAkB;AAAA,IACxB,WAAW,QAAQ;AAAA,IACnB,aAAS,4BAAa,QAAQ,UAAU,QAAQ;AAAA,IAChD,oBAAgB,8BAAe,QA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mBAAmB;AAAA,IACpE,kBAAc,8BAAe,mBAAmB,kBAAkB;AAAA,IAClE,kBAAc,8BAAe,mBAAmB,kBAAkB;AAAA,IAClE,uBAAmB;AAAA,MACjB,mBAAmB;AAAA,IACrB;AAAA,IACA,2BAAuB;AAAA,MACrB,mBAAmB;AAAA,IACrB;AAAA,EACF;AACF;AAEO,SAAS,qBACd,cACmB;AACnB,SAAO;AAAA,IACL,SAAK,8BAAe,aAAa,OAAO;AAAA,IACxC,SAAK,8BAAe,aAAa,OAAO;AAAA,IACxC,WAAW,aAAa;AAAA,EAC1B;AACF;AAEO,SAAS,iCACd,cACoC;AACpC,QAAM,iBACJ,aAAa,gBAAgB,IAAI,CAAC,mBAAmB;AAAA,IACnD,WAAW,cAAc,QAAQ;AAAA,IACjC,aAAS,4BAAa,cAAc,QAAQ,QAAQ,MAAM;AAAA,IAC1D,YAAY,cAAc;AAAA,EAC5B,EAAE;AAEJ,SAAO;AAAA,IACL;AAAA,IACA,eAAe;AAAA,MACb,WAAW,aAAa,eAAe;AAAA,MACvC,aAAS,4BAAa,aAAa,eAAe,QAAQ,MAAM;AAAA,IAClE;AAAA,IACA,iBAAiB;AAAA,MACf,WAAW,aAAa,iBAAiB;AAAA,MACzC,aAAS,4BAAa,aAAa,iBAAiB,QAAQ,MAAM;AAAA,IACpE;AAAA,EACF;AACF;AAEO,SAAS,2BACd,cAC8B;AAC9B,SAAO;AAAA,IACL,UAAU,aAAa,UAAU,IAAI,CAAC,UAAU;AAAA,MAC9C,QAAQ,KAAK;AAAA,MACb,eAAe,KAAK;AAAA,MACpB,cAAc,KAAK;AAAA,MACnB,mBAAe,8BAAe,KAAK,kBAAkB;AAAA,MACrD,gBAAgB,qBAAqB,KAAK,eAAe;AAAA,MACzD,YAAY,KAAK,YAAY,IAAI,oBAAoB;AAAA,IACvD,EAAE;AAAA,EACJ;AACF;","names":["product"]}
1
+ {"version":3,"sources":["../../src/utils/queryDataMappers.ts"],"sourcesContent":["import {\n BalanceHealthContributions,\n calcTotalBorrowed,\n calcTotalDeposited,\n mapValues,\n PerpMarket,\n ProductEngineType,\n removeDecimals,\n SpotMarket,\n subaccountFromHex,\n toBigDecimal,\n unpackOrderAppendix,\n} from '@nadohq/shared';\nimport {\n EngineMarketPrice,\n EngineNlpLockedBalance,\n EngineOrder,\n EnginePriceTickLiquidity,\n EngineServerIsolatedPositionsResponse,\n EngineServerMarketPrice,\n EngineServerNlpLockedBalancesResponse,\n EngineServerNlpPoolInfoResponse,\n EngineServerOrderResponse,\n EngineServerPerpProduct,\n EngineServerPriceTickLiquidity,\n EngineServerSpotProduct,\n EngineServerSubaccountInfoResponse,\n EngineServerSymbol,\n EngineServerSymbolsResponse,\n EngineSymbol,\n EngineSymbolsResponse,\n GetEngineIsolatedPositionsResponse,\n GetEngineNlpLockedBalancesResponse,\n GetEngineNlpPoolInfoResponse,\n GetEngineSubaccountSummaryResponse,\n} from '../types';\nimport { mapEngineServerProductType } from './productEngineTypeMappers';\n\nexport function mapEngineServerTickLiquidity(\n tick: EngineServerPriceTickLiquidity,\n): EnginePriceTickLiquidity {\n return {\n price: removeDecimals(tick[0]),\n liquidity: toBigDecimal(tick[1]),\n };\n}\n\nexport function mapEngineServerOrder(\n order: EngineServerOrderResponse,\n): EngineOrder {\n const subaccount = subaccountFromHex(order.sender);\n return {\n digest: order.digest,\n expiration: Number(order.expiration),\n nonce: order.nonce,\n price: removeDecimals(order.price_x18),\n productId: order.product_id,\n subaccountOwner: subaccount.subaccountOwner,\n subaccountName: subaccount.subaccountName,\n totalAmount: toBigDecimal(order.amount),\n unfilledAmount: toBigDecimal(order.unfilled_amount),\n placementTime: order.placed_at,\n appendix: unpackOrderAppendix(order.appendix),\n };\n}\n\nexport function mapEngineServerSpotProduct(\n product: EngineServerSpotProduct,\n): SpotMarket {\n return {\n type: ProductEngineType.SPOT,\n productId: product.product_id,\n minSize: toBigDecimal(product.book_info.min_size),\n priceIncrement: removeDecimals(product.book_info.price_increment_x18),\n sizeIncrement: toBigDecimal(product.book_info.size_increment),\n product: {\n productId: product.product_id,\n type: ProductEngineType.SPOT,\n totalBorrowed: calcTotalBorrowed(\n product.state.total_borrows_normalized,\n product.state.cumulative_borrows_multiplier_x18,\n ),\n totalDeposited: calcTotalDeposited(\n product.state.total_deposits_normalized,\n product.state.cumulative_deposits_multiplier_x18,\n ),\n oraclePrice: removeDecimals(product.oracle_price_x18),\n interestFloor: removeDecimals(product.config.interest_floor_x18),\n interestInflectionUtil: removeDecimals(\n product.config.interest_inflection_util_x18,\n ),\n interestLargeCap: removeDecimals(product.config.interest_large_cap_x18),\n interestSmallCap: removeDecimals(product.config.interest_small_cap_x18),\n minDepositRate: removeDecimals(product.config.min_deposit_rate_x18),\n longWeightInitial: removeDecimals(product.risk.long_weight_initial_x18),\n longWeightMaintenance: removeDecimals(\n product.risk.long_weight_maintenance_x18,\n ),\n shortWeightInitial: removeDecimals(product.risk.short_weight_initial_x18),\n shortWeightMaintenance: removeDecimals(\n product.risk.short_weight_maintenance_x18,\n ),\n tokenAddr: product.config.token,\n },\n };\n}\n\nexport function mapEngineServerPerpProduct(\n product: EngineServerPerpProduct,\n): PerpMarket {\n return {\n type: ProductEngineType.PERP,\n productId: product.product_id,\n minSize: toBigDecimal(product.book_info.min_size),\n priceIncrement: removeDecimals(product.book_info.price_increment_x18),\n sizeIncrement: toBigDecimal(product.book_info.size_increment),\n product: {\n productId: product.product_id,\n type: ProductEngineType.PERP,\n oraclePrice: removeDecimals(product.oracle_price_x18),\n longWeightInitial: removeDecimals(product.risk.long_weight_initial_x18),\n longWeightMaintenance: removeDecimals(\n product.risk.long_weight_maintenance_x18,\n ),\n shortWeightInitial: removeDecimals(product.risk.short_weight_initial_x18),\n shortWeightMaintenance: removeDecimals(\n product.risk.short_weight_maintenance_x18,\n ),\n openInterest: toBigDecimal(product.state.open_interest),\n cumulativeFundingLong: removeDecimals(\n product.state.cumulative_funding_long_x18,\n ),\n cumulativeFundingShort: removeDecimals(\n product.state.cumulative_funding_short_x18,\n ),\n },\n };\n}\n\nexport function mapEngineServerBalanceHealthContributions(\n healthContributionsForBalance: string[],\n): BalanceHealthContributions {\n return {\n initial: toBigDecimal(healthContributionsForBalance[0]),\n maintenance: toBigDecimal(healthContributionsForBalance[1]),\n unweighted: toBigDecimal(healthContributionsForBalance[2]),\n };\n}\n\nexport function mapSubaccountSummary(\n baseResponse: EngineServerSubaccountInfoResponse,\n): GetEngineSubaccountSummaryResponse {\n const balances: GetEngineSubaccountSummaryResponse['balances'] = [];\n\n baseResponse.spot_balances.forEach((spotBalance) => {\n const product = baseResponse.spot_products.find(\n (product) => product.product_id === spotBalance.product_id,\n );\n if (!product) {\n throw Error(`Could not find product ${spotBalance.product_id}`);\n }\n\n balances.push({\n amount: toBigDecimal(spotBalance.balance.amount),\n healthContributions: mapEngineServerBalanceHealthContributions(\n baseResponse.health_contributions[spotBalance.product_id],\n ),\n ...mapEngineServerSpotProduct(product).product,\n });\n });\n\n baseResponse.perp_balances.forEach((perpBalance) => {\n const product = baseResponse.perp_products.find(\n (product) => product.product_id === perpBalance.product_id,\n );\n if (!product) {\n throw Error(`Could not find product ${perpBalance.product_id}`);\n }\n\n balances.push({\n amount: toBigDecimal(perpBalance.balance.amount),\n vQuoteBalance: toBigDecimal(perpBalance.balance.v_quote_balance),\n healthContributions: mapEngineServerBalanceHealthContributions(\n baseResponse.health_contributions[perpBalance.product_id],\n ),\n ...mapEngineServerPerpProduct(product).product,\n });\n });\n\n return {\n balances: balances,\n exists: baseResponse.exists,\n health: {\n initial: {\n health: toBigDecimal(baseResponse.healths[0].health),\n assets: toBigDecimal(baseResponse.healths[0].assets),\n liabilities: toBigDecimal(baseResponse.healths[0].liabilities),\n },\n maintenance: {\n health: toBigDecimal(baseResponse.healths[1].health),\n assets: toBigDecimal(baseResponse.healths[1].assets),\n liabilities: toBigDecimal(baseResponse.healths[1].liabilities),\n },\n unweighted: {\n health: toBigDecimal(baseResponse.healths[2].health),\n assets: toBigDecimal(baseResponse.healths[2].assets),\n liabilities: toBigDecimal(baseResponse.healths[2].liabilities),\n },\n },\n };\n}\n\nexport function mapEngineServerIsolatedPositions(\n baseResponse: EngineServerIsolatedPositionsResponse,\n): GetEngineIsolatedPositionsResponse {\n return baseResponse.isolated_positions.map((position) => {\n const perpBalance = position.base_balance;\n const quoteBalance = position.quote_balance;\n\n return {\n subaccount: subaccountFromHex(position.subaccount),\n healths: {\n initial: toBigDecimal(position.healths[0].health),\n maintenance: toBigDecimal(position.healths[1].health),\n unweighted: toBigDecimal(position.healths[2].health),\n },\n baseBalance: {\n amount: toBigDecimal(perpBalance.balance.amount),\n vQuoteBalance: toBigDecimal(perpBalance.balance.v_quote_balance),\n // Health contributions === healths for an isolated position\n healthContributions: {\n initial: toBigDecimal(position.base_healths[0]),\n maintenance: toBigDecimal(position.base_healths[1]),\n unweighted: toBigDecimal(position.base_healths[2]),\n },\n ...mapEngineServerPerpProduct(position.base_product).product,\n },\n quoteBalance: {\n amount: toBigDecimal(quoteBalance.balance.amount),\n healthContributions: {\n initial: toBigDecimal(position.quote_healths[0]),\n maintenance: toBigDecimal(position.quote_healths[1]),\n unweighted: toBigDecimal(position.quote_healths[2]),\n },\n ...mapEngineServerSpotProduct(position.quote_product).product,\n },\n };\n });\n}\n\nexport function mapEngineServerSymbols(\n baseResponse: EngineServerSymbolsResponse,\n): EngineSymbolsResponse {\n const symbols: Record<string, EngineSymbol> = mapValues(\n baseResponse.symbols,\n mapEngineServerSymbol,\n );\n\n return {\n symbols,\n };\n}\n\nexport function mapEngineServerSymbol(\n engineServerSymbol: EngineServerSymbol,\n): EngineSymbol {\n return {\n type: mapEngineServerProductType(engineServerSymbol.type),\n productId: engineServerSymbol.product_id,\n symbol: engineServerSymbol.symbol,\n priceIncrement: removeDecimals(engineServerSymbol.price_increment_x18),\n sizeIncrement: toBigDecimal(engineServerSymbol.size_increment),\n minSize: toBigDecimal(engineServerSymbol.min_size),\n makerFeeRate: removeDecimals(engineServerSymbol.maker_fee_rate_x18),\n takerFeeRate: removeDecimals(engineServerSymbol.taker_fee_rate_x18),\n longWeightInitial: removeDecimals(\n engineServerSymbol.long_weight_initial_x18,\n ),\n longWeightMaintenance: removeDecimals(\n engineServerSymbol.long_weight_maintenance_x18,\n ),\n maxOpenInterest: removeDecimals(engineServerSymbol.max_open_interest_x18),\n };\n}\n\nexport function mapEngineMarketPrice(\n baseResponse: EngineServerMarketPrice,\n): EngineMarketPrice {\n return {\n ask: removeDecimals(baseResponse.ask_x18),\n bid: removeDecimals(baseResponse.bid_x18),\n productId: baseResponse.product_id,\n };\n}\n\nexport function mapEngineServerNlpLockedBalances(\n baseResponse: EngineServerNlpLockedBalancesResponse,\n): GetEngineNlpLockedBalancesResponse {\n const lockedBalances: EngineNlpLockedBalance[] =\n baseResponse.locked_balances.map((lockedBalance) => ({\n productId: lockedBalance.balance.product_id,\n balance: toBigDecimal(lockedBalance.balance.balance.amount),\n unlockedAt: lockedBalance.unlocked_at,\n }));\n\n return {\n lockedBalances,\n balanceLocked: {\n productId: baseResponse.balance_locked.product_id,\n balance: toBigDecimal(baseResponse.balance_locked.balance.amount),\n },\n balanceUnlocked: {\n productId: baseResponse.balance_unlocked.product_id,\n balance: toBigDecimal(baseResponse.balance_unlocked.balance.amount),\n },\n };\n}\n\nexport function mapEngineServerNlpPoolInfo(\n baseResponse: EngineServerNlpPoolInfoResponse,\n): GetEngineNlpPoolInfoResponse {\n return {\n nlpPools: baseResponse.nlp_pools.map((pool) => ({\n poolId: pool.pool_id,\n subaccountHex: pool.subaccount,\n ownerAddress: pool.owner,\n balanceWeight: removeDecimals(pool.balance_weight_x18),\n subaccountInfo: mapSubaccountSummary(pool.subaccount_info),\n openOrders: pool.open_orders.map(mapEngineServerOrder),\n })),\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAYO;AAwBP,sCA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AAAA,IAC1D,YAAY,cAAc;AAAA,EAC5B,EAAE;AAEJ,SAAO;AAAA,IACL;AAAA,IACA,eAAe;AAAA,MACb,WAAW,aAAa,eAAe;AAAA,MACvC,aAAS,4BAAa,aAAa,eAAe,QAAQ,MAAM;AAAA,IAClE;AAAA,IACA,iBAAiB;AAAA,MACf,WAAW,aAAa,iBAAiB;AAAA,MACzC,aAAS,4BAAa,aAAa,iBAAiB,QAAQ,MAAM;AAAA,IACpE;AAAA,EACF;AACF;AAEO,SAAS,2BACd,cAC8B;AAC9B,SAAO;AAAA,IACL,UAAU,aAAa,UAAU,IAAI,CAAC,UAAU;AAAA,MAC9C,QAAQ,KAAK;AAAA,MACb,eAAe,KAAK;AAAA,MACpB,cAAc,KAAK;AAAA,MACnB,mBAAe,8BAAe,KAAK,kBAAkB;AAAA,MACrD,gBAAgB,qBAAqB,KAAK,eAAe;AAAA,MACzD,YAAY,KAAK,YAAY,IAAI,oBAAoB;AAAA,IACvD,EAAE;AAAA,EACJ;AACF;","names":["product"]}
@@ -212,8 +212,6 @@ function mapEngineServerSymbol(engineServerSymbol) {
212
212
  priceIncrement: removeDecimals(engineServerSymbol.price_increment_x18),
213
213
  sizeIncrement: toBigDecimal(engineServerSymbol.size_increment),
214
214
  minSize: toBigDecimal(engineServerSymbol.min_size),
215
- minDepth: removeDecimals(engineServerSymbol.min_depth_x18),
216
- maxSpreadRate: removeDecimals(engineServerSymbol.max_spread_rate_x18),
217
215
  makerFeeRate: removeDecimals(engineServerSymbol.maker_fee_rate_x18),
218
216
  takerFeeRate: removeDecimals(engineServerSymbol.taker_fee_rate_x18),
219
217
  longWeightInitial: removeDecimals(
@@ -221,7 +219,8 @@ function mapEngineServerSymbol(engineServerSymbol) {
221
219
  ),
222
220
  longWeightMaintenance: removeDecimals(
223
221
  engineServerSymbol.long_weight_maintenance_x18
224
- )
222
+ ),
223
+ maxOpenInterest: removeDecimals(engineServerSymbol.max_open_interest_x18)
225
224
  };
226
225
  }
227
226
  function mapEngineMarketPrice(baseResponse) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utils/queryDataMappers.ts"],"sourcesContent":["import {\n BalanceHealthContributions,\n calcTotalBorrowed,\n calcTotalDeposited,\n mapValues,\n PerpMarket,\n ProductEngineType,\n removeDecimals,\n SpotMarket,\n subaccountFromHex,\n toBigDecimal,\n unpackOrderAppendix,\n} from '@nadohq/shared';\nimport {\n EngineMarketPrice,\n EngineNlpLockedBalance,\n EngineOrder,\n EnginePriceTickLiquidity,\n EngineServerIsolatedPositionsResponse,\n EngineServerMarketPrice,\n EngineServerNlpLockedBalancesResponse,\n EngineServerNlpPoolInfoResponse,\n EngineServerOrderResponse,\n EngineServerPerpProduct,\n EngineServerPriceTickLiquidity,\n EngineServerSpotProduct,\n EngineServerSubaccountInfoResponse,\n EngineServerSymbol,\n EngineServerSymbolsResponse,\n EngineSymbol,\n EngineSymbolsResponse,\n GetEngineIsolatedPositionsResponse,\n GetEngineNlpLockedBalancesResponse,\n GetEngineNlpPoolInfoResponse,\n GetEngineSubaccountSummaryResponse,\n} from '../types';\nimport { mapEngineServerProductType } from './productEngineTypeMappers';\n\nexport function mapEngineServerTickLiquidity(\n tick: EngineServerPriceTickLiquidity,\n): EnginePriceTickLiquidity {\n return {\n price: removeDecimals(tick[0]),\n liquidity: toBigDecimal(tick[1]),\n };\n}\n\nexport function mapEngineServerOrder(\n order: EngineServerOrderResponse,\n): EngineOrder {\n const subaccount = subaccountFromHex(order.sender);\n return {\n digest: order.digest,\n expiration: Number(order.expiration),\n nonce: order.nonce,\n price: removeDecimals(order.price_x18),\n productId: order.product_id,\n subaccountOwner: subaccount.subaccountOwner,\n subaccountName: subaccount.subaccountName,\n totalAmount: toBigDecimal(order.amount),\n unfilledAmount: toBigDecimal(order.unfilled_amount),\n placementTime: order.placed_at,\n appendix: unpackOrderAppendix(order.appendix),\n };\n}\n\nexport function mapEngineServerSpotProduct(\n product: EngineServerSpotProduct,\n): SpotMarket {\n return {\n type: ProductEngineType.SPOT,\n productId: product.product_id,\n minSize: toBigDecimal(product.book_info.min_size),\n priceIncrement: removeDecimals(product.book_info.price_increment_x18),\n sizeIncrement: toBigDecimal(product.book_info.size_increment),\n product: {\n productId: product.product_id,\n type: ProductEngineType.SPOT,\n totalBorrowed: calcTotalBorrowed(\n product.state.total_borrows_normalized,\n product.state.cumulative_borrows_multiplier_x18,\n ),\n totalDeposited: calcTotalDeposited(\n product.state.total_deposits_normalized,\n product.state.cumulative_deposits_multiplier_x18,\n ),\n oraclePrice: removeDecimals(product.oracle_price_x18),\n interestFloor: removeDecimals(product.config.interest_floor_x18),\n interestInflectionUtil: removeDecimals(\n product.config.interest_inflection_util_x18,\n ),\n interestLargeCap: removeDecimals(product.config.interest_large_cap_x18),\n interestSmallCap: removeDecimals(product.config.interest_small_cap_x18),\n minDepositRate: removeDecimals(product.config.min_deposit_rate_x18),\n longWeightInitial: removeDecimals(product.risk.long_weight_initial_x18),\n longWeightMaintenance: removeDecimals(\n product.risk.long_weight_maintenance_x18,\n ),\n shortWeightInitial: removeDecimals(product.risk.short_weight_initial_x18),\n shortWeightMaintenance: removeDecimals(\n product.risk.short_weight_maintenance_x18,\n ),\n tokenAddr: product.config.token,\n },\n };\n}\n\nexport function mapEngineServerPerpProduct(\n product: EngineServerPerpProduct,\n): PerpMarket {\n return {\n type: ProductEngineType.PERP,\n productId: product.product_id,\n minSize: toBigDecimal(product.book_info.min_size),\n priceIncrement: removeDecimals(product.book_info.price_increment_x18),\n sizeIncrement: toBigDecimal(product.book_info.size_increment),\n product: {\n productId: product.product_id,\n type: ProductEngineType.PERP,\n oraclePrice: removeDecimals(product.oracle_price_x18),\n longWeightInitial: removeDecimals(product.risk.long_weight_initial_x18),\n longWeightMaintenance: removeDecimals(\n product.risk.long_weight_maintenance_x18,\n ),\n shortWeightInitial: removeDecimals(product.risk.short_weight_initial_x18),\n shortWeightMaintenance: removeDecimals(\n product.risk.short_weight_maintenance_x18,\n ),\n openInterest: toBigDecimal(product.state.open_interest),\n cumulativeFundingLong: removeDecimals(\n product.state.cumulative_funding_long_x18,\n ),\n cumulativeFundingShort: removeDecimals(\n product.state.cumulative_funding_short_x18,\n ),\n },\n };\n}\n\nexport function mapEngineServerBalanceHealthContributions(\n healthContributionsForBalance: string[],\n): BalanceHealthContributions {\n return {\n initial: toBigDecimal(healthContributionsForBalance[0]),\n maintenance: toBigDecimal(healthContributionsForBalance[1]),\n unweighted: toBigDecimal(healthContributionsForBalance[2]),\n };\n}\n\nexport function mapSubaccountSummary(\n baseResponse: EngineServerSubaccountInfoResponse,\n): GetEngineSubaccountSummaryResponse {\n const balances: GetEngineSubaccountSummaryResponse['balances'] = [];\n\n baseResponse.spot_balances.forEach((spotBalance) => {\n const product = baseResponse.spot_products.find(\n (product) => product.product_id === spotBalance.product_id,\n );\n if (!product) {\n throw Error(`Could not find product ${spotBalance.product_id}`);\n }\n\n balances.push({\n amount: toBigDecimal(spotBalance.balance.amount),\n healthContributions: mapEngineServerBalanceHealthContributions(\n baseResponse.health_contributions[spotBalance.product_id],\n ),\n ...mapEngineServerSpotProduct(product).product,\n });\n });\n\n baseResponse.perp_balances.forEach((perpBalance) => {\n const product = baseResponse.perp_products.find(\n (product) => product.product_id === perpBalance.product_id,\n );\n if (!product) {\n throw Error(`Could not find product ${perpBalance.product_id}`);\n }\n\n balances.push({\n amount: toBigDecimal(perpBalance.balance.amount),\n vQuoteBalance: toBigDecimal(perpBalance.balance.v_quote_balance),\n healthContributions: mapEngineServerBalanceHealthContributions(\n baseResponse.health_contributions[perpBalance.product_id],\n ),\n ...mapEngineServerPerpProduct(product).product,\n });\n });\n\n return {\n balances: balances,\n exists: baseResponse.exists,\n health: {\n initial: {\n health: toBigDecimal(baseResponse.healths[0].health),\n assets: toBigDecimal(baseResponse.healths[0].assets),\n liabilities: toBigDecimal(baseResponse.healths[0].liabilities),\n },\n maintenance: {\n health: toBigDecimal(baseResponse.healths[1].health),\n assets: toBigDecimal(baseResponse.healths[1].assets),\n liabilities: toBigDecimal(baseResponse.healths[1].liabilities),\n },\n unweighted: {\n health: toBigDecimal(baseResponse.healths[2].health),\n assets: toBigDecimal(baseResponse.healths[2].assets),\n liabilities: toBigDecimal(baseResponse.healths[2].liabilities),\n },\n },\n };\n}\n\nexport function mapEngineServerIsolatedPositions(\n baseResponse: EngineServerIsolatedPositionsResponse,\n): GetEngineIsolatedPositionsResponse {\n return baseResponse.isolated_positions.map((position) => {\n const perpBalance = position.base_balance;\n const quoteBalance = position.quote_balance;\n\n return {\n subaccount: subaccountFromHex(position.subaccount),\n healths: {\n initial: toBigDecimal(position.healths[0].health),\n maintenance: toBigDecimal(position.healths[1].health),\n unweighted: toBigDecimal(position.healths[2].health),\n },\n baseBalance: {\n amount: toBigDecimal(perpBalance.balance.amount),\n vQuoteBalance: toBigDecimal(perpBalance.balance.v_quote_balance),\n // Health contributions === healths for an isolated position\n healthContributions: {\n initial: toBigDecimal(position.base_healths[0]),\n maintenance: toBigDecimal(position.base_healths[1]),\n unweighted: toBigDecimal(position.base_healths[2]),\n },\n ...mapEngineServerPerpProduct(position.base_product).product,\n },\n quoteBalance: {\n amount: toBigDecimal(quoteBalance.balance.amount),\n healthContributions: {\n initial: toBigDecimal(position.quote_healths[0]),\n maintenance: toBigDecimal(position.quote_healths[1]),\n unweighted: toBigDecimal(position.quote_healths[2]),\n },\n ...mapEngineServerSpotProduct(position.quote_product).product,\n },\n };\n });\n}\n\nexport function mapEngineServerSymbols(\n baseResponse: EngineServerSymbolsResponse,\n): EngineSymbolsResponse {\n const symbols: Record<string, EngineSymbol> = mapValues(\n baseResponse.symbols,\n mapEngineServerSymbol,\n );\n\n return {\n symbols,\n };\n}\n\nexport function mapEngineServerSymbol(\n engineServerSymbol: EngineServerSymbol,\n): EngineSymbol {\n return {\n type: mapEngineServerProductType(engineServerSymbol.type),\n productId: engineServerSymbol.product_id,\n symbol: engineServerSymbol.symbol,\n priceIncrement: removeDecimals(engineServerSymbol.price_increment_x18),\n sizeIncrement: toBigDecimal(engineServerSymbol.size_increment),\n minSize: toBigDecimal(engineServerSymbol.min_size),\n minDepth: removeDecimals(engineServerSymbol.min_depth_x18),\n maxSpreadRate: removeDecimals(engineServerSymbol.max_spread_rate_x18),\n makerFeeRate: removeDecimals(engineServerSymbol.maker_fee_rate_x18),\n takerFeeRate: removeDecimals(engineServerSymbol.taker_fee_rate_x18),\n longWeightInitial: removeDecimals(\n engineServerSymbol.long_weight_initial_x18,\n ),\n longWeightMaintenance: removeDecimals(\n engineServerSymbol.long_weight_maintenance_x18,\n ),\n };\n}\n\nexport function mapEngineMarketPrice(\n baseResponse: EngineServerMarketPrice,\n): EngineMarketPrice {\n return {\n ask: removeDecimals(baseResponse.ask_x18),\n bid: removeDecimals(baseResponse.bid_x18),\n productId: baseResponse.product_id,\n };\n}\n\nexport function mapEngineServerNlpLockedBalances(\n baseResponse: EngineServerNlpLockedBalancesResponse,\n): GetEngineNlpLockedBalancesResponse {\n const lockedBalances: EngineNlpLockedBalance[] =\n baseResponse.locked_balances.map((lockedBalance) => ({\n productId: lockedBalance.balance.product_id,\n balance: toBigDecimal(lockedBalance.balance.balance.amount),\n unlockedAt: lockedBalance.unlocked_at,\n }));\n\n return {\n lockedBalances,\n balanceLocked: {\n productId: baseResponse.balance_locked.product_id,\n balance: toBigDecimal(baseResponse.balance_locked.balance.amount),\n },\n balanceUnlocked: {\n productId: baseResponse.balance_unlocked.product_id,\n balance: toBigDecimal(baseResponse.balance_unlocked.balance.amount),\n },\n };\n}\n\nexport function mapEngineServerNlpPoolInfo(\n baseResponse: EngineServerNlpPoolInfoResponse,\n): GetEngineNlpPoolInfoResponse {\n return {\n nlpPools: baseResponse.nlp_pools.map((pool) => ({\n poolId: pool.pool_id,\n subaccountHex: pool.subaccount,\n ownerAddress: pool.owner,\n balanceWeight: removeDecimals(pool.balance_weight_x18),\n subaccountInfo: mapSubaccountSummary(pool.subaccount_info),\n openOrders: pool.open_orders.map(mapEngineServerOrder),\n })),\n };\n}\n"],"mappings":";AAA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Q;AAAA,IACjC,SAAS,aAAa,cAAc,QAAQ,QAAQ,MAAM;AAAA,IAC1D,YAAY,cAAc;AAAA,EAC5B,EAAE;AAEJ,SAAO;AAAA,IACL;AAAA,IACA,eAAe;AAAA,MACb,WAAW,aAAa,eAAe;AAAA,MACvC,SAAS,aAAa,aAAa,eAAe,QAAQ,MAAM;AAAA,IAClE;AAAA,IACA,iBAAiB;AAAA,MACf,WAAW,aAAa,iBAAiB;AAAA,MACzC,SAAS,aAAa,aAAa,iBAAiB,QAAQ,MAAM;AAAA,IACpE;AAAA,EACF;AACF;AAEO,SAAS,2BACd,cAC8B;AAC9B,SAAO;AAAA,IACL,UAAU,aAAa,UAAU,IAAI,CAAC,UAAU;AAAA,MAC9C,QAAQ,KAAK;AAAA,MACb,eAAe,KAAK;AAAA,MACpB,cAAc,KAAK;AAAA,MACnB,eAAe,eAAe,KAAK,kBAAkB;AAAA,MACrD,gBAAgB,qBAAqB,KAAK,eAAe;AAAA,MACzD,YAAY,KAAK,YAAY,IAAI,oBAAoB;AAAA,IACvD,EAAE;AAAA,EACJ;AACF;","names":["product"]}
1
+ {"version":3,"sources":["../../src/utils/queryDataMappers.ts"],"sourcesContent":["import {\n BalanceHealthContributions,\n calcTotalBorrowed,\n calcTotalDeposited,\n mapValues,\n PerpMarket,\n ProductEngineType,\n removeDecimals,\n SpotMarket,\n subaccountFromHex,\n toBigDecimal,\n unpackOrderAppendix,\n} from '@nadohq/shared';\nimport {\n EngineMarketPrice,\n EngineNlpLockedBalance,\n EngineOrder,\n EnginePriceTickLiquidity,\n EngineServerIsolatedPositionsResponse,\n EngineServerMarketPrice,\n EngineServerNlpLockedBalancesResponse,\n EngineServerNlpPoolInfoResponse,\n EngineServerOrderResponse,\n EngineServerPerpProduct,\n EngineServerPriceTickLiquidity,\n EngineServerSpotProduct,\n EngineServerSubaccountInfoResponse,\n EngineServerSymbol,\n EngineServerSymbolsResponse,\n EngineSymbol,\n EngineSymbolsResponse,\n GetEngineIsolatedPositionsResponse,\n GetEngineNlpLockedBalancesResponse,\n GetEngineNlpPoolInfoResponse,\n GetEngineSubaccountSummaryResponse,\n} from '../types';\nimport { mapEngineServerProductType } from './productEngineTypeMappers';\n\nexport function mapEngineServerTickLiquidity(\n tick: EngineServerPriceTickLiquidity,\n): EnginePriceTickLiquidity {\n return {\n price: removeDecimals(tick[0]),\n liquidity: toBigDecimal(tick[1]),\n };\n}\n\nexport function mapEngineServerOrder(\n order: EngineServerOrderResponse,\n): EngineOrder {\n const subaccount = subaccountFromHex(order.sender);\n return {\n digest: order.digest,\n expiration: Number(order.expiration),\n nonce: order.nonce,\n price: removeDecimals(order.price_x18),\n productId: order.product_id,\n subaccountOwner: subaccount.subaccountOwner,\n subaccountName: subaccount.subaccountName,\n totalAmount: toBigDecimal(order.amount),\n unfilledAmount: toBigDecimal(order.unfilled_amount),\n placementTime: order.placed_at,\n appendix: unpackOrderAppendix(order.appendix),\n };\n}\n\nexport function mapEngineServerSpotProduct(\n product: EngineServerSpotProduct,\n): SpotMarket {\n return {\n type: ProductEngineType.SPOT,\n productId: product.product_id,\n minSize: toBigDecimal(product.book_info.min_size),\n priceIncrement: removeDecimals(product.book_info.price_increment_x18),\n sizeIncrement: toBigDecimal(product.book_info.size_increment),\n product: {\n productId: product.product_id,\n type: ProductEngineType.SPOT,\n totalBorrowed: calcTotalBorrowed(\n product.state.total_borrows_normalized,\n product.state.cumulative_borrows_multiplier_x18,\n ),\n totalDeposited: calcTotalDeposited(\n product.state.total_deposits_normalized,\n product.state.cumulative_deposits_multiplier_x18,\n ),\n oraclePrice: removeDecimals(product.oracle_price_x18),\n interestFloor: removeDecimals(product.config.interest_floor_x18),\n interestInflectionUtil: removeDecimals(\n product.config.interest_inflection_util_x18,\n ),\n interestLargeCap: removeDecimals(product.config.interest_large_cap_x18),\n interestSmallCap: removeDecimals(product.config.interest_small_cap_x18),\n minDepositRate: removeDecimals(product.config.min_deposit_rate_x18),\n longWeightInitial: removeDecimals(product.risk.long_weight_initial_x18),\n longWeightMaintenance: removeDecimals(\n product.risk.long_weight_maintenance_x18,\n ),\n shortWeightInitial: removeDecimals(product.risk.short_weight_initial_x18),\n shortWeightMaintenance: removeDecimals(\n product.risk.short_weight_maintenance_x18,\n ),\n tokenAddr: product.config.token,\n },\n };\n}\n\nexport function mapEngineServerPerpProduct(\n product: EngineServerPerpProduct,\n): PerpMarket {\n return {\n type: ProductEngineType.PERP,\n productId: product.product_id,\n minSize: toBigDecimal(product.book_info.min_size),\n priceIncrement: removeDecimals(product.book_info.price_increment_x18),\n sizeIncrement: toBigDecimal(product.book_info.size_increment),\n product: {\n productId: product.product_id,\n type: ProductEngineType.PERP,\n oraclePrice: removeDecimals(product.oracle_price_x18),\n longWeightInitial: removeDecimals(product.risk.long_weight_initial_x18),\n longWeightMaintenance: removeDecimals(\n product.risk.long_weight_maintenance_x18,\n ),\n shortWeightInitial: removeDecimals(product.risk.short_weight_initial_x18),\n shortWeightMaintenance: removeDecimals(\n product.risk.short_weight_maintenance_x18,\n ),\n openInterest: toBigDecimal(product.state.open_interest),\n cumulativeFundingLong: removeDecimals(\n product.state.cumulative_funding_long_x18,\n ),\n cumulativeFundingShort: removeDecimals(\n product.state.cumulative_funding_short_x18,\n ),\n },\n };\n}\n\nexport function mapEngineServerBalanceHealthContributions(\n healthContributionsForBalance: string[],\n): BalanceHealthContributions {\n return {\n initial: toBigDecimal(healthContributionsForBalance[0]),\n maintenance: toBigDecimal(healthContributionsForBalance[1]),\n unweighted: toBigDecimal(healthContributionsForBalance[2]),\n };\n}\n\nexport function mapSubaccountSummary(\n baseResponse: EngineServerSubaccountInfoResponse,\n): GetEngineSubaccountSummaryResponse {\n const balances: GetEngineSubaccountSummaryResponse['balances'] = [];\n\n baseResponse.spot_balances.forEach((spotBalance) => {\n const product = baseResponse.spot_products.find(\n (product) => product.product_id === spotBalance.product_id,\n );\n if (!product) {\n throw Error(`Could not find product ${spotBalance.product_id}`);\n }\n\n balances.push({\n amount: toBigDecimal(spotBalance.balance.amount),\n healthContributions: mapEngineServerBalanceHealthContributions(\n baseResponse.health_contributions[spotBalance.product_id],\n ),\n ...mapEngineServerSpotProduct(product).product,\n });\n });\n\n baseResponse.perp_balances.forEach((perpBalance) => {\n const product = baseResponse.perp_products.find(\n (product) => product.product_id === perpBalance.product_id,\n );\n if (!product) {\n throw Error(`Could not find product ${perpBalance.product_id}`);\n }\n\n balances.push({\n amount: toBigDecimal(perpBalance.balance.amount),\n vQuoteBalance: toBigDecimal(perpBalance.balance.v_quote_balance),\n healthContributions: mapEngineServerBalanceHealthContributions(\n baseResponse.health_contributions[perpBalance.product_id],\n ),\n ...mapEngineServerPerpProduct(product).product,\n });\n });\n\n return {\n balances: balances,\n exists: baseResponse.exists,\n health: {\n initial: {\n health: toBigDecimal(baseResponse.healths[0].health),\n assets: toBigDecimal(baseResponse.healths[0].assets),\n liabilities: toBigDecimal(baseResponse.healths[0].liabilities),\n },\n maintenance: {\n health: toBigDecimal(baseResponse.healths[1].health),\n assets: toBigDecimal(baseResponse.healths[1].assets),\n liabilities: toBigDecimal(baseResponse.healths[1].liabilities),\n },\n unweighted: {\n health: toBigDecimal(baseResponse.healths[2].health),\n assets: toBigDecimal(baseResponse.healths[2].assets),\n liabilities: toBigDecimal(baseResponse.healths[2].liabilities),\n },\n },\n };\n}\n\nexport function mapEngineServerIsolatedPositions(\n baseResponse: EngineServerIsolatedPositionsResponse,\n): GetEngineIsolatedPositionsResponse {\n return baseResponse.isolated_positions.map((position) => {\n const perpBalance = position.base_balance;\n const quoteBalance = position.quote_balance;\n\n return {\n subaccount: subaccountFromHex(position.subaccount),\n healths: {\n initial: toBigDecimal(position.healths[0].health),\n maintenance: toBigDecimal(position.healths[1].health),\n unweighted: toBigDecimal(position.healths[2].health),\n },\n baseBalance: {\n amount: toBigDecimal(perpBalance.balance.amount),\n vQuoteBalance: toBigDecimal(perpBalance.balance.v_quote_balance),\n // Health contributions === healths for an isolated position\n healthContributions: {\n initial: toBigDecimal(position.base_healths[0]),\n maintenance: toBigDecimal(position.base_healths[1]),\n unweighted: toBigDecimal(position.base_healths[2]),\n },\n ...mapEngineServerPerpProduct(position.base_product).product,\n },\n quoteBalance: {\n amount: toBigDecimal(quoteBalance.balance.amount),\n healthContributions: {\n initial: toBigDecimal(position.quote_healths[0]),\n maintenance: toBigDecimal(position.quote_healths[1]),\n unweighted: toBigDecimal(position.quote_healths[2]),\n },\n ...mapEngineServerSpotProduct(position.quote_product).product,\n },\n };\n });\n}\n\nexport function mapEngineServerSymbols(\n baseResponse: EngineServerSymbolsResponse,\n): EngineSymbolsResponse {\n const symbols: Record<string, EngineSymbol> = mapValues(\n baseResponse.symbols,\n mapEngineServerSymbol,\n );\n\n return {\n symbols,\n };\n}\n\nexport function mapEngineServerSymbol(\n engineServerSymbol: EngineServerSymbol,\n): EngineSymbol {\n return {\n type: mapEngineServerProductType(engineServerSymbol.type),\n productId: engineServerSymbol.product_id,\n symbol: engineServerSymbol.symbol,\n priceIncrement: removeDecimals(engineServerSymbol.price_increment_x18),\n sizeIncrement: toBigDecimal(engineServerSymbol.size_increment),\n minSize: toBigDecimal(engineServerSymbol.min_size),\n makerFeeRate: removeDecimals(engineServerSymbol.maker_fee_rate_x18),\n takerFeeRate: removeDecimals(engineServerSymbol.taker_fee_rate_x18),\n longWeightInitial: removeDecimals(\n engineServerSymbol.long_weight_initial_x18,\n ),\n longWeightMaintenance: removeDecimals(\n engineServerSymbol.long_weight_maintenance_x18,\n ),\n maxOpenInterest: removeDecimals(engineServerSymbol.max_open_interest_x18),\n };\n}\n\nexport function mapEngineMarketPrice(\n baseResponse: EngineServerMarketPrice,\n): EngineMarketPrice {\n return {\n ask: removeDecimals(baseResponse.ask_x18),\n bid: removeDecimals(baseResponse.bid_x18),\n productId: baseResponse.product_id,\n };\n}\n\nexport function mapEngineServerNlpLockedBalances(\n baseResponse: EngineServerNlpLockedBalancesResponse,\n): GetEngineNlpLockedBalancesResponse {\n const lockedBalances: EngineNlpLockedBalance[] =\n baseResponse.locked_balances.map((lockedBalance) => ({\n productId: lockedBalance.balance.product_id,\n balance: toBigDecimal(lockedBalance.balance.balance.amount),\n unlockedAt: lockedBalance.unlocked_at,\n }));\n\n return {\n lockedBalances,\n balanceLocked: {\n productId: baseResponse.balance_locked.product_id,\n balance: toBigDecimal(baseResponse.balance_locked.balance.amount),\n },\n balanceUnlocked: {\n productId: baseResponse.balance_unlocked.product_id,\n balance: toBigDecimal(baseResponse.balance_unlocked.balance.amount),\n },\n };\n}\n\nexport function mapEngineServerNlpPoolInfo(\n baseResponse: EngineServerNlpPoolInfoResponse,\n): GetEngineNlpPoolInfoResponse {\n return {\n nlpPools: baseResponse.nlp_pools.map((pool) => ({\n poolId: pool.pool_id,\n subaccountHex: pool.subaccount,\n ownerAddress: pool.owner,\n balanceWeight: removeDecimals(pool.balance_weight_x18),\n subaccountInfo: mapSubaccountSummary(pool.subaccount_info),\n openOrders: pool.open_orders.map(mapEngineServerOrder),\n })),\n };\n}\n"],"mappings":";AAAA;AAAA,EAEE;AAAA,EACA;AAAA,EACA;AAAA,EAEA;AAAA,EACA;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAwBP,SAAS,kCAAkC;AAEpC,SAAS,6BACd,MAC0B;AAC1B,SAAO;AAAA,IACL,OAAO,eAAe,KAAK,CAAC,CAAC;AAAA,IAC7B,WAAW,aAAa,KAAK,CAAC,CAAC;AAAA,EACjC;AACF;AAEO,SAAS,qBACd,OACa;AACb,QAAM,aAAa,kBAAkB,MAAM,MAAM;AACjD,SAAO;AAAA,IACL,QAAQ,MAAM;AAAA,IACd,YAAY,OAAO,MAAM,UAAU;AAAA,IACnC,OAAO,MAAM;AAAA,IACb,OAAO,eAAe,MAAM,SAAS;AAAA,IACrC,WAAW,MAAM;AAAA,IACjB,iBAAiB,WAAW;AAAA,IAC5B,gBAAgB,WAAW;AAAA,IAC3B,aAAa,aAAa,MAAM,MAAM;AAAA,IACtC,gBAAgB,aAAa,MAAM,eAAe;AAAA,IA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,EAAE;AAAA,EACJ;AACF;","names":["product"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nadohq/engine-client",
3
- "version": "0.1.0-alpha.36",
3
+ "version": "0.1.0-alpha.38",
4
4
  "type": "module",
5
5
  "sideEffects": false,
6
6
  "description": "> TODO: description",
@@ -41,7 +41,7 @@
41
41
  "module": "./dist/index.js",
42
42
  "types": "./dist/index.d.ts",
43
43
  "dependencies": {
44
- "@nadohq/shared": "^0.1.0-alpha.36",
44
+ "@nadohq/shared": "^0.1.0-alpha.38",
45
45
  "axios": "*",
46
46
  "ts-mixer": "*"
47
47
  },
@@ -51,5 +51,5 @@
51
51
  "devDependencies": {
52
52
  "viem": "*"
53
53
  },
54
- "gitHead": "e695f02dc33e35a17eb91a8bc6dde6f051823152"
54
+ "gitHead": "c8ac81156389514bb8ceec1f8a6193d55ef18b32"
55
55
  }
@@ -82,12 +82,12 @@ export interface EngineSymbol {
82
82
  priceIncrement: BigDecimal;
83
83
  sizeIncrement: BigDecimal;
84
84
  minSize: BigDecimal;
85
- minDepth: BigDecimal;
86
- maxSpreadRate: BigDecimal;
87
85
  makerFeeRate: BigDecimal;
88
86
  takerFeeRate: BigDecimal;
89
87
  longWeightInitial: BigDecimal;
90
88
  longWeightMaintenance: BigDecimal;
89
+ // undefined when there is no max open interest limit (always undefined for spot products)
90
+ maxOpenInterest: BigDecimal | undefined;
91
91
  }
92
92
 
93
93
  export type GetEngineAllMarketsResponse = MarketWithProduct[];
@@ -218,12 +218,12 @@ export interface EngineServerSymbol {
218
218
  price_increment_x18: string;
219
219
  size_increment: string;
220
220
  min_size: string;
221
- min_depth_x18: string;
222
- max_spread_rate_x18: string;
223
221
  maker_fee_rate_x18: string;
224
222
  taker_fee_rate_x18: string;
225
223
  long_weight_initial_x18: string;
226
224
  long_weight_maintenance_x18: string;
225
+ // undefined when there is no max open interest limit (always undefined for spot products)
226
+ max_open_interest_x18: string | undefined;
227
227
  }
228
228
 
229
229
  export interface EngineServerSymbolsResponse {
@@ -271,8 +271,6 @@ export function mapEngineServerSymbol(
271
271
  priceIncrement: removeDecimals(engineServerSymbol.price_increment_x18),
272
272
  sizeIncrement: toBigDecimal(engineServerSymbol.size_increment),
273
273
  minSize: toBigDecimal(engineServerSymbol.min_size),
274
- minDepth: removeDecimals(engineServerSymbol.min_depth_x18),
275
- maxSpreadRate: removeDecimals(engineServerSymbol.max_spread_rate_x18),
276
274
  makerFeeRate: removeDecimals(engineServerSymbol.maker_fee_rate_x18),
277
275
  takerFeeRate: removeDecimals(engineServerSymbol.taker_fee_rate_x18),
278
276
  longWeightInitial: removeDecimals(
@@ -281,6 +279,7 @@ export function mapEngineServerSymbol(
281
279
  longWeightMaintenance: removeDecimals(
282
280
  engineServerSymbol.long_weight_maintenance_x18,
283
281
  ),
282
+ maxOpenInterest: removeDecimals(engineServerSymbol.max_open_interest_x18),
284
283
  };
285
284
  }
286
285