@streamflow/distributor 10.0.3 → 11.0.0-alpha.p334.30f5e22
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 +2660 -3339
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/solana/descriptor/aligned_distributor.d.cts +187 -12
- package/dist/cjs/solana/descriptor/merkle_distributor.d.cts +465 -11
- package/dist/cjs/solana/index.cjs +2660 -3339
- package/dist/cjs/solana/index.cjs.map +1 -1
- package/dist/cjs/solana/index.d.cts +71 -999
- package/dist/esm/index.js +1546 -2205
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/solana/descriptor/aligned_distributor.d.ts +187 -12
- package/dist/esm/solana/descriptor/idl/aligned_distributor.json +187 -12
- package/dist/esm/solana/descriptor/idl/merkle_distributor.json +465 -11
- package/dist/esm/solana/descriptor/merkle_distributor.d.ts +465 -11
- package/dist/esm/solana/index.d.ts +71 -999
- package/dist/esm/solana/index.js +1547 -2196
- package/dist/esm/solana/index.js.map +1 -1
- package/package.json +6 -6
package/dist/esm/solana/index.js
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
import { PublicKey,
|
|
1
|
+
import { PublicKey, Connection, SystemProgram } from '@solana/web3.js';
|
|
2
|
+
import BN from 'bn.js';
|
|
2
3
|
import '@solana/wallet-adapter-base';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
4
|
+
import { parseIdlErrors, translateError, Program } from '@coral-xyz/anchor';
|
|
5
|
+
import { NATIVE_MINT, getAssociatedTokenAddressSync, getTransferFeeConfig, createTransferCheckedWithFeeInstruction, createTransferCheckedInstruction } from '@solana/spl-token';
|
|
6
|
+
import { ICluster, multiplyBigIntByNumber, fetchTokenPrice, signAndExecuteTransaction, ContractError, divCeilN, invariant, getNumberFromBN, pk, getBN, buildPartnerOracle, buildSendThrottler, prepareBaseInstructions, getMintAndProgram, ata, prepareWrappedAccount, createAndEstimateTransaction, prepareTransaction, checkOrCreateAtaBatch, unwrapExecutionParams } from '@streamflow/common';
|
|
6
7
|
import { Buffer as Buffer$1 } from 'buffer';
|
|
7
|
-
import BN5 from 'bn.js';
|
|
8
|
-
import { NATIVE_MINT, getTransferFeeConfig, ASSOCIATED_TOKEN_PROGRAM_ID, createTransferCheckedWithFeeInstruction, createTransferCheckedInstruction } from '@solana/spl-token';
|
|
9
|
-
import bs58 from 'bs58';
|
|
10
8
|
|
|
11
9
|
var __defProp = Object.defineProperty;
|
|
12
10
|
var __export = (target, all) => {
|
|
@@ -94,187 +92,12 @@ var ContractErrorCode = /* @__PURE__ */ ((ContractErrorCode2) => {
|
|
|
94
92
|
ContractErrorCode2["ClaimsAreNotClosable"] = "ClaimsAreNotClosable";
|
|
95
93
|
return ContractErrorCode2;
|
|
96
94
|
})(ContractErrorCode || {});
|
|
97
|
-
var PROGRAM_ID_CLI = new PublicKey("MErKy6nZVoVAkryxAejJz2juifQ4ArgLgHmaJCQkU7N");
|
|
98
|
-
var PROGRAM_ID = PROGRAM_ID_CLI;
|
|
99
|
-
|
|
100
|
-
// solana/generated/instructions/newDistributor.ts
|
|
101
|
-
var layout = borsh7.struct([
|
|
102
|
-
borsh7.u64("version"),
|
|
103
|
-
borsh7.array(borsh7.u8(), 32, "root"),
|
|
104
|
-
borsh7.u64("maxTotalClaim"),
|
|
105
|
-
borsh7.u64("maxNumNodes"),
|
|
106
|
-
borsh7.u64("unlockPeriod"),
|
|
107
|
-
borsh7.u64("startVestingTs"),
|
|
108
|
-
borsh7.u64("endVestingTs"),
|
|
109
|
-
borsh7.u64("clawbackStartTs"),
|
|
110
|
-
borsh7.bool("claimsClosableByAdmin"),
|
|
111
|
-
borsh7.option(borsh7.bool(), "canUpdateDuration"),
|
|
112
|
-
borsh7.option(borsh7.u64(), "totalAmountUnlocked"),
|
|
113
|
-
borsh7.option(borsh7.u64(), "totalAmountLocked"),
|
|
114
|
-
borsh7.option(borsh7.bool(), "claimsClosableByClaimant"),
|
|
115
|
-
borsh7.option(borsh7.u16(), "claimsLimit")
|
|
116
|
-
]);
|
|
117
|
-
function newDistributor(args, accounts, programId = PROGRAM_ID) {
|
|
118
|
-
const keys = [
|
|
119
|
-
{ pubkey: accounts.distributor, isSigner: false, isWritable: true },
|
|
120
|
-
{ pubkey: accounts.clawbackReceiver, isSigner: false, isWritable: true },
|
|
121
|
-
{ pubkey: accounts.mint, isSigner: false, isWritable: false },
|
|
122
|
-
{ pubkey: accounts.tokenVault, isSigner: false, isWritable: true },
|
|
123
|
-
{ pubkey: accounts.admin, isSigner: true, isWritable: true },
|
|
124
|
-
{ pubkey: accounts.systemProgram, isSigner: false, isWritable: false },
|
|
125
|
-
{
|
|
126
|
-
pubkey: accounts.associatedTokenProgram,
|
|
127
|
-
isSigner: false,
|
|
128
|
-
isWritable: false
|
|
129
|
-
},
|
|
130
|
-
{ pubkey: accounts.tokenProgram, isSigner: false, isWritable: false }
|
|
131
|
-
];
|
|
132
|
-
const identifier = Buffer$1.from([32, 139, 112, 171, 0, 2, 225, 155]);
|
|
133
|
-
const buffer = Buffer$1.alloc(1e3);
|
|
134
|
-
const len = layout.encode(
|
|
135
|
-
{
|
|
136
|
-
version: args.version,
|
|
137
|
-
root: args.root,
|
|
138
|
-
maxTotalClaim: args.maxTotalClaim,
|
|
139
|
-
maxNumNodes: args.maxNumNodes,
|
|
140
|
-
unlockPeriod: args.unlockPeriod,
|
|
141
|
-
startVestingTs: args.startVestingTs,
|
|
142
|
-
endVestingTs: args.endVestingTs,
|
|
143
|
-
clawbackStartTs: args.clawbackStartTs,
|
|
144
|
-
claimsClosableByAdmin: args.claimsClosableByAdmin,
|
|
145
|
-
canUpdateDuration: null,
|
|
146
|
-
totalAmountUnlocked: null,
|
|
147
|
-
totalAmountLocked: null,
|
|
148
|
-
claimsClosableByClaimant: args.claimsClosableByClaimant ?? null,
|
|
149
|
-
claimsLimit: args.claimsLimit ?? null
|
|
150
|
-
},
|
|
151
|
-
buffer
|
|
152
|
-
);
|
|
153
|
-
const data = Buffer$1.concat([identifier, buffer]).slice(0, 8 + len);
|
|
154
|
-
const ix = new TransactionInstruction({ keys, programId, data });
|
|
155
|
-
return ix;
|
|
156
|
-
}
|
|
157
|
-
var layout2 = borsh7.struct([
|
|
158
|
-
borsh7.u64("amountUnlocked"),
|
|
159
|
-
borsh7.u64("amountLocked"),
|
|
160
|
-
borsh7.vec(borsh7.array(borsh7.u8(), 32), "proof")
|
|
161
|
-
]);
|
|
162
|
-
function newClaim(args, accounts, programId = PROGRAM_ID) {
|
|
163
|
-
const keys = [
|
|
164
|
-
{ pubkey: accounts.distributor, isSigner: false, isWritable: true },
|
|
165
|
-
{ pubkey: accounts.claimStatus, isSigner: false, isWritable: true },
|
|
166
|
-
{ pubkey: accounts.from, isSigner: false, isWritable: true },
|
|
167
|
-
{ pubkey: accounts.to, isSigner: false, isWritable: true },
|
|
168
|
-
{ pubkey: accounts.claimant, isSigner: true, isWritable: true },
|
|
169
|
-
{ pubkey: accounts.mint, isSigner: false, isWritable: false },
|
|
170
|
-
{ pubkey: accounts.tokenProgram, isSigner: false, isWritable: false },
|
|
171
|
-
{ pubkey: accounts.systemProgram, isSigner: false, isWritable: false },
|
|
172
|
-
{ pubkey: accounts.eventAuthority, isSigner: false, isWritable: false },
|
|
173
|
-
{ pubkey: accounts.program, isSigner: false, isWritable: false }
|
|
174
|
-
];
|
|
175
|
-
const identifier = Buffer.from([78, 177, 98, 123, 210, 21, 187, 83]);
|
|
176
|
-
const buffer = Buffer.alloc(1e3);
|
|
177
|
-
const len = layout2.encode(
|
|
178
|
-
{
|
|
179
|
-
amountUnlocked: args.amountUnlocked,
|
|
180
|
-
amountLocked: args.amountLocked,
|
|
181
|
-
proof: args.proof
|
|
182
|
-
},
|
|
183
|
-
buffer
|
|
184
|
-
);
|
|
185
|
-
const data = Buffer.concat([identifier, buffer]).slice(0, 8 + len);
|
|
186
|
-
const ix = new TransactionInstruction({ keys, programId, data });
|
|
187
|
-
return ix;
|
|
188
|
-
}
|
|
189
|
-
function claimLocked(accounts, programId = PROGRAM_ID) {
|
|
190
|
-
const keys = [
|
|
191
|
-
{ pubkey: accounts.distributor, isSigner: false, isWritable: true },
|
|
192
|
-
{ pubkey: accounts.claimStatus, isSigner: false, isWritable: true },
|
|
193
|
-
{ pubkey: accounts.from, isSigner: false, isWritable: true },
|
|
194
|
-
{ pubkey: accounts.to, isSigner: false, isWritable: true },
|
|
195
|
-
{ pubkey: accounts.claimant, isSigner: true, isWritable: true },
|
|
196
|
-
{ pubkey: accounts.mint, isSigner: false, isWritable: false },
|
|
197
|
-
{ pubkey: accounts.tokenProgram, isSigner: false, isWritable: false },
|
|
198
|
-
{ pubkey: accounts.eventAuthority, isSigner: false, isWritable: false },
|
|
199
|
-
{ pubkey: accounts.program, isSigner: false, isWritable: false }
|
|
200
|
-
];
|
|
201
|
-
const identifier = Buffer.from([34, 206, 181, 23, 11, 207, 147, 90]);
|
|
202
|
-
const data = identifier;
|
|
203
|
-
const ix = new TransactionInstruction({ keys, programId, data });
|
|
204
|
-
return ix;
|
|
205
|
-
}
|
|
206
|
-
function clawback(accounts, programId = PROGRAM_ID) {
|
|
207
|
-
const keys = [
|
|
208
|
-
{ pubkey: accounts.distributor, isSigner: false, isWritable: true },
|
|
209
|
-
{ pubkey: accounts.from, isSigner: false, isWritable: true },
|
|
210
|
-
{ pubkey: accounts.to, isSigner: false, isWritable: true },
|
|
211
|
-
{ pubkey: accounts.admin, isSigner: true, isWritable: true },
|
|
212
|
-
{ pubkey: accounts.mint, isSigner: false, isWritable: false },
|
|
213
|
-
{ pubkey: accounts.systemProgram, isSigner: false, isWritable: false },
|
|
214
|
-
{ pubkey: accounts.tokenProgram, isSigner: false, isWritable: false }
|
|
215
|
-
];
|
|
216
|
-
const identifier = Buffer$1.from([111, 92, 142, 79, 33, 234, 82, 27]);
|
|
217
|
-
const data = identifier;
|
|
218
|
-
const ix = new TransactionInstruction({ keys, programId, data });
|
|
219
|
-
return ix;
|
|
220
|
-
}
|
|
221
|
-
var layout3 = borsh7.struct([
|
|
222
|
-
borsh7.option(borsh7.u64(), "amountUnlocked"),
|
|
223
|
-
borsh7.option(borsh7.u64(), "amountLocked"),
|
|
224
|
-
borsh7.option(borsh7.vec(borsh7.array(borsh7.u8(), 32)), "proof")
|
|
225
|
-
]);
|
|
226
|
-
function closeClaim(args, accounts, programId = PROGRAM_ID) {
|
|
227
|
-
const keys = [
|
|
228
|
-
{ pubkey: accounts.distributor, isSigner: false, isWritable: true },
|
|
229
|
-
{ pubkey: accounts.adminOrClaimant, isSigner: true, isWritable: true },
|
|
230
|
-
{ pubkey: accounts.payer, isSigner: true, isWritable: true },
|
|
231
|
-
{ pubkey: accounts.claimant, isSigner: false, isWritable: true },
|
|
232
|
-
{ pubkey: accounts.claimStatus, isSigner: false, isWritable: true },
|
|
233
|
-
{ pubkey: accounts.systemProgram, isSigner: false, isWritable: false },
|
|
234
|
-
{ pubkey: accounts.eventAuthority, isSigner: false, isWritable: false },
|
|
235
|
-
{ pubkey: accounts.program, isSigner: false, isWritable: false }
|
|
236
|
-
];
|
|
237
|
-
const identifier = Buffer$1.from([42, 177, 165, 35, 213, 179, 211, 19]);
|
|
238
|
-
const buffer = Buffer$1.alloc(1e3);
|
|
239
|
-
const len = layout3.encode(
|
|
240
|
-
{
|
|
241
|
-
amountUnlocked: args.amountUnlocked ?? null,
|
|
242
|
-
amountLocked: args.amountLocked ?? null,
|
|
243
|
-
proof: args.proof ?? null
|
|
244
|
-
},
|
|
245
|
-
buffer
|
|
246
|
-
);
|
|
247
|
-
const data = Buffer$1.concat([identifier, buffer]).slice(0, 8 + len);
|
|
248
|
-
const ix = new TransactionInstruction({ keys, programId, data });
|
|
249
|
-
return ix;
|
|
250
|
-
}
|
|
251
|
-
function setClawbackReceiver(accounts, programId = PROGRAM_ID) {
|
|
252
|
-
const keys = [
|
|
253
|
-
{ pubkey: accounts.distributor, isSigner: false, isWritable: true },
|
|
254
|
-
{ pubkey: accounts.newClawbackAccount, isSigner: false, isWritable: false },
|
|
255
|
-
{ pubkey: accounts.admin, isSigner: true, isWritable: true }
|
|
256
|
-
];
|
|
257
|
-
const identifier = Buffer$1.from([153, 217, 34, 20, 19, 29, 229, 75]);
|
|
258
|
-
const data = identifier;
|
|
259
|
-
const ix = new TransactionInstruction({ keys, programId, data });
|
|
260
|
-
return ix;
|
|
261
|
-
}
|
|
262
|
-
function setAdmin(accounts, programId = PROGRAM_ID) {
|
|
263
|
-
const keys = [
|
|
264
|
-
{ pubkey: accounts.distributor, isSigner: false, isWritable: true },
|
|
265
|
-
{ pubkey: accounts.admin, isSigner: true, isWritable: true },
|
|
266
|
-
{ pubkey: accounts.newAdmin, isSigner: false, isWritable: true }
|
|
267
|
-
];
|
|
268
|
-
const identifier = Buffer$1.from([251, 163, 0, 52, 91, 194, 187, 92]);
|
|
269
|
-
const data = identifier;
|
|
270
|
-
const ix = new TransactionInstruction({ keys, programId, data });
|
|
271
|
-
return ix;
|
|
272
|
-
}
|
|
273
95
|
|
|
274
96
|
// solana/constants.ts
|
|
275
97
|
var constants_exports = {};
|
|
276
98
|
__export(constants_exports, {
|
|
277
99
|
AIRDROP_CLAIM_FEE: () => AIRDROP_CLAIM_FEE,
|
|
100
|
+
ALIGNED_DISTRIBUTOR_ERRORS: () => ALIGNED_DISTRIBUTOR_ERRORS,
|
|
278
101
|
ALIGNED_DISTRIBUTOR_PREFIX: () => ALIGNED_DISTRIBUTOR_PREFIX,
|
|
279
102
|
ALIGNED_DISTRIBUTOR_PROGRAM_ID: () => ALIGNED_DISTRIBUTOR_PROGRAM_ID,
|
|
280
103
|
ALIGNED_PRECISION_FACTOR_POW: () => ALIGNED_PRECISION_FACTOR_POW,
|
|
@@ -284,194 +107,21 @@ __export(constants_exports, {
|
|
|
284
107
|
DISTRIBUTOR_MINT_OFFSET: () => DISTRIBUTOR_MINT_OFFSET,
|
|
285
108
|
DISTRIBUTOR_PREFIX: () => DISTRIBUTOR_PREFIX,
|
|
286
109
|
DISTRIBUTOR_PROGRAM_ID: () => DISTRIBUTOR_PROGRAM_ID,
|
|
110
|
+
FEE_CONFIG_PUBLIC_KEY: () => FEE_CONFIG_PUBLIC_KEY,
|
|
111
|
+
MERKLE_DISTRIBUTOR_ERRORS: () => MERKLE_DISTRIBUTOR_ERRORS,
|
|
287
112
|
ONE_IN_BASIS_POINTS: () => ONE_IN_BASIS_POINTS,
|
|
113
|
+
PARTNER_ORACLE_PROGRAM_ID: () => PARTNER_ORACLE_PROGRAM_ID,
|
|
114
|
+
SOL_FEE_PROGRAM_VERSION: () => SOL_FEE_PROGRAM_VERSION,
|
|
288
115
|
STREAMFLOW_TREASURY_PUBLIC_KEY: () => STREAMFLOW_TREASURY_PUBLIC_KEY,
|
|
289
116
|
TEST_ORACLE_PREFIX: () => TEST_ORACLE_PREFIX
|
|
290
117
|
});
|
|
291
|
-
var ANCHOR_DISCRIMINATOR_OFFSET = 8;
|
|
292
|
-
var DISTRIBUTOR_MINT_OFFSET = ANCHOR_DISCRIMINATOR_OFFSET + 41;
|
|
293
|
-
var DISTRIBUTOR_ADMIN_OFFSET = ANCHOR_DISCRIMINATOR_OFFSET + 201;
|
|
294
|
-
var DISTRIBUTOR_PREFIX = Buffer.from("MerkleDistributor", "utf-8");
|
|
295
|
-
var ALIGNED_DISTRIBUTOR_PREFIX = Buffer.from("aligned-distributor", "utf-8");
|
|
296
|
-
var TEST_ORACLE_PREFIX = Buffer.from("test-oracle", "utf-8");
|
|
297
|
-
var CLAIM_STATUS_PREFIX = Buffer.from("ClaimStatus", "utf-8");
|
|
298
|
-
var ALIGNED_PRECISION_FACTOR_POW = 9;
|
|
299
|
-
var AIRDROP_CLAIM_FEE = BigInt(1e7);
|
|
300
|
-
var STREAMFLOW_TREASURY_PUBLIC_KEY = new PublicKey("5SEpbdjFK5FxwTvfsGMXVQTD2v4M2c5tyRTxhdsPkgDw");
|
|
301
|
-
var ONE_IN_BASIS_POINTS = BigInt(1e4);
|
|
302
|
-
var ALIGNED_DISTRIBUTOR_PROGRAM_ID = {
|
|
303
|
-
[ICluster.Devnet]: "aMERKpFAWoChCi5oZwPvgsSCoGpZKBiU7fi76bdZjt2",
|
|
304
|
-
[ICluster.Mainnet]: "aMERKpFAWoChCi5oZwPvgsSCoGpZKBiU7fi76bdZjt2",
|
|
305
|
-
[ICluster.Testnet]: "aMERKpFAWoChCi5oZwPvgsSCoGpZKBiU7fi76bdZjt2",
|
|
306
|
-
[ICluster.Local]: "aMERKpFAWoChCi5oZwPvgsSCoGpZKBiU7fi76bdZjt2"
|
|
307
|
-
};
|
|
308
|
-
var DISTRIBUTOR_PROGRAM_ID = {
|
|
309
|
-
[ICluster.Devnet]: "MErKy6nZVoVAkryxAejJz2juifQ4ArgLgHmaJCQkU7N",
|
|
310
|
-
[ICluster.Mainnet]: "MErKy6nZVoVAkryxAejJz2juifQ4ArgLgHmaJCQkU7N",
|
|
311
|
-
[ICluster.Testnet]: "MErKy6nZVoVAkryxAejJz2juifQ4ArgLgHmaJCQkU7N",
|
|
312
|
-
[ICluster.Local]: "MErKy6nZVoVAkryxAejJz2juifQ4ArgLgHmaJCQkU7N"
|
|
313
|
-
};
|
|
314
|
-
|
|
315
|
-
// solana/fetchAirdropFee.ts
|
|
316
|
-
var fetchAirdropFee = async (distributorId, apiUrl, apiKey, fetchFn = fetch) => {
|
|
317
|
-
const url = `${apiUrl}/v2/api/airdrops/${encodeURIComponent(distributorId)}/fees`;
|
|
318
|
-
const res = await fetchFn(url, {
|
|
319
|
-
method: "GET",
|
|
320
|
-
headers: {
|
|
321
|
-
"Content-Type": "application/json",
|
|
322
|
-
...apiKey ? { "x-api-key": apiKey } : {}
|
|
323
|
-
}
|
|
324
|
-
});
|
|
325
|
-
if (!res.ok) {
|
|
326
|
-
const text = await res.text().catch(() => "");
|
|
327
|
-
throw new Error(`Airdrop fee API error: ${res.status} ${res.statusText}${text ? ` - ${text}` : ""}`);
|
|
328
|
-
}
|
|
329
|
-
const json = await res.json();
|
|
330
|
-
return json;
|
|
331
|
-
};
|
|
332
|
-
|
|
333
|
-
// solana/fees.ts
|
|
334
|
-
var MAXIMUM_FEE_FALLBACK = 9900000n;
|
|
335
|
-
var MINIMUM_FEE_FALLBACK = 5000000n;
|
|
336
|
-
var FEE_ALLOCATION_FACTOR_FALLBACK_NUMERATOR = 90n;
|
|
337
|
-
var FEE_ALLOCATION_FACTOR_FALLBACK_DENOMINATOR = 100n;
|
|
338
|
-
var LAMPORTS_PER_SOL = 1000000000n;
|
|
339
|
-
var lamportsToSolString = (lamports) => {
|
|
340
|
-
const int = lamports / LAMPORTS_PER_SOL;
|
|
341
|
-
const frac = lamports % LAMPORTS_PER_SOL;
|
|
342
|
-
if (frac === 0n) return int.toString();
|
|
343
|
-
const fracStr = frac.toString().padStart(9, "0").replace(/0+$/, "");
|
|
344
|
-
return `${int.toString()}.${fracStr}`;
|
|
345
|
-
};
|
|
346
|
-
var allocationToString = (num, den) => {
|
|
347
|
-
const SCALE = 1000000000n;
|
|
348
|
-
const scaled = num * SCALE / den;
|
|
349
|
-
const int = scaled / SCALE;
|
|
350
|
-
const frac = scaled % SCALE;
|
|
351
|
-
if (frac === 0n) return int.toString();
|
|
352
|
-
const fracStr = frac.toString().padStart(9, "0").replace(/0+$/, "");
|
|
353
|
-
return `${int.toString()}.${fracStr}`;
|
|
354
|
-
};
|
|
355
|
-
var defaultAPIFeesResponse = {
|
|
356
|
-
isCustom: false,
|
|
357
|
-
claimFee: void 0,
|
|
358
|
-
claimFeeDynamic: {
|
|
359
|
-
minPrice: lamportsToSolString(MINIMUM_FEE_FALLBACK),
|
|
360
|
-
maxPrice: lamportsToSolString(MAXIMUM_FEE_FALLBACK),
|
|
361
|
-
allocationFactor: allocationToString(
|
|
362
|
-
FEE_ALLOCATION_FACTOR_FALLBACK_NUMERATOR,
|
|
363
|
-
FEE_ALLOCATION_FACTOR_FALLBACK_DENOMINATOR
|
|
364
|
-
)
|
|
365
|
-
}
|
|
366
|
-
};
|
|
367
|
-
var toLamportsSOL = (value, solDecimals = 9) => {
|
|
368
|
-
const y = typeof value === "bigint" ? Number(value) : typeof value === "string" ? Number(value) : value;
|
|
369
|
-
if (!Number.isFinite(y) || y <= 0) return 0n;
|
|
370
|
-
const scale = 10n ** BigInt(solDecimals);
|
|
371
|
-
return multiplyBigIntByNumber(scale, y);
|
|
372
|
-
};
|
|
373
|
-
var applyFeeLogic = (baseLamports) => {
|
|
374
|
-
if (baseLamports <= 0n) {
|
|
375
|
-
return MINIMUM_FEE_FALLBACK;
|
|
376
|
-
}
|
|
377
|
-
const raw = baseLamports * FEE_ALLOCATION_FACTOR_FALLBACK_NUMERATOR / FEE_ALLOCATION_FACTOR_FALLBACK_DENOMINATOR;
|
|
378
|
-
if (raw < MINIMUM_FEE_FALLBACK) return MINIMUM_FEE_FALLBACK;
|
|
379
|
-
if (raw > MAXIMUM_FEE_FALLBACK) return MAXIMUM_FEE_FALLBACK;
|
|
380
|
-
return raw;
|
|
381
|
-
};
|
|
382
|
-
async function calculateAirdropFeeLamports(params) {
|
|
383
|
-
const { distributorAddress, client, claimableLamports } = params;
|
|
384
|
-
try {
|
|
385
|
-
if (client) {
|
|
386
|
-
const res = await client.getAirdropFee(distributorAddress);
|
|
387
|
-
const data = res?.data;
|
|
388
|
-
if (data?.isCustom && data.claimFee !== void 0) {
|
|
389
|
-
return toLamportsSOL(data.claimFee);
|
|
390
|
-
}
|
|
391
|
-
if (data?.claimFeeDynamic && claimableLamports !== void 0) {
|
|
392
|
-
const min = toLamportsSOL(data.claimFeeDynamic.minPrice);
|
|
393
|
-
const max = toLamportsSOL(data.claimFeeDynamic.maxPrice);
|
|
394
|
-
const factor = Math.max(0, Math.min(1, parseFloat(data.claimFeeDynamic.allocationFactor)));
|
|
395
|
-
const fee = multiplyBigIntByNumber(claimableLamports, factor);
|
|
396
|
-
if (fee < min) return min;
|
|
397
|
-
if (fee > max) return max;
|
|
398
|
-
return fee;
|
|
399
|
-
}
|
|
400
|
-
}
|
|
401
|
-
} catch (_err) {
|
|
402
|
-
}
|
|
403
|
-
if (claimableLamports !== void 0) {
|
|
404
|
-
return applyFeeLogic(claimableLamports);
|
|
405
|
-
}
|
|
406
|
-
return MINIMUM_FEE_FALLBACK;
|
|
407
|
-
}
|
|
408
|
-
function calculateClaimableLamportsFromPrices(params) {
|
|
409
|
-
const { claimableAmount, tokenPriceUsd, solPriceUsd, tokenDecimals, solDecimals = 9 } = params;
|
|
410
|
-
if (tokenPriceUsd <= 0 || solPriceUsd <= 0) return 0n;
|
|
411
|
-
const scaleDigits = Math.min(18, Math.max(0, tokenDecimals));
|
|
412
|
-
const SCALE = 10n ** BigInt(scaleDigits);
|
|
413
|
-
const pScaled = multiplyBigIntByNumber(SCALE, tokenPriceUsd, scaleDigits);
|
|
414
|
-
const sScaled = multiplyBigIntByNumber(SCALE, solPriceUsd, scaleDigits);
|
|
415
|
-
if (pScaled <= 0n || sScaled <= 0n) return 0n;
|
|
416
|
-
const pow10 = (n) => 10n ** BigInt(n);
|
|
417
|
-
const numerator = claimableAmount * pow10(solDecimals) * pScaled;
|
|
418
|
-
const denominator = pow10(tokenDecimals) * sScaled;
|
|
419
|
-
return numerator / denominator;
|
|
420
|
-
}
|
|
421
|
-
function calculateDynamicFeeFromSolParams(params) {
|
|
422
|
-
const { minPrice, maxPrice, allocationFactor, claimableLamports, solDecimals = 9 } = params;
|
|
423
|
-
const minLamports = toLamportsSOL(minPrice, solDecimals);
|
|
424
|
-
const maxLamports = toLamportsSOL(maxPrice, solDecimals);
|
|
425
|
-
const factor = Math.max(0, Math.min(1, parseFloat(allocationFactor)));
|
|
426
|
-
const raw = multiplyBigIntByNumber(claimableLamports, factor);
|
|
427
|
-
if (raw < minLamports) return minLamports;
|
|
428
|
-
if (raw > maxLamports) return maxLamports;
|
|
429
|
-
return raw;
|
|
430
|
-
}
|
|
431
|
-
async function resolveAirdropFeeLamportsUsingApi(params) {
|
|
432
|
-
const { distributorAddress, mintAccount, claimableAmount, cluster, apiUrl, apiKey } = params;
|
|
433
|
-
let apiFeesResponse = void 0;
|
|
434
|
-
try {
|
|
435
|
-
apiFeesResponse = await fetchAirdropFee(distributorAddress, apiUrl, apiKey);
|
|
436
|
-
} catch (_) {
|
|
437
|
-
}
|
|
438
|
-
let solPrice = null;
|
|
439
|
-
let tokenPrice = null;
|
|
440
|
-
try {
|
|
441
|
-
[solPrice, tokenPrice] = await Promise.all([
|
|
442
|
-
fetchTokenPrice(NATIVE_MINT.toBase58(), cluster),
|
|
443
|
-
fetchTokenPrice(mintAccount.address.toBase58(), cluster)
|
|
444
|
-
]);
|
|
445
|
-
} catch (_) {
|
|
446
|
-
}
|
|
447
|
-
const response = apiFeesResponse ?? defaultAPIFeesResponse;
|
|
448
|
-
if (response?.isCustom && response.claimFee !== void 0 && response.claimFee !== null) {
|
|
449
|
-
return toLamportsSOL(response.claimFee);
|
|
450
|
-
}
|
|
451
|
-
const claimFeeDynamic = response?.claimFeeDynamic ?? defaultAPIFeesResponse.claimFeeDynamic;
|
|
452
|
-
if (!tokenPrice?.value || !solPrice?.value) {
|
|
453
|
-
return MINIMUM_FEE_FALLBACK;
|
|
454
|
-
}
|
|
455
|
-
const baseLamports = calculateClaimableLamportsFromPrices({
|
|
456
|
-
claimableAmount,
|
|
457
|
-
tokenPriceUsd: tokenPrice.value,
|
|
458
|
-
solPriceUsd: solPrice.value,
|
|
459
|
-
tokenDecimals: mintAccount.decimals
|
|
460
|
-
});
|
|
461
|
-
return calculateDynamicFeeFromSolParams({
|
|
462
|
-
minPrice: claimFeeDynamic.minPrice,
|
|
463
|
-
maxPrice: claimFeeDynamic.maxPrice,
|
|
464
|
-
allocationFactor: claimFeeDynamic.allocationFactor,
|
|
465
|
-
claimableLamports: baseLamports
|
|
466
|
-
});
|
|
467
|
-
}
|
|
468
118
|
|
|
469
119
|
// solana/descriptor/idl/merkle_distributor.json
|
|
470
120
|
var merkle_distributor_default = {
|
|
471
121
|
address: "MErKy6nZVoVAkryxAejJz2juifQ4ArgLgHmaJCQkU7N",
|
|
472
122
|
metadata: {
|
|
473
123
|
name: "merkle_distributor",
|
|
474
|
-
version: "
|
|
124
|
+
version: "2.0.0",
|
|
475
125
|
spec: "0.1.0",
|
|
476
126
|
description: "A Solana program for distributing tokens according to a Merkle root.",
|
|
477
127
|
repository: "https://github.com/streamflow-finance/distributor"
|
|
@@ -756,16 +406,16 @@ var merkle_distributor_default = {
|
|
|
756
406
|
args: []
|
|
757
407
|
},
|
|
758
408
|
{
|
|
759
|
-
name: "
|
|
409
|
+
name: "claim_locked_v2",
|
|
760
410
|
discriminator: [
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
411
|
+
44,
|
|
412
|
+
21,
|
|
413
|
+
175,
|
|
414
|
+
161,
|
|
415
|
+
99,
|
|
416
|
+
76,
|
|
417
|
+
44,
|
|
418
|
+
249
|
|
769
419
|
],
|
|
770
420
|
accounts: [
|
|
771
421
|
{
|
|
@@ -775,17 +425,291 @@ var merkle_distributor_default = {
|
|
|
775
425
|
],
|
|
776
426
|
writable: true
|
|
777
427
|
},
|
|
428
|
+
{
|
|
429
|
+
name: "claim_status",
|
|
430
|
+
writable: true,
|
|
431
|
+
pda: {
|
|
432
|
+
seeds: [
|
|
433
|
+
{
|
|
434
|
+
kind: "const",
|
|
435
|
+
value: [
|
|
436
|
+
67,
|
|
437
|
+
108,
|
|
438
|
+
97,
|
|
439
|
+
105,
|
|
440
|
+
109,
|
|
441
|
+
83,
|
|
442
|
+
116,
|
|
443
|
+
97,
|
|
444
|
+
116,
|
|
445
|
+
117,
|
|
446
|
+
115
|
|
447
|
+
]
|
|
448
|
+
},
|
|
449
|
+
{
|
|
450
|
+
kind: "account",
|
|
451
|
+
path: "claimant"
|
|
452
|
+
},
|
|
453
|
+
{
|
|
454
|
+
kind: "account",
|
|
455
|
+
path: "distributor"
|
|
456
|
+
}
|
|
457
|
+
]
|
|
458
|
+
}
|
|
459
|
+
},
|
|
778
460
|
{
|
|
779
461
|
name: "from",
|
|
780
462
|
docs: [
|
|
781
463
|
"Distributor ATA containing the tokens to distribute."
|
|
782
464
|
],
|
|
783
|
-
writable: true
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
465
|
+
writable: true,
|
|
466
|
+
pda: {
|
|
467
|
+
seeds: [
|
|
468
|
+
{
|
|
469
|
+
kind: "account",
|
|
470
|
+
path: "distributor"
|
|
471
|
+
},
|
|
472
|
+
{
|
|
473
|
+
kind: "account",
|
|
474
|
+
path: "token_program"
|
|
475
|
+
},
|
|
476
|
+
{
|
|
477
|
+
kind: "account",
|
|
478
|
+
path: "distributor.mint",
|
|
479
|
+
account: "MerkleDistributor"
|
|
480
|
+
}
|
|
481
|
+
],
|
|
482
|
+
program: {
|
|
483
|
+
kind: "const",
|
|
484
|
+
value: [
|
|
485
|
+
140,
|
|
486
|
+
151,
|
|
487
|
+
37,
|
|
488
|
+
143,
|
|
489
|
+
78,
|
|
490
|
+
36,
|
|
491
|
+
137,
|
|
492
|
+
241,
|
|
493
|
+
187,
|
|
494
|
+
61,
|
|
495
|
+
16,
|
|
496
|
+
41,
|
|
497
|
+
20,
|
|
498
|
+
142,
|
|
499
|
+
13,
|
|
500
|
+
131,
|
|
501
|
+
11,
|
|
502
|
+
90,
|
|
503
|
+
19,
|
|
504
|
+
153,
|
|
505
|
+
218,
|
|
506
|
+
255,
|
|
507
|
+
16,
|
|
508
|
+
132,
|
|
509
|
+
4,
|
|
510
|
+
142,
|
|
511
|
+
123,
|
|
512
|
+
216,
|
|
513
|
+
219,
|
|
514
|
+
233,
|
|
515
|
+
248,
|
|
516
|
+
89
|
|
517
|
+
]
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
},
|
|
521
|
+
{
|
|
522
|
+
name: "to",
|
|
523
|
+
docs: [
|
|
524
|
+
"Account to send the claimed tokens to.",
|
|
525
|
+
"Claimant must sign the transaction and can only claim on behalf of themself"
|
|
526
|
+
],
|
|
527
|
+
writable: true
|
|
528
|
+
},
|
|
529
|
+
{
|
|
530
|
+
name: "claimant",
|
|
531
|
+
docs: [
|
|
532
|
+
"Who is claiming the tokens."
|
|
533
|
+
],
|
|
534
|
+
writable: true,
|
|
535
|
+
signer: true
|
|
536
|
+
},
|
|
537
|
+
{
|
|
538
|
+
name: "mint",
|
|
539
|
+
docs: [
|
|
540
|
+
"The mint to claim."
|
|
541
|
+
],
|
|
542
|
+
relations: [
|
|
543
|
+
"distributor"
|
|
544
|
+
]
|
|
545
|
+
},
|
|
546
|
+
{
|
|
547
|
+
name: "token_program",
|
|
548
|
+
docs: [
|
|
549
|
+
"SPL [Token] program."
|
|
550
|
+
]
|
|
551
|
+
},
|
|
552
|
+
{
|
|
553
|
+
name: "system_program",
|
|
554
|
+
docs: [
|
|
555
|
+
"System program for fee transfers."
|
|
556
|
+
],
|
|
557
|
+
address: "11111111111111111111111111111111"
|
|
558
|
+
},
|
|
559
|
+
{
|
|
560
|
+
name: "event_authority",
|
|
561
|
+
pda: {
|
|
562
|
+
seeds: [
|
|
563
|
+
{
|
|
564
|
+
kind: "const",
|
|
565
|
+
value: [
|
|
566
|
+
95,
|
|
567
|
+
95,
|
|
568
|
+
101,
|
|
569
|
+
118,
|
|
570
|
+
101,
|
|
571
|
+
110,
|
|
572
|
+
116,
|
|
573
|
+
95,
|
|
574
|
+
97,
|
|
575
|
+
117,
|
|
576
|
+
116,
|
|
577
|
+
104,
|
|
578
|
+
111,
|
|
579
|
+
114,
|
|
580
|
+
105,
|
|
581
|
+
116,
|
|
582
|
+
121
|
|
583
|
+
]
|
|
584
|
+
}
|
|
585
|
+
]
|
|
586
|
+
}
|
|
587
|
+
},
|
|
588
|
+
{
|
|
589
|
+
name: "program"
|
|
590
|
+
}
|
|
591
|
+
],
|
|
592
|
+
args: []
|
|
593
|
+
},
|
|
594
|
+
{
|
|
595
|
+
name: "claim_sol_fees",
|
|
596
|
+
discriminator: [
|
|
597
|
+
127,
|
|
598
|
+
0,
|
|
599
|
+
119,
|
|
600
|
+
89,
|
|
601
|
+
193,
|
|
602
|
+
27,
|
|
603
|
+
209,
|
|
604
|
+
142
|
|
605
|
+
],
|
|
606
|
+
accounts: [
|
|
607
|
+
{
|
|
608
|
+
name: "distributor",
|
|
609
|
+
docs: [
|
|
610
|
+
"The [MerkleDistributor]."
|
|
611
|
+
],
|
|
612
|
+
writable: true
|
|
613
|
+
},
|
|
614
|
+
{
|
|
615
|
+
name: "treasury",
|
|
616
|
+
writable: true,
|
|
617
|
+
address: "5SEpbdjFK5FxwTvfsGMXVQTD2v4M2c5tyRTxhdsPkgDw"
|
|
618
|
+
}
|
|
619
|
+
],
|
|
620
|
+
args: []
|
|
621
|
+
},
|
|
622
|
+
{
|
|
623
|
+
name: "claim_token_fees",
|
|
624
|
+
discriminator: [
|
|
625
|
+
205,
|
|
626
|
+
136,
|
|
627
|
+
215,
|
|
628
|
+
209,
|
|
629
|
+
62,
|
|
630
|
+
196,
|
|
631
|
+
69,
|
|
632
|
+
182
|
|
633
|
+
],
|
|
634
|
+
accounts: [
|
|
635
|
+
{
|
|
636
|
+
name: "distributor",
|
|
637
|
+
docs: [
|
|
638
|
+
"The [MerkleDistributor]."
|
|
639
|
+
],
|
|
640
|
+
writable: true
|
|
641
|
+
},
|
|
642
|
+
{
|
|
643
|
+
name: "token_vault",
|
|
644
|
+
docs: [
|
|
645
|
+
"Token vault to return clawback fee from"
|
|
646
|
+
],
|
|
647
|
+
writable: true,
|
|
648
|
+
relations: [
|
|
649
|
+
"distributor"
|
|
650
|
+
]
|
|
651
|
+
},
|
|
652
|
+
{
|
|
653
|
+
name: "mint",
|
|
654
|
+
docs: [
|
|
655
|
+
"Distributor mint"
|
|
656
|
+
],
|
|
657
|
+
relations: [
|
|
658
|
+
"distributor"
|
|
659
|
+
]
|
|
660
|
+
},
|
|
661
|
+
{
|
|
662
|
+
name: "treasury",
|
|
663
|
+
writable: true,
|
|
664
|
+
address: "5SEpbdjFK5FxwTvfsGMXVQTD2v4M2c5tyRTxhdsPkgDw"
|
|
665
|
+
},
|
|
666
|
+
{
|
|
667
|
+
name: "to",
|
|
668
|
+
docs: [
|
|
669
|
+
"Account to send the clawed back fee to."
|
|
670
|
+
],
|
|
671
|
+
writable: true
|
|
672
|
+
},
|
|
673
|
+
{
|
|
674
|
+
name: "token_program",
|
|
675
|
+
docs: [
|
|
676
|
+
"SPL [Token] program."
|
|
677
|
+
]
|
|
678
|
+
}
|
|
679
|
+
],
|
|
680
|
+
args: []
|
|
681
|
+
},
|
|
682
|
+
{
|
|
683
|
+
name: "clawback",
|
|
684
|
+
discriminator: [
|
|
685
|
+
111,
|
|
686
|
+
92,
|
|
687
|
+
142,
|
|
688
|
+
79,
|
|
689
|
+
33,
|
|
690
|
+
234,
|
|
691
|
+
82,
|
|
692
|
+
27
|
|
693
|
+
],
|
|
694
|
+
accounts: [
|
|
695
|
+
{
|
|
696
|
+
name: "distributor",
|
|
697
|
+
docs: [
|
|
698
|
+
"The [MerkleDistributor]."
|
|
699
|
+
],
|
|
700
|
+
writable: true
|
|
701
|
+
},
|
|
702
|
+
{
|
|
703
|
+
name: "from",
|
|
704
|
+
docs: [
|
|
705
|
+
"Distributor ATA containing the tokens to distribute."
|
|
706
|
+
],
|
|
707
|
+
writable: true
|
|
708
|
+
},
|
|
709
|
+
{
|
|
710
|
+
name: "to",
|
|
711
|
+
docs: [
|
|
712
|
+
"The Clawback token account."
|
|
789
713
|
],
|
|
790
714
|
writable: true
|
|
791
715
|
},
|
|
@@ -1409,34 +1333,104 @@ var merkle_distributor_default = {
|
|
|
1409
1333
|
docs: [
|
|
1410
1334
|
"The [Token] program."
|
|
1411
1335
|
]
|
|
1412
|
-
}
|
|
1413
|
-
],
|
|
1414
|
-
args: [
|
|
1415
|
-
{
|
|
1416
|
-
name: "version",
|
|
1417
|
-
type: "u64"
|
|
1418
|
-
},
|
|
1419
|
-
{
|
|
1420
|
-
name: "root",
|
|
1421
|
-
type: {
|
|
1422
|
-
array: [
|
|
1423
|
-
"u8",
|
|
1424
|
-
32
|
|
1425
|
-
]
|
|
1426
|
-
}
|
|
1427
|
-
},
|
|
1428
|
-
{
|
|
1429
|
-
name: "max_total_claim",
|
|
1430
|
-
type: "u64"
|
|
1431
|
-
},
|
|
1432
|
-
{
|
|
1433
|
-
name: "max_num_nodes",
|
|
1434
|
-
type: "u64"
|
|
1435
1336
|
},
|
|
1436
1337
|
{
|
|
1437
|
-
name: "
|
|
1438
|
-
|
|
1439
|
-
|
|
1338
|
+
name: "partner_oracle_config",
|
|
1339
|
+
pda: {
|
|
1340
|
+
seeds: [
|
|
1341
|
+
{
|
|
1342
|
+
kind: "const",
|
|
1343
|
+
value: [
|
|
1344
|
+
97,
|
|
1345
|
+
105,
|
|
1346
|
+
114,
|
|
1347
|
+
100,
|
|
1348
|
+
114,
|
|
1349
|
+
111,
|
|
1350
|
+
112,
|
|
1351
|
+
95,
|
|
1352
|
+
99,
|
|
1353
|
+
111,
|
|
1354
|
+
110,
|
|
1355
|
+
102,
|
|
1356
|
+
105,
|
|
1357
|
+
103
|
|
1358
|
+
]
|
|
1359
|
+
}
|
|
1360
|
+
],
|
|
1361
|
+
program: {
|
|
1362
|
+
kind: "const",
|
|
1363
|
+
value: [
|
|
1364
|
+
12,
|
|
1365
|
+
48,
|
|
1366
|
+
148,
|
|
1367
|
+
48,
|
|
1368
|
+
221,
|
|
1369
|
+
89,
|
|
1370
|
+
2,
|
|
1371
|
+
209,
|
|
1372
|
+
180,
|
|
1373
|
+
126,
|
|
1374
|
+
151,
|
|
1375
|
+
216,
|
|
1376
|
+
166,
|
|
1377
|
+
3,
|
|
1378
|
+
112,
|
|
1379
|
+
50,
|
|
1380
|
+
177,
|
|
1381
|
+
192,
|
|
1382
|
+
141,
|
|
1383
|
+
218,
|
|
1384
|
+
37,
|
|
1385
|
+
78,
|
|
1386
|
+
51,
|
|
1387
|
+
109,
|
|
1388
|
+
243,
|
|
1389
|
+
106,
|
|
1390
|
+
174,
|
|
1391
|
+
122,
|
|
1392
|
+
93,
|
|
1393
|
+
121,
|
|
1394
|
+
191,
|
|
1395
|
+
119
|
|
1396
|
+
]
|
|
1397
|
+
}
|
|
1398
|
+
}
|
|
1399
|
+
},
|
|
1400
|
+
{
|
|
1401
|
+
name: "partner_oracle",
|
|
1402
|
+
docs: [
|
|
1403
|
+
"Partner Oracle program that stores fees"
|
|
1404
|
+
],
|
|
1405
|
+
address: "pardpVtPjC8nLj1Dwncew62mUzfChdCX1EaoZe8oCAa"
|
|
1406
|
+
}
|
|
1407
|
+
],
|
|
1408
|
+
args: [
|
|
1409
|
+
{
|
|
1410
|
+
name: "version",
|
|
1411
|
+
type: "u64"
|
|
1412
|
+
},
|
|
1413
|
+
{
|
|
1414
|
+
name: "root",
|
|
1415
|
+
type: {
|
|
1416
|
+
array: [
|
|
1417
|
+
"u8",
|
|
1418
|
+
32
|
|
1419
|
+
]
|
|
1420
|
+
}
|
|
1421
|
+
},
|
|
1422
|
+
{
|
|
1423
|
+
name: "max_total_claim",
|
|
1424
|
+
type: "u64"
|
|
1425
|
+
},
|
|
1426
|
+
{
|
|
1427
|
+
name: "max_num_nodes",
|
|
1428
|
+
type: "u64"
|
|
1429
|
+
},
|
|
1430
|
+
{
|
|
1431
|
+
name: "unlock_period",
|
|
1432
|
+
type: "u64"
|
|
1433
|
+
},
|
|
1440
1434
|
{
|
|
1441
1435
|
name: "start_vesting_ts",
|
|
1442
1436
|
type: "u64"
|
|
@@ -1638,6 +1632,43 @@ var merkle_distributor_default = {
|
|
|
1638
1632
|
],
|
|
1639
1633
|
args: []
|
|
1640
1634
|
},
|
|
1635
|
+
{
|
|
1636
|
+
name: "set_token_price",
|
|
1637
|
+
discriminator: [
|
|
1638
|
+
166,
|
|
1639
|
+
216,
|
|
1640
|
+
142,
|
|
1641
|
+
197,
|
|
1642
|
+
200,
|
|
1643
|
+
225,
|
|
1644
|
+
253,
|
|
1645
|
+
233
|
|
1646
|
+
],
|
|
1647
|
+
accounts: [
|
|
1648
|
+
{
|
|
1649
|
+
name: "authority",
|
|
1650
|
+
docs: [
|
|
1651
|
+
"Wallet authorized to call this method"
|
|
1652
|
+
],
|
|
1653
|
+
writable: true,
|
|
1654
|
+
signer: true,
|
|
1655
|
+
address: "wdrwhnCv4pzW8beKsbPa4S2UDZrXenjg16KJdKSpb5u"
|
|
1656
|
+
},
|
|
1657
|
+
{
|
|
1658
|
+
name: "distributor",
|
|
1659
|
+
docs: [
|
|
1660
|
+
"The [MerkleDistributor]."
|
|
1661
|
+
],
|
|
1662
|
+
writable: true
|
|
1663
|
+
}
|
|
1664
|
+
],
|
|
1665
|
+
args: [
|
|
1666
|
+
{
|
|
1667
|
+
name: "price_lamports",
|
|
1668
|
+
type: "u64"
|
|
1669
|
+
}
|
|
1670
|
+
]
|
|
1671
|
+
},
|
|
1641
1672
|
{
|
|
1642
1673
|
name: "update",
|
|
1643
1674
|
discriminator: [
|
|
@@ -1886,6 +1917,21 @@ var merkle_distributor_default = {
|
|
|
1886
1917
|
code: 6023,
|
|
1887
1918
|
name: "ClaimsLimitReached",
|
|
1888
1919
|
msg: "Claims limit has been reached"
|
|
1920
|
+
},
|
|
1921
|
+
{
|
|
1922
|
+
code: 6024,
|
|
1923
|
+
name: "InsufficientFunds",
|
|
1924
|
+
msg: "Account does not have enough funds to cover fees"
|
|
1925
|
+
},
|
|
1926
|
+
{
|
|
1927
|
+
code: 6025,
|
|
1928
|
+
name: "ClaimV2Required",
|
|
1929
|
+
msg: "This Airdrop must be claimed via claimLockedV2"
|
|
1930
|
+
},
|
|
1931
|
+
{
|
|
1932
|
+
code: 6026,
|
|
1933
|
+
name: "NoFeesToClaim",
|
|
1934
|
+
msg: "No fees to claim"
|
|
1889
1935
|
}
|
|
1890
1936
|
],
|
|
1891
1937
|
types: [
|
|
@@ -2240,26 +2286,84 @@ var merkle_distributor_default = {
|
|
|
2240
2286
|
type: "u16"
|
|
2241
2287
|
},
|
|
2242
2288
|
{
|
|
2243
|
-
name: "
|
|
2289
|
+
name: "creation_fee",
|
|
2244
2290
|
docs: [
|
|
2245
|
-
"
|
|
2291
|
+
"Creation SOL fee"
|
|
2246
2292
|
],
|
|
2247
|
-
type:
|
|
2248
|
-
array: [
|
|
2249
|
-
"u8",
|
|
2250
|
-
20
|
|
2251
|
-
]
|
|
2252
|
-
}
|
|
2293
|
+
type: "u32"
|
|
2253
2294
|
},
|
|
2254
2295
|
{
|
|
2255
|
-
name: "
|
|
2296
|
+
name: "creation_fee_claimed",
|
|
2297
|
+
docs: [
|
|
2298
|
+
"Whether creation SOL was claimed"
|
|
2299
|
+
],
|
|
2300
|
+
type: "bool"
|
|
2301
|
+
},
|
|
2302
|
+
{
|
|
2303
|
+
name: "claim_min_fee",
|
|
2304
|
+
docs: [
|
|
2305
|
+
"Dynamic claim fee in SOL, min"
|
|
2306
|
+
],
|
|
2307
|
+
type: "u32"
|
|
2308
|
+
},
|
|
2309
|
+
{
|
|
2310
|
+
name: "claim_max_fee",
|
|
2311
|
+
docs: [
|
|
2312
|
+
"Dynamic claim fee in SOL, max"
|
|
2313
|
+
],
|
|
2314
|
+
type: "u32"
|
|
2315
|
+
},
|
|
2316
|
+
{
|
|
2317
|
+
name: "allocation_factor",
|
|
2318
|
+
docs: [
|
|
2319
|
+
"Factor to multiply claimable SOL lamports by when calculating fee"
|
|
2320
|
+
],
|
|
2321
|
+
type: "f64"
|
|
2322
|
+
},
|
|
2323
|
+
{
|
|
2324
|
+
name: "claim_fee_claimed",
|
|
2325
|
+
docs: [
|
|
2326
|
+
"Whether all claim fees were claimed, true by default since no claim fee is taken on creation"
|
|
2327
|
+
],
|
|
2328
|
+
type: "bool"
|
|
2329
|
+
},
|
|
2330
|
+
{
|
|
2331
|
+
name: "token_price_lamports",
|
|
2332
|
+
docs: [
|
|
2333
|
+
"Last observed token price in lamports per 1 whole token for claim fee calculation"
|
|
2334
|
+
],
|
|
2335
|
+
type: "u64"
|
|
2336
|
+
},
|
|
2337
|
+
{
|
|
2338
|
+
name: "clawback_token_fee_percent",
|
|
2339
|
+
docs: [
|
|
2340
|
+
"Token % fee on clawback"
|
|
2341
|
+
],
|
|
2342
|
+
type: "f64"
|
|
2343
|
+
},
|
|
2344
|
+
{
|
|
2345
|
+
name: "clawback_fee_claimed",
|
|
2346
|
+
docs: [
|
|
2347
|
+
"Whether clawback token % fee has been claimed"
|
|
2348
|
+
],
|
|
2349
|
+
type: "bool"
|
|
2350
|
+
},
|
|
2351
|
+
{
|
|
2352
|
+
name: "program_version",
|
|
2353
|
+
docs: [
|
|
2354
|
+
"Program version that initiated the Distributor account"
|
|
2355
|
+
],
|
|
2356
|
+
type: "u8"
|
|
2357
|
+
},
|
|
2358
|
+
{
|
|
2359
|
+
name: "buffer",
|
|
2256
2360
|
docs: [
|
|
2257
2361
|
"Buffer for additional fields"
|
|
2258
2362
|
],
|
|
2259
2363
|
type: {
|
|
2260
2364
|
array: [
|
|
2261
2365
|
"u8",
|
|
2262
|
-
|
|
2366
|
+
13
|
|
2263
2367
|
]
|
|
2264
2368
|
}
|
|
2265
2369
|
}
|
|
@@ -2307,1676 +2411,13 @@ var merkle_distributor_default = {
|
|
|
2307
2411
|
}
|
|
2308
2412
|
]
|
|
2309
2413
|
};
|
|
2310
|
-
var _MerkleDistributor = class _MerkleDistributor {
|
|
2311
|
-
constructor(fields) {
|
|
2312
|
-
this.bump = fields.bump;
|
|
2313
|
-
this.version = fields.version;
|
|
2314
|
-
this.root = fields.root;
|
|
2315
|
-
this.mint = fields.mint;
|
|
2316
|
-
this.tokenVault = fields.tokenVault;
|
|
2317
|
-
this.maxTotalClaim = fields.maxTotalClaim;
|
|
2318
|
-
this.maxNumNodes = fields.maxNumNodes;
|
|
2319
|
-
this.unlockPeriod = fields.unlockPeriod;
|
|
2320
|
-
this.totalAmountClaimed = fields.totalAmountClaimed;
|
|
2321
|
-
this.numNodesClaimed = fields.numNodesClaimed;
|
|
2322
|
-
this.startTs = fields.startTs;
|
|
2323
|
-
this.endTs = fields.endTs;
|
|
2324
|
-
this.clawbackStartTs = fields.clawbackStartTs;
|
|
2325
|
-
this.clawbackReceiver = fields.clawbackReceiver;
|
|
2326
|
-
this.admin = fields.admin;
|
|
2327
|
-
this.clawedBack = fields.clawedBack;
|
|
2328
|
-
this.claimsClosableByAdmin = fields.claimsClosableByAdmin;
|
|
2329
|
-
this.canUpdateDuration = fields.canUpdateDuration;
|
|
2330
|
-
this.totalAmountUnlocked = fields.totalAmountUnlocked;
|
|
2331
|
-
this.totalAmountLocked = fields.totalAmountLocked;
|
|
2332
|
-
this.lastDurationUpdateTs = fields.lastDurationUpdateTs;
|
|
2333
|
-
this.totalClaimablePreUpdate = fields.totalClaimablePreUpdate;
|
|
2334
|
-
this.clawedBackTs = fields.clawedBackTs;
|
|
2335
|
-
this.claimsClosableByClaimant = fields.claimsClosableByClaimant;
|
|
2336
|
-
this.claimsLimit = fields.claimsLimit;
|
|
2337
|
-
this.buffer2 = fields.buffer2;
|
|
2338
|
-
this.buffer3 = fields.buffer3;
|
|
2339
|
-
}
|
|
2340
|
-
static async fetch(c, address, programId = PROGRAM_ID) {
|
|
2341
|
-
const info = await c.getAccountInfo(address);
|
|
2342
|
-
if (info === null) {
|
|
2343
|
-
return null;
|
|
2344
|
-
}
|
|
2345
|
-
if (!info.owner.equals(programId)) {
|
|
2346
|
-
throw new Error("account doesn't belong to this program");
|
|
2347
|
-
}
|
|
2348
|
-
return this.decode(info.data);
|
|
2349
|
-
}
|
|
2350
|
-
static async fetchMultiple(c, addresses, programId = PROGRAM_ID) {
|
|
2351
|
-
const infos = await c.getMultipleAccountsInfo(addresses);
|
|
2352
|
-
return infos.map((info) => {
|
|
2353
|
-
if (info === null) {
|
|
2354
|
-
return null;
|
|
2355
|
-
}
|
|
2356
|
-
if (!info.owner.equals(programId)) {
|
|
2357
|
-
throw new Error("account doesn't belong to this program");
|
|
2358
|
-
}
|
|
2359
|
-
return this.decode(info.data);
|
|
2360
|
-
});
|
|
2361
|
-
}
|
|
2362
|
-
static decode(data) {
|
|
2363
|
-
if (!data.slice(0, 8).equals(_MerkleDistributor.discriminator)) {
|
|
2364
|
-
throw new Error("invalid account discriminator");
|
|
2365
|
-
}
|
|
2366
|
-
const dec = _MerkleDistributor.layout.decode(data.slice(8));
|
|
2367
|
-
return new _MerkleDistributor({
|
|
2368
|
-
bump: dec.bump,
|
|
2369
|
-
version: dec.version,
|
|
2370
|
-
root: dec.root,
|
|
2371
|
-
mint: dec.mint,
|
|
2372
|
-
tokenVault: dec.tokenVault,
|
|
2373
|
-
maxTotalClaim: dec.maxTotalClaim,
|
|
2374
|
-
maxNumNodes: dec.maxNumNodes,
|
|
2375
|
-
unlockPeriod: dec.unlockPeriod,
|
|
2376
|
-
totalAmountClaimed: dec.totalAmountClaimed,
|
|
2377
|
-
numNodesClaimed: dec.numNodesClaimed,
|
|
2378
|
-
startTs: dec.startTs,
|
|
2379
|
-
endTs: dec.endTs,
|
|
2380
|
-
clawbackStartTs: dec.clawbackStartTs,
|
|
2381
|
-
clawbackReceiver: dec.clawbackReceiver,
|
|
2382
|
-
admin: dec.admin,
|
|
2383
|
-
clawedBack: dec.clawedBack,
|
|
2384
|
-
claimsClosableByAdmin: dec.claimsClosableByAdmin,
|
|
2385
|
-
canUpdateDuration: dec.canUpdateDuration,
|
|
2386
|
-
totalAmountUnlocked: dec.totalAmountUnlocked,
|
|
2387
|
-
totalAmountLocked: dec.totalAmountLocked,
|
|
2388
|
-
lastDurationUpdateTs: dec.lastDurationUpdateTs,
|
|
2389
|
-
totalClaimablePreUpdate: dec.totalClaimablePreUpdate,
|
|
2390
|
-
clawedBackTs: dec.clawedBackTs,
|
|
2391
|
-
claimsClosableByClaimant: dec.claimsClosableByClaimant,
|
|
2392
|
-
claimsLimit: dec.claimsLimit,
|
|
2393
|
-
buffer2: dec.buffer2,
|
|
2394
|
-
buffer3: dec.buffer3
|
|
2395
|
-
});
|
|
2396
|
-
}
|
|
2397
|
-
toJSON() {
|
|
2398
|
-
return {
|
|
2399
|
-
bump: this.bump,
|
|
2400
|
-
version: this.version.toString(),
|
|
2401
|
-
root: this.root,
|
|
2402
|
-
mint: this.mint.toString(),
|
|
2403
|
-
tokenVault: this.tokenVault.toString(),
|
|
2404
|
-
maxTotalClaim: this.maxTotalClaim.toString(),
|
|
2405
|
-
maxNumNodes: this.maxNumNodes.toString(),
|
|
2406
|
-
unlockPeriod: this.unlockPeriod.toString(),
|
|
2407
|
-
totalAmountClaimed: this.totalAmountClaimed.toString(),
|
|
2408
|
-
numNodesClaimed: this.numNodesClaimed.toString(),
|
|
2409
|
-
startTs: this.startTs.toString(),
|
|
2410
|
-
endTs: this.endTs.toString(),
|
|
2411
|
-
clawbackStartTs: this.clawbackStartTs.toString(),
|
|
2412
|
-
clawbackReceiver: this.clawbackReceiver.toString(),
|
|
2413
|
-
admin: this.admin.toString(),
|
|
2414
|
-
clawedBack: this.clawedBack,
|
|
2415
|
-
claimsClosableByAdmin: this.claimsClosableByAdmin,
|
|
2416
|
-
canUpdateDuration: this.canUpdateDuration,
|
|
2417
|
-
totalAmountUnlocked: this.totalAmountUnlocked.toString(),
|
|
2418
|
-
totalAmountLocked: this.totalAmountLocked.toString(),
|
|
2419
|
-
lastDurationUpdateTs: this.lastDurationUpdateTs.toString(),
|
|
2420
|
-
totalClaimablePreUpdate: this.totalClaimablePreUpdate.toString(),
|
|
2421
|
-
clawedBackTs: this.clawedBackTs.toString(),
|
|
2422
|
-
claimsClosableByClaimant: this.claimsClosableByClaimant,
|
|
2423
|
-
claimsLimit: this.claimsLimit,
|
|
2424
|
-
buffer2: this.buffer2,
|
|
2425
|
-
buffer3: this.buffer3
|
|
2426
|
-
};
|
|
2427
|
-
}
|
|
2428
|
-
static fromJSON(obj) {
|
|
2429
|
-
return new _MerkleDistributor({
|
|
2430
|
-
bump: obj.bump,
|
|
2431
|
-
version: new BN5(obj.version),
|
|
2432
|
-
root: obj.root,
|
|
2433
|
-
mint: new PublicKey(obj.mint),
|
|
2434
|
-
tokenVault: new PublicKey(obj.tokenVault),
|
|
2435
|
-
maxTotalClaim: new BN5(obj.maxTotalClaim),
|
|
2436
|
-
maxNumNodes: new BN5(obj.maxNumNodes),
|
|
2437
|
-
unlockPeriod: new BN5(obj.unlockPeriod),
|
|
2438
|
-
totalAmountClaimed: new BN5(obj.totalAmountClaimed),
|
|
2439
|
-
numNodesClaimed: new BN5(obj.numNodesClaimed),
|
|
2440
|
-
startTs: new BN5(obj.startTs),
|
|
2441
|
-
endTs: new BN5(obj.endTs),
|
|
2442
|
-
clawbackStartTs: new BN5(obj.clawbackStartTs),
|
|
2443
|
-
clawbackReceiver: new PublicKey(obj.clawbackReceiver),
|
|
2444
|
-
admin: new PublicKey(obj.admin),
|
|
2445
|
-
clawedBack: obj.clawedBack,
|
|
2446
|
-
claimsClosableByAdmin: obj.claimsClosableByAdmin,
|
|
2447
|
-
canUpdateDuration: obj.canUpdateDuration,
|
|
2448
|
-
totalAmountUnlocked: new BN5(obj.totalAmountUnlocked),
|
|
2449
|
-
totalAmountLocked: new BN5(obj.totalAmountLocked),
|
|
2450
|
-
lastDurationUpdateTs: new BN5(obj.lastDurationUpdateTs),
|
|
2451
|
-
totalClaimablePreUpdate: new BN5(obj.totalClaimablePreUpdate),
|
|
2452
|
-
clawedBackTs: new BN5(obj.clawedBackTs),
|
|
2453
|
-
claimsClosableByClaimant: obj.claimsClosableByClaimant,
|
|
2454
|
-
claimsLimit: obj.claimsLimit,
|
|
2455
|
-
buffer2: obj.buffer2,
|
|
2456
|
-
buffer3: obj.buffer3
|
|
2457
|
-
});
|
|
2458
|
-
}
|
|
2459
|
-
};
|
|
2460
|
-
_MerkleDistributor.discriminator = Buffer.from([77, 119, 139, 70, 84, 247, 12, 26]);
|
|
2461
|
-
_MerkleDistributor.layout = borsh7.struct([
|
|
2462
|
-
borsh7.u8("bump"),
|
|
2463
|
-
borsh7.u64("version"),
|
|
2464
|
-
borsh7.array(borsh7.u8(), 32, "root"),
|
|
2465
|
-
borsh7.publicKey("mint"),
|
|
2466
|
-
borsh7.publicKey("tokenVault"),
|
|
2467
|
-
borsh7.u64("maxTotalClaim"),
|
|
2468
|
-
borsh7.u64("maxNumNodes"),
|
|
2469
|
-
borsh7.u64("unlockPeriod"),
|
|
2470
|
-
borsh7.u64("totalAmountClaimed"),
|
|
2471
|
-
borsh7.u64("numNodesClaimed"),
|
|
2472
|
-
borsh7.u64("startTs"),
|
|
2473
|
-
borsh7.u64("endTs"),
|
|
2474
|
-
borsh7.u64("clawbackStartTs"),
|
|
2475
|
-
borsh7.publicKey("clawbackReceiver"),
|
|
2476
|
-
borsh7.publicKey("admin"),
|
|
2477
|
-
borsh7.bool("clawedBack"),
|
|
2478
|
-
borsh7.bool("claimsClosableByAdmin"),
|
|
2479
|
-
borsh7.bool("canUpdateDuration"),
|
|
2480
|
-
borsh7.u64("totalAmountUnlocked"),
|
|
2481
|
-
borsh7.u64("totalAmountLocked"),
|
|
2482
|
-
borsh7.u64("lastDurationUpdateTs"),
|
|
2483
|
-
borsh7.u64("totalClaimablePreUpdate"),
|
|
2484
|
-
borsh7.u64("clawedBackTs"),
|
|
2485
|
-
borsh7.bool("claimsClosableByClaimant"),
|
|
2486
|
-
borsh7.u16("claimsLimit"),
|
|
2487
|
-
borsh7.array(borsh7.u8(), 20, "buffer2"),
|
|
2488
|
-
borsh7.array(borsh7.u8(), 32, "buffer3")
|
|
2489
|
-
]);
|
|
2490
|
-
var MerkleDistributor = _MerkleDistributor;
|
|
2491
|
-
|
|
2492
|
-
// solana/generated/errors/anchor.ts
|
|
2493
|
-
var InstructionMissing = class extends Error {
|
|
2494
|
-
constructor(logs) {
|
|
2495
|
-
super("100: 8 byte instruction identifier not provided");
|
|
2496
|
-
this.logs = logs;
|
|
2497
|
-
this.code = 100;
|
|
2498
|
-
this.name = "InstructionMissing";
|
|
2499
|
-
this.msg = "8 byte instruction identifier not provided";
|
|
2500
|
-
}
|
|
2501
|
-
};
|
|
2502
|
-
InstructionMissing.code = 100;
|
|
2503
|
-
var InstructionFallbackNotFound = class extends Error {
|
|
2504
|
-
constructor(logs) {
|
|
2505
|
-
super("101: Fallback functions are not supported");
|
|
2506
|
-
this.logs = logs;
|
|
2507
|
-
this.code = 101;
|
|
2508
|
-
this.name = "InstructionFallbackNotFound";
|
|
2509
|
-
this.msg = "Fallback functions are not supported";
|
|
2510
|
-
}
|
|
2511
|
-
};
|
|
2512
|
-
InstructionFallbackNotFound.code = 101;
|
|
2513
|
-
var InstructionDidNotDeserialize = class extends Error {
|
|
2514
|
-
constructor(logs) {
|
|
2515
|
-
super("102: The program could not deserialize the given instruction");
|
|
2516
|
-
this.logs = logs;
|
|
2517
|
-
this.code = 102;
|
|
2518
|
-
this.name = "InstructionDidNotDeserialize";
|
|
2519
|
-
this.msg = "The program could not deserialize the given instruction";
|
|
2520
|
-
}
|
|
2521
|
-
};
|
|
2522
|
-
InstructionDidNotDeserialize.code = 102;
|
|
2523
|
-
var InstructionDidNotSerialize = class extends Error {
|
|
2524
|
-
constructor(logs) {
|
|
2525
|
-
super("103: The program could not serialize the given instruction");
|
|
2526
|
-
this.logs = logs;
|
|
2527
|
-
this.code = 103;
|
|
2528
|
-
this.name = "InstructionDidNotSerialize";
|
|
2529
|
-
this.msg = "The program could not serialize the given instruction";
|
|
2530
|
-
}
|
|
2531
|
-
};
|
|
2532
|
-
InstructionDidNotSerialize.code = 103;
|
|
2533
|
-
var IdlInstructionStub = class extends Error {
|
|
2534
|
-
constructor(logs) {
|
|
2535
|
-
super("1000: The program was compiled without idl instructions");
|
|
2536
|
-
this.logs = logs;
|
|
2537
|
-
this.code = 1e3;
|
|
2538
|
-
this.name = "IdlInstructionStub";
|
|
2539
|
-
this.msg = "The program was compiled without idl instructions";
|
|
2540
|
-
}
|
|
2541
|
-
};
|
|
2542
|
-
IdlInstructionStub.code = 1e3;
|
|
2543
|
-
var IdlInstructionInvalidProgram = class extends Error {
|
|
2544
|
-
constructor(logs) {
|
|
2545
|
-
super("1001: The transaction was given an invalid program for the IDL instruction");
|
|
2546
|
-
this.logs = logs;
|
|
2547
|
-
this.code = 1001;
|
|
2548
|
-
this.name = "IdlInstructionInvalidProgram";
|
|
2549
|
-
this.msg = "The transaction was given an invalid program for the IDL instruction";
|
|
2550
|
-
}
|
|
2551
|
-
};
|
|
2552
|
-
IdlInstructionInvalidProgram.code = 1001;
|
|
2553
|
-
var ConstraintMut = class extends Error {
|
|
2554
|
-
constructor(logs) {
|
|
2555
|
-
super("2000: A mut constraint was violated");
|
|
2556
|
-
this.logs = logs;
|
|
2557
|
-
this.code = 2e3;
|
|
2558
|
-
this.name = "ConstraintMut";
|
|
2559
|
-
this.msg = "A mut constraint was violated";
|
|
2560
|
-
}
|
|
2561
|
-
};
|
|
2562
|
-
ConstraintMut.code = 2e3;
|
|
2563
|
-
var ConstraintHasOne = class extends Error {
|
|
2564
|
-
constructor(logs) {
|
|
2565
|
-
super("2001: A has one constraint was violated");
|
|
2566
|
-
this.logs = logs;
|
|
2567
|
-
this.code = 2001;
|
|
2568
|
-
this.name = "ConstraintHasOne";
|
|
2569
|
-
this.msg = "A has one constraint was violated";
|
|
2570
|
-
}
|
|
2571
|
-
};
|
|
2572
|
-
ConstraintHasOne.code = 2001;
|
|
2573
|
-
var ConstraintSigner = class extends Error {
|
|
2574
|
-
constructor(logs) {
|
|
2575
|
-
super("2002: A signer constraint was violated");
|
|
2576
|
-
this.logs = logs;
|
|
2577
|
-
this.code = 2002;
|
|
2578
|
-
this.name = "ConstraintSigner";
|
|
2579
|
-
this.msg = "A signer constraint was violated";
|
|
2580
|
-
}
|
|
2581
|
-
};
|
|
2582
|
-
ConstraintSigner.code = 2002;
|
|
2583
|
-
var ConstraintRaw = class extends Error {
|
|
2584
|
-
constructor(logs) {
|
|
2585
|
-
super("2003: A raw constraint was violated");
|
|
2586
|
-
this.logs = logs;
|
|
2587
|
-
this.code = 2003;
|
|
2588
|
-
this.name = "ConstraintRaw";
|
|
2589
|
-
this.msg = "A raw constraint was violated";
|
|
2590
|
-
}
|
|
2591
|
-
};
|
|
2592
|
-
ConstraintRaw.code = 2003;
|
|
2593
|
-
var ConstraintOwner = class extends Error {
|
|
2594
|
-
constructor(logs) {
|
|
2595
|
-
super("2004: An owner constraint was violated");
|
|
2596
|
-
this.logs = logs;
|
|
2597
|
-
this.code = 2004;
|
|
2598
|
-
this.name = "ConstraintOwner";
|
|
2599
|
-
this.msg = "An owner constraint was violated";
|
|
2600
|
-
}
|
|
2601
|
-
};
|
|
2602
|
-
ConstraintOwner.code = 2004;
|
|
2603
|
-
var ConstraintRentExempt = class extends Error {
|
|
2604
|
-
constructor(logs) {
|
|
2605
|
-
super("2005: A rent exemption constraint was violated");
|
|
2606
|
-
this.logs = logs;
|
|
2607
|
-
this.code = 2005;
|
|
2608
|
-
this.name = "ConstraintRentExempt";
|
|
2609
|
-
this.msg = "A rent exemption constraint was violated";
|
|
2610
|
-
}
|
|
2611
|
-
};
|
|
2612
|
-
ConstraintRentExempt.code = 2005;
|
|
2613
|
-
var ConstraintSeeds = class extends Error {
|
|
2614
|
-
constructor(logs) {
|
|
2615
|
-
super("2006: A seeds constraint was violated");
|
|
2616
|
-
this.logs = logs;
|
|
2617
|
-
this.code = 2006;
|
|
2618
|
-
this.name = "ConstraintSeeds";
|
|
2619
|
-
this.msg = "A seeds constraint was violated";
|
|
2620
|
-
}
|
|
2621
|
-
};
|
|
2622
|
-
ConstraintSeeds.code = 2006;
|
|
2623
|
-
var ConstraintExecutable = class extends Error {
|
|
2624
|
-
constructor(logs) {
|
|
2625
|
-
super("2007: An executable constraint was violated");
|
|
2626
|
-
this.logs = logs;
|
|
2627
|
-
this.code = 2007;
|
|
2628
|
-
this.name = "ConstraintExecutable";
|
|
2629
|
-
this.msg = "An executable constraint was violated";
|
|
2630
|
-
}
|
|
2631
|
-
};
|
|
2632
|
-
ConstraintExecutable.code = 2007;
|
|
2633
|
-
var ConstraintState = class extends Error {
|
|
2634
|
-
constructor(logs) {
|
|
2635
|
-
super("2008: Deprecated Error, feel free to replace with something else");
|
|
2636
|
-
this.logs = logs;
|
|
2637
|
-
this.code = 2008;
|
|
2638
|
-
this.name = "ConstraintState";
|
|
2639
|
-
this.msg = "Deprecated Error, feel free to replace with something else";
|
|
2640
|
-
}
|
|
2641
|
-
};
|
|
2642
|
-
ConstraintState.code = 2008;
|
|
2643
|
-
var ConstraintAssociated = class extends Error {
|
|
2644
|
-
constructor(logs) {
|
|
2645
|
-
super("2009: An associated constraint was violated");
|
|
2646
|
-
this.logs = logs;
|
|
2647
|
-
this.code = 2009;
|
|
2648
|
-
this.name = "ConstraintAssociated";
|
|
2649
|
-
this.msg = "An associated constraint was violated";
|
|
2650
|
-
}
|
|
2651
|
-
};
|
|
2652
|
-
ConstraintAssociated.code = 2009;
|
|
2653
|
-
var ConstraintAssociatedInit = class extends Error {
|
|
2654
|
-
constructor(logs) {
|
|
2655
|
-
super("2010: An associated init constraint was violated");
|
|
2656
|
-
this.logs = logs;
|
|
2657
|
-
this.code = 2010;
|
|
2658
|
-
this.name = "ConstraintAssociatedInit";
|
|
2659
|
-
this.msg = "An associated init constraint was violated";
|
|
2660
|
-
}
|
|
2661
|
-
};
|
|
2662
|
-
ConstraintAssociatedInit.code = 2010;
|
|
2663
|
-
var ConstraintClose = class extends Error {
|
|
2664
|
-
constructor(logs) {
|
|
2665
|
-
super("2011: A close constraint was violated");
|
|
2666
|
-
this.logs = logs;
|
|
2667
|
-
this.code = 2011;
|
|
2668
|
-
this.name = "ConstraintClose";
|
|
2669
|
-
this.msg = "A close constraint was violated";
|
|
2670
|
-
}
|
|
2671
|
-
};
|
|
2672
|
-
ConstraintClose.code = 2011;
|
|
2673
|
-
var ConstraintAddress = class extends Error {
|
|
2674
|
-
constructor(logs) {
|
|
2675
|
-
super("2012: An address constraint was violated");
|
|
2676
|
-
this.logs = logs;
|
|
2677
|
-
this.code = 2012;
|
|
2678
|
-
this.name = "ConstraintAddress";
|
|
2679
|
-
this.msg = "An address constraint was violated";
|
|
2680
|
-
}
|
|
2681
|
-
};
|
|
2682
|
-
ConstraintAddress.code = 2012;
|
|
2683
|
-
var ConstraintZero = class extends Error {
|
|
2684
|
-
constructor(logs) {
|
|
2685
|
-
super("2013: Expected zero account discriminant");
|
|
2686
|
-
this.logs = logs;
|
|
2687
|
-
this.code = 2013;
|
|
2688
|
-
this.name = "ConstraintZero";
|
|
2689
|
-
this.msg = "Expected zero account discriminant";
|
|
2690
|
-
}
|
|
2691
|
-
};
|
|
2692
|
-
ConstraintZero.code = 2013;
|
|
2693
|
-
var ConstraintTokenMint = class extends Error {
|
|
2694
|
-
constructor(logs) {
|
|
2695
|
-
super("2014: A token mint constraint was violated");
|
|
2696
|
-
this.logs = logs;
|
|
2697
|
-
this.code = 2014;
|
|
2698
|
-
this.name = "ConstraintTokenMint";
|
|
2699
|
-
this.msg = "A token mint constraint was violated";
|
|
2700
|
-
}
|
|
2701
|
-
};
|
|
2702
|
-
ConstraintTokenMint.code = 2014;
|
|
2703
|
-
var ConstraintTokenOwner = class extends Error {
|
|
2704
|
-
constructor(logs) {
|
|
2705
|
-
super("2015: A token owner constraint was violated");
|
|
2706
|
-
this.logs = logs;
|
|
2707
|
-
this.code = 2015;
|
|
2708
|
-
this.name = "ConstraintTokenOwner";
|
|
2709
|
-
this.msg = "A token owner constraint was violated";
|
|
2710
|
-
}
|
|
2711
|
-
};
|
|
2712
|
-
ConstraintTokenOwner.code = 2015;
|
|
2713
|
-
var ConstraintMintMintAuthority = class extends Error {
|
|
2714
|
-
constructor(logs) {
|
|
2715
|
-
super("2016: A mint mint authority constraint was violated");
|
|
2716
|
-
this.logs = logs;
|
|
2717
|
-
this.code = 2016;
|
|
2718
|
-
this.name = "ConstraintMintMintAuthority";
|
|
2719
|
-
this.msg = "A mint mint authority constraint was violated";
|
|
2720
|
-
}
|
|
2721
|
-
};
|
|
2722
|
-
ConstraintMintMintAuthority.code = 2016;
|
|
2723
|
-
var ConstraintMintFreezeAuthority = class extends Error {
|
|
2724
|
-
constructor(logs) {
|
|
2725
|
-
super("2017: A mint freeze authority constraint was violated");
|
|
2726
|
-
this.logs = logs;
|
|
2727
|
-
this.code = 2017;
|
|
2728
|
-
this.name = "ConstraintMintFreezeAuthority";
|
|
2729
|
-
this.msg = "A mint freeze authority constraint was violated";
|
|
2730
|
-
}
|
|
2731
|
-
};
|
|
2732
|
-
ConstraintMintFreezeAuthority.code = 2017;
|
|
2733
|
-
var ConstraintMintDecimals = class extends Error {
|
|
2734
|
-
constructor(logs) {
|
|
2735
|
-
super("2018: A mint decimals constraint was violated");
|
|
2736
|
-
this.logs = logs;
|
|
2737
|
-
this.code = 2018;
|
|
2738
|
-
this.name = "ConstraintMintDecimals";
|
|
2739
|
-
this.msg = "A mint decimals constraint was violated";
|
|
2740
|
-
}
|
|
2741
|
-
};
|
|
2742
|
-
ConstraintMintDecimals.code = 2018;
|
|
2743
|
-
var ConstraintSpace = class extends Error {
|
|
2744
|
-
constructor(logs) {
|
|
2745
|
-
super("2019: A space constraint was violated");
|
|
2746
|
-
this.logs = logs;
|
|
2747
|
-
this.code = 2019;
|
|
2748
|
-
this.name = "ConstraintSpace";
|
|
2749
|
-
this.msg = "A space constraint was violated";
|
|
2750
|
-
}
|
|
2751
|
-
};
|
|
2752
|
-
ConstraintSpace.code = 2019;
|
|
2753
|
-
var ConstraintAccountIsNone = class extends Error {
|
|
2754
|
-
constructor(logs) {
|
|
2755
|
-
super("2020: A required account for the constraint is None");
|
|
2756
|
-
this.logs = logs;
|
|
2757
|
-
this.code = 2020;
|
|
2758
|
-
this.name = "ConstraintAccountIsNone";
|
|
2759
|
-
this.msg = "A required account for the constraint is None";
|
|
2760
|
-
}
|
|
2761
|
-
};
|
|
2762
|
-
ConstraintAccountIsNone.code = 2020;
|
|
2763
|
-
var RequireViolated = class extends Error {
|
|
2764
|
-
constructor(logs) {
|
|
2765
|
-
super("2500: A require expression was violated");
|
|
2766
|
-
this.logs = logs;
|
|
2767
|
-
this.code = 2500;
|
|
2768
|
-
this.name = "RequireViolated";
|
|
2769
|
-
this.msg = "A require expression was violated";
|
|
2770
|
-
}
|
|
2771
|
-
};
|
|
2772
|
-
RequireViolated.code = 2500;
|
|
2773
|
-
var RequireEqViolated = class extends Error {
|
|
2774
|
-
constructor(logs) {
|
|
2775
|
-
super("2501: A require_eq expression was violated");
|
|
2776
|
-
this.logs = logs;
|
|
2777
|
-
this.code = 2501;
|
|
2778
|
-
this.name = "RequireEqViolated";
|
|
2779
|
-
this.msg = "A require_eq expression was violated";
|
|
2780
|
-
}
|
|
2781
|
-
};
|
|
2782
|
-
RequireEqViolated.code = 2501;
|
|
2783
|
-
var RequireKeysEqViolated = class extends Error {
|
|
2784
|
-
constructor(logs) {
|
|
2785
|
-
super("2502: A require_keys_eq expression was violated");
|
|
2786
|
-
this.logs = logs;
|
|
2787
|
-
this.code = 2502;
|
|
2788
|
-
this.name = "RequireKeysEqViolated";
|
|
2789
|
-
this.msg = "A require_keys_eq expression was violated";
|
|
2790
|
-
}
|
|
2791
|
-
};
|
|
2792
|
-
RequireKeysEqViolated.code = 2502;
|
|
2793
|
-
var RequireNeqViolated = class extends Error {
|
|
2794
|
-
constructor(logs) {
|
|
2795
|
-
super("2503: A require_neq expression was violated");
|
|
2796
|
-
this.logs = logs;
|
|
2797
|
-
this.code = 2503;
|
|
2798
|
-
this.name = "RequireNeqViolated";
|
|
2799
|
-
this.msg = "A require_neq expression was violated";
|
|
2800
|
-
}
|
|
2801
|
-
};
|
|
2802
|
-
RequireNeqViolated.code = 2503;
|
|
2803
|
-
var RequireKeysNeqViolated = class extends Error {
|
|
2804
|
-
constructor(logs) {
|
|
2805
|
-
super("2504: A require_keys_neq expression was violated");
|
|
2806
|
-
this.logs = logs;
|
|
2807
|
-
this.code = 2504;
|
|
2808
|
-
this.name = "RequireKeysNeqViolated";
|
|
2809
|
-
this.msg = "A require_keys_neq expression was violated";
|
|
2810
|
-
}
|
|
2811
|
-
};
|
|
2812
|
-
RequireKeysNeqViolated.code = 2504;
|
|
2813
|
-
var RequireGtViolated = class extends Error {
|
|
2814
|
-
constructor(logs) {
|
|
2815
|
-
super("2505: A require_gt expression was violated");
|
|
2816
|
-
this.logs = logs;
|
|
2817
|
-
this.code = 2505;
|
|
2818
|
-
this.name = "RequireGtViolated";
|
|
2819
|
-
this.msg = "A require_gt expression was violated";
|
|
2820
|
-
}
|
|
2821
|
-
};
|
|
2822
|
-
RequireGtViolated.code = 2505;
|
|
2823
|
-
var RequireGteViolated = class extends Error {
|
|
2824
|
-
constructor(logs) {
|
|
2825
|
-
super("2506: A require_gte expression was violated");
|
|
2826
|
-
this.logs = logs;
|
|
2827
|
-
this.code = 2506;
|
|
2828
|
-
this.name = "RequireGteViolated";
|
|
2829
|
-
this.msg = "A require_gte expression was violated";
|
|
2830
|
-
}
|
|
2831
|
-
};
|
|
2832
|
-
RequireGteViolated.code = 2506;
|
|
2833
|
-
var AccountDiscriminatorAlreadySet = class extends Error {
|
|
2834
|
-
constructor(logs) {
|
|
2835
|
-
super("3000: The account discriminator was already set on this account");
|
|
2836
|
-
this.logs = logs;
|
|
2837
|
-
this.code = 3e3;
|
|
2838
|
-
this.name = "AccountDiscriminatorAlreadySet";
|
|
2839
|
-
this.msg = "The account discriminator was already set on this account";
|
|
2840
|
-
}
|
|
2841
|
-
};
|
|
2842
|
-
AccountDiscriminatorAlreadySet.code = 3e3;
|
|
2843
|
-
var AccountDiscriminatorNotFound = class extends Error {
|
|
2844
|
-
constructor(logs) {
|
|
2845
|
-
super("3001: No 8 byte discriminator was found on the account");
|
|
2846
|
-
this.logs = logs;
|
|
2847
|
-
this.code = 3001;
|
|
2848
|
-
this.name = "AccountDiscriminatorNotFound";
|
|
2849
|
-
this.msg = "No 8 byte discriminator was found on the account";
|
|
2850
|
-
}
|
|
2851
|
-
};
|
|
2852
|
-
AccountDiscriminatorNotFound.code = 3001;
|
|
2853
|
-
var AccountDiscriminatorMismatch = class extends Error {
|
|
2854
|
-
constructor(logs) {
|
|
2855
|
-
super("3002: 8 byte discriminator did not match what was expected");
|
|
2856
|
-
this.logs = logs;
|
|
2857
|
-
this.code = 3002;
|
|
2858
|
-
this.name = "AccountDiscriminatorMismatch";
|
|
2859
|
-
this.msg = "8 byte discriminator did not match what was expected";
|
|
2860
|
-
}
|
|
2861
|
-
};
|
|
2862
|
-
AccountDiscriminatorMismatch.code = 3002;
|
|
2863
|
-
var AccountDidNotDeserialize = class extends Error {
|
|
2864
|
-
constructor(logs) {
|
|
2865
|
-
super("3003: Failed to deserialize the account");
|
|
2866
|
-
this.logs = logs;
|
|
2867
|
-
this.code = 3003;
|
|
2868
|
-
this.name = "AccountDidNotDeserialize";
|
|
2869
|
-
this.msg = "Failed to deserialize the account";
|
|
2870
|
-
}
|
|
2871
|
-
};
|
|
2872
|
-
AccountDidNotDeserialize.code = 3003;
|
|
2873
|
-
var AccountDidNotSerialize = class extends Error {
|
|
2874
|
-
constructor(logs) {
|
|
2875
|
-
super("3004: Failed to serialize the account");
|
|
2876
|
-
this.logs = logs;
|
|
2877
|
-
this.code = 3004;
|
|
2878
|
-
this.name = "AccountDidNotSerialize";
|
|
2879
|
-
this.msg = "Failed to serialize the account";
|
|
2880
|
-
}
|
|
2881
|
-
};
|
|
2882
|
-
AccountDidNotSerialize.code = 3004;
|
|
2883
|
-
var AccountNotEnoughKeys = class extends Error {
|
|
2884
|
-
constructor(logs) {
|
|
2885
|
-
super("3005: Not enough account keys given to the instruction");
|
|
2886
|
-
this.logs = logs;
|
|
2887
|
-
this.code = 3005;
|
|
2888
|
-
this.name = "AccountNotEnoughKeys";
|
|
2889
|
-
this.msg = "Not enough account keys given to the instruction";
|
|
2890
|
-
}
|
|
2891
|
-
};
|
|
2892
|
-
AccountNotEnoughKeys.code = 3005;
|
|
2893
|
-
var AccountNotMutable = class extends Error {
|
|
2894
|
-
constructor(logs) {
|
|
2895
|
-
super("3006: The given account is not mutable");
|
|
2896
|
-
this.logs = logs;
|
|
2897
|
-
this.code = 3006;
|
|
2898
|
-
this.name = "AccountNotMutable";
|
|
2899
|
-
this.msg = "The given account is not mutable";
|
|
2900
|
-
}
|
|
2901
|
-
};
|
|
2902
|
-
AccountNotMutable.code = 3006;
|
|
2903
|
-
var AccountOwnedByWrongProgram = class extends Error {
|
|
2904
|
-
constructor(logs) {
|
|
2905
|
-
super("3007: The given account is owned by a different program than expected");
|
|
2906
|
-
this.logs = logs;
|
|
2907
|
-
this.code = 3007;
|
|
2908
|
-
this.name = "AccountOwnedByWrongProgram";
|
|
2909
|
-
this.msg = "The given account is owned by a different program than expected";
|
|
2910
|
-
}
|
|
2911
|
-
};
|
|
2912
|
-
AccountOwnedByWrongProgram.code = 3007;
|
|
2913
|
-
var InvalidProgramId = class extends Error {
|
|
2914
|
-
constructor(logs) {
|
|
2915
|
-
super("3008: Program ID was not as expected");
|
|
2916
|
-
this.logs = logs;
|
|
2917
|
-
this.code = 3008;
|
|
2918
|
-
this.name = "InvalidProgramId";
|
|
2919
|
-
this.msg = "Program ID was not as expected";
|
|
2920
|
-
}
|
|
2921
|
-
};
|
|
2922
|
-
InvalidProgramId.code = 3008;
|
|
2923
|
-
var InvalidProgramExecutable = class extends Error {
|
|
2924
|
-
constructor(logs) {
|
|
2925
|
-
super("3009: Program account is not executable");
|
|
2926
|
-
this.logs = logs;
|
|
2927
|
-
this.code = 3009;
|
|
2928
|
-
this.name = "InvalidProgramExecutable";
|
|
2929
|
-
this.msg = "Program account is not executable";
|
|
2930
|
-
}
|
|
2931
|
-
};
|
|
2932
|
-
InvalidProgramExecutable.code = 3009;
|
|
2933
|
-
var AccountNotSigner = class extends Error {
|
|
2934
|
-
constructor(logs) {
|
|
2935
|
-
super("3010: The given account did not sign");
|
|
2936
|
-
this.logs = logs;
|
|
2937
|
-
this.code = 3010;
|
|
2938
|
-
this.name = "AccountNotSigner";
|
|
2939
|
-
this.msg = "The given account did not sign";
|
|
2940
|
-
}
|
|
2941
|
-
};
|
|
2942
|
-
AccountNotSigner.code = 3010;
|
|
2943
|
-
var AccountNotSystemOwned = class extends Error {
|
|
2944
|
-
constructor(logs) {
|
|
2945
|
-
super("3011: The given account is not owned by the system program");
|
|
2946
|
-
this.logs = logs;
|
|
2947
|
-
this.code = 3011;
|
|
2948
|
-
this.name = "AccountNotSystemOwned";
|
|
2949
|
-
this.msg = "The given account is not owned by the system program";
|
|
2950
|
-
}
|
|
2951
|
-
};
|
|
2952
|
-
AccountNotSystemOwned.code = 3011;
|
|
2953
|
-
var AccountNotInitialized = class extends Error {
|
|
2954
|
-
constructor(logs) {
|
|
2955
|
-
super("3012: The program expected this account to be already initialized");
|
|
2956
|
-
this.logs = logs;
|
|
2957
|
-
this.code = 3012;
|
|
2958
|
-
this.name = "AccountNotInitialized";
|
|
2959
|
-
this.msg = "The program expected this account to be already initialized";
|
|
2960
|
-
}
|
|
2961
|
-
};
|
|
2962
|
-
AccountNotInitialized.code = 3012;
|
|
2963
|
-
var AccountNotProgramData = class extends Error {
|
|
2964
|
-
constructor(logs) {
|
|
2965
|
-
super("3013: The given account is not a program data account");
|
|
2966
|
-
this.logs = logs;
|
|
2967
|
-
this.code = 3013;
|
|
2968
|
-
this.name = "AccountNotProgramData";
|
|
2969
|
-
this.msg = "The given account is not a program data account";
|
|
2970
|
-
}
|
|
2971
|
-
};
|
|
2972
|
-
AccountNotProgramData.code = 3013;
|
|
2973
|
-
var AccountNotAssociatedTokenAccount = class extends Error {
|
|
2974
|
-
constructor(logs) {
|
|
2975
|
-
super("3014: The given account is not the associated token account");
|
|
2976
|
-
this.logs = logs;
|
|
2977
|
-
this.code = 3014;
|
|
2978
|
-
this.name = "AccountNotAssociatedTokenAccount";
|
|
2979
|
-
this.msg = "The given account is not the associated token account";
|
|
2980
|
-
}
|
|
2981
|
-
};
|
|
2982
|
-
AccountNotAssociatedTokenAccount.code = 3014;
|
|
2983
|
-
var AccountSysvarMismatch = class extends Error {
|
|
2984
|
-
constructor(logs) {
|
|
2985
|
-
super("3015: The given public key does not match the required sysvar");
|
|
2986
|
-
this.logs = logs;
|
|
2987
|
-
this.code = 3015;
|
|
2988
|
-
this.name = "AccountSysvarMismatch";
|
|
2989
|
-
this.msg = "The given public key does not match the required sysvar";
|
|
2990
|
-
}
|
|
2991
|
-
};
|
|
2992
|
-
AccountSysvarMismatch.code = 3015;
|
|
2993
|
-
var AccountReallocExceedsLimit = class extends Error {
|
|
2994
|
-
constructor(logs) {
|
|
2995
|
-
super("3016: The account reallocation exceeds the MAX_PERMITTED_DATA_INCREASE limit");
|
|
2996
|
-
this.logs = logs;
|
|
2997
|
-
this.code = 3016;
|
|
2998
|
-
this.name = "AccountReallocExceedsLimit";
|
|
2999
|
-
this.msg = "The account reallocation exceeds the MAX_PERMITTED_DATA_INCREASE limit";
|
|
3000
|
-
}
|
|
3001
|
-
};
|
|
3002
|
-
AccountReallocExceedsLimit.code = 3016;
|
|
3003
|
-
var AccountDuplicateReallocs = class extends Error {
|
|
3004
|
-
constructor(logs) {
|
|
3005
|
-
super("3017: The account was duplicated for more than one reallocation");
|
|
3006
|
-
this.logs = logs;
|
|
3007
|
-
this.code = 3017;
|
|
3008
|
-
this.name = "AccountDuplicateReallocs";
|
|
3009
|
-
this.msg = "The account was duplicated for more than one reallocation";
|
|
3010
|
-
}
|
|
3011
|
-
};
|
|
3012
|
-
AccountDuplicateReallocs.code = 3017;
|
|
3013
|
-
var DeclaredProgramIdMismatch = class extends Error {
|
|
3014
|
-
constructor(logs) {
|
|
3015
|
-
super("4100: The declared program id does not match the actual program id");
|
|
3016
|
-
this.logs = logs;
|
|
3017
|
-
this.code = 4100;
|
|
3018
|
-
this.name = "DeclaredProgramIdMismatch";
|
|
3019
|
-
this.msg = "The declared program id does not match the actual program id";
|
|
3020
|
-
}
|
|
3021
|
-
};
|
|
3022
|
-
DeclaredProgramIdMismatch.code = 4100;
|
|
3023
|
-
var Deprecated = class extends Error {
|
|
3024
|
-
constructor(logs) {
|
|
3025
|
-
super("5000: The API being used is deprecated and should no longer be used");
|
|
3026
|
-
this.logs = logs;
|
|
3027
|
-
this.code = 5e3;
|
|
3028
|
-
this.name = "Deprecated";
|
|
3029
|
-
this.msg = "The API being used is deprecated and should no longer be used";
|
|
3030
|
-
}
|
|
3031
|
-
};
|
|
3032
|
-
Deprecated.code = 5e3;
|
|
3033
|
-
function fromCode(code, logs) {
|
|
3034
|
-
switch (code) {
|
|
3035
|
-
case 100:
|
|
3036
|
-
return new InstructionMissing(logs);
|
|
3037
|
-
case 101:
|
|
3038
|
-
return new InstructionFallbackNotFound(logs);
|
|
3039
|
-
case 102:
|
|
3040
|
-
return new InstructionDidNotDeserialize(logs);
|
|
3041
|
-
case 103:
|
|
3042
|
-
return new InstructionDidNotSerialize(logs);
|
|
3043
|
-
case 1e3:
|
|
3044
|
-
return new IdlInstructionStub(logs);
|
|
3045
|
-
case 1001:
|
|
3046
|
-
return new IdlInstructionInvalidProgram(logs);
|
|
3047
|
-
case 2e3:
|
|
3048
|
-
return new ConstraintMut(logs);
|
|
3049
|
-
case 2001:
|
|
3050
|
-
return new ConstraintHasOne(logs);
|
|
3051
|
-
case 2002:
|
|
3052
|
-
return new ConstraintSigner(logs);
|
|
3053
|
-
case 2003:
|
|
3054
|
-
return new ConstraintRaw(logs);
|
|
3055
|
-
case 2004:
|
|
3056
|
-
return new ConstraintOwner(logs);
|
|
3057
|
-
case 2005:
|
|
3058
|
-
return new ConstraintRentExempt(logs);
|
|
3059
|
-
case 2006:
|
|
3060
|
-
return new ConstraintSeeds(logs);
|
|
3061
|
-
case 2007:
|
|
3062
|
-
return new ConstraintExecutable(logs);
|
|
3063
|
-
case 2008:
|
|
3064
|
-
return new ConstraintState(logs);
|
|
3065
|
-
case 2009:
|
|
3066
|
-
return new ConstraintAssociated(logs);
|
|
3067
|
-
case 2010:
|
|
3068
|
-
return new ConstraintAssociatedInit(logs);
|
|
3069
|
-
case 2011:
|
|
3070
|
-
return new ConstraintClose(logs);
|
|
3071
|
-
case 2012:
|
|
3072
|
-
return new ConstraintAddress(logs);
|
|
3073
|
-
case 2013:
|
|
3074
|
-
return new ConstraintZero(logs);
|
|
3075
|
-
case 2014:
|
|
3076
|
-
return new ConstraintTokenMint(logs);
|
|
3077
|
-
case 2015:
|
|
3078
|
-
return new ConstraintTokenOwner(logs);
|
|
3079
|
-
case 2016:
|
|
3080
|
-
return new ConstraintMintMintAuthority(logs);
|
|
3081
|
-
case 2017:
|
|
3082
|
-
return new ConstraintMintFreezeAuthority(logs);
|
|
3083
|
-
case 2018:
|
|
3084
|
-
return new ConstraintMintDecimals(logs);
|
|
3085
|
-
case 2019:
|
|
3086
|
-
return new ConstraintSpace(logs);
|
|
3087
|
-
case 2020:
|
|
3088
|
-
return new ConstraintAccountIsNone(logs);
|
|
3089
|
-
case 2500:
|
|
3090
|
-
return new RequireViolated(logs);
|
|
3091
|
-
case 2501:
|
|
3092
|
-
return new RequireEqViolated(logs);
|
|
3093
|
-
case 2502:
|
|
3094
|
-
return new RequireKeysEqViolated(logs);
|
|
3095
|
-
case 2503:
|
|
3096
|
-
return new RequireNeqViolated(logs);
|
|
3097
|
-
case 2504:
|
|
3098
|
-
return new RequireKeysNeqViolated(logs);
|
|
3099
|
-
case 2505:
|
|
3100
|
-
return new RequireGtViolated(logs);
|
|
3101
|
-
case 2506:
|
|
3102
|
-
return new RequireGteViolated(logs);
|
|
3103
|
-
case 3e3:
|
|
3104
|
-
return new AccountDiscriminatorAlreadySet(logs);
|
|
3105
|
-
case 3001:
|
|
3106
|
-
return new AccountDiscriminatorNotFound(logs);
|
|
3107
|
-
case 3002:
|
|
3108
|
-
return new AccountDiscriminatorMismatch(logs);
|
|
3109
|
-
case 3003:
|
|
3110
|
-
return new AccountDidNotDeserialize(logs);
|
|
3111
|
-
case 3004:
|
|
3112
|
-
return new AccountDidNotSerialize(logs);
|
|
3113
|
-
case 3005:
|
|
3114
|
-
return new AccountNotEnoughKeys(logs);
|
|
3115
|
-
case 3006:
|
|
3116
|
-
return new AccountNotMutable(logs);
|
|
3117
|
-
case 3007:
|
|
3118
|
-
return new AccountOwnedByWrongProgram(logs);
|
|
3119
|
-
case 3008:
|
|
3120
|
-
return new InvalidProgramId(logs);
|
|
3121
|
-
case 3009:
|
|
3122
|
-
return new InvalidProgramExecutable(logs);
|
|
3123
|
-
case 3010:
|
|
3124
|
-
return new AccountNotSigner(logs);
|
|
3125
|
-
case 3011:
|
|
3126
|
-
return new AccountNotSystemOwned(logs);
|
|
3127
|
-
case 3012:
|
|
3128
|
-
return new AccountNotInitialized(logs);
|
|
3129
|
-
case 3013:
|
|
3130
|
-
return new AccountNotProgramData(logs);
|
|
3131
|
-
case 3014:
|
|
3132
|
-
return new AccountNotAssociatedTokenAccount(logs);
|
|
3133
|
-
case 3015:
|
|
3134
|
-
return new AccountSysvarMismatch(logs);
|
|
3135
|
-
case 3016:
|
|
3136
|
-
return new AccountReallocExceedsLimit(logs);
|
|
3137
|
-
case 3017:
|
|
3138
|
-
return new AccountDuplicateReallocs(logs);
|
|
3139
|
-
case 4100:
|
|
3140
|
-
return new DeclaredProgramIdMismatch(logs);
|
|
3141
|
-
case 5e3:
|
|
3142
|
-
return new Deprecated(logs);
|
|
3143
|
-
}
|
|
3144
|
-
return null;
|
|
3145
|
-
}
|
|
3146
|
-
|
|
3147
|
-
// solana/generated/errors/custom.ts
|
|
3148
|
-
var InsufficientUnlockedTokens = class extends Error {
|
|
3149
|
-
constructor(logs) {
|
|
3150
|
-
super("6000: Insufficient unlocked tokens");
|
|
3151
|
-
this.logs = logs;
|
|
3152
|
-
this.code = 6e3;
|
|
3153
|
-
this.name = "InsufficientUnlockedTokens";
|
|
3154
|
-
this.msg = "Insufficient unlocked tokens";
|
|
3155
|
-
}
|
|
3156
|
-
};
|
|
3157
|
-
InsufficientUnlockedTokens.code = 6e3;
|
|
3158
|
-
var InvalidProof = class extends Error {
|
|
3159
|
-
constructor(logs) {
|
|
3160
|
-
super("6001: Invalid Merkle proof");
|
|
3161
|
-
this.logs = logs;
|
|
3162
|
-
this.code = 6001;
|
|
3163
|
-
this.name = "InvalidProof";
|
|
3164
|
-
this.msg = "Invalid Merkle proof";
|
|
3165
|
-
}
|
|
3166
|
-
};
|
|
3167
|
-
InvalidProof.code = 6001;
|
|
3168
|
-
var ExceededMaxClaim = class extends Error {
|
|
3169
|
-
constructor(logs) {
|
|
3170
|
-
super("6002: Exceeded maximum claim amount");
|
|
3171
|
-
this.logs = logs;
|
|
3172
|
-
this.code = 6002;
|
|
3173
|
-
this.name = "ExceededMaxClaim";
|
|
3174
|
-
this.msg = "Exceeded maximum claim amount";
|
|
3175
|
-
}
|
|
3176
|
-
};
|
|
3177
|
-
ExceededMaxClaim.code = 6002;
|
|
3178
|
-
var MaxNodesExceeded = class extends Error {
|
|
3179
|
-
constructor(logs) {
|
|
3180
|
-
super("6003: Exceeded maximum node count");
|
|
3181
|
-
this.logs = logs;
|
|
3182
|
-
this.code = 6003;
|
|
3183
|
-
this.name = "MaxNodesExceeded";
|
|
3184
|
-
this.msg = "Exceeded maximum node count";
|
|
3185
|
-
}
|
|
3186
|
-
};
|
|
3187
|
-
MaxNodesExceeded.code = 6003;
|
|
3188
|
-
var Unauthorized = class extends Error {
|
|
3189
|
-
constructor(logs) {
|
|
3190
|
-
super("6004: Account is not authorized to execute this instruction");
|
|
3191
|
-
this.logs = logs;
|
|
3192
|
-
this.code = 6004;
|
|
3193
|
-
this.name = "Unauthorized";
|
|
3194
|
-
this.msg = "Account is not authorized to execute this instruction";
|
|
3195
|
-
}
|
|
3196
|
-
};
|
|
3197
|
-
Unauthorized.code = 6004;
|
|
3198
|
-
var OwnerMismatch = class extends Error {
|
|
3199
|
-
constructor(logs) {
|
|
3200
|
-
super("6005: Token account owner did not match intended owner");
|
|
3201
|
-
this.logs = logs;
|
|
3202
|
-
this.code = 6005;
|
|
3203
|
-
this.name = "OwnerMismatch";
|
|
3204
|
-
this.msg = "Token account owner did not match intended owner";
|
|
3205
|
-
}
|
|
3206
|
-
};
|
|
3207
|
-
OwnerMismatch.code = 6005;
|
|
3208
|
-
var ClawbackBeforeStart = class extends Error {
|
|
3209
|
-
constructor(logs) {
|
|
3210
|
-
super("6006: Attempted clawback before start");
|
|
3211
|
-
this.logs = logs;
|
|
3212
|
-
this.code = 6006;
|
|
3213
|
-
this.name = "ClawbackBeforeStart";
|
|
3214
|
-
this.msg = "Attempted clawback before start";
|
|
3215
|
-
}
|
|
3216
|
-
};
|
|
3217
|
-
ClawbackBeforeStart.code = 6006;
|
|
3218
|
-
var ClawbackAlreadyClaimed = class extends Error {
|
|
3219
|
-
constructor(logs) {
|
|
3220
|
-
super("6007: Clawback already claimed");
|
|
3221
|
-
this.logs = logs;
|
|
3222
|
-
this.code = 6007;
|
|
3223
|
-
this.name = "ClawbackAlreadyClaimed";
|
|
3224
|
-
this.msg = "Clawback already claimed";
|
|
3225
|
-
}
|
|
3226
|
-
};
|
|
3227
|
-
ClawbackAlreadyClaimed.code = 6007;
|
|
3228
|
-
var SameClawbackReceiver = class extends Error {
|
|
3229
|
-
constructor(logs) {
|
|
3230
|
-
super("6008: New and old Clawback receivers are identical");
|
|
3231
|
-
this.logs = logs;
|
|
3232
|
-
this.code = 6008;
|
|
3233
|
-
this.name = "SameClawbackReceiver";
|
|
3234
|
-
this.msg = "New and old Clawback receivers are identical";
|
|
3235
|
-
}
|
|
3236
|
-
};
|
|
3237
|
-
SameClawbackReceiver.code = 6008;
|
|
3238
|
-
var ClawbackReceiverIsTokenVault = class extends Error {
|
|
3239
|
-
constructor(logs) {
|
|
3240
|
-
super("6009: Clawback receiver can not be the Token Vault");
|
|
3241
|
-
this.logs = logs;
|
|
3242
|
-
this.code = 6009;
|
|
3243
|
-
this.name = "ClawbackReceiverIsTokenVault";
|
|
3244
|
-
this.msg = "Clawback receiver can not be the Token Vault";
|
|
3245
|
-
}
|
|
3246
|
-
};
|
|
3247
|
-
ClawbackReceiverIsTokenVault.code = 6009;
|
|
3248
|
-
var SameAdmin = class extends Error {
|
|
3249
|
-
constructor(logs) {
|
|
3250
|
-
super("6010: New and old admin are identical");
|
|
3251
|
-
this.logs = logs;
|
|
3252
|
-
this.code = 6010;
|
|
3253
|
-
this.name = "SameAdmin";
|
|
3254
|
-
this.msg = "New and old admin are identical";
|
|
3255
|
-
}
|
|
3256
|
-
};
|
|
3257
|
-
SameAdmin.code = 6010;
|
|
3258
|
-
var ClaimExpired = class extends Error {
|
|
3259
|
-
constructor(logs) {
|
|
3260
|
-
super("6011: Claim window expired");
|
|
3261
|
-
this.logs = logs;
|
|
3262
|
-
this.code = 6011;
|
|
3263
|
-
this.name = "ClaimExpired";
|
|
3264
|
-
this.msg = "Claim window expired";
|
|
3265
|
-
}
|
|
3266
|
-
};
|
|
3267
|
-
ClaimExpired.code = 6011;
|
|
3268
|
-
var ArithmeticError = class extends Error {
|
|
3269
|
-
constructor(logs) {
|
|
3270
|
-
super("6012: Arithmetic Error (overflow/underflow)");
|
|
3271
|
-
this.logs = logs;
|
|
3272
|
-
this.code = 6012;
|
|
3273
|
-
this.name = "ArithmeticError";
|
|
3274
|
-
this.msg = "Arithmetic Error (overflow/underflow)";
|
|
3275
|
-
}
|
|
3276
|
-
};
|
|
3277
|
-
ArithmeticError.code = 6012;
|
|
3278
|
-
var StartTimestampAfterEnd = class extends Error {
|
|
3279
|
-
constructor(logs) {
|
|
3280
|
-
super("6013: Start Timestamp cannot be after end Timestamp");
|
|
3281
|
-
this.logs = logs;
|
|
3282
|
-
this.code = 6013;
|
|
3283
|
-
this.name = "StartTimestampAfterEnd";
|
|
3284
|
-
this.msg = "Start Timestamp cannot be after end Timestamp";
|
|
3285
|
-
}
|
|
3286
|
-
};
|
|
3287
|
-
StartTimestampAfterEnd.code = 6013;
|
|
3288
|
-
var TimestampsNotInFuture = class extends Error {
|
|
3289
|
-
constructor(logs) {
|
|
3290
|
-
super("6014: Timestamps cannot be in the past");
|
|
3291
|
-
this.logs = logs;
|
|
3292
|
-
this.code = 6014;
|
|
3293
|
-
this.name = "TimestampsNotInFuture";
|
|
3294
|
-
this.msg = "Timestamps cannot be in the past";
|
|
3295
|
-
}
|
|
3296
|
-
};
|
|
3297
|
-
TimestampsNotInFuture.code = 6014;
|
|
3298
|
-
var InvalidMint = class extends Error {
|
|
3299
|
-
constructor(logs) {
|
|
3300
|
-
super("6015: Invalid Mint");
|
|
3301
|
-
this.logs = logs;
|
|
3302
|
-
this.code = 6015;
|
|
3303
|
-
this.name = "InvalidMint";
|
|
3304
|
-
this.msg = "Invalid Mint";
|
|
3305
|
-
}
|
|
3306
|
-
};
|
|
3307
|
-
InvalidMint.code = 6015;
|
|
3308
|
-
var ClaimIsClosed = class extends Error {
|
|
3309
|
-
constructor(logs) {
|
|
3310
|
-
super("6016: Claim is closed");
|
|
3311
|
-
this.logs = logs;
|
|
3312
|
-
this.code = 6016;
|
|
3313
|
-
this.name = "ClaimIsClosed";
|
|
3314
|
-
this.msg = "Claim is closed";
|
|
3315
|
-
}
|
|
3316
|
-
};
|
|
3317
|
-
ClaimIsClosed.code = 6016;
|
|
3318
|
-
var ClaimsAreNotClosable = class extends Error {
|
|
3319
|
-
constructor(logs) {
|
|
3320
|
-
super("6017: Claims are not closable");
|
|
3321
|
-
this.logs = logs;
|
|
3322
|
-
this.code = 6017;
|
|
3323
|
-
this.name = "ClaimsAreNotClosable";
|
|
3324
|
-
this.msg = "Claims are not closable";
|
|
3325
|
-
}
|
|
3326
|
-
};
|
|
3327
|
-
ClaimsAreNotClosable.code = 6017;
|
|
3328
|
-
var InvalidUnlockPeriod = class extends Error {
|
|
3329
|
-
constructor(logs) {
|
|
3330
|
-
super("6018: Invalid unlock period");
|
|
3331
|
-
this.logs = logs;
|
|
3332
|
-
this.code = 6018;
|
|
3333
|
-
this.name = "InvalidUnlockPeriod";
|
|
3334
|
-
this.msg = "Invalid unlock period";
|
|
3335
|
-
}
|
|
3336
|
-
};
|
|
3337
|
-
InvalidUnlockPeriod.code = 6018;
|
|
3338
|
-
var DurationUpdateNotAllowed = class extends Error {
|
|
3339
|
-
constructor(logs) {
|
|
3340
|
-
super("6019: Duration update is not allowed");
|
|
3341
|
-
this.logs = logs;
|
|
3342
|
-
this.code = 6019;
|
|
3343
|
-
this.name = "DurationUpdateNotAllowed";
|
|
3344
|
-
this.msg = "Duration update is not allowed";
|
|
3345
|
-
}
|
|
3346
|
-
};
|
|
3347
|
-
DurationUpdateNotAllowed.code = 6019;
|
|
3348
|
-
var NoVestingAmount = class extends Error {
|
|
3349
|
-
constructor(logs) {
|
|
3350
|
-
super("6020: Vesting amounts are not set");
|
|
3351
|
-
this.logs = logs;
|
|
3352
|
-
this.code = 6020;
|
|
3353
|
-
this.name = "NoVestingAmount";
|
|
3354
|
-
this.msg = "Vesting amounts are not set";
|
|
3355
|
-
}
|
|
3356
|
-
};
|
|
3357
|
-
NoVestingAmount.code = 6020;
|
|
3358
|
-
var VestingAlreadyFinished = class extends Error {
|
|
3359
|
-
constructor(logs) {
|
|
3360
|
-
super("6021: Vesting already finished");
|
|
3361
|
-
this.logs = logs;
|
|
3362
|
-
this.code = 6021;
|
|
3363
|
-
this.name = "VestingAlreadyFinished";
|
|
3364
|
-
this.msg = "Vesting already finished";
|
|
3365
|
-
}
|
|
3366
|
-
};
|
|
3367
|
-
VestingAlreadyFinished.code = 6021;
|
|
3368
|
-
var InvalidAmounts = class extends Error {
|
|
3369
|
-
constructor(logs) {
|
|
3370
|
-
super("6022: Provided amounts are invalid");
|
|
3371
|
-
this.logs = logs;
|
|
3372
|
-
this.code = 6022;
|
|
3373
|
-
this.name = "InvalidAmounts";
|
|
3374
|
-
this.msg = "Provided amounts are invalid";
|
|
3375
|
-
}
|
|
3376
|
-
};
|
|
3377
|
-
InvalidAmounts.code = 6022;
|
|
3378
|
-
var ClaimsLimitReached = class extends Error {
|
|
3379
|
-
constructor(logs) {
|
|
3380
|
-
super("6023: Claims limit has been reached");
|
|
3381
|
-
this.logs = logs;
|
|
3382
|
-
this.code = 6023;
|
|
3383
|
-
this.name = "ClaimsLimitReached";
|
|
3384
|
-
this.msg = "Claims limit has been reached";
|
|
3385
|
-
}
|
|
3386
|
-
};
|
|
3387
|
-
ClaimsLimitReached.code = 6023;
|
|
3388
|
-
function fromCode2(code, logs) {
|
|
3389
|
-
switch (code) {
|
|
3390
|
-
case 6e3:
|
|
3391
|
-
return new InsufficientUnlockedTokens(logs);
|
|
3392
|
-
case 6001:
|
|
3393
|
-
return new InvalidProof(logs);
|
|
3394
|
-
case 6002:
|
|
3395
|
-
return new ExceededMaxClaim(logs);
|
|
3396
|
-
case 6003:
|
|
3397
|
-
return new MaxNodesExceeded(logs);
|
|
3398
|
-
case 6004:
|
|
3399
|
-
return new Unauthorized(logs);
|
|
3400
|
-
case 6005:
|
|
3401
|
-
return new OwnerMismatch(logs);
|
|
3402
|
-
case 6006:
|
|
3403
|
-
return new ClawbackBeforeStart(logs);
|
|
3404
|
-
case 6007:
|
|
3405
|
-
return new ClawbackAlreadyClaimed(logs);
|
|
3406
|
-
case 6008:
|
|
3407
|
-
return new SameClawbackReceiver(logs);
|
|
3408
|
-
case 6009:
|
|
3409
|
-
return new ClawbackReceiverIsTokenVault(logs);
|
|
3410
|
-
case 6010:
|
|
3411
|
-
return new SameAdmin(logs);
|
|
3412
|
-
case 6011:
|
|
3413
|
-
return new ClaimExpired(logs);
|
|
3414
|
-
case 6012:
|
|
3415
|
-
return new ArithmeticError(logs);
|
|
3416
|
-
case 6013:
|
|
3417
|
-
return new StartTimestampAfterEnd(logs);
|
|
3418
|
-
case 6014:
|
|
3419
|
-
return new TimestampsNotInFuture(logs);
|
|
3420
|
-
case 6015:
|
|
3421
|
-
return new InvalidMint(logs);
|
|
3422
|
-
case 6016:
|
|
3423
|
-
return new ClaimIsClosed(logs);
|
|
3424
|
-
case 6017:
|
|
3425
|
-
return new ClaimsAreNotClosable(logs);
|
|
3426
|
-
case 6018:
|
|
3427
|
-
return new InvalidUnlockPeriod(logs);
|
|
3428
|
-
case 6019:
|
|
3429
|
-
return new DurationUpdateNotAllowed(logs);
|
|
3430
|
-
case 6020:
|
|
3431
|
-
return new NoVestingAmount(logs);
|
|
3432
|
-
case 6021:
|
|
3433
|
-
return new VestingAlreadyFinished(logs);
|
|
3434
|
-
case 6022:
|
|
3435
|
-
return new InvalidAmounts(logs);
|
|
3436
|
-
case 6023:
|
|
3437
|
-
return new ClaimsLimitReached(logs);
|
|
3438
|
-
}
|
|
3439
|
-
return null;
|
|
3440
|
-
}
|
|
3441
|
-
|
|
3442
|
-
// solana/generated/errors/index.ts
|
|
3443
|
-
function fromCode3(code, logs) {
|
|
3444
|
-
return code >= 6e3 ? fromCode2(code, logs) : fromCode(code, logs);
|
|
3445
|
-
}
|
|
3446
|
-
function hasOwnProperty(obj, prop) {
|
|
3447
|
-
return Object.hasOwnProperty.call(obj, prop);
|
|
3448
|
-
}
|
|
3449
|
-
var errorRe = /Program (\w+) failed: custom program error: (\w+)/;
|
|
3450
|
-
function fromTxError(err, programId = PROGRAM_ID) {
|
|
3451
|
-
if (typeof err !== "object" || err === null || !hasOwnProperty(err, "logs") || !Array.isArray(err.logs)) {
|
|
3452
|
-
return null;
|
|
3453
|
-
}
|
|
3454
|
-
let firstMatch = null;
|
|
3455
|
-
for (const logLine of err.logs) {
|
|
3456
|
-
firstMatch = errorRe.exec(logLine);
|
|
3457
|
-
if (firstMatch !== null) {
|
|
3458
|
-
break;
|
|
3459
|
-
}
|
|
3460
|
-
}
|
|
3461
|
-
if (firstMatch === null) {
|
|
3462
|
-
return null;
|
|
3463
|
-
}
|
|
3464
|
-
const [programIdRaw, codeRaw] = firstMatch.slice(1);
|
|
3465
|
-
if (programIdRaw !== programId.toString()) {
|
|
3466
|
-
return null;
|
|
3467
|
-
}
|
|
3468
|
-
let errorCode;
|
|
3469
|
-
try {
|
|
3470
|
-
errorCode = parseInt(codeRaw, 16);
|
|
3471
|
-
} catch (parseErr) {
|
|
3472
|
-
return null;
|
|
3473
|
-
}
|
|
3474
|
-
return fromCode3(errorCode, err.logs);
|
|
3475
|
-
}
|
|
3476
|
-
|
|
3477
|
-
// solana/utils.ts
|
|
3478
|
-
var getAlignedDistributorPda = (programId, distributor) => {
|
|
3479
|
-
return PublicKey.findProgramAddressSync([ALIGNED_DISTRIBUTOR_PREFIX, distributor.toBuffer()], programId)[0];
|
|
3480
|
-
};
|
|
3481
|
-
var getTestOraclePda = (programId, mint, creator) => {
|
|
3482
|
-
return PublicKey.findProgramAddressSync([TEST_ORACLE_PREFIX, mint.toBuffer(), creator.toBuffer()], programId)[0];
|
|
3483
|
-
};
|
|
3484
|
-
function getDistributorPda(programId, mint, version) {
|
|
3485
|
-
const seeds = [
|
|
3486
|
-
DISTRIBUTOR_PREFIX,
|
|
3487
|
-
mint.toBuffer(),
|
|
3488
|
-
Buffer$1.from(new Uint8Array(new BigUint64Array([BigInt(version)]).buffer))
|
|
3489
|
-
];
|
|
3490
|
-
return PublicKey.findProgramAddressSync(seeds, programId)[0];
|
|
3491
|
-
}
|
|
3492
|
-
function getClaimantStatusPda(programId, distributor, claimant) {
|
|
3493
|
-
const seeds = [CLAIM_STATUS_PREFIX, claimant.toBuffer(), distributor.toBuffer()];
|
|
3494
|
-
return PublicKey.findProgramAddressSync(seeds, programId)[0];
|
|
3495
|
-
}
|
|
3496
|
-
function getEventAuthorityPda(programId) {
|
|
3497
|
-
const seeds = [Buffer$1.from("__event_authority")];
|
|
3498
|
-
return PublicKey.findProgramAddressSync(seeds, programId)[0];
|
|
3499
|
-
}
|
|
3500
|
-
var isCompressedClaimStatus = (status) => {
|
|
3501
|
-
return !!status && "state" in status;
|
|
3502
|
-
};
|
|
3503
|
-
async function wrappedSignAndExecuteTransaction(...args) {
|
|
3504
|
-
try {
|
|
3505
|
-
return await signAndExecuteTransaction(...args);
|
|
3506
|
-
} catch (err) {
|
|
3507
|
-
if (err instanceof Error) {
|
|
3508
|
-
const parsed = fromTxError(err);
|
|
3509
|
-
if (parsed) {
|
|
3510
|
-
throw new ContractError(err, parsed.name, parsed.msg);
|
|
3511
|
-
}
|
|
3512
|
-
}
|
|
3513
|
-
throw err;
|
|
3514
|
-
}
|
|
3515
|
-
}
|
|
3516
|
-
async function calculateAmountWithTransferFees(connection, transferFeeConfig, transferAmount) {
|
|
3517
|
-
const epoch = await connection.getEpochInfo();
|
|
3518
|
-
const transferFee = epoch.epoch >= transferFeeConfig.newerTransferFee.epoch ? transferFeeConfig.newerTransferFee : transferFeeConfig.olderTransferFee;
|
|
3519
|
-
const transferFeeBasisPoints = BigInt(transferFee.transferFeeBasisPoints);
|
|
3520
|
-
let feeCharged = BigInt(0);
|
|
3521
|
-
if (transferFeeBasisPoints !== BigInt(0)) {
|
|
3522
|
-
const numerator = transferAmount * ONE_IN_BASIS_POINTS;
|
|
3523
|
-
const denominator = ONE_IN_BASIS_POINTS - transferFeeBasisPoints;
|
|
3524
|
-
const rawPreFeeAmount = divCeilN(numerator, denominator);
|
|
3525
|
-
const fee = rawPreFeeAmount - transferAmount;
|
|
3526
|
-
transferAmount = rawPreFeeAmount;
|
|
3527
|
-
feeCharged = fee > transferFee.maximumFee ? transferFee.maximumFee : fee;
|
|
3528
|
-
}
|
|
3529
|
-
return { transferAmount, feeCharged };
|
|
3530
|
-
}
|
|
3531
|
-
|
|
3532
|
-
// solana/clients/BaseDistributorClient.ts
|
|
3533
|
-
var BaseDistributorClient = class {
|
|
3534
|
-
constructor({
|
|
3535
|
-
clusterUrl,
|
|
3536
|
-
cluster = ICluster.Mainnet,
|
|
3537
|
-
commitment = "confirmed",
|
|
3538
|
-
programId = "",
|
|
3539
|
-
sendRate = 1,
|
|
3540
|
-
sendThrottler,
|
|
3541
|
-
apiUrl,
|
|
3542
|
-
apiKey
|
|
3543
|
-
}) {
|
|
3544
|
-
this.commitment = commitment;
|
|
3545
|
-
this.cluster = cluster;
|
|
3546
|
-
this.connection = new Connection(clusterUrl, this.commitment);
|
|
3547
|
-
this.programId = programId !== "" ? new PublicKey(programId) : new PublicKey(DISTRIBUTOR_PROGRAM_ID[cluster]);
|
|
3548
|
-
this.sendThrottler = sendThrottler ?? buildSendThrottler(sendRate);
|
|
3549
|
-
const merkleDistributorProgram = {
|
|
3550
|
-
...merkle_distributor_default
|
|
3551
|
-
};
|
|
3552
|
-
this.merkleDistributorProgram = new Program(merkleDistributorProgram, { connection: this.connection });
|
|
3553
|
-
this.apiUrl = apiUrl;
|
|
3554
|
-
this.apiKey = apiKey;
|
|
3555
|
-
}
|
|
3556
|
-
getConnection() {
|
|
3557
|
-
return this.connection;
|
|
3558
|
-
}
|
|
3559
|
-
getCommitment() {
|
|
3560
|
-
return typeof this.commitment == "string" ? this.commitment : this.commitment.commitment;
|
|
3561
|
-
}
|
|
3562
|
-
getDistributorProgramId() {
|
|
3563
|
-
return this.programId;
|
|
3564
|
-
}
|
|
3565
|
-
async prepareCreateInstructions(data, extParams) {
|
|
3566
|
-
if (!extParams.invoker.publicKey) {
|
|
3567
|
-
throw new Error("Invoker's PublicKey is not available, check passed wallet adapter!");
|
|
3568
|
-
}
|
|
3569
|
-
const { version, mint } = data;
|
|
3570
|
-
const ixs = prepareBaseInstructions(this.connection, extParams);
|
|
3571
|
-
const mintPublicKey = extParams.isNative ? NATIVE_MINT : new PublicKey(mint);
|
|
3572
|
-
const { mint: mintAccount, tokenProgramId } = await getMintAndProgram(this.connection, mintPublicKey);
|
|
3573
|
-
const transferFeeConfig = getTransferFeeConfig(mintAccount);
|
|
3574
|
-
const distributorPublicKey = getDistributorPda(this.programId, mintPublicKey, version);
|
|
3575
|
-
const tokenVault = await ata(mintPublicKey, distributorPublicKey, tokenProgramId);
|
|
3576
|
-
const senderTokens = await ata(mintPublicKey, extParams.invoker.publicKey, tokenProgramId);
|
|
3577
|
-
const accounts = {
|
|
3578
|
-
distributor: distributorPublicKey,
|
|
3579
|
-
clawbackReceiver: senderTokens,
|
|
3580
|
-
mint: mintPublicKey,
|
|
3581
|
-
tokenVault,
|
|
3582
|
-
admin: extParams.invoker.publicKey,
|
|
3583
|
-
systemProgram: SystemProgram.programId,
|
|
3584
|
-
associatedTokenProgram: ASSOCIATED_TOKEN_PROGRAM_ID,
|
|
3585
|
-
tokenProgram: tokenProgramId
|
|
3586
|
-
};
|
|
3587
|
-
if (extParams.isNative) {
|
|
3588
|
-
ixs.push(
|
|
3589
|
-
...await prepareWrappedAccount(this.connection, extParams.invoker.publicKey, new BN5(data.maxTotalClaim))
|
|
3590
|
-
);
|
|
3591
|
-
}
|
|
3592
|
-
const newDistributorInstruction = await this.getNewDistributorInstruction(data, accounts);
|
|
3593
|
-
ixs.push(newDistributorInstruction);
|
|
3594
|
-
if (transferFeeConfig) {
|
|
3595
|
-
const { transferAmount, feeCharged } = await calculateAmountWithTransferFees(
|
|
3596
|
-
this.connection,
|
|
3597
|
-
transferFeeConfig,
|
|
3598
|
-
BigInt(data.maxTotalClaim.toString())
|
|
3599
|
-
);
|
|
3600
|
-
ixs.push(
|
|
3601
|
-
createTransferCheckedWithFeeInstruction(
|
|
3602
|
-
senderTokens,
|
|
3603
|
-
mintPublicKey,
|
|
3604
|
-
tokenVault,
|
|
3605
|
-
extParams.invoker.publicKey,
|
|
3606
|
-
transferAmount,
|
|
3607
|
-
mintAccount.decimals,
|
|
3608
|
-
feeCharged,
|
|
3609
|
-
void 0,
|
|
3610
|
-
tokenProgramId
|
|
3611
|
-
)
|
|
3612
|
-
);
|
|
3613
|
-
} else {
|
|
3614
|
-
ixs.push(
|
|
3615
|
-
createTransferCheckedInstruction(
|
|
3616
|
-
senderTokens,
|
|
3617
|
-
mintPublicKey,
|
|
3618
|
-
tokenVault,
|
|
3619
|
-
extParams.invoker.publicKey,
|
|
3620
|
-
BigInt(data.maxTotalClaim.toString()),
|
|
3621
|
-
mintAccount.decimals,
|
|
3622
|
-
void 0,
|
|
3623
|
-
tokenProgramId
|
|
3624
|
-
)
|
|
3625
|
-
);
|
|
3626
|
-
}
|
|
3627
|
-
return { distributorPublicKey, ixs };
|
|
3628
|
-
}
|
|
3629
|
-
async create(data, extParams) {
|
|
3630
|
-
const invoker = extParams.invoker.publicKey;
|
|
3631
|
-
invariant(invoker, "Invoker's PublicKey is not available, check passed wallet adapter!");
|
|
3632
|
-
const executionParams = this.unwrapExecutionParams(extParams);
|
|
3633
|
-
const { ixs, distributorPublicKey } = await createAndEstimateTransaction(
|
|
3634
|
-
(params) => this.prepareCreateInstructions(data, params),
|
|
3635
|
-
executionParams,
|
|
3636
|
-
(q) => q.ixs
|
|
3637
|
-
);
|
|
3638
|
-
const { tx, hash, context } = await prepareTransaction(this.connection, ixs, extParams.invoker.publicKey);
|
|
3639
|
-
const signature = await wrappedSignAndExecuteTransaction(
|
|
3640
|
-
this.connection,
|
|
3641
|
-
extParams.invoker,
|
|
3642
|
-
tx,
|
|
3643
|
-
{
|
|
3644
|
-
hash,
|
|
3645
|
-
context,
|
|
3646
|
-
commitment: this.getCommitment()
|
|
3647
|
-
},
|
|
3648
|
-
{ sendThrottler: this.sendThrottler, skipSimulation: executionParams.skipSimulation }
|
|
3649
|
-
);
|
|
3650
|
-
return {
|
|
3651
|
-
ixs,
|
|
3652
|
-
txId: signature,
|
|
3653
|
-
metadataId: distributorPublicKey.toBase58()
|
|
3654
|
-
};
|
|
3655
|
-
}
|
|
3656
|
-
async claim(data, extParams, _serviceTransfer) {
|
|
3657
|
-
const executionParams = this.unwrapExecutionParams(extParams);
|
|
3658
|
-
const invoker = executionParams.invoker.publicKey;
|
|
3659
|
-
invariant(invoker, "Invoker's PublicKey is not available, check passed wallet adapter!");
|
|
3660
|
-
const ixs = await createAndEstimateTransaction(
|
|
3661
|
-
(params) => this.prepareClaimInstructions(data, params, _serviceTransfer),
|
|
3662
|
-
executionParams
|
|
3663
|
-
);
|
|
3664
|
-
const { tx, hash, context } = await prepareTransaction(this.connection, ixs, invoker);
|
|
3665
|
-
const signature = await wrappedSignAndExecuteTransaction(
|
|
3666
|
-
this.connection,
|
|
3667
|
-
executionParams.invoker,
|
|
3668
|
-
tx,
|
|
3669
|
-
{
|
|
3670
|
-
hash,
|
|
3671
|
-
context,
|
|
3672
|
-
commitment: this.getCommitment()
|
|
3673
|
-
},
|
|
3674
|
-
{ sendThrottler: this.sendThrottler, skipSimulation: executionParams.skipSimulation }
|
|
3675
|
-
);
|
|
3676
|
-
return { ixs, txId: signature };
|
|
3677
|
-
}
|
|
3678
|
-
async prepareClaimInstructions(data, extParams, _serviceTransfer) {
|
|
3679
|
-
if (!extParams.invoker.publicKey) {
|
|
3680
|
-
throw new Error("Invoker's PublicKey is not available, check passed wallet adapter!");
|
|
3681
|
-
}
|
|
3682
|
-
const distributorPublicKey = new PublicKey(data.id);
|
|
3683
|
-
const distributor = await MerkleDistributor.fetch(this.connection, distributorPublicKey);
|
|
3684
|
-
if (!distributor) {
|
|
3685
|
-
throw new Error("Couldn't get account info");
|
|
3686
|
-
}
|
|
3687
|
-
const { tokenProgramId } = await getMintAndProgram(this.connection, distributor.mint);
|
|
3688
|
-
const ixs = prepareBaseInstructions(this.connection, extParams);
|
|
3689
|
-
ixs.push(
|
|
3690
|
-
...await checkOrCreateAtaBatch(
|
|
3691
|
-
this.connection,
|
|
3692
|
-
[extParams.invoker.publicKey],
|
|
3693
|
-
distributor.mint,
|
|
3694
|
-
extParams.invoker,
|
|
3695
|
-
tokenProgramId,
|
|
3696
|
-
extParams.feePayer
|
|
3697
|
-
)
|
|
3698
|
-
);
|
|
3699
|
-
const invokerTokens = await ata(distributor.mint, extParams.invoker.publicKey, tokenProgramId);
|
|
3700
|
-
const claimStatusPublicKey = getClaimantStatusPda(
|
|
3701
|
-
this.programId,
|
|
3702
|
-
distributorPublicKey,
|
|
3703
|
-
extParams.invoker.publicKey
|
|
3704
|
-
);
|
|
3705
|
-
const eventAuthorityPublicKey = getEventAuthorityPda(this.programId);
|
|
3706
|
-
const claimStatus = await this.getClaim(claimStatusPublicKey);
|
|
3707
|
-
const accounts = {
|
|
3708
|
-
distributor: distributorPublicKey,
|
|
3709
|
-
claimStatus: claimStatusPublicKey,
|
|
3710
|
-
from: distributor.tokenVault,
|
|
3711
|
-
to: invokerTokens,
|
|
3712
|
-
claimant: extParams.invoker.publicKey,
|
|
3713
|
-
mint: distributor.mint,
|
|
3714
|
-
tokenProgram: tokenProgramId,
|
|
3715
|
-
systemProgram: SystemProgram.programId,
|
|
3716
|
-
eventAuthority: eventAuthorityPublicKey,
|
|
3717
|
-
program: this.programId
|
|
3718
|
-
};
|
|
3719
|
-
if (!claimStatus) {
|
|
3720
|
-
const args = {
|
|
3721
|
-
amountLocked: new BN5(data.amountLocked),
|
|
3722
|
-
amountUnlocked: new BN5(data.amountUnlocked),
|
|
3723
|
-
proof: data.proof
|
|
3724
|
-
};
|
|
3725
|
-
ixs.push(newClaim(args, accounts, this.programId));
|
|
3726
|
-
}
|
|
3727
|
-
const nowTs = new BN5(Math.floor(Date.now() / 1e3));
|
|
3728
|
-
if (claimStatus || new BN5(data.amountLocked).gtn(0) && nowTs.sub(distributor.startTs).gte(distributor.unlockPeriod)) {
|
|
3729
|
-
ixs.push(claimLocked(accounts, this.programId));
|
|
3730
|
-
}
|
|
3731
|
-
let feeLamports = typeof _serviceTransfer === "bigint" ? _serviceTransfer : void 0;
|
|
3732
|
-
if (!feeLamports) {
|
|
3733
|
-
try {
|
|
3734
|
-
const { mint: mintAccount } = await getMintAndProgram(this.connection, distributor.mint);
|
|
3735
|
-
const claimableAmountRaw = data?.claimableAmount;
|
|
3736
|
-
const unlockedRaw = data?.amountUnlocked;
|
|
3737
|
-
const lockedRaw = data?.amountLocked;
|
|
3738
|
-
const unlocked = unlockedRaw != null ? new BN5(unlockedRaw) : new BN5(0);
|
|
3739
|
-
const locked = lockedRaw != null ? new BN5(lockedRaw) : new BN5(0);
|
|
3740
|
-
const computedFallback = unlocked.add(locked);
|
|
3741
|
-
const claimableAmount = claimableAmountRaw != null ? BigInt(claimableAmountRaw.toString()) : BigInt(computedFallback.toString());
|
|
3742
|
-
feeLamports = await resolveAirdropFeeLamportsUsingApi({
|
|
3743
|
-
distributorAddress: distributorPublicKey.toBase58(),
|
|
3744
|
-
mintAccount,
|
|
3745
|
-
claimableAmount,
|
|
3746
|
-
cluster: this.cluster,
|
|
3747
|
-
apiUrl: this.apiUrl,
|
|
3748
|
-
apiKey: this.apiKey
|
|
3749
|
-
});
|
|
3750
|
-
} catch (_) {
|
|
3751
|
-
feeLamports = MINIMUM_FEE_FALLBACK;
|
|
3752
|
-
}
|
|
3753
|
-
}
|
|
3754
|
-
ixs.push(this.prepareClaimFeeInstruction(extParams.feePayer ?? extParams.invoker.publicKey, feeLamports));
|
|
3755
|
-
return ixs;
|
|
3756
|
-
}
|
|
3757
|
-
async closeClaim(data, extParams) {
|
|
3758
|
-
const executionParams = this.unwrapExecutionParams(extParams);
|
|
3759
|
-
const invoker = executionParams.invoker.publicKey;
|
|
3760
|
-
invariant(invoker, "Invoker's PublicKey is not available, check passed wallet adapter!");
|
|
3761
|
-
const ixs = await createAndEstimateTransaction(
|
|
3762
|
-
(params) => this.prepareCloseClaimInstructions(data, params),
|
|
3763
|
-
executionParams
|
|
3764
|
-
);
|
|
3765
|
-
const { tx, hash, context } = await prepareTransaction(this.connection, ixs, invoker);
|
|
3766
|
-
const signature = await wrappedSignAndExecuteTransaction(
|
|
3767
|
-
this.connection,
|
|
3768
|
-
executionParams.invoker,
|
|
3769
|
-
tx,
|
|
3770
|
-
{
|
|
3771
|
-
hash,
|
|
3772
|
-
context,
|
|
3773
|
-
commitment: this.getCommitment()
|
|
3774
|
-
},
|
|
3775
|
-
{ sendThrottler: this.sendThrottler, skipSimulation: executionParams.skipSimulation }
|
|
3776
|
-
);
|
|
3777
|
-
return { ixs, txId: signature };
|
|
3778
|
-
}
|
|
3779
|
-
async prepareCloseClaimInstructions(data, extParams) {
|
|
3780
|
-
if (!extParams.invoker.publicKey) {
|
|
3781
|
-
throw new Error("Invoker's PublicKey is not available, check passed wallet adapter!");
|
|
3782
|
-
}
|
|
3783
|
-
const distributorPublicKey = new PublicKey(data.id);
|
|
3784
|
-
const distributor = await MerkleDistributor.fetch(this.connection, distributorPublicKey);
|
|
3785
|
-
const claimantPublicKey = pk(data.claimant);
|
|
3786
|
-
if (!distributor) {
|
|
3787
|
-
throw new Error("Couldn't get distributor account info");
|
|
3788
|
-
}
|
|
3789
|
-
const ixs = prepareBaseInstructions(this.connection, extParams);
|
|
3790
|
-
const claimStatusPublicKey = getClaimantStatusPda(this.programId, distributorPublicKey, claimantPublicKey);
|
|
3791
|
-
const eventAuthorityPublicKey = getEventAuthorityPda(this.programId);
|
|
3792
|
-
const closeClaimAccounts = {
|
|
3793
|
-
adminOrClaimant: extParams.invoker.publicKey,
|
|
3794
|
-
payer: extParams.invoker.publicKey,
|
|
3795
|
-
distributor: distributorPublicKey,
|
|
3796
|
-
claimStatus: claimStatusPublicKey,
|
|
3797
|
-
claimant: claimantPublicKey,
|
|
3798
|
-
systemProgram: SystemProgram.programId,
|
|
3799
|
-
eventAuthority: eventAuthorityPublicKey,
|
|
3800
|
-
program: this.programId
|
|
3801
|
-
};
|
|
3802
|
-
const closeClaimArgs = {
|
|
3803
|
-
amountLocked: data.amountLocked ? new BN5(data.amountLocked) : void 0,
|
|
3804
|
-
amountUnlocked: data.amountUnlocked ? new BN5(data.amountUnlocked) : void 0,
|
|
3805
|
-
proof: data.proof
|
|
3806
|
-
};
|
|
3807
|
-
ixs.push(closeClaim(closeClaimArgs, closeClaimAccounts, this.programId));
|
|
3808
|
-
return ixs;
|
|
3809
|
-
}
|
|
3810
|
-
async prepareClawbackInstructions(data, extParams) {
|
|
3811
|
-
if (!extParams.invoker.publicKey) {
|
|
3812
|
-
throw new Error("Invoker's PublicKey is not available, check passed wallet adapter!");
|
|
3813
|
-
}
|
|
3814
|
-
const distributorPublicKey = new PublicKey(data.id);
|
|
3815
|
-
const distributor = await MerkleDistributor.fetch(this.connection, distributorPublicKey);
|
|
3816
|
-
if (!distributor) {
|
|
3817
|
-
throw new Error("Couldn't get account info");
|
|
3818
|
-
}
|
|
3819
|
-
const { tokenProgramId } = await getMintAndProgram(this.connection, distributor.mint);
|
|
3820
|
-
const ixs = prepareBaseInstructions(this.connection, extParams);
|
|
3821
|
-
ixs.push(
|
|
3822
|
-
...await checkOrCreateAtaBatch(
|
|
3823
|
-
this.connection,
|
|
3824
|
-
[extParams.invoker.publicKey],
|
|
3825
|
-
distributor.mint,
|
|
3826
|
-
extParams.invoker,
|
|
3827
|
-
tokenProgramId,
|
|
3828
|
-
extParams.feePayer
|
|
3829
|
-
)
|
|
3830
|
-
);
|
|
3831
|
-
const accounts = {
|
|
3832
|
-
distributor: distributorPublicKey,
|
|
3833
|
-
from: distributor.tokenVault,
|
|
3834
|
-
to: distributor.clawbackReceiver,
|
|
3835
|
-
admin: extParams.invoker.publicKey,
|
|
3836
|
-
mint: distributor.mint,
|
|
3837
|
-
systemProgram: SystemProgram.programId,
|
|
3838
|
-
tokenProgram: tokenProgramId
|
|
3839
|
-
};
|
|
3840
|
-
const clawbackInstruction = await this.getClawbackInstruction(accounts);
|
|
3841
|
-
ixs.push(clawbackInstruction);
|
|
3842
|
-
return ixs;
|
|
3843
|
-
}
|
|
3844
|
-
async clawback(data, extParams) {
|
|
3845
|
-
const executionParams = this.unwrapExecutionParams(extParams);
|
|
3846
|
-
const invoker = executionParams.invoker.publicKey;
|
|
3847
|
-
invariant(invoker, "Invoker's PublicKey is not available, check passed wallet adapter!");
|
|
3848
|
-
const ixs = await createAndEstimateTransaction(
|
|
3849
|
-
(params) => this.prepareClawbackInstructions(data, params),
|
|
3850
|
-
executionParams
|
|
3851
|
-
);
|
|
3852
|
-
const { tx, hash, context } = await prepareTransaction(this.connection, ixs, invoker);
|
|
3853
|
-
const signature = await wrappedSignAndExecuteTransaction(
|
|
3854
|
-
this.connection,
|
|
3855
|
-
executionParams.invoker,
|
|
3856
|
-
tx,
|
|
3857
|
-
{
|
|
3858
|
-
hash,
|
|
3859
|
-
context,
|
|
3860
|
-
commitment: this.getCommitment()
|
|
3861
|
-
},
|
|
3862
|
-
{ sendThrottler: this.sendThrottler, skipSimulation: executionParams.skipSimulation }
|
|
3863
|
-
);
|
|
3864
|
-
return { ixs, txId: signature };
|
|
3865
|
-
}
|
|
3866
|
-
async getClaim(claimStatus) {
|
|
3867
|
-
return this.connection.getAccountInfo(pk(claimStatus)).then((account) => this.decodeClaimStatus(account));
|
|
3868
|
-
}
|
|
3869
|
-
async getClaims(data) {
|
|
3870
|
-
const claimStatusPublicKeys = data.map(({ id, recipient }) => {
|
|
3871
|
-
return getClaimantStatusPda(this.programId, new PublicKey(id), new PublicKey(recipient));
|
|
3872
|
-
});
|
|
3873
|
-
return this.connection.getMultipleAccountsInfo(claimStatusPublicKeys).then((accounts) => {
|
|
3874
|
-
return accounts.map((account) => this.decodeClaimStatus(account));
|
|
3875
|
-
});
|
|
3876
|
-
}
|
|
3877
|
-
async getDistributors(data) {
|
|
3878
|
-
const distributorPublicKeys = data.ids.map((distributorId) => new PublicKey(distributorId));
|
|
3879
|
-
return MerkleDistributor.fetchMultiple(this.connection, distributorPublicKeys, this.programId);
|
|
3880
|
-
}
|
|
3881
|
-
async searchDistributors(data) {
|
|
3882
|
-
const filters = [{ memcmp: { offset: 0, bytes: bs58.encode(MerkleDistributor.discriminator) } }];
|
|
3883
|
-
if (data.mint) {
|
|
3884
|
-
filters.push({
|
|
3885
|
-
memcmp: {
|
|
3886
|
-
offset: DISTRIBUTOR_MINT_OFFSET,
|
|
3887
|
-
bytes: data.mint
|
|
3888
|
-
}
|
|
3889
|
-
});
|
|
3890
|
-
}
|
|
3891
|
-
if (data.admin) {
|
|
3892
|
-
filters.push({
|
|
3893
|
-
memcmp: {
|
|
3894
|
-
offset: DISTRIBUTOR_ADMIN_OFFSET,
|
|
3895
|
-
bytes: data.admin
|
|
3896
|
-
}
|
|
3897
|
-
});
|
|
3898
|
-
}
|
|
3899
|
-
const accounts = await this.connection.getProgramAccounts(this.programId, { filters });
|
|
3900
|
-
return accounts.map(({ pubkey, account }) => ({
|
|
3901
|
-
publicKey: pubkey,
|
|
3902
|
-
account: MerkleDistributor.decode(account.data)
|
|
3903
|
-
}));
|
|
3904
|
-
}
|
|
3905
|
-
prepareClaimFeeInstruction(payer, fee = AIRDROP_CLAIM_FEE) {
|
|
3906
|
-
return SystemProgram.transfer({
|
|
3907
|
-
fromPubkey: payer,
|
|
3908
|
-
toPubkey: STREAMFLOW_TREASURY_PUBLIC_KEY,
|
|
3909
|
-
lamports: fee
|
|
3910
|
-
});
|
|
3911
|
-
}
|
|
3912
|
-
getNewDistributorArgs(data) {
|
|
3913
|
-
const args = {
|
|
3914
|
-
version: new BN5(data.version),
|
|
3915
|
-
root: data.root,
|
|
3916
|
-
maxTotalClaim: new BN5(data.maxTotalClaim),
|
|
3917
|
-
maxNumNodes: new BN5(data.maxNumNodes),
|
|
3918
|
-
unlockPeriod: new BN5(data.unlockPeriod),
|
|
3919
|
-
startVestingTs: new BN5(data.startVestingTs),
|
|
3920
|
-
endVestingTs: new BN5(data.endVestingTs),
|
|
3921
|
-
clawbackStartTs: new BN5(data.clawbackStartTs),
|
|
3922
|
-
claimsClosableByAdmin: data.claimsClosableByAdmin,
|
|
3923
|
-
claimsClosableByClaimant: data.claimsClosableByClaimant,
|
|
3924
|
-
claimsLimit: data.claimsLimit
|
|
3925
|
-
};
|
|
3926
|
-
const nowTs = new BN5(Math.floor(Date.now() / 1e3));
|
|
3927
|
-
const endVestingTs = args.endVestingTs.isZero() ? nowTs : args.endVestingTs;
|
|
3928
|
-
const startVestingTs = args.startVestingTs.isZero() ? nowTs : args.startVestingTs;
|
|
3929
|
-
if (endVestingTs.gt(startVestingTs) && endVestingTs.sub(startVestingTs).lt(args.unlockPeriod)) {
|
|
3930
|
-
throw new Error("The unlock period cannot be longer than the total vesting duration!");
|
|
3931
|
-
}
|
|
3932
|
-
return args;
|
|
3933
|
-
}
|
|
3934
|
-
unwrapExecutionParams(extParams) {
|
|
3935
|
-
return unwrapExecutionParams(extParams, this.connection);
|
|
3936
|
-
}
|
|
3937
|
-
decodeClaimStatus(account) {
|
|
3938
|
-
if (!account) {
|
|
3939
|
-
return null;
|
|
3940
|
-
}
|
|
3941
|
-
try {
|
|
3942
|
-
return decode(this.merkleDistributorProgram, "claimStatus", account.data);
|
|
3943
|
-
} catch (baseClaimStatusError) {
|
|
3944
|
-
try {
|
|
3945
|
-
return decode(this.merkleDistributorProgram, "compressedClaimStatus", account.data);
|
|
3946
|
-
} catch (compressedClaimStatusError) {
|
|
3947
|
-
throw new Error("Couldn't decode claim status");
|
|
3948
|
-
}
|
|
3949
|
-
}
|
|
3950
|
-
}
|
|
3951
|
-
};
|
|
3952
|
-
function decode(program, accountName, accInfo, programKey) {
|
|
3953
|
-
const programId = program.programId?.toBase58() ?? "N/A";
|
|
3954
|
-
invariant(program, `Decoding program with key ${programId} is not available`);
|
|
3955
|
-
const accountEntity = program.idl.accounts?.find((acc) => acc.name === accountName);
|
|
3956
|
-
invariant(
|
|
3957
|
-
!!accountEntity,
|
|
3958
|
-
`Decoding program with key ${programId} doesn't specify account with name ${String(accountName)}`
|
|
3959
|
-
);
|
|
3960
|
-
return program.coder.accounts.decode(accountName, accInfo);
|
|
3961
|
-
}
|
|
3962
|
-
|
|
3963
|
-
// solana/clients/SolanaDistributorClient.ts
|
|
3964
|
-
var SolanaDistributorClient = class extends BaseDistributorClient {
|
|
3965
|
-
async getNewDistributorInstruction(data, accounts) {
|
|
3966
|
-
const args = this.getNewDistributorArgs(data);
|
|
3967
|
-
return newDistributor(args, accounts, this.programId);
|
|
3968
|
-
}
|
|
3969
|
-
async getClawbackInstruction(accounts) {
|
|
3970
|
-
return clawback(accounts, this.programId);
|
|
3971
|
-
}
|
|
3972
|
-
};
|
|
3973
2414
|
|
|
3974
2415
|
// solana/descriptor/idl/aligned_distributor.json
|
|
3975
2416
|
var aligned_distributor_default = {
|
|
3976
2417
|
address: "aMERKpFAWoChCi5oZwPvgsSCoGpZKBiU7fi76bdZjt2",
|
|
3977
2418
|
metadata: {
|
|
3978
2419
|
name: "aligned_distributor",
|
|
3979
|
-
version: "
|
|
2420
|
+
version: "2.0.0",
|
|
3980
2421
|
spec: "0.1.0",
|
|
3981
2422
|
description: "Proxy for merkle distributor that updates Vesting duration according to token market performance."
|
|
3982
2423
|
},
|
|
@@ -4024,6 +2465,34 @@ var aligned_distributor_default = {
|
|
|
4024
2465
|
}
|
|
4025
2466
|
]
|
|
4026
2467
|
},
|
|
2468
|
+
{
|
|
2469
|
+
name: "claim_sol_fees",
|
|
2470
|
+
discriminator: [
|
|
2471
|
+
127,
|
|
2472
|
+
0,
|
|
2473
|
+
119,
|
|
2474
|
+
89,
|
|
2475
|
+
193,
|
|
2476
|
+
27,
|
|
2477
|
+
209,
|
|
2478
|
+
142
|
|
2479
|
+
],
|
|
2480
|
+
accounts: [
|
|
2481
|
+
{
|
|
2482
|
+
name: "aligned_distributor",
|
|
2483
|
+
docs: [
|
|
2484
|
+
"The [MerkleDistributor]."
|
|
2485
|
+
],
|
|
2486
|
+
writable: true
|
|
2487
|
+
},
|
|
2488
|
+
{
|
|
2489
|
+
name: "treasury",
|
|
2490
|
+
writable: true,
|
|
2491
|
+
address: "5SEpbdjFK5FxwTvfsGMXVQTD2v4M2c5tyRTxhdsPkgDw"
|
|
2492
|
+
}
|
|
2493
|
+
],
|
|
2494
|
+
args: []
|
|
2495
|
+
},
|
|
4027
2496
|
{
|
|
4028
2497
|
name: "clawback",
|
|
4029
2498
|
discriminator: [
|
|
@@ -4527,6 +2996,76 @@ var aligned_distributor_default = {
|
|
|
4527
2996
|
docs: [
|
|
4528
2997
|
"The [Token] program."
|
|
4529
2998
|
]
|
|
2999
|
+
},
|
|
3000
|
+
{
|
|
3001
|
+
name: "partner_oracle_config",
|
|
3002
|
+
pda: {
|
|
3003
|
+
seeds: [
|
|
3004
|
+
{
|
|
3005
|
+
kind: "const",
|
|
3006
|
+
value: [
|
|
3007
|
+
97,
|
|
3008
|
+
105,
|
|
3009
|
+
114,
|
|
3010
|
+
100,
|
|
3011
|
+
114,
|
|
3012
|
+
111,
|
|
3013
|
+
112,
|
|
3014
|
+
95,
|
|
3015
|
+
99,
|
|
3016
|
+
111,
|
|
3017
|
+
110,
|
|
3018
|
+
102,
|
|
3019
|
+
105,
|
|
3020
|
+
103
|
|
3021
|
+
]
|
|
3022
|
+
}
|
|
3023
|
+
],
|
|
3024
|
+
program: {
|
|
3025
|
+
kind: "const",
|
|
3026
|
+
value: [
|
|
3027
|
+
12,
|
|
3028
|
+
48,
|
|
3029
|
+
148,
|
|
3030
|
+
48,
|
|
3031
|
+
221,
|
|
3032
|
+
89,
|
|
3033
|
+
2,
|
|
3034
|
+
209,
|
|
3035
|
+
180,
|
|
3036
|
+
126,
|
|
3037
|
+
151,
|
|
3038
|
+
216,
|
|
3039
|
+
166,
|
|
3040
|
+
3,
|
|
3041
|
+
112,
|
|
3042
|
+
50,
|
|
3043
|
+
177,
|
|
3044
|
+
192,
|
|
3045
|
+
141,
|
|
3046
|
+
218,
|
|
3047
|
+
37,
|
|
3048
|
+
78,
|
|
3049
|
+
51,
|
|
3050
|
+
109,
|
|
3051
|
+
243,
|
|
3052
|
+
106,
|
|
3053
|
+
174,
|
|
3054
|
+
122,
|
|
3055
|
+
93,
|
|
3056
|
+
121,
|
|
3057
|
+
191,
|
|
3058
|
+
119
|
|
3059
|
+
]
|
|
3060
|
+
}
|
|
3061
|
+
}
|
|
3062
|
+
},
|
|
3063
|
+
{
|
|
3064
|
+
name: "partner_oracle",
|
|
3065
|
+
docs: [
|
|
3066
|
+
"Partner Oracle program that stores fees"
|
|
3067
|
+
],
|
|
3068
|
+
address: "pardpVtPjC8nLj1Dwncew62mUzfChdCX1EaoZe8oCAa"
|
|
4530
3069
|
}
|
|
4531
3070
|
],
|
|
4532
3071
|
args: [
|
|
@@ -4902,6 +3441,11 @@ var aligned_distributor_default = {
|
|
|
4902
3441
|
code: 6013,
|
|
4903
3442
|
name: "InvalidMint",
|
|
4904
3443
|
msg: "Invalid Mint"
|
|
3444
|
+
},
|
|
3445
|
+
{
|
|
3446
|
+
code: 6014,
|
|
3447
|
+
name: "NoFeesToClaim",
|
|
3448
|
+
msg: "No fees to claim"
|
|
4905
3449
|
}
|
|
4906
3450
|
],
|
|
4907
3451
|
types: [
|
|
@@ -5050,6 +3594,20 @@ var aligned_distributor_default = {
|
|
|
5050
3594
|
],
|
|
5051
3595
|
type: "pubkey"
|
|
5052
3596
|
},
|
|
3597
|
+
{
|
|
3598
|
+
name: "price_oracle_fee",
|
|
3599
|
+
docs: [
|
|
3600
|
+
"Fee for custom price oracle used in dynamic airdrops"
|
|
3601
|
+
],
|
|
3602
|
+
type: "u32"
|
|
3603
|
+
},
|
|
3604
|
+
{
|
|
3605
|
+
name: "price_oracle_fee_claimed",
|
|
3606
|
+
docs: [
|
|
3607
|
+
"Whether fee for the price oracle has been claimed"
|
|
3608
|
+
],
|
|
3609
|
+
type: "bool"
|
|
3610
|
+
},
|
|
5053
3611
|
{
|
|
5054
3612
|
name: "buffer_2",
|
|
5055
3613
|
docs: [
|
|
@@ -5058,7 +3616,7 @@ var aligned_distributor_default = {
|
|
|
5058
3616
|
type: {
|
|
5059
3617
|
array: [
|
|
5060
3618
|
"u8",
|
|
5061
|
-
|
|
3619
|
+
27
|
|
5062
3620
|
]
|
|
5063
3621
|
}
|
|
5064
3622
|
},
|
|
@@ -5247,85 +3805,143 @@ var aligned_distributor_default = {
|
|
|
5247
3805
|
docs: [
|
|
5248
3806
|
"Whether claims are closable by the admin or not"
|
|
5249
3807
|
],
|
|
5250
|
-
type: "bool"
|
|
3808
|
+
type: "bool"
|
|
3809
|
+
},
|
|
3810
|
+
{
|
|
3811
|
+
name: "can_update_duration",
|
|
3812
|
+
docs: [
|
|
3813
|
+
"Whether admin can update vesting duration"
|
|
3814
|
+
],
|
|
3815
|
+
type: "bool"
|
|
3816
|
+
},
|
|
3817
|
+
{
|
|
3818
|
+
name: "total_amount_unlocked",
|
|
3819
|
+
docs: [
|
|
3820
|
+
"Total amount of funds unlocked (cliff/instant)"
|
|
3821
|
+
],
|
|
3822
|
+
type: "u64"
|
|
3823
|
+
},
|
|
3824
|
+
{
|
|
3825
|
+
name: "total_amount_locked",
|
|
3826
|
+
docs: [
|
|
3827
|
+
"Total amount of funds locked (vested)"
|
|
3828
|
+
],
|
|
3829
|
+
type: "u64"
|
|
3830
|
+
},
|
|
3831
|
+
{
|
|
3832
|
+
name: "last_duration_update_ts",
|
|
3833
|
+
docs: [
|
|
3834
|
+
"Timestamp when update was last called"
|
|
3835
|
+
],
|
|
3836
|
+
type: "u64"
|
|
3837
|
+
},
|
|
3838
|
+
{
|
|
3839
|
+
name: "total_claimable_pre_update",
|
|
3840
|
+
docs: [
|
|
3841
|
+
"Total amount of locked amount claimable as of last duration update, ever increasing total, accumulates with each update"
|
|
3842
|
+
],
|
|
3843
|
+
type: "u64"
|
|
3844
|
+
},
|
|
3845
|
+
{
|
|
3846
|
+
name: "clawed_back_ts",
|
|
3847
|
+
docs: [
|
|
3848
|
+
"Timestamp when funds were clawed back"
|
|
3849
|
+
],
|
|
3850
|
+
type: "u64"
|
|
3851
|
+
},
|
|
3852
|
+
{
|
|
3853
|
+
name: "claims_closable_by_claimant",
|
|
3854
|
+
docs: [
|
|
3855
|
+
"Whether claims are closable by claimant or not"
|
|
3856
|
+
],
|
|
3857
|
+
type: "bool"
|
|
3858
|
+
},
|
|
3859
|
+
{
|
|
3860
|
+
name: "claims_limit",
|
|
3861
|
+
docs: [
|
|
3862
|
+
"Limit number of claims"
|
|
3863
|
+
],
|
|
3864
|
+
type: "u16"
|
|
3865
|
+
},
|
|
3866
|
+
{
|
|
3867
|
+
name: "creation_fee",
|
|
3868
|
+
docs: [
|
|
3869
|
+
"Creation SOL fee"
|
|
3870
|
+
],
|
|
3871
|
+
type: "u32"
|
|
5251
3872
|
},
|
|
5252
3873
|
{
|
|
5253
|
-
name: "
|
|
3874
|
+
name: "creation_fee_claimed",
|
|
5254
3875
|
docs: [
|
|
5255
|
-
"Whether
|
|
3876
|
+
"Whether creation SOL was claimed"
|
|
5256
3877
|
],
|
|
5257
3878
|
type: "bool"
|
|
5258
3879
|
},
|
|
5259
3880
|
{
|
|
5260
|
-
name: "
|
|
3881
|
+
name: "claim_min_fee",
|
|
5261
3882
|
docs: [
|
|
5262
|
-
"
|
|
3883
|
+
"Dynamic claim fee in SOL, min"
|
|
5263
3884
|
],
|
|
5264
|
-
type: "
|
|
3885
|
+
type: "u32"
|
|
5265
3886
|
},
|
|
5266
3887
|
{
|
|
5267
|
-
name: "
|
|
3888
|
+
name: "claim_max_fee",
|
|
5268
3889
|
docs: [
|
|
5269
|
-
"
|
|
3890
|
+
"Dynamic claim fee in SOL, max"
|
|
5270
3891
|
],
|
|
5271
|
-
type: "
|
|
3892
|
+
type: "u32"
|
|
5272
3893
|
},
|
|
5273
3894
|
{
|
|
5274
|
-
name: "
|
|
3895
|
+
name: "allocation_factor",
|
|
5275
3896
|
docs: [
|
|
5276
|
-
"
|
|
3897
|
+
"Factor to multiply claimable SOL lamports by when calculating fee"
|
|
5277
3898
|
],
|
|
5278
|
-
type: "
|
|
3899
|
+
type: "f64"
|
|
5279
3900
|
},
|
|
5280
3901
|
{
|
|
5281
|
-
name: "
|
|
3902
|
+
name: "claim_fee_claimed",
|
|
5282
3903
|
docs: [
|
|
5283
|
-
"
|
|
3904
|
+
"Whether all claim fees were claimed, true by default since no claim fee is taken on creation"
|
|
5284
3905
|
],
|
|
5285
|
-
type: "
|
|
3906
|
+
type: "bool"
|
|
5286
3907
|
},
|
|
5287
3908
|
{
|
|
5288
|
-
name: "
|
|
3909
|
+
name: "token_price_lamports",
|
|
5289
3910
|
docs: [
|
|
5290
|
-
"
|
|
3911
|
+
"Last observed token price in lamports per 1 whole token for claim fee calculation"
|
|
5291
3912
|
],
|
|
5292
3913
|
type: "u64"
|
|
5293
3914
|
},
|
|
5294
3915
|
{
|
|
5295
|
-
name: "
|
|
3916
|
+
name: "clawback_token_fee_percent",
|
|
5296
3917
|
docs: [
|
|
5297
|
-
"
|
|
3918
|
+
"Token % fee on clawback"
|
|
5298
3919
|
],
|
|
5299
|
-
type: "
|
|
3920
|
+
type: "f64"
|
|
5300
3921
|
},
|
|
5301
3922
|
{
|
|
5302
|
-
name: "
|
|
3923
|
+
name: "clawback_fee_claimed",
|
|
5303
3924
|
docs: [
|
|
5304
|
-
"
|
|
3925
|
+
"Whether clawback token % fee has been claimed"
|
|
5305
3926
|
],
|
|
5306
|
-
type: "
|
|
3927
|
+
type: "bool"
|
|
5307
3928
|
},
|
|
5308
3929
|
{
|
|
5309
|
-
name: "
|
|
3930
|
+
name: "program_version",
|
|
5310
3931
|
docs: [
|
|
5311
|
-
"
|
|
3932
|
+
"Program version that initiated the Distributor account"
|
|
5312
3933
|
],
|
|
5313
|
-
type:
|
|
5314
|
-
array: [
|
|
5315
|
-
"u8",
|
|
5316
|
-
20
|
|
5317
|
-
]
|
|
5318
|
-
}
|
|
3934
|
+
type: "u8"
|
|
5319
3935
|
},
|
|
5320
3936
|
{
|
|
5321
|
-
name: "
|
|
3937
|
+
name: "buffer",
|
|
5322
3938
|
docs: [
|
|
5323
3939
|
"Buffer for additional fields"
|
|
5324
3940
|
],
|
|
5325
3941
|
type: {
|
|
5326
3942
|
array: [
|
|
5327
3943
|
"u8",
|
|
5328
|
-
|
|
3944
|
+
13
|
|
5329
3945
|
]
|
|
5330
3946
|
}
|
|
5331
3947
|
}
|
|
@@ -5444,73 +4060,805 @@ var aligned_distributor_default = {
|
|
|
5444
4060
|
}
|
|
5445
4061
|
]
|
|
5446
4062
|
}
|
|
5447
|
-
},
|
|
5448
|
-
{
|
|
5449
|
-
name: "TestOracle",
|
|
5450
|
-
type: {
|
|
5451
|
-
kind: "struct",
|
|
5452
|
-
fields: [
|
|
5453
|
-
{
|
|
5454
|
-
name: "price",
|
|
5455
|
-
type: "u64"
|
|
5456
|
-
},
|
|
5457
|
-
{
|
|
5458
|
-
name: "expo",
|
|
5459
|
-
type: "i32"
|
|
5460
|
-
},
|
|
5461
|
-
{
|
|
5462
|
-
name: "conf",
|
|
5463
|
-
type: "u64"
|
|
5464
|
-
},
|
|
5465
|
-
{
|
|
5466
|
-
name: "publish_time",
|
|
5467
|
-
type: "i64"
|
|
5468
|
-
},
|
|
5469
|
-
{
|
|
5470
|
-
name: "creator",
|
|
5471
|
-
type: "pubkey"
|
|
5472
|
-
},
|
|
5473
|
-
{
|
|
5474
|
-
name: "authority",
|
|
5475
|
-
type: "pubkey"
|
|
5476
|
-
},
|
|
5477
|
-
{
|
|
5478
|
-
name: "mint",
|
|
5479
|
-
type: "pubkey"
|
|
5480
|
-
}
|
|
5481
|
-
]
|
|
4063
|
+
},
|
|
4064
|
+
{
|
|
4065
|
+
name: "TestOracle",
|
|
4066
|
+
type: {
|
|
4067
|
+
kind: "struct",
|
|
4068
|
+
fields: [
|
|
4069
|
+
{
|
|
4070
|
+
name: "price",
|
|
4071
|
+
type: "u64"
|
|
4072
|
+
},
|
|
4073
|
+
{
|
|
4074
|
+
name: "expo",
|
|
4075
|
+
type: "i32"
|
|
4076
|
+
},
|
|
4077
|
+
{
|
|
4078
|
+
name: "conf",
|
|
4079
|
+
type: "u64"
|
|
4080
|
+
},
|
|
4081
|
+
{
|
|
4082
|
+
name: "publish_time",
|
|
4083
|
+
type: "i64"
|
|
4084
|
+
},
|
|
4085
|
+
{
|
|
4086
|
+
name: "creator",
|
|
4087
|
+
type: "pubkey"
|
|
4088
|
+
},
|
|
4089
|
+
{
|
|
4090
|
+
name: "authority",
|
|
4091
|
+
type: "pubkey"
|
|
4092
|
+
},
|
|
4093
|
+
{
|
|
4094
|
+
name: "mint",
|
|
4095
|
+
type: "pubkey"
|
|
4096
|
+
}
|
|
4097
|
+
]
|
|
4098
|
+
}
|
|
4099
|
+
},
|
|
4100
|
+
{
|
|
4101
|
+
name: "UpdateTestOracleParams",
|
|
4102
|
+
type: {
|
|
4103
|
+
kind: "struct",
|
|
4104
|
+
fields: [
|
|
4105
|
+
{
|
|
4106
|
+
name: "price",
|
|
4107
|
+
type: "u64"
|
|
4108
|
+
},
|
|
4109
|
+
{
|
|
4110
|
+
name: "expo",
|
|
4111
|
+
type: "i32"
|
|
4112
|
+
},
|
|
4113
|
+
{
|
|
4114
|
+
name: "conf",
|
|
4115
|
+
type: "u64"
|
|
4116
|
+
},
|
|
4117
|
+
{
|
|
4118
|
+
name: "publish_time",
|
|
4119
|
+
type: "i64"
|
|
4120
|
+
}
|
|
4121
|
+
]
|
|
4122
|
+
}
|
|
4123
|
+
}
|
|
4124
|
+
]
|
|
4125
|
+
};
|
|
4126
|
+
|
|
4127
|
+
// solana/constants.ts
|
|
4128
|
+
var MERKLE_DISTRIBUTOR_ERRORS = parseIdlErrors(merkle_distributor_default);
|
|
4129
|
+
var ALIGNED_DISTRIBUTOR_ERRORS = parseIdlErrors(aligned_distributor_default);
|
|
4130
|
+
var ANCHOR_DISCRIMINATOR_OFFSET = 8;
|
|
4131
|
+
var DISTRIBUTOR_MINT_OFFSET = ANCHOR_DISCRIMINATOR_OFFSET + 41;
|
|
4132
|
+
var DISTRIBUTOR_ADMIN_OFFSET = ANCHOR_DISCRIMINATOR_OFFSET + 201;
|
|
4133
|
+
var DISTRIBUTOR_PREFIX = Buffer.from("MerkleDistributor", "utf-8");
|
|
4134
|
+
var ALIGNED_DISTRIBUTOR_PREFIX = Buffer.from("aligned-distributor", "utf-8");
|
|
4135
|
+
var TEST_ORACLE_PREFIX = Buffer.from("test-oracle", "utf-8");
|
|
4136
|
+
var CLAIM_STATUS_PREFIX = Buffer.from("ClaimStatus", "utf-8");
|
|
4137
|
+
var ALIGNED_PRECISION_FACTOR_POW = 9;
|
|
4138
|
+
var AIRDROP_CLAIM_FEE = BigInt(1e7);
|
|
4139
|
+
var STREAMFLOW_TREASURY_PUBLIC_KEY = new PublicKey("5SEpbdjFK5FxwTvfsGMXVQTD2v4M2c5tyRTxhdsPkgDw");
|
|
4140
|
+
var ONE_IN_BASIS_POINTS = BigInt(1e4);
|
|
4141
|
+
var SOL_FEE_PROGRAM_VERSION = 1;
|
|
4142
|
+
var ALIGNED_DISTRIBUTOR_PROGRAM_ID = {
|
|
4143
|
+
[ICluster.Devnet]: "aMERKpFAWoChCi5oZwPvgsSCoGpZKBiU7fi76bdZjt2",
|
|
4144
|
+
[ICluster.Mainnet]: "aMERKpFAWoChCi5oZwPvgsSCoGpZKBiU7fi76bdZjt2",
|
|
4145
|
+
[ICluster.Testnet]: "aMERKpFAWoChCi5oZwPvgsSCoGpZKBiU7fi76bdZjt2",
|
|
4146
|
+
[ICluster.Local]: "aMERKpFAWoChCi5oZwPvgsSCoGpZKBiU7fi76bdZjt2"
|
|
4147
|
+
};
|
|
4148
|
+
var DISTRIBUTOR_PROGRAM_ID = {
|
|
4149
|
+
[ICluster.Devnet]: "MErKy6nZVoVAkryxAejJz2juifQ4ArgLgHmaJCQkU7N",
|
|
4150
|
+
[ICluster.Mainnet]: "MErKy6nZVoVAkryxAejJz2juifQ4ArgLgHmaJCQkU7N",
|
|
4151
|
+
[ICluster.Testnet]: "MErKy6nZVoVAkryxAejJz2juifQ4ArgLgHmaJCQkU7N",
|
|
4152
|
+
[ICluster.Local]: "MErKy6nZVoVAkryxAejJz2juifQ4ArgLgHmaJCQkU7N"
|
|
4153
|
+
};
|
|
4154
|
+
var PARTNER_ORACLE_PROGRAM_ID = {
|
|
4155
|
+
[ICluster.Devnet]: "pardoTarcc6HKsPcbXkVycxsJsoN9QEzrdHgVdHAGY3",
|
|
4156
|
+
[ICluster.Mainnet]: "pardpVtPjC8nLj1Dwncew62mUzfChdCX1EaoZe8oCAa",
|
|
4157
|
+
[ICluster.Testnet]: "pardoTarcc6HKsPcbXkVycxsJsoN9QEzrdHgVdHAGY3",
|
|
4158
|
+
[ICluster.Local]: "pardoTarcc6HKsPcbXkVycxsJsoN9QEzrdHgVdHAGY3"
|
|
4159
|
+
};
|
|
4160
|
+
var FEE_CONFIG_PUBLIC_KEY = {
|
|
4161
|
+
[ICluster.Devnet]: "5HCju3fLTQGNNPZyZwaWGQqRcTRKE1VEdr7HFZKc7NhB",
|
|
4162
|
+
[ICluster.Mainnet]: "5WHEQeA5uX7zJ8r7yAzsxomF7LTnX9acQy3V8oWXHa8b",
|
|
4163
|
+
[ICluster.Testnet]: "5HCju3fLTQGNNPZyZwaWGQqRcTRKE1VEdr7HFZKc7NhB",
|
|
4164
|
+
[ICluster.Local]: "5HCju3fLTQGNNPZyZwaWGQqRcTRKE1VEdr7HFZKc7NhB"
|
|
4165
|
+
};
|
|
4166
|
+
|
|
4167
|
+
// solana/fetchAirdropFee.ts
|
|
4168
|
+
var fetchAirdropFee = async (distributorId, apiUrl, apiKey, fetchFn = fetch) => {
|
|
4169
|
+
const url = `${apiUrl}/v2/api/airdrops/${encodeURIComponent(distributorId)}/fees`;
|
|
4170
|
+
const res = await fetchFn(url, {
|
|
4171
|
+
method: "GET",
|
|
4172
|
+
headers: {
|
|
4173
|
+
"Content-Type": "application/json",
|
|
4174
|
+
...apiKey ? { "x-api-key": apiKey } : {}
|
|
4175
|
+
}
|
|
4176
|
+
});
|
|
4177
|
+
if (!res.ok) {
|
|
4178
|
+
const text = await res.text().catch(() => "");
|
|
4179
|
+
throw new Error(`Airdrop fee API error: ${res.status} ${res.statusText}${text ? ` - ${text}` : ""}`);
|
|
4180
|
+
}
|
|
4181
|
+
const json = await res.json();
|
|
4182
|
+
return json;
|
|
4183
|
+
};
|
|
4184
|
+
|
|
4185
|
+
// solana/fees.ts
|
|
4186
|
+
var MAXIMUM_FEE_FALLBACK = 9900000n;
|
|
4187
|
+
var MINIMUM_FEE_FALLBACK = 5000000n;
|
|
4188
|
+
var FEE_ALLOCATION_FACTOR_FALLBACK_NUMERATOR = 90n;
|
|
4189
|
+
var FEE_ALLOCATION_FACTOR_FALLBACK_DENOMINATOR = 100n;
|
|
4190
|
+
var LAMPORTS_PER_SOL = 1000000000n;
|
|
4191
|
+
var lamportsToSolString = (lamports) => {
|
|
4192
|
+
const int = lamports / LAMPORTS_PER_SOL;
|
|
4193
|
+
const frac = lamports % LAMPORTS_PER_SOL;
|
|
4194
|
+
if (frac === 0n) return int.toString();
|
|
4195
|
+
const fracStr = frac.toString().padStart(9, "0").replace(/0+$/, "");
|
|
4196
|
+
return `${int.toString()}.${fracStr}`;
|
|
4197
|
+
};
|
|
4198
|
+
var allocationToString = (num, den) => {
|
|
4199
|
+
const SCALE = 1000000000n;
|
|
4200
|
+
const scaled = num * SCALE / den;
|
|
4201
|
+
const int = scaled / SCALE;
|
|
4202
|
+
const frac = scaled % SCALE;
|
|
4203
|
+
if (frac === 0n) return int.toString();
|
|
4204
|
+
const fracStr = frac.toString().padStart(9, "0").replace(/0+$/, "");
|
|
4205
|
+
return `${int.toString()}.${fracStr}`;
|
|
4206
|
+
};
|
|
4207
|
+
var defaultAPIFeesResponse = {
|
|
4208
|
+
isCustom: false,
|
|
4209
|
+
claimFee: void 0,
|
|
4210
|
+
claimFeeDynamic: {
|
|
4211
|
+
minPrice: lamportsToSolString(MINIMUM_FEE_FALLBACK),
|
|
4212
|
+
maxPrice: lamportsToSolString(MAXIMUM_FEE_FALLBACK),
|
|
4213
|
+
allocationFactor: allocationToString(
|
|
4214
|
+
FEE_ALLOCATION_FACTOR_FALLBACK_NUMERATOR,
|
|
4215
|
+
FEE_ALLOCATION_FACTOR_FALLBACK_DENOMINATOR
|
|
4216
|
+
)
|
|
4217
|
+
}
|
|
4218
|
+
};
|
|
4219
|
+
var toLamportsSOL = (value, solDecimals = 9) => {
|
|
4220
|
+
const y = typeof value === "bigint" ? Number(value) : typeof value === "string" ? Number(value) : value;
|
|
4221
|
+
if (!Number.isFinite(y) || y <= 0) return 0n;
|
|
4222
|
+
const scale = 10n ** BigInt(solDecimals);
|
|
4223
|
+
return multiplyBigIntByNumber(scale, y);
|
|
4224
|
+
};
|
|
4225
|
+
var applyFeeLogic = (baseLamports) => {
|
|
4226
|
+
if (baseLamports <= 0n) {
|
|
4227
|
+
return MINIMUM_FEE_FALLBACK;
|
|
4228
|
+
}
|
|
4229
|
+
const raw = baseLamports * FEE_ALLOCATION_FACTOR_FALLBACK_NUMERATOR / FEE_ALLOCATION_FACTOR_FALLBACK_DENOMINATOR;
|
|
4230
|
+
if (raw < MINIMUM_FEE_FALLBACK) return MINIMUM_FEE_FALLBACK;
|
|
4231
|
+
if (raw > MAXIMUM_FEE_FALLBACK) return MAXIMUM_FEE_FALLBACK;
|
|
4232
|
+
return raw;
|
|
4233
|
+
};
|
|
4234
|
+
async function calculateAirdropFeeLamports(params) {
|
|
4235
|
+
const { distributorAddress, client, claimableLamports } = params;
|
|
4236
|
+
try {
|
|
4237
|
+
if (client) {
|
|
4238
|
+
const res = await client.getAirdropFee(distributorAddress);
|
|
4239
|
+
const data = res?.data;
|
|
4240
|
+
if (data?.isCustom && data.claimFee !== void 0) {
|
|
4241
|
+
return toLamportsSOL(data.claimFee);
|
|
4242
|
+
}
|
|
4243
|
+
if (data?.claimFeeDynamic && claimableLamports !== void 0) {
|
|
4244
|
+
const min = toLamportsSOL(data.claimFeeDynamic.minPrice);
|
|
4245
|
+
const max = toLamportsSOL(data.claimFeeDynamic.maxPrice);
|
|
4246
|
+
const factor = Math.max(0, Math.min(1, parseFloat(data.claimFeeDynamic.allocationFactor)));
|
|
4247
|
+
const fee = multiplyBigIntByNumber(claimableLamports, factor);
|
|
4248
|
+
if (fee < min) return min;
|
|
4249
|
+
if (fee > max) return max;
|
|
4250
|
+
return fee;
|
|
4251
|
+
}
|
|
4252
|
+
}
|
|
4253
|
+
} catch (_err) {
|
|
4254
|
+
}
|
|
4255
|
+
if (claimableLamports !== void 0) {
|
|
4256
|
+
return applyFeeLogic(claimableLamports);
|
|
4257
|
+
}
|
|
4258
|
+
return MINIMUM_FEE_FALLBACK;
|
|
4259
|
+
}
|
|
4260
|
+
function calculateClaimableLamportsFromPrices(params) {
|
|
4261
|
+
const { claimableAmount, tokenPriceUsd, solPriceUsd, tokenDecimals, solDecimals = 9 } = params;
|
|
4262
|
+
if (tokenPriceUsd <= 0 || solPriceUsd <= 0) return 0n;
|
|
4263
|
+
const scaleDigits = Math.min(18, Math.max(0, tokenDecimals));
|
|
4264
|
+
const SCALE = 10n ** BigInt(scaleDigits);
|
|
4265
|
+
const pScaled = multiplyBigIntByNumber(SCALE, tokenPriceUsd, scaleDigits);
|
|
4266
|
+
const sScaled = multiplyBigIntByNumber(SCALE, solPriceUsd, scaleDigits);
|
|
4267
|
+
if (pScaled <= 0n || sScaled <= 0n) return 0n;
|
|
4268
|
+
const pow10 = (n) => 10n ** BigInt(n);
|
|
4269
|
+
const numerator = claimableAmount * pow10(solDecimals) * pScaled;
|
|
4270
|
+
const denominator = pow10(tokenDecimals) * sScaled;
|
|
4271
|
+
return numerator / denominator;
|
|
4272
|
+
}
|
|
4273
|
+
function calculateDynamicFeeFromSolParams(params) {
|
|
4274
|
+
const { minPrice, maxPrice, allocationFactor, claimableLamports, solDecimals = 9 } = params;
|
|
4275
|
+
const minLamports = toLamportsSOL(minPrice, solDecimals);
|
|
4276
|
+
const maxLamports = toLamportsSOL(maxPrice, solDecimals);
|
|
4277
|
+
const factor = Math.max(0, Math.min(1, parseFloat(allocationFactor)));
|
|
4278
|
+
const raw = multiplyBigIntByNumber(claimableLamports, factor);
|
|
4279
|
+
if (raw < minLamports) return minLamports;
|
|
4280
|
+
if (raw > maxLamports) return maxLamports;
|
|
4281
|
+
return raw;
|
|
4282
|
+
}
|
|
4283
|
+
async function resolveAirdropFeeLamportsUsingApi(params) {
|
|
4284
|
+
const { distributorAddress, mintAccount, claimableAmount, cluster, apiUrl, apiKey } = params;
|
|
4285
|
+
let apiFeesResponse = void 0;
|
|
4286
|
+
try {
|
|
4287
|
+
apiFeesResponse = await fetchAirdropFee(distributorAddress, apiUrl, apiKey);
|
|
4288
|
+
} catch (_) {
|
|
4289
|
+
}
|
|
4290
|
+
let solPrice = null;
|
|
4291
|
+
let tokenPrice = null;
|
|
4292
|
+
try {
|
|
4293
|
+
[solPrice, tokenPrice] = await Promise.all([
|
|
4294
|
+
fetchTokenPrice(NATIVE_MINT.toBase58(), cluster),
|
|
4295
|
+
fetchTokenPrice(mintAccount.address.toBase58(), cluster)
|
|
4296
|
+
]);
|
|
4297
|
+
} catch (_) {
|
|
4298
|
+
}
|
|
4299
|
+
const response = apiFeesResponse ?? defaultAPIFeesResponse;
|
|
4300
|
+
if (response?.isCustom && response.claimFee !== void 0 && response.claimFee !== null) {
|
|
4301
|
+
return toLamportsSOL(response.claimFee);
|
|
4302
|
+
}
|
|
4303
|
+
const claimFeeDynamic = response?.claimFeeDynamic ?? defaultAPIFeesResponse.claimFeeDynamic;
|
|
4304
|
+
if (!tokenPrice?.value || !solPrice?.value) {
|
|
4305
|
+
return MINIMUM_FEE_FALLBACK;
|
|
4306
|
+
}
|
|
4307
|
+
const baseLamports = calculateClaimableLamportsFromPrices({
|
|
4308
|
+
claimableAmount,
|
|
4309
|
+
tokenPriceUsd: tokenPrice.value,
|
|
4310
|
+
solPriceUsd: solPrice.value,
|
|
4311
|
+
tokenDecimals: mintAccount.decimals
|
|
4312
|
+
});
|
|
4313
|
+
return calculateDynamicFeeFromSolParams({
|
|
4314
|
+
minPrice: claimFeeDynamic.minPrice,
|
|
4315
|
+
maxPrice: claimFeeDynamic.maxPrice,
|
|
4316
|
+
allocationFactor: claimFeeDynamic.allocationFactor,
|
|
4317
|
+
claimableLamports: baseLamports
|
|
4318
|
+
});
|
|
4319
|
+
}
|
|
4320
|
+
var getAlignedDistributorPda = (programId, distributor) => {
|
|
4321
|
+
return PublicKey.findProgramAddressSync([ALIGNED_DISTRIBUTOR_PREFIX, distributor.toBuffer()], programId)[0];
|
|
4322
|
+
};
|
|
4323
|
+
var getTestOraclePda = (programId, mint, creator) => {
|
|
4324
|
+
return PublicKey.findProgramAddressSync([TEST_ORACLE_PREFIX, mint.toBuffer(), creator.toBuffer()], programId)[0];
|
|
4325
|
+
};
|
|
4326
|
+
function getDistributorPda(programId, mint, version) {
|
|
4327
|
+
const seeds = [
|
|
4328
|
+
DISTRIBUTOR_PREFIX,
|
|
4329
|
+
mint.toBuffer(),
|
|
4330
|
+
Buffer$1.from(new Uint8Array(new BigUint64Array([BigInt(version)]).buffer))
|
|
4331
|
+
];
|
|
4332
|
+
return PublicKey.findProgramAddressSync(seeds, programId)[0];
|
|
4333
|
+
}
|
|
4334
|
+
function getClaimantStatusPda(programId, distributor, claimant) {
|
|
4335
|
+
const seeds = [CLAIM_STATUS_PREFIX, claimant.toBuffer(), distributor.toBuffer()];
|
|
4336
|
+
return PublicKey.findProgramAddressSync(seeds, programId)[0];
|
|
4337
|
+
}
|
|
4338
|
+
function getEventAuthorityPda(programId) {
|
|
4339
|
+
const seeds = [Buffer$1.from("__event_authority")];
|
|
4340
|
+
return PublicKey.findProgramAddressSync(seeds, programId)[0];
|
|
4341
|
+
}
|
|
4342
|
+
var isCompressedClaimStatus = (status) => {
|
|
4343
|
+
return !!status && "state" in status;
|
|
4344
|
+
};
|
|
4345
|
+
async function wrappedSignAndExecuteTransaction(...args) {
|
|
4346
|
+
try {
|
|
4347
|
+
return await signAndExecuteTransaction(...args);
|
|
4348
|
+
} catch (err) {
|
|
4349
|
+
if (err instanceof Error) {
|
|
4350
|
+
const parsed = translateError(err, MERKLE_DISTRIBUTOR_ERRORS);
|
|
4351
|
+
if ("error" in parsed) {
|
|
4352
|
+
throw new ContractError(err, parsed.error.errorCode?.code, parsed.error.errorMessage);
|
|
4353
|
+
}
|
|
4354
|
+
}
|
|
4355
|
+
throw err;
|
|
4356
|
+
}
|
|
4357
|
+
}
|
|
4358
|
+
async function calculateAmountWithTransferFees(connection, transferFeeConfig, transferAmount) {
|
|
4359
|
+
const epoch = await connection.getEpochInfo();
|
|
4360
|
+
const transferFee = epoch.epoch >= transferFeeConfig.newerTransferFee.epoch ? transferFeeConfig.newerTransferFee : transferFeeConfig.olderTransferFee;
|
|
4361
|
+
const transferFeeBasisPoints = BigInt(transferFee.transferFeeBasisPoints);
|
|
4362
|
+
let feeCharged = BigInt(0);
|
|
4363
|
+
if (transferFeeBasisPoints !== BigInt(0)) {
|
|
4364
|
+
const numerator = transferAmount * ONE_IN_BASIS_POINTS;
|
|
4365
|
+
const denominator = ONE_IN_BASIS_POINTS - transferFeeBasisPoints;
|
|
4366
|
+
const rawPreFeeAmount = divCeilN(numerator, denominator);
|
|
4367
|
+
const fee = rawPreFeeAmount - transferAmount;
|
|
4368
|
+
transferAmount = rawPreFeeAmount;
|
|
4369
|
+
feeCharged = fee > transferFee.maximumFee ? transferFee.maximumFee : fee;
|
|
4370
|
+
}
|
|
4371
|
+
return { transferAmount, feeCharged };
|
|
4372
|
+
}
|
|
4373
|
+
|
|
4374
|
+
// solana/clients/BaseDistributorClient.ts
|
|
4375
|
+
var BaseDistributorClient = class {
|
|
4376
|
+
constructor({
|
|
4377
|
+
clusterUrl,
|
|
4378
|
+
cluster = ICluster.Mainnet,
|
|
4379
|
+
commitment = "confirmed",
|
|
4380
|
+
programId = "",
|
|
4381
|
+
sendRate = 1,
|
|
4382
|
+
sendThrottler,
|
|
4383
|
+
apiUrl,
|
|
4384
|
+
apiKey
|
|
4385
|
+
}) {
|
|
4386
|
+
this.commitment = commitment;
|
|
4387
|
+
this.cluster = cluster;
|
|
4388
|
+
this.connection = new Connection(clusterUrl, this.commitment);
|
|
4389
|
+
this.programId = programId !== "" ? new PublicKey(programId) : new PublicKey(DISTRIBUTOR_PROGRAM_ID[cluster]);
|
|
4390
|
+
this.partnerOracleProgramId = new PublicKey(PARTNER_ORACLE_PROGRAM_ID[cluster]);
|
|
4391
|
+
this.partnerOracle = buildPartnerOracle(this.connection);
|
|
4392
|
+
this.feeConfigPublicKey = new PublicKey(FEE_CONFIG_PUBLIC_KEY[cluster]);
|
|
4393
|
+
this.sendThrottler = sendThrottler ?? buildSendThrottler(sendRate);
|
|
4394
|
+
const merkleDistributorProgram = {
|
|
4395
|
+
...merkle_distributor_default
|
|
4396
|
+
};
|
|
4397
|
+
this.merkleDistributorProgram = new Program(merkleDistributorProgram, { connection: this.connection });
|
|
4398
|
+
this.apiUrl = apiUrl;
|
|
4399
|
+
this.apiKey = apiKey;
|
|
4400
|
+
}
|
|
4401
|
+
getConnection() {
|
|
4402
|
+
return this.connection;
|
|
4403
|
+
}
|
|
4404
|
+
getCommitment() {
|
|
4405
|
+
return typeof this.commitment == "string" ? this.commitment : this.commitment.commitment;
|
|
4406
|
+
}
|
|
4407
|
+
getDistributorProgramId() {
|
|
4408
|
+
return this.programId;
|
|
4409
|
+
}
|
|
4410
|
+
async prepareCreateInstructions(data, extParams) {
|
|
4411
|
+
if (!extParams.invoker.publicKey) {
|
|
4412
|
+
throw new Error("Invoker's PublicKey is not available, check passed wallet adapter!");
|
|
4413
|
+
}
|
|
4414
|
+
const { version, mint } = data;
|
|
4415
|
+
const ixs = prepareBaseInstructions(this.connection, extParams);
|
|
4416
|
+
const mintPublicKey = extParams.isNative ? NATIVE_MINT : new PublicKey(mint);
|
|
4417
|
+
const { mint: mintAccount, tokenProgramId } = await getMintAndProgram(this.connection, mintPublicKey);
|
|
4418
|
+
const transferFeeConfig = getTransferFeeConfig(mintAccount);
|
|
4419
|
+
const distributorPublicKey = getDistributorPda(this.programId, mintPublicKey, version);
|
|
4420
|
+
const tokenVault = await ata(mintPublicKey, distributorPublicKey, tokenProgramId);
|
|
4421
|
+
const senderTokens = await ata(mintPublicKey, extParams.invoker.publicKey, tokenProgramId);
|
|
4422
|
+
const accounts = {
|
|
4423
|
+
clawbackReceiver: senderTokens,
|
|
4424
|
+
mint: mintPublicKey,
|
|
4425
|
+
admin: extParams.invoker.publicKey,
|
|
4426
|
+
tokenProgram: tokenProgramId
|
|
4427
|
+
};
|
|
4428
|
+
if (extParams.isNative) {
|
|
4429
|
+
ixs.push(
|
|
4430
|
+
...await prepareWrappedAccount(this.connection, extParams.invoker.publicKey, new BN(data.maxTotalClaim))
|
|
4431
|
+
);
|
|
4432
|
+
}
|
|
4433
|
+
const newDistributorInstruction = await this.getNewDistributorInstruction(data, accounts);
|
|
4434
|
+
ixs.push(newDistributorInstruction);
|
|
4435
|
+
if (transferFeeConfig) {
|
|
4436
|
+
const { transferAmount, feeCharged } = await calculateAmountWithTransferFees(
|
|
4437
|
+
this.connection,
|
|
4438
|
+
transferFeeConfig,
|
|
4439
|
+
BigInt(data.maxTotalClaim.toString())
|
|
4440
|
+
);
|
|
4441
|
+
ixs.push(
|
|
4442
|
+
createTransferCheckedWithFeeInstruction(
|
|
4443
|
+
senderTokens,
|
|
4444
|
+
mintPublicKey,
|
|
4445
|
+
tokenVault,
|
|
4446
|
+
extParams.invoker.publicKey,
|
|
4447
|
+
transferAmount,
|
|
4448
|
+
mintAccount.decimals,
|
|
4449
|
+
feeCharged,
|
|
4450
|
+
void 0,
|
|
4451
|
+
tokenProgramId
|
|
4452
|
+
)
|
|
4453
|
+
);
|
|
4454
|
+
} else {
|
|
4455
|
+
ixs.push(
|
|
4456
|
+
createTransferCheckedInstruction(
|
|
4457
|
+
senderTokens,
|
|
4458
|
+
mintPublicKey,
|
|
4459
|
+
tokenVault,
|
|
4460
|
+
extParams.invoker.publicKey,
|
|
4461
|
+
BigInt(data.maxTotalClaim.toString()),
|
|
4462
|
+
mintAccount.decimals,
|
|
4463
|
+
void 0,
|
|
4464
|
+
tokenProgramId
|
|
4465
|
+
)
|
|
4466
|
+
);
|
|
4467
|
+
}
|
|
4468
|
+
return { distributorPublicKey, ixs };
|
|
4469
|
+
}
|
|
4470
|
+
async create(data, extParams) {
|
|
4471
|
+
const invoker = extParams.invoker.publicKey;
|
|
4472
|
+
invariant(invoker, "Invoker's PublicKey is not available, check passed wallet adapter!");
|
|
4473
|
+
const executionParams = this.unwrapExecutionParams(extParams);
|
|
4474
|
+
const { ixs, distributorPublicKey } = await createAndEstimateTransaction(
|
|
4475
|
+
(params) => this.prepareCreateInstructions(data, params),
|
|
4476
|
+
executionParams,
|
|
4477
|
+
(q) => q.ixs
|
|
4478
|
+
);
|
|
4479
|
+
const { tx, hash, context } = await prepareTransaction(this.connection, ixs, extParams.invoker.publicKey);
|
|
4480
|
+
const signature = await wrappedSignAndExecuteTransaction(
|
|
4481
|
+
this.connection,
|
|
4482
|
+
extParams.invoker,
|
|
4483
|
+
tx,
|
|
4484
|
+
{
|
|
4485
|
+
hash,
|
|
4486
|
+
context,
|
|
4487
|
+
commitment: this.getCommitment()
|
|
4488
|
+
},
|
|
4489
|
+
{ sendThrottler: this.sendThrottler, skipSimulation: executionParams.skipSimulation }
|
|
4490
|
+
);
|
|
4491
|
+
return {
|
|
4492
|
+
ixs,
|
|
4493
|
+
txId: signature,
|
|
4494
|
+
metadataId: distributorPublicKey.toBase58()
|
|
4495
|
+
};
|
|
4496
|
+
}
|
|
4497
|
+
async claim(data, extParams, _serviceTransfer) {
|
|
4498
|
+
const executionParams = this.unwrapExecutionParams(extParams);
|
|
4499
|
+
const invoker = executionParams.invoker.publicKey;
|
|
4500
|
+
invariant(invoker, "Invoker's PublicKey is not available, check passed wallet adapter!");
|
|
4501
|
+
const ixs = await createAndEstimateTransaction(
|
|
4502
|
+
(params) => this.prepareClaimInstructions(data, params, _serviceTransfer),
|
|
4503
|
+
executionParams
|
|
4504
|
+
);
|
|
4505
|
+
const { tx, hash, context } = await prepareTransaction(this.connection, ixs, invoker);
|
|
4506
|
+
const signature = await wrappedSignAndExecuteTransaction(
|
|
4507
|
+
this.connection,
|
|
4508
|
+
executionParams.invoker,
|
|
4509
|
+
tx,
|
|
4510
|
+
{
|
|
4511
|
+
hash,
|
|
4512
|
+
context,
|
|
4513
|
+
commitment: this.getCommitment()
|
|
4514
|
+
},
|
|
4515
|
+
{ sendThrottler: this.sendThrottler, skipSimulation: true }
|
|
4516
|
+
);
|
|
4517
|
+
return { ixs, txId: signature };
|
|
4518
|
+
}
|
|
4519
|
+
async prepareClaimInstructions(data, extParams, _serviceTransfer) {
|
|
4520
|
+
if (!extParams.invoker.publicKey) {
|
|
4521
|
+
throw new Error("Invoker's PublicKey is not available, check passed wallet adapter!");
|
|
4522
|
+
}
|
|
4523
|
+
const distributorPublicKey = new PublicKey(data.id);
|
|
4524
|
+
const distributor = await this.merkleDistributorProgram.account.merkleDistributor.fetch(distributorPublicKey);
|
|
4525
|
+
if (!distributor) {
|
|
4526
|
+
throw new Error("Couldn't get account info");
|
|
4527
|
+
}
|
|
4528
|
+
const { tokenProgramId } = await getMintAndProgram(this.connection, distributor.mint);
|
|
4529
|
+
const ixs = prepareBaseInstructions(this.connection, extParams);
|
|
4530
|
+
ixs.push(
|
|
4531
|
+
...await checkOrCreateAtaBatch(
|
|
4532
|
+
this.connection,
|
|
4533
|
+
[extParams.invoker.publicKey],
|
|
4534
|
+
distributor.mint,
|
|
4535
|
+
extParams.invoker,
|
|
4536
|
+
tokenProgramId,
|
|
4537
|
+
extParams.feePayer
|
|
4538
|
+
)
|
|
4539
|
+
);
|
|
4540
|
+
const invokerTokens = await ata(distributor.mint, extParams.invoker.publicKey, tokenProgramId);
|
|
4541
|
+
const claimStatusPublicKey = getClaimantStatusPda(
|
|
4542
|
+
this.programId,
|
|
4543
|
+
distributorPublicKey,
|
|
4544
|
+
extParams.invoker.publicKey
|
|
4545
|
+
);
|
|
4546
|
+
const claimStatus = await this.getClaim(claimStatusPublicKey);
|
|
4547
|
+
if (!claimStatus) {
|
|
4548
|
+
ixs.push(
|
|
4549
|
+
await this.merkleDistributorProgram.methods.newClaim(new BN(data.amountUnlocked), new BN(data.amountLocked), data.proof).accounts({
|
|
4550
|
+
distributor: distributorPublicKey,
|
|
4551
|
+
to: invokerTokens,
|
|
4552
|
+
claimant: extParams.invoker.publicKey,
|
|
4553
|
+
tokenProgram: tokenProgramId,
|
|
4554
|
+
program: this.programId
|
|
4555
|
+
}).instruction()
|
|
4556
|
+
);
|
|
4557
|
+
}
|
|
4558
|
+
const nowTs = new BN(Math.floor(Date.now() / 1e3));
|
|
4559
|
+
if (claimStatus || new BN(data.amountLocked).gtn(0) && nowTs.sub(distributor.startTs).gte(distributor.unlockPeriod)) {
|
|
4560
|
+
const claimMethod = distributor.programVersion >= SOL_FEE_PROGRAM_VERSION ? this.merkleDistributorProgram.methods.claimLockedV2 : this.merkleDistributorProgram.methods.claimLocked;
|
|
4561
|
+
ixs.push(
|
|
4562
|
+
await claimMethod().accounts({
|
|
4563
|
+
distributor: distributorPublicKey,
|
|
4564
|
+
to: invokerTokens,
|
|
4565
|
+
claimant: extParams.invoker.publicKey,
|
|
4566
|
+
tokenProgram: tokenProgramId,
|
|
4567
|
+
program: this.programId
|
|
4568
|
+
}).instruction()
|
|
4569
|
+
);
|
|
4570
|
+
}
|
|
4571
|
+
if (distributor.programVersion >= SOL_FEE_PROGRAM_VERSION) {
|
|
4572
|
+
return ixs;
|
|
4573
|
+
}
|
|
4574
|
+
let feeLamports = typeof _serviceTransfer === "bigint" ? _serviceTransfer : void 0;
|
|
4575
|
+
if (!feeLamports) {
|
|
4576
|
+
try {
|
|
4577
|
+
const { mint: mintAccount } = await getMintAndProgram(this.connection, distributor.mint);
|
|
4578
|
+
const claimableAmountRaw = data?.claimableAmount;
|
|
4579
|
+
const unlockedRaw = data?.amountUnlocked;
|
|
4580
|
+
const lockedRaw = data?.amountLocked;
|
|
4581
|
+
const unlocked = unlockedRaw != null ? new BN(unlockedRaw) : new BN(0);
|
|
4582
|
+
const locked = lockedRaw != null ? new BN(lockedRaw) : new BN(0);
|
|
4583
|
+
const computedFallback = unlocked.add(locked);
|
|
4584
|
+
const claimableAmount = claimableAmountRaw != null ? BigInt(claimableAmountRaw.toString()) : BigInt(computedFallback.toString());
|
|
4585
|
+
feeLamports = await resolveAirdropFeeLamportsUsingApi({
|
|
4586
|
+
distributorAddress: distributorPublicKey.toBase58(),
|
|
4587
|
+
mintAccount,
|
|
4588
|
+
claimableAmount,
|
|
4589
|
+
cluster: this.cluster,
|
|
4590
|
+
apiUrl: this.apiUrl,
|
|
4591
|
+
apiKey: this.apiKey
|
|
4592
|
+
});
|
|
4593
|
+
} catch (_) {
|
|
4594
|
+
feeLamports = MINIMUM_FEE_FALLBACK;
|
|
5482
4595
|
}
|
|
5483
|
-
}
|
|
5484
|
-
|
|
5485
|
-
|
|
5486
|
-
|
|
5487
|
-
|
|
5488
|
-
|
|
5489
|
-
|
|
5490
|
-
|
|
5491
|
-
|
|
5492
|
-
|
|
5493
|
-
|
|
5494
|
-
|
|
5495
|
-
|
|
5496
|
-
|
|
5497
|
-
|
|
5498
|
-
|
|
5499
|
-
|
|
5500
|
-
|
|
5501
|
-
|
|
5502
|
-
|
|
5503
|
-
|
|
5504
|
-
|
|
5505
|
-
|
|
4596
|
+
}
|
|
4597
|
+
ixs.push(this.prepareClaimFeeInstruction(extParams.feePayer ?? extParams.invoker.publicKey, feeLamports));
|
|
4598
|
+
return ixs;
|
|
4599
|
+
}
|
|
4600
|
+
async closeClaim(data, extParams) {
|
|
4601
|
+
const executionParams = this.unwrapExecutionParams(extParams);
|
|
4602
|
+
const invoker = executionParams.invoker.publicKey;
|
|
4603
|
+
invariant(invoker, "Invoker's PublicKey is not available, check passed wallet adapter!");
|
|
4604
|
+
const ixs = await createAndEstimateTransaction(
|
|
4605
|
+
(params) => this.prepareCloseClaimInstructions(data, params),
|
|
4606
|
+
executionParams
|
|
4607
|
+
);
|
|
4608
|
+
const { tx, hash, context } = await prepareTransaction(this.connection, ixs, invoker);
|
|
4609
|
+
const signature = await wrappedSignAndExecuteTransaction(
|
|
4610
|
+
this.connection,
|
|
4611
|
+
executionParams.invoker,
|
|
4612
|
+
tx,
|
|
4613
|
+
{
|
|
4614
|
+
hash,
|
|
4615
|
+
context,
|
|
4616
|
+
commitment: this.getCommitment()
|
|
4617
|
+
},
|
|
4618
|
+
{ sendThrottler: this.sendThrottler, skipSimulation: executionParams.skipSimulation }
|
|
4619
|
+
);
|
|
4620
|
+
return { ixs, txId: signature };
|
|
4621
|
+
}
|
|
4622
|
+
async prepareCloseClaimInstructions(data, extParams) {
|
|
4623
|
+
if (!extParams.invoker.publicKey) {
|
|
4624
|
+
throw new Error("Invoker's PublicKey is not available, check passed wallet adapter!");
|
|
4625
|
+
}
|
|
4626
|
+
const distributorPublicKey = new PublicKey(data.id);
|
|
4627
|
+
const distributor = await this.merkleDistributorProgram.account.merkleDistributor.fetch(distributorPublicKey);
|
|
4628
|
+
const claimantPublicKey = pk(data.claimant);
|
|
4629
|
+
if (!distributor) {
|
|
4630
|
+
throw new Error("Couldn't get distributor account info");
|
|
4631
|
+
}
|
|
4632
|
+
const ixs = prepareBaseInstructions(this.connection, extParams);
|
|
4633
|
+
ixs.push(
|
|
4634
|
+
await this.merkleDistributorProgram.methods.closeClaim(
|
|
4635
|
+
data.amountUnlocked ? new BN(data.amountUnlocked) : null,
|
|
4636
|
+
data.amountLocked ? new BN(data.amountLocked) : null,
|
|
4637
|
+
data.proof ?? null
|
|
4638
|
+
).accounts({
|
|
4639
|
+
adminOrClaimant: extParams.invoker.publicKey,
|
|
4640
|
+
payer: extParams.invoker.publicKey,
|
|
4641
|
+
distributor: distributorPublicKey,
|
|
4642
|
+
claimant: claimantPublicKey,
|
|
4643
|
+
program: this.programId
|
|
4644
|
+
}).instruction()
|
|
4645
|
+
);
|
|
4646
|
+
return ixs;
|
|
4647
|
+
}
|
|
4648
|
+
async prepareClawbackInstructions(data, extParams) {
|
|
4649
|
+
if (!extParams.invoker.publicKey) {
|
|
4650
|
+
throw new Error("Invoker's PublicKey is not available, check passed wallet adapter!");
|
|
4651
|
+
}
|
|
4652
|
+
const distributorPublicKey = new PublicKey(data.id);
|
|
4653
|
+
const distributor = await this.merkleDistributorProgram.account.merkleDistributor.fetch(distributorPublicKey);
|
|
4654
|
+
if (!distributor) {
|
|
4655
|
+
throw new Error("Couldn't get account info");
|
|
4656
|
+
}
|
|
4657
|
+
const { tokenProgramId } = await getMintAndProgram(this.connection, distributor.mint);
|
|
4658
|
+
const ixs = prepareBaseInstructions(this.connection, extParams);
|
|
4659
|
+
ixs.push(
|
|
4660
|
+
...await checkOrCreateAtaBatch(
|
|
4661
|
+
this.connection,
|
|
4662
|
+
[extParams.invoker.publicKey],
|
|
4663
|
+
distributor.mint,
|
|
4664
|
+
extParams.invoker,
|
|
4665
|
+
tokenProgramId,
|
|
4666
|
+
extParams.feePayer
|
|
4667
|
+
)
|
|
4668
|
+
);
|
|
4669
|
+
const accounts = {
|
|
4670
|
+
distributor: distributorPublicKey,
|
|
4671
|
+
from: distributor.tokenVault,
|
|
4672
|
+
to: distributor.clawbackReceiver,
|
|
4673
|
+
admin: extParams.invoker.publicKey,
|
|
4674
|
+
mint: distributor.mint,
|
|
4675
|
+
tokenProgram: tokenProgramId
|
|
4676
|
+
};
|
|
4677
|
+
const clawbackInstruction = await this.getClawbackInstruction(accounts);
|
|
4678
|
+
ixs.push(clawbackInstruction);
|
|
4679
|
+
return ixs;
|
|
4680
|
+
}
|
|
4681
|
+
async clawback(data, extParams) {
|
|
4682
|
+
const executionParams = this.unwrapExecutionParams(extParams);
|
|
4683
|
+
const invoker = executionParams.invoker.publicKey;
|
|
4684
|
+
invariant(invoker, "Invoker's PublicKey is not available, check passed wallet adapter!");
|
|
4685
|
+
const ixs = await createAndEstimateTransaction(
|
|
4686
|
+
(params) => this.prepareClawbackInstructions(data, params),
|
|
4687
|
+
executionParams
|
|
4688
|
+
);
|
|
4689
|
+
const { tx, hash, context } = await prepareTransaction(this.connection, ixs, invoker);
|
|
4690
|
+
const signature = await wrappedSignAndExecuteTransaction(
|
|
4691
|
+
this.connection,
|
|
4692
|
+
executionParams.invoker,
|
|
4693
|
+
tx,
|
|
4694
|
+
{
|
|
4695
|
+
hash,
|
|
4696
|
+
context,
|
|
4697
|
+
commitment: this.getCommitment()
|
|
4698
|
+
},
|
|
4699
|
+
{ sendThrottler: this.sendThrottler, skipSimulation: executionParams.skipSimulation }
|
|
4700
|
+
);
|
|
4701
|
+
return { ixs, txId: signature };
|
|
4702
|
+
}
|
|
4703
|
+
async getClaim(claimStatus) {
|
|
4704
|
+
return this.connection.getAccountInfo(pk(claimStatus)).then((account) => this.decodeClaimStatus(account));
|
|
4705
|
+
}
|
|
4706
|
+
async getClaims(data) {
|
|
4707
|
+
const claimStatusPublicKeys = data.map(({ id, recipient }) => {
|
|
4708
|
+
return getClaimantStatusPda(this.programId, new PublicKey(id), new PublicKey(recipient));
|
|
4709
|
+
});
|
|
4710
|
+
return this.connection.getMultipleAccountsInfo(claimStatusPublicKeys).then((accounts) => {
|
|
4711
|
+
return accounts.map((account) => this.decodeClaimStatus(account));
|
|
4712
|
+
});
|
|
4713
|
+
}
|
|
4714
|
+
async getDistributors(data) {
|
|
4715
|
+
const distributorPublicKeys = data.ids.map((distributorId) => new PublicKey(distributorId));
|
|
4716
|
+
return this.merkleDistributorProgram.account.merkleDistributor.fetchMultiple(distributorPublicKeys);
|
|
4717
|
+
}
|
|
4718
|
+
async searchDistributors(data) {
|
|
4719
|
+
const filters = [];
|
|
4720
|
+
if (data.mint) {
|
|
4721
|
+
filters.push({
|
|
4722
|
+
memcmp: {
|
|
4723
|
+
offset: DISTRIBUTOR_MINT_OFFSET,
|
|
4724
|
+
bytes: data.mint
|
|
4725
|
+
}
|
|
4726
|
+
});
|
|
4727
|
+
}
|
|
4728
|
+
if (data.admin) {
|
|
4729
|
+
filters.push({
|
|
4730
|
+
memcmp: {
|
|
4731
|
+
offset: DISTRIBUTOR_ADMIN_OFFSET,
|
|
4732
|
+
bytes: data.admin
|
|
4733
|
+
}
|
|
4734
|
+
});
|
|
4735
|
+
}
|
|
4736
|
+
return this.merkleDistributorProgram.account.merkleDistributor.all(filters);
|
|
4737
|
+
}
|
|
4738
|
+
/**
|
|
4739
|
+
* Fetch Fee Config for the Airdrop protocol from Partner Oracle.
|
|
4740
|
+
*/
|
|
4741
|
+
async getFeeConfig() {
|
|
4742
|
+
const accInfo = await this.connection.getAccountInfo(this.feeConfigPublicKey);
|
|
4743
|
+
if (!accInfo) {
|
|
4744
|
+
throw new Error("Fee config is not initialized!");
|
|
4745
|
+
}
|
|
4746
|
+
return decode(this.partnerOracle, "airdropConfig", accInfo.data);
|
|
4747
|
+
}
|
|
4748
|
+
/**
|
|
4749
|
+
* Get all defaults fees applied by the protocol.
|
|
4750
|
+
*/
|
|
4751
|
+
async getDefaultFees() {
|
|
4752
|
+
const feeConfig = await this.getFeeConfig();
|
|
4753
|
+
return {
|
|
4754
|
+
pubkey: PublicKey.default,
|
|
4755
|
+
creationFee: feeConfig.creationFee,
|
|
4756
|
+
priceOracleFee: feeConfig.priceOracleFee,
|
|
4757
|
+
claimMinFee: feeConfig.claimMinFee,
|
|
4758
|
+
claimMaxFee: feeConfig.claimMaxFee,
|
|
4759
|
+
allocationFactor: feeConfig.allocationFactor,
|
|
4760
|
+
clawbackTokenFeePercent: feeConfig.clawbackTokenFeePercent
|
|
4761
|
+
};
|
|
4762
|
+
}
|
|
4763
|
+
/**
|
|
4764
|
+
* Get fees for a given wallet.
|
|
4765
|
+
*
|
|
4766
|
+
* @param pubkey partner to search fees for
|
|
4767
|
+
*/
|
|
4768
|
+
async getFees(pubkey) {
|
|
4769
|
+
const feeConfig = await this.getFeeConfig();
|
|
4770
|
+
const nowTs = new BN(Math.trunc(Date.now() / 1e3));
|
|
4771
|
+
const filteredPartners = feeConfig.partners.filter(
|
|
4772
|
+
(partner) => partner.pubkey.equals(pubkey) && (partner.expiryTs.eqn(0) || partner.expiryTs.gt(nowTs))
|
|
4773
|
+
);
|
|
4774
|
+
if (filteredPartners.length > 1) {
|
|
4775
|
+
throw new Error("More than one partner found, fees fetching is not possible.");
|
|
4776
|
+
}
|
|
4777
|
+
return filteredPartners[0] ?? null;
|
|
4778
|
+
}
|
|
4779
|
+
prepareClaimFeeInstruction(payer, fee = AIRDROP_CLAIM_FEE) {
|
|
4780
|
+
return SystemProgram.transfer({
|
|
4781
|
+
fromPubkey: payer,
|
|
4782
|
+
toPubkey: STREAMFLOW_TREASURY_PUBLIC_KEY,
|
|
4783
|
+
lamports: fee
|
|
4784
|
+
});
|
|
4785
|
+
}
|
|
4786
|
+
validateDistributorArgs(data) {
|
|
4787
|
+
const nowTs = Math.floor(Date.now() / 1e3);
|
|
4788
|
+
const endVestingTs = data.endVestingTs === 0 ? nowTs : data.endVestingTs;
|
|
4789
|
+
const startVestingTs = data.startVestingTs === 0 ? nowTs : data.startVestingTs;
|
|
4790
|
+
if (endVestingTs > startVestingTs && endVestingTs - startVestingTs < data.unlockPeriod) {
|
|
4791
|
+
throw new Error("The unlock period cannot be longer than the total vesting duration!");
|
|
4792
|
+
}
|
|
4793
|
+
}
|
|
4794
|
+
unwrapExecutionParams(extParams) {
|
|
4795
|
+
return unwrapExecutionParams(extParams, this.connection);
|
|
4796
|
+
}
|
|
4797
|
+
decodeClaimStatus(account) {
|
|
4798
|
+
if (!account) {
|
|
4799
|
+
return null;
|
|
4800
|
+
}
|
|
4801
|
+
try {
|
|
4802
|
+
return decode(this.merkleDistributorProgram, "claimStatus", account.data);
|
|
4803
|
+
} catch (baseClaimStatusError) {
|
|
4804
|
+
try {
|
|
4805
|
+
return decode(this.merkleDistributorProgram, "compressedClaimStatus", account.data);
|
|
4806
|
+
} catch (compressedClaimStatusError) {
|
|
4807
|
+
throw new Error("Couldn't decode claim status");
|
|
5506
4808
|
}
|
|
5507
4809
|
}
|
|
5508
|
-
|
|
4810
|
+
}
|
|
5509
4811
|
};
|
|
4812
|
+
function decode(program, accountName, accInfo, programKey) {
|
|
4813
|
+
const programId = program.programId?.toBase58() ?? "N/A";
|
|
4814
|
+
invariant(program, `Decoding program with key ${programId} is not available`);
|
|
4815
|
+
const accountEntity = program.idl.accounts?.find((acc) => acc.name === accountName);
|
|
4816
|
+
invariant(
|
|
4817
|
+
!!accountEntity,
|
|
4818
|
+
`Decoding program with key ${programId} doesn't specify account with name ${String(accountName)}`
|
|
4819
|
+
);
|
|
4820
|
+
return program.coder.accounts.decode(accountName, accInfo);
|
|
4821
|
+
}
|
|
5510
4822
|
|
|
5511
|
-
// solana/clients/
|
|
4823
|
+
// solana/clients/SolanaDistributorClient.ts
|
|
4824
|
+
var SolanaDistributorClient = class extends BaseDistributorClient {
|
|
4825
|
+
async getNewDistributorInstruction(data, accounts) {
|
|
4826
|
+
this.validateDistributorArgs(data);
|
|
4827
|
+
return this.merkleDistributorProgram.methods.newDistributor(
|
|
4828
|
+
new BN(data.version),
|
|
4829
|
+
data.root,
|
|
4830
|
+
new BN(data.maxTotalClaim),
|
|
4831
|
+
new BN(data.maxNumNodes),
|
|
4832
|
+
new BN(data.unlockPeriod),
|
|
4833
|
+
new BN(data.startVestingTs),
|
|
4834
|
+
new BN(data.endVestingTs),
|
|
4835
|
+
new BN(data.clawbackStartTs),
|
|
4836
|
+
data.claimsClosableByAdmin,
|
|
4837
|
+
null,
|
|
4838
|
+
// can_update_duration
|
|
4839
|
+
null,
|
|
4840
|
+
// total_amount_unlocked
|
|
4841
|
+
null,
|
|
4842
|
+
// total_amount_locked
|
|
4843
|
+
data.claimsClosableByClaimant ?? null,
|
|
4844
|
+
data.claimsLimit ?? null
|
|
4845
|
+
).accounts(accounts).accountsPartial({ partnerOracle: this.partnerOracleProgramId, partnerOracleConfig: this.feeConfigPublicKey }).instruction();
|
|
4846
|
+
}
|
|
4847
|
+
async getClawbackInstruction(accounts) {
|
|
4848
|
+
return this.merkleDistributorProgram.methods.clawback().accounts(accounts).instruction();
|
|
4849
|
+
}
|
|
4850
|
+
};
|
|
5512
4851
|
var SolanaAlignedDistributorClient = class extends BaseDistributorClient {
|
|
5513
|
-
constructor({
|
|
4852
|
+
constructor({
|
|
4853
|
+
clusterUrl,
|
|
4854
|
+
cluster,
|
|
4855
|
+
commitment,
|
|
4856
|
+
programId,
|
|
4857
|
+
sendRate,
|
|
4858
|
+
sendThrottler,
|
|
4859
|
+
apiUrl,
|
|
4860
|
+
apiKey
|
|
4861
|
+
}) {
|
|
5514
4862
|
super({ clusterUrl, cluster, commitment, programId, sendRate, sendThrottler, apiUrl, apiKey });
|
|
5515
4863
|
const alignedAirdropsProgram = {
|
|
5516
4864
|
...aligned_distributor_default
|
|
@@ -5546,38 +4894,42 @@ var SolanaAlignedDistributorClient = class extends BaseDistributorClient {
|
|
|
5546
4894
|
};
|
|
5547
4895
|
}
|
|
5548
4896
|
async getNewDistributorInstruction(data, accounts) {
|
|
5549
|
-
const {
|
|
5550
|
-
const
|
|
4897
|
+
const { mint, clawbackReceiver, tokenProgram, admin } = accounts;
|
|
4898
|
+
const distributorKey = getDistributorPda(this.merkleDistributorProgram.programId, pk(accounts.mint), data.version);
|
|
4899
|
+
const tokenVaultKey = getAssociatedTokenAddressSync(pk(mint), distributorKey, true, pk(tokenProgram));
|
|
4900
|
+
this.validateDistributorArgs(data);
|
|
5551
4901
|
const alignedArgs = this.getNewAlignedDistributorArgs(data);
|
|
5552
|
-
const oracle = data.oracleAddress ? new PublicKey(data.oracleAddress) : getTestOraclePda(this.alignedProxyProgram.programId, mint, admin);
|
|
5553
|
-
|
|
5554
|
-
claimsClosable:
|
|
5555
|
-
version:
|
|
5556
|
-
root:
|
|
5557
|
-
maxTotalClaim:
|
|
5558
|
-
maxNumNodes:
|
|
5559
|
-
unlockPeriod:
|
|
5560
|
-
startVestingTs:
|
|
5561
|
-
endVestingTs:
|
|
5562
|
-
clawbackStartTs:
|
|
4902
|
+
const oracle = data.oracleAddress ? new PublicKey(data.oracleAddress) : getTestOraclePda(this.alignedProxyProgram.programId, pk(mint), pk(admin));
|
|
4903
|
+
return this.alignedProxyProgram.methods.newDistributor({
|
|
4904
|
+
claimsClosable: data.claimsClosableByAdmin,
|
|
4905
|
+
version: new BN(data.version),
|
|
4906
|
+
root: data.root,
|
|
4907
|
+
maxTotalClaim: new BN(data.maxTotalClaim),
|
|
4908
|
+
maxNumNodes: new BN(data.maxNumNodes),
|
|
4909
|
+
unlockPeriod: new BN(data.unlockPeriod),
|
|
4910
|
+
startVestingTs: new BN(data.startVestingTs),
|
|
4911
|
+
endVestingTs: new BN(data.endVestingTs),
|
|
4912
|
+
clawbackStartTs: new BN(data.clawbackStartTs),
|
|
5563
4913
|
...alignedArgs
|
|
5564
4914
|
}).accounts({
|
|
5565
4915
|
admin,
|
|
5566
|
-
tokenVault,
|
|
5567
|
-
distributor,
|
|
4916
|
+
tokenVault: tokenVaultKey,
|
|
4917
|
+
distributor: distributorKey,
|
|
5568
4918
|
clawbackReceiver,
|
|
5569
4919
|
mint,
|
|
5570
4920
|
tokenProgram,
|
|
5571
4921
|
priceOracle: oracle
|
|
5572
|
-
}).instruction();
|
|
5573
|
-
return newDistributorIx;
|
|
4922
|
+
}).accountsPartial({ partnerOracle: this.partnerOracleProgramId, partnerOracleConfig: this.feeConfigPublicKey }).instruction();
|
|
5574
4923
|
}
|
|
5575
4924
|
async getClawbackInstruction(accounts) {
|
|
5576
4925
|
const { distributor, from, to, mint, tokenProgram, admin } = accounts;
|
|
5577
|
-
const alignedDistributorKey = getAlignedDistributorPda(
|
|
4926
|
+
const alignedDistributorKey = getAlignedDistributorPda(
|
|
4927
|
+
this.alignedProxyProgram.programId,
|
|
4928
|
+
pk(accounts.distributor)
|
|
4929
|
+
);
|
|
5578
4930
|
const alignedProxy = await this.alignedProxyProgram.account.alignedDistributor.fetch(alignedDistributorKey);
|
|
5579
4931
|
invariant(alignedProxy, "Aligned Distributor proxy account not found");
|
|
5580
|
-
|
|
4932
|
+
return this.alignedProxyProgram.methods.clawback().accounts({
|
|
5581
4933
|
admin,
|
|
5582
4934
|
distributor,
|
|
5583
4935
|
from,
|
|
@@ -5585,7 +4937,6 @@ var SolanaAlignedDistributorClient = class extends BaseDistributorClient {
|
|
|
5585
4937
|
mint,
|
|
5586
4938
|
tokenProgram
|
|
5587
4939
|
}).instruction();
|
|
5588
|
-
return clawbackInstruction;
|
|
5589
4940
|
}
|
|
5590
4941
|
getNewAlignedDistributorArgs(data) {
|
|
5591
4942
|
const {
|
|
@@ -5601,20 +4952,20 @@ var SolanaAlignedDistributorClient = class extends BaseDistributorClient {
|
|
|
5601
4952
|
unlockPeriod
|
|
5602
4953
|
} = data;
|
|
5603
4954
|
return {
|
|
5604
|
-
totalAmountLocked: new
|
|
5605
|
-
totalAmountUnlocked: new
|
|
4955
|
+
totalAmountLocked: new BN(totalAmountLocked),
|
|
4956
|
+
totalAmountUnlocked: new BN(totalAmountUnlocked),
|
|
5606
4957
|
oracleType: !!oracleType ? { [oracleType]: {} } : { none: {} },
|
|
5607
4958
|
minPrice: getBN(minPrice, ALIGNED_PRECISION_FACTOR_POW),
|
|
5608
4959
|
maxPrice: getBN(maxPrice, ALIGNED_PRECISION_FACTOR_POW),
|
|
5609
4960
|
minPercentage: getBN(minPercentage, ALIGNED_PRECISION_FACTOR_POW),
|
|
5610
4961
|
maxPercentage: getBN(maxPercentage, ALIGNED_PRECISION_FACTOR_POW),
|
|
5611
|
-
tickSize: new
|
|
4962
|
+
tickSize: new BN(tickSize || 1),
|
|
5612
4963
|
skipInitial: skipInitial ?? false,
|
|
5613
|
-
updatePeriod: unlockPeriod < 30 ? new
|
|
4964
|
+
updatePeriod: unlockPeriod < 30 ? new BN(30) : new BN(unlockPeriod)
|
|
5614
4965
|
};
|
|
5615
4966
|
}
|
|
5616
4967
|
};
|
|
5617
4968
|
|
|
5618
|
-
export { AnchorErrorCode, ContractErrorCode, FEE_ALLOCATION_FACTOR_FALLBACK_DENOMINATOR, FEE_ALLOCATION_FACTOR_FALLBACK_NUMERATOR, MAXIMUM_FEE_FALLBACK, MINIMUM_FEE_FALLBACK,
|
|
4969
|
+
export { AnchorErrorCode, ContractErrorCode, FEE_ALLOCATION_FACTOR_FALLBACK_DENOMINATOR, FEE_ALLOCATION_FACTOR_FALLBACK_NUMERATOR, MAXIMUM_FEE_FALLBACK, MINIMUM_FEE_FALLBACK, SolanaAlignedDistributorClient, SolanaDistributorClient, applyFeeLogic, calculateAirdropFeeLamports, calculateAmountWithTransferFees, calculateClaimableLamportsFromPrices, calculateDynamicFeeFromSolParams, constants_exports as constants, fetchAirdropFee, getAlignedDistributorPda, getClaimantStatusPda, getDistributorPda, getEventAuthorityPda, getTestOraclePda, isCompressedClaimStatus, resolveAirdropFeeLamportsUsingApi, toLamportsSOL, wrappedSignAndExecuteTransaction };
|
|
5619
4970
|
//# sourceMappingURL=index.js.map
|
|
5620
4971
|
//# sourceMappingURL=index.js.map
|