66 useGetVeDelegateBalance ,
77 useGetTokenUsdPrice ,
88 useGetCustomTokenBalances ,
9+ useGetErc20Balance ,
910} from '..' ;
1011import { useVeChainKitConfig } from '@/providers' ;
1112import { getConfig } from '@/config' ;
@@ -16,6 +17,7 @@ type UseBalancesProps = {
1617
1718export const useBalances = ( { address = '' } : UseBalancesProps ) => {
1819 const { network } = useVeChainKitConfig ( ) ;
20+ const config = getConfig ( network . type ) ;
1921
2022 // Base token balances
2123 const { data : vetData , isLoading : vetLoading } = useAccountBalance ( address ) ;
@@ -31,6 +33,8 @@ export const useBalances = ({ address = '' }: UseBalancesProps) => {
3133 useGetVot3Balance ( address ) ;
3234 const { data : veDelegateBalance , isLoading : veDelegateLoading } =
3335 useGetVeDelegateBalance ( address ) ;
36+ const { data : gloDollarBalance , isLoading : gloDollarLoading } =
37+ useGetErc20Balance ( config . gloDollarContractAddress , address ) ;
3438
3539 // Custom token balances
3640 const customTokenBalancesQueries = useGetCustomTokenBalances ( address ) ;
@@ -50,15 +54,17 @@ export const useBalances = ({ address = '' }: UseBalancesProps) => {
5054 b3trUsdPriceLoading ||
5155 veDelegateLoading ||
5256 vthoUsdPriceLoading ||
53- customTokensLoading ;
57+ customTokensLoading ||
58+ gloDollarLoading ;
5459
5560 // Get contract addresses from config
5661 const contractAddresses = {
5762 vet : '0x' ,
58- vtho : getConfig ( network . type ) . vthoContractAddress ,
59- b3tr : getConfig ( network . type ) . b3trContractAddress ,
60- vot3 : getConfig ( network . type ) . vot3ContractAddress ,
61- veDelegate : getConfig ( network . type ) . veDelegate ,
63+ vtho : config . vthoContractAddress ,
64+ b3tr : config . b3trContractAddress ,
65+ vot3 : config . vot3ContractAddress ,
66+ veDelegate : config . veDelegate ,
67+ USDGLO : config . gloDollarContractAddress ,
6268 } ;
6369
6470 // Base balances using contract addresses
@@ -93,6 +99,12 @@ export const useBalances = ({ address = '' }: UseBalancesProps) => {
9399 symbol : 'veDelegate' ,
94100 priceAddress : contractAddresses . b3tr , // using b3tr price for veDelegate
95101 } ,
102+ {
103+ address : contractAddresses . USDGLO ,
104+ value : gloDollarBalance ?. scaled ?? '0' ,
105+ symbol : 'USDGLO' ,
106+ priceAddress : contractAddresses . USDGLO ,
107+ } ,
96108 ] ;
97109
98110 // Add custom token balances
@@ -112,6 +124,7 @@ export const useBalances = ({ address = '' }: UseBalancesProps) => {
112124 { address : contractAddresses . vet , price : vetUsdPrice || 0 } ,
113125 { address : contractAddresses . vtho , price : vthoUsdPrice || 0 } ,
114126 { address : contractAddresses . b3tr , price : b3trUsdPrice || 0 } ,
127+ { address : contractAddresses . USDGLO , price : 1 } , // gloDollar is pegged to 1 USD
115128 ] ;
116129
117130 // Compute total balance
0 commit comments