-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature/fix token history request v2 (#403)
* fix large token stats request * fix * upgrade settings lib * fix * fix * fix * fix * fix cd * test * fix build
- Loading branch information
1 parent
74c3ebc
commit dc10d61
Showing
12 changed files
with
83 additions
and
102 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { useQuery } from '@tanstack/react-query' | ||
import { fetchTokenStatsData, processTokenStatsData } from 'apis/mngo' | ||
import useMangoGroup from './useMangoGroup' | ||
import { PublicKey } from '@solana/web3.js' | ||
|
||
const refetchMs = 24 * 60 * 60 * 1000 | ||
|
||
export function useTokenStats(mint?: PublicKey) { | ||
const { group } = useMangoGroup() | ||
const criteria = mint | ||
? [group?.publicKey.toBase58(), mint.toBase58()] | ||
: [group?.publicKey.toBase58(), 'all'] | ||
|
||
return useQuery( | ||
['tokenStats', criteria], | ||
async () => { | ||
try { | ||
const rawData = await fetchTokenStatsData(group!, mint) | ||
const [data, mangoStats] = processTokenStatsData(rawData, group!) | ||
return { | ||
data, | ||
mangoStats, | ||
} | ||
} catch (error) { | ||
return { | ||
data: [], | ||
mangoStats: [], | ||
} | ||
} | ||
}, | ||
{ | ||
enabled: !!group && mint ? !!mint : !!'all', | ||
staleTime: refetchMs, | ||
retry: 1, | ||
refetchInterval: refetchMs, | ||
}, | ||
) | ||
} |
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