Skip to content

Commit

Permalink
fix: collateral not found error (#79)
Browse files Browse the repository at this point in the history
  • Loading branch information
peiman3 authored Dec 5, 2024
1 parent 25ad264 commit f42a3fd
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 17 deletions.
5 changes: 3 additions & 2 deletions liquidity/lib/useCollateralTypes/useCollateralTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,10 @@ export function useCollateralType(collateralSymbol?: string, customNetwork?: Net
const { network } = useNetwork();
const targetNetwork = customNetwork || network;

const { data: collateralTypes } = useCollateralTypes();
const { data: collateralTypes } = useCollateralTypes(true, customNetwork);

return useQuery({
enabled: Boolean(targetNetwork?.id && targetNetwork?.preset && collateralTypes),
enabled: Boolean(targetNetwork?.id && targetNetwork?.preset && !!collateralTypes?.length),
queryKey: [
`${targetNetwork?.id}-${targetNetwork?.preset}`,
'CollateralType',
Expand Down
17 changes: 4 additions & 13 deletions liquidity/lib/useTransferableSynthetix/useTransferableSynthetix.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
import { useQuery } from '@tanstack/react-query';
import { useNetwork, useProvider, useWallet } from '@snx-v3/useBlockchain';
import { MAINNET, useProviderForChain, useWallet } from '@snx-v3/useBlockchain';
import { Wei, wei } from '@synthetixio/wei';
import { ethers } from 'ethers';
import { useCollateralType } from '@snx-v3/useCollateralTypes';

export function useTransferableSynthetix() {
const { network } = useNetwork();
const { activeWallet } = useWallet();
const provider = useProvider();
const { data: snxCollateral } = useCollateralType('SNX');
const provider = useProviderForChain(MAINNET);
const { data: snxCollateral } = useCollateralType('SNX', MAINNET);

const accountAddress = activeWallet?.address;
const snxAddress = snxCollateral?.tokenAddress;

return useQuery({
enabled: Boolean(provider && accountAddress && snxAddress),
queryKey: [
`${network?.id}-${network?.preset}`,
`${MAINNET?.id}-${MAINNET?.preset}`,
'TransferableSynthetix',
{ address: activeWallet?.address },
],
Expand All @@ -34,14 +33,6 @@ export function useTransferableSynthetix() {
provider
);
try {
// Cannon case
if (network?.name === 'cannon') {
const balanceOf = await contract.balanceOf(accountAddress);
return {
transferable: wei(balanceOf),
};
}

// Normal case for SNX case
const [transferableSynthetix, collateral] = await Promise.all([
contract.transferableSynthetix(accountAddress),
Expand Down
4 changes: 2 additions & 2 deletions liquidity/ui/src/components/Migration/StepSummary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
} from '@chakra-ui/react';
import { wei } from '@synthetixio/wei';
import { useV2Position } from '@snx-v3/useV2Position';
import { Network } from '@snx-v3/useBlockchain';
import { MAINNET, Network } from '@snx-v3/useBlockchain';
import { InfoIcon } from '@chakra-ui/icons';
import { useMigrate } from '@snx-v3/useMigrate';
import { StepSuccess } from './StepSuccess';
Expand All @@ -38,7 +38,7 @@ export const StepSummary = ({
onConfirm: (accountId: string) => void;
network: Network;
}) => {
const { data: snxCollateral } = useCollateralType('SNX');
const { data: snxCollateral } = useCollateralType('SNX', MAINNET);
const [isUnderstanding, setIsUnderstanding] = useState(false);
const { data } = useV2Position(network);
const { migrate, transaction, isLoading, isSuccess, accountId } = useMigrate();
Expand Down

0 comments on commit f42a3fd

Please sign in to comment.