-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixed bonus rewards apr by considering sponsored supply
- Loading branch information
Showing
12 changed files
with
211 additions
and
18 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
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
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
30 changes: 30 additions & 0 deletions
30
packages/hyperstructure-react-hooks/src/vaults/useAllVaultTotalDelegateSupplies.ts
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,30 @@ | ||
import { Vaults } from '@generationsoftware/hyperstructure-client-js' | ||
import { NO_REFETCH } from '@shared/generic-react-hooks' | ||
import { useQuery, useQueryClient } from '@tanstack/react-query' | ||
import { populateCachePerId } from '..' | ||
import { QUERY_KEYS } from '../constants' | ||
|
||
/** | ||
* Returns each vault's total delegate supply (total supply - sponsored supply) | ||
* @param vaults instance of the `Vaults` class | ||
* @returns | ||
*/ | ||
export const useAllVaultTotalDelegateSupplies = (vaults: Vaults) => { | ||
const queryClient = useQueryClient() | ||
|
||
const vaultIds = !!vaults ? Object.keys(vaults.vaults) : [] | ||
const getQueryKey = (val: (string | number)[]) => [QUERY_KEYS.vaultTotalDelegateSupplies, val] | ||
|
||
return useQuery({ | ||
queryKey: getQueryKey(vaultIds), | ||
queryFn: async () => { | ||
const totalDelegateSupply = await vaults.getTotalDelegateSupplies() | ||
|
||
populateCachePerId(queryClient, getQueryKey, totalDelegateSupply) | ||
|
||
return totalDelegateSupply | ||
}, | ||
enabled: !!vaults, | ||
...NO_REFETCH | ||
}) | ||
} |
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
20 changes: 20 additions & 0 deletions
20
packages/hyperstructure-react-hooks/src/vaults/useVaultTotalDelegateSupply.ts
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,20 @@ | ||
import { Vault } from '@generationsoftware/hyperstructure-client-js' | ||
import { NO_REFETCH } from '@shared/generic-react-hooks' | ||
import { useQuery, UseQueryResult } from '@tanstack/react-query' | ||
import { QUERY_KEYS } from '../constants' | ||
|
||
/** | ||
* Returns the vault's total delegate supply (total supply - sponsored supply) | ||
* @param vault instance of the `Vault` class | ||
* @returns | ||
*/ | ||
export const useVaultTotalDelegateSupply = (vault: Vault): UseQueryResult<bigint> => { | ||
const queryKey = [QUERY_KEYS.vaultTotalDelegateSupplies, vault?.id] | ||
|
||
return useQuery({ | ||
queryKey, | ||
queryFn: async () => await vault.getTotalDelegateSupply(), | ||
enabled: !!vault, | ||
...NO_REFETCH | ||
}) | ||
} |
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