@streamflow/distributor 9.0.0 → 9.0.1

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.
@@ -395,6 +395,41 @@ var toLamportsSOL = (value, solDecimals = 9) => {
395
395
  const scale = 10n ** BigInt(solDecimals);
396
396
  return common.multiplyBigIntByNumber(scale, y);
397
397
  };
398
+ var applyFeeLogic = (baseLamports) => {
399
+ if (baseLamports <= 0n) {
400
+ return MINIMUM_FEE_FALLBACK;
401
+ }
402
+ const raw = baseLamports * FEE_ALLOCATION_FACTOR_FALLBACK_NUMERATOR / FEE_ALLOCATION_FACTOR_FALLBACK_DENOMINATOR;
403
+ if (raw < MINIMUM_FEE_FALLBACK) return MINIMUM_FEE_FALLBACK;
404
+ if (raw > MAXIMUM_FEE_FALLBACK) return MAXIMUM_FEE_FALLBACK;
405
+ return raw;
406
+ };
407
+ async function calculateAirdropFeeLamports(params) {
408
+ const { distributorAddress, client, claimableLamports } = params;
409
+ try {
410
+ if (client) {
411
+ const res = await client.getAirdropFee(distributorAddress);
412
+ const data = res?.data;
413
+ if (data?.isCustom && data.claimFee !== void 0) {
414
+ return toLamportsSOL(data.claimFee);
415
+ }
416
+ if (data?.claimFeeDynamic && claimableLamports !== void 0) {
417
+ const min = toLamportsSOL(data.claimFeeDynamic.minPrice);
418
+ const max = toLamportsSOL(data.claimFeeDynamic.maxPrice);
419
+ const factor = Math.max(0, Math.min(1, parseFloat(data.claimFeeDynamic.allocationFactor)));
420
+ const fee = common.multiplyBigIntByNumber(claimableLamports, factor);
421
+ if (fee < min) return min;
422
+ if (fee > max) return max;
423
+ return fee;
424
+ }
425
+ }
426
+ } catch (_err) {
427
+ }
428
+ if (claimableLamports !== void 0) {
429
+ return applyFeeLogic(claimableLamports);
430
+ }
431
+ return MINIMUM_FEE_FALLBACK;
432
+ }
398
433
  function calculateClaimableLamportsFromPrices(params) {
399
434
  const { claimableAmount, tokenPriceUsd, solPriceUsd, tokenDecimals, solDecimals = 9 } = params;
400
435
  if (tokenPriceUsd <= 0 || solPriceUsd <= 0) return 0n;
@@ -5601,10 +5636,18 @@ var SolanaAlignedDistributorClient = class extends BaseDistributorClient {
5601
5636
 
5602
5637
  exports.AnchorErrorCode = AnchorErrorCode;
5603
5638
  exports.ContractErrorCode = ContractErrorCode;
5639
+ exports.FEE_ALLOCATION_FACTOR_FALLBACK_DENOMINATOR = FEE_ALLOCATION_FACTOR_FALLBACK_DENOMINATOR;
5640
+ exports.FEE_ALLOCATION_FACTOR_FALLBACK_NUMERATOR = FEE_ALLOCATION_FACTOR_FALLBACK_NUMERATOR;
5641
+ exports.MAXIMUM_FEE_FALLBACK = MAXIMUM_FEE_FALLBACK;
5642
+ exports.MINIMUM_FEE_FALLBACK = MINIMUM_FEE_FALLBACK;
5604
5643
  exports.MerkleDistributor = MerkleDistributor;
5605
5644
  exports.SolanaAlignedDistributorClient = SolanaAlignedDistributorClient;
5606
5645
  exports.SolanaDistributorClient = SolanaDistributorClient;
5646
+ exports.applyFeeLogic = applyFeeLogic;
5647
+ exports.calculateAirdropFeeLamports = calculateAirdropFeeLamports;
5607
5648
  exports.calculateAmountWithTransferFees = calculateAmountWithTransferFees;
5649
+ exports.calculateClaimableLamportsFromPrices = calculateClaimableLamportsFromPrices;
5650
+ exports.calculateDynamicFeeFromSolParams = calculateDynamicFeeFromSolParams;
5608
5651
  exports.claimLocked = claimLocked;
5609
5652
  exports.clawback = clawback;
5610
5653
  exports.closeClaim = closeClaim;
@@ -5620,8 +5663,10 @@ exports.getTestOraclePda = getTestOraclePda;
5620
5663
  exports.isCompressedClaimStatus = isCompressedClaimStatus;
5621
5664
  exports.newClaim = newClaim;
5622
5665
  exports.newDistributor = newDistributor;
5666
+ exports.resolveAirdropFeeLamportsUsingApi = resolveAirdropFeeLamportsUsingApi;
5623
5667
  exports.setAdmin = setAdmin;
5624
5668
  exports.setClawbackReceiver = setClawbackReceiver;
5669
+ exports.toLamportsSOL = toLamportsSOL;
5625
5670
  exports.wrappedSignAndExecuteTransaction = wrappedSignAndExecuteTransaction;
5626
5671
  //# sourceMappingURL=index.cjs.map
5627
5672
  //# sourceMappingURL=index.cjs.map