@symmio/trading-react 0.1.1 → 1.0.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/README.md +2 -2
- 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 +16 -5
- package/dist/account-layer/use-account-balance-info.d.ts.map +1 -1
- package/dist/account-layer/use-account-balance-info.js +21 -9
- package/dist/account-layer/use-account-balance-info.js.map +1 -1
- package/dist/account-layer/use-account-balance-of.d.ts +16 -5
- package/dist/account-layer/use-account-balance-of.d.ts.map +1 -1
- package/dist/account-layer/use-account-balance-of.js +20 -9
- package/dist/account-layer/use-account-balance-of.js.map +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 +5 -3
- package/dist/account-layer/use-deposit.d.ts.map +1 -1
- package/dist/account-layer/use-deposit.js +17 -15
- package/dist/account-layer/use-deposit.js.map +1 -1
- 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/estimated-price/index.d.ts +2 -0
- package/dist/estimated-price/index.d.ts.map +1 -0
- package/dist/estimated-price/use-debounced-value.d.ts +9 -0
- package/dist/estimated-price/use-debounced-value.d.ts.map +1 -0
- package/dist/estimated-price/use-debounced-value.js +18 -0
- package/dist/estimated-price/use-debounced-value.js.map +1 -0
- package/dist/estimated-price/use-estimated-price.d.ts +46 -0
- package/dist/estimated-price/use-estimated-price.d.ts.map +1 -0
- package/dist/estimated-price/use-estimated-price.js +31 -0
- package/dist/estimated-price/use-estimated-price.js.map +1 -0
- 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 +45 -24
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +120 -113
- 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 +64 -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/margin/index.d.ts +2 -0
- package/dist/margin/index.d.ts.map +1 -0
- package/dist/margin/use-available-instant-open-margin.d.ts +51 -0
- package/dist/margin/use-available-instant-open-margin.d.ts.map +1 -0
- package/dist/margin/use-available-instant-open-margin.js +66 -0
- package/dist/margin/use-available-instant-open-margin.js.map +1 -0
- 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/provider/symmio-provider.d.ts +14 -5
- package/dist/provider/symmio-provider.d.ts.map +1 -1
- package/dist/provider/symmio-provider.js +2 -2
- package/dist/provider/symmio-provider.js.map +1 -1
- 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 +131 -128
- 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/is-settle-notification.d.ts +15 -0
- package/dist/websocket/is-settle-notification.d.ts.map +1 -0
- package/dist/websocket/is-settle-notification.js +15 -0
- package/dist/websocket/is-settle-notification.js.map +1 -0
- 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 +11 -10
- 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 +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
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Notification } from '@symmio/trading-core';
|
|
2
|
+
/**
|
|
3
|
+
* `true` when a notification marks an on-chain settle — a `SUCCESS` frame whose
|
|
4
|
+
* `lastSeenAction` is an open-anchor or close-fill. Live balance reads refetch
|
|
5
|
+
* on exactly these.
|
|
6
|
+
*/
|
|
7
|
+
export declare function isSettleNotification(notification: Notification): boolean;
|
|
8
|
+
/**
|
|
9
|
+
* Delays (ms) at which a live balance read refetches after a settle
|
|
10
|
+
* notification. The on-chain read lags the anchor block, so a single immediate
|
|
11
|
+
* read often returns the pre-settle value; a short spaced burst lets the updated
|
|
12
|
+
* balance land without a manual refresh.
|
|
13
|
+
*/
|
|
14
|
+
export declare const SETTLE_REFETCH_DELAYS_MS: readonly [0, 2000, 5000];
|
|
15
|
+
//# sourceMappingURL=is-settle-notification.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"is-settle-notification.d.ts","sourceRoot":"","sources":["../../src/websocket/is-settle-notification.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,KAAK,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAU3E;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,YAAY,EAAE,YAAY,GAAG,OAAO,CAMxE;AAED;;;;;GAKG;AACH,eAAO,MAAM,wBAAwB,0BAA2B,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { NotificationType as e } from "@symmio/trading-core";
|
|
2
|
+
//#region src/websocket/is-settle-notification.ts
|
|
3
|
+
var t = new Set(["SendQuoteTransaction", "FillMarketOrderInstantClose"]);
|
|
4
|
+
function n(n) {
|
|
5
|
+
return n.type === e.SUCCESS && n.lastSeenAction !== null && t.has(n.lastSeenAction);
|
|
6
|
+
}
|
|
7
|
+
var r = [
|
|
8
|
+
0,
|
|
9
|
+
2e3,
|
|
10
|
+
5e3
|
|
11
|
+
];
|
|
12
|
+
//#endregion
|
|
13
|
+
export { r as SETTLE_REFETCH_DELAYS_MS, n as isSettleNotification };
|
|
14
|
+
|
|
15
|
+
//# sourceMappingURL=is-settle-notification.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"is-settle-notification.js","names":[],"sources":["../../src/websocket/is-settle-notification.ts"],"sourcesContent":["import { NotificationType, type Notification } from \"@symmio/trading-core\";\n\n/**\n * Solver actions that mean a position settled on-chain — an open anchored\n * (margin locked) or a close filled (PnL realized, margin unlocked). These are\n * the frames that move a subaccount's balance; the earlier request / price-fill\n * frames do not. Mirrors core's `OPEN_ANCHOR_ACTIONS` ∪ `CLOSE_FILL_ACTIONS`.\n */\nconst SETTLE_ACTIONS = new Set<string>([\"SendQuoteTransaction\", \"FillMarketOrderInstantClose\"]);\n\n/**\n * `true` when a notification marks an on-chain settle — a `SUCCESS` frame whose\n * `lastSeenAction` is an open-anchor or close-fill. Live balance reads refetch\n * on exactly these.\n */\nexport function isSettleNotification(notification: Notification): boolean {\n return (\n notification.type === NotificationType.SUCCESS &&\n notification.lastSeenAction !== null &&\n SETTLE_ACTIONS.has(notification.lastSeenAction)\n );\n}\n\n/**\n * Delays (ms) at which a live balance read refetches after a settle\n * notification. The on-chain read lags the anchor block, so a single immediate\n * read often returns the pre-settle value; a short spaced burst lets the updated\n * balance land without a manual refresh.\n */\nexport const SETTLE_REFETCH_DELAYS_MS = [0, 2000, 5000] as const;\n"],"mappings":";;AAQA,IAAM,IAAiB,IAAI,IAAY,CAAC,wBAAwB,6BAA6B,CAAC;AAO9F,SAAgB,EAAqB,GAAqC;CACxE,OACE,EAAa,SAAS,EAAiB,WACvC,EAAa,mBAAmB,QAChC,EAAe,IAAI,EAAa,cAAc;AAElD;AAQA,IAAa,IAA2B;CAAC;CAAG;CAAM;AAAI"}
|
|
@@ -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`.
|
|
@@ -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,15 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@symmio/trading-react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.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
|
-
"homepage": "https://github.com/SYMM-IO/
|
|
6
|
+
"homepage": "https://github.com/SYMM-IO/Trading-SDK/tree/main/packages/trading-react#readme",
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|
|
9
|
-
"url": "git+https://github.com/SYMM-IO/
|
|
9
|
+
"url": "git+https://github.com/SYMM-IO/Trading-SDK.git",
|
|
10
10
|
"directory": "packages/trading-react"
|
|
11
11
|
},
|
|
12
|
-
"bugs": "https://github.com/SYMM-IO/
|
|
12
|
+
"bugs": "https://github.com/SYMM-IO/Trading-SDK/issues",
|
|
13
13
|
"type": "module",
|
|
14
14
|
"sideEffects": false,
|
|
15
15
|
"main": "./dist/index.js",
|
|
@@ -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": "^1.0.0"
|
|
75
75
|
},
|
|
76
76
|
"peerDependencies": {
|
|
77
77
|
"react": "^19.0.0",
|
|
@@ -86,7 +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
|
-
"@
|
|
89
|
+
"@vitest/coverage-v8": "^4.1.10",
|
|
90
90
|
"eslint": "^9.39.4",
|
|
91
91
|
"happy-dom": "^16.0.0",
|
|
92
92
|
"react": "^19.2.5",
|
|
@@ -95,18 +95,19 @@
|
|
|
95
95
|
"viem": "^2.49.0",
|
|
96
96
|
"vite": "^8.0.10",
|
|
97
97
|
"vite-plugin-dts": "^5.0.0",
|
|
98
|
-
"vitest": "^4.1.
|
|
98
|
+
"vitest": "^4.1.10",
|
|
99
99
|
"wagmi": "^3.4.2",
|
|
100
|
-
"@symmio/eslint-config": "^0.
|
|
101
|
-
"@symmio/typescript-config": "^0.
|
|
100
|
+
"@symmio/eslint-config": "^1.0.0",
|
|
101
|
+
"@symmio/typescript-config": "^1.0.0"
|
|
102
102
|
},
|
|
103
103
|
"scripts": {
|
|
104
|
-
"build": "vite build",
|
|
104
|
+
"build": "vite build && node ../../scripts/fix-dts-extensions.mjs dist",
|
|
105
105
|
"dev": "vite build --watch",
|
|
106
106
|
"lint": "eslint . --max-warnings 0",
|
|
107
107
|
"check-types": "tsc --noEmit",
|
|
108
108
|
"test": "vitest run --project unit",
|
|
109
109
|
"test:watch": "vitest --project unit",
|
|
110
|
+
"test:coverage": "vitest run --project unit --coverage",
|
|
110
111
|
"test:integration": "vitest run --project integration"
|
|
111
112
|
}
|
|
112
113
|
}
|
|
@@ -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"}
|