@streamflow/distributor 7.0.0-alpha.9 → 7.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. package/README.md +3 -3
  2. package/dist/cjs/solana/{client.js → clients/BaseDistributorClient.js} +73 -67
  3. package/dist/cjs/solana/clients/SolanaAlignedDistributorClient.js +104 -0
  4. package/dist/cjs/solana/clients/SolanaDistributorClient.js +17 -0
  5. package/dist/cjs/solana/clients/index.js +10 -0
  6. package/dist/cjs/solana/constants.js +12 -1
  7. package/dist/cjs/solana/descriptor/aligned_distributor.js +2 -0
  8. package/dist/cjs/solana/descriptor/idl/aligned_distributor.json +1242 -0
  9. package/dist/cjs/solana/generated/accounts/ClaimStatus.js +11 -11
  10. package/dist/cjs/solana/generated/accounts/MerkleDistributor.js +41 -16
  11. package/dist/cjs/solana/generated/errors/anchor.js +2 -2
  12. package/dist/cjs/solana/generated/errors/custom.js +2 -2
  13. package/dist/cjs/solana/generated/errors/index.js +2 -3
  14. package/dist/cjs/solana/generated/instructions/claimLocked.js +1 -2
  15. package/dist/cjs/solana/generated/instructions/clawback.js +1 -2
  16. package/dist/cjs/solana/generated/instructions/closeClaim.js +1 -2
  17. package/dist/cjs/solana/generated/instructions/newClaim.js +2 -2
  18. package/dist/cjs/solana/generated/instructions/newDistributor.js +2 -2
  19. package/dist/cjs/solana/generated/instructions/setAdmin.js +1 -2
  20. package/dist/cjs/solana/generated/instructions/setClawbackReceiver.js +1 -2
  21. package/dist/cjs/solana/index.js +2 -6
  22. package/dist/cjs/solana/types.js +2 -2
  23. package/dist/cjs/solana/utils.js +22 -16
  24. package/dist/esm/solana/clients/BaseDistributorClient.d.ts +39 -0
  25. package/dist/esm/solana/{client.js → clients/BaseDistributorClient.js} +73 -67
  26. package/dist/esm/solana/clients/SolanaAlignedDistributorClient.d.ts +14 -0
  27. package/dist/esm/solana/clients/SolanaAlignedDistributorClient.js +99 -0
  28. package/dist/esm/solana/clients/SolanaDistributorClient.d.ts +8 -0
  29. package/dist/esm/solana/clients/SolanaDistributorClient.js +11 -0
  30. package/dist/esm/solana/clients/index.d.ts +2 -0
  31. package/dist/esm/solana/clients/index.js +2 -0
  32. package/dist/esm/solana/constants.d.ts +11 -0
  33. package/dist/esm/solana/constants.js +12 -1
  34. package/dist/esm/solana/descriptor/aligned_distributor.d.ts +918 -0
  35. package/dist/esm/solana/descriptor/aligned_distributor.js +1 -0
  36. package/dist/esm/solana/descriptor/idl/aligned_distributor.json +1242 -0
  37. package/dist/esm/solana/generated/accounts/ClaimStatus.d.ts +17 -18
  38. package/dist/esm/solana/generated/accounts/ClaimStatus.js +13 -13
  39. package/dist/esm/solana/generated/accounts/MerkleDistributor.d.ts +55 -26
  40. package/dist/esm/solana/generated/accounts/MerkleDistributor.js +53 -18
  41. package/dist/esm/solana/generated/instructions/newClaim.d.ts +3 -3
  42. package/dist/esm/solana/generated/instructions/newDistributor.d.ts +8 -8
  43. package/dist/esm/solana/index.d.ts +1 -1
  44. package/dist/esm/solana/index.js +1 -1
  45. package/dist/esm/solana/types.d.ts +45 -5
  46. package/dist/esm/solana/utils.d.ts +2 -1
  47. package/dist/esm/solana/utils.js +11 -6
  48. package/package.json +11 -9
  49. package/dist/esm/solana/client.d.ts +0 -38
@@ -1,21 +1,18 @@
1
- import bs58 from "bs58";
2
- import BigNumber from "bignumber.js";
3
- import { ASSOCIATED_TOKEN_PROGRAM_ID, NATIVE_MINT, createTransferCheckedInstruction, createTransferCheckedWithFeeInstruction, getTransferFeeConfig, } from "@solana/spl-token";
1
+ import BN from "bn.js";
4
2
  import { Connection, PublicKey, SystemProgram, } from "@solana/web3.js";
5
3
  import { ICluster } from "@streamflow/common";
6
- import { ata, checkOrCreateAtaBatch, prepareWrappedAccount, prepareBaseInstructions, prepareTransaction, getMintAndProgram, buildSendThrottler, } from "@streamflow/common/solana";
7
- import { DISTRIBUTOR_ADMIN_OFFSET, DISTRIBUTOR_MINT_OFFSET, DISTRIBUTOR_PROGRAM_ID } from "./constants";
8
- import { claimLocked, clawback, newClaim, newDistributor, } from "./generated/instructions";
9
- import { ClaimStatus, MerkleDistributor } from "./generated/accounts";
10
- import { calculateAmountWithTransferFees, getClaimantStatusPda, getDistributorPda, getEventAuthorityPda, wrappedSignAndExecuteTransaction, } from "./utils";
11
- export default class SolanaDistributorClient {
4
+ import { ata, checkOrCreateAtaBatch, prepareBaseInstructions, prepareTransaction, getMintAndProgram, buildSendThrottler, prepareWrappedAccount, } from "@streamflow/common/solana";
5
+ import { ASSOCIATED_TOKEN_PROGRAM_ID, createTransferCheckedInstruction, createTransferCheckedWithFeeInstruction, getTransferFeeConfig, NATIVE_MINT, } from "@solana/spl-token";
6
+ import bs58 from "bs58";
7
+ import { DISTRIBUTOR_ADMIN_OFFSET, DISTRIBUTOR_MINT_OFFSET, DISTRIBUTOR_PROGRAM_ID } from "../constants";
8
+ import { claimLocked, newClaim, } from "../generated/instructions";
9
+ import { ClaimStatus, MerkleDistributor } from "../generated/accounts";
10
+ import { calculateAmountWithTransferFees, getClaimantStatusPda, getDistributorPda, getEventAuthorityPda, wrappedSignAndExecuteTransaction, } from "../utils";
11
+ export default class BaseDistributorClient {
12
12
  connection;
13
13
  programId;
14
14
  commitment;
15
15
  sendThrottler;
16
- /**
17
- * Create Stream instance
18
- */
19
16
  constructor({ clusterUrl, cluster = ICluster.Mainnet, commitment = "confirmed", programId = "", sendRate = 1, sendThrottler, }) {
20
17
  this.commitment = commitment;
21
18
  this.connection = new Connection(clusterUrl, this.commitment);
@@ -25,46 +22,25 @@ export default class SolanaDistributorClient {
25
22
  getCommitment() {
26
23
  return typeof this.commitment == "string" ? this.commitment : this.commitment.commitment;
27
24
  }
28
- async create(data, extParams) {
29
- const { ixs, distributorPublicKey } = await this.prepareCreateInstructions(data, extParams);
30
- const { tx, hash, context } = await prepareTransaction(this.connection, ixs, extParams.invoker.publicKey);
31
- const signature = await wrappedSignAndExecuteTransaction(this.connection, extParams.invoker, tx, {
32
- hash,
33
- context,
34
- commitment: this.getCommitment(),
35
- }, { sendThrottler: this.sendThrottler });
36
- return {
37
- ixs,
38
- txId: signature,
39
- metadataId: distributorPublicKey.toBase58(),
40
- };
25
+ getDistributorProgramId() {
26
+ return this.programId;
41
27
  }
42
28
  async prepareCreateInstructions(data, extParams) {
43
29
  if (!extParams.invoker.publicKey) {
44
30
  throw new Error("Invoker's PublicKey is not available, check passed wallet adapter!");
45
31
  }
32
+ const { version, mint } = data;
46
33
  const ixs = prepareBaseInstructions(this.connection, extParams);
47
- const mint = extParams.isNative ? NATIVE_MINT : new PublicKey(data.mint);
48
- const { mint: mintAccount, tokenProgramId } = await getMintAndProgram(this.connection, mint);
34
+ const mintPublicKey = extParams.isNative ? NATIVE_MINT : new PublicKey(mint);
35
+ const { mint: mintAccount, tokenProgramId } = await getMintAndProgram(this.connection, mintPublicKey);
49
36
  const transferFeeConfig = getTransferFeeConfig(mintAccount);
50
- const distributorPublicKey = getDistributorPda(this.programId, mint, data.version);
51
- const tokenVault = await ata(mint, distributorPublicKey, tokenProgramId);
52
- const senderTokens = await ata(mint, extParams.invoker.publicKey, tokenProgramId);
53
- const args = {
54
- version: BigNumber(data.version),
55
- root: data.root,
56
- maxTotalClaim: BigNumber(data.maxTotalClaim),
57
- maxNumNodes: BigNumber(data.maxNumNodes),
58
- unlockPeriod: BigNumber(data.unlockPeriod),
59
- startVestingTs: BigNumber(data.startVestingTs),
60
- endVestingTs: BigNumber(data.endVestingTs),
61
- clawbackStartTs: BigNumber(data.clawbackStartTs),
62
- claimsClosable: data.claimsClosable,
63
- };
37
+ const distributorPublicKey = getDistributorPda(this.programId, mintPublicKey, version);
38
+ const tokenVault = await ata(mintPublicKey, distributorPublicKey, tokenProgramId);
39
+ const senderTokens = await ata(mintPublicKey, extParams.invoker.publicKey, tokenProgramId);
64
40
  const accounts = {
65
41
  distributor: distributorPublicKey,
66
42
  clawbackReceiver: senderTokens,
67
- mint,
43
+ mint: mintPublicKey,
68
44
  tokenVault,
69
45
  admin: extParams.invoker.publicKey,
70
46
  systemProgram: SystemProgram.programId,
@@ -72,24 +48,33 @@ export default class SolanaDistributorClient {
72
48
  tokenProgram: tokenProgramId,
73
49
  };
74
50
  if (extParams.isNative) {
75
- ixs.push(...(await prepareWrappedAccount(this.connection, extParams.invoker.publicKey, BigNumber(data.maxTotalClaim))));
76
- }
77
- const nowTs = BigNumber(Math.floor(Date.now() / 1000));
78
- const endVestingTs = args.endVestingTs.isZero() ? nowTs : args.endVestingTs;
79
- const startVestingTs = args.startVestingTs.isZero() ? nowTs : args.startVestingTs;
80
- if (endVestingTs.gt(startVestingTs) && endVestingTs.minus(startVestingTs).lt(args.unlockPeriod)) {
81
- throw new Error("The unlock period cannot be longer than the total vesting duration!");
51
+ ixs.push(...(await prepareWrappedAccount(this.connection, extParams.invoker.publicKey, new BN(data.maxTotalClaim))));
82
52
  }
83
- ixs.push(newDistributor(args, accounts, this.programId));
53
+ const newDistributorInstruction = await this.getNewDistributorInstruction(data, accounts);
54
+ ixs.push(newDistributorInstruction);
84
55
  if (transferFeeConfig) {
85
56
  const { transferAmount, feeCharged } = await calculateAmountWithTransferFees(this.connection, transferFeeConfig, BigInt(data.maxTotalClaim.toString()));
86
- ixs.push(createTransferCheckedWithFeeInstruction(senderTokens, mint, tokenVault, extParams.invoker.publicKey, transferAmount, mintAccount.decimals, feeCharged, undefined, tokenProgramId));
57
+ ixs.push(createTransferCheckedWithFeeInstruction(senderTokens, mintPublicKey, tokenVault, extParams.invoker.publicKey, transferAmount, mintAccount.decimals, feeCharged, undefined, tokenProgramId));
87
58
  }
88
59
  else {
89
- ixs.push(createTransferCheckedInstruction(senderTokens, mint, tokenVault, extParams.invoker.publicKey, BigInt(data.maxTotalClaim.toString()), mintAccount.decimals, undefined, tokenProgramId));
60
+ ixs.push(createTransferCheckedInstruction(senderTokens, mintPublicKey, tokenVault, extParams.invoker.publicKey, BigInt(data.maxTotalClaim.toString()), mintAccount.decimals, undefined, tokenProgramId));
90
61
  }
91
62
  return { distributorPublicKey, ixs };
92
63
  }
64
+ async create(data, extParams) {
65
+ const { ixs, distributorPublicKey } = await this.prepareCreateInstructions(data, extParams);
66
+ const { tx, hash, context } = await prepareTransaction(this.connection, ixs, extParams.invoker.publicKey);
67
+ const signature = await wrappedSignAndExecuteTransaction(this.connection, extParams.invoker, tx, {
68
+ hash,
69
+ context,
70
+ commitment: this.getCommitment(),
71
+ }, { sendThrottler: this.sendThrottler });
72
+ return {
73
+ ixs,
74
+ txId: signature,
75
+ metadataId: distributorPublicKey.toBase58(),
76
+ };
77
+ }
93
78
  async claim(data, extParams) {
94
79
  const ixs = await this.prepareClaimInstructions(data, extParams);
95
80
  const { tx, hash, context } = await prepareTransaction(this.connection, ixs, extParams.invoker.publicKey);
@@ -130,29 +115,19 @@ export default class SolanaDistributorClient {
130
115
  };
131
116
  if (!claimStatus) {
132
117
  const args = {
133
- amountLocked: BigNumber(data.amountLocked),
134
- amountUnlocked: BigNumber(data.amountUnlocked),
118
+ amountLocked: new BN(data.amountLocked),
119
+ amountUnlocked: new BN(data.amountUnlocked),
135
120
  proof: data.proof,
136
121
  };
137
122
  ixs.push(newClaim(args, accounts, this.programId));
138
123
  }
139
- const nowTs = BigNumber(Math.floor(Date.now() / 1000));
124
+ const nowTs = new BN(Math.floor(Date.now() / 1000));
140
125
  if (claimStatus ||
141
- (BigNumber(data.amountLocked).gt(0) && nowTs.minus(distributor.startTs).gte(distributor.unlockPeriod))) {
126
+ (new BN(data.amountLocked).gtn(0) && nowTs.sub(distributor.startTs).gte(distributor.unlockPeriod))) {
142
127
  ixs.push(claimLocked(accounts, this.programId));
143
128
  }
144
129
  return ixs;
145
130
  }
146
- async clawback(data, extParams) {
147
- const ixs = await this.prepareClawbackInstructions(data, extParams);
148
- const { tx, hash, context } = await prepareTransaction(this.connection, ixs, extParams.invoker.publicKey);
149
- const signature = await wrappedSignAndExecuteTransaction(this.connection, extParams.invoker, tx, {
150
- hash,
151
- context,
152
- commitment: this.getCommitment(),
153
- }, { sendThrottler: this.sendThrottler });
154
- return { ixs, txId: signature };
155
- }
156
131
  async prepareClawbackInstructions(data, extParams) {
157
132
  if (!extParams.invoker.publicKey) {
158
133
  throw new Error("Invoker's PublicKey is not available, check passed wallet adapter!");
@@ -174,9 +149,20 @@ export default class SolanaDistributorClient {
174
149
  systemProgram: SystemProgram.programId,
175
150
  tokenProgram: tokenProgramId,
176
151
  };
177
- ixs.push(clawback(accounts, this.programId));
152
+ const clawbackInstruction = await this.getClawbackInstruction(accounts);
153
+ ixs.push(clawbackInstruction);
178
154
  return ixs;
179
155
  }
156
+ async clawback(data, extParams) {
157
+ const ixs = await this.prepareClawbackInstructions(data, extParams);
158
+ const { tx, hash, context } = await prepareTransaction(this.connection, ixs, extParams.invoker.publicKey);
159
+ const signature = await wrappedSignAndExecuteTransaction(this.connection, extParams.invoker, tx, {
160
+ hash,
161
+ context,
162
+ commitment: this.getCommitment(),
163
+ }, { sendThrottler: this.sendThrottler });
164
+ return { ixs, txId: signature };
165
+ }
180
166
  async getClaims(data) {
181
167
  const claimStatusPublicKeys = data.map(({ id, recipient }) => {
182
168
  return getClaimantStatusPda(this.programId, new PublicKey(id), new PublicKey(recipient));
@@ -211,4 +197,24 @@ export default class SolanaDistributorClient {
211
197
  account: MerkleDistributor.decode(account.data),
212
198
  }));
213
199
  }
200
+ getNewDistributorArgs(data) {
201
+ const args = {
202
+ version: new BN(data.version),
203
+ root: data.root,
204
+ maxTotalClaim: new BN(data.maxTotalClaim),
205
+ maxNumNodes: new BN(data.maxNumNodes),
206
+ unlockPeriod: new BN(data.unlockPeriod),
207
+ startVestingTs: new BN(data.startVestingTs),
208
+ endVestingTs: new BN(data.endVestingTs),
209
+ clawbackStartTs: new BN(data.clawbackStartTs),
210
+ claimsClosable: data.claimsClosable,
211
+ };
212
+ const nowTs = new BN(Math.floor(Date.now() / 1000));
213
+ const endVestingTs = args.endVestingTs.isZero() ? nowTs : args.endVestingTs;
214
+ const startVestingTs = args.startVestingTs.isZero() ? nowTs : args.startVestingTs;
215
+ if (endVestingTs.gt(startVestingTs) && endVestingTs.sub(startVestingTs).lt(args.unlockPeriod)) {
216
+ throw new Error("The unlock period cannot be longer than the total vesting duration!");
217
+ }
218
+ return args;
219
+ }
214
220
  }
@@ -0,0 +1,14 @@
1
+ import { PublicKey, TransactionInstruction } from "@solana/web3.js";
2
+ import { ICreateAlignedDistributorData, AlignedDistributorData, NewAlignedDistributorArgs } from "../types";
3
+ import { ClawbackAccounts, NewDistributorAccounts } from "../generated/instructions";
4
+ import BaseDistributorClient, { IInitOptions } from "./BaseDistributorClient.js";
5
+ export default class SolanaAlignedDistributorClient extends BaseDistributorClient {
6
+ private alignedProxyProgram;
7
+ constructor({ clusterUrl, cluster, commitment, programId, sendRate, sendThrottler }: IInitOptions);
8
+ getAlignedDistributorProgramId(): PublicKey;
9
+ getAlignedDistributorAddress(distributorAddress: string): PublicKey;
10
+ getAlignedDistributorData(distributorAddress: string): Promise<AlignedDistributorData>;
11
+ protected getNewDistributorInstruction(data: ICreateAlignedDistributorData, accounts: NewDistributorAccounts): Promise<TransactionInstruction>;
12
+ protected getClawbackInstruction(accounts: ClawbackAccounts): Promise<TransactionInstruction>;
13
+ protected getNewAlignedDistributorArgs(data: ICreateAlignedDistributorData): NewAlignedDistributorArgs;
14
+ }
@@ -0,0 +1,99 @@
1
+ import BN from "bn.js";
2
+ import { PublicKey } from "@solana/web3.js";
3
+ import { Program } from "@coral-xyz/anchor";
4
+ import { getBN, getNumberFromBN, invariant } from "@streamflow/common";
5
+ import BaseDistributorClient from "./BaseDistributorClient.js";
6
+ import StreamflowAlignedAirdropsIDL from "../descriptor/idl/aligned_distributor.json";
7
+ import { ALIGNED_PRECISION_FACTOR_POW } from "../constants.js";
8
+ import { getAlignedDistributorPda, getTestOraclePda } from "../utils.js";
9
+ export default class SolanaAlignedDistributorClient extends BaseDistributorClient {
10
+ alignedProxyProgram;
11
+ constructor({ clusterUrl, cluster, commitment, programId, sendRate, sendThrottler }) {
12
+ super({ clusterUrl, cluster, commitment, programId, sendRate, sendThrottler });
13
+ const alignedAirdropsProgram = {
14
+ ...StreamflowAlignedAirdropsIDL,
15
+ };
16
+ this.alignedProxyProgram = new Program(alignedAirdropsProgram, { connection: this.connection });
17
+ }
18
+ getAlignedDistributorProgramId() {
19
+ return this.alignedProxyProgram.programId;
20
+ }
21
+ getAlignedDistributorAddress(distributorAddress) {
22
+ const distributorKey = new PublicKey(distributorAddress);
23
+ return getAlignedDistributorPda(this.alignedProxyProgram.programId, distributorKey);
24
+ }
25
+ async getAlignedDistributorData(distributorAddress) {
26
+ const alignedDistributorKey = this.getAlignedDistributorAddress(distributorAddress);
27
+ const alignedProxy = await this.alignedProxyProgram.account.alignedDistributor.fetch(alignedDistributorKey);
28
+ invariant(alignedProxy, "Aligned Distributor proxy account not found");
29
+ const oracleType = Object.keys(alignedProxy.priceOracleType).find((key) => !!key);
30
+ return {
31
+ oracleType,
32
+ minPrice: getNumberFromBN(alignedProxy.minPrice, ALIGNED_PRECISION_FACTOR_POW),
33
+ maxPrice: getNumberFromBN(alignedProxy.maxPrice, ALIGNED_PRECISION_FACTOR_POW),
34
+ minPercentage: getNumberFromBN(alignedProxy.minPercentage, ALIGNED_PRECISION_FACTOR_POW),
35
+ maxPercentage: getNumberFromBN(alignedProxy.maxPercentage, ALIGNED_PRECISION_FACTOR_POW),
36
+ priceOracle: oracleType === "none" ? undefined : alignedProxy.priceOracle.toBase58(),
37
+ sender: alignedProxy.admin.toBase58(),
38
+ updatePeriod: getNumberFromBN(alignedProxy.updatePeriod, ALIGNED_PRECISION_FACTOR_POW),
39
+ clawedBack: alignedProxy.distributorClawedBack,
40
+ };
41
+ }
42
+ async getNewDistributorInstruction(data, accounts) {
43
+ const { distributor, mint, clawbackReceiver, tokenProgram, tokenVault, admin } = accounts;
44
+ const baseArgs = this.getNewDistributorArgs(data);
45
+ const alignedArgs = this.getNewAlignedDistributorArgs(data);
46
+ const oracle = data.oracleAddress
47
+ ? new PublicKey(data.oracleAddress)
48
+ : getTestOraclePda(this.alignedProxyProgram.programId, mint, admin);
49
+ const newDistributorIx = await this.alignedProxyProgram.methods
50
+ .newDistributor({
51
+ ...baseArgs,
52
+ ...alignedArgs,
53
+ })
54
+ .accounts({
55
+ admin,
56
+ tokenVault,
57
+ distributor,
58
+ clawbackReceiver,
59
+ mint,
60
+ tokenProgram,
61
+ priceOracle: oracle,
62
+ })
63
+ .instruction();
64
+ return newDistributorIx;
65
+ }
66
+ async getClawbackInstruction(accounts) {
67
+ const { distributor, from, to, mint, tokenProgram, admin } = accounts;
68
+ const alignedDistributorKey = getAlignedDistributorPda(this.alignedProxyProgram.programId, distributor);
69
+ const alignedProxy = await this.alignedProxyProgram.account.alignedDistributor.fetch(alignedDistributorKey);
70
+ invariant(alignedProxy, "Aligned Distributor proxy account not found");
71
+ const clawbackInstruction = await this.alignedProxyProgram.methods
72
+ .clawback()
73
+ .accounts({
74
+ admin,
75
+ distributor,
76
+ from,
77
+ to,
78
+ mint,
79
+ tokenProgram,
80
+ })
81
+ .instruction();
82
+ return clawbackInstruction;
83
+ }
84
+ getNewAlignedDistributorArgs(data) {
85
+ const { oracleType, minPrice, maxPrice, minPercentage, maxPercentage, tickSize, skipInitial, totalAmountLocked, totalAmountUnlocked, unlockPeriod, } = data;
86
+ return {
87
+ totalAmountLocked: new BN(totalAmountLocked),
88
+ totalAmountUnlocked: new BN(totalAmountUnlocked),
89
+ oracleType: (!!oracleType ? { [oracleType]: {} } : { none: {} }),
90
+ minPrice: getBN(minPrice, ALIGNED_PRECISION_FACTOR_POW),
91
+ maxPrice: getBN(maxPrice, ALIGNED_PRECISION_FACTOR_POW),
92
+ minPercentage: getBN(minPercentage, ALIGNED_PRECISION_FACTOR_POW),
93
+ maxPercentage: getBN(maxPercentage, ALIGNED_PRECISION_FACTOR_POW),
94
+ tickSize: new BN(tickSize || 1),
95
+ skipInitial: skipInitial ?? false,
96
+ updatePeriod: unlockPeriod < 30 ? new BN(30) : new BN(unlockPeriod),
97
+ };
98
+ }
99
+ }
@@ -0,0 +1,8 @@
1
+ import { TransactionInstruction } from "@solana/web3.js";
2
+ import { ICreateDistributorData } from "../types";
3
+ import { ClawbackAccounts, NewDistributorAccounts } from "../generated/instructions";
4
+ import BaseDistributorClient from "./BaseDistributorClient.js";
5
+ export default class SolanaDistributorClient extends BaseDistributorClient {
6
+ protected getNewDistributorInstruction(data: ICreateDistributorData, accounts: NewDistributorAccounts): Promise<TransactionInstruction>;
7
+ protected getClawbackInstruction(accounts: ClawbackAccounts): Promise<TransactionInstruction>;
8
+ }
@@ -0,0 +1,11 @@
1
+ import { clawback, newDistributor } from "../generated/instructions";
2
+ import BaseDistributorClient from "./BaseDistributorClient.js";
3
+ export default class SolanaDistributorClient extends BaseDistributorClient {
4
+ async getNewDistributorInstruction(data, accounts) {
5
+ const args = this.getNewDistributorArgs(data);
6
+ return newDistributor(args, accounts, this.programId);
7
+ }
8
+ async getClawbackInstruction(accounts) {
9
+ return clawback(accounts, this.programId);
10
+ }
11
+ }
@@ -0,0 +1,2 @@
1
+ export { default as SolanaDistributorClient } from "./SolanaDistributorClient.js";
2
+ export { default as SolanaAlignedDistributorClient } from "./SolanaAlignedDistributorClient.js";
@@ -0,0 +1,2 @@
1
+ export { default as SolanaDistributorClient } from "./SolanaDistributorClient.js";
2
+ export { default as SolanaAlignedDistributorClient } from "./SolanaAlignedDistributorClient.js";
@@ -1,7 +1,18 @@
1
1
  export declare const ANCHOR_DISCRIMINATOR_OFFSET = 8;
2
2
  export declare const DISTRIBUTOR_MINT_OFFSET: number;
3
3
  export declare const DISTRIBUTOR_ADMIN_OFFSET: number;
4
+ export declare const DISTRIBUTOR_PREFIX: Buffer;
5
+ export declare const ALIGNED_DISTRIBUTOR_PREFIX: Buffer;
6
+ export declare const TEST_ORACLE_PREFIX: Buffer;
7
+ export declare const CLAIM_STATUS_PREFIX: Buffer;
8
+ export declare const ALIGNED_PRECISION_FACTOR_POW = 9;
4
9
  export declare const ONE_IN_BASIS_POINTS: bigint;
10
+ export declare const ALIGNED_DISTRIBUTOR_PROGRAM_ID: {
11
+ devnet: string;
12
+ mainnet: string;
13
+ testnet: string;
14
+ local: string;
15
+ };
5
16
  export declare const DISTRIBUTOR_PROGRAM_ID: {
6
17
  devnet: string;
7
18
  mainnet: string;
@@ -2,7 +2,18 @@ import { ICluster } from "@streamflow/common";
2
2
  export const ANCHOR_DISCRIMINATOR_OFFSET = 8;
3
3
  export const DISTRIBUTOR_MINT_OFFSET = ANCHOR_DISCRIMINATOR_OFFSET + 41;
4
4
  export const DISTRIBUTOR_ADMIN_OFFSET = ANCHOR_DISCRIMINATOR_OFFSET + 201;
5
- export const ONE_IN_BASIS_POINTS = BigInt(10000);
5
+ export const DISTRIBUTOR_PREFIX = Buffer.from("MerkleDistributor", "utf-8");
6
+ export const ALIGNED_DISTRIBUTOR_PREFIX = Buffer.from("aligned-distributor", "utf-8");
7
+ export const TEST_ORACLE_PREFIX = Buffer.from("test-oracle", "utf-8");
8
+ export const CLAIM_STATUS_PREFIX = Buffer.from("ClaimStatus", "utf-8");
9
+ export const ALIGNED_PRECISION_FACTOR_POW = 9;
10
+ export const ONE_IN_BASIS_POINTS = BigInt(10_000);
11
+ export const ALIGNED_DISTRIBUTOR_PROGRAM_ID = {
12
+ [ICluster.Devnet]: "aMERKpFAWoChCi5oZwPvgsSCoGpZKBiU7fi76bdZjt2",
13
+ [ICluster.Mainnet]: "aMERKpFAWoChCi5oZwPvgsSCoGpZKBiU7fi76bdZjt2",
14
+ [ICluster.Testnet]: "aMERKpFAWoChCi5oZwPvgsSCoGpZKBiU7fi76bdZjt2",
15
+ [ICluster.Local]: "aMERKpFAWoChCi5oZwPvgsSCoGpZKBiU7fi76bdZjt2",
16
+ };
6
17
  export const DISTRIBUTOR_PROGRAM_ID = {
7
18
  [ICluster.Devnet]: "MErKy6nZVoVAkryxAejJz2juifQ4ArgLgHmaJCQkU7N",
8
19
  [ICluster.Mainnet]: "MErKy6nZVoVAkryxAejJz2juifQ4ArgLgHmaJCQkU7N",