-
Notifications
You must be signed in to change notification settings - Fork 3.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
perf: Dont fetch v2 expired pools data and make price fetcher unique #10869
base: develop
Are you sure you want to change the base?
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
6 Skipped Deployments
|
|
@@ -1,10 +1,14 @@ | |||
import { CurrencyParams, CurrencyUsdResult, getCurrencyKey, getCurrencyListUsdPrice } from '@pancakeswap/price-api-sdk' | |||
import { create, windowedFiniteBatchScheduler } from '@yornaath/batshit' | |||
import uniqBy from 'lodash/uniqBy' | |||
|
|||
export const usdPriceBatcher = create<CurrencyUsdResult, CurrencyParams, number>({ | |||
// The fetcher resolves the list of queries to one single api call. | |||
fetcher: async (params: CurrencyParams[]) => { |
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.
batcher shallowly compares currencyparams (which are tokens where it is called) and if same tokens are different objects it can be double fetched because of that
PR-Codex overview
This PR focuses on optimizing the fetching of currency prices and pool data by eliminating duplicate requests and improving performance through the use of
lodash
'suniqBy
function.Detailed summary
uniqBy
fromlodash
to filter unique currency parameters inusdPriceBatcher
.totalSupplyCalls
toendTimestampCalls
.activeValidPools
instead ofvalidPools
.endTimestampCalls
and adjusted related logic.