-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: update to use proxy for staking apr (#702)
- Loading branch information
Showing
6 changed files
with
68 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { useQuery } from '@tanstack/react-query'; | ||
|
||
import { PERCENT_DECIMALS } from '@/constants/numbers'; | ||
|
||
import { useEndpointsConfig } from './useEndpointsConfig'; | ||
|
||
export const useStakingAPR = () => { | ||
const { stakingAPR: stakingAPREndpoint } = useEndpointsConfig(); | ||
|
||
const queryFn = async () => { | ||
if (!stakingAPREndpoint) { | ||
return undefined; | ||
} | ||
const response = await fetch(stakingAPREndpoint, { | ||
headers: { | ||
'content-type': 'application/json', | ||
}, | ||
}); | ||
|
||
const data = await response.json(); | ||
return data?.[0].rewardRate as number | undefined; | ||
}; | ||
|
||
const { data } = useQuery({ | ||
queryKey: ['stakingAPR'], | ||
queryFn, | ||
enabled: true, | ||
refetchOnWindowFocus: false, | ||
refetchOnReconnect: false, | ||
}); | ||
|
||
const formattedAPR = data ? (data * 100).toFixed(PERCENT_DECIMALS) : undefined; | ||
|
||
return formattedAPR; | ||
}; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters