Skip to content

[Pairs] TWAP price calculation implementation#443

Draft
psparacino wants to merge 21 commits into
stagingfrom
pairs/twap-pair-prices
Draft

[Pairs] TWAP price calculation implementation#443
psparacino wants to merge 21 commits into
stagingfrom
pairs/twap-pair-prices

Conversation

@psparacino
Copy link
Copy Markdown
Collaborator

@psparacino psparacino commented Jun 20, 2025

Pull Request Template

📄 Description

Calculating the new price based on the swap params results in price spikes when dust amount are involved. By using Uniswap's TWAP method: https://docs.uniswap.org/contracts/v2/concepts/core-concepts/oracles, essentially the average price of the last 10 minutes, the effects of any huge spikes are mitigated to a sane price range.

Included a new entity to track the necessary timestamp & previous cumulative prices params for TWAP.

dev deployment: https://api.studio.thegraph.com/query/28985/pairs-testing/version/latest

📝 Changelog

feat: use Uniswap TWAP pricing to calculate pairs prices

✅ Checklist

  • Matchstick test included (if applicable).
  • Version incremented in package.json of the applicable subgraph(s)
  • All changes are reflected in the changelog of this PR for the applicable subgraph(s)
  • If modifying polygon-digital-carbon or carbonmark subgraphs, MAKE SURE TO MODIFY subgraph.template.yaml (NOT subgraph.yaml DIRECTLY!)
    • If modifying subgraph.template.yaml, also make sure to run npm run prepare-matic locally and commit the resulting rendered subgraph.yaml

ℹ️ Additional Information

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant