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

funding: apportion rewards to voters/LPs #5035

Merged
merged 5 commits into from
Jan 31, 2025

Conversation

cronokirby
Copy link
Contributor

Describe your changes

This trait is responsible for the actual accounting of moving funds around, to be later consumed by the end epoch handler, which figures out what portion of the rewards needs to go where. The bank will just actually move fractions of its budget in the community pool to the requested locations, atomically.

Testing deferred.

Checklist before requesting a review

  • I have added guiding text to explain how a reviewer should test these changes.

  • If this code contains consensus-breaking changes, I have added the "consensus-breaking" label. Otherwise, I declare my belief that there are not consensus-breaking changes, for the following reason:

    yes indeed

@cronokirby cronokirby added the consensus-breaking breaking change to execution of on-chain data label Jan 30, 2025
@cronokirby cronokirby changed the base branch from main to protocol/lqt_branch January 30, 2025 23:43
@cronokirby cronokirby marked this pull request as ready for review January 31, 2025 04:26
position::State::Opened => position::State::Opened,
position::State::Closed => position::State::Closed,
position::State::Withdrawn { sequence } => position::State::Withdrawn {
sequence: sequence.saturating_add(1),
Copy link
Member

Choose a reason for hiding this comment

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

I think it would be better to remove the defensive guard, in a separate PR.

There are already two levels of defense:

  • the value balance mint/burn flow
  • the withdraw position implementation

We are not losing any ground by not having the sequential check in the inner update guard, and we don't have to fabricate withdrawal sequence numbers in return, that seems good

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I like extra defensive guards, but the sequential number bit does seem contrived.

// portion > budget, so eat the whole budget.
None => (0u64.into(), budget),
};
state.set_lqt_reward_issuance_for_epoch(new_budget);
Copy link
Member

Choose a reason for hiding this comment

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

I don't feel super good about rewriting the budget every run rather than letting this be a top-level concern in a single simple loop that it is easy to read. As is, we have to walk through a yo-yo of reads and writes to figure out if this works correctly. And it makes an innocuous method in a different component, totally load-bearing of something that is far away from its context (for example, the keying by epoch is ambient)

Copy link
Member

Choose a reason for hiding this comment

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

I also think there's a bug here, we want:

$f_1 + ... f_n = 1$

and

$(\sum f_i * B) = B$

right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah that makes sense, let's just refactor the module to take in amounts, and tie in the budget at one level higher

Copy link
Member

@erwanor erwanor left a comment

Choose a reason for hiding this comment

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

Great work

@cronokirby cronokirby merged commit 1a5dccb into protocol/lqt_branch Jan 31, 2025
12 of 13 checks passed
@cronokirby cronokirby deleted the cronokirby/lqt-bank branch January 31, 2025 19:51
@erwanor erwanor mentioned this pull request Jan 31, 2025
28 tasks
@erwanor erwanor changed the title Implement "Bank" extension trait for liquidity tournament funding: apportion rewards to voters/LPs Jan 31, 2025
conorsch pushed a commit that referenced this pull request Jan 31, 2025
## Describe your changes

This trait is responsible for the actual accounting of moving funds
around, to be later consumed by the end epoch handler, which figures out
what portion of the rewards needs to go where. The bank will just
actually move fractions of its budget in the community pool to the
requested locations, atomically.

Testing deferred.

## Checklist before requesting a review

- [x] I have added guiding text to explain how a reviewer should test
these changes.

- [x] If this code contains consensus-breaking changes, I have added the
"consensus-breaking" label. Otherwise, I declare my belief that there
are not consensus-breaking changes, for the following reason:

  > yes indeed
conorsch pushed a commit that referenced this pull request Feb 4, 2025
## Describe your changes

This trait is responsible for the actual accounting of moving funds
around, to be later consumed by the end epoch handler, which figures out
what portion of the rewards needs to go where. The bank will just
actually move fractions of its budget in the community pool to the
requested locations, atomically.

Testing deferred.

## Checklist before requesting a review

- [x] I have added guiding text to explain how a reviewer should test
these changes.

- [x] If this code contains consensus-breaking changes, I have added the
"consensus-breaking" label. Otherwise, I declare my belief that there
are not consensus-breaking changes, for the following reason:

  > yes indeed
conorsch pushed a commit that referenced this pull request Feb 5, 2025
## Describe your changes

This trait is responsible for the actual accounting of moving funds
around, to be later consumed by the end epoch handler, which figures out
what portion of the rewards needs to go where. The bank will just
actually move fractions of its budget in the community pool to the
requested locations, atomically.

Testing deferred.

## Checklist before requesting a review

- [x] I have added guiding text to explain how a reviewer should test
these changes.

- [x] If this code contains consensus-breaking changes, I have added the
"consensus-breaking" label. Otherwise, I declare my belief that there
are not consensus-breaking changes, for the following reason:

  > yes indeed
conorsch pushed a commit that referenced this pull request Feb 5, 2025
## Describe your changes

This trait is responsible for the actual accounting of moving funds
around, to be later consumed by the end epoch handler, which figures out
what portion of the rewards needs to go where. The bank will just
actually move fractions of its budget in the community pool to the
requested locations, atomically.

Testing deferred.

## Checklist before requesting a review

- [x] I have added guiding text to explain how a reviewer should test
these changes.

- [x] If this code contains consensus-breaking changes, I have added the
"consensus-breaking" label. Otherwise, I declare my belief that there
are not consensus-breaking changes, for the following reason:

  > yes indeed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
consensus-breaking breaking change to execution of on-chain data
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants