Skip to content

feat(stake-vault): replace opaque u32 multiplier with MultiplierBps enum - #46

Open
malaysiaonelove wants to merge 1 commit into
Kqirox:mainfrom
malaysiaonelove:feat/multiplier-bps-enum-18
Open

feat(stake-vault): replace opaque u32 multiplier with MultiplierBps enum#46
malaysiaonelove wants to merge 1 commit into
Kqirox:mainfrom
malaysiaonelove:feat/multiplier-bps-enum-18

Conversation

@malaysiaonelove

Copy link
Copy Markdown

Summary

Closes #18

Replaces the raw u32 basis-points return value from StakeVault::get_multiplier with a typed MultiplierBps enum, 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.rs

  • New pub enum MultiplierBps { None, Low, High } with #[contracttype]
  • MultiplierBps::as_bps() -> u32 accessor returning 100 / 120 / 200
  • Full rustdoc on the enum, variants, and as_bps()

stake-vault/src/lib.rs

  • get_multiplier now returns MultiplierBps instead of u32
  • Returns enum variants instead of magic numbers; uses existing TIER_*_STAKE_BOUND constants
  • Comprehensive rustdoc with tier table and basis-points usage example
  • Deprecated STAKE_TIER_{HIGH,LOW,NONE}_BPS bare constants with #[deprecated] pointing to as_bps()

stake-vault/src/test.rs

  • Updated test_get_multiplier to assert MultiplierBps variants
  • New test: test_multiplier_bps_round_trip — verifies as_bps() values and scaled-payout arithmetic for all three tiers

quest-engine/Cargo.toml

  • Added stake-vault = { path = "../stake-vault" } dependency

quest-engine/src/lib.rs

  • StakeVaultInterface::get_multiplier trait now returns MultiplierBps
  • Payout arithmetic updated: multiplier as i128multiplier.as_bps() as i128

quest-engine/src/test.rs

  • Both mock StakeVault contracts updated to return MultiplierBps variants

stake-vault/README.md

  • Updated function signature, added MultiplierBps enum table with tier/bps/multiplier columns, as_bps() usage example, and staking tier constants reference

Testing

  • All existing quest-engine tests unchanged in behaviour
  • New test_multiplier_bps_round_trip enum round-trip test added
  • test_get_multiplier updated to compare typed enum variants

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
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.

[18] Replace opaque u32 basis-points multiplier enum in stake-vault::get_multiplier

1 participant