@streamflow/distributor 8.9.0-alpha.p308.94c0898 → 9.0.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -91,6 +91,7 @@ interface IClaimData {
91
91
  id: string;
92
92
  amountUnlocked: BN;
93
93
  amountLocked: BN;
94
+ claimableAmount: BN;
94
95
  proof: Array<Array<number>>;
95
96
  }
96
97
  interface ICloseClaimData extends Partial<Omit<IClaimData, "id">> {
@@ -634,6 +635,7 @@ declare abstract class BaseDistributorClient {
634
635
  protected commitment: Commitment | ConnectionConfig;
635
636
  protected sendThrottler: PQueue;
636
637
  merkleDistributorProgram: Program<MerkleDistributor$1>;
638
+ protected cluster: ICluster;
637
639
  constructor({ clusterUrl, cluster, commitment, programId, sendRate, sendThrottler, }: IInitOptions);
638
640
  protected abstract getNewDistributorInstruction(data: ICreateDistributorData | ICreateAlignedDistributorData, accounts: NewDistributorAccounts): Promise<TransactionInstruction>;
639
641
  protected abstract getClawbackInstruction(account: ClawbackAccounts): Promise<TransactionInstruction>;
@@ -1377,6 +1379,38 @@ declare namespace constants {
1377
1379
  export { constants_AIRDROP_CLAIM_FEE as AIRDROP_CLAIM_FEE, constants_ALIGNED_DISTRIBUTOR_PREFIX as ALIGNED_DISTRIBUTOR_PREFIX, constants_ALIGNED_DISTRIBUTOR_PROGRAM_ID as ALIGNED_DISTRIBUTOR_PROGRAM_ID, constants_ALIGNED_PRECISION_FACTOR_POW as ALIGNED_PRECISION_FACTOR_POW, constants_ANCHOR_DISCRIMINATOR_OFFSET as ANCHOR_DISCRIMINATOR_OFFSET, constants_CLAIM_STATUS_PREFIX as CLAIM_STATUS_PREFIX, constants_DISTRIBUTOR_ADMIN_OFFSET as DISTRIBUTOR_ADMIN_OFFSET, constants_DISTRIBUTOR_MINT_OFFSET as DISTRIBUTOR_MINT_OFFSET, constants_DISTRIBUTOR_PREFIX as DISTRIBUTOR_PREFIX, constants_DISTRIBUTOR_PROGRAM_ID as DISTRIBUTOR_PROGRAM_ID, constants_ONE_IN_BASIS_POINTS as ONE_IN_BASIS_POINTS, constants_STREAMFLOW_TREASURY_PUBLIC_KEY as STREAMFLOW_TREASURY_PUBLIC_KEY, constants_TEST_ORACLE_PREFIX as TEST_ORACLE_PREFIX };
1378
1380
  }
1379
1381
 
1382
+ type AirdropFeeResponse = {
1383
+ claimFee: string | number;
1384
+ claimFeeDynamic?: {
1385
+ minPrice: string;
1386
+ maxPrice: string;
1387
+ allocationFactor: string;
1388
+ };
1389
+ isCustom: boolean;
1390
+ };
1391
+
1392
+ declare const fetchAirdropFee: (distributorId: string, cluster?: ICluster, fetchFn?: typeof fetch) => Promise<AirdropFeeResponse>;
1393
+ interface AirdropFeeQueryOptionsOverrides {
1394
+ staleTimeMs?: number;
1395
+ gcTimeMs?: number;
1396
+ retry?: number | boolean;
1397
+ refetchOnWindowFocus?: boolean;
1398
+ }
1399
+ declare function getAirdropFeeQueryOptions(params: {
1400
+ distributorId: string;
1401
+ cluster?: ICluster;
1402
+ fetchFn?: typeof fetch;
1403
+ }, options?: AirdropFeeQueryOptionsOverrides): {
1404
+ queryKey: string[];
1405
+ queryFn: () => Promise<AirdropFeeResponse>;
1406
+ staleTime: number;
1407
+ gcTime: number;
1408
+ retry: number | boolean;
1409
+ refetchOnWindowFocus: boolean;
1410
+ };
1411
+
1412
+ type index_AirdropFeeQueryOptionsOverrides = AirdropFeeQueryOptionsOverrides;
1413
+ type index_AirdropFeeResponse = AirdropFeeResponse;
1380
1414
  type index_AlignedDistributorData = AlignedDistributorData;
1381
1415
  type index_AnchorErrorCode = AnchorErrorCode;
1382
1416
  declare const index_AnchorErrorCode: typeof AnchorErrorCode;
@@ -1424,8 +1458,10 @@ declare const index_claimLocked: typeof claimLocked;
1424
1458
  declare const index_clawback: typeof clawback;
1425
1459
  declare const index_closeClaim: typeof closeClaim;
1426
1460
  declare const index_constants: typeof constants;
1461
+ declare const index_fetchAirdropFee: typeof fetchAirdropFee;
1427
1462
  declare const index_fromCode: typeof fromCode;
1428
1463
  declare const index_fromTxError: typeof fromTxError;
1464
+ declare const index_getAirdropFeeQueryOptions: typeof getAirdropFeeQueryOptions;
1429
1465
  declare const index_getAlignedDistributorPda: typeof getAlignedDistributorPda;
1430
1466
  declare const index_getClaimantStatusPda: typeof getClaimantStatusPda;
1431
1467
  declare const index_getDistributorPda: typeof getDistributorPda;
@@ -1438,7 +1474,7 @@ declare const index_setAdmin: typeof setAdmin;
1438
1474
  declare const index_setClawbackReceiver: typeof setClawbackReceiver;
1439
1475
  declare const index_wrappedSignAndExecuteTransaction: typeof wrappedSignAndExecuteTransaction;
1440
1476
  declare namespace index {
1441
- export { type index_AlignedDistributorData as AlignedDistributorData, index_AnchorErrorCode as AnchorErrorCode, type index_AnyClaimStatus as AnyClaimStatus, type index_ClaimLockedAccounts as ClaimLockedAccounts, type index_ClaimStatus as ClaimStatus, type index_ClawbackAccounts as ClawbackAccounts, type index_CloseClaimAccounts as CloseClaimAccounts, type index_CompressedClaimStatus as CompressedClaimStatus, index_ContractErrorCode as ContractErrorCode, type index_IClaimData as IClaimData, type index_IClawbackData as IClawbackData, type index_ICloseClaimData as ICloseClaimData, type index_ICreateAlignedDistributorData as ICreateAlignedDistributorData, type index_ICreateDistributorData as ICreateDistributorData, type index_ICreateDistributorResult as ICreateDistributorResult, type index_ICreateSolanaExt as ICreateSolanaExt, type index_IGetClaimData as IGetClaimData, type index_IGetDistributors as IGetDistributors, type index_IInteractSolanaExt as IInteractSolanaExt, type index_ISearchDistributors as ISearchDistributors, type index_ISetClawbackReceiverData as ISetClawbackReceiverData, type index_ISetDataAdmin as ISetDataAdmin, index_MerkleDistributor as MerkleDistributor, type index_MerkleDistributorAccountTypes as MerkleDistributorAccountTypes, type index_MerkleDistributorFields as MerkleDistributorFields, type index_MerkleDistributorJSON as MerkleDistributorJSON, type index_NewAlignedDistributorArgs as NewAlignedDistributorArgs, type index_NewClaimAccounts as NewClaimAccounts, type index_NewClaimArgs as NewClaimArgs, type index_NewDistributorAccounts as NewDistributorAccounts, type index_NewDistributorArgs as NewDistributorArgs, type index_OracleType as OracleType, type index_OracleTypeName as OracleTypeName, type index_SetAdminAccounts as SetAdminAccounts, type index_SetClawbackReceiverAccounts as SetClawbackReceiverAccounts, index_SolanaAlignedDistributorClient as SolanaAlignedDistributorClient, index_SolanaDistributorClient as SolanaDistributorClient, index_calculateAmountWithTransferFees as calculateAmountWithTransferFees, index_claimLocked as claimLocked, index_clawback as clawback, index_closeClaim as closeClaim, index_constants as constants, index_fromCode as fromCode, index_fromTxError as fromTxError, index_getAlignedDistributorPda as getAlignedDistributorPda, index_getClaimantStatusPda as getClaimantStatusPda, index_getDistributorPda as getDistributorPda, index_getEventAuthorityPda as getEventAuthorityPda, index_getTestOraclePda as getTestOraclePda, index_isCompressedClaimStatus as isCompressedClaimStatus, index_newClaim as newClaim, index_newDistributor as newDistributor, index_setAdmin as setAdmin, index_setClawbackReceiver as setClawbackReceiver, index_wrappedSignAndExecuteTransaction as wrappedSignAndExecuteTransaction };
1477
+ export { type index_AirdropFeeQueryOptionsOverrides as AirdropFeeQueryOptionsOverrides, type index_AirdropFeeResponse as AirdropFeeResponse, type index_AlignedDistributorData as AlignedDistributorData, index_AnchorErrorCode as AnchorErrorCode, type index_AnyClaimStatus as AnyClaimStatus, type index_ClaimLockedAccounts as ClaimLockedAccounts, type index_ClaimStatus as ClaimStatus, type index_ClawbackAccounts as ClawbackAccounts, type index_CloseClaimAccounts as CloseClaimAccounts, type index_CompressedClaimStatus as CompressedClaimStatus, index_ContractErrorCode as ContractErrorCode, type index_IClaimData as IClaimData, type index_IClawbackData as IClawbackData, type index_ICloseClaimData as ICloseClaimData, type index_ICreateAlignedDistributorData as ICreateAlignedDistributorData, type index_ICreateDistributorData as ICreateDistributorData, type index_ICreateDistributorResult as ICreateDistributorResult, type index_ICreateSolanaExt as ICreateSolanaExt, type index_IGetClaimData as IGetClaimData, type index_IGetDistributors as IGetDistributors, type index_IInteractSolanaExt as IInteractSolanaExt, type index_ISearchDistributors as ISearchDistributors, type index_ISetClawbackReceiverData as ISetClawbackReceiverData, type index_ISetDataAdmin as ISetDataAdmin, index_MerkleDistributor as MerkleDistributor, type index_MerkleDistributorAccountTypes as MerkleDistributorAccountTypes, type index_MerkleDistributorFields as MerkleDistributorFields, type index_MerkleDistributorJSON as MerkleDistributorJSON, type index_NewAlignedDistributorArgs as NewAlignedDistributorArgs, type index_NewClaimAccounts as NewClaimAccounts, type index_NewClaimArgs as NewClaimArgs, type index_NewDistributorAccounts as NewDistributorAccounts, type index_NewDistributorArgs as NewDistributorArgs, type index_OracleType as OracleType, type index_OracleTypeName as OracleTypeName, type index_SetAdminAccounts as SetAdminAccounts, type index_SetClawbackReceiverAccounts as SetClawbackReceiverAccounts, index_SolanaAlignedDistributorClient as SolanaAlignedDistributorClient, index_SolanaDistributorClient as SolanaDistributorClient, index_calculateAmountWithTransferFees as calculateAmountWithTransferFees, index_claimLocked as claimLocked, index_clawback as clawback, index_closeClaim as closeClaim, index_constants as constants, index_fetchAirdropFee as fetchAirdropFee, index_fromCode as fromCode, index_fromTxError as fromTxError, index_getAirdropFeeQueryOptions as getAirdropFeeQueryOptions, index_getAlignedDistributorPda as getAlignedDistributorPda, index_getClaimantStatusPda as getClaimantStatusPda, index_getDistributorPda as getDistributorPda, index_getEventAuthorityPda as getEventAuthorityPda, index_getTestOraclePda as getTestOraclePda, index_isCompressedClaimStatus as isCompressedClaimStatus, index_newClaim as newClaim, index_newDistributor as newDistributor, index_setAdmin as setAdmin, index_setClawbackReceiver as setClawbackReceiver, index_wrappedSignAndExecuteTransaction as wrappedSignAndExecuteTransaction };
1442
1478
  }
1443
1479
 
1444
- export { type AlignedDistributorData, AnchorErrorCode, type AnyClaimStatus, type ClaimLockedAccounts, type ClaimStatus, type ClawbackAccounts, type CloseClaimAccounts, type CompressedClaimStatus, ContractErrorCode, type IClaimData, type IClawbackData, type ICloseClaimData, type ICreateAlignedDistributorData, type ICreateDistributorData, type ICreateDistributorResult, type ICreateSolanaExt, type IGetClaimData, type IGetDistributors, type IInteractSolanaExt, type ISearchDistributors, type ISetClawbackReceiverData, type ISetDataAdmin, MerkleDistributor, type MerkleDistributorAccountTypes, type MerkleDistributorFields, type MerkleDistributorJSON, type NewAlignedDistributorArgs, type NewClaimAccounts, type NewClaimArgs, type NewDistributorAccounts, type NewDistributorArgs, type OracleType, type OracleTypeName, type SetAdminAccounts, type SetClawbackReceiverAccounts, SolanaAlignedDistributorClient, SolanaDistributorClient, calculateAmountWithTransferFees, claimLocked, clawback, closeClaim, constants, fromCode, fromTxError, getAlignedDistributorPda, getClaimantStatusPda, getDistributorPda, getEventAuthorityPda, getTestOraclePda, index as i, isCompressedClaimStatus, newClaim, newDistributor, setAdmin, setClawbackReceiver, wrappedSignAndExecuteTransaction };
1480
+ export { type AirdropFeeQueryOptionsOverrides, type AirdropFeeResponse, type AlignedDistributorData, AnchorErrorCode, type AnyClaimStatus, type ClaimLockedAccounts, type ClaimStatus, type ClawbackAccounts, type CloseClaimAccounts, type CompressedClaimStatus, ContractErrorCode, type IClaimData, type IClawbackData, type ICloseClaimData, type ICreateAlignedDistributorData, type ICreateDistributorData, type ICreateDistributorResult, type ICreateSolanaExt, type IGetClaimData, type IGetDistributors, type IInteractSolanaExt, type ISearchDistributors, type ISetClawbackReceiverData, type ISetDataAdmin, MerkleDistributor, type MerkleDistributorAccountTypes, type MerkleDistributorFields, type MerkleDistributorJSON, type NewAlignedDistributorArgs, type NewClaimAccounts, type NewClaimArgs, type NewDistributorAccounts, type NewDistributorArgs, type OracleType, type OracleTypeName, type SetAdminAccounts, type SetClawbackReceiverAccounts, SolanaAlignedDistributorClient, SolanaDistributorClient, calculateAmountWithTransferFees, claimLocked, clawback, closeClaim, constants, fetchAirdropFee, fromCode, fromTxError, getAirdropFeeQueryOptions, getAlignedDistributorPda, getClaimantStatusPda, getDistributorPda, getEventAuthorityPda, getTestOraclePda, index as i, isCompressedClaimStatus, newClaim, newDistributor, setAdmin, setClawbackReceiver, wrappedSignAndExecuteTransaction };
@@ -1,6 +1,6 @@
1
1
  import { PublicKey, TransactionInstruction, Connection, SystemProgram } from '@solana/web3.js';
2
2
  import '@solana/wallet-adapter-base';
3
- import { ICluster, ContractError, divCeilN, invariant, getNumberFromBN, getBN } from '@streamflow/common';
3
+ import { ICluster, ContractError, divCeilN, invariant, getNumberFromBN, getBN, multiplyBigIntByNumber } from '@streamflow/common';
4
4
  import { signAndExecuteTransaction, buildSendThrottler, prepareBaseInstructions, getMintAndProgram, ata, prepareWrappedAccount, createAndEstimateTransaction, prepareTransaction, checkOrCreateAtaBatch, pk, unwrapExecutionParams } from '@streamflow/common/solana';
5
5
  import { Program } from '@coral-xyz/anchor';
6
6
  import * as borsh7 from '@coral-xyz/borsh';
@@ -312,6 +312,150 @@ var DISTRIBUTOR_PROGRAM_ID = {
312
312
  [ICluster.Testnet]: "MErKy6nZVoVAkryxAejJz2juifQ4ArgLgHmaJCQkU7N",
313
313
  [ICluster.Local]: "MErKy6nZVoVAkryxAejJz2juifQ4ArgLgHmaJCQkU7N"
314
314
  };
315
+ var fetchAirdropFee = async (distributorId, cluster = ICluster.Mainnet, fetchFn = fetch) => {
316
+ const baseUrl = cluster === ICluster.Mainnet ? "https://api.streamflow.finance" : "https://staging-api.streamflow.finance";
317
+ const url = `${baseUrl}/v2/api/airdrops/${encodeURIComponent(distributorId)}/fees`;
318
+ const res = await fetchFn(url, {
319
+ method: "GET",
320
+ headers: {
321
+ "Content-Type": "application/json"
322
+ }
323
+ });
324
+ if (!res.ok) {
325
+ const text = await res.text().catch(() => "");
326
+ throw new Error(`Airdrop fee API error: ${res.status} ${res.statusText}${text ? ` - ${text}` : ""}`);
327
+ }
328
+ const json = await res.json();
329
+ return json;
330
+ };
331
+ function getAirdropFeeQueryOptions(params, options) {
332
+ const { staleTimeMs = 6e4, gcTimeMs = 3e5, retry = 2, refetchOnWindowFocus = false } = options ?? {};
333
+ const cluster = params.cluster ?? ICluster.Mainnet;
334
+ const key = ["sf", "airdrop", "fee", cluster, params.distributorId];
335
+ return {
336
+ queryKey: key,
337
+ queryFn: () => fetchAirdropFee(params.distributorId, cluster, params.fetchFn ?? fetch),
338
+ staleTime: staleTimeMs,
339
+ gcTime: gcTimeMs,
340
+ retry,
341
+ refetchOnWindowFocus
342
+ };
343
+ }
344
+
345
+ // solana/fees.ts
346
+ var MAXIMUM_FEE_FALLBACK = 9900000n;
347
+ var MINIMUM_FEE_FALLBACK = 5000000n;
348
+ var FEE_ALLOCATION_FACTOR_FALLBACK_NUMERATOR = 90n;
349
+ var FEE_ALLOCATION_FACTOR_FALLBACK_DENOMINATOR = 100n;
350
+ var LAMPORTS_PER_SOL = 1000000000n;
351
+ var lamportsToSolString = (lamports) => {
352
+ const int = lamports / LAMPORTS_PER_SOL;
353
+ const frac = lamports % LAMPORTS_PER_SOL;
354
+ if (frac === 0n) return int.toString();
355
+ const fracStr = frac.toString().padStart(9, "0").replace(/0+$/, "");
356
+ return `${int.toString()}.${fracStr}`;
357
+ };
358
+ var allocationToString = (num, den) => {
359
+ const SCALE = 1000000000n;
360
+ const scaled = num * SCALE / den;
361
+ const int = scaled / SCALE;
362
+ const frac = scaled % SCALE;
363
+ if (frac === 0n) return int.toString();
364
+ const fracStr = frac.toString().padStart(9, "0").replace(/0+$/, "");
365
+ return `${int.toString()}.${fracStr}`;
366
+ };
367
+ var defaultAPIFeesResponse = {
368
+ isCustom: false,
369
+ claimFee: void 0,
370
+ claimFeeDynamic: {
371
+ minPrice: lamportsToSolString(MINIMUM_FEE_FALLBACK),
372
+ maxPrice: lamportsToSolString(MAXIMUM_FEE_FALLBACK),
373
+ allocationFactor: allocationToString(
374
+ FEE_ALLOCATION_FACTOR_FALLBACK_NUMERATOR,
375
+ FEE_ALLOCATION_FACTOR_FALLBACK_DENOMINATOR
376
+ )
377
+ }
378
+ };
379
+ var toLamportsSOL = (value, solDecimals = 9) => {
380
+ const y = typeof value === "bigint" ? Number(value) : typeof value === "string" ? Number(value) : value;
381
+ if (!Number.isFinite(y) || y <= 0) return 0n;
382
+ const scale = 10n ** BigInt(solDecimals);
383
+ return multiplyBigIntByNumber(scale, y);
384
+ };
385
+ function calculateClaimableLamportsFromPrices(params) {
386
+ const {
387
+ claimableAmount,
388
+ tokenPriceUsd,
389
+ solPriceUsd,
390
+ tokenDecimals,
391
+ solDecimals = 9
392
+ } = params;
393
+ if (tokenPriceUsd <= 0 || solPriceUsd <= 0) return 0n;
394
+ const scaleDigits = Math.min(18, Math.max(0, tokenDecimals));
395
+ const SCALE = 10n ** BigInt(scaleDigits);
396
+ const pScaled = multiplyBigIntByNumber(SCALE, tokenPriceUsd, scaleDigits);
397
+ const sScaled = multiplyBigIntByNumber(SCALE, solPriceUsd, scaleDigits);
398
+ if (pScaled <= 0n || sScaled <= 0n) return 0n;
399
+ const pow10 = (n) => 10n ** BigInt(n);
400
+ const numerator = claimableAmount * pow10(solDecimals) * pScaled;
401
+ const denominator = pow10(tokenDecimals) * sScaled;
402
+ return numerator / denominator;
403
+ }
404
+ function calculateDynamicFeeFromSolParams(params) {
405
+ const { minPrice, maxPrice, allocationFactor, claimableLamports, solDecimals = 9 } = params;
406
+ const minLamports = toLamportsSOL(minPrice, solDecimals);
407
+ const maxLamports = toLamportsSOL(maxPrice, solDecimals);
408
+ const factor = Math.max(0, Math.min(1, parseFloat(allocationFactor)));
409
+ const raw = multiplyBigIntByNumber(claimableLamports, factor);
410
+ if (raw < minLamports) return minLamports;
411
+ if (raw > maxLamports) return maxLamports;
412
+ return raw;
413
+ }
414
+ async function fetchTokenPriceUsd(mintId, cluster, fetchFn = fetch) {
415
+ const url = `https://token-api.streamflow.finance/price?ids=${encodeURIComponent(mintId)}&cluster=${encodeURIComponent(cluster)}`;
416
+ const res = await fetchFn(url, { headers: { "Content-Type": "application/json" } });
417
+ if (!res.ok) return null;
418
+ const json = await res.json();
419
+ const val = json?.data?.[mintId]?.value;
420
+ return typeof val === "number" ? val : null;
421
+ }
422
+ async function resolveAirdropFeeLamportsUsingApi(params) {
423
+ const { distributorAddress, mintAccount, claimableAmount, cluster, fetchFn } = params;
424
+ let apiFeesResponse = void 0;
425
+ try {
426
+ apiFeesResponse = await fetchAirdropFee(distributorAddress, cluster);
427
+ } catch (_) {
428
+ }
429
+ let solPrice = null;
430
+ let tokenPrice = null;
431
+ try {
432
+ [solPrice, tokenPrice] = await Promise.all([
433
+ fetchTokenPriceUsd("So11111111111111111111111111111111111111112", cluster, fetchFn),
434
+ fetchTokenPriceUsd(mintAccount.address.toBase58(), cluster, fetchFn)
435
+ ]);
436
+ } catch (_) {
437
+ }
438
+ const response = apiFeesResponse ?? defaultAPIFeesResponse;
439
+ if (response?.isCustom && response.claimFee !== void 0) {
440
+ return toLamportsSOL(response.claimFee);
441
+ }
442
+ const claimFeeDynamic = response?.claimFeeDynamic ?? defaultAPIFeesResponse.claimFeeDynamic;
443
+ if (!tokenPrice || !solPrice) {
444
+ return MINIMUM_FEE_FALLBACK;
445
+ }
446
+ const baseLamports = calculateClaimableLamportsFromPrices({
447
+ claimableAmount,
448
+ tokenPriceUsd: tokenPrice,
449
+ solPriceUsd: solPrice,
450
+ tokenDecimals: mintAccount.decimals
451
+ });
452
+ return calculateDynamicFeeFromSolParams({
453
+ minPrice: claimFeeDynamic.minPrice,
454
+ maxPrice: claimFeeDynamic.maxPrice,
455
+ allocationFactor: claimFeeDynamic.allocationFactor,
456
+ claimableLamports: baseLamports
457
+ });
458
+ }
315
459
 
316
460
  // solana/descriptor/idl/merkle_distributor.json
317
461
  var merkle_distributor_default = {
@@ -3387,6 +3531,7 @@ var BaseDistributorClient = class {
3387
3531
  sendThrottler
3388
3532
  }) {
3389
3533
  this.commitment = commitment;
3534
+ this.cluster = cluster;
3390
3535
  this.connection = new Connection(clusterUrl, this.commitment);
3391
3536
  this.programId = programId !== "" ? new PublicKey(programId) : new PublicKey(DISTRIBUTOR_PROGRAM_ID[cluster]);
3392
3537
  this.sendThrottler = sendThrottler ?? buildSendThrottler(sendRate);
@@ -3570,12 +3715,21 @@ var BaseDistributorClient = class {
3570
3715
  if (claimStatus || new BN5(data.amountLocked).gtn(0) && nowTs.sub(distributor.startTs).gte(distributor.unlockPeriod)) {
3571
3716
  ixs.push(claimLocked(accounts, this.programId));
3572
3717
  }
3573
- ixs.push(
3574
- this.prepareClaimFeeInstruction(
3575
- extParams.feePayer ?? extParams.invoker.publicKey,
3576
- typeof _serviceTransfer === "bigint" ? _serviceTransfer : void 0
3577
- )
3578
- );
3718
+ let feeLamports = typeof _serviceTransfer === "bigint" ? _serviceTransfer : void 0;
3719
+ if (!feeLamports) {
3720
+ try {
3721
+ const { mint: mintAccount } = await getMintAndProgram(this.connection, distributor.mint);
3722
+ feeLamports = await resolveAirdropFeeLamportsUsingApi({
3723
+ distributorAddress: distributorPublicKey.toBase58(),
3724
+ mintAccount,
3725
+ claimableAmount: BigInt(data.claimableAmount.toString()),
3726
+ cluster: this.cluster
3727
+ });
3728
+ } catch (_) {
3729
+ feeLamports = MINIMUM_FEE_FALLBACK;
3730
+ }
3731
+ }
3732
+ ixs.push(this.prepareClaimFeeInstruction(extParams.feePayer ?? extParams.invoker.publicKey, feeLamports));
3579
3733
  return ixs;
3580
3734
  }
3581
3735
  async closeClaim(data, extParams) {
@@ -5439,6 +5593,6 @@ var SolanaAlignedDistributorClient = class extends BaseDistributorClient {
5439
5593
  }
5440
5594
  };
5441
5595
 
5442
- export { AnchorErrorCode, ContractErrorCode, MerkleDistributor, SolanaAlignedDistributorClient, SolanaDistributorClient, calculateAmountWithTransferFees, claimLocked, clawback, closeClaim, constants_exports as constants, fromCode3 as fromCode, fromTxError, getAlignedDistributorPda, getClaimantStatusPda, getDistributorPda, getEventAuthorityPda, getTestOraclePda, isCompressedClaimStatus, newClaim, newDistributor, setAdmin, setClawbackReceiver, wrappedSignAndExecuteTransaction };
5596
+ export { AnchorErrorCode, ContractErrorCode, MerkleDistributor, SolanaAlignedDistributorClient, SolanaDistributorClient, calculateAmountWithTransferFees, claimLocked, clawback, closeClaim, constants_exports as constants, fetchAirdropFee, fromCode3 as fromCode, fromTxError, getAirdropFeeQueryOptions, getAlignedDistributorPda, getClaimantStatusPda, getDistributorPda, getEventAuthorityPda, getTestOraclePda, isCompressedClaimStatus, newClaim, newDistributor, setAdmin, setClawbackReceiver, wrappedSignAndExecuteTransaction };
5443
5597
  //# sourceMappingURL=index.js.map
5444
5598
  //# sourceMappingURL=index.js.map