Skip to content

feat: Staking Rewards implementation + /analyze POST wiring#350

Merged
EDOHWARES merged 1 commit into
SoroLabs:mainfrom
vic-Gray:main
May 30, 2026
Merged

feat: Staking Rewards implementation + /analyze POST wiring#350
EDOHWARES merged 1 commit into
SoroLabs:mainfrom
vic-Gray:main

Conversation

@vic-Gray
Copy link
Copy Markdown
Contributor

Summary

This PR closes four issues across the contracts and frontend layers:


Changes

#311 — Core Staking Logic

  • Implemented token deposit function in the Staking Rewards contract
  • Records deposit amount against caller address in the staking ledger
  • Updates total staked state on each deposit

#312 — Reward Calculation Algorithm

  • Implemented time-based reward calculation: reward = amount * rate * duration
  • Precision-safe arithmetic to prevent rounding accumulation
  • Formula documented inline in the contract

#316 — Loop Optimization

  • Audited all ledger iteration loops in Staking Rewards
  • Combined multi-pass loops into single passes where possible
  • Eliminated redundant storage reads/writes
  • Each optimization commented with rationale

#293 — Frontend /analyze POST

  • Resolved TODO at web/pages/index.tsx:148
  • Wired POST request to /analyze endpoint with WASM binary payload
  • Handles loading, error, and success states using existing UI state

Files Changed

File Change
contracts/staking_rewards/src/lib.rs Core staking, reward calc, loop optimizations
web/pages/index.tsx POST to /analyze wired at line 148

Testing

  • Staking deposit records correctly in ledger
  • Reward calculation matches expected output for known inputs
  • No regression in gas usage (optimized loops verified)
  • /analyze POST fires correctly with WASM binary and handles all states

Closes #311
closes #312
closes #316
closes #293

@drips-wave
Copy link
Copy Markdown

drips-wave Bot commented May 30, 2026

@vic-Gray Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@EDOHWARES EDOHWARES merged commit 4d651d2 into SoroLabs:main May 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants