-
Notifications
You must be signed in to change notification settings - Fork 15
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
Onchain data fetching refactor #524
Conversation
gmbronco
commented
Nov 9, 2023
- separating data fetching and parsing from database logic
- splitting into separate responsibilities (state, data, gyro)
- fixing protocol fee for pools in recovery - should be 0
- fixing BPT price rate
* simpler data fetching and parsing * splitting into separate responsibilities (state, data, gyro) * fixing protocol fee for pools in recovery - should be 0 * fixing BPT price rate
multicaller.call(`${id}.totalSupply`, address, 'totalSupply'); | ||
multicaller.call(`${id}.virtualSupply`, address, 'getVirtualSupply'); | ||
multicaller.call(`${id}.actualSupply`, address, 'getActualSupply'); |
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.
I would move these to the pool type specific queries, otherwise its an extra 2 queries per pool that will either fail or are not needed.
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.
that's the part where we need to know the composable stable pool type, which depends on adding logic based on the factory address. i understand we don't need overfetching, but we fetch so much already that the cost is marginal. i tested both versions (this vs previous) and there is no perfomance impact.
multicaller.call(`${id}.actualSupply`, address, 'getActualSupply'); | ||
multicaller.call(`${id}.swapFee`, address, getSwapFeeFn(type)); | ||
multicaller.call(`${id}.rate`, address, 'getRate'); | ||
multicaller.call(`${id}.protocolYieldFeePercentageCache`, address, 'getProtocolFeePercentageCache', [2]); |
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.
Same here, but I dont see a way to have this without relying on the network context :)
|
||
tokens.forEach(({ address: tokenAddress }, i) => { | ||
multicaller.call(`${id}.tokenRate[${i}]`, address, 'getTokenRate', [tokenAddress]); | ||
multicaller.call(`${id}.metaPriceRateCache[${i}]`, address, 'getPriceRateCache', [tokenAddress]); |
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.
same as above
tokens: result.poolTokens[0].map((t) => t.toLocaleLowerCase()), | ||
balances: result.poolTokens[1].map((w, i) => formatUnits(w, decimalsLookup[result.poolTokens[0][i].toLocaleLowerCase()])), |
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.
can you change toLocaleLowerCase()
to toLowerCase()
? Just avoid any side effects
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.
good catch
weights: result.weights?.map(formatEther), | ||
targets: result.targets?.map(String), | ||
poolTokens: result.poolTokens ? { | ||
tokens: result.poolTokens[0].map((t) => t.toLocaleLowerCase()), |
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.
I'm a fan of writing complete words for variables, we don't need to save any bytes :)
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.
sure!
} | ||
if (multicallResult[pool.id] && multicallResult[pool.id].pausedState) { | ||
isPaused = multicallResult[pool.id].pausedState.paused; | ||
} | ||
operations.push( | ||
prisma.prismaPoolDynamicData.update({ | ||
where: { id_chain: { id: pool.id, chain: networkContext.chain } }, |
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.
any chance we could also get rid of the network context while we're refactoring that?
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.
good point, moving it up to the pool service