-
Notifications
You must be signed in to change notification settings - Fork 4
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
Feature: Price Tokens on Swap #229
Conversation
"test": "mocha --recursive --require ts-node/register \"test/**/*.ts\" --timeout 30000", | ||
"dottest": "mocha -w --recursive -R dot --require ts-node/register \"test/**/*.ts\" --timeout 30000", | ||
"test": "mocha --recursive --R spec --require ts-node/register \"test/**/*.ts\" --timeout 30000", | ||
"test-watch": "mocha -w --recursive --R dot --require ts-node/register \"test/**/*.ts\" --timeout 30000", |
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.
Update test runners for easier dev.
src/EventHandlers/CLPool.ts
Outdated
@@ -503,25 +506,27 @@ CLPool.Swap.handlerWithLoader({ | |||
tokenUpdateData.netAmount0 = abs(event.params.amount0); | |||
tokenUpdateData.netAmount1 = abs(event.params.amount1); | |||
|
|||
if (token0Instance) { | |||
if (token0) { | |||
token0 = await refreshTokenPrice(token0, event.block.number, event.block.timestamp, event.chainId, context); |
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.
Calls refreshTokenPrice, forcing price fetch on swaps.
chainId: number, | ||
context: any | ||
): Promise<Token> { | ||
if (blockTimestamp - token.lastUpdatedTimestamp.getTime() < ONE_HOUR_MS) { |
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.
Only actually updates if the last token price is older than 1 hour. Might update this at some point it it seems this should work for now.
Feature: Price Tokens on Swap (#229)
Description
Adds improved token pricing to run on swaps. Also logs tokens on liquidity pool creation.