@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
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ConfigParameter, DeleteQuoteTpSlParameters, DeleteQuoteTpSlReturnType } from '@symmio/trading-core';
|
|
2
|
+
import { UseMutationResult } from '@tanstack/react-query';
|
|
3
|
+
import { SymmioRequestError } from '../errors/symmio-request-error.js';
|
|
4
|
+
/** Parameters for {@link useDeleteQuoteTpSl}. */
|
|
5
|
+
export type UseDeleteQuoteTpSlParameters = ConfigParameter;
|
|
6
|
+
/** Return type of {@link useDeleteQuoteTpSl}. */
|
|
7
|
+
export type UseDeleteQuoteTpSlReturnType = UseMutationResult<DeleteQuoteTpSlReturnType, SymmioRequestError, DeleteQuoteTpSlParameters>;
|
|
8
|
+
/**
|
|
9
|
+
* Cancel a live TP or SL by its `cohQuoteId`. Signs an EIP-712 delete message
|
|
10
|
+
* with the session-key wallet and calls `DELETE /api/v5/`. On 200 the target
|
|
11
|
+
* side is marked `"confirming"` in the shared TP/SL store; the WS `cancel`
|
|
12
|
+
* report flips it to `"canceled"` via `applyNotification`.
|
|
13
|
+
*/
|
|
14
|
+
export declare function useDeleteQuoteTpSl(parameters?: UseDeleteQuoteTpSlParameters): UseDeleteQuoteTpSlReturnType;
|
|
15
|
+
//# sourceMappingURL=use-delete-quote-tpsl.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-delete-quote-tpsl.d.ts","sourceRoot":"","sources":["../../src/tpsl/use-delete-quote-tpsl.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,KAAK,eAAe,EACpB,KAAK,yBAAyB,EAC9B,KAAK,yBAAyB,EAC/B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAe,KAAK,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAE5E,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAKzE,iDAAiD;AACjD,MAAM,MAAM,4BAA4B,GAAG,eAAe,CAAC;AAE3D,iDAAiD;AACjD,MAAM,MAAM,4BAA4B,GAAG,iBAAiB,CAC1D,yBAAyB,EACzB,kBAAkB,EAClB,yBAAyB,CAC1B,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,UAAU,GAAE,4BAAiC,GAAG,4BAA4B,CAoB9G"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useSymmioChainId as e } from "../provider/use-symmio-chain-id.js";
|
|
3
|
+
import { useSymmioConfig as t } from "../provider/use-symmio-config.js";
|
|
4
|
+
import { normalizeSymmError as n } from "../errors/normalize-symm-error.js";
|
|
5
|
+
import { useTpSlStore as r } from "./tpsl-store.js";
|
|
6
|
+
import { deleteQuoteTpSlMutationOptions as i } from "@symmio/trading-core";
|
|
7
|
+
import { useMutation as a } from "@tanstack/react-query";
|
|
8
|
+
//#region src/tpsl/use-delete-quote-tpsl.ts
|
|
9
|
+
function o(o = {}) {
|
|
10
|
+
let s = t(o), c = e(), l = i(s), u = r((e) => e.markConfirming);
|
|
11
|
+
return a({
|
|
12
|
+
mutationKey: l.mutationKey,
|
|
13
|
+
mutationFn: async (e) => {
|
|
14
|
+
try {
|
|
15
|
+
return await l.mutationFn({
|
|
16
|
+
...e,
|
|
17
|
+
chainId: e.chainId ?? c
|
|
18
|
+
});
|
|
19
|
+
} catch (e) {
|
|
20
|
+
throw n(e);
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
onSuccess: (e, t) => {
|
|
24
|
+
t.conditionalOrderType === "take_profit" && u(t.quoteId, "tp"), t.conditionalOrderType === "stop_loss" && u(t.quoteId, "sl");
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
//#endregion
|
|
29
|
+
export { o as useDeleteQuoteTpSl };
|
|
30
|
+
|
|
31
|
+
//# sourceMappingURL=use-delete-quote-tpsl.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-delete-quote-tpsl.js","names":[],"sources":["../../src/tpsl/use-delete-quote-tpsl.ts"],"sourcesContent":["\"use client\";\n\nimport {\n deleteQuoteTpSlMutationOptions,\n type ConfigParameter,\n type DeleteQuoteTpSlParameters,\n type DeleteQuoteTpSlReturnType,\n} from \"@symmio/trading-core\";\nimport { useMutation, type UseMutationResult } from \"@tanstack/react-query\";\nimport { normalizeSymmError } from \"../errors/normalize-symm-error\";\nimport type { SymmioRequestError } from \"../errors/symmio-request-error\";\nimport { useSymmioChainId } from \"../provider/use-symmio-chain-id\";\nimport { useSymmioConfig } from \"../provider/use-symmio-config\";\nimport { useTpSlStore } from \"./tpsl-store\";\n\n/** Parameters for {@link useDeleteQuoteTpSl}. */\nexport type UseDeleteQuoteTpSlParameters = ConfigParameter;\n\n/** Return type of {@link useDeleteQuoteTpSl}. */\nexport type UseDeleteQuoteTpSlReturnType = UseMutationResult<\n DeleteQuoteTpSlReturnType,\n SymmioRequestError,\n DeleteQuoteTpSlParameters\n>;\n\n/**\n * Cancel a live TP or SL by its `cohQuoteId`. Signs an EIP-712 delete message\n * with the session-key wallet and calls `DELETE /api/v5/`. On 200 the target\n * side is marked `\"confirming\"` in the shared TP/SL store; the WS `cancel`\n * report flips it to `\"canceled\"` via `applyNotification`.\n */\nexport function useDeleteQuoteTpSl(parameters: UseDeleteQuoteTpSlParameters = {}): UseDeleteQuoteTpSlReturnType {\n const config = useSymmioConfig(parameters);\n const chainId = useSymmioChainId();\n const base = deleteQuoteTpSlMutationOptions(config);\n const markConfirming = useTpSlStore((state) => state.markConfirming);\n\n return useMutation<DeleteQuoteTpSlReturnType, SymmioRequestError, DeleteQuoteTpSlParameters>({\n mutationKey: base.mutationKey,\n mutationFn: async (variables) => {\n try {\n return await base.mutationFn({ ...variables, chainId: variables.chainId ?? chainId });\n } catch (err) {\n throw normalizeSymmError(err);\n }\n },\n onSuccess: (_result, variables) => {\n if (variables.conditionalOrderType === \"take_profit\") markConfirming(variables.quoteId, \"tp\");\n if (variables.conditionalOrderType === \"stop_loss\") markConfirming(variables.quoteId, \"sl\");\n },\n });\n}\n"],"mappings":";;;;;;;;AA+BA,SAAgB,EAAmB,IAA2C,CAAC,GAAiC;CAC9G,IAAM,IAAS,EAAgB,CAAU,GACnC,IAAU,EAAiB,GAC3B,IAAO,EAA+B,CAAM,GAC5C,IAAiB,GAAc,MAAU,EAAM,cAAc;CAEnE,OAAO,EAAsF;EAC3F,aAAa,EAAK;EAClB,YAAY,OAAO,MAAc;GAC/B,IAAI;IACF,OAAO,MAAM,EAAK,WAAW;KAAE,GAAG;KAAW,SAAS,EAAU,WAAW;IAAQ,CAAC;GACtF,SAAS,GAAK;IACZ,MAAM,EAAmB,CAAG;GAC9B;EACF;EACA,YAAY,GAAS,MAAc;GAEjC,AADI,EAAU,yBAAyB,iBAAe,EAAe,EAAU,SAAS,IAAI,GACxF,EAAU,yBAAyB,eAAa,EAAe,EAAU,SAAS,IAAI;EAC5F;CACF,CAAC;AACH"}
|
|
@@ -1,34 +1,33 @@
|
|
|
1
|
-
import { ConfigParameter, GetQuoteTpSlOptions
|
|
1
|
+
import { ConfigParameter, GetQuoteTpSlOptions } from '@symmio/trading-core';
|
|
2
2
|
import { UseQueryResult } from '@tanstack/react-query';
|
|
3
3
|
import { Address } from 'viem';
|
|
4
|
-
import { SymmioRequestError } from '../errors/symmio-request-error';
|
|
4
|
+
import { SymmioRequestError } from '../errors/symmio-request-error.js';
|
|
5
|
+
import { TpSlRecord } from './tpsl-store.js';
|
|
5
6
|
/** Parameters for {@link useQuoteTpSl}. */
|
|
6
|
-
export type UseQuoteTpSlParameters = GetQuoteTpSlOptions & ConfigParameter & {
|
|
7
|
+
export type UseQuoteTpSlParameters = Omit<GetQuoteTpSlOptions, "quoteId"> & ConfigParameter & {
|
|
8
|
+
/**
|
|
9
|
+
* Quote id — accepts either the on-chain `quoteId` or the hedger
|
|
10
|
+
* `tempQuoteId`. Whichever is passed, the hook resolves to the same
|
|
11
|
+
* shared record via the store's id index.
|
|
12
|
+
*/
|
|
13
|
+
quoteId: bigint;
|
|
7
14
|
/**
|
|
8
15
|
* SubAccount address — when provided, the hook also subscribes to the
|
|
9
|
-
* TP/SL WebSocket and reconciles the
|
|
10
|
-
* without manual polling. Omit to skip WS (REST-only).
|
|
16
|
+
* TP/SL WebSocket and reconciles the record without manual polling.
|
|
11
17
|
*/
|
|
12
18
|
account?: Address;
|
|
13
19
|
};
|
|
14
20
|
/** Return type of {@link useQuoteTpSl}. */
|
|
15
|
-
export type UseQuoteTpSlReturnType = UseQueryResult<
|
|
16
|
-
/** The unfiltered conditional-order rows returned by the handler. */
|
|
17
|
-
rows: QuoteTpSlRow[] | undefined;
|
|
18
|
-
};
|
|
21
|
+
export type UseQuoteTpSlReturnType = UseQueryResult<TpSlRecord, SymmioRequestError>;
|
|
19
22
|
/**
|
|
20
|
-
* Read the TP/SL snapshot for one on-chain
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
* {@link QuoteTpSl} via {@link toQuoteTpSl}.
|
|
23
|
+
* Read the folded TP/SL snapshot for one quote. Pass either the on-chain
|
|
24
|
+
* `quoteId` or the hedger `tempQuoteId` — the store keeps a single record per
|
|
25
|
+
* quote indexed under every id it has learned for that quote, so both callers
|
|
26
|
+
* get the same object.
|
|
25
27
|
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
* until a matching WebSocket `report` arrives with `successful: true`. On
|
|
30
|
-
* that report the slot is cleared and the rows query is invalidated, so the
|
|
31
|
-
* fresh snapshot flips the side to `new` (active).
|
|
28
|
+
* The `confirming` overlay ("POST accepted, awaiting handler") is merged into
|
|
29
|
+
* `tpState` / `slState` at read time — a side flagged as confirming reports
|
|
30
|
+
* state `"confirming"` regardless of what the row set says.
|
|
32
31
|
*/
|
|
33
32
|
export declare function useQuoteTpSl(parameters: UseQuoteTpSlParameters): UseQuoteTpSlReturnType;
|
|
34
33
|
//# sourceMappingURL=use-quote-tpsl.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-quote-tpsl.d.ts","sourceRoot":"","sources":["../../src/tpsl/use-quote-tpsl.ts"],"names":[],"mappings":"AAEA,OAAO,
|
|
1
|
+
{"version":3,"file":"use-quote-tpsl.d.ts","sourceRoot":"","sources":["../../src/tpsl/use-quote-tpsl.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,KAAK,eAAe,EACpB,KAAK,mBAAmB,EAEzB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAY,KAAK,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACtE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAEpC,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAGzE,OAAO,EAA+B,KAAK,UAAU,EAAE,MAAM,cAAc,CAAC;AAG5E,2CAA2C;AAC3C,MAAM,MAAM,sBAAsB,GAAG,IAAI,CAAC,mBAAmB,EAAE,SAAS,CAAC,GACvE,eAAe,GAAG;IAChB;;;;OAIG;IACH,OAAO,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB,CAAC;AAEJ,2CAA2C;AAC3C,MAAM,MAAM,sBAAsB,GAAG,cAAc,CAAC,UAAU,EAAE,kBAAkB,CAAC,CAAC;AAEpF;;;;;;;;;GASG;AACH,wBAAgB,YAAY,CAAC,UAAU,EAAE,sBAAsB,GAAG,sBAAsB,CA8CvF"}
|
|
@@ -2,72 +2,43 @@
|
|
|
2
2
|
import { useSymmioChainId as e } from "../provider/use-symmio-chain-id.js";
|
|
3
3
|
import { useSymmioConfig as t } from "../provider/use-symmio-config.js";
|
|
4
4
|
import { normalizeSymmError as n } from "../errors/normalize-symm-error.js";
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import { useEffect as u, useMemo as d } from "react";
|
|
10
|
-
import { useQuery as f, useQueryClient as p } from "@tanstack/react-query";
|
|
5
|
+
import { useTpSlRecord as r, useTpSlStore as i } from "./tpsl-store.js";
|
|
6
|
+
import { useWatchTpSlNotifications as a } from "./use-watch-tpsl-notifications.js";
|
|
7
|
+
import { getQuoteTpSlQueryOptions as o } from "@symmio/trading-core";
|
|
8
|
+
import { useQuery as s } from "@tanstack/react-query";
|
|
11
9
|
//#region src/tpsl/use-quote-tpsl.ts
|
|
12
|
-
function
|
|
13
|
-
let
|
|
10
|
+
function c(c) {
|
|
11
|
+
let u = t(c), d = e(), f = c.chainId ?? d, p = r(c.quoteId), m = o(u, {
|
|
12
|
+
...c,
|
|
13
|
+
chainId: f,
|
|
14
|
+
quoteId: c.quoteId
|
|
15
|
+
}), h = s({
|
|
14
16
|
...m,
|
|
15
|
-
chainId: y
|
|
16
|
-
}), C = f({
|
|
17
|
-
...S,
|
|
18
17
|
queryFn: async () => {
|
|
19
18
|
try {
|
|
20
|
-
|
|
19
|
+
let e = await m.queryFn();
|
|
20
|
+
return i.getState().setRows(c.quoteId, e), e;
|
|
21
21
|
} catch (e) {
|
|
22
22
|
throw n(e);
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
|
-
})
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}), T = o({
|
|
30
|
-
chainId: y,
|
|
31
|
-
quoteId: m.quoteId,
|
|
32
|
-
configKey: x
|
|
33
|
-
}), E = f({
|
|
34
|
-
queryKey: T,
|
|
35
|
-
queryFn: () => b.getQueryData(T) ?? i,
|
|
36
|
-
initialData: i,
|
|
37
|
-
staleTime: Infinity,
|
|
38
|
-
gcTime: Infinity
|
|
39
|
-
}).data ?? i, D = d(() => {
|
|
40
|
-
if (C.data) return g(r(C.data), E);
|
|
41
|
-
}, [C.data, E]), O = m.account, k = m.quoteId, A = JSON.stringify(w);
|
|
42
|
-
return s({
|
|
43
|
-
account: O,
|
|
44
|
-
enabled: !!O && k > 0n,
|
|
25
|
+
});
|
|
26
|
+
return a({
|
|
27
|
+
account: c.account,
|
|
28
|
+
enabled: !!c.account && c.quoteId !== 0n,
|
|
45
29
|
onNotification: (e) => {
|
|
46
|
-
|
|
47
|
-
if (e.successful) {
|
|
48
|
-
let t = e.conditionalOrderType === "take_profit" ? "tp" : e.conditionalOrderType === "stop_loss" ? "sl" : null;
|
|
49
|
-
t && (e.state === "new" || e.state === "edit") && a(b, T, t);
|
|
50
|
-
}
|
|
51
|
-
b.invalidateQueries({ queryKey: w });
|
|
52
|
-
}
|
|
30
|
+
e.primaryIdentifier !== 0 && e.secondaryIdentifier !== 0 && i.getState().link(BigInt(e.primaryIdentifier), BigInt(e.secondaryIdentifier)), l(e, c.quoteId) && i.getState().applyNotification(c.quoteId, e);
|
|
53
31
|
}
|
|
54
|
-
}),
|
|
55
|
-
|
|
56
|
-
data:
|
|
57
|
-
rows: C.data
|
|
32
|
+
}), {
|
|
33
|
+
query: h,
|
|
34
|
+
data: p
|
|
58
35
|
};
|
|
59
36
|
}
|
|
60
|
-
function
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
function g(e, t) {
|
|
64
|
-
return !t.tp && !t.sl ? e : {
|
|
65
|
-
...e,
|
|
66
|
-
tpState: t.tp ? "confirming" : e.tpState,
|
|
67
|
-
slState: t.sl ? "confirming" : e.slState
|
|
68
|
-
};
|
|
37
|
+
function l(e, t) {
|
|
38
|
+
let n = i.getState(), r = n.get(t);
|
|
39
|
+
return r ? e.primaryIdentifier !== 0 && n.get(BigInt(e.primaryIdentifier)) === r || e.secondaryIdentifier !== 0 && n.get(BigInt(e.secondaryIdentifier)) === r : e.primaryIdentifier === Number(t) || e.secondaryIdentifier === Number(t) || e.quoteId === Number(t);
|
|
69
40
|
}
|
|
70
41
|
//#endregion
|
|
71
|
-
export {
|
|
42
|
+
export { c as useQuoteTpSl };
|
|
72
43
|
|
|
73
44
|
//# sourceMappingURL=use-quote-tpsl.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-quote-tpsl.js","names":[],"sources":["../../src/tpsl/use-quote-tpsl.ts"],"sourcesContent":["\"use client\";\n\nimport {\n
|
|
1
|
+
{"version":3,"file":"use-quote-tpsl.js","names":[],"sources":["../../src/tpsl/use-quote-tpsl.ts"],"sourcesContent":["\"use client\";\n\nimport {\n getQuoteTpSlQueryOptions,\n type ConfigParameter,\n type GetQuoteTpSlOptions,\n type TpSlNotification,\n} from \"@symmio/trading-core\";\nimport { useQuery, type UseQueryResult } from \"@tanstack/react-query\";\nimport type { Address } from \"viem\";\nimport { normalizeSymmError } from \"../errors/normalize-symm-error\";\nimport type { SymmioRequestError } from \"../errors/symmio-request-error\";\nimport { useSymmioChainId } from \"../provider/use-symmio-chain-id\";\nimport { useSymmioConfig } from \"../provider/use-symmio-config\";\nimport { useTpSlRecord, useTpSlStore, type TpSlRecord } from \"./tpsl-store\";\nimport { useWatchTpSlNotifications } from \"./use-watch-tpsl-notifications\";\n\n/** Parameters for {@link useQuoteTpSl}. */\nexport type UseQuoteTpSlParameters = Omit<GetQuoteTpSlOptions, \"quoteId\"> &\n ConfigParameter & {\n /**\n * Quote id — accepts either the on-chain `quoteId` or the hedger\n * `tempQuoteId`. Whichever is passed, the hook resolves to the same\n * shared record via the store's id index.\n */\n quoteId: bigint;\n /**\n * SubAccount address — when provided, the hook also subscribes to the\n * TP/SL WebSocket and reconciles the record without manual polling.\n */\n account?: Address;\n };\n\n/** Return type of {@link useQuoteTpSl}. */\nexport type UseQuoteTpSlReturnType = UseQueryResult<TpSlRecord, SymmioRequestError>;\n\n/**\n * Read the folded TP/SL snapshot for one quote. Pass either the on-chain\n * `quoteId` or the hedger `tempQuoteId` — the store keeps a single record per\n * quote indexed under every id it has learned for that quote, so both callers\n * get the same object.\n *\n * The `confirming` overlay (\"POST accepted, awaiting handler\") is merged into\n * `tpState` / `slState` at read time — a side flagged as confirming reports\n * state `\"confirming\"` regardless of what the row set says.\n */\nexport function useQuoteTpSl(parameters: UseQuoteTpSlParameters): UseQuoteTpSlReturnType {\n const config = useSymmioConfig(parameters);\n const defaultChainId = useSymmioChainId();\n const chainId = parameters.chainId ?? defaultChainId;\n\n const record = useTpSlRecord(parameters.quoteId);\n const options = getQuoteTpSlQueryOptions(config, {\n ...parameters,\n chainId,\n quoteId: parameters.quoteId,\n });\n // Re-fetch is driven by TanStack Query cache: mutations invalidate `rowsKey`,\n // which triggers a refetch here so the store record picks up the newly\n // committed tp/sl values. (An earlier version gated on `record === undefined`\n // to avoid a duplicate fetch when the on-chain quoteId first appeared, but\n // that also swallowed post-mutation invalidations — leaving the box stuck on\n // the old values.)\n const queryResult = useQuery({\n ...options,\n queryFn: async () => {\n try {\n const rows = await options.queryFn();\n useTpSlStore.getState().setRows(parameters.quoteId, rows);\n return rows;\n } catch (err) {\n throw normalizeSymmError(err);\n }\n },\n });\n\n useWatchTpSlNotifications({\n account: parameters.account,\n enabled: Boolean(parameters.account) && parameters.quoteId !== 0n,\n onNotification: (notification) => {\n if (notification.primaryIdentifier !== 0 && notification.secondaryIdentifier !== 0) {\n useTpSlStore.getState().link(BigInt(notification.primaryIdentifier), BigInt(notification.secondaryIdentifier));\n }\n if (!matchesQuote(notification, parameters.quoteId)) return;\n useTpSlStore.getState().applyNotification(parameters.quoteId, notification);\n },\n });\n\n return {\n query: queryResult,\n data: record,\n } as unknown as UseQuoteTpSlReturnType;\n}\n\n/**\n * True when the notification and the caller address the same store record.\n * Uses the store's id index — every id linked to the same record maps to\n * the same object, so reference equality decides the match.\n */\nfunction matchesQuote(notification: TpSlNotification, quoteId: bigint): boolean {\n const store = useTpSlStore.getState();\n const target = store.get(quoteId);\n if (!target) {\n // No record yet for the target — fall back to raw-id compare so the\n // first \"seed\" frame still matches.\n return (\n notification.primaryIdentifier === Number(quoteId) ||\n notification.secondaryIdentifier === Number(quoteId) ||\n notification.quoteId === Number(quoteId)\n );\n }\n if (notification.primaryIdentifier !== 0 && store.get(BigInt(notification.primaryIdentifier)) === target) return true;\n if (notification.secondaryIdentifier !== 0 && store.get(BigInt(notification.secondaryIdentifier)) === target)\n return true;\n return false;\n}\n"],"mappings":";;;;;;;;;AA8CA,SAAgB,EAAa,GAA4D;CACvF,IAAM,IAAS,EAAgB,CAAU,GACnC,IAAiB,EAAiB,GAClC,IAAU,EAAW,WAAW,GAEhC,IAAS,EAAc,EAAW,OAAO,GACzC,IAAU,EAAyB,GAAQ;EAC/C,GAAG;EACH;EACA,SAAS,EAAW;CACtB,CAAC,GAOK,IAAc,EAAS;EAC3B,GAAG;EACH,SAAS,YAAY;GACnB,IAAI;IACF,IAAM,IAAO,MAAM,EAAQ,QAAQ;IAEnC,OADA,EAAa,SAAS,EAAE,QAAQ,EAAW,SAAS,CAAI,GACjD;GACT,SAAS,GAAK;IACZ,MAAM,EAAmB,CAAG;GAC9B;EACF;CACF,CAAC;CAcD,OAZA,EAA0B;EACxB,SAAS,EAAW;EACpB,SAAS,EAAQ,EAAW,WAAY,EAAW,YAAY;EAC/D,iBAAiB,MAAiB;GAChC,AAAI,EAAa,sBAAsB,KAAK,EAAa,wBAAwB,KAC/E,EAAa,SAAS,EAAE,KAAK,OAAO,EAAa,iBAAiB,GAAG,OAAO,EAAa,mBAAmB,CAAC,GAE1G,EAAa,GAAc,EAAW,OAAO,KAClD,EAAa,SAAS,EAAE,kBAAkB,EAAW,SAAS,CAAY;EAC5E;CACF,CAAC,GAEM;EACL,OAAO;EACP,MAAM;CACR;AACF;AAOA,SAAS,EAAa,GAAgC,GAA0B;CAC9E,IAAM,IAAQ,EAAa,SAAS,GAC9B,IAAS,EAAM,IAAI,CAAO;CAahC,OAZK,IASD,EAAa,sBAAsB,KAAK,EAAM,IAAI,OAAO,EAAa,iBAAiB,CAAC,MAAM,KAC9F,EAAa,wBAAwB,KAAK,EAAM,IAAI,OAAO,EAAa,mBAAmB,CAAC,MAAM,IANlG,EAAa,sBAAsB,OAAO,CAAO,KACjD,EAAa,wBAAwB,OAAO,CAAO,KACnD,EAAa,YAAY,OAAO,CAAO;AAO7C"}
|
|
@@ -1,22 +1,23 @@
|
|
|
1
1
|
import { ConfigParameter, SetQuoteTpSlParameters, SetQuoteTpSlReturnType } 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
|
/** Parameters for {@link useSetQuoteTpSl}. */
|
|
5
5
|
export type UseSetQuoteTpSlParameters = ConfigParameter;
|
|
6
6
|
/** Return type of {@link useSetQuoteTpSl}. */
|
|
7
7
|
export type UseSetQuoteTpSlReturnType = UseMutationResult<SetQuoteTpSlReturnType, SymmioRequestError, SetQuoteTpSlParameters>;
|
|
8
8
|
/**
|
|
9
|
-
* Submit a TP/SL order for one
|
|
10
|
-
*
|
|
9
|
+
* Submit a TP/SL order for one quote. Signs an EIP-712 message with the
|
|
10
|
+
* session-key wallet and POSTs to the handler.
|
|
11
11
|
*
|
|
12
12
|
* State machine (per side):
|
|
13
|
-
* 1. `pending`
|
|
14
|
-
* 2. `confirming` — POST returned 200;
|
|
15
|
-
* confirming
|
|
16
|
-
*
|
|
17
|
-
* 3. `new`
|
|
18
|
-
* `useQuoteTpSl`'s WS listener
|
|
19
|
-
*
|
|
13
|
+
* 1. `pending` — POST in flight (`mutation.isPending`).
|
|
14
|
+
* 2. `confirming` — POST returned 200; the store's `markConfirming` sets
|
|
15
|
+
* `tp/slState` to `"confirming"` and seeds the target trigger price so
|
|
16
|
+
* the UI can render it immediately.
|
|
17
|
+
* 3. `new` — Handler broadcast a `report` with `successful: true`;
|
|
18
|
+
* `useQuoteTpSl`'s WS listener runs `applyNotification`, which flips the
|
|
19
|
+
* side into its wire-reported state and confirms the trigger price from
|
|
20
|
+
* `details.trigger_price`. No REST refetch — the store is authoritative.
|
|
20
21
|
*/
|
|
21
22
|
export declare function useSetQuoteTpSl(parameters?: UseSetQuoteTpSlParameters): UseSetQuoteTpSlReturnType;
|
|
22
23
|
//# sourceMappingURL=use-set-quote-tpsl.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-set-quote-tpsl.d.ts","sourceRoot":"","sources":["../../src/tpsl/use-set-quote-tpsl.ts"],"names":[],"mappings":"AAEA,OAAO,
|
|
1
|
+
{"version":3,"file":"use-set-quote-tpsl.d.ts","sourceRoot":"","sources":["../../src/tpsl/use-set-quote-tpsl.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,KAAK,eAAe,EACpB,KAAK,sBAAsB,EAC3B,KAAK,sBAAsB,EAC5B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAe,KAAK,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAE5E,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAKzE,8CAA8C;AAC9C,MAAM,MAAM,yBAAyB,GAAG,eAAe,CAAC;AAExD,8CAA8C;AAC9C,MAAM,MAAM,yBAAyB,GAAG,iBAAiB,CACvD,sBAAsB,EACtB,kBAAkB,EAClB,sBAAsB,CACvB,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,wBAAgB,eAAe,CAAC,UAAU,GAAE,yBAA8B,GAAG,yBAAyB,CAgCrG"}
|
|
@@ -2,42 +2,38 @@
|
|
|
2
2
|
import { useSymmioChainId as e } from "../provider/use-symmio-chain-id.js";
|
|
3
3
|
import { useSymmioConfig as t } from "../provider/use-symmio-config.js";
|
|
4
4
|
import { normalizeSymmError as n } from "../errors/normalize-symm-error.js";
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import { useMutation as
|
|
5
|
+
import { useTpSlStore as r } from "./tpsl-store.js";
|
|
6
|
+
import { setQuoteTpSlMutationOptions as i } from "@symmio/trading-core";
|
|
7
|
+
import { useMutation as a } from "@tanstack/react-query";
|
|
8
8
|
//#region src/tpsl/use-set-quote-tpsl.ts
|
|
9
|
-
function
|
|
10
|
-
let
|
|
11
|
-
return
|
|
12
|
-
mutationKey:
|
|
9
|
+
function o(o = {}) {
|
|
10
|
+
let s = t(o), c = e(), l = i(s), u = r((e) => e.markConfirming);
|
|
11
|
+
return a({
|
|
12
|
+
mutationKey: l.mutationKey,
|
|
13
13
|
mutationFn: async (e) => {
|
|
14
14
|
try {
|
|
15
|
-
return await
|
|
15
|
+
return await l.mutationFn({
|
|
16
16
|
...e,
|
|
17
|
-
chainId: e.chainId ??
|
|
17
|
+
chainId: e.chainId ?? c
|
|
18
18
|
});
|
|
19
19
|
} catch (e) {
|
|
20
20
|
throw n(e);
|
|
21
21
|
}
|
|
22
22
|
},
|
|
23
23
|
onSuccess: (e, t) => {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
24
|
+
t.tp && u(t.quoteId, "tp", {
|
|
25
|
+
price: t.tp.triggerPrice,
|
|
26
|
+
priceType: t.tp.priceType,
|
|
27
|
+
cohQuoteId: e.cohQuoteId
|
|
28
|
+
}), t.sl && u(t.quoteId, "sl", {
|
|
29
|
+
price: t.sl.triggerPrice,
|
|
30
|
+
priceType: t.sl.priceType,
|
|
31
|
+
cohQuoteId: e.cohQuoteId
|
|
28
32
|
});
|
|
29
|
-
i(f, r({
|
|
30
|
-
chainId: n,
|
|
31
|
-
quoteId: t.quoteId,
|
|
32
|
-
configKey: o
|
|
33
|
-
}), {
|
|
34
|
-
tp: !!t.tp,
|
|
35
|
-
sl: !!t.sl
|
|
36
|
-
}), f.invalidateQueries({ queryKey: s });
|
|
37
33
|
}
|
|
38
34
|
});
|
|
39
35
|
}
|
|
40
36
|
//#endregion
|
|
41
|
-
export {
|
|
37
|
+
export { o as useSetQuoteTpSl };
|
|
42
38
|
|
|
43
39
|
//# sourceMappingURL=use-set-quote-tpsl.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-set-quote-tpsl.js","names":[],"sources":["../../src/tpsl/use-set-quote-tpsl.ts"],"sourcesContent":["\"use client\";\n\nimport {\n
|
|
1
|
+
{"version":3,"file":"use-set-quote-tpsl.js","names":[],"sources":["../../src/tpsl/use-set-quote-tpsl.ts"],"sourcesContent":["\"use client\";\n\nimport {\n setQuoteTpSlMutationOptions,\n type ConfigParameter,\n type SetQuoteTpSlParameters,\n type SetQuoteTpSlReturnType,\n} from \"@symmio/trading-core\";\nimport { useMutation, type UseMutationResult } from \"@tanstack/react-query\";\nimport { normalizeSymmError } from \"../errors/normalize-symm-error\";\nimport type { SymmioRequestError } from \"../errors/symmio-request-error\";\nimport { useSymmioChainId } from \"../provider/use-symmio-chain-id\";\nimport { useSymmioConfig } from \"../provider/use-symmio-config\";\nimport { useTpSlStore } from \"./tpsl-store\";\n\n/** Parameters for {@link useSetQuoteTpSl}. */\nexport type UseSetQuoteTpSlParameters = ConfigParameter;\n\n/** Return type of {@link useSetQuoteTpSl}. */\nexport type UseSetQuoteTpSlReturnType = UseMutationResult<\n SetQuoteTpSlReturnType,\n SymmioRequestError,\n SetQuoteTpSlParameters\n>;\n\n/**\n * Submit a TP/SL order for one quote. Signs an EIP-712 message with the\n * session-key wallet and POSTs to the handler.\n *\n * State machine (per side):\n * 1. `pending` — POST in flight (`mutation.isPending`).\n * 2. `confirming` — POST returned 200; the store's `markConfirming` sets\n * `tp/slState` to `\"confirming\"` and seeds the target trigger price so\n * the UI can render it immediately.\n * 3. `new` — Handler broadcast a `report` with `successful: true`;\n * `useQuoteTpSl`'s WS listener runs `applyNotification`, which flips the\n * side into its wire-reported state and confirms the trigger price from\n * `details.trigger_price`. No REST refetch — the store is authoritative.\n */\nexport function useSetQuoteTpSl(parameters: UseSetQuoteTpSlParameters = {}): UseSetQuoteTpSlReturnType {\n const config = useSymmioConfig(parameters);\n const chainId = useSymmioChainId();\n const base = setQuoteTpSlMutationOptions(config);\n const markConfirming = useTpSlStore((state) => state.markConfirming);\n\n return useMutation<SetQuoteTpSlReturnType, SymmioRequestError, SetQuoteTpSlParameters>({\n mutationKey: base.mutationKey,\n mutationFn: async (variables) => {\n try {\n return await base.mutationFn({ ...variables, chainId: variables.chainId ?? chainId });\n } catch (err) {\n throw normalizeSymmError(err);\n }\n },\n onSuccess: (result, variables) => {\n if (variables.tp) {\n markConfirming(variables.quoteId, \"tp\", {\n price: variables.tp.triggerPrice,\n priceType: variables.tp.priceType,\n cohQuoteId: result.cohQuoteId,\n });\n }\n if (variables.sl) {\n markConfirming(variables.quoteId, \"sl\", {\n price: variables.sl.triggerPrice,\n priceType: variables.sl.priceType,\n cohQuoteId: result.cohQuoteId,\n });\n }\n },\n });\n}\n"],"mappings":";;;;;;;;AAuCA,SAAgB,EAAgB,IAAwC,CAAC,GAA8B;CACrG,IAAM,IAAS,EAAgB,CAAU,GACnC,IAAU,EAAiB,GAC3B,IAAO,EAA4B,CAAM,GACzC,IAAiB,GAAc,MAAU,EAAM,cAAc;CAEnE,OAAO,EAAgF;EACrF,aAAa,EAAK;EAClB,YAAY,OAAO,MAAc;GAC/B,IAAI;IACF,OAAO,MAAM,EAAK,WAAW;KAAE,GAAG;KAAW,SAAS,EAAU,WAAW;IAAQ,CAAC;GACtF,SAAS,GAAK;IACZ,MAAM,EAAmB,CAAG;GAC9B;EACF;EACA,YAAY,GAAQ,MAAc;GAQhC,AAPI,EAAU,MACZ,EAAe,EAAU,SAAS,MAAM;IACtC,OAAO,EAAU,GAAG;IACpB,WAAW,EAAU,GAAG;IACxB,YAAY,EAAO;GACrB,CAAC,GAEC,EAAU,MACZ,EAAe,EAAU,SAAS,MAAM;IACtC,OAAO,EAAU,GAAG;IACpB,WAAW,EAAU,GAAG;IACxB,YAAY,EAAO;GACrB,CAAC;EAEL;CACF,CAAC;AACH"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ConfigParameter, GetTpSlConfigOptions, GetTpSlConfigReturnType } 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
|
/** Parameters for {@link useTpSlConfig}. */
|
|
5
5
|
export type UseTpSlConfigParameters = GetTpSlConfigOptions & ConfigParameter;
|
|
6
6
|
/** Return type of {@link useTpSlConfig}. */
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ConfigParameter, GetTpSlSigningSpecOptions, GetTpSlSigningSpecReturnType } 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
|
/** Parameters for {@link useTpSlSigningSpec}. */
|
|
5
5
|
export type UseTpSlSigningSpecParameters = GetTpSlSigningSpecOptions & ConfigParameter;
|
|
6
6
|
/** Return type of {@link useTpSlSigningSpec}. */
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ConfigParameter, SocketStatus, TpSlNotification } from '@symmio/trading-core';
|
|
2
2
|
import { Address } from 'viem';
|
|
3
|
-
import { SymmioRequestError } from '../errors/symmio-request-error';
|
|
3
|
+
import { SymmioRequestError } from '../errors/symmio-request-error.js';
|
|
4
4
|
/**
|
|
5
5
|
* Parameters for {@link useWatchTpSlNotifications}.
|
|
6
6
|
*/
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export * from './resolve-write-result';
|
|
2
|
-
export * from './use-transactions-store';
|
|
3
|
-
export * from './write-types';
|
|
1
|
+
export * from './resolve-write-result.js';
|
|
2
|
+
export * from './use-transactions-store.js';
|
|
3
|
+
export * from './write-types.js';
|
|
4
4
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './use-transfer-history';
|
|
1
|
+
export * from './use-transfer-history.js';
|
|
2
2
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ConfigParameter, GetTransferHistoryOptions, GetTransferHistoryReturnType } 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 useTransferHistory}: the core query options (accounts,
|
|
6
6
|
* direction, paging, time range, chain id, TanStack `query` overrides) plus an
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { predicateMatch } from './predicate-match';
|
|
1
|
+
export { predicateMatch } from './predicate-match.js';
|
|
2
2
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/wallet/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export * from './use-connect-wallet';
|
|
2
|
-
export * from './use-disconnect-wallet';
|
|
3
|
-
export * from './use-switch-to-symmio-chain';
|
|
4
|
-
export * from './use-wallet-account';
|
|
1
|
+
export * from './use-connect-wallet.js';
|
|
2
|
+
export * from './use-disconnect-wallet.js';
|
|
3
|
+
export * from './use-switch-to-symmio-chain.js';
|
|
4
|
+
export * from './use-wallet-account.js';
|
|
5
5
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { useConnectWallet as e } from "./use-connect-wallet.js";
|
|
2
|
+
import { useDisconnectWallet as t } from "./use-disconnect-wallet.js";
|
|
3
|
+
import { useSwitchToSymmioChain as n } from "./use-switch-to-symmio-chain.js";
|
|
4
|
+
import { useWalletAccount as r } from "./use-wallet-account.js";
|
|
5
|
+
export { e as useConnectWallet, t as useDisconnectWallet, n as useSwitchToSymmioChain, r as useWalletAccount };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { useNotifications, type UseNotificationsParameters, type UseNotificationsReturnType, } from './use-notifications';
|
|
1
|
+
export { useNotifications, type UseNotificationsParameters, type UseNotificationsReturnType, } from './use-notifications.js';
|
|
2
2
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ConfigParameter, Notification, SocketStatus } from '@symmio/trading-core';
|
|
2
2
|
import { Address } from 'viem';
|
|
3
|
-
import { SymmioRequestError } from '../errors/symmio-request-error';
|
|
3
|
+
import { SymmioRequestError } from '../errors/symmio-request-error.js';
|
|
4
4
|
/**
|
|
5
5
|
* Parameters for {@link useNotifications}.
|
|
6
6
|
*/
|
package/dist/withdraw/index.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
export * from './use-finalize-withdraw-request';
|
|
2
|
-
export * from './use-initiate-withdraw';
|
|
3
|
-
export * from './use-last-withdraw-request-id';
|
|
4
|
-
export * from './use-pending-withdraw-requests';
|
|
5
|
-
export * from './use-request-cancel-withdraw';
|
|
6
|
-
export * from './use-simulate-finalize-withdraw-request';
|
|
7
|
-
export * from './use-simulate-initiate-withdraw';
|
|
8
|
-
export * from './use-simulate-request-cancel-withdraw';
|
|
9
|
-
export * from './use-withdraw-requests';
|
|
10
|
-
export * from './use-withdrawable-time';
|
|
1
|
+
export * from './use-finalize-withdraw-request.js';
|
|
2
|
+
export * from './use-initiate-withdraw.js';
|
|
3
|
+
export * from './use-last-withdraw-request-id.js';
|
|
4
|
+
export * from './use-pending-withdraw-requests.js';
|
|
5
|
+
export * from './use-request-cancel-withdraw.js';
|
|
6
|
+
export * from './use-simulate-finalize-withdraw-request.js';
|
|
7
|
+
export * from './use-simulate-initiate-withdraw.js';
|
|
8
|
+
export * from './use-simulate-request-cancel-withdraw.js';
|
|
9
|
+
export * from './use-withdraw-requests.js';
|
|
10
|
+
export * from './use-withdrawable-time.js';
|
|
11
11
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { FinalizeWithdrawRequestParameters } from '@symmio/trading-core';
|
|
2
2
|
import { UseMutationResult } from '@tanstack/react-query';
|
|
3
|
-
import { SymmioRequestError } from '../errors/symmio-request-error';
|
|
4
|
-
import { WriteParameters, WriteResult } from '../transactions';
|
|
3
|
+
import { SymmioRequestError } from '../errors/symmio-request-error.js';
|
|
4
|
+
import { WriteParameters, WriteResult } from '../transactions/index.js';
|
|
5
5
|
/**
|
|
6
6
|
* Parameters for {@link useFinalizeWithdrawRequest}.
|
|
7
7
|
*/
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { InitiateWithdrawParameters } from '@symmio/trading-core';
|
|
2
2
|
import { UseMutationResult } from '@tanstack/react-query';
|
|
3
|
-
import { SymmioRequestError } from '../errors/symmio-request-error';
|
|
4
|
-
import { WriteParameters, WriteResult } from '../transactions';
|
|
3
|
+
import { SymmioRequestError } from '../errors/symmio-request-error.js';
|
|
4
|
+
import { WriteParameters, WriteResult } from '../transactions/index.js';
|
|
5
5
|
/**
|
|
6
6
|
* Parameters for {@link useInitiateWithdraw}.
|
|
7
7
|
*/
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ConfigParameter, GetLastWithdrawRequestIdOptions, GetLastWithdrawRequestIdReturnType } 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 useLastWithdrawRequestId}: the core query options (user,
|
|
6
6
|
* chain id, TanStack `query` overrides) plus an optional `config`.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ConfigParameter, GetPendingWithdrawRequestsOptions, GetPendingWithdrawRequestsReturnType } 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 usePendingWithdrawRequests}: the core query options (user,
|
|
6
6
|
* pagination, chain id, TanStack `query` overrides) plus an optional `config`.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { RequestCancelWithdrawParameters } from '@symmio/trading-core';
|
|
2
2
|
import { UseMutationResult } from '@tanstack/react-query';
|
|
3
|
-
import { SymmioRequestError } from '../errors/symmio-request-error';
|
|
4
|
-
import { WriteParameters, WriteResult } from '../transactions';
|
|
3
|
+
import { SymmioRequestError } from '../errors/symmio-request-error.js';
|
|
4
|
+
import { WriteParameters, WriteResult } from '../transactions/index.js';
|
|
5
5
|
/**
|
|
6
6
|
* Parameters for {@link useRequestCancelWithdraw}.
|
|
7
7
|
*/
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ConfigParameter, SimulateFinalizeWithdrawRequestParameters, SimulateFinalizeWithdrawRequestReturnType } 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 useSimulateFinalizeWithdrawRequest}: an optional `config` override. The dry-run's
|
|
6
6
|
* inputs are passed as the mutation `variables`.
|