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

test(staker): reward calculation warmup #460

Merged
merged 3 commits into from
Jan 16, 2025
Merged

test(staker): reward calculation warmup #460

merged 3 commits into from
Jan 16, 2025

Conversation

notJoon
Copy link
Member

@notJoon notJoon commented Jan 15, 2025

Description

1. Warmup Template Validation

  • Verify default warmup stages (5, 10, 30 days)
  • Validate correct warmup ratios (30%, 50%, 70%, 100%)
  • Check block duration calculations

2. Reward Calculation Precision

  • Test various warmup ratios (30%, 50%, 70%, 100%)
  • Verify reward and penalty calculations
  • Handle edge cases with small and large numbers
  • Ensure rounding behavior in integer division

3. Liquidity Ratio Tests

  • Test different position/staked liquidity ratios
  • Validate calculations with various pool sizes
  • Check boundary conditions (very small/large ratios)

4. Warmup Stage Transitions

  • Verify correct warmup stage identification
  • Test boundary conditions between stages
  • Validate warmup height calculations

5. Edge Cases

  • Handle zero values
  • Test maximum uint64 values
  • Verify calculation precision with small numbers
  • Ensure total rewards + penalties match expected values

@notJoon notJoon added the staker label Jan 15, 2025
@notJoon notJoon requested review from onlyhyde and mconcat January 15, 2025 03:37
@notJoon notJoon changed the title Test: reward calculation warmup test(staker): reward calculation warmup Jan 15, 2025
Copy link
Member

@dongwon8247 dongwon8247 left a comment

Choose a reason for hiding this comment

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

Looks good.

Can you add one more test case with multiple warm-up conditions? Reward and penalty should be calculated separately for each warm-up period. I suggest two cases:

  1. When a position is staked for 5 days of blocks + 1 block, then WarmupRatio30 should be applied for 5 days of blocks , and WarmupRatio50 for the last one block.
  2. When a position is staked for 40 days, then WarmupRatio30 for 0-5 days of blocks, WarmupRatio50 for 6-10 days of blocks, WarmupRatio70 for 11-30 days of blocks, WarmupRatio100, aka full rewards, for 31-40 days of blocks.

onlyhyde
onlyhyde previously approved these changes Jan 15, 2025
@notJoon
Copy link
Member Author

notJoon commented Jan 15, 2025

Can you add one more test case with multiple warm-up conditions? Reward and penalty should be calculated separately for each warm-up period. I suggest two cases:

1. When a position is staked for 5 days of blocks + 1 block, then `WarmupRatio30` should be applied for 5 days of blocks , and `WarmupRatio50` for the last one block.

2. When a position is staked for 40 days, then `WarmupRatio30` for 0-5 days of blocks, `WarmupRatio50` for 6-10 days of blocks, `WarmupRatio70` for 11-30 days of blocks, `WarmupRatio100`, aka full rewards, for 31-40 days of blocks.

@dongwon8247 added 1d82231

@onlyhyde onlyhyde self-requested a review January 16, 2025 12:25
@onlyhyde onlyhyde merged commit 8c2805e into main Jan 16, 2025
2 checks passed
@onlyhyde onlyhyde deleted the warmup-test branch January 16, 2025 12:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants