Skip to content

[oracle] Add twap calculation and endpoints#44

Merged
udpatil merged 3 commits intomasterfrom
oracle-twap-2
Jun 16, 2022
Merged

[oracle] Add twap calculation and endpoints#44
udpatil merged 3 commits intomasterfrom
oracle-twap-2

Conversation

@udpatil
Copy link
Collaborator

@udpatil udpatil commented Jun 15, 2022

This is a PR for the oracle TWAP stuff on top of the price history snapshots. Putting it out for review, but will modify PR to merge to master after the prior PR is merged.

})

// iterate over all denoms with TWAP data
for denomKey := range denomToTimeWeightedMap {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's be careful here - we're iterating over a map which can be nondeterministic. I think it should be ok since this isn't saving to state, but it might still be safer to somehow store the keys in a list, sort then iterate based on that in case we decide to use this in the future for saving to state

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure yeah, I'll collect denoms in a sorted list prior to iterating and outputting twaps 👍

denomTimeWeightedSum := denomToTimeWeightedMap[denom]
denomDuration := denomDurationMap[denom]

// calculate the new Time Weighted Sum for the denom exchange rate
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do you mind adding a comment here including the twap formula?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yup will do

Base automatically changed from oracle-twap to master June 16, 2022 02:08
@udpatil
Copy link
Collaborator Author

udpatil commented Jun 16, 2022

@philipsu522 I addressed the feedback 👍

@udpatil udpatil requested a review from philipsu522 June 16, 2022 16:24
@udpatil udpatil merged commit 3f8a7c6 into master Jun 16, 2022
@udpatil udpatil deleted the oracle-twap-2 branch June 16, 2022 16:29
masih pushed a commit that referenced this pull request Sep 26, 2025
masih pushed a commit that referenced this pull request Sep 29, 2025
## Describe your changes and provide context
This adds the antedeps generated to the graph prior to adding message
deps.

## Testing performed to validate your change
masih pushed a commit that referenced this pull request Sep 30, 2025
## Describe your changes and provide context
This adds the antedeps generated to the graph prior to adding message
deps.

## Testing performed to validate your change
masih pushed a commit that referenced this pull request Oct 1, 2025
masih pushed a commit that referenced this pull request Oct 9, 2025
[SeiDB] Fix PebbleDB Iterator Issue
masih pushed a commit that referenced this pull request Nov 21, 2025
Added replace directives and fixed build errors
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.

3 participants