Skip to content

Conversation

@DannyDelott
Copy link
Contributor

@DannyDelott DannyDelott commented Feb 4, 2025

Implement Claim Button for Rewards in Portfolio

This PR wires up the Claim button on the Rewards tab in the portfolio, enabling users to claim their rewards from the rewards contract.

Hyperdrive---DeFi-Yield-your-way.12.webm

Claiming Rewards

The claim process follows these steps:

  1. Fetch the user's reward data from the server, which includes:
    • claimableAmount (the total amount the user can claim)
    • merkleProof (proof required to validate the claim)
  2. Call the claim function on the rewards contract using these exact values.

Important Notes:

  • The claim is always for the full balance, as claimableAmount is embedded in the merkleProof, meaning it must match exactly when making the claim—partial claims are not allowed.

Displaying Rewards

  • The claimableAmount always increases over time.
  • However, it represents the total earned rewards, not just the new rewards since the last claim.
  • For example:
    • A user has 10 MORPHO in rewards and claims them.
    • On the next merkle update, they earn another 5 MORPHO.
    • The new claimableAmount will be 15 MORPHO, but since they already claimed 10, they will only receive 5 MORPHO when they claim again.
    • In this case, the UI will display 5 MORPHO, but then properly call claim with the claimableAmount set to 15.

This ensures users always see their new rewards accumulated since their last claim.

@changeset-bot
Copy link

changeset-bot bot commented Feb 4, 2025

⚠️ No Changeset found

Latest commit: 156a2ae

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@vercel
Copy link

vercel bot commented Feb 4, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
hyperdrive-mainnet-staging ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 4, 2025 5:26pm
hyperdrive-sepolia-staging ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 4, 2025 5:26pm
6 Skipped Deployments
Name Status Preview Comments Updated (UTC)
hyperdrive-js ⬜️ Ignored (Inspect) Visit Preview Feb 4, 2025 5:26pm
hyperdrive-mainnet-production ⬜️ Ignored (Inspect) Visit Preview Feb 4, 2025 5:26pm
hyperdrive-sepolia-production ⬜️ Ignored (Inspect) Visit Preview Feb 4, 2025 5:26pm
testnet-v1 ⬜️ Ignored (Inspect) Feb 4, 2025 5:26pm
testnet-v1.0.6 ⬜️ Ignored (Inspect) Visit Preview Feb 4, 2025 5:26pm
trading-competition ⬜️ Ignored (Inspect) Visit Preview Feb 4, 2025 5:26pm

@DannyDelott DannyDelott merged commit 420fb11 into main Feb 4, 2025
15 checks passed
@DannyDelott DannyDelott deleted the danny-rewards-claim-button branch February 4, 2025 17:35
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.

3 participants