proof-of-take-sdk 3.1.3 → 5.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 (58) 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 +4548 -1670
  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 +102 -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 +4530 -1652
  41. package/dist/types.d.ts +15 -2
  42. package/dist/types.js +7 -1
  43. package/dist/utils/accountConverters.js +6 -1
  44. package/dist/utils/accountUpdates.d.ts +38 -8
  45. package/dist/utils/accountUpdates.js +108 -19
  46. package/dist/utils/constants.d.ts +11 -0
  47. package/dist/utils/constants.js +14 -1
  48. package/dist/utils/pdaManager.d.ts +42 -2
  49. package/dist/utils/pdaManager.js +70 -28
  50. package/dist/utils/pdas.d.ts +46 -8
  51. package/dist/utils/pdas.js +111 -11
  52. package/dist/utils/remainingAccounts.d.ts +1 -0
  53. package/dist/utils/remainingAccounts.js +3 -2
  54. package/dist/utils/seedRegistry.d.ts +10 -0
  55. package/dist/utils/seedRegistry.js +10 -0
  56. package/package.json +1 -1
  57. package/dist/instructions/initializeEscrowVault.d.ts +0 -12
  58. 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.
@@ -100,14 +100,21 @@ export declare enum WindowState {
100
100
  Active = 1,
101
101
  Finalized = 2
102
102
  }
103
+ export declare enum PoolType {
104
+ Uninitialized = 0,
105
+ Sunpool = 1,
106
+ Moonpool = 2
107
+ }
103
108
  /**
104
109
  * Anchor enum formats returned by account fetches.
105
110
  * We accept both the SDK numeric enums and Anchor object enums throughout the SDK.
106
111
  */
107
112
  export type SeasonStateAnchor = AnchorEnumVariant<"uninitialized"> | AnchorEnumVariant<"active"> | AnchorEnumVariant<"ended">;
108
113
  export type WindowStateAnchor = AnchorEnumVariant<"uninitialized"> | AnchorEnumVariant<"active"> | AnchorEnumVariant<"finalized">;
114
+ export type PoolTypeAnchor = AnchorEnumVariant<"uninitialized"> | AnchorEnumVariant<"sunpool"> | AnchorEnumVariant<"moonpool">;
109
115
  export type SeasonStateLike = SeasonState | SeasonStateAnchor | number;
110
116
  export type WindowStateLike = WindowState | WindowStateAnchor | number;
117
+ export type PoolTypeLike = PoolType | PoolTypeAnchor | number;
111
118
  /**
112
119
  * Season deposit tier (Anchor enum representation)
113
120
  *
@@ -149,9 +156,11 @@ export interface SeasonSettings {
149
156
  }
150
157
  export interface Season {
151
158
  seasonNumber: BN;
159
+ tokenMint: PublicKey;
152
160
  seasonState: SeasonStateLike;
153
161
  startedAt: BN;
154
162
  endsAt: BN;
163
+ windowDuration: BN;
155
164
  totalWindows: number;
156
165
  totalMembers: BN;
157
166
  copperMembersCount: BN;
@@ -164,6 +173,7 @@ export interface Season {
164
173
  totalSuccessfulPosts: BN;
165
174
  totalPenaltiesCollected: BN;
166
175
  totalUnallocatedFunds: BN;
176
+ poolType: PoolTypeLike;
167
177
  bump: number;
168
178
  }
169
179
  export interface SeasonMembership {
@@ -175,7 +185,6 @@ export interface SeasonMembership {
175
185
  seasonNumber: BN;
176
186
  depositTier: SeasonDepositTier;
177
187
  depositAmount: BN;
178
- depositEscrowedAmount: BN;
179
188
  joinedAt: BN;
180
189
  joinedWindowNumber: BN;
181
190
  successfulPostsCount: BN;
@@ -190,6 +199,8 @@ export interface SeasonMembership {
190
199
  /** Whether the user has already withdrawn their season deposit (prevents double-withdraw). */
191
200
  depositWithdrawn: boolean;
192
201
  isActive: boolean;
202
+ /** Launchpad-mode virtual token escrow balance (base units). */
203
+ launchpadTokenEscrowUnits: BN;
193
204
  bump: number;
194
205
  }
195
206
  export interface RewardWindow {
@@ -228,6 +239,8 @@ export interface ReferralPenaltyClaim {
228
239
  windowNumber: BN;
229
240
  claimant: PublicKey;
230
241
  amount: BN;
242
+ tokenSoldUnits: BN;
243
+ solPaidLamports: BN;
231
244
  claimedAt: BN;
232
245
  claimed: boolean;
233
246
  bump: number;
package/dist/types.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.WindowState = exports.SeasonState = void 0;
3
+ exports.PoolType = exports.WindowState = exports.SeasonState = void 0;
4
4
  // Season Membership State Types
5
5
  var SeasonState;
6
6
  (function (SeasonState) {
@@ -14,3 +14,9 @@ var WindowState;
14
14
  WindowState[WindowState["Active"] = 1] = "Active";
15
15
  WindowState[WindowState["Finalized"] = 2] = "Finalized";
16
16
  })(WindowState || (exports.WindowState = WindowState = {}));
17
+ var PoolType;
18
+ (function (PoolType) {
19
+ PoolType[PoolType["Uninitialized"] = 0] = "Uninitialized";
20
+ PoolType[PoolType["Sunpool"] = 1] = "Sunpool";
21
+ PoolType[PoolType["Moonpool"] = 2] = "Moonpool";
22
+ })(PoolType || (exports.PoolType = PoolType = {}));
@@ -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,7 @@ function toSdkSeason(a) {
86
88
  totalSuccessfulPosts: a.totalSuccessfulPosts,
87
89
  totalPenaltiesCollected: a.totalPenaltiesCollected,
88
90
  totalUnallocatedFunds: a.totalUnallocatedFunds,
91
+ poolType: a.poolType,
89
92
  bump: a.bump,
90
93
  };
91
94
  }
@@ -97,7 +100,6 @@ function toSdkSeasonMembership(a) {
97
100
  seasonNumber: a.seasonNumber,
98
101
  depositTier: a.depositTier,
99
102
  depositAmount: a.depositAmount,
100
- depositEscrowedAmount: a.depositEscrowedAmount,
101
103
  joinedAt: a.joinedAt,
102
104
  joinedWindowNumber: a.joinedWindowNumber,
103
105
  successfulPostsCount: a.successfulPostsCount,
@@ -108,6 +110,7 @@ function toSdkSeasonMembership(a) {
108
110
  totalPenaltiesPaid: a.totalPenaltiesPaid,
109
111
  depositWithdrawn: a.depositWithdrawn,
110
112
  isActive: a.isActive,
113
+ launchpadTokenEscrowUnits: a.launchpadTokenEscrowUnits,
111
114
  bump: a.bump,
112
115
  };
113
116
  }
@@ -146,6 +149,8 @@ function toSdkReferralPenaltyClaim(a) {
146
149
  windowNumber: a.windowNumber,
147
150
  claimant: a.claimant,
148
151
  amount: a.amount,
152
+ tokenSoldUnits: a.tokenSoldUnits,
153
+ solPaidLamports: a.solPaidLamports,
149
154
  claimedAt: a.claimedAt,
150
155
  claimed: a.claimed,
151
156
  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,7 @@ 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
+ poolType: types_1.PoolType.Sunpool,
95
103
  bump,
96
104
  };
97
105
  }
@@ -259,12 +267,11 @@ function updateMiztakeForSeasonUse(miztake, seasonNumber, windowNumber) {
259
267
  * @param seasonNumber - Season number
260
268
  * @param depositTier - Tier chosen at join time
261
269
  * @param depositAmount - Active deposit amount (participates in rewards/penalties)
262
- * @param depositEscrowedAmount - Escrowed deposit amount (always refundable)
263
270
  * @param joinedAt - Timestamp when joined
264
271
  * @param joinedWindowNumber - Window number when joined
265
272
  * @returns Initialized SeasonMembership object
266
273
  */
267
- function initializeSeasonMembership(user, seasonNumber, depositTier, referrer, depositAmount, depositEscrowedAmount, joinedAt, joinedWindowNumber, bump, isStar = false) {
274
+ function initializeSeasonMembership(user, seasonNumber, depositTier, referrer, depositAmount, joinedAt, joinedWindowNumber, bump, isStar = false) {
268
275
  return {
269
276
  owner: user,
270
277
  referrer,
@@ -272,7 +279,6 @@ function initializeSeasonMembership(user, seasonNumber, depositTier, referrer, d
272
279
  seasonNumber,
273
280
  depositTier,
274
281
  depositAmount,
275
- depositEscrowedAmount,
276
282
  joinedAt,
277
283
  joinedWindowNumber,
278
284
  successfulPostsCount: new anchor_1.BN(0),
@@ -283,6 +289,7 @@ function initializeSeasonMembership(user, seasonNumber, depositTier, referrer, d
283
289
  totalPenaltiesPaid: new anchor_1.BN(0),
284
290
  depositWithdrawn: false,
285
291
  isActive: true,
292
+ launchpadTokenEscrowUnits: new anchor_1.BN(0),
286
293
  bump,
287
294
  };
288
295
  }
@@ -379,21 +386,32 @@ function updateSeasonForJoin(season, depositActive, depositTier, joinedWindowNum
379
386
  *
380
387
  * @param window - Current window
381
388
  * @param isOnTime - Whether the post was on time
382
- * @param penaltyAmount - Penalty amount if late (REQUIRED when isOnTime=false)
389
+ * @param stakeAmount - Stake amount (REQUIRED when isOnTime=true for non-launchpad)
390
+ * @param launchpad - Whether this is a launchpad season (default: false)
383
391
  * @returns Updated RewardWindow object
384
392
  *
385
- * @throws Error if penaltyAmount missing when isOnTime is false
393
+ * @throws Error if stakeAmount missing when isOnTime is true and !launchpad
386
394
  */
387
- function updateWindowForConfirmation(window, isOnTime, stakeAmount) {
395
+ function updateWindowForConfirmation(window, isOnTime, stakeAmount, launchpad = false) {
388
396
  if (isOnTime) {
389
- if (!stakeAmount || stakeAmount.isZero()) {
390
- throw new Error("updateWindowForConfirmation: stakeAmount is required when isOnTime is true");
397
+ // Only mutate successful_stake_total for non-launchpad seasons
398
+ if (!launchpad) {
399
+ if (!stakeAmount || stakeAmount.isZero()) {
400
+ throw new Error("updateWindowForConfirmation: stakeAmount is required when isOnTime is true for non-launchpad seasons");
401
+ }
402
+ return {
403
+ ...window,
404
+ successfulPostersCount: window.successfulPostersCount.add(new anchor_1.BN(1)),
405
+ successfulStakeTotal: window.successfulStakeTotal.add(stakeAmount),
406
+ };
407
+ }
408
+ else {
409
+ // Launchpad mode: only increment successfulPostersCount
410
+ return {
411
+ ...window,
412
+ successfulPostersCount: window.successfulPostersCount.add(new anchor_1.BN(1)),
413
+ };
391
414
  }
392
- return {
393
- ...window,
394
- successfulPostersCount: window.successfulPostersCount.add(new anchor_1.BN(1)),
395
- successfulStakeTotal: window.successfulStakeTotal.add(stakeAmount),
396
- };
397
415
  }
398
416
  else {
399
417
  // penaltyPool is derived at finalization as X - Y; do not mutate here
@@ -469,10 +487,20 @@ function updateSeasonForConfirmation(season, isOnTime, _stakeAmount) {
469
487
  * Finalize RewardWindow and calculate rewards
470
488
  * Mirrors claim_window_rewards.rs finalization logic (lines 22-86)
471
489
  *
490
+ * NOTE: Launchpad mode bypasses window finalization economics.
491
+ * In launchpad mode, windows are NOT finalized and isFinalized remains false.
492
+ *
472
493
  * @param window - Current window
473
- * @returns Updated finalized RewardWindow object
494
+ * @param eligibleStakeX - Eligible stake for this window (only used for non-launchpad)
495
+ * @param launchpad - Whether this is a launchpad season (default: false)
496
+ * @returns Updated finalized RewardWindow object (or unchanged for launchpad)
474
497
  */
475
- function updateWindowForFinalization(window, eligibleStakeX) {
498
+ function updateWindowForFinalization(window, eligibleStakeX, launchpad = false) {
499
+ // Launchpad mode bypasses window finalization economics
500
+ if (launchpad) {
501
+ return { ...window }; // No finalization in launchpad mode
502
+ }
503
+ // Non-launchpad mode: standard X-Y finalization
476
504
  // penalty_pool is derived as X - Y.
477
505
  const finalPenaltyPool = eligibleStakeX.gt(window.successfulStakeTotal)
478
506
  ? eligibleStakeX.sub(window.successfulStakeTotal)
@@ -557,6 +585,8 @@ function initializeReferralPenaltyClaim(params) {
557
585
  windowNumber: params.windowNumber,
558
586
  claimant: params.claimant,
559
587
  amount,
588
+ tokenSoldUnits: new anchor_1.BN(0),
589
+ solPaidLamports: new anchor_1.BN(0),
560
590
  claimedAt,
561
591
  claimed: true,
562
592
  bump,
@@ -607,12 +637,10 @@ function calculateWithdrawalAmount(membership, season, settings) {
607
637
  const clampedWithdrawalAmount = withdrawalAmount.gt(new anchor_1.BN(0))
608
638
  ? withdrawalAmount
609
639
  : new anchor_1.BN(0);
610
- // Escrowed portion is always refunded in full at season end.
611
- const totalWithdrawalAmount = clampedWithdrawalAmount.add(membership.depositEscrowedAmount);
640
+ const totalWithdrawalAmount = clampedWithdrawalAmount;
612
641
  // Update membership
613
642
  const updatedMembership = {
614
643
  ...membership,
615
- depositEscrowedAmount: new anchor_1.BN(0),
616
644
  depositWithdrawn: true,
617
645
  isActive: false,
618
646
  };
@@ -669,3 +697,64 @@ function updateSeasonSettingsForAdminUpdate(settings, newAdmin) {
669
697
  admin: newAdmin,
670
698
  };
671
699
  }
700
+ /**
701
+ * Helper: Compute constant-product invariant K
702
+ * Mirrors bonding_curve_math::compute_k
703
+ *
704
+ * @param solReserveLamports - SOL reserve in lamports
705
+ * @param tokenReserveUnits - Token reserve in base units
706
+ * @param virtualSolReserveLamports - Virtual SOL reserve
707
+ * @param virtualTokenReserveUnits - Virtual token reserve
708
+ * @returns Invariant K as BN
709
+ */
710
+ function computeK(solReserveLamports, tokenReserveUnits, virtualSolReserveLamports, virtualTokenReserveUnits) {
711
+ const x = solReserveLamports.add(virtualSolReserveLamports);
712
+ const y = tokenReserveUnits.add(virtualTokenReserveUnits);
713
+ return x.mul(y);
714
+ }
715
+ /**
716
+ * Update Moonpool after buying tokens (joinSeason launchpad mode)
717
+ * Mirrors moonpool::buy_exact_tokens logic
718
+ *
719
+ * @param moonpool - Current moonpool state
720
+ * @param currentTreasurySolLamports - Current treasury SOL balance before transaction
721
+ * @param solInLamports - SOL paid in lamports
722
+ * @param tokenOutUnits - Tokens bought in base units
723
+ * @returns Updated Moonpool object
724
+ */
725
+ function updateMoonpoolForBuyTokens(moonpool, currentTreasurySolLamports, solInLamports, tokenOutUnits) {
726
+ // Update token reserve (decreases)
727
+ const newTokenReserve = moonpool.tokenReserveUnits.sub(tokenOutUnits);
728
+ // Update SOL reserve (increases)
729
+ const solAfter = currentTreasurySolLamports.add(solInLamports);
730
+ // Compute new K with updated reserves
731
+ const newK = computeK(solAfter, newTokenReserve, moonpool.virtualSolReserveLamports, moonpool.virtualTokenReserveUnits);
732
+ return {
733
+ ...moonpool,
734
+ tokenReserveUnits: newTokenReserve,
735
+ lastK: newK,
736
+ };
737
+ }
738
+ /**
739
+ * Update Moonpool after selling tokens (claimRewards launchpad mode)
740
+ * Mirrors moonpool::sell_tokens_for_sol logic
741
+ *
742
+ * @param moonpool - Current moonpool state
743
+ * @param currentTreasurySolLamports - Current treasury SOL balance before transaction
744
+ * @param tokenInUnits - Tokens sold in base units
745
+ * @param solOutLamports - SOL received in lamports
746
+ * @returns Updated Moonpool object
747
+ */
748
+ function updateMoonpoolForSellTokens(moonpool, currentTreasurySolLamports, tokenInUnits, solOutLamports) {
749
+ // Update token reserve (increases)
750
+ const newTokenReserve = moonpool.tokenReserveUnits.add(tokenInUnits);
751
+ // Update SOL reserve (decreases)
752
+ const solAfter = currentTreasurySolLamports.sub(solOutLamports);
753
+ // Compute new K with updated reserves
754
+ const newK = computeK(solAfter, newTokenReserve, moonpool.virtualSolReserveLamports, moonpool.virtualTokenReserveUnits);
755
+ return {
756
+ ...moonpool,
757
+ tokenReserveUnits: newTokenReserve,
758
+ lastK: newK,
759
+ };
760
+ }
@@ -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
  }