{"version":3,"sources":["../../src/types/serverQueryTypes.ts"],"sourcesContent":["import { HealthStatus } from '@vertex-protocol/contracts';\nimport {\n  EngineServerHealthBreakdown,\n  EngineServerPerpBalance,\n  EngineServerPerpProduct,\n  EngineServerProductType,\n  EngineServerSpotBalance,\n  EngineServerSpotProduct,\n} from './serverQueryModelTypes';\n\nexport interface EngineServerNoncesParams {\n  address: string;\n}\n\nexport interface EngineServerSubaccountInfoQueryParams {\n  subaccount: string;\n  txns?: Array<\n    | {\n        mint_lp: {\n          product_id: number;\n          subaccount: string;\n          amount_base: string;\n          quote_amount_low: string;\n          quote_amount_high: string;\n        };\n      }\n    | {\n        burn_lp: {\n          product_id: number;\n          subaccount: string;\n          amount_lp: string;\n        };\n      }\n    | {\n        apply_delta: {\n          product_id: number;\n          subaccount: string;\n          amount_delta: string;\n          v_quote_delta: string;\n        };\n      }\n  >;\n}\n\nexport interface EngineServerIsolatedPositionsQueryParams {\n  subaccount: string;\n}\n\nexport interface EngineServerSymbolsQueryParams {\n  product_type?: EngineServerProductType;\n  product_ids?: number[];\n}\n\nexport interface EngineServerMarketPriceQueryParams {\n  product_id: number;\n}\n\nexport interface EngineServerMarketPricesQueryParams {\n  product_ids: number[];\n}\n\nexport interface EngineServerGetOrderQueryParams {\n  product_id: number;\n  digest: string;\n}\n\nexport interface EngineServerValidateOrderQueryParams {\n  product_id: number;\n  // Bytes for order, does not need to be signed\n  order: string;\n}\n\nexport interface EngineServerOrdersQueryParams {\n  sender: string;\n  product_ids: number[];\n}\n\nexport interface EngineServerSubaccountOrdersQueryParams {\n  sender: string;\n  product_id: number;\n}\n\nexport interface EngineServerSubaccountFeeRatesParams {\n  sender: string;\n}\n\nexport interface EngineServerMarketLiquidityQueryParams {\n  product_id: number;\n  depth: number;\n}\n\nexport interface EngineServerMaxWithdrawableQueryParams {\n  sender: string;\n  product_id: number;\n  // If not given, engine defaults to true (leverage/borrow enabled)\n  spot_leverage: string | null;\n}\n\nexport interface EngineServerMaxOrderSizeQueryParams {\n  sender: string;\n  product_id: number;\n  price_x18: string;\n  // Note: When `reduce_only` is true, `direction` must be opposite of the current position, otherwise it returns 0.\n  direction: 'long' | 'short';\n  // If not given, engine defaults to true (leverage/borrow enabled)\n  spot_leverage: string | null;\n  // If not given, engine defaults to false. If true, the max order size will be capped to the subaccount's current position size;\n  // If no position exists, it will return 0.\n  reduce_only: string | null;\n}\n\nexport interface EngineServerMaxMintLpQueryParams {\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 EngineServerLinkedSignerParams {\n  subaccount: string;\n}\n\nexport interface EngineServerMaxMintVlpQueryParams {\n  sender: string;\n  // If not given, engine defaults to true (leverage/borrow enabled)\n  spot_leverage: string | null;\n}\n\nexport interface EngineServerQueryRequestByType {\n  all_products: Record<string, never>;\n  contracts: Record<string, never>;\n  edge_all_products: Record<string, never>;\n  fee_rates: EngineServerSubaccountFeeRatesParams;\n  health_groups: Record<string, never>;\n  insurance: Record<string, never>;\n  isolated_positions: EngineServerIsolatedPositionsQueryParams;\n  linked_signer: EngineServerLinkedSignerParams;\n  market_liquidity: EngineServerMarketLiquidityQueryParams;\n  market_price: EngineServerMarketPriceQueryParams;\n  market_prices: EngineServerMarketPricesQueryParams;\n  max_lp_mintable: EngineServerMaxMintLpQueryParams;\n  max_vlp_mintable: EngineServerMaxMintVlpQueryParams;\n  max_order_size: EngineServerMaxOrderSizeQueryParams;\n  max_withdrawable: EngineServerMaxWithdrawableQueryParams;\n  min_deposit_rates: Record<string, never>;\n  nonces: EngineServerNoncesParams;\n  order: EngineServerGetOrderQueryParams;\n  orders: EngineServerOrdersQueryParams;\n  status: Record<string, never>;\n  subaccount_info: Omit<EngineServerSubaccountInfoQueryParams, 'txns'> & {\n    // JSON serialized txns\n    txns?: string;\n  };\n  subaccount_orders: EngineServerSubaccountOrdersQueryParams;\n  symbols: EngineServerSymbolsQueryParams;\n  validate_order: EngineServerValidateOrderQueryParams;\n}\n\nexport type EngineServerQueryRequestType = keyof EngineServerQueryRequestByType;\n\nexport type EngineServerQueryRequest<\n  TRequestType extends EngineServerQueryRequestType,\n> = {\n  type: TRequestType;\n} & EngineServerQueryRequestByType[TRequestType];\n\nexport interface EngineServerContractsResponse {\n  chain_id: string;\n  endpoint_addr: string;\n  // Index is product ID\n  book_addrs: string[];\n}\n\n// Unless in active state, engine is not fully operational\nexport type EngineServerStatusResponse =\n  | 'started'\n  | 'active'\n  | 'stopping'\n  | 'syncing'\n  | 'live_syncing'\n  | 'failed';\n\nexport interface EngineServerNoncesResponse {\n  order_nonce: string;\n  tx_nonce: string;\n}\n\nexport interface EngineServerSubaccountInfoResponse {\n  exists: boolean;\n  subaccount: string;\n  healths: [\n    initial: EngineServerHealthBreakdown,\n    maintenance: EngineServerHealthBreakdown,\n    unweighted: EngineServerHealthBreakdown,\n  ];\n  // First index is product ID, each subarray is of length 3 [initial, maintenance, unweighted]\n  health_contributions: string[][];\n  spot_count: number;\n  perp_count: number;\n  spot_balances: EngineServerSpotBalance[];\n  perp_balances: EngineServerPerpBalance[];\n  spot_products: EngineServerSpotProduct[];\n  perp_products: EngineServerPerpProduct[];\n}\n\nexport interface EngineServerIsolatedPosition {\n  subaccount: string;\n  healths: [\n    initial: HealthStatus,\n    maintenance: HealthStatus,\n    unweighted: HealthStatus,\n  ];\n  quote_healths: [initial: string, maintenance: string, unweighted: string];\n  base_healths: [initial: string, maintenance: string, unweighted: string];\n  quote_balance: EngineServerSpotBalance;\n  base_balance: EngineServerPerpBalance;\n  quote_product: EngineServerSpotProduct;\n  base_product: EngineServerPerpProduct;\n}\n\nexport type EngineServerIsolatedPositionsResponse = {\n  isolated_positions: EngineServerIsolatedPosition[];\n};\n\nexport interface EngineServerSymbol {\n  type: EngineServerProductType;\n  product_id: number;\n  symbol: string;\n  price_increment_x18: string;\n  size_increment: string;\n  min_size: string;\n  min_depth_x18: string;\n  max_spread_rate_x18: string;\n  maker_fee_rate_x18: string;\n  taker_fee_rate_x18: string;\n  long_weight_initial_x18: string;\n  long_weight_maintenance_x18: string;\n}\n\nexport interface EngineServerSymbolsResponse {\n  symbols: Record<string, EngineServerSymbol>;\n}\n\nexport interface EngineServerAllProductsResponse {\n  spot_products: EngineServerSpotProduct[];\n  perp_products: EngineServerPerpProduct[];\n}\n\nexport interface EngineServerHealthGroupsResponse {\n  health_groups: [spotProductId: number, perpProductId: number][];\n}\n\n// Price, liquidity pairs\nexport type EngineServerPriceTickLiquidity = [\n  priceX18: string,\n  liquidity: string,\n];\n\nexport interface EngineServerMarketLiquidityResponse {\n  bids: EngineServerPriceTickLiquidity[];\n  asks: EngineServerPriceTickLiquidity[];\n}\n\nexport interface EngineServerSubaccountOrders {\n  sender: string;\n  product_id: number;\n  orders: EngineServerOrder[];\n}\n\nexport type EngineServerSubaccountOrdersResponse = EngineServerSubaccountOrders;\n\nexport interface EngineServerProductOrdersResponse {\n  sender: string;\n  product_orders: EngineServerSubaccountOrders[];\n}\n\nexport interface EngineServerFeeRatesResponse {\n  liquidation_sequencer_fee: string;\n  health_check_sequencer_fee: string;\n  taker_sequencer_fee: string;\n  // Product ID is the index\n  withdraw_sequencer_fees: string[];\n  taker_fee_rates_x18: string[];\n  maker_fee_rates_x18: string[];\n}\n\nexport interface EngineServerMarketPrice {\n  product_id: number;\n  bid_x18: string;\n  ask_x18: string;\n}\n\nexport type EngineServerMarketPriceResponse = EngineServerMarketPrice;\n\nexport interface EngineServerMarketPricesResponse {\n  market_prices: EngineServerMarketPrice[];\n}\n\nexport interface EngineServerOrder {\n  product_id: number;\n  sender: string;\n  price_x18: string;\n  amount: string;\n  expiration: string;\n  nonce: string;\n  unfilled_amount: string;\n  digest: string;\n  placed_at: number;\n  order_type: string;\n  margin: string | null;\n}\n\nexport type EngineServerOrderResponse = EngineServerOrder;\n\nexport interface EngineServerValidateOrderResponse {\n  product_id: number;\n  order: string;\n  valid: boolean;\n}\n\nexport interface EngineServerMaxOrderSizeResponse {\n  max_order_size: string;\n}\n\nexport interface EngineServerMaxWithdrawableResponse {\n  max_withdrawable: string;\n}\n\nexport type EngineServerTimeResponse = number;\n\nexport interface EngineServerMaxMintLpResponse {\n  max_base_amount: string;\n  max_quote_amount: string;\n}\n\nexport interface EngineServerIpBlockResponse {\n  blocked: boolean;\n  reason: string;\n}\n\nexport interface EngineServerLinkedSignerResponse {\n  linked_signer: string;\n}\n\nexport interface EngineInsuranceResponse {\n  insurance: string;\n}\n\nexport interface EngineServerMinDepositRate {\n  product_id: number;\n  min_deposit_rate_x18: string;\n}\n\nexport interface EngineServerMinDepositRatesResponse {\n  // product_id -> EngineServerMinDepositRate\n  min_deposit_rates: Record<number, EngineServerMinDepositRate>;\n}\n\nexport interface EngineServerEdgeAllProductsResponse {\n  // chain_id -> EngineServerAllProductsResponse\n  edge_all_products: Record<number, EngineServerAllProductsResponse>;\n}\n\nexport interface EngineServerMaxMintVlpResponse {\n  max_quote_amount: string;\n}\n\nexport interface EngineServerQueryResponseByType {\n  all_products: EngineServerAllProductsResponse;\n  contracts: EngineServerContractsResponse;\n  edge_all_products: EngineServerEdgeAllProductsResponse;\n  fee_rates: EngineServerFeeRatesResponse;\n  health_groups: EngineServerHealthGroupsResponse;\n  insurance: EngineInsuranceResponse;\n  isolated_positions: EngineServerIsolatedPositionsResponse;\n  linked_signer: EngineServerLinkedSignerResponse;\n  market_liquidity: EngineServerMarketLiquidityResponse;\n  market_price: EngineServerMarketPriceResponse;\n  market_prices: EngineServerMarketPricesResponse;\n  max_lp_mintable: EngineServerMaxMintLpResponse;\n  max_vlp_mintable: EngineServerMaxMintVlpResponse;\n  max_order_size: EngineServerMaxOrderSizeResponse;\n  max_withdrawable: EngineServerMaxWithdrawableResponse;\n  min_deposit_rates: EngineServerMinDepositRatesResponse;\n  nonces: EngineServerNoncesResponse;\n  order: EngineServerOrderResponse;\n  orders: EngineServerProductOrdersResponse;\n  status: EngineServerStatusResponse;\n  subaccount_info: EngineServerSubaccountInfoResponse;\n  subaccount_orders: EngineServerSubaccountOrdersResponse;\n  symbols: EngineServerSymbolsResponse;\n  validate_order: EngineServerValidateOrderResponse;\n}\n\nexport interface EngineServerQuerySuccessResponse<\n  TQueryType extends\n    keyof EngineServerQueryResponseByType = EngineServerQueryRequestType,\n> {\n  status: 'success';\n  data: EngineServerQueryResponseByType[TQueryType];\n}\n\nexport interface EngineServerQueryFailureResponse {\n  status: 'failure';\n  error: string;\n  error_code: number;\n}\n\nexport type EngineServerQueryResponse<\n  TQueryType extends\n    keyof EngineServerQueryResponseByType = EngineServerQueryRequestType,\n> =\n  | EngineServerQuerySuccessResponse<TQueryType>\n  | EngineServerQueryFailureResponse;\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}