@sodax/dapp-kit 2.0.0-rc.11 → 2.0.0-rc.13
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 +5 -5
- package/dist/index.d.ts +282 -8
- package/dist/index.mjs +290 -47
- package/package.json +2 -2
- package/src/hooks/_mutationContract.test.ts +6 -1
- package/src/hooks/bitcoin/resolveBtcReadAddress.test.ts +54 -0
- package/src/hooks/bitcoin/resolveBtcReadAddress.ts +21 -0
- package/src/hooks/bitcoin/useFundTradingWallet.ts +1 -1
- package/src/hooks/bitcoin/useRadfiAuth.ts +2 -2
- package/src/hooks/bitcoin/useRadfiWithdraw.ts +2 -2
- package/src/hooks/bitcoin/useRenewUtxos.ts +2 -2
- package/src/hooks/bitcoin/useTradingWallet.ts +1 -1
- package/src/hooks/index.ts +1 -0
- package/src/hooks/leverageYield/index.ts +9 -0
- package/src/hooks/leverageYield/useLeverageYieldDeposit.ts +40 -0
- package/src/hooks/leverageYield/useLeverageYieldEffectiveApr.ts +42 -0
- package/src/hooks/leverageYield/useLeverageYieldNotifySolver.ts +34 -0
- package/src/hooks/leverageYield/useLeverageYieldPosition.ts +40 -0
- package/src/hooks/leverageYield/useLeverageYieldPreviewRedeem.ts +43 -0
- package/src/hooks/leverageYield/useLeverageYieldShareBalances.ts +74 -0
- package/src/hooks/leverageYield/useLeverageYieldTotalAssets.ts +36 -0
- package/src/hooks/leverageYield/useLeverageYieldVaultSwap.ts +50 -0
- package/src/hooks/leverageYield/useLeverageYieldWithdraw.ts +40 -0
- package/src/hooks/mm/useATokensBalances.ts +7 -1
- package/src/hooks/mm/useUserFormattedSummary.ts +5 -1
- package/src/hooks/mm/useUserReservesData.ts +5 -1
- package/src/hooks/shared/index.ts +3 -0
- package/src/hooks/shared/useGetUserHubWalletAddress.ts +5 -1
- package/src/hooks/shared/useNearStorageCheck.ts +45 -0
- package/src/hooks/shared/useNearStorageGate.ts +60 -0
- package/src/hooks/shared/useRegisterNearStorage.ts +46 -0
- package/src/providers/SodaxProvider.tsx +2 -3
- package/src/utils/index.ts +1 -0
- package/src/utils/nearStorageGate.test.ts +46 -0
- package/src/utils/nearStorageGate.ts +39 -0
package/README.md
CHANGED
|
@@ -10,7 +10,7 @@ High-level React hooks library for dApp developers. Wraps `@sodax/sdk` with Reac
|
|
|
10
10
|
- **Staking** — `useStake`, `useUnstake`, `useInstantUnstake`, `useClaim`, `useCancelUnstake`, approval hooks, info/config/ratio queries
|
|
11
11
|
- **DEX** — `useDexDeposit`, `useDexWithdraw`, `useSupplyLiquidity`, `useDecreaseLiquidity`, `useClaimRewards`, pool/position queries, param builders
|
|
12
12
|
- **Migration** — `useMigrateIcxToSoda`, `useRevertMigrateSodaToIcx`, `useMigratebnUSD`, `useMigrateBaln`, `useMigrationApprove`, `useMigrationAllowance`
|
|
13
|
-
- **Bitcoin (
|
|
13
|
+
- **Bitcoin (Bound Exchange)** — `useRadfiAuth`, `useRadfiSession`, `useTradingWallet`, `useTradingWalletBalance`, `useBitcoinBalance`, `useFundTradingWallet`, `useRadfiWithdraw`, `useExpiredUtxos`, `useRenewUtxos`
|
|
14
14
|
- **Partner** — `useFetchAssetsBalances`, `useGetAutoSwapPreferences`, `useIsTokenApproved`, `useApproveToken`, `useSetSwapPreference`, `useFeeClaimSwap`
|
|
15
15
|
- **Recovery** — `useHubAssetBalances`, `useWithdrawHubAsset`
|
|
16
16
|
- **Backend Queries** — Intent tracking, orderbook, money market position queries
|
|
@@ -213,13 +213,13 @@ function SwapButton({ intentParams }: { intentParams: CreateIntentParams }) {
|
|
|
213
213
|
- [`useMigrationApprove()`](src/hooks/migrate/useMigrationApprove.ts) — Approve token spending before migration
|
|
214
214
|
- [`useMigrationAllowance()`](src/hooks/migrate/useMigrationAllowance.ts) — Check if approval is needed
|
|
215
215
|
|
|
216
|
-
### Bitcoin (
|
|
216
|
+
### Bitcoin (Bound Exchange) Hooks
|
|
217
217
|
|
|
218
|
-
- [`useRadfiSession()`](src/hooks/bitcoin/useRadfiSession.ts) — Manage
|
|
219
|
-
- [`useRadfiAuth()`](src/hooks/bitcoin/useRadfiAuth.ts) — Authenticate with
|
|
218
|
+
- [`useRadfiSession()`](src/hooks/bitcoin/useRadfiSession.ts) — Manage Bound Exchange session (login, auto-refresh)
|
|
219
|
+
- [`useRadfiAuth()`](src/hooks/bitcoin/useRadfiAuth.ts) — Authenticate with Bound Exchange via BIP322 signing
|
|
220
220
|
- [`useTradingWallet()`](src/hooks/bitcoin/useTradingWallet.ts) — Get trading wallet address from persisted session
|
|
221
221
|
- [`useBitcoinBalance()`](src/hooks/bitcoin/useBitcoinBalance.ts) — BTC balance for any address
|
|
222
|
-
- [`useTradingWalletBalance()`](src/hooks/bitcoin/useTradingWalletBalance.ts) — Trading wallet balance from
|
|
222
|
+
- [`useTradingWalletBalance()`](src/hooks/bitcoin/useTradingWalletBalance.ts) — Trading wallet balance from Bound Exchange API
|
|
223
223
|
- [`useFundTradingWallet()`](src/hooks/bitcoin/useFundTradingWallet.ts) — Fund trading wallet from personal wallet
|
|
224
224
|
- [`useRadfiWithdraw()`](src/hooks/bitcoin/useRadfiWithdraw.ts) — Withdraw from trading wallet
|
|
225
225
|
- [`useExpiredUtxos()`](src/hooks/bitcoin/useExpiredUtxos.ts) — Fetch expired UTXOs (polls every 60s)
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { UseMutationOptions, UseQueryOptions, UseMutationResult, MutateOptions, UseQueryResult, QueryClientConfig, QueryClient } from '@tanstack/react-query';
|
|
2
|
-
import { Result, Sodax, SpokeChainKey, GetEstimateGasReturnType, EstimateGasParams, IStellarWalletProvider, StellarChainKey, IXServiceBase, XToken, EvmHubProvider, IBitcoinWalletProvider, RadfiWalletBalance, RadfiUtxo, MoneyMarketBorrowActionParams, TxHashPair, MoneyMarketRepayActionParams, MoneyMarketSupplyActionParams, MoneyMarketWithdrawActionParams, UserReserveData, AggregatedReserveData, BaseCurrencyInfo, ReservesDataHumanized, Address as Address$1, MoneyMarketParams, MoneyMarketApproveActionParams, TxReturnType, Erc20Token, ChainKey, ReserveDataHumanized, FormatReserveUSDResponse, FormatUserSummaryResponse, SolverIntentQuoteResponse, SolverErrorResponse, SolverIntentQuoteRequest, SwapActionParams, SwapResponse, SolverIntentStatusResponse, Hex, CreateIntentParams, CreateLimitOrderParams,
|
|
2
|
+
import { Result, Sodax, SpokeChainKey, GetEstimateGasReturnType, EstimateGasParams, IStellarWalletProvider, StellarChainKey, INearWalletProvider, GetWalletProviderType, IXServiceBase, XToken, EvmHubProvider, IBitcoinWalletProvider, RadfiWalletBalance, RadfiUtxo, MoneyMarketBorrowActionParams, TxHashPair, MoneyMarketRepayActionParams, MoneyMarketSupplyActionParams, MoneyMarketWithdrawActionParams, UserReserveData, AggregatedReserveData, BaseCurrencyInfo, ReservesDataHumanized, Address as Address$1, MoneyMarketParams, MoneyMarketApproveActionParams, TxReturnType, Erc20Token, ChainKey, ReserveDataHumanized, FormatReserveUSDResponse, FormatUserSummaryResponse, SolverIntentQuoteResponse, SolverErrorResponse, SolverIntentQuoteRequest, SwapActionParams, SwapResponse, SolverIntentStatusResponse, Hex, CreateIntentParams, CreateLimitOrderParams, Intent, LimitOrderActionParams, IntentResponse, UserIntentsResponse, SubmitSwapTxResponse, SubmitSwapTxRequest, RequestOverrideConfig, SubmitSwapTxStatusResponse, OrderbookResponse, MoneyMarketPosition, MoneyMarketAsset, MoneyMarketAssetBorrowers, MoneyMarketAssetSuppliers, MoneyMarketBorrowers, BridgeParams, CreateBridgeIntentParams, BridgeLimit, StakeAction, StakeParams, UnstakeAction, ClaimAction, CancelUnstakeAction, StakingInfo, UnstakingInfo, UnstakeRequestWithPenalty, StakingConfig, InstantUnstakeAction, UnstakeParams, InstantUnstakeParams, PartnerFeeClaimAssetBalance, AutoSwapPreferences, FeeTokenApproveParams, FeeTokenApproveAction, HubChainKey, SetSwapPreferenceAction, PartnerFeeClaimSwapAction, IntentAutoSwapResult, HubAssetBalance, WithdrawHubAssetAction, IcxMigrateAction, IcxRevertMigrationAction, UnifiedBnUSDMigrateAction, BalnMigrateAction, MigrationAction, IcxMigrateParams, IcxCreateRevertMigrationParams, UnifiedBnUSDMigrateParams, BalnMigrateParams, PoolKey, PoolData, ClPositionInfo, AssetDepositAction, AssetWithdrawAction, CreateAssetDepositParams, ClSupplyParams, ClIncreaseLiquidityParams, ClLiquidityDecreaseLiquidityAction, ClDecreaseLiquidityParams, CreateAssetWithdrawParams, PoolSpokeAssets, DestinationParamsType, ClLiquidityClaimRewardsAction, LeverageYieldEffectiveApr, LeverageYieldPosition, LeverageYieldSwapDepositParams, LeverageYieldSwapPayload, SolverExecutionRequest, SolverExecutionResponse, VaultSwapActionParams, VaultSwapResponse, LeverageYieldSwapWithdrawParams, SodaxOptions } from '@sodax/sdk';
|
|
3
3
|
export * from '@sodax/sdk';
|
|
4
4
|
import { Address } from 'viem';
|
|
5
5
|
import { ReactNode, ReactElement } from 'react';
|
|
@@ -151,6 +151,72 @@ declare function useRequestTrustline(token: string | undefined): {
|
|
|
151
151
|
data: string | null;
|
|
152
152
|
};
|
|
153
153
|
|
|
154
|
+
type UseNearStorageCheckParams = ReadHookParams<boolean, {
|
|
155
|
+
token: string | undefined;
|
|
156
|
+
accountId: string | undefined;
|
|
157
|
+
chainId: SpokeChainKey | undefined;
|
|
158
|
+
}>;
|
|
159
|
+
/**
|
|
160
|
+
* Whether `accountId` is NEP-141 storage-registered for `token` on NEAR — the receive-side
|
|
161
|
+
* prerequisite for any leg that delivers a token to the user on NEAR (swap output on NEAR, bridge
|
|
162
|
+
* into NEAR, money-market borrow/withdraw to NEAR). NEAR's analogue of a Stellar trustline.
|
|
163
|
+
*
|
|
164
|
+
* Returns `true` (no gate) when `chainId` is not NEAR, mirroring how the Stellar trustline check
|
|
165
|
+
* short-circuits off-chain. Native NEAR is not a NEP-141 token, so the SDK reports it as registered.
|
|
166
|
+
*
|
|
167
|
+
* Pair with {@link useRegisterNearStorage} to perform the one-time `storage_deposit` when this
|
|
168
|
+
* resolves to `false`.
|
|
169
|
+
*/
|
|
170
|
+
declare function useNearStorageCheck({ params, queryOptions, }?: UseNearStorageCheckParams): UseQueryResult<boolean, Error>;
|
|
171
|
+
|
|
172
|
+
type UseRegisterNearStorageVars = {
|
|
173
|
+
token: string;
|
|
174
|
+
accountId: string;
|
|
175
|
+
walletProvider: INearWalletProvider;
|
|
176
|
+
/** Storage bond override; defaults to the SDK's `NEAR_STORAGE_DEPOSIT` (0.00125 NEAR). */
|
|
177
|
+
deposit?: bigint;
|
|
178
|
+
};
|
|
179
|
+
/**
|
|
180
|
+
* Submit a NEP-141 `storage_deposit` so `accountId` can receive `token` on NEAR. NEAR's analogue of
|
|
181
|
+
* requesting a Stellar trustline; pair with {@link useNearStorageCheck} and call this when the check
|
|
182
|
+
* resolves to `false`. The recipient's NEAR wallet signs the registration tx.
|
|
183
|
+
*
|
|
184
|
+
* Pure mutation: pass `{ token, accountId, walletProvider }` to `mutate(...)`. The hook itself only
|
|
185
|
+
* takes the structural `mutationOptions` slot. `registerStorage` throws natively (no `Result<T>`),
|
|
186
|
+
* so this hook is registered as `nativeThrow` in the mutation contract. On success it invalidates
|
|
187
|
+
* the matching {@link useNearStorageCheck} query.
|
|
188
|
+
*/
|
|
189
|
+
declare function useRegisterNearStorage({ mutationOptions, }?: MutationHookParams<string, UseRegisterNearStorageVars>): SafeUseMutationResult<string, Error, UseRegisterNearStorageVars>;
|
|
190
|
+
|
|
191
|
+
interface UseNearStorageGateParams {
|
|
192
|
+
/** Destination chain the token is delivered on. */
|
|
193
|
+
dstChainKey: SpokeChainKey;
|
|
194
|
+
/** Destination token address the recipient must be registered for. */
|
|
195
|
+
token: string | undefined;
|
|
196
|
+
/** Recipient NEAR account id. */
|
|
197
|
+
accountId: string | undefined;
|
|
198
|
+
/** Destination wallet provider; only consumed when it is the NEAR provider. */
|
|
199
|
+
walletProvider: GetWalletProviderType<SpokeChainKey> | undefined;
|
|
200
|
+
}
|
|
201
|
+
interface NearStorageGate {
|
|
202
|
+
/** Destination is NEAR. */
|
|
203
|
+
isNear: boolean;
|
|
204
|
+
/** Destination is NEAR and the recipient is not yet storage-registered for `token`. */
|
|
205
|
+
needsRegistration: boolean;
|
|
206
|
+
/** The downstream action must stay disabled while the gate is unresolved or unmet. */
|
|
207
|
+
blocksAction: boolean;
|
|
208
|
+
/** The registration-status query is actively fetching. */
|
|
209
|
+
isChecking: boolean;
|
|
210
|
+
/** A `storage_deposit` tx is in flight. */
|
|
211
|
+
isRegistering: boolean;
|
|
212
|
+
/** Submit the `storage_deposit`; resolves to the SDK `Result` or `undefined` if inputs are missing. */
|
|
213
|
+
registerStorage: () => Promise<Result<string> | undefined>;
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* NEP-141 storage-registration gate for flows that deliver a token to a user on NEAR.
|
|
217
|
+
*/
|
|
218
|
+
declare function useNearStorageGate({ dstChainKey, token, accountId, walletProvider, }: UseNearStorageGateParams): NearStorageGate;
|
|
219
|
+
|
|
154
220
|
type UseGetUserHubWalletAddressParams = ReadHookParams<Address, {
|
|
155
221
|
spokeChainId?: SpokeChainKey;
|
|
156
222
|
spokeAddress?: string;
|
|
@@ -228,7 +294,7 @@ declare function saveRadfiSession(address: string, session: RadfiSession): void;
|
|
|
228
294
|
declare function loadRadfiSession(address: string): RadfiSession | null;
|
|
229
295
|
declare function clearRadfiSession(address: string): void;
|
|
230
296
|
/**
|
|
231
|
-
* React hook for authenticating with
|
|
297
|
+
* React hook for authenticating with Bound Exchange via BIP322-signed message. Pure mutation: pass
|
|
232
298
|
* `{ walletProvider }` to `mutate({...})`. The hook itself takes no arguments other than the
|
|
233
299
|
* structural `mutationOptions` slot.
|
|
234
300
|
*/
|
|
@@ -248,7 +314,7 @@ type UseFundTradingWalletVars = {
|
|
|
248
314
|
walletProvider: IBitcoinWalletProvider;
|
|
249
315
|
};
|
|
250
316
|
/**
|
|
251
|
-
* React hook for funding the user's
|
|
317
|
+
* React hook for funding the user's Bound Exchange trading wallet from their personal Bitcoin wallet.
|
|
252
318
|
* Pure mutation: pass `{ amount, walletProvider }` to `mutate({...})`. Returns the broadcast tx
|
|
253
319
|
* id on success.
|
|
254
320
|
*/
|
|
@@ -271,7 +337,7 @@ type UseTradingWalletReturn = {
|
|
|
271
337
|
tradingAddress: string | undefined;
|
|
272
338
|
};
|
|
273
339
|
/**
|
|
274
|
-
* Returns the
|
|
340
|
+
* Returns the Bound Exchange trading wallet address from the persisted session.
|
|
275
341
|
* Trading wallet is created automatically during authentication — no API call needed.
|
|
276
342
|
*/
|
|
277
343
|
declare function useTradingWallet(walletAddress: string | undefined): UseTradingWalletReturn;
|
|
@@ -293,7 +359,7 @@ type UseRenewUtxosVars = {
|
|
|
293
359
|
walletProvider: IBitcoinWalletProvider;
|
|
294
360
|
};
|
|
295
361
|
/**
|
|
296
|
-
* React hook for renewing expired UTXOs in the user's
|
|
362
|
+
* React hook for renewing expired UTXOs in the user's Bound Exchange trading wallet. Pure mutation: pass
|
|
297
363
|
* `{ txIdVouts, walletProvider }` to `mutate({...})`.
|
|
298
364
|
*/
|
|
299
365
|
declare function useRenewUtxos({ mutationOptions, }?: MutationHookParams<string, UseRenewUtxosVars>): SafeUseMutationResult<string, Error, UseRenewUtxosVars>;
|
|
@@ -309,7 +375,7 @@ type WithdrawResult = {
|
|
|
309
375
|
fee: number;
|
|
310
376
|
};
|
|
311
377
|
/**
|
|
312
|
-
* React hook for withdrawing BTC from the user's
|
|
378
|
+
* React hook for withdrawing BTC from the user's Bound Exchange trading wallet back to their personal
|
|
313
379
|
* Bitcoin wallet. Pure mutation: pass all inputs (including the wallet provider) to
|
|
314
380
|
* `mutate({...})`.
|
|
315
381
|
*/
|
|
@@ -1475,6 +1541,188 @@ type UseClaimRewardsVars<K extends SpokeChainKey = SpokeChainKey> = Omit<ClLiqui
|
|
|
1475
1541
|
*/
|
|
1476
1542
|
declare function useClaimRewards<K extends SpokeChainKey = SpokeChainKey>({ mutationOptions, }?: MutationHookParams<TxHashPair, UseClaimRewardsVars<K>>): SafeUseMutationResult<TxHashPair, Error, UseClaimRewardsVars<K>>;
|
|
1477
1543
|
|
|
1544
|
+
type UseLeverageYieldEffectiveAprParams = ReadHookParams<LeverageYieldEffectiveApr, {
|
|
1545
|
+
vault: Address$1 | undefined;
|
|
1546
|
+
}>;
|
|
1547
|
+
/**
|
|
1548
|
+
* Reads a leverage-yield vault's effective APR — AAVE supply/borrow rates plus the LSD
|
|
1549
|
+
* staking yield, with the vault's leverage formula re-applied on the boosted supply side.
|
|
1550
|
+
*
|
|
1551
|
+
* The underlying SDK call does the on-chain reads (AAVE rates + `targetLTV`) and the
|
|
1552
|
+
* off-chain LSD fetch in parallel. Rates drift slowly, so the default refresh is 60s.
|
|
1553
|
+
*
|
|
1554
|
+
* @example
|
|
1555
|
+
* ```typescript
|
|
1556
|
+
* const { data: apr } = useLeverageYieldEffectiveApr({ params: { vault: vault.vault } });
|
|
1557
|
+
* ```
|
|
1558
|
+
*/
|
|
1559
|
+
declare function useLeverageYieldEffectiveApr({ params, queryOptions, }?: UseLeverageYieldEffectiveAprParams): UseQueryResult<LeverageYieldEffectiveApr, Error>;
|
|
1560
|
+
|
|
1561
|
+
type UseLeverageYieldPositionParams = ReadHookParams<LeverageYieldPosition, {
|
|
1562
|
+
vault: Address$1 | undefined;
|
|
1563
|
+
}>;
|
|
1564
|
+
/**
|
|
1565
|
+
* Reads a leverage-yield vault's live position snapshot via the vault's `getPositionDetails`:
|
|
1566
|
+
* collateral, debt, current LTV (drift vs `targetLTV`), health factor (∞ when no debt), and
|
|
1567
|
+
* idle (not-yet-deployed) asset.
|
|
1568
|
+
*
|
|
1569
|
+
* LTV shifts with each rebalance/rate tick, so the default refresh (30s) is faster than the
|
|
1570
|
+
* APR/stats reads.
|
|
1571
|
+
*
|
|
1572
|
+
* @example
|
|
1573
|
+
* ```typescript
|
|
1574
|
+
* const { data: position } = useLeverageYieldPosition({ params: { vault: vault.vault } });
|
|
1575
|
+
* ```
|
|
1576
|
+
*/
|
|
1577
|
+
declare function useLeverageYieldPosition({ params, queryOptions, }?: UseLeverageYieldPositionParams): UseQueryResult<LeverageYieldPosition, Error>;
|
|
1578
|
+
|
|
1579
|
+
type UseLeverageYieldTotalAssetsParams = ReadHookParams<bigint, {
|
|
1580
|
+
vault: Address$1 | undefined;
|
|
1581
|
+
}>;
|
|
1582
|
+
/**
|
|
1583
|
+
* Reads a leverage-yield vault's total underlying assets (vault-asset units, 18 decimals) —
|
|
1584
|
+
* i.e. its TVL. Moves slowly, so the default refresh is 60s.
|
|
1585
|
+
*
|
|
1586
|
+
* @example
|
|
1587
|
+
* ```typescript
|
|
1588
|
+
* const { data: tvl } = useLeverageYieldTotalAssets({ params: { vault: vault.vault } });
|
|
1589
|
+
* ```
|
|
1590
|
+
*/
|
|
1591
|
+
declare function useLeverageYieldTotalAssets({ params, queryOptions, }?: UseLeverageYieldTotalAssetsParams): UseQueryResult<bigint, Error>;
|
|
1592
|
+
|
|
1593
|
+
type UseLeverageYieldPreviewRedeemParams = ReadHookParams<bigint, {
|
|
1594
|
+
vault: Address$1 | undefined;
|
|
1595
|
+
shares: bigint | undefined;
|
|
1596
|
+
}>;
|
|
1597
|
+
/**
|
|
1598
|
+
* Reads the assets received for redeeming `shares` of a leverage-yield vault (ERC-4626
|
|
1599
|
+
* `previewRedeem`). Passing `10n ** 18n` (one share) yields the per-share price that creeps
|
|
1600
|
+
* up as the vault accrues interest. Moves slowly, so the default refresh is 60s.
|
|
1601
|
+
*
|
|
1602
|
+
* @example
|
|
1603
|
+
* ```typescript
|
|
1604
|
+
* const { data: sharePrice } = useLeverageYieldPreviewRedeem({
|
|
1605
|
+
* params: { vault: vault.vault, shares: 10n ** 18n },
|
|
1606
|
+
* });
|
|
1607
|
+
* ```
|
|
1608
|
+
*/
|
|
1609
|
+
declare function useLeverageYieldPreviewRedeem({ params, queryOptions, }?: UseLeverageYieldPreviewRedeemParams): UseQueryResult<bigint, Error>;
|
|
1610
|
+
|
|
1611
|
+
/** A single `(chain, hub-wallet holder, share balance)` row produced by {@link useLeverageYieldShareBalances}. */
|
|
1612
|
+
type LeverageYieldShareHolding = {
|
|
1613
|
+
chainKey: SpokeChainKey;
|
|
1614
|
+
holder: Address$1;
|
|
1615
|
+
shares: bigint;
|
|
1616
|
+
};
|
|
1617
|
+
/** A `(chainKey, EOA address)` pair the user controls — one per spoke chain they may hold shares under. */
|
|
1618
|
+
type LeverageYieldShareHolder = {
|
|
1619
|
+
chainKey: SpokeChainKey;
|
|
1620
|
+
address: string;
|
|
1621
|
+
};
|
|
1622
|
+
type UseLeverageYieldShareBalancesParams = ReadHookParams<LeverageYieldShareHolding, {
|
|
1623
|
+
vault: Address$1 | undefined;
|
|
1624
|
+
holders: readonly LeverageYieldShareHolder[] | undefined;
|
|
1625
|
+
}>;
|
|
1626
|
+
/**
|
|
1627
|
+
* Reads a user's leverage-vault share (`lsoda*`) balances across every chain they may hold a
|
|
1628
|
+
* position under — one query per holder, fanned out via `useQueries`.
|
|
1629
|
+
*
|
|
1630
|
+
* For each `(chainKey, address)` the holder is resolved to the address that actually owns the
|
|
1631
|
+
* shares: the user's **derived hub wallet** on every chain, including the hub itself. Leverage
|
|
1632
|
+
* deposits always deliver `lsoda*` to `getUserHubWalletAddress(srcAddress, srcChainKey)` (the
|
|
1633
|
+
* CREATE3 user-router on Sonic for a hub-sourced deposit, the per-spoke hub wallet otherwise) —
|
|
1634
|
+
* never the bare EOA — so a hub-chain deposit's shares live in the router, not the signing EOA.
|
|
1635
|
+
* Resolving the holder the same way the deposit does is what makes a Sonic-sourced position show
|
|
1636
|
+
* up here instead of reading a stale zero off the EOA.
|
|
1637
|
+
*
|
|
1638
|
+
* Returns the raw `useQueries` result array (15s refresh per query); callers aggregate as needed
|
|
1639
|
+
* (e.g. sum `shares` for a headline total, or pick the row for the active chain).
|
|
1640
|
+
*
|
|
1641
|
+
* `useQueries` has no top-level options slot, so `queryOptions` is spread into every individual
|
|
1642
|
+
* query config (and applies uniformly to each holder's query).
|
|
1643
|
+
*
|
|
1644
|
+
* @example
|
|
1645
|
+
* ```typescript
|
|
1646
|
+
* const balances = useLeverageYieldShareBalances({ params: { vault: vault.vault, holders } });
|
|
1647
|
+
* const total = balances.reduce((acc, q) => acc + (q.data?.shares ?? 0n), 0n);
|
|
1648
|
+
* ```
|
|
1649
|
+
*/
|
|
1650
|
+
declare function useLeverageYieldShareBalances({ params, queryOptions, }?: UseLeverageYieldShareBalancesParams): UseQueryResult<LeverageYieldShareHolding, Error>[];
|
|
1651
|
+
|
|
1652
|
+
/** Mutation variables for {@link useLeverageYieldDeposit} — the swap-style deposit inputs. */
|
|
1653
|
+
type UseLeverageYieldDepositVars = LeverageYieldSwapDepositParams;
|
|
1654
|
+
/**
|
|
1655
|
+
* Builds the `LeverageYieldSwapPayload` for a leverage-yield deposit (any token → `lsoda*` shares,
|
|
1656
|
+
* delivered to the user's hub wallet). Spread the returned payload into
|
|
1657
|
+
* {@link useLeverageYieldVaultSwap}.
|
|
1658
|
+
*
|
|
1659
|
+
* This is a builder, not an executor — it derives the hub wallet and assembles the intent; the
|
|
1660
|
+
* actual swap is relayed by `useLeverageYieldVaultSwap`. Throws on SDK failure so React Query's
|
|
1661
|
+
* error model engages; returns the unwrapped `LeverageYieldSwapPayload` on success.
|
|
1662
|
+
*
|
|
1663
|
+
* @example
|
|
1664
|
+
* ```typescript
|
|
1665
|
+
* const { mutateAsyncSafe: buildDeposit } = useLeverageYieldDeposit();
|
|
1666
|
+
* const built = await buildDeposit({ vault, srcChainKey, srcAddress, inputToken, inputAmount, minOutputAmount });
|
|
1667
|
+
* if (built.ok) vaultSwap({ ...built.value, walletProvider });
|
|
1668
|
+
* ```
|
|
1669
|
+
*/
|
|
1670
|
+
declare function useLeverageYieldDeposit({ mutationOptions, }?: MutationHookParams<LeverageYieldSwapPayload, UseLeverageYieldDepositVars>): SafeUseMutationResult<LeverageYieldSwapPayload, Error, UseLeverageYieldDepositVars>;
|
|
1671
|
+
|
|
1672
|
+
/** Mutation variables for {@link useLeverageYieldNotifySolver} — the hub-side intent tx hash. */
|
|
1673
|
+
type UseLeverageYieldNotifySolverVars = SolverExecutionRequest;
|
|
1674
|
+
/**
|
|
1675
|
+
* Notifies the solver that a leverage-yield vault intent landed on the hub, triggering the fill.
|
|
1676
|
+
* The standalone notify step for the manual create → relay → notify flow: build the intent with
|
|
1677
|
+
* `sodax.leverageYield.createVaultIntent`, relay it yourself, then call this with the hub-side
|
|
1678
|
+
* intent tx hash. The end-to-end {@link useLeverageYieldVaultSwap} already calls notifySolver
|
|
1679
|
+
* internally — only reach for this hook when driving the relay manually.
|
|
1680
|
+
*
|
|
1681
|
+
* Throws on SDK failure so React Query's error model engages; returns the unwrapped
|
|
1682
|
+
* `SolverExecutionResponse` (`{ answer: 'OK', intent_hash }`) on success.
|
|
1683
|
+
*/
|
|
1684
|
+
declare function useLeverageYieldNotifySolver({ mutationOptions, }?: MutationHookParams<SolverExecutionResponse, UseLeverageYieldNotifySolverVars>): SafeUseMutationResult<SolverExecutionResponse, Error, UseLeverageYieldNotifySolverVars>;
|
|
1685
|
+
|
|
1686
|
+
/**
|
|
1687
|
+
* Mutation variables for {@link useLeverageYieldVaultSwap}. Generic over `K extends SpokeChainKey`
|
|
1688
|
+
* (defaults to the full union). Sophisticated callers can lock K at the hook call site to narrow
|
|
1689
|
+
* the `walletProvider` and `params.srcChainKey` types.
|
|
1690
|
+
*/
|
|
1691
|
+
type UseLeverageYieldVaultSwapVars<K extends SpokeChainKey = SpokeChainKey> = Omit<VaultSwapActionParams<K, false>, 'raw'>;
|
|
1692
|
+
/**
|
|
1693
|
+
* React hook for executing an end-to-end leverage-yield vault swap (deposit or withdraw).
|
|
1694
|
+
*
|
|
1695
|
+
* Spread a `LeverageYieldSwapPayload` built by {@link useLeverageYieldDeposit} /
|
|
1696
|
+
* {@link useLeverageYieldWithdraw} into `mutate` alongside the wallet provider:
|
|
1697
|
+
* `vaultSwap({ ...payload, walletProvider })`. Runs `sodax.leverageYield.vaultSwap` —
|
|
1698
|
+
* create intent → verify → relay → notify solver — so vault flows never touch the
|
|
1699
|
+
* generic swap surface.
|
|
1700
|
+
*
|
|
1701
|
+
* Throws on SDK failure so React Query's native error model engages (`isError`, `error`,
|
|
1702
|
+
* `onError`, `retry`). Returns the unwrapped `VaultSwapResponse` on success.
|
|
1703
|
+
*/
|
|
1704
|
+
declare function useLeverageYieldVaultSwap<K extends SpokeChainKey = SpokeChainKey>({ mutationOptions, }?: MutationHookParams<VaultSwapResponse, UseLeverageYieldVaultSwapVars<K>>): SafeUseMutationResult<VaultSwapResponse, Error, UseLeverageYieldVaultSwapVars<K>>;
|
|
1705
|
+
|
|
1706
|
+
/** Mutation variables for {@link useLeverageYieldWithdraw} — the swap-style withdraw inputs. */
|
|
1707
|
+
type UseLeverageYieldWithdrawVars = LeverageYieldSwapWithdrawParams;
|
|
1708
|
+
/**
|
|
1709
|
+
* Builds the `LeverageYieldSwapPayload` for a leverage-yield withdraw (`lsoda*` shares → any token).
|
|
1710
|
+
* The returned payload carries `hubWalletSwap: true`; spread it into
|
|
1711
|
+
* {@link useLeverageYieldVaultSwap}, which authorises the hub wallet to spend the shares via a
|
|
1712
|
+
* `Connection.sendMessage`.
|
|
1713
|
+
*
|
|
1714
|
+
* This is a builder, not an executor. Throws on SDK failure so React Query's error model engages;
|
|
1715
|
+
* returns the unwrapped `LeverageYieldSwapPayload` on success.
|
|
1716
|
+
*
|
|
1717
|
+
* @example
|
|
1718
|
+
* ```typescript
|
|
1719
|
+
* const { mutateAsyncSafe: buildWithdraw } = useLeverageYieldWithdraw();
|
|
1720
|
+
* const built = await buildWithdraw({ vault, srcChainKey, srcAddress, dstChainKey, outputToken, inputAmount, minOutputAmount });
|
|
1721
|
+
* if (built.ok) vaultSwap({ ...built.value, walletProvider });
|
|
1722
|
+
* ```
|
|
1723
|
+
*/
|
|
1724
|
+
declare function useLeverageYieldWithdraw({ mutationOptions, }?: MutationHookParams<LeverageYieldSwapPayload, UseLeverageYieldWithdrawVars>): SafeUseMutationResult<LeverageYieldSwapPayload, Error, UseLeverageYieldWithdrawVars>;
|
|
1725
|
+
|
|
1478
1726
|
interface SodaxProviderProps {
|
|
1479
1727
|
children: ReactNode;
|
|
1480
1728
|
/**
|
|
@@ -1489,7 +1737,7 @@ interface SodaxProviderProps {
|
|
|
1489
1737
|
* <SodaxProvider config={config}>...</SodaxProvider>
|
|
1490
1738
|
* ```
|
|
1491
1739
|
*/
|
|
1492
|
-
config?:
|
|
1740
|
+
config?: SodaxOptions;
|
|
1493
1741
|
}
|
|
1494
1742
|
/** Root provider for `@sodax/dapp-kit`. Must be paired with `QueryClientProvider`. */
|
|
1495
1743
|
declare const SodaxProvider: ({ children, config }: SodaxProviderProps) => ReactElement;
|
|
@@ -1554,4 +1802,30 @@ type CreateSodaxQueryClientOptions = {
|
|
|
1554
1802
|
*/
|
|
1555
1803
|
declare function createSodaxQueryClient({ onMutationError, config, }?: CreateSodaxQueryClientOptions): QueryClient;
|
|
1556
1804
|
|
|
1557
|
-
|
|
1805
|
+
/** The subset of a `useNearStorageCheck` result the gate reads. A full `UseQueryResult<boolean>` satisfies it. */
|
|
1806
|
+
type NearStorageCheckResult = Pick<UseQueryResult<boolean>, 'isLoading' | 'data'>;
|
|
1807
|
+
/** UI gate state for NEP-141 storage registration on NEAR. */
|
|
1808
|
+
interface NearStorageGateState {
|
|
1809
|
+
/** Destination is NEAR — the only chain with a NEP-141 storage-registration prerequisite. */
|
|
1810
|
+
isNear: boolean;
|
|
1811
|
+
/** Show the "register storage" action: the check resolved and the recipient is not registered. */
|
|
1812
|
+
needsRegistration: boolean;
|
|
1813
|
+
/**
|
|
1814
|
+
* Keep the downstream action (swap/bridge/borrow/withdraw) disabled: the NEAR gate is unresolved
|
|
1815
|
+
* (still checking) or unmet (needs registration).
|
|
1816
|
+
*/
|
|
1817
|
+
blocksAction: boolean;
|
|
1818
|
+
}
|
|
1819
|
+
/**
|
|
1820
|
+
* Derives the NEP-141 storage-registration UI gate state for a flow that delivers a token to a user
|
|
1821
|
+
* on NEAR — NEAR's analogue of the Stellar trustline gate. Unwrapped (no hook): pass the destination
|
|
1822
|
+
* `chainKey` and the `useNearStorageCheck` result; the util owns the `=== NEAR` test and reads
|
|
1823
|
+
* `isLoading` (NOT `isPending`, which stays `true` for a disabled query and would block forever).
|
|
1824
|
+
*
|
|
1825
|
+
* `blocksAction` deliberately also covers the in-flight check window so the action can't be
|
|
1826
|
+
* triggered before registration status is known; `needsRegistration` only flips once the check has
|
|
1827
|
+
* resolved (so the "register" button isn't shown speculatively while still checking).
|
|
1828
|
+
*/
|
|
1829
|
+
declare function resolveNearStorageGate(chainKey: SpokeChainKey, check: NearStorageCheckResult): NearStorageGateState;
|
|
1830
|
+
|
|
1831
|
+
export { type ATokenData, type BackendPaginationParams, type CreateSodaxQueryClientOptions, type DecreaseLiquidityParamsCore, type DepositParamsCore, type LeverageYieldShareHolder, type LeverageYieldShareHolding, type MutationHookOptions, type MutationHookParams, type NearStorageCheckResult, type NearStorageGateState, type RadfiSession, type ReadHookParams, type ReadQueryOptions, type ReserveUsdFormat, type SafeUseMutationResult, SodaxProvider, type UseATokenParams, type UseATokensBalancesParams, type UseApproveTokenVars, type UseBitcoinBalanceParams, type UseBorrowVars, type UseBridgeAllowanceParams, type UseBridgeApproveVars, type UseBridgeVars, type UseClaimRewardsVars, type UseCreateDecreaseLiquidityParamsProps, type UseCreateDepositParamsProps, type UseCreateLimitOrderVars, type UseCreateSupplyLiquidityParamsProps, type UseCreateSupplyLiquidityParamsResult, type UseCreateWithdrawParamsProps, type UseDecreaseLiquidityVars, type UseDeriveUserWalletAddressParams, type UseDexAllowanceParams, type UseDexApproveVars, type UseDexDepositVars, type UseDexWithdrawVars, type UseExpiredUtxosParams, type UseFeeClaimSwapVars, type UseFetchAssetsBalancesParams, type UseFundTradingWalletVars, type UseGetAutoSwapPreferencesParams, type UseGetBridgeableAmountParams, type UseGetBridgeableTokensParams, type UseGetUserHubWalletAddressParams, type UseHubAssetBalancesParams, type UseIsTokenApprovedParams, type UseLeverageYieldDepositVars, type UseLeverageYieldEffectiveAprParams, type UseLeverageYieldNotifySolverVars, type UseLeverageYieldPositionParams, type UseLeverageYieldPreviewRedeemParams, type UseLeverageYieldShareBalancesParams, type UseLeverageYieldTotalAssetsParams, type UseLeverageYieldVaultSwapVars, type UseLeverageYieldWithdrawVars, type UseLiquidityAmountsResult, type UseMMAllowanceParams, type UseMMApproveVars, type UseMigrateBalnVars, type UseMigrateIcxToSodaVars, type UseMigratebnUSDVars, type UseMigrationAllowanceInputs, type UseMigrationAllowanceParams, type UseMigrationApproveVars, type UseNearStorageCheckParams, type UsePoolBalancesParams, type UsePoolBalancesResponse, type UsePoolDataParams, type UsePoolsParams, type UsePositionInfoParams, type UsePositionInfoResponse, type UseQuoteParams, type UseRadfiAuthVars, type UseRadfiSessionReturn, type UseRadfiWithdrawVars, type UseRegisterNearStorageVars, type UseRenewUtxosVars, type UseRepayVars, type UseReservesDataParams, type UseReservesHumanizedParams, type UseReservesListParams, type UseReservesUsdFormatParams, type UseRevertMigrateSodaToIcxVars, type UseSetSwapPreferenceVars, type UseSetSwapPreferenceVarsHub, type UseStatusParams, type UseStellarTrustlineCheckParams, type UseSupplyLiquidityVars, type UseSupplyVars, type UseSwapAllowanceParams, type UseSwapApproveVars, type UseSwapVars, type UseTradingWalletBalanceParams, type UseUserFormattedSummaryParams, type UseUserReservesDataParams, type UseWithdrawHubAssetVars, type UseWithdrawVars, type UseXBalancesParams, type WithdrawParamsCore, type XBalancesInputs, clearRadfiSession, createDecreaseLiquidityParamsProps, createDepositParamsProps, createSodaxQueryClient, createSupplyLiquidityParamsProps, createWithdrawParamsProps, getXBalancesQueryOptions, loadRadfiSession, resolveNearStorageGate, saveRadfiSession, toResult, unwrapResult, useAToken, useATokensBalances, useApproveToken, useBackendAllMoneyMarketAssets, useBackendAllMoneyMarketBorrowers, useBackendIntentByHash, useBackendIntentByTxHash, useBackendMoneyMarketAsset, useBackendMoneyMarketAssetBorrowers, useBackendMoneyMarketAssetSuppliers, useBackendMoneyMarketPosition, useBackendOrderbook, useBackendSubmitSwapTx, useBackendSubmitSwapTxStatus, useBackendUserIntents, useBitcoinBalance, useBorrow, useBridge, useBridgeAllowance, useBridgeApprove, useCancelLimitOrder, useCancelSwap, useCancelUnstake, useClaim, useClaimRewards, useConvertedAssets, useCreateDecreaseLiquidityParams, useCreateDepositParams, useCreateLimitOrder, useCreateSupplyLiquidityParams, useCreateWithdrawParams, useDecreaseLiquidity, useDeriveUserWalletAddress, useDexAllowance, useDexApprove, useDexDeposit, useDexWithdraw, useEstimateGas, useExpiredUtxos, useFeeClaimSwap, useFetchAssetsBalances, useFundTradingWallet, useGetAutoSwapPreferences, useGetBridgeableAmount, useGetBridgeableTokens, useGetUserHubWalletAddress, useHubAssetBalances, useHubProvider, useInstantUnstake, useInstantUnstakeAllowance, useInstantUnstakeApprove, useInstantUnstakeRatio, useIsTokenApproved, useLeverageYieldDeposit, useLeverageYieldEffectiveApr, useLeverageYieldNotifySolver, useLeverageYieldPosition, useLeverageYieldPreviewRedeem, useLeverageYieldShareBalances, useLeverageYieldTotalAssets, useLeverageYieldVaultSwap, useLeverageYieldWithdraw, useLiquidityAmounts, useMMAllowance, useMMApprove, useMigrateBaln, useMigrateIcxToSoda, useMigratebnUSD, useMigrationAllowance, useMigrationApprove, useNearStorageCheck, useNearStorageGate, usePoolBalances, usePoolData, usePools, usePositionInfo, useQuote, useRadfiAuth, useRadfiSession, useRadfiWithdraw, useRegisterNearStorage, useRenewUtxos, useRepay, useRequestTrustline, useReservesData, useReservesHumanized, useReservesList, useReservesUsdFormat, useRevertMigrateSodaToIcx, useSafeMutation, useSetSwapPreference, useSodaxContext, useStake, useStakeAllowance, useStakeApprove, useStakeRatio, useStakingConfig, useStakingInfo, useStatus, useStellarTrustlineCheck, useSupply, useSupplyLiquidity, useSwap, useSwapAllowance, useSwapApprove, useTradingWallet, useTradingWalletBalance, useUnstake, useUnstakeAllowance, useUnstakeApprove, useUnstakingInfo, useUnstakingInfoWithPenalty, useUserFormattedSummary, useUserReservesData, useWithdraw, useWithdrawHubAsset, useXBalances };
|