@metaplex-foundation/genesis 0.20.3 → 0.20.4
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/src/conditions.d.ts +55 -1
- package/dist/src/conditions.js +99 -1
- package/dist/src/conditions.js.map +1 -1
- package/package.json +1 -1
package/dist/src/conditions.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { PublicKey } from '@metaplex-foundation/umi';
|
|
2
|
+
import { BucketTimes, ClaimScheduleArgs, ConditionArgs } from './generated';
|
|
2
3
|
/**
|
|
3
4
|
* Type guard to narrow a ConditionArgs to a specific variant.
|
|
4
5
|
* @param kind - The discriminant to check for ('TimeAbsolute' or 'TimeRelative')
|
|
@@ -8,3 +9,56 @@ import { ConditionArgs } from './generated';
|
|
|
8
9
|
export declare function isConditionArgs<K extends ConditionArgs['__kind']>(kind: K, value: ConditionArgs): value is ConditionArgs & {
|
|
9
10
|
__kind: K;
|
|
10
11
|
};
|
|
12
|
+
/**
|
|
13
|
+
* Creates a TimeAbsolute condition that triggers at a specific Unix timestamp.
|
|
14
|
+
* @param time - Unix timestamp (seconds) when the condition is met
|
|
15
|
+
*/
|
|
16
|
+
export declare function createTimeAbsoluteCondition(time: bigint): ConditionArgs;
|
|
17
|
+
/**
|
|
18
|
+
* Creates a TimeRelative condition that triggers relative to another bucket's
|
|
19
|
+
* start or end time.
|
|
20
|
+
* @param referenceBucket - The public key of the bucket to reference
|
|
21
|
+
* @param bucketTime - Which time on the reference bucket (e.g. Start, End)
|
|
22
|
+
* @param timeOffset - Offset in seconds from the reference time (default 0)
|
|
23
|
+
*/
|
|
24
|
+
export declare function createTimeRelativeCondition(referenceBucket: PublicKey, bucketTime: BucketTimes, timeOffset?: bigint): ConditionArgs;
|
|
25
|
+
/**
|
|
26
|
+
* Creates a Never condition. The condition will never be met and its
|
|
27
|
+
* `triggeredTimestamp` will never be set. Use this for permanently locked
|
|
28
|
+
* schedules (e.g. LP tokens that should never vest).
|
|
29
|
+
*/
|
|
30
|
+
export declare function createNeverCondition(): ConditionArgs;
|
|
31
|
+
/**
|
|
32
|
+
* Creates a ClaimSchedule with TimeAbsolute conditions.
|
|
33
|
+
*
|
|
34
|
+
* Conditions start untriggered — call `CrankExtensionConditionsV2`
|
|
35
|
+
* (or `TriggerConditionsV2`) before claiming to trigger them on-chain.
|
|
36
|
+
*
|
|
37
|
+
* @param params.startTime - Unix timestamp when linear vesting begins
|
|
38
|
+
* @param params.endTime - Unix timestamp when linear vesting ends
|
|
39
|
+
* @param params.cliffTime - Unix timestamp for the cliff
|
|
40
|
+
* @param params.cliffAmountBps - Basis points (0-10000) unlocked at cliff
|
|
41
|
+
* @param params.period - Vesting period length in seconds
|
|
42
|
+
*/
|
|
43
|
+
export declare function createClaimSchedule(params: {
|
|
44
|
+
startTime: bigint;
|
|
45
|
+
endTime: bigint;
|
|
46
|
+
cliffTime: bigint;
|
|
47
|
+
cliffAmountBps: number;
|
|
48
|
+
period: bigint;
|
|
49
|
+
}): ClaimScheduleArgs;
|
|
50
|
+
/**
|
|
51
|
+
* Creates a ClaimSchedule with Never conditions for both start and cliff.
|
|
52
|
+
* Represents a **permanently locked** schedule where tokens never vest.
|
|
53
|
+
*
|
|
54
|
+
* Use this for LP tokens that should be locked forever.
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* ```ts
|
|
58
|
+
* import { createNeverClaimSchedule } from '@metaplex-foundation/genesis';
|
|
59
|
+
*
|
|
60
|
+
* const schedule = createNeverClaimSchedule();
|
|
61
|
+
* // pass as lpLockSchedule when adding a Raydium CPMM bucket
|
|
62
|
+
* ```
|
|
63
|
+
*/
|
|
64
|
+
export declare function createNeverClaimSchedule(): ClaimScheduleArgs;
|
package/dist/src/conditions.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isConditionArgs = void 0;
|
|
3
|
+
exports.createNeverClaimSchedule = exports.createClaimSchedule = exports.createNeverCondition = exports.createTimeRelativeCondition = exports.createTimeAbsoluteCondition = exports.isConditionArgs = void 0;
|
|
4
4
|
/**
|
|
5
5
|
* Type guard to narrow a ConditionArgs to a specific variant.
|
|
6
6
|
* @param kind - The discriminant to check for ('TimeAbsolute' or 'TimeRelative')
|
|
@@ -11,4 +11,102 @@ function isConditionArgs(kind, value) {
|
|
|
11
11
|
return value.__kind === kind;
|
|
12
12
|
}
|
|
13
13
|
exports.isConditionArgs = isConditionArgs;
|
|
14
|
+
// ---------------------------------------------------------------------------
|
|
15
|
+
// Condition Creators
|
|
16
|
+
// ---------------------------------------------------------------------------
|
|
17
|
+
/**
|
|
18
|
+
* Creates a TimeAbsolute condition that triggers at a specific Unix timestamp.
|
|
19
|
+
* @param time - Unix timestamp (seconds) when the condition is met
|
|
20
|
+
*/
|
|
21
|
+
function createTimeAbsoluteCondition(time) {
|
|
22
|
+
return {
|
|
23
|
+
__kind: 'TimeAbsolute',
|
|
24
|
+
padding: Array(47).fill(0),
|
|
25
|
+
time,
|
|
26
|
+
triggeredTimestamp: null,
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
exports.createTimeAbsoluteCondition = createTimeAbsoluteCondition;
|
|
30
|
+
/**
|
|
31
|
+
* Creates a TimeRelative condition that triggers relative to another bucket's
|
|
32
|
+
* start or end time.
|
|
33
|
+
* @param referenceBucket - The public key of the bucket to reference
|
|
34
|
+
* @param bucketTime - Which time on the reference bucket (e.g. Start, End)
|
|
35
|
+
* @param timeOffset - Offset in seconds from the reference time (default 0)
|
|
36
|
+
*/
|
|
37
|
+
function createTimeRelativeCondition(referenceBucket, bucketTime, timeOffset = 0n) {
|
|
38
|
+
return {
|
|
39
|
+
__kind: 'TimeRelative',
|
|
40
|
+
bucketTime,
|
|
41
|
+
padding: Array(14).fill(0),
|
|
42
|
+
timeOffset,
|
|
43
|
+
bucket: referenceBucket,
|
|
44
|
+
triggeredTimestamp: null,
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
exports.createTimeRelativeCondition = createTimeRelativeCondition;
|
|
48
|
+
/**
|
|
49
|
+
* Creates a Never condition. The condition will never be met and its
|
|
50
|
+
* `triggeredTimestamp` will never be set. Use this for permanently locked
|
|
51
|
+
* schedules (e.g. LP tokens that should never vest).
|
|
52
|
+
*/
|
|
53
|
+
function createNeverCondition() {
|
|
54
|
+
return {
|
|
55
|
+
__kind: 'Never',
|
|
56
|
+
padding: Array(55).fill(0),
|
|
57
|
+
triggeredTimestamp: null,
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
exports.createNeverCondition = createNeverCondition;
|
|
61
|
+
// ---------------------------------------------------------------------------
|
|
62
|
+
// ClaimSchedule Creators
|
|
63
|
+
// ---------------------------------------------------------------------------
|
|
64
|
+
/**
|
|
65
|
+
* Creates a ClaimSchedule with TimeAbsolute conditions.
|
|
66
|
+
*
|
|
67
|
+
* Conditions start untriggered — call `CrankExtensionConditionsV2`
|
|
68
|
+
* (or `TriggerConditionsV2`) before claiming to trigger them on-chain.
|
|
69
|
+
*
|
|
70
|
+
* @param params.startTime - Unix timestamp when linear vesting begins
|
|
71
|
+
* @param params.endTime - Unix timestamp when linear vesting ends
|
|
72
|
+
* @param params.cliffTime - Unix timestamp for the cliff
|
|
73
|
+
* @param params.cliffAmountBps - Basis points (0-10000) unlocked at cliff
|
|
74
|
+
* @param params.period - Vesting period length in seconds
|
|
75
|
+
*/
|
|
76
|
+
function createClaimSchedule(params) {
|
|
77
|
+
return {
|
|
78
|
+
startCondition: createTimeAbsoluteCondition(params.startTime),
|
|
79
|
+
duration: params.endTime - params.startTime,
|
|
80
|
+
period: params.period,
|
|
81
|
+
cliffCondition: createTimeAbsoluteCondition(params.cliffTime),
|
|
82
|
+
cliffAmountBps: params.cliffAmountBps,
|
|
83
|
+
reserved: Array(126).fill(0),
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
exports.createClaimSchedule = createClaimSchedule;
|
|
87
|
+
/**
|
|
88
|
+
* Creates a ClaimSchedule with Never conditions for both start and cliff.
|
|
89
|
+
* Represents a **permanently locked** schedule where tokens never vest.
|
|
90
|
+
*
|
|
91
|
+
* Use this for LP tokens that should be locked forever.
|
|
92
|
+
*
|
|
93
|
+
* @example
|
|
94
|
+
* ```ts
|
|
95
|
+
* import { createNeverClaimSchedule } from '@metaplex-foundation/genesis';
|
|
96
|
+
*
|
|
97
|
+
* const schedule = createNeverClaimSchedule();
|
|
98
|
+
* // pass as lpLockSchedule when adding a Raydium CPMM bucket
|
|
99
|
+
* ```
|
|
100
|
+
*/
|
|
101
|
+
function createNeverClaimSchedule() {
|
|
102
|
+
return {
|
|
103
|
+
startCondition: createNeverCondition(),
|
|
104
|
+
duration: 1n,
|
|
105
|
+
period: 1n,
|
|
106
|
+
cliffCondition: createNeverCondition(),
|
|
107
|
+
cliffAmountBps: 0,
|
|
108
|
+
reserved: Array(126).fill(0),
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
exports.createNeverClaimSchedule = createNeverClaimSchedule;
|
|
14
112
|
//# sourceMappingURL=conditions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"conditions.js","sourceRoot":"","sources":["../../src/conditions.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"conditions.js","sourceRoot":"","sources":["../../src/conditions.ts"],"names":[],"mappings":";;;AAGA;;;;;GAKG;AACH,SAAgB,eAAe,CAC7B,IAAO,EACP,KAAoB;IAEpB,OAAO,KAAK,CAAC,MAAM,KAAK,IAAI,CAAC;AAC/B,CAAC;AALD,0CAKC;AAED,8EAA8E;AAC9E,qBAAqB;AACrB,8EAA8E;AAE9E;;;GAGG;AACH,SAAgB,2BAA2B,CAAC,IAAY;IACtD,OAAO;QACL,MAAM,EAAE,cAAc;QACtB,OAAO,EAAE,KAAK,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC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