feat(stake-vault): replace opaque u32 multiplier with MultiplierBps enum - #46
Open
malaysiaonelove wants to merge 1 commit into
Open
feat(stake-vault): replace opaque u32 multiplier with MultiplierBps enum#46malaysiaonelove wants to merge 1 commit into
malaysiaonelove wants to merge 1 commit into
Conversation
Closes Kqirox#18 - Add pub enum MultiplierBps { None, Low, High } with #[contracttype] in stake-vault/src/types.rs - Add MultiplierBps::as_bps() -> u32 accessor (100 / 120 / 200) - Update get_multiplier to return MultiplierBps instead of raw u32 - Now uses TIER_HIGH_STAKE_BOUND / TIER_LOW_STAKE_BOUND constants (previously inlined magic numbers) - Add comprehensive rustdoc with tier table and basis-points convention - Deprecate bare STAKE_TIER_{HIGH,LOW,NONE}_BPS constants with #[deprecated] pointing to MultiplierBps::as_bps() - Update stake-vault tests to assert MultiplierBps variants - Add test_multiplier_bps_round_trip: verifies as_bps() values and scaled-payout arithmetic for all three tiers - Add stake-vault path dependency to quest-engine Cargo.toml - Update StakeVaultInterface trait in quest-engine: returns MultiplierBps - Fix payout arithmetic in review_submission to call .as_bps() - Update both mock StakeVault contracts in quest-engine tests - Update stake-vault/README.md with MultiplierBps enum table, as_bps() usage example, and staking tier constants reference
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Closes #18
Replaces the raw
u32basis-points return value fromStakeVault::get_multiplierwith a typedMultiplierBpsenum, eliminating silent payout bugs in cross-contract callers who previously had no way to know the divisor (100) without reading the source.Changes
stake-vault/src/types.rspub enum MultiplierBps { None, Low, High }with#[contracttype]MultiplierBps::as_bps() -> u32accessor returning 100 / 120 / 200as_bps()stake-vault/src/lib.rsget_multipliernow returnsMultiplierBpsinstead ofu32TIER_*_STAKE_BOUNDconstantsSTAKE_TIER_{HIGH,LOW,NONE}_BPSbare constants with#[deprecated]pointing toas_bps()stake-vault/src/test.rstest_get_multiplierto assertMultiplierBpsvariantstest_multiplier_bps_round_trip— verifiesas_bps()values and scaled-payout arithmetic for all three tiersquest-engine/Cargo.tomlstake-vault = { path = "../stake-vault" }dependencyquest-engine/src/lib.rsStakeVaultInterface::get_multipliertrait now returnsMultiplierBpsmultiplier as i128→multiplier.as_bps() as i128quest-engine/src/test.rsMultiplierBpsvariantsstake-vault/README.mdMultiplierBpsenum table with tier/bps/multiplier columns,as_bps()usage example, and staking tier constants referenceTesting
quest-enginetests unchanged in behaviourtest_multiplier_bps_round_tripenum round-trip test addedtest_get_multiplierupdated to compare typed enum variants