-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Feat: Prefetch Function Support in Adapter #3027
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
Conversation
The rainbow-wallet.ts adapter exports:
|
The rainbow-wallet.ts adapter exports:
|
The rainbow-wallet.ts adapter exports:
|
adapters/utils/runAdapter.ts
Outdated
@@ -17,6 +17,7 @@ function getUnixTimeNow() { | |||
export default async function runAdapter(volumeAdapter: BaseAdapter, cleanCurrentDayTimestamp: number, chainBlocks: ChainBlocks, id?: string, version?: string, { | |||
adapterVersion = 1, | |||
isTest = false, | |||
prefetch = null, |
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.
volumeAdapter will have the prefetch field right? if you use that instead of the extra field here, prefetch will work without automatically for all the code calling runAdapter without any modification to them
The rainbow-wallet.ts adapter exports:
|
The rainbow-wallet.ts adapter exports:
|
The rainbow-wallet.ts adapter exports:
|
The prefetch function solves a key inefficiency in multi-chain DeFi adapters by fetching common data once instead of repeatedly for each chain. In the Rainbow Wallet example, it executes a single Dune SQL query that retrieves fee data for all chains, then stores this in preFetchedResults. Each chain's fetch function accesses this shared data through options.preFetchedResults, eliminating redundant database queries, reducing API load, and improving performance. This approach keeps the codebase cleaner by separating shared data fetching from chain-specific processing while maintaining backward compatibility.
This function would improve performance and use less resource/credits. mostly would be useful in dune/allium query/APIs where we can have multi-chain data in single request.