Skip to content

Commit

Permalink
restaking: record the last received height when collecting rewards in…
Browse files Browse the repository at this point in the history
… withdrawal request (#318)

When requesting for withdrawal, the pending rewards are transferred to
the user but the height at which the rewards were claimed was not
updated. This fixes that.

---------

Co-authored-by: Michal Nazarewicz <mina86@mina86.com>
  • Loading branch information
dhruvja and mina86 authored May 5, 2024
1 parent 3882ee9 commit e69bba3
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion solana/restaking/programs/restaking/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,12 +176,14 @@ pub mod restaking {
* Get the rewards from guest blockchain.
*/

let (rewards, _current_height) = chain.calculate_rewards(
let (rewards, current_height) = chain.calculate_rewards(
vault_params.last_received_rewards_height,
*validator_key,
vault_params.stake_amount,
)?;

vault_params.last_received_rewards_height = current_height;

let bump = ctx.bumps.staking_params;
let seeds =
[STAKING_PARAMS_SEED, TEST_SEED, core::slice::from_ref(&bump)];
Expand Down

0 comments on commit e69bba3

Please sign in to comment.