Skip to content

Commit

Permalink
- expose fee fetchers for default and whitelisted states
Browse files Browse the repository at this point in the history
  • Loading branch information
RolginRoman committed Oct 8, 2024
1 parent 6255290 commit df89b5d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
7 changes: 4 additions & 3 deletions packages/staking/solana/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import {
CreateRewardEntryArgs,
CreateRewardPoolArgs,
CreateStakePoolArgs,
DefaultFeeValueConfig,
FeeValue,
FundPoolArgs,
IInteractSolanaExt,
Expand Down Expand Up @@ -166,18 +167,18 @@ export class SolanaStakingClient {
return rewardPoolProgram.account.rewardEntry.all(getFilters(criteria, REWARD_ENTRY_BYTE_OFFSETS));
}

async getFee(target: string | PublicKey): Promise<FeeValue> {
async getFee(target: string | PublicKey): Promise<FeeValue | DefaultFeeValueConfig> {
const perTargetFee = await this.getFeeValueIfExists(target);
if (perTargetFee) {
return perTargetFee;
}
return this.getDefaultFeeValue();
}

getDefaultFeeValue(): Promise<FeeValue> {
getDefaultFeeValue(): Promise<DefaultFeeValueConfig> {
const { feeManagerProgram } = this.programs;
const feeValueKey = deriveConfigPDA(feeManagerProgram.programId);
return feeManagerProgram.account.feeValue.fetch(feeValueKey);
return feeManagerProgram.account.config.fetch(feeValueKey);
}

getFeeValueIfExists(target: string | PublicKey): Promise<FeeValue | null> {
Expand Down
1 change: 1 addition & 0 deletions packages/staking/solana/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export type StakeEntry = IdlTypes<StakePoolIDL>["stakeEntry"];
export type RewardEntry = IdlTypes<RewardPoolIDL>["rewardEntry"];
export type RewardPool = IdlTypes<RewardPoolIDL>["rewardPool"];
export type FeeValue = IdlTypes<FeeManagerIDL>["feeValue"];
export type DefaultFeeValueConfig = IdlTypes<FeeManagerIDL>["config"];

export interface IInteractSolanaExt extends ITransactionSolanaExt {
invoker: SignerWalletAdapter | Keypair;
Expand Down

0 comments on commit df89b5d

Please sign in to comment.