@sodax/dapp-kit 0.0.1-rc.29 → 0.0.1-rc.30
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 +37 -37
- package/dist/index.d.mts +1425 -0
- package/dist/index.d.ts +1425 -5
- package/dist/index.js +364 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +347 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
- package/src/contexts/index.ts +1 -1
- package/src/hooks/bridge/useGetBridgeableAmount.ts +1 -1
- package/src/hooks/index.ts +1 -0
- package/src/hooks/shared/useDeriveUserWalletAddress.ts +1 -1
- package/src/hooks/staking/index.ts +19 -0
- package/src/hooks/staking/useCancelUnstake.ts +52 -0
- package/src/hooks/staking/useClaim.ts +46 -0
- package/src/hooks/staking/useConvertedAssets.ts +47 -0
- package/src/hooks/staking/useInstantUnstake.ts +50 -0
- package/src/hooks/staking/useInstantUnstakeAllowance.ts +59 -0
- package/src/hooks/staking/useInstantUnstakeApprove.ts +52 -0
- package/src/hooks/staking/useInstantUnstakeRatio.ts +54 -0
- package/src/hooks/staking/useStake.ts +47 -0
- package/src/hooks/staking/useStakeAllowance.ts +57 -0
- package/src/hooks/staking/useStakeApprove.ts +50 -0
- package/src/hooks/staking/useStakeRatio.ts +53 -0
- package/src/hooks/staking/useStakingConfig.ts +40 -0
- package/src/hooks/staking/useStakingInfo.ts +50 -0
- package/src/hooks/staking/useUnstake.ts +54 -0
- package/src/hooks/staking/useUnstakeAllowance.ts +58 -0
- package/src/hooks/staking/useUnstakeApprove.ts +52 -0
- package/src/hooks/staking/useUnstakingInfo.ts +53 -0
- package/src/hooks/staking/useUnstakingInfoWithPenalty.ts +59 -0
- package/src/index.ts +0 -1
- package/src/providers/SodaxProvider.tsx +1 -1
- package/dist/contexts/index.d.ts +0 -9
- package/dist/contexts/index.d.ts.map +0 -1
- package/dist/core/index.d.ts +0 -3
- package/dist/core/index.d.ts.map +0 -1
- package/dist/hooks/backend/index.d.ts +0 -17
- package/dist/hooks/backend/index.d.ts.map +0 -1
- package/dist/hooks/backend/useBackendAllMoneyMarketAssets.d.ts +0 -37
- package/dist/hooks/backend/useBackendAllMoneyMarketAssets.d.ts.map +0 -1
- package/dist/hooks/backend/useBackendAllMoneyMarketBorrowers.d.ts +0 -45
- package/dist/hooks/backend/useBackendAllMoneyMarketBorrowers.d.ts.map +0 -1
- package/dist/hooks/backend/useBackendIntentByHash.d.ts +0 -36
- package/dist/hooks/backend/useBackendIntentByHash.d.ts.map +0 -1
- package/dist/hooks/backend/useBackendIntentByTxHash.d.ts +0 -35
- package/dist/hooks/backend/useBackendIntentByTxHash.d.ts.map +0 -1
- package/dist/hooks/backend/useBackendMoneyMarketAsset.d.ts +0 -38
- package/dist/hooks/backend/useBackendMoneyMarketAsset.d.ts.map +0 -1
- package/dist/hooks/backend/useBackendMoneyMarketAssetBorrowers.d.ts +0 -47
- package/dist/hooks/backend/useBackendMoneyMarketAssetBorrowers.d.ts.map +0 -1
- package/dist/hooks/backend/useBackendMoneyMarketAssetSuppliers.d.ts +0 -47
- package/dist/hooks/backend/useBackendMoneyMarketAssetSuppliers.d.ts.map +0 -1
- package/dist/hooks/backend/useBackendMoneyMarketPosition.d.ts +0 -37
- package/dist/hooks/backend/useBackendMoneyMarketPosition.d.ts.map +0 -1
- package/dist/hooks/backend/useBackendOrderbook.d.ts +0 -46
- package/dist/hooks/backend/useBackendOrderbook.d.ts.map +0 -1
- package/dist/hooks/bridge/index.d.ts +0 -6
- package/dist/hooks/bridge/index.d.ts.map +0 -1
- package/dist/hooks/bridge/useBridge.d.ts +0 -33
- package/dist/hooks/bridge/useBridge.d.ts.map +0 -1
- package/dist/hooks/bridge/useBridgeAllowance.d.ts +0 -23
- package/dist/hooks/bridge/useBridgeAllowance.d.ts.map +0 -1
- package/dist/hooks/bridge/useBridgeApprove.d.ts +0 -29
- package/dist/hooks/bridge/useBridgeApprove.d.ts.map +0 -1
- package/dist/hooks/bridge/useGetBridgeableAmount.d.ts +0 -26
- package/dist/hooks/bridge/useGetBridgeableAmount.d.ts.map +0 -1
- package/dist/hooks/bridge/useGetBridgeableTokens.d.ts +0 -37
- package/dist/hooks/bridge/useGetBridgeableTokens.d.ts.map +0 -1
- package/dist/hooks/index.d.ts +0 -7
- package/dist/hooks/index.d.ts.map +0 -1
- package/dist/hooks/mm/index.d.ts +0 -9
- package/dist/hooks/mm/index.d.ts.map +0 -1
- package/dist/hooks/mm/useBorrow.d.ts +0 -35
- package/dist/hooks/mm/useBorrow.d.ts.map +0 -1
- package/dist/hooks/mm/useMMAllowance.d.ts +0 -26
- package/dist/hooks/mm/useMMAllowance.d.ts.map +0 -1
- package/dist/hooks/mm/useMMApprove.d.ts +0 -27
- package/dist/hooks/mm/useMMApprove.d.ts.map +0 -1
- package/dist/hooks/mm/useRepay.d.ts +0 -35
- package/dist/hooks/mm/useRepay.d.ts.map +0 -1
- package/dist/hooks/mm/useReservesData.d.ts +0 -19
- package/dist/hooks/mm/useReservesData.d.ts.map +0 -1
- package/dist/hooks/mm/useReservesHumanized.d.ts +0 -21
- package/dist/hooks/mm/useReservesHumanized.d.ts.map +0 -1
- package/dist/hooks/mm/useReservesList.d.ts +0 -18
- package/dist/hooks/mm/useReservesList.d.ts.map +0 -1
- package/dist/hooks/mm/useReservesUsdFormat.d.ts +0 -23
- package/dist/hooks/mm/useReservesUsdFormat.d.ts.map +0 -1
- package/dist/hooks/mm/useSupply.d.ts +0 -34
- package/dist/hooks/mm/useSupply.d.ts.map +0 -1
- package/dist/hooks/mm/useUserFormattedSummary.d.ts +0 -21
- package/dist/hooks/mm/useUserFormattedSummary.d.ts.map +0 -1
- package/dist/hooks/mm/useUserReservesData.d.ts +0 -20
- package/dist/hooks/mm/useUserReservesData.d.ts.map +0 -1
- package/dist/hooks/mm/useWithdraw.d.ts +0 -33
- package/dist/hooks/mm/useWithdraw.d.ts.map +0 -1
- package/dist/hooks/provider/index.d.ts +0 -3
- package/dist/hooks/provider/index.d.ts.map +0 -1
- package/dist/hooks/provider/useHubProvider.d.ts +0 -3
- package/dist/hooks/provider/useHubProvider.d.ts.map +0 -1
- package/dist/hooks/provider/useSpokeProvider.d.ts +0 -18
- package/dist/hooks/provider/useSpokeProvider.d.ts.map +0 -1
- package/dist/hooks/shared/index.d.ts +0 -6
- package/dist/hooks/shared/index.d.ts.map +0 -1
- package/dist/hooks/shared/useDeriveUserWalletAddress.d.ts +0 -24
- package/dist/hooks/shared/useDeriveUserWalletAddress.d.ts.map +0 -1
- package/dist/hooks/shared/useEstimateGas.d.ts +0 -4
- package/dist/hooks/shared/useEstimateGas.d.ts.map +0 -1
- package/dist/hooks/shared/useRequestTrustline.d.ts +0 -44
- package/dist/hooks/shared/useRequestTrustline.d.ts.map +0 -1
- package/dist/hooks/shared/useSodaxContext.d.ts +0 -8
- package/dist/hooks/shared/useSodaxContext.d.ts.map +0 -1
- package/dist/hooks/shared/useStellarTrustlineCheck.d.ts +0 -40
- package/dist/hooks/shared/useStellarTrustlineCheck.d.ts.map +0 -1
- package/dist/hooks/swap/index.d.ts +0 -7
- package/dist/hooks/swap/index.d.ts.map +0 -1
- package/dist/hooks/swap/useCancelSwap.d.ts +0 -29
- package/dist/hooks/swap/useCancelSwap.d.ts.map +0 -1
- package/dist/hooks/swap/useQuote.d.ts +0 -39
- package/dist/hooks/swap/useQuote.d.ts.map +0 -1
- package/dist/hooks/swap/useStatus.d.ts +0 -31
- package/dist/hooks/swap/useStatus.d.ts.map +0 -1
- package/dist/hooks/swap/useSwap.d.ts +0 -29
- package/dist/hooks/swap/useSwap.d.ts.map +0 -1
- package/dist/hooks/swap/useSwapAllowance.d.ts +0 -23
- package/dist/hooks/swap/useSwapAllowance.d.ts.map +0 -1
- package/dist/hooks/swap/useSwapApprove.d.ts +0 -25
- package/dist/hooks/swap/useSwapApprove.d.ts.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/providers/SodaxProvider.d.ts +0 -12
- package/dist/providers/SodaxProvider.d.ts.map +0 -1
- package/dist/providers/index.d.ts +0 -2
- package/dist/providers/index.d.ts.map +0 -1
- package/dist/types.d.ts +0 -17
- package/dist/types.d.ts.map +0 -1
- package/src/types.ts +0 -22
package/dist/index.js
CHANGED
|
@@ -687,6 +687,352 @@ function useGetBridgeableTokens(from, to, token) {
|
|
|
687
687
|
enabled: !!from && !!to && !!token
|
|
688
688
|
});
|
|
689
689
|
}
|
|
690
|
+
function useStake(spokeProvider) {
|
|
691
|
+
const { sodax } = useSodaxContext();
|
|
692
|
+
return reactQuery.useMutation({
|
|
693
|
+
mutationFn: async (params) => {
|
|
694
|
+
if (!spokeProvider) {
|
|
695
|
+
throw new Error("Spoke provider not found");
|
|
696
|
+
}
|
|
697
|
+
const result = await sodax.staking.stake(params, spokeProvider);
|
|
698
|
+
if (!result.ok) {
|
|
699
|
+
throw new Error(`Stake failed: ${result.error.code}`);
|
|
700
|
+
}
|
|
701
|
+
return result.value;
|
|
702
|
+
}
|
|
703
|
+
});
|
|
704
|
+
}
|
|
705
|
+
function useStakeApprove(spokeProvider) {
|
|
706
|
+
const { sodax } = useSodaxContext();
|
|
707
|
+
return reactQuery.useMutation({
|
|
708
|
+
mutationFn: async (params) => {
|
|
709
|
+
if (!spokeProvider) {
|
|
710
|
+
throw new Error("Spoke provider not found");
|
|
711
|
+
}
|
|
712
|
+
const result = await sodax.staking.approve({
|
|
713
|
+
params: { ...params, action: "stake" },
|
|
714
|
+
spokeProvider
|
|
715
|
+
});
|
|
716
|
+
if (!result.ok) {
|
|
717
|
+
throw new Error(`Stake approval failed: ${result.error.code}`);
|
|
718
|
+
}
|
|
719
|
+
return result.value;
|
|
720
|
+
}
|
|
721
|
+
});
|
|
722
|
+
}
|
|
723
|
+
function useStakeAllowance(params, spokeProvider) {
|
|
724
|
+
const { sodax } = useSodaxContext();
|
|
725
|
+
return reactQuery.useQuery({
|
|
726
|
+
queryKey: ["soda", "stakeAllowance", params, spokeProvider?.chainConfig.chain.id],
|
|
727
|
+
queryFn: async () => {
|
|
728
|
+
if (!params || !spokeProvider) {
|
|
729
|
+
return false;
|
|
730
|
+
}
|
|
731
|
+
const result = await sodax.staking.isAllowanceValid({
|
|
732
|
+
params: { ...params, action: "stake" },
|
|
733
|
+
spokeProvider
|
|
734
|
+
});
|
|
735
|
+
if (!result.ok) {
|
|
736
|
+
throw new Error(`Allowance check failed: ${result.error.code}`);
|
|
737
|
+
}
|
|
738
|
+
return result.value;
|
|
739
|
+
},
|
|
740
|
+
enabled: !!params && !!spokeProvider,
|
|
741
|
+
refetchInterval: 5e3
|
|
742
|
+
// Refetch every 5 seconds
|
|
743
|
+
});
|
|
744
|
+
}
|
|
745
|
+
function useUnstake(spokeProvider) {
|
|
746
|
+
const { sodax } = useSodaxContext();
|
|
747
|
+
const queryClient = reactQuery.useQueryClient();
|
|
748
|
+
return reactQuery.useMutation({
|
|
749
|
+
mutationFn: async (params) => {
|
|
750
|
+
if (!spokeProvider) {
|
|
751
|
+
throw new Error("Spoke provider not found");
|
|
752
|
+
}
|
|
753
|
+
const result = await sodax.staking.unstake({ ...params, action: "unstake" }, spokeProvider);
|
|
754
|
+
if (!result.ok) {
|
|
755
|
+
throw new Error(`Unstake failed: ${result.error.code}`);
|
|
756
|
+
}
|
|
757
|
+
return result.value;
|
|
758
|
+
},
|
|
759
|
+
onSuccess: () => {
|
|
760
|
+
queryClient.invalidateQueries({ queryKey: ["stakingInfo"] });
|
|
761
|
+
queryClient.invalidateQueries({ queryKey: ["unstakingInfo"] });
|
|
762
|
+
queryClient.invalidateQueries({ queryKey: ["unstakingInfoWithPenalty"] });
|
|
763
|
+
}
|
|
764
|
+
});
|
|
765
|
+
}
|
|
766
|
+
function useClaim(spokeProvider) {
|
|
767
|
+
const { sodax } = useSodaxContext();
|
|
768
|
+
return reactQuery.useMutation({
|
|
769
|
+
mutationFn: async (params) => {
|
|
770
|
+
if (!spokeProvider) {
|
|
771
|
+
throw new Error("Spoke provider not found");
|
|
772
|
+
}
|
|
773
|
+
const result = await sodax.staking.claim({ ...params, action: "claim" }, spokeProvider);
|
|
774
|
+
if (!result.ok) {
|
|
775
|
+
throw new Error(`Claim failed: ${result.error.code}`);
|
|
776
|
+
}
|
|
777
|
+
return result.value;
|
|
778
|
+
}
|
|
779
|
+
});
|
|
780
|
+
}
|
|
781
|
+
function useCancelUnstake(spokeProvider) {
|
|
782
|
+
const { sodax } = useSodaxContext();
|
|
783
|
+
const queryClient = reactQuery.useQueryClient();
|
|
784
|
+
return reactQuery.useMutation({
|
|
785
|
+
mutationFn: async (params) => {
|
|
786
|
+
if (!spokeProvider) {
|
|
787
|
+
throw new Error("Spoke provider not available");
|
|
788
|
+
}
|
|
789
|
+
const result = await sodax.staking.cancelUnstake({ ...params, action: "cancelUnstake" }, spokeProvider);
|
|
790
|
+
if (!result.ok) {
|
|
791
|
+
throw new Error(`Cancel unstake failed: ${result.error.code}`);
|
|
792
|
+
}
|
|
793
|
+
return result.value;
|
|
794
|
+
},
|
|
795
|
+
onSuccess: () => {
|
|
796
|
+
queryClient.invalidateQueries({ queryKey: ["stakingInfo"] });
|
|
797
|
+
queryClient.invalidateQueries({ queryKey: ["unstakingInfo"] });
|
|
798
|
+
queryClient.invalidateQueries({ queryKey: ["unstakingInfoWithPenalty"] });
|
|
799
|
+
}
|
|
800
|
+
});
|
|
801
|
+
}
|
|
802
|
+
function useStakingInfo(spokeProvider, refetchInterval = 5e3) {
|
|
803
|
+
const { sodax } = useSodaxContext();
|
|
804
|
+
return reactQuery.useQuery({
|
|
805
|
+
queryKey: ["soda", "stakingInfo", spokeProvider?.chainConfig.chain.id],
|
|
806
|
+
queryFn: async () => {
|
|
807
|
+
if (!spokeProvider) {
|
|
808
|
+
throw new Error("Spoke provider not found");
|
|
809
|
+
}
|
|
810
|
+
const result = await sodax.staking.getStakingInfoFromSpoke(spokeProvider);
|
|
811
|
+
if (!result.ok) {
|
|
812
|
+
throw new Error(`Failed to fetch staking info: ${result.error.code}`);
|
|
813
|
+
}
|
|
814
|
+
return result.value;
|
|
815
|
+
},
|
|
816
|
+
enabled: !!spokeProvider,
|
|
817
|
+
refetchInterval
|
|
818
|
+
});
|
|
819
|
+
}
|
|
820
|
+
function useUnstakingInfoWithPenalty(userAddress, spokeProvider, refetchInterval = 5e3) {
|
|
821
|
+
const { sodax } = useSodaxContext();
|
|
822
|
+
return reactQuery.useQuery({
|
|
823
|
+
queryKey: ["soda", "unstakingInfoWithPenalty", spokeProvider?.chainConfig.chain.id, userAddress],
|
|
824
|
+
queryFn: async () => {
|
|
825
|
+
if (!spokeProvider) {
|
|
826
|
+
throw new Error("Spoke provider not found");
|
|
827
|
+
}
|
|
828
|
+
const penaltyResult = await sodax.staking.getUnstakingInfoWithPenalty(spokeProvider);
|
|
829
|
+
if (!penaltyResult.ok) {
|
|
830
|
+
throw new Error(`Failed to fetch unstaking info with penalty: ${penaltyResult.error.code}`);
|
|
831
|
+
}
|
|
832
|
+
return penaltyResult.value;
|
|
833
|
+
},
|
|
834
|
+
enabled: !!spokeProvider && !!userAddress,
|
|
835
|
+
refetchInterval
|
|
836
|
+
});
|
|
837
|
+
}
|
|
838
|
+
function useStakingConfig(refetchInterval = 3e4) {
|
|
839
|
+
const { sodax } = useSodaxContext();
|
|
840
|
+
return reactQuery.useQuery({
|
|
841
|
+
queryKey: ["soda", "stakingConfig"],
|
|
842
|
+
queryFn: async () => {
|
|
843
|
+
const result = await sodax.staking.getStakingConfig();
|
|
844
|
+
if (!result.ok) {
|
|
845
|
+
throw new Error(`Failed to fetch staking config: ${result.error.code}`);
|
|
846
|
+
}
|
|
847
|
+
return result.value;
|
|
848
|
+
},
|
|
849
|
+
refetchInterval
|
|
850
|
+
});
|
|
851
|
+
}
|
|
852
|
+
function useStakeRatio(amount, refetchInterval = 1e4) {
|
|
853
|
+
const { sodax } = useSodaxContext();
|
|
854
|
+
return reactQuery.useQuery({
|
|
855
|
+
queryKey: ["soda", "stakeRatio", amount?.toString()],
|
|
856
|
+
queryFn: async () => {
|
|
857
|
+
if (!amount || amount <= 0n) {
|
|
858
|
+
throw new Error("Amount must be greater than 0");
|
|
859
|
+
}
|
|
860
|
+
if (!sodax?.staking) {
|
|
861
|
+
throw new Error("Staking service not available");
|
|
862
|
+
}
|
|
863
|
+
const result = await sodax.staking.getStakeRatio(amount);
|
|
864
|
+
if (!result.ok) {
|
|
865
|
+
throw new Error(`Failed to fetch stake ratio: ${result.error.code}`);
|
|
866
|
+
}
|
|
867
|
+
return result.value;
|
|
868
|
+
},
|
|
869
|
+
enabled: !!amount && amount > 0n && !!sodax?.staking,
|
|
870
|
+
refetchInterval
|
|
871
|
+
});
|
|
872
|
+
}
|
|
873
|
+
function useInstantUnstakeRatio(amount, refetchInterval = 1e4) {
|
|
874
|
+
const { sodax } = useSodaxContext();
|
|
875
|
+
console.log("useInstantUnstakeRatio hook called with:", { amount: amount?.toString(), sodax: !!sodax });
|
|
876
|
+
return reactQuery.useQuery({
|
|
877
|
+
queryKey: ["soda", "instantUnstakeRatio", amount?.toString()],
|
|
878
|
+
queryFn: async () => {
|
|
879
|
+
console.log("useInstantUnstakeRatio queryFn called with amount:", amount?.toString());
|
|
880
|
+
if (!amount || amount <= 0n) {
|
|
881
|
+
throw new Error("Amount must be greater than 0");
|
|
882
|
+
}
|
|
883
|
+
if (!sodax?.staking) {
|
|
884
|
+
throw new Error("Staking service not available");
|
|
885
|
+
}
|
|
886
|
+
const result = await sodax.staking.getInstantUnstakeRatio(amount);
|
|
887
|
+
if (!result.ok) {
|
|
888
|
+
throw new Error(`Failed to fetch instant unstake ratio: ${result.error.code}`);
|
|
889
|
+
}
|
|
890
|
+
return result.value;
|
|
891
|
+
},
|
|
892
|
+
enabled: !!amount && amount > 0n && !!sodax?.staking,
|
|
893
|
+
refetchInterval
|
|
894
|
+
});
|
|
895
|
+
}
|
|
896
|
+
function useConvertedAssets(amount, refetchInterval = 1e4) {
|
|
897
|
+
const { sodax } = useSodaxContext();
|
|
898
|
+
console.log("useConvertedAssets hook called with:", { amount: amount?.toString(), sodax: !!sodax });
|
|
899
|
+
return reactQuery.useQuery({
|
|
900
|
+
queryKey: ["soda", "convertedAssets", amount?.toString()],
|
|
901
|
+
queryFn: async () => {
|
|
902
|
+
console.log("useConvertedAssets queryFn called with amount:", amount?.toString());
|
|
903
|
+
if (!amount || amount <= 0n) {
|
|
904
|
+
throw new Error("Amount must be greater than 0");
|
|
905
|
+
}
|
|
906
|
+
const result = await sodax.staking.getConvertedAssets(amount);
|
|
907
|
+
if (!result.ok) {
|
|
908
|
+
throw new Error(`Failed to fetch converted assets: ${result.error.code}`);
|
|
909
|
+
}
|
|
910
|
+
return result.value;
|
|
911
|
+
},
|
|
912
|
+
enabled: !!amount && amount > 0n && !!sodax?.staking,
|
|
913
|
+
refetchInterval
|
|
914
|
+
});
|
|
915
|
+
}
|
|
916
|
+
function useInstantUnstake(spokeProvider) {
|
|
917
|
+
const { sodax } = useSodaxContext();
|
|
918
|
+
return reactQuery.useMutation({
|
|
919
|
+
mutationFn: async (params) => {
|
|
920
|
+
if (!spokeProvider) {
|
|
921
|
+
throw new Error("spokeProvider is not found");
|
|
922
|
+
}
|
|
923
|
+
const result = await sodax.staking.instantUnstake({ ...params, action: "instantUnstake" }, spokeProvider);
|
|
924
|
+
if (!result.ok) {
|
|
925
|
+
throw new Error(`Instant unstake failed: ${result.error.code}`);
|
|
926
|
+
}
|
|
927
|
+
return result.value;
|
|
928
|
+
},
|
|
929
|
+
onError: (error) => {
|
|
930
|
+
console.error("Instant unstake error:", error);
|
|
931
|
+
}
|
|
932
|
+
});
|
|
933
|
+
}
|
|
934
|
+
function useUnstakeAllowance(params, spokeProvider) {
|
|
935
|
+
const { sodax } = useSodaxContext();
|
|
936
|
+
return reactQuery.useQuery({
|
|
937
|
+
queryKey: ["soda", "unstakeAllowance", params, spokeProvider?.chainConfig.chain.id],
|
|
938
|
+
queryFn: async () => {
|
|
939
|
+
if (!params || !spokeProvider) {
|
|
940
|
+
return false;
|
|
941
|
+
}
|
|
942
|
+
const result = await sodax.staking.isAllowanceValid({
|
|
943
|
+
params: { ...params, action: "unstake" },
|
|
944
|
+
spokeProvider
|
|
945
|
+
});
|
|
946
|
+
if (!result.ok) {
|
|
947
|
+
console.error(`Unstake allowance check failed: ${result.error.code}, error: ${result.error.error}`);
|
|
948
|
+
throw new Error(`Unstake allowance check failed: ${result.error.code}`);
|
|
949
|
+
}
|
|
950
|
+
return result.value;
|
|
951
|
+
},
|
|
952
|
+
enabled: !!params && !!spokeProvider,
|
|
953
|
+
refetchInterval: 5e3
|
|
954
|
+
// Refetch every 5 seconds
|
|
955
|
+
});
|
|
956
|
+
}
|
|
957
|
+
function useUnstakeApprove(spokeProvider) {
|
|
958
|
+
const { sodax } = useSodaxContext();
|
|
959
|
+
return reactQuery.useMutation({
|
|
960
|
+
mutationFn: async (params) => {
|
|
961
|
+
console.log("useUnstakeApprove called with params:", params);
|
|
962
|
+
if (!spokeProvider) {
|
|
963
|
+
throw new Error("Spoke provider not found");
|
|
964
|
+
}
|
|
965
|
+
const result = await sodax.staking.approve({
|
|
966
|
+
params: { ...params, action: "unstake" },
|
|
967
|
+
spokeProvider
|
|
968
|
+
});
|
|
969
|
+
if (!result.ok) {
|
|
970
|
+
throw new Error(`Unstake approval failed: ${result.error.code}`);
|
|
971
|
+
}
|
|
972
|
+
return result.value;
|
|
973
|
+
}
|
|
974
|
+
});
|
|
975
|
+
}
|
|
976
|
+
function useUnstakingInfo(userAddress, spokeProvider, refetchInterval = 5e3) {
|
|
977
|
+
const { sodax } = useSodaxContext();
|
|
978
|
+
return reactQuery.useQuery({
|
|
979
|
+
queryKey: ["soda", "unstakingInfoWithPenalty", spokeProvider?.chainConfig.chain.id, userAddress],
|
|
980
|
+
queryFn: async () => {
|
|
981
|
+
if (!spokeProvider || !userAddress) {
|
|
982
|
+
throw new Error("Spoke provider or user address not found");
|
|
983
|
+
}
|
|
984
|
+
const result = await sodax.staking.getUnstakingInfo(spokeProvider);
|
|
985
|
+
if (!result.ok) {
|
|
986
|
+
throw new Error(`Failed to fetch unstaking info: ${result.error.code}`);
|
|
987
|
+
}
|
|
988
|
+
return result.value;
|
|
989
|
+
},
|
|
990
|
+
enabled: !!spokeProvider && !!userAddress,
|
|
991
|
+
refetchInterval
|
|
992
|
+
});
|
|
993
|
+
}
|
|
994
|
+
function useInstantUnstakeApprove(spokeProvider) {
|
|
995
|
+
const { sodax } = useSodaxContext();
|
|
996
|
+
return reactQuery.useMutation({
|
|
997
|
+
mutationFn: async (params) => {
|
|
998
|
+
console.log("useInstantUnstakeApprove called with params:", params);
|
|
999
|
+
if (!spokeProvider) {
|
|
1000
|
+
throw new Error("Spoke provider not found");
|
|
1001
|
+
}
|
|
1002
|
+
const result = await sodax.staking.approve({
|
|
1003
|
+
params: { ...params, action: "instantUnstake" },
|
|
1004
|
+
spokeProvider
|
|
1005
|
+
});
|
|
1006
|
+
if (!result.ok) {
|
|
1007
|
+
throw new Error(`Instant unstake approval failed: ${result.error.code}`);
|
|
1008
|
+
}
|
|
1009
|
+
return result.value;
|
|
1010
|
+
}
|
|
1011
|
+
});
|
|
1012
|
+
}
|
|
1013
|
+
function useInstantUnstakeAllowance(params, spokeProvider) {
|
|
1014
|
+
const { sodax } = useSodaxContext();
|
|
1015
|
+
return reactQuery.useQuery({
|
|
1016
|
+
queryKey: ["soda", "instantUnstakeAllowance", params, spokeProvider?.chainConfig.chain.id],
|
|
1017
|
+
queryFn: async () => {
|
|
1018
|
+
if (!params || !spokeProvider) {
|
|
1019
|
+
return false;
|
|
1020
|
+
}
|
|
1021
|
+
const result = await sodax.staking.isAllowanceValid({
|
|
1022
|
+
params: { ...params, action: "instantUnstake" },
|
|
1023
|
+
spokeProvider
|
|
1024
|
+
});
|
|
1025
|
+
if (!result.ok) {
|
|
1026
|
+
console.error(`Unstake allowance check failed: ${result.error.code}, error: ${result.error.error}`);
|
|
1027
|
+
throw new Error(`Unstake allowance check failed: ${result.error.code}`);
|
|
1028
|
+
}
|
|
1029
|
+
return result.value;
|
|
1030
|
+
},
|
|
1031
|
+
enabled: !!params && !!spokeProvider,
|
|
1032
|
+
refetchInterval: 5e3
|
|
1033
|
+
// Refetch every 5 seconds
|
|
1034
|
+
});
|
|
1035
|
+
}
|
|
690
1036
|
var SodaxProvider = ({ children, testnet = false, config, rpcConfig }) => {
|
|
691
1037
|
const sodax = new sdk.Sodax(config);
|
|
692
1038
|
return /* @__PURE__ */ React__default.default.createElement(SodaxContext.Provider, { value: { sodax, testnet, rpcConfig } }, children);
|
|
@@ -715,11 +1061,18 @@ exports.useBridge = useBridge;
|
|
|
715
1061
|
exports.useBridgeAllowance = useBridgeAllowance;
|
|
716
1062
|
exports.useBridgeApprove = useBridgeApprove;
|
|
717
1063
|
exports.useCancelSwap = useCancelSwap;
|
|
1064
|
+
exports.useCancelUnstake = useCancelUnstake;
|
|
1065
|
+
exports.useClaim = useClaim;
|
|
1066
|
+
exports.useConvertedAssets = useConvertedAssets;
|
|
718
1067
|
exports.useDeriveUserWalletAddress = useDeriveUserWalletAddress;
|
|
719
1068
|
exports.useEstimateGas = useEstimateGas;
|
|
720
1069
|
exports.useGetBridgeableAmount = useGetBridgeableAmount;
|
|
721
1070
|
exports.useGetBridgeableTokens = useGetBridgeableTokens;
|
|
722
1071
|
exports.useHubProvider = useHubProvider;
|
|
1072
|
+
exports.useInstantUnstake = useInstantUnstake;
|
|
1073
|
+
exports.useInstantUnstakeAllowance = useInstantUnstakeAllowance;
|
|
1074
|
+
exports.useInstantUnstakeApprove = useInstantUnstakeApprove;
|
|
1075
|
+
exports.useInstantUnstakeRatio = useInstantUnstakeRatio;
|
|
723
1076
|
exports.useMMAllowance = useMMAllowance;
|
|
724
1077
|
exports.useMMApprove = useMMApprove;
|
|
725
1078
|
exports.useQuote = useQuote;
|
|
@@ -728,12 +1081,23 @@ exports.useRequestTrustline = useRequestTrustline;
|
|
|
728
1081
|
exports.useReservesData = useReservesData;
|
|
729
1082
|
exports.useSodaxContext = useSodaxContext;
|
|
730
1083
|
exports.useSpokeProvider = useSpokeProvider;
|
|
1084
|
+
exports.useStake = useStake;
|
|
1085
|
+
exports.useStakeAllowance = useStakeAllowance;
|
|
1086
|
+
exports.useStakeApprove = useStakeApprove;
|
|
1087
|
+
exports.useStakeRatio = useStakeRatio;
|
|
1088
|
+
exports.useStakingConfig = useStakingConfig;
|
|
1089
|
+
exports.useStakingInfo = useStakingInfo;
|
|
731
1090
|
exports.useStatus = useStatus;
|
|
732
1091
|
exports.useStellarTrustlineCheck = useStellarTrustlineCheck;
|
|
733
1092
|
exports.useSupply = useSupply;
|
|
734
1093
|
exports.useSwap = useSwap;
|
|
735
1094
|
exports.useSwapAllowance = useSwapAllowance;
|
|
736
1095
|
exports.useSwapApprove = useSwapApprove;
|
|
1096
|
+
exports.useUnstake = useUnstake;
|
|
1097
|
+
exports.useUnstakeAllowance = useUnstakeAllowance;
|
|
1098
|
+
exports.useUnstakeApprove = useUnstakeApprove;
|
|
1099
|
+
exports.useUnstakingInfo = useUnstakingInfo;
|
|
1100
|
+
exports.useUnstakingInfoWithPenalty = useUnstakingInfoWithPenalty;
|
|
737
1101
|
exports.useUserReservesData = useUserReservesData;
|
|
738
1102
|
exports.useWithdraw = useWithdraw;
|
|
739
1103
|
//# sourceMappingURL=index.js.map
|