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

Commitment sma support #190

Merged
merged 20 commits into from Nov 1, 2021
Merged

Commitment sma support #190

merged 20 commits into from Nov 1, 2021

Conversation

CalabashSquash
Copy link
Contributor

@CalabashSquash CalabashSquash commented Oct 31, 2021

Motivation

We need support for arbitrary frontrunning intervals (which can be many factors larger than the updateInterval). This requires being able to store data for an arbitrary number of update intervals at a particular point in time.

Note that this PR introduces loops, but the amount of iterations still has a limited upper-bound. The upper-bound is frontRunningInterval / updateInterval (e.g. if frontRunningInterval = 5 * updateInterval, then there will be at most 5 iterations.

Changes

PoolSwapLibrary

  • Add function appropriateUpdateIntervalId
    • This calculates the correct update interval ID based on the current time, frontrunning interval and update interval
      PoolCommitter
  • Removed userMostRecentCommit, userNextIntervalCommit, totalMostRecentCommit and totalNextIntervalCommit
    • The use of these was essentially just hardcoding support for only two update intervals.
    • The purpose of this PR is to generalise that part of the code to support any number of update intervals being stored at one particular point in time.
  • Changed commit to now store commitment data in the commitment corresponding to the result of a call to PoolSwapLibrary.appropriateUpdateIntervalId.
  • executeCommitments now loops through a theoretically unbound number of update intervals (should never actually happen if pool is upkept in a reasonable amount of time.
  • updateAggregateBalance now loops over all un-aggregated balances. As per the note above, this still has a strict upper bound.
  • getAggregateBalance has now been updated to reflect the above changes.

@CalabashSquash CalabashSquash marked this pull request as draft October 31, 2021 06:28
@CalabashSquash CalabashSquash marked this pull request as ready for review October 31, 2021 08:25
@sporejack sporejack self-requested a review November 1, 2021 02:56
@sporejack sporejack changed the base branch from new-commit-types to pools-v2 November 1, 2021 03:22
@sporejack sporejack merged commit ef8267e into pools-v2 Nov 1, 2021
@CalabashSquash CalabashSquash deleted the commitment-sma-support branch April 18, 2022 21:09
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.

None yet

2 participants