@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,6 +1,6 @@
|
|
|
1
1
|
import { ConfigParameter, SimulateEditAccountNameParameters, SimulateEditAccountNameReturnType } 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 useSimulateEditAccountName}: 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, SimulateRemoveMarginParameters, SimulateRemoveMarginReturnType } 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 useSimulateRemoveMargin}: an optional `config` override.
|
|
6
6
|
* The dry-run's inputs (including a `upnlSig`) are passed as the mutation
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ConfigParameter, GetSubAccountVirtualNonceOptions, GetSubAccountVirtualNonceReturnType } 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 useSubAccountVirtualNonce}: the core query options
|
|
6
6
|
* (subAccount, chain id, TanStack `query` overrides) plus an optional `config`.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ConfigParameter, GetSubAccountOptions, GetSubAccountReturnType } 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 useSubAccount}: the core query options (account, chain
|
|
6
6
|
* id, TanStack `query` overrides) plus an optional `config`.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ConfigParameter, GetSubAccountsCountOfUserOptions, GetSubAccountsCountOfUserReturnType } 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 useSubAccountsCountOfUser}: the core query options (user,
|
|
6
6
|
* chain id, TanStack `query` overrides) plus an optional `config`.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ConfigParameter, GetUserSubAccountsAddressesOptions, GetUserSubAccountsAddressesReturnType } 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 useUserSubAccountsAddresses}: the core query options
|
|
6
6
|
* (user, pagination, chain id, TanStack `query` overrides) plus an optional
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ConfigParameter, GetUserSubAccountsOptions, SubAccountDetail } 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 useUserSubAccounts}: the core query options (user,
|
|
6
6
|
* pagination, chain id, TanStack `query` overrides) plus an optional `config`.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ConfigParameter, GetVirtualAccountOptions, GetVirtualAccountReturnType } 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 useVirtualAccount}: the core query options
|
|
6
6
|
* (`account`, chain id, TanStack `query` overrides) plus an optional `config`.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ConfigParameter, GetVirtualAccountsAddressesOfSubAccountOptions, GetVirtualAccountsAddressesOfSubAccountReturnType } 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 useVirtualAccountsAddressesOfSubAccount}: the core query
|
|
6
6
|
* options (subAccount, pagination, chain id, TanStack `query` overrides) plus an
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export * from './use-balance-history';
|
|
2
|
-
export * from './use-deposit-history';
|
|
3
|
-
export * from './use-withdraw-history';
|
|
1
|
+
export * from './use-balance-history.js';
|
|
2
|
+
export * from './use-deposit-history.js';
|
|
3
|
+
export * from './use-withdraw-history.js';
|
|
4
4
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ConfigParameter, GetBalanceHistoryOptions, GetBalanceHistoryReturnType } 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 useBalanceHistory}: the core query options (accounts,
|
|
6
6
|
* filter, paging, time range, chain id, TanStack `query` overrides) plus an
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { UseBalanceHistoryParameters, UseBalanceHistoryReturnType } from './use-balance-history';
|
|
1
|
+
import { UseBalanceHistoryParameters, UseBalanceHistoryReturnType } from './use-balance-history.js';
|
|
2
2
|
/**
|
|
3
3
|
* Parameters for {@link useDepositHistory}: same as {@link useBalanceHistory} but
|
|
4
4
|
* without `filter` — it is pinned to deposits.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { UseBalanceHistoryParameters, UseBalanceHistoryReturnType } from './use-balance-history';
|
|
1
|
+
import { UseBalanceHistoryParameters, UseBalanceHistoryReturnType } from './use-balance-history.js';
|
|
2
2
|
/**
|
|
3
3
|
* Parameters for {@link useWithdrawHistory}: same as {@link useBalanceHistory} but
|
|
4
4
|
* without `filter` — it is pinned to withdrawals.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export * from './use-approve-collateral';
|
|
2
|
-
export * from './use-collateral-allowance';
|
|
3
|
-
export * from './use-collateral-balance';
|
|
4
|
-
export * from './use-simulate-approve-collateral';
|
|
1
|
+
export * from './use-approve-collateral.js';
|
|
2
|
+
export * from './use-collateral-allowance.js';
|
|
3
|
+
export * from './use-collateral-balance.js';
|
|
4
|
+
export * from './use-simulate-approve-collateral.js';
|
|
5
5
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ApproveCollateralParameters } 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 useApproveCollateral}.
|
|
7
7
|
*/
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ConfigParameter, GetCollateralAllowanceOptions, GetCollateralAllowanceReturnType } 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 useCollateralAllowance}: the core query options (owner,
|
|
6
6
|
* chain id, TanStack `query` overrides) plus an optional `config`.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ConfigParameter, GetCollateralBalanceOptions, GetCollateralBalanceReturnType } 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 useCollateralBalance}: the core query options (owner,
|
|
6
6
|
* chain id, TanStack `query` overrides) plus an optional `config`.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ConfigParameter, SimulateApproveCollateralParameters, SimulateApproveCollateralReturnType } 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 useSimulateApproveCollateral}: an optional `config` override. The dry-run's
|
|
6
6
|
* inputs are passed as the mutation `variables`.
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from './use-solver-error-codes';
|
|
2
|
-
export * from './use-solver-error-message';
|
|
1
|
+
export * from './use-solver-error-codes.js';
|
|
2
|
+
export * from './use-solver-error-message.js';
|
|
3
3
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ConfigParameter, GetSolverErrorCodesOptions, GetSolverErrorCodesReturnType } 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 useSolverErrorCodes}: the core query options (chain id,
|
|
6
6
|
* TanStack `query` overrides) plus an optional `config`.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { UseSolverErrorCodesParameters } from './use-solver-error-codes';
|
|
1
|
+
import { UseSolverErrorCodesParameters } from './use-solver-error-codes.js';
|
|
2
2
|
/**
|
|
3
3
|
* Resolve a single solver error code — the `errorCode` reported on a failed
|
|
4
4
|
* open/close notification or carried on a failed `UnifiedQuote` — to its
|
package/dist/errors/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export * from './normalize-symm-error';
|
|
2
|
-
export * from './symmio-request-error';
|
|
3
|
-
export * from './types';
|
|
1
|
+
export * from './normalize-symm-error.js';
|
|
2
|
+
export * from './symmio-request-error.js';
|
|
3
|
+
export * from './types.js';
|
|
4
4
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SymmioRequestError } from './symmio-request-error';
|
|
1
|
+
import { SymmioRequestError } from './symmio-request-error.js';
|
|
2
2
|
/**
|
|
3
3
|
* Classify any thrown value into a {@link SymmioRequestError}. Hooks call this
|
|
4
4
|
* inside their `queryFn` / `mutationFn` so consumers always see the same
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/estimated-price/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Debounce a fast-changing value: returns `value` only after it has stayed
|
|
3
|
+
* unchanged for `delayMs`. Used to hold back solver requests while the user is
|
|
4
|
+
* still typing an amount. A `delayMs <= 0` passes the value through immediately.
|
|
5
|
+
*
|
|
6
|
+
* @internal
|
|
7
|
+
*/
|
|
8
|
+
export declare function useDebouncedValue<T>(value: T, delayMs: number): T;
|
|
9
|
+
//# sourceMappingURL=use-debounced-value.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-debounced-value.d.ts","sourceRoot":"","sources":["../../src/estimated-price/use-debounced-value.ts"],"names":[],"mappings":"AAIA;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,OAAO,EAAE,MAAM,GAAG,CAAC,CAajE"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useEffect as e, useState as t } from "react";
|
|
3
|
+
//#region src/estimated-price/use-debounced-value.ts
|
|
4
|
+
function n(n, r) {
|
|
5
|
+
let [i, a] = t(n);
|
|
6
|
+
return e(() => {
|
|
7
|
+
if (r <= 0) {
|
|
8
|
+
a(n);
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
let e = setTimeout(() => a(n), r);
|
|
12
|
+
return () => clearTimeout(e);
|
|
13
|
+
}, [n, r]), i;
|
|
14
|
+
}
|
|
15
|
+
//#endregion
|
|
16
|
+
export { n as useDebouncedValue };
|
|
17
|
+
|
|
18
|
+
//# sourceMappingURL=use-debounced-value.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-debounced-value.js","names":[],"sources":["../../src/estimated-price/use-debounced-value.ts"],"sourcesContent":["\"use client\";\n\nimport { useEffect, useState } from \"react\";\n\n/**\n * Debounce a fast-changing value: returns `value` only after it has stayed\n * unchanged for `delayMs`. Used to hold back solver requests while the user is\n * still typing an amount. A `delayMs <= 0` passes the value through immediately.\n *\n * @internal\n */\nexport function useDebouncedValue<T>(value: T, delayMs: number): T {\n const [debounced, setDebounced] = useState(value);\n\n useEffect(() => {\n if (delayMs <= 0) {\n setDebounced(value);\n return;\n }\n const timer = setTimeout(() => setDebounced(value), delayMs);\n return () => clearTimeout(timer);\n }, [value, delayMs]);\n\n return debounced;\n}\n"],"mappings":";;;AAWA,SAAgB,EAAqB,GAAU,GAAoB;CACjE,IAAM,CAAC,GAAW,KAAgB,EAAS,CAAK;CAWhD,OATA,QAAgB;EACd,IAAI,KAAW,GAAG;GAChB,EAAa,CAAK;GAClB;EACF;EACA,IAAM,IAAQ,iBAAiB,EAAa,CAAK,GAAG,CAAO;EAC3D,aAAa,aAAa,CAAK;CACjC,GAAG,CAAC,GAAO,CAAO,CAAC,GAEZ;AACT"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { ConfigParameter, GetEstimatedPriceOptions, GetEstimatedPriceReturnType } from '@symmio/trading-core';
|
|
2
|
+
import { UseQueryResult } from '@tanstack/react-query';
|
|
3
|
+
import { SymmioRequestError } from '../errors/symmio-request-error.js';
|
|
4
|
+
/**
|
|
5
|
+
* Parameters for {@link useEstimatedPrice}: the core query options (`symbolId`,
|
|
6
|
+
* `quantity`, `positionType`, `entry`, `price`, chain id, TanStack `query`
|
|
7
|
+
* overrides), an optional `config`, and an optional `debounceMs`.
|
|
8
|
+
*/
|
|
9
|
+
export type UseEstimatedPriceParameters = GetEstimatedPriceOptions & ConfigParameter & {
|
|
10
|
+
/**
|
|
11
|
+
* Debounce (ms) applied to `quantity` and `price` so one request fires once
|
|
12
|
+
* the user stops typing — not one per keystroke. Defaults to
|
|
13
|
+
* {@link DEFAULT_DEBOUNCE_MS} (350); set `0` to disable.
|
|
14
|
+
*/
|
|
15
|
+
debounceMs?: number;
|
|
16
|
+
};
|
|
17
|
+
/** Return type of {@link useEstimatedPrice}. */
|
|
18
|
+
export type UseEstimatedPriceReturnType = UseQueryResult<GetEstimatedPriceReturnType, SymmioRequestError>;
|
|
19
|
+
/**
|
|
20
|
+
* Ask the solver what price an open or close would **fill at** — a read-only
|
|
21
|
+
* simulation of the trade (`/estimated-price`; nothing is submitted). Use it to
|
|
22
|
+
* preview the fill price, the price impact
|
|
23
|
+
* ([`calculatePriceImpact`](../../core/solvers/estimated-price)) and — for a
|
|
24
|
+
* close — an estimated PnL, before the user submits.
|
|
25
|
+
*
|
|
26
|
+
* `price` is the **slippage-adjusted request price** the caller computed (not the
|
|
27
|
+
* raw mark). The query is disabled until `quantity` and `price` are non-empty, so
|
|
28
|
+
* it doesn't fire on partial input. `quantity` and `price` are **debounced
|
|
29
|
+
* internally** (`debounceMs`, default 350) so typing an amount fires a single
|
|
30
|
+
* request once the user settles — the caller passes the raw input, no external
|
|
31
|
+
* debounce needed. Errors are normalized to {@link SymmioRequestError}.
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* ```tsx
|
|
35
|
+
* const { data } = useEstimatedPrice({
|
|
36
|
+
* symbolId,
|
|
37
|
+
* quantity: tradeParams.quantity,
|
|
38
|
+
* positionType,
|
|
39
|
+
* entry: "open",
|
|
40
|
+
* price: tradeParams.price, // slippage-adjusted
|
|
41
|
+
* });
|
|
42
|
+
* // data?.estimatedPrice
|
|
43
|
+
* ```
|
|
44
|
+
*/
|
|
45
|
+
export declare function useEstimatedPrice(parameters: UseEstimatedPriceParameters): UseEstimatedPriceReturnType;
|
|
46
|
+
//# sourceMappingURL=use-estimated-price.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-estimated-price.d.ts","sourceRoot":"","sources":["../../src/estimated-price/use-estimated-price.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,KAAK,eAAe,EACpB,KAAK,wBAAwB,EAC7B,KAAK,2BAA2B,EACjC,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAY,KAAK,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAEtE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAQzE;;;;GAIG;AACH,MAAM,MAAM,2BAA2B,GAAG,wBAAwB,GAChE,eAAe,GAAG;IAChB;;;;OAIG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,CAAC;AAEJ,gDAAgD;AAChD,MAAM,MAAM,2BAA2B,GAAG,cAAc,CAAC,2BAA2B,EAAE,kBAAkB,CAAC,CAAC;AAE1G;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,iBAAiB,CAAC,UAAU,EAAE,2BAA2B,GAAG,2BAA2B,CA6BtG"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useSymmioChainId as e } from "../provider/use-symmio-chain-id.js";
|
|
3
|
+
import { useSymmioConfig as t } from "../provider/use-symmio-config.js";
|
|
4
|
+
import { normalizeSymmError as n } from "../errors/normalize-symm-error.js";
|
|
5
|
+
import { useDebouncedValue as r } from "./use-debounced-value.js";
|
|
6
|
+
import { getEstimatedPriceQueryOptions as i } from "@symmio/trading-core";
|
|
7
|
+
import { useQuery as a } from "@tanstack/react-query";
|
|
8
|
+
//#region src/estimated-price/use-estimated-price.ts
|
|
9
|
+
var o = 500;
|
|
10
|
+
function s(s) {
|
|
11
|
+
let c = t(s), l = e(), { debounceMs: u, ...d } = s, f = r(s.quantity, u ?? o), p = r(s.price, u ?? o), m = i(c, {
|
|
12
|
+
...d,
|
|
13
|
+
quantity: f,
|
|
14
|
+
price: p,
|
|
15
|
+
chainId: s.chainId ?? l
|
|
16
|
+
});
|
|
17
|
+
return a({
|
|
18
|
+
...m,
|
|
19
|
+
queryFn: async () => {
|
|
20
|
+
try {
|
|
21
|
+
return await m.queryFn();
|
|
22
|
+
} catch (e) {
|
|
23
|
+
throw n(e);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
//#endregion
|
|
29
|
+
export { s as useEstimatedPrice };
|
|
30
|
+
|
|
31
|
+
//# sourceMappingURL=use-estimated-price.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-estimated-price.js","names":[],"sources":["../../src/estimated-price/use-estimated-price.ts"],"sourcesContent":["\"use client\";\n\nimport {\n getEstimatedPriceQueryOptions,\n type ConfigParameter,\n type GetEstimatedPriceOptions,\n type GetEstimatedPriceReturnType,\n} from \"@symmio/trading-core\";\nimport { useQuery, type UseQueryResult } 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 { useDebouncedValue } from \"./use-debounced-value\";\n\n/** Default debounce (ms) applied to the typed `quantity` / `price` inputs. */\nconst DEFAULT_DEBOUNCE_MS = 500;\n\n/**\n * Parameters for {@link useEstimatedPrice}: the core query options (`symbolId`,\n * `quantity`, `positionType`, `entry`, `price`, chain id, TanStack `query`\n * overrides), an optional `config`, and an optional `debounceMs`.\n */\nexport type UseEstimatedPriceParameters = GetEstimatedPriceOptions &\n ConfigParameter & {\n /**\n * Debounce (ms) applied to `quantity` and `price` so one request fires once\n * the user stops typing — not one per keystroke. Defaults to\n * {@link DEFAULT_DEBOUNCE_MS} (350); set `0` to disable.\n */\n debounceMs?: number;\n };\n\n/** Return type of {@link useEstimatedPrice}. */\nexport type UseEstimatedPriceReturnType = UseQueryResult<GetEstimatedPriceReturnType, SymmioRequestError>;\n\n/**\n * Ask the solver what price an open or close would **fill at** — a read-only\n * simulation of the trade (`/estimated-price`; nothing is submitted). Use it to\n * preview the fill price, the price impact\n * ([`calculatePriceImpact`](../../core/solvers/estimated-price)) and — for a\n * close — an estimated PnL, before the user submits.\n *\n * `price` is the **slippage-adjusted request price** the caller computed (not the\n * raw mark). The query is disabled until `quantity` and `price` are non-empty, so\n * it doesn't fire on partial input. `quantity` and `price` are **debounced\n * internally** (`debounceMs`, default 350) so typing an amount fires a single\n * request once the user settles — the caller passes the raw input, no external\n * debounce needed. Errors are normalized to {@link SymmioRequestError}.\n *\n * @example\n * ```tsx\n * const { data } = useEstimatedPrice({\n * symbolId,\n * quantity: tradeParams.quantity,\n * positionType,\n * entry: \"open\",\n * price: tradeParams.price, // slippage-adjusted\n * });\n * // data?.estimatedPrice\n * ```\n */\nexport function useEstimatedPrice(parameters: UseEstimatedPriceParameters): UseEstimatedPriceReturnType {\n const config = useSymmioConfig(parameters);\n const chainId = useSymmioChainId();\n\n // The amount and request price change on every keystroke; debounce them so the\n // solver is hit once the user settles, not once per digit. Market, side, and\n // entry change discretely and pass through untouched. `debounceMs` is pulled\n // out so it never leaks into the query options / cache key.\n const { debounceMs, ...queryParams } = parameters;\n const quantity = useDebouncedValue(parameters.quantity, debounceMs ?? DEFAULT_DEBOUNCE_MS);\n const price = useDebouncedValue(parameters.price, debounceMs ?? DEFAULT_DEBOUNCE_MS);\n\n const options = getEstimatedPriceQueryOptions(config, {\n ...queryParams,\n quantity,\n price,\n chainId: parameters.chainId ?? chainId,\n });\n\n return useQuery({\n ...options,\n queryFn: async () => {\n try {\n return await options.queryFn();\n } catch (err) {\n throw normalizeSymmError(err);\n }\n },\n }) as UseEstimatedPriceReturnType;\n}\n"],"mappings":";;;;;;;;AAgBA,IAAM,IAAsB;AA8C5B,SAAgB,EAAkB,GAAsE;CACtG,IAAM,IAAS,EAAgB,CAAU,GACnC,IAAU,EAAiB,GAM3B,EAAE,eAAY,GAAG,MAAgB,GACjC,IAAW,EAAkB,EAAW,UAAU,KAAc,CAAmB,GACnF,IAAQ,EAAkB,EAAW,OAAO,KAAc,CAAmB,GAE7E,IAAU,EAA8B,GAAQ;EACpD,GAAG;EACH;EACA;EACA,SAAS,EAAW,WAAW;CACjC,CAAC;CAED,OAAO,EAAS;EACd,GAAG;EACH,SAAS,YAAY;GACnB,IAAI;IACF,OAAO,MAAM,EAAQ,QAAQ;GAC/B,SAAS,GAAK;IACZ,MAAM,EAAmB,CAAG;GAC9B;EACF;CACF,CAAC;AACH"}
|
package/dist/fees/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './use-fee-for-user';
|
|
1
|
+
export * from './use-fee-for-user.js';
|
|
2
2
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ConfigParameter, GetFeeForUserOptions, GetFeeForUserReturnType } 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 useFeeForUser}: the core query options (user, symbol id,
|
|
6
6
|
* optional affiliate, chain id, TanStack `query` overrides) plus an optional
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/funding-info/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { ConfigParameter, GetFundingInfoOptions, GetFundingInfoReturnType } from '@symmio/trading-core';
|
|
2
|
+
import { UseQueryResult } from '@tanstack/react-query';
|
|
3
|
+
import { SymmioRequestError } from '../errors/symmio-request-error.js';
|
|
4
|
+
/**
|
|
5
|
+
* Parameters for {@link useFundingInfo}: the core query options plus an optional
|
|
6
|
+
* `config`.
|
|
7
|
+
*/
|
|
8
|
+
export type UseFundingInfoParameters = GetFundingInfoOptions & ConfigParameter;
|
|
9
|
+
/** Return type of {@link useFundingInfo}. */
|
|
10
|
+
export type UseFundingInfoReturnType = UseQueryResult<GetFundingInfoReturnType, SymmioRequestError>;
|
|
11
|
+
/**
|
|
12
|
+
* Read per-market funding rates from the active chain's solver in one call.
|
|
13
|
+
* Surfaces the next-epoch long/short funding rate, next funding time, and epoch
|
|
14
|
+
* length for every market (or only the requested `symbols`).
|
|
15
|
+
*
|
|
16
|
+
* Does not poll by default; pass `query.refetchInterval` to opt into polling.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```tsx
|
|
20
|
+
* const { data } = useFundingInfo();
|
|
21
|
+
* const btc = data?.find((f) => f.symbol === "BTCUSDT");
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export declare function useFundingInfo(parameters?: UseFundingInfoParameters): UseFundingInfoReturnType;
|
|
25
|
+
//# sourceMappingURL=use-funding-info.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-funding-info.d.ts","sourceRoot":"","sources":["../../src/funding-info/use-funding-info.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,KAAK,eAAe,EACpB,KAAK,qBAAqB,EAC1B,KAAK,wBAAwB,EAC9B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAY,KAAK,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAEtE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAIzE;;;GAGG;AACH,MAAM,MAAM,wBAAwB,GAAG,qBAAqB,GAAG,eAAe,CAAC;AAE/E,6CAA6C;AAC7C,MAAM,MAAM,wBAAwB,GAAG,cAAc,CAAC,wBAAwB,EAAE,kBAAkB,CAAC,CAAC;AAEpG;;;;;;;;;;;;GAYG;AACH,wBAAgB,cAAc,CAAC,UAAU,GAAE,wBAA6B,GAAG,wBAAwB,CAkBlG"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useSymmioChainId as e } from "../provider/use-symmio-chain-id.js";
|
|
3
|
+
import { useSymmioConfig as t } from "../provider/use-symmio-config.js";
|
|
4
|
+
import { normalizeSymmError as n } from "../errors/normalize-symm-error.js";
|
|
5
|
+
import { getFundingInfoQueryOptions as r } from "@symmio/trading-core";
|
|
6
|
+
import { useQuery as i } from "@tanstack/react-query";
|
|
7
|
+
//#region src/funding-info/use-funding-info.ts
|
|
8
|
+
function a(a = {}) {
|
|
9
|
+
let o = t(a), s = e(), c = r(o, {
|
|
10
|
+
...a,
|
|
11
|
+
chainId: a.chainId ?? s
|
|
12
|
+
});
|
|
13
|
+
return i({
|
|
14
|
+
...c,
|
|
15
|
+
queryFn: async () => {
|
|
16
|
+
try {
|
|
17
|
+
return await c.queryFn();
|
|
18
|
+
} catch (e) {
|
|
19
|
+
throw n(e);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
//#endregion
|
|
25
|
+
export { a as useFundingInfo };
|
|
26
|
+
|
|
27
|
+
//# sourceMappingURL=use-funding-info.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-funding-info.js","names":[],"sources":["../../src/funding-info/use-funding-info.ts"],"sourcesContent":["\"use client\";\n\nimport {\n getFundingInfoQueryOptions,\n type ConfigParameter,\n type GetFundingInfoOptions,\n type GetFundingInfoReturnType,\n} from \"@symmio/trading-core\";\nimport { useQuery, type UseQueryResult } 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\";\n\n/**\n * Parameters for {@link useFundingInfo}: the core query options plus an optional\n * `config`.\n */\nexport type UseFundingInfoParameters = GetFundingInfoOptions & ConfigParameter;\n\n/** Return type of {@link useFundingInfo}. */\nexport type UseFundingInfoReturnType = UseQueryResult<GetFundingInfoReturnType, SymmioRequestError>;\n\n/**\n * Read per-market funding rates from the active chain's solver in one call.\n * Surfaces the next-epoch long/short funding rate, next funding time, and epoch\n * length for every market (or only the requested `symbols`).\n *\n * Does not poll by default; pass `query.refetchInterval` to opt into polling.\n *\n * @example\n * ```tsx\n * const { data } = useFundingInfo();\n * const btc = data?.find((f) => f.symbol === \"BTCUSDT\");\n * ```\n */\nexport function useFundingInfo(parameters: UseFundingInfoParameters = {}): UseFundingInfoReturnType {\n const config = useSymmioConfig(parameters);\n const chainId = useSymmioChainId();\n const options = getFundingInfoQueryOptions(config, {\n ...parameters,\n chainId: parameters.chainId ?? chainId,\n });\n\n return useQuery({\n ...options,\n queryFn: async () => {\n try {\n return await options.queryFn();\n } catch (err) {\n throw normalizeSymmError(err);\n }\n },\n }) as UseFundingInfoReturnType;\n}\n"],"mappings":";;;;;;;AAoCA,SAAgB,EAAe,IAAuC,CAAC,GAA6B;CAClG,IAAM,IAAS,EAAgB,CAAU,GACnC,IAAU,EAAiB,GAC3B,IAAU,EAA2B,GAAQ;EACjD,GAAG;EACH,SAAS,EAAW,WAAW;CACjC,CAAC;CAED,OAAO,EAAS;EACd,GAAG;EACH,SAAS,YAAY;GACnB,IAAI;IACF,OAAO,MAAM,EAAQ,QAAQ;GAC/B,SAAS,GAAK;IACZ,MAAM,EAAmB,CAAG;GAC9B;EACF;CACF,CAAC;AACH"}
|