Skip to content

Commit

Permalink
fix(staking): claimable rewards (#1894)
Browse files Browse the repository at this point in the history
* fix(staking): claimable rewards

* fix
  • Loading branch information
keyvankhademi authored Sep 11, 2024
1 parent eb5f600 commit b4fcc32
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions governance/pyth_staking_sdk/src/pyth-staking-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -475,12 +475,20 @@ export class PythStakingClient {
stakeAccountPositions,
);

let totalRewards = 0n;

for (const instruction of instructions) {
await this.connection.simulateTransaction(
new Transaction().add(instruction),
);
const tx = new Transaction().add(instruction);
tx.feePayer = this.wallet.publicKey;
const res = await this.connection.simulateTransaction(tx);
const val = res.value.returnData?.data[0];
if (val === undefined) {
continue;
}
const buffer = Buffer.from(val, "base64");
totalRewards += BigInt("0x" + buffer.toString("hex"));
}

return 1n;
return totalRewards;
}
}

0 comments on commit b4fcc32

Please sign in to comment.