@sodax/dapp-kit 2.4.0-rc.2 → 2.4.0-rc.3
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 +1 -1
- package/dist/index.d.ts +279 -2428
- package/dist/index.mjs +15 -24
- package/package.json +2 -2
- package/src/hooks/_apiKeyWire.test.ts +4 -29
- package/src/hooks/_mutationContract.test.ts +1 -8
- package/src/hooks/backend/index.ts +0 -13
- package/src/hooks/backend/useBackendAllMoneyMarketAssets.ts +0 -6
- package/src/hooks/backend/useBackendAllMoneyMarketBorrowers.ts +0 -10
- package/src/hooks/backend/useBackendIntentByHash.ts +0 -6
- package/src/hooks/backend/useBackendIntentByTxHash.ts +1 -10
- package/src/hooks/backend/useBackendMoneyMarketAsset.ts +0 -6
- package/src/hooks/backend/useBackendMoneyMarketAssetBorrowers.ts +0 -8
- package/src/hooks/backend/useBackendMoneyMarketAssetSuppliers.ts +0 -8
- package/src/hooks/backend/useBackendMoneyMarketPosition.ts +0 -6
- package/src/hooks/backend/useBackendOracleCandles.ts +1 -9
- package/src/hooks/backend/useBackendOracleMarkets.ts +1 -7
- package/src/hooks/backend/useBackendOrderbook.ts +0 -6
- package/src/hooks/backend/useBackendUserIntents.ts +0 -8
- package/src/hooks/bitcoin/resolveBtcReadAddress.test.ts +1 -3
- package/src/hooks/bitcoin/resolveBtcReadAddress.ts +2 -12
- package/src/hooks/bitcoin/useBitcoinBalance.ts +1 -7
- package/src/hooks/bitcoin/useBitcoinTradingSetup.ts +2 -4
- package/src/hooks/bitcoin/useEnsureRadfiAccessToken.ts +2 -13
- package/src/hooks/bitcoin/useFundTradingWallet.ts +0 -6
- package/src/hooks/bitcoin/useRadfiAuth.ts +1 -6
- package/src/hooks/bitcoin/useRadfiSession.ts +0 -1
- package/src/hooks/bitcoin/useRadfiWithdraw.ts +0 -6
- package/src/hooks/bitcoin/useRenewUtxos.ts +0 -5
- package/src/hooks/bitcoin/useTradingWallet.ts +1 -4
- package/src/hooks/bridge/getBridgeDetailedStatusRefetchInterval.test.ts +1 -7
- package/src/hooks/bridge/getBridgeDetailedStatusRefetchInterval.ts +7 -21
- package/src/hooks/bridge/useBridge.test.ts +1 -11
- package/src/hooks/bridge/useBridge.ts +2 -12
- package/src/hooks/bridge/useBridgeAllowance.ts +1 -2
- package/src/hooks/bridge/useBridgeApprovalStrategy.ts +2 -6
- package/src/hooks/bridge/useBridgeApprove.ts +2 -14
- package/src/hooks/bridge/useBridgeDetailedStatus.test.ts +2 -11
- package/src/hooks/bridge/useBridgeDetailedStatus.ts +3 -23
- package/src/hooks/bridge/useBridgeWithApproval.ts +2 -11
- package/src/hooks/bridgeApi/getBridgeSubmitTxStatusRefetchInterval.test.ts +2 -7
- package/src/hooks/bridgeApi/getBridgeSubmitTxStatusRefetchInterval.ts +2 -13
- package/src/hooks/bridgeApi/index.ts +11 -14
- package/src/hooks/bridgeApi/useBridgeApiAllowance.ts +1 -9
- package/src/hooks/bridgeApi/useBridgeApiApprove.ts +2 -17
- package/src/hooks/bridgeApi/useBridgeApiApproveAndBroadcast.test.ts +2 -13
- package/src/hooks/bridgeApi/useBridgeApiApproveAndBroadcast.ts +3 -20
- package/src/hooks/bridgeApi/useBridgeApiBridgeableAmount.ts +1 -12
- package/src/hooks/bridgeApi/useBridgeApiCreateBridgeIntent.ts +1 -14
- package/src/hooks/bridgeApi/useBridgeApiFee.ts +2 -11
- package/src/hooks/bridgeApi/useBridgeApiIsBridgeable.ts +1 -12
- package/src/hooks/bridgeApi/useBridgeApiSubmitTx.ts +2 -23
- package/src/hooks/bridgeApi/useBridgeApiSubmitTxStatus.test.ts +1 -9
- package/src/hooks/bridgeApi/useBridgeApiSubmitTxStatus.ts +1 -19
- package/src/hooks/bridgeApi/useBridgeApiTokens.ts +0 -8
- package/src/hooks/bridgeApi/useBridgeApiTokensByChain.ts +0 -7
- package/src/hooks/dex/useClaimRewards.ts +1 -12
- package/src/hooks/dex/useCreateDecreaseLiquidityParams.ts +1 -5
- package/src/hooks/dex/useCreateDepositParams.ts +1 -5
- package/src/hooks/dex/useCreateSupplyLiquidityParams.ts +1 -10
- package/src/hooks/dex/useCreateWithdrawParams.ts +1 -5
- package/src/hooks/dex/useDecreaseLiquidity.ts +2 -15
- package/src/hooks/dex/useDexAllowance.ts +1 -5
- package/src/hooks/dex/useDexApprove.ts +1 -12
- package/src/hooks/dex/useDexDeposit.ts +1 -23
- package/src/hooks/dex/useDexWithdraw.ts +1 -13
- package/src/hooks/dex/useLiquidityAmounts.ts +1 -4
- package/src/hooks/dex/usePoolBalances.ts +0 -4
- package/src/hooks/dex/usePoolData.ts +1 -4
- package/src/hooks/dex/usePools.ts +1 -4
- package/src/hooks/dex/usePositionInfo.ts +1 -4
- package/src/hooks/dex/useSupplyLiquidity.ts +3 -20
- package/src/hooks/leverageYield/useApproveLeveragePositionFunding.ts +2 -8
- package/src/hooks/leverageYield/useLeveragePositionAccount.ts +2 -13
- package/src/hooks/leverageYield/useLeveragePositionCollateral.ts +2 -14
- package/src/hooks/leverageYield/useLeveragePositionFundingAllowance.ts +2 -9
- package/src/hooks/leverageYield/useLeveragePositionInfo.ts +1 -13
- package/src/hooks/leverageYield/useLeveragePositionPayoutAddress.ts +3 -15
- package/src/hooks/leverageYield/useLeveragePositionPending.ts +2 -16
- package/src/hooks/leverageYield/useLeveragePositions.ts +1 -15
- package/src/hooks/leverageYield/useLeveragePositionsForUser.ts +1 -15
- package/src/hooks/leverageYield/useLeverageYieldApprovalStrategy.ts +1 -6
- package/src/hooks/leverageYield/useLeverageYieldDeposit.ts +1 -17
- package/src/hooks/leverageYield/useLeverageYieldDetailedStatus.test.ts +3 -14
- package/src/hooks/leverageYield/useLeverageYieldDetailedStatus.ts +2 -19
- package/src/hooks/leverageYield/useLeverageYieldEffectiveApr.ts +1 -12
- package/src/hooks/leverageYield/useLeverageYieldNotifySolver.ts +1 -11
- package/src/hooks/leverageYield/useLeverageYieldPosition.ts +1 -13
- package/src/hooks/leverageYield/useLeverageYieldPreviewRedeem.ts +1 -12
- package/src/hooks/leverageYield/useLeverageYieldQuote.test.ts +3 -13
- package/src/hooks/leverageYield/useLeverageYieldQuote.ts +5 -54
- package/src/hooks/leverageYield/useLeverageYieldShareBalances.ts +2 -29
- package/src/hooks/leverageYield/useLeverageYieldTotalAssets.ts +1 -9
- package/src/hooks/leverageYield/useLeverageYieldVaultSwap.ts +2 -25
- package/src/hooks/leverageYield/useLeverageYieldVaultSwapWithApproval.ts +1 -11
- package/src/hooks/leverageYield/useLeverageYieldWithdraw.ts +1 -17
- package/src/hooks/leverageYield/useOpenLeveragePosition.ts +5 -18
- package/src/hooks/leverageYield/useRunLeveragePositionOperation.ts +4 -20
- package/src/hooks/leverageYield/useSubmitLeveragePositionIntent.ts +3 -15
- package/src/hooks/leverageYieldApi/index.ts +0 -15
- package/src/hooks/leverageYieldApi/useLeverageYieldApiAllowance.ts +1 -8
- package/src/hooks/leverageYieldApi/useLeverageYieldApiApprove.ts +3 -6
- package/src/hooks/leverageYieldApi/useLeverageYieldApiApproveAndBroadcast.test.ts +4 -14
- package/src/hooks/leverageYieldApi/useLeverageYieldApiApproveAndBroadcast.ts +4 -26
- package/src/hooks/leverageYieldApi/useLeverageYieldApiApr.ts +1 -7
- package/src/hooks/leverageYieldApi/useLeverageYieldApiAsset.ts +0 -7
- package/src/hooks/leverageYieldApi/useLeverageYieldApiCancelIntent.ts +2 -8
- package/src/hooks/leverageYieldApi/useLeverageYieldApiCreateDepositIntent.ts +2 -8
- package/src/hooks/leverageYieldApi/useLeverageYieldApiCreateWithdrawIntent.ts +2 -8
- package/src/hooks/leverageYieldApi/useLeverageYieldApiDeadline.ts +1 -7
- package/src/hooks/leverageYieldApi/useLeverageYieldApiDepositQuote.ts +1 -15
- package/src/hooks/leverageYieldApi/useLeverageYieldApiEffectiveApr.ts +1 -7
- package/src/hooks/leverageYieldApi/useLeverageYieldApiEstimateGas.ts +1 -7
- package/src/hooks/leverageYieldApi/useLeverageYieldApiFilledIntent.ts +1 -6
- package/src/hooks/leverageYieldApi/useLeverageYieldApiIntent.ts +1 -6
- package/src/hooks/leverageYieldApi/useLeverageYieldApiIntentExtraData.ts +1 -8
- package/src/hooks/leverageYieldApi/useLeverageYieldApiIntentHash.ts +0 -7
- package/src/hooks/leverageYieldApi/useLeverageYieldApiIntentPacket.ts +1 -7
- package/src/hooks/leverageYieldApi/useLeverageYieldApiLsdApr.ts +1 -7
- package/src/hooks/leverageYieldApi/useLeverageYieldApiMaxWithdraw.ts +1 -7
- package/src/hooks/leverageYieldApi/useLeverageYieldApiPartnerFee.ts +1 -7
- package/src/hooks/leverageYieldApi/useLeverageYieldApiPosition.ts +0 -7
- package/src/hooks/leverageYieldApi/useLeverageYieldApiPreviewDeposit.ts +1 -7
- package/src/hooks/leverageYieldApi/useLeverageYieldApiPreviewRedeem.ts +1 -7
- package/src/hooks/leverageYieldApi/useLeverageYieldApiPreviewWithdraw.ts +1 -7
- package/src/hooks/leverageYieldApi/useLeverageYieldApiShareBalance.ts +0 -7
- package/src/hooks/leverageYieldApi/useLeverageYieldApiSolverFee.ts +1 -7
- package/src/hooks/leverageYieldApi/useLeverageYieldApiStatus.ts +2 -12
- package/src/hooks/leverageYieldApi/useLeverageYieldApiSubmitIntent.ts +2 -8
- package/src/hooks/leverageYieldApi/useLeverageYieldApiSubmitTx.ts +2 -8
- package/src/hooks/leverageYieldApi/useLeverageYieldApiSubmitTxStatus.ts +2 -17
- package/src/hooks/leverageYieldApi/useLeverageYieldApiTotalAssets.ts +0 -7
- package/src/hooks/leverageYieldApi/useLeverageYieldApiVault.ts +1 -7
- package/src/hooks/leverageYieldApi/useLeverageYieldApiVaults.ts +0 -7
- package/src/hooks/leverageYieldApi/useLeverageYieldApiWithdrawQuote.ts +1 -15
- package/src/hooks/migrate/useMigrateBaln.ts +1 -8
- package/src/hooks/migrate/useMigrateIcxToSoda.ts +1 -12
- package/src/hooks/migrate/useMigratebnUSD.ts +1 -12
- package/src/hooks/migrate/useMigrationAllowance.ts +3 -19
- package/src/hooks/migrate/useMigrationApprove.ts +2 -20
- package/src/hooks/migrate/useRevertMigrateSodaToIcx.ts +0 -7
- package/src/hooks/mm/useAToken.ts +1 -6
- package/src/hooks/mm/useATokensBalances.ts +0 -5
- package/src/hooks/mm/useBorrow.ts +1 -13
- package/src/hooks/mm/useEModes.ts +2 -13
- package/src/hooks/mm/useMMAllowance.test.ts +55 -0
- package/src/hooks/mm/useMMAllowance.ts +6 -16
- package/src/hooks/mm/useMMApprove.ts +1 -14
- package/src/hooks/mm/useRepay.ts +1 -12
- package/src/hooks/mm/useReservesData.ts +0 -4
- package/src/hooks/mm/useReservesHumanized.ts +0 -4
- package/src/hooks/mm/useReservesList.ts +0 -4
- package/src/hooks/mm/useReservesUsdFormat.ts +0 -4
- package/src/hooks/mm/useSupply.ts +1 -24
- package/src/hooks/mm/useUserFormattedSummary.ts +0 -7
- package/src/hooks/mm/useUserReservesData.ts +0 -4
- package/src/hooks/mm/useWithdraw.ts +1 -13
- package/src/hooks/partner/useApproveToken.ts +1 -7
- package/src/hooks/partner/useFeeClaimSwap.ts +1 -7
- package/src/hooks/partner/useFeeClaimWithdraw.ts +3 -20
- package/src/hooks/partner/useFetchAssetsBalances.ts +0 -4
- package/src/hooks/partner/useGetAutoSwapPreferences.ts +0 -4
- package/src/hooks/partner/useGetIntentDetails.ts +1 -8
- package/src/hooks/partner/useGetUserIntent.ts +1 -8
- package/src/hooks/partner/useIsTokenApproved.ts +0 -4
- package/src/hooks/partner/usePartnerCancelIntent.ts +2 -9
- package/src/hooks/partner/useSetSwapPreference.ts +1 -14
- package/src/hooks/recovery/useHubAssetBalances.ts +1 -6
- package/src/hooks/recovery/useWithdrawHubAsset.ts +1 -13
- package/src/hooks/shared/invalidateBalances.ts +2 -10
- package/src/hooks/shared/isUserRejectedError.test.ts +0 -3
- package/src/hooks/shared/isUserRejectedError.ts +2 -23
- package/src/hooks/shared/notFoundStreak.ts +5 -22
- package/src/hooks/shared/retryUnlessAuthFailure.test.ts +1 -2
- package/src/hooks/shared/retryUnlessAuthFailure.ts +1 -12
- package/src/hooks/shared/solverStatusPolicy.test.ts +0 -5
- package/src/hooks/shared/solverStatusPolicy.ts +8 -58
- package/src/hooks/shared/types.ts +4 -55
- package/src/hooks/shared/unwrapResult.ts +1 -8
- package/src/hooks/shared/useBalances.ts +6 -39
- package/src/hooks/shared/useEstablishTrustline.test.ts +1 -5
- package/src/hooks/shared/useEstablishTrustline.ts +3 -13
- package/src/hooks/shared/useEstablishXrpTrustline.test.ts +1 -2
- package/src/hooks/shared/useEstablishXrpTrustline.ts +3 -5
- package/src/hooks/shared/useEstimateGas.ts +0 -1
- package/src/hooks/shared/useGetUserHubWalletAddress.ts +1 -18
- package/src/hooks/shared/useNearStorageCheck.ts +2 -9
- package/src/hooks/shared/useNearStorageGate.ts +5 -15
- package/src/hooks/shared/useRegisterNearStorage.ts +2 -10
- package/src/hooks/shared/useRequestTrustline.test.ts +1 -7
- package/src/hooks/shared/useRequestTrustline.ts +4 -14
- package/src/hooks/shared/useSafeMutation.test.ts +0 -3
- package/src/hooks/shared/useSafeMutation.ts +2 -26
- package/src/hooks/shared/useSodaxContext.ts +0 -6
- package/src/hooks/shared/useStellarGate.test.ts +2 -9
- package/src/hooks/shared/useStellarGate.ts +3 -9
- package/src/hooks/shared/useStellarTrustlineCheck.test.ts +0 -2
- package/src/hooks/shared/useStellarTrustlineCheck.ts +1 -4
- package/src/hooks/shared/useXBalances.ts +2 -20
- package/src/hooks/shared/useXrpDestinationCheck.ts +1 -5
- package/src/hooks/shared/useXrpGate.test.ts +1 -3
- package/src/hooks/shared/useXrpGate.ts +2 -3
- package/src/hooks/shared/waitForApiAllowance.test.ts +0 -1
- package/src/hooks/shared/waitForApiAllowance.ts +2 -6
- package/src/hooks/sponsoring/useActivateStellarAccount.test.ts +1 -2
- package/src/hooks/sponsoring/useActivateStellarAccount.ts +1 -5
- package/src/hooks/sponsoring/useActivateStellarAccount.wire.test.ts +2 -13
- package/src/hooks/sponsoring/useSponsorConfig.ts +0 -1
- package/src/hooks/sponsoring/useStellarAccountActive.ts +0 -1
- package/src/hooks/sponsoring/useStellarAccountStatus.ts +1 -4
- package/src/hooks/staking/index.ts +0 -1
- package/src/hooks/staking/useCancelUnstake.ts +1 -7
- package/src/hooks/staking/useClaim.ts +1 -7
- package/src/hooks/staking/useConvertedAssets.ts +1 -4
- package/src/hooks/staking/useInstantUnstake.ts +1 -7
- package/src/hooks/staking/useInstantUnstakeAllowance.ts +1 -5
- package/src/hooks/staking/useInstantUnstakeApprove.ts +1 -11
- package/src/hooks/staking/useInstantUnstakeRatio.ts +1 -4
- package/src/hooks/staking/useStake.ts +1 -12
- package/src/hooks/staking/useStakeAllowance.ts +1 -5
- package/src/hooks/staking/useStakeApprove.ts +1 -11
- package/src/hooks/staking/useStakeRatio.ts +1 -4
- package/src/hooks/staking/useStakingConfig.ts +1 -4
- package/src/hooks/staking/useStakingInfo.ts +1 -5
- package/src/hooks/staking/useUnstake.ts +2 -9
- package/src/hooks/staking/useUnstakeAllowance.ts +1 -5
- package/src/hooks/staking/useUnstakeApprove.ts +1 -10
- package/src/hooks/staking/useUnstakingInfo.ts +1 -4
- package/src/hooks/staking/useUnstakingInfoWithPenalty.ts +1 -4
- package/src/hooks/swap/useCancelLimitOrder.ts +1 -7
- package/src/hooks/swap/useCancelSwap.ts +1 -7
- package/src/hooks/swap/useCreateLimitOrder.ts +2 -12
- package/src/hooks/swap/useDetailedStatus.test.ts +6 -18
- package/src/hooks/swap/useDetailedStatus.ts +2 -19
- package/src/hooks/swap/useQuote.test.ts +2 -8
- package/src/hooks/swap/useQuote.ts +5 -32
- package/src/hooks/swap/useStatus.ts +2 -10
- package/src/hooks/swap/useSwap.test.ts +1 -11
- package/src/hooks/swap/useSwap.ts +2 -12
- package/src/hooks/swap/useSwapAllowance.ts +1 -2
- package/src/hooks/swap/useSwapApprovalStrategy.ts +2 -7
- package/src/hooks/swap/useSwapApprove.ts +2 -14
- package/src/hooks/swap/useSwapLifecycle.test.ts +1 -2
- package/src/hooks/swap/useSwapLifecycle.ts +9 -27
- package/src/hooks/swap/useSwapWithApproval.ts +2 -11
- package/src/hooks/swapsApi/index.ts +2 -14
- package/src/hooks/swapsApi/isTerminalSwapIntentStatus.test.ts +1 -5
- package/src/hooks/swapsApi/isTerminalSwapIntentStatus.ts +1 -7
- package/src/hooks/swapsApi/useSwapsApiAllowance.ts +0 -7
- package/src/hooks/swapsApi/useSwapsApiApprove.ts +1 -14
- package/src/hooks/swapsApi/useSwapsApiApproveAndBroadcast.test.ts +5 -20
- package/src/hooks/swapsApi/useSwapsApiApproveAndBroadcast.ts +3 -24
- package/src/hooks/swapsApi/useSwapsApiBroadcastWithApproval.test.ts +2 -8
- package/src/hooks/swapsApi/useSwapsApiBroadcastWithApproval.ts +6 -41
- package/src/hooks/swapsApi/useSwapsApiCancelIntent.ts +0 -13
- package/src/hooks/swapsApi/useSwapsApiCreateIntent.ts +0 -13
- package/src/hooks/swapsApi/useSwapsApiCreateLimitOrder.ts +1 -13
- package/src/hooks/swapsApi/useSwapsApiDeadline.ts +1 -7
- package/src/hooks/swapsApi/useSwapsApiEstimateGas.ts +0 -7
- package/src/hooks/swapsApi/useSwapsApiFilledIntent.ts +0 -8
- package/src/hooks/swapsApi/useSwapsApiIntent.ts +1 -7
- package/src/hooks/swapsApi/useSwapsApiIntentExtraData.ts +1 -8
- package/src/hooks/swapsApi/useSwapsApiIntentHash.ts +0 -7
- package/src/hooks/swapsApi/useSwapsApiIntentPacket.ts +1 -10
- package/src/hooks/swapsApi/useSwapsApiPartnerFee.ts +0 -7
- package/src/hooks/swapsApi/useSwapsApiQuote.ts +2 -24
- package/src/hooks/swapsApi/useSwapsApiSolverFee.ts +0 -7
- package/src/hooks/swapsApi/useSwapsApiStatus.ts +1 -11
- package/src/hooks/swapsApi/useSwapsApiSubmitIntent.ts +1 -15
- package/src/hooks/swapsApi/useSwapsApiSubmitTx.ts +0 -21
- package/src/hooks/swapsApi/useSwapsApiSubmitTxStatus.ts +2 -19
- package/src/hooks/swapsApi/useSwapsApiTokens.ts +0 -7
- package/src/hooks/swapsApi/useSwapsApiTokensByChain.ts +0 -7
- package/src/index.ts +1 -1
- package/src/providers/SodaxProvider.test.ts +2 -9
- package/src/providers/SodaxProvider.tsx +1 -12
- package/src/providers/createSodaxQueryClient.ts +4 -56
- package/src/utils/approvalPlan.ts +9 -32
- package/src/utils/dex-utils.ts +5 -20
- package/src/utils/nearStorageGate.ts +3 -14
- package/src/utils/stellarGate.ts +3 -16
- package/src/utils/swapLifecycle.ts +7 -26
- package/src/utils/xrpGate.ts +1 -4
|
@@ -12,30 +12,15 @@ import type { MutationHookParams } from '../shared/types.js';
|
|
|
12
12
|
import { useSafeMutation, type SafeUseMutationResult } from '../shared/useSafeMutation.js';
|
|
13
13
|
import { unwrapResult } from '../shared/unwrapResult.js';
|
|
14
14
|
|
|
15
|
-
/** Mutation variables for {@link useRunLeveragePositionOperation} — the calls to run as the owner. */
|
|
16
15
|
export type UseRunLeveragePositionOperationVars<K extends SpokeChainKey = SpokeChainKey> = Omit<
|
|
17
16
|
SpokeExecActionParams<K, false, PositionOperationParams<K, PositionDirectCall>>,
|
|
18
17
|
'raw'
|
|
19
18
|
>;
|
|
20
19
|
|
|
21
20
|
/**
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
* Still routed, never sent directly: the position's `onlyOwner` is the hub wallet, so a call sent
|
|
26
|
-
* from the signer reverts `NotOwner`. Locally through the wallet router on the hub, relayed from
|
|
27
|
-
* anywhere else.
|
|
28
|
-
*
|
|
29
|
-
* USE {@link useSubmitLeveragePositionIntent} FOR `increaseLeverage` AND `decreaseLeverage`. Those
|
|
30
|
-
* only post a request a solver fills later, and this hook does not notify the solver, so sending one
|
|
31
|
-
* through here creates an intent nothing will fill. It expires silently and the operation is lost.
|
|
32
|
-
* The other direction is harmless by comparison: notifying about a withdraw is noise, not damage.
|
|
33
|
-
*
|
|
34
|
-
* Balances are invalidated for `srcChainKey` because a withdraw pays out.
|
|
35
|
-
*
|
|
36
|
-
* @experimental OFF-HUB (SPOKE) ORIGINS ARE UNVERIFIED ON-CHAIN, and this is the hook that carries the
|
|
37
|
-
* worst of it: an exit or cancellation delivering the underlying back to the spoke it
|
|
38
|
-
* came from has never run on mainnet. Bitcoin is refused outright.
|
|
21
|
+
* Synchronous position calls (`withdraw`, `settle`, `cancel`) as the hub wallet; does not notify the solver, so
|
|
22
|
+
* use {@link useSubmitLeveragePositionIntent} for leverage changes or the intent expires unfilled.
|
|
23
|
+
* @experimental Off-hub (spoke) origins are unverified on-chain; Bitcoin is refused.
|
|
39
24
|
*/
|
|
40
25
|
export function useRunLeveragePositionOperation<K extends SpokeChainKey = SpokeChainKey>({
|
|
41
26
|
mutationOptions,
|
|
@@ -54,8 +39,7 @@ export function useRunLeveragePositionOperation<K extends SpokeChainKey = SpokeC
|
|
|
54
39
|
unwrapResult(await sodax.leverageYield.runLeveragePositionOperation({ ...vars, raw: false })),
|
|
55
40
|
onSuccess: async (data, vars, ctx) => {
|
|
56
41
|
invalidateBalances(queryClient, vars.params.srcChainKey);
|
|
57
|
-
// A position write
|
|
58
|
-
// partner that has to remember this leaves the UI stale after the one action it just took.
|
|
42
|
+
// A position write affects every position read (account, pending slot, list).
|
|
59
43
|
queryClient.invalidateQueries({ queryKey: ['leverageYield'] });
|
|
60
44
|
await mutationOptions?.onSuccess?.(data, vars, ctx);
|
|
61
45
|
},
|
|
@@ -11,25 +11,14 @@ import type { MutationHookParams } from '../shared/types.js';
|
|
|
11
11
|
import { useSafeMutation, type SafeUseMutationResult } from '../shared/useSafeMutation.js';
|
|
12
12
|
import { unwrapResult } from '../shared/unwrapResult.js';
|
|
13
13
|
|
|
14
|
-
/** Mutation variables for {@link useSubmitLeveragePositionIntent} — the calls to run as the owner. */
|
|
15
14
|
export type UseSubmitLeveragePositionIntentVars<K extends SpokeChainKey = SpokeChainKey> = Omit<
|
|
16
15
|
SpokeExecActionParams<K, false, PositionOperationParams<K, PositionBatchCall>>,
|
|
17
16
|
'raw'
|
|
18
17
|
>;
|
|
19
18
|
|
|
20
19
|
/**
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
* USE {@link useRunLeveragePositionOperation} for `withdraw`, `settle` and `cancel`. The split is the
|
|
25
|
-
* SDK's: those three are synchronous on the hub and need no notification, while these two only post
|
|
26
|
-
* a request a solver fills later. Sending a leverage change through the other hook leaves an intent
|
|
27
|
-
* nothing will fill, and it expires without a word.
|
|
28
|
-
*
|
|
29
|
-
* A position permits one intent at a time, so poll `useLeveragePositionPending` rather than assuming
|
|
30
|
-
* the next call may go out.
|
|
31
|
-
*
|
|
32
|
-
* @experimental Off-hub (spoke) origins are unverified on-chain; see the SDK method.
|
|
20
|
+
* Intent-posting position calls (`increaseLeverage`, `decreaseLeverage`); one intent at a time, so gate on `useLeveragePositionPending`.
|
|
21
|
+
* @experimental Off-hub (spoke) origins are unverified on-chain.
|
|
33
22
|
*/
|
|
34
23
|
export function useSubmitLeveragePositionIntent<K extends SpokeChainKey = SpokeChainKey>({
|
|
35
24
|
mutationOptions,
|
|
@@ -46,8 +35,7 @@ export function useSubmitLeveragePositionIntent<K extends SpokeChainKey = SpokeC
|
|
|
46
35
|
mutationFn: async vars =>
|
|
47
36
|
unwrapResult(await sodax.leverageYield.submitLeveragePositionIntent({ ...vars, raw: false })),
|
|
48
37
|
onSuccess: async (data, vars, ctx) => {
|
|
49
|
-
// The slot is occupied
|
|
50
|
-
// pending read has to be refetched even though nothing has filled yet.
|
|
38
|
+
// The pending slot is occupied as soon as this resolves, before any fill.
|
|
51
39
|
queryClient.invalidateQueries({ queryKey: ['leverageYield'] });
|
|
52
40
|
await mutationOptions?.onSuccess?.(data, vars, ctx);
|
|
53
41
|
},
|
|
@@ -1,16 +1,6 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Leverage Yield API hooks — typed React Query wrappers over `sodax.api.leverageYield.*` (the
|
|
3
|
-
* LeverageYieldApiService HTTP client). One hook per endpoint of the backend Leverage Yield API.
|
|
4
|
-
*
|
|
5
|
-
* Distinct from the on-chain `leverageYield/` hooks (`useLeverageYieldDeposit`/…), which drive the
|
|
6
|
-
* `LeverageYieldService` path (wallet → hub chain). These hooks call the backend HTTP API instead.
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
// Vault registry
|
|
10
1
|
export * from './useLeverageYieldApiVaults.js';
|
|
11
2
|
export * from './useLeverageYieldApiVault.js';
|
|
12
3
|
|
|
13
|
-
// Vault reads
|
|
14
4
|
export * from './useLeverageYieldApiAsset.js';
|
|
15
5
|
export * from './useLeverageYieldApiPosition.js';
|
|
16
6
|
export * from './useLeverageYieldApiApr.js';
|
|
@@ -23,19 +13,16 @@ export * from './useLeverageYieldApiPreviewRedeem.js';
|
|
|
23
13
|
export * from './useLeverageYieldApiShareBalance.js';
|
|
24
14
|
export * from './useLeverageYieldApiMaxWithdraw.js';
|
|
25
15
|
|
|
26
|
-
// Quote · deadline · allowance
|
|
27
16
|
export * from './useLeverageYieldApiDepositQuote.js';
|
|
28
17
|
export * from './useLeverageYieldApiWithdrawQuote.js';
|
|
29
18
|
export * from './useLeverageYieldApiDeadline.js';
|
|
30
19
|
export * from './useLeverageYieldApiAllowance.js';
|
|
31
20
|
|
|
32
|
-
// Approve · create intent (deposit / withdraw)
|
|
33
21
|
export * from './useLeverageYieldApiApprove.js';
|
|
34
22
|
export * from './useLeverageYieldApiApproveAndBroadcast.js';
|
|
35
23
|
export * from './useLeverageYieldApiCreateDepositIntent.js';
|
|
36
24
|
export * from './useLeverageYieldApiCreateWithdrawIntent.js';
|
|
37
25
|
|
|
38
|
-
// Intent lifecycle: submit · status · cancel · hash · packet · extra-data · lookup
|
|
39
26
|
export * from './useLeverageYieldApiSubmitIntent.js';
|
|
40
27
|
export * from './useLeverageYieldApiStatus.js';
|
|
41
28
|
export * from './useLeverageYieldApiCancelIntent.js';
|
|
@@ -45,11 +32,9 @@ export * from './useLeverageYieldApiIntentExtraData.js';
|
|
|
45
32
|
export * from './useLeverageYieldApiFilledIntent.js';
|
|
46
33
|
export * from './useLeverageYieldApiIntent.js';
|
|
47
34
|
|
|
48
|
-
// Gas · fees
|
|
49
35
|
export * from './useLeverageYieldApiEstimateGas.js';
|
|
50
36
|
export * from './useLeverageYieldApiPartnerFee.js';
|
|
51
37
|
export * from './useLeverageYieldApiSolverFee.js';
|
|
52
38
|
|
|
53
|
-
// Submit-tx state machine
|
|
54
39
|
export * from './useLeverageYieldApiSubmitTx.js';
|
|
55
40
|
export * from './useLeverageYieldApiSubmitTxStatus.js';
|
|
@@ -13,14 +13,7 @@ export type UseLeverageYieldApiAllowanceParams = ReadHookParams<
|
|
|
13
13
|
}
|
|
14
14
|
>;
|
|
15
15
|
|
|
16
|
-
/**
|
|
17
|
-
* React hook to check whether the deposit input-token allowance is already sufficient for an intent
|
|
18
|
-
* via the leverage-yield API — `sodax.api.leverageYield.checkAllowance`. Returns `{ valid }`.
|
|
19
|
-
* (Withdraw needs no spoke allowance — it spends lsoda* from the hub wallet.)
|
|
20
|
-
*
|
|
21
|
-
* @example
|
|
22
|
-
* const { data: allowance } = useLeverageYieldApiAllowance({ params: { body: depositIntentParams } });
|
|
23
|
-
*/
|
|
16
|
+
/** Deposit-only: a withdraw needs no spoke allowance (it spends lsoda* from the hub wallet). */
|
|
24
17
|
export const useLeverageYieldApiAllowance = ({
|
|
25
18
|
params,
|
|
26
19
|
queryOptions,
|
|
@@ -5,18 +5,15 @@ import { unwrapResult } from '../shared/unwrapResult.js';
|
|
|
5
5
|
import type { MutationHookParams } from '../shared/types.js';
|
|
6
6
|
import { useSafeMutation, type SafeUseMutationResult } from '../shared/useSafeMutation.js';
|
|
7
7
|
|
|
8
|
-
/**
|
|
9
|
-
* Mutation variables for {@link useLeverageYieldApiApprove}. The per-request `apiConfig` override belongs here
|
|
10
|
-
* rather than at the hook level — different calls in the same component can target different
|
|
11
|
-
* endpoints without re-rendering.
|
|
12
|
-
*/
|
|
8
|
+
/** Per-call `apiConfig` so calls in one component can target different endpoints. */
|
|
13
9
|
export type UseLeverageYieldApiApproveVars = {
|
|
14
10
|
body: CreateDepositIntentParamsV2;
|
|
15
11
|
apiConfig?: RequestOverrideConfig;
|
|
16
12
|
};
|
|
17
13
|
|
|
18
14
|
/**
|
|
19
|
-
*
|
|
15
|
+
* Returns the unsigned `{ tx, resetTx? }`; the reset must be mined before the approve.
|
|
16
|
+
* Prefer {@link useLeverageYieldApiApproveAndBroadcast}, which owns that ordering.
|
|
20
17
|
*/
|
|
21
18
|
export const useLeverageYieldApiApprove = ({
|
|
22
19
|
mutationOptions,
|
|
@@ -1,13 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
* `runApprovalPlan` itself — every chain family, every progress phase — is covered by the swaps and
|
|
6
|
-
* bridge suites; this one pins what is leverage-yield-specific: the client method it asks for the
|
|
7
|
-
* plan, that the ordering survives, that errors name THIS hook, and its own invalidation key.
|
|
8
|
-
*
|
|
9
|
-
* Follows the package convention of testing hooks without a renderer: the React Query wrapper is
|
|
10
|
-
* mocked so `mutationFn` can be captured and driven directly.
|
|
2
|
+
* Pins leverage-yield specifics: client method, reset-before-approve ordering, error hook name, invalidation key.
|
|
3
|
+
* `runApprovalPlan` itself is covered by the swaps/bridge suites; React Query is mocked to capture `mutationFn`.
|
|
11
4
|
*/
|
|
12
5
|
|
|
13
6
|
import { ChainKeys } from '@sodax/sdk';
|
|
@@ -65,7 +58,6 @@ function evmProvider(calls: string[], onWait?: (hash: string) => string | void)
|
|
|
65
58
|
};
|
|
66
59
|
}
|
|
67
60
|
|
|
68
|
-
/** One render, then the captured `mutationFn` invoked with `vars`. */
|
|
69
61
|
// biome-ignore lint/suspicious/noExplicitAny: vars mirror the hook's generic mutation variables.
|
|
70
62
|
const run = (vars: any) => {
|
|
71
63
|
useLeverageYieldApiApproveAndBroadcast();
|
|
@@ -112,8 +104,7 @@ describe('useLeverageYieldApiApproveAndBroadcast', () => {
|
|
|
112
104
|
const result = await run({ body: body(ChainKeys.ARBITRUM_MAINNET), walletProvider: evmProvider(calls) });
|
|
113
105
|
|
|
114
106
|
expect(result).toEqual({ resetTxHash: RESET_HASH, approveTxHash: APPROVE_HASH });
|
|
115
|
-
// The wait
|
|
116
|
-
// the transaction `useLeverageYieldApiApprove` callers were dropping.
|
|
107
|
+
// The wait must sit between the two sends; approving over an unconfirmed reset reverts.
|
|
117
108
|
expect(calls).toEqual(['send:0xreset', `wait:${RESET_HASH}`, 'send:0xapprove', `wait:${APPROVE_HASH}`]);
|
|
118
109
|
});
|
|
119
110
|
|
|
@@ -136,8 +127,7 @@ describe('useLeverageYieldApiApproveAndBroadcast', () => {
|
|
|
136
127
|
});
|
|
137
128
|
|
|
138
129
|
it('names this hook, not a sibling, in an error from the shared plan runner', async () => {
|
|
139
|
-
// The runner is shared with
|
|
140
|
-
// leverage-yield integrator at the wrong hook.
|
|
130
|
+
// The runner is shared with swaps and bridge; a hard-coded hook name there would misdirect integrators.
|
|
141
131
|
approve.mockResolvedValue({ ok: true, value: { tx: APPROVE_TX } });
|
|
142
132
|
|
|
143
133
|
await expect(run({ body: body(ChainKeys.SOLANA_MAINNET), walletProvider: {} })).rejects.toThrow(
|
|
@@ -24,30 +24,9 @@ export type UseLeverageYieldApiApproveAndBroadcastVars<K extends SpokeChainKey =
|
|
|
24
24
|
};
|
|
25
25
|
|
|
26
26
|
/**
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
* Prefer this over {@link useLeverageYieldApiApprove}, which hands back the unsigned
|
|
32
|
-
* `{ tx, resetTx? }` and leaves the ordering — reset mined first, then approve — to the caller. A
|
|
33
|
-
* deposit token of the 2017 TetherToken lineage rejects an allowance change from one non-zero value
|
|
34
|
-
* to another, so broadcasting the approve without the reset spends the user's gas on a transaction
|
|
35
|
-
* that is certain to revert. Confirmation happens inside the hook, so it invalidates
|
|
36
|
-
* `['leverageYieldApi','allowance']` itself — after waiting up to about 15 seconds for the API to report
|
|
37
|
-
* the allowance as valid, since its RPC can trail the node that confirmed the approve. It resolves after
|
|
38
|
-
* that wait either way, so read the allowance rather than treating success as `valid`.
|
|
39
|
-
*
|
|
40
|
-
* Supports the chains the leverage-yield API can approve on — the hub (Sonic), EVM spokes, and
|
|
41
|
-
* Stellar. Every other chain reports its allowance as always sufficient, so approval never runs.
|
|
42
|
-
*
|
|
43
|
-
* `onProgress` reports each transaction as `{ step, phase, index, total }`, so the UI can name the
|
|
44
|
-
* wallet prompt the user is looking at instead of one flat "Approving…" across two signatures.
|
|
45
|
-
*
|
|
46
|
-
* @example
|
|
47
|
-
* const { mutateAsyncSafe: approve } = useLeverageYieldApiApproveAndBroadcast();
|
|
48
|
-
* const result = await approve({ body: depositIntentParams, walletProvider, onProgress: setStep });
|
|
49
|
-
* if (!result.ok) return;
|
|
50
|
-
* const { resetTxHash, approveTxHash } = result.value; // resetTxHash only on a guarded token
|
|
27
|
+
* Signs and confirms the deposit approval plan, mining the reset before the approve (USDT-lineage tokens revert).
|
|
28
|
+
* Resolves after waiting up to ~15s for the API allowance to turn valid, valid or not: read the allowance.
|
|
29
|
+
* Approval runs only on the hub, EVM spokes and Stellar; other chains report the allowance as always sufficient.
|
|
51
30
|
*/
|
|
52
31
|
export const useLeverageYieldApiApproveAndBroadcast = <K extends SpokeChainKey = SpokeChainKey>({
|
|
53
32
|
mutationOptions,
|
|
@@ -79,8 +58,7 @@ export const useLeverageYieldApiApproveAndBroadcast = <K extends SpokeChainKey =
|
|
|
79
58
|
return hashes;
|
|
80
59
|
},
|
|
81
60
|
onSuccess: async (data, vars, ctx) => {
|
|
82
|
-
// Awaited
|
|
83
|
-
// has actually refetched, or a stale cached `valid: false` re-enables a duplicate approval.
|
|
61
|
+
// Awaited so a stale cached `valid: false` cannot re-enable Approve before the refetch lands.
|
|
84
62
|
await queryClient.invalidateQueries({ queryKey: ['leverageYieldApi', 'allowance'] });
|
|
85
63
|
await mutationOptions?.onSuccess?.(data, vars, ctx);
|
|
86
64
|
},
|
|
@@ -13,13 +13,7 @@ export type UseLeverageYieldApiAprParams = ReadHookParams<
|
|
|
13
13
|
}
|
|
14
14
|
>;
|
|
15
15
|
|
|
16
|
-
/**
|
|
17
|
-
* React hook to fetch the AAVE-only steady-state APR for a leverage-yield vault via the leverage-yield API —
|
|
18
|
-
* `sodax.api.leverageYield.getApr`.
|
|
19
|
-
*
|
|
20
|
-
* @example
|
|
21
|
-
* const { data } = useLeverageYieldApiApr({ params: { vault: '0x...' } });
|
|
22
|
-
*/
|
|
16
|
+
/** AAVE-only steady-state APR; {@link useLeverageYieldApiEffectiveApr} includes LSD yield. */
|
|
23
17
|
export const useLeverageYieldApiApr = ({
|
|
24
18
|
params,
|
|
25
19
|
queryOptions,
|
|
@@ -13,13 +13,6 @@ export type UseLeverageYieldApiAssetParams = ReadHookParams<
|
|
|
13
13
|
}
|
|
14
14
|
>;
|
|
15
15
|
|
|
16
|
-
/**
|
|
17
|
-
* React hook to fetch the underlying hub asset for a leverage-yield vault via the leverage-yield API —
|
|
18
|
-
* `sodax.api.leverageYield.getAsset`.
|
|
19
|
-
*
|
|
20
|
-
* @example
|
|
21
|
-
* const { data } = useLeverageYieldApiAsset({ params: { vault: '0x...' } });
|
|
22
|
-
*/
|
|
23
16
|
export const useLeverageYieldApiAsset = ({
|
|
24
17
|
params,
|
|
25
18
|
queryOptions,
|
|
@@ -5,19 +5,13 @@ import { unwrapResult } from '../shared/unwrapResult.js';
|
|
|
5
5
|
import type { MutationHookParams } from '../shared/types.js';
|
|
6
6
|
import { useSafeMutation, type SafeUseMutationResult } from '../shared/useSafeMutation.js';
|
|
7
7
|
|
|
8
|
-
/**
|
|
9
|
-
* Mutation variables for {@link useLeverageYieldApiCancelIntent}. The per-request `apiConfig` override belongs here
|
|
10
|
-
* rather than at the hook level — different calls in the same component can target different
|
|
11
|
-
* endpoints without re-rendering.
|
|
12
|
-
*/
|
|
8
|
+
/** Per-call `apiConfig` so calls in one component can target different endpoints. */
|
|
13
9
|
export type UseLeverageYieldApiCancelIntentVars = {
|
|
14
10
|
body: CancelIntentRequestV2;
|
|
15
11
|
apiConfig?: RequestOverrideConfig;
|
|
16
12
|
};
|
|
17
13
|
|
|
18
|
-
/**
|
|
19
|
-
* React hook to build an unsigned cancel-intent transaction via the leverage-yield API — `sodax.api.leverageYield.cancelIntent`.
|
|
20
|
-
*/
|
|
14
|
+
/** Builds an unsigned cancel-intent tx for the caller to sign and broadcast. */
|
|
21
15
|
export const useLeverageYieldApiCancelIntent = ({
|
|
22
16
|
mutationOptions,
|
|
23
17
|
}: MutationHookParams<CancelIntentResponseV2, UseLeverageYieldApiCancelIntentVars> = {}): SafeUseMutationResult<
|
|
@@ -5,19 +5,13 @@ import { unwrapResult } from '../shared/unwrapResult.js';
|
|
|
5
5
|
import type { MutationHookParams } from '../shared/types.js';
|
|
6
6
|
import { useSafeMutation, type SafeUseMutationResult } from '../shared/useSafeMutation.js';
|
|
7
7
|
|
|
8
|
-
/**
|
|
9
|
-
* Mutation variables for {@link useLeverageYieldApiCreateDepositIntent}. The per-request `apiConfig` override belongs here
|
|
10
|
-
* rather than at the hook level — different calls in the same component can target different
|
|
11
|
-
* endpoints without re-rendering.
|
|
12
|
-
*/
|
|
8
|
+
/** Per-call `apiConfig` so calls in one component can target different endpoints. */
|
|
13
9
|
export type UseLeverageYieldApiCreateDepositIntentVars = {
|
|
14
10
|
body: CreateDepositIntentParamsV2;
|
|
15
11
|
apiConfig?: RequestOverrideConfig;
|
|
16
12
|
};
|
|
17
13
|
|
|
18
|
-
/**
|
|
19
|
-
* React hook to build an unsigned deposit create-intent transaction (any token → lsoda* shares) via the leverage-yield API — `sodax.api.leverageYield.createDepositIntent`.
|
|
20
|
-
*/
|
|
14
|
+
/** Builds an unsigned deposit create-intent tx (any token → lsoda* shares). */
|
|
21
15
|
export const useLeverageYieldApiCreateDepositIntent = ({
|
|
22
16
|
mutationOptions,
|
|
23
17
|
}: MutationHookParams<CreateIntentResponseV2, UseLeverageYieldApiCreateDepositIntentVars> = {}): SafeUseMutationResult<
|
|
@@ -5,19 +5,13 @@ import { unwrapResult } from '../shared/unwrapResult.js';
|
|
|
5
5
|
import type { MutationHookParams } from '../shared/types.js';
|
|
6
6
|
import { useSafeMutation, type SafeUseMutationResult } from '../shared/useSafeMutation.js';
|
|
7
7
|
|
|
8
|
-
/**
|
|
9
|
-
* Mutation variables for {@link useLeverageYieldApiCreateWithdrawIntent}. The per-request `apiConfig` override belongs here
|
|
10
|
-
* rather than at the hook level — different calls in the same component can target different
|
|
11
|
-
* endpoints without re-rendering.
|
|
12
|
-
*/
|
|
8
|
+
/** Per-call `apiConfig` so calls in one component can target different endpoints. */
|
|
13
9
|
export type UseLeverageYieldApiCreateWithdrawIntentVars = {
|
|
14
10
|
body: CreateWithdrawIntentParamsV2;
|
|
15
11
|
apiConfig?: RequestOverrideConfig;
|
|
16
12
|
};
|
|
17
13
|
|
|
18
|
-
/**
|
|
19
|
-
* React hook to build an unsigned withdraw create-intent transaction (lsoda* shares → any token) via the leverage-yield API — `sodax.api.leverageYield.createWithdrawIntent`.
|
|
20
|
-
*/
|
|
14
|
+
/** Builds an unsigned withdraw create-intent tx (lsoda* shares → any token). */
|
|
21
15
|
export const useLeverageYieldApiCreateWithdrawIntent = ({
|
|
22
16
|
mutationOptions,
|
|
23
17
|
}: MutationHookParams<CreateIntentResponseV2, UseLeverageYieldApiCreateWithdrawIntentVars> = {}): SafeUseMutationResult<
|
|
@@ -13,13 +13,7 @@ export type UseLeverageYieldApiDeadlineParams = ReadHookParams<
|
|
|
13
13
|
}
|
|
14
14
|
>;
|
|
15
15
|
|
|
16
|
-
/**
|
|
17
|
-
* React hook to compute a deposit/withdraw deadline (hub timestamp + `offsetSeconds`, default 300s)
|
|
18
|
-
* via the leverage-yield API — `sodax.api.leverageYield.getDeadline`.
|
|
19
|
-
*
|
|
20
|
-
* @example
|
|
21
|
-
* const { data: deadline } = useLeverageYieldApiDeadline({ params: { query: { offsetSeconds: 600 } } });
|
|
22
|
-
*/
|
|
16
|
+
/** Deadline = hub timestamp + `offsetSeconds` (default 300s). */
|
|
23
17
|
export const useLeverageYieldApiDeadline = ({
|
|
24
18
|
params,
|
|
25
19
|
queryOptions,
|
|
@@ -19,21 +19,7 @@ export type UseLeverageYieldApiDepositQuoteParams = ReadHookParams<
|
|
|
19
19
|
}
|
|
20
20
|
>;
|
|
21
21
|
|
|
22
|
-
/**
|
|
23
|
-
* React hook to quote a swap-style leverage-yield deposit (any token → lsoda* shares) via the
|
|
24
|
-
* leverage-yield API — `sodax.api.leverageYield.getDepositQuote`. Pass `query.includeTxData = true`
|
|
25
|
-
* to also build the unsigned create-intent transaction (`srcAddress` then required in the body).
|
|
26
|
-
*
|
|
27
|
-
* @example
|
|
28
|
-
* const { data: quote } = useLeverageYieldApiDepositQuote({
|
|
29
|
-
* params: {
|
|
30
|
-
* body: {
|
|
31
|
-
* vault: '0x...', tokenSrc: '0x...', tokenSrcChainKey: '0xa4b1.arbitrum',
|
|
32
|
-
* amount: '1000000', quoteType: 'exact_input',
|
|
33
|
-
* },
|
|
34
|
-
* },
|
|
35
|
-
* });
|
|
36
|
-
*/
|
|
22
|
+
/** `query.includeTxData = true` also builds the unsigned create-intent tx and requires `srcAddress` in the body. */
|
|
37
23
|
export const useLeverageYieldApiDepositQuote = ({
|
|
38
24
|
params,
|
|
39
25
|
queryOptions,
|
|
@@ -13,13 +13,7 @@ export type UseLeverageYieldApiEffectiveAprParams = ReadHookParams<
|
|
|
13
13
|
}
|
|
14
14
|
>;
|
|
15
15
|
|
|
16
|
-
/**
|
|
17
|
-
* React hook to fetch the honest combined AAVE + LSD effective APR for a leverage-yield vault via the leverage-yield API —
|
|
18
|
-
* `sodax.api.leverageYield.getEffectiveApr`.
|
|
19
|
-
*
|
|
20
|
-
* @example
|
|
21
|
-
* const { data } = useLeverageYieldApiEffectiveApr({ params: { vault: '0x...' } });
|
|
22
|
-
*/
|
|
16
|
+
/** Combined AAVE + LSD effective APR. */
|
|
23
17
|
export const useLeverageYieldApiEffectiveApr = ({
|
|
24
18
|
params,
|
|
25
19
|
queryOptions,
|
|
@@ -13,13 +13,7 @@ export type UseLeverageYieldApiEstimateGasParams = ReadHookParams<
|
|
|
13
13
|
}
|
|
14
14
|
>;
|
|
15
15
|
|
|
16
|
-
/**
|
|
17
|
-
* React hook to estimate gas for a raw transaction on a spoke chain via the leverage-yield API —
|
|
18
|
-
* `sodax.api.leverageYield.estimateGas`. Returns `{ gas }` (chain-specific shape).
|
|
19
|
-
*
|
|
20
|
-
* @example
|
|
21
|
-
* const { data } = useLeverageYieldApiEstimateGas({ params: { body: { chainKey: 'sonic', tx: {...} } } });
|
|
22
|
-
*/
|
|
16
|
+
/** Returns `{ gas }` in a chain-specific shape. */
|
|
23
17
|
export const useLeverageYieldApiEstimateGas = ({
|
|
24
18
|
params,
|
|
25
19
|
queryOptions,
|
|
@@ -13,12 +13,7 @@ export type UseLeverageYieldApiFilledIntentParams = ReadHookParams<
|
|
|
13
13
|
}
|
|
14
14
|
>;
|
|
15
15
|
|
|
16
|
-
/**
|
|
17
|
-
* React hook to get the on-chain fill state for an intent by its hub-chain tx hash via the leverage-yield API — `sodax.api.leverageYield.getFilledIntent`.
|
|
18
|
-
*
|
|
19
|
-
* @example
|
|
20
|
-
* const { data } = useLeverageYieldApiFilledIntent({ params: { txHash: '0x123...' } });
|
|
21
|
-
*/
|
|
16
|
+
/** On-chain fill state, keyed by the intent's hub-chain tx hash. */
|
|
22
17
|
export const useLeverageYieldApiFilledIntent = ({
|
|
23
18
|
params,
|
|
24
19
|
queryOptions,
|
|
@@ -13,12 +13,7 @@ export type UseLeverageYieldApiIntentParams = ReadHookParams<
|
|
|
13
13
|
}
|
|
14
14
|
>;
|
|
15
15
|
|
|
16
|
-
/**
|
|
17
|
-
* React hook to look up an Intent struct by its hub-chain creation tx hash via the leverage-yield API — `sodax.api.leverageYield.getIntent`.
|
|
18
|
-
*
|
|
19
|
-
* @example
|
|
20
|
-
* const { data } = useLeverageYieldApiIntent({ params: { txHash: '0x123...' } });
|
|
21
|
-
*/
|
|
16
|
+
/** Looks up the Intent struct by its hub-chain creation tx hash. */
|
|
22
17
|
export const useLeverageYieldApiIntent = ({
|
|
23
18
|
params,
|
|
24
19
|
queryOptions,
|
|
@@ -13,14 +13,7 @@ export type UseLeverageYieldApiIntentExtraDataParams = ReadHookParams<
|
|
|
13
13
|
}
|
|
14
14
|
>;
|
|
15
15
|
|
|
16
|
-
/**
|
|
17
|
-
* React hook to recover the relay extra data needed by `/leverage-yield/intents/submit` via the
|
|
18
|
-
* leverage-yield API — `sodax.api.leverageYield.getIntentSubmitTxExtraData`. Provide EITHER `txHash`
|
|
19
|
-
* OR `intent` in the body.
|
|
20
|
-
*
|
|
21
|
-
* @example
|
|
22
|
-
* const { data } = useLeverageYieldApiIntentExtraData({ params: { body: { txHash: '0x...' } } });
|
|
23
|
-
*/
|
|
16
|
+
/** Relay extra data for `/leverage-yield/intents/submit`; the body takes EITHER `txHash` OR `intent`. */
|
|
24
17
|
export const useLeverageYieldApiIntentExtraData = ({
|
|
25
18
|
params,
|
|
26
19
|
queryOptions,
|
|
@@ -13,13 +13,6 @@ export type UseLeverageYieldApiIntentHashParams = ReadHookParams<
|
|
|
13
13
|
}
|
|
14
14
|
>;
|
|
15
15
|
|
|
16
|
-
/**
|
|
17
|
-
* React hook to compute the keccak256 hash of an Intent struct via the leverage-yield API —
|
|
18
|
-
* `sodax.api.leverageYield.getIntentHash`. Returns `{ hash }`.
|
|
19
|
-
*
|
|
20
|
-
* @example
|
|
21
|
-
* const { data } = useLeverageYieldApiIntentHash({ params: { intent } });
|
|
22
|
-
*/
|
|
23
16
|
export const useLeverageYieldApiIntentHash = ({
|
|
24
17
|
params,
|
|
25
18
|
queryOptions,
|
|
@@ -13,13 +13,7 @@ export type UseLeverageYieldApiIntentPacketParams = ReadHookParams<
|
|
|
13
13
|
}
|
|
14
14
|
>;
|
|
15
15
|
|
|
16
|
-
/**
|
|
17
|
-
* React hook to long-poll the relayer until the fill packet lands on the destination chain via the
|
|
18
|
-
* leverage-yield API — `sodax.api.leverageYield.getSolvedIntentPacket`.
|
|
19
|
-
*
|
|
20
|
-
* @example
|
|
21
|
-
* const { data } = useLeverageYieldApiIntentPacket({ params: { body: { chainId: 'sonic', fillTxHash: '0x...' } } });
|
|
22
|
-
*/
|
|
16
|
+
/** Long-polls the relayer until the fill packet lands on the destination chain. */
|
|
23
17
|
export const useLeverageYieldApiIntentPacket = ({
|
|
24
18
|
params,
|
|
25
19
|
queryOptions,
|
|
@@ -13,13 +13,7 @@ export type UseLeverageYieldApiLsdAprParams = ReadHookParams<
|
|
|
13
13
|
}
|
|
14
14
|
>;
|
|
15
15
|
|
|
16
|
-
/**
|
|
17
|
-
* React hook to fetch the off-chain LSD staking-APR snapshot for a leverage-yield vault via the leverage-yield API —
|
|
18
|
-
* `sodax.api.leverageYield.getLsdApr`.
|
|
19
|
-
*
|
|
20
|
-
* @example
|
|
21
|
-
* const { data } = useLeverageYieldApiLsdApr({ params: { vault: '0x...' } });
|
|
22
|
-
*/
|
|
16
|
+
/** Off-chain LSD staking-APR snapshot. */
|
|
23
17
|
export const useLeverageYieldApiLsdApr = ({
|
|
24
18
|
params,
|
|
25
19
|
queryOptions,
|
|
@@ -14,13 +14,7 @@ export type UseLeverageYieldApiMaxWithdrawParams = ReadHookParams<
|
|
|
14
14
|
}
|
|
15
15
|
>;
|
|
16
16
|
|
|
17
|
-
/**
|
|
18
|
-
* React hook to get the maximum assets an owner can withdraw (ERC-4626 maxWithdraw) via the leverage-yield API —
|
|
19
|
-
* `sodax.api.leverageYield.getMaxWithdraw`.
|
|
20
|
-
*
|
|
21
|
-
* @example
|
|
22
|
-
* const { data } = useLeverageYieldApiMaxWithdraw({ params: { vault: '0x...', owner: '1000000000000000000' } });
|
|
23
|
-
*/
|
|
17
|
+
/** ERC-4626 `maxWithdraw` for `owner`. */
|
|
24
18
|
export const useLeverageYieldApiMaxWithdraw = ({
|
|
25
19
|
params,
|
|
26
20
|
queryOptions,
|
|
@@ -13,13 +13,7 @@ export type UseLeverageYieldApiPartnerFeeParams = ReadHookParams<
|
|
|
13
13
|
}
|
|
14
14
|
>;
|
|
15
15
|
|
|
16
|
-
/**
|
|
17
|
-
* React hook to compute the partner fee for a given input amount via the leverage-yield API — `sodax.api.leverageYield.getPartnerFee`.
|
|
18
|
-
* Returns `{ fee }` (decimal string).
|
|
19
|
-
*
|
|
20
|
-
* @example
|
|
21
|
-
* const { data } = useLeverageYieldApiPartnerFee({ params: { amount: '1000000' } });
|
|
22
|
-
*/
|
|
16
|
+
/** Returns `{ fee }` as a decimal string. */
|
|
23
17
|
export const useLeverageYieldApiPartnerFee = ({
|
|
24
18
|
params,
|
|
25
19
|
queryOptions,
|
|
@@ -13,13 +13,6 @@ export type UseLeverageYieldApiPositionParams = ReadHookParams<
|
|
|
13
13
|
}
|
|
14
14
|
>;
|
|
15
15
|
|
|
16
|
-
/**
|
|
17
|
-
* React hook to fetch a leveraged-position snapshot for a leverage-yield vault via the leverage-yield API —
|
|
18
|
-
* `sodax.api.leverageYield.getPosition`.
|
|
19
|
-
*
|
|
20
|
-
* @example
|
|
21
|
-
* const { data } = useLeverageYieldApiPosition({ params: { vault: '0x...' } });
|
|
22
|
-
*/
|
|
23
16
|
export const useLeverageYieldApiPosition = ({
|
|
24
17
|
params,
|
|
25
18
|
queryOptions,
|
|
@@ -14,13 +14,7 @@ export type UseLeverageYieldApiPreviewDepositParams = ReadHookParams<
|
|
|
14
14
|
}
|
|
15
15
|
>;
|
|
16
16
|
|
|
17
|
-
/**
|
|
18
|
-
* React hook to preview the shares minted for depositing `assets` (ERC-4626 previewDeposit) via the leverage-yield API —
|
|
19
|
-
* `sodax.api.leverageYield.previewDeposit`.
|
|
20
|
-
*
|
|
21
|
-
* @example
|
|
22
|
-
* const { data } = useLeverageYieldApiPreviewDeposit({ params: { vault: '0x...', assets: '1000000000000000000' } });
|
|
23
|
-
*/
|
|
17
|
+
/** ERC-4626 `previewDeposit`: shares minted for `assets`. */
|
|
24
18
|
export const useLeverageYieldApiPreviewDeposit = ({
|
|
25
19
|
params,
|
|
26
20
|
queryOptions,
|
|
@@ -14,13 +14,7 @@ export type UseLeverageYieldApiPreviewRedeemParams = ReadHookParams<
|
|
|
14
14
|
}
|
|
15
15
|
>;
|
|
16
16
|
|
|
17
|
-
/**
|
|
18
|
-
* React hook to preview the assets returned for redeeming `shares` (ERC-4626 previewRedeem) via the leverage-yield API —
|
|
19
|
-
* `sodax.api.leverageYield.previewRedeem`.
|
|
20
|
-
*
|
|
21
|
-
* @example
|
|
22
|
-
* const { data } = useLeverageYieldApiPreviewRedeem({ params: { vault: '0x...', shares: '1000000000000000000' } });
|
|
23
|
-
*/
|
|
17
|
+
/** ERC-4626 `previewRedeem`: assets returned for `shares`. */
|
|
24
18
|
export const useLeverageYieldApiPreviewRedeem = ({
|
|
25
19
|
params,
|
|
26
20
|
queryOptions,
|
|
@@ -14,13 +14,7 @@ export type UseLeverageYieldApiPreviewWithdrawParams = ReadHookParams<
|
|
|
14
14
|
}
|
|
15
15
|
>;
|
|
16
16
|
|
|
17
|
-
/**
|
|
18
|
-
* React hook to preview the shares burned to withdraw `assets` (ERC-4626 previewWithdraw) via the leverage-yield API —
|
|
19
|
-
* `sodax.api.leverageYield.previewWithdraw`.
|
|
20
|
-
*
|
|
21
|
-
* @example
|
|
22
|
-
* const { data } = useLeverageYieldApiPreviewWithdraw({ params: { vault: '0x...', assets: '1000000000000000000' } });
|
|
23
|
-
*/
|
|
17
|
+
/** ERC-4626 `previewWithdraw`: shares burned to withdraw `assets`. */
|
|
24
18
|
export const useLeverageYieldApiPreviewWithdraw = ({
|
|
25
19
|
params,
|
|
26
20
|
queryOptions,
|
|
@@ -14,13 +14,6 @@ export type UseLeverageYieldApiShareBalanceParams = ReadHookParams<
|
|
|
14
14
|
}
|
|
15
15
|
>;
|
|
16
16
|
|
|
17
|
-
/**
|
|
18
|
-
* React hook to get an owner's vault share (lsoda*) balance via the leverage-yield API —
|
|
19
|
-
* `sodax.api.leverageYield.getShareBalance`.
|
|
20
|
-
*
|
|
21
|
-
* @example
|
|
22
|
-
* const { data } = useLeverageYieldApiShareBalance({ params: { vault: '0x...', owner: '1000000000000000000' } });
|
|
23
|
-
*/
|
|
24
17
|
export const useLeverageYieldApiShareBalance = ({
|
|
25
18
|
params,
|
|
26
19
|
queryOptions,
|