@symmio/trading-react 0.1.1 → 0.2.0
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/account-layer/index.d.ts +28 -28
- package/dist/account-layer/index.js +29 -0
- package/dist/account-layer/use-account-balance-info.d.ts +1 -1
- package/dist/account-layer/use-account-balance-of.d.ts +1 -1
- package/dist/account-layer/use-add-margin.d.ts +2 -2
- package/dist/account-layer/use-allocate.d.ts +2 -2
- package/dist/account-layer/use-create-sub-accounts.d.ts +2 -2
- package/dist/account-layer/use-deallocate.d.ts +2 -2
- package/dist/account-layer/use-delete-sub-account.d.ts +2 -2
- package/dist/account-layer/use-deposit-and-allocate.d.ts +2 -2
- package/dist/account-layer/use-deposit.d.ts +2 -2
- package/dist/account-layer/use-edit-account-name.d.ts +2 -2
- package/dist/account-layer/use-predicted-next-virtual-account.d.ts +1 -1
- package/dist/account-layer/use-remove-margin.d.ts +2 -2
- package/dist/account-layer/use-simulate-add-margin.d.ts +1 -1
- package/dist/account-layer/use-simulate-allocate.d.ts +1 -1
- package/dist/account-layer/use-simulate-create-sub-accounts.d.ts +1 -1
- package/dist/account-layer/use-simulate-deallocate.d.ts +1 -1
- package/dist/account-layer/use-simulate-delete-sub-account.d.ts +1 -1
- package/dist/account-layer/use-simulate-deposit-and-allocate.d.ts +1 -1
- package/dist/account-layer/use-simulate-deposit.d.ts +1 -1
- package/dist/account-layer/use-simulate-edit-account-name.d.ts +1 -1
- package/dist/account-layer/use-simulate-remove-margin.d.ts +1 -1
- package/dist/account-layer/use-sub-account-virtual-nonce.d.ts +1 -1
- package/dist/account-layer/use-sub-account.d.ts +1 -1
- package/dist/account-layer/use-sub-accounts-count-of-user.d.ts +1 -1
- package/dist/account-layer/use-user-sub-accounts-addresses.d.ts +1 -1
- package/dist/account-layer/use-user-sub-accounts.d.ts +1 -1
- package/dist/account-layer/use-virtual-account.d.ts +1 -1
- package/dist/account-layer/use-virtual-accounts-addresses-of-sub-account.d.ts +1 -1
- package/dist/balance-history/index.d.ts +3 -3
- package/dist/balance-history/use-balance-history.d.ts +1 -1
- package/dist/balance-history/use-deposit-history.d.ts +1 -1
- package/dist/balance-history/use-withdraw-history.d.ts +1 -1
- package/dist/collateral/index.d.ts +4 -4
- package/dist/collateral/use-approve-collateral.d.ts +2 -2
- package/dist/collateral/use-collateral-allowance.d.ts +1 -1
- package/dist/collateral/use-collateral-balance.d.ts +1 -1
- package/dist/collateral/use-simulate-approve-collateral.d.ts +1 -1
- package/dist/error-codes/index.d.ts +2 -2
- package/dist/error-codes/use-solver-error-codes.d.ts +1 -1
- package/dist/error-codes/use-solver-error-message.d.ts +1 -1
- package/dist/errors/index.d.ts +3 -3
- package/dist/errors/index.js +3 -0
- package/dist/errors/normalize-symm-error.d.ts +1 -1
- package/dist/errors/symmio-request-error.d.ts +1 -1
- package/dist/fees/index.d.ts +1 -1
- package/dist/fees/index.js +2 -0
- package/dist/fees/use-fee-for-user.d.ts +1 -1
- package/dist/funding-info/index.d.ts +2 -0
- package/dist/funding-info/index.d.ts.map +1 -0
- package/dist/funding-info/use-funding-info.d.ts +25 -0
- package/dist/funding-info/use-funding-info.d.ts.map +1 -0
- package/dist/funding-info/use-funding-info.js +27 -0
- package/dist/funding-info/use-funding-info.js.map +1 -0
- package/dist/index.d.ts +40 -24
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +74 -69
- package/dist/instant-layer/index.d.ts +14 -13
- package/dist/instant-layer/index.d.ts.map +1 -1
- package/dist/instant-layer/index.js +15 -0
- package/dist/instant-layer/use-delegation-expiry.d.ts +1 -1
- package/dist/instant-layer/use-grant-delegation.d.ts +2 -2
- package/dist/instant-layer/use-instant-close-auto.d.ts +1 -1
- package/dist/instant-layer/use-instant-close-bulk-auto.d.ts +1 -1
- package/dist/instant-layer/use-instant-close-bulk.d.ts +1 -1
- package/dist/instant-layer/use-instant-close.d.ts +1 -1
- package/dist/instant-layer/use-instant-closes.d.ts +1 -1
- package/dist/instant-layer/use-instant-open-auto.d.ts +1 -1
- package/dist/instant-layer/use-instant-open-quote-id.d.ts +1 -1
- package/dist/instant-layer/use-instant-open-with-tpsl.d.ts +55 -0
- package/dist/instant-layer/use-instant-open-with-tpsl.d.ts.map +1 -0
- package/dist/instant-layer/use-instant-open-with-tpsl.js +56 -0
- package/dist/instant-layer/use-instant-open-with-tpsl.js.map +1 -0
- package/dist/instant-layer/use-instant-open.d.ts +1 -1
- package/dist/instant-layer/use-instant-opens.d.ts +1 -1
- package/dist/instant-layer/use-is-delegation-active.d.ts +1 -1
- package/dist/instant-layer/use-simulate-grant-delegation.d.ts +1 -1
- package/dist/locked-params/index.d.ts +1 -1
- package/dist/locked-params/use-locked-params.d.ts +1 -1
- package/dist/market-info/index.d.ts +2 -0
- package/dist/market-info/index.d.ts.map +1 -0
- package/dist/market-info/use-market-info.d.ts +28 -0
- package/dist/market-info/use-market-info.d.ts.map +1 -0
- package/dist/market-info/use-market-info.js +27 -0
- package/dist/market-info/use-market-info.js.map +1 -0
- package/dist/markets/index.d.ts +2 -2
- package/dist/markets/index.js +3 -0
- package/dist/markets/use-markets.d.ts +1 -1
- package/dist/markets/use-onchain-contract-markets.d.ts +1 -1
- package/dist/muon/index.d.ts +10 -10
- package/dist/muon/use-deallocate-upnl-sig.d.ts +1 -1
- package/dist/muon/use-muon-party-a-overview.d.ts +1 -1
- package/dist/muon/use-muon-price-range.d.ts +1 -1
- package/dist/muon/use-muon-price.d.ts +1 -1
- package/dist/muon/use-muon-settle-upnl.d.ts +1 -1
- package/dist/muon/use-muon-upnl-a-with-symbol-price.d.ts +1 -1
- package/dist/muon/use-muon-upnl-a.d.ts +1 -1
- package/dist/muon/use-muon-upnl-b.d.ts +1 -1
- package/dist/muon/use-muon-upnl-with-symbol-price.d.ts +1 -1
- package/dist/muon/use-muon-upnl.d.ts +1 -1
- package/dist/notifications/index.d.ts +1 -1
- package/dist/notifications/use-search-notifications.d.ts +1 -1
- package/dist/notional-cap/index.d.ts +3 -3
- package/dist/notional-cap/use-notional-cap-all.d.ts +1 -1
- package/dist/notional-cap/use-notional-cap-by-symbol-id.d.ts +1 -1
- package/dist/notional-cap/use-open-interest-by-symbol-id.d.ts +1 -1
- package/dist/price-service/index.d.ts +8 -8
- package/dist/price-service/index.js +9 -0
- package/dist/price-service/use-enigma-price-by-market-id.d.ts +1 -1
- package/dist/price-service/use-enigma-price-by-name.d.ts +1 -1
- package/dist/price-service/use-enigma-price-service-health.d.ts +1 -1
- package/dist/price-service/use-enigma-price-service-metadata.d.ts +1 -1
- package/dist/price-service/use-enigma-price-service-prices-by-addresses.d.ts +1 -1
- package/dist/price-service/use-enigma-price-service-prices-by-names.d.ts +1 -1
- package/dist/price-service/use-enigma-price-service-symbols-info.d.ts +1 -1
- package/dist/price-service/use-enigma-prices.d.ts +1 -1
- package/dist/provider/index.d.ts +3 -3
- package/dist/provider/index.js +4 -0
- package/dist/quotes/index.d.ts +15 -15
- package/dist/quotes/use-account-liquidation-price.d.ts +4 -7
- package/dist/quotes/use-account-liquidation-price.d.ts.map +1 -1
- package/dist/quotes/use-account-liquidation-price.js.map +1 -1
- package/dist/quotes/use-grouped-quotes.d.ts +1 -1
- package/dist/quotes/use-managed-quotes.d.ts +1 -1
- package/dist/quotes/use-managed-quotes.d.ts.map +1 -1
- package/dist/quotes/use-managed-quotes.js +125 -122
- package/dist/quotes/use-managed-quotes.js.map +1 -1
- package/dist/quotes/use-party-a-open-positions.d.ts +4 -4
- package/dist/quotes/use-party-a-open-positions.js.map +1 -1
- package/dist/quotes/use-party-a-pending-quotes.d.ts +1 -1
- package/dist/quotes/use-quote-events-by-type.d.ts +1 -1
- package/dist/quotes/use-quote-funding.d.ts +1 -1
- package/dist/quotes/use-quote-history.d.ts +1 -1
- package/dist/quotes/use-quote-price-history.d.ts +1 -1
- package/dist/quotes/use-quote.d.ts +1 -1
- package/dist/quotes/use-quotes-funding.d.ts +1 -1
- package/dist/quotes/use-subgraph-query.d.ts +1 -1
- package/dist/tpsl/index.d.ts +8 -7
- package/dist/tpsl/index.d.ts.map +1 -1
- package/dist/tpsl/tpsl-store.d.ts +84 -0
- package/dist/tpsl/tpsl-store.d.ts.map +1 -0
- package/dist/tpsl/tpsl-store.js +154 -0
- package/dist/tpsl/tpsl-store.js.map +1 -0
- package/dist/tpsl/use-delete-quote-tpsl.d.ts +15 -0
- package/dist/tpsl/use-delete-quote-tpsl.d.ts.map +1 -0
- package/dist/tpsl/use-delete-quote-tpsl.js +31 -0
- package/dist/tpsl/use-delete-quote-tpsl.js.map +1 -0
- package/dist/tpsl/use-quote-tpsl.d.ts +19 -20
- package/dist/tpsl/use-quote-tpsl.d.ts.map +1 -1
- package/dist/tpsl/use-quote-tpsl.js +24 -53
- package/dist/tpsl/use-quote-tpsl.js.map +1 -1
- package/dist/tpsl/use-set-quote-tpsl.d.ts +11 -10
- package/dist/tpsl/use-set-quote-tpsl.d.ts.map +1 -1
- package/dist/tpsl/use-set-quote-tpsl.js +18 -22
- package/dist/tpsl/use-set-quote-tpsl.js.map +1 -1
- package/dist/tpsl/use-tpsl-config.d.ts +1 -1
- package/dist/tpsl/use-tpsl-signing-spec.d.ts +1 -1
- package/dist/tpsl/use-watch-tpsl-notifications.d.ts +1 -1
- package/dist/transactions/index.d.ts +3 -3
- package/dist/transactions/index.js +3 -0
- package/dist/transactions/resolve-write-result.d.ts +1 -1
- package/dist/transfers/index.d.ts +1 -1
- package/dist/transfers/use-transfer-history.d.ts +1 -1
- package/dist/utils/index.d.ts +1 -1
- package/dist/wallet/index.d.ts +4 -4
- package/dist/wallet/index.js +5 -0
- package/dist/wallet/use-connect-wallet.d.ts +1 -1
- package/dist/wallet/use-switch-to-symmio-chain.d.ts +1 -1
- package/dist/websocket/index.d.ts +1 -1
- package/dist/websocket/use-notifications.d.ts +1 -1
- package/dist/withdraw/index.d.ts +10 -10
- package/dist/withdraw/use-finalize-withdraw-request.d.ts +2 -2
- package/dist/withdraw/use-initiate-withdraw.d.ts +2 -2
- package/dist/withdraw/use-last-withdraw-request-id.d.ts +1 -1
- package/dist/withdraw/use-pending-withdraw-requests.d.ts +1 -1
- package/dist/withdraw/use-request-cancel-withdraw.d.ts +2 -2
- package/dist/withdraw/use-simulate-finalize-withdraw-request.d.ts +1 -1
- package/dist/withdraw/use-simulate-initiate-withdraw.d.ts +1 -1
- package/dist/withdraw/use-simulate-request-cancel-withdraw.d.ts +1 -1
- package/dist/withdraw/use-withdraw-requests.d.ts +1 -1
- package/dist/withdraw/use-withdrawable-time.d.ts +1 -1
- package/package.json +7 -5
- package/dist/tpsl/tpsl-confirming.d.ts +0 -36
- package/dist/tpsl/tpsl-confirming.d.ts.map +0 -1
- package/dist/tpsl/tpsl-confirming.js +0 -28
- package/dist/tpsl/tpsl-confirming.js.map +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ConfigParameter, SimulateInitiateWithdrawParameters, SimulateInitiateWithdrawReturnType } from '@symmio/trading-core';
|
|
2
2
|
import { UseMutationResult } from '@tanstack/react-query';
|
|
3
|
-
import { SymmioRequestError } from '../errors/symmio-request-error';
|
|
3
|
+
import { SymmioRequestError } from '../errors/symmio-request-error.js';
|
|
4
4
|
/**
|
|
5
5
|
* Parameters for {@link useSimulateInitiateWithdraw}: an optional `config` override. The dry-run's
|
|
6
6
|
* inputs are passed as the mutation `variables`.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ConfigParameter, SimulateRequestCancelWithdrawParameters, SimulateRequestCancelWithdrawReturnType } from '@symmio/trading-core';
|
|
2
2
|
import { UseMutationResult } from '@tanstack/react-query';
|
|
3
|
-
import { SymmioRequestError } from '../errors/symmio-request-error';
|
|
3
|
+
import { SymmioRequestError } from '../errors/symmio-request-error.js';
|
|
4
4
|
/**
|
|
5
5
|
* Parameters for {@link useSimulateRequestCancelWithdraw}: an optional `config` override. The dry-run's
|
|
6
6
|
* inputs are passed as the mutation `variables`.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ConfigParameter, GetWithdrawRequestsOptions, GetWithdrawRequestsReturnType } from '@symmio/trading-core';
|
|
2
2
|
import { UseQueryResult } from '@tanstack/react-query';
|
|
3
|
-
import { SymmioRequestError } from '../errors/symmio-request-error';
|
|
3
|
+
import { SymmioRequestError } from '../errors/symmio-request-error.js';
|
|
4
4
|
/**
|
|
5
5
|
* Parameters for {@link useWithdrawRequest}: the core query options (user, request
|
|
6
6
|
* id, chain id, TanStack `query` overrides) plus an optional `config`.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ConfigParameter, GetWithdrawableTimeOptions, GetWithdrawableTimeReturnType } from '@symmio/trading-core';
|
|
2
2
|
import { UseQueryResult } from '@tanstack/react-query';
|
|
3
|
-
import { SymmioRequestError } from '../errors/symmio-request-error';
|
|
3
|
+
import { SymmioRequestError } from '../errors/symmio-request-error.js';
|
|
4
4
|
/**
|
|
5
5
|
* Parameters for {@link useWithdrawableTime}: the core query options (user, chain
|
|
6
6
|
* id, TanStack `query` overrides) plus an optional `config`.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@symmio/trading-react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "React adapter for the SYMMIO SDK. Hooks, providers, and React-bound ergonomics on top of @symmio/trading-core.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://github.com/SYMM-IO/SYMM-Frontier/tree/main/packages/trading-react#readme",
|
|
@@ -71,7 +71,7 @@
|
|
|
71
71
|
"@tanstack/react-query": "^5.100.0",
|
|
72
72
|
"decimal.js": "^10.4.3",
|
|
73
73
|
"zustand": "^5.0.0",
|
|
74
|
-
"@symmio/trading-core": "^0.
|
|
74
|
+
"@symmio/trading-core": "^0.2.0"
|
|
75
75
|
},
|
|
76
76
|
"peerDependencies": {
|
|
77
77
|
"react": "^19.0.0",
|
|
@@ -86,6 +86,7 @@
|
|
|
86
86
|
"@types/react": "^19.2.14",
|
|
87
87
|
"@types/react-dom": "^19.2.3",
|
|
88
88
|
"@vitejs/plugin-react": "^6.0.1",
|
|
89
|
+
"@vitest/coverage-v8": "^4.1.10",
|
|
89
90
|
"@wagmi/connectors": "^8.0.0",
|
|
90
91
|
"eslint": "^9.39.4",
|
|
91
92
|
"happy-dom": "^16.0.0",
|
|
@@ -95,18 +96,19 @@
|
|
|
95
96
|
"viem": "^2.49.0",
|
|
96
97
|
"vite": "^8.0.10",
|
|
97
98
|
"vite-plugin-dts": "^5.0.0",
|
|
98
|
-
"vitest": "^4.1.
|
|
99
|
+
"vitest": "^4.1.10",
|
|
99
100
|
"wagmi": "^3.4.2",
|
|
100
|
-
"@symmio/eslint-config": "^0.1.
|
|
101
|
+
"@symmio/eslint-config": "^0.1.2",
|
|
101
102
|
"@symmio/typescript-config": "^0.1.1"
|
|
102
103
|
},
|
|
103
104
|
"scripts": {
|
|
104
|
-
"build": "vite build",
|
|
105
|
+
"build": "vite build && node ../../scripts/fix-dts-extensions.mjs dist",
|
|
105
106
|
"dev": "vite build --watch",
|
|
106
107
|
"lint": "eslint . --max-warnings 0",
|
|
107
108
|
"check-types": "tsc --noEmit",
|
|
108
109
|
"test": "vitest run --project unit",
|
|
109
110
|
"test:watch": "vitest --project unit",
|
|
111
|
+
"test:coverage": "vitest run --project unit --coverage",
|
|
110
112
|
"test:integration": "vitest run --project integration"
|
|
111
113
|
}
|
|
112
114
|
}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { QueryClient } from '@tanstack/react-query';
|
|
2
|
-
/** Per-side flags marking "POST accepted, waiting for WS confirmation". */
|
|
3
|
-
export interface TpSlConfirming {
|
|
4
|
-
tp: boolean;
|
|
5
|
-
sl: boolean;
|
|
6
|
-
}
|
|
7
|
-
/** Empty snapshot — nothing awaiting confirmation. */
|
|
8
|
-
export declare const EMPTY_TPSL_CONFIRMING: TpSlConfirming;
|
|
9
|
-
/**
|
|
10
|
-
* Query key for the shared "confirming" slot used to bridge
|
|
11
|
-
* {@link useSetQuoteTpSl} and {@link useQuoteTpSl}.
|
|
12
|
-
*
|
|
13
|
-
* The set-mutation writes `{tp,sl}` here on POST 200; the read-hook overlays
|
|
14
|
-
* `confirming` onto the folded snapshot until a matching WS report clears the
|
|
15
|
-
* flag.
|
|
16
|
-
*/
|
|
17
|
-
export declare function getTpSlConfirmingQueryKey(parameters: {
|
|
18
|
-
chainId: number;
|
|
19
|
-
quoteId: bigint;
|
|
20
|
-
configKey: string;
|
|
21
|
-
}): readonly [string, {
|
|
22
|
-
chainId: number;
|
|
23
|
-
quoteId: string;
|
|
24
|
-
configKey: string;
|
|
25
|
-
}];
|
|
26
|
-
/**
|
|
27
|
-
* Mark one or both sides as awaiting WS confirmation. Merges with any existing
|
|
28
|
-
* flags so an in-flight SL doesn't clear a TP that's still waiting.
|
|
29
|
-
*/
|
|
30
|
-
export declare function markTpSlConfirming(queryClient: QueryClient, key: ReturnType<typeof getTpSlConfirmingQueryKey>, sides: Partial<TpSlConfirming>): void;
|
|
31
|
-
/**
|
|
32
|
-
* Clear one side's confirming flag (called on a matching successful WS
|
|
33
|
-
* frame). Leaves the other side untouched.
|
|
34
|
-
*/
|
|
35
|
-
export declare function clearTpSlConfirmingSide(queryClient: QueryClient, key: ReturnType<typeof getTpSlConfirmingQueryKey>, side: "tp" | "sl"): void;
|
|
36
|
-
//# sourceMappingURL=tpsl-confirming.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tpsl-confirming.d.ts","sourceRoot":"","sources":["../../src/tpsl/tpsl-confirming.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAEzD,2EAA2E;AAC3E,MAAM,WAAW,cAAc;IAC7B,EAAE,EAAE,OAAO,CAAC;IACZ,EAAE,EAAE,OAAO,CAAC;CACb;AAED,sDAAsD;AACtD,eAAO,MAAM,qBAAqB,EAAE,cAAyC,CAAC;AAE9E;;;;;;;GAOG;AACH,wBAAgB,yBAAyB,CAAC,UAAU,EAAE;IACpD,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;CACnB,GAAG,SAAS,CAAC,MAAM,EAAE;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,CAAC,CAK7E;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAChC,WAAW,EAAE,WAAW,EACxB,GAAG,EAAE,UAAU,CAAC,OAAO,yBAAyB,CAAC,EACjD,KAAK,EAAE,OAAO,CAAC,cAAc,CAAC,GAC7B,IAAI,CAKN;AAED;;;GAGG;AACH,wBAAgB,uBAAuB,CACrC,WAAW,EAAE,WAAW,EACxB,GAAG,EAAE,UAAU,CAAC,OAAO,yBAAyB,CAAC,EACjD,IAAI,EAAE,IAAI,GAAG,IAAI,GAChB,IAAI,CAKN"}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
//#region src/tpsl/tpsl-confirming.ts
|
|
2
|
-
var e = {
|
|
3
|
-
tp: !1,
|
|
4
|
-
sl: !1
|
|
5
|
-
};
|
|
6
|
-
function t(e) {
|
|
7
|
-
return ["tpsl-confirming", {
|
|
8
|
-
chainId: e.chainId,
|
|
9
|
-
quoteId: e.quoteId.toString(),
|
|
10
|
-
configKey: e.configKey
|
|
11
|
-
}];
|
|
12
|
-
}
|
|
13
|
-
function n(e, t, n) {
|
|
14
|
-
e.setQueryData(t, (e) => ({
|
|
15
|
-
tp: n.tp ?? e?.tp ?? !1,
|
|
16
|
-
sl: n.sl ?? e?.sl ?? !1
|
|
17
|
-
}));
|
|
18
|
-
}
|
|
19
|
-
function r(t, n, r) {
|
|
20
|
-
t.setQueryData(n, (t) => !t || !t[r] ? t ?? e : {
|
|
21
|
-
...t,
|
|
22
|
-
[r]: !1
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
//#endregion
|
|
26
|
-
export { e as EMPTY_TPSL_CONFIRMING, r as clearTpSlConfirmingSide, t as getTpSlConfirmingQueryKey, n as markTpSlConfirming };
|
|
27
|
-
|
|
28
|
-
//# sourceMappingURL=tpsl-confirming.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tpsl-confirming.js","names":[],"sources":["../../src/tpsl/tpsl-confirming.ts"],"sourcesContent":["import type { QueryClient } from \"@tanstack/react-query\";\n\n/** Per-side flags marking \"POST accepted, waiting for WS confirmation\". */\nexport interface TpSlConfirming {\n tp: boolean;\n sl: boolean;\n}\n\n/** Empty snapshot — nothing awaiting confirmation. */\nexport const EMPTY_TPSL_CONFIRMING: TpSlConfirming = { tp: false, sl: false };\n\n/**\n * Query key for the shared \"confirming\" slot used to bridge\n * {@link useSetQuoteTpSl} and {@link useQuoteTpSl}.\n *\n * The set-mutation writes `{tp,sl}` here on POST 200; the read-hook overlays\n * `confirming` onto the folded snapshot until a matching WS report clears the\n * flag.\n */\nexport function getTpSlConfirmingQueryKey(parameters: {\n chainId: number;\n quoteId: bigint;\n configKey: string;\n}): readonly [string, { chainId: number; quoteId: string; configKey: string }] {\n return [\n \"tpsl-confirming\",\n { chainId: parameters.chainId, quoteId: parameters.quoteId.toString(), configKey: parameters.configKey },\n ] as const;\n}\n\n/**\n * Mark one or both sides as awaiting WS confirmation. Merges with any existing\n * flags so an in-flight SL doesn't clear a TP that's still waiting.\n */\nexport function markTpSlConfirming(\n queryClient: QueryClient,\n key: ReturnType<typeof getTpSlConfirmingQueryKey>,\n sides: Partial<TpSlConfirming>,\n): void {\n queryClient.setQueryData<TpSlConfirming>(key, (prev) => ({\n tp: sides.tp ?? prev?.tp ?? false,\n sl: sides.sl ?? prev?.sl ?? false,\n }));\n}\n\n/**\n * Clear one side's confirming flag (called on a matching successful WS\n * frame). Leaves the other side untouched.\n */\nexport function clearTpSlConfirmingSide(\n queryClient: QueryClient,\n key: ReturnType<typeof getTpSlConfirmingQueryKey>,\n side: \"tp\" | \"sl\",\n): void {\n queryClient.setQueryData<TpSlConfirming>(key, (prev) => {\n if (!prev || !prev[side]) return prev ?? EMPTY_TPSL_CONFIRMING;\n return { ...prev, [side]: false };\n });\n}\n"],"mappings":";AASA,IAAa,IAAwC;CAAE,IAAI;CAAO,IAAI;AAAM;AAU5E,SAAgB,EAA0B,GAIqC;CAC7E,OAAO,CACL,mBACA;EAAE,SAAS,EAAW;EAAS,SAAS,EAAW,QAAQ,SAAS;EAAG,WAAW,EAAW;CAAU,CACzG;AACF;AAMA,SAAgB,EACd,GACA,GACA,GACM;CACN,EAAY,aAA6B,IAAM,OAAU;EACvD,IAAI,EAAM,MAAM,GAAM,MAAM;EAC5B,IAAI,EAAM,MAAM,GAAM,MAAM;CAC9B,EAAE;AACJ;AAMA,SAAgB,EACd,GACA,GACA,GACM;CACN,EAAY,aAA6B,IAAM,MACzC,CAAC,KAAQ,CAAC,EAAK,KAAc,KAAQ,IAClC;EAAE,GAAG;GAAO,IAAO;CAAM,CACjC;AACH"}
|