Skip to content

Commit

Permalink
fix: ultrasound issues (#264)
Browse files Browse the repository at this point in the history
  • Loading branch information
Rickk137 authored May 13, 2024
1 parent e2b8877 commit 7cd3e4d
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 16 deletions.
22 changes: 13 additions & 9 deletions ultrasound/ui/hooks/SNXUSDBalanceOfBuyBackContract.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
import { useGetNetwork, useProviderForChain } from '@snx-v3/useBlockchain';
import { useQuery } from '@tanstack/react-query';
import { BigNumber, Contract, providers } from 'ethers';
import { BigNumber, Contract } from 'ethers';

const USDC = new Contract(
'0x09d51516F38980035153a554c26Df3C6f51a23C3',
['function balanceOf(address _owner) view returns (uint256 balance)'],
new providers.JsonRpcProvider('https://base.llamarpc.com')
);
export function SNXUSDBalanceOfBuyBackContract(contractAddress: string) {
const baseNetwork = useGetNetwork(`0x${Number(8453).toString(16)}`);
const baseProvider = useProviderForChain(baseNetwork);

export function SNXUSDBalanceOfBuyBackContract(contract: string) {
return useQuery({
queryKey: ['USDCBalanceOfBuyBackContract'],
queryKey: ['USDCBalanceOfBuyBackContract', contractAddress],
queryFn: async () => {
const balance: BigNumber = await USDC.balanceOf(contract);
const USDC = new Contract(
'0x09d51516F38980035153a554c26Df3C6f51a23C3',
['function balanceOf(address _owner) view returns (uint256 balance)'],
baseProvider
);

const balance: BigNumber = await USDC.balanceOf(contractAddress);
return balance;
},
refetchInterval: 100000,
Expand Down
18 changes: 11 additions & 7 deletions ultrasound/ui/hooks/useBurnEvents.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { useGetNetwork, useProviderForChain } from '@snx-v3/useBlockchain';
import { useQuery } from '@tanstack/react-query';
import { BigNumber, Contract, providers, utils } from 'ethers';
import { BigNumber, Contract, utils } from 'ethers';

interface BurnEvent {
ts: number;
Expand All @@ -9,21 +10,24 @@ interface BurnEvent {
cumulativeUsdAmount: number;
}

const SNXonL1 = new Contract(
'0xC011a73ee8576Fb46F5E1c5751cA3B9Fe0af2a6F',
['function totalSupply() view returns(uint256)'],
new providers.JsonRpcProvider('https://eth.llamarpc.com')
);

const now = new Date();
now.setDate(now.getDate() - 7);
const thirtyDaysAgo = new Date();
thirtyDaysAgo.setDate(thirtyDaysAgo.getDate() - 30);

export function useBurnEvents() {
const ethNetwork = useGetNetwork(`0x${Number(1).toString(16)}`);
const ethProvider = useProviderForChain(ethNetwork);

return useQuery({
queryKey: ['burn-events'],
queryFn: async () => {
const SNXonL1 = new Contract(
'0xC011a73ee8576Fb46F5E1c5751cA3B9Fe0af2a6F',
['function totalSupply() view returns(uint256)'],
ethProvider
);

const repsonse = await fetch('https://api.synthetix.io/v3/base/snx-buyback');
const events: BurnEvent[] = await repsonse.json();

Expand Down

0 comments on commit 7cd3e4d

Please sign in to comment.