Skip to content

Alter TWA snapshot parameters #42

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

Merged
merged 5 commits into from
Oct 22, 2024
Merged

Alter TWA snapshot parameters #42

merged 5 commits into from
Oct 22, 2024

Conversation

heswithme
Copy link
Collaborator

@heswithme heswithme commented Oct 21, 2024

Summary of Changes

  1. Increased Snapshot Interval:

    • The snapshot interval is now set to 1 hour (3_600 s), which reduces gas consumption.
    • Each snapshot costs ~5_500 gas in .compute_twa(). Over 7 days, this results in a maximum gas usage of 86_400 * 7 / 3_600 * 5_500 = 924_000.
  2. Reordered Variables in twa Module:

    • Variables were reordered to produce cleaner and more readable memory addresses during debugging, making the module easier to work with.
  3. Removed Default Snapshots in process_rewards():

    • Snapshots are no longer taken by default when calling process_rewards(), avoiding unnecessary gas costs (170_000 gas for lens.circulating_supply() when iterating through peg keepers and controllers).
    • To include snapshots when using automated keepers, one should call process_rewards(True).

@heswithme
Copy link
Collaborator Author

Piggybacking the fee_splitter new deployment, as it's a minor change in test suite.

@heswithme
Copy link
Collaborator Author

Had to fix some tests to assume non-zero initial balances in the system.
Also added some lines in tests to demonstrate how to measure gas to get tenderly-like estimation.

Copy link
Collaborator

@AlbertoCentonze AlbertoCentonze left a comment

Choose a reason for hiding this comment

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

Nicely done, LGTM

@heswithme heswithme merged commit 7008ce2 into main Oct 22, 2024
4 checks passed
@heswithme heswithme deleted the fix/adjust-min-dt branch October 24, 2024 09:36
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.

2 participants