@streamflow/distributor 7.0.0-alpha.2 → 7.0.0-alpha.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +19 -3
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/solana/clients/BaseDistributorClient.js +222 -0
- package/dist/cjs/solana/clients/SolanaAlignedDistributorClient.js +104 -0
- package/dist/cjs/solana/clients/SolanaDistributorClient.js +17 -0
- package/dist/cjs/solana/clients/index.js +10 -0
- package/dist/cjs/solana/constants.js +22 -9
- package/dist/cjs/solana/descriptor/aligned_distributor.js +2 -0
- package/dist/cjs/solana/descriptor/idl/aligned_distributor.json +1242 -0
- package/dist/cjs/solana/generated/accounts/ClaimStatus.js +56 -114
- package/dist/cjs/solana/generated/accounts/MerkleDistributor.js +96 -129
- package/dist/cjs/solana/generated/errors/anchor.js +540 -717
- package/dist/cjs/solana/generated/errors/custom.js +171 -243
- package/dist/cjs/solana/generated/errors/index.js +12 -51
- package/dist/cjs/solana/generated/instructions/claimLocked.js +7 -8
- package/dist/cjs/solana/generated/instructions/clawback.js +8 -9
- package/dist/cjs/solana/generated/instructions/closeClaim.js +8 -9
- package/dist/cjs/solana/generated/instructions/newClaim.js +10 -11
- package/dist/cjs/solana/generated/instructions/newDistributor.js +17 -12
- package/dist/cjs/solana/generated/instructions/setAdmin.js +8 -9
- package/dist/cjs/solana/generated/instructions/setClawbackReceiver.js +8 -9
- package/dist/cjs/solana/generated/programId.js +1 -1
- package/dist/cjs/solana/index.js +8 -12
- package/dist/cjs/solana/utils.js +46 -94
- package/dist/esm/index.d.ts +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/solana/clients/BaseDistributorClient.d.ts +39 -0
- package/dist/esm/solana/{client.js → clients/BaseDistributorClient.js} +97 -66
- package/dist/esm/solana/clients/SolanaAlignedDistributorClient.d.ts +14 -0
- package/dist/esm/solana/clients/SolanaAlignedDistributorClient.js +99 -0
- package/dist/esm/solana/clients/SolanaDistributorClient.d.ts +8 -0
- package/dist/esm/solana/clients/SolanaDistributorClient.js +11 -0
- package/dist/esm/solana/clients/index.d.ts +2 -0
- package/dist/esm/solana/clients/index.js +2 -0
- package/dist/esm/solana/constants.d.ts +15 -0
- package/dist/esm/solana/constants.js +14 -0
- package/dist/esm/solana/descriptor/aligned_distributor.d.ts +918 -0
- package/dist/esm/solana/descriptor/aligned_distributor.js +1 -0
- package/dist/esm/solana/descriptor/idl/aligned_distributor.json +1242 -0
- package/dist/esm/solana/generated/accounts/ClaimStatus.d.ts +17 -17
- package/dist/esm/solana/generated/accounts/ClaimStatus.js +13 -13
- package/dist/esm/solana/generated/accounts/MerkleDistributor.d.ts +55 -25
- package/dist/esm/solana/generated/accounts/MerkleDistributor.js +53 -18
- package/dist/esm/solana/generated/instructions/newClaim.d.ts +3 -3
- package/dist/esm/solana/generated/instructions/newDistributor.d.ts +8 -8
- package/dist/esm/solana/generated/instructions/newDistributor.js +6 -0
- package/dist/esm/solana/index.d.ts +7 -7
- package/dist/esm/solana/index.js +7 -7
- package/dist/esm/solana/types.d.ts +49 -4
- package/dist/esm/solana/utils.d.ts +2 -1
- package/dist/esm/solana/utils.js +11 -6
- package/package.json +9 -7
- package/dist/cjs/solana/client.js +0 -365
- package/dist/esm/solana/client.d.ts +0 -36
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { PublicKey, Connection } from "@solana/web3.js";
|
|
3
|
-
import
|
|
3
|
+
import BN from "bn.js";
|
|
4
4
|
export interface ClaimStatusFields {
|
|
5
5
|
/** Authority that claimed the tokens. */
|
|
6
6
|
claimant: PublicKey;
|
|
7
7
|
/** Locked amount */
|
|
8
|
-
lockedAmount:
|
|
8
|
+
lockedAmount: BN;
|
|
9
9
|
/** Locked amount withdrawn */
|
|
10
|
-
lockedAmountWithdrawn:
|
|
10
|
+
lockedAmountWithdrawn: BN;
|
|
11
11
|
/** Unlocked amount */
|
|
12
|
-
unlockedAmount:
|
|
12
|
+
unlockedAmount: BN;
|
|
13
13
|
/** Last claim time */
|
|
14
|
-
lastClaimTs:
|
|
14
|
+
lastClaimTs: BN;
|
|
15
15
|
/** Track amount per unlock, can be useful for non-linear vesting */
|
|
16
|
-
lastAmountPerUnlock:
|
|
16
|
+
lastAmountPerUnlock: BN;
|
|
17
17
|
/** Whether claim is closed */
|
|
18
18
|
closed: boolean;
|
|
19
|
-
/**
|
|
20
|
-
|
|
19
|
+
/** Distributor account for which ClaimStatus was created, useful to filter by in get_program_accounts */
|
|
20
|
+
distributor: PublicKey;
|
|
21
21
|
/** Buffer for additional fields */
|
|
22
22
|
buffer2: Array<number>;
|
|
23
23
|
}
|
|
@@ -36,8 +36,8 @@ export interface ClaimStatusJSON {
|
|
|
36
36
|
lastAmountPerUnlock: string;
|
|
37
37
|
/** Whether claim is closed */
|
|
38
38
|
closed: boolean;
|
|
39
|
-
/**
|
|
40
|
-
|
|
39
|
+
/** Distributor account for which ClaimStatus was created, useful to filter by in get_program_accounts */
|
|
40
|
+
distributor: string;
|
|
41
41
|
/** Buffer for additional fields */
|
|
42
42
|
buffer2: Array<number>;
|
|
43
43
|
}
|
|
@@ -46,19 +46,19 @@ export declare class ClaimStatus {
|
|
|
46
46
|
/** Authority that claimed the tokens. */
|
|
47
47
|
readonly claimant: PublicKey;
|
|
48
48
|
/** Locked amount */
|
|
49
|
-
readonly lockedAmount:
|
|
49
|
+
readonly lockedAmount: BN;
|
|
50
50
|
/** Locked amount withdrawn */
|
|
51
|
-
readonly lockedAmountWithdrawn:
|
|
51
|
+
readonly lockedAmountWithdrawn: BN;
|
|
52
52
|
/** Unlocked amount */
|
|
53
|
-
readonly unlockedAmount:
|
|
53
|
+
readonly unlockedAmount: BN;
|
|
54
54
|
/** Last claim time */
|
|
55
|
-
readonly lastClaimTs:
|
|
55
|
+
readonly lastClaimTs: BN;
|
|
56
56
|
/** Track amount per unlock, can be useful for non-linear vesting */
|
|
57
|
-
readonly lastAmountPerUnlock:
|
|
57
|
+
readonly lastAmountPerUnlock: BN;
|
|
58
58
|
/** Whether claim is closed */
|
|
59
59
|
readonly closed: boolean;
|
|
60
|
-
/**
|
|
61
|
-
readonly
|
|
60
|
+
/** Distributor account for which ClaimStatus was created, useful to filter by in get_program_accounts */
|
|
61
|
+
readonly distributor: PublicKey;
|
|
62
62
|
/** Buffer for additional fields */
|
|
63
63
|
readonly buffer2: Array<number>;
|
|
64
64
|
static readonly discriminator: Buffer;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { PublicKey } from "@solana/web3.js";
|
|
2
|
-
import
|
|
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
|
-
/**
|
|
22
|
-
|
|
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.
|
|
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.
|
|
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
|
-
|
|
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
|
-
|
|
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:
|
|
104
|
-
lockedAmountWithdrawn:
|
|
105
|
-
unlockedAmount:
|
|
106
|
-
lastClaimTs:
|
|
107
|
-
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
|
-
|
|
109
|
+
distributor: new PublicKey(obj.distributor),
|
|
110
110
|
buffer2: obj.buffer2,
|
|
111
111
|
});
|
|
112
112
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { PublicKey, Connection } from "@solana/web3.js";
|
|
3
|
-
import
|
|
3
|
+
import BN from "bn.js";
|
|
4
4
|
export interface MerkleDistributorFields {
|
|
5
5
|
/** Bump seed. */
|
|
6
6
|
bump: number;
|
|
7
7
|
/** Version of the airdrop */
|
|
8
|
-
version:
|
|
8
|
+
version: BN;
|
|
9
9
|
/** The 256-bit merkle root. */
|
|
10
10
|
root: Array<number>;
|
|
11
11
|
/** [Mint] of the token to be distributed. */
|
|
@@ -13,21 +13,21 @@ export interface MerkleDistributorFields {
|
|
|
13
13
|
/** Token Address of the vault */
|
|
14
14
|
tokenVault: PublicKey;
|
|
15
15
|
/** Maximum number of tokens that can ever be claimed from this [MerkleDistributor]. */
|
|
16
|
-
maxTotalClaim:
|
|
16
|
+
maxTotalClaim: BN;
|
|
17
17
|
/** Maximum number of nodes in [MerkleDistributor]. */
|
|
18
|
-
maxNumNodes:
|
|
18
|
+
maxNumNodes: BN;
|
|
19
19
|
/** Time step (period) in seconds per which the unlock occurs */
|
|
20
|
-
unlockPeriod:
|
|
20
|
+
unlockPeriod: BN;
|
|
21
21
|
/** Total amount of tokens that have been claimed. */
|
|
22
|
-
totalAmountClaimed:
|
|
22
|
+
totalAmountClaimed: BN;
|
|
23
23
|
/** Number of nodes that have been claimed. */
|
|
24
|
-
numNodesClaimed:
|
|
24
|
+
numNodesClaimed: BN;
|
|
25
25
|
/** Lockup time start (Unix Timestamp) */
|
|
26
|
-
startTs:
|
|
26
|
+
startTs: BN;
|
|
27
27
|
/** Lockup time end (Unix Timestamp) */
|
|
28
|
-
endTs:
|
|
28
|
+
endTs: BN;
|
|
29
29
|
/** Clawback start (Unix Timestamp) */
|
|
30
|
-
clawbackStartTs:
|
|
30
|
+
clawbackStartTs: BN;
|
|
31
31
|
/** Clawback receiver */
|
|
32
32
|
clawbackReceiver: PublicKey;
|
|
33
33
|
/** Admin wallet */
|
|
@@ -36,8 +36,18 @@ export interface MerkleDistributorFields {
|
|
|
36
36
|
clawedBack: boolean;
|
|
37
37
|
/** Whether claims are closable by the admin or not */
|
|
38
38
|
claimsClosable: boolean;
|
|
39
|
-
/**
|
|
40
|
-
|
|
39
|
+
/** Whether admin can update vesting duration */
|
|
40
|
+
canUpdateDuration: boolean;
|
|
41
|
+
/** Total amount of funds unlocked (cliff/instant) */
|
|
42
|
+
totalAmountUnlocked: BN;
|
|
43
|
+
/** Total amount of funds locked (vested) */
|
|
44
|
+
totalAmountLocked: BN;
|
|
45
|
+
/** Timestamp when update was last called */
|
|
46
|
+
lastDurationUpdateTs: BN;
|
|
47
|
+
/** Total amount of locked amount claimable as of last duration update, ever increasing total, accumulates with each update */
|
|
48
|
+
totalClaimablePreUpdate: BN;
|
|
49
|
+
/** Timestamp when funds were clawed back */
|
|
50
|
+
clawedBackTs: BN;
|
|
41
51
|
/** Buffer for additional fields */
|
|
42
52
|
buffer2: Array<number>;
|
|
43
53
|
/** Buffer for additional fields */
|
|
@@ -78,8 +88,18 @@ export interface MerkleDistributorJSON {
|
|
|
78
88
|
clawedBack: boolean;
|
|
79
89
|
/** Whether claims are closable by the admin or not */
|
|
80
90
|
claimsClosable: boolean;
|
|
81
|
-
/**
|
|
82
|
-
|
|
91
|
+
/** Whether admin can update vesting duration */
|
|
92
|
+
canUpdateDuration: boolean;
|
|
93
|
+
/** Total amount of funds unlocked (cliff/instant) */
|
|
94
|
+
totalAmountUnlocked: string;
|
|
95
|
+
/** Total amount of funds locked (vested) */
|
|
96
|
+
totalAmountLocked: string;
|
|
97
|
+
/** Timestamp when update was last called */
|
|
98
|
+
lastDurationUpdateTs: string;
|
|
99
|
+
/** Total amount of locked amount claimable as of last duration update, ever increasing total, accumulates with each update */
|
|
100
|
+
totalClaimablePreUpdate: string;
|
|
101
|
+
/** Timestamp when funds were clawed back */
|
|
102
|
+
clawedBackTs: string;
|
|
83
103
|
/** Buffer for additional fields */
|
|
84
104
|
buffer2: Array<number>;
|
|
85
105
|
/** Buffer for additional fields */
|
|
@@ -90,7 +110,7 @@ export declare class MerkleDistributor {
|
|
|
90
110
|
/** Bump seed. */
|
|
91
111
|
readonly bump: number;
|
|
92
112
|
/** Version of the airdrop */
|
|
93
|
-
readonly version:
|
|
113
|
+
readonly version: BN;
|
|
94
114
|
/** The 256-bit merkle root. */
|
|
95
115
|
readonly root: Array<number>;
|
|
96
116
|
/** [Mint] of the token to be distributed. */
|
|
@@ -98,21 +118,21 @@ export declare class MerkleDistributor {
|
|
|
98
118
|
/** Token Address of the vault */
|
|
99
119
|
readonly tokenVault: PublicKey;
|
|
100
120
|
/** Maximum number of tokens that can ever be claimed from this [MerkleDistributor]. */
|
|
101
|
-
readonly maxTotalClaim:
|
|
121
|
+
readonly maxTotalClaim: BN;
|
|
102
122
|
/** Maximum number of nodes in [MerkleDistributor]. */
|
|
103
|
-
readonly maxNumNodes:
|
|
123
|
+
readonly maxNumNodes: BN;
|
|
104
124
|
/** Time step (period) in seconds per which the unlock occurs */
|
|
105
|
-
readonly unlockPeriod:
|
|
125
|
+
readonly unlockPeriod: BN;
|
|
106
126
|
/** Total amount of tokens that have been claimed. */
|
|
107
|
-
readonly totalAmountClaimed:
|
|
127
|
+
readonly totalAmountClaimed: BN;
|
|
108
128
|
/** Number of nodes that have been claimed. */
|
|
109
|
-
readonly numNodesClaimed:
|
|
129
|
+
readonly numNodesClaimed: BN;
|
|
110
130
|
/** Lockup time start (Unix Timestamp) */
|
|
111
|
-
readonly startTs:
|
|
131
|
+
readonly startTs: BN;
|
|
112
132
|
/** Lockup time end (Unix Timestamp) */
|
|
113
|
-
readonly endTs:
|
|
133
|
+
readonly endTs: BN;
|
|
114
134
|
/** Clawback start (Unix Timestamp) */
|
|
115
|
-
readonly clawbackStartTs:
|
|
135
|
+
readonly clawbackStartTs: BN;
|
|
116
136
|
/** Clawback receiver */
|
|
117
137
|
readonly clawbackReceiver: PublicKey;
|
|
118
138
|
/** Admin wallet */
|
|
@@ -121,8 +141,18 @@ export declare class MerkleDistributor {
|
|
|
121
141
|
readonly clawedBack: boolean;
|
|
122
142
|
/** Whether claims are closable by the admin or not */
|
|
123
143
|
readonly claimsClosable: boolean;
|
|
124
|
-
/**
|
|
125
|
-
readonly
|
|
144
|
+
/** Whether admin can update vesting duration */
|
|
145
|
+
readonly canUpdateDuration: boolean;
|
|
146
|
+
/** Total amount of funds unlocked (cliff/instant) */
|
|
147
|
+
readonly totalAmountUnlocked: BN;
|
|
148
|
+
/** Total amount of funds locked (vested) */
|
|
149
|
+
readonly totalAmountLocked: BN;
|
|
150
|
+
/** Timestamp when update was last called */
|
|
151
|
+
readonly lastDurationUpdateTs: BN;
|
|
152
|
+
/** Total amount of locked amount claimable as of last duration update, ever increasing total, accumulates with each update */
|
|
153
|
+
readonly totalClaimablePreUpdate: BN;
|
|
154
|
+
/** Timestamp when funds were clawed back */
|
|
155
|
+
readonly clawedBackTs: BN;
|
|
126
156
|
/** Buffer for additional fields */
|
|
127
157
|
readonly buffer2: Array<number>;
|
|
128
158
|
/** Buffer for additional fields */
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { PublicKey } from "@solana/web3.js";
|
|
2
|
-
import
|
|
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
|
-
/**
|
|
42
|
-
|
|
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.
|
|
67
|
-
borsh.
|
|
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.
|
|
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
|
-
|
|
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
|
-
|
|
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:
|
|
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:
|
|
174
|
-
maxNumNodes:
|
|
175
|
-
unlockPeriod:
|
|
176
|
-
totalAmountClaimed:
|
|
177
|
-
numNodesClaimed:
|
|
178
|
-
startTs:
|
|
179
|
-
endTs:
|
|
180
|
-
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
|
-
|
|
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
|
|
2
|
+
import BN from "bn.js";
|
|
3
3
|
export interface NewClaimArgs {
|
|
4
|
-
amountUnlocked:
|
|
5
|
-
amountLocked:
|
|
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
|
|
2
|
+
import BN from "bn.js";
|
|
3
3
|
export interface NewDistributorArgs {
|
|
4
|
-
version:
|
|
4
|
+
version: BN;
|
|
5
5
|
root: Array<number>;
|
|
6
|
-
maxTotalClaim:
|
|
7
|
-
maxNumNodes:
|
|
8
|
-
unlockPeriod:
|
|
9
|
-
startVestingTs:
|
|
10
|
-
endVestingTs:
|
|
11
|
-
clawbackStartTs:
|
|
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 {
|
|
@@ -12,6 +12,9 @@ export const layout = borsh.struct([
|
|
|
12
12
|
borsh.u64("endVestingTs"),
|
|
13
13
|
borsh.u64("clawbackStartTs"),
|
|
14
14
|
borsh.bool("claimsClosable"),
|
|
15
|
+
borsh.option(borsh.bool(), "canUpdateDuration"),
|
|
16
|
+
borsh.option(borsh.u64(), "totalAmountUnlocked"),
|
|
17
|
+
borsh.option(borsh.u64(), "totalAmountLocked"),
|
|
15
18
|
]);
|
|
16
19
|
/**
|
|
17
20
|
* READ THE FOLLOWING:
|
|
@@ -60,6 +63,9 @@ export function newDistributor(args, accounts, programId = PROGRAM_ID) {
|
|
|
60
63
|
endVestingTs: args.endVestingTs,
|
|
61
64
|
clawbackStartTs: args.clawbackStartTs,
|
|
62
65
|
claimsClosable: args.claimsClosable,
|
|
66
|
+
canUpdateDuration: null,
|
|
67
|
+
totalAmountUnlocked: null,
|
|
68
|
+
totalAmountLocked: null,
|
|
63
69
|
}, buffer);
|
|
64
70
|
const data = Buffer.concat([identifier, buffer]).slice(0, 8 + len);
|
|
65
71
|
const ix = new TransactionInstruction({ keys, programId, data });
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export
|
|
2
|
-
export * from "./generated/accounts";
|
|
3
|
-
export * from "./generated/errors";
|
|
4
|
-
export * from "./generated/instructions";
|
|
5
|
-
export * from "./utils";
|
|
6
|
-
export * from "./types";
|
|
7
|
-
export * as constants from "./constants";
|
|
1
|
+
export * from "./clients/index.js";
|
|
2
|
+
export * from "./generated/accounts/index.js";
|
|
3
|
+
export * from "./generated/errors/index.js";
|
|
4
|
+
export * from "./generated/instructions/index.js";
|
|
5
|
+
export * from "./utils.js";
|
|
6
|
+
export * from "./types.js";
|
|
7
|
+
export * as constants from "./constants.js";
|
package/dist/esm/solana/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export
|
|
2
|
-
export * from "./generated/accounts";
|
|
3
|
-
export * from "./generated/errors";
|
|
4
|
-
export * from "./generated/instructions";
|
|
5
|
-
export * from "./utils";
|
|
6
|
-
export * from "./types";
|
|
7
|
-
export * as constants from "./constants";
|
|
1
|
+
export * from "./clients/index.js";
|
|
2
|
+
export * from "./generated/accounts/index.js";
|
|
3
|
+
export * from "./generated/errors/index.js";
|
|
4
|
+
export * from "./generated/instructions/index.js";
|
|
5
|
+
export * from "./utils.js";
|
|
6
|
+
export * from "./types.js";
|
|
7
|
+
export * as constants from "./constants.js";
|
|
@@ -2,6 +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 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";
|
|
5
10
|
export interface IInteractSolanaExt extends ITransactionSolanaExt {
|
|
6
11
|
invoker: SignerWalletAdapter | Keypair;
|
|
7
12
|
}
|
|
@@ -12,18 +17,54 @@ export interface ICreateDistributorData {
|
|
|
12
17
|
mint: string;
|
|
13
18
|
version: number;
|
|
14
19
|
root: Array<number>;
|
|
15
|
-
maxTotalClaim: number | string;
|
|
16
|
-
maxNumNodes: number | string;
|
|
20
|
+
maxTotalClaim: BN | number | string;
|
|
21
|
+
maxNumNodes: BN | number | string;
|
|
17
22
|
unlockPeriod: number;
|
|
18
23
|
startVestingTs: number;
|
|
19
24
|
endVestingTs: number;
|
|
20
25
|
clawbackStartTs: number;
|
|
21
26
|
claimsClosable: boolean;
|
|
22
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
|
+
}
|
|
23
64
|
export interface IClaimData {
|
|
24
65
|
id: string;
|
|
25
|
-
amountUnlocked:
|
|
26
|
-
amountLocked:
|
|
66
|
+
amountUnlocked: BN;
|
|
67
|
+
amountLocked: BN;
|
|
27
68
|
proof: Array<Array<number>>;
|
|
28
69
|
}
|
|
29
70
|
export interface IClawbackData {
|
|
@@ -36,6 +77,10 @@ export interface IGetClaimData {
|
|
|
36
77
|
export interface IGetDistributors {
|
|
37
78
|
ids: string[];
|
|
38
79
|
}
|
|
80
|
+
export interface ISearchDistributors {
|
|
81
|
+
mint?: string;
|
|
82
|
+
admin?: string;
|
|
83
|
+
}
|
|
39
84
|
export interface ISetDataAdmin {
|
|
40
85
|
id: string;
|
|
41
86
|
newAdmin: string;
|
|
@@ -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
|
|
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;
|
package/dist/esm/solana/utils.js
CHANGED
|
@@ -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
|
|
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
|
-
|
|
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 = [
|
|
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
|
}
|