Skip to content

Commit

Permalink
feat: add sui bonded token
Browse files Browse the repository at this point in the history
  • Loading branch information
icfor committed Nov 29, 2023
1 parent 2c2e04a commit cd2b11b
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 18 deletions.
8 changes: 8 additions & 0 deletions graphql/queries/bondedToken.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,11 @@ export const getOasisBondedToken = () => `
}
}
`;

export const getSuiBondedToken = () => `
query SuiBondedToken {
suiBondedToken {
bondedToken
}
}
`;
32 changes: 17 additions & 15 deletions graphql/queries/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
getOasisBondedToken,
getRadixBondedToken,
getSolanaBondedToken,
getSuiBondedToken,
} from "./bondedToken";
import { getEachCosmosCommission } from "./commission";
import { getEachCosmosInflation } from "./inflation";
Expand All @@ -27,26 +28,27 @@ import {
} from "./usersCount";

export {
getEachCosmosBondedToken,
getElrondBondedToken,
getRadixBondedToken,
getSolanaBondedToken,
getOasisBondedToken,
getAllCosmosTVL,
getCosmosUsersCount,
getEachCosmosAPY,
getElrondAPY,
getEachCosmosBondedToken,
getEachCosmosCommission,
getEachCosmosInflation,
getEachCosmosTVL,
getAllCosmosTVL,
getSolanaTVL,
getEachCosmosTokenSupply,
getEachCosmosUnbondingTime,
getElrondAPY,
getElrondBondedToken,
getElrondTVL,
getOasisTVL,
getRadixTVL,
getCosmosUsersCount,
getSolanaUsersCount,
getElrondUsersCount,
getOasisBondedToken,
getOasisTVL,
getOasisUsersCount,
getRadixBondedToken,
getRadixTVL,
getRadixUsersCount,
getEachCosmosTokenSupply,
getEachCosmosInflation,
getEachCosmosUnbondingTime,
getSolanaBondedToken,
getSolanaTVL,
getSolanaUsersCount,
getSuiBondedToken,
};
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ const NetworkCard: FC<CardProp> = (props: CardProp) => {
[network],
);

if (network.key === "sui") {
console.log("debug: index.tsx: networkSummary", network, networkSummary);
}
const isEmptyPopover =
networksWithoutPopover.has(network.graphql) ||
(!!networkSummary &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
getRadixTVL,
getSolanaBondedToken,
getSolanaTVL,
getSuiBondedToken,
} from "@graphql/queries";
import { useMemo, useState } from "react";

Expand Down Expand Up @@ -66,6 +67,11 @@ export const useNetworkHook = () => {
${getOasisTVL()}
`);

const [suiNetwork, setSuiNetwork] = useState(oasisNetworkParams);
const { loading: suiBondedLoading, data: suiBondedData } = useQuery(gql`
${getSuiBondedToken()}
`);

const [radixNetwork, setRadixNetwork] = useState(radixNetworkParams);
const { loading: radixBondedLoading, data: radixBondedData } = useQuery(gql`
${getRadixBondedToken()}
Expand Down Expand Up @@ -264,6 +270,20 @@ export const useNetworkHook = () => {
}
}, [oasisBondedData, oasisBondedLoading, oasisNetwork]);

useMemo(() => {
if (!suiBondedLoading && suiBondedData) {
const suiBondedToken = suiBondedData?.suiBondedToken
?.bondedToken as string;

const bonded = Number(suiBondedToken);
if (Number.isNaN(bonded)) {
return;
}

setSuiNetwork({ sui: { bonded, APY: 0, TVL: 0 } });
}
}, [suiBondedLoading, suiBondedData]);

useMemo(() => {
if (!radixTVLLoading && radixTVLData) {
const { radixTVL } = radixTVLData;
Expand Down Expand Up @@ -302,8 +322,9 @@ export const useNetworkHook = () => {
return {
cosmosNetworks,
elrondNetwork,
solanaNetwork,
oasisNetwork,
radixNetwork,
solanaNetwork,
suiNetwork,
};
};
6 changes: 4 additions & 2 deletions src/screens/staking/components/networks/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,18 @@ const Networks = () => {
const {
cosmosNetworks,
elrondNetwork,
solanaNetwork,
oasisNetwork,
radixNetwork,
solanaNetwork,
suiNetwork,
} = useNetworkHook();
const allNetworkInfo: NetworkProps = {
...cosmosNetworks,
...elrondNetwork,
...solanaNetwork,
...oasisNetwork,
...radixNetwork,
...solanaNetwork,
...suiNetwork,
};
const allNetworkData = allNetworkKeys
.map((x: string | number) => getNetworkInfo(x))
Expand Down

0 comments on commit cd2b11b

Please sign in to comment.