-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Include redemption fees in the APY calc
- Loading branch information
1 parent
52305a0
commit 86b18ff
Showing
2 changed files
with
65 additions
and
16 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { useQuery } from "@tanstack/react-query"; | ||
import { alchemy } from "src/provider"; | ||
import { | ||
fetchRedemptionInfos, | ||
RedemptionInfosFile, | ||
REDEMPTION_INFOS_URL, | ||
} from "liquity"; | ||
import { ONE_DAY_IN_MILLISECONDS } from "src/base/time"; | ||
|
||
export function useRedemptionInfos() { | ||
return useQuery({ | ||
queryKey: ["redemption-infos"], | ||
queryFn: async () => { | ||
// Move fetch to own hook w/ staleTime 2 hours | ||
const response = await fetch(REDEMPTION_INFOS_URL); | ||
const redemptionInfos = (await response.json()) as RedemptionInfosFile; | ||
|
||
const provider = await alchemy.config.getProvider(); | ||
const latestRedemptionInfos = await fetchRedemptionInfos( | ||
redemptionInfos.data[redemptionInfos.data.length - 1].block + 1, | ||
provider | ||
); | ||
|
||
return { | ||
...redemptionInfos, | ||
data: [...redemptionInfos.data, ...latestRedemptionInfos], | ||
}; | ||
}, | ||
// This is scraped fresh once a day | ||
staleTime: ONE_DAY_IN_MILLISECONDS, | ||
}); | ||
} |
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
86b18ff
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
liquity-ui – ./
liquity-ui-blond.vercel.app
liquity-ui-dannydelott.vercel.app
liquity-ui-git-main-dannydelott.vercel.app
www.liquity.events
liquity.events