@streamflow/distributor 7.5.3 → 8.0.0-alpha.p287.25d0c28

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.
Files changed (97) hide show
  1. package/dist/cjs/index.cjs +4531 -0
  2. package/dist/cjs/index.cjs.map +1 -0
  3. package/dist/cjs/index.d.cts +11 -0
  4. package/dist/cjs/solana/descriptor/aligned_distributor.cjs +4 -0
  5. package/dist/cjs/solana/descriptor/aligned_distributor.cjs.map +1 -0
  6. package/dist/cjs/solana/descriptor/{idl/aligned_distributor.json → aligned_distributor.d.cts} +641 -507
  7. package/dist/cjs/solana/descriptor/merkle_distributor.cjs +4 -0
  8. package/dist/cjs/solana/descriptor/merkle_distributor.cjs.map +1 -0
  9. package/dist/cjs/solana/descriptor/merkle_distributor.d.cts +1840 -0
  10. package/dist/cjs/solana/index.cjs +4525 -0
  11. package/dist/cjs/solana/index.cjs.map +1 -0
  12. package/dist/cjs/solana/index.d.cts +1506 -0
  13. package/dist/esm/index.d.ts +11 -1
  14. package/dist/esm/index.js +4505 -1
  15. package/dist/esm/index.js.map +1 -0
  16. package/dist/esm/solana/descriptor/aligned_distributor.d.ts +965 -506
  17. package/dist/esm/solana/descriptor/aligned_distributor.js +3 -1
  18. package/dist/esm/solana/descriptor/aligned_distributor.js.map +1 -0
  19. package/dist/esm/solana/descriptor/idl/aligned_distributor.json +934 -1181
  20. package/dist/esm/solana/descriptor/idl/merkle_distributor.json +1218 -0
  21. package/dist/esm/solana/descriptor/merkle_distributor.d.ts +1275 -561
  22. package/dist/esm/solana/descriptor/merkle_distributor.js +3 -1
  23. package/dist/esm/solana/descriptor/merkle_distributor.js.map +1 -0
  24. package/dist/esm/solana/index.d.ts +1506 -7
  25. package/dist/esm/solana/index.js +4477 -7
  26. package/dist/esm/solana/index.js.map +1 -0
  27. package/package.json +56 -20
  28. package/dist/cjs/index.js +0 -27
  29. package/dist/cjs/solana/clients/BaseDistributorClient.js +0 -276
  30. package/dist/cjs/solana/clients/SolanaAlignedDistributorClient.js +0 -116
  31. package/dist/cjs/solana/clients/SolanaDistributorClient.js +0 -17
  32. package/dist/cjs/solana/clients/index.js +0 -10
  33. package/dist/cjs/solana/constants.js +0 -28
  34. package/dist/cjs/solana/descriptor/aligned_distributor.js +0 -2
  35. package/dist/cjs/solana/descriptor/merkle_distributor.js +0 -2
  36. package/dist/cjs/solana/generated/accounts/ClaimStatus.js +0 -135
  37. package/dist/cjs/solana/generated/accounts/MerkleDistributor.js +0 -215
  38. package/dist/cjs/solana/generated/accounts/index.js +0 -7
  39. package/dist/cjs/solana/generated/errors/anchor.js +0 -712
  40. package/dist/cjs/solana/generated/errors/custom.js +0 -321
  41. package/dist/cjs/solana/generated/errors/index.js +0 -64
  42. package/dist/cjs/solana/generated/instructions/claimLocked.js +0 -22
  43. package/dist/cjs/solana/generated/instructions/clawback.js +0 -21
  44. package/dist/cjs/solana/generated/instructions/closeClaim.js +0 -57
  45. package/dist/cjs/solana/generated/instructions/index.js +0 -17
  46. package/dist/cjs/solana/generated/instructions/newClaim.js +0 -59
  47. package/dist/cjs/solana/generated/instructions/newDistributor.js +0 -104
  48. package/dist/cjs/solana/generated/instructions/setAdmin.js +0 -17
  49. package/dist/cjs/solana/generated/instructions/setClawbackReceiver.js +0 -17
  50. package/dist/cjs/solana/generated/programId.js +0 -8
  51. package/dist/cjs/solana/index.js +0 -36
  52. package/dist/cjs/solana/types.js +0 -159
  53. package/dist/cjs/solana/utils.js +0 -75
  54. package/dist/esm/solana/clients/BaseDistributorClient.d.ts +0 -43
  55. package/dist/esm/solana/clients/BaseDistributorClient.js +0 -274
  56. package/dist/esm/solana/clients/SolanaAlignedDistributorClient.d.ts +0 -16
  57. package/dist/esm/solana/clients/SolanaAlignedDistributorClient.js +0 -111
  58. package/dist/esm/solana/clients/SolanaDistributorClient.d.ts +0 -8
  59. package/dist/esm/solana/clients/SolanaDistributorClient.js +0 -11
  60. package/dist/esm/solana/clients/index.d.ts +0 -2
  61. package/dist/esm/solana/clients/index.js +0 -2
  62. package/dist/esm/solana/constants.d.ts +0 -24
  63. package/dist/esm/solana/constants.js +0 -25
  64. package/dist/esm/solana/generated/accounts/ClaimStatus.d.ts +0 -83
  65. package/dist/esm/solana/generated/accounts/ClaimStatus.js +0 -127
  66. package/dist/esm/solana/generated/accounts/MerkleDistributor.d.ts +0 -179
  67. package/dist/esm/solana/generated/accounts/MerkleDistributor.js +0 -239
  68. package/dist/esm/solana/generated/accounts/index.d.ts +0 -4
  69. package/dist/esm/solana/generated/accounts/index.js +0 -2
  70. package/dist/esm/solana/generated/errors/anchor.d.ts +0 -434
  71. package/dist/esm/solana/generated/errors/anchor.js +0 -707
  72. package/dist/esm/solana/generated/errors/custom.d.ts +0 -194
  73. package/dist/esm/solana/generated/errors/custom.js +0 -317
  74. package/dist/esm/solana/generated/errors/index.d.ts +0 -5
  75. package/dist/esm/solana/generated/errors/index.js +0 -37
  76. package/dist/esm/solana/generated/instructions/claimLocked.d.ts +0 -23
  77. package/dist/esm/solana/generated/instructions/claimLocked.js +0 -19
  78. package/dist/esm/solana/generated/instructions/clawback.d.ts +0 -17
  79. package/dist/esm/solana/generated/instructions/clawback.js +0 -18
  80. package/dist/esm/solana/generated/instructions/closeClaim.d.ts +0 -22
  81. package/dist/esm/solana/generated/instructions/closeClaim.js +0 -30
  82. package/dist/esm/solana/generated/instructions/index.d.ts +0 -14
  83. package/dist/esm/solana/generated/instructions/index.js +0 -7
  84. package/dist/esm/solana/generated/instructions/newClaim.d.ts +0 -29
  85. package/dist/esm/solana/generated/instructions/newClaim.js +0 -32
  86. package/dist/esm/solana/generated/instructions/newDistributor.d.ts +0 -58
  87. package/dist/esm/solana/generated/instructions/newDistributor.js +0 -77
  88. package/dist/esm/solana/generated/instructions/setAdmin.d.ts +0 -10
  89. package/dist/esm/solana/generated/instructions/setAdmin.js +0 -14
  90. package/dist/esm/solana/generated/instructions/setClawbackReceiver.d.ts +0 -10
  91. package/dist/esm/solana/generated/instructions/setClawbackReceiver.js +0 -14
  92. package/dist/esm/solana/generated/programId.d.ts +0 -3
  93. package/dist/esm/solana/generated/programId.js +0 -5
  94. package/dist/esm/solana/types.d.ts +0 -258
  95. package/dist/esm/solana/types.js +0 -156
  96. package/dist/esm/solana/utils.d.ts +0 -14
  97. package/dist/esm/solana/utils.js +0 -65
package/dist/esm/index.js CHANGED
@@ -1 +1,4505 @@
1
- export * as StreamflowDistributorSolana from "./solana/index.js";
1
+ import { PublicKey, TransactionInstruction, Connection, SystemProgram } from '@solana/web3.js';
2
+ import '@solana/wallet-adapter-base';
3
+ import { ICluster, ContractError, divCeilN, invariant, getNumberFromBN, getBN } from '@streamflow/common';
4
+ import { signAndExecuteTransaction, buildSendThrottler, prepareBaseInstructions, getMintAndProgram, ata, prepareWrappedAccount, createAndEstimateTransaction, prepareTransaction, checkOrCreateAtaBatch, pk, unwrapExecutionParams } from '@streamflow/common/solana';
5
+ import { Program } from '@coral-xyz/anchor';
6
+ import * as borsh8 from '@coral-xyz/borsh';
7
+ import { Buffer as Buffer$1 } from 'buffer';
8
+ import BN6 from 'bn.js';
9
+ import { NATIVE_MINT, getTransferFeeConfig, ASSOCIATED_TOKEN_PROGRAM_ID, createTransferCheckedWithFeeInstruction, createTransferCheckedInstruction } from '@solana/spl-token';
10
+ import bs58 from 'bs58';
11
+
12
+ var __defProp = Object.defineProperty;
13
+ var __export = (target, all) => {
14
+ for (var name in all)
15
+ __defProp(target, name, { get: all[name], enumerable: true });
16
+ };
17
+
18
+ // solana/index.ts
19
+ var solana_exports = {};
20
+ __export(solana_exports, {
21
+ AnchorErrorCode: () => AnchorErrorCode,
22
+ ClaimStatus: () => ClaimStatus,
23
+ ContractErrorCode: () => ContractErrorCode,
24
+ MerkleDistributor: () => MerkleDistributor,
25
+ SolanaAlignedDistributorClient: () => SolanaAlignedDistributorClient,
26
+ SolanaDistributorClient: () => SolanaDistributorClient,
27
+ calculateAmountWithTransferFees: () => calculateAmountWithTransferFees,
28
+ claimLocked: () => claimLocked,
29
+ clawback: () => clawback,
30
+ closeClaim: () => closeClaim,
31
+ constants: () => constants_exports,
32
+ fromCode: () => fromCode3,
33
+ fromTxError: () => fromTxError,
34
+ getAlignedDistributorPda: () => getAlignedDistributorPda,
35
+ getClaimantStatusPda: () => getClaimantStatusPda,
36
+ getDistributorPda: () => getDistributorPda,
37
+ getEventAuthorityPda: () => getEventAuthorityPda,
38
+ getTestOraclePda: () => getTestOraclePda,
39
+ newClaim: () => newClaim,
40
+ newDistributor: () => newDistributor,
41
+ setAdmin: () => setAdmin,
42
+ setClawbackReceiver: () => setClawbackReceiver,
43
+ wrappedSignAndExecuteTransaction: () => wrappedSignAndExecuteTransaction
44
+ });
45
+ var AnchorErrorCode = /* @__PURE__ */ ((AnchorErrorCode2) => {
46
+ AnchorErrorCode2["InstructionMissing"] = "InstructionMissing";
47
+ AnchorErrorCode2["InstructionFallbackNotFound"] = "InstructionFallbackNotFound";
48
+ AnchorErrorCode2["InstructionDidNotDeserialize"] = "InstructionDidNotDeserialize";
49
+ AnchorErrorCode2["InstructionDidNotSerialize"] = "InstructionDidNotSerialize";
50
+ AnchorErrorCode2["IdlInstructionStub"] = "IdlInstructionStub";
51
+ AnchorErrorCode2["IdlInstructionInvalidProgram"] = "IdlInstructionInvalidProgram";
52
+ AnchorErrorCode2["ConstraintMut"] = "ConstraintMut";
53
+ AnchorErrorCode2["ConstraintHasOne"] = "ConstraintHasOne";
54
+ AnchorErrorCode2["ConstraintSigner"] = "ConstraintSigner";
55
+ AnchorErrorCode2["ConstraintRaw"] = "ConstraintRaw";
56
+ AnchorErrorCode2["ConstraintOwner"] = "ConstraintOwner";
57
+ AnchorErrorCode2["ConstraintRentExempt"] = "ConstraintRentExempt";
58
+ AnchorErrorCode2["ConstraintSeeds"] = "ConstraintSeeds";
59
+ AnchorErrorCode2["ConstraintExecutable"] = "ConstraintExecutable";
60
+ AnchorErrorCode2["ConstraintState"] = "ConstraintState";
61
+ AnchorErrorCode2["ConstraintAssociated"] = "ConstraintAssociated";
62
+ AnchorErrorCode2["ConstraintAssociatedInit"] = "ConstraintAssociatedInit";
63
+ AnchorErrorCode2["ConstraintClose"] = "ConstraintClose";
64
+ AnchorErrorCode2["ConstraintAddress"] = "ConstraintAddress";
65
+ AnchorErrorCode2["ConstraintZero"] = "ConstraintZero";
66
+ AnchorErrorCode2["ConstraintTokenMint"] = "ConstraintTokenMint";
67
+ AnchorErrorCode2["ConstraintTokenOwner"] = "ConstraintTokenOwner";
68
+ AnchorErrorCode2["ConstraintMintMintAuthority"] = "ConstraintMintMintAuthority";
69
+ AnchorErrorCode2["ConstraintMintFreezeAuthority"] = "ConstraintMintFreezeAuthority";
70
+ AnchorErrorCode2["ConstraintMintDecimals"] = "ConstraintMintDecimals";
71
+ AnchorErrorCode2["ConstraintSpace"] = "ConstraintSpace";
72
+ AnchorErrorCode2["ConstraintAccountIsNone"] = "ConstraintAccountIsNone";
73
+ AnchorErrorCode2["RequireViolated"] = "RequireViolated";
74
+ AnchorErrorCode2["RequireEqViolated"] = "RequireEqViolated";
75
+ AnchorErrorCode2["RequireKeysEqViolated"] = "RequireKeysEqViolated";
76
+ AnchorErrorCode2["RequireNeqViolated"] = "RequireNeqViolated";
77
+ AnchorErrorCode2["RequireKeysNeqViolated"] = "RequireKeysNeqViolated";
78
+ AnchorErrorCode2["RequireGtViolated"] = "RequireGtViolated";
79
+ AnchorErrorCode2["RequireGteViolated"] = "RequireGteViolated";
80
+ AnchorErrorCode2["AccountDiscriminatorAlreadySet"] = "AccountDiscriminatorAlreadySet";
81
+ AnchorErrorCode2["AccountDiscriminatorNotFound"] = "AccountDiscriminatorNotFound";
82
+ AnchorErrorCode2["AccountDiscriminatorMismatch"] = "AccountDiscriminatorMismatch";
83
+ AnchorErrorCode2["AccountDidNotDeserialize"] = "AccountDidNotDeserialize";
84
+ AnchorErrorCode2["AccountDidNotSerialize"] = "AccountDidNotSerialize";
85
+ AnchorErrorCode2["AccountNotEnoughKeys"] = "AccountNotEnoughKeys";
86
+ AnchorErrorCode2["AccountNotMutable"] = "AccountNotMutable";
87
+ AnchorErrorCode2["AccountOwnedByWrongProgram"] = "AccountOwnedByWrongProgram";
88
+ AnchorErrorCode2["InvalidProgramId"] = "InvalidProgramId";
89
+ AnchorErrorCode2["InvalidProgramExecutable"] = "InvalidProgramExecutable";
90
+ AnchorErrorCode2["AccountNotSigner"] = "AccountNotSigner";
91
+ AnchorErrorCode2["AccountNotSystemOwned"] = "AccountNotSystemOwned";
92
+ AnchorErrorCode2["AccountNotInitialized"] = "AccountNotInitialized";
93
+ AnchorErrorCode2["AccountNotProgramData"] = "AccountNotProgramData";
94
+ AnchorErrorCode2["AccountNotAssociatedTokenAccount"] = "AccountNotAssociatedTokenAccount";
95
+ AnchorErrorCode2["AccountSysvarMismatch"] = "AccountSysvarMismatch";
96
+ AnchorErrorCode2["AccountReallocExceedsLimit"] = "AccountReallocExceedsLimit";
97
+ AnchorErrorCode2["AccountDuplicateReallocs"] = "AccountDuplicateReallocs";
98
+ AnchorErrorCode2["DeclaredProgramIdMismatch"] = "DeclaredProgramIdMismatch";
99
+ AnchorErrorCode2["Deprecated"] = "Deprecated";
100
+ return AnchorErrorCode2;
101
+ })(AnchorErrorCode || {});
102
+ var ContractErrorCode = /* @__PURE__ */ ((ContractErrorCode2) => {
103
+ ContractErrorCode2["InsufficientUnlockedTokens"] = "InsufficientUnlockedTokens";
104
+ ContractErrorCode2["StartTooFarInFuture"] = "StartTooFarInFuture";
105
+ ContractErrorCode2["InvalidProof"] = "InvalidProof";
106
+ ContractErrorCode2["ExceededMaxClaim"] = "ExceededMaxClaim";
107
+ ContractErrorCode2["MaxNodesExceeded"] = "MaxNodesExceeded";
108
+ ContractErrorCode2["Unauthorized"] = "Unauthorized";
109
+ ContractErrorCode2["OwnerMismatch"] = "OwnerMismatch";
110
+ ContractErrorCode2["ClawbackBeforeVesting"] = "ClawbackBeforeVesting";
111
+ ContractErrorCode2["ClawbackBeforeStart"] = "ClawbackBeforeStart";
112
+ ContractErrorCode2["ClawbackAlreadyClaimed"] = "ClawbackAlreadyClaimed";
113
+ ContractErrorCode2["InsufficientClawbackDelay"] = "InsufficientClawbackDelay";
114
+ ContractErrorCode2["SameClawbackReceiver"] = "SameClawbackReceiver";
115
+ ContractErrorCode2["SameAdmin"] = "SameAdmin";
116
+ ContractErrorCode2["ClaimExpired"] = "ClaimExpired";
117
+ ContractErrorCode2["ArithmeticError"] = "ArithmeticError";
118
+ ContractErrorCode2["StartTimestampAfterEnd"] = "StartTimestampAfterEnd";
119
+ ContractErrorCode2["TimestampsNotInFuture"] = "TimestampsNotInFuture";
120
+ ContractErrorCode2["InvalidVersion"] = "InvalidVersion";
121
+ ContractErrorCode2["InvalidMint"] = "InvalidMint";
122
+ ContractErrorCode2["ClaimIsClosed"] = "ClaimIsClosed";
123
+ ContractErrorCode2["ClaimsAreNotClosable"] = "ClaimsAreNotClosable";
124
+ return ContractErrorCode2;
125
+ })(ContractErrorCode || {});
126
+ var PROGRAM_ID_CLI = new PublicKey("MErKy6nZVoVAkryxAejJz2juifQ4ArgLgHmaJCQkU7N");
127
+ var PROGRAM_ID = PROGRAM_ID_CLI;
128
+
129
+ // solana/generated/instructions/newDistributor.ts
130
+ var layout = borsh8.struct([
131
+ borsh8.u64("version"),
132
+ borsh8.array(borsh8.u8(), 32, "root"),
133
+ borsh8.u64("maxTotalClaim"),
134
+ borsh8.u64("maxNumNodes"),
135
+ borsh8.u64("unlockPeriod"),
136
+ borsh8.u64("startVestingTs"),
137
+ borsh8.u64("endVestingTs"),
138
+ borsh8.u64("clawbackStartTs"),
139
+ borsh8.bool("claimsClosableByAdmin"),
140
+ borsh8.option(borsh8.bool(), "canUpdateDuration"),
141
+ borsh8.option(borsh8.u64(), "totalAmountUnlocked"),
142
+ borsh8.option(borsh8.u64(), "totalAmountLocked"),
143
+ borsh8.option(borsh8.bool(), "claimsClosableByClaimant"),
144
+ borsh8.option(borsh8.u16(), "claimsLimit")
145
+ ]);
146
+ function newDistributor(args, accounts, programId = PROGRAM_ID) {
147
+ const keys = [
148
+ { pubkey: accounts.distributor, isSigner: false, isWritable: true },
149
+ { pubkey: accounts.clawbackReceiver, isSigner: false, isWritable: true },
150
+ { pubkey: accounts.mint, isSigner: false, isWritable: false },
151
+ { pubkey: accounts.tokenVault, isSigner: false, isWritable: true },
152
+ { pubkey: accounts.admin, isSigner: true, isWritable: true },
153
+ { pubkey: accounts.systemProgram, isSigner: false, isWritable: false },
154
+ {
155
+ pubkey: accounts.associatedTokenProgram,
156
+ isSigner: false,
157
+ isWritable: false
158
+ },
159
+ { pubkey: accounts.tokenProgram, isSigner: false, isWritable: false }
160
+ ];
161
+ const identifier = Buffer$1.from([32, 139, 112, 171, 0, 2, 225, 155]);
162
+ const buffer = Buffer$1.alloc(1e3);
163
+ const len = layout.encode(
164
+ {
165
+ version: args.version,
166
+ root: args.root,
167
+ maxTotalClaim: args.maxTotalClaim,
168
+ maxNumNodes: args.maxNumNodes,
169
+ unlockPeriod: args.unlockPeriod,
170
+ startVestingTs: args.startVestingTs,
171
+ endVestingTs: args.endVestingTs,
172
+ clawbackStartTs: args.clawbackStartTs,
173
+ claimsClosableByAdmin: args.claimsClosableByAdmin,
174
+ canUpdateDuration: null,
175
+ totalAmountUnlocked: null,
176
+ totalAmountLocked: null,
177
+ claimsClosableByClaimant: args.claimsClosableByClaimant ?? null,
178
+ claimsLimit: args.claimsLimit ?? null
179
+ },
180
+ buffer
181
+ );
182
+ const data = Buffer$1.concat([identifier, buffer]).slice(0, 8 + len);
183
+ const ix = new TransactionInstruction({ keys, programId, data });
184
+ return ix;
185
+ }
186
+ var layout2 = borsh8.struct([
187
+ borsh8.u64("amountUnlocked"),
188
+ borsh8.u64("amountLocked"),
189
+ borsh8.vec(borsh8.array(borsh8.u8(), 32), "proof")
190
+ ]);
191
+ function newClaim(args, accounts, programId = PROGRAM_ID) {
192
+ const keys = [
193
+ { pubkey: accounts.distributor, isSigner: false, isWritable: true },
194
+ { pubkey: accounts.claimStatus, isSigner: false, isWritable: true },
195
+ { pubkey: accounts.from, isSigner: false, isWritable: true },
196
+ { pubkey: accounts.to, isSigner: false, isWritable: true },
197
+ { pubkey: accounts.claimant, isSigner: true, isWritable: true },
198
+ { pubkey: accounts.mint, isSigner: false, isWritable: false },
199
+ { pubkey: accounts.tokenProgram, isSigner: false, isWritable: false },
200
+ { pubkey: accounts.systemProgram, isSigner: false, isWritable: false },
201
+ { pubkey: accounts.eventAuthority, isSigner: false, isWritable: false },
202
+ { pubkey: accounts.program, isSigner: false, isWritable: false }
203
+ ];
204
+ const identifier = Buffer.from([78, 177, 98, 123, 210, 21, 187, 83]);
205
+ const buffer = Buffer.alloc(1e3);
206
+ const len = layout2.encode(
207
+ {
208
+ amountUnlocked: args.amountUnlocked,
209
+ amountLocked: args.amountLocked,
210
+ proof: args.proof
211
+ },
212
+ buffer
213
+ );
214
+ const data = Buffer.concat([identifier, buffer]).slice(0, 8 + len);
215
+ const ix = new TransactionInstruction({ keys, programId, data });
216
+ return ix;
217
+ }
218
+ function claimLocked(accounts, programId = PROGRAM_ID) {
219
+ const keys = [
220
+ { pubkey: accounts.distributor, isSigner: false, isWritable: true },
221
+ { pubkey: accounts.claimStatus, isSigner: false, isWritable: true },
222
+ { pubkey: accounts.from, isSigner: false, isWritable: true },
223
+ { pubkey: accounts.to, isSigner: false, isWritable: true },
224
+ { pubkey: accounts.claimant, isSigner: true, isWritable: true },
225
+ { pubkey: accounts.mint, isSigner: false, isWritable: false },
226
+ { pubkey: accounts.tokenProgram, isSigner: false, isWritable: false },
227
+ { pubkey: accounts.eventAuthority, isSigner: false, isWritable: false },
228
+ { pubkey: accounts.program, isSigner: false, isWritable: false }
229
+ ];
230
+ const identifier = Buffer.from([34, 206, 181, 23, 11, 207, 147, 90]);
231
+ const data = identifier;
232
+ const ix = new TransactionInstruction({ keys, programId, data });
233
+ return ix;
234
+ }
235
+ function clawback(accounts, programId = PROGRAM_ID) {
236
+ const keys = [
237
+ { pubkey: accounts.distributor, isSigner: false, isWritable: true },
238
+ { pubkey: accounts.from, isSigner: false, isWritable: true },
239
+ { pubkey: accounts.to, isSigner: false, isWritable: true },
240
+ { pubkey: accounts.admin, isSigner: true, isWritable: true },
241
+ { pubkey: accounts.mint, isSigner: false, isWritable: false },
242
+ { pubkey: accounts.systemProgram, isSigner: false, isWritable: false },
243
+ { pubkey: accounts.tokenProgram, isSigner: false, isWritable: false }
244
+ ];
245
+ const identifier = Buffer$1.from([111, 92, 142, 79, 33, 234, 82, 27]);
246
+ const data = identifier;
247
+ const ix = new TransactionInstruction({ keys, programId, data });
248
+ return ix;
249
+ }
250
+ var layout3 = borsh8.struct([
251
+ borsh8.option(borsh8.u64(), "amountUnlocked"),
252
+ borsh8.option(borsh8.u64(), "amountLocked"),
253
+ borsh8.option(borsh8.vec(borsh8.array(borsh8.u8(), 32)), "proof")
254
+ ]);
255
+ function closeClaim(args, accounts, programId = PROGRAM_ID) {
256
+ const keys = [
257
+ { pubkey: accounts.distributor, isSigner: false, isWritable: true },
258
+ { pubkey: accounts.adminOrClaimant, isSigner: true, isWritable: true },
259
+ { pubkey: accounts.claimant, isSigner: false, isWritable: false },
260
+ { pubkey: accounts.claimStatus, isSigner: false, isWritable: true },
261
+ { pubkey: accounts.systemProgram, isSigner: false, isWritable: false },
262
+ { pubkey: accounts.eventAuthority, isSigner: false, isWritable: false },
263
+ { pubkey: accounts.program, isSigner: false, isWritable: false }
264
+ ];
265
+ const identifier = Buffer$1.from([42, 177, 165, 35, 213, 179, 211, 19]);
266
+ const buffer = Buffer$1.alloc(1e3);
267
+ const len = layout3.encode(
268
+ {
269
+ amountUnlocked: args.amountUnlocked ?? null,
270
+ amountLocked: args.amountLocked ?? null,
271
+ proof: args.proof ?? null
272
+ },
273
+ buffer
274
+ );
275
+ const data = Buffer$1.concat([identifier, buffer]).slice(0, 8 + len);
276
+ const ix = new TransactionInstruction({ keys, programId, data });
277
+ return ix;
278
+ }
279
+ function setClawbackReceiver(accounts, programId = PROGRAM_ID) {
280
+ const keys = [
281
+ { pubkey: accounts.distributor, isSigner: false, isWritable: true },
282
+ { pubkey: accounts.newClawbackAccount, isSigner: false, isWritable: false },
283
+ { pubkey: accounts.admin, isSigner: true, isWritable: true }
284
+ ];
285
+ const identifier = Buffer$1.from([153, 217, 34, 20, 19, 29, 229, 75]);
286
+ const data = identifier;
287
+ const ix = new TransactionInstruction({ keys, programId, data });
288
+ return ix;
289
+ }
290
+ function setAdmin(accounts, programId = PROGRAM_ID) {
291
+ const keys = [
292
+ { pubkey: accounts.distributor, isSigner: false, isWritable: true },
293
+ { pubkey: accounts.admin, isSigner: true, isWritable: true },
294
+ { pubkey: accounts.newAdmin, isSigner: false, isWritable: true }
295
+ ];
296
+ const identifier = Buffer$1.from([251, 163, 0, 52, 91, 194, 187, 92]);
297
+ const data = identifier;
298
+ const ix = new TransactionInstruction({ keys, programId, data });
299
+ return ix;
300
+ }
301
+
302
+ // solana/descriptor/idl/merkle_distributor.json
303
+ var merkle_distributor_default = {
304
+ address: "MErKy6nZVoVAkryxAejJz2juifQ4ArgLgHmaJCQkU7N",
305
+ metadata: {
306
+ name: "merkle_distributor",
307
+ version: "1.5.0",
308
+ spec: "0.1.0",
309
+ description: "A Solana program for distributing tokens according to a Merkle root.",
310
+ repository: "https://github.com/streamflow-finance/distributor"
311
+ },
312
+ instructions: [
313
+ {
314
+ name: "_expose_claim",
315
+ discriminator: [103, 233, 83, 69, 115, 199, 128, 249],
316
+ accounts: [
317
+ {
318
+ name: "distributor",
319
+ docs: ["The [MerkleDistributor]."]
320
+ },
321
+ {
322
+ name: "claim_status",
323
+ docs: ["Claim Status PDA"],
324
+ optional: true,
325
+ pda: {
326
+ seeds: [
327
+ {
328
+ kind: "const",
329
+ value: [67, 108, 97, 105, 109, 83, 116, 97, 116, 117, 115]
330
+ },
331
+ {
332
+ kind: "account",
333
+ path: "claimant"
334
+ },
335
+ {
336
+ kind: "account",
337
+ path: "distributor"
338
+ }
339
+ ]
340
+ }
341
+ },
342
+ {
343
+ name: "compressed_claim_status",
344
+ docs: ["Compress Claim Status PDA"],
345
+ optional: true,
346
+ pda: {
347
+ seeds: [
348
+ {
349
+ kind: "const",
350
+ value: [67, 108, 97, 105, 109, 83, 116, 97, 116, 117, 115]
351
+ },
352
+ {
353
+ kind: "account",
354
+ path: "claimant"
355
+ },
356
+ {
357
+ kind: "account",
358
+ path: "distributor"
359
+ }
360
+ ]
361
+ }
362
+ },
363
+ {
364
+ name: "claimant",
365
+ docs: ["Who is claiming the tokens."],
366
+ signer: true
367
+ }
368
+ ],
369
+ args: []
370
+ },
371
+ {
372
+ name: "claim_locked",
373
+ discriminator: [34, 206, 181, 23, 11, 207, 147, 90],
374
+ accounts: [
375
+ {
376
+ name: "distributor",
377
+ docs: ["The [MerkleDistributor]."],
378
+ writable: true
379
+ },
380
+ {
381
+ name: "claim_status",
382
+ writable: true,
383
+ pda: {
384
+ seeds: [
385
+ {
386
+ kind: "const",
387
+ value: [67, 108, 97, 105, 109, 83, 116, 97, 116, 117, 115]
388
+ },
389
+ {
390
+ kind: "account",
391
+ path: "claimant"
392
+ },
393
+ {
394
+ kind: "account",
395
+ path: "distributor"
396
+ }
397
+ ]
398
+ }
399
+ },
400
+ {
401
+ name: "from",
402
+ docs: ["Distributor ATA containing the tokens to distribute."],
403
+ writable: true,
404
+ pda: {
405
+ seeds: [
406
+ {
407
+ kind: "account",
408
+ path: "distributor"
409
+ },
410
+ {
411
+ kind: "account",
412
+ path: "token_program"
413
+ },
414
+ {
415
+ kind: "account",
416
+ path: "distributor.mint",
417
+ account: "MerkleDistributor"
418
+ }
419
+ ],
420
+ program: {
421
+ kind: "const",
422
+ value: [
423
+ 140,
424
+ 151,
425
+ 37,
426
+ 143,
427
+ 78,
428
+ 36,
429
+ 137,
430
+ 241,
431
+ 187,
432
+ 61,
433
+ 16,
434
+ 41,
435
+ 20,
436
+ 142,
437
+ 13,
438
+ 131,
439
+ 11,
440
+ 90,
441
+ 19,
442
+ 153,
443
+ 218,
444
+ 255,
445
+ 16,
446
+ 132,
447
+ 4,
448
+ 142,
449
+ 123,
450
+ 216,
451
+ 219,
452
+ 233,
453
+ 248,
454
+ 89
455
+ ]
456
+ }
457
+ }
458
+ },
459
+ {
460
+ name: "to",
461
+ docs: [
462
+ "Account to send the claimed tokens to.",
463
+ "Claimant must sign the transaction and can only claim on behalf of themself"
464
+ ],
465
+ writable: true
466
+ },
467
+ {
468
+ name: "claimant",
469
+ docs: ["Who is claiming the tokens."],
470
+ writable: true,
471
+ signer: true
472
+ },
473
+ {
474
+ name: "mint",
475
+ docs: ["The mint to claim."],
476
+ relations: ["distributor"]
477
+ },
478
+ {
479
+ name: "token_program",
480
+ docs: ["SPL [Token] program."]
481
+ },
482
+ {
483
+ name: "event_authority",
484
+ pda: {
485
+ seeds: [
486
+ {
487
+ kind: "const",
488
+ value: [95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, 114, 105, 116, 121]
489
+ }
490
+ ]
491
+ }
492
+ },
493
+ {
494
+ name: "program"
495
+ }
496
+ ],
497
+ args: []
498
+ },
499
+ {
500
+ name: "clawback",
501
+ discriminator: [111, 92, 142, 79, 33, 234, 82, 27],
502
+ accounts: [
503
+ {
504
+ name: "distributor",
505
+ docs: ["The [MerkleDistributor]."],
506
+ writable: true
507
+ },
508
+ {
509
+ name: "from",
510
+ docs: ["Distributor ATA containing the tokens to distribute."],
511
+ writable: true
512
+ },
513
+ {
514
+ name: "to",
515
+ docs: ["The Clawback token account."],
516
+ writable: true
517
+ },
518
+ {
519
+ name: "admin",
520
+ docs: ["Only Admin can trigger the clawback of funds"],
521
+ writable: true,
522
+ signer: true
523
+ },
524
+ {
525
+ name: "mint"
526
+ },
527
+ {
528
+ name: "system_program",
529
+ docs: ["The [System] program."],
530
+ address: "11111111111111111111111111111111"
531
+ },
532
+ {
533
+ name: "token_program",
534
+ docs: ["SPL [Token] program."]
535
+ }
536
+ ],
537
+ args: []
538
+ },
539
+ {
540
+ name: "close_claim",
541
+ discriminator: [42, 177, 165, 35, 213, 179, 211, 19],
542
+ accounts: [
543
+ {
544
+ name: "distributor",
545
+ docs: ["The [MerkleDistributor]."],
546
+ writable: true
547
+ },
548
+ {
549
+ name: "admin_or_claimant",
550
+ docs: ["Admin signer"],
551
+ writable: true,
552
+ signer: true
553
+ },
554
+ {
555
+ name: "claimant",
556
+ writable: true
557
+ },
558
+ {
559
+ name: "claim_status",
560
+ writable: true,
561
+ pda: {
562
+ seeds: [
563
+ {
564
+ kind: "const",
565
+ value: [67, 108, 97, 105, 109, 83, 116, 97, 116, 117, 115]
566
+ },
567
+ {
568
+ kind: "account",
569
+ path: "claimant"
570
+ },
571
+ {
572
+ kind: "account",
573
+ path: "distributor"
574
+ }
575
+ ]
576
+ }
577
+ },
578
+ {
579
+ name: "system_program",
580
+ docs: ["The [System] program."],
581
+ address: "11111111111111111111111111111111"
582
+ },
583
+ {
584
+ name: "event_authority",
585
+ pda: {
586
+ seeds: [
587
+ {
588
+ kind: "const",
589
+ value: [95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, 114, 105, 116, 121]
590
+ }
591
+ ]
592
+ }
593
+ },
594
+ {
595
+ name: "program"
596
+ }
597
+ ],
598
+ args: [
599
+ {
600
+ name: "amount_unlocked",
601
+ type: {
602
+ option: "u64"
603
+ }
604
+ },
605
+ {
606
+ name: "amount_locked",
607
+ type: {
608
+ option: "u64"
609
+ }
610
+ },
611
+ {
612
+ name: "proof",
613
+ type: {
614
+ option: {
615
+ vec: {
616
+ array: ["u8", 32]
617
+ }
618
+ }
619
+ }
620
+ }
621
+ ]
622
+ },
623
+ {
624
+ name: "compress_claim",
625
+ discriminator: [219, 45, 247, 134, 71, 119, 125, 89],
626
+ accounts: [
627
+ {
628
+ name: "distributor",
629
+ docs: ["The [MerkleDistributor]."],
630
+ writable: true
631
+ },
632
+ {
633
+ name: "claim_status",
634
+ writable: true,
635
+ pda: {
636
+ seeds: [
637
+ {
638
+ kind: "const",
639
+ value: [67, 108, 97, 105, 109, 83, 116, 97, 116, 117, 115]
640
+ },
641
+ {
642
+ kind: "account",
643
+ path: "claimant"
644
+ },
645
+ {
646
+ kind: "account",
647
+ path: "distributor"
648
+ }
649
+ ]
650
+ }
651
+ },
652
+ {
653
+ name: "signer",
654
+ docs: ["Signer account"],
655
+ writable: true,
656
+ signer: true
657
+ },
658
+ {
659
+ name: "claimant"
660
+ },
661
+ {
662
+ name: "system_program",
663
+ docs: ["The [System] program."],
664
+ address: "11111111111111111111111111111111"
665
+ }
666
+ ],
667
+ args: []
668
+ },
669
+ {
670
+ name: "new_claim",
671
+ discriminator: [78, 177, 98, 123, 210, 21, 187, 83],
672
+ accounts: [
673
+ {
674
+ name: "distributor",
675
+ docs: ["The [MerkleDistributor]."],
676
+ writable: true
677
+ },
678
+ {
679
+ name: "claim_status",
680
+ writable: true,
681
+ pda: {
682
+ seeds: [
683
+ {
684
+ kind: "const",
685
+ value: [67, 108, 97, 105, 109, 83, 116, 97, 116, 117, 115]
686
+ },
687
+ {
688
+ kind: "account",
689
+ path: "claimant"
690
+ },
691
+ {
692
+ kind: "account",
693
+ path: "distributor"
694
+ }
695
+ ]
696
+ }
697
+ },
698
+ {
699
+ name: "from",
700
+ docs: ["Distributor ATA containing the tokens to distribute."],
701
+ writable: true,
702
+ pda: {
703
+ seeds: [
704
+ {
705
+ kind: "account",
706
+ path: "distributor"
707
+ },
708
+ {
709
+ kind: "account",
710
+ path: "token_program"
711
+ },
712
+ {
713
+ kind: "account",
714
+ path: "distributor.mint",
715
+ account: "MerkleDistributor"
716
+ }
717
+ ],
718
+ program: {
719
+ kind: "const",
720
+ value: [
721
+ 140,
722
+ 151,
723
+ 37,
724
+ 143,
725
+ 78,
726
+ 36,
727
+ 137,
728
+ 241,
729
+ 187,
730
+ 61,
731
+ 16,
732
+ 41,
733
+ 20,
734
+ 142,
735
+ 13,
736
+ 131,
737
+ 11,
738
+ 90,
739
+ 19,
740
+ 153,
741
+ 218,
742
+ 255,
743
+ 16,
744
+ 132,
745
+ 4,
746
+ 142,
747
+ 123,
748
+ 216,
749
+ 219,
750
+ 233,
751
+ 248,
752
+ 89
753
+ ]
754
+ }
755
+ }
756
+ },
757
+ {
758
+ name: "to",
759
+ docs: ["Account to send the claimed tokens to."],
760
+ writable: true
761
+ },
762
+ {
763
+ name: "claimant",
764
+ docs: ["Who is claiming the tokens."],
765
+ writable: true,
766
+ signer: true
767
+ },
768
+ {
769
+ name: "mint",
770
+ docs: ["The mint to claim."],
771
+ relations: ["distributor"]
772
+ },
773
+ {
774
+ name: "token_program",
775
+ docs: ["SPL [Token] program."]
776
+ },
777
+ {
778
+ name: "system_program",
779
+ docs: ["The [System] program."],
780
+ address: "11111111111111111111111111111111"
781
+ },
782
+ {
783
+ name: "event_authority",
784
+ pda: {
785
+ seeds: [
786
+ {
787
+ kind: "const",
788
+ value: [95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, 114, 105, 116, 121]
789
+ }
790
+ ]
791
+ }
792
+ },
793
+ {
794
+ name: "program"
795
+ }
796
+ ],
797
+ args: [
798
+ {
799
+ name: "amount_unlocked",
800
+ type: "u64"
801
+ },
802
+ {
803
+ name: "amount_locked",
804
+ type: "u64"
805
+ },
806
+ {
807
+ name: "proof",
808
+ type: {
809
+ vec: {
810
+ array: ["u8", 32]
811
+ }
812
+ }
813
+ }
814
+ ]
815
+ },
816
+ {
817
+ name: "new_distributor",
818
+ docs: [
819
+ "READ THE FOLLOWING:",
820
+ "",
821
+ "This instruction is susceptible to frontrunning that could result in loss of funds if not handled properly.",
822
+ "",
823
+ "An attack could look like:",
824
+ "- A legitimate user opens a new distributor.",
825
+ "- Someone observes the call to this instruction.",
826
+ "- They replace the clawback_receiver, admin, or time parameters with their own.",
827
+ "",
828
+ "One situation that could happen here is the attacker replaces the admin and clawback_receiver with their own",
829
+ "and sets the clawback_start_ts with the minimal time allowed. After clawback_start_ts has elapsed,",
830
+ "the attacker can steal all funds from the distributor to their own clawback_receiver account.",
831
+ "",
832
+ "HOW TO AVOID:",
833
+ "- When you call into this instruction, ensure your transaction succeeds.",
834
+ "- To be extra safe, after your transaction succeeds, read back the state of the created MerkleDistributor account and",
835
+ "assert the parameters are what you expect, most importantly the clawback_receiver and admin.",
836
+ "- If your transaction fails, double check the value on-chain matches what you expect."
837
+ ],
838
+ discriminator: [32, 139, 112, 171, 0, 2, 225, 155],
839
+ accounts: [
840
+ {
841
+ name: "distributor",
842
+ docs: ["[MerkleDistributor]."],
843
+ writable: true,
844
+ pda: {
845
+ seeds: [
846
+ {
847
+ kind: "const",
848
+ value: [77, 101, 114, 107, 108, 101, 68, 105, 115, 116, 114, 105, 98, 117, 116, 111, 114]
849
+ },
850
+ {
851
+ kind: "account",
852
+ path: "mint"
853
+ },
854
+ {
855
+ kind: "arg",
856
+ path: "version"
857
+ }
858
+ ]
859
+ }
860
+ },
861
+ {
862
+ name: "clawback_receiver",
863
+ docs: ["Clawback receiver token account"],
864
+ writable: true
865
+ },
866
+ {
867
+ name: "mint",
868
+ docs: ["The mint to distribute."]
869
+ },
870
+ {
871
+ name: "token_vault",
872
+ docs: ["Token vault"],
873
+ writable: true,
874
+ pda: {
875
+ seeds: [
876
+ {
877
+ kind: "account",
878
+ path: "distributor"
879
+ },
880
+ {
881
+ kind: "account",
882
+ path: "token_program"
883
+ },
884
+ {
885
+ kind: "account",
886
+ path: "mint"
887
+ }
888
+ ],
889
+ program: {
890
+ kind: "const",
891
+ value: [
892
+ 140,
893
+ 151,
894
+ 37,
895
+ 143,
896
+ 78,
897
+ 36,
898
+ 137,
899
+ 241,
900
+ 187,
901
+ 61,
902
+ 16,
903
+ 41,
904
+ 20,
905
+ 142,
906
+ 13,
907
+ 131,
908
+ 11,
909
+ 90,
910
+ 19,
911
+ 153,
912
+ 218,
913
+ 255,
914
+ 16,
915
+ 132,
916
+ 4,
917
+ 142,
918
+ 123,
919
+ 216,
920
+ 219,
921
+ 233,
922
+ 248,
923
+ 89
924
+ ]
925
+ }
926
+ }
927
+ },
928
+ {
929
+ name: "admin",
930
+ docs: [
931
+ "Admin wallet, responsible for creating the distributor and paying for the transaction.",
932
+ "Also has the authority to set the clawback receiver and change itself."
933
+ ],
934
+ writable: true,
935
+ signer: true
936
+ },
937
+ {
938
+ name: "system_program",
939
+ docs: ["The [System] program."],
940
+ address: "11111111111111111111111111111111"
941
+ },
942
+ {
943
+ name: "associated_token_program",
944
+ docs: ["The [Associated Token] program."],
945
+ address: "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"
946
+ },
947
+ {
948
+ name: "token_program",
949
+ docs: ["The [Token] program."]
950
+ }
951
+ ],
952
+ args: [
953
+ {
954
+ name: "version",
955
+ type: "u64"
956
+ },
957
+ {
958
+ name: "root",
959
+ type: {
960
+ array: ["u8", 32]
961
+ }
962
+ },
963
+ {
964
+ name: "max_total_claim",
965
+ type: "u64"
966
+ },
967
+ {
968
+ name: "max_num_nodes",
969
+ type: "u64"
970
+ },
971
+ {
972
+ name: "unlock_period",
973
+ type: "u64"
974
+ },
975
+ {
976
+ name: "start_vesting_ts",
977
+ type: "u64"
978
+ },
979
+ {
980
+ name: "end_vesting_ts",
981
+ type: "u64"
982
+ },
983
+ {
984
+ name: "clawback_start_ts",
985
+ type: "u64"
986
+ },
987
+ {
988
+ name: "claims_closable_by_admin",
989
+ type: "bool"
990
+ },
991
+ {
992
+ name: "can_update_duration",
993
+ type: {
994
+ option: "bool"
995
+ }
996
+ },
997
+ {
998
+ name: "total_amount_unlocked",
999
+ type: {
1000
+ option: "u64"
1001
+ }
1002
+ },
1003
+ {
1004
+ name: "total_amount_locked",
1005
+ type: {
1006
+ option: "u64"
1007
+ }
1008
+ },
1009
+ {
1010
+ name: "claims_closable_by_claimant",
1011
+ type: {
1012
+ option: "bool"
1013
+ }
1014
+ },
1015
+ {
1016
+ name: "claims_limit",
1017
+ type: {
1018
+ option: "u16"
1019
+ }
1020
+ }
1021
+ ]
1022
+ },
1023
+ {
1024
+ name: "refund_claim",
1025
+ discriminator: [157, 23, 164, 146, 176, 53, 147, 143],
1026
+ accounts: [
1027
+ {
1028
+ name: "distributor",
1029
+ docs: ["The [MerkleDistributor]."],
1030
+ writable: true
1031
+ },
1032
+ {
1033
+ name: "claim_status",
1034
+ writable: true,
1035
+ pda: {
1036
+ seeds: [
1037
+ {
1038
+ kind: "const",
1039
+ value: [67, 108, 97, 105, 109, 83, 116, 97, 116, 117, 115]
1040
+ },
1041
+ {
1042
+ kind: "account",
1043
+ path: "claimant"
1044
+ },
1045
+ {
1046
+ kind: "account",
1047
+ path: "distributor"
1048
+ }
1049
+ ]
1050
+ }
1051
+ },
1052
+ {
1053
+ name: "signer",
1054
+ docs: ["Signer account"],
1055
+ writable: true,
1056
+ signer: true
1057
+ },
1058
+ {
1059
+ name: "claimant"
1060
+ },
1061
+ {
1062
+ name: "streamflow_treasury",
1063
+ writable: true,
1064
+ address: "5SEpbdjFK5FxwTvfsGMXVQTD2v4M2c5tyRTxhdsPkgDw"
1065
+ },
1066
+ {
1067
+ name: "system_program",
1068
+ docs: ["The [System] program."],
1069
+ address: "11111111111111111111111111111111"
1070
+ }
1071
+ ],
1072
+ args: []
1073
+ },
1074
+ {
1075
+ name: "set_admin",
1076
+ discriminator: [251, 163, 0, 52, 91, 194, 187, 92],
1077
+ accounts: [
1078
+ {
1079
+ name: "distributor",
1080
+ docs: ["The [MerkleDistributor]."],
1081
+ writable: true
1082
+ },
1083
+ {
1084
+ name: "admin",
1085
+ docs: ["Admin signer"],
1086
+ writable: true,
1087
+ signer: true
1088
+ },
1089
+ {
1090
+ name: "new_admin",
1091
+ docs: ["New admin account"],
1092
+ writable: true
1093
+ }
1094
+ ],
1095
+ args: []
1096
+ },
1097
+ {
1098
+ name: "set_clawback_receiver",
1099
+ discriminator: [153, 217, 34, 20, 19, 29, 229, 75],
1100
+ accounts: [
1101
+ {
1102
+ name: "distributor",
1103
+ docs: ["The [MerkleDistributor]."],
1104
+ writable: true
1105
+ },
1106
+ {
1107
+ name: "new_clawback_account",
1108
+ docs: ["New clawback account"]
1109
+ },
1110
+ {
1111
+ name: "admin",
1112
+ docs: ["Admin signer"],
1113
+ writable: true,
1114
+ signer: true
1115
+ }
1116
+ ],
1117
+ args: []
1118
+ },
1119
+ {
1120
+ name: "update",
1121
+ discriminator: [219, 200, 88, 176, 158, 63, 253, 127],
1122
+ accounts: [
1123
+ {
1124
+ name: "distributor",
1125
+ docs: ["The [MerkleDistributor]."],
1126
+ writable: true
1127
+ },
1128
+ {
1129
+ name: "admin",
1130
+ docs: ["Only Admin can trigger the clawback of funds"],
1131
+ writable: true,
1132
+ signer: true
1133
+ },
1134
+ {
1135
+ name: "system_program",
1136
+ docs: ["The [System] program."],
1137
+ address: "11111111111111111111111111111111"
1138
+ }
1139
+ ],
1140
+ args: [
1141
+ {
1142
+ name: "end_ts",
1143
+ type: {
1144
+ option: "u64"
1145
+ }
1146
+ }
1147
+ ]
1148
+ }
1149
+ ],
1150
+ accounts: [
1151
+ {
1152
+ name: "ClaimStatus",
1153
+ discriminator: [22, 183, 249, 157, 247, 95, 150, 96]
1154
+ },
1155
+ {
1156
+ name: "CompressedClaimStatus",
1157
+ discriminator: [53, 68, 161, 131, 212, 106, 98, 48]
1158
+ },
1159
+ {
1160
+ name: "MerkleDistributor",
1161
+ discriminator: [77, 119, 139, 70, 84, 247, 12, 26]
1162
+ }
1163
+ ],
1164
+ events: [
1165
+ {
1166
+ name: "ClaimClosedEvent",
1167
+ discriminator: [139, 166, 215, 195, 184, 233, 26, 217]
1168
+ },
1169
+ {
1170
+ name: "ClaimedEvent",
1171
+ discriminator: [144, 172, 209, 86, 144, 87, 84, 115]
1172
+ },
1173
+ {
1174
+ name: "NewClaimEvent",
1175
+ discriminator: [244, 3, 231, 151, 60, 101, 55, 55]
1176
+ }
1177
+ ],
1178
+ errors: [
1179
+ {
1180
+ code: 6e3,
1181
+ name: "InsufficientUnlockedTokens",
1182
+ msg: "Insufficient unlocked tokens"
1183
+ },
1184
+ {
1185
+ code: 6001,
1186
+ name: "InvalidProof",
1187
+ msg: "Invalid Merkle proof"
1188
+ },
1189
+ {
1190
+ code: 6002,
1191
+ name: "ExceededMaxClaim",
1192
+ msg: "Exceeded maximum claim amount"
1193
+ },
1194
+ {
1195
+ code: 6003,
1196
+ name: "MaxNodesExceeded",
1197
+ msg: "Exceeded maximum node count"
1198
+ },
1199
+ {
1200
+ code: 6004,
1201
+ name: "Unauthorized",
1202
+ msg: "Account is not authorized to execute this instruction"
1203
+ },
1204
+ {
1205
+ code: 6005,
1206
+ name: "OwnerMismatch",
1207
+ msg: "Token account owner did not match intended owner"
1208
+ },
1209
+ {
1210
+ code: 6006,
1211
+ name: "ClawbackBeforeStart",
1212
+ msg: "Attempted clawback before start"
1213
+ },
1214
+ {
1215
+ code: 6007,
1216
+ name: "ClawbackAlreadyClaimed",
1217
+ msg: "Clawback already claimed"
1218
+ },
1219
+ {
1220
+ code: 6008,
1221
+ name: "SameClawbackReceiver",
1222
+ msg: "New and old Clawback receivers are identical"
1223
+ },
1224
+ {
1225
+ code: 6009,
1226
+ name: "ClawbackReceiverIsTokenVault",
1227
+ msg: "Clawback receiver can not be the Token Vault"
1228
+ },
1229
+ {
1230
+ code: 6010,
1231
+ name: "SameAdmin",
1232
+ msg: "New and old admin are identical"
1233
+ },
1234
+ {
1235
+ code: 6011,
1236
+ name: "ClaimExpired",
1237
+ msg: "Claim window expired"
1238
+ },
1239
+ {
1240
+ code: 6012,
1241
+ name: "ArithmeticError",
1242
+ msg: "Arithmetic Error (overflow/underflow)"
1243
+ },
1244
+ {
1245
+ code: 6013,
1246
+ name: "StartTimestampAfterEnd",
1247
+ msg: "Start Timestamp cannot be after end Timestamp"
1248
+ },
1249
+ {
1250
+ code: 6014,
1251
+ name: "TimestampsNotInFuture",
1252
+ msg: "Timestamps cannot be in the past"
1253
+ },
1254
+ {
1255
+ code: 6015,
1256
+ name: "InvalidMint",
1257
+ msg: "Invalid Mint"
1258
+ },
1259
+ {
1260
+ code: 6016,
1261
+ name: "ClaimIsClosed",
1262
+ msg: "Claim is closed"
1263
+ },
1264
+ {
1265
+ code: 6017,
1266
+ name: "ClaimsAreNotClosable",
1267
+ msg: "Claims are not closable"
1268
+ },
1269
+ {
1270
+ code: 6018,
1271
+ name: "InvalidUnlockPeriod",
1272
+ msg: "Invalid unlock period"
1273
+ },
1274
+ {
1275
+ code: 6019,
1276
+ name: "DurationUpdateNotAllowed",
1277
+ msg: "Duration update is not allowed"
1278
+ },
1279
+ {
1280
+ code: 6020,
1281
+ name: "NoVestingAmount",
1282
+ msg: "Vesting amounts are not set"
1283
+ },
1284
+ {
1285
+ code: 6021,
1286
+ name: "VestingAlreadyFinished",
1287
+ msg: "Vesting already finished"
1288
+ },
1289
+ {
1290
+ code: 6022,
1291
+ name: "InvalidAmounts",
1292
+ msg: "Provided amounts are invalid"
1293
+ },
1294
+ {
1295
+ code: 6023,
1296
+ name: "ClaimsLimitReached",
1297
+ msg: "Claims limit has been reached"
1298
+ }
1299
+ ],
1300
+ types: [
1301
+ {
1302
+ name: "ClaimClosedEvent",
1303
+ docs: ["Emitted when a new claim is created."],
1304
+ type: {
1305
+ kind: "struct",
1306
+ fields: [
1307
+ {
1308
+ name: "claimant",
1309
+ docs: ["User that claimed."],
1310
+ type: "pubkey"
1311
+ },
1312
+ {
1313
+ name: "timestamp",
1314
+ docs: ["Timestamp."],
1315
+ type: "u64"
1316
+ }
1317
+ ]
1318
+ }
1319
+ },
1320
+ {
1321
+ name: "ClaimStatus",
1322
+ docs: ["Holds whether or not a claimant has claimed tokens."],
1323
+ type: {
1324
+ kind: "struct",
1325
+ fields: [
1326
+ {
1327
+ name: "claimant",
1328
+ docs: ["Authority that claimed the tokens."],
1329
+ type: "pubkey"
1330
+ },
1331
+ {
1332
+ name: "locked_amount",
1333
+ docs: ["Locked amount"],
1334
+ type: "u64"
1335
+ },
1336
+ {
1337
+ name: "locked_amount_withdrawn",
1338
+ docs: ["Locked amount withdrawn"],
1339
+ type: "u64"
1340
+ },
1341
+ {
1342
+ name: "unlocked_amount",
1343
+ docs: ["Unlocked amount"],
1344
+ type: "u64"
1345
+ },
1346
+ {
1347
+ name: "last_claim_ts",
1348
+ docs: ["Last claim time"],
1349
+ type: "u64"
1350
+ },
1351
+ {
1352
+ name: "last_amount_per_unlock",
1353
+ docs: ["Track amount per unlock, can be useful for non-linear vesting"],
1354
+ type: "u64"
1355
+ },
1356
+ {
1357
+ name: "closed",
1358
+ docs: ["Whether claim is closed"],
1359
+ type: "bool"
1360
+ },
1361
+ {
1362
+ name: "distributor",
1363
+ docs: [
1364
+ "Distributor account for which ClaimStatus was created, useful to filter by in get_program_accounts"
1365
+ ],
1366
+ type: "pubkey"
1367
+ },
1368
+ {
1369
+ name: "claims_count",
1370
+ docs: ["Number of time amount has been claimed"],
1371
+ type: "u16"
1372
+ },
1373
+ {
1374
+ name: "closed_ts",
1375
+ docs: ["Time when claim has been closed"],
1376
+ type: "u64"
1377
+ },
1378
+ {
1379
+ name: "buffer_2",
1380
+ docs: ["Buffer for additional fields"],
1381
+ type: {
1382
+ array: ["u8", 22]
1383
+ }
1384
+ }
1385
+ ]
1386
+ }
1387
+ },
1388
+ {
1389
+ name: "ClaimedEvent",
1390
+ docs: ["Emitted when tokens are claimed."],
1391
+ type: {
1392
+ kind: "struct",
1393
+ fields: [
1394
+ {
1395
+ name: "claimant",
1396
+ docs: ["User that claimed."],
1397
+ type: "pubkey"
1398
+ },
1399
+ {
1400
+ name: "amount",
1401
+ docs: ["Amount of tokens to distribute."],
1402
+ type: "u64"
1403
+ }
1404
+ ]
1405
+ }
1406
+ },
1407
+ {
1408
+ name: "CompressedClaimStatus",
1409
+ docs: ["Holds whether or not a claimant has claimed tokens."],
1410
+ type: {
1411
+ kind: "struct",
1412
+ fields: [
1413
+ {
1414
+ name: "state",
1415
+ type: {
1416
+ defined: {
1417
+ name: "State"
1418
+ }
1419
+ }
1420
+ }
1421
+ ]
1422
+ }
1423
+ },
1424
+ {
1425
+ name: "MerkleDistributor",
1426
+ docs: ["State for the account which distributes tokens."],
1427
+ type: {
1428
+ kind: "struct",
1429
+ fields: [
1430
+ {
1431
+ name: "bump",
1432
+ docs: ["Bump seed."],
1433
+ type: "u8"
1434
+ },
1435
+ {
1436
+ name: "version",
1437
+ docs: ["Version of the airdrop"],
1438
+ type: "u64"
1439
+ },
1440
+ {
1441
+ name: "root",
1442
+ docs: ["The 256-bit merkle root."],
1443
+ type: {
1444
+ array: ["u8", 32]
1445
+ }
1446
+ },
1447
+ {
1448
+ name: "mint",
1449
+ docs: ["[Mint] of the token to be distributed."],
1450
+ type: "pubkey"
1451
+ },
1452
+ {
1453
+ name: "token_vault",
1454
+ docs: ["Token Address of the vault"],
1455
+ type: "pubkey"
1456
+ },
1457
+ {
1458
+ name: "max_total_claim",
1459
+ docs: ["Maximum number of tokens that can ever be claimed from this [MerkleDistributor]."],
1460
+ type: "u64"
1461
+ },
1462
+ {
1463
+ name: "max_num_nodes",
1464
+ docs: ["Maximum number of nodes in [MerkleDistributor]."],
1465
+ type: "u64"
1466
+ },
1467
+ {
1468
+ name: "unlock_period",
1469
+ docs: ["Time step (period) in seconds per which the unlock occurs"],
1470
+ type: "u64"
1471
+ },
1472
+ {
1473
+ name: "total_amount_claimed",
1474
+ docs: ["Total amount of tokens that have been claimed."],
1475
+ type: "u64"
1476
+ },
1477
+ {
1478
+ name: "num_nodes_claimed",
1479
+ docs: ["Number of nodes that have been claimed."],
1480
+ type: "u64"
1481
+ },
1482
+ {
1483
+ name: "start_ts",
1484
+ docs: ["Lockup time start (Unix Timestamp)"],
1485
+ type: "u64"
1486
+ },
1487
+ {
1488
+ name: "end_ts",
1489
+ docs: ["Lockup time end (Unix Timestamp)"],
1490
+ type: "u64"
1491
+ },
1492
+ {
1493
+ name: "clawback_start_ts",
1494
+ docs: ["Clawback start (Unix Timestamp)"],
1495
+ type: "u64"
1496
+ },
1497
+ {
1498
+ name: "clawback_receiver",
1499
+ docs: ["Clawback receiver"],
1500
+ type: "pubkey"
1501
+ },
1502
+ {
1503
+ name: "admin",
1504
+ docs: ["Admin wallet"],
1505
+ type: "pubkey"
1506
+ },
1507
+ {
1508
+ name: "clawed_back",
1509
+ docs: ["Whether or not the distributor has been clawed back"],
1510
+ type: "bool"
1511
+ },
1512
+ {
1513
+ name: "claims_closable_by_admin",
1514
+ docs: ["Whether claims are closable by the admin or not"],
1515
+ type: "bool"
1516
+ },
1517
+ {
1518
+ name: "can_update_duration",
1519
+ docs: ["Whether admin can update vesting duration"],
1520
+ type: "bool"
1521
+ },
1522
+ {
1523
+ name: "total_amount_unlocked",
1524
+ docs: ["Total amount of funds unlocked (cliff/instant)"],
1525
+ type: "u64"
1526
+ },
1527
+ {
1528
+ name: "total_amount_locked",
1529
+ docs: ["Total amount of funds locked (vested)"],
1530
+ type: "u64"
1531
+ },
1532
+ {
1533
+ name: "last_duration_update_ts",
1534
+ docs: ["Timestamp when update was last called"],
1535
+ type: "u64"
1536
+ },
1537
+ {
1538
+ name: "total_claimable_pre_update",
1539
+ docs: [
1540
+ "Total amount of locked amount claimable as of last duration update, ever increasing total, accumulates with each update"
1541
+ ],
1542
+ type: "u64"
1543
+ },
1544
+ {
1545
+ name: "clawed_back_ts",
1546
+ docs: ["Timestamp when funds were clawed back"],
1547
+ type: "u64"
1548
+ },
1549
+ {
1550
+ name: "claims_closable_by_claimant",
1551
+ docs: ["Whether claims are closable by claimant or not"],
1552
+ type: "bool"
1553
+ },
1554
+ {
1555
+ name: "claims_limit",
1556
+ docs: ["Limit number of claims"],
1557
+ type: "u16"
1558
+ },
1559
+ {
1560
+ name: "buffer_2",
1561
+ docs: ["Buffer for additional fields"],
1562
+ type: {
1563
+ array: ["u8", 20]
1564
+ }
1565
+ },
1566
+ {
1567
+ name: "buffer_3",
1568
+ docs: ["Buffer for additional fields"],
1569
+ type: {
1570
+ array: ["u8", 32]
1571
+ }
1572
+ }
1573
+ ]
1574
+ }
1575
+ },
1576
+ {
1577
+ name: "NewClaimEvent",
1578
+ docs: ["Emitted when a new claim is created."],
1579
+ type: {
1580
+ kind: "struct",
1581
+ fields: [
1582
+ {
1583
+ name: "claimant",
1584
+ docs: ["User that claimed."],
1585
+ type: "pubkey"
1586
+ },
1587
+ {
1588
+ name: "timestamp",
1589
+ docs: ["Timestamp."],
1590
+ type: "u64"
1591
+ }
1592
+ ]
1593
+ }
1594
+ },
1595
+ {
1596
+ name: "State",
1597
+ type: {
1598
+ kind: "enum",
1599
+ variants: [
1600
+ {
1601
+ name: "Claimed"
1602
+ },
1603
+ {
1604
+ name: "Closed"
1605
+ }
1606
+ ]
1607
+ }
1608
+ }
1609
+ ]
1610
+ };
1611
+
1612
+ // solana/constants.ts
1613
+ var constants_exports = {};
1614
+ __export(constants_exports, {
1615
+ AIRDROP_CLAIM_FEE: () => AIRDROP_CLAIM_FEE,
1616
+ ALIGNED_DISTRIBUTOR_PREFIX: () => ALIGNED_DISTRIBUTOR_PREFIX,
1617
+ ALIGNED_DISTRIBUTOR_PROGRAM_ID: () => ALIGNED_DISTRIBUTOR_PROGRAM_ID,
1618
+ ALIGNED_PRECISION_FACTOR_POW: () => ALIGNED_PRECISION_FACTOR_POW,
1619
+ ANCHOR_DISCRIMINATOR_OFFSET: () => ANCHOR_DISCRIMINATOR_OFFSET,
1620
+ CLAIM_STATUS_PREFIX: () => CLAIM_STATUS_PREFIX,
1621
+ DISTRIBUTOR_ADMIN_OFFSET: () => DISTRIBUTOR_ADMIN_OFFSET,
1622
+ DISTRIBUTOR_MINT_OFFSET: () => DISTRIBUTOR_MINT_OFFSET,
1623
+ DISTRIBUTOR_PREFIX: () => DISTRIBUTOR_PREFIX,
1624
+ DISTRIBUTOR_PROGRAM_ID: () => DISTRIBUTOR_PROGRAM_ID,
1625
+ ONE_IN_BASIS_POINTS: () => ONE_IN_BASIS_POINTS,
1626
+ STREAMFLOW_TREASURY_PUBLIC_KEY: () => STREAMFLOW_TREASURY_PUBLIC_KEY,
1627
+ TEST_ORACLE_PREFIX: () => TEST_ORACLE_PREFIX
1628
+ });
1629
+ var ANCHOR_DISCRIMINATOR_OFFSET = 8;
1630
+ var DISTRIBUTOR_MINT_OFFSET = ANCHOR_DISCRIMINATOR_OFFSET + 41;
1631
+ var DISTRIBUTOR_ADMIN_OFFSET = ANCHOR_DISCRIMINATOR_OFFSET + 201;
1632
+ var DISTRIBUTOR_PREFIX = Buffer.from("MerkleDistributor", "utf-8");
1633
+ var ALIGNED_DISTRIBUTOR_PREFIX = Buffer.from("aligned-distributor", "utf-8");
1634
+ var TEST_ORACLE_PREFIX = Buffer.from("test-oracle", "utf-8");
1635
+ var CLAIM_STATUS_PREFIX = Buffer.from("ClaimStatus", "utf-8");
1636
+ var ALIGNED_PRECISION_FACTOR_POW = 9;
1637
+ var AIRDROP_CLAIM_FEE = BigInt(52e5);
1638
+ var STREAMFLOW_TREASURY_PUBLIC_KEY = new PublicKey("5SEpbdjFK5FxwTvfsGMXVQTD2v4M2c5tyRTxhdsPkgDw");
1639
+ var ONE_IN_BASIS_POINTS = BigInt(1e4);
1640
+ var ALIGNED_DISTRIBUTOR_PROGRAM_ID = {
1641
+ [ICluster.Devnet]: "aMERKpFAWoChCi5oZwPvgsSCoGpZKBiU7fi76bdZjt2",
1642
+ [ICluster.Mainnet]: "aMERKpFAWoChCi5oZwPvgsSCoGpZKBiU7fi76bdZjt2",
1643
+ [ICluster.Testnet]: "aMERKpFAWoChCi5oZwPvgsSCoGpZKBiU7fi76bdZjt2",
1644
+ [ICluster.Local]: "aMERKpFAWoChCi5oZwPvgsSCoGpZKBiU7fi76bdZjt2"
1645
+ };
1646
+ var DISTRIBUTOR_PROGRAM_ID = {
1647
+ [ICluster.Devnet]: "MErKy6nZVoVAkryxAejJz2juifQ4ArgLgHmaJCQkU7N",
1648
+ [ICluster.Mainnet]: "MErKy6nZVoVAkryxAejJz2juifQ4ArgLgHmaJCQkU7N",
1649
+ [ICluster.Testnet]: "MErKy6nZVoVAkryxAejJz2juifQ4ArgLgHmaJCQkU7N",
1650
+ [ICluster.Local]: "MErKy6nZVoVAkryxAejJz2juifQ4ArgLgHmaJCQkU7N"
1651
+ };
1652
+ var _ClaimStatus = class _ClaimStatus {
1653
+ constructor(fields) {
1654
+ this.claimant = fields.claimant;
1655
+ this.lockedAmount = fields.lockedAmount;
1656
+ this.lockedAmountWithdrawn = fields.lockedAmountWithdrawn;
1657
+ this.unlockedAmount = fields.unlockedAmount;
1658
+ this.lastClaimTs = fields.lastClaimTs;
1659
+ this.lastAmountPerUnlock = fields.lastAmountPerUnlock;
1660
+ this.closed = fields.closed;
1661
+ this.distributor = fields.distributor;
1662
+ this.claimsCount = fields.claimsCount;
1663
+ this.closedTs = fields.closedTs;
1664
+ this.buffer2 = fields.buffer2;
1665
+ }
1666
+ static async fetch(c, address, programId = PROGRAM_ID) {
1667
+ const info = await c.getAccountInfo(address);
1668
+ if (info === null) {
1669
+ return null;
1670
+ }
1671
+ if (!info.owner.equals(programId)) {
1672
+ throw new Error("account doesn't belong to this program");
1673
+ }
1674
+ return this.decode(info.data);
1675
+ }
1676
+ static async fetchMultiple(c, addresses, programId = PROGRAM_ID) {
1677
+ const infos = await c.getMultipleAccountsInfo(addresses);
1678
+ return infos.map((info) => {
1679
+ if (info === null) {
1680
+ return null;
1681
+ }
1682
+ if (!info.owner.equals(programId)) {
1683
+ throw new Error("account doesn't belong to this program");
1684
+ }
1685
+ return this.decode(info.data);
1686
+ });
1687
+ }
1688
+ static decode(data) {
1689
+ if (!data.slice(0, 8).equals(_ClaimStatus.discriminator)) {
1690
+ throw new Error("invalid account discriminator");
1691
+ }
1692
+ const dec = _ClaimStatus.layout.decode(data.slice(8));
1693
+ return new _ClaimStatus({
1694
+ claimant: dec.claimant,
1695
+ lockedAmount: dec.lockedAmount,
1696
+ lockedAmountWithdrawn: dec.lockedAmountWithdrawn,
1697
+ unlockedAmount: dec.unlockedAmount,
1698
+ lastClaimTs: dec.lastClaimTs,
1699
+ lastAmountPerUnlock: dec.lastAmountPerUnlock,
1700
+ closed: dec.closed,
1701
+ distributor: dec.distributor,
1702
+ claimsCount: dec.claimsCount,
1703
+ closedTs: dec.closedTs,
1704
+ buffer2: dec.buffer2
1705
+ });
1706
+ }
1707
+ toJSON() {
1708
+ return {
1709
+ claimant: this.claimant.toString(),
1710
+ lockedAmount: this.lockedAmount.toString(),
1711
+ lockedAmountWithdrawn: this.lockedAmountWithdrawn.toString(),
1712
+ unlockedAmount: this.unlockedAmount.toString(),
1713
+ lastClaimTs: this.lastClaimTs.toString(),
1714
+ lastAmountPerUnlock: this.lastAmountPerUnlock.toString(),
1715
+ closed: this.closed,
1716
+ distributor: this.distributor.toString(),
1717
+ claimsCount: this.claimsCount,
1718
+ closedTs: this.closedTs.toString(),
1719
+ buffer2: this.buffer2
1720
+ };
1721
+ }
1722
+ static fromJSON(obj) {
1723
+ return new _ClaimStatus({
1724
+ claimant: new PublicKey(obj.claimant),
1725
+ lockedAmount: new BN6(obj.lockedAmount),
1726
+ lockedAmountWithdrawn: new BN6(obj.lockedAmountWithdrawn),
1727
+ unlockedAmount: new BN6(obj.unlockedAmount),
1728
+ lastClaimTs: new BN6(obj.lastClaimTs),
1729
+ lastAmountPerUnlock: new BN6(obj.lastAmountPerUnlock),
1730
+ closed: obj.closed,
1731
+ distributor: new PublicKey(obj.distributor),
1732
+ claimsCount: obj.claimsCount,
1733
+ closedTs: new BN6(obj.closedTs),
1734
+ buffer2: obj.buffer2
1735
+ });
1736
+ }
1737
+ };
1738
+ _ClaimStatus.discriminator = Buffer.from([22, 183, 249, 157, 247, 95, 150, 96]);
1739
+ _ClaimStatus.layout = borsh8.struct([
1740
+ borsh8.publicKey("claimant"),
1741
+ borsh8.u64("lockedAmount"),
1742
+ borsh8.u64("lockedAmountWithdrawn"),
1743
+ borsh8.u64("unlockedAmount"),
1744
+ borsh8.u64("lastClaimTs"),
1745
+ borsh8.u64("lastAmountPerUnlock"),
1746
+ borsh8.bool("closed"),
1747
+ borsh8.publicKey("distributor"),
1748
+ borsh8.u16("claimsCount"),
1749
+ borsh8.u64("closedTs"),
1750
+ borsh8.array(borsh8.u8(), 22, "buffer2")
1751
+ ]);
1752
+ var ClaimStatus = _ClaimStatus;
1753
+ var _MerkleDistributor = class _MerkleDistributor {
1754
+ constructor(fields) {
1755
+ this.bump = fields.bump;
1756
+ this.version = fields.version;
1757
+ this.root = fields.root;
1758
+ this.mint = fields.mint;
1759
+ this.tokenVault = fields.tokenVault;
1760
+ this.maxTotalClaim = fields.maxTotalClaim;
1761
+ this.maxNumNodes = fields.maxNumNodes;
1762
+ this.unlockPeriod = fields.unlockPeriod;
1763
+ this.totalAmountClaimed = fields.totalAmountClaimed;
1764
+ this.numNodesClaimed = fields.numNodesClaimed;
1765
+ this.startTs = fields.startTs;
1766
+ this.endTs = fields.endTs;
1767
+ this.clawbackStartTs = fields.clawbackStartTs;
1768
+ this.clawbackReceiver = fields.clawbackReceiver;
1769
+ this.admin = fields.admin;
1770
+ this.clawedBack = fields.clawedBack;
1771
+ this.claimsClosableByAdmin = fields.claimsClosableByAdmin;
1772
+ this.canUpdateDuration = fields.canUpdateDuration;
1773
+ this.totalAmountUnlocked = fields.totalAmountUnlocked;
1774
+ this.totalAmountLocked = fields.totalAmountLocked;
1775
+ this.lastDurationUpdateTs = fields.lastDurationUpdateTs;
1776
+ this.totalClaimablePreUpdate = fields.totalClaimablePreUpdate;
1777
+ this.clawedBackTs = fields.clawedBackTs;
1778
+ this.claimsClosableByClaimant = fields.claimsClosableByClaimant;
1779
+ this.claimsLimit = fields.claimsLimit;
1780
+ this.buffer2 = fields.buffer2;
1781
+ this.buffer3 = fields.buffer3;
1782
+ }
1783
+ static async fetch(c, address, programId = PROGRAM_ID) {
1784
+ const info = await c.getAccountInfo(address);
1785
+ if (info === null) {
1786
+ return null;
1787
+ }
1788
+ if (!info.owner.equals(programId)) {
1789
+ throw new Error("account doesn't belong to this program");
1790
+ }
1791
+ return this.decode(info.data);
1792
+ }
1793
+ static async fetchMultiple(c, addresses, programId = PROGRAM_ID) {
1794
+ const infos = await c.getMultipleAccountsInfo(addresses);
1795
+ return infos.map((info) => {
1796
+ if (info === null) {
1797
+ return null;
1798
+ }
1799
+ if (!info.owner.equals(programId)) {
1800
+ throw new Error("account doesn't belong to this program");
1801
+ }
1802
+ return this.decode(info.data);
1803
+ });
1804
+ }
1805
+ static decode(data) {
1806
+ if (!data.slice(0, 8).equals(_MerkleDistributor.discriminator)) {
1807
+ throw new Error("invalid account discriminator");
1808
+ }
1809
+ const dec = _MerkleDistributor.layout.decode(data.slice(8));
1810
+ return new _MerkleDistributor({
1811
+ bump: dec.bump,
1812
+ version: dec.version,
1813
+ root: dec.root,
1814
+ mint: dec.mint,
1815
+ tokenVault: dec.tokenVault,
1816
+ maxTotalClaim: dec.maxTotalClaim,
1817
+ maxNumNodes: dec.maxNumNodes,
1818
+ unlockPeriod: dec.unlockPeriod,
1819
+ totalAmountClaimed: dec.totalAmountClaimed,
1820
+ numNodesClaimed: dec.numNodesClaimed,
1821
+ startTs: dec.startTs,
1822
+ endTs: dec.endTs,
1823
+ clawbackStartTs: dec.clawbackStartTs,
1824
+ clawbackReceiver: dec.clawbackReceiver,
1825
+ admin: dec.admin,
1826
+ clawedBack: dec.clawedBack,
1827
+ claimsClosableByAdmin: dec.claimsClosableByAdmin,
1828
+ canUpdateDuration: dec.canUpdateDuration,
1829
+ totalAmountUnlocked: dec.totalAmountUnlocked,
1830
+ totalAmountLocked: dec.totalAmountLocked,
1831
+ lastDurationUpdateTs: dec.lastDurationUpdateTs,
1832
+ totalClaimablePreUpdate: dec.totalClaimablePreUpdate,
1833
+ clawedBackTs: dec.clawedBackTs,
1834
+ claimsClosableByClaimant: dec.claimsClosableByClaimant,
1835
+ claimsLimit: dec.claimsLimit,
1836
+ buffer2: dec.buffer2,
1837
+ buffer3: dec.buffer3
1838
+ });
1839
+ }
1840
+ toJSON() {
1841
+ return {
1842
+ bump: this.bump,
1843
+ version: this.version.toString(),
1844
+ root: this.root,
1845
+ mint: this.mint.toString(),
1846
+ tokenVault: this.tokenVault.toString(),
1847
+ maxTotalClaim: this.maxTotalClaim.toString(),
1848
+ maxNumNodes: this.maxNumNodes.toString(),
1849
+ unlockPeriod: this.unlockPeriod.toString(),
1850
+ totalAmountClaimed: this.totalAmountClaimed.toString(),
1851
+ numNodesClaimed: this.numNodesClaimed.toString(),
1852
+ startTs: this.startTs.toString(),
1853
+ endTs: this.endTs.toString(),
1854
+ clawbackStartTs: this.clawbackStartTs.toString(),
1855
+ clawbackReceiver: this.clawbackReceiver.toString(),
1856
+ admin: this.admin.toString(),
1857
+ clawedBack: this.clawedBack,
1858
+ claimsClosableByAdmin: this.claimsClosableByAdmin,
1859
+ canUpdateDuration: this.canUpdateDuration,
1860
+ totalAmountUnlocked: this.totalAmountUnlocked.toString(),
1861
+ totalAmountLocked: this.totalAmountLocked.toString(),
1862
+ lastDurationUpdateTs: this.lastDurationUpdateTs.toString(),
1863
+ totalClaimablePreUpdate: this.totalClaimablePreUpdate.toString(),
1864
+ clawedBackTs: this.clawedBackTs.toString(),
1865
+ claimsClosableByClaimant: this.claimsClosableByClaimant,
1866
+ claimsLimit: this.claimsLimit,
1867
+ buffer2: this.buffer2,
1868
+ buffer3: this.buffer3
1869
+ };
1870
+ }
1871
+ static fromJSON(obj) {
1872
+ return new _MerkleDistributor({
1873
+ bump: obj.bump,
1874
+ version: new BN6(obj.version),
1875
+ root: obj.root,
1876
+ mint: new PublicKey(obj.mint),
1877
+ tokenVault: new PublicKey(obj.tokenVault),
1878
+ maxTotalClaim: new BN6(obj.maxTotalClaim),
1879
+ maxNumNodes: new BN6(obj.maxNumNodes),
1880
+ unlockPeriod: new BN6(obj.unlockPeriod),
1881
+ totalAmountClaimed: new BN6(obj.totalAmountClaimed),
1882
+ numNodesClaimed: new BN6(obj.numNodesClaimed),
1883
+ startTs: new BN6(obj.startTs),
1884
+ endTs: new BN6(obj.endTs),
1885
+ clawbackStartTs: new BN6(obj.clawbackStartTs),
1886
+ clawbackReceiver: new PublicKey(obj.clawbackReceiver),
1887
+ admin: new PublicKey(obj.admin),
1888
+ clawedBack: obj.clawedBack,
1889
+ claimsClosableByAdmin: obj.claimsClosableByAdmin,
1890
+ canUpdateDuration: obj.canUpdateDuration,
1891
+ totalAmountUnlocked: new BN6(obj.totalAmountUnlocked),
1892
+ totalAmountLocked: new BN6(obj.totalAmountLocked),
1893
+ lastDurationUpdateTs: new BN6(obj.lastDurationUpdateTs),
1894
+ totalClaimablePreUpdate: new BN6(obj.totalClaimablePreUpdate),
1895
+ clawedBackTs: new BN6(obj.clawedBackTs),
1896
+ claimsClosableByClaimant: obj.claimsClosableByClaimant,
1897
+ claimsLimit: obj.claimsLimit,
1898
+ buffer2: obj.buffer2,
1899
+ buffer3: obj.buffer3
1900
+ });
1901
+ }
1902
+ };
1903
+ _MerkleDistributor.discriminator = Buffer.from([77, 119, 139, 70, 84, 247, 12, 26]);
1904
+ _MerkleDistributor.layout = borsh8.struct([
1905
+ borsh8.u8("bump"),
1906
+ borsh8.u64("version"),
1907
+ borsh8.array(borsh8.u8(), 32, "root"),
1908
+ borsh8.publicKey("mint"),
1909
+ borsh8.publicKey("tokenVault"),
1910
+ borsh8.u64("maxTotalClaim"),
1911
+ borsh8.u64("maxNumNodes"),
1912
+ borsh8.u64("unlockPeriod"),
1913
+ borsh8.u64("totalAmountClaimed"),
1914
+ borsh8.u64("numNodesClaimed"),
1915
+ borsh8.u64("startTs"),
1916
+ borsh8.u64("endTs"),
1917
+ borsh8.u64("clawbackStartTs"),
1918
+ borsh8.publicKey("clawbackReceiver"),
1919
+ borsh8.publicKey("admin"),
1920
+ borsh8.bool("clawedBack"),
1921
+ borsh8.bool("claimsClosableByAdmin"),
1922
+ borsh8.bool("canUpdateDuration"),
1923
+ borsh8.u64("totalAmountUnlocked"),
1924
+ borsh8.u64("totalAmountLocked"),
1925
+ borsh8.u64("lastDurationUpdateTs"),
1926
+ borsh8.u64("totalClaimablePreUpdate"),
1927
+ borsh8.u64("clawedBackTs"),
1928
+ borsh8.bool("claimsClosableByClaimant"),
1929
+ borsh8.u16("claimsLimit"),
1930
+ borsh8.array(borsh8.u8(), 20, "buffer2"),
1931
+ borsh8.array(borsh8.u8(), 32, "buffer3")
1932
+ ]);
1933
+ var MerkleDistributor = _MerkleDistributor;
1934
+
1935
+ // solana/generated/errors/anchor.ts
1936
+ var InstructionMissing = class extends Error {
1937
+ constructor(logs) {
1938
+ super("100: 8 byte instruction identifier not provided");
1939
+ this.logs = logs;
1940
+ this.code = 100;
1941
+ this.name = "InstructionMissing";
1942
+ this.msg = "8 byte instruction identifier not provided";
1943
+ }
1944
+ };
1945
+ InstructionMissing.code = 100;
1946
+ var InstructionFallbackNotFound = class extends Error {
1947
+ constructor(logs) {
1948
+ super("101: Fallback functions are not supported");
1949
+ this.logs = logs;
1950
+ this.code = 101;
1951
+ this.name = "InstructionFallbackNotFound";
1952
+ this.msg = "Fallback functions are not supported";
1953
+ }
1954
+ };
1955
+ InstructionFallbackNotFound.code = 101;
1956
+ var InstructionDidNotDeserialize = class extends Error {
1957
+ constructor(logs) {
1958
+ super("102: The program could not deserialize the given instruction");
1959
+ this.logs = logs;
1960
+ this.code = 102;
1961
+ this.name = "InstructionDidNotDeserialize";
1962
+ this.msg = "The program could not deserialize the given instruction";
1963
+ }
1964
+ };
1965
+ InstructionDidNotDeserialize.code = 102;
1966
+ var InstructionDidNotSerialize = class extends Error {
1967
+ constructor(logs) {
1968
+ super("103: The program could not serialize the given instruction");
1969
+ this.logs = logs;
1970
+ this.code = 103;
1971
+ this.name = "InstructionDidNotSerialize";
1972
+ this.msg = "The program could not serialize the given instruction";
1973
+ }
1974
+ };
1975
+ InstructionDidNotSerialize.code = 103;
1976
+ var IdlInstructionStub = class extends Error {
1977
+ constructor(logs) {
1978
+ super("1000: The program was compiled without idl instructions");
1979
+ this.logs = logs;
1980
+ this.code = 1e3;
1981
+ this.name = "IdlInstructionStub";
1982
+ this.msg = "The program was compiled without idl instructions";
1983
+ }
1984
+ };
1985
+ IdlInstructionStub.code = 1e3;
1986
+ var IdlInstructionInvalidProgram = class extends Error {
1987
+ constructor(logs) {
1988
+ super("1001: The transaction was given an invalid program for the IDL instruction");
1989
+ this.logs = logs;
1990
+ this.code = 1001;
1991
+ this.name = "IdlInstructionInvalidProgram";
1992
+ this.msg = "The transaction was given an invalid program for the IDL instruction";
1993
+ }
1994
+ };
1995
+ IdlInstructionInvalidProgram.code = 1001;
1996
+ var ConstraintMut = class extends Error {
1997
+ constructor(logs) {
1998
+ super("2000: A mut constraint was violated");
1999
+ this.logs = logs;
2000
+ this.code = 2e3;
2001
+ this.name = "ConstraintMut";
2002
+ this.msg = "A mut constraint was violated";
2003
+ }
2004
+ };
2005
+ ConstraintMut.code = 2e3;
2006
+ var ConstraintHasOne = class extends Error {
2007
+ constructor(logs) {
2008
+ super("2001: A has one constraint was violated");
2009
+ this.logs = logs;
2010
+ this.code = 2001;
2011
+ this.name = "ConstraintHasOne";
2012
+ this.msg = "A has one constraint was violated";
2013
+ }
2014
+ };
2015
+ ConstraintHasOne.code = 2001;
2016
+ var ConstraintSigner = class extends Error {
2017
+ constructor(logs) {
2018
+ super("2002: A signer constraint was violated");
2019
+ this.logs = logs;
2020
+ this.code = 2002;
2021
+ this.name = "ConstraintSigner";
2022
+ this.msg = "A signer constraint was violated";
2023
+ }
2024
+ };
2025
+ ConstraintSigner.code = 2002;
2026
+ var ConstraintRaw = class extends Error {
2027
+ constructor(logs) {
2028
+ super("2003: A raw constraint was violated");
2029
+ this.logs = logs;
2030
+ this.code = 2003;
2031
+ this.name = "ConstraintRaw";
2032
+ this.msg = "A raw constraint was violated";
2033
+ }
2034
+ };
2035
+ ConstraintRaw.code = 2003;
2036
+ var ConstraintOwner = class extends Error {
2037
+ constructor(logs) {
2038
+ super("2004: An owner constraint was violated");
2039
+ this.logs = logs;
2040
+ this.code = 2004;
2041
+ this.name = "ConstraintOwner";
2042
+ this.msg = "An owner constraint was violated";
2043
+ }
2044
+ };
2045
+ ConstraintOwner.code = 2004;
2046
+ var ConstraintRentExempt = class extends Error {
2047
+ constructor(logs) {
2048
+ super("2005: A rent exemption constraint was violated");
2049
+ this.logs = logs;
2050
+ this.code = 2005;
2051
+ this.name = "ConstraintRentExempt";
2052
+ this.msg = "A rent exemption constraint was violated";
2053
+ }
2054
+ };
2055
+ ConstraintRentExempt.code = 2005;
2056
+ var ConstraintSeeds = class extends Error {
2057
+ constructor(logs) {
2058
+ super("2006: A seeds constraint was violated");
2059
+ this.logs = logs;
2060
+ this.code = 2006;
2061
+ this.name = "ConstraintSeeds";
2062
+ this.msg = "A seeds constraint was violated";
2063
+ }
2064
+ };
2065
+ ConstraintSeeds.code = 2006;
2066
+ var ConstraintExecutable = class extends Error {
2067
+ constructor(logs) {
2068
+ super("2007: An executable constraint was violated");
2069
+ this.logs = logs;
2070
+ this.code = 2007;
2071
+ this.name = "ConstraintExecutable";
2072
+ this.msg = "An executable constraint was violated";
2073
+ }
2074
+ };
2075
+ ConstraintExecutable.code = 2007;
2076
+ var ConstraintState = class extends Error {
2077
+ constructor(logs) {
2078
+ super("2008: Deprecated Error, feel free to replace with something else");
2079
+ this.logs = logs;
2080
+ this.code = 2008;
2081
+ this.name = "ConstraintState";
2082
+ this.msg = "Deprecated Error, feel free to replace with something else";
2083
+ }
2084
+ };
2085
+ ConstraintState.code = 2008;
2086
+ var ConstraintAssociated = class extends Error {
2087
+ constructor(logs) {
2088
+ super("2009: An associated constraint was violated");
2089
+ this.logs = logs;
2090
+ this.code = 2009;
2091
+ this.name = "ConstraintAssociated";
2092
+ this.msg = "An associated constraint was violated";
2093
+ }
2094
+ };
2095
+ ConstraintAssociated.code = 2009;
2096
+ var ConstraintAssociatedInit = class extends Error {
2097
+ constructor(logs) {
2098
+ super("2010: An associated init constraint was violated");
2099
+ this.logs = logs;
2100
+ this.code = 2010;
2101
+ this.name = "ConstraintAssociatedInit";
2102
+ this.msg = "An associated init constraint was violated";
2103
+ }
2104
+ };
2105
+ ConstraintAssociatedInit.code = 2010;
2106
+ var ConstraintClose = class extends Error {
2107
+ constructor(logs) {
2108
+ super("2011: A close constraint was violated");
2109
+ this.logs = logs;
2110
+ this.code = 2011;
2111
+ this.name = "ConstraintClose";
2112
+ this.msg = "A close constraint was violated";
2113
+ }
2114
+ };
2115
+ ConstraintClose.code = 2011;
2116
+ var ConstraintAddress = class extends Error {
2117
+ constructor(logs) {
2118
+ super("2012: An address constraint was violated");
2119
+ this.logs = logs;
2120
+ this.code = 2012;
2121
+ this.name = "ConstraintAddress";
2122
+ this.msg = "An address constraint was violated";
2123
+ }
2124
+ };
2125
+ ConstraintAddress.code = 2012;
2126
+ var ConstraintZero = class extends Error {
2127
+ constructor(logs) {
2128
+ super("2013: Expected zero account discriminant");
2129
+ this.logs = logs;
2130
+ this.code = 2013;
2131
+ this.name = "ConstraintZero";
2132
+ this.msg = "Expected zero account discriminant";
2133
+ }
2134
+ };
2135
+ ConstraintZero.code = 2013;
2136
+ var ConstraintTokenMint = class extends Error {
2137
+ constructor(logs) {
2138
+ super("2014: A token mint constraint was violated");
2139
+ this.logs = logs;
2140
+ this.code = 2014;
2141
+ this.name = "ConstraintTokenMint";
2142
+ this.msg = "A token mint constraint was violated";
2143
+ }
2144
+ };
2145
+ ConstraintTokenMint.code = 2014;
2146
+ var ConstraintTokenOwner = class extends Error {
2147
+ constructor(logs) {
2148
+ super("2015: A token owner constraint was violated");
2149
+ this.logs = logs;
2150
+ this.code = 2015;
2151
+ this.name = "ConstraintTokenOwner";
2152
+ this.msg = "A token owner constraint was violated";
2153
+ }
2154
+ };
2155
+ ConstraintTokenOwner.code = 2015;
2156
+ var ConstraintMintMintAuthority = class extends Error {
2157
+ constructor(logs) {
2158
+ super("2016: A mint mint authority constraint was violated");
2159
+ this.logs = logs;
2160
+ this.code = 2016;
2161
+ this.name = "ConstraintMintMintAuthority";
2162
+ this.msg = "A mint mint authority constraint was violated";
2163
+ }
2164
+ };
2165
+ ConstraintMintMintAuthority.code = 2016;
2166
+ var ConstraintMintFreezeAuthority = class extends Error {
2167
+ constructor(logs) {
2168
+ super("2017: A mint freeze authority constraint was violated");
2169
+ this.logs = logs;
2170
+ this.code = 2017;
2171
+ this.name = "ConstraintMintFreezeAuthority";
2172
+ this.msg = "A mint freeze authority constraint was violated";
2173
+ }
2174
+ };
2175
+ ConstraintMintFreezeAuthority.code = 2017;
2176
+ var ConstraintMintDecimals = class extends Error {
2177
+ constructor(logs) {
2178
+ super("2018: A mint decimals constraint was violated");
2179
+ this.logs = logs;
2180
+ this.code = 2018;
2181
+ this.name = "ConstraintMintDecimals";
2182
+ this.msg = "A mint decimals constraint was violated";
2183
+ }
2184
+ };
2185
+ ConstraintMintDecimals.code = 2018;
2186
+ var ConstraintSpace = class extends Error {
2187
+ constructor(logs) {
2188
+ super("2019: A space constraint was violated");
2189
+ this.logs = logs;
2190
+ this.code = 2019;
2191
+ this.name = "ConstraintSpace";
2192
+ this.msg = "A space constraint was violated";
2193
+ }
2194
+ };
2195
+ ConstraintSpace.code = 2019;
2196
+ var ConstraintAccountIsNone = class extends Error {
2197
+ constructor(logs) {
2198
+ super("2020: A required account for the constraint is None");
2199
+ this.logs = logs;
2200
+ this.code = 2020;
2201
+ this.name = "ConstraintAccountIsNone";
2202
+ this.msg = "A required account for the constraint is None";
2203
+ }
2204
+ };
2205
+ ConstraintAccountIsNone.code = 2020;
2206
+ var RequireViolated = class extends Error {
2207
+ constructor(logs) {
2208
+ super("2500: A require expression was violated");
2209
+ this.logs = logs;
2210
+ this.code = 2500;
2211
+ this.name = "RequireViolated";
2212
+ this.msg = "A require expression was violated";
2213
+ }
2214
+ };
2215
+ RequireViolated.code = 2500;
2216
+ var RequireEqViolated = class extends Error {
2217
+ constructor(logs) {
2218
+ super("2501: A require_eq expression was violated");
2219
+ this.logs = logs;
2220
+ this.code = 2501;
2221
+ this.name = "RequireEqViolated";
2222
+ this.msg = "A require_eq expression was violated";
2223
+ }
2224
+ };
2225
+ RequireEqViolated.code = 2501;
2226
+ var RequireKeysEqViolated = class extends Error {
2227
+ constructor(logs) {
2228
+ super("2502: A require_keys_eq expression was violated");
2229
+ this.logs = logs;
2230
+ this.code = 2502;
2231
+ this.name = "RequireKeysEqViolated";
2232
+ this.msg = "A require_keys_eq expression was violated";
2233
+ }
2234
+ };
2235
+ RequireKeysEqViolated.code = 2502;
2236
+ var RequireNeqViolated = class extends Error {
2237
+ constructor(logs) {
2238
+ super("2503: A require_neq expression was violated");
2239
+ this.logs = logs;
2240
+ this.code = 2503;
2241
+ this.name = "RequireNeqViolated";
2242
+ this.msg = "A require_neq expression was violated";
2243
+ }
2244
+ };
2245
+ RequireNeqViolated.code = 2503;
2246
+ var RequireKeysNeqViolated = class extends Error {
2247
+ constructor(logs) {
2248
+ super("2504: A require_keys_neq expression was violated");
2249
+ this.logs = logs;
2250
+ this.code = 2504;
2251
+ this.name = "RequireKeysNeqViolated";
2252
+ this.msg = "A require_keys_neq expression was violated";
2253
+ }
2254
+ };
2255
+ RequireKeysNeqViolated.code = 2504;
2256
+ var RequireGtViolated = class extends Error {
2257
+ constructor(logs) {
2258
+ super("2505: A require_gt expression was violated");
2259
+ this.logs = logs;
2260
+ this.code = 2505;
2261
+ this.name = "RequireGtViolated";
2262
+ this.msg = "A require_gt expression was violated";
2263
+ }
2264
+ };
2265
+ RequireGtViolated.code = 2505;
2266
+ var RequireGteViolated = class extends Error {
2267
+ constructor(logs) {
2268
+ super("2506: A require_gte expression was violated");
2269
+ this.logs = logs;
2270
+ this.code = 2506;
2271
+ this.name = "RequireGteViolated";
2272
+ this.msg = "A require_gte expression was violated";
2273
+ }
2274
+ };
2275
+ RequireGteViolated.code = 2506;
2276
+ var AccountDiscriminatorAlreadySet = class extends Error {
2277
+ constructor(logs) {
2278
+ super("3000: The account discriminator was already set on this account");
2279
+ this.logs = logs;
2280
+ this.code = 3e3;
2281
+ this.name = "AccountDiscriminatorAlreadySet";
2282
+ this.msg = "The account discriminator was already set on this account";
2283
+ }
2284
+ };
2285
+ AccountDiscriminatorAlreadySet.code = 3e3;
2286
+ var AccountDiscriminatorNotFound = class extends Error {
2287
+ constructor(logs) {
2288
+ super("3001: No 8 byte discriminator was found on the account");
2289
+ this.logs = logs;
2290
+ this.code = 3001;
2291
+ this.name = "AccountDiscriminatorNotFound";
2292
+ this.msg = "No 8 byte discriminator was found on the account";
2293
+ }
2294
+ };
2295
+ AccountDiscriminatorNotFound.code = 3001;
2296
+ var AccountDiscriminatorMismatch = class extends Error {
2297
+ constructor(logs) {
2298
+ super("3002: 8 byte discriminator did not match what was expected");
2299
+ this.logs = logs;
2300
+ this.code = 3002;
2301
+ this.name = "AccountDiscriminatorMismatch";
2302
+ this.msg = "8 byte discriminator did not match what was expected";
2303
+ }
2304
+ };
2305
+ AccountDiscriminatorMismatch.code = 3002;
2306
+ var AccountDidNotDeserialize = class extends Error {
2307
+ constructor(logs) {
2308
+ super("3003: Failed to deserialize the account");
2309
+ this.logs = logs;
2310
+ this.code = 3003;
2311
+ this.name = "AccountDidNotDeserialize";
2312
+ this.msg = "Failed to deserialize the account";
2313
+ }
2314
+ };
2315
+ AccountDidNotDeserialize.code = 3003;
2316
+ var AccountDidNotSerialize = class extends Error {
2317
+ constructor(logs) {
2318
+ super("3004: Failed to serialize the account");
2319
+ this.logs = logs;
2320
+ this.code = 3004;
2321
+ this.name = "AccountDidNotSerialize";
2322
+ this.msg = "Failed to serialize the account";
2323
+ }
2324
+ };
2325
+ AccountDidNotSerialize.code = 3004;
2326
+ var AccountNotEnoughKeys = class extends Error {
2327
+ constructor(logs) {
2328
+ super("3005: Not enough account keys given to the instruction");
2329
+ this.logs = logs;
2330
+ this.code = 3005;
2331
+ this.name = "AccountNotEnoughKeys";
2332
+ this.msg = "Not enough account keys given to the instruction";
2333
+ }
2334
+ };
2335
+ AccountNotEnoughKeys.code = 3005;
2336
+ var AccountNotMutable = class extends Error {
2337
+ constructor(logs) {
2338
+ super("3006: The given account is not mutable");
2339
+ this.logs = logs;
2340
+ this.code = 3006;
2341
+ this.name = "AccountNotMutable";
2342
+ this.msg = "The given account is not mutable";
2343
+ }
2344
+ };
2345
+ AccountNotMutable.code = 3006;
2346
+ var AccountOwnedByWrongProgram = class extends Error {
2347
+ constructor(logs) {
2348
+ super("3007: The given account is owned by a different program than expected");
2349
+ this.logs = logs;
2350
+ this.code = 3007;
2351
+ this.name = "AccountOwnedByWrongProgram";
2352
+ this.msg = "The given account is owned by a different program than expected";
2353
+ }
2354
+ };
2355
+ AccountOwnedByWrongProgram.code = 3007;
2356
+ var InvalidProgramId = class extends Error {
2357
+ constructor(logs) {
2358
+ super("3008: Program ID was not as expected");
2359
+ this.logs = logs;
2360
+ this.code = 3008;
2361
+ this.name = "InvalidProgramId";
2362
+ this.msg = "Program ID was not as expected";
2363
+ }
2364
+ };
2365
+ InvalidProgramId.code = 3008;
2366
+ var InvalidProgramExecutable = class extends Error {
2367
+ constructor(logs) {
2368
+ super("3009: Program account is not executable");
2369
+ this.logs = logs;
2370
+ this.code = 3009;
2371
+ this.name = "InvalidProgramExecutable";
2372
+ this.msg = "Program account is not executable";
2373
+ }
2374
+ };
2375
+ InvalidProgramExecutable.code = 3009;
2376
+ var AccountNotSigner = class extends Error {
2377
+ constructor(logs) {
2378
+ super("3010: The given account did not sign");
2379
+ this.logs = logs;
2380
+ this.code = 3010;
2381
+ this.name = "AccountNotSigner";
2382
+ this.msg = "The given account did not sign";
2383
+ }
2384
+ };
2385
+ AccountNotSigner.code = 3010;
2386
+ var AccountNotSystemOwned = class extends Error {
2387
+ constructor(logs) {
2388
+ super("3011: The given account is not owned by the system program");
2389
+ this.logs = logs;
2390
+ this.code = 3011;
2391
+ this.name = "AccountNotSystemOwned";
2392
+ this.msg = "The given account is not owned by the system program";
2393
+ }
2394
+ };
2395
+ AccountNotSystemOwned.code = 3011;
2396
+ var AccountNotInitialized = class extends Error {
2397
+ constructor(logs) {
2398
+ super("3012: The program expected this account to be already initialized");
2399
+ this.logs = logs;
2400
+ this.code = 3012;
2401
+ this.name = "AccountNotInitialized";
2402
+ this.msg = "The program expected this account to be already initialized";
2403
+ }
2404
+ };
2405
+ AccountNotInitialized.code = 3012;
2406
+ var AccountNotProgramData = class extends Error {
2407
+ constructor(logs) {
2408
+ super("3013: The given account is not a program data account");
2409
+ this.logs = logs;
2410
+ this.code = 3013;
2411
+ this.name = "AccountNotProgramData";
2412
+ this.msg = "The given account is not a program data account";
2413
+ }
2414
+ };
2415
+ AccountNotProgramData.code = 3013;
2416
+ var AccountNotAssociatedTokenAccount = class extends Error {
2417
+ constructor(logs) {
2418
+ super("3014: The given account is not the associated token account");
2419
+ this.logs = logs;
2420
+ this.code = 3014;
2421
+ this.name = "AccountNotAssociatedTokenAccount";
2422
+ this.msg = "The given account is not the associated token account";
2423
+ }
2424
+ };
2425
+ AccountNotAssociatedTokenAccount.code = 3014;
2426
+ var AccountSysvarMismatch = class extends Error {
2427
+ constructor(logs) {
2428
+ super("3015: The given public key does not match the required sysvar");
2429
+ this.logs = logs;
2430
+ this.code = 3015;
2431
+ this.name = "AccountSysvarMismatch";
2432
+ this.msg = "The given public key does not match the required sysvar";
2433
+ }
2434
+ };
2435
+ AccountSysvarMismatch.code = 3015;
2436
+ var AccountReallocExceedsLimit = class extends Error {
2437
+ constructor(logs) {
2438
+ super("3016: The account reallocation exceeds the MAX_PERMITTED_DATA_INCREASE limit");
2439
+ this.logs = logs;
2440
+ this.code = 3016;
2441
+ this.name = "AccountReallocExceedsLimit";
2442
+ this.msg = "The account reallocation exceeds the MAX_PERMITTED_DATA_INCREASE limit";
2443
+ }
2444
+ };
2445
+ AccountReallocExceedsLimit.code = 3016;
2446
+ var AccountDuplicateReallocs = class extends Error {
2447
+ constructor(logs) {
2448
+ super("3017: The account was duplicated for more than one reallocation");
2449
+ this.logs = logs;
2450
+ this.code = 3017;
2451
+ this.name = "AccountDuplicateReallocs";
2452
+ this.msg = "The account was duplicated for more than one reallocation";
2453
+ }
2454
+ };
2455
+ AccountDuplicateReallocs.code = 3017;
2456
+ var DeclaredProgramIdMismatch = class extends Error {
2457
+ constructor(logs) {
2458
+ super("4100: The declared program id does not match the actual program id");
2459
+ this.logs = logs;
2460
+ this.code = 4100;
2461
+ this.name = "DeclaredProgramIdMismatch";
2462
+ this.msg = "The declared program id does not match the actual program id";
2463
+ }
2464
+ };
2465
+ DeclaredProgramIdMismatch.code = 4100;
2466
+ var Deprecated = class extends Error {
2467
+ constructor(logs) {
2468
+ super("5000: The API being used is deprecated and should no longer be used");
2469
+ this.logs = logs;
2470
+ this.code = 5e3;
2471
+ this.name = "Deprecated";
2472
+ this.msg = "The API being used is deprecated and should no longer be used";
2473
+ }
2474
+ };
2475
+ Deprecated.code = 5e3;
2476
+ function fromCode(code, logs) {
2477
+ switch (code) {
2478
+ case 100:
2479
+ return new InstructionMissing(logs);
2480
+ case 101:
2481
+ return new InstructionFallbackNotFound(logs);
2482
+ case 102:
2483
+ return new InstructionDidNotDeserialize(logs);
2484
+ case 103:
2485
+ return new InstructionDidNotSerialize(logs);
2486
+ case 1e3:
2487
+ return new IdlInstructionStub(logs);
2488
+ case 1001:
2489
+ return new IdlInstructionInvalidProgram(logs);
2490
+ case 2e3:
2491
+ return new ConstraintMut(logs);
2492
+ case 2001:
2493
+ return new ConstraintHasOne(logs);
2494
+ case 2002:
2495
+ return new ConstraintSigner(logs);
2496
+ case 2003:
2497
+ return new ConstraintRaw(logs);
2498
+ case 2004:
2499
+ return new ConstraintOwner(logs);
2500
+ case 2005:
2501
+ return new ConstraintRentExempt(logs);
2502
+ case 2006:
2503
+ return new ConstraintSeeds(logs);
2504
+ case 2007:
2505
+ return new ConstraintExecutable(logs);
2506
+ case 2008:
2507
+ return new ConstraintState(logs);
2508
+ case 2009:
2509
+ return new ConstraintAssociated(logs);
2510
+ case 2010:
2511
+ return new ConstraintAssociatedInit(logs);
2512
+ case 2011:
2513
+ return new ConstraintClose(logs);
2514
+ case 2012:
2515
+ return new ConstraintAddress(logs);
2516
+ case 2013:
2517
+ return new ConstraintZero(logs);
2518
+ case 2014:
2519
+ return new ConstraintTokenMint(logs);
2520
+ case 2015:
2521
+ return new ConstraintTokenOwner(logs);
2522
+ case 2016:
2523
+ return new ConstraintMintMintAuthority(logs);
2524
+ case 2017:
2525
+ return new ConstraintMintFreezeAuthority(logs);
2526
+ case 2018:
2527
+ return new ConstraintMintDecimals(logs);
2528
+ case 2019:
2529
+ return new ConstraintSpace(logs);
2530
+ case 2020:
2531
+ return new ConstraintAccountIsNone(logs);
2532
+ case 2500:
2533
+ return new RequireViolated(logs);
2534
+ case 2501:
2535
+ return new RequireEqViolated(logs);
2536
+ case 2502:
2537
+ return new RequireKeysEqViolated(logs);
2538
+ case 2503:
2539
+ return new RequireNeqViolated(logs);
2540
+ case 2504:
2541
+ return new RequireKeysNeqViolated(logs);
2542
+ case 2505:
2543
+ return new RequireGtViolated(logs);
2544
+ case 2506:
2545
+ return new RequireGteViolated(logs);
2546
+ case 3e3:
2547
+ return new AccountDiscriminatorAlreadySet(logs);
2548
+ case 3001:
2549
+ return new AccountDiscriminatorNotFound(logs);
2550
+ case 3002:
2551
+ return new AccountDiscriminatorMismatch(logs);
2552
+ case 3003:
2553
+ return new AccountDidNotDeserialize(logs);
2554
+ case 3004:
2555
+ return new AccountDidNotSerialize(logs);
2556
+ case 3005:
2557
+ return new AccountNotEnoughKeys(logs);
2558
+ case 3006:
2559
+ return new AccountNotMutable(logs);
2560
+ case 3007:
2561
+ return new AccountOwnedByWrongProgram(logs);
2562
+ case 3008:
2563
+ return new InvalidProgramId(logs);
2564
+ case 3009:
2565
+ return new InvalidProgramExecutable(logs);
2566
+ case 3010:
2567
+ return new AccountNotSigner(logs);
2568
+ case 3011:
2569
+ return new AccountNotSystemOwned(logs);
2570
+ case 3012:
2571
+ return new AccountNotInitialized(logs);
2572
+ case 3013:
2573
+ return new AccountNotProgramData(logs);
2574
+ case 3014:
2575
+ return new AccountNotAssociatedTokenAccount(logs);
2576
+ case 3015:
2577
+ return new AccountSysvarMismatch(logs);
2578
+ case 3016:
2579
+ return new AccountReallocExceedsLimit(logs);
2580
+ case 3017:
2581
+ return new AccountDuplicateReallocs(logs);
2582
+ case 4100:
2583
+ return new DeclaredProgramIdMismatch(logs);
2584
+ case 5e3:
2585
+ return new Deprecated(logs);
2586
+ }
2587
+ return null;
2588
+ }
2589
+
2590
+ // solana/generated/errors/custom.ts
2591
+ var InsufficientUnlockedTokens = class extends Error {
2592
+ constructor(logs) {
2593
+ super("6000: Insufficient unlocked tokens");
2594
+ this.logs = logs;
2595
+ this.code = 6e3;
2596
+ this.name = "InsufficientUnlockedTokens";
2597
+ this.msg = "Insufficient unlocked tokens";
2598
+ }
2599
+ };
2600
+ InsufficientUnlockedTokens.code = 6e3;
2601
+ var InvalidProof = class extends Error {
2602
+ constructor(logs) {
2603
+ super("6001: Invalid Merkle proof");
2604
+ this.logs = logs;
2605
+ this.code = 6001;
2606
+ this.name = "InvalidProof";
2607
+ this.msg = "Invalid Merkle proof";
2608
+ }
2609
+ };
2610
+ InvalidProof.code = 6001;
2611
+ var ExceededMaxClaim = class extends Error {
2612
+ constructor(logs) {
2613
+ super("6002: Exceeded maximum claim amount");
2614
+ this.logs = logs;
2615
+ this.code = 6002;
2616
+ this.name = "ExceededMaxClaim";
2617
+ this.msg = "Exceeded maximum claim amount";
2618
+ }
2619
+ };
2620
+ ExceededMaxClaim.code = 6002;
2621
+ var MaxNodesExceeded = class extends Error {
2622
+ constructor(logs) {
2623
+ super("6003: Exceeded maximum node count");
2624
+ this.logs = logs;
2625
+ this.code = 6003;
2626
+ this.name = "MaxNodesExceeded";
2627
+ this.msg = "Exceeded maximum node count";
2628
+ }
2629
+ };
2630
+ MaxNodesExceeded.code = 6003;
2631
+ var Unauthorized = class extends Error {
2632
+ constructor(logs) {
2633
+ super("6004: Account is not authorized to execute this instruction");
2634
+ this.logs = logs;
2635
+ this.code = 6004;
2636
+ this.name = "Unauthorized";
2637
+ this.msg = "Account is not authorized to execute this instruction";
2638
+ }
2639
+ };
2640
+ Unauthorized.code = 6004;
2641
+ var OwnerMismatch = class extends Error {
2642
+ constructor(logs) {
2643
+ super("6005: Token account owner did not match intended owner");
2644
+ this.logs = logs;
2645
+ this.code = 6005;
2646
+ this.name = "OwnerMismatch";
2647
+ this.msg = "Token account owner did not match intended owner";
2648
+ }
2649
+ };
2650
+ OwnerMismatch.code = 6005;
2651
+ var ClawbackBeforeStart = class extends Error {
2652
+ constructor(logs) {
2653
+ super("6006: Attempted clawback before start");
2654
+ this.logs = logs;
2655
+ this.code = 6006;
2656
+ this.name = "ClawbackBeforeStart";
2657
+ this.msg = "Attempted clawback before start";
2658
+ }
2659
+ };
2660
+ ClawbackBeforeStart.code = 6006;
2661
+ var ClawbackAlreadyClaimed = class extends Error {
2662
+ constructor(logs) {
2663
+ super("6007: Clawback already claimed");
2664
+ this.logs = logs;
2665
+ this.code = 6007;
2666
+ this.name = "ClawbackAlreadyClaimed";
2667
+ this.msg = "Clawback already claimed";
2668
+ }
2669
+ };
2670
+ ClawbackAlreadyClaimed.code = 6007;
2671
+ var SameClawbackReceiver = class extends Error {
2672
+ constructor(logs) {
2673
+ super("6008: New and old Clawback receivers are identical");
2674
+ this.logs = logs;
2675
+ this.code = 6008;
2676
+ this.name = "SameClawbackReceiver";
2677
+ this.msg = "New and old Clawback receivers are identical";
2678
+ }
2679
+ };
2680
+ SameClawbackReceiver.code = 6008;
2681
+ var ClawbackReceiverIsTokenVault = class extends Error {
2682
+ constructor(logs) {
2683
+ super("6009: Clawback receiver can not be the Token Vault");
2684
+ this.logs = logs;
2685
+ this.code = 6009;
2686
+ this.name = "ClawbackReceiverIsTokenVault";
2687
+ this.msg = "Clawback receiver can not be the Token Vault";
2688
+ }
2689
+ };
2690
+ ClawbackReceiverIsTokenVault.code = 6009;
2691
+ var SameAdmin = class extends Error {
2692
+ constructor(logs) {
2693
+ super("6010: New and old admin are identical");
2694
+ this.logs = logs;
2695
+ this.code = 6010;
2696
+ this.name = "SameAdmin";
2697
+ this.msg = "New and old admin are identical";
2698
+ }
2699
+ };
2700
+ SameAdmin.code = 6010;
2701
+ var ClaimExpired = class extends Error {
2702
+ constructor(logs) {
2703
+ super("6011: Claim window expired");
2704
+ this.logs = logs;
2705
+ this.code = 6011;
2706
+ this.name = "ClaimExpired";
2707
+ this.msg = "Claim window expired";
2708
+ }
2709
+ };
2710
+ ClaimExpired.code = 6011;
2711
+ var ArithmeticError = class extends Error {
2712
+ constructor(logs) {
2713
+ super("6012: Arithmetic Error (overflow/underflow)");
2714
+ this.logs = logs;
2715
+ this.code = 6012;
2716
+ this.name = "ArithmeticError";
2717
+ this.msg = "Arithmetic Error (overflow/underflow)";
2718
+ }
2719
+ };
2720
+ ArithmeticError.code = 6012;
2721
+ var StartTimestampAfterEnd = class extends Error {
2722
+ constructor(logs) {
2723
+ super("6013: Start Timestamp cannot be after end Timestamp");
2724
+ this.logs = logs;
2725
+ this.code = 6013;
2726
+ this.name = "StartTimestampAfterEnd";
2727
+ this.msg = "Start Timestamp cannot be after end Timestamp";
2728
+ }
2729
+ };
2730
+ StartTimestampAfterEnd.code = 6013;
2731
+ var TimestampsNotInFuture = class extends Error {
2732
+ constructor(logs) {
2733
+ super("6014: Timestamps cannot be in the past");
2734
+ this.logs = logs;
2735
+ this.code = 6014;
2736
+ this.name = "TimestampsNotInFuture";
2737
+ this.msg = "Timestamps cannot be in the past";
2738
+ }
2739
+ };
2740
+ TimestampsNotInFuture.code = 6014;
2741
+ var InvalidMint = class extends Error {
2742
+ constructor(logs) {
2743
+ super("6015: Invalid Mint");
2744
+ this.logs = logs;
2745
+ this.code = 6015;
2746
+ this.name = "InvalidMint";
2747
+ this.msg = "Invalid Mint";
2748
+ }
2749
+ };
2750
+ InvalidMint.code = 6015;
2751
+ var ClaimIsClosed = class extends Error {
2752
+ constructor(logs) {
2753
+ super("6016: Claim is closed");
2754
+ this.logs = logs;
2755
+ this.code = 6016;
2756
+ this.name = "ClaimIsClosed";
2757
+ this.msg = "Claim is closed";
2758
+ }
2759
+ };
2760
+ ClaimIsClosed.code = 6016;
2761
+ var ClaimsAreNotClosable = class extends Error {
2762
+ constructor(logs) {
2763
+ super("6017: Claims are not closable");
2764
+ this.logs = logs;
2765
+ this.code = 6017;
2766
+ this.name = "ClaimsAreNotClosable";
2767
+ this.msg = "Claims are not closable";
2768
+ }
2769
+ };
2770
+ ClaimsAreNotClosable.code = 6017;
2771
+ var InvalidUnlockPeriod = class extends Error {
2772
+ constructor(logs) {
2773
+ super("6018: Invalid unlock period");
2774
+ this.logs = logs;
2775
+ this.code = 6018;
2776
+ this.name = "InvalidUnlockPeriod";
2777
+ this.msg = "Invalid unlock period";
2778
+ }
2779
+ };
2780
+ InvalidUnlockPeriod.code = 6018;
2781
+ var DurationUpdateNotAllowed = class extends Error {
2782
+ constructor(logs) {
2783
+ super("6019: Duration update is not allowed");
2784
+ this.logs = logs;
2785
+ this.code = 6019;
2786
+ this.name = "DurationUpdateNotAllowed";
2787
+ this.msg = "Duration update is not allowed";
2788
+ }
2789
+ };
2790
+ DurationUpdateNotAllowed.code = 6019;
2791
+ var NoVestingAmount = class extends Error {
2792
+ constructor(logs) {
2793
+ super("6020: Vesting amounts are not set");
2794
+ this.logs = logs;
2795
+ this.code = 6020;
2796
+ this.name = "NoVestingAmount";
2797
+ this.msg = "Vesting amounts are not set";
2798
+ }
2799
+ };
2800
+ NoVestingAmount.code = 6020;
2801
+ var VestingAlreadyFinished = class extends Error {
2802
+ constructor(logs) {
2803
+ super("6021: Vesting already finished");
2804
+ this.logs = logs;
2805
+ this.code = 6021;
2806
+ this.name = "VestingAlreadyFinished";
2807
+ this.msg = "Vesting already finished";
2808
+ }
2809
+ };
2810
+ VestingAlreadyFinished.code = 6021;
2811
+ var InvalidAmounts = class extends Error {
2812
+ constructor(logs) {
2813
+ super("6022: Provided amounts are invalid");
2814
+ this.logs = logs;
2815
+ this.code = 6022;
2816
+ this.name = "InvalidAmounts";
2817
+ this.msg = "Provided amounts are invalid";
2818
+ }
2819
+ };
2820
+ InvalidAmounts.code = 6022;
2821
+ var ClaimsLimitReached = class extends Error {
2822
+ constructor(logs) {
2823
+ super("6023: Claims limit has been reached");
2824
+ this.logs = logs;
2825
+ this.code = 6023;
2826
+ this.name = "ClaimsLimitReached";
2827
+ this.msg = "Claims limit has been reached";
2828
+ }
2829
+ };
2830
+ ClaimsLimitReached.code = 6023;
2831
+ function fromCode2(code, logs) {
2832
+ switch (code) {
2833
+ case 6e3:
2834
+ return new InsufficientUnlockedTokens(logs);
2835
+ case 6001:
2836
+ return new InvalidProof(logs);
2837
+ case 6002:
2838
+ return new ExceededMaxClaim(logs);
2839
+ case 6003:
2840
+ return new MaxNodesExceeded(logs);
2841
+ case 6004:
2842
+ return new Unauthorized(logs);
2843
+ case 6005:
2844
+ return new OwnerMismatch(logs);
2845
+ case 6006:
2846
+ return new ClawbackBeforeStart(logs);
2847
+ case 6007:
2848
+ return new ClawbackAlreadyClaimed(logs);
2849
+ case 6008:
2850
+ return new SameClawbackReceiver(logs);
2851
+ case 6009:
2852
+ return new ClawbackReceiverIsTokenVault(logs);
2853
+ case 6010:
2854
+ return new SameAdmin(logs);
2855
+ case 6011:
2856
+ return new ClaimExpired(logs);
2857
+ case 6012:
2858
+ return new ArithmeticError(logs);
2859
+ case 6013:
2860
+ return new StartTimestampAfterEnd(logs);
2861
+ case 6014:
2862
+ return new TimestampsNotInFuture(logs);
2863
+ case 6015:
2864
+ return new InvalidMint(logs);
2865
+ case 6016:
2866
+ return new ClaimIsClosed(logs);
2867
+ case 6017:
2868
+ return new ClaimsAreNotClosable(logs);
2869
+ case 6018:
2870
+ return new InvalidUnlockPeriod(logs);
2871
+ case 6019:
2872
+ return new DurationUpdateNotAllowed(logs);
2873
+ case 6020:
2874
+ return new NoVestingAmount(logs);
2875
+ case 6021:
2876
+ return new VestingAlreadyFinished(logs);
2877
+ case 6022:
2878
+ return new InvalidAmounts(logs);
2879
+ case 6023:
2880
+ return new ClaimsLimitReached(logs);
2881
+ }
2882
+ return null;
2883
+ }
2884
+
2885
+ // solana/generated/errors/index.ts
2886
+ function fromCode3(code, logs) {
2887
+ return code >= 6e3 ? fromCode2(code, logs) : fromCode(code, logs);
2888
+ }
2889
+ function hasOwnProperty(obj, prop) {
2890
+ return Object.hasOwnProperty.call(obj, prop);
2891
+ }
2892
+ var errorRe = /Program (\w+) failed: custom program error: (\w+)/;
2893
+ function fromTxError(err, programId = PROGRAM_ID) {
2894
+ if (typeof err !== "object" || err === null || !hasOwnProperty(err, "logs") || !Array.isArray(err.logs)) {
2895
+ return null;
2896
+ }
2897
+ let firstMatch = null;
2898
+ for (const logLine of err.logs) {
2899
+ firstMatch = errorRe.exec(logLine);
2900
+ if (firstMatch !== null) {
2901
+ break;
2902
+ }
2903
+ }
2904
+ if (firstMatch === null) {
2905
+ return null;
2906
+ }
2907
+ const [programIdRaw, codeRaw] = firstMatch.slice(1);
2908
+ if (programIdRaw !== programId.toString()) {
2909
+ return null;
2910
+ }
2911
+ let errorCode;
2912
+ try {
2913
+ errorCode = parseInt(codeRaw, 16);
2914
+ } catch (parseErr) {
2915
+ return null;
2916
+ }
2917
+ return fromCode3(errorCode, err.logs);
2918
+ }
2919
+
2920
+ // solana/utils.ts
2921
+ var getAlignedDistributorPda = (programId, distributor) => {
2922
+ return PublicKey.findProgramAddressSync([ALIGNED_DISTRIBUTOR_PREFIX, distributor.toBuffer()], programId)[0];
2923
+ };
2924
+ var getTestOraclePda = (programId, mint, creator) => {
2925
+ return PublicKey.findProgramAddressSync([TEST_ORACLE_PREFIX, mint.toBuffer(), creator.toBuffer()], programId)[0];
2926
+ };
2927
+ function getDistributorPda(programId, mint, version) {
2928
+ const seeds = [
2929
+ DISTRIBUTOR_PREFIX,
2930
+ mint.toBuffer(),
2931
+ Buffer$1.from(new Uint8Array(new BigUint64Array([BigInt(version)]).buffer))
2932
+ ];
2933
+ return PublicKey.findProgramAddressSync(seeds, programId)[0];
2934
+ }
2935
+ function getClaimantStatusPda(programId, distributor, claimant) {
2936
+ const seeds = [CLAIM_STATUS_PREFIX, claimant.toBuffer(), distributor.toBuffer()];
2937
+ return PublicKey.findProgramAddressSync(seeds, programId)[0];
2938
+ }
2939
+ function getEventAuthorityPda(programId) {
2940
+ const seeds = [Buffer$1.from("__event_authority")];
2941
+ return PublicKey.findProgramAddressSync(seeds, programId)[0];
2942
+ }
2943
+ async function wrappedSignAndExecuteTransaction(...args) {
2944
+ try {
2945
+ return await signAndExecuteTransaction(...args);
2946
+ } catch (err) {
2947
+ if (err instanceof Error) {
2948
+ const parsed = fromTxError(err);
2949
+ if (parsed) {
2950
+ throw new ContractError(err, parsed.name, parsed.msg);
2951
+ }
2952
+ }
2953
+ throw err;
2954
+ }
2955
+ }
2956
+ async function calculateAmountWithTransferFees(connection, transferFeeConfig, transferAmount) {
2957
+ const epoch = await connection.getEpochInfo();
2958
+ const transferFee = epoch.epoch >= transferFeeConfig.newerTransferFee.epoch ? transferFeeConfig.newerTransferFee : transferFeeConfig.olderTransferFee;
2959
+ const transferFeeBasisPoints = BigInt(transferFee.transferFeeBasisPoints);
2960
+ let feeCharged = BigInt(0);
2961
+ if (transferFeeBasisPoints !== BigInt(0)) {
2962
+ const numerator = transferAmount * ONE_IN_BASIS_POINTS;
2963
+ const denominator = ONE_IN_BASIS_POINTS - transferFeeBasisPoints;
2964
+ const rawPreFeeAmount = divCeilN(numerator, denominator);
2965
+ const fee = rawPreFeeAmount - transferAmount;
2966
+ transferAmount = rawPreFeeAmount;
2967
+ feeCharged = fee > transferFee.maximumFee ? transferFee.maximumFee : fee;
2968
+ }
2969
+ return { transferAmount, feeCharged };
2970
+ }
2971
+
2972
+ // solana/clients/BaseDistributorClient.ts
2973
+ var BaseDistributorClient = class {
2974
+ constructor({
2975
+ clusterUrl,
2976
+ cluster = ICluster.Mainnet,
2977
+ commitment = "confirmed",
2978
+ programId = "",
2979
+ sendRate = 1,
2980
+ sendThrottler
2981
+ }) {
2982
+ this.commitment = commitment;
2983
+ this.connection = new Connection(clusterUrl, this.commitment);
2984
+ this.programId = programId !== "" ? new PublicKey(programId) : new PublicKey(DISTRIBUTOR_PROGRAM_ID[cluster]);
2985
+ this.sendThrottler = sendThrottler ?? buildSendThrottler(sendRate);
2986
+ const merkleDistributorProgram = {
2987
+ ...merkle_distributor_default
2988
+ };
2989
+ this.merkleDistributorProgram = new Program(merkleDistributorProgram, { connection: this.connection });
2990
+ }
2991
+ getConnection() {
2992
+ return this.connection;
2993
+ }
2994
+ getCommitment() {
2995
+ return typeof this.commitment == "string" ? this.commitment : this.commitment.commitment;
2996
+ }
2997
+ getDistributorProgramId() {
2998
+ return this.programId;
2999
+ }
3000
+ async prepareCreateInstructions(data, extParams) {
3001
+ if (!extParams.invoker.publicKey) {
3002
+ throw new Error("Invoker's PublicKey is not available, check passed wallet adapter!");
3003
+ }
3004
+ const { version, mint } = data;
3005
+ const ixs = prepareBaseInstructions(this.connection, extParams);
3006
+ const mintPublicKey = extParams.isNative ? NATIVE_MINT : new PublicKey(mint);
3007
+ const { mint: mintAccount, tokenProgramId } = await getMintAndProgram(this.connection, mintPublicKey);
3008
+ const transferFeeConfig = getTransferFeeConfig(mintAccount);
3009
+ const distributorPublicKey = getDistributorPda(this.programId, mintPublicKey, version);
3010
+ const tokenVault = await ata(mintPublicKey, distributorPublicKey, tokenProgramId);
3011
+ const senderTokens = await ata(mintPublicKey, extParams.invoker.publicKey, tokenProgramId);
3012
+ const accounts = {
3013
+ distributor: distributorPublicKey,
3014
+ clawbackReceiver: senderTokens,
3015
+ mint: mintPublicKey,
3016
+ tokenVault,
3017
+ admin: extParams.invoker.publicKey,
3018
+ systemProgram: SystemProgram.programId,
3019
+ associatedTokenProgram: ASSOCIATED_TOKEN_PROGRAM_ID,
3020
+ tokenProgram: tokenProgramId
3021
+ };
3022
+ if (extParams.isNative) {
3023
+ ixs.push(
3024
+ ...await prepareWrappedAccount(this.connection, extParams.invoker.publicKey, new BN6(data.maxTotalClaim))
3025
+ );
3026
+ }
3027
+ const newDistributorInstruction = await this.getNewDistributorInstruction(data, accounts);
3028
+ ixs.push(newDistributorInstruction);
3029
+ if (transferFeeConfig) {
3030
+ const { transferAmount, feeCharged } = await calculateAmountWithTransferFees(
3031
+ this.connection,
3032
+ transferFeeConfig,
3033
+ BigInt(data.maxTotalClaim.toString())
3034
+ );
3035
+ ixs.push(
3036
+ createTransferCheckedWithFeeInstruction(
3037
+ senderTokens,
3038
+ mintPublicKey,
3039
+ tokenVault,
3040
+ extParams.invoker.publicKey,
3041
+ transferAmount,
3042
+ mintAccount.decimals,
3043
+ feeCharged,
3044
+ void 0,
3045
+ tokenProgramId
3046
+ )
3047
+ );
3048
+ } else {
3049
+ ixs.push(
3050
+ createTransferCheckedInstruction(
3051
+ senderTokens,
3052
+ mintPublicKey,
3053
+ tokenVault,
3054
+ extParams.invoker.publicKey,
3055
+ BigInt(data.maxTotalClaim.toString()),
3056
+ mintAccount.decimals,
3057
+ void 0,
3058
+ tokenProgramId
3059
+ )
3060
+ );
3061
+ }
3062
+ return { distributorPublicKey, ixs };
3063
+ }
3064
+ async create(data, extParams) {
3065
+ const invoker = extParams.invoker.publicKey;
3066
+ invariant(invoker, "Invoker's PublicKey is not available, check passed wallet adapter!");
3067
+ const executionParams = this.unwrapExecutionParams(extParams);
3068
+ const { ixs, distributorPublicKey } = await createAndEstimateTransaction(
3069
+ (params) => this.prepareCreateInstructions(data, params),
3070
+ executionParams,
3071
+ (q) => q.ixs
3072
+ );
3073
+ const { tx, hash, context } = await prepareTransaction(this.connection, ixs, extParams.invoker.publicKey);
3074
+ const signature = await wrappedSignAndExecuteTransaction(
3075
+ this.connection,
3076
+ extParams.invoker,
3077
+ tx,
3078
+ {
3079
+ hash,
3080
+ context,
3081
+ commitment: this.getCommitment()
3082
+ },
3083
+ { sendThrottler: this.sendThrottler, skipSimulation: executionParams.skipSimulation }
3084
+ );
3085
+ return {
3086
+ ixs,
3087
+ txId: signature,
3088
+ metadataId: distributorPublicKey.toBase58()
3089
+ };
3090
+ }
3091
+ async claim(data, extParams, _serviceTransfer) {
3092
+ const executionParams = this.unwrapExecutionParams(extParams);
3093
+ const invoker = executionParams.invoker.publicKey;
3094
+ invariant(invoker, "Invoker's PublicKey is not available, check passed wallet adapter!");
3095
+ const ixs = await createAndEstimateTransaction(
3096
+ (params) => this.prepareClaimInstructions(data, params, _serviceTransfer),
3097
+ executionParams
3098
+ );
3099
+ const { tx, hash, context } = await prepareTransaction(this.connection, ixs, invoker);
3100
+ const signature = await wrappedSignAndExecuteTransaction(
3101
+ this.connection,
3102
+ executionParams.invoker,
3103
+ tx,
3104
+ {
3105
+ hash,
3106
+ context,
3107
+ commitment: this.getCommitment()
3108
+ },
3109
+ { sendThrottler: this.sendThrottler, skipSimulation: executionParams.skipSimulation }
3110
+ );
3111
+ return { ixs, txId: signature };
3112
+ }
3113
+ async prepareClaimInstructions(data, extParams, _serviceTransfer) {
3114
+ if (!extParams.invoker.publicKey) {
3115
+ throw new Error("Invoker's PublicKey is not available, check passed wallet adapter!");
3116
+ }
3117
+ const distributorPublicKey = new PublicKey(data.id);
3118
+ const distributor = await MerkleDistributor.fetch(this.connection, distributorPublicKey);
3119
+ if (!distributor) {
3120
+ throw new Error("Couldn't get account info");
3121
+ }
3122
+ const { tokenProgramId } = await getMintAndProgram(this.connection, distributor.mint);
3123
+ const ixs = prepareBaseInstructions(this.connection, extParams);
3124
+ ixs.push(
3125
+ ...await checkOrCreateAtaBatch(
3126
+ this.connection,
3127
+ [extParams.invoker.publicKey],
3128
+ distributor.mint,
3129
+ extParams.invoker,
3130
+ tokenProgramId
3131
+ )
3132
+ );
3133
+ const invokerTokens = await ata(distributor.mint, extParams.invoker.publicKey, tokenProgramId);
3134
+ const claimStatusPublicKey = getClaimantStatusPda(
3135
+ this.programId,
3136
+ distributorPublicKey,
3137
+ extParams.invoker.publicKey
3138
+ );
3139
+ const eventAuthorityPublicKey = getEventAuthorityPda(this.programId);
3140
+ const claimStatus = await ClaimStatus.fetch(this.connection, claimStatusPublicKey);
3141
+ const accounts = {
3142
+ distributor: distributorPublicKey,
3143
+ claimStatus: claimStatusPublicKey,
3144
+ from: distributor.tokenVault,
3145
+ to: invokerTokens,
3146
+ claimant: extParams.invoker.publicKey,
3147
+ mint: distributor.mint,
3148
+ tokenProgram: tokenProgramId,
3149
+ systemProgram: SystemProgram.programId,
3150
+ eventAuthority: eventAuthorityPublicKey,
3151
+ program: this.programId
3152
+ };
3153
+ if (!claimStatus) {
3154
+ const args = {
3155
+ amountLocked: new BN6(data.amountLocked),
3156
+ amountUnlocked: new BN6(data.amountUnlocked),
3157
+ proof: data.proof
3158
+ };
3159
+ ixs.push(newClaim(args, accounts, this.programId));
3160
+ }
3161
+ const nowTs = new BN6(Math.floor(Date.now() / 1e3));
3162
+ if (claimStatus || new BN6(data.amountLocked).gtn(0) && nowTs.sub(distributor.startTs).gte(distributor.unlockPeriod)) {
3163
+ ixs.push(claimLocked(accounts, this.programId));
3164
+ }
3165
+ ixs.push(
3166
+ this.prepareClaimFeeInstruction(
3167
+ extParams.invoker.publicKey,
3168
+ typeof _serviceTransfer === "bigint" ? _serviceTransfer : void 0
3169
+ )
3170
+ );
3171
+ return ixs;
3172
+ }
3173
+ async closeClaim(data, extParams) {
3174
+ const executionParams = this.unwrapExecutionParams(extParams);
3175
+ const invoker = executionParams.invoker.publicKey;
3176
+ invariant(invoker, "Invoker's PublicKey is not available, check passed wallet adapter!");
3177
+ const ixs = await createAndEstimateTransaction(
3178
+ (params) => this.prepareCloseClaimInstructions(data, params),
3179
+ executionParams
3180
+ );
3181
+ const { tx, hash, context } = await prepareTransaction(this.connection, ixs, invoker);
3182
+ const signature = await wrappedSignAndExecuteTransaction(
3183
+ this.connection,
3184
+ executionParams.invoker,
3185
+ tx,
3186
+ {
3187
+ hash,
3188
+ context,
3189
+ commitment: this.getCommitment()
3190
+ },
3191
+ { sendThrottler: this.sendThrottler, skipSimulation: executionParams.skipSimulation }
3192
+ );
3193
+ return { ixs, txId: signature };
3194
+ }
3195
+ async prepareCloseClaimInstructions(data, extParams) {
3196
+ if (!extParams.invoker.publicKey) {
3197
+ throw new Error("Invoker's PublicKey is not available, check passed wallet adapter!");
3198
+ }
3199
+ const distributorPublicKey = new PublicKey(data.id);
3200
+ const distributor = await MerkleDistributor.fetch(this.connection, distributorPublicKey);
3201
+ const claimantPublicKey = pk(data.claimant);
3202
+ if (!distributor) {
3203
+ throw new Error("Couldn't get distributor account info");
3204
+ }
3205
+ const ixs = prepareBaseInstructions(this.connection, extParams);
3206
+ const claimStatusPublicKey = getClaimantStatusPda(this.programId, distributorPublicKey, claimantPublicKey);
3207
+ const eventAuthorityPublicKey = getEventAuthorityPda(this.programId);
3208
+ const closeClaimAccounts = {
3209
+ adminOrClaimant: extParams.invoker.publicKey,
3210
+ distributor: distributorPublicKey,
3211
+ claimStatus: claimStatusPublicKey,
3212
+ claimant: claimantPublicKey,
3213
+ systemProgram: SystemProgram.programId,
3214
+ eventAuthority: eventAuthorityPublicKey,
3215
+ program: this.programId
3216
+ };
3217
+ const closeClaimArgs = {
3218
+ amountLocked: data.amountLocked ? new BN6(data.amountLocked) : void 0,
3219
+ amountUnlocked: data.amountUnlocked ? new BN6(data.amountUnlocked) : void 0,
3220
+ proof: data.proof
3221
+ };
3222
+ ixs.push(closeClaim(closeClaimArgs, closeClaimAccounts, this.programId));
3223
+ return ixs;
3224
+ }
3225
+ async prepareClawbackInstructions(data, extParams) {
3226
+ if (!extParams.invoker.publicKey) {
3227
+ throw new Error("Invoker's PublicKey is not available, check passed wallet adapter!");
3228
+ }
3229
+ const distributorPublicKey = new PublicKey(data.id);
3230
+ const distributor = await MerkleDistributor.fetch(this.connection, distributorPublicKey);
3231
+ if (!distributor) {
3232
+ throw new Error("Couldn't get account info");
3233
+ }
3234
+ const { tokenProgramId } = await getMintAndProgram(this.connection, distributor.mint);
3235
+ const ixs = prepareBaseInstructions(this.connection, extParams);
3236
+ ixs.push(
3237
+ ...await checkOrCreateAtaBatch(
3238
+ this.connection,
3239
+ [extParams.invoker.publicKey],
3240
+ distributor.mint,
3241
+ extParams.invoker,
3242
+ tokenProgramId
3243
+ )
3244
+ );
3245
+ const accounts = {
3246
+ distributor: distributorPublicKey,
3247
+ from: distributor.tokenVault,
3248
+ to: distributor.clawbackReceiver,
3249
+ admin: extParams.invoker.publicKey,
3250
+ mint: distributor.mint,
3251
+ systemProgram: SystemProgram.programId,
3252
+ tokenProgram: tokenProgramId
3253
+ };
3254
+ const clawbackInstruction = await this.getClawbackInstruction(accounts);
3255
+ ixs.push(clawbackInstruction);
3256
+ return ixs;
3257
+ }
3258
+ async clawback(data, extParams) {
3259
+ const executionParams = this.unwrapExecutionParams(extParams);
3260
+ const invoker = executionParams.invoker.publicKey;
3261
+ invariant(invoker, "Invoker's PublicKey is not available, check passed wallet adapter!");
3262
+ const ixs = await createAndEstimateTransaction(
3263
+ (params) => this.prepareClawbackInstructions(data, params),
3264
+ executionParams
3265
+ );
3266
+ const { tx, hash, context } = await prepareTransaction(this.connection, ixs, invoker);
3267
+ const signature = await wrappedSignAndExecuteTransaction(
3268
+ this.connection,
3269
+ executionParams.invoker,
3270
+ tx,
3271
+ {
3272
+ hash,
3273
+ context,
3274
+ commitment: this.getCommitment()
3275
+ },
3276
+ { sendThrottler: this.sendThrottler, skipSimulation: executionParams.skipSimulation }
3277
+ );
3278
+ return { ixs, txId: signature };
3279
+ }
3280
+ async getClaims(data) {
3281
+ const claimStatusPublicKeys = data.map(({ id, recipient }) => {
3282
+ return getClaimantStatusPda(this.programId, new PublicKey(id), new PublicKey(recipient));
3283
+ });
3284
+ return this.connection.getMultipleAccountsInfo(claimStatusPublicKeys).then((accounts) => {
3285
+ return accounts.map((account) => {
3286
+ if (!account) {
3287
+ return account;
3288
+ }
3289
+ try {
3290
+ return decode(this.merkleDistributorProgram, "claimStatus", account.data);
3291
+ } catch (baseClaimStatusError) {
3292
+ try {
3293
+ return decode(this.merkleDistributorProgram, "compressedClaimStatus", account.data);
3294
+ } catch (compressedClaimStatusError) {
3295
+ throw new Error("Couldn't decode claim status");
3296
+ }
3297
+ }
3298
+ });
3299
+ });
3300
+ }
3301
+ async getDistributors(data) {
3302
+ const distributorPublicKeys = data.ids.map((distributorId) => new PublicKey(distributorId));
3303
+ return MerkleDistributor.fetchMultiple(this.connection, distributorPublicKeys, this.programId);
3304
+ }
3305
+ async searchDistributors(data) {
3306
+ const filters = [{ memcmp: { offset: 0, bytes: bs58.encode(MerkleDistributor.discriminator) } }];
3307
+ if (data.mint) {
3308
+ filters.push({
3309
+ memcmp: {
3310
+ offset: DISTRIBUTOR_MINT_OFFSET,
3311
+ bytes: data.mint
3312
+ }
3313
+ });
3314
+ }
3315
+ if (data.admin) {
3316
+ filters.push({
3317
+ memcmp: {
3318
+ offset: DISTRIBUTOR_ADMIN_OFFSET,
3319
+ bytes: data.admin
3320
+ }
3321
+ });
3322
+ }
3323
+ const accounts = await this.connection.getProgramAccounts(this.programId, { filters });
3324
+ return accounts.map(({ pubkey, account }) => ({
3325
+ publicKey: pubkey,
3326
+ account: MerkleDistributor.decode(account.data)
3327
+ }));
3328
+ }
3329
+ prepareClaimFeeInstruction(payer, fee = AIRDROP_CLAIM_FEE) {
3330
+ return SystemProgram.transfer({
3331
+ fromPubkey: payer,
3332
+ toPubkey: STREAMFLOW_TREASURY_PUBLIC_KEY,
3333
+ lamports: fee
3334
+ });
3335
+ }
3336
+ getNewDistributorArgs(data) {
3337
+ const args = {
3338
+ version: new BN6(data.version),
3339
+ root: data.root,
3340
+ maxTotalClaim: new BN6(data.maxTotalClaim),
3341
+ maxNumNodes: new BN6(data.maxNumNodes),
3342
+ unlockPeriod: new BN6(data.unlockPeriod),
3343
+ startVestingTs: new BN6(data.startVestingTs),
3344
+ endVestingTs: new BN6(data.endVestingTs),
3345
+ clawbackStartTs: new BN6(data.clawbackStartTs),
3346
+ claimsClosableByAdmin: data.claimsClosableByAdmin,
3347
+ claimsClosableByClaimant: data.claimsClosableByClaimant,
3348
+ claimsLimit: data.claimsLimit
3349
+ };
3350
+ const nowTs = new BN6(Math.floor(Date.now() / 1e3));
3351
+ const endVestingTs = args.endVestingTs.isZero() ? nowTs : args.endVestingTs;
3352
+ const startVestingTs = args.startVestingTs.isZero() ? nowTs : args.startVestingTs;
3353
+ if (endVestingTs.gt(startVestingTs) && endVestingTs.sub(startVestingTs).lt(args.unlockPeriod)) {
3354
+ throw new Error("The unlock period cannot be longer than the total vesting duration!");
3355
+ }
3356
+ return args;
3357
+ }
3358
+ unwrapExecutionParams(extParams) {
3359
+ return unwrapExecutionParams(extParams, this.connection);
3360
+ }
3361
+ };
3362
+ function decode(program, accountName, accInfo, programKey) {
3363
+ invariant(
3364
+ program,
3365
+ `Decoding program with key ${program.programId?.toBase58() ?? "N/A"} is not available`
3366
+ );
3367
+ const accountEntity = program.idl.accounts?.find((acc) => acc.name === accountName);
3368
+ invariant(
3369
+ !!accountEntity,
3370
+ `Decoding program with key ${programKey} doesn't specify account with name ${String(accountName)}`
3371
+ );
3372
+ return program.coder.accounts.decode(accountName, accInfo);
3373
+ }
3374
+
3375
+ // solana/clients/SolanaDistributorClient.ts
3376
+ var SolanaDistributorClient = class extends BaseDistributorClient {
3377
+ async getNewDistributorInstruction(data, accounts) {
3378
+ const args = this.getNewDistributorArgs(data);
3379
+ return newDistributor(args, accounts, this.programId);
3380
+ }
3381
+ async getClawbackInstruction(accounts) {
3382
+ return clawback(accounts, this.programId);
3383
+ }
3384
+ };
3385
+
3386
+ // solana/descriptor/idl/aligned_distributor.json
3387
+ var aligned_distributor_default = {
3388
+ address: "aMERKpFAWoChCi5oZwPvgsSCoGpZKBiU7fi76bdZjt2",
3389
+ metadata: {
3390
+ name: "aligned_distributor",
3391
+ version: "1.5.0",
3392
+ spec: "0.1.0",
3393
+ description: "Proxy for merkle distributor that updates Vesting duration according to token market performance."
3394
+ },
3395
+ instructions: [
3396
+ {
3397
+ name: "change_oracle",
3398
+ discriminator: [177, 227, 230, 103, 13, 72, 141, 248],
3399
+ accounts: [
3400
+ {
3401
+ name: "aligned_distributor",
3402
+ docs: ["The [MerkleDistributor]."],
3403
+ writable: true
3404
+ },
3405
+ {
3406
+ name: "admin",
3407
+ docs: ["Admin signer"],
3408
+ writable: true,
3409
+ signer: true
3410
+ },
3411
+ {
3412
+ name: "new_price_oracle"
3413
+ }
3414
+ ],
3415
+ args: [
3416
+ {
3417
+ name: "ix",
3418
+ type: {
3419
+ defined: {
3420
+ name: "ChangeOracleParams"
3421
+ }
3422
+ }
3423
+ }
3424
+ ]
3425
+ },
3426
+ {
3427
+ name: "clawback",
3428
+ discriminator: [111, 92, 142, 79, 33, 234, 82, 27],
3429
+ accounts: [
3430
+ {
3431
+ name: "aligned_distributor",
3432
+ docs: ["The [AlignedDistributor]."],
3433
+ writable: true,
3434
+ pda: {
3435
+ seeds: [
3436
+ {
3437
+ kind: "const",
3438
+ value: [97, 108, 105, 103, 110, 101, 100, 45, 100, 105, 115, 116, 114, 105, 98, 117, 116, 111, 114]
3439
+ },
3440
+ {
3441
+ kind: "account",
3442
+ path: "distributor"
3443
+ }
3444
+ ]
3445
+ }
3446
+ },
3447
+ {
3448
+ name: "distributor",
3449
+ docs: ["The [MerkleDistributor]."],
3450
+ writable: true
3451
+ },
3452
+ {
3453
+ name: "from",
3454
+ docs: ["Distributor ATA containing the tokens to distribute."],
3455
+ writable: true
3456
+ },
3457
+ {
3458
+ name: "to",
3459
+ docs: ["The Clawback token account."],
3460
+ writable: true
3461
+ },
3462
+ {
3463
+ name: "admin",
3464
+ docs: ["Only Admin can trigger the clawback of funds"],
3465
+ writable: true,
3466
+ signer: true
3467
+ },
3468
+ {
3469
+ name: "mint"
3470
+ },
3471
+ {
3472
+ name: "distributor_program",
3473
+ address: "MErKy6nZVoVAkryxAejJz2juifQ4ArgLgHmaJCQkU7N"
3474
+ },
3475
+ {
3476
+ name: "system_program",
3477
+ docs: ["The [System] program."],
3478
+ address: "11111111111111111111111111111111"
3479
+ },
3480
+ {
3481
+ name: "token_program",
3482
+ docs: ["SPL [Token] program."]
3483
+ }
3484
+ ],
3485
+ args: []
3486
+ },
3487
+ {
3488
+ name: "create_test_oracle",
3489
+ discriminator: [183, 110, 4, 11, 131, 220, 84, 12],
3490
+ accounts: [
3491
+ {
3492
+ name: "creator",
3493
+ writable: true,
3494
+ signer: true
3495
+ },
3496
+ {
3497
+ name: "mint"
3498
+ },
3499
+ {
3500
+ name: "test_oracle",
3501
+ writable: true,
3502
+ pda: {
3503
+ seeds: [
3504
+ {
3505
+ kind: "const",
3506
+ value: [116, 101, 115, 116, 45, 111, 114, 97, 99, 108, 101]
3507
+ },
3508
+ {
3509
+ kind: "account",
3510
+ path: "mint"
3511
+ },
3512
+ {
3513
+ kind: "account",
3514
+ path: "creator"
3515
+ }
3516
+ ]
3517
+ }
3518
+ },
3519
+ {
3520
+ name: "system_program",
3521
+ address: "11111111111111111111111111111111"
3522
+ }
3523
+ ],
3524
+ args: [
3525
+ {
3526
+ name: "ix",
3527
+ type: {
3528
+ defined: {
3529
+ name: "CreateTestOracleParams"
3530
+ }
3531
+ }
3532
+ }
3533
+ ]
3534
+ },
3535
+ {
3536
+ name: "migrate_test_oracle",
3537
+ discriminator: [203, 254, 19, 3, 172, 185, 85, 190],
3538
+ accounts: [
3539
+ {
3540
+ name: "payer",
3541
+ writable: true,
3542
+ signer: true
3543
+ },
3544
+ {
3545
+ name: "mint"
3546
+ },
3547
+ {
3548
+ name: "creator"
3549
+ },
3550
+ {
3551
+ name: "test_oracle",
3552
+ writable: true,
3553
+ pda: {
3554
+ seeds: [
3555
+ {
3556
+ kind: "const",
3557
+ value: [116, 101, 115, 116, 45, 111, 114, 97, 99, 108, 101]
3558
+ },
3559
+ {
3560
+ kind: "account",
3561
+ path: "mint"
3562
+ },
3563
+ {
3564
+ kind: "account",
3565
+ path: "creator"
3566
+ }
3567
+ ]
3568
+ }
3569
+ },
3570
+ {
3571
+ name: "system_program",
3572
+ address: "11111111111111111111111111111111"
3573
+ }
3574
+ ],
3575
+ args: []
3576
+ },
3577
+ {
3578
+ name: "new_distributor",
3579
+ discriminator: [32, 139, 112, 171, 0, 2, 225, 155],
3580
+ accounts: [
3581
+ {
3582
+ name: "aligned_distributor",
3583
+ writable: true,
3584
+ pda: {
3585
+ seeds: [
3586
+ {
3587
+ kind: "const",
3588
+ value: [97, 108, 105, 103, 110, 101, 100, 45, 100, 105, 115, 116, 114, 105, 98, 117, 116, 111, 114]
3589
+ },
3590
+ {
3591
+ kind: "account",
3592
+ path: "distributor"
3593
+ }
3594
+ ]
3595
+ }
3596
+ },
3597
+ {
3598
+ name: "price_oracle"
3599
+ },
3600
+ {
3601
+ name: "withdrawor",
3602
+ writable: true,
3603
+ address: "wdrwhnCv4pzW8beKsbPa4S2UDZrXenjg16KJdKSpb5u"
3604
+ },
3605
+ {
3606
+ name: "clawback_receiver",
3607
+ docs: ["Clawback receiver token account"],
3608
+ writable: true
3609
+ },
3610
+ {
3611
+ name: "mint",
3612
+ docs: ["The mint to distribute."]
3613
+ },
3614
+ {
3615
+ name: "distributor",
3616
+ writable: true
3617
+ },
3618
+ {
3619
+ name: "token_vault",
3620
+ writable: true
3621
+ },
3622
+ {
3623
+ name: "admin",
3624
+ docs: [
3625
+ "Original Admin wallet, responsible for creating the distributor and paying for the transaction.",
3626
+ "Also has the authority to set the clawback receiver and change itself."
3627
+ ],
3628
+ writable: true,
3629
+ signer: true
3630
+ },
3631
+ {
3632
+ name: "distributor_program",
3633
+ docs: ["MerkleDistributor program"],
3634
+ address: "MErKy6nZVoVAkryxAejJz2juifQ4ArgLgHmaJCQkU7N"
3635
+ },
3636
+ {
3637
+ name: "system_program",
3638
+ docs: ["The [System] program."],
3639
+ address: "11111111111111111111111111111111"
3640
+ },
3641
+ {
3642
+ name: "associated_token_program",
3643
+ docs: ["The [Associated Token] program."],
3644
+ address: "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"
3645
+ },
3646
+ {
3647
+ name: "token_program",
3648
+ docs: ["The [Token] program."]
3649
+ }
3650
+ ],
3651
+ args: [
3652
+ {
3653
+ name: "ix",
3654
+ type: {
3655
+ defined: {
3656
+ name: "NewDistributorIx"
3657
+ }
3658
+ }
3659
+ }
3660
+ ]
3661
+ },
3662
+ {
3663
+ name: "realloc_test_oracle",
3664
+ discriminator: [234, 221, 116, 4, 198, 251, 244, 206],
3665
+ accounts: [
3666
+ {
3667
+ name: "payer",
3668
+ writable: true,
3669
+ signer: true
3670
+ },
3671
+ {
3672
+ name: "mint"
3673
+ },
3674
+ {
3675
+ name: "creator"
3676
+ },
3677
+ {
3678
+ name: "test_oracle",
3679
+ writable: true,
3680
+ pda: {
3681
+ seeds: [
3682
+ {
3683
+ kind: "const",
3684
+ value: [116, 101, 115, 116, 45, 111, 114, 97, 99, 108, 101]
3685
+ },
3686
+ {
3687
+ kind: "account",
3688
+ path: "mint"
3689
+ },
3690
+ {
3691
+ kind: "account",
3692
+ path: "creator"
3693
+ }
3694
+ ]
3695
+ }
3696
+ },
3697
+ {
3698
+ name: "system_program",
3699
+ address: "11111111111111111111111111111111"
3700
+ }
3701
+ ],
3702
+ args: []
3703
+ },
3704
+ {
3705
+ name: "set_admin",
3706
+ discriminator: [251, 163, 0, 52, 91, 194, 187, 92],
3707
+ accounts: [
3708
+ {
3709
+ name: "aligned_distributor",
3710
+ docs: ["The [MerkleDistributor]."],
3711
+ writable: true
3712
+ },
3713
+ {
3714
+ name: "admin",
3715
+ docs: ["Admin signer"],
3716
+ writable: true,
3717
+ signer: true
3718
+ },
3719
+ {
3720
+ name: "new_admin",
3721
+ docs: ["New admin account"],
3722
+ writable: true
3723
+ }
3724
+ ],
3725
+ args: []
3726
+ },
3727
+ {
3728
+ name: "set_test_oracle_authority",
3729
+ discriminator: [26, 66, 233, 99, 38, 118, 181, 247],
3730
+ accounts: [
3731
+ {
3732
+ name: "authority",
3733
+ writable: true,
3734
+ signer: true
3735
+ },
3736
+ {
3737
+ name: "test_oracle",
3738
+ writable: true
3739
+ },
3740
+ {
3741
+ name: "new_authority"
3742
+ }
3743
+ ],
3744
+ args: []
3745
+ },
3746
+ {
3747
+ name: "update_duration",
3748
+ discriminator: [69, 126, 172, 250, 164, 14, 10, 161],
3749
+ accounts: [
3750
+ {
3751
+ name: "authority",
3752
+ docs: ["Wallet authorised to call this method"],
3753
+ writable: true,
3754
+ signer: true
3755
+ },
3756
+ {
3757
+ name: "aligned_distributor",
3758
+ docs: ["The account holding the proxy parameters."],
3759
+ writable: true,
3760
+ pda: {
3761
+ seeds: [
3762
+ {
3763
+ kind: "const",
3764
+ value: [97, 108, 105, 103, 110, 101, 100, 45, 100, 105, 115, 116, 114, 105, 98, 117, 116, 111, 114]
3765
+ },
3766
+ {
3767
+ kind: "account",
3768
+ path: "distributor"
3769
+ }
3770
+ ]
3771
+ }
3772
+ },
3773
+ {
3774
+ name: "distributor",
3775
+ docs: ["The account holding the vesting parameters."],
3776
+ writable: true
3777
+ },
3778
+ {
3779
+ name: "price_oracle",
3780
+ relations: ["aligned_distributor"]
3781
+ },
3782
+ {
3783
+ name: "distributor_program",
3784
+ docs: ["MerkleDistributor program"],
3785
+ address: "MErKy6nZVoVAkryxAejJz2juifQ4ArgLgHmaJCQkU7N"
3786
+ },
3787
+ {
3788
+ name: "system_program",
3789
+ address: "11111111111111111111111111111111"
3790
+ }
3791
+ ],
3792
+ args: []
3793
+ },
3794
+ {
3795
+ name: "update_test_oracle",
3796
+ discriminator: [158, 147, 215, 74, 34, 123, 80, 76],
3797
+ accounts: [
3798
+ {
3799
+ name: "authority",
3800
+ writable: true,
3801
+ signer: true
3802
+ },
3803
+ {
3804
+ name: "test_oracle",
3805
+ writable: true
3806
+ }
3807
+ ],
3808
+ args: [
3809
+ {
3810
+ name: "ix",
3811
+ type: {
3812
+ defined: {
3813
+ name: "UpdateTestOracleParams"
3814
+ }
3815
+ }
3816
+ }
3817
+ ]
3818
+ }
3819
+ ],
3820
+ accounts: [
3821
+ {
3822
+ name: "AlignedDistributor",
3823
+ discriminator: [128, 76, 80, 203, 248, 175, 3, 43]
3824
+ },
3825
+ {
3826
+ name: "MerkleDistributor",
3827
+ discriminator: [77, 119, 139, 70, 84, 247, 12, 26]
3828
+ },
3829
+ {
3830
+ name: "TestOracle",
3831
+ discriminator: [198, 49, 63, 134, 232, 251, 168, 28]
3832
+ }
3833
+ ],
3834
+ errors: [
3835
+ {
3836
+ code: 6e3,
3837
+ name: "Unauthorized",
3838
+ msg: "Account is not authorized to execute this instruction"
3839
+ },
3840
+ {
3841
+ code: 6001,
3842
+ name: "ArithmeticError",
3843
+ msg: "Arithmetic error"
3844
+ },
3845
+ {
3846
+ code: 6002,
3847
+ name: "NoLockedAmount",
3848
+ msg: "Provided Distributor has no locked amount"
3849
+ },
3850
+ {
3851
+ code: 6003,
3852
+ name: "InvalidUpdatePeriod",
3853
+ msg: "Provided is invalid, should be equal or more than 30 seconds and unlock_period"
3854
+ },
3855
+ {
3856
+ code: 6004,
3857
+ name: "InvalidTickSize",
3858
+ msg: "Provided percentage tick size is invalid"
3859
+ },
3860
+ {
3861
+ code: 6005,
3862
+ name: "InvalidPercentageBoundaries",
3863
+ msg: "Provided percentage bounds are invalid"
3864
+ },
3865
+ {
3866
+ code: 6006,
3867
+ name: "InvalidPriceBoundaries",
3868
+ msg: "Provided price bounds are invalid"
3869
+ },
3870
+ {
3871
+ code: 6007,
3872
+ name: "UnsupportedOracle",
3873
+ msg: "Unsupported price oracle"
3874
+ },
3875
+ {
3876
+ code: 6008,
3877
+ name: "InvalidOracleAccount",
3878
+ msg: "Invalid oracle account"
3879
+ },
3880
+ {
3881
+ code: 6009,
3882
+ name: "InvalidOraclePrice",
3883
+ msg: "Invalid oracle price"
3884
+ },
3885
+ {
3886
+ code: 6010,
3887
+ name: "DurationAlreadyUpdated",
3888
+ msg: "Duration has been already updated in this period"
3889
+ },
3890
+ {
3891
+ code: 6011,
3892
+ name: "VestingAlreadyFinished",
3893
+ msg: "Vesting already finished"
3894
+ },
3895
+ {
3896
+ code: 6012,
3897
+ name: "SameAdmin",
3898
+ msg: "New and old admin are identical"
3899
+ },
3900
+ {
3901
+ code: 6013,
3902
+ name: "InvalidMint",
3903
+ msg: "Invalid Mint"
3904
+ }
3905
+ ],
3906
+ types: [
3907
+ {
3908
+ name: "AlignedDistributor",
3909
+ docs: ["State for the account which distributes tokens."],
3910
+ type: {
3911
+ kind: "struct",
3912
+ fields: [
3913
+ {
3914
+ name: "bump",
3915
+ docs: ["Bump seed."],
3916
+ type: "u8"
3917
+ },
3918
+ {
3919
+ name: "distributor",
3920
+ docs: ["[Mint] of the token to be distributed."],
3921
+ type: "pubkey"
3922
+ },
3923
+ {
3924
+ name: "admin",
3925
+ docs: ["Admin wallet"],
3926
+ type: "pubkey"
3927
+ },
3928
+ {
3929
+ name: "price_oracle_type",
3930
+ docs: ["Type of the Oracle used to derive Token Price"],
3931
+ type: {
3932
+ defined: {
3933
+ name: "OracleType"
3934
+ }
3935
+ }
3936
+ },
3937
+ {
3938
+ name: "price_oracle",
3939
+ docs: ["Address of the Price Oracle"],
3940
+ type: "pubkey"
3941
+ },
3942
+ {
3943
+ name: "update_period",
3944
+ docs: ["Period of updates, can be different from unlock period if needed"],
3945
+ type: "u64"
3946
+ },
3947
+ {
3948
+ name: "min_price",
3949
+ docs: ["Min price boundary"],
3950
+ type: "u64"
3951
+ },
3952
+ {
3953
+ name: "max_price",
3954
+ docs: ["Max price boundary"],
3955
+ type: "u64"
3956
+ },
3957
+ {
3958
+ name: "min_percentage",
3959
+ docs: ["Min percentage boundary, can be 0 that equals 1 Raw Token"],
3960
+ type: "u64"
3961
+ },
3962
+ {
3963
+ name: "max_percentage",
3964
+ docs: ["Max percentage boundary"],
3965
+ type: "u64"
3966
+ },
3967
+ {
3968
+ name: "tick_size",
3969
+ docs: ["Ticket size for percentage boundaries"],
3970
+ type: "u64"
3971
+ },
3972
+ {
3973
+ name: "start_ts",
3974
+ docs: ["Copy start ts from the Distributor to be used in the worker"],
3975
+ type: "u64"
3976
+ },
3977
+ {
3978
+ name: "end_ts",
3979
+ docs: ["Copy end ts from the Distributor to be used in the worker"],
3980
+ type: "u64"
3981
+ },
3982
+ {
3983
+ name: "last_duration_update_ts",
3984
+ docs: [
3985
+ "Copy last_duration_update_ts from Distributor for our worker to be able to fetch it in one call with the proxy"
3986
+ ],
3987
+ type: "u64"
3988
+ },
3989
+ {
3990
+ name: "last_price",
3991
+ docs: ["Price used on last amount calculation"],
3992
+ type: "u64"
3993
+ },
3994
+ {
3995
+ name: "initial_duration",
3996
+ docs: ["Initial Airdrop Vesting duration"],
3997
+ type: "u64"
3998
+ },
3999
+ {
4000
+ name: "initial_price",
4001
+ docs: ["Initial token price at the time of Contract creation"],
4002
+ type: "u64"
4003
+ },
4004
+ {
4005
+ name: "distributor_clawed_back",
4006
+ docs: ["Whether distributor was clawed backed"],
4007
+ type: "bool"
4008
+ },
4009
+ {
4010
+ name: "mint",
4011
+ docs: ["Mint for which the distributor was created"],
4012
+ type: "pubkey"
4013
+ },
4014
+ {
4015
+ name: "buffer_2",
4016
+ docs: ["Buffer for additional fields"],
4017
+ type: {
4018
+ array: ["u8", 32]
4019
+ }
4020
+ },
4021
+ {
4022
+ name: "buffer_3",
4023
+ docs: ["Buffer for additional fields"],
4024
+ type: {
4025
+ array: ["u8", 32]
4026
+ }
4027
+ }
4028
+ ]
4029
+ }
4030
+ },
4031
+ {
4032
+ name: "ChangeOracleParams",
4033
+ type: {
4034
+ kind: "struct",
4035
+ fields: [
4036
+ {
4037
+ name: "oracle_type",
4038
+ type: {
4039
+ defined: {
4040
+ name: "OracleType"
4041
+ }
4042
+ }
4043
+ }
4044
+ ]
4045
+ }
4046
+ },
4047
+ {
4048
+ name: "CreateTestOracleParams",
4049
+ type: {
4050
+ kind: "struct",
4051
+ fields: [
4052
+ {
4053
+ name: "price",
4054
+ type: "u64"
4055
+ },
4056
+ {
4057
+ name: "expo",
4058
+ type: "i32"
4059
+ },
4060
+ {
4061
+ name: "conf",
4062
+ type: "u64"
4063
+ },
4064
+ {
4065
+ name: "publish_time",
4066
+ type: "i64"
4067
+ }
4068
+ ]
4069
+ }
4070
+ },
4071
+ {
4072
+ name: "MerkleDistributor",
4073
+ docs: ["State for the account which distributes tokens."],
4074
+ type: {
4075
+ kind: "struct",
4076
+ fields: [
4077
+ {
4078
+ name: "bump",
4079
+ docs: ["Bump seed."],
4080
+ type: "u8"
4081
+ },
4082
+ {
4083
+ name: "version",
4084
+ docs: ["Version of the airdrop"],
4085
+ type: "u64"
4086
+ },
4087
+ {
4088
+ name: "root",
4089
+ docs: ["The 256-bit merkle root."],
4090
+ type: {
4091
+ array: ["u8", 32]
4092
+ }
4093
+ },
4094
+ {
4095
+ name: "mint",
4096
+ docs: ["[Mint] of the token to be distributed."],
4097
+ type: "pubkey"
4098
+ },
4099
+ {
4100
+ name: "token_vault",
4101
+ docs: ["Token Address of the vault"],
4102
+ type: "pubkey"
4103
+ },
4104
+ {
4105
+ name: "max_total_claim",
4106
+ docs: ["Maximum number of tokens that can ever be claimed from this [MerkleDistributor]."],
4107
+ type: "u64"
4108
+ },
4109
+ {
4110
+ name: "max_num_nodes",
4111
+ docs: ["Maximum number of nodes in [MerkleDistributor]."],
4112
+ type: "u64"
4113
+ },
4114
+ {
4115
+ name: "unlock_period",
4116
+ docs: ["Time step (period) in seconds per which the unlock occurs"],
4117
+ type: "u64"
4118
+ },
4119
+ {
4120
+ name: "total_amount_claimed",
4121
+ docs: ["Total amount of tokens that have been claimed."],
4122
+ type: "u64"
4123
+ },
4124
+ {
4125
+ name: "num_nodes_claimed",
4126
+ docs: ["Number of nodes that have been claimed."],
4127
+ type: "u64"
4128
+ },
4129
+ {
4130
+ name: "start_ts",
4131
+ docs: ["Lockup time start (Unix Timestamp)"],
4132
+ type: "u64"
4133
+ },
4134
+ {
4135
+ name: "end_ts",
4136
+ docs: ["Lockup time end (Unix Timestamp)"],
4137
+ type: "u64"
4138
+ },
4139
+ {
4140
+ name: "clawback_start_ts",
4141
+ docs: ["Clawback start (Unix Timestamp)"],
4142
+ type: "u64"
4143
+ },
4144
+ {
4145
+ name: "clawback_receiver",
4146
+ docs: ["Clawback receiver"],
4147
+ type: "pubkey"
4148
+ },
4149
+ {
4150
+ name: "admin",
4151
+ docs: ["Admin wallet"],
4152
+ type: "pubkey"
4153
+ },
4154
+ {
4155
+ name: "clawed_back",
4156
+ docs: ["Whether or not the distributor has been clawed back"],
4157
+ type: "bool"
4158
+ },
4159
+ {
4160
+ name: "claims_closable_by_admin",
4161
+ docs: ["Whether claims are closable by the admin or not"],
4162
+ type: "bool"
4163
+ },
4164
+ {
4165
+ name: "can_update_duration",
4166
+ docs: ["Whether admin can update vesting duration"],
4167
+ type: "bool"
4168
+ },
4169
+ {
4170
+ name: "total_amount_unlocked",
4171
+ docs: ["Total amount of funds unlocked (cliff/instant)"],
4172
+ type: "u64"
4173
+ },
4174
+ {
4175
+ name: "total_amount_locked",
4176
+ docs: ["Total amount of funds locked (vested)"],
4177
+ type: "u64"
4178
+ },
4179
+ {
4180
+ name: "last_duration_update_ts",
4181
+ docs: ["Timestamp when update was last called"],
4182
+ type: "u64"
4183
+ },
4184
+ {
4185
+ name: "total_claimable_pre_update",
4186
+ docs: [
4187
+ "Total amount of locked amount claimable as of last duration update, ever increasing total, accumulates with each update"
4188
+ ],
4189
+ type: "u64"
4190
+ },
4191
+ {
4192
+ name: "clawed_back_ts",
4193
+ docs: ["Timestamp when funds were clawed back"],
4194
+ type: "u64"
4195
+ },
4196
+ {
4197
+ name: "claims_closable_by_claimant",
4198
+ docs: ["Whether claims are closable by claimant or not"],
4199
+ type: "bool"
4200
+ },
4201
+ {
4202
+ name: "claims_limit",
4203
+ docs: ["Limit number of claims"],
4204
+ type: "u16"
4205
+ },
4206
+ {
4207
+ name: "buffer_2",
4208
+ docs: ["Buffer for additional fields"],
4209
+ type: {
4210
+ array: ["u8", 20]
4211
+ }
4212
+ },
4213
+ {
4214
+ name: "buffer_3",
4215
+ docs: ["Buffer for additional fields"],
4216
+ type: {
4217
+ array: ["u8", 32]
4218
+ }
4219
+ }
4220
+ ]
4221
+ }
4222
+ },
4223
+ {
4224
+ name: "NewDistributorIx",
4225
+ type: {
4226
+ kind: "struct",
4227
+ fields: [
4228
+ {
4229
+ name: "version",
4230
+ type: "u64"
4231
+ },
4232
+ {
4233
+ name: "root",
4234
+ type: {
4235
+ array: ["u8", 32]
4236
+ }
4237
+ },
4238
+ {
4239
+ name: "max_total_claim",
4240
+ type: "u64"
4241
+ },
4242
+ {
4243
+ name: "max_num_nodes",
4244
+ type: "u64"
4245
+ },
4246
+ {
4247
+ name: "unlock_period",
4248
+ type: "u64"
4249
+ },
4250
+ {
4251
+ name: "start_vesting_ts",
4252
+ type: "u64"
4253
+ },
4254
+ {
4255
+ name: "end_vesting_ts",
4256
+ type: "u64"
4257
+ },
4258
+ {
4259
+ name: "clawback_start_ts",
4260
+ type: "u64"
4261
+ },
4262
+ {
4263
+ name: "claims_closable",
4264
+ type: "bool"
4265
+ },
4266
+ {
4267
+ name: "total_amount_unlocked",
4268
+ type: "u64"
4269
+ },
4270
+ {
4271
+ name: "total_amount_locked",
4272
+ type: "u64"
4273
+ },
4274
+ {
4275
+ name: "update_period",
4276
+ type: "u64"
4277
+ },
4278
+ {
4279
+ name: "oracle_type",
4280
+ type: {
4281
+ defined: {
4282
+ name: "OracleType"
4283
+ }
4284
+ }
4285
+ },
4286
+ {
4287
+ name: "min_price",
4288
+ type: "u64"
4289
+ },
4290
+ {
4291
+ name: "max_price",
4292
+ type: "u64"
4293
+ },
4294
+ {
4295
+ name: "min_percentage",
4296
+ type: "u64"
4297
+ },
4298
+ {
4299
+ name: "max_percentage",
4300
+ type: "u64"
4301
+ },
4302
+ {
4303
+ name: "tick_size",
4304
+ type: "u64"
4305
+ },
4306
+ {
4307
+ name: "skip_initial",
4308
+ type: "bool"
4309
+ }
4310
+ ]
4311
+ }
4312
+ },
4313
+ {
4314
+ name: "OracleType",
4315
+ type: {
4316
+ kind: "enum",
4317
+ variants: [
4318
+ {
4319
+ name: "None"
4320
+ },
4321
+ {
4322
+ name: "Test"
4323
+ },
4324
+ {
4325
+ name: "Pyth"
4326
+ },
4327
+ {
4328
+ name: "Switchboard"
4329
+ }
4330
+ ]
4331
+ }
4332
+ },
4333
+ {
4334
+ name: "TestOracle",
4335
+ type: {
4336
+ kind: "struct",
4337
+ fields: [
4338
+ {
4339
+ name: "price",
4340
+ type: "u64"
4341
+ },
4342
+ {
4343
+ name: "expo",
4344
+ type: "i32"
4345
+ },
4346
+ {
4347
+ name: "conf",
4348
+ type: "u64"
4349
+ },
4350
+ {
4351
+ name: "publish_time",
4352
+ type: "i64"
4353
+ },
4354
+ {
4355
+ name: "creator",
4356
+ type: "pubkey"
4357
+ },
4358
+ {
4359
+ name: "authority",
4360
+ type: "pubkey"
4361
+ },
4362
+ {
4363
+ name: "mint",
4364
+ type: "pubkey"
4365
+ }
4366
+ ]
4367
+ }
4368
+ },
4369
+ {
4370
+ name: "UpdateTestOracleParams",
4371
+ type: {
4372
+ kind: "struct",
4373
+ fields: [
4374
+ {
4375
+ name: "price",
4376
+ type: "u64"
4377
+ },
4378
+ {
4379
+ name: "expo",
4380
+ type: "i32"
4381
+ },
4382
+ {
4383
+ name: "conf",
4384
+ type: "u64"
4385
+ },
4386
+ {
4387
+ name: "publish_time",
4388
+ type: "i64"
4389
+ }
4390
+ ]
4391
+ }
4392
+ }
4393
+ ]
4394
+ };
4395
+
4396
+ // solana/clients/SolanaAlignedDistributorClient.ts
4397
+ var SolanaAlignedDistributorClient = class extends BaseDistributorClient {
4398
+ constructor({ clusterUrl, cluster, commitment, programId, sendRate, sendThrottler }) {
4399
+ super({ clusterUrl, cluster, commitment, programId, sendRate, sendThrottler });
4400
+ const alignedAirdropsProgram = {
4401
+ ...aligned_distributor_default
4402
+ };
4403
+ this.alignedProxyProgram = new Program(alignedAirdropsProgram, { connection: this.connection });
4404
+ }
4405
+ getAlignedDistributorProgramId() {
4406
+ return this.alignedProxyProgram.programId;
4407
+ }
4408
+ getAlignedDistributorAddress(distributorAddress) {
4409
+ const distributorKey = new PublicKey(distributorAddress);
4410
+ return getAlignedDistributorPda(this.alignedProxyProgram.programId, distributorKey);
4411
+ }
4412
+ async getAlignedDistributorData(distributorAddress) {
4413
+ const alignedDistributorKey = this.getAlignedDistributorAddress(distributorAddress);
4414
+ const alignedProxy = await this.alignedProxyProgram.account.alignedDistributor.fetch(alignedDistributorKey);
4415
+ invariant(alignedProxy, "Aligned Distributor proxy account not found");
4416
+ const oracleType = Object.keys(alignedProxy.priceOracleType).find((key) => !!key);
4417
+ return {
4418
+ oracleType,
4419
+ minPrice: getNumberFromBN(alignedProxy.minPrice, ALIGNED_PRECISION_FACTOR_POW),
4420
+ maxPrice: getNumberFromBN(alignedProxy.maxPrice, ALIGNED_PRECISION_FACTOR_POW),
4421
+ minPercentage: getNumberFromBN(alignedProxy.minPercentage, ALIGNED_PRECISION_FACTOR_POW),
4422
+ maxPercentage: getNumberFromBN(alignedProxy.maxPercentage, ALIGNED_PRECISION_FACTOR_POW),
4423
+ priceOracle: oracleType === "none" ? void 0 : alignedProxy.priceOracle.toBase58(),
4424
+ sender: alignedProxy.admin.toBase58(),
4425
+ updatePeriod: getNumberFromBN(alignedProxy.updatePeriod, ALIGNED_PRECISION_FACTOR_POW),
4426
+ clawedBack: alignedProxy.distributorClawedBack,
4427
+ initialDuration: alignedProxy.initialDuration.toNumber(),
4428
+ initialPrice: getNumberFromBN(alignedProxy.initialPrice, ALIGNED_PRECISION_FACTOR_POW),
4429
+ lastPrice: getNumberFromBN(alignedProxy.lastPrice, ALIGNED_PRECISION_FACTOR_POW),
4430
+ lastDurationUpdateTs: alignedProxy.lastDurationUpdateTs.toNumber()
4431
+ };
4432
+ }
4433
+ async getNewDistributorInstruction(data, accounts) {
4434
+ const { distributor, mint, clawbackReceiver, tokenProgram, tokenVault, admin } = accounts;
4435
+ const baseArgs = this.getNewDistributorArgs(data);
4436
+ const alignedArgs = this.getNewAlignedDistributorArgs(data);
4437
+ const oracle = data.oracleAddress ? new PublicKey(data.oracleAddress) : getTestOraclePda(this.alignedProxyProgram.programId, mint, admin);
4438
+ const newDistributorIx = await this.alignedProxyProgram.methods.newDistributor({
4439
+ claimsClosable: baseArgs.claimsClosableByAdmin,
4440
+ version: baseArgs.version,
4441
+ root: baseArgs.root,
4442
+ maxTotalClaim: baseArgs.maxTotalClaim,
4443
+ maxNumNodes: baseArgs.maxNumNodes,
4444
+ unlockPeriod: baseArgs.unlockPeriod,
4445
+ startVestingTs: baseArgs.startVestingTs,
4446
+ endVestingTs: baseArgs.endVestingTs,
4447
+ clawbackStartTs: baseArgs.clawbackStartTs,
4448
+ ...alignedArgs
4449
+ }).accounts({
4450
+ admin,
4451
+ tokenVault,
4452
+ distributor,
4453
+ clawbackReceiver,
4454
+ mint,
4455
+ tokenProgram,
4456
+ priceOracle: oracle
4457
+ }).instruction();
4458
+ return newDistributorIx;
4459
+ }
4460
+ async getClawbackInstruction(accounts) {
4461
+ const { distributor, from, to, mint, tokenProgram, admin } = accounts;
4462
+ const alignedDistributorKey = getAlignedDistributorPda(this.alignedProxyProgram.programId, distributor);
4463
+ const alignedProxy = await this.alignedProxyProgram.account.alignedDistributor.fetch(alignedDistributorKey);
4464
+ invariant(alignedProxy, "Aligned Distributor proxy account not found");
4465
+ const clawbackInstruction = await this.alignedProxyProgram.methods.clawback().accounts({
4466
+ admin,
4467
+ distributor,
4468
+ from,
4469
+ to,
4470
+ mint,
4471
+ tokenProgram
4472
+ }).instruction();
4473
+ return clawbackInstruction;
4474
+ }
4475
+ getNewAlignedDistributorArgs(data) {
4476
+ const {
4477
+ oracleType,
4478
+ minPrice,
4479
+ maxPrice,
4480
+ minPercentage,
4481
+ maxPercentage,
4482
+ tickSize,
4483
+ skipInitial,
4484
+ totalAmountLocked,
4485
+ totalAmountUnlocked,
4486
+ unlockPeriod
4487
+ } = data;
4488
+ return {
4489
+ totalAmountLocked: new BN6(totalAmountLocked),
4490
+ totalAmountUnlocked: new BN6(totalAmountUnlocked),
4491
+ oracleType: !!oracleType ? { [oracleType]: {} } : { none: {} },
4492
+ minPrice: getBN(minPrice, ALIGNED_PRECISION_FACTOR_POW),
4493
+ maxPrice: getBN(maxPrice, ALIGNED_PRECISION_FACTOR_POW),
4494
+ minPercentage: getBN(minPercentage, ALIGNED_PRECISION_FACTOR_POW),
4495
+ maxPercentage: getBN(maxPercentage, ALIGNED_PRECISION_FACTOR_POW),
4496
+ tickSize: new BN6(tickSize || 1),
4497
+ skipInitial: skipInitial ?? false,
4498
+ updatePeriod: unlockPeriod < 30 ? new BN6(30) : new BN6(unlockPeriod)
4499
+ };
4500
+ }
4501
+ };
4502
+
4503
+ export { solana_exports as StreamflowDistributorSolana };
4504
+ //# sourceMappingURL=index.js.map
4505
+ //# sourceMappingURL=index.js.map