@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,23 +1,22 @@
1
- /// <reference types="node" />
2
1
  import { PublicKey, Connection } from "@solana/web3.js";
3
- import BigNumber from "bignumber.js";
2
+ import BN from "bn.js";
4
3
  export interface ClaimStatusFields {
5
4
  /** Authority that claimed the tokens. */
6
5
  claimant: PublicKey;
7
6
  /** Locked amount */
8
- lockedAmount: BigNumber;
7
+ lockedAmount: BN;
9
8
  /** Locked amount withdrawn */
10
- lockedAmountWithdrawn: BigNumber;
9
+ lockedAmountWithdrawn: BN;
11
10
  /** Unlocked amount */
12
- unlockedAmount: BigNumber;
11
+ unlockedAmount: BN;
13
12
  /** Last claim time */
14
- lastClaimTs: BigNumber;
13
+ lastClaimTs: BN;
15
14
  /** Track amount per unlock, can be useful for non-linear vesting */
16
- lastAmountPerUnlock: BigNumber;
15
+ lastAmountPerUnlock: BN;
17
16
  /** Whether claim is closed */
18
17
  closed: boolean;
19
- /** Buffer for additional fields */
20
- buffer1: Array<number>;
18
+ /** Distributor account for which ClaimStatus was created, useful to filter by in get_program_accounts */
19
+ distributor: PublicKey;
21
20
  /** Buffer for additional fields */
22
21
  buffer2: Array<number>;
23
22
  }
@@ -36,8 +35,8 @@ export interface ClaimStatusJSON {
36
35
  lastAmountPerUnlock: string;
37
36
  /** Whether claim is closed */
38
37
  closed: boolean;
39
- /** Buffer for additional fields */
40
- buffer1: Array<number>;
38
+ /** Distributor account for which ClaimStatus was created, useful to filter by in get_program_accounts */
39
+ distributor: string;
41
40
  /** Buffer for additional fields */
42
41
  buffer2: Array<number>;
43
42
  }
@@ -46,19 +45,19 @@ export declare class ClaimStatus {
46
45
  /** Authority that claimed the tokens. */
47
46
  readonly claimant: PublicKey;
48
47
  /** Locked amount */
49
- readonly lockedAmount: BigNumber;
48
+ readonly lockedAmount: BN;
50
49
  /** Locked amount withdrawn */
51
- readonly lockedAmountWithdrawn: BigNumber;
50
+ readonly lockedAmountWithdrawn: BN;
52
51
  /** Unlocked amount */
53
- readonly unlockedAmount: BigNumber;
52
+ readonly unlockedAmount: BN;
54
53
  /** Last claim time */
55
- readonly lastClaimTs: BigNumber;
54
+ readonly lastClaimTs: BN;
56
55
  /** Track amount per unlock, can be useful for non-linear vesting */
57
- readonly lastAmountPerUnlock: BigNumber;
56
+ readonly lastAmountPerUnlock: BN;
58
57
  /** Whether claim is closed */
59
58
  readonly closed: boolean;
60
- /** Buffer for additional fields */
61
- readonly buffer1: Array<number>;
59
+ /** Distributor account for which ClaimStatus was created, useful to filter by in get_program_accounts */
60
+ readonly distributor: PublicKey;
62
61
  /** Buffer for additional fields */
63
62
  readonly buffer2: Array<number>;
64
63
  static readonly discriminator: Buffer;
@@ -1,5 +1,5 @@
1
1
  import { PublicKey } from "@solana/web3.js";
2
- import BigNumber from "bignumber.js"; // eslint-disable-line @typescript-eslint/no-unused-vars
2
+ import BN from "bn.js"; // eslint-disable-line @typescript-eslint/no-unused-vars
3
3
  import * as borsh from "@coral-xyz/borsh"; // eslint-disable-line @typescript-eslint/no-unused-vars
4
4
  import { PROGRAM_ID } from "../programId";
5
5
  /** Holds whether or not a claimant has claimed tokens. */
@@ -18,8 +18,8 @@ export class ClaimStatus {
18
18
  lastAmountPerUnlock;
19
19
  /** Whether claim is closed */
20
20
  closed;
21
- /** Buffer for additional fields */
22
- buffer1;
21
+ /** Distributor account for which ClaimStatus was created, useful to filter by in get_program_accounts */
22
+ distributor;
23
23
  /** Buffer for additional fields */
24
24
  buffer2;
25
25
  static discriminator = Buffer.from([22, 183, 249, 157, 247, 95, 150, 96]);
@@ -31,7 +31,7 @@ export class ClaimStatus {
31
31
  borsh.u64("lastClaimTs"),
32
32
  borsh.u64("lastAmountPerUnlock"),
33
33
  borsh.bool("closed"),
34
- borsh.array(borsh.u8(), 32, "buffer1"),
34
+ borsh.publicKey("distributor"),
35
35
  borsh.array(borsh.u8(), 32, "buffer2"),
36
36
  ]);
37
37
  constructor(fields) {
@@ -42,7 +42,7 @@ export class ClaimStatus {
42
42
  this.lastClaimTs = fields.lastClaimTs;
43
43
  this.lastAmountPerUnlock = fields.lastAmountPerUnlock;
44
44
  this.closed = fields.closed;
45
- this.buffer1 = fields.buffer1;
45
+ this.distributor = fields.distributor;
46
46
  this.buffer2 = fields.buffer2;
47
47
  }
48
48
  static async fetch(c, address, programId = PROGRAM_ID) {
@@ -80,7 +80,7 @@ export class ClaimStatus {
80
80
  lastClaimTs: dec.lastClaimTs,
81
81
  lastAmountPerUnlock: dec.lastAmountPerUnlock,
82
82
  closed: dec.closed,
83
- buffer1: dec.buffer1,
83
+ distributor: dec.distributor,
84
84
  buffer2: dec.buffer2,
85
85
  });
86
86
  }
@@ -93,20 +93,20 @@ export class ClaimStatus {
93
93
  lastClaimTs: this.lastClaimTs.toString(),
94
94
  lastAmountPerUnlock: this.lastAmountPerUnlock.toString(),
95
95
  closed: this.closed,
96
- buffer1: this.buffer1,
96
+ distributor: this.distributor.toString(),
97
97
  buffer2: this.buffer2,
98
98
  };
99
99
  }
100
100
  static fromJSON(obj) {
101
101
  return new ClaimStatus({
102
102
  claimant: new PublicKey(obj.claimant),
103
- lockedAmount: BigNumber(obj.lockedAmount),
104
- lockedAmountWithdrawn: BigNumber(obj.lockedAmountWithdrawn),
105
- unlockedAmount: BigNumber(obj.unlockedAmount),
106
- lastClaimTs: BigNumber(obj.lastClaimTs),
107
- lastAmountPerUnlock: BigNumber(obj.lastAmountPerUnlock),
103
+ lockedAmount: new BN(obj.lockedAmount),
104
+ lockedAmountWithdrawn: new BN(obj.lockedAmountWithdrawn),
105
+ unlockedAmount: new BN(obj.unlockedAmount),
106
+ lastClaimTs: new BN(obj.lastClaimTs),
107
+ lastAmountPerUnlock: new BN(obj.lastAmountPerUnlock),
108
108
  closed: obj.closed,
109
- buffer1: obj.buffer1,
109
+ distributor: new PublicKey(obj.distributor),
110
110
  buffer2: obj.buffer2,
111
111
  });
112
112
  }
@@ -1,11 +1,10 @@
1
- /// <reference types="node" />
2
1
  import { PublicKey, Connection } from "@solana/web3.js";
3
- import BigNumber from "bignumber.js";
2
+ import BN from "bn.js";
4
3
  export interface MerkleDistributorFields {
5
4
  /** Bump seed. */
6
5
  bump: number;
7
6
  /** Version of the airdrop */
8
- version: BigNumber;
7
+ version: BN;
9
8
  /** The 256-bit merkle root. */
10
9
  root: Array<number>;
11
10
  /** [Mint] of the token to be distributed. */
@@ -13,21 +12,21 @@ export interface MerkleDistributorFields {
13
12
  /** Token Address of the vault */
14
13
  tokenVault: PublicKey;
15
14
  /** Maximum number of tokens that can ever be claimed from this [MerkleDistributor]. */
16
- maxTotalClaim: BigNumber;
15
+ maxTotalClaim: BN;
17
16
  /** Maximum number of nodes in [MerkleDistributor]. */
18
- maxNumNodes: BigNumber;
17
+ maxNumNodes: BN;
19
18
  /** Time step (period) in seconds per which the unlock occurs */
20
- unlockPeriod: BigNumber;
19
+ unlockPeriod: BN;
21
20
  /** Total amount of tokens that have been claimed. */
22
- totalAmountClaimed: BigNumber;
21
+ totalAmountClaimed: BN;
23
22
  /** Number of nodes that have been claimed. */
24
- numNodesClaimed: BigNumber;
23
+ numNodesClaimed: BN;
25
24
  /** Lockup time start (Unix Timestamp) */
26
- startTs: BigNumber;
25
+ startTs: BN;
27
26
  /** Lockup time end (Unix Timestamp) */
28
- endTs: BigNumber;
27
+ endTs: BN;
29
28
  /** Clawback start (Unix Timestamp) */
30
- clawbackStartTs: BigNumber;
29
+ clawbackStartTs: BN;
31
30
  /** Clawback receiver */
32
31
  clawbackReceiver: PublicKey;
33
32
  /** Admin wallet */
@@ -36,8 +35,18 @@ export interface MerkleDistributorFields {
36
35
  clawedBack: boolean;
37
36
  /** Whether claims are closable by the admin or not */
38
37
  claimsClosable: boolean;
39
- /** Buffer for additional fields */
40
- buffer1: Array<number>;
38
+ /** Whether admin can update vesting duration */
39
+ canUpdateDuration: boolean;
40
+ /** Total amount of funds unlocked (cliff/instant) */
41
+ totalAmountUnlocked: BN;
42
+ /** Total amount of funds locked (vested) */
43
+ totalAmountLocked: BN;
44
+ /** Timestamp when update was last called */
45
+ lastDurationUpdateTs: BN;
46
+ /** Total amount of locked amount claimable as of last duration update, ever increasing total, accumulates with each update */
47
+ totalClaimablePreUpdate: BN;
48
+ /** Timestamp when funds were clawed back */
49
+ clawedBackTs: BN;
41
50
  /** Buffer for additional fields */
42
51
  buffer2: Array<number>;
43
52
  /** Buffer for additional fields */
@@ -78,8 +87,18 @@ export interface MerkleDistributorJSON {
78
87
  clawedBack: boolean;
79
88
  /** Whether claims are closable by the admin or not */
80
89
  claimsClosable: boolean;
81
- /** Buffer for additional fields */
82
- buffer1: Array<number>;
90
+ /** Whether admin can update vesting duration */
91
+ canUpdateDuration: boolean;
92
+ /** Total amount of funds unlocked (cliff/instant) */
93
+ totalAmountUnlocked: string;
94
+ /** Total amount of funds locked (vested) */
95
+ totalAmountLocked: string;
96
+ /** Timestamp when update was last called */
97
+ lastDurationUpdateTs: string;
98
+ /** Total amount of locked amount claimable as of last duration update, ever increasing total, accumulates with each update */
99
+ totalClaimablePreUpdate: string;
100
+ /** Timestamp when funds were clawed back */
101
+ clawedBackTs: string;
83
102
  /** Buffer for additional fields */
84
103
  buffer2: Array<number>;
85
104
  /** Buffer for additional fields */
@@ -90,7 +109,7 @@ export declare class MerkleDistributor {
90
109
  /** Bump seed. */
91
110
  readonly bump: number;
92
111
  /** Version of the airdrop */
93
- readonly version: BigNumber;
112
+ readonly version: BN;
94
113
  /** The 256-bit merkle root. */
95
114
  readonly root: Array<number>;
96
115
  /** [Mint] of the token to be distributed. */
@@ -98,21 +117,21 @@ export declare class MerkleDistributor {
98
117
  /** Token Address of the vault */
99
118
  readonly tokenVault: PublicKey;
100
119
  /** Maximum number of tokens that can ever be claimed from this [MerkleDistributor]. */
101
- readonly maxTotalClaim: BigNumber;
120
+ readonly maxTotalClaim: BN;
102
121
  /** Maximum number of nodes in [MerkleDistributor]. */
103
- readonly maxNumNodes: BigNumber;
122
+ readonly maxNumNodes: BN;
104
123
  /** Time step (period) in seconds per which the unlock occurs */
105
- readonly unlockPeriod: BigNumber;
124
+ readonly unlockPeriod: BN;
106
125
  /** Total amount of tokens that have been claimed. */
107
- readonly totalAmountClaimed: BigNumber;
126
+ readonly totalAmountClaimed: BN;
108
127
  /** Number of nodes that have been claimed. */
109
- readonly numNodesClaimed: BigNumber;
128
+ readonly numNodesClaimed: BN;
110
129
  /** Lockup time start (Unix Timestamp) */
111
- readonly startTs: BigNumber;
130
+ readonly startTs: BN;
112
131
  /** Lockup time end (Unix Timestamp) */
113
- readonly endTs: BigNumber;
132
+ readonly endTs: BN;
114
133
  /** Clawback start (Unix Timestamp) */
115
- readonly clawbackStartTs: BigNumber;
134
+ readonly clawbackStartTs: BN;
116
135
  /** Clawback receiver */
117
136
  readonly clawbackReceiver: PublicKey;
118
137
  /** Admin wallet */
@@ -121,8 +140,18 @@ export declare class MerkleDistributor {
121
140
  readonly clawedBack: boolean;
122
141
  /** Whether claims are closable by the admin or not */
123
142
  readonly claimsClosable: boolean;
124
- /** Buffer for additional fields */
125
- readonly buffer1: Array<number>;
143
+ /** Whether admin can update vesting duration */
144
+ readonly canUpdateDuration: boolean;
145
+ /** Total amount of funds unlocked (cliff/instant) */
146
+ readonly totalAmountUnlocked: BN;
147
+ /** Total amount of funds locked (vested) */
148
+ readonly totalAmountLocked: BN;
149
+ /** Timestamp when update was last called */
150
+ readonly lastDurationUpdateTs: BN;
151
+ /** Total amount of locked amount claimable as of last duration update, ever increasing total, accumulates with each update */
152
+ readonly totalClaimablePreUpdate: BN;
153
+ /** Timestamp when funds were clawed back */
154
+ readonly clawedBackTs: BN;
126
155
  /** Buffer for additional fields */
127
156
  readonly buffer2: Array<number>;
128
157
  /** Buffer for additional fields */
@@ -1,5 +1,5 @@
1
1
  import { PublicKey } from "@solana/web3.js";
2
- import BigNumber from "bignumber.js"; // eslint-disable-line @typescript-eslint/no-unused-vars
2
+ import BN from "bn.js"; // eslint-disable-line @typescript-eslint/no-unused-vars
3
3
  import * as borsh from "@coral-xyz/borsh"; // eslint-disable-line @typescript-eslint/no-unused-vars
4
4
  import { PROGRAM_ID } from "../programId";
5
5
  /** State for the account which distributes tokens. */
@@ -38,8 +38,18 @@ export class MerkleDistributor {
38
38
  clawedBack;
39
39
  /** Whether claims are closable by the admin or not */
40
40
  claimsClosable;
41
- /** Buffer for additional fields */
42
- buffer1;
41
+ /** Whether admin can update vesting duration */
42
+ canUpdateDuration;
43
+ /** Total amount of funds unlocked (cliff/instant) */
44
+ totalAmountUnlocked;
45
+ /** Total amount of funds locked (vested) */
46
+ totalAmountLocked;
47
+ /** Timestamp when update was last called */
48
+ lastDurationUpdateTs;
49
+ /** Total amount of locked amount claimable as of last duration update, ever increasing total, accumulates with each update */
50
+ totalClaimablePreUpdate;
51
+ /** Timestamp when funds were clawed back */
52
+ clawedBackTs;
43
53
  /** Buffer for additional fields */
44
54
  buffer2;
45
55
  /** Buffer for additional fields */
@@ -63,8 +73,13 @@ export class MerkleDistributor {
63
73
  borsh.publicKey("admin"),
64
74
  borsh.bool("clawedBack"),
65
75
  borsh.bool("claimsClosable"),
66
- borsh.array(borsh.u8(), 32, "buffer1"),
67
- borsh.array(borsh.u8(), 32, "buffer2"),
76
+ borsh.bool("canUpdateDuration"),
77
+ borsh.u64("totalAmountUnlocked"),
78
+ borsh.u64("totalAmountLocked"),
79
+ borsh.u64("lastDurationUpdateTs"),
80
+ borsh.u64("totalClaimablePreUpdate"),
81
+ borsh.u64("clawedBackTs"),
82
+ borsh.array(borsh.u8(), 23, "buffer2"),
68
83
  borsh.array(borsh.u8(), 32, "buffer3"),
69
84
  ]);
70
85
  constructor(fields) {
@@ -85,7 +100,12 @@ export class MerkleDistributor {
85
100
  this.admin = fields.admin;
86
101
  this.clawedBack = fields.clawedBack;
87
102
  this.claimsClosable = fields.claimsClosable;
88
- this.buffer1 = fields.buffer1;
103
+ this.canUpdateDuration = fields.canUpdateDuration;
104
+ this.totalAmountUnlocked = fields.totalAmountUnlocked;
105
+ this.totalAmountLocked = fields.totalAmountLocked;
106
+ this.lastDurationUpdateTs = fields.lastDurationUpdateTs;
107
+ this.totalClaimablePreUpdate = fields.totalClaimablePreUpdate;
108
+ this.clawedBackTs = fields.clawedBackTs;
89
109
  this.buffer2 = fields.buffer2;
90
110
  this.buffer3 = fields.buffer3;
91
111
  }
@@ -134,7 +154,12 @@ export class MerkleDistributor {
134
154
  admin: dec.admin,
135
155
  clawedBack: dec.clawedBack,
136
156
  claimsClosable: dec.claimsClosable,
137
- buffer1: dec.buffer1,
157
+ canUpdateDuration: dec.canUpdateDuration,
158
+ totalAmountUnlocked: dec.totalAmountUnlocked,
159
+ totalAmountLocked: dec.totalAmountLocked,
160
+ lastDurationUpdateTs: dec.lastDurationUpdateTs,
161
+ totalClaimablePreUpdate: dec.totalClaimablePreUpdate,
162
+ clawedBackTs: dec.clawedBackTs,
138
163
  buffer2: dec.buffer2,
139
164
  buffer3: dec.buffer3,
140
165
  });
@@ -158,7 +183,12 @@ export class MerkleDistributor {
158
183
  admin: this.admin.toString(),
159
184
  clawedBack: this.clawedBack,
160
185
  claimsClosable: this.claimsClosable,
161
- buffer1: this.buffer1,
186
+ canUpdateDuration: this.canUpdateDuration,
187
+ totalAmountUnlocked: this.totalAmountUnlocked.toString(),
188
+ totalAmountLocked: this.totalAmountLocked.toString(),
189
+ lastDurationUpdateTs: this.lastDurationUpdateTs.toString(),
190
+ totalClaimablePreUpdate: this.totalClaimablePreUpdate.toString(),
191
+ clawedBackTs: this.clawedBackTs.toString(),
162
192
  buffer2: this.buffer2,
163
193
  buffer3: this.buffer3,
164
194
  };
@@ -166,23 +196,28 @@ export class MerkleDistributor {
166
196
  static fromJSON(obj) {
167
197
  return new MerkleDistributor({
168
198
  bump: obj.bump,
169
- version: BigNumber(obj.version),
199
+ version: new BN(obj.version),
170
200
  root: obj.root,
171
201
  mint: new PublicKey(obj.mint),
172
202
  tokenVault: new PublicKey(obj.tokenVault),
173
- maxTotalClaim: BigNumber(obj.maxTotalClaim),
174
- maxNumNodes: BigNumber(obj.maxNumNodes),
175
- unlockPeriod: BigNumber(obj.unlockPeriod),
176
- totalAmountClaimed: BigNumber(obj.totalAmountClaimed),
177
- numNodesClaimed: BigNumber(obj.numNodesClaimed),
178
- startTs: BigNumber(obj.startTs),
179
- endTs: BigNumber(obj.endTs),
180
- clawbackStartTs: BigNumber(obj.clawbackStartTs),
203
+ maxTotalClaim: new BN(obj.maxTotalClaim),
204
+ maxNumNodes: new BN(obj.maxNumNodes),
205
+ unlockPeriod: new BN(obj.unlockPeriod),
206
+ totalAmountClaimed: new BN(obj.totalAmountClaimed),
207
+ numNodesClaimed: new BN(obj.numNodesClaimed),
208
+ startTs: new BN(obj.startTs),
209
+ endTs: new BN(obj.endTs),
210
+ clawbackStartTs: new BN(obj.clawbackStartTs),
181
211
  clawbackReceiver: new PublicKey(obj.clawbackReceiver),
182
212
  admin: new PublicKey(obj.admin),
183
213
  clawedBack: obj.clawedBack,
184
214
  claimsClosable: obj.claimsClosable,
185
- buffer1: obj.buffer1,
215
+ canUpdateDuration: obj.canUpdateDuration,
216
+ totalAmountUnlocked: new BN(obj.totalAmountUnlocked),
217
+ totalAmountLocked: new BN(obj.totalAmountLocked),
218
+ lastDurationUpdateTs: new BN(obj.lastDurationUpdateTs),
219
+ totalClaimablePreUpdate: new BN(obj.totalClaimablePreUpdate),
220
+ clawedBackTs: new BN(obj.clawedBackTs),
186
221
  buffer2: obj.buffer2,
187
222
  buffer3: obj.buffer3,
188
223
  });
@@ -1,8 +1,8 @@
1
1
  import { TransactionInstruction, PublicKey } from "@solana/web3.js";
2
- import BigNumber from "bignumber.js";
2
+ import BN from "bn.js";
3
3
  export interface NewClaimArgs {
4
- amountUnlocked: BigNumber;
5
- amountLocked: BigNumber;
4
+ amountUnlocked: BN;
5
+ amountLocked: BN;
6
6
  proof: Array<Array<number>>;
7
7
  }
8
8
  export interface NewClaimAccounts {
@@ -1,14 +1,14 @@
1
1
  import { TransactionInstruction, PublicKey } from "@solana/web3.js";
2
- import BigNumber from "bignumber.js";
2
+ import BN from "bn.js";
3
3
  export interface NewDistributorArgs {
4
- version: BigNumber;
4
+ version: BN;
5
5
  root: Array<number>;
6
- maxTotalClaim: BigNumber;
7
- maxNumNodes: BigNumber;
8
- unlockPeriod: BigNumber;
9
- startVestingTs: BigNumber;
10
- endVestingTs: BigNumber;
11
- clawbackStartTs: BigNumber;
6
+ maxTotalClaim: BN;
7
+ maxNumNodes: BN;
8
+ unlockPeriod: BN;
9
+ startVestingTs: BN;
10
+ endVestingTs: BN;
11
+ clawbackStartTs: BN;
12
12
  claimsClosable: boolean;
13
13
  }
14
14
  export interface NewDistributorAccounts {
@@ -1,4 +1,4 @@
1
- export { default as SolanaDistributorClient } from "./client";
1
+ export * from "./clients/index.js";
2
2
  export * from "./generated/accounts/index.js";
3
3
  export * from "./generated/errors/index.js";
4
4
  export * from "./generated/instructions/index.js";
@@ -1,4 +1,4 @@
1
- export { default as SolanaDistributorClient } from "./client";
1
+ export * from "./clients/index.js";
2
2
  export * from "./generated/accounts/index.js";
3
3
  export * from "./generated/errors/index.js";
4
4
  export * from "./generated/instructions/index.js";
@@ -2,7 +2,11 @@ import { SignerWalletAdapter } from "@solana/wallet-adapter-base";
2
2
  import { Keypair } from "@solana/web3.js";
3
3
  import { ITransactionResult } from "@streamflow/common";
4
4
  import { ITransactionSolanaExt } from "@streamflow/common/solana";
5
- import BigNumber from "bignumber.js";
5
+ import BN from "bn.js";
6
+ import { IdlTypes } from "@coral-xyz/anchor";
7
+ import { AlignedDistributor as AlignedDistributorIDL } from "./descriptor/aligned_distributor.js";
8
+ export type OracleType = IdlTypes<AlignedDistributorIDL>["oracleType"];
9
+ export type OracleTypeName = "none" | "pyth" | "switchboard" | "test";
6
10
  export interface IInteractSolanaExt extends ITransactionSolanaExt {
7
11
  invoker: SignerWalletAdapter | Keypair;
8
12
  }
@@ -13,18 +17,54 @@ export interface ICreateDistributorData {
13
17
  mint: string;
14
18
  version: number;
15
19
  root: Array<number>;
16
- maxTotalClaim: BigNumber;
17
- maxNumNodes: number | string;
20
+ maxTotalClaim: BN | number | string;
21
+ maxNumNodes: BN | number | string;
18
22
  unlockPeriod: number;
19
23
  startVestingTs: number;
20
24
  endVestingTs: number;
21
25
  clawbackStartTs: number;
22
26
  claimsClosable: boolean;
23
27
  }
28
+ export interface AlignedDistributorData {
29
+ sender: string;
30
+ minPrice: number;
31
+ maxPrice: number;
32
+ minPercentage: number;
33
+ maxPercentage: number;
34
+ oracleType: OracleTypeName;
35
+ priceOracle: string | undefined;
36
+ updatePeriod: number;
37
+ clawedBack: boolean;
38
+ }
39
+ export interface NewAlignedDistributorArgs {
40
+ totalAmountLocked: BN;
41
+ totalAmountUnlocked: BN;
42
+ oracleType: OracleType;
43
+ minPrice: BN;
44
+ maxPrice: BN;
45
+ minPercentage: BN;
46
+ maxPercentage: BN;
47
+ tickSize: BN;
48
+ skipInitial: boolean;
49
+ updatePeriod: BN;
50
+ }
51
+ export interface ICreateAlignedDistributorData extends ICreateDistributorData {
52
+ minPrice: number;
53
+ maxPrice: number;
54
+ minPercentage: number;
55
+ maxPercentage: number;
56
+ oracleType: OracleTypeName;
57
+ oracleAddress: string;
58
+ totalAmountLocked: BN | number | string;
59
+ totalAmountUnlocked: BN | number | string;
60
+ updatePeriod?: number;
61
+ tickSize?: number;
62
+ skipInitial?: boolean;
63
+ }
24
64
  export interface IClaimData {
25
65
  id: string;
26
- amountUnlocked: BigNumber;
27
- amountLocked: BigNumber;
66
+ amountUnlocked: BN;
67
+ amountLocked: BN;
28
68
  proof: Array<Array<number>>;
29
69
  }
30
70
  export interface IClawbackData {
@@ -2,7 +2,8 @@ import { TransferFeeConfig } from "@solana/spl-token";
2
2
  import { SignerWalletAdapter } from "@solana/wallet-adapter-base";
3
3
  import { Connection, Keypair, PublicKey, Transaction, VersionedTransaction } from "@solana/web3.js";
4
4
  import { ConfirmationParams, ThrottleParams } from "@streamflow/common/solana";
5
- export declare const divCeilN: (n: bigint, d: bigint) => bigint;
5
+ export declare const getAlignedDistributorPda: (programId: PublicKey, distributor: PublicKey) => PublicKey;
6
+ export declare const getTestOraclePda: (programId: PublicKey, mint: PublicKey, creator: PublicKey) => PublicKey;
6
7
  export declare function getDistributorPda(programId: PublicKey, mint: PublicKey, version: number): PublicKey;
7
8
  export declare function getClaimantStatusPda(programId: PublicKey, distributor: PublicKey, claimant: PublicKey): PublicKey;
8
9
  export declare function getEventAuthorityPda(programId: PublicKey): PublicKey;
@@ -1,14 +1,19 @@
1
1
  import { Buffer } from "buffer";
2
2
  import { PublicKey } from "@solana/web3.js";
3
- import { ContractError } from "@streamflow/common";
3
+ import { ContractError, divCeilN } from "@streamflow/common";
4
4
  import { signAndExecuteTransaction } from "@streamflow/common/solana";
5
- import { fromTxError } from "./generated/errors";
6
- import { ONE_IN_BASIS_POINTS } from "./constants";
7
- export const divCeilN = (n, d) => n / d + (n % d ? BigInt(1) : BigInt(0));
5
+ import { fromTxError } from "./generated/errors/index.js";
6
+ import { ONE_IN_BASIS_POINTS, ALIGNED_DISTRIBUTOR_PREFIX, TEST_ORACLE_PREFIX, DISTRIBUTOR_PREFIX, CLAIM_STATUS_PREFIX, } from "./constants.js";
7
+ export const getAlignedDistributorPda = (programId, distributor) => {
8
+ return PublicKey.findProgramAddressSync([ALIGNED_DISTRIBUTOR_PREFIX, distributor.toBuffer()], programId)[0];
9
+ };
10
+ export const getTestOraclePda = (programId, mint, creator) => {
11
+ return PublicKey.findProgramAddressSync([TEST_ORACLE_PREFIX, mint.toBuffer(), creator.toBuffer()], programId)[0];
12
+ };
8
13
  export function getDistributorPda(programId, mint, version) {
9
14
  // Constructing the seed for the PDA
10
15
  const seeds = [
11
- Buffer.from("MerkleDistributor"),
16
+ DISTRIBUTOR_PREFIX,
12
17
  mint.toBuffer(),
13
18
  Buffer.from(new Uint8Array(new BigUint64Array([BigInt(version)]).buffer)),
14
19
  ];
@@ -17,7 +22,7 @@ export function getDistributorPda(programId, mint, version) {
17
22
  }
18
23
  export function getClaimantStatusPda(programId, distributor, claimant) {
19
24
  // Constructing the seed for the PDA
20
- const seeds = [Buffer.from("ClaimStatus"), claimant.toBuffer(), distributor.toBuffer()];
25
+ const seeds = [CLAIM_STATUS_PREFIX, claimant.toBuffer(), distributor.toBuffer()];
21
26
  // Finding the PDA
22
27
  return PublicKey.findProgramAddressSync(seeds, programId)[0];
23
28
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@streamflow/distributor",
3
- "version": "7.0.0-alpha.9",
3
+ "version": "7.0.0",
4
4
  "description": "JavaScript SDK to interact with Streamflow Airdrop protocol.",
5
5
  "homepage": "https://github.com/streamflow-finance/js-sdk/",
6
6
  "main": "dist/esm/index.js",
@@ -26,20 +26,22 @@
26
26
  "lint": "eslint --fix .",
27
27
  "prepublishOnly": "npm run lint && npm run build"
28
28
  },
29
- "gitHead": "5b3f47ca167e818df9b0d9c0f0818d9a67436c55",
29
+ "gitHead": "c555d74918994e2f688c6c9c906c90e94a201f37",
30
30
  "devDependencies": {
31
- "@streamflow/eslint-config": "7.0.0-alpha.9",
31
+ "@streamflow/eslint-config": "7.0.0",
32
+ "@types/bn.js": "5.1.1",
32
33
  "date-fns": "2.28.0",
33
- "typescript": "^4.9.5"
34
+ "typescript": "^5.6.3"
34
35
  },
35
36
  "dependencies": {
37
+ "@coral-xyz/anchor": "^0.30.0",
36
38
  "@coral-xyz/borsh": "0.30.1",
37
- "@solana/buffer-layout": "4.0.1 ",
38
- "@solana/spl-token": "0.3.6",
39
+ "@solana/buffer-layout": "4.0.1",
40
+ "@solana/spl-token": "0.4.9",
39
41
  "@solana/wallet-adapter-base": "0.9.19",
40
- "@solana/web3.js": "1.90.2",
41
- "@streamflow/common": "7.0.0-alpha.9",
42
- "bignumber.js": "^9.1.2",
42
+ "@solana/web3.js": "1.95.4",
43
+ "@streamflow/common": "7.0.0",
44
+ "bn.js": "5.2.1",
43
45
  "borsh": "^2.0.0",
44
46
  "bs58": "5.0.0",
45
47
  "p-queue": "^8.0.1"
@@ -1,38 +0,0 @@
1
- import PQueue from "p-queue";
2
- import { PublicKey, TransactionInstruction, Commitment, ConnectionConfig } from "@solana/web3.js";
3
- import { ICluster, ITransactionResult } from "@streamflow/common";
4
- import { IProgramAccount } from "@streamflow/common/solana";
5
- import { IClaimData, IClawbackData, ICreateDistributorData, ICreateDistributorResult, IGetClaimData, IGetDistributors, ICreateSolanaExt, IInteractSolanaExt, ISearchDistributors } from "./types";
6
- import { ClaimStatus, MerkleDistributor } from "./generated/accounts";
7
- interface IInitOptions {
8
- clusterUrl: string;
9
- cluster?: ICluster;
10
- commitment?: Commitment | ConnectionConfig;
11
- programId?: string;
12
- sendRate?: number;
13
- sendThrottler?: PQueue;
14
- }
15
- export default class SolanaDistributorClient {
16
- private connection;
17
- private programId;
18
- private commitment;
19
- private sendThrottler;
20
- /**
21
- * Create Stream instance
22
- */
23
- constructor({ clusterUrl, cluster, commitment, programId, sendRate, sendThrottler, }: IInitOptions);
24
- getCommitment(): Commitment | undefined;
25
- create(data: ICreateDistributorData, extParams: ICreateSolanaExt): Promise<ICreateDistributorResult>;
26
- prepareCreateInstructions(data: ICreateDistributorData, extParams: ICreateSolanaExt): Promise<{
27
- distributorPublicKey: PublicKey;
28
- ixs: TransactionInstruction[];
29
- }>;
30
- claim(data: IClaimData, extParams: IInteractSolanaExt): Promise<ITransactionResult>;
31
- prepareClaimInstructions(data: IClaimData, extParams: IInteractSolanaExt): Promise<TransactionInstruction[]>;
32
- clawback(data: IClawbackData, extParams: IInteractSolanaExt): Promise<ITransactionResult>;
33
- prepareClawbackInstructions(data: IClawbackData, extParams: IInteractSolanaExt): Promise<TransactionInstruction[]>;
34
- getClaims(data: IGetClaimData[]): Promise<(ClaimStatus | null)[]>;
35
- getDistributors(data: IGetDistributors): Promise<(MerkleDistributor | null)[]>;
36
- searchDistributors(data: ISearchDistributors): Promise<IProgramAccount<MerkleDistributor>[]>;
37
- }
38
- export {};