-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: integrate token pool prices into wallet management and pool creation * chore: update persistence version to 3.2 * refactor: remove debug logging for pricesViaPool in getTotalUsd function
- Loading branch information
Showing
19 changed files
with
153 additions
and
59 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { useQuery } from '@tanstack/react-query'; | ||
import useConfigReducer from './useConfigReducer'; | ||
import axios from 'rest/request'; | ||
|
||
/** | ||
* Fetches prices of tokens from pools oraiDEX backend. | ||
* @returns The pool prices. | ||
*/ | ||
export const useGetTokenPoolPrices = () => { | ||
// use cached first then update by query, if is limited then return cached version | ||
const [tokenPoolPrices, setTokenPoolPrices] = useConfigReducer('tokenPoolPrices'); | ||
|
||
return useQuery({ | ||
initialData: tokenPoolPrices, | ||
// make unique | ||
queryKey: ['tokenPoolPrices'], | ||
queryFn: async () => { | ||
const prices = await getTokenPrices(); | ||
if (Object.keys(prices).length === 0) return tokenPoolPrices; | ||
setTokenPoolPrices(prices); | ||
return prices; | ||
} | ||
}); | ||
}; | ||
|
||
export const getTokenPrices = async () => { | ||
const res = await axios.get('/prices/pool-tokens'); | ||
return res.data; | ||
}; | ||
|
||
getTokenPrices(); |
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
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
Oops, something went wrong.