import { GetSubaccountSummaryParams, SubaccountSummaryResponse, Subaccount, BalanceHealthContributions, SpotBalanceWithProduct, PerpBalanceWithProduct, ProductEngineType, GetAllMarketsResponse, HealthGroup, EIP712OrderParams, OrderExpirationType, SignedEIP712OrderParams, BalanceSide } from '@vertex-protocol/contracts'; import { BigDecimal } from '@vertex-protocol/utils'; import { EngineServerNoncesParams, EngineServerTimeResponse } from './serverQueryTypes.js'; import './serverQueryModelTypes.js'; type GetEngineSubaccountSummaryResponse = SubaccountSummaryResponse; type GetEngineSubaccountSummaryParams = GetSubaccountSummaryParams; type GetEngineIsolatedPositionsParams = Subaccount; interface SubaccountIsolatedPosition { subaccount: Subaccount; healths: BalanceHealthContributions; quoteBalance: SpotBalanceWithProduct; baseBalance: PerpBalanceWithProduct; } type GetEngineIsolatedPositionsResponse = SubaccountIsolatedPosition[]; type SubaccountTx = { type: 'mint_lp'; tx: SubaccountMintLpTx; } | { type: 'burn_lp'; tx: SubaccountBurnLpTx; } | { type: 'apply_delta'; tx: SubaccountProductDeltaTx; }; interface SubaccountMintLpTx { productId: number; amountBase: BigDecimal; amountQuoteLow: BigDecimal; amountQuoteHigh: BigDecimal; } interface SubaccountBurnLpTx { productId: number; amountLp: BigDecimal; } interface SubaccountProductDeltaTx { productId: number; amountDelta: BigDecimal; vQuoteDelta: BigDecimal; } interface GetEngineContractsResponse { chainId: number; endpointAddr: string; /** * Address for the orderbook contract, with the product ID being the index */ orderbookAddrs: string[]; } type GetEngineEstimatedSubaccountSummaryParams = GetSubaccountSummaryParams & { txs: SubaccountTx[]; }; type GetEngineNoncesParams = EngineServerNoncesParams; interface GetEngineNoncesResponse { orderNonce: string; txNonce: string; } interface GetEngineSymbolsParams { productType?: ProductEngineType; productIds?: number[]; } interface EngineSymbolsResponse { symbols: Record; } interface EngineSymbol { type: ProductEngineType; productId: number; symbol: string; priceIncrement: BigDecimal; sizeIncrement: BigDecimal; minSize: BigDecimal; minDepth: BigDecimal; maxSpreadRate: BigDecimal; makerFeeRate: BigDecimal; takerFeeRate: BigDecimal; longWeightInitial: BigDecimal; longWeightMaintenance: BigDecimal; } type GetEngineAllMarketsResponse = GetAllMarketsResponse; interface GetEngineHealthGroupsResponse { healthGroups: HealthGroup[]; } interface GetEngineOrderParams { productId: number; digest: string; } interface EngineOrder extends Subaccount { productId: number; price: BigDecimal; totalAmount: BigDecimal; unfilledAmount: BigDecimal; expiration: BigDecimal; margin: BigDecimal | null; nonce: string; digest: string; orderParams: EIP712OrderParams; placementTime: number; orderType: OrderExpirationType; } type GetEngineOrderResponse = EngineOrder; interface ValidateSignedEngineOrderParams { productId: number; signedOrder: SignedEIP712OrderParams; } interface ValidateEngineOrderParams { productId: number; orderbookAddr: string; chainId: number; order: EIP712OrderParams; } interface ValidateEngineOrderResponse { productId: number; valid: boolean; } interface GetEngineSubaccountOrdersParams extends Subaccount { productId: number; } interface EngineSubaccountOrders { productId: number; orders: EngineOrder[]; } type GetEngineSubaccountOrdersResponse = EngineSubaccountOrders; interface GetEngineSubaccountProductOrdersParams extends Subaccount { productIds: number[]; } interface GetEngineSubaccountProductOrdersResponse { productOrders: EngineSubaccountOrders[]; } type GetEngineSubaccountFeeRatesParams = Subaccount; interface SubaccountOrderFeeRates { maker: BigDecimal; taker: BigDecimal; } interface GetEngineSubaccountFeeRatesResponse { orders: Record; withdrawal: Record; liquidationSequencerFee: BigDecimal; healthCheckSequencerFee: BigDecimal; takerSequencerFee: BigDecimal; } interface EnginePriceTickLiquidity { price: BigDecimal; liquidity: BigDecimal; } interface GetEngineMarketLiquidityParams { productId: number; depth: number; } interface GetEngineMarketLiquidityResponse { bids: EnginePriceTickLiquidity[]; asks: EnginePriceTickLiquidity[]; } interface GetEngineMarketPriceParams { productId: number; } interface EngineMarketPrice { productId: number; bid: BigDecimal; ask: BigDecimal; } type GetEngineMarketPriceResponse = EngineMarketPrice; interface GetEngineMarketPricesParams { productIds: number[]; } interface GetEngineMarketPricesResponse { marketPrices: EngineMarketPrice[]; } interface GetEngineMaxOrderSizeParams extends Subaccount { price: BigDecimal; productId: number; side: BalanceSide; spotLeverage?: boolean; reduceOnly?: boolean; } type GetEngineMaxOrderSizeResponse = BigDecimal; interface GetEngineMaxWithdrawableParams extends Subaccount { productId: number; spotLeverage?: boolean; } type GetEngineMaxWithdrawableResponse = BigDecimal; interface GetEngineMaxMintLpAmountParams extends Subaccount { productId: number; spotLeverage?: boolean; } interface GetEngineMaxMintLpAmountResponse { maxBaseAmount: BigDecimal; maxQuoteAmount: BigDecimal; } type GetEngineTimeResponse = EngineServerTimeResponse; type GetEngineLinkedSignerParams = Subaccount; interface GetEngineLinkedSignerResponse { signer: string; } type GetEngineInsuranceResponse = BigDecimal; interface EngineMinDepositRate { productId: number; minDepositRate: BigDecimal; } interface GetEngineMinDepositRatesResponse { minDepositRates: Record; } /** * Given an IP, backend will either: * - Allow queries only through archive / engine (query_only) * - Block all requests (blocked) * - Allow all requests (null) */ type GetEngineIpBlockStatusResponse = 'query_only' | 'blocked' | null; interface GetEngineMaxMintVlpAmountParams extends Subaccount { spotLeverage?: boolean; } type GetEngineMaxMintVlpAmountResponse = BigDecimal; export type { EngineMarketPrice, EngineMinDepositRate, EngineOrder, EnginePriceTickLiquidity, EngineSubaccountOrders, EngineSymbol, EngineSymbolsResponse, GetEngineAllMarketsResponse, GetEngineContractsResponse, GetEngineEstimatedSubaccountSummaryParams, GetEngineHealthGroupsResponse, GetEngineInsuranceResponse, GetEngineIpBlockStatusResponse, GetEngineIsolatedPositionsParams, GetEngineIsolatedPositionsResponse, GetEngineLinkedSignerParams, GetEngineLinkedSignerResponse, GetEngineMarketLiquidityParams, GetEngineMarketLiquidityResponse, GetEngineMarketPriceParams, GetEngineMarketPriceResponse, GetEngineMarketPricesParams, GetEngineMarketPricesResponse, GetEngineMaxMintLpAmountParams, GetEngineMaxMintLpAmountResponse, GetEngineMaxMintVlpAmountParams, GetEngineMaxMintVlpAmountResponse, GetEngineMaxOrderSizeParams, GetEngineMaxOrderSizeResponse, GetEngineMaxWithdrawableParams, GetEngineMaxWithdrawableResponse, GetEngineMinDepositRatesResponse, GetEngineNoncesParams, GetEngineNoncesResponse, GetEngineOrderParams, GetEngineOrderResponse, GetEngineSubaccountFeeRatesParams, GetEngineSubaccountFeeRatesResponse, GetEngineSubaccountOrdersParams, GetEngineSubaccountOrdersResponse, GetEngineSubaccountProductOrdersParams, GetEngineSubaccountProductOrdersResponse, GetEngineSubaccountSummaryParams, GetEngineSubaccountSummaryResponse, GetEngineSymbolsParams, GetEngineTimeResponse, SubaccountBurnLpTx, SubaccountIsolatedPosition, SubaccountMintLpTx, SubaccountOrderFeeRates, SubaccountProductDeltaTx, SubaccountTx, ValidateEngineOrderParams, ValidateEngineOrderResponse, ValidateSignedEngineOrderParams };