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