@streamflow/distributor 8.9.0 → 9.0.0-alpha.p308.791571f
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.
- package/dist/cjs/index.cjs +141 -6
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/solana/index.cjs +141 -6
- package/dist/cjs/solana/index.cjs.map +1 -1
- package/dist/cjs/solana/index.d.cts +24 -2
- package/dist/esm/index.js +142 -7
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/solana/index.d.ts +24 -2
- package/dist/esm/solana/index.js +142 -8
- package/dist/esm/solana/index.js.map +1 -1
- package/package.json +4 -4
|
@@ -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,25 @@ 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
|
+
interface AirdropFeeQueryOptionsOverrides {
|
|
1392
|
+
staleTimeMs?: number;
|
|
1393
|
+
gcTimeMs?: number;
|
|
1394
|
+
retry?: number | boolean;
|
|
1395
|
+
refetchOnWindowFocus?: boolean;
|
|
1396
|
+
}
|
|
1397
|
+
declare const fetchAirdropFee: (distributorId: string, cluster?: ICluster, fetchFn?: typeof fetch) => Promise<AirdropFeeResponse>;
|
|
1398
|
+
|
|
1399
|
+
type index_AirdropFeeQueryOptionsOverrides = AirdropFeeQueryOptionsOverrides;
|
|
1400
|
+
type index_AirdropFeeResponse = AirdropFeeResponse;
|
|
1380
1401
|
type index_AlignedDistributorData = AlignedDistributorData;
|
|
1381
1402
|
type index_AnchorErrorCode = AnchorErrorCode;
|
|
1382
1403
|
declare const index_AnchorErrorCode: typeof AnchorErrorCode;
|
|
@@ -1424,6 +1445,7 @@ declare const index_claimLocked: typeof claimLocked;
|
|
|
1424
1445
|
declare const index_clawback: typeof clawback;
|
|
1425
1446
|
declare const index_closeClaim: typeof closeClaim;
|
|
1426
1447
|
declare const index_constants: typeof constants;
|
|
1448
|
+
declare const index_fetchAirdropFee: typeof fetchAirdropFee;
|
|
1427
1449
|
declare const index_fromCode: typeof fromCode;
|
|
1428
1450
|
declare const index_fromTxError: typeof fromTxError;
|
|
1429
1451
|
declare const index_getAlignedDistributorPda: typeof getAlignedDistributorPda;
|
|
@@ -1438,7 +1460,7 @@ declare const index_setAdmin: typeof setAdmin;
|
|
|
1438
1460
|
declare const index_setClawbackReceiver: typeof setClawbackReceiver;
|
|
1439
1461
|
declare const index_wrappedSignAndExecuteTransaction: typeof wrappedSignAndExecuteTransaction;
|
|
1440
1462
|
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 };
|
|
1463
|
+
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_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
1464
|
}
|
|
1443
1465
|
|
|
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 };
|
|
1466
|
+
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, getAlignedDistributorPda, getClaimantStatusPda, getDistributorPda, getEventAuthorityPda, getTestOraclePda, index as i, isCompressedClaimStatus, newClaim, newDistributor, setAdmin, setClawbackReceiver, wrappedSignAndExecuteTransaction };
|
package/dist/esm/solana/index.js
CHANGED
|
@@ -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, fetchTokenPrice, 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,123 @@ 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
|
+
|
|
332
|
+
// solana/fees.ts
|
|
333
|
+
var MAXIMUM_FEE_FALLBACK = 9900000n;
|
|
334
|
+
var MINIMUM_FEE_FALLBACK = 5000000n;
|
|
335
|
+
var FEE_ALLOCATION_FACTOR_FALLBACK_NUMERATOR = 90n;
|
|
336
|
+
var FEE_ALLOCATION_FACTOR_FALLBACK_DENOMINATOR = 100n;
|
|
337
|
+
var LAMPORTS_PER_SOL = 1000000000n;
|
|
338
|
+
var lamportsToSolString = (lamports) => {
|
|
339
|
+
const int = lamports / LAMPORTS_PER_SOL;
|
|
340
|
+
const frac = lamports % LAMPORTS_PER_SOL;
|
|
341
|
+
if (frac === 0n) return int.toString();
|
|
342
|
+
const fracStr = frac.toString().padStart(9, "0").replace(/0+$/, "");
|
|
343
|
+
return `${int.toString()}.${fracStr}`;
|
|
344
|
+
};
|
|
345
|
+
var allocationToString = (num, den) => {
|
|
346
|
+
const SCALE = 1000000000n;
|
|
347
|
+
const scaled = num * SCALE / den;
|
|
348
|
+
const int = scaled / SCALE;
|
|
349
|
+
const frac = scaled % SCALE;
|
|
350
|
+
if (frac === 0n) return int.toString();
|
|
351
|
+
const fracStr = frac.toString().padStart(9, "0").replace(/0+$/, "");
|
|
352
|
+
return `${int.toString()}.${fracStr}`;
|
|
353
|
+
};
|
|
354
|
+
var defaultAPIFeesResponse = {
|
|
355
|
+
isCustom: false,
|
|
356
|
+
claimFee: void 0,
|
|
357
|
+
claimFeeDynamic: {
|
|
358
|
+
minPrice: lamportsToSolString(MINIMUM_FEE_FALLBACK),
|
|
359
|
+
maxPrice: lamportsToSolString(MAXIMUM_FEE_FALLBACK),
|
|
360
|
+
allocationFactor: allocationToString(
|
|
361
|
+
FEE_ALLOCATION_FACTOR_FALLBACK_NUMERATOR,
|
|
362
|
+
FEE_ALLOCATION_FACTOR_FALLBACK_DENOMINATOR
|
|
363
|
+
)
|
|
364
|
+
}
|
|
365
|
+
};
|
|
366
|
+
var toLamportsSOL = (value, solDecimals = 9) => {
|
|
367
|
+
const y = typeof value === "bigint" ? Number(value) : typeof value === "string" ? Number(value) : value;
|
|
368
|
+
if (!Number.isFinite(y) || y <= 0) return 0n;
|
|
369
|
+
const scale = 10n ** BigInt(solDecimals);
|
|
370
|
+
return multiplyBigIntByNumber(scale, y);
|
|
371
|
+
};
|
|
372
|
+
function calculateClaimableLamportsFromPrices(params) {
|
|
373
|
+
const { claimableAmount, tokenPriceUsd, solPriceUsd, tokenDecimals, solDecimals = 9 } = params;
|
|
374
|
+
if (tokenPriceUsd <= 0 || solPriceUsd <= 0) return 0n;
|
|
375
|
+
const scaleDigits = Math.min(18, Math.max(0, tokenDecimals));
|
|
376
|
+
const SCALE = 10n ** BigInt(scaleDigits);
|
|
377
|
+
const pScaled = multiplyBigIntByNumber(SCALE, tokenPriceUsd, scaleDigits);
|
|
378
|
+
const sScaled = multiplyBigIntByNumber(SCALE, solPriceUsd, scaleDigits);
|
|
379
|
+
if (pScaled <= 0n || sScaled <= 0n) return 0n;
|
|
380
|
+
const pow10 = (n) => 10n ** BigInt(n);
|
|
381
|
+
const numerator = claimableAmount * pow10(solDecimals) * pScaled;
|
|
382
|
+
const denominator = pow10(tokenDecimals) * sScaled;
|
|
383
|
+
return numerator / denominator;
|
|
384
|
+
}
|
|
385
|
+
function calculateDynamicFeeFromSolParams(params) {
|
|
386
|
+
const { minPrice, maxPrice, allocationFactor, claimableLamports, solDecimals = 9 } = params;
|
|
387
|
+
const minLamports = toLamportsSOL(minPrice, solDecimals);
|
|
388
|
+
const maxLamports = toLamportsSOL(maxPrice, solDecimals);
|
|
389
|
+
const factor = Math.max(0, Math.min(1, parseFloat(allocationFactor)));
|
|
390
|
+
const raw = multiplyBigIntByNumber(claimableLamports, factor);
|
|
391
|
+
if (raw < minLamports) return minLamports;
|
|
392
|
+
if (raw > maxLamports) return maxLamports;
|
|
393
|
+
return raw;
|
|
394
|
+
}
|
|
395
|
+
async function resolveAirdropFeeLamportsUsingApi(params) {
|
|
396
|
+
const { distributorAddress, mintAccount, claimableAmount, cluster } = params;
|
|
397
|
+
let apiFeesResponse = void 0;
|
|
398
|
+
try {
|
|
399
|
+
apiFeesResponse = await fetchAirdropFee(distributorAddress, cluster);
|
|
400
|
+
} catch (_) {
|
|
401
|
+
}
|
|
402
|
+
let solPrice = null;
|
|
403
|
+
let tokenPrice = null;
|
|
404
|
+
try {
|
|
405
|
+
[solPrice, tokenPrice] = await Promise.all([
|
|
406
|
+
fetchTokenPrice(NATIVE_MINT.toBase58(), cluster),
|
|
407
|
+
fetchTokenPrice(mintAccount.address.toBase58(), cluster)
|
|
408
|
+
]);
|
|
409
|
+
} catch (_) {
|
|
410
|
+
}
|
|
411
|
+
const response = apiFeesResponse ?? defaultAPIFeesResponse;
|
|
412
|
+
if (response?.isCustom && response.claimFee !== void 0) {
|
|
413
|
+
return toLamportsSOL(response.claimFee);
|
|
414
|
+
}
|
|
415
|
+
const claimFeeDynamic = response?.claimFeeDynamic ?? defaultAPIFeesResponse.claimFeeDynamic;
|
|
416
|
+
if (!tokenPrice?.value || !solPrice?.value) {
|
|
417
|
+
return MINIMUM_FEE_FALLBACK;
|
|
418
|
+
}
|
|
419
|
+
const baseLamports = calculateClaimableLamportsFromPrices({
|
|
420
|
+
claimableAmount,
|
|
421
|
+
tokenPriceUsd: tokenPrice.value,
|
|
422
|
+
solPriceUsd: solPrice.value,
|
|
423
|
+
tokenDecimals: mintAccount.decimals
|
|
424
|
+
});
|
|
425
|
+
return calculateDynamicFeeFromSolParams({
|
|
426
|
+
minPrice: claimFeeDynamic.minPrice,
|
|
427
|
+
maxPrice: claimFeeDynamic.maxPrice,
|
|
428
|
+
allocationFactor: claimFeeDynamic.allocationFactor,
|
|
429
|
+
claimableLamports: baseLamports
|
|
430
|
+
});
|
|
431
|
+
}
|
|
315
432
|
|
|
316
433
|
// solana/descriptor/idl/merkle_distributor.json
|
|
317
434
|
var merkle_distributor_default = {
|
|
@@ -3387,6 +3504,7 @@ var BaseDistributorClient = class {
|
|
|
3387
3504
|
sendThrottler
|
|
3388
3505
|
}) {
|
|
3389
3506
|
this.commitment = commitment;
|
|
3507
|
+
this.cluster = cluster;
|
|
3390
3508
|
this.connection = new Connection(clusterUrl, this.commitment);
|
|
3391
3509
|
this.programId = programId !== "" ? new PublicKey(programId) : new PublicKey(DISTRIBUTOR_PROGRAM_ID[cluster]);
|
|
3392
3510
|
this.sendThrottler = sendThrottler ?? buildSendThrottler(sendRate);
|
|
@@ -3570,12 +3688,28 @@ var BaseDistributorClient = class {
|
|
|
3570
3688
|
if (claimStatus || new BN5(data.amountLocked).gtn(0) && nowTs.sub(distributor.startTs).gte(distributor.unlockPeriod)) {
|
|
3571
3689
|
ixs.push(claimLocked(accounts, this.programId));
|
|
3572
3690
|
}
|
|
3573
|
-
|
|
3574
|
-
|
|
3575
|
-
|
|
3576
|
-
|
|
3577
|
-
|
|
3578
|
-
|
|
3691
|
+
let feeLamports = typeof _serviceTransfer === "bigint" ? _serviceTransfer : void 0;
|
|
3692
|
+
if (!feeLamports) {
|
|
3693
|
+
try {
|
|
3694
|
+
const { mint: mintAccount } = await getMintAndProgram(this.connection, distributor.mint);
|
|
3695
|
+
const claimableAmountRaw = data?.claimableAmount;
|
|
3696
|
+
const unlockedRaw = data?.amountUnlocked;
|
|
3697
|
+
const lockedRaw = data?.amountLocked;
|
|
3698
|
+
const unlocked = unlockedRaw != null ? new BN5(unlockedRaw) : new BN5(0);
|
|
3699
|
+
const locked = lockedRaw != null ? new BN5(lockedRaw) : new BN5(0);
|
|
3700
|
+
const computedFallback = unlocked.add(locked);
|
|
3701
|
+
const claimableAmount = claimableAmountRaw != null ? BigInt(claimableAmountRaw.toString()) : BigInt(computedFallback.toString());
|
|
3702
|
+
feeLamports = await resolveAirdropFeeLamportsUsingApi({
|
|
3703
|
+
distributorAddress: distributorPublicKey.toBase58(),
|
|
3704
|
+
mintAccount,
|
|
3705
|
+
claimableAmount,
|
|
3706
|
+
cluster: this.cluster
|
|
3707
|
+
});
|
|
3708
|
+
} catch (_) {
|
|
3709
|
+
feeLamports = MINIMUM_FEE_FALLBACK;
|
|
3710
|
+
}
|
|
3711
|
+
}
|
|
3712
|
+
ixs.push(this.prepareClaimFeeInstruction(extParams.feePayer ?? extParams.invoker.publicKey, feeLamports));
|
|
3579
3713
|
return ixs;
|
|
3580
3714
|
}
|
|
3581
3715
|
async closeClaim(data, extParams) {
|
|
@@ -5439,6 +5573,6 @@ var SolanaAlignedDistributorClient = class extends BaseDistributorClient {
|
|
|
5439
5573
|
}
|
|
5440
5574
|
};
|
|
5441
5575
|
|
|
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 };
|
|
5576
|
+
export { AnchorErrorCode, ContractErrorCode, MerkleDistributor, SolanaAlignedDistributorClient, SolanaDistributorClient, calculateAmountWithTransferFees, claimLocked, clawback, closeClaim, constants_exports as constants, fetchAirdropFee, fromCode3 as fromCode, fromTxError, getAlignedDistributorPda, getClaimantStatusPda, getDistributorPda, getEventAuthorityPda, getTestOraclePda, isCompressedClaimStatus, newClaim, newDistributor, setAdmin, setClawbackReceiver, wrappedSignAndExecuteTransaction };
|
|
5443
5577
|
//# sourceMappingURL=index.js.map
|
|
5444
5578
|
//# sourceMappingURL=index.js.map
|