@symmio/trading-react 0.2.0 → 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/use-account-balance-info.d.ts +15 -4
- 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 +15 -4
- 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-deposit.d.ts +3 -1
- 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/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/index.d.ts +6 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +106 -104
- package/dist/instant-layer/use-instant-open-with-tpsl.d.ts.map +1 -1
- package/dist/instant-layer/use-instant-open-with-tpsl.js +10 -2
- package/dist/instant-layer/use-instant-open-with-tpsl.js.map +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/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/use-managed-quotes.js +16 -16
- package/dist/quotes/use-managed-quotes.js.map +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/package.json +7 -8
package/dist/index.js
CHANGED
|
@@ -7,74 +7,74 @@ import { useConnectWallet as a } from "./wallet/use-connect-wallet.js";
|
|
|
7
7
|
import { useDisconnectWallet as o } from "./wallet/use-disconnect-wallet.js";
|
|
8
8
|
import { useSwitchToSymmioChain as s } from "./wallet/use-switch-to-symmio-chain.js";
|
|
9
9
|
import { useWalletAccount as c } from "./wallet/use-wallet-account.js";
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
24
|
-
import {
|
|
25
|
-
import {
|
|
26
|
-
import {
|
|
27
|
-
import {
|
|
28
|
-
import {
|
|
29
|
-
import {
|
|
30
|
-
import {
|
|
31
|
-
import {
|
|
32
|
-
import {
|
|
33
|
-
import {
|
|
34
|
-
import {
|
|
35
|
-
import {
|
|
36
|
-
import {
|
|
37
|
-
import {
|
|
38
|
-
import {
|
|
39
|
-
import {
|
|
40
|
-
import {
|
|
41
|
-
import {
|
|
42
|
-
import {
|
|
43
|
-
import {
|
|
44
|
-
import {
|
|
45
|
-
import {
|
|
46
|
-
import {
|
|
47
|
-
import {
|
|
48
|
-
import {
|
|
49
|
-
import {
|
|
50
|
-
import {
|
|
51
|
-
import {
|
|
52
|
-
import {
|
|
53
|
-
import {
|
|
54
|
-
import {
|
|
55
|
-
import {
|
|
56
|
-
import {
|
|
57
|
-
import {
|
|
58
|
-
import {
|
|
59
|
-
import {
|
|
60
|
-
import {
|
|
61
|
-
import {
|
|
62
|
-
import {
|
|
63
|
-
import {
|
|
64
|
-
import {
|
|
65
|
-
import {
|
|
66
|
-
import {
|
|
67
|
-
import {
|
|
68
|
-
import {
|
|
69
|
-
import {
|
|
70
|
-
import {
|
|
71
|
-
import {
|
|
72
|
-
import {
|
|
73
|
-
import {
|
|
74
|
-
import {
|
|
75
|
-
import {
|
|
76
|
-
import {
|
|
77
|
-
import {
|
|
10
|
+
import { useNotifications as l } from "./websocket/use-notifications.js";
|
|
11
|
+
import { useAccountBalanceInfo as u } from "./account-layer/use-account-balance-info.js";
|
|
12
|
+
import { useAccountBalanceOf as d } from "./account-layer/use-account-balance-of.js";
|
|
13
|
+
import { useTransactionsStore as f } from "./transactions/use-transactions-store.js";
|
|
14
|
+
import { predicateMatch as p } from "./utils/predicate-match.js";
|
|
15
|
+
import { useAddMargin as m } from "./account-layer/use-add-margin.js";
|
|
16
|
+
import { useAllocate as h } from "./account-layer/use-allocate.js";
|
|
17
|
+
import { useCreateSubAccounts as g } from "./account-layer/use-create-sub-accounts.js";
|
|
18
|
+
import { useDeallocate as _ } from "./account-layer/use-deallocate.js";
|
|
19
|
+
import { useDeleteSubAccount as v } from "./account-layer/use-delete-sub-account.js";
|
|
20
|
+
import { useDeposit as y } from "./account-layer/use-deposit.js";
|
|
21
|
+
import { useDepositAndAllocate as b } from "./account-layer/use-deposit-and-allocate.js";
|
|
22
|
+
import { useEditAccountName as x } from "./account-layer/use-edit-account-name.js";
|
|
23
|
+
import { usePredictedNextVirtualAccount as S } from "./account-layer/use-predicted-next-virtual-account.js";
|
|
24
|
+
import { useRemoveMargin as C } from "./account-layer/use-remove-margin.js";
|
|
25
|
+
import { useSimulateAddMargin as w } from "./account-layer/use-simulate-add-margin.js";
|
|
26
|
+
import { useSimulateAllocate as T } from "./account-layer/use-simulate-allocate.js";
|
|
27
|
+
import { useSimulateCreateSubAccounts as E } from "./account-layer/use-simulate-create-sub-accounts.js";
|
|
28
|
+
import { useSimulateDeallocate as D } from "./account-layer/use-simulate-deallocate.js";
|
|
29
|
+
import { useSimulateDeleteSubAccount as O } from "./account-layer/use-simulate-delete-sub-account.js";
|
|
30
|
+
import { useSimulateDeposit as k } from "./account-layer/use-simulate-deposit.js";
|
|
31
|
+
import { useSimulateDepositAndAllocate as A } from "./account-layer/use-simulate-deposit-and-allocate.js";
|
|
32
|
+
import { useSimulateEditAccountName as j } from "./account-layer/use-simulate-edit-account-name.js";
|
|
33
|
+
import { useSimulateRemoveMargin as M } from "./account-layer/use-simulate-remove-margin.js";
|
|
34
|
+
import { useSubAccount as N } from "./account-layer/use-sub-account.js";
|
|
35
|
+
import { useSubAccountVirtualNonce as P } from "./account-layer/use-sub-account-virtual-nonce.js";
|
|
36
|
+
import { useSubAccountsCountOfUser as F } from "./account-layer/use-sub-accounts-count-of-user.js";
|
|
37
|
+
import { useUserSubAccounts as I } from "./account-layer/use-user-sub-accounts.js";
|
|
38
|
+
import { useUserSubAccountsAddresses as L } from "./account-layer/use-user-sub-accounts-addresses.js";
|
|
39
|
+
import { useVirtualAccount as R } from "./account-layer/use-virtual-account.js";
|
|
40
|
+
import { useVirtualAccountsAddressesOfSubAccount as z } from "./account-layer/use-virtual-accounts-addresses-of-sub-account.js";
|
|
41
|
+
import { useApproveCollateral as B } from "./collateral/use-approve-collateral.js";
|
|
42
|
+
import { useCollateralAllowance as V } from "./collateral/use-collateral-allowance.js";
|
|
43
|
+
import { useCollateralBalance as H } from "./collateral/use-collateral-balance.js";
|
|
44
|
+
import { useSimulateApproveCollateral as U } from "./collateral/use-simulate-approve-collateral.js";
|
|
45
|
+
import { useDelegationExpiry as W } from "./instant-layer/use-delegation-expiry.js";
|
|
46
|
+
import { useGrantDelegation as G } from "./instant-layer/use-grant-delegation.js";
|
|
47
|
+
import { useInstantClose as K } from "./instant-layer/use-instant-close.js";
|
|
48
|
+
import { useInstantCloseAuto as q } from "./instant-layer/use-instant-close-auto.js";
|
|
49
|
+
import { useInstantCloseBulk as J } from "./instant-layer/use-instant-close-bulk.js";
|
|
50
|
+
import { useInstantCloseBulkAuto as Y } from "./instant-layer/use-instant-close-bulk-auto.js";
|
|
51
|
+
import { useInstantCloses as X } from "./instant-layer/use-instant-closes.js";
|
|
52
|
+
import { useInstantOpen as Z } from "./instant-layer/use-instant-open.js";
|
|
53
|
+
import { useInstantOpenAuto as Q } from "./instant-layer/use-instant-open-auto.js";
|
|
54
|
+
import { useInstantOpenQuoteId as $ } from "./instant-layer/use-instant-open-quote-id.js";
|
|
55
|
+
import { toQuoteTpSl as ee } from "./tpsl/to-quote-tpsl.js";
|
|
56
|
+
import { useTpSlRecord as te, useTpSlStore as ne } from "./tpsl/tpsl-store.js";
|
|
57
|
+
import { useInstantOpenWithTpSl as re } from "./instant-layer/use-instant-open-with-tpsl.js";
|
|
58
|
+
import { useInstantOpens as ie } from "./instant-layer/use-instant-opens.js";
|
|
59
|
+
import { useIsDelegationActive as ae } from "./instant-layer/use-is-delegation-active.js";
|
|
60
|
+
import { useSimulateGrantDelegation as oe } from "./instant-layer/use-simulate-grant-delegation.js";
|
|
61
|
+
import { useFinalizeWithdrawRequest as se } from "./withdraw/use-finalize-withdraw-request.js";
|
|
62
|
+
import { useInitiateWithdraw as ce } from "./withdraw/use-initiate-withdraw.js";
|
|
63
|
+
import { useLastWithdrawRequestId as le } from "./withdraw/use-last-withdraw-request-id.js";
|
|
64
|
+
import { usePendingWithdrawRequests as ue } from "./withdraw/use-pending-withdraw-requests.js";
|
|
65
|
+
import { useRequestCancelWithdraw as de } from "./withdraw/use-request-cancel-withdraw.js";
|
|
66
|
+
import { useSimulateFinalizeWithdrawRequest as fe } from "./withdraw/use-simulate-finalize-withdraw-request.js";
|
|
67
|
+
import { useSimulateInitiateWithdraw as pe } from "./withdraw/use-simulate-initiate-withdraw.js";
|
|
68
|
+
import { useSimulateRequestCancelWithdraw as me } from "./withdraw/use-simulate-request-cancel-withdraw.js";
|
|
69
|
+
import { useWithdrawRequest as he } from "./withdraw/use-withdraw-requests.js";
|
|
70
|
+
import { useWithdrawableTime as ge } from "./withdraw/use-withdrawable-time.js";
|
|
71
|
+
import { useMarkets as _e } from "./markets/use-markets.js";
|
|
72
|
+
import { useOnchainContractMarkets as ve } from "./markets/use-onchain-contract-markets.js";
|
|
73
|
+
import { useSolverErrorCodes as ye } from "./error-codes/use-solver-error-codes.js";
|
|
74
|
+
import { useSolverErrorMessage as be } from "./error-codes/use-solver-error-message.js";
|
|
75
|
+
import { useOptimisticQuotesStore as xe } from "./quotes/optimistic-quotes-store.js";
|
|
76
|
+
import { usePartyAOpenPositions as Se } from "./quotes/use-party-a-open-positions.js";
|
|
77
|
+
import { useAccountLiquidationPrice as Ce } from "./quotes/use-account-liquidation-price.js";
|
|
78
78
|
import { useManagedQuotes as we } from "./quotes/use-managed-quotes.js";
|
|
79
79
|
import { useGroupedQuotes as Te } from "./quotes/use-grouped-quotes.js";
|
|
80
80
|
import { usePartyAPendingQuotes as Ee } from "./quotes/use-party-a-pending-quotes.js";
|
|
@@ -89,39 +89,41 @@ import { useEnigmaPriceByName as Pe } from "./price-service/use-enigma-price-by-
|
|
|
89
89
|
import { useEnigmaPriceByMarketId as Fe } from "./price-service/use-enigma-price-by-market-id.js";
|
|
90
90
|
import { useQuoteUpnlAndPnl as Ie } from "./quotes/use-quote-upnl-and-pnl.js";
|
|
91
91
|
import { useSubgraphQuery as Le } from "./quotes/use-subgraph-query.js";
|
|
92
|
-
import {
|
|
93
|
-
import {
|
|
94
|
-
import {
|
|
95
|
-
import {
|
|
96
|
-
import {
|
|
97
|
-
import {
|
|
98
|
-
import {
|
|
99
|
-
import {
|
|
100
|
-
import {
|
|
101
|
-
import {
|
|
102
|
-
import {
|
|
103
|
-
import {
|
|
104
|
-
import {
|
|
105
|
-
import {
|
|
106
|
-
import {
|
|
107
|
-
import {
|
|
108
|
-
import {
|
|
109
|
-
import {
|
|
110
|
-
import {
|
|
111
|
-
import {
|
|
112
|
-
import {
|
|
113
|
-
import {
|
|
114
|
-
import {
|
|
115
|
-
import {
|
|
116
|
-
import {
|
|
117
|
-
import {
|
|
118
|
-
import {
|
|
119
|
-
import {
|
|
120
|
-
import {
|
|
121
|
-
import {
|
|
122
|
-
import {
|
|
123
|
-
import {
|
|
124
|
-
import {
|
|
125
|
-
import {
|
|
126
|
-
import {
|
|
127
|
-
|
|
92
|
+
import { useFeeForUser as Re } from "./fees/use-fee-for-user.js";
|
|
93
|
+
import { useAvailableInstantOpenMargin as ze } from "./margin/use-available-instant-open-margin.js";
|
|
94
|
+
import { useBalanceHistory as Be } from "./balance-history/use-balance-history.js";
|
|
95
|
+
import { useDepositHistory as Ve } from "./balance-history/use-deposit-history.js";
|
|
96
|
+
import { useWithdrawHistory as He } from "./balance-history/use-withdraw-history.js";
|
|
97
|
+
import { useTransferHistory as Ue } from "./transfers/use-transfer-history.js";
|
|
98
|
+
import { useLockedParams as We } from "./locked-params/use-locked-params.js";
|
|
99
|
+
import { DEFAULT_NOTIONAL_CAP_POLLING_MS as Ge, useNotionalCapBySymbolId as Ke } from "./notional-cap/use-notional-cap-by-symbol-id.js";
|
|
100
|
+
import { useNotionalCapAll as qe } from "./notional-cap/use-notional-cap-all.js";
|
|
101
|
+
import { useOpenInterestBySymbolId as Je } from "./notional-cap/use-open-interest-by-symbol-id.js";
|
|
102
|
+
import { useEstimatedPrice as Ye } from "./estimated-price/use-estimated-price.js";
|
|
103
|
+
import { useFundingInfo as Xe } from "./funding-info/use-funding-info.js";
|
|
104
|
+
import { useMarketInfo as Ze } from "./market-info/use-market-info.js";
|
|
105
|
+
import { useEnigmaPriceServiceHealth as Qe } from "./price-service/use-enigma-price-service-health.js";
|
|
106
|
+
import { useEnigmaPriceServiceMetadata as $e } from "./price-service/use-enigma-price-service-metadata.js";
|
|
107
|
+
import { useEnigmaPriceServicePricesByAddresses as et } from "./price-service/use-enigma-price-service-prices-by-addresses.js";
|
|
108
|
+
import { useEnigmaPriceServicePricesByNames as tt } from "./price-service/use-enigma-price-service-prices-by-names.js";
|
|
109
|
+
import { useEnigmaPriceServiceSymbolsInfo as nt } from "./price-service/use-enigma-price-service-symbols-info.js";
|
|
110
|
+
import { useEnigmaPrices as rt } from "./price-service/use-enigma-prices.js";
|
|
111
|
+
import { useSearchNotifications as it } from "./notifications/use-search-notifications.js";
|
|
112
|
+
import { useDeallocateUpnlSig as at } from "./muon/use-deallocate-upnl-sig.js";
|
|
113
|
+
import { useMuonPartyAOverview as ot } from "./muon/use-muon-party-a-overview.js";
|
|
114
|
+
import { useMuonPrice as st } from "./muon/use-muon-price.js";
|
|
115
|
+
import { useMuonPriceRange as ct } from "./muon/use-muon-price-range.js";
|
|
116
|
+
import { useMuonSettleUpnl as lt } from "./muon/use-muon-settle-upnl.js";
|
|
117
|
+
import { useMuonUpnl as ut } from "./muon/use-muon-upnl.js";
|
|
118
|
+
import { useMuonUpnlA as dt } from "./muon/use-muon-upnl-a.js";
|
|
119
|
+
import { useMuonUpnlAWithSymbolPrice as ft } from "./muon/use-muon-upnl-a-with-symbol-price.js";
|
|
120
|
+
import { useMuonUpnlB as pt } from "./muon/use-muon-upnl-b.js";
|
|
121
|
+
import { useMuonUpnlWithSymbolPrice as mt } from "./muon/use-muon-upnl-with-symbol-price.js";
|
|
122
|
+
import { useDeleteQuoteTpSl as ht } from "./tpsl/use-delete-quote-tpsl.js";
|
|
123
|
+
import { useWatchTpSlNotifications as gt } from "./tpsl/use-watch-tpsl-notifications.js";
|
|
124
|
+
import { useQuoteTpSl as _t } from "./tpsl/use-quote-tpsl.js";
|
|
125
|
+
import { useSetQuoteTpSl as vt } from "./tpsl/use-set-quote-tpsl.js";
|
|
126
|
+
import { useTpSlConfig as yt } from "./tpsl/use-tpsl-config.js";
|
|
127
|
+
import { useTpSlSigningSpec as bt } from "./tpsl/use-tpsl-signing-spec.js";
|
|
128
|
+
import { ADD_MARGIN_TO_NEXT_VA_SELECTOR as xt, DEFAULT_TPSL_SLIPPAGE_LOWCAPS as St, INSTANT_TRADE_REQUIRED_SELECTORS as Ct, NotificationType as wt, OrderType as Tt, PositionType as Et, QuoteStatus as Dt, REQUEST_TO_CLOSE_POSITION_SELECTOR as Ot, SEND_QUOTE_WITH_AFFILIATE_AND_DATA_SELECTOR as kt, SubAccountIsolationType as At, SymmApiError as jt, SymmError as Mt, VIRTUAL_ACCOUNT_ISOLATION_TYPE as Nt, ZERO_LEG as Pt, buildConditionalOrderLeg as Ft, buildConditionalOrderMessage as It, buildTpSlDeleteMessage as Lt, calculateAvailableInstantOpenMargin as Rt, calculateClosePrice as zt, calculatePriceImpact as Bt, calculateQuotePnl as Vt, calculateTradeParams as Ht, clampClosePrecision as Ut, deleteQuoteTpSl as Wt, deleteQuoteTpSlMutationOptions as Gt, generateTpSlSalt as Kt, getPartyAOpenPositionsQueryKey as qt, getPartyAOpenPositionsQueryOptions as Jt, isolationTypeForSide as Yt, parseTpSlFrame as Xt, priceSlippageCalculation as Zt, signTpSlRequest as Qt, toSignableTpSlMessage as $t, validateInstantCloseAgainstMarket as en, validateInstantOpenAgainstMarket as tn, validateTpSl as nn, watchTpSlNotifications as rn } from "@symmio/trading-core";
|
|
129
|
+
export { xt as ADD_MARGIN_TO_NEXT_VA_SELECTOR, Ge as DEFAULT_NOTIONAL_CAP_POLLING_MS, St as DEFAULT_TPSL_SLIPPAGE_LOWCAPS, Ct as INSTANT_TRADE_REQUIRED_SELECTORS, wt as NotificationType, Tt as OrderType, Et as PositionType, Dt as QuoteStatus, Ot as REQUEST_TO_CLOSE_POSITION_SELECTOR, kt as SEND_QUOTE_WITH_AFFILIATE_AND_DATA_SELECTOR, At as SubAccountIsolationType, jt as SymmApiError, Mt as SymmError, e as SymmioProvider, r as SymmioRequestError, Nt as VIRTUAL_ACCOUNT_ISOLATION_TYPE, Pt as ZERO_LEG, Ft as buildConditionalOrderLeg, It as buildConditionalOrderMessage, Lt as buildTpSlDeleteMessage, Rt as calculateAvailableInstantOpenMargin, zt as calculateClosePrice, Bt as calculatePriceImpact, Vt as calculateQuotePnl, Ht as calculateTradeParams, Ut as clampClosePrecision, Wt as deleteQuoteTpSl, Gt as deleteQuoteTpSlMutationOptions, Kt as generateTpSlSalt, qt as getPartyAOpenPositionsQueryKey, Jt as getPartyAOpenPositionsQueryOptions, Yt as isolationTypeForSide, i as normalizeSymmError, Xt as parseTpSlFrame, p as predicateMatch, Zt as priceSlippageCalculation, Qt as signTpSlRequest, ee as toQuoteTpSl, $t as toSignableTpSlMessage, u as useAccountBalanceInfo, d as useAccountBalanceOf, Ce as useAccountLiquidationPrice, m as useAddMargin, h as useAllocate, B as useApproveCollateral, ze as useAvailableInstantOpenMargin, Be as useBalanceHistory, V as useCollateralAllowance, H as useCollateralBalance, a as useConnectWallet, g as useCreateSubAccounts, _ as useDeallocate, at as useDeallocateUpnlSig, W as useDelegationExpiry, ht as useDeleteQuoteTpSl, v as useDeleteSubAccount, y as useDeposit, b as useDepositAndAllocate, Ve as useDepositHistory, o as useDisconnectWallet, x as useEditAccountName, Fe as useEnigmaPriceByMarketId, Pe as useEnigmaPriceByName, Qe as useEnigmaPriceServiceHealth, $e as useEnigmaPriceServiceMetadata, et as useEnigmaPriceServicePricesByAddresses, tt as useEnigmaPriceServicePricesByNames, nt as useEnigmaPriceServiceSymbolsInfo, rt as useEnigmaPrices, Ye as useEstimatedPrice, Re as useFeeForUser, se as useFinalizeWithdrawRequest, Xe as useFundingInfo, G as useGrantDelegation, Te as useGroupedQuotes, ce as useInitiateWithdraw, K as useInstantClose, q as useInstantCloseAuto, J as useInstantCloseBulk, Y as useInstantCloseBulkAuto, X as useInstantCloses, Z as useInstantOpen, Q as useInstantOpenAuto, $ as useInstantOpenQuoteId, re as useInstantOpenWithTpSl, ie as useInstantOpens, ae as useIsDelegationActive, le as useLastWithdrawRequestId, We as useLockedParams, we as useManagedQuotes, Ze as useMarketInfo, _e as useMarkets, ot as useMuonPartyAOverview, st as useMuonPrice, ct as useMuonPriceRange, lt as useMuonSettleUpnl, ut as useMuonUpnl, dt as useMuonUpnlA, ft as useMuonUpnlAWithSymbolPrice, pt as useMuonUpnlB, mt as useMuonUpnlWithSymbolPrice, l as useNotifications, qe as useNotionalCapAll, Ke as useNotionalCapBySymbolId, ve as useOnchainContractMarkets, Je as useOpenInterestBySymbolId, xe as useOptimisticQuotesStore, Se as usePartyAOpenPositions, Ee as usePartyAPendingQuotes, ue as usePendingWithdrawRequests, S as usePredictedNextVirtualAccount, De as useQuote, Oe as useQuoteEventsByType, Ae as useQuoteFunding, je as useQuoteHistory, Me as useQuotePlatformFee, Ne as useQuotePriceHistory, _t as useQuoteTpSl, Ie as useQuoteUpnlAndPnl, ke as useQuotesFunding, C as useRemoveMargin, de as useRequestCancelWithdraw, it as useSearchNotifications, vt as useSetQuoteTpSl, w as useSimulateAddMargin, T as useSimulateAllocate, U as useSimulateApproveCollateral, E as useSimulateCreateSubAccounts, D as useSimulateDeallocate, O as useSimulateDeleteSubAccount, k as useSimulateDeposit, A as useSimulateDepositAndAllocate, j as useSimulateEditAccountName, fe as useSimulateFinalizeWithdrawRequest, oe as useSimulateGrantDelegation, pe as useSimulateInitiateWithdraw, M as useSimulateRemoveMargin, me as useSimulateRequestCancelWithdraw, ye as useSolverErrorCodes, be as useSolverErrorMessage, N as useSubAccount, P as useSubAccountVirtualNonce, F as useSubAccountsCountOfUser, Le as useSubgraphQuery, s as useSwitchToSymmioChain, t as useSymmioChainId, n as useSymmioConfig, yt as useTpSlConfig, te as useTpSlRecord, bt as useTpSlSigningSpec, ne as useTpSlStore, f as useTransactionsStore, Ue as useTransferHistory, I as useUserSubAccounts, L as useUserSubAccountsAddresses, R as useVirtualAccount, z as useVirtualAccountsAddressesOfSubAccount, c as useWalletAccount, gt as useWatchTpSlNotifications, He as useWithdrawHistory, he as useWithdrawRequest, ge as useWithdrawableTime, en as validateInstantCloseAgainstMarket, tn as validateInstantOpenAgainstMarket, nn as validateTpSl, rn as watchTpSlNotifications };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-instant-open-with-tpsl.d.ts","sourceRoot":"","sources":["../../src/instant-layer/use-instant-open-with-tpsl.ts"],"names":[],"mappings":"AAEA,OAAO,EAIL,KAAK,eAAe,EACpB,KAAK,qBAAqB,EAC1B,KAAK,4BAA4B,EACjC,KAAK,sBAAsB,EAC3B,KAAK,sBAAsB,EAC5B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAA+B,KAAK,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAG5F,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAMzE;;;;;;;;;;;GAWG;AACH,MAAM,WAAW,+BAAgC,SAAQ,4BAA4B;IACnF,IAAI,CAAC,EAAE,IAAI,CAAC,sBAAsB,EAAE,SAAS,GAAG,SAAS,CAAC,CAAC;CAC5D;AAED,sEAAsE;AACtE,MAAM,WAAW,0BAA0B;IACzC,WAAW,EAAE,qBAAqB,CAAC;IACnC,0DAA0D;IAC1D,IAAI,CAAC,EAAE,sBAAsB,CAAC;IAC9B,mFAAmF;IACnF,SAAS,CAAC,EAAE,kBAAkB,CAAC;CAChC;AAED,kDAAkD;AAClD,MAAM,MAAM,2BAA2B,GAAG,MAAM,GAAG,SAAS,GAAG,gBAAgB,GAAG,SAAS,GAAG,OAAO,CAAC;AAEtG,qDAAqD;AACrD,MAAM,MAAM,gCAAgC,GAAG,eAAe,CAAC;AAE/D,qDAAqD;AACrD,MAAM,MAAM,gCAAgC,GAAG,iBAAiB,CAC9D,0BAA0B,EAC1B,kBAAkB,EAClB,+BAA+B,CAChC,GAAG;IACF,+DAA+D;IAC/D,KAAK,EAAE,2BAA2B,CAAC;CACpC,CAAC;AAEF;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,sBAAsB,CACpC,UAAU,GAAE,gCAAqC,GAChD,gCAAgC,
|
|
1
|
+
{"version":3,"file":"use-instant-open-with-tpsl.d.ts","sourceRoot":"","sources":["../../src/instant-layer/use-instant-open-with-tpsl.ts"],"names":[],"mappings":"AAEA,OAAO,EAIL,KAAK,eAAe,EACpB,KAAK,qBAAqB,EAC1B,KAAK,4BAA4B,EACjC,KAAK,sBAAsB,EAC3B,KAAK,sBAAsB,EAC5B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAA+B,KAAK,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAG5F,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAMzE;;;;;;;;;;;GAWG;AACH,MAAM,WAAW,+BAAgC,SAAQ,4BAA4B;IACnF,IAAI,CAAC,EAAE,IAAI,CAAC,sBAAsB,EAAE,SAAS,GAAG,SAAS,CAAC,CAAC;CAC5D;AAED,sEAAsE;AACtE,MAAM,WAAW,0BAA0B;IACzC,WAAW,EAAE,qBAAqB,CAAC;IACnC,0DAA0D;IAC1D,IAAI,CAAC,EAAE,sBAAsB,CAAC;IAC9B,mFAAmF;IACnF,SAAS,CAAC,EAAE,kBAAkB,CAAC;CAChC;AAED,kDAAkD;AAClD,MAAM,MAAM,2BAA2B,GAAG,MAAM,GAAG,SAAS,GAAG,gBAAgB,GAAG,SAAS,GAAG,OAAO,CAAC;AAEtG,qDAAqD;AACrD,MAAM,MAAM,gCAAgC,GAAG,eAAe,CAAC;AAE/D,qDAAqD;AACrD,MAAM,MAAM,gCAAgC,GAAG,iBAAiB,CAC9D,0BAA0B,EAC1B,kBAAkB,EAClB,+BAA+B,CAChC,GAAG;IACF,+DAA+D;IAC/D,KAAK,EAAE,2BAA2B,CAAC;CACpC,CAAC;AAEF;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,sBAAsB,CACpC,UAAU,GAAE,gCAAqC,GAChD,gCAAgC,CAiFlC"}
|
|
@@ -34,8 +34,16 @@ function d(d = {}) {
|
|
|
34
34
|
...e.tpsl,
|
|
35
35
|
chainId: t,
|
|
36
36
|
quoteId: c
|
|
37
|
-
});
|
|
38
|
-
return
|
|
37
|
+
}), r = e.tpsl.tp, a = e.tpsl.sl;
|
|
38
|
+
return r && _(c, "tp", {
|
|
39
|
+
price: r.triggerPrice,
|
|
40
|
+
priceType: r.priceType,
|
|
41
|
+
cohQuoteId: n.cohQuoteId
|
|
42
|
+
}), a && _(c, "sl", {
|
|
43
|
+
price: a.triggerPrice,
|
|
44
|
+
priceType: a.priceType,
|
|
45
|
+
cohQuoteId: n.cohQuoteId
|
|
46
|
+
}), y("success"), {
|
|
39
47
|
instantOpen: i,
|
|
40
48
|
tpsl: n
|
|
41
49
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-instant-open-with-tpsl.js","names":[],"sources":["../../src/instant-layer/use-instant-open-with-tpsl.ts"],"sourcesContent":["\"use client\";\n\nimport {\n getInstantOpensQueryKey,\n instantOpenAutoMutationOptions,\n setQuoteTpSlMutationOptions,\n type ConfigParameter,\n type InstantOpenReturnType,\n type PrepareInstantOpenParameters,\n type SetQuoteTpSlParameters,\n type SetQuoteTpSlReturnType,\n} from \"@symmio/trading-core\";\nimport { useMutation, useQueryClient, type UseMutationResult } from \"@tanstack/react-query\";\nimport { useState } from \"react\";\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/tpsl-store\";\nimport { predicateMatch } from \"../utils\";\n\n/**\n * Parameters for {@link useInstantOpenWithTpSl}: the standard instant-open\n * inputs, plus an optional `tpsl` block that mirrors {@link SetQuoteTpSlParameters}\n * minus `quoteId` (derived from the hedger response) and `chainId` (defaulted).\n *\n * When `tpsl` is omitted (or both `tp` and `sl` are empty), the hook behaves\n * exactly like {@link useInstantOpenAuto}. When present, the SDK dispatches\n * `setQuoteTpSl` immediately after the hedger returns a `tempQuoteId` — the\n * message is signed against the (predicted) VA the caller supplies, so no\n * on-chain reconciliation wait is needed. Confirmation still comes through the\n * TP/SL WebSocket picked up by {@link useQuoteTpSl}.\n */\nexport interface UseInstantOpenWithTpSlVariables extends PrepareInstantOpenParameters {\n tpsl?: Omit<SetQuoteTpSlParameters, \"quoteId\" | \"chainId\">;\n}\n\n/** Aggregated success payload from {@link useInstantOpenWithTpSl}. */\nexport interface UseInstantOpenWithTpSlData {\n instantOpen: InstantOpenReturnType;\n /** Set when the TP/SL leg was attempted and succeeded. */\n tpsl?: SetQuoteTpSlReturnType;\n /** Set when the TP/SL leg was attempted and failed — instant open still landed. */\n tpslError?: SymmioRequestError;\n}\n\n/** Which leg the orchestrator is currently on. */\nexport type UseInstantOpenWithTpSlPhase = \"idle\" | \"opening\" | \"attaching-tpsl\" | \"success\" | \"error\";\n\n/** Parameters for {@link useInstantOpenWithTpSl}. */\nexport type UseInstantOpenWithTpSlParameters = ConfigParameter;\n\n/** Return type of {@link useInstantOpenWithTpSl}. */\nexport type UseInstantOpenWithTpSlReturnType = UseMutationResult<\n UseInstantOpenWithTpSlData,\n SymmioRequestError,\n UseInstantOpenWithTpSlVariables\n> & {\n /** Current orchestration phase. Handy for phased status UI. */\n phase: UseInstantOpenWithTpSlPhase;\n};\n\n/**\n * One-shot orchestrator: post an instant open and — if the caller pre-filled\n * a TP/SL block — immediately submit `setQuoteTpSl` using the hedger's returned\n * `tempQuoteId`. Web layer just wires inputs; all mutation logic (both legs +\n * cache invalidation + confirming-slot write) lives in the SDK.\n *\n * @example\n * ```tsx\n * const open = useInstantOpenWithTpSl();\n * open.mutate({\n * ...instantOpenParams,\n * tpsl: hasTpOrSl\n * ? { from: sessionKey, virtualAccount: predictedVa, subAccount,\n * symbolId, positionType, quantity, pricePrecision, tp, sl }\n * : undefined,\n * });\n * ```\n */\nexport function useInstantOpenWithTpSl(\n parameters: UseInstantOpenWithTpSlParameters = {},\n): UseInstantOpenWithTpSlReturnType {\n const config = useSymmioConfig(parameters);\n const chainId = useSymmioChainId();\n const queryClient = useQueryClient();\n const openBase = instantOpenAutoMutationOptions(config);\n const tpslBase = setQuoteTpSlMutationOptions(config);\n const markConfirming = useTpSlStore((state) => state.markConfirming);\n\n const [phase, setPhase] = useState<UseInstantOpenWithTpSlPhase>(\"idle\");\n\n const mutation = useMutation<UseInstantOpenWithTpSlData, SymmioRequestError, UseInstantOpenWithTpSlVariables>({\n mutationKey: [\"useInstantOpenWithTpSl\"] as const,\n mutationFn: async (variables) => {\n const resolvedChainId = variables.chainId ?? chainId;\n setPhase(\"opening\");\n let openResult: InstantOpenReturnType;\n try {\n openResult = await openBase.mutationFn({ ...variables, chainId: resolvedChainId });\n } catch (err) {\n setPhase(\"error\");\n throw normalizeSymmError(err);\n }\n\n // Refresh the instant-opens feed the moment the hedger accepts.\n const configKey = config.getChainConfigKey(resolvedChainId);\n void queryClient.invalidateQueries({ predicate: predicateMatch(getInstantOpensQueryKey, { configKey }) });\n\n const wantsTpSl = Boolean(variables.tpsl && (variables.tpsl.tp || variables.tpsl.sl));\n if (!wantsTpSl || !openResult.tempQuoteId) {\n setPhase(\"success\");\n return { instantOpen: openResult };\n }\n\n const tempIdNumber = Number(openResult.tempQuoteId);\n if (!Number.isFinite(tempIdNumber)) {\n setPhase(\"success\");\n return { instantOpen: openResult };\n }\n\n setPhase(\"attaching-tpsl\");\n const quoteId = BigInt(tempIdNumber);\n try {\n const tpslResult = await tpslBase.mutationFn({\n ...(variables.tpsl as Omit<SetQuoteTpSlParameters, \"quoteId\" | \"chainId\">),\n chainId: resolvedChainId,\n quoteId,\n });\n // Mirror useSetQuoteTpSl.onSuccess:
|
|
1
|
+
{"version":3,"file":"use-instant-open-with-tpsl.js","names":[],"sources":["../../src/instant-layer/use-instant-open-with-tpsl.ts"],"sourcesContent":["\"use client\";\n\nimport {\n getInstantOpensQueryKey,\n instantOpenAutoMutationOptions,\n setQuoteTpSlMutationOptions,\n type ConfigParameter,\n type InstantOpenReturnType,\n type PrepareInstantOpenParameters,\n type SetQuoteTpSlParameters,\n type SetQuoteTpSlReturnType,\n} from \"@symmio/trading-core\";\nimport { useMutation, useQueryClient, type UseMutationResult } from \"@tanstack/react-query\";\nimport { useState } from \"react\";\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/tpsl-store\";\nimport { predicateMatch } from \"../utils\";\n\n/**\n * Parameters for {@link useInstantOpenWithTpSl}: the standard instant-open\n * inputs, plus an optional `tpsl` block that mirrors {@link SetQuoteTpSlParameters}\n * minus `quoteId` (derived from the hedger response) and `chainId` (defaulted).\n *\n * When `tpsl` is omitted (or both `tp` and `sl` are empty), the hook behaves\n * exactly like {@link useInstantOpenAuto}. When present, the SDK dispatches\n * `setQuoteTpSl` immediately after the hedger returns a `tempQuoteId` — the\n * message is signed against the (predicted) VA the caller supplies, so no\n * on-chain reconciliation wait is needed. Confirmation still comes through the\n * TP/SL WebSocket picked up by {@link useQuoteTpSl}.\n */\nexport interface UseInstantOpenWithTpSlVariables extends PrepareInstantOpenParameters {\n tpsl?: Omit<SetQuoteTpSlParameters, \"quoteId\" | \"chainId\">;\n}\n\n/** Aggregated success payload from {@link useInstantOpenWithTpSl}. */\nexport interface UseInstantOpenWithTpSlData {\n instantOpen: InstantOpenReturnType;\n /** Set when the TP/SL leg was attempted and succeeded. */\n tpsl?: SetQuoteTpSlReturnType;\n /** Set when the TP/SL leg was attempted and failed — instant open still landed. */\n tpslError?: SymmioRequestError;\n}\n\n/** Which leg the orchestrator is currently on. */\nexport type UseInstantOpenWithTpSlPhase = \"idle\" | \"opening\" | \"attaching-tpsl\" | \"success\" | \"error\";\n\n/** Parameters for {@link useInstantOpenWithTpSl}. */\nexport type UseInstantOpenWithTpSlParameters = ConfigParameter;\n\n/** Return type of {@link useInstantOpenWithTpSl}. */\nexport type UseInstantOpenWithTpSlReturnType = UseMutationResult<\n UseInstantOpenWithTpSlData,\n SymmioRequestError,\n UseInstantOpenWithTpSlVariables\n> & {\n /** Current orchestration phase. Handy for phased status UI. */\n phase: UseInstantOpenWithTpSlPhase;\n};\n\n/**\n * One-shot orchestrator: post an instant open and — if the caller pre-filled\n * a TP/SL block — immediately submit `setQuoteTpSl` using the hedger's returned\n * `tempQuoteId`. Web layer just wires inputs; all mutation logic (both legs +\n * cache invalidation + confirming-slot write) lives in the SDK.\n *\n * @example\n * ```tsx\n * const open = useInstantOpenWithTpSl();\n * open.mutate({\n * ...instantOpenParams,\n * tpsl: hasTpOrSl\n * ? { from: sessionKey, virtualAccount: predictedVa, subAccount,\n * symbolId, positionType, quantity, pricePrecision, tp, sl }\n * : undefined,\n * });\n * ```\n */\nexport function useInstantOpenWithTpSl(\n parameters: UseInstantOpenWithTpSlParameters = {},\n): UseInstantOpenWithTpSlReturnType {\n const config = useSymmioConfig(parameters);\n const chainId = useSymmioChainId();\n const queryClient = useQueryClient();\n const openBase = instantOpenAutoMutationOptions(config);\n const tpslBase = setQuoteTpSlMutationOptions(config);\n const markConfirming = useTpSlStore((state) => state.markConfirming);\n\n const [phase, setPhase] = useState<UseInstantOpenWithTpSlPhase>(\"idle\");\n\n const mutation = useMutation<UseInstantOpenWithTpSlData, SymmioRequestError, UseInstantOpenWithTpSlVariables>({\n mutationKey: [\"useInstantOpenWithTpSl\"] as const,\n mutationFn: async (variables) => {\n const resolvedChainId = variables.chainId ?? chainId;\n setPhase(\"opening\");\n let openResult: InstantOpenReturnType;\n try {\n openResult = await openBase.mutationFn({ ...variables, chainId: resolvedChainId });\n } catch (err) {\n setPhase(\"error\");\n throw normalizeSymmError(err);\n }\n\n // Refresh the instant-opens feed the moment the hedger accepts.\n const configKey = config.getChainConfigKey(resolvedChainId);\n void queryClient.invalidateQueries({ predicate: predicateMatch(getInstantOpensQueryKey, { configKey }) });\n\n const wantsTpSl = Boolean(variables.tpsl && (variables.tpsl.tp || variables.tpsl.sl));\n if (!wantsTpSl || !openResult.tempQuoteId) {\n setPhase(\"success\");\n return { instantOpen: openResult };\n }\n\n const tempIdNumber = Number(openResult.tempQuoteId);\n if (!Number.isFinite(tempIdNumber)) {\n setPhase(\"success\");\n return { instantOpen: openResult };\n }\n\n setPhase(\"attaching-tpsl\");\n const quoteId = BigInt(tempIdNumber);\n try {\n const tpslResult = await tpslBase.mutationFn({\n ...(variables.tpsl as Omit<SetQuoteTpSlParameters, \"quoteId\" | \"chainId\">),\n chainId: resolvedChainId,\n quoteId,\n });\n // Mirror useSetQuoteTpSl.onSuccess: seed the confirming slot with the\n // target trigger price/type (not just the state) so useQuoteTpSl renders\n // the levels immediately — e.g. inline on the freshly-opened position row,\n // keyed by the tempQuoteId — instead of blank until the WS report lands.\n const tp = variables.tpsl!.tp;\n const sl = variables.tpsl!.sl;\n if (tp) {\n markConfirming(quoteId, \"tp\", {\n price: tp.triggerPrice,\n priceType: tp.priceType,\n cohQuoteId: tpslResult.cohQuoteId,\n });\n }\n if (sl) {\n markConfirming(quoteId, \"sl\", {\n price: sl.triggerPrice,\n priceType: sl.priceType,\n cohQuoteId: tpslResult.cohQuoteId,\n });\n }\n setPhase(\"success\");\n return { instantOpen: openResult, tpsl: tpslResult };\n } catch (err) {\n // Instant open landed; only the TP/SL leg failed. Surface it on the\n // return payload rather than throwing, so callers can render a partial\n // success state without losing the trade.\n setPhase(\"success\");\n return { instantOpen: openResult, tpslError: normalizeSymmError(err) };\n }\n },\n onError: () => setPhase(\"error\"),\n }) as UseMutationResult<UseInstantOpenWithTpSlData, SymmioRequestError, UseInstantOpenWithTpSlVariables>;\n\n return Object.assign(mutation, { phase });\n}\n"],"mappings":";;;;;;;;;;AAgFA,SAAgB,EACd,IAA+C,CAAC,GACd;CAClC,IAAM,IAAS,EAAgB,CAAU,GACnC,IAAU,EAAiB,GAC3B,IAAc,EAAe,GAC7B,IAAW,EAA+B,CAAM,GAChD,IAAW,EAA4B,CAAM,GAC7C,IAAiB,GAAc,MAAU,EAAM,cAAc,GAE7D,CAAC,GAAO,KAAY,EAAsC,MAAM,GAEhE,IAAW,EAA6F;EAC5G,aAAa,CAAC,wBAAwB;EACtC,YAAY,OAAO,MAAc;GAC/B,IAAM,IAAkB,EAAU,WAAW;GAC7C,EAAS,SAAS;GAClB,IAAI;GACJ,IAAI;IACF,IAAa,MAAM,EAAS,WAAW;KAAE,GAAG;KAAW,SAAS;IAAgB,CAAC;GACnF,SAAS,GAAK;IAEZ,MADA,EAAS,OAAO,GACV,EAAmB,CAAG;GAC9B;GAGA,IAAM,IAAY,EAAO,kBAAkB,CAAe;GAI1D,IAHA,EAAiB,kBAAkB,EAAE,WAAW,EAAe,GAAyB,EAAE,aAAU,CAAC,EAAE,CAAC,GAGpG,EADsB,EAAU,SAAS,EAAU,KAAK,MAAM,EAAU,KAAK,QAC/D,CAAC,EAAW,aAE5B,OADA,EAAS,SAAS,GACX,EAAE,aAAa,EAAW;GAGnC,IAAM,IAAe,OAAO,EAAW,WAAW;GAClD,IAAI,CAAC,OAAO,SAAS,CAAY,GAE/B,OADA,EAAS,SAAS,GACX,EAAE,aAAa,EAAW;GAGnC,EAAS,gBAAgB;GACzB,IAAM,IAAU,OAAO,CAAY;GACnC,IAAI;IACF,IAAM,IAAa,MAAM,EAAS,WAAW;KAC3C,GAAI,EAAU;KACd,SAAS;KACT;IACF,CAAC,GAKK,IAAK,EAAU,KAAM,IACrB,IAAK,EAAU,KAAM;IAgB3B,OAfI,KACF,EAAe,GAAS,MAAM;KAC5B,OAAO,EAAG;KACV,WAAW,EAAG;KACd,YAAY,EAAW;IACzB,CAAC,GAEC,KACF,EAAe,GAAS,MAAM;KAC5B,OAAO,EAAG;KACV,WAAW,EAAG;KACd,YAAY,EAAW;IACzB,CAAC,GAEH,EAAS,SAAS,GACX;KAAE,aAAa;KAAY,MAAM;IAAW;GACrD,SAAS,GAAK;IAKZ,OADA,EAAS,SAAS,GACX;KAAE,aAAa;KAAY,WAAW,EAAmB,CAAG;IAAE;GACvE;EACF;EACA,eAAe,EAAS,OAAO;CACjC,CAAC;CAED,OAAO,OAAO,OAAO,GAAU,EAAE,SAAM,CAAC;AAC1C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/margin/index.ts"],"names":[],"mappings":"AAAA,cAAc,qCAAqC,CAAC"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { PositionType, ConfigParameter } from '@symmio/trading-core';
|
|
2
|
+
import { Address } from 'viem';
|
|
3
|
+
import { SymmioRequestError } from '../errors/symmio-request-error.js';
|
|
4
|
+
/** Parameters for {@link useAvailableInstantOpenMargin}. */
|
|
5
|
+
export interface UseAvailableInstantOpenMarginParameters extends ConfigParameter {
|
|
6
|
+
/** SubAccount to spend margin from. The hook is idle until it is set. */
|
|
7
|
+
account?: Address;
|
|
8
|
+
/** Market symbol id, for the fee lookup. Idle until it is set. */
|
|
9
|
+
symbolId?: bigint | number;
|
|
10
|
+
/** Requested leverage (integer ≥ 1). */
|
|
11
|
+
leverage: number;
|
|
12
|
+
/** LONG skips the slippage cap; SHORT applies it. */
|
|
13
|
+
positionType: PositionType;
|
|
14
|
+
/** Slippage percent, e.g. `5`. */
|
|
15
|
+
slippage: number;
|
|
16
|
+
/** Optional chain override; defaults to the connected chain. */
|
|
17
|
+
chainId?: number;
|
|
18
|
+
}
|
|
19
|
+
/** Return type of {@link useAvailableInstantOpenMargin}. */
|
|
20
|
+
export interface UseAvailableInstantOpenMarginReturnType {
|
|
21
|
+
/** Spendable margin in 18-decimal wei; `undefined` until balance + fees load. */
|
|
22
|
+
availableMarginWei: bigint | undefined;
|
|
23
|
+
/** {@link UseAvailableInstantOpenMarginReturnType.availableMarginWei} as a decimal string; `"0"` when unavailable. */
|
|
24
|
+
availableMargin: string;
|
|
25
|
+
/** `true` while the underlying balance / fee reads are loading. */
|
|
26
|
+
isLoading: boolean;
|
|
27
|
+
/** First error from the balance / fee reads, if any. */
|
|
28
|
+
error: SymmioRequestError | null;
|
|
29
|
+
/** Refetch the underlying balance + fee reads (e.g. after an open/close settles). */
|
|
30
|
+
refetch: () => Promise<void>;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Maximum initial margin an instant open can spend for `account` on a market,
|
|
34
|
+
* shaved for fees and — SHORT only — a worst-case slippage fill. Composes
|
|
35
|
+
* {@link useAccountBalanceOf} + {@link useFeeForUser} and feeds them to
|
|
36
|
+
* `calculateAvailableInstantOpenMargin`. Wire the result to the trade form's
|
|
37
|
+
* `Max` chip and gate submit on it.
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* ```tsx
|
|
41
|
+
* const { availableMargin, availableMarginWei } = useAvailableInstantOpenMargin({
|
|
42
|
+
* account: subAccount,
|
|
43
|
+
* symbolId: market.symbol_id,
|
|
44
|
+
* leverage,
|
|
45
|
+
* positionType,
|
|
46
|
+
* slippage,
|
|
47
|
+
* });
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
50
|
+
export declare function useAvailableInstantOpenMargin(parameters: UseAvailableInstantOpenMarginParameters): UseAvailableInstantOpenMarginReturnType;
|
|
51
|
+
//# sourceMappingURL=use-available-instant-open-margin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-available-instant-open-margin.d.ts","sourceRoot":"","sources":["../../src/margin/use-available-instant-open-margin.ts"],"names":[],"mappings":"AAEA,OAAO,EAAuC,YAAY,EAAE,KAAK,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAE/G,OAAO,EAA4B,KAAK,OAAO,EAAE,MAAM,MAAM,CAAC;AAE9D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAQzE,4DAA4D;AAC5D,MAAM,WAAW,uCAAwC,SAAQ,eAAe;IAC9E,yEAAyE;IACzE,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,kEAAkE;IAClE,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAC3B,wCAAwC;IACxC,QAAQ,EAAE,MAAM,CAAC;IACjB,qDAAqD;IACrD,YAAY,EAAE,YAAY,CAAC;IAC3B,kCAAkC;IAClC,QAAQ,EAAE,MAAM,CAAC;IACjB,gEAAgE;IAChE,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,4DAA4D;AAC5D,MAAM,WAAW,uCAAuC;IACtD,iFAAiF;IACjF,kBAAkB,EAAE,MAAM,GAAG,SAAS,CAAC;IACvC,sHAAsH;IACtH,eAAe,EAAE,MAAM,CAAC;IACxB,mEAAmE;IACnE,SAAS,EAAE,OAAO,CAAC;IACnB,wDAAwD;IACxD,KAAK,EAAE,kBAAkB,GAAG,IAAI,CAAC;IACjC,qFAAqF;IACrF,OAAO,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAC9B;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,6BAA6B,CAC3C,UAAU,EAAE,uCAAuC,GAClD,uCAAuC,CAwCzC"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useAccountBalanceOf as e } from "../account-layer/use-account-balance-of.js";
|
|
3
|
+
import { useFeeForUser as t } from "../fees/use-fee-for-user.js";
|
|
4
|
+
import { calculateAvailableInstantOpenMargin as n } from "@symmio/trading-core";
|
|
5
|
+
import { useCallback as r, useMemo as i } from "react";
|
|
6
|
+
import { formatUnits as a, zeroAddress as o } from "viem";
|
|
7
|
+
//#region src/margin/use-available-instant-open-margin.ts
|
|
8
|
+
function s(e) {
|
|
9
|
+
return BigInt(Math.round(e * 0x2386f26fc10000));
|
|
10
|
+
}
|
|
11
|
+
function c(c) {
|
|
12
|
+
let { account: l, symbolId: u, leverage: d, positionType: f, slippage: p, chainId: m, config: h } = c, g = e({
|
|
13
|
+
account: l,
|
|
14
|
+
chainId: m,
|
|
15
|
+
config: h,
|
|
16
|
+
live: !0
|
|
17
|
+
}), _ = t({
|
|
18
|
+
user: l ?? o,
|
|
19
|
+
symbolId: u ?? 0,
|
|
20
|
+
chainId: m,
|
|
21
|
+
config: h,
|
|
22
|
+
query: { enabled: !!(l && u !== void 0) }
|
|
23
|
+
}), { data: v, isLoading: y, error: b, refetch: x } = g, { data: S, isLoading: C, error: w, refetch: T } = _, E = r(async () => {
|
|
24
|
+
await Promise.all([x(), T()]);
|
|
25
|
+
}, [x, T]);
|
|
26
|
+
return i(() => {
|
|
27
|
+
let e = y || C, t = b ?? w ?? null;
|
|
28
|
+
if (v === void 0 || S === void 0) return {
|
|
29
|
+
availableMarginWei: void 0,
|
|
30
|
+
availableMargin: "0",
|
|
31
|
+
isLoading: e,
|
|
32
|
+
error: t,
|
|
33
|
+
refetch: E
|
|
34
|
+
};
|
|
35
|
+
let r = n({
|
|
36
|
+
balance: v,
|
|
37
|
+
openFee: S.openFee,
|
|
38
|
+
closeFee: S.closeFee,
|
|
39
|
+
slippageFractionWei: s(p),
|
|
40
|
+
leverage: d,
|
|
41
|
+
positionType: f
|
|
42
|
+
});
|
|
43
|
+
return {
|
|
44
|
+
availableMarginWei: r,
|
|
45
|
+
availableMargin: a(r, 18),
|
|
46
|
+
isLoading: e,
|
|
47
|
+
error: t,
|
|
48
|
+
refetch: E
|
|
49
|
+
};
|
|
50
|
+
}, [
|
|
51
|
+
v,
|
|
52
|
+
y,
|
|
53
|
+
b,
|
|
54
|
+
S,
|
|
55
|
+
C,
|
|
56
|
+
w,
|
|
57
|
+
p,
|
|
58
|
+
d,
|
|
59
|
+
f,
|
|
60
|
+
E
|
|
61
|
+
]);
|
|
62
|
+
}
|
|
63
|
+
//#endregion
|
|
64
|
+
export { c as useAvailableInstantOpenMargin };
|
|
65
|
+
|
|
66
|
+
//# sourceMappingURL=use-available-instant-open-margin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-available-instant-open-margin.js","names":[],"sources":["../../src/margin/use-available-instant-open-margin.ts"],"sourcesContent":["\"use client\";\n\nimport { calculateAvailableInstantOpenMargin, PositionType, type ConfigParameter } from \"@symmio/trading-core\";\nimport { useCallback, useMemo } from \"react\";\nimport { formatUnits, zeroAddress, type Address } from \"viem\";\nimport { useAccountBalanceOf } from \"../account-layer/use-account-balance-of\";\nimport type { SymmioRequestError } from \"../errors/symmio-request-error\";\nimport { useFeeForUser } from \"../fees/use-fee-for-user\";\n\n/** Convert a slippage percent (e.g. `5`) to an 18-decimal fraction (`5e16`). */\nfunction slippagePercentToFractionWei(slippage: number): bigint {\n return BigInt(Math.round(slippage * 1e16));\n}\n\n/** Parameters for {@link useAvailableInstantOpenMargin}. */\nexport interface UseAvailableInstantOpenMarginParameters extends ConfigParameter {\n /** SubAccount to spend margin from. The hook is idle until it is set. */\n account?: Address;\n /** Market symbol id, for the fee lookup. Idle until it is set. */\n symbolId?: bigint | number;\n /** Requested leverage (integer ≥ 1). */\n leverage: number;\n /** LONG skips the slippage cap; SHORT applies it. */\n positionType: PositionType;\n /** Slippage percent, e.g. `5`. */\n slippage: number;\n /** Optional chain override; defaults to the connected chain. */\n chainId?: number;\n}\n\n/** Return type of {@link useAvailableInstantOpenMargin}. */\nexport interface UseAvailableInstantOpenMarginReturnType {\n /** Spendable margin in 18-decimal wei; `undefined` until balance + fees load. */\n availableMarginWei: bigint | undefined;\n /** {@link UseAvailableInstantOpenMarginReturnType.availableMarginWei} as a decimal string; `\"0\"` when unavailable. */\n availableMargin: string;\n /** `true` while the underlying balance / fee reads are loading. */\n isLoading: boolean;\n /** First error from the balance / fee reads, if any. */\n error: SymmioRequestError | null;\n /** Refetch the underlying balance + fee reads (e.g. after an open/close settles). */\n refetch: () => Promise<void>;\n}\n\n/**\n * Maximum initial margin an instant open can spend for `account` on a market,\n * shaved for fees and — SHORT only — a worst-case slippage fill. Composes\n * {@link useAccountBalanceOf} + {@link useFeeForUser} and feeds them to\n * `calculateAvailableInstantOpenMargin`. Wire the result to the trade form's\n * `Max` chip and gate submit on it.\n *\n * @example\n * ```tsx\n * const { availableMargin, availableMarginWei } = useAvailableInstantOpenMargin({\n * account: subAccount,\n * symbolId: market.symbol_id,\n * leverage,\n * positionType,\n * slippage,\n * });\n * ```\n */\nexport function useAvailableInstantOpenMargin(\n parameters: UseAvailableInstantOpenMarginParameters,\n): UseAvailableInstantOpenMarginReturnType {\n const { account, symbolId, leverage, positionType, slippage, chainId, config } = parameters;\n\n // `live` keeps the shaved margin fresh: the balance refetches when an\n // open/close settles on-chain, so the Max chip drops without a manual refresh.\n const balanceQuery = useAccountBalanceOf({ account, chainId, config, live: true });\n const feeQuery = useFeeForUser({\n user: account ?? zeroAddress,\n symbolId: symbolId ?? 0,\n chainId,\n config,\n query: { enabled: Boolean(account && symbolId !== undefined) },\n });\n\n const { data: balance, isLoading: balanceLoading, error: balanceError, refetch: refetchBalance } = balanceQuery;\n const { data: fees, isLoading: feeLoading, error: feeError, refetch: refetchFees } = feeQuery;\n\n const refetch = useCallback(async () => {\n await Promise.all([refetchBalance(), refetchFees()]);\n }, [refetchBalance, refetchFees]);\n\n return useMemo<UseAvailableInstantOpenMarginReturnType>(() => {\n const isLoading = balanceLoading || feeLoading;\n const error = balanceError ?? feeError ?? null;\n\n if (balance === undefined || fees === undefined) {\n return { availableMarginWei: undefined, availableMargin: \"0\", isLoading, error, refetch };\n }\n\n const availableMarginWei = calculateAvailableInstantOpenMargin({\n balance,\n openFee: fees.openFee,\n closeFee: fees.closeFee,\n slippageFractionWei: slippagePercentToFractionWei(slippage),\n leverage,\n positionType,\n });\n\n return { availableMarginWei, availableMargin: formatUnits(availableMarginWei, 18), isLoading, error, refetch };\n }, [balance, balanceLoading, balanceError, fees, feeLoading, feeError, slippage, leverage, positionType, refetch]);\n}\n"],"mappings":";;;;;;;AAUA,SAAS,EAA6B,GAA0B;CAC9D,OAAO,OAAO,KAAK,MAAM,IAAW,gBAAI,CAAC;AAC3C;AAkDA,SAAgB,EACd,GACyC;CACzC,IAAM,EAAE,YAAS,aAAU,aAAU,iBAAc,aAAU,YAAS,cAAW,GAI3E,IAAe,EAAoB;EAAE;EAAS;EAAS;EAAQ,MAAM;CAAK,CAAC,GAC3E,IAAW,EAAc;EAC7B,MAAM,KAAW;EACjB,UAAU,KAAY;EACtB;EACA;EACA,OAAO,EAAE,SAAS,GAAQ,KAAW,MAAa,KAAA,GAAW;CAC/D,CAAC,GAEK,EAAE,MAAM,GAAS,WAAW,GAAgB,OAAO,GAAc,SAAS,MAAmB,GAC7F,EAAE,MAAM,GAAM,WAAW,GAAY,OAAO,GAAU,SAAS,MAAgB,GAE/E,IAAU,EAAY,YAAY;EACtC,MAAM,QAAQ,IAAI,CAAC,EAAe,GAAG,EAAY,CAAC,CAAC;CACrD,GAAG,CAAC,GAAgB,CAAW,CAAC;CAEhC,OAAO,QAAuD;EAC5D,IAAM,IAAY,KAAkB,GAC9B,IAAQ,KAAgB,KAAY;EAE1C,IAAI,MAAY,KAAA,KAAa,MAAS,KAAA,GACpC,OAAO;GAAE,oBAAoB,KAAA;GAAW,iBAAiB;GAAK;GAAW;GAAO;EAAQ;EAG1F,IAAM,IAAqB,EAAoC;GAC7D;GACA,SAAS,EAAK;GACd,UAAU,EAAK;GACf,qBAAqB,EAA6B,CAAQ;GAC1D;GACA;EACF,CAAC;EAED,OAAO;GAAE;GAAoB,iBAAiB,EAAY,GAAoB,EAAE;GAAG;GAAW;GAAO;EAAQ;CAC/G,GAAG;EAAC;EAAS;EAAgB;EAAc;EAAM;EAAY;EAAU;EAAU;EAAU;EAAc;CAAO,CAAC;AACnH"}
|
|
@@ -7,10 +7,19 @@ export interface SymmioProviderProps {
|
|
|
7
7
|
/** React subtree that may use SYMMIO SDK hooks. */
|
|
8
8
|
children: ReactNode;
|
|
9
9
|
/**
|
|
10
|
-
* Per-chain
|
|
11
|
-
*
|
|
10
|
+
* Per-chain SYMMIO configuration, keyed by chain id — deep-merged onto the
|
|
11
|
+
* SDK's built-in defaults (addresses, subgraphs, solver, …).
|
|
12
|
+
*
|
|
13
|
+
* **Required.** Every supported chain must set a non-zero
|
|
14
|
+
* `addresses.affiliatesAddress` — your frontend's on-chain affiliate (your
|
|
15
|
+
* identity in SYMMIO on that chain), attached to every quote so the protocol
|
|
16
|
+
* attributes the trade to you and routes your fee share. Affiliate addresses
|
|
17
|
+
* are per chain (a registration on one chain is not valid on another). The
|
|
18
|
+
* provider throws `AFFILIATE_ADDRESS_REQUIRED` (via `createConfig`) for any
|
|
19
|
+
* supported chain missing it, so trades can never silently fall back to the
|
|
20
|
+
* built-in default affiliate and lose attribution.
|
|
12
21
|
*/
|
|
13
|
-
|
|
22
|
+
symmioConfig: CreateConfigParameters["symmioConfig"];
|
|
14
23
|
/** Chain used when a hook or action omits `chainId`. Defaults to the first supported chain. */
|
|
15
24
|
defaultChainId?: number;
|
|
16
25
|
/**
|
|
@@ -35,7 +44,7 @@ export interface SymmioProviderProps {
|
|
|
35
44
|
* ```tsx
|
|
36
45
|
* <WagmiProvider config={wagmiConfig}>
|
|
37
46
|
* <QueryClientProvider client={queryClient}>
|
|
38
|
-
* <SymmioProvider>
|
|
47
|
+
* <SymmioProvider symmioConfig={{ [SymmioSupportedChainId.HYPER_EVM]: { addresses: { affiliatesAddress: "0x…" } } }}>
|
|
39
48
|
* <App />
|
|
40
49
|
* </SymmioProvider>
|
|
41
50
|
* </QueryClientProvider>
|
|
@@ -45,5 +54,5 @@ export interface SymmioProviderProps {
|
|
|
45
54
|
* The SDK never mounts wagmi or a `QueryClient` for the host — those (which
|
|
46
55
|
* connectors, which RPC URLs, which shared `QueryClient`) belong to the host.
|
|
47
56
|
*/
|
|
48
|
-
export declare function SymmioProvider({ children,
|
|
57
|
+
export declare function SymmioProvider({ children, symmioConfig, defaultChainId, getWalletClient: getWalletClientProp, }: SymmioProviderProps): import("react").JSX.Element;
|
|
49
58
|
//# sourceMappingURL=symmio-provider.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"symmio-provider.d.ts","sourceRoot":"","sources":["../../src/provider/symmio-provider.tsx"],"names":[],"mappings":"AAEA,OAAO,EAIL,KAAK,sBAAsB,EAC3B,KAAK,iBAAiB,EACvB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAW,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAMhD;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,mDAAmD;IACnD,QAAQ,EAAE,SAAS,CAAC;IACpB
|
|
1
|
+
{"version":3,"file":"symmio-provider.d.ts","sourceRoot":"","sources":["../../src/provider/symmio-provider.tsx"],"names":[],"mappings":"AAEA,OAAO,EAIL,KAAK,sBAAsB,EAC3B,KAAK,iBAAiB,EACvB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAW,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAMhD;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,mDAAmD;IACnD,QAAQ,EAAE,SAAS,CAAC;IACpB;;;;;;;;;;;;OAYG;IACH,YAAY,EAAE,sBAAsB,CAAC,cAAc,CAAC,CAAC;IACrD,+FAA+F;IAC/F,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB;;;;;;;OAOG;IACH,eAAe,CAAC,EAAE,iBAAiB,CAAC;CACrC;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,cAAc,CAAC,EAC7B,QAAQ,EACR,YAAY,EACZ,cAAc,EACd,eAAe,EAAE,mBAAmB,GACrC,EAAE,mBAAmB,+BAsCrB"}
|
|
@@ -6,9 +6,9 @@ import { useConfig as i } from "wagmi";
|
|
|
6
6
|
import { getPublicClient as a, getWalletClient as o } from "wagmi/actions";
|
|
7
7
|
import { jsx as s } from "react/jsx-runtime";
|
|
8
8
|
//#region src/provider/symmio-provider.tsx
|
|
9
|
-
function c({ children: c,
|
|
9
|
+
function c({ children: c, symmioConfig: l, defaultChainId: u, getWalletClient: d }) {
|
|
10
10
|
let f = i(), p = r(() => n({
|
|
11
|
-
|
|
11
|
+
symmioConfig: l,
|
|
12
12
|
defaultChainId: u,
|
|
13
13
|
getClient: ({ chainId: e } = {}) => {
|
|
14
14
|
let n = a(f, { chainId: e });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"symmio-provider.js","names":[],"sources":["../../src/provider/symmio-provider.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n createConfig,\n SymmError,\n type Config,\n type CreateConfigParameters,\n type GetWalletClientFn,\n} from \"@symmio/trading-core\";\nimport { useMemo, type ReactNode } from \"react\";\nimport type { PublicClient } from \"viem\";\nimport { useConfig } from \"wagmi\";\nimport { getPublicClient, getWalletClient } from \"wagmi/actions\";\nimport { SymmioConfigContext } from \"./symmio-config-context\";\n\n/**\n * Props for {@link SymmioProvider}.\n */\nexport interface SymmioProviderProps {\n /** React subtree that may use SYMMIO SDK hooks. */\n children: ReactNode;\n /**\n * Per-chain
|
|
1
|
+
{"version":3,"file":"symmio-provider.js","names":[],"sources":["../../src/provider/symmio-provider.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n createConfig,\n SymmError,\n type Config,\n type CreateConfigParameters,\n type GetWalletClientFn,\n} from \"@symmio/trading-core\";\nimport { useMemo, type ReactNode } from \"react\";\nimport type { PublicClient } from \"viem\";\nimport { useConfig } from \"wagmi\";\nimport { getPublicClient, getWalletClient } from \"wagmi/actions\";\nimport { SymmioConfigContext } from \"./symmio-config-context\";\n\n/**\n * Props for {@link SymmioProvider}.\n */\nexport interface SymmioProviderProps {\n /** React subtree that may use SYMMIO SDK hooks. */\n children: ReactNode;\n /**\n * Per-chain SYMMIO configuration, keyed by chain id — deep-merged onto the\n * SDK's built-in defaults (addresses, subgraphs, solver, …).\n *\n * **Required.** Every supported chain must set a non-zero\n * `addresses.affiliatesAddress` — your frontend's on-chain affiliate (your\n * identity in SYMMIO on that chain), attached to every quote so the protocol\n * attributes the trade to you and routes your fee share. Affiliate addresses\n * are per chain (a registration on one chain is not valid on another). The\n * provider throws `AFFILIATE_ADDRESS_REQUIRED` (via `createConfig`) for any\n * supported chain missing it, so trades can never silently fall back to the\n * built-in default affiliate and lose attribution.\n */\n symmioConfig: CreateConfigParameters[\"symmioConfig\"];\n /** Chain used when a hook or action omits `chainId`. Defaults to the first supported chain. */\n defaultChainId?: number;\n /**\n * Custom wallet-client resolver. Receives `{ chainId, from? }` from the SDK\n * and returns the wallet client to sign with. Use this to plug in\n * session-key, multi-signer, or any non-wagmi flow — the resolver decides.\n *\n * When omitted, the provider falls back to wagmi's connected wallet (ignores\n * `from`).\n */\n getWalletClient?: GetWalletClientFn;\n}\n\n/**\n * Provides the SYMMIO {@link Config} to descendant hooks. The config's viem\n * clients are resolved from the host's wagmi config, so this is the only place\n * the SDK touches wagmi.\n *\n * **Mount order matters**: this reads wagmi context and (transitively) the\n * host's `@tanstack/react-query` `QueryClient`. Both must be mounted **outside**\n * `SymmioProvider`:\n *\n * ```tsx\n * <WagmiProvider config={wagmiConfig}>\n * <QueryClientProvider client={queryClient}>\n * <SymmioProvider symmioConfig={{ [SymmioSupportedChainId.HYPER_EVM]: { addresses: { affiliatesAddress: \"0x…\" } } }}>\n * <App />\n * </SymmioProvider>\n * </QueryClientProvider>\n * </WagmiProvider>\n * ```\n *\n * The SDK never mounts wagmi or a `QueryClient` for the host — those (which\n * connectors, which RPC URLs, which shared `QueryClient`) belong to the host.\n */\nexport function SymmioProvider({\n children,\n symmioConfig,\n defaultChainId,\n getWalletClient: getWalletClientProp,\n}: SymmioProviderProps) {\n const wagmiConfig = useConfig();\n\n const config = useMemo<Config>(\n () =>\n createConfig({\n symmioConfig,\n defaultChainId,\n getClient: ({ chainId } = {}): PublicClient => {\n const client = getPublicClient(wagmiConfig, { chainId });\n\n if (!client)\n throw new SymmError(\n \"config\",\n \"NO_PUBLIC_CLIENT\",\n `No public client available for chain ${chainId ?? \"(default)\"}.`,\n );\n return client;\n },\n getWalletClient:\n getWalletClientProp ??\n (async ({ chainId }) => {\n try {\n return await getWalletClient(wagmiConfig, { chainId });\n } catch (err) {\n throw new SymmError(\n \"config\",\n \"NO_WALLET_CONNECTED\",\n \"No connected wallet. Connect a wallet before sending transactions.\",\n { cause: err instanceof Error ? err : undefined },\n );\n }\n }),\n }),\n [symmioConfig, defaultChainId, getWalletClientProp, wagmiConfig],\n );\n\n return <SymmioConfigContext.Provider value={config}>{children}</SymmioConfigContext.Provider>;\n}\n"],"mappings":";;;;;;;;AAsEA,SAAgB,EAAe,EAC7B,aACA,iBACA,mBACA,iBAAiB,KACK;CACtB,IAAM,IAAc,EAAU,GAExB,IAAS,QAEX,EAAa;EACX;EACA;EACA,YAAY,EAAE,eAAY,CAAC,MAAoB;GAC7C,IAAM,IAAS,EAAgB,GAAa,EAAE,WAAQ,CAAC;GAEvD,IAAI,CAAC,GACH,MAAM,IAAI,EACR,UACA,oBACA,wCAAwC,KAAW,YAAY,EACjE;GACF,OAAO;EACT;EACA,iBACE,MACC,OAAO,EAAE,iBAAc;GACtB,IAAI;IACF,OAAO,MAAM,EAAgB,GAAa,EAAE,WAAQ,CAAC;GACvD,SAAS,GAAK;IACZ,MAAM,IAAI,EACR,UACA,uBACA,sEACA,EAAE,OAAO,aAAe,QAAQ,IAAM,KAAA,EAAU,CAClD;GACF;EACF;CACJ,CAAC,GACH;EAAC;EAAc;EAAgB;EAAqB;CAAW,CACjE;CAEA,OAAO,kBAAC,EAAoB,UAArB;EAA8B,OAAO;EAAS;CAAuC,CAAA;AAC9F"}
|