-
Notifications
You must be signed in to change notification settings - Fork 207
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make amount claimable constant across airdrop epochs (#363)
## Context and purpose of the change During each period, a user should be able to claim a fixed number of tokens, relative to the total number of tokens claimable in a period. Currently, users can claim less tokens after each successive claim, because the formula for claims is ``` claimable = distributor_balance * weight ``` Instead, we should allow claims like so ``` claimable = max_claimable_in_period * weight ``` To accomplish this, we add a variable to each airdrop `ClaimedSoFar`. Then, when a user claims, they claim relative to the pool like so ``` max_claimable = distributor_balance + claimed_so_far ``` This accounts for the case where the distributor receives more tokens - `max_claimable` will be larger (by the amount of received tokens) if tokens are sent to that address. After each claim, we increment `ClaimedSoFar` on the airdrop for which tokens were claimed. Finally, after each epoch, we set `ClaimedSoFar` to 0. NOTE: This also updates `ClaimFreeAmount` to claim tokens for all airdrops, removing `AirdropIdentifier` from that message. ## Brief Changelog * add `claimed_so_far` to `Airdrop` proto * `ClearClaimedStatus` -> `ResetClaimedStatus` to account for resetting `claimed_so_far` * calculate `poolBal` using distributor balance and claimed so far * add `AfterClaim` method to Increment `ClaimedSoFar` * add airdrop update methods `IncrementClaimedSoFar` and `ResetClaimedSoFar` * Clean up claims so that we can call a single keeper function to process all claims ## Tests * update existing tests * ResetClaimStatus * Check that airdrop claimed amount updates after a claim * Verify that ClaimAllCoinsForAction claims all free coins across two airdrops * Verify IncrementClaimedSoFar and ResetClaimedSoFar work as expected ## Author's Checklist I have... - [ ] Run and PASSED locally all GAIA integration tests - [ ] If the change is contentful, I either: - [ ] Added a new unit test OR - [ ] Added test cases to existing unit tests - [ ] OR this change is a trivial rework / code cleanup without any test coverage If skipped any of the tests above, explain. ## Reviewers Checklist *All items are required. Please add a note if the item is not applicable and please add your handle next to the items reviewed if you only reviewed selected items.* I have... - [ ] reviewed state machine logic - [ ] reviewed API design and naming - [ ] manually tested (if applicable) - [ ] confirmed the author wrote unit tests for new logic - [ ] reviewed documentation exists and is accurate ## Documentation and Release Note - [ ] Does this pull request introduce a new feature or user-facing behavior changes? - [ ] Is a relevant changelog entry added to the `Unreleased` section in `CHANGELOG.md`? - [ ] This pull request updates existing proto field values (and require a backend and frontend migration)? - [ ] Does this pull request change existing proto field names (and require a frontend migration)? How is the feature or change documented? - [ ] not applicable - [ ] jira ticket `XXX` - [ ] specification (`x/<module>/spec/`) - [ ] README.md - [ ] not documented
- Loading branch information
Showing
11 changed files
with
246 additions
and
179 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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 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 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
Oops, something went wrong.