proof-of-take-sdk 3.1.3 → 4.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. package/dist/getters/getSeasonLaunchpadPool.d.ts +31 -0
  2. package/dist/getters/getSeasonLaunchpadPool.js +49 -0
  3. package/dist/getters/index.d.ts +1 -0
  4. package/dist/getters/index.js +1 -0
  5. package/dist/idl/proof_of_take.json +4490 -1674
  6. package/dist/index.d.ts +14 -7
  7. package/dist/index.js +20 -3
  8. package/dist/instructions/buyMizd.d.ts +19 -0
  9. package/dist/instructions/buyMizd.js +41 -0
  10. package/dist/instructions/claimReferralPenaltyForWindow.d.ts +53 -2
  11. package/dist/instructions/claimReferralPenaltyForWindow.js +45 -3
  12. package/dist/instructions/claimSignupRewards.d.ts +30 -0
  13. package/dist/instructions/claimSignupRewards.js +37 -3
  14. package/dist/instructions/claimWindowRewards.d.ts +42 -1
  15. package/dist/instructions/claimWindowRewards.js +47 -3
  16. package/dist/instructions/confirmedPostOnX.d.ts +2 -0
  17. package/dist/instructions/confirmedPostOnX.js +4 -0
  18. package/dist/instructions/createMiztake.d.ts +2 -0
  19. package/dist/instructions/createMiztake.js +4 -0
  20. package/dist/instructions/initializeBondingCurve.d.ts +24 -0
  21. package/dist/instructions/initializeBondingCurve.js +37 -0
  22. package/dist/instructions/initializeRewardWindow.d.ts +2 -0
  23. package/dist/instructions/initializeRewardWindow.js +5 -2
  24. package/dist/instructions/initializeSeasonVault.d.ts +1 -1
  25. package/dist/instructions/initializeSeasonVault.js +3 -2
  26. package/dist/instructions/joinSeason.d.ts +92 -3
  27. package/dist/instructions/joinSeason.js +117 -40
  28. package/dist/instructions/sellMizd.d.ts +19 -0
  29. package/dist/instructions/sellMizd.js +41 -0
  30. package/dist/instructions/viewSeasonMembershipStatus.d.ts +1 -1
  31. package/dist/instructions/viewSeasonMembershipStatus.js +13 -8
  32. package/dist/instructions/withdrawSeasonDeposit.d.ts +2 -0
  33. package/dist/instructions/withdrawSeasonDeposit.js +6 -1
  34. package/dist/optimistic/index.d.ts +1 -0
  35. package/dist/optimistic/index.js +5 -1
  36. package/dist/optimistic/joinSeasonOptimistic.d.ts +31 -0
  37. package/dist/optimistic/joinSeasonOptimistic.js +55 -0
  38. package/dist/types/accountTypes.d.ts +72 -18
  39. package/dist/types/anchorAccounts.d.ts +2 -0
  40. package/dist/types/proof_of_take.d.ts +4471 -1655
  41. package/dist/types.d.ts +10 -2
  42. package/dist/utils/accountConverters.js +7 -1
  43. package/dist/utils/accountUpdates.d.ts +38 -8
  44. package/dist/utils/accountUpdates.js +109 -19
  45. package/dist/utils/constants.d.ts +11 -0
  46. package/dist/utils/constants.js +14 -1
  47. package/dist/utils/pdaManager.d.ts +42 -2
  48. package/dist/utils/pdaManager.js +70 -28
  49. package/dist/utils/pdas.d.ts +46 -8
  50. package/dist/utils/pdas.js +111 -11
  51. package/dist/utils/remainingAccounts.d.ts +1 -0
  52. package/dist/utils/remainingAccounts.js +3 -2
  53. package/dist/utils/seedRegistry.d.ts +10 -0
  54. package/dist/utils/seedRegistry.js +10 -0
  55. package/package.json +1 -1
  56. package/dist/instructions/initializeEscrowVault.d.ts +0 -12
  57. package/dist/instructions/initializeEscrowVault.js +0 -37
package/dist/types.d.ts CHANGED
@@ -4,7 +4,7 @@ import { BN } from "@coral-xyz/anchor";
4
4
  * Type definitions for Proof of Take SDK
5
5
  */
6
6
  export type { ProofOfTake } from "./types/proof_of_take";
7
- export type { ProofOfTakeIdlAccounts, AnchorMiztake, AnchorMiztakeStatistics, AnchorUserStats, AnchorSeasonSettings, AnchorSeason, AnchorSeasonMembership, AnchorRewardWindow, AnchorUserWindowParticipation, AnchorReferralPenaltyClaim, } from "./types/anchorAccounts";
7
+ export type { ProofOfTakeIdlAccounts, AnchorMiztake, AnchorMiztakeStatistics, AnchorUserStats, AnchorSeasonSettings, AnchorSeason, AnchorSeasonMembership, AnchorRewardWindow, AnchorUserWindowParticipation, AnchorReferralPenaltyClaim, AnchorMoonpool, AnchorSunpool, } from "./types/anchorAccounts";
8
8
  export type { ProofOfTakeIdlTypes, AnchorCurrentSeasonView, AnchorSeasonMembershipStatusView, AnchorWindowStatusView, } from "./types/anchorViews";
9
9
  /**
10
10
  * Helper for Anchor "unit enum" variants.
@@ -149,9 +149,11 @@ export interface SeasonSettings {
149
149
  }
150
150
  export interface Season {
151
151
  seasonNumber: BN;
152
+ tokenMint: PublicKey;
152
153
  seasonState: SeasonStateLike;
153
154
  startedAt: BN;
154
155
  endsAt: BN;
156
+ windowDuration: BN;
155
157
  totalWindows: number;
156
158
  totalMembers: BN;
157
159
  copperMembersCount: BN;
@@ -164,6 +166,9 @@ export interface Season {
164
166
  totalSuccessfulPosts: BN;
165
167
  totalPenaltiesCollected: BN;
166
168
  totalUnallocatedFunds: BN;
169
+ launchpad: boolean;
170
+ /** Star flag prompt: a short message (max 33 chars) displayed when users raise their flag. */
171
+ starFlagPrompt: string;
167
172
  bump: number;
168
173
  }
169
174
  export interface SeasonMembership {
@@ -175,7 +180,6 @@ export interface SeasonMembership {
175
180
  seasonNumber: BN;
176
181
  depositTier: SeasonDepositTier;
177
182
  depositAmount: BN;
178
- depositEscrowedAmount: BN;
179
183
  joinedAt: BN;
180
184
  joinedWindowNumber: BN;
181
185
  successfulPostsCount: BN;
@@ -190,6 +194,8 @@ export interface SeasonMembership {
190
194
  /** Whether the user has already withdrawn their season deposit (prevents double-withdraw). */
191
195
  depositWithdrawn: boolean;
192
196
  isActive: boolean;
197
+ /** Launchpad-mode virtual token escrow balance (base units). */
198
+ launchpadTokenEscrowUnits: BN;
193
199
  bump: number;
194
200
  }
195
201
  export interface RewardWindow {
@@ -228,6 +234,8 @@ export interface ReferralPenaltyClaim {
228
234
  windowNumber: BN;
229
235
  claimant: PublicKey;
230
236
  amount: BN;
237
+ tokenSoldUnits: BN;
238
+ solPaidLamports: BN;
231
239
  claimedAt: BN;
232
240
  claimed: boolean;
233
241
  bump: number;
@@ -71,9 +71,11 @@ function toSdkSeason(a) {
71
71
  const eligibleStakePerWindow = (0, conversions_1.toEligibleStakePerWindow)(a.eligibleStakePerWindow);
72
72
  return {
73
73
  seasonNumber: a.seasonNumber,
74
+ tokenMint: a.tokenMint,
74
75
  seasonState: a.seasonState,
75
76
  startedAt: a.startedAt,
76
77
  endsAt: a.endsAt,
78
+ windowDuration: a.windowDuration,
77
79
  totalWindows: a.totalWindows,
78
80
  totalMembers: a.totalMembers,
79
81
  copperMembersCount: a.copperMembersCount,
@@ -86,6 +88,8 @@ function toSdkSeason(a) {
86
88
  totalSuccessfulPosts: a.totalSuccessfulPosts,
87
89
  totalPenaltiesCollected: a.totalPenaltiesCollected,
88
90
  totalUnallocatedFunds: a.totalUnallocatedFunds,
91
+ launchpad: a.launchpad,
92
+ starFlagPrompt: a.starFlagPrompt,
89
93
  bump: a.bump,
90
94
  };
91
95
  }
@@ -97,7 +101,6 @@ function toSdkSeasonMembership(a) {
97
101
  seasonNumber: a.seasonNumber,
98
102
  depositTier: a.depositTier,
99
103
  depositAmount: a.depositAmount,
100
- depositEscrowedAmount: a.depositEscrowedAmount,
101
104
  joinedAt: a.joinedAt,
102
105
  joinedWindowNumber: a.joinedWindowNumber,
103
106
  successfulPostsCount: a.successfulPostsCount,
@@ -108,6 +111,7 @@ function toSdkSeasonMembership(a) {
108
111
  totalPenaltiesPaid: a.totalPenaltiesPaid,
109
112
  depositWithdrawn: a.depositWithdrawn,
110
113
  isActive: a.isActive,
114
+ launchpadTokenEscrowUnits: a.launchpadTokenEscrowUnits,
111
115
  bump: a.bump,
112
116
  };
113
117
  }
@@ -146,6 +150,8 @@ function toSdkReferralPenaltyClaim(a) {
146
150
  windowNumber: a.windowNumber,
147
151
  claimant: a.claimant,
148
152
  amount: a.amount,
153
+ tokenSoldUnits: a.tokenSoldUnits,
154
+ solPaidLamports: a.solPaidLamports,
149
155
  claimedAt: a.claimedAt,
150
156
  claimed: a.claimed,
151
157
  bump: a.bump,
@@ -1,6 +1,7 @@
1
1
  import { BN } from "@coral-xyz/anchor";
2
2
  import { PublicKey } from "@solana/web3.js";
3
3
  import { Miztake, UserStats, MiztakeStatistics, SeasonSettings, Season, SeasonMembership, RewardWindow, UserWindowParticipation, SeasonDepositTier, ReferralPenaltyClaim, TierNumber } from "../types";
4
+ import type { AnchorMoonpool } from "../types/anchorAccounts";
4
5
  /**
5
6
  * Get current Unix timestamp in SECONDS as BN
6
7
  *
@@ -33,13 +34,15 @@ export declare function getCurrentTimestamp(now?: BN): BN;
33
34
  export declare function expectedToBeLazyInitialized(params: {
34
35
  /** Season number to initialize. */
35
36
  seasonNumber: BN;
37
+ /** Token mint this season is scoped to (used for PDA derivation). Defaults to MIZD_TOKEN_MINT. */
38
+ tokenMint?: PublicKey;
36
39
  /** Unix timestamp in seconds used as `started_at` (i64 on-chain). */
37
40
  startedAt: BN;
38
41
  /**
39
42
  * Optional settings snapshot (recommended) to compute `endsAt` and `totalWindows`.
40
43
  * Providing this avoids drift if settings ever change.
41
44
  */
42
- seasonSettings?: Pick<SeasonSettings, "seasonDuration" | "totalWindowsPerSeason" | "lastSeasonEndsAt">;
45
+ seasonSettings?: Pick<SeasonSettings, "seasonDuration" | "windowDuration" | "totalWindowsPerSeason" | "lastSeasonEndsAt">;
43
46
  }): Season;
44
47
  /**
45
48
  * Create an empty/initialized UserStats object
@@ -129,12 +132,11 @@ export declare function updateMiztakeForSeasonUse(miztake: Miztake, seasonNumber
129
132
  * @param seasonNumber - Season number
130
133
  * @param depositTier - Tier chosen at join time
131
134
  * @param depositAmount - Active deposit amount (participates in rewards/penalties)
132
- * @param depositEscrowedAmount - Escrowed deposit amount (always refundable)
133
135
  * @param joinedAt - Timestamp when joined
134
136
  * @param joinedWindowNumber - Window number when joined
135
137
  * @returns Initialized SeasonMembership object
136
138
  */
137
- export declare function initializeSeasonMembership(user: PublicKey, seasonNumber: BN, depositTier: SeasonDepositTier, referrer: PublicKey, depositAmount: BN, depositEscrowedAmount: BN, joinedAt: BN, joinedWindowNumber: BN, bump: number, isStar?: boolean): SeasonMembership;
139
+ export declare function initializeSeasonMembership(user: PublicKey, seasonNumber: BN, depositTier: SeasonDepositTier, referrer: PublicKey, depositAmount: BN, joinedAt: BN, joinedWindowNumber: BN, bump: number, isStar?: boolean): SeasonMembership;
138
140
  /**
139
141
  * Update Season after a user joins
140
142
  * Mirrors the update from join_season.rs (lines 98-104)
@@ -150,12 +152,13 @@ export declare function updateSeasonForJoin(season: Season, depositActive: BN, d
150
152
  *
151
153
  * @param window - Current window
152
154
  * @param isOnTime - Whether the post was on time
153
- * @param penaltyAmount - Penalty amount if late (REQUIRED when isOnTime=false)
155
+ * @param stakeAmount - Stake amount (REQUIRED when isOnTime=true for non-launchpad)
156
+ * @param launchpad - Whether this is a launchpad season (default: false)
154
157
  * @returns Updated RewardWindow object
155
158
  *
156
- * @throws Error if penaltyAmount missing when isOnTime is false
159
+ * @throws Error if stakeAmount missing when isOnTime is true and !launchpad
157
160
  */
158
- export declare function updateWindowForConfirmation(window: RewardWindow, isOnTime: boolean, stakeAmount?: BN): RewardWindow;
161
+ export declare function updateWindowForConfirmation(window: RewardWindow, isOnTime: boolean, stakeAmount?: BN, launchpad?: boolean): RewardWindow;
159
162
  /**
160
163
  * Update UserWindowParticipation after post confirmation
161
164
  * Mirrors confirmed_post_on_x.rs logic
@@ -193,10 +196,15 @@ export declare function updateSeasonForConfirmation(season: Season, isOnTime: bo
193
196
  * Finalize RewardWindow and calculate rewards
194
197
  * Mirrors claim_window_rewards.rs finalization logic (lines 22-86)
195
198
  *
199
+ * NOTE: Launchpad mode bypasses window finalization economics.
200
+ * In launchpad mode, windows are NOT finalized and isFinalized remains false.
201
+ *
196
202
  * @param window - Current window
197
- * @returns Updated finalized RewardWindow object
203
+ * @param eligibleStakeX - Eligible stake for this window (only used for non-launchpad)
204
+ * @param launchpad - Whether this is a launchpad season (default: false)
205
+ * @returns Updated finalized RewardWindow object (or unchanged for launchpad)
198
206
  */
199
- export declare function updateWindowForFinalization(window: RewardWindow, eligibleStakeX: BN): RewardWindow;
207
+ export declare function updateWindowForFinalization(window: RewardWindow, eligibleStakeX: BN, launchpad?: boolean): RewardWindow;
200
208
  /**
201
209
  * Update UserWindowParticipation after claiming window rewards
202
210
  * Mirrors claim_window_rewards.rs logic
@@ -271,3 +279,25 @@ export declare function updateSeasonSettingsForPauseToggle(settings: SeasonSetti
271
279
  * @returns Updated SeasonSettings object
272
280
  */
273
281
  export declare function updateSeasonSettingsForAdminUpdate(settings: SeasonSettings, newAdmin: PublicKey): SeasonSettings;
282
+ /**
283
+ * Update Moonpool after buying tokens (joinSeason launchpad mode)
284
+ * Mirrors moonpool::buy_exact_tokens logic
285
+ *
286
+ * @param moonpool - Current moonpool state
287
+ * @param currentTreasurySolLamports - Current treasury SOL balance before transaction
288
+ * @param solInLamports - SOL paid in lamports
289
+ * @param tokenOutUnits - Tokens bought in base units
290
+ * @returns Updated Moonpool object
291
+ */
292
+ export declare function updateMoonpoolForBuyTokens(moonpool: AnchorMoonpool, currentTreasurySolLamports: BN, solInLamports: BN, tokenOutUnits: BN): AnchorMoonpool;
293
+ /**
294
+ * Update Moonpool after selling tokens (claimRewards launchpad mode)
295
+ * Mirrors moonpool::sell_tokens_for_sol logic
296
+ *
297
+ * @param moonpool - Current moonpool state
298
+ * @param currentTreasurySolLamports - Current treasury SOL balance before transaction
299
+ * @param tokenInUnits - Tokens sold in base units
300
+ * @param solOutLamports - SOL received in lamports
301
+ * @returns Updated Moonpool object
302
+ */
303
+ export declare function updateMoonpoolForSellTokens(moonpool: AnchorMoonpool, currentTreasurySolLamports: BN, tokenInUnits: BN, solOutLamports: BN): AnchorMoonpool;
@@ -22,6 +22,8 @@ exports.initializeReferralPenaltyClaim = initializeReferralPenaltyClaim;
22
22
  exports.calculateWithdrawalAmount = calculateWithdrawalAmount;
23
23
  exports.updateSeasonSettingsForPauseToggle = updateSeasonSettingsForPauseToggle;
24
24
  exports.updateSeasonSettingsForAdminUpdate = updateSeasonSettingsForAdminUpdate;
25
+ exports.updateMoonpoolForBuyTokens = updateMoonpoolForBuyTokens;
26
+ exports.updateMoonpoolForSellTokens = updateMoonpoolForSellTokens;
25
27
  const anchor_1 = require("@coral-xyz/anchor");
26
28
  const types_1 = require("../types");
27
29
  const depositTier_1 = require("./depositTier");
@@ -29,6 +31,7 @@ const tierPenalty_1 = require("./tierPenalty");
29
31
  const conversions_1 = require("./conversions");
30
32
  const pdas_1 = require("./pdas");
31
33
  const enumHelpers_1 = require("./enumHelpers");
34
+ const constants_1 = require("./constants");
32
35
  /**
33
36
  * Get current Unix timestamp in SECONDS as BN
34
37
  *
@@ -64,9 +67,11 @@ function getCurrentTimestamp(now) {
64
67
  */
65
68
  function expectedToBeLazyInitialized(params) {
66
69
  const seasonDuration = params.seasonSettings?.seasonDuration ?? new anchor_1.BN(604800); // 7 days
70
+ const windowDuration = params.seasonSettings?.windowDuration ?? new anchor_1.BN(28800); // 8 hours
67
71
  const totalWindows = params.seasonSettings?.totalWindowsPerSeason ?? 21;
72
+ const tokenMint = params.tokenMint ?? constants_1.MIZD_TOKEN_MINT;
68
73
  // Derive bump seed locally (mirrors Anchor ctx.bumps.season).
69
- const [, bump] = (0, pdas_1.getSeasonPda)(params.seasonNumber);
74
+ const [, bump] = (0, pdas_1.getSeasonPda)(params.seasonNumber, tokenMint);
70
75
  const lastSeasonEndsAt = params.seasonSettings?.lastSeasonEndsAt ?? new anchor_1.BN(0);
71
76
  // If lastSeasonEndsAt is 0 (first season), use params.startedAt.
72
77
  // Otherwise, use lastSeasonEndsAt exactly (gapless).
@@ -77,9 +82,11 @@ function expectedToBeLazyInitialized(params) {
77
82
  : lastSeasonEndsAt;
78
83
  return {
79
84
  seasonNumber: params.seasonNumber,
85
+ tokenMint,
80
86
  seasonState: types_1.SeasonState.Active,
81
87
  startedAt: effectiveStartedAt,
82
88
  endsAt: effectiveStartedAt.add(seasonDuration),
89
+ windowDuration,
83
90
  totalWindows,
84
91
  totalMembers: new anchor_1.BN(0),
85
92
  copperMembersCount: new anchor_1.BN(0),
@@ -92,6 +99,8 @@ function expectedToBeLazyInitialized(params) {
92
99
  totalSuccessfulPosts: new anchor_1.BN(0),
93
100
  totalPenaltiesCollected: new anchor_1.BN(0),
94
101
  totalUnallocatedFunds: new anchor_1.BN(0),
102
+ launchpad: false,
103
+ starFlagPrompt: "",
95
104
  bump,
96
105
  };
97
106
  }
@@ -259,12 +268,11 @@ function updateMiztakeForSeasonUse(miztake, seasonNumber, windowNumber) {
259
268
  * @param seasonNumber - Season number
260
269
  * @param depositTier - Tier chosen at join time
261
270
  * @param depositAmount - Active deposit amount (participates in rewards/penalties)
262
- * @param depositEscrowedAmount - Escrowed deposit amount (always refundable)
263
271
  * @param joinedAt - Timestamp when joined
264
272
  * @param joinedWindowNumber - Window number when joined
265
273
  * @returns Initialized SeasonMembership object
266
274
  */
267
- function initializeSeasonMembership(user, seasonNumber, depositTier, referrer, depositAmount, depositEscrowedAmount, joinedAt, joinedWindowNumber, bump, isStar = false) {
275
+ function initializeSeasonMembership(user, seasonNumber, depositTier, referrer, depositAmount, joinedAt, joinedWindowNumber, bump, isStar = false) {
268
276
  return {
269
277
  owner: user,
270
278
  referrer,
@@ -272,7 +280,6 @@ function initializeSeasonMembership(user, seasonNumber, depositTier, referrer, d
272
280
  seasonNumber,
273
281
  depositTier,
274
282
  depositAmount,
275
- depositEscrowedAmount,
276
283
  joinedAt,
277
284
  joinedWindowNumber,
278
285
  successfulPostsCount: new anchor_1.BN(0),
@@ -283,6 +290,7 @@ function initializeSeasonMembership(user, seasonNumber, depositTier, referrer, d
283
290
  totalPenaltiesPaid: new anchor_1.BN(0),
284
291
  depositWithdrawn: false,
285
292
  isActive: true,
293
+ launchpadTokenEscrowUnits: new anchor_1.BN(0),
286
294
  bump,
287
295
  };
288
296
  }
@@ -379,21 +387,32 @@ function updateSeasonForJoin(season, depositActive, depositTier, joinedWindowNum
379
387
  *
380
388
  * @param window - Current window
381
389
  * @param isOnTime - Whether the post was on time
382
- * @param penaltyAmount - Penalty amount if late (REQUIRED when isOnTime=false)
390
+ * @param stakeAmount - Stake amount (REQUIRED when isOnTime=true for non-launchpad)
391
+ * @param launchpad - Whether this is a launchpad season (default: false)
383
392
  * @returns Updated RewardWindow object
384
393
  *
385
- * @throws Error if penaltyAmount missing when isOnTime is false
394
+ * @throws Error if stakeAmount missing when isOnTime is true and !launchpad
386
395
  */
387
- function updateWindowForConfirmation(window, isOnTime, stakeAmount) {
396
+ function updateWindowForConfirmation(window, isOnTime, stakeAmount, launchpad = false) {
388
397
  if (isOnTime) {
389
- if (!stakeAmount || stakeAmount.isZero()) {
390
- throw new Error("updateWindowForConfirmation: stakeAmount is required when isOnTime is true");
398
+ // Only mutate successful_stake_total for non-launchpad seasons
399
+ if (!launchpad) {
400
+ if (!stakeAmount || stakeAmount.isZero()) {
401
+ throw new Error("updateWindowForConfirmation: stakeAmount is required when isOnTime is true for non-launchpad seasons");
402
+ }
403
+ return {
404
+ ...window,
405
+ successfulPostersCount: window.successfulPostersCount.add(new anchor_1.BN(1)),
406
+ successfulStakeTotal: window.successfulStakeTotal.add(stakeAmount),
407
+ };
408
+ }
409
+ else {
410
+ // Launchpad mode: only increment successfulPostersCount
411
+ return {
412
+ ...window,
413
+ successfulPostersCount: window.successfulPostersCount.add(new anchor_1.BN(1)),
414
+ };
391
415
  }
392
- return {
393
- ...window,
394
- successfulPostersCount: window.successfulPostersCount.add(new anchor_1.BN(1)),
395
- successfulStakeTotal: window.successfulStakeTotal.add(stakeAmount),
396
- };
397
416
  }
398
417
  else {
399
418
  // penaltyPool is derived at finalization as X - Y; do not mutate here
@@ -469,10 +488,20 @@ function updateSeasonForConfirmation(season, isOnTime, _stakeAmount) {
469
488
  * Finalize RewardWindow and calculate rewards
470
489
  * Mirrors claim_window_rewards.rs finalization logic (lines 22-86)
471
490
  *
491
+ * NOTE: Launchpad mode bypasses window finalization economics.
492
+ * In launchpad mode, windows are NOT finalized and isFinalized remains false.
493
+ *
472
494
  * @param window - Current window
473
- * @returns Updated finalized RewardWindow object
495
+ * @param eligibleStakeX - Eligible stake for this window (only used for non-launchpad)
496
+ * @param launchpad - Whether this is a launchpad season (default: false)
497
+ * @returns Updated finalized RewardWindow object (or unchanged for launchpad)
474
498
  */
475
- function updateWindowForFinalization(window, eligibleStakeX) {
499
+ function updateWindowForFinalization(window, eligibleStakeX, launchpad = false) {
500
+ // Launchpad mode bypasses window finalization economics
501
+ if (launchpad) {
502
+ return { ...window }; // No finalization in launchpad mode
503
+ }
504
+ // Non-launchpad mode: standard X-Y finalization
476
505
  // penalty_pool is derived as X - Y.
477
506
  const finalPenaltyPool = eligibleStakeX.gt(window.successfulStakeTotal)
478
507
  ? eligibleStakeX.sub(window.successfulStakeTotal)
@@ -557,6 +586,8 @@ function initializeReferralPenaltyClaim(params) {
557
586
  windowNumber: params.windowNumber,
558
587
  claimant: params.claimant,
559
588
  amount,
589
+ tokenSoldUnits: new anchor_1.BN(0),
590
+ solPaidLamports: new anchor_1.BN(0),
560
591
  claimedAt,
561
592
  claimed: true,
562
593
  bump,
@@ -607,12 +638,10 @@ function calculateWithdrawalAmount(membership, season, settings) {
607
638
  const clampedWithdrawalAmount = withdrawalAmount.gt(new anchor_1.BN(0))
608
639
  ? withdrawalAmount
609
640
  : new anchor_1.BN(0);
610
- // Escrowed portion is always refunded in full at season end.
611
- const totalWithdrawalAmount = clampedWithdrawalAmount.add(membership.depositEscrowedAmount);
641
+ const totalWithdrawalAmount = clampedWithdrawalAmount;
612
642
  // Update membership
613
643
  const updatedMembership = {
614
644
  ...membership,
615
- depositEscrowedAmount: new anchor_1.BN(0),
616
645
  depositWithdrawn: true,
617
646
  isActive: false,
618
647
  };
@@ -669,3 +698,64 @@ function updateSeasonSettingsForAdminUpdate(settings, newAdmin) {
669
698
  admin: newAdmin,
670
699
  };
671
700
  }
701
+ /**
702
+ * Helper: Compute constant-product invariant K
703
+ * Mirrors bonding_curve_math::compute_k
704
+ *
705
+ * @param solReserveLamports - SOL reserve in lamports
706
+ * @param tokenReserveUnits - Token reserve in base units
707
+ * @param virtualSolReserveLamports - Virtual SOL reserve
708
+ * @param virtualTokenReserveUnits - Virtual token reserve
709
+ * @returns Invariant K as BN
710
+ */
711
+ function computeK(solReserveLamports, tokenReserveUnits, virtualSolReserveLamports, virtualTokenReserveUnits) {
712
+ const x = solReserveLamports.add(virtualSolReserveLamports);
713
+ const y = tokenReserveUnits.add(virtualTokenReserveUnits);
714
+ return x.mul(y);
715
+ }
716
+ /**
717
+ * Update Moonpool after buying tokens (joinSeason launchpad mode)
718
+ * Mirrors moonpool::buy_exact_tokens logic
719
+ *
720
+ * @param moonpool - Current moonpool state
721
+ * @param currentTreasurySolLamports - Current treasury SOL balance before transaction
722
+ * @param solInLamports - SOL paid in lamports
723
+ * @param tokenOutUnits - Tokens bought in base units
724
+ * @returns Updated Moonpool object
725
+ */
726
+ function updateMoonpoolForBuyTokens(moonpool, currentTreasurySolLamports, solInLamports, tokenOutUnits) {
727
+ // Update token reserve (decreases)
728
+ const newTokenReserve = moonpool.tokenReserveUnits.sub(tokenOutUnits);
729
+ // Update SOL reserve (increases)
730
+ const solAfter = currentTreasurySolLamports.add(solInLamports);
731
+ // Compute new K with updated reserves
732
+ const newK = computeK(solAfter, newTokenReserve, moonpool.virtualSolReserveLamports, moonpool.virtualTokenReserveUnits);
733
+ return {
734
+ ...moonpool,
735
+ tokenReserveUnits: newTokenReserve,
736
+ lastK: newK,
737
+ };
738
+ }
739
+ /**
740
+ * Update Moonpool after selling tokens (claimRewards launchpad mode)
741
+ * Mirrors moonpool::sell_tokens_for_sol logic
742
+ *
743
+ * @param moonpool - Current moonpool state
744
+ * @param currentTreasurySolLamports - Current treasury SOL balance before transaction
745
+ * @param tokenInUnits - Tokens sold in base units
746
+ * @param solOutLamports - SOL received in lamports
747
+ * @returns Updated Moonpool object
748
+ */
749
+ function updateMoonpoolForSellTokens(moonpool, currentTreasurySolLamports, tokenInUnits, solOutLamports) {
750
+ // Update token reserve (increases)
751
+ const newTokenReserve = moonpool.tokenReserveUnits.add(tokenInUnits);
752
+ // Update SOL reserve (decreases)
753
+ const solAfter = currentTreasurySolLamports.sub(solOutLamports);
754
+ // Compute new K with updated reserves
755
+ const newK = computeK(solAfter, newTokenReserve, moonpool.virtualSolReserveLamports, moonpool.virtualTokenReserveUnits);
756
+ return {
757
+ ...moonpool,
758
+ tokenReserveUnits: newTokenReserve,
759
+ lastK: newK,
760
+ };
761
+ }
@@ -5,12 +5,23 @@ import { PublicKey } from "@solana/web3.js";
5
5
  export declare const PROGRAM_ID: PublicKey;
6
6
  export declare const ADMIN_PUBLIC_KEY: PublicKey;
7
7
  export declare const MIZD_TOKEN_MINT: PublicKey;
8
+ export declare const SEASON_INSTANCE_ID: any;
8
9
  export declare const DEFAULT_FEE_RECIPIENT: PublicKey;
9
10
  export declare const MIZTAKE_STATISTICS_SEED: "miztake_statistics";
10
11
  export declare const USER_STATS_SEED: "user_stats";
11
12
  export declare const MIZTAKE_SEED: "miztake";
12
13
  export declare const REFERRAL_PENALTY_CLAIM_SEED: "referral_penalty_claim";
13
14
  export declare const SIGNUP_REWARDS_SEED: "signup_rewards";
15
+ export declare const USER_JOIN_CREDIT_SEED: "user_join_credit";
16
+ /** The Moonpool is the Moon's seesaw for buying and selling stars (real SPL Token-2022 tokens). */
17
+ export declare const MOONPOOL_SEED: "moonpool";
18
+ export declare const MOONPOOL_TREASURY_SEED: "moonpool_treasury";
19
+ /** SPL Token-2022 mint for launchpad tokens. Mint authority is the Moonpool PDA. */
20
+ export declare const LAUNCHPAD_TOKEN_MINT_SEED: "launchpad_token_mint";
21
+ /** The Sunpool is the Sun's flag shop for classic (non-launchpad) mode. */
22
+ export declare const SUNPOOL_SEED: "sunpool";
23
+ export declare const BONDING_CURVE_SEED: "bonding_curve";
24
+ export declare const BONDING_CURVE_MIZD_VAULT_SEED: "bonding_curve_mizd_vault";
14
25
  export declare const DEFAULT_MIZTAKE_FEE = 100000;
15
26
  export declare const DEFAULT_MAX_CLAIMABLE = 10000000000;
16
27
  export declare const MIN_FEE = 10000;
@@ -1,7 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.MIN_HASH_LENGTH = exports.MAX_USERNAME_LENGTH = exports.MAX_MAX_CLAIMABLE = exports.MIN_MAX_CLAIMABLE = exports.MAX_FEE = exports.MIN_FEE = exports.DEFAULT_MAX_CLAIMABLE = exports.DEFAULT_MIZTAKE_FEE = exports.SIGNUP_REWARDS_SEED = exports.REFERRAL_PENALTY_CLAIM_SEED = exports.MIZTAKE_SEED = exports.USER_STATS_SEED = exports.MIZTAKE_STATISTICS_SEED = exports.DEFAULT_FEE_RECIPIENT = exports.MIZD_TOKEN_MINT = exports.ADMIN_PUBLIC_KEY = exports.PROGRAM_ID = void 0;
3
+ exports.MIN_HASH_LENGTH = exports.MAX_USERNAME_LENGTH = exports.MAX_MAX_CLAIMABLE = exports.MIN_MAX_CLAIMABLE = exports.MAX_FEE = exports.MIN_FEE = exports.DEFAULT_MAX_CLAIMABLE = exports.DEFAULT_MIZTAKE_FEE = exports.BONDING_CURVE_MIZD_VAULT_SEED = exports.BONDING_CURVE_SEED = exports.SUNPOOL_SEED = exports.LAUNCHPAD_TOKEN_MINT_SEED = exports.MOONPOOL_TREASURY_SEED = exports.MOONPOOL_SEED = exports.USER_JOIN_CREDIT_SEED = exports.SIGNUP_REWARDS_SEED = exports.REFERRAL_PENALTY_CLAIM_SEED = exports.MIZTAKE_SEED = exports.USER_STATS_SEED = exports.MIZTAKE_STATISTICS_SEED = exports.DEFAULT_FEE_RECIPIENT = exports.SEASON_INSTANCE_ID = exports.MIZD_TOKEN_MINT = exports.ADMIN_PUBLIC_KEY = exports.PROGRAM_ID = void 0;
4
4
  const web3_js_1 = require("@solana/web3.js");
5
+ const anchor_1 = require("@coral-xyz/anchor");
5
6
  const seedRegistry_1 = require("./seedRegistry");
6
7
  /**
7
8
  * Proof of Miztake Program Constants
@@ -12,6 +13,8 @@ exports.PROGRAM_ID = new web3_js_1.PublicKey("takeA82AwosboZgG7HQx8D3dGLbbbPUyQC
12
13
  exports.ADMIN_PUBLIC_KEY = new web3_js_1.PublicKey("Lude4DE3jDXVViJ3s7bUfPXdXy8Zq7G1stMwHNQrc2s");
13
14
  // MIZD Token Mint
14
15
  exports.MIZD_TOKEN_MINT = new web3_js_1.PublicKey("mizdS9fDNUKWZcXBeRhJoJQHJJmsTeF4fFRyPdXWv99");
16
+ // Reserved season instance id for a given token mint (must mirror on-chain).
17
+ exports.SEASON_INSTANCE_ID = new anchor_1.BN(1);
15
18
  // Default fee recipient
16
19
  exports.DEFAULT_FEE_RECIPIENT = new web3_js_1.PublicKey("Dkhu2VgGPfvXPVuohG2fPfryRacWMpNBJXvRGF1dhzUh");
17
20
  // Seeds for PDAs
@@ -20,6 +23,16 @@ exports.USER_STATS_SEED = seedRegistry_1.SEEDS.USER_STATS;
20
23
  exports.MIZTAKE_SEED = seedRegistry_1.SEEDS.MIZTAKE;
21
24
  exports.REFERRAL_PENALTY_CLAIM_SEED = seedRegistry_1.SEEDS.REFERRAL_PENALTY_CLAIM;
22
25
  exports.SIGNUP_REWARDS_SEED = seedRegistry_1.SEEDS.SIGNUP_REWARDS;
26
+ exports.USER_JOIN_CREDIT_SEED = seedRegistry_1.SEEDS.USER_JOIN_CREDIT;
27
+ /** The Moonpool is the Moon's seesaw for buying and selling stars (real SPL Token-2022 tokens). */
28
+ exports.MOONPOOL_SEED = seedRegistry_1.SEEDS.MOONPOOL;
29
+ exports.MOONPOOL_TREASURY_SEED = seedRegistry_1.SEEDS.MOONPOOL_TREASURY;
30
+ /** SPL Token-2022 mint for launchpad tokens. Mint authority is the Moonpool PDA. */
31
+ exports.LAUNCHPAD_TOKEN_MINT_SEED = seedRegistry_1.SEEDS.LAUNCHPAD_TOKEN_MINT;
32
+ /** The Sunpool is the Sun's flag shop for classic (non-launchpad) mode. */
33
+ exports.SUNPOOL_SEED = seedRegistry_1.SEEDS.SUNPOOL;
34
+ exports.BONDING_CURVE_SEED = seedRegistry_1.SEEDS.BONDING_CURVE;
35
+ exports.BONDING_CURVE_MIZD_VAULT_SEED = seedRegistry_1.SEEDS.BONDING_CURVE_MIZD_VAULT;
23
36
  // Default values
24
37
  exports.DEFAULT_MIZTAKE_FEE = 100000; // 0.0001 SOL in lamports
25
38
  exports.DEFAULT_MAX_CLAIMABLE = 10000000000; // 1000 tokens with 7 decimals
@@ -16,6 +16,7 @@ export declare class PDAManager {
16
16
  windowNumber: BN;
17
17
  user: PublicKey;
18
18
  tier: TierNumber;
19
+ tokenMint?: PublicKey;
19
20
  }): {
20
21
  miztake: PublicKey;
21
22
  userStats: PublicKey;
@@ -33,12 +34,17 @@ export declare class PDAManager {
33
34
  user: PublicKey;
34
35
  seasonNumber: SeasonNumberLike;
35
36
  tier: TierNumber;
37
+ tokenMint?: PublicKey;
36
38
  }): {
37
39
  seasonSettings: PublicKey;
38
40
  season: PublicKey;
39
41
  seasonMembership: PublicKey;
42
+ moonpool: PublicKey;
43
+ moonpoolTreasury: PublicKey;
44
+ launchpadTokenMint: PublicKey;
45
+ sunpool: PublicKey;
40
46
  seasonDepositVault: PublicKey;
41
- seasonEscrowVault: PublicKey;
47
+ userJoinCredit: PublicKey;
42
48
  };
43
49
  /**
44
50
  * Derive PDAs for confirmed_post_on_x instruction
@@ -50,6 +56,7 @@ export declare class PDAManager {
50
56
  tier: TierNumber;
51
57
  /** SHA-256 hex string (64 chars) */
52
58
  miztakeShaHash: Sha256HexString | string;
59
+ tokenMint?: PublicKey;
53
60
  }): {
54
61
  seasonSettings: PublicKey;
55
62
  seasonMembership: PublicKey;
@@ -66,12 +73,16 @@ export declare class PDAManager {
66
73
  seasonNumber: SeasonNumberLike;
67
74
  windowNumber: BN;
68
75
  tier: TierNumber;
76
+ tokenMint?: PublicKey;
69
77
  }): {
70
78
  seasonSettings: PublicKey;
71
79
  season: PublicKey;
72
80
  rewardWindow: PublicKey;
73
81
  userWindowParticipation: PublicKey;
74
82
  seasonMembership: PublicKey;
83
+ moonpool: PublicKey;
84
+ moonpoolTreasury: PublicKey;
85
+ launchpadTokenMint: PublicKey;
75
86
  seasonDepositVault: PublicKey;
76
87
  };
77
88
  /**
@@ -81,12 +92,25 @@ export declare class PDAManager {
81
92
  user: PublicKey;
82
93
  seasonNumber: SeasonNumberLike;
83
94
  tier: TierNumber;
95
+ tokenMint?: PublicKey;
84
96
  }): {
85
97
  seasonSettings: PublicKey;
86
98
  season: PublicKey;
87
99
  seasonMembership: PublicKey;
88
100
  seasonDepositVault: PublicKey;
89
- seasonEscrowVault: PublicKey;
101
+ };
102
+ /**
103
+ * Derive PDAs for view_season_membership_status instruction (read-only).
104
+ */
105
+ static deriveViewSeasonMembershipStatusPdas(params: {
106
+ user: PublicKey;
107
+ seasonNumber: SeasonNumberLike;
108
+ tier: TierNumber;
109
+ tokenMint?: PublicKey;
110
+ }): {
111
+ seasonSettings: PublicKey;
112
+ season: PublicKey;
113
+ seasonMembership: PublicKey;
90
114
  };
91
115
  /**
92
116
  * Derive PDAs for claim_referral_penalty_for_window instruction
@@ -96,12 +120,16 @@ export declare class PDAManager {
96
120
  seasonNumber: SeasonNumberLike;
97
121
  windowNumber: BN;
98
122
  tier: TierNumber;
123
+ tokenMint?: PublicKey;
99
124
  }): {
100
125
  seasonSettings: PublicKey;
101
126
  season: PublicKey;
102
127
  seasonMembership: PublicKey;
103
128
  userWindowParticipation: PublicKey;
104
129
  referralPenaltyClaim: PublicKey;
130
+ moonpool: PublicKey;
131
+ moonpoolTreasury: PublicKey;
132
+ launchpadTokenMint: PublicKey;
105
133
  seasonDepositVault: PublicKey;
106
134
  };
107
135
  /**
@@ -111,8 +139,20 @@ export declare class PDAManager {
111
139
  user: PublicKey;
112
140
  seasonNumber: SeasonNumberLike;
113
141
  tier: TierNumber;
142
+ tokenMint?: PublicKey;
114
143
  }): {
115
144
  seasonMembership: PublicKey;
145
+ season: PublicKey;
146
+ moonpool: PublicKey;
147
+ moonpoolTreasury: PublicKey;
148
+ launchpadTokenMint: PublicKey;
116
149
  signupRewardsPda: PublicKey;
117
150
  };
151
+ /**
152
+ * Derive PDAs for the SOL↔MIZD bonding curve instructions (global).
153
+ */
154
+ static deriveBondingCurvePdas(): {
155
+ bondingCurve: PublicKey;
156
+ mizdVault: PublicKey;
157
+ };
118
158
  }