@nadohq/engine-client 0.1.0-alpha.1 → 0.1.0-alpha.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/EngineBaseClient.cjs +8 -7
- package/dist/EngineBaseClient.cjs.map +1 -1
- package/dist/EngineBaseClient.d.cts +1 -2
- package/dist/EngineBaseClient.d.ts +1 -2
- package/dist/EngineBaseClient.js +7 -5
- package/dist/EngineBaseClient.js.map +1 -1
- package/dist/EngineClient.d.cts +1 -2
- package/dist/EngineClient.d.ts +1 -2
- package/dist/EngineExecuteBuilder.cjs +33 -61
- package/dist/EngineExecuteBuilder.cjs.map +1 -1
- package/dist/EngineExecuteBuilder.d.cts +14 -25
- package/dist/EngineExecuteBuilder.d.ts +14 -25
- package/dist/EngineExecuteBuilder.js +25 -53
- package/dist/EngineExecuteBuilder.js.map +1 -1
- package/dist/EngineExecuteClient.cjs +12 -16
- package/dist/EngineExecuteClient.cjs.map +1 -1
- package/dist/EngineExecuteClient.d.cts +5 -6
- package/dist/EngineExecuteClient.d.ts +5 -6
- package/dist/EngineExecuteClient.js +12 -16
- package/dist/EngineExecuteClient.js.map +1 -1
- package/dist/EngineQueryClient.cjs +33 -57
- package/dist/EngineQueryClient.cjs.map +1 -1
- package/dist/EngineQueryClient.d.cts +4 -15
- package/dist/EngineQueryClient.d.ts +4 -15
- package/dist/EngineQueryClient.js +11 -35
- package/dist/EngineQueryClient.js.map +1 -1
- package/dist/EngineWebClient.cjs +0 -2
- package/dist/EngineWebClient.cjs.map +1 -1
- package/dist/EngineWebClient.d.cts +1 -2
- package/dist/EngineWebClient.d.ts +1 -2
- package/dist/EngineWebClient.js +0 -2
- package/dist/EngineWebClient.js.map +1 -1
- package/dist/endpoints.cjs +6 -6
- package/dist/endpoints.cjs.map +1 -1
- package/dist/endpoints.d.cts +1 -1
- package/dist/endpoints.d.ts +1 -1
- package/dist/endpoints.js +6 -6
- package/dist/endpoints.js.map +1 -1
- package/dist/index.d.cts +7 -8
- package/dist/index.d.ts +7 -8
- package/dist/types/EngineServerFailureError.cjs +1 -1
- package/dist/types/EngineServerFailureError.cjs.map +1 -1
- package/dist/types/EngineServerFailureError.d.cts +2 -2
- package/dist/types/EngineServerFailureError.d.ts +2 -2
- package/dist/types/EngineServerFailureError.js +1 -1
- package/dist/types/EngineServerFailureError.js.map +1 -1
- package/dist/types/clientExecuteTypes.cjs.map +1 -1
- package/dist/types/clientExecuteTypes.d.cts +8 -16
- package/dist/types/clientExecuteTypes.d.ts +8 -16
- package/dist/types/clientQueryTypes.cjs.map +1 -1
- package/dist/types/clientQueryTypes.d.cts +15 -25
- package/dist/types/clientQueryTypes.d.ts +15 -25
- package/dist/types/index.d.cts +7 -8
- package/dist/types/index.d.ts +7 -8
- package/dist/types/serverExecuteTypes.cjs.map +1 -1
- package/dist/types/serverExecuteTypes.d.cts +10 -18
- package/dist/types/serverExecuteTypes.d.ts +10 -18
- package/dist/types/serverQueryModelTypes.cjs.map +1 -1
- package/dist/types/serverQueryModelTypes.d.cts +1 -1
- package/dist/types/serverQueryModelTypes.d.ts +1 -1
- package/dist/types/serverQueryTypes.cjs.map +1 -1
- package/dist/types/serverQueryTypes.d.cts +8 -17
- package/dist/types/serverQueryTypes.d.ts +8 -17
- package/dist/types/serverSubscriptionEventTypes.cjs.map +1 -1
- package/dist/types/serverSubscriptionEventTypes.d.cts +83 -24
- package/dist/types/serverSubscriptionEventTypes.d.ts +83 -24
- package/dist/types/serverSubscriptionTypes.cjs.map +1 -1
- package/dist/types/serverSubscriptionTypes.d.cts +21 -4
- package/dist/types/serverSubscriptionTypes.d.ts +21 -4
- package/dist/utils/index.d.cts +1 -2
- package/dist/utils/index.d.ts +1 -2
- package/dist/utils/productEngineTypeMappers.cjs +5 -5
- package/dist/utils/productEngineTypeMappers.cjs.map +1 -1
- package/dist/utils/productEngineTypeMappers.d.cts +1 -1
- package/dist/utils/productEngineTypeMappers.d.ts +1 -1
- package/dist/utils/productEngineTypeMappers.js +1 -1
- package/dist/utils/productEngineTypeMappers.js.map +1 -1
- package/dist/utils/queryDataMappers.cjs +79 -90
- package/dist/utils/queryDataMappers.cjs.map +1 -1
- package/dist/utils/queryDataMappers.d.cts +1 -2
- package/dist/utils/queryDataMappers.d.ts +1 -2
- package/dist/utils/queryDataMappers.js +7 -19
- package/dist/utils/queryDataMappers.js.map +1 -1
- package/package.json +3 -4
- package/src/EngineBaseClient.ts +5 -3
- package/src/EngineExecuteBuilder.ts +30 -70
- package/src/EngineExecuteClient.ts +13 -21
- package/src/EngineQueryClient.ts +14 -42
- package/src/EngineWebClient.ts +0 -2
- package/src/endpoints.ts +4 -5
- package/src/types/EngineServerFailureError.ts +2 -2
- package/src/types/clientExecuteTypes.ts +13 -25
- package/src/types/clientQueryTypes.ts +21 -34
- package/src/types/serverExecuteTypes.ts +13 -24
- package/src/types/serverQueryModelTypes.ts +1 -1
- package/src/types/serverQueryTypes.ts +7 -20
- package/src/types/serverSubscriptionEventTypes.ts +130 -22
- package/src/types/serverSubscriptionTypes.ts +23 -3
- package/src/utils/productEngineTypeMappers.ts +1 -1
- package/src/utils/queryDataMappers.ts +7 -20
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/EngineQueryClient.ts"],"sourcesContent":["import {\n encodeSignedOrder,\n MarketWithProduct,\n subaccountToHex,\n} from '@nadohq/contracts';\nimport {\n addDecimals,\n BigDecimal,\n mapValues,\n removeDecimals,\n toBigDecimal,\n toIntegerString,\n} from '@nadohq/utils';\nimport { EngineBaseClient } from './EngineBaseClient';\nimport {\n EngineServerStatusResponse,\n EngineServerSubaccountInfoQueryParams,\n EngineSymbolsResponse,\n GetEngineAllMarketsResponse,\n GetEngineContractsResponse,\n GetEngineEstimatedSubaccountSummaryParams,\n GetEngineHealthGroupsResponse,\n GetEngineInsuranceResponse,\n GetEngineIsolatedPositionsParams,\n GetEngineIsolatedPositionsResponse,\n GetEngineLinkedSignerParams,\n GetEngineLinkedSignerResponse,\n GetEngineMarketLiquidityParams,\n GetEngineMarketLiquidityResponse,\n GetEngineMarketPriceParams,\n GetEngineMarketPriceResponse,\n GetEngineMarketPricesParams,\n GetEngineMarketPricesResponse,\n GetEngineMaxMintVlpAmountParams,\n GetEngineMaxMintVlpAmountResponse,\n GetEngineMaxOrderSizeParams,\n GetEngineMaxOrderSizeResponse,\n GetEngineMaxWithdrawableParams,\n GetEngineMaxWithdrawableResponse,\n GetEngineMinDepositRatesResponse,\n GetEngineOrderParams,\n GetEngineOrderResponse,\n GetEngineSubaccountFeeRatesParams,\n GetEngineSubaccountFeeRatesResponse,\n GetEngineSubaccountOrdersParams,\n GetEngineSubaccountOrdersResponse,\n GetEngineSubaccountProductOrdersParams,\n GetEngineSubaccountProductOrdersResponse,\n GetEngineSubaccountSummaryParams,\n GetEngineSubaccountSummaryResponse,\n GetEngineSymbolsParams,\n SubaccountOrderFeeRates,\n ValidateEngineOrderParams,\n ValidateEngineOrderResponse,\n ValidateSignedEngineOrderParams,\n} from './types';\nimport { mapProductEngineType } from './utils/productEngineTypeMappers';\nimport {\n mapEngineMarketPrice,\n mapEngineServerIsolatedPositions,\n mapEngineServerOrder,\n mapEngineServerPerpProduct,\n mapEngineServerSpotProduct,\n mapEngineServerSymbols,\n mapEngineServerTickLiquidity,\n mapSubaccountSummary,\n} from './utils/queryDataMappers';\n\nexport class EngineQueryClient extends EngineBaseClient {\n /**\n * Retrieves the set of contracts that the engine is interfacing with\n */\n async getContracts(): Promise<GetEngineContractsResponse> {\n const baseResponse = await this.query('contracts', {});\n return {\n chainId: Number(baseResponse.chain_id),\n endpointAddr: baseResponse.endpoint_addr,\n orderbookAddrs: baseResponse.book_addrs,\n };\n }\n\n /**\n * Retrieves current engine status\n */\n async getStatus(): Promise<EngineServerStatusResponse> {\n return this.query('status', {});\n }\n\n /**\n * Retrieves a subaccount summary reflective of the state within the offchain engine. This adheres to the\n * same return interface as the contract version\n *\n * @param params\n */\n async getSubaccountSummary(\n params: GetEngineSubaccountSummaryParams,\n ): Promise<GetEngineSubaccountSummaryResponse> {\n const subaccount = subaccountToHex({\n subaccountOwner: params.subaccountOwner,\n subaccountName: params.subaccountName,\n });\n const baseResponse = await this.query('subaccount_info', {\n subaccount,\n });\n\n return mapSubaccountSummary(baseResponse);\n }\n\n /**\n * Retrieves a list of isolated positions\n *\n * @param params\n */\n async getIsolatedPositions(\n params: GetEngineIsolatedPositionsParams,\n ): Promise<GetEngineIsolatedPositionsResponse> {\n const subaccount = subaccountToHex({\n subaccountOwner: params.subaccountOwner,\n subaccountName: params.subaccountName,\n });\n const baseResponse = await this.query('isolated_positions', {\n subaccount,\n });\n\n return mapEngineServerIsolatedPositions(baseResponse);\n }\n\n /**\n * Retrieves an estimated subaccount summary with the applied transactions\n *\n * @param params\n */\n async getEstimatedSubaccountSummary(\n params: GetEngineEstimatedSubaccountSummaryParams,\n ): Promise<GetEngineSubaccountSummaryResponse> {\n const subaccount = subaccountToHex({\n subaccountOwner: params.subaccountOwner,\n subaccountName: params.subaccountName,\n });\n const queryParams: EngineServerSubaccountInfoQueryParams = {\n subaccount: subaccount,\n txns: params.txs.map(\n (\n tx,\n ): NonNullable<\n EngineServerSubaccountInfoQueryParams['txns']\n >[number] => {\n switch (tx.type) {\n case 'apply_delta':\n return {\n apply_delta: {\n product_id: tx.tx.productId,\n subaccount,\n amount_delta: toIntegerString(tx.tx.amountDelta),\n v_quote_delta: toIntegerString(tx.tx.vQuoteDelta),\n },\n };\n }\n },\n ),\n };\n const baseResponse = await this.query('subaccount_info', {\n subaccount: queryParams.subaccount,\n txns: JSON.stringify(queryParams.txns),\n });\n\n return mapSubaccountSummary(baseResponse);\n }\n\n /**\n * Retrieves symbols and product info\n *\n * @param params\n */\n async getSymbols(\n params: GetEngineSymbolsParams,\n ): Promise<EngineSymbolsResponse> {\n const baseResponse = await this.query('symbols', {\n product_ids: params.productIds,\n product_type:\n params.productType != null\n ? mapProductEngineType(params.productType)\n : undefined,\n });\n return mapEngineServerSymbols(baseResponse);\n }\n\n /**\n * Retrieves all market states as per the offchain engine. Same return interface as contracts\n */\n async getAllMarkets(): Promise<GetEngineAllMarketsResponse> {\n const markets: MarketWithProduct[] = [];\n\n const baseResponse = await this.query('all_products', {});\n baseResponse.spot_products.forEach((spotProduct) => {\n markets.push(mapEngineServerSpotProduct(spotProduct));\n });\n baseResponse.perp_products.forEach((perpProduct) => {\n markets.push(mapEngineServerPerpProduct(perpProduct));\n });\n\n return markets;\n }\n\n /**\n * Retrieves all markets by chain id.\n */\n async getEdgeAllMarkets(): Promise<Record<number, MarketWithProduct[]>> {\n const baseResponse = await this.query('edge_all_products', {});\n\n return mapValues(baseResponse.edge_all_products, (allProducts) => {\n const markets: MarketWithProduct[] = [];\n\n allProducts.spot_products.forEach((spotProduct) => {\n markets.push(mapEngineServerSpotProduct(spotProduct));\n });\n\n allProducts.perp_products.forEach((perpProduct) => {\n markets.push(mapEngineServerPerpProduct(perpProduct));\n });\n\n return markets;\n });\n }\n\n /**\n * Retrieves all health groups (linked spot & perp products) from the engine\n */\n async getHealthGroups(): Promise<GetEngineHealthGroupsResponse> {\n const baseResponse = await this.query('health_groups', {});\n\n return {\n healthGroups: baseResponse.health_groups.map(\n ([spotProductId, perpProductId]) => {\n return {\n spotProductId,\n perpProductId,\n };\n },\n ),\n };\n }\n\n /**\n * Retrieves min deposit rates for all spot products from the engine\n */\n async getMinDepositRates(): Promise<GetEngineMinDepositRatesResponse> {\n const baseResponse = await this.query('min_deposit_rates', {});\n\n return {\n minDepositRates: mapValues(baseResponse.min_deposit_rates, (m) => {\n return {\n productId: m.product_id,\n minDepositRate: removeDecimals(m.min_deposit_rate_x18),\n };\n }),\n };\n }\n\n /**\n * Retrieves an order from the offchain engine\n *\n * @param params\n */\n async getOrder(\n params: GetEngineOrderParams,\n ): Promise<GetEngineOrderResponse> {\n const baseResponse = await this.query('order', {\n digest: params.digest,\n product_id: params.productId,\n });\n\n return mapEngineServerOrder(baseResponse);\n }\n\n /**\n * Signs and validates with the engine that the order is valid to be submitted (i.e. does not violate health reqs)\n *\n * @param params\n */\n async validateOrderParams(\n params: ValidateEngineOrderParams,\n ): Promise<ValidateEngineOrderResponse> {\n const signedOrder = {\n order: params.order,\n signature: await this.sign(\n 'place_order',\n params.orderbookAddr,\n params.chainId,\n params.order,\n ),\n };\n return this.validateSignedOrderParams({\n signedOrder,\n productId: params.productId,\n });\n }\n\n /**\n * Validates an existing signed order with the engine as a pre-check for health\n *\n * @param params\n */\n async validateSignedOrderParams(\n params: ValidateSignedEngineOrderParams,\n ): Promise<ValidateEngineOrderResponse> {\n const baseResponse = await this.query('validate_order', {\n product_id: params.productId,\n order: encodeSignedOrder(params.signedOrder),\n });\n\n return {\n productId: baseResponse.product_id,\n valid: baseResponse.valid,\n };\n }\n\n /**\n * Get all subaccount orders from the engine, per product ID\n * @param params\n */\n async getSubaccountOrders(\n params: GetEngineSubaccountOrdersParams,\n ): Promise<GetEngineSubaccountOrdersResponse> {\n const baseResponse = await this.query('subaccount_orders', {\n sender: subaccountToHex({\n subaccountOwner: params.subaccountOwner,\n subaccountName: params.subaccountName,\n }),\n product_id: params.productId,\n });\n\n return {\n orders: baseResponse.orders.map(mapEngineServerOrder),\n productId: params.productId,\n };\n }\n\n /**\n * Get all subaccount orders from the engine, for multiple products\n * @param params\n */\n async getSubaccountMultiProductOrders(\n params: GetEngineSubaccountProductOrdersParams,\n ): Promise<GetEngineSubaccountProductOrdersResponse> {\n const baseResponse = await this.query('orders', {\n sender: subaccountToHex({\n subaccountOwner: params.subaccountOwner,\n subaccountName: params.subaccountName,\n }),\n product_ids: params.productIds,\n });\n\n return {\n productOrders: baseResponse.product_orders.map((orders) => {\n return {\n orders: orders.orders.map(mapEngineServerOrder),\n productId: orders.product_id,\n };\n }),\n };\n }\n\n /**\n * Gets maker & taker fee rates for order fees\n * @param params\n */\n async getSubaccountFeeRates(\n params: GetEngineSubaccountFeeRatesParams,\n ): Promise<GetEngineSubaccountFeeRatesResponse> {\n const baseResponse = await this.query('fee_rates', {\n sender: subaccountToHex({\n subaccountOwner: params.subaccountOwner,\n subaccountName: params.subaccountName,\n }),\n });\n\n return {\n healthCheckSequencerFee: toBigDecimal(\n baseResponse.health_check_sequencer_fee,\n ),\n liquidationSequencerFee: toBigDecimal(\n baseResponse.liquidation_sequencer_fee,\n ),\n takerSequencerFee: toBigDecimal(baseResponse.taker_sequencer_fee),\n orders: baseResponse.taker_fee_rates_x18.reduce(\n (acc, takerRateX18, currIndex) => {\n acc[currIndex] = {\n taker: removeDecimals(takerRateX18),\n maker: removeDecimals(baseResponse.maker_fee_rates_x18[currIndex]),\n };\n return acc;\n },\n {} as Record<number, SubaccountOrderFeeRates>,\n ),\n withdrawal: baseResponse.withdraw_sequencer_fees.reduce(\n (acc, productFee, currIndex) => {\n acc[currIndex] = toBigDecimal(productFee);\n return acc;\n },\n {} as Record<number, BigDecimal>,\n ),\n };\n }\n\n /**\n * Gets \"price ticks\" for a given market, useful for constructing liquidity levels at each price\n * @param params\n */\n async getMarketLiquidity(\n params: GetEngineMarketLiquidityParams,\n ): Promise<GetEngineMarketLiquidityResponse> {\n const baseResponse = await this.query('market_liquidity', {\n product_id: params.productId,\n depth: params.depth,\n });\n return {\n asks: baseResponse.asks.map(mapEngineServerTickLiquidity),\n bids: baseResponse.bids.map(mapEngineServerTickLiquidity),\n };\n }\n\n /**\n * Retrieves the latest price for a given market\n * @param params\n */\n async getMarketPrice(\n params: GetEngineMarketPriceParams,\n ): Promise<GetEngineMarketPriceResponse> {\n const baseResponse = await this.query('market_price', {\n product_id: params.productId,\n });\n return mapEngineMarketPrice(baseResponse);\n }\n\n /**\n * Retrieves the latest prices for provided markets\n * @param params\n */\n async getMarketPrices(\n params: GetEngineMarketPricesParams,\n ): Promise<GetEngineMarketPricesResponse> {\n const baseResponse = await this.query('market_prices', {\n product_ids: params.productIds,\n });\n return {\n marketPrices: baseResponse.market_prices.map(mapEngineMarketPrice),\n };\n }\n\n /**\n * Retrieves the estimated max order size for a product\n * @param params\n */\n async getMaxOrderSize(\n params: GetEngineMaxOrderSizeParams,\n ): Promise<GetEngineMaxOrderSizeResponse> {\n const baseResponse = await this.query('max_order_size', {\n direction: params.side,\n price_x18: toIntegerString(addDecimals(params.price)),\n product_id: params.productId,\n sender: subaccountToHex({\n subaccountOwner: params.subaccountOwner,\n subaccountName: params.subaccountName,\n }),\n spot_leverage:\n params.spotLeverage != null ? String(params.spotLeverage) : null,\n reduce_only: params.reduceOnly != null ? String(params.reduceOnly) : null,\n });\n\n return toBigDecimal(baseResponse.max_order_size);\n }\n\n /**\n * Retrieves the estimated max withdrawal size for a product\n * @param params\n */\n async getMaxWithdrawable(\n params: GetEngineMaxWithdrawableParams,\n ): Promise<GetEngineMaxWithdrawableResponse> {\n const baseResponse = await this.query('max_withdrawable', {\n product_id: params.productId,\n sender: subaccountToHex({\n subaccountOwner: params.subaccountOwner,\n subaccountName: params.subaccountName,\n }),\n spot_leverage:\n params.spotLeverage != null ? String(params.spotLeverage) : null,\n });\n\n return toBigDecimal(baseResponse.max_withdrawable);\n }\n\n /**\n * Retrieves the estimated max quote amount for minting VLP.\n *\n * @param params\n */\n async getMaxMintVlpAmount(\n params: GetEngineMaxMintVlpAmountParams,\n ): Promise<GetEngineMaxMintVlpAmountResponse> {\n const baseResponse = await this.query('max_vlp_mintable', {\n sender: subaccountToHex({\n subaccountOwner: params.subaccountOwner,\n subaccountName: params.subaccountName,\n }),\n spot_leverage:\n params.spotLeverage != null ? String(params.spotLeverage) : null,\n });\n\n return toBigDecimal(baseResponse.max_quote_amount);\n }\n\n /**\n * Gets the currently linked signer for the subaccount\n * @param params\n * @returns\n */\n public async getLinkedSigner(\n params: GetEngineLinkedSignerParams,\n ): Promise<GetEngineLinkedSignerResponse> {\n const baseResponse = await this.query('linked_signer', {\n subaccount: subaccountToHex({\n subaccountOwner: params.subaccountOwner,\n subaccountName: params.subaccountName,\n }),\n });\n\n return {\n signer: baseResponse.linked_signer,\n };\n }\n\n /**\n * Gets the insurance funds in USDC.\n * @returns\n */\n public async getInsurance(): Promise<GetEngineInsuranceResponse> {\n const baseResponse = await this.query('insurance', {});\n\n return toBigDecimal(baseResponse.insurance);\n }\n\n /**\n * Gets the orderbook contract address for a given product\n * @param productId\n * @returns\n */\n public async getOrderbookAddress(productId: number): Promise<string> {\n const contracts = await this.getContracts();\n return contracts.orderbookAddrs[productId];\n }\n}\n"],"mappings":";AAAA;AAAA,EACE;AAAA,EAEA;AAAA,OACK;AACP;AAAA,EACE;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,wBAAwB;AA2CjC,SAAS,4BAA4B;AACrC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEA,IAAM,oBAAN,cAAgC,iBAAiB;AAAA;AAAA;AAAA;AAAA,EAItD,MAAM,eAAoD;AACxD,UAAM,eAAe,MAAM,KAAK,MAAM,aAAa,CAAC,CAAC;AACrD,WAAO;AAAA,MACL,SAAS,OAAO,aAAa,QAAQ;AAAA,MACrC,cAAc,aAAa;AAAA,MAC3B,gBAAgB,aAAa;AAAA,IAC/B;AAAA,EACF;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM,YAAiD;AACrD,WAAO,KAAK,MAAM,UAAU,CAAC,CAAC;AAAA,EAChC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,MAAM,qBACJ,QAC6C;AAC7C,UAAM,aAAa,gBAAgB;AAAA,MACjC,iBAAiB,OAAO;AAAA,MACxB,gBAAgB,OAAO;AAAA,IACzB,CAAC;AACD,UAAM,eAAe,MAAM,KAAK,MAAM,mBAAmB;AAAA,MACvD;AAAA,IACF,CAAC;AAED,WAAO,qBAAqB,YAAY;AAAA,EAC1C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,MAAM,qBACJ,QAC6C;AAC7C,UAAM,aAAa,gBAAgB;AAAA,MACjC,i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,OAAO,gBAAgB,OAAO,OAAO,OAAO,YAAY,IAAI;AAAA,IAChE,CAAC;AAED,WAAO,aAAa,aAAa,gBAAgB;AAAA,EACnD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,MAAM,oBACJ,QAC4C;AAC5C,UAAM,eAAe,MAAM,KAAK,MAAM,oBAAoB;AAAA,MACxD,QAAQ,gBAAgB;AAAA,QACtB,iBAAiB,OAAO;AAAA,QACxB,gBAAgB,OAAO;AAAA,MACzB,CAAC;AAAA,MACD,eACE,OAAO,gBAAgB,OAAO,OAAO,OAAO,YAAY,IAAI;AAAA,IAChE,CAAC;AAED,WAAO,aAAa,aAAa,gBAAgB;AAAA,EACnD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,MAAa,gBACX,QACwC;AACxC,UAAM,eAAe,MAAM,KAAK,MAAM,iBAAiB;AAAA,MACrD,YAAY,gBAAgB;AAAA,QAC1B,iBAAiB,OAAO;AAAA,QACxB,gBAAgB,OAAO;AAAA,MACzB,CAAC;AAAA,IACH,CAAC;AAED,WAAO;AAAA,MACL,QAAQ,aAAa;AAAA,IACvB;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,MAAa,eAAoD;AAC/D,UAAM,eAAe,MAAM,KAAK,MAAM,aAAa,CAAC,CAAC;AAErD,WAAO,aAAa,aAAa,SAAS;AAAA,EAC5C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,MAAa,oBAAoB,WAAoC;AACnE,UAAM,YAAY,MAAM,KAAK,aAAa;AAC1C,WAAO,UAAU,eAAe,SAAS;AAAA,EAC3C;AACF;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/EngineQueryClient.ts"],"sourcesContent":["import {\n addDecimals,\n BigDecimal,\n encodeSignedOrder,\n getOrderVerifyingAddress,\n mapValues,\n MarketWithProduct,\n removeDecimals,\n subaccountToHex,\n toBigDecimal,\n toIntegerString,\n} from '@nadohq/shared';\nimport { EngineBaseClient } from './EngineBaseClient';\nimport {\n EngineServerStatusResponse,\n EngineServerSubaccountInfoQueryParams,\n EngineSymbolsResponse,\n GetEngineAllMarketsResponse,\n GetEngineContractsResponse,\n GetEngineEstimatedSubaccountSummaryParams,\n GetEngineHealthGroupsResponse,\n GetEngineInsuranceResponse,\n GetEngineIsolatedPositionsParams,\n GetEngineIsolatedPositionsResponse,\n GetEngineLinkedSignerParams,\n GetEngineLinkedSignerResponse,\n GetEngineMarketLiquidityParams,\n GetEngineMarketLiquidityResponse,\n GetEngineMarketPriceParams,\n GetEngineMarketPriceResponse,\n GetEngineMarketPricesParams,\n GetEngineMarketPricesResponse,\n GetEngineMaxMintNlpAmountParams,\n GetEngineMaxMintNlpAmountResponse,\n GetEngineMaxOrderSizeParams,\n GetEngineMaxOrderSizeResponse,\n GetEngineMaxWithdrawableParams,\n GetEngineMaxWithdrawableResponse,\n GetEngineOrderParams,\n GetEngineOrderResponse,\n GetEngineSubaccountFeeRatesParams,\n GetEngineSubaccountFeeRatesResponse,\n GetEngineSubaccountOrdersParams,\n GetEngineSubaccountOrdersResponse,\n GetEngineSubaccountProductOrdersParams,\n GetEngineSubaccountProductOrdersResponse,\n GetEngineSubaccountSummaryParams,\n GetEngineSubaccountSummaryResponse,\n GetEngineSymbolsParams,\n SubaccountOrderFeeRates,\n ValidateEngineOrderParams,\n ValidateEngineOrderResponse,\n ValidateSignedEngineOrderParams,\n} from './types';\nimport { mapProductEngineType } from './utils/productEngineTypeMappers';\nimport {\n mapEngineMarketPrice,\n mapEngineServerIsolatedPositions,\n mapEngineServerOrder,\n mapEngineServerPerpProduct,\n mapEngineServerSpotProduct,\n mapEngineServerSymbols,\n mapEngineServerTickLiquidity,\n mapSubaccountSummary,\n} from './utils/queryDataMappers';\n\nexport class EngineQueryClient extends EngineBaseClient {\n /**\n * Retrieves the set of contracts that the engine is interfacing with\n */\n async getContracts(): Promise<GetEngineContractsResponse> {\n const baseResponse = await this.query('contracts', {});\n return {\n chainId: Number(baseResponse.chain_id),\n endpointAddr: baseResponse.endpoint_addr,\n };\n }\n\n /**\n * Retrieves current engine status\n */\n async getStatus(): Promise<EngineServerStatusResponse> {\n return this.query('status', {});\n }\n\n /**\n * Retrieves a subaccount summary reflective of the state within the offchain engine. This adheres to the\n * same return interface as the contract version\n *\n * @param params\n */\n async getSubaccountSummary(\n params: GetEngineSubaccountSummaryParams,\n ): Promise<GetEngineSubaccountSummaryResponse> {\n const subaccount = subaccountToHex({\n subaccountOwner: params.subaccountOwner,\n subaccountName: params.subaccountName,\n });\n const baseResponse = await this.query('subaccount_info', {\n subaccount,\n });\n\n return mapSubaccountSummary(baseResponse);\n }\n\n /**\n * Retrieves a list of isolated positions\n *\n * @param params\n */\n async getIsolatedPositions(\n params: GetEngineIsolatedPositionsParams,\n ): Promise<GetEngineIsolatedPositionsResponse> {\n const subaccount = subaccountToHex({\n subaccountOwner: params.subaccountOwner,\n subaccountName: params.subaccountName,\n });\n const baseResponse = await this.query('isolated_positions', {\n subaccount,\n });\n\n return mapEngineServerIsolatedPositions(baseResponse);\n }\n\n /**\n * Retrieves an estimated subaccount summary with the applied transactions\n *\n * @param params\n */\n async getEstimatedSubaccountSummary(\n params: GetEngineEstimatedSubaccountSummaryParams,\n ): Promise<GetEngineSubaccountSummaryResponse> {\n const subaccount = subaccountToHex({\n subaccountOwner: params.subaccountOwner,\n subaccountName: params.subaccountName,\n });\n const queryParams: EngineServerSubaccountInfoQueryParams = {\n subaccount: subaccount,\n txns: params.txs.map(\n (\n tx,\n ): NonNullable<\n EngineServerSubaccountInfoQueryParams['txns']\n >[number] => {\n switch (tx.type) {\n case 'apply_delta':\n return {\n apply_delta: {\n product_id: tx.tx.productId,\n subaccount,\n amount_delta: toIntegerString(tx.tx.amountDelta),\n v_quote_delta: toIntegerString(tx.tx.vQuoteDelta),\n },\n };\n }\n },\n ),\n };\n const baseResponse = await this.query('subaccount_info', {\n subaccount: queryParams.subaccount,\n txns: JSON.stringify(queryParams.txns),\n });\n\n return mapSubaccountSummary(baseResponse);\n }\n\n /**\n * Retrieves symbols and product info\n *\n * @param params\n */\n async getSymbols(\n params: GetEngineSymbolsParams,\n ): Promise<EngineSymbolsResponse> {\n const baseResponse = await this.query('symbols', {\n product_ids: params.productIds,\n product_type:\n params.productType != null\n ? mapProductEngineType(params.productType)\n : undefined,\n });\n return mapEngineServerSymbols(baseResponse);\n }\n\n /**\n * Retrieves all market states as per the offchain engine. Same return interface as contracts\n */\n async getAllMarkets(): Promise<GetEngineAllMarketsResponse> {\n const markets: MarketWithProduct[] = [];\n\n const baseResponse = await this.query('all_products', {});\n baseResponse.spot_products.forEach((spotProduct) => {\n markets.push(mapEngineServerSpotProduct(spotProduct));\n });\n baseResponse.perp_products.forEach((perpProduct) => {\n markets.push(mapEngineServerPerpProduct(perpProduct));\n });\n\n return markets;\n }\n\n /**\n * Retrieves all markets by chain id.\n */\n async getEdgeAllMarkets(): Promise<Record<number, MarketWithProduct[]>> {\n const baseResponse = await this.query('edge_all_products', {});\n\n return mapValues(baseResponse.edge_all_products, (allProducts) => {\n const markets: MarketWithProduct[] = [];\n\n allProducts.spot_products.forEach((spotProduct) => {\n markets.push(mapEngineServerSpotProduct(spotProduct));\n });\n\n allProducts.perp_products.forEach((perpProduct) => {\n markets.push(mapEngineServerPerpProduct(perpProduct));\n });\n\n return markets;\n });\n }\n\n /**\n * Retrieves all health groups (linked spot & perp products) from the engine\n */\n async getHealthGroups(): Promise<GetEngineHealthGroupsResponse> {\n const baseResponse = await this.query('health_groups', {});\n\n return {\n healthGroups: baseResponse.health_groups.map(\n ([spotProductId, perpProductId]) => {\n return {\n spotProductId,\n perpProductId,\n };\n },\n ),\n };\n }\n\n /**\n * Retrieves an order from the offchain engine\n *\n * @param params\n */\n async getOrder(\n params: GetEngineOrderParams,\n ): Promise<GetEngineOrderResponse> {\n const baseResponse = await this.query('order', {\n digest: params.digest,\n product_id: params.productId,\n });\n\n return mapEngineServerOrder(baseResponse);\n }\n\n /**\n * Signs and validates with the engine that the order is valid to be submitted (i.e. does not violate health reqs)\n *\n * @param params\n */\n async validateOrderParams(\n params: ValidateEngineOrderParams,\n ): Promise<ValidateEngineOrderResponse> {\n const signedOrder = {\n order: params.order,\n signature: await this.sign(\n 'place_order',\n getOrderVerifyingAddress(params.productId),\n params.chainId,\n params.order,\n ),\n };\n return this.validateSignedOrderParams({\n signedOrder,\n productId: params.productId,\n });\n }\n\n /**\n * Validates an existing signed order with the engine as a pre-check for health\n *\n * @param params\n */\n async validateSignedOrderParams(\n params: ValidateSignedEngineOrderParams,\n ): Promise<ValidateEngineOrderResponse> {\n const baseResponse = await this.query('validate_order', {\n product_id: params.productId,\n order: encodeSignedOrder(params.signedOrder),\n });\n\n return {\n productId: baseResponse.product_id,\n valid: baseResponse.valid,\n };\n }\n\n /**\n * Get all subaccount orders from the engine, per product ID\n * @param params\n */\n async getSubaccountOrders(\n params: GetEngineSubaccountOrdersParams,\n ): Promise<GetEngineSubaccountOrdersResponse> {\n const baseResponse = await this.query('subaccount_orders', {\n sender: subaccountToHex({\n subaccountOwner: params.subaccountOwner,\n subaccountName: params.subaccountName,\n }),\n product_id: params.productId,\n });\n\n return {\n orders: baseResponse.orders.map(mapEngineServerOrder),\n productId: params.productId,\n };\n }\n\n /**\n * Get all subaccount orders from the engine, for multiple products\n * @param params\n */\n async getSubaccountMultiProductOrders(\n params: GetEngineSubaccountProductOrdersParams,\n ): Promise<GetEngineSubaccountProductOrdersResponse> {\n const baseResponse = await this.query('orders', {\n sender: subaccountToHex({\n subaccountOwner: params.subaccountOwner,\n subaccountName: params.subaccountName,\n }),\n product_ids: params.productIds,\n });\n\n return {\n productOrders: baseResponse.product_orders.map((orders) => {\n return {\n orders: orders.orders.map(mapEngineServerOrder),\n productId: orders.product_id,\n };\n }),\n };\n }\n\n /**\n * Gets maker & taker fee rates for order fees\n * @param params\n */\n async getSubaccountFeeRates(\n params: GetEngineSubaccountFeeRatesParams,\n ): Promise<GetEngineSubaccountFeeRatesResponse> {\n const baseResponse = await this.query('fee_rates', {\n sender: subaccountToHex({\n subaccountOwner: params.subaccountOwner,\n subaccountName: params.subaccountName,\n }),\n });\n\n return {\n healthCheckSequencerFee: toBigDecimal(\n baseResponse.health_check_sequencer_fee,\n ),\n liquidationSequencerFee: toBigDecimal(\n baseResponse.liquidation_sequencer_fee,\n ),\n takerSequencerFee: toBigDecimal(baseResponse.taker_sequencer_fee),\n orders: baseResponse.taker_fee_rates_x18.reduce(\n (acc, takerRateX18, currIndex) => {\n acc[currIndex] = {\n taker: removeDecimals(takerRateX18),\n maker: removeDecimals(baseResponse.maker_fee_rates_x18[currIndex]),\n };\n return acc;\n },\n {} as Record<number, SubaccountOrderFeeRates>,\n ),\n withdrawal: baseResponse.withdraw_sequencer_fees.reduce(\n (acc, productFee, currIndex) => {\n acc[currIndex] = toBigDecimal(productFee);\n return acc;\n },\n {} as Record<number, BigDecimal>,\n ),\n feeTier: baseResponse.fee_tier,\n };\n }\n\n /**\n * Gets \"price ticks\" for a given market, useful for constructing liquidity levels at each price\n * @param params\n */\n async getMarketLiquidity(\n params: GetEngineMarketLiquidityParams,\n ): Promise<GetEngineMarketLiquidityResponse> {\n const baseResponse = await this.query('market_liquidity', {\n product_id: params.productId,\n depth: params.depth,\n });\n return {\n asks: baseResponse.asks.map(mapEngineServerTickLiquidity),\n bids: baseResponse.bids.map(mapEngineServerTickLiquidity),\n };\n }\n\n /**\n * Retrieves the latest price for a given market\n * @param params\n */\n async getMarketPrice(\n params: GetEngineMarketPriceParams,\n ): Promise<GetEngineMarketPriceResponse> {\n const baseResponse = await this.query('market_price', {\n product_id: params.productId,\n });\n return mapEngineMarketPrice(baseResponse);\n }\n\n /**\n * Retrieves the latest prices for provided markets\n * @param params\n */\n async getMarketPrices(\n params: GetEngineMarketPricesParams,\n ): Promise<GetEngineMarketPricesResponse> {\n const baseResponse = await this.query('market_prices', {\n product_ids: params.productIds,\n });\n return {\n marketPrices: baseResponse.market_prices.map(mapEngineMarketPrice),\n };\n }\n\n /**\n * Retrieves the estimated max order size for a product\n * @param params\n */\n async getMaxOrderSize(\n params: GetEngineMaxOrderSizeParams,\n ): Promise<GetEngineMaxOrderSizeResponse> {\n const baseResponse = await this.query('max_order_size', {\n direction: params.side,\n price_x18: toIntegerString(addDecimals(params.price)),\n product_id: params.productId,\n sender: subaccountToHex({\n subaccountOwner: params.subaccountOwner,\n subaccountName: params.subaccountName,\n }),\n spot_leverage:\n params.spotLeverage != null ? String(params.spotLeverage) : null,\n reduce_only: params.reduceOnly != null ? String(params.reduceOnly) : null,\n });\n\n return toBigDecimal(baseResponse.max_order_size);\n }\n\n /**\n * Retrieves the estimated max withdrawal size for a product\n * @param params\n */\n async getMaxWithdrawable(\n params: GetEngineMaxWithdrawableParams,\n ): Promise<GetEngineMaxWithdrawableResponse> {\n const baseResponse = await this.query('max_withdrawable', {\n product_id: params.productId,\n sender: subaccountToHex({\n subaccountOwner: params.subaccountOwner,\n subaccountName: params.subaccountName,\n }),\n spot_leverage:\n params.spotLeverage != null ? String(params.spotLeverage) : null,\n });\n\n return toBigDecimal(baseResponse.max_withdrawable);\n }\n\n /**\n * Retrieves the estimated max quote amount for minting NLP.\n *\n * @param params\n */\n async getMaxMintNlpAmount(\n params: GetEngineMaxMintNlpAmountParams,\n ): Promise<GetEngineMaxMintNlpAmountResponse> {\n const baseResponse = await this.query('max_nlp_mintable', {\n sender: subaccountToHex({\n subaccountOwner: params.subaccountOwner,\n subaccountName: params.subaccountName,\n }),\n spot_leverage:\n params.spotLeverage != null ? String(params.spotLeverage) : null,\n });\n\n return toBigDecimal(baseResponse.max_quote_amount);\n }\n\n /**\n * Gets the currently linked signer for the subaccount\n * @param params\n * @returns\n */\n public async getLinkedSigner(\n params: GetEngineLinkedSignerParams,\n ): Promise<GetEngineLinkedSignerResponse> {\n const baseResponse = await this.query('linked_signer', {\n subaccount: subaccountToHex({\n subaccountOwner: params.subaccountOwner,\n subaccountName: params.subaccountName,\n }),\n });\n\n return {\n signer: baseResponse.linked_signer,\n };\n }\n\n /**\n * Gets the insurance funds in USDC.\n * @returns\n */\n public async getInsurance(): Promise<GetEngineInsuranceResponse> {\n const baseResponse = await this.query('insurance', {});\n\n return toBigDecimal(baseResponse.insurance);\n }\n}\n"],"mappings":";AAAA;AAAA,EACE;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,wBAAwB;AA0CjC,SAAS,4BAA4B;AACrC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEA,IAAM,oBAAN,cAAgC,iBAAiB;AAAA;AAAA;AAAA;AAAA,EAItD,MAAM,eAAoD;AACxD,UAAM,eAAe,MAAM,KAAK,MAAM,aAAa,CAAC,CAAC;AACrD,WAAO;AAAA,MACL,SAAS,OAAO,aAAa,QAAQ;AAAA,MACrC,cAAc,aAAa;AAAA,IAC7B;AAAA,EACF;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM,YAAiD;AACrD,WAAO,KAAK,MAAM,UAAU,CAAC,CAAC;AAAA,EAChC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,MAAM,qBACJ,QAC6C;AAC7C,UAAM,aAAa,gBAAgB;AAAA,MACjC,iBAAiB,OAAO;AAAA,MACxB,gBAAgB,OAAO;AAAA,IACzB,CAAC;AACD,UAAM,eAAe,MAAM,KAAK,MAAM,mBAAmB;AAAA,MACvD;AAAA,IACF,CAAC;AAED,WAAO,qBAAqB,YAAY;AAAA,EAC1C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,MAAM,qBACJ,QAC6C;AAC7C,UAAM,aAAa,gBAAgB;AAAA,MACjC,iBAAiB,OAAO;AAAA,MACxB,gBAAgB,OAAO;AAAA,IACzB,CAAC;AACD,UAAM,eAAe,MAAM,KAAK,MAAM,sBAAsB;AAAA,MAC1D;AAAA,IACF,CA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,IAChE,CAAC;AAED,WAAO,aAAa,aAAa,gBAAgB;AAAA,EACnD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,MAAa,gBACX,QACwC;AACxC,UAAM,eAAe,MAAM,KAAK,MAAM,iBAAiB;AAAA,MACrD,YAAY,gBAAgB;AAAA,QAC1B,iBAAiB,OAAO;AAAA,QACxB,gBAAgB,OAAO;AAAA,MACzB,CAAC;AAAA,IACH,CAAC;AAED,WAAO;AAAA,MACL,QAAQ,aAAa;AAAA,IACvB;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,MAAa,eAAoD;AAC/D,UAAM,eAAe,MAAM,KAAK,MAAM,aAAa,CAAC,CAAC;AAErD,WAAO,aAAa,aAAa,SAAS;AAAA,EAC5C;AACF;","names":[]}
|
package/dist/EngineWebClient.cjs
CHANGED
|
@@ -30,8 +30,6 @@ var EngineWebClient = class extends import_EngineBaseClient.EngineBaseClient {
|
|
|
30
30
|
*/
|
|
31
31
|
async getIpBlockStatus() {
|
|
32
32
|
return this.axiosInstance.get(`${this.opts.url}/ip`, {
|
|
33
|
-
// Allow all statuses
|
|
34
|
-
validateStatus: () => true,
|
|
35
33
|
// IP checks go through Cloudflare, which uses allow-origin as *, so withCredentials needs to be false
|
|
36
34
|
withCredentials: false
|
|
37
35
|
}).then((res) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/EngineWebClient.ts"],"sourcesContent":["import { EngineBaseClient } from './EngineBaseClient';\nimport {\n EngineServerIpBlockResponse,\n GetEngineIpBlockStatusResponse,\n GetEngineTimeResponse,\n} from './types';\n\n/**\n * Queries that talk directly to web, _not_ the engine. Placing here in the `engine-client` as we don't have enough\n * use cases to justify a separate package\n */\nexport class EngineWebClient extends EngineBaseClient {\n /**\n * Determines the IP block status for the current client\n */\n async getIpBlockStatus(): Promise<GetEngineIpBlockStatusResponse> {\n return (\n this.axiosInstance\n // Use the /time endpoint and listen to 403 responses\n .get(`${this.opts.url}/ip`, {\n //
|
|
1
|
+
{"version":3,"sources":["../src/EngineWebClient.ts"],"sourcesContent":["import { EngineBaseClient } from './EngineBaseClient';\nimport {\n EngineServerIpBlockResponse,\n GetEngineIpBlockStatusResponse,\n GetEngineTimeResponse,\n} from './types';\n\n/**\n * Queries that talk directly to web, _not_ the engine. Placing here in the `engine-client` as we don't have enough\n * use cases to justify a separate package\n */\nexport class EngineWebClient extends EngineBaseClient {\n /**\n * Determines the IP block status for the current client\n */\n async getIpBlockStatus(): Promise<GetEngineIpBlockStatusResponse> {\n return (\n this.axiosInstance\n // Use the /time endpoint and listen to 403 responses\n .get(`${this.opts.url}/ip`, {\n // IP checks go through Cloudflare, which uses allow-origin as *, so withCredentials needs to be false\n withCredentials: false,\n })\n .then((res) => {\n if (res.status !== 403) {\n return null;\n }\n const resData = res.data as EngineServerIpBlockResponse;\n\n if (!resData.blocked) {\n return null;\n }\n\n return resData.reason === 'ip_query_only' ? 'query_only' : 'blocked';\n })\n );\n }\n\n /**\n * Determines whether a client needs to complete the cloudflare JS challenge to interact with the API\n *\n * @return true if the client needs to complete the JS challenge at '/challenge', false otherwise\n */\n async getRequiresCloudflareAuth(): Promise<boolean> {\n // We use a generic endpoint and check for the CF challenge header\n // Note: this uses a CORS set to the relevant frontend endpoint (ex. testnet.vertexprotocol.com) so it will NOT\n // work from other domains\n return this.axiosInstance\n .get(`${this.opts.url}/cf-check`, {\n // Allow all statuses\n validateStatus: () => true,\n })\n .then((res) => {\n if (res.status !== 403) {\n return false;\n }\n\n return res.headers['cf-mitigated'] === 'challenge';\n });\n }\n\n /**\n * Retrieves current server epoch in milliseconds\n */\n async getTime(): Promise<GetEngineTimeResponse> {\n return this.axiosInstance\n .get(`${this.opts.url}/time`)\n .then((res) => res.data as GetEngineTimeResponse);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,8BAAiC;AAW1B,IAAM,kBAAN,cAA8B,yCAAiB;AAAA;AAAA;AAAA;AAAA,EAIpD,MAAM,mBAA4D;AAChE,WACE,KAAK,cAEF,IAAI,GAAG,KAAK,KAAK,GAAG,OAAO;AAAA;AAAA,MAE1B,iBAAiB;AAAA,IACnB,CAAC,EACA,KAAK,CAAC,QAAQ;AACb,UAAI,IAAI,WAAW,KAAK;AACtB,eAAO;AAAA,MACT;AACA,YAAM,UAAU,IAAI;AAEpB,UAAI,CAAC,QAAQ,SAAS;AACpB,eAAO;AAAA,MACT;AAEA,aAAO,QAAQ,WAAW,kBAAkB,eAAe;AAAA,IAC7D,CAAC;AAAA,EAEP;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,MAAM,4BAA8C;AAIlD,WAAO,KAAK,cACT,IAAI,GAAG,KAAK,KAAK,GAAG,aAAa;AAAA;AAAA,MAEhC,gBAAgB,MAAM;AAAA,IACxB,CAAC,EACA,KAAK,CAAC,QAAQ;AACb,UAAI,IAAI,WAAW,KAAK;AACtB,eAAO;AAAA,MACT;AAEA,aAAO,IAAI,QAAQ,cAAc,MAAM;AAAA,IACzC,CAAC;AAAA,EACL;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM,UAA0C;AAC9C,WAAO,KAAK,cACT,IAAI,GAAG,KAAK,KAAK,GAAG,OAAO,EAC3B,KAAK,CAAC,QAAQ,IAAI,IAA6B;AAAA,EACpD;AACF;","names":[]}
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { EngineBaseClient } from './EngineBaseClient.cjs';
|
|
2
2
|
import { GetEngineIpBlockStatusResponse, GetEngineTimeResponse } from './types/clientQueryTypes.cjs';
|
|
3
|
-
import '@nadohq/
|
|
3
|
+
import '@nadohq/shared';
|
|
4
4
|
import 'axios';
|
|
5
5
|
import './types/serverExecuteTypes.cjs';
|
|
6
6
|
import './types/serverQueryTypes.cjs';
|
|
7
7
|
import './types/serverQueryModelTypes.cjs';
|
|
8
|
-
import '@nadohq/utils';
|
|
9
8
|
|
|
10
9
|
/**
|
|
11
10
|
* Queries that talk directly to web, _not_ the engine. Placing here in the `engine-client` as we don't have enough
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { EngineBaseClient } from './EngineBaseClient.js';
|
|
2
2
|
import { GetEngineIpBlockStatusResponse, GetEngineTimeResponse } from './types/clientQueryTypes.js';
|
|
3
|
-
import '@nadohq/
|
|
3
|
+
import '@nadohq/shared';
|
|
4
4
|
import 'axios';
|
|
5
5
|
import './types/serverExecuteTypes.js';
|
|
6
6
|
import './types/serverQueryTypes.js';
|
|
7
7
|
import './types/serverQueryModelTypes.js';
|
|
8
|
-
import '@nadohq/utils';
|
|
9
8
|
|
|
10
9
|
/**
|
|
11
10
|
* Queries that talk directly to web, _not_ the engine. Placing here in the `engine-client` as we don't have enough
|
package/dist/EngineWebClient.js
CHANGED
|
@@ -6,8 +6,6 @@ var EngineWebClient = class extends EngineBaseClient {
|
|
|
6
6
|
*/
|
|
7
7
|
async getIpBlockStatus() {
|
|
8
8
|
return this.axiosInstance.get(`${this.opts.url}/ip`, {
|
|
9
|
-
// Allow all statuses
|
|
10
|
-
validateStatus: () => true,
|
|
11
9
|
// IP checks go through Cloudflare, which uses allow-origin as *, so withCredentials needs to be false
|
|
12
10
|
withCredentials: false
|
|
13
11
|
}).then((res) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/EngineWebClient.ts"],"sourcesContent":["import { EngineBaseClient } from './EngineBaseClient';\nimport {\n EngineServerIpBlockResponse,\n GetEngineIpBlockStatusResponse,\n GetEngineTimeResponse,\n} from './types';\n\n/**\n * Queries that talk directly to web, _not_ the engine. Placing here in the `engine-client` as we don't have enough\n * use cases to justify a separate package\n */\nexport class EngineWebClient extends EngineBaseClient {\n /**\n * Determines the IP block status for the current client\n */\n async getIpBlockStatus(): Promise<GetEngineIpBlockStatusResponse> {\n return (\n this.axiosInstance\n // Use the /time endpoint and listen to 403 responses\n .get(`${this.opts.url}/ip`, {\n //
|
|
1
|
+
{"version":3,"sources":["../src/EngineWebClient.ts"],"sourcesContent":["import { EngineBaseClient } from './EngineBaseClient';\nimport {\n EngineServerIpBlockResponse,\n GetEngineIpBlockStatusResponse,\n GetEngineTimeResponse,\n} from './types';\n\n/**\n * Queries that talk directly to web, _not_ the engine. Placing here in the `engine-client` as we don't have enough\n * use cases to justify a separate package\n */\nexport class EngineWebClient extends EngineBaseClient {\n /**\n * Determines the IP block status for the current client\n */\n async getIpBlockStatus(): Promise<GetEngineIpBlockStatusResponse> {\n return (\n this.axiosInstance\n // Use the /time endpoint and listen to 403 responses\n .get(`${this.opts.url}/ip`, {\n // IP checks go through Cloudflare, which uses allow-origin as *, so withCredentials needs to be false\n withCredentials: false,\n })\n .then((res) => {\n if (res.status !== 403) {\n return null;\n }\n const resData = res.data as EngineServerIpBlockResponse;\n\n if (!resData.blocked) {\n return null;\n }\n\n return resData.reason === 'ip_query_only' ? 'query_only' : 'blocked';\n })\n );\n }\n\n /**\n * Determines whether a client needs to complete the cloudflare JS challenge to interact with the API\n *\n * @return true if the client needs to complete the JS challenge at '/challenge', false otherwise\n */\n async getRequiresCloudflareAuth(): Promise<boolean> {\n // We use a generic endpoint and check for the CF challenge header\n // Note: this uses a CORS set to the relevant frontend endpoint (ex. testnet.vertexprotocol.com) so it will NOT\n // work from other domains\n return this.axiosInstance\n .get(`${this.opts.url}/cf-check`, {\n // Allow all statuses\n validateStatus: () => true,\n })\n .then((res) => {\n if (res.status !== 403) {\n return false;\n }\n\n return res.headers['cf-mitigated'] === 'challenge';\n });\n }\n\n /**\n * Retrieves current server epoch in milliseconds\n */\n async getTime(): Promise<GetEngineTimeResponse> {\n return this.axiosInstance\n .get(`${this.opts.url}/time`)\n .then((res) => res.data as GetEngineTimeResponse);\n }\n}\n"],"mappings":";AAAA,SAAS,wBAAwB;AAW1B,IAAM,kBAAN,cAA8B,iBAAiB;AAAA;AAAA;AAAA;AAAA,EAIpD,MAAM,mBAA4D;AAChE,WACE,KAAK,cAEF,IAAI,GAAG,KAAK,KAAK,GAAG,OAAO;AAAA;AAAA,MAE1B,iBAAiB;AAAA,IACnB,CAAC,EACA,KAAK,CAAC,QAAQ;AACb,UAAI,IAAI,WAAW,KAAK;AACtB,eAAO;AAAA,MACT;AACA,YAAM,UAAU,IAAI;AAEpB,UAAI,CAAC,QAAQ,SAAS;AACpB,eAAO;AAAA,MACT;AAEA,aAAO,QAAQ,WAAW,kBAAkB,eAAe;AAAA,IAC7D,CAAC;AAAA,EAEP;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,MAAM,4BAA8C;AAIlD,WAAO,KAAK,cACT,IAAI,GAAG,KAAK,KAAK,GAAG,aAAa;AAAA;AAAA,MAEhC,gBAAgB,MAAM;AAAA,IACxB,CAAC,EACA,KAAK,CAAC,QAAQ;AACb,UAAI,IAAI,WAAW,KAAK;AACtB,eAAO;AAAA,MACT;AAEA,aAAO,IAAI,QAAQ,cAAc,MAAM;AAAA,IACzC,CAAC;AAAA,EACL;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM,UAA0C;AAC9C,WAAO,KAAK,cACT,IAAI,GAAG,KAAK,KAAK,GAAG,OAAO,EAC3B,KAAK,CAAC,QAAQ,IAAI,IAA6B;AAAA,EACpD;AACF;","names":[]}
|
package/dist/endpoints.cjs
CHANGED
|
@@ -27,18 +27,18 @@ __export(endpoints_exports, {
|
|
|
27
27
|
module.exports = __toCommonJS(endpoints_exports);
|
|
28
28
|
var ENGINE_CLIENT_ENDPOINTS = {
|
|
29
29
|
local: "http://localhost:80",
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
arbitrum: "https://gateway.prod.vertexprotocol.com/v1",
|
|
31
|
+
inkTestnet: "https://gateway.test.nado-backend.xyz/v1"
|
|
32
32
|
};
|
|
33
33
|
var ENGINE_WS_CLIENT_ENDPOINTS = {
|
|
34
34
|
local: "ws://localhost:80",
|
|
35
|
-
|
|
36
|
-
|
|
35
|
+
arbitrum: "wss://gateway.prod.vertexprotocol.com/v1/ws",
|
|
36
|
+
inkTestnet: "wss://gateway.test.nado-backend.xyz/v1/ws"
|
|
37
37
|
};
|
|
38
38
|
var ENGINE_WS_SUBSCRIPTION_CLIENT_ENDPOINTS = {
|
|
39
39
|
local: "ws://localhost:80",
|
|
40
|
-
|
|
41
|
-
|
|
40
|
+
arbitrum: "wss://gateway.prod.vertexprotocol.com/v1/subscribe",
|
|
41
|
+
inkTestnet: "wss://gateway.test.nado-backend.xyz/v1/subscribe"
|
|
42
42
|
};
|
|
43
43
|
// Annotate the CommonJS export names for ESM import in node:
|
|
44
44
|
0 && (module.exports = {
|
package/dist/endpoints.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/endpoints.ts"],"sourcesContent":["import { ChainEnv } from '@nadohq/
|
|
1
|
+
{"version":3,"sources":["../src/endpoints.ts"],"sourcesContent":["import { ChainEnv } from '@nadohq/shared';\n\nexport const ENGINE_CLIENT_ENDPOINTS: Record<ChainEnv, string> = {\n local: 'http://localhost:80',\n arbitrum: 'https://gateway.prod.vertexprotocol.com/v1',\n inkTestnet: 'https://gateway.test.nado-backend.xyz/v1',\n};\n\nexport const ENGINE_WS_CLIENT_ENDPOINTS: Record<ChainEnv, string> = {\n local: 'ws://localhost:80',\n arbitrum: 'wss://gateway.prod.vertexprotocol.com/v1/ws',\n inkTestnet: 'wss://gateway.test.nado-backend.xyz/v1/ws',\n};\n\nexport const ENGINE_WS_SUBSCRIPTION_CLIENT_ENDPOINTS: Record<ChainEnv, string> =\n {\n local: 'ws://localhost:80',\n arbitrum: 'wss://gateway.prod.vertexprotocol.com/v1/subscribe',\n inkTestnet: 'wss://gateway.test.nado-backend.xyz/v1/subscribe',\n };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEO,IAAM,0BAAoD;AAAA,EAC/D,OAAO;AAAA,EACP,UAAU;AAAA,EACV,YAAY;AACd;AAEO,IAAM,6BAAuD;AAAA,EAClE,OAAO;AAAA,EACP,UAAU;AAAA,EACV,YAAY;AACd;AAEO,IAAM,0CACX;AAAA,EACE,OAAO;AAAA,EACP,UAAU;AAAA,EACV,YAAY;AACd;","names":[]}
|
package/dist/endpoints.d.cts
CHANGED
package/dist/endpoints.d.ts
CHANGED
package/dist/endpoints.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
// src/endpoints.ts
|
|
2
2
|
var ENGINE_CLIENT_ENDPOINTS = {
|
|
3
3
|
local: "http://localhost:80",
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
arbitrum: "https://gateway.prod.vertexprotocol.com/v1",
|
|
5
|
+
inkTestnet: "https://gateway.test.nado-backend.xyz/v1"
|
|
6
6
|
};
|
|
7
7
|
var ENGINE_WS_CLIENT_ENDPOINTS = {
|
|
8
8
|
local: "ws://localhost:80",
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
arbitrum: "wss://gateway.prod.vertexprotocol.com/v1/ws",
|
|
10
|
+
inkTestnet: "wss://gateway.test.nado-backend.xyz/v1/ws"
|
|
11
11
|
};
|
|
12
12
|
var ENGINE_WS_SUBSCRIPTION_CLIENT_ENDPOINTS = {
|
|
13
13
|
local: "ws://localhost:80",
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
arbitrum: "wss://gateway.prod.vertexprotocol.com/v1/subscribe",
|
|
15
|
+
inkTestnet: "wss://gateway.test.nado-backend.xyz/v1/subscribe"
|
|
16
16
|
};
|
|
17
17
|
export {
|
|
18
18
|
ENGINE_CLIENT_ENDPOINTS,
|
package/dist/endpoints.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/endpoints.ts"],"sourcesContent":["import { ChainEnv } from '@nadohq/
|
|
1
|
+
{"version":3,"sources":["../src/endpoints.ts"],"sourcesContent":["import { ChainEnv } from '@nadohq/shared';\n\nexport const ENGINE_CLIENT_ENDPOINTS: Record<ChainEnv, string> = {\n local: 'http://localhost:80',\n arbitrum: 'https://gateway.prod.vertexprotocol.com/v1',\n inkTestnet: 'https://gateway.test.nado-backend.xyz/v1',\n};\n\nexport const ENGINE_WS_CLIENT_ENDPOINTS: Record<ChainEnv, string> = {\n local: 'ws://localhost:80',\n arbitrum: 'wss://gateway.prod.vertexprotocol.com/v1/ws',\n inkTestnet: 'wss://gateway.test.nado-backend.xyz/v1/ws',\n};\n\nexport const ENGINE_WS_SUBSCRIPTION_CLIENT_ENDPOINTS: Record<ChainEnv, string> =\n {\n local: 'ws://localhost:80',\n arbitrum: 'wss://gateway.prod.vertexprotocol.com/v1/subscribe',\n inkTestnet: 'wss://gateway.test.nado-backend.xyz/v1/subscribe',\n };\n"],"mappings":";AAEO,IAAM,0BAAoD;AAAA,EAC/D,OAAO;AAAA,EACP,UAAU;AAAA,EACV,YAAY;AACd;AAEO,IAAM,6BAAuD;AAAA,EAClE,OAAO;AAAA,EACP,UAAU;AAAA,EACV,YAAY;AACd;AAEO,IAAM,0CACX;AAAA,EACE,OAAO;AAAA,EACP,UAAU;AAAA,EACV,YAAY;AACd;","names":[]}
|
package/dist/index.d.cts
CHANGED
|
@@ -1,16 +1,15 @@
|
|
|
1
|
-
export { EngineMarketPrice,
|
|
2
|
-
export {
|
|
3
|
-
export { EngineInsuranceResponse, EngineServerAllProductsResponse, EngineServerContractsResponse, EngineServerEdgeAllProductsResponse, EngineServerFeeRatesResponse, EngineServerGetOrderQueryParams, EngineServerHealthGroupsResponse, EngineServerIpBlockResponse, EngineServerIsolatedPosition, EngineServerIsolatedPositionsQueryParams, EngineServerIsolatedPositionsResponse, EngineServerLinkedSignerParams, EngineServerLinkedSignerResponse, EngineServerMarketLiquidityQueryParams, EngineServerMarketLiquidityResponse, EngineServerMarketPrice, EngineServerMarketPriceQueryParams, EngineServerMarketPriceResponse, EngineServerMarketPricesQueryParams, EngineServerMarketPricesResponse,
|
|
1
|
+
export { EngineMarketPrice, EngineOrder, EnginePriceTickLiquidity, EngineSubaccountOrders, EngineSymbol, EngineSymbolsResponse, GetEngineAllMarketsResponse, GetEngineContractsResponse, GetEngineEstimatedSubaccountSummaryParams, GetEngineHealthGroupsResponse, GetEngineInsuranceResponse, GetEngineIpBlockStatusResponse, GetEngineIsolatedPositionsParams, GetEngineIsolatedPositionsResponse, GetEngineLinkedSignerParams, GetEngineLinkedSignerResponse, GetEngineMarketLiquidityParams, GetEngineMarketLiquidityResponse, GetEngineMarketPriceParams, GetEngineMarketPriceResponse, GetEngineMarketPricesParams, GetEngineMarketPricesResponse, GetEngineMaxMintNlpAmountParams, GetEngineMaxMintNlpAmountResponse, GetEngineMaxOrderSizeParams, GetEngineMaxOrderSizeResponse, GetEngineMaxWithdrawableParams, GetEngineMaxWithdrawableResponse, GetEngineNoncesParams, GetEngineNoncesResponse, GetEngineOrderParams, GetEngineOrderResponse, GetEngineSubaccountFeeRatesParams, GetEngineSubaccountFeeRatesResponse, GetEngineSubaccountOrdersParams, GetEngineSubaccountOrdersResponse, GetEngineSubaccountProductOrdersParams, GetEngineSubaccountProductOrdersResponse, GetEngineSubaccountSummaryParams, GetEngineSubaccountSummaryResponse, GetEngineSymbolsParams, GetEngineTimeResponse, SubaccountIsolatedPosition, SubaccountOrderFeeRates, SubaccountProductDeltaTx, SubaccountTx, ValidateEngineOrderParams, ValidateEngineOrderResponse, ValidateSignedEngineOrderParams } from './types/clientQueryTypes.cjs';
|
|
2
|
+
export { EngineBurnNlpParams, EngineCancelAndPlaceParams, EngineCancelOrdersParams, EngineCancelProductOrdersParams, EngineExecuteRequestParamsByType, EngineLinkSignerParams, EngineLiquidateSubaccountParams, EngineMintNlpParams, EngineOrderParams, EnginePlaceOrderParams, EnginePlaceOrderResult, EnginePlaceOrdersParams, EngineTransferQuoteParams, EngineWithdrawCollateralParams, SignatureParams, WithBaseEngineExecuteParams, WithSignature } from './types/clientExecuteTypes.cjs';
|
|
3
|
+
export { EngineInsuranceResponse, EngineServerAllProductsResponse, EngineServerContractsResponse, EngineServerEdgeAllProductsResponse, EngineServerFeeRatesResponse, EngineServerGetOrderQueryParams, EngineServerHealthGroupsResponse, EngineServerIpBlockResponse, EngineServerIsolatedPosition, EngineServerIsolatedPositionsQueryParams, EngineServerIsolatedPositionsResponse, EngineServerLinkedSignerParams, EngineServerLinkedSignerResponse, EngineServerMarketLiquidityQueryParams, EngineServerMarketLiquidityResponse, EngineServerMarketPrice, EngineServerMarketPriceQueryParams, EngineServerMarketPriceResponse, EngineServerMarketPricesQueryParams, EngineServerMarketPricesResponse, EngineServerMaxMintNlpQueryParams, EngineServerMaxMintNlpResponse, EngineServerMaxOrderSizeQueryParams, EngineServerMaxOrderSizeResponse, EngineServerMaxWithdrawableQueryParams, EngineServerMaxWithdrawableResponse, EngineServerNoncesParams, EngineServerNoncesResponse, EngineServerOrder, EngineServerOrderResponse, EngineServerOrdersQueryParams, EngineServerPriceTickLiquidity, EngineServerProductOrdersResponse, EngineServerQueryFailureResponse, EngineServerQueryRequest, EngineServerQueryRequestByType, EngineServerQueryRequestType, EngineServerQueryResponse, EngineServerQueryResponseByType, EngineServerQuerySuccessResponse, EngineServerStatusResponse, EngineServerSubaccountFeeRatesParams, EngineServerSubaccountInfoQueryParams, EngineServerSubaccountInfoResponse, EngineServerSubaccountOrders, EngineServerSubaccountOrdersQueryParams, EngineServerSubaccountOrdersResponse, EngineServerSymbol, EngineServerSymbolsQueryParams, EngineServerSymbolsResponse, EngineServerTimeResponse, EngineServerValidateOrderQueryParams, EngineServerValidateOrderResponse } from './types/serverQueryTypes.cjs';
|
|
4
4
|
export { EngineServerBookInfo, EngineServerHealthBreakdown, EngineServerPerpBalance, EngineServerPerpBalanceData, EngineServerPerpProduct, EngineServerPerpState, EngineServerProductType, EngineServerRisk, EngineServerSpotBalance, EngineServerSpotBalanceData, EngineServerSpotConfig, EngineServerSpotProduct, EngineServerSpotState } from './types/serverQueryModelTypes.cjs';
|
|
5
|
-
export { EngineServerCancelOrdersParams, EngineServerCancelOrdersResponse, EngineServerExecuteFailureResult,
|
|
6
|
-
export { EngineServerBestBidOfferStreamParams, EngineServerBookDepthStreamParams, EngineServerFillStreamParams, EngineServerOrderUpdateStreamParams, EngineServerPositionChangeStreamParams, EngineServerSubscriptionParams, EngineServerSubscriptionRequest, EngineServerSubscriptionRequestByType, EngineServerSubscriptionRequestType, EngineServerSubscriptionStream, EngineServerSubscriptionStreamParamsByType, EngineServerSubscriptionStreamParamsType, EngineServerTradeStreamParams } from './types/serverSubscriptionTypes.cjs';
|
|
7
|
-
export { EngineServerSubscriptionBestBidOfferEvent, EngineServerSubscriptionBookDepthEvent, EngineServerSubscriptionFillEvent, EngineServerSubscriptionOrderUpdateEvent, EngineServerSubscriptionPositionChangeEvent, EngineServerSubscriptionTradeEvent } from './types/serverSubscriptionEventTypes.cjs';
|
|
5
|
+
export { EngineServerCancelOrdersParams, EngineServerCancelOrdersResponse, EngineServerExecuteFailureResult, EngineServerExecutePlaceOrderPayload, EngineServerExecuteRequestByType, EngineServerExecuteRequestType, EngineServerExecuteResponseDataByType, EngineServerExecuteResult, EngineServerExecuteSuccessResult, EngineServerPlaceOrderParams, EngineServerPlaceOrderResponse, EngineServerPlaceOrdersResponse, EngineServiceCancelAndPlaceParams } from './types/serverExecuteTypes.cjs';
|
|
6
|
+
export { EngineServerBestBidOfferStreamParams, EngineServerBookDepthStreamParams, EngineServerFillStreamParams, EngineServerFundingPaymentStreamParams, EngineServerLatestCandlestickStreamParams, EngineServerLiquidationStreamParams, EngineServerOrderUpdateStreamParams, EngineServerPositionChangeStreamParams, EngineServerSubscriptionParams, EngineServerSubscriptionRequest, EngineServerSubscriptionRequestByType, EngineServerSubscriptionRequestType, EngineServerSubscriptionStream, EngineServerSubscriptionStreamParamsByType, EngineServerSubscriptionStreamParamsType, EngineServerTradeStreamParams } from './types/serverSubscriptionTypes.cjs';
|
|
7
|
+
export { EngineServerSubscriptionBaseEvent, EngineServerSubscriptionBestBidOfferEvent, EngineServerSubscriptionBookDepthEvent, EngineServerSubscriptionEvent, EngineServerSubscriptionEventType, EngineServerSubscriptionFillEvent, EngineServerSubscriptionFundingPaymentEvent, EngineServerSubscriptionLatestCandlestickEvent, EngineServerSubscriptionLiquidationEvent, EngineServerSubscriptionOrderUpdateEvent, EngineServerSubscriptionPositionChangeEvent, EngineServerSubscriptionTradeEvent, OrderUpdateReason, PositionChangeReason } from './types/serverSubscriptionEventTypes.cjs';
|
|
8
8
|
export { EngineServerFailureError } from './types/EngineServerFailureError.cjs';
|
|
9
9
|
export { EngineClient } from './EngineClient.cjs';
|
|
10
10
|
export { ENGINE_CLIENT_ENDPOINTS, ENGINE_WS_CLIENT_ENDPOINTS, ENGINE_WS_SUBSCRIPTION_CLIENT_ENDPOINTS } from './endpoints.cjs';
|
|
11
11
|
export { mapEngineMarketPrice, mapEngineServerBalanceHealthContributions, mapEngineServerIsolatedPositions, mapEngineServerOrder, mapEngineServerPerpProduct, mapEngineServerSpotProduct, mapEngineServerSymbol, mapEngineServerSymbols, mapEngineServerTickLiquidity, mapSubaccountSummary } from './utils/queryDataMappers.cjs';
|
|
12
|
-
import '@nadohq/
|
|
13
|
-
import '@nadohq/utils';
|
|
12
|
+
import '@nadohq/shared';
|
|
14
13
|
import 'ts-mixer/dist/types/types';
|
|
15
14
|
import './EngineExecuteClient.cjs';
|
|
16
15
|
import './EngineBaseClient.cjs';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,16 +1,15 @@
|
|
|
1
|
-
export { EngineMarketPrice,
|
|
2
|
-
export {
|
|
3
|
-
export { EngineInsuranceResponse, EngineServerAllProductsResponse, EngineServerContractsResponse, EngineServerEdgeAllProductsResponse, EngineServerFeeRatesResponse, EngineServerGetOrderQueryParams, EngineServerHealthGroupsResponse, EngineServerIpBlockResponse, EngineServerIsolatedPosition, EngineServerIsolatedPositionsQueryParams, EngineServerIsolatedPositionsResponse, EngineServerLinkedSignerParams, EngineServerLinkedSignerResponse, EngineServerMarketLiquidityQueryParams, EngineServerMarketLiquidityResponse, EngineServerMarketPrice, EngineServerMarketPriceQueryParams, EngineServerMarketPriceResponse, EngineServerMarketPricesQueryParams, EngineServerMarketPricesResponse,
|
|
1
|
+
export { EngineMarketPrice, EngineOrder, EnginePriceTickLiquidity, EngineSubaccountOrders, EngineSymbol, EngineSymbolsResponse, GetEngineAllMarketsResponse, GetEngineContractsResponse, GetEngineEstimatedSubaccountSummaryParams, GetEngineHealthGroupsResponse, GetEngineInsuranceResponse, GetEngineIpBlockStatusResponse, GetEngineIsolatedPositionsParams, GetEngineIsolatedPositionsResponse, GetEngineLinkedSignerParams, GetEngineLinkedSignerResponse, GetEngineMarketLiquidityParams, GetEngineMarketLiquidityResponse, GetEngineMarketPriceParams, GetEngineMarketPriceResponse, GetEngineMarketPricesParams, GetEngineMarketPricesResponse, GetEngineMaxMintNlpAmountParams, GetEngineMaxMintNlpAmountResponse, GetEngineMaxOrderSizeParams, GetEngineMaxOrderSizeResponse, GetEngineMaxWithdrawableParams, GetEngineMaxWithdrawableResponse, GetEngineNoncesParams, GetEngineNoncesResponse, GetEngineOrderParams, GetEngineOrderResponse, GetEngineSubaccountFeeRatesParams, GetEngineSubaccountFeeRatesResponse, GetEngineSubaccountOrdersParams, GetEngineSubaccountOrdersResponse, GetEngineSubaccountProductOrdersParams, GetEngineSubaccountProductOrdersResponse, GetEngineSubaccountSummaryParams, GetEngineSubaccountSummaryResponse, GetEngineSymbolsParams, GetEngineTimeResponse, SubaccountIsolatedPosition, SubaccountOrderFeeRates, SubaccountProductDeltaTx, SubaccountTx, ValidateEngineOrderParams, ValidateEngineOrderResponse, ValidateSignedEngineOrderParams } from './types/clientQueryTypes.js';
|
|
2
|
+
export { EngineBurnNlpParams, EngineCancelAndPlaceParams, EngineCancelOrdersParams, EngineCancelProductOrdersParams, EngineExecuteRequestParamsByType, EngineLinkSignerParams, EngineLiquidateSubaccountParams, EngineMintNlpParams, EngineOrderParams, EnginePlaceOrderParams, EnginePlaceOrderResult, EnginePlaceOrdersParams, EngineTransferQuoteParams, EngineWithdrawCollateralParams, SignatureParams, WithBaseEngineExecuteParams, WithSignature } from './types/clientExecuteTypes.js';
|
|
3
|
+
export { EngineInsuranceResponse, EngineServerAllProductsResponse, EngineServerContractsResponse, EngineServerEdgeAllProductsResponse, EngineServerFeeRatesResponse, EngineServerGetOrderQueryParams, EngineServerHealthGroupsResponse, EngineServerIpBlockResponse, EngineServerIsolatedPosition, EngineServerIsolatedPositionsQueryParams, EngineServerIsolatedPositionsResponse, EngineServerLinkedSignerParams, EngineServerLinkedSignerResponse, EngineServerMarketLiquidityQueryParams, EngineServerMarketLiquidityResponse, EngineServerMarketPrice, EngineServerMarketPriceQueryParams, EngineServerMarketPriceResponse, EngineServerMarketPricesQueryParams, EngineServerMarketPricesResponse, EngineServerMaxMintNlpQueryParams, EngineServerMaxMintNlpResponse, EngineServerMaxOrderSizeQueryParams, EngineServerMaxOrderSizeResponse, EngineServerMaxWithdrawableQueryParams, EngineServerMaxWithdrawableResponse, EngineServerNoncesParams, EngineServerNoncesResponse, EngineServerOrder, EngineServerOrderResponse, EngineServerOrdersQueryParams, EngineServerPriceTickLiquidity, EngineServerProductOrdersResponse, EngineServerQueryFailureResponse, EngineServerQueryRequest, EngineServerQueryRequestByType, EngineServerQueryRequestType, EngineServerQueryResponse, EngineServerQueryResponseByType, EngineServerQuerySuccessResponse, EngineServerStatusResponse, EngineServerSubaccountFeeRatesParams, EngineServerSubaccountInfoQueryParams, EngineServerSubaccountInfoResponse, EngineServerSubaccountOrders, EngineServerSubaccountOrdersQueryParams, EngineServerSubaccountOrdersResponse, EngineServerSymbol, EngineServerSymbolsQueryParams, EngineServerSymbolsResponse, EngineServerTimeResponse, EngineServerValidateOrderQueryParams, EngineServerValidateOrderResponse } from './types/serverQueryTypes.js';
|
|
4
4
|
export { EngineServerBookInfo, EngineServerHealthBreakdown, EngineServerPerpBalance, EngineServerPerpBalanceData, EngineServerPerpProduct, EngineServerPerpState, EngineServerProductType, EngineServerRisk, EngineServerSpotBalance, EngineServerSpotBalanceData, EngineServerSpotConfig, EngineServerSpotProduct, EngineServerSpotState } from './types/serverQueryModelTypes.js';
|
|
5
|
-
export { EngineServerCancelOrdersParams, EngineServerCancelOrdersResponse, EngineServerExecuteFailureResult,
|
|
6
|
-
export { EngineServerBestBidOfferStreamParams, EngineServerBookDepthStreamParams, EngineServerFillStreamParams, EngineServerOrderUpdateStreamParams, EngineServerPositionChangeStreamParams, EngineServerSubscriptionParams, EngineServerSubscriptionRequest, EngineServerSubscriptionRequestByType, EngineServerSubscriptionRequestType, EngineServerSubscriptionStream, EngineServerSubscriptionStreamParamsByType, EngineServerSubscriptionStreamParamsType, EngineServerTradeStreamParams } from './types/serverSubscriptionTypes.js';
|
|
7
|
-
export { EngineServerSubscriptionBestBidOfferEvent, EngineServerSubscriptionBookDepthEvent, EngineServerSubscriptionFillEvent, EngineServerSubscriptionOrderUpdateEvent, EngineServerSubscriptionPositionChangeEvent, EngineServerSubscriptionTradeEvent } from './types/serverSubscriptionEventTypes.js';
|
|
5
|
+
export { EngineServerCancelOrdersParams, EngineServerCancelOrdersResponse, EngineServerExecuteFailureResult, EngineServerExecutePlaceOrderPayload, EngineServerExecuteRequestByType, EngineServerExecuteRequestType, EngineServerExecuteResponseDataByType, EngineServerExecuteResult, EngineServerExecuteSuccessResult, EngineServerPlaceOrderParams, EngineServerPlaceOrderResponse, EngineServerPlaceOrdersResponse, EngineServiceCancelAndPlaceParams } from './types/serverExecuteTypes.js';
|
|
6
|
+
export { EngineServerBestBidOfferStreamParams, EngineServerBookDepthStreamParams, EngineServerFillStreamParams, EngineServerFundingPaymentStreamParams, EngineServerLatestCandlestickStreamParams, EngineServerLiquidationStreamParams, EngineServerOrderUpdateStreamParams, EngineServerPositionChangeStreamParams, EngineServerSubscriptionParams, EngineServerSubscriptionRequest, EngineServerSubscriptionRequestByType, EngineServerSubscriptionRequestType, EngineServerSubscriptionStream, EngineServerSubscriptionStreamParamsByType, EngineServerSubscriptionStreamParamsType, EngineServerTradeStreamParams } from './types/serverSubscriptionTypes.js';
|
|
7
|
+
export { EngineServerSubscriptionBaseEvent, EngineServerSubscriptionBestBidOfferEvent, EngineServerSubscriptionBookDepthEvent, EngineServerSubscriptionEvent, EngineServerSubscriptionEventType, EngineServerSubscriptionFillEvent, EngineServerSubscriptionFundingPaymentEvent, EngineServerSubscriptionLatestCandlestickEvent, EngineServerSubscriptionLiquidationEvent, EngineServerSubscriptionOrderUpdateEvent, EngineServerSubscriptionPositionChangeEvent, EngineServerSubscriptionTradeEvent, OrderUpdateReason, PositionChangeReason } from './types/serverSubscriptionEventTypes.js';
|
|
8
8
|
export { EngineServerFailureError } from './types/EngineServerFailureError.js';
|
|
9
9
|
export { EngineClient } from './EngineClient.js';
|
|
10
10
|
export { ENGINE_CLIENT_ENDPOINTS, ENGINE_WS_CLIENT_ENDPOINTS, ENGINE_WS_SUBSCRIPTION_CLIENT_ENDPOINTS } from './endpoints.js';
|
|
11
11
|
export { mapEngineMarketPrice, mapEngineServerBalanceHealthContributions, mapEngineServerIsolatedPositions, mapEngineServerOrder, mapEngineServerPerpProduct, mapEngineServerSpotProduct, mapEngineServerSymbol, mapEngineServerSymbols, mapEngineServerTickLiquidity, mapSubaccountSummary } from './utils/queryDataMappers.js';
|
|
12
|
-
import '@nadohq/
|
|
13
|
-
import '@nadohq/utils';
|
|
12
|
+
import '@nadohq/shared';
|
|
14
13
|
import 'ts-mixer/dist/types/types';
|
|
15
14
|
import './EngineExecuteClient.js';
|
|
16
15
|
import './EngineBaseClient.js';
|
|
@@ -25,7 +25,7 @@ __export(EngineServerFailureError_exports, {
|
|
|
25
25
|
module.exports = __toCommonJS(EngineServerFailureError_exports);
|
|
26
26
|
var EngineServerFailureError = class extends Error {
|
|
27
27
|
constructor(responseData) {
|
|
28
|
-
super();
|
|
28
|
+
super(`${responseData.error_code}: ${responseData.error}`);
|
|
29
29
|
this.responseData = responseData;
|
|
30
30
|
}
|
|
31
31
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/types/EngineServerFailureError.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"sources":["../../src/types/EngineServerFailureError.ts"],"sourcesContent":["import { EngineServerExecuteFailureResult } from './serverExecuteTypes';\nimport { EngineServerQueryFailureResponse } from './serverQueryTypes';\n\nexport class EngineServerFailureError extends Error {\n constructor(\n readonly responseData:\n | EngineServerQueryFailureResponse\n | EngineServerExecuteFailureResult,\n ) {\n super(`${responseData.error_code}: ${responseData.error}`);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGO,IAAM,2BAAN,cAAuC,MAAM;AAAA,EAClD,YACW,cAGT;AACA,UAAM,GAAG,aAAa,UAAU,KAAK,aAAa,KAAK,EAAE;AAJhD;AAAA,EAKX;AACF;","names":[]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { EngineServerQueryFailureResponse } from './serverQueryTypes.cjs';
|
|
2
1
|
import { EngineServerExecuteFailureResult } from './serverExecuteTypes.cjs';
|
|
3
|
-
import '
|
|
2
|
+
import { EngineServerQueryFailureResponse } from './serverQueryTypes.cjs';
|
|
3
|
+
import '@nadohq/shared';
|
|
4
4
|
import './serverQueryModelTypes.cjs';
|
|
5
5
|
|
|
6
6
|
declare class EngineServerFailureError extends Error {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { EngineServerQueryFailureResponse } from './serverQueryTypes.js';
|
|
2
1
|
import { EngineServerExecuteFailureResult } from './serverExecuteTypes.js';
|
|
3
|
-
import '
|
|
2
|
+
import { EngineServerQueryFailureResponse } from './serverQueryTypes.js';
|
|
3
|
+
import '@nadohq/shared';
|
|
4
4
|
import './serverQueryModelTypes.js';
|
|
5
5
|
|
|
6
6
|
declare class EngineServerFailureError extends Error {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/types/EngineServerFailureError.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"sources":["../../src/types/EngineServerFailureError.ts"],"sourcesContent":["import { EngineServerExecuteFailureResult } from './serverExecuteTypes';\nimport { EngineServerQueryFailureResponse } from './serverQueryTypes';\n\nexport class EngineServerFailureError extends Error {\n constructor(\n readonly responseData:\n | EngineServerQueryFailureResponse\n | EngineServerExecuteFailureResult,\n ) {\n super(`${responseData.error_code}: ${responseData.error}`);\n }\n}\n"],"mappings":";AAGO,IAAM,2BAAN,cAAuC,MAAM;AAAA,EAClD,YACW,cAGT;AACA,UAAM,GAAG,aAAa,UAAU,KAAK,aAAa,KAAK,EAAE;AAJhD;AAAA,EAKX;AACF;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/types/clientExecuteTypes.ts"],"sourcesContent":["import {\n
|
|
1
|
+
{"version":3,"sources":["../../src/types/clientExecuteTypes.ts"],"sourcesContent":["import {\n EIP712BurnNlpParams,\n EIP712CancelOrdersParams,\n EIP712CancelProductOrdersParams,\n EIP712LinkSignerParams,\n EIP712LiquidateSubaccountParams,\n EIP712MintNlpParams,\n EIP712OrderParams,\n EIP712TransferQuoteParams,\n EIP712WithdrawCollateralParams,\n} from '@nadohq/shared';\nimport { EngineServerExecuteSuccessResult } from './serverExecuteTypes';\n\n/**\n * Either verifying address or signature must be provided;\n * If signature is not provided, the verifying address with the engine signer will be used to sign.\n */\nexport type SignatureParams =\n | {\n // Endpoint address for all executes except order placement\n verifyingAddr: string;\n chainId: number;\n }\n | {\n signature: string;\n };\n\ntype WithoutNonce<T extends { nonce: unknown }> = Omit<T, 'nonce'>;\n\ntype WithSpotLeverage<T> = T & {\n spotLeverage?: boolean;\n};\n\nexport type WithSignature<T> = T & {\n signature: string;\n};\n\n// Params associated with all engine executes\nexport type WithBaseEngineExecuteParams<T> = SignatureParams &\n Omit<T, 'nonce'> & {\n nonce?: string;\n };\n\nexport type EngineOrderParams = WithoutNonce<EIP712OrderParams>;\n\nexport type EnginePlaceOrderParams = WithBaseEngineExecuteParams<{\n id?: number;\n productId: number;\n order: EngineOrderParams;\n // If not given, engine defaults to true (leverage/borrow enabled)\n spotLeverage?: boolean;\n // For isolated orders, this specifies whether margin can be borrowed (i.e. whether the cross account can have a negative USDC balance)\n borrowMargin?: boolean;\n}>;\n\nexport type EngineLiquidateSubaccountParams =\n WithBaseEngineExecuteParams<EIP712LiquidateSubaccountParams>;\n\nexport type EngineWithdrawCollateralParams = WithBaseEngineExecuteParams<\n WithSpotLeverage<EIP712WithdrawCollateralParams>\n>;\n\nexport type EngineCancelOrdersParams =\n WithBaseEngineExecuteParams<EIP712CancelOrdersParams>;\n\nexport type EngineCancelAndPlaceParams = {\n cancelOrders: EngineCancelOrdersParams;\n placeOrder: EnginePlaceOrderParams;\n};\n\nexport type EngineCancelProductOrdersParams =\n WithBaseEngineExecuteParams<EIP712CancelProductOrdersParams>;\n\nexport type EngineLinkSignerParams =\n WithBaseEngineExecuteParams<EIP712LinkSignerParams>;\n\nexport type EngineTransferQuoteParams =\n WithBaseEngineExecuteParams<EIP712TransferQuoteParams>;\n\nexport type EngineMintNlpParams = WithBaseEngineExecuteParams<\n WithSpotLeverage<EIP712MintNlpParams>\n>;\n\nexport type EngineBurnNlpParams =\n WithBaseEngineExecuteParams<EIP712BurnNlpParams>;\n\nexport type EnginePlaceOrdersParams = EnginePlaceOrderParams[];\n\nexport interface EngineExecuteRequestParamsByType {\n burn_nlp: EngineBurnNlpParams;\n cancel_and_place: EngineCancelAndPlaceParams;\n cancel_orders: EngineCancelOrdersParams;\n cancel_product_orders: EngineCancelProductOrdersParams;\n link_signer: EngineLinkSignerParams;\n liquidate_subaccount: EngineLiquidateSubaccountParams;\n mint_nlp: EngineMintNlpParams;\n place_order: EnginePlaceOrderParams;\n place_orders: EnginePlaceOrdersParams;\n transfer_quote: EngineTransferQuoteParams;\n withdraw_collateral: EngineWithdrawCollateralParams;\n}\n\nexport type EnginePlaceOrderResult =\n EngineServerExecuteSuccessResult<'place_order'> & {\n orderParams: EIP712OrderParams;\n };\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { EIP712BurnNlpParams, EIP712CancelOrdersParams, EIP712OrderParams, EIP712CancelProductOrdersParams, EIP712LinkSignerParams, EIP712LiquidateSubaccountParams, EIP712MintNlpParams, EIP712TransferQuoteParams, EIP712WithdrawCollateralParams } from '@nadohq/shared';
|
|
2
2
|
import { EngineServerExecuteSuccessResult } from './serverExecuteTypes.cjs';
|
|
3
3
|
import './serverQueryTypes.cjs';
|
|
4
4
|
import './serverQueryModelTypes.cjs';
|
|
@@ -31,12 +31,6 @@ type EnginePlaceOrderParams = WithBaseEngineExecuteParams<{
|
|
|
31
31
|
productId: number;
|
|
32
32
|
order: EngineOrderParams;
|
|
33
33
|
spotLeverage?: boolean;
|
|
34
|
-
}>;
|
|
35
|
-
type EngineIsolatedOrderParams = WithoutNonce<EIP712IsolatedOrderParams>;
|
|
36
|
-
type EnginePlaceIsolatedOrderParams = WithBaseEngineExecuteParams<{
|
|
37
|
-
id?: number;
|
|
38
|
-
productId: number;
|
|
39
|
-
order: EngineIsolatedOrderParams;
|
|
40
34
|
borrowMargin?: boolean;
|
|
41
35
|
}>;
|
|
42
36
|
type EngineLiquidateSubaccountParams = WithBaseEngineExecuteParams<EIP712LiquidateSubaccountParams>;
|
|
@@ -49,26 +43,24 @@ type EngineCancelAndPlaceParams = {
|
|
|
49
43
|
type EngineCancelProductOrdersParams = WithBaseEngineExecuteParams<EIP712CancelProductOrdersParams>;
|
|
50
44
|
type EngineLinkSignerParams = WithBaseEngineExecuteParams<EIP712LinkSignerParams>;
|
|
51
45
|
type EngineTransferQuoteParams = WithBaseEngineExecuteParams<EIP712TransferQuoteParams>;
|
|
52
|
-
type
|
|
53
|
-
type
|
|
46
|
+
type EngineMintNlpParams = WithBaseEngineExecuteParams<WithSpotLeverage<EIP712MintNlpParams>>;
|
|
47
|
+
type EngineBurnNlpParams = WithBaseEngineExecuteParams<EIP712BurnNlpParams>;
|
|
48
|
+
type EnginePlaceOrdersParams = EnginePlaceOrderParams[];
|
|
54
49
|
interface EngineExecuteRequestParamsByType {
|
|
55
|
-
|
|
50
|
+
burn_nlp: EngineBurnNlpParams;
|
|
56
51
|
cancel_and_place: EngineCancelAndPlaceParams;
|
|
57
52
|
cancel_orders: EngineCancelOrdersParams;
|
|
58
53
|
cancel_product_orders: EngineCancelProductOrdersParams;
|
|
59
54
|
link_signer: EngineLinkSignerParams;
|
|
60
55
|
liquidate_subaccount: EngineLiquidateSubaccountParams;
|
|
61
|
-
|
|
62
|
-
place_isolated_order: EnginePlaceIsolatedOrderParams;
|
|
56
|
+
mint_nlp: EngineMintNlpParams;
|
|
63
57
|
place_order: EnginePlaceOrderParams;
|
|
58
|
+
place_orders: EnginePlaceOrdersParams;
|
|
64
59
|
transfer_quote: EngineTransferQuoteParams;
|
|
65
60
|
withdraw_collateral: EngineWithdrawCollateralParams;
|
|
66
61
|
}
|
|
67
62
|
type EnginePlaceOrderResult = EngineServerExecuteSuccessResult<'place_order'> & {
|
|
68
63
|
orderParams: EIP712OrderParams;
|
|
69
64
|
};
|
|
70
|
-
type EnginePlaceIsolatedOrderResult = EngineServerExecuteSuccessResult<'place_isolated_order'> & {
|
|
71
|
-
orderParams: EIP712IsolatedOrderParams;
|
|
72
|
-
};
|
|
73
65
|
|
|
74
|
-
export type {
|
|
66
|
+
export type { EngineBurnNlpParams, EngineCancelAndPlaceParams, EngineCancelOrdersParams, EngineCancelProductOrdersParams, EngineExecuteRequestParamsByType, EngineLinkSignerParams, EngineLiquidateSubaccountParams, EngineMintNlpParams, EngineOrderParams, EnginePlaceOrderParams, EnginePlaceOrderResult, EnginePlaceOrdersParams, EngineTransferQuoteParams, EngineWithdrawCollateralParams, SignatureParams, WithBaseEngineExecuteParams, WithSignature };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { EIP712BurnNlpParams, EIP712CancelOrdersParams, EIP712OrderParams, EIP712CancelProductOrdersParams, EIP712LinkSignerParams, EIP712LiquidateSubaccountParams, EIP712MintNlpParams, EIP712TransferQuoteParams, EIP712WithdrawCollateralParams } from '@nadohq/shared';
|
|
2
2
|
import { EngineServerExecuteSuccessResult } from './serverExecuteTypes.js';
|
|
3
3
|
import './serverQueryTypes.js';
|
|
4
4
|
import './serverQueryModelTypes.js';
|
|
@@ -31,12 +31,6 @@ type EnginePlaceOrderParams = WithBaseEngineExecuteParams<{
|
|
|
31
31
|
productId: number;
|
|
32
32
|
order: EngineOrderParams;
|
|
33
33
|
spotLeverage?: boolean;
|
|
34
|
-
}>;
|
|
35
|
-
type EngineIsolatedOrderParams = WithoutNonce<EIP712IsolatedOrderParams>;
|
|
36
|
-
type EnginePlaceIsolatedOrderParams = WithBaseEngineExecuteParams<{
|
|
37
|
-
id?: number;
|
|
38
|
-
productId: number;
|
|
39
|
-
order: EngineIsolatedOrderParams;
|
|
40
34
|
borrowMargin?: boolean;
|
|
41
35
|
}>;
|
|
42
36
|
type EngineLiquidateSubaccountParams = WithBaseEngineExecuteParams<EIP712LiquidateSubaccountParams>;
|
|
@@ -49,26 +43,24 @@ type EngineCancelAndPlaceParams = {
|
|
|
49
43
|
type EngineCancelProductOrdersParams = WithBaseEngineExecuteParams<EIP712CancelProductOrdersParams>;
|
|
50
44
|
type EngineLinkSignerParams = WithBaseEngineExecuteParams<EIP712LinkSignerParams>;
|
|
51
45
|
type EngineTransferQuoteParams = WithBaseEngineExecuteParams<EIP712TransferQuoteParams>;
|
|
52
|
-
type
|
|
53
|
-
type
|
|
46
|
+
type EngineMintNlpParams = WithBaseEngineExecuteParams<WithSpotLeverage<EIP712MintNlpParams>>;
|
|
47
|
+
type EngineBurnNlpParams = WithBaseEngineExecuteParams<EIP712BurnNlpParams>;
|
|
48
|
+
type EnginePlaceOrdersParams = EnginePlaceOrderParams[];
|
|
54
49
|
interface EngineExecuteRequestParamsByType {
|
|
55
|
-
|
|
50
|
+
burn_nlp: EngineBurnNlpParams;
|
|
56
51
|
cancel_and_place: EngineCancelAndPlaceParams;
|
|
57
52
|
cancel_orders: EngineCancelOrdersParams;
|
|
58
53
|
cancel_product_orders: EngineCancelProductOrdersParams;
|
|
59
54
|
link_signer: EngineLinkSignerParams;
|
|
60
55
|
liquidate_subaccount: EngineLiquidateSubaccountParams;
|
|
61
|
-
|
|
62
|
-
place_isolated_order: EnginePlaceIsolatedOrderParams;
|
|
56
|
+
mint_nlp: EngineMintNlpParams;
|
|
63
57
|
place_order: EnginePlaceOrderParams;
|
|
58
|
+
place_orders: EnginePlaceOrdersParams;
|
|
64
59
|
transfer_quote: EngineTransferQuoteParams;
|
|
65
60
|
withdraw_collateral: EngineWithdrawCollateralParams;
|
|
66
61
|
}
|
|
67
62
|
type EnginePlaceOrderResult = EngineServerExecuteSuccessResult<'place_order'> & {
|
|
68
63
|
orderParams: EIP712OrderParams;
|
|
69
64
|
};
|
|
70
|
-
type EnginePlaceIsolatedOrderResult = EngineServerExecuteSuccessResult<'place_isolated_order'> & {
|
|
71
|
-
orderParams: EIP712IsolatedOrderParams;
|
|
72
|
-
};
|
|
73
65
|
|
|
74
|
-
export type {
|
|
66
|
+
export type { EngineBurnNlpParams, EngineCancelAndPlaceParams, EngineCancelOrdersParams, EngineCancelProductOrdersParams, EngineExecuteRequestParamsByType, EngineLinkSignerParams, EngineLiquidateSubaccountParams, EngineMintNlpParams, EngineOrderParams, EnginePlaceOrderParams, EnginePlaceOrderResult, EnginePlaceOrdersParams, EngineTransferQuoteParams, EngineWithdrawCollateralParams, SignatureParams, WithBaseEngineExecuteParams, WithSignature };
|