@streamflow/distributor 7.5.2 → 7.5.3-alpha.cffa362.20250508190445
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.cjs +3073 -0
- package/dist/cjs/index.cjs.map +1 -0
- package/dist/cjs/index.d.cts +10 -0
- package/dist/cjs/solana/descriptor/aligned_distributor.cjs +4 -0
- package/dist/cjs/solana/descriptor/aligned_distributor.cjs.map +1 -0
- package/dist/cjs/solana/descriptor/aligned_distributor.d.cts +932 -0
- package/dist/cjs/solana/descriptor/merkle_distributor.cjs +4 -0
- package/dist/cjs/solana/descriptor/merkle_distributor.cjs.map +1 -0
- package/dist/cjs/solana/descriptor/merkle_distributor.d.cts +1128 -0
- package/dist/cjs/solana/index.cjs +3067 -0
- package/dist/cjs/solana/index.cjs.map +1 -0
- package/dist/cjs/solana/index.d.cts +1485 -0
- package/dist/esm/index.d.ts +10 -1
- package/dist/esm/index.js +3047 -1
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/solana/descriptor/aligned_distributor.d.ts +3 -1
- package/dist/esm/solana/descriptor/aligned_distributor.js +3 -1
- package/dist/esm/solana/descriptor/aligned_distributor.js.map +1 -0
- package/dist/esm/solana/descriptor/idl/aligned_distributor.json +851 -1182
- package/dist/esm/solana/descriptor/idl/merkle_distributor.json +1030 -0
- package/dist/esm/solana/descriptor/merkle_distributor.d.ts +3 -1
- package/dist/esm/solana/descriptor/merkle_distributor.js +3 -1
- package/dist/esm/solana/descriptor/merkle_distributor.js.map +1 -0
- package/dist/esm/solana/index.d.ts +1485 -7
- package/dist/esm/solana/index.js +3019 -7
- package/dist/esm/solana/index.js.map +1 -0
- package/package.json +50 -22
- package/dist/cjs/index.js +0 -27
- package/dist/cjs/solana/clients/BaseDistributorClient.js +0 -276
- package/dist/cjs/solana/clients/SolanaAlignedDistributorClient.js +0 -116
- package/dist/cjs/solana/clients/SolanaDistributorClient.js +0 -17
- package/dist/cjs/solana/clients/index.js +0 -10
- package/dist/cjs/solana/constants.js +0 -28
- package/dist/cjs/solana/descriptor/aligned_distributor.js +0 -2
- package/dist/cjs/solana/descriptor/idl/aligned_distributor.json +0 -1255
- package/dist/cjs/solana/descriptor/merkle_distributor.js +0 -2
- package/dist/cjs/solana/generated/accounts/ClaimStatus.js +0 -135
- package/dist/cjs/solana/generated/accounts/MerkleDistributor.js +0 -215
- package/dist/cjs/solana/generated/accounts/index.js +0 -7
- package/dist/cjs/solana/generated/errors/anchor.js +0 -712
- package/dist/cjs/solana/generated/errors/custom.js +0 -321
- package/dist/cjs/solana/generated/errors/index.js +0 -64
- package/dist/cjs/solana/generated/instructions/claimLocked.js +0 -22
- package/dist/cjs/solana/generated/instructions/clawback.js +0 -21
- package/dist/cjs/solana/generated/instructions/closeClaim.js +0 -57
- package/dist/cjs/solana/generated/instructions/index.js +0 -17
- package/dist/cjs/solana/generated/instructions/newClaim.js +0 -59
- package/dist/cjs/solana/generated/instructions/newDistributor.js +0 -104
- package/dist/cjs/solana/generated/instructions/setAdmin.js +0 -17
- package/dist/cjs/solana/generated/instructions/setClawbackReceiver.js +0 -17
- package/dist/cjs/solana/generated/programId.js +0 -8
- package/dist/cjs/solana/index.js +0 -36
- package/dist/cjs/solana/types.js +0 -159
- package/dist/cjs/solana/utils.js +0 -75
- package/dist/esm/solana/clients/BaseDistributorClient.d.ts +0 -43
- package/dist/esm/solana/clients/BaseDistributorClient.js +0 -274
- package/dist/esm/solana/clients/SolanaAlignedDistributorClient.d.ts +0 -16
- package/dist/esm/solana/clients/SolanaAlignedDistributorClient.js +0 -111
- package/dist/esm/solana/clients/SolanaDistributorClient.d.ts +0 -8
- package/dist/esm/solana/clients/SolanaDistributorClient.js +0 -11
- package/dist/esm/solana/clients/index.d.ts +0 -2
- package/dist/esm/solana/clients/index.js +0 -2
- package/dist/esm/solana/constants.d.ts +0 -24
- package/dist/esm/solana/constants.js +0 -25
- package/dist/esm/solana/generated/accounts/ClaimStatus.d.ts +0 -83
- package/dist/esm/solana/generated/accounts/ClaimStatus.js +0 -127
- package/dist/esm/solana/generated/accounts/MerkleDistributor.d.ts +0 -179
- package/dist/esm/solana/generated/accounts/MerkleDistributor.js +0 -239
- package/dist/esm/solana/generated/accounts/index.d.ts +0 -4
- package/dist/esm/solana/generated/accounts/index.js +0 -2
- package/dist/esm/solana/generated/errors/anchor.d.ts +0 -434
- package/dist/esm/solana/generated/errors/anchor.js +0 -707
- package/dist/esm/solana/generated/errors/custom.d.ts +0 -194
- package/dist/esm/solana/generated/errors/custom.js +0 -317
- package/dist/esm/solana/generated/errors/index.d.ts +0 -5
- package/dist/esm/solana/generated/errors/index.js +0 -37
- package/dist/esm/solana/generated/instructions/claimLocked.d.ts +0 -23
- package/dist/esm/solana/generated/instructions/claimLocked.js +0 -19
- package/dist/esm/solana/generated/instructions/clawback.d.ts +0 -17
- package/dist/esm/solana/generated/instructions/clawback.js +0 -18
- package/dist/esm/solana/generated/instructions/closeClaim.d.ts +0 -22
- package/dist/esm/solana/generated/instructions/closeClaim.js +0 -30
- package/dist/esm/solana/generated/instructions/index.d.ts +0 -14
- package/dist/esm/solana/generated/instructions/index.js +0 -7
- package/dist/esm/solana/generated/instructions/newClaim.d.ts +0 -29
- package/dist/esm/solana/generated/instructions/newClaim.js +0 -32
- package/dist/esm/solana/generated/instructions/newDistributor.d.ts +0 -58
- package/dist/esm/solana/generated/instructions/newDistributor.js +0 -77
- package/dist/esm/solana/generated/instructions/setAdmin.d.ts +0 -10
- package/dist/esm/solana/generated/instructions/setAdmin.js +0 -14
- package/dist/esm/solana/generated/instructions/setClawbackReceiver.d.ts +0 -10
- package/dist/esm/solana/generated/instructions/setClawbackReceiver.js +0 -14
- package/dist/esm/solana/generated/programId.d.ts +0 -3
- package/dist/esm/solana/generated/programId.js +0 -5
- package/dist/esm/solana/types.d.ts +0 -258
- package/dist/esm/solana/types.js +0 -156
- package/dist/esm/solana/utils.d.ts +0 -14
- package/dist/esm/solana/utils.js +0 -65
|
@@ -1,111 +0,0 @@
|
|
|
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
|
-
initialDuration: alignedProxy.initialDuration.toNumber(),
|
|
41
|
-
initialPrice: getNumberFromBN(alignedProxy.initialPrice, ALIGNED_PRECISION_FACTOR_POW),
|
|
42
|
-
lastPrice: getNumberFromBN(alignedProxy.lastPrice, ALIGNED_PRECISION_FACTOR_POW),
|
|
43
|
-
lastDurationUpdateTs: alignedProxy.lastDurationUpdateTs.toNumber(),
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
async getNewDistributorInstruction(data, accounts) {
|
|
47
|
-
const { distributor, mint, clawbackReceiver, tokenProgram, tokenVault, admin } = accounts;
|
|
48
|
-
const baseArgs = this.getNewDistributorArgs(data);
|
|
49
|
-
const alignedArgs = this.getNewAlignedDistributorArgs(data);
|
|
50
|
-
const oracle = data.oracleAddress
|
|
51
|
-
? new PublicKey(data.oracleAddress)
|
|
52
|
-
: getTestOraclePda(this.alignedProxyProgram.programId, mint, admin);
|
|
53
|
-
const newDistributorIx = await this.alignedProxyProgram.methods
|
|
54
|
-
.newDistributor({
|
|
55
|
-
claimsClosable: baseArgs.claimsClosableByAdmin,
|
|
56
|
-
version: baseArgs.version,
|
|
57
|
-
root: baseArgs.root,
|
|
58
|
-
maxTotalClaim: baseArgs.maxTotalClaim,
|
|
59
|
-
maxNumNodes: baseArgs.maxNumNodes,
|
|
60
|
-
unlockPeriod: baseArgs.unlockPeriod,
|
|
61
|
-
startVestingTs: baseArgs.startVestingTs,
|
|
62
|
-
endVestingTs: baseArgs.endVestingTs,
|
|
63
|
-
clawbackStartTs: baseArgs.clawbackStartTs,
|
|
64
|
-
...alignedArgs,
|
|
65
|
-
})
|
|
66
|
-
.accounts({
|
|
67
|
-
admin,
|
|
68
|
-
tokenVault,
|
|
69
|
-
distributor,
|
|
70
|
-
clawbackReceiver,
|
|
71
|
-
mint,
|
|
72
|
-
tokenProgram,
|
|
73
|
-
priceOracle: oracle,
|
|
74
|
-
})
|
|
75
|
-
.instruction();
|
|
76
|
-
return newDistributorIx;
|
|
77
|
-
}
|
|
78
|
-
async getClawbackInstruction(accounts) {
|
|
79
|
-
const { distributor, from, to, mint, tokenProgram, admin } = accounts;
|
|
80
|
-
const alignedDistributorKey = getAlignedDistributorPda(this.alignedProxyProgram.programId, distributor);
|
|
81
|
-
const alignedProxy = await this.alignedProxyProgram.account.alignedDistributor.fetch(alignedDistributorKey);
|
|
82
|
-
invariant(alignedProxy, "Aligned Distributor proxy account not found");
|
|
83
|
-
const clawbackInstruction = await this.alignedProxyProgram.methods
|
|
84
|
-
.clawback()
|
|
85
|
-
.accounts({
|
|
86
|
-
admin,
|
|
87
|
-
distributor,
|
|
88
|
-
from,
|
|
89
|
-
to,
|
|
90
|
-
mint,
|
|
91
|
-
tokenProgram,
|
|
92
|
-
})
|
|
93
|
-
.instruction();
|
|
94
|
-
return clawbackInstruction;
|
|
95
|
-
}
|
|
96
|
-
getNewAlignedDistributorArgs(data) {
|
|
97
|
-
const { oracleType, minPrice, maxPrice, minPercentage, maxPercentage, tickSize, skipInitial, totalAmountLocked, totalAmountUnlocked, unlockPeriod, } = data;
|
|
98
|
-
return {
|
|
99
|
-
totalAmountLocked: new BN(totalAmountLocked),
|
|
100
|
-
totalAmountUnlocked: new BN(totalAmountUnlocked),
|
|
101
|
-
oracleType: (!!oracleType ? { [oracleType]: {} } : { none: {} }),
|
|
102
|
-
minPrice: getBN(minPrice, ALIGNED_PRECISION_FACTOR_POW),
|
|
103
|
-
maxPrice: getBN(maxPrice, ALIGNED_PRECISION_FACTOR_POW),
|
|
104
|
-
minPercentage: getBN(minPercentage, ALIGNED_PRECISION_FACTOR_POW),
|
|
105
|
-
maxPercentage: getBN(maxPercentage, ALIGNED_PRECISION_FACTOR_POW),
|
|
106
|
-
tickSize: new BN(tickSize || 1),
|
|
107
|
-
skipInitial: skipInitial ?? false,
|
|
108
|
-
updatePeriod: unlockPeriod < 30 ? new BN(30) : new BN(unlockPeriod),
|
|
109
|
-
};
|
|
110
|
-
}
|
|
111
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { PublicKey } from "@solana/web3.js";
|
|
2
|
-
export declare const ANCHOR_DISCRIMINATOR_OFFSET = 8;
|
|
3
|
-
export declare const DISTRIBUTOR_MINT_OFFSET: number;
|
|
4
|
-
export declare const DISTRIBUTOR_ADMIN_OFFSET: number;
|
|
5
|
-
export declare const DISTRIBUTOR_PREFIX: Buffer;
|
|
6
|
-
export declare const ALIGNED_DISTRIBUTOR_PREFIX: Buffer;
|
|
7
|
-
export declare const TEST_ORACLE_PREFIX: Buffer;
|
|
8
|
-
export declare const CLAIM_STATUS_PREFIX: Buffer;
|
|
9
|
-
export declare const ALIGNED_PRECISION_FACTOR_POW = 9;
|
|
10
|
-
export declare const AIRDROP_CLAIM_FEE: bigint;
|
|
11
|
-
export declare const STREAMFLOW_TREASURY_PUBLIC_KEY: PublicKey;
|
|
12
|
-
export declare const ONE_IN_BASIS_POINTS: bigint;
|
|
13
|
-
export declare const ALIGNED_DISTRIBUTOR_PROGRAM_ID: {
|
|
14
|
-
devnet: string;
|
|
15
|
-
mainnet: string;
|
|
16
|
-
testnet: string;
|
|
17
|
-
local: string;
|
|
18
|
-
};
|
|
19
|
-
export declare const DISTRIBUTOR_PROGRAM_ID: {
|
|
20
|
-
devnet: string;
|
|
21
|
-
mainnet: string;
|
|
22
|
-
testnet: string;
|
|
23
|
-
local: string;
|
|
24
|
-
};
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { PublicKey } from "@solana/web3.js";
|
|
2
|
-
import { ICluster } from "@streamflow/common";
|
|
3
|
-
export const ANCHOR_DISCRIMINATOR_OFFSET = 8;
|
|
4
|
-
export const DISTRIBUTOR_MINT_OFFSET = ANCHOR_DISCRIMINATOR_OFFSET + 41;
|
|
5
|
-
export const DISTRIBUTOR_ADMIN_OFFSET = ANCHOR_DISCRIMINATOR_OFFSET + 201;
|
|
6
|
-
export const DISTRIBUTOR_PREFIX = Buffer.from("MerkleDistributor", "utf-8");
|
|
7
|
-
export const ALIGNED_DISTRIBUTOR_PREFIX = Buffer.from("aligned-distributor", "utf-8");
|
|
8
|
-
export const TEST_ORACLE_PREFIX = Buffer.from("test-oracle", "utf-8");
|
|
9
|
-
export const CLAIM_STATUS_PREFIX = Buffer.from("ClaimStatus", "utf-8");
|
|
10
|
-
export const ALIGNED_PRECISION_FACTOR_POW = 9;
|
|
11
|
-
export const AIRDROP_CLAIM_FEE = BigInt(5_200_000);
|
|
12
|
-
export const STREAMFLOW_TREASURY_PUBLIC_KEY = new PublicKey("5SEpbdjFK5FxwTvfsGMXVQTD2v4M2c5tyRTxhdsPkgDw");
|
|
13
|
-
export const ONE_IN_BASIS_POINTS = BigInt(10_000);
|
|
14
|
-
export const ALIGNED_DISTRIBUTOR_PROGRAM_ID = {
|
|
15
|
-
[ICluster.Devnet]: "aMERKpFAWoChCi5oZwPvgsSCoGpZKBiU7fi76bdZjt2",
|
|
16
|
-
[ICluster.Mainnet]: "aMERKpFAWoChCi5oZwPvgsSCoGpZKBiU7fi76bdZjt2",
|
|
17
|
-
[ICluster.Testnet]: "aMERKpFAWoChCi5oZwPvgsSCoGpZKBiU7fi76bdZjt2",
|
|
18
|
-
[ICluster.Local]: "aMERKpFAWoChCi5oZwPvgsSCoGpZKBiU7fi76bdZjt2",
|
|
19
|
-
};
|
|
20
|
-
export const DISTRIBUTOR_PROGRAM_ID = {
|
|
21
|
-
[ICluster.Devnet]: "MErKy6nZVoVAkryxAejJz2juifQ4ArgLgHmaJCQkU7N",
|
|
22
|
-
[ICluster.Mainnet]: "MErKy6nZVoVAkryxAejJz2juifQ4ArgLgHmaJCQkU7N",
|
|
23
|
-
[ICluster.Testnet]: "MErKy6nZVoVAkryxAejJz2juifQ4ArgLgHmaJCQkU7N",
|
|
24
|
-
[ICluster.Local]: "MErKy6nZVoVAkryxAejJz2juifQ4ArgLgHmaJCQkU7N",
|
|
25
|
-
};
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
import { PublicKey, Connection } from "@solana/web3.js";
|
|
2
|
-
import BN from "bn.js";
|
|
3
|
-
export interface ClaimStatusFields {
|
|
4
|
-
/** Authority that claimed the tokens. */
|
|
5
|
-
claimant: PublicKey;
|
|
6
|
-
/** Locked amount */
|
|
7
|
-
lockedAmount: BN;
|
|
8
|
-
/** Locked amount withdrawn */
|
|
9
|
-
lockedAmountWithdrawn: BN;
|
|
10
|
-
/** Unlocked amount */
|
|
11
|
-
unlockedAmount: BN;
|
|
12
|
-
/** Last claim time */
|
|
13
|
-
lastClaimTs: BN;
|
|
14
|
-
/** Track amount per unlock, can be useful for non-linear vesting */
|
|
15
|
-
lastAmountPerUnlock: BN;
|
|
16
|
-
/** Whether claim is closed */
|
|
17
|
-
closed: boolean;
|
|
18
|
-
/** Distributor account for which ClaimStatus was created, useful to filter by in get_program_accounts */
|
|
19
|
-
distributor: PublicKey;
|
|
20
|
-
/** Number of time amount has been claimed */
|
|
21
|
-
claimsCount: number;
|
|
22
|
-
/** Time when claim was closed */
|
|
23
|
-
closedTs: BN;
|
|
24
|
-
/** Buffer for additional fields */
|
|
25
|
-
buffer2: Array<number>;
|
|
26
|
-
}
|
|
27
|
-
export interface ClaimStatusJSON {
|
|
28
|
-
/** Authority that claimed the tokens. */
|
|
29
|
-
claimant: string;
|
|
30
|
-
/** Locked amount */
|
|
31
|
-
lockedAmount: string;
|
|
32
|
-
/** Locked amount withdrawn */
|
|
33
|
-
lockedAmountWithdrawn: string;
|
|
34
|
-
/** Unlocked amount */
|
|
35
|
-
unlockedAmount: string;
|
|
36
|
-
/** Last claim time */
|
|
37
|
-
lastClaimTs: string;
|
|
38
|
-
/** Track amount per unlock, can be useful for non-linear vesting */
|
|
39
|
-
lastAmountPerUnlock: string;
|
|
40
|
-
/** Whether claim is closed */
|
|
41
|
-
closed: boolean;
|
|
42
|
-
/** Distributor account for which ClaimStatus was created, useful to filter by in get_program_accounts */
|
|
43
|
-
distributor: string;
|
|
44
|
-
/** Number of time amount has been claimed */
|
|
45
|
-
claimsCount: number;
|
|
46
|
-
/** Time when claim was closed */
|
|
47
|
-
closedTs: string;
|
|
48
|
-
/** Buffer for additional fields */
|
|
49
|
-
buffer2: Array<number>;
|
|
50
|
-
}
|
|
51
|
-
/** Holds whether or not a claimant has claimed tokens. */
|
|
52
|
-
export declare class ClaimStatus {
|
|
53
|
-
/** Authority that claimed the tokens. */
|
|
54
|
-
readonly claimant: PublicKey;
|
|
55
|
-
/** Locked amount */
|
|
56
|
-
readonly lockedAmount: BN;
|
|
57
|
-
/** Locked amount withdrawn */
|
|
58
|
-
readonly lockedAmountWithdrawn: BN;
|
|
59
|
-
/** Unlocked amount */
|
|
60
|
-
readonly unlockedAmount: BN;
|
|
61
|
-
/** Last claim time */
|
|
62
|
-
readonly lastClaimTs: BN;
|
|
63
|
-
/** Track amount per unlock, can be useful for non-linear vesting */
|
|
64
|
-
readonly lastAmountPerUnlock: BN;
|
|
65
|
-
/** Whether claim is closed */
|
|
66
|
-
readonly closed: boolean;
|
|
67
|
-
/** Distributor account for which ClaimStatus was created, useful to filter by in get_program_accounts */
|
|
68
|
-
readonly distributor: PublicKey;
|
|
69
|
-
/** Number of time amount has been claimed */
|
|
70
|
-
readonly claimsCount: number;
|
|
71
|
-
/** Time when claim was closed */
|
|
72
|
-
readonly closedTs: BN;
|
|
73
|
-
/** Buffer for additional fields */
|
|
74
|
-
readonly buffer2: Array<number>;
|
|
75
|
-
static readonly discriminator: Buffer;
|
|
76
|
-
static readonly layout: any;
|
|
77
|
-
constructor(fields: ClaimStatusFields);
|
|
78
|
-
static fetch(c: Connection, address: PublicKey, programId?: PublicKey): Promise<ClaimStatus | null>;
|
|
79
|
-
static fetchMultiple(c: Connection, addresses: PublicKey[], programId?: PublicKey): Promise<Array<ClaimStatus | null>>;
|
|
80
|
-
static decode(data: Buffer): ClaimStatus;
|
|
81
|
-
toJSON(): ClaimStatusJSON;
|
|
82
|
-
static fromJSON(obj: ClaimStatusJSON): ClaimStatus;
|
|
83
|
-
}
|
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
import { PublicKey } from "@solana/web3.js";
|
|
2
|
-
import BN from "bn.js"; // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
3
|
-
import * as borsh from "@coral-xyz/borsh"; // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
4
|
-
import { PROGRAM_ID } from "../programId";
|
|
5
|
-
/** Holds whether or not a claimant has claimed tokens. */
|
|
6
|
-
export class ClaimStatus {
|
|
7
|
-
/** Authority that claimed the tokens. */
|
|
8
|
-
claimant;
|
|
9
|
-
/** Locked amount */
|
|
10
|
-
lockedAmount;
|
|
11
|
-
/** Locked amount withdrawn */
|
|
12
|
-
lockedAmountWithdrawn;
|
|
13
|
-
/** Unlocked amount */
|
|
14
|
-
unlockedAmount;
|
|
15
|
-
/** Last claim time */
|
|
16
|
-
lastClaimTs;
|
|
17
|
-
/** Track amount per unlock, can be useful for non-linear vesting */
|
|
18
|
-
lastAmountPerUnlock;
|
|
19
|
-
/** Whether claim is closed */
|
|
20
|
-
closed;
|
|
21
|
-
/** Distributor account for which ClaimStatus was created, useful to filter by in get_program_accounts */
|
|
22
|
-
distributor;
|
|
23
|
-
/** Number of time amount has been claimed */
|
|
24
|
-
claimsCount;
|
|
25
|
-
/** Time when claim was closed */
|
|
26
|
-
closedTs;
|
|
27
|
-
/** Buffer for additional fields */
|
|
28
|
-
buffer2;
|
|
29
|
-
static discriminator = Buffer.from([22, 183, 249, 157, 247, 95, 150, 96]);
|
|
30
|
-
static layout = borsh.struct([
|
|
31
|
-
borsh.publicKey("claimant"),
|
|
32
|
-
borsh.u64("lockedAmount"),
|
|
33
|
-
borsh.u64("lockedAmountWithdrawn"),
|
|
34
|
-
borsh.u64("unlockedAmount"),
|
|
35
|
-
borsh.u64("lastClaimTs"),
|
|
36
|
-
borsh.u64("lastAmountPerUnlock"),
|
|
37
|
-
borsh.bool("closed"),
|
|
38
|
-
borsh.publicKey("distributor"),
|
|
39
|
-
borsh.u16("claimsCount"),
|
|
40
|
-
borsh.u64("closedTs"),
|
|
41
|
-
borsh.array(borsh.u8(), 22, "buffer2"),
|
|
42
|
-
]);
|
|
43
|
-
constructor(fields) {
|
|
44
|
-
this.claimant = fields.claimant;
|
|
45
|
-
this.lockedAmount = fields.lockedAmount;
|
|
46
|
-
this.lockedAmountWithdrawn = fields.lockedAmountWithdrawn;
|
|
47
|
-
this.unlockedAmount = fields.unlockedAmount;
|
|
48
|
-
this.lastClaimTs = fields.lastClaimTs;
|
|
49
|
-
this.lastAmountPerUnlock = fields.lastAmountPerUnlock;
|
|
50
|
-
this.closed = fields.closed;
|
|
51
|
-
this.distributor = fields.distributor;
|
|
52
|
-
this.claimsCount = fields.claimsCount;
|
|
53
|
-
this.closedTs = fields.closedTs;
|
|
54
|
-
this.buffer2 = fields.buffer2;
|
|
55
|
-
}
|
|
56
|
-
static async fetch(c, address, programId = PROGRAM_ID) {
|
|
57
|
-
const info = await c.getAccountInfo(address);
|
|
58
|
-
if (info === null) {
|
|
59
|
-
return null;
|
|
60
|
-
}
|
|
61
|
-
if (!info.owner.equals(programId)) {
|
|
62
|
-
throw new Error("account doesn't belong to this program");
|
|
63
|
-
}
|
|
64
|
-
return this.decode(info.data);
|
|
65
|
-
}
|
|
66
|
-
static async fetchMultiple(c, addresses, programId = PROGRAM_ID) {
|
|
67
|
-
const infos = await c.getMultipleAccountsInfo(addresses);
|
|
68
|
-
return infos.map((info) => {
|
|
69
|
-
if (info === null) {
|
|
70
|
-
return null;
|
|
71
|
-
}
|
|
72
|
-
if (!info.owner.equals(programId)) {
|
|
73
|
-
throw new Error("account doesn't belong to this program");
|
|
74
|
-
}
|
|
75
|
-
return this.decode(info.data);
|
|
76
|
-
});
|
|
77
|
-
}
|
|
78
|
-
static decode(data) {
|
|
79
|
-
if (!data.slice(0, 8).equals(ClaimStatus.discriminator)) {
|
|
80
|
-
throw new Error("invalid account discriminator");
|
|
81
|
-
}
|
|
82
|
-
const dec = ClaimStatus.layout.decode(data.slice(8));
|
|
83
|
-
return new ClaimStatus({
|
|
84
|
-
claimant: dec.claimant,
|
|
85
|
-
lockedAmount: dec.lockedAmount,
|
|
86
|
-
lockedAmountWithdrawn: dec.lockedAmountWithdrawn,
|
|
87
|
-
unlockedAmount: dec.unlockedAmount,
|
|
88
|
-
lastClaimTs: dec.lastClaimTs,
|
|
89
|
-
lastAmountPerUnlock: dec.lastAmountPerUnlock,
|
|
90
|
-
closed: dec.closed,
|
|
91
|
-
distributor: dec.distributor,
|
|
92
|
-
claimsCount: dec.claimsCount,
|
|
93
|
-
closedTs: dec.closedTs,
|
|
94
|
-
buffer2: dec.buffer2,
|
|
95
|
-
});
|
|
96
|
-
}
|
|
97
|
-
toJSON() {
|
|
98
|
-
return {
|
|
99
|
-
claimant: this.claimant.toString(),
|
|
100
|
-
lockedAmount: this.lockedAmount.toString(),
|
|
101
|
-
lockedAmountWithdrawn: this.lockedAmountWithdrawn.toString(),
|
|
102
|
-
unlockedAmount: this.unlockedAmount.toString(),
|
|
103
|
-
lastClaimTs: this.lastClaimTs.toString(),
|
|
104
|
-
lastAmountPerUnlock: this.lastAmountPerUnlock.toString(),
|
|
105
|
-
closed: this.closed,
|
|
106
|
-
distributor: this.distributor.toString(),
|
|
107
|
-
claimsCount: this.claimsCount,
|
|
108
|
-
closedTs: this.closedTs.toString(),
|
|
109
|
-
buffer2: this.buffer2,
|
|
110
|
-
};
|
|
111
|
-
}
|
|
112
|
-
static fromJSON(obj) {
|
|
113
|
-
return new ClaimStatus({
|
|
114
|
-
claimant: new PublicKey(obj.claimant),
|
|
115
|
-
lockedAmount: new BN(obj.lockedAmount),
|
|
116
|
-
lockedAmountWithdrawn: new BN(obj.lockedAmountWithdrawn),
|
|
117
|
-
unlockedAmount: new BN(obj.unlockedAmount),
|
|
118
|
-
lastClaimTs: new BN(obj.lastClaimTs),
|
|
119
|
-
lastAmountPerUnlock: new BN(obj.lastAmountPerUnlock),
|
|
120
|
-
closed: obj.closed,
|
|
121
|
-
distributor: new PublicKey(obj.distributor),
|
|
122
|
-
claimsCount: obj.claimsCount,
|
|
123
|
-
closedTs: new BN(obj.closedTs),
|
|
124
|
-
buffer2: obj.buffer2,
|
|
125
|
-
});
|
|
126
|
-
}
|
|
127
|
-
}
|
|
@@ -1,179 +0,0 @@
|
|
|
1
|
-
import { PublicKey, Connection } from "@solana/web3.js";
|
|
2
|
-
import BN from "bn.js";
|
|
3
|
-
export interface MerkleDistributorFields {
|
|
4
|
-
/** Bump seed. */
|
|
5
|
-
bump: number;
|
|
6
|
-
/** Version of the airdrop */
|
|
7
|
-
version: BN;
|
|
8
|
-
/** The 256-bit merkle root. */
|
|
9
|
-
root: Array<number>;
|
|
10
|
-
/** [Mint] of the token to be distributed. */
|
|
11
|
-
mint: PublicKey;
|
|
12
|
-
/** Token Address of the vault */
|
|
13
|
-
tokenVault: PublicKey;
|
|
14
|
-
/** Maximum number of tokens that can ever be claimed from this [MerkleDistributor]. */
|
|
15
|
-
maxTotalClaim: BN;
|
|
16
|
-
/** Maximum number of nodes in [MerkleDistributor]. */
|
|
17
|
-
maxNumNodes: BN;
|
|
18
|
-
/** Time step (period) in seconds per which the unlock occurs */
|
|
19
|
-
unlockPeriod: BN;
|
|
20
|
-
/** Total amount of tokens that have been claimed. */
|
|
21
|
-
totalAmountClaimed: BN;
|
|
22
|
-
/** Number of nodes that have been claimed. */
|
|
23
|
-
numNodesClaimed: BN;
|
|
24
|
-
/** Lockup time start (Unix Timestamp) */
|
|
25
|
-
startTs: BN;
|
|
26
|
-
/** Lockup time end (Unix Timestamp) */
|
|
27
|
-
endTs: BN;
|
|
28
|
-
/** Clawback start (Unix Timestamp) */
|
|
29
|
-
clawbackStartTs: BN;
|
|
30
|
-
/** Clawback receiver */
|
|
31
|
-
clawbackReceiver: PublicKey;
|
|
32
|
-
/** Admin wallet */
|
|
33
|
-
admin: PublicKey;
|
|
34
|
-
/** Whether or not the distributor has been clawed back */
|
|
35
|
-
clawedBack: boolean;
|
|
36
|
-
/** Whether claims are closable by the admin or not */
|
|
37
|
-
claimsClosableByAdmin: boolean;
|
|
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;
|
|
50
|
-
/** Whether claims are closable by the claimant or not */
|
|
51
|
-
claimsClosableByClaimant: boolean;
|
|
52
|
-
/** Limit number of claims */
|
|
53
|
-
claimsLimit: number;
|
|
54
|
-
/** Buffer for additional fields */
|
|
55
|
-
buffer2: Array<number>;
|
|
56
|
-
/** Buffer for additional fields */
|
|
57
|
-
buffer3: Array<number>;
|
|
58
|
-
}
|
|
59
|
-
export interface MerkleDistributorJSON {
|
|
60
|
-
/** Bump seed. */
|
|
61
|
-
bump: number;
|
|
62
|
-
/** Version of the airdrop */
|
|
63
|
-
version: string;
|
|
64
|
-
/** The 256-bit merkle root. */
|
|
65
|
-
root: Array<number>;
|
|
66
|
-
/** [Mint] of the token to be distributed. */
|
|
67
|
-
mint: string;
|
|
68
|
-
/** Token Address of the vault */
|
|
69
|
-
tokenVault: string;
|
|
70
|
-
/** Maximum number of tokens that can ever be claimed from this [MerkleDistributor]. */
|
|
71
|
-
maxTotalClaim: string;
|
|
72
|
-
/** Maximum number of nodes in [MerkleDistributor]. */
|
|
73
|
-
maxNumNodes: string;
|
|
74
|
-
/** Time step (period) in seconds per which the unlock occurs */
|
|
75
|
-
unlockPeriod: string;
|
|
76
|
-
/** Total amount of tokens that have been claimed. */
|
|
77
|
-
totalAmountClaimed: string;
|
|
78
|
-
/** Number of nodes that have been claimed. */
|
|
79
|
-
numNodesClaimed: string;
|
|
80
|
-
/** Lockup time start (Unix Timestamp) */
|
|
81
|
-
startTs: string;
|
|
82
|
-
/** Lockup time end (Unix Timestamp) */
|
|
83
|
-
endTs: string;
|
|
84
|
-
/** Clawback start (Unix Timestamp) */
|
|
85
|
-
clawbackStartTs: string;
|
|
86
|
-
/** Clawback receiver */
|
|
87
|
-
clawbackReceiver: string;
|
|
88
|
-
/** Admin wallet */
|
|
89
|
-
admin: string;
|
|
90
|
-
/** Whether or not the distributor has been clawed back */
|
|
91
|
-
clawedBack: boolean;
|
|
92
|
-
/** Whether claims are closable by the admin or not */
|
|
93
|
-
claimsClosableByAdmin: boolean;
|
|
94
|
-
/** Whether admin can update vesting duration */
|
|
95
|
-
canUpdateDuration: boolean;
|
|
96
|
-
/** Total amount of funds unlocked (cliff/instant) */
|
|
97
|
-
totalAmountUnlocked: string;
|
|
98
|
-
/** Total amount of funds locked (vested) */
|
|
99
|
-
totalAmountLocked: string;
|
|
100
|
-
/** Timestamp when update was last called */
|
|
101
|
-
lastDurationUpdateTs: string;
|
|
102
|
-
/** Total amount of locked amount claimable as of last duration update, ever increasing total, accumulates with each update */
|
|
103
|
-
totalClaimablePreUpdate: string;
|
|
104
|
-
/** Timestamp when funds were clawed back */
|
|
105
|
-
clawedBackTs: string;
|
|
106
|
-
/** Whether claims are closable by the claimant or not */
|
|
107
|
-
claimsClosableByClaimant: boolean;
|
|
108
|
-
/** Limit number of claims */
|
|
109
|
-
claimsLimit: number;
|
|
110
|
-
/** Buffer for additional fields */
|
|
111
|
-
buffer2: Array<number>;
|
|
112
|
-
/** Buffer for additional fields */
|
|
113
|
-
buffer3: Array<number>;
|
|
114
|
-
}
|
|
115
|
-
/** State for the account which distributes tokens. */
|
|
116
|
-
export declare class MerkleDistributor {
|
|
117
|
-
/** Bump seed. */
|
|
118
|
-
readonly bump: number;
|
|
119
|
-
/** Version of the airdrop */
|
|
120
|
-
readonly version: BN;
|
|
121
|
-
/** The 256-bit merkle root. */
|
|
122
|
-
readonly root: Array<number>;
|
|
123
|
-
/** [Mint] of the token to be distributed. */
|
|
124
|
-
readonly mint: PublicKey;
|
|
125
|
-
/** Token Address of the vault */
|
|
126
|
-
readonly tokenVault: PublicKey;
|
|
127
|
-
/** Maximum number of tokens that can ever be claimed from this [MerkleDistributor]. */
|
|
128
|
-
readonly maxTotalClaim: BN;
|
|
129
|
-
/** Maximum number of nodes in [MerkleDistributor]. */
|
|
130
|
-
readonly maxNumNodes: BN;
|
|
131
|
-
/** Time step (period) in seconds per which the unlock occurs */
|
|
132
|
-
readonly unlockPeriod: BN;
|
|
133
|
-
/** Total amount of tokens that have been claimed. */
|
|
134
|
-
readonly totalAmountClaimed: BN;
|
|
135
|
-
/** Number of nodes that have been claimed. */
|
|
136
|
-
readonly numNodesClaimed: BN;
|
|
137
|
-
/** Lockup time start (Unix Timestamp) */
|
|
138
|
-
readonly startTs: BN;
|
|
139
|
-
/** Lockup time end (Unix Timestamp) */
|
|
140
|
-
readonly endTs: BN;
|
|
141
|
-
/** Clawback start (Unix Timestamp) */
|
|
142
|
-
readonly clawbackStartTs: BN;
|
|
143
|
-
/** Clawback receiver */
|
|
144
|
-
readonly clawbackReceiver: PublicKey;
|
|
145
|
-
/** Admin wallet */
|
|
146
|
-
readonly admin: PublicKey;
|
|
147
|
-
/** Whether or not the distributor has been clawed back */
|
|
148
|
-
readonly clawedBack: boolean;
|
|
149
|
-
/** Whether claims are closable by the admin or not */
|
|
150
|
-
readonly claimsClosableByAdmin: boolean;
|
|
151
|
-
/** Whether admin can update vesting duration */
|
|
152
|
-
readonly canUpdateDuration: boolean;
|
|
153
|
-
/** Total amount of funds unlocked (cliff/instant) */
|
|
154
|
-
readonly totalAmountUnlocked: BN;
|
|
155
|
-
/** Total amount of funds locked (vested) */
|
|
156
|
-
readonly totalAmountLocked: BN;
|
|
157
|
-
/** Timestamp when update was last called */
|
|
158
|
-
readonly lastDurationUpdateTs: BN;
|
|
159
|
-
/** Total amount of locked amount claimable as of last duration update, ever increasing total, accumulates with each update */
|
|
160
|
-
readonly totalClaimablePreUpdate: BN;
|
|
161
|
-
/** Timestamp when funds were clawed back */
|
|
162
|
-
readonly clawedBackTs: BN;
|
|
163
|
-
/** Whether claims are closable by the claimant or not */
|
|
164
|
-
readonly claimsClosableByClaimant: boolean;
|
|
165
|
-
/** Limit number of claims */
|
|
166
|
-
readonly claimsLimit: number;
|
|
167
|
-
/** Buffer for additional fields */
|
|
168
|
-
readonly buffer2: Array<number>;
|
|
169
|
-
/** Buffer for additional fields */
|
|
170
|
-
readonly buffer3: Array<number>;
|
|
171
|
-
static readonly discriminator: Buffer;
|
|
172
|
-
static readonly layout: any;
|
|
173
|
-
constructor(fields: MerkleDistributorFields);
|
|
174
|
-
static fetch(c: Connection, address: PublicKey, programId?: PublicKey): Promise<MerkleDistributor | null>;
|
|
175
|
-
static fetchMultiple(c: Connection, addresses: PublicKey[], programId?: PublicKey): Promise<Array<MerkleDistributor | null>>;
|
|
176
|
-
static decode(data: Buffer): MerkleDistributor;
|
|
177
|
-
toJSON(): MerkleDistributorJSON;
|
|
178
|
-
static fromJSON(obj: MerkleDistributorJSON): MerkleDistributor;
|
|
179
|
-
}
|