@whetstone-research/doppler-sdk 1.0.5 → 1.0.6
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 +10 -1
- package/dist/evm/index.cjs +241 -28
- package/dist/evm/index.cjs.map +1 -1
- package/dist/evm/index.d.cts +35 -0
- package/dist/evm/index.d.ts +35 -0
- package/dist/evm/index.js +241 -28
- package/dist/evm/index.js.map +1 -1
- package/package.json +1 -1
package/dist/evm/index.d.cts
CHANGED
|
@@ -135,11 +135,17 @@ interface OpeningAuctionDopplerConfig$1 {
|
|
|
135
135
|
startTimeOffset?: number;
|
|
136
136
|
startingTime?: number;
|
|
137
137
|
}
|
|
138
|
+
interface VestingScheduleConfig {
|
|
139
|
+
duration: number;
|
|
140
|
+
cliffDuration: number;
|
|
141
|
+
}
|
|
138
142
|
interface VestingConfig {
|
|
139
143
|
duration: number;
|
|
140
144
|
cliffDuration: number;
|
|
141
145
|
recipients?: Address[];
|
|
142
146
|
amounts?: bigint[];
|
|
147
|
+
schedules?: VestingScheduleConfig[];
|
|
148
|
+
scheduleIds?: number[];
|
|
143
149
|
}
|
|
144
150
|
declare const NO_OP_ENABLED_CHAIN_IDS: readonly [1, 11155111, 8453, 84532, 130, 1301, 10143, 143];
|
|
145
151
|
type NoOpEnabledChainId = (typeof NO_OP_ENABLED_CHAIN_IDS)[number];
|
|
@@ -764,8 +770,12 @@ declare class DopplerFactory<C extends SupportedChainId = SupportedChainId> {
|
|
|
764
770
|
private customMigrationEncoder?;
|
|
765
771
|
private multicurveBundlerSupport;
|
|
766
772
|
constructor(publicClient: SupportedPublicClient, walletClient: WalletClient | undefined, chainId: C);
|
|
773
|
+
private hasCustomV2Schedules;
|
|
767
774
|
private usesDerc20V2Vesting;
|
|
768
775
|
private resolveVestingAllocations;
|
|
776
|
+
private normalizeV2ScheduleId;
|
|
777
|
+
private validateUint64LikeNumber;
|
|
778
|
+
private resolveV2VestingSchedules;
|
|
769
779
|
private resolveStandardTokenFactoryMode;
|
|
770
780
|
private assertStandardTokenFactoryCompatibility;
|
|
771
781
|
private buildStandardTokenFactoryData;
|
|
@@ -2402,6 +2412,11 @@ interface BaseAuctionBuilder<C extends SupportedChainId> {
|
|
|
2402
2412
|
cliffDuration?: number;
|
|
2403
2413
|
recipients?: Address[];
|
|
2404
2414
|
amounts?: bigint[];
|
|
2415
|
+
schedules?: {
|
|
2416
|
+
duration?: bigint;
|
|
2417
|
+
cliffDuration?: number;
|
|
2418
|
+
}[];
|
|
2419
|
+
scheduleIds?: Array<number | bigint>;
|
|
2405
2420
|
}): this;
|
|
2406
2421
|
/**
|
|
2407
2422
|
* Configure governance for the token.
|
|
@@ -2548,6 +2563,11 @@ declare class StaticAuctionBuilder<C extends SupportedChainId> implements BaseAu
|
|
|
2548
2563
|
cliffDuration?: number;
|
|
2549
2564
|
recipients?: Address[];
|
|
2550
2565
|
amounts?: bigint[];
|
|
2566
|
+
schedules?: {
|
|
2567
|
+
duration?: bigint;
|
|
2568
|
+
cliffDuration?: number;
|
|
2569
|
+
}[];
|
|
2570
|
+
scheduleIds?: Array<number | bigint>;
|
|
2551
2571
|
}): this;
|
|
2552
2572
|
withGovernance(params: GovernanceOption<C>): this;
|
|
2553
2573
|
withMigration(migration: MigrationConfig): this;
|
|
@@ -2671,6 +2691,11 @@ declare class DynamicAuctionBuilder<C extends SupportedChainId> implements BaseA
|
|
|
2671
2691
|
cliffDuration?: number;
|
|
2672
2692
|
recipients?: Address[];
|
|
2673
2693
|
amounts?: bigint[];
|
|
2694
|
+
schedules?: {
|
|
2695
|
+
duration?: bigint;
|
|
2696
|
+
cliffDuration?: number;
|
|
2697
|
+
}[];
|
|
2698
|
+
scheduleIds?: Array<number | bigint>;
|
|
2674
2699
|
}): this;
|
|
2675
2700
|
withGovernance(params: GovernanceOption<C>): this;
|
|
2676
2701
|
withMigration(migration: MigrationConfig): this;
|
|
@@ -2848,6 +2873,11 @@ declare class MulticurveBuilder<C extends SupportedChainId> implements BaseAucti
|
|
|
2848
2873
|
cliffDuration?: number;
|
|
2849
2874
|
recipients?: Address[];
|
|
2850
2875
|
amounts?: bigint[];
|
|
2876
|
+
schedules?: {
|
|
2877
|
+
duration?: bigint;
|
|
2878
|
+
cliffDuration?: number;
|
|
2879
|
+
}[];
|
|
2880
|
+
scheduleIds?: Array<number | bigint>;
|
|
2851
2881
|
}): this;
|
|
2852
2882
|
private parseStartTimeSeconds;
|
|
2853
2883
|
private assertCanSetInitializer;
|
|
@@ -2986,6 +3016,11 @@ declare class OpeningAuctionBuilder<C extends SupportedChainId> implements BaseA
|
|
|
2986
3016
|
cliffDuration?: number;
|
|
2987
3017
|
recipients?: Address[];
|
|
2988
3018
|
amounts?: bigint[];
|
|
3019
|
+
schedules?: {
|
|
3020
|
+
duration?: bigint;
|
|
3021
|
+
cliffDuration?: number;
|
|
3022
|
+
}[];
|
|
3023
|
+
scheduleIds?: Array<number | bigint>;
|
|
2989
3024
|
}): this;
|
|
2990
3025
|
withGovernance(params: GovernanceOption<C>): this;
|
|
2991
3026
|
withMigration(migration: MigrationConfig): this;
|
package/dist/evm/index.d.ts
CHANGED
|
@@ -135,11 +135,17 @@ interface OpeningAuctionDopplerConfig$1 {
|
|
|
135
135
|
startTimeOffset?: number;
|
|
136
136
|
startingTime?: number;
|
|
137
137
|
}
|
|
138
|
+
interface VestingScheduleConfig {
|
|
139
|
+
duration: number;
|
|
140
|
+
cliffDuration: number;
|
|
141
|
+
}
|
|
138
142
|
interface VestingConfig {
|
|
139
143
|
duration: number;
|
|
140
144
|
cliffDuration: number;
|
|
141
145
|
recipients?: Address[];
|
|
142
146
|
amounts?: bigint[];
|
|
147
|
+
schedules?: VestingScheduleConfig[];
|
|
148
|
+
scheduleIds?: number[];
|
|
143
149
|
}
|
|
144
150
|
declare const NO_OP_ENABLED_CHAIN_IDS: readonly [1, 11155111, 8453, 84532, 130, 1301, 10143, 143];
|
|
145
151
|
type NoOpEnabledChainId = (typeof NO_OP_ENABLED_CHAIN_IDS)[number];
|
|
@@ -764,8 +770,12 @@ declare class DopplerFactory<C extends SupportedChainId = SupportedChainId> {
|
|
|
764
770
|
private customMigrationEncoder?;
|
|
765
771
|
private multicurveBundlerSupport;
|
|
766
772
|
constructor(publicClient: SupportedPublicClient, walletClient: WalletClient | undefined, chainId: C);
|
|
773
|
+
private hasCustomV2Schedules;
|
|
767
774
|
private usesDerc20V2Vesting;
|
|
768
775
|
private resolveVestingAllocations;
|
|
776
|
+
private normalizeV2ScheduleId;
|
|
777
|
+
private validateUint64LikeNumber;
|
|
778
|
+
private resolveV2VestingSchedules;
|
|
769
779
|
private resolveStandardTokenFactoryMode;
|
|
770
780
|
private assertStandardTokenFactoryCompatibility;
|
|
771
781
|
private buildStandardTokenFactoryData;
|
|
@@ -2402,6 +2412,11 @@ interface BaseAuctionBuilder<C extends SupportedChainId> {
|
|
|
2402
2412
|
cliffDuration?: number;
|
|
2403
2413
|
recipients?: Address[];
|
|
2404
2414
|
amounts?: bigint[];
|
|
2415
|
+
schedules?: {
|
|
2416
|
+
duration?: bigint;
|
|
2417
|
+
cliffDuration?: number;
|
|
2418
|
+
}[];
|
|
2419
|
+
scheduleIds?: Array<number | bigint>;
|
|
2405
2420
|
}): this;
|
|
2406
2421
|
/**
|
|
2407
2422
|
* Configure governance for the token.
|
|
@@ -2548,6 +2563,11 @@ declare class StaticAuctionBuilder<C extends SupportedChainId> implements BaseAu
|
|
|
2548
2563
|
cliffDuration?: number;
|
|
2549
2564
|
recipients?: Address[];
|
|
2550
2565
|
amounts?: bigint[];
|
|
2566
|
+
schedules?: {
|
|
2567
|
+
duration?: bigint;
|
|
2568
|
+
cliffDuration?: number;
|
|
2569
|
+
}[];
|
|
2570
|
+
scheduleIds?: Array<number | bigint>;
|
|
2551
2571
|
}): this;
|
|
2552
2572
|
withGovernance(params: GovernanceOption<C>): this;
|
|
2553
2573
|
withMigration(migration: MigrationConfig): this;
|
|
@@ -2671,6 +2691,11 @@ declare class DynamicAuctionBuilder<C extends SupportedChainId> implements BaseA
|
|
|
2671
2691
|
cliffDuration?: number;
|
|
2672
2692
|
recipients?: Address[];
|
|
2673
2693
|
amounts?: bigint[];
|
|
2694
|
+
schedules?: {
|
|
2695
|
+
duration?: bigint;
|
|
2696
|
+
cliffDuration?: number;
|
|
2697
|
+
}[];
|
|
2698
|
+
scheduleIds?: Array<number | bigint>;
|
|
2674
2699
|
}): this;
|
|
2675
2700
|
withGovernance(params: GovernanceOption<C>): this;
|
|
2676
2701
|
withMigration(migration: MigrationConfig): this;
|
|
@@ -2848,6 +2873,11 @@ declare class MulticurveBuilder<C extends SupportedChainId> implements BaseAucti
|
|
|
2848
2873
|
cliffDuration?: number;
|
|
2849
2874
|
recipients?: Address[];
|
|
2850
2875
|
amounts?: bigint[];
|
|
2876
|
+
schedules?: {
|
|
2877
|
+
duration?: bigint;
|
|
2878
|
+
cliffDuration?: number;
|
|
2879
|
+
}[];
|
|
2880
|
+
scheduleIds?: Array<number | bigint>;
|
|
2851
2881
|
}): this;
|
|
2852
2882
|
private parseStartTimeSeconds;
|
|
2853
2883
|
private assertCanSetInitializer;
|
|
@@ -2986,6 +3016,11 @@ declare class OpeningAuctionBuilder<C extends SupportedChainId> implements BaseA
|
|
|
2986
3016
|
cliffDuration?: number;
|
|
2987
3017
|
recipients?: Address[];
|
|
2988
3018
|
amounts?: bigint[];
|
|
3019
|
+
schedules?: {
|
|
3020
|
+
duration?: bigint;
|
|
3021
|
+
cliffDuration?: number;
|
|
3022
|
+
}[];
|
|
3023
|
+
scheduleIds?: Array<number | bigint>;
|
|
2989
3024
|
}): this;
|
|
2990
3025
|
withGovernance(params: GovernanceOption<C>): this;
|
|
2991
3026
|
withMigration(migration: MigrationConfig): this;
|
package/dist/evm/index.js
CHANGED
|
@@ -5280,6 +5280,7 @@ var erc20BalanceOfAbi = [
|
|
|
5280
5280
|
];
|
|
5281
5281
|
var TOKEN_FACTORY_80_ADDRESS2 = "0xf0b5141dd9096254b2ca624dff26024f46087229";
|
|
5282
5282
|
var DERC20_V2_MIN_VESTING_DURATION = 24 * 60 * 60;
|
|
5283
|
+
var MAX_UINT64 = (1n << 64n) - 1n;
|
|
5283
5284
|
var DopplerFactory = class {
|
|
5284
5285
|
publicClient;
|
|
5285
5286
|
walletClient;
|
|
@@ -5291,8 +5292,14 @@ var DopplerFactory = class {
|
|
|
5291
5292
|
this.walletClient = walletClient;
|
|
5292
5293
|
this.chainId = chainId;
|
|
5293
5294
|
}
|
|
5295
|
+
hasCustomV2Schedules(vesting) {
|
|
5296
|
+
return (vesting?.schedules?.length ?? 0) > 0 || (vesting?.scheduleIds?.length ?? 0) > 0;
|
|
5297
|
+
}
|
|
5294
5298
|
usesDerc20V2Vesting(vesting) {
|
|
5295
|
-
|
|
5299
|
+
if (!vesting) {
|
|
5300
|
+
return false;
|
|
5301
|
+
}
|
|
5302
|
+
return this.hasCustomV2Schedules(vesting) || (vesting.cliffDuration ?? 0) > 0;
|
|
5296
5303
|
}
|
|
5297
5304
|
resolveVestingAllocations(args) {
|
|
5298
5305
|
if (!args.vesting) {
|
|
@@ -5309,6 +5316,83 @@ var DopplerFactory = class {
|
|
|
5309
5316
|
amounts: [args.sale.initialSupply - args.sale.numTokensToSell]
|
|
5310
5317
|
};
|
|
5311
5318
|
}
|
|
5319
|
+
normalizeV2ScheduleId(scheduleId, label) {
|
|
5320
|
+
if (!Number.isFinite(scheduleId) || !Number.isInteger(scheduleId)) {
|
|
5321
|
+
throw new Error(`${label} must be an integer`);
|
|
5322
|
+
}
|
|
5323
|
+
if (!Number.isSafeInteger(scheduleId)) {
|
|
5324
|
+
throw new Error(`${label} must be a safe integer`);
|
|
5325
|
+
}
|
|
5326
|
+
if (scheduleId < 0) {
|
|
5327
|
+
throw new Error(`${label} cannot be negative`);
|
|
5328
|
+
}
|
|
5329
|
+
return BigInt(scheduleId);
|
|
5330
|
+
}
|
|
5331
|
+
validateUint64LikeNumber(value, fieldPath, options = {}) {
|
|
5332
|
+
const { allowZero = true } = options;
|
|
5333
|
+
if (!Number.isFinite(value) || !Number.isInteger(value)) {
|
|
5334
|
+
throw new Error(`${fieldPath} must be a finite integer`);
|
|
5335
|
+
}
|
|
5336
|
+
if (!Number.isSafeInteger(value)) {
|
|
5337
|
+
throw new Error(`${fieldPath} must be a safe integer`);
|
|
5338
|
+
}
|
|
5339
|
+
if (value < 0) {
|
|
5340
|
+
throw new Error(`${fieldPath} cannot be negative`);
|
|
5341
|
+
}
|
|
5342
|
+
if (!allowZero && value === 0) {
|
|
5343
|
+
throw new Error(`${fieldPath} must be greater than zero`);
|
|
5344
|
+
}
|
|
5345
|
+
if (BigInt(value) > MAX_UINT64) {
|
|
5346
|
+
throw new Error(`${fieldPath} must fit in uint64`);
|
|
5347
|
+
}
|
|
5348
|
+
}
|
|
5349
|
+
resolveV2VestingSchedules(args) {
|
|
5350
|
+
if (!args.vesting) {
|
|
5351
|
+
return { schedules: [], scheduleIds: [] };
|
|
5352
|
+
}
|
|
5353
|
+
if (!this.hasCustomV2Schedules(args.vesting)) {
|
|
5354
|
+
return {
|
|
5355
|
+
schedules: [
|
|
5356
|
+
{
|
|
5357
|
+
cliff: BigInt(args.vesting.cliffDuration ?? 0),
|
|
5358
|
+
duration: BigInt(args.vesting.duration ?? 0)
|
|
5359
|
+
}
|
|
5360
|
+
],
|
|
5361
|
+
scheduleIds: Array.from({ length: args.recipientCount }, () => 0n)
|
|
5362
|
+
};
|
|
5363
|
+
}
|
|
5364
|
+
const schedules = args.vesting.schedules?.map((schedule) => ({
|
|
5365
|
+
cliff: BigInt(schedule.cliffDuration ?? 0),
|
|
5366
|
+
duration: BigInt(schedule.duration ?? 0)
|
|
5367
|
+
})) ?? [];
|
|
5368
|
+
const explicitScheduleIds = args.vesting.scheduleIds;
|
|
5369
|
+
if (explicitScheduleIds && explicitScheduleIds.length > 0) {
|
|
5370
|
+
return {
|
|
5371
|
+
schedules,
|
|
5372
|
+
scheduleIds: explicitScheduleIds.map(
|
|
5373
|
+
(scheduleId, index) => this.normalizeV2ScheduleId(
|
|
5374
|
+
scheduleId,
|
|
5375
|
+
`Vesting scheduleIds[${index}]`
|
|
5376
|
+
)
|
|
5377
|
+
)
|
|
5378
|
+
};
|
|
5379
|
+
}
|
|
5380
|
+
if (schedules.length === 1) {
|
|
5381
|
+
return {
|
|
5382
|
+
schedules,
|
|
5383
|
+
scheduleIds: Array.from({ length: args.recipientCount }, () => 0n)
|
|
5384
|
+
};
|
|
5385
|
+
}
|
|
5386
|
+
if (schedules.length === args.recipientCount) {
|
|
5387
|
+
return {
|
|
5388
|
+
schedules,
|
|
5389
|
+
scheduleIds: schedules.map((_, index) => BigInt(index))
|
|
5390
|
+
};
|
|
5391
|
+
}
|
|
5392
|
+
throw new Error(
|
|
5393
|
+
"Vesting schedules must either contain exactly one shared schedule or one schedule per recipient when scheduleIds are omitted"
|
|
5394
|
+
);
|
|
5395
|
+
}
|
|
5312
5396
|
resolveStandardTokenFactoryMode(args) {
|
|
5313
5397
|
if (this.usesDerc20V2Vesting(args.vesting)) {
|
|
5314
5398
|
return "v2";
|
|
@@ -5350,12 +5434,10 @@ var DopplerFactory = class {
|
|
|
5350
5434
|
"DERC20 V2 implementation address not configured for this chain."
|
|
5351
5435
|
);
|
|
5352
5436
|
}
|
|
5353
|
-
const schedules =
|
|
5354
|
-
|
|
5355
|
-
|
|
5356
|
-
|
|
5357
|
-
}
|
|
5358
|
-
];
|
|
5437
|
+
const { schedules, scheduleIds } = this.resolveV2VestingSchedules({
|
|
5438
|
+
vesting: args.vesting,
|
|
5439
|
+
recipientCount: recipients.length
|
|
5440
|
+
});
|
|
5359
5441
|
return {
|
|
5360
5442
|
kind: "v2",
|
|
5361
5443
|
name: args.token.name,
|
|
@@ -5365,7 +5447,7 @@ var DopplerFactory = class {
|
|
|
5365
5447
|
yearlyMintRate,
|
|
5366
5448
|
schedules,
|
|
5367
5449
|
beneficiaries: recipients,
|
|
5368
|
-
scheduleIds
|
|
5450
|
+
scheduleIds,
|
|
5369
5451
|
amounts,
|
|
5370
5452
|
tokenURI: args.token.tokenURI,
|
|
5371
5453
|
implementation
|
|
@@ -8152,18 +8234,10 @@ var DopplerFactory = class {
|
|
|
8152
8234
|
}
|
|
8153
8235
|
const cliffDuration = vesting.cliffDuration ?? 0;
|
|
8154
8236
|
const duration = vesting.duration ?? 0;
|
|
8155
|
-
|
|
8156
|
-
|
|
8157
|
-
}
|
|
8158
|
-
if (duration < 0) {
|
|
8159
|
-
throw new Error("Vesting duration cannot be negative");
|
|
8160
|
-
}
|
|
8161
|
-
if (cliffDuration > duration) {
|
|
8162
|
-
throw new Error("Vesting cliff duration cannot exceed vesting duration");
|
|
8163
|
-
}
|
|
8164
|
-
if (cliffDuration > 0 && duration > 0 && duration < DERC20_V2_MIN_VESTING_DURATION) {
|
|
8237
|
+
const hasCustomSchedules = this.hasCustomV2Schedules(vesting);
|
|
8238
|
+
if (hasCustomSchedules && (cliffDuration > 0 || duration > 0)) {
|
|
8165
8239
|
throw new Error(
|
|
8166
|
-
|
|
8240
|
+
"Use vesting.schedules instead of top-level duration/cliffDuration when configuring multiple vesting schedules"
|
|
8167
8241
|
);
|
|
8168
8242
|
}
|
|
8169
8243
|
if (vesting.recipients && vesting.amounts) {
|
|
@@ -8182,11 +8256,79 @@ var DopplerFactory = class {
|
|
|
8182
8256
|
`Total vesting amount (${totalVested}) exceeds available tokens (${availableForVesting})`
|
|
8183
8257
|
);
|
|
8184
8258
|
}
|
|
8259
|
+
} else {
|
|
8260
|
+
const vestedAmount = sale.initialSupply - sale.numTokensToSell;
|
|
8261
|
+
if (vestedAmount <= 0n) {
|
|
8262
|
+
throw new Error("No tokens available for vesting");
|
|
8263
|
+
}
|
|
8264
|
+
}
|
|
8265
|
+
if (hasCustomSchedules) {
|
|
8266
|
+
const schedules = vesting.schedules;
|
|
8267
|
+
if (!schedules || schedules.length === 0) {
|
|
8268
|
+
throw new Error(
|
|
8269
|
+
"Vesting schedules are required when using scheduleIds or multiple vesting schedules"
|
|
8270
|
+
);
|
|
8271
|
+
}
|
|
8272
|
+
const recipientCount = vesting.recipients && vesting.amounts ? vesting.recipients.length : 1;
|
|
8273
|
+
if (vesting.scheduleIds) {
|
|
8274
|
+
if (vesting.scheduleIds.length !== recipientCount) {
|
|
8275
|
+
throw new Error(
|
|
8276
|
+
"Vesting scheduleIds array must have the same length as vesting recipients"
|
|
8277
|
+
);
|
|
8278
|
+
}
|
|
8279
|
+
for (const [index, scheduleId] of vesting.scheduleIds.entries()) {
|
|
8280
|
+
this.validateUint64LikeNumber(
|
|
8281
|
+
scheduleId,
|
|
8282
|
+
`Vesting scheduleIds[${index}]`
|
|
8283
|
+
);
|
|
8284
|
+
if (scheduleId >= schedules.length) {
|
|
8285
|
+
throw new Error(
|
|
8286
|
+
`Vesting scheduleIds[${index}] references missing schedule ${scheduleId}`
|
|
8287
|
+
);
|
|
8288
|
+
}
|
|
8289
|
+
}
|
|
8290
|
+
} else if (schedules.length !== 1 && schedules.length !== recipientCount) {
|
|
8291
|
+
throw new Error(
|
|
8292
|
+
"Vesting schedules must either contain exactly one shared schedule or one schedule per recipient when scheduleIds are omitted"
|
|
8293
|
+
);
|
|
8294
|
+
}
|
|
8295
|
+
for (const [index, schedule] of schedules.entries()) {
|
|
8296
|
+
const scheduleCliff = schedule.cliffDuration ?? 0;
|
|
8297
|
+
const scheduleDuration = schedule.duration ?? 0;
|
|
8298
|
+
this.validateUint64LikeNumber(
|
|
8299
|
+
scheduleCliff,
|
|
8300
|
+
`Vesting schedules[${index}].cliffDuration`
|
|
8301
|
+
);
|
|
8302
|
+
this.validateUint64LikeNumber(
|
|
8303
|
+
scheduleDuration,
|
|
8304
|
+
`Vesting schedules[${index}].duration`
|
|
8305
|
+
);
|
|
8306
|
+
if (scheduleCliff > scheduleDuration) {
|
|
8307
|
+
throw new Error(
|
|
8308
|
+
`Vesting schedules[${index}].cliffDuration cannot exceed duration`
|
|
8309
|
+
);
|
|
8310
|
+
}
|
|
8311
|
+
if (scheduleCliff > 0 && scheduleDuration > 0 && scheduleDuration < DERC20_V2_MIN_VESTING_DURATION) {
|
|
8312
|
+
throw new Error(
|
|
8313
|
+
`Vesting schedules[${index}].duration must be 0 or at least ${DERC20_V2_MIN_VESTING_DURATION} seconds when using cliffs`
|
|
8314
|
+
);
|
|
8315
|
+
}
|
|
8316
|
+
}
|
|
8185
8317
|
return;
|
|
8186
8318
|
}
|
|
8187
|
-
|
|
8188
|
-
|
|
8189
|
-
|
|
8319
|
+
if (cliffDuration < 0) {
|
|
8320
|
+
throw new Error("Vesting cliff duration cannot be negative");
|
|
8321
|
+
}
|
|
8322
|
+
if (duration < 0) {
|
|
8323
|
+
throw new Error("Vesting duration cannot be negative");
|
|
8324
|
+
}
|
|
8325
|
+
if (cliffDuration > duration) {
|
|
8326
|
+
throw new Error("Vesting cliff duration cannot exceed vesting duration");
|
|
8327
|
+
}
|
|
8328
|
+
if (cliffDuration > 0 && duration > 0 && duration < DERC20_V2_MIN_VESTING_DURATION) {
|
|
8329
|
+
throw new Error(
|
|
8330
|
+
`Vesting duration must be 0 or at least ${DERC20_V2_MIN_VESTING_DURATION} seconds when using cliffs`
|
|
8331
|
+
);
|
|
8190
8332
|
}
|
|
8191
8333
|
}
|
|
8192
8334
|
validateStaticAuctionParams(params) {
|
|
@@ -8227,7 +8369,6 @@ var DopplerFactory = class {
|
|
|
8227
8369
|
throw new Error("Cannot sell more tokens than initial supply");
|
|
8228
8370
|
}
|
|
8229
8371
|
this.validateVestingConfig(params.sale, params.vesting);
|
|
8230
|
-
this.validateVestingConfig(params.sale, params.vesting);
|
|
8231
8372
|
if (params.migration.type === "dopplerHook") {
|
|
8232
8373
|
throw new Error(
|
|
8233
8374
|
"dopplerHook migration is only supported for dynamic auctions"
|
|
@@ -13422,6 +13563,35 @@ var Eth = class {
|
|
|
13422
13563
|
};
|
|
13423
13564
|
|
|
13424
13565
|
// src/evm/builders/shared.ts
|
|
13566
|
+
var MAX_SAFE_INTEGER_BIGINT = BigInt(Number.MAX_SAFE_INTEGER);
|
|
13567
|
+
function normalizeBuilderVestingScheduleDuration(value, fieldPath) {
|
|
13568
|
+
const duration = value ?? 0n;
|
|
13569
|
+
if (duration < 0n) {
|
|
13570
|
+
throw new RangeError(`${fieldPath} cannot be negative`);
|
|
13571
|
+
}
|
|
13572
|
+
if (duration > MAX_SAFE_INTEGER_BIGINT) {
|
|
13573
|
+
throw new RangeError(`${fieldPath} must be a safe integer`);
|
|
13574
|
+
}
|
|
13575
|
+
return Number(duration);
|
|
13576
|
+
}
|
|
13577
|
+
function normalizeBuilderScheduleId(scheduleId, fieldPath) {
|
|
13578
|
+
if (typeof scheduleId === "bigint") {
|
|
13579
|
+
if (scheduleId < 0n) {
|
|
13580
|
+
throw new RangeError(`${fieldPath} cannot be negative`);
|
|
13581
|
+
}
|
|
13582
|
+
if (scheduleId > MAX_SAFE_INTEGER_BIGINT) {
|
|
13583
|
+
throw new RangeError(`${fieldPath} must be a safe integer`);
|
|
13584
|
+
}
|
|
13585
|
+
return Number(scheduleId);
|
|
13586
|
+
}
|
|
13587
|
+
if (!Number.isSafeInteger(scheduleId)) {
|
|
13588
|
+
throw new RangeError(`${fieldPath} must be a safe integer`);
|
|
13589
|
+
}
|
|
13590
|
+
if (scheduleId < 0) {
|
|
13591
|
+
throw new RangeError(`${fieldPath} cannot be negative`);
|
|
13592
|
+
}
|
|
13593
|
+
return scheduleId;
|
|
13594
|
+
}
|
|
13425
13595
|
function computeTicks(priceRange, tickSpacing) {
|
|
13426
13596
|
const startTick = Math.floor(
|
|
13427
13597
|
Math.log(priceRange.startPrice) / Math.log(1.0001) / tickSpacing
|
|
@@ -13717,11 +13887,24 @@ var StaticAuctionBuilder = class _StaticAuctionBuilder {
|
|
|
13717
13887
|
this.vesting = void 0;
|
|
13718
13888
|
return this;
|
|
13719
13889
|
}
|
|
13890
|
+
const hasCustomSchedules = (params.schedules?.length ?? 0) > 0 || (params.scheduleIds?.length ?? 0) > 0;
|
|
13720
13891
|
this.vesting = {
|
|
13721
|
-
duration: Number(
|
|
13892
|
+
duration: Number(
|
|
13893
|
+
params.duration ?? (hasCustomSchedules ? 0n : DEFAULT_V3_VESTING_DURATION)
|
|
13894
|
+
),
|
|
13722
13895
|
cliffDuration: params.cliffDuration ?? 0,
|
|
13723
13896
|
recipients: params.recipients,
|
|
13724
|
-
amounts: params.amounts
|
|
13897
|
+
amounts: params.amounts,
|
|
13898
|
+
schedules: params.schedules?.map((schedule) => ({
|
|
13899
|
+
duration: normalizeBuilderVestingScheduleDuration(
|
|
13900
|
+
schedule.duration,
|
|
13901
|
+
"Vesting schedule duration"
|
|
13902
|
+
),
|
|
13903
|
+
cliffDuration: schedule.cliffDuration ?? 0
|
|
13904
|
+
})),
|
|
13905
|
+
scheduleIds: params.scheduleIds?.map(
|
|
13906
|
+
(scheduleId, index) => normalizeBuilderScheduleId(scheduleId, `Vesting scheduleIds[${index}]`)
|
|
13907
|
+
)
|
|
13725
13908
|
};
|
|
13726
13909
|
return this;
|
|
13727
13910
|
}
|
|
@@ -14053,7 +14236,17 @@ var DynamicAuctionBuilder = class _DynamicAuctionBuilder {
|
|
|
14053
14236
|
duration: Number(params.duration ?? 0n),
|
|
14054
14237
|
cliffDuration: params.cliffDuration ?? 0,
|
|
14055
14238
|
recipients: params.recipients,
|
|
14056
|
-
amounts: params.amounts
|
|
14239
|
+
amounts: params.amounts,
|
|
14240
|
+
schedules: params.schedules?.map((schedule) => ({
|
|
14241
|
+
duration: normalizeBuilderVestingScheduleDuration(
|
|
14242
|
+
schedule.duration,
|
|
14243
|
+
"Vesting schedule duration"
|
|
14244
|
+
),
|
|
14245
|
+
cliffDuration: schedule.cliffDuration ?? 0
|
|
14246
|
+
})),
|
|
14247
|
+
scheduleIds: params.scheduleIds?.map(
|
|
14248
|
+
(scheduleId, index) => normalizeBuilderScheduleId(scheduleId, `Vesting scheduleIds[${index}]`)
|
|
14249
|
+
)
|
|
14057
14250
|
};
|
|
14058
14251
|
return this;
|
|
14059
14252
|
}
|
|
@@ -14659,7 +14852,17 @@ var MulticurveBuilder = class _MulticurveBuilder {
|
|
|
14659
14852
|
duration: Number(params.duration ?? 0n),
|
|
14660
14853
|
cliffDuration: params.cliffDuration ?? 0,
|
|
14661
14854
|
recipients: params.recipients,
|
|
14662
|
-
amounts: params.amounts
|
|
14855
|
+
amounts: params.amounts,
|
|
14856
|
+
schedules: params.schedules?.map((schedule) => ({
|
|
14857
|
+
duration: normalizeBuilderVestingScheduleDuration(
|
|
14858
|
+
schedule.duration,
|
|
14859
|
+
"Vesting schedule duration"
|
|
14860
|
+
),
|
|
14861
|
+
cliffDuration: schedule.cliffDuration ?? 0
|
|
14862
|
+
})),
|
|
14863
|
+
scheduleIds: params.scheduleIds?.map(
|
|
14864
|
+
(scheduleId, index) => normalizeBuilderScheduleId(scheduleId, `Vesting scheduleIds[${index}]`)
|
|
14865
|
+
)
|
|
14663
14866
|
};
|
|
14664
14867
|
return this;
|
|
14665
14868
|
}
|
|
@@ -15048,7 +15251,17 @@ var OpeningAuctionBuilder = class _OpeningAuctionBuilder {
|
|
|
15048
15251
|
duration: Number(params.duration ?? 0n),
|
|
15049
15252
|
cliffDuration: params.cliffDuration ?? 0,
|
|
15050
15253
|
recipients: params.recipients,
|
|
15051
|
-
amounts: params.amounts
|
|
15254
|
+
amounts: params.amounts,
|
|
15255
|
+
schedules: params.schedules?.map((schedule) => ({
|
|
15256
|
+
duration: normalizeBuilderVestingScheduleDuration(
|
|
15257
|
+
schedule.duration,
|
|
15258
|
+
"Vesting schedule duration"
|
|
15259
|
+
),
|
|
15260
|
+
cliffDuration: schedule.cliffDuration ?? 0
|
|
15261
|
+
})),
|
|
15262
|
+
scheduleIds: params.scheduleIds?.map(
|
|
15263
|
+
(scheduleId, index) => normalizeBuilderScheduleId(scheduleId, `Vesting scheduleIds[${index}]`)
|
|
15264
|
+
)
|
|
15052
15265
|
};
|
|
15053
15266
|
return this;
|
|
15054
15267
|
}
|