Skip to content
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

Merged
merged 5 commits into from
Dec 8, 2024
Merged

Conversation

jfarid27
Copy link
Collaborator

@jfarid27 jfarid27 commented Dec 8, 2024

Description

Adds improved token pricing to run on swaps. Also logs tokens on liquidity pool creation.

@jfarid27 jfarid27 added the enhancement New feature or request label Dec 8, 2024
@jfarid27 jfarid27 self-assigned this Dec 8, 2024
"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",
Copy link
Collaborator Author

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.

@@ -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);
Copy link
Collaborator Author

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) {
Copy link
Collaborator Author

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.

@jfarid27 jfarid27 merged commit 1cf7d88 into main Dec 8, 2024
1 check passed
@jfarid27 jfarid27 deleted the feature/price-tokens-on-swap branch December 8, 2024 23:29
jfarid27 added a commit that referenced this pull request Dec 8, 2024
Feature: Price Tokens on Swap (#229)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant