Skip to content

Commit 71dd9f4

Browse files
committed
feat(staking): add reward custody account
1 parent 92efb88 commit 71dd9f4

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

apps/staking/src/components/Header/stats.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ const Loading = () => (
5858
const fetchStats = async (connection: Connection) => {
5959
const client = new PythStakingClient({ connection });
6060
const poolData = await client.getPoolDataAccount();
61+
const rewardCustodyAccount = await client.getRewardCustodyAccount();
6162
const totalDelegated = sum(
6263
poolData.delState.map(
6364
({ totalDelegation, deltaDelegation }) =>
@@ -73,7 +74,10 @@ const fetchStats = async (connection: Connection) => {
7374

7475
return {
7576
totalStaked: totalDelegated + totalSelfStaked,
76-
rewardsDistributed: poolData.claimableRewards + INITIAL_REWARD_POOL_SIZE,
77+
rewardsDistributed:
78+
poolData.claimableRewards +
79+
INITIAL_REWARD_POOL_SIZE -
80+
rewardCustodyAccount.amount,
7781
};
7882
};
7983

governance/pyth_staking_sdk/src/pyth-staking-client.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -974,4 +974,17 @@ export class PythStakingClient {
974974
const globalConfig = await this.getGlobalConfig();
975975
return getMint(this.connection, globalConfig.pythTokenMint);
976976
}
977+
978+
public async getRewardCustodyAccount(): Promise<Account> {
979+
const poolConfigAddress = getPoolConfigAddress();
980+
const config = await this.getGlobalConfig();
981+
982+
const rewardCustodyAccountAddress = getAssociatedTokenAddressSync(
983+
config.pythTokenMint,
984+
poolConfigAddress,
985+
true,
986+
);
987+
988+
return getAccount(this.connection, rewardCustodyAccountAddress);
989+
}
977990
}

0 commit comments

Comments
 (0)