-
Notifications
You must be signed in to change notification settings - Fork 363
funding: apportion rewards to voters/LPs #5035
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
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
353b98e
Stub funding/LQT Bank interface
cronokirby 19d91db
LQT: implement budget appropriation function
cronokirby 3689bc3
Implement LQT voter rewards
cronokirby 3271f07
Implement LQT position rewards
cronokirby cb87f0b
Make LQT bank take in arbitrary amounts
cronokirby File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
crates/core/component/funding/src/component/liquidity_tournament/bank.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| use async_trait::async_trait; | ||
| use cnidarium::StateWrite; | ||
| use penumbra_sdk_asset::{Value, STAKING_TOKEN_ASSET_ID}; | ||
| use penumbra_sdk_dex::component::PositionManager as _; | ||
| use penumbra_sdk_dex::lp::position; | ||
| use penumbra_sdk_keys::Address; | ||
| use penumbra_sdk_num::Amount; | ||
| use penumbra_sdk_sct::component::clock::EpochRead as _; | ||
| use penumbra_sdk_sct::CommitmentSource; | ||
| use penumbra_sdk_shielded_pool::component::NoteManager as _; | ||
| use penumbra_sdk_txhash::TransactionId; | ||
|
|
||
| #[allow(dead_code)] | ||
| #[async_trait] | ||
| /// The bank strictly controls issuance of rewards in the liquidity tournament. | ||
| /// | ||
| /// This ensures that rewards do not exceed the issuance budget, and are immediately | ||
| /// debited from the appropriate source (which happens to be the community pool), | ||
| /// and credited towards the appropriate destination (i.e. positions or new notes). | ||
| pub trait Bank: StateWrite + Sized { | ||
erwanor marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| /// Move a fraction of our issuance budget towards an address, by minting a note. | ||
| async fn reward_to_voter( | ||
| &mut self, | ||
| reward: Amount, | ||
| voter: &Address, | ||
| tx_hash: TransactionId, | ||
| ) -> anyhow::Result<()> { | ||
| let epoch = self | ||
| .get_current_epoch() | ||
| .await | ||
| .expect("should be able to read current epoch"); | ||
| self.mint_note( | ||
| Value { | ||
| asset_id: *STAKING_TOKEN_ASSET_ID, | ||
| amount: reward, | ||
| }, | ||
| voter, | ||
| CommitmentSource::LiquidityTournamentReward { | ||
| epoch: epoch.index, | ||
| tx_hash, | ||
| }, | ||
| ) | ||
| .await?; | ||
| Ok(()) | ||
| } | ||
|
|
||
| /// Move a fraction of our issuance budget towards a position, increasing its reserves. | ||
| async fn reward_to_position(&mut self, reward: Amount, lp: position::Id) -> anyhow::Result<()> { | ||
| self.reward_position(lp, reward).await?; | ||
| Ok(()) | ||
| } | ||
| } | ||
1 change: 1 addition & 0 deletions
1
crates/core/component/funding/src/component/liquidity_tournament/mod.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,3 @@ | ||
| pub mod bank; | ||
| pub mod nullifier; | ||
| pub mod votes; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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:
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
There was a problem hiding this comment.
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.