proof-of-take-sdk 1.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 (90) hide show
  1. package/FINAL_USAGE.md +342 -0
  2. package/LIBRARY_GUIDE.md +400 -0
  3. package/LICENSE +22 -0
  4. package/README.md +370 -0
  5. package/dist/client.d.ts +32 -0
  6. package/dist/client.js +47 -0
  7. package/dist/constants/season.d.ts +18 -0
  8. package/dist/constants/season.js +22 -0
  9. package/dist/getters/getMiztake.d.ts +11 -0
  10. package/dist/getters/getMiztake.js +34 -0
  11. package/dist/getters/getMiztakeStatistics.d.ts +10 -0
  12. package/dist/getters/getMiztakeStatistics.js +20 -0
  13. package/dist/getters/getTokenVault.d.ts +30 -0
  14. package/dist/getters/getTokenVault.js +56 -0
  15. package/dist/getters/getUserStats.d.ts +21 -0
  16. package/dist/getters/getUserStats.js +43 -0
  17. package/dist/getters/index.d.ts +7 -0
  18. package/dist/getters/index.js +23 -0
  19. package/dist/idl/idl.d.ts +2 -0
  20. package/dist/idl/idl.js +8 -0
  21. package/dist/idl/proof_of_take.json +3803 -0
  22. package/dist/index.d.ts +48 -0
  23. package/dist/index.js +92 -0
  24. package/dist/instructions/claimReferralPenaltyForWindow.d.ts +38 -0
  25. package/dist/instructions/claimReferralPenaltyForWindow.js +72 -0
  26. package/dist/instructions/claimWindowRewards.d.ts +48 -0
  27. package/dist/instructions/claimWindowRewards.js +94 -0
  28. package/dist/instructions/confirmedPostOnX.d.ts +51 -0
  29. package/dist/instructions/confirmedPostOnX.js +78 -0
  30. package/dist/instructions/createMiztake.d.ts +90 -0
  31. package/dist/instructions/createMiztake.js +166 -0
  32. package/dist/instructions/initializeEscrowVault.d.ts +15 -0
  33. package/dist/instructions/initializeEscrowVault.js +36 -0
  34. package/dist/instructions/initializeSeasonSettings.d.ts +20 -0
  35. package/dist/instructions/initializeSeasonSettings.js +39 -0
  36. package/dist/instructions/initializeSeasonVault.d.ts +20 -0
  37. package/dist/instructions/initializeSeasonVault.js +43 -0
  38. package/dist/instructions/initializeStatistics.d.ts +32 -0
  39. package/dist/instructions/initializeStatistics.js +73 -0
  40. package/dist/instructions/joinSeason.d.ts +50 -0
  41. package/dist/instructions/joinSeason.js +120 -0
  42. package/dist/instructions/toggleSeasonPause.d.ts +22 -0
  43. package/dist/instructions/toggleSeasonPause.js +42 -0
  44. package/dist/instructions/updateSeasonAdmin.d.ts +23 -0
  45. package/dist/instructions/updateSeasonAdmin.js +43 -0
  46. package/dist/instructions/viewCurrentSeason.d.ts +12 -0
  47. package/dist/instructions/viewCurrentSeason.js +30 -0
  48. package/dist/instructions/viewSeasonMembershipStatus.d.ts +16 -0
  49. package/dist/instructions/viewSeasonMembershipStatus.js +33 -0
  50. package/dist/instructions/viewWindowStatus.d.ts +15 -0
  51. package/dist/instructions/viewWindowStatus.js +28 -0
  52. package/dist/instructions/withdrawSeasonDeposit.d.ts +38 -0
  53. package/dist/instructions/withdrawSeasonDeposit.js +66 -0
  54. package/dist/optimistic/index.d.ts +7 -0
  55. package/dist/optimistic/index.js +33 -0
  56. package/dist/types/accountTypes.d.ts +121 -0
  57. package/dist/types/accountTypes.js +2 -0
  58. package/dist/types/instructionResults.d.ts +44 -0
  59. package/dist/types/instructionResults.js +2 -0
  60. package/dist/types/proof_of_take.d.ts +3809 -0
  61. package/dist/types/proof_of_take.js +2 -0
  62. package/dist/types.d.ts +232 -0
  63. package/dist/types.js +16 -0
  64. package/dist/utils/accountUpdates.d.ts +245 -0
  65. package/dist/utils/accountUpdates.js +611 -0
  66. package/dist/utils/anchorHelpers.d.ts +7 -0
  67. package/dist/utils/anchorHelpers.js +21 -0
  68. package/dist/utils/constants.d.ts +21 -0
  69. package/dist/utils/constants.js +31 -0
  70. package/dist/utils/conversions.d.ts +25 -0
  71. package/dist/utils/conversions.js +53 -0
  72. package/dist/utils/enumHelpers.d.ts +63 -0
  73. package/dist/utils/enumHelpers.js +110 -0
  74. package/dist/utils/index.d.ts +0 -0
  75. package/dist/utils/index.js +2 -0
  76. package/dist/utils/pdaManager.d.ts +106 -0
  77. package/dist/utils/pdaManager.js +89 -0
  78. package/dist/utils/pdas.d.ts +68 -0
  79. package/dist/utils/pdas.js +128 -0
  80. package/dist/utils/programHelpers.d.ts +9 -0
  81. package/dist/utils/programHelpers.js +18 -0
  82. package/dist/utils/signerHelpers.d.ts +17 -0
  83. package/dist/utils/signerHelpers.js +21 -0
  84. package/dist/utils/simulationHelpers.d.ts +121 -0
  85. package/dist/utils/simulationHelpers.js +183 -0
  86. package/dist/utils/tierPenalty.d.ts +9 -0
  87. package/dist/utils/tierPenalty.js +24 -0
  88. package/dist/utils/transactionBuilder.d.ts +77 -0
  89. package/dist/utils/transactionBuilder.js +147 -0
  90. package/package.json +50 -0
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,232 @@
1
+ import { PublicKey } from "@solana/web3.js";
2
+ import { BN } from "@coral-xyz/anchor";
3
+ /**
4
+ * Type definitions for Proof of Take SDK
5
+ */
6
+ export type { ProofOfTake } from "./types/proof_of_take";
7
+ export interface CreateMiztakeParams {
8
+ telegramId: BN;
9
+ telegramUsername: string;
10
+ perceptualHash: string;
11
+ averageHash: string;
12
+ differenceHash: string;
13
+ waveletHash: string;
14
+ shaHash: string;
15
+ computedAt: string;
16
+ }
17
+ export interface ClaimRewardParams {
18
+ miztakePda: PublicKey;
19
+ userTokenAccount: PublicKey;
20
+ amount: BN;
21
+ }
22
+ export interface DepositTokensParams {
23
+ amount: BN;
24
+ depositorTokenAccount: PublicKey;
25
+ }
26
+ export interface WithdrawTokensParams {
27
+ amount: BN;
28
+ adminTokenAccount: PublicKey;
29
+ }
30
+ export interface UpdateConfigParams {
31
+ newFee?: BN;
32
+ newFeeRecipient?: PublicKey;
33
+ newDefaultMaxClaimable?: BN;
34
+ }
35
+ export interface MiztakeStatistics {
36
+ totalMiztakes: BN;
37
+ bump: number;
38
+ }
39
+ export interface UserStats {
40
+ telegramId: BN;
41
+ totalNumberOfMiztakes: BN;
42
+ onchainFirstMiztakeAt: BN;
43
+ onchainLastMiztakeAt: BN;
44
+ bump: number;
45
+ }
46
+ export interface Miztake {
47
+ id: BN;
48
+ telegramId: BN;
49
+ telegramUsername: string;
50
+ perceptualHash: string;
51
+ averageHash: string;
52
+ differenceHash: string;
53
+ waveletHash: string;
54
+ shaHash: string;
55
+ computedAt: string;
56
+ creator: PublicKey;
57
+ userStats: PublicKey;
58
+ userKey: PublicKey;
59
+ onchainCreatedAt: BN;
60
+ usedInSeason: BN;
61
+ usedInWindow: BN;
62
+ }
63
+ export declare enum SeasonState {
64
+ Uninitialized = 0,
65
+ Active = 1,
66
+ Ended = 2
67
+ }
68
+ export declare enum WindowState {
69
+ Uninitialized = 0,
70
+ Active = 1,
71
+ Finalized = 2
72
+ }
73
+ /**
74
+ * Season deposit tier (Anchor enum representation)
75
+ *
76
+ * Note: Anchor represents enum values as an object with a single key.
77
+ * Example: `{ silver: {} }`
78
+ */
79
+ export type SeasonDepositTier = {
80
+ copper: Record<string, never>;
81
+ } | {
82
+ silver: Record<string, never>;
83
+ } | {
84
+ gold: Record<string, never>;
85
+ } | {
86
+ platinum: Record<string, never>;
87
+ } | {
88
+ mithril: Record<string, never>;
89
+ };
90
+ export interface SeasonSettings {
91
+ completedSeasons: BN;
92
+ seasonDuration: BN;
93
+ windowDuration: BN;
94
+ totalWindowsPerSeason: number;
95
+ canInitializeNextSeason: boolean;
96
+ lastSeasonEndsAt: BN;
97
+ currentSeasonNumber: BN;
98
+ admin: PublicKey;
99
+ isPaused: boolean;
100
+ maxMembersPerSeason: BN;
101
+ bump: number;
102
+ }
103
+ export interface Season {
104
+ seasonNumber: BN;
105
+ seasonState: SeasonState;
106
+ startedAt: BN;
107
+ endsAt: BN;
108
+ totalWindows: number;
109
+ totalMembers: BN;
110
+ copperMembersCount: BN;
111
+ silverMembersCount: BN;
112
+ goldMembersCount: BN;
113
+ platinumMembersCount: BN;
114
+ mithrilMembersCount: BN;
115
+ eligibleStakePerWindow: BN[];
116
+ totalDepositsHeld: BN;
117
+ totalSuccessfulPosts: BN;
118
+ totalPenaltiesCollected: BN;
119
+ bump: number;
120
+ }
121
+ export interface SeasonMembership {
122
+ id: BN;
123
+ owner: PublicKey;
124
+ /** Optional referrer (PublicKey.default means no referrer). */
125
+ referrer: PublicKey;
126
+ seasonNumber: BN;
127
+ depositTier: SeasonDepositTier;
128
+ depositAmount: BN;
129
+ depositEscrowedAmount: BN;
130
+ joinedAt: BN;
131
+ joinedWindowNumber: BN;
132
+ successfulPostsCount: BN;
133
+ totalRewardsClaimed: BN;
134
+ totalPenaltiesPaid: BN;
135
+ /** Whether the user has already withdrawn their season deposit (prevents double-withdraw). */
136
+ depositWithdrawn: boolean;
137
+ isActive: boolean;
138
+ bump: number;
139
+ }
140
+ export interface RewardWindow {
141
+ seasonNumber: BN;
142
+ windowNumber: BN;
143
+ windowState: WindowState;
144
+ startedAt: BN;
145
+ endsAt: BN;
146
+ totalMembersInSeason: BN;
147
+ penaltyPool: BN;
148
+ successfulPostersCount: BN;
149
+ successfulStakeTotal: BN;
150
+ rewardPerPoster: BN;
151
+ isFinalized: boolean;
152
+ bump: number;
153
+ }
154
+ export interface UserWindowParticipation {
155
+ user: PublicKey;
156
+ seasonNumber: BN;
157
+ windowNumber: BN;
158
+ seasonMembershipId: BN;
159
+ postedSuccessfully: boolean;
160
+ claimedReward: boolean;
161
+ rewardAmount: BN;
162
+ miztakeId: BN;
163
+ bump: number;
164
+ }
165
+ /**
166
+ * Referral penalty claim record
167
+ *
168
+ * Mirrors on-chain `ReferralPenaltyClaim` account.
169
+ * NOTE: `claimedAt` is i64 on-chain; Anchor typically returns it as BN.
170
+ */
171
+ export interface ReferralPenaltyClaim {
172
+ referredUser: PublicKey;
173
+ seasonNumber: BN;
174
+ windowNumber: BN;
175
+ seasonMembershipId: BN;
176
+ claimant: PublicKey;
177
+ amount: BN;
178
+ claimedAt: BN;
179
+ claimed: boolean;
180
+ bump: number;
181
+ }
182
+ /**
183
+ * View return types (Anchor `.view()` RPC return structs).
184
+ *
185
+ * These are not on-chain accounts; they are computed/returned by view instructions.
186
+ * All u64/i64 fields are returned as BN by Anchor.
187
+ */
188
+ export interface CurrentSeasonView {
189
+ seasonNumber: BN;
190
+ startedAt: BN;
191
+ endsAt: BN;
192
+ totalWindows: number;
193
+ totalMembers: BN;
194
+ totalDepositsHeld: BN;
195
+ totalSuccessfulPosts: BN;
196
+ totalPenaltiesCollected: BN;
197
+ currentWindowNumber: BN;
198
+ windowsRemaining: BN;
199
+ timeRemaining: BN;
200
+ isActive: boolean;
201
+ isJoinable: boolean;
202
+ }
203
+ export interface SeasonMembershipStatusView {
204
+ owner: PublicKey;
205
+ seasonNumber: BN;
206
+ depositAmount: BN;
207
+ joinedAt: BN;
208
+ joinedWindowNumber: BN;
209
+ successfulPostsCount: BN;
210
+ totalRewardsClaimed: BN;
211
+ totalPenaltiesPaid: BN;
212
+ depositWithdrawn: boolean;
213
+ isActive: boolean;
214
+ seasonStartedAt: BN;
215
+ seasonEndsAt: BN;
216
+ seasonTotalMembers: BN;
217
+ currentWindowNumber: BN;
218
+ windowsRemaining: BN;
219
+ }
220
+ export interface WindowStatusView {
221
+ seasonNumber: BN;
222
+ windowNumber: BN;
223
+ startedAt: BN;
224
+ endsAt: BN;
225
+ totalMembersInSeason: BN;
226
+ successfulPostersCount: BN;
227
+ penaltyPool: BN;
228
+ rewardPerPoster: BN;
229
+ isFinalized: boolean;
230
+ isActive: boolean;
231
+ isEnded: boolean;
232
+ }
package/dist/types.js ADDED
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.WindowState = exports.SeasonState = void 0;
4
+ // Season Membership State Types
5
+ var SeasonState;
6
+ (function (SeasonState) {
7
+ SeasonState[SeasonState["Uninitialized"] = 0] = "Uninitialized";
8
+ SeasonState[SeasonState["Active"] = 1] = "Active";
9
+ SeasonState[SeasonState["Ended"] = 2] = "Ended";
10
+ })(SeasonState || (exports.SeasonState = SeasonState = {}));
11
+ var WindowState;
12
+ (function (WindowState) {
13
+ WindowState[WindowState["Uninitialized"] = 0] = "Uninitialized";
14
+ WindowState[WindowState["Active"] = 1] = "Active";
15
+ WindowState[WindowState["Finalized"] = 2] = "Finalized";
16
+ })(WindowState || (exports.WindowState = WindowState = {}));
@@ -0,0 +1,245 @@
1
+ import { BN } from "@coral-xyz/anchor";
2
+ import { PublicKey } from "@solana/web3.js";
3
+ import { Miztake, UserStats, MiztakeStatistics, SeasonSettings, Season, SeasonMembership, RewardWindow, UserWindowParticipation, SeasonDepositTier, ReferralPenaltyClaim } from "../types";
4
+ /**
5
+ * Get current Unix timestamp in SECONDS as BN
6
+ *
7
+ * Note:
8
+ * - Returns Unix timestamp in SECONDS (not milliseconds)
9
+ * - Matches Solana's Clock::unix_timestamp format
10
+ * - This is an approximate timestamp; the actual on-chain timestamp
11
+ * will be set by the Solana runtime when the transaction is processed
12
+ *
13
+ * @returns Current Unix timestamp in seconds
14
+ */
15
+ export declare function getCurrentTimestamp(now?: BN): BN;
16
+ /**
17
+ * Create an empty/initialized UserStats object
18
+ * Used when initializing a new user stats account
19
+ */
20
+ export declare function createEmptyUserStats(telegramId: BN): UserStats;
21
+ /**
22
+ * Create a fully initialized UserStats account with PDA bump
23
+ * Mirrors the initialization logic from create_miztake.rs (lines 33-48)
24
+ *
25
+ * This function derives the PDA and returns a UserStats object exactly as it
26
+ * will appear on-chain after initialization.
27
+ *
28
+ * @param telegramId - Telegram ID of the user
29
+ * @returns Initialized UserStats object with proper bump seed
30
+ *
31
+ * @example
32
+ * ```typescript
33
+ * const userStats = initializeUserStats(new BN(123456789));
34
+ * // userStats is ready to be used for local state tracking
35
+ * // and matches exactly what will be created on-chain
36
+ * ```
37
+ */
38
+ export declare function initializeUserStats(telegramId: BN): UserStats;
39
+ /**
40
+ * Update UserStats after creating a miztake
41
+ * Mirrors the increment_miztakes logic from user_stats.rs
42
+ *
43
+ * @param userStats - Current user stats
44
+ * @param telegramId - Telegram ID for initialization check
45
+ * @param timestamp - Timestamp for the update in SECONDS (Unix timestamp)
46
+ * @returns Updated UserStats object
47
+ */
48
+ export declare function updateUserStatsForMiztakeCreation(userStats: UserStats, telegramId: BN, timestamp?: BN): UserStats;
49
+ /**
50
+ * Update MiztakeStatistics after creating a miztake
51
+ * Mirrors the increment_miztakes logic from miztake_statistics.rs
52
+ *
53
+ * @param statistics - Current miztake statistics
54
+ * @returns Updated MiztakeStatistics object and new miztake ID
55
+ *
56
+ * @throws Error if invalid statistics provided
57
+ */
58
+ export declare function updateMiztakeStatisticsForCreation(statistics: MiztakeStatistics): {
59
+ statistics: MiztakeStatistics;
60
+ newMiztakeId: BN;
61
+ };
62
+ /**
63
+ * Initialize or update UserWindowParticipation
64
+ * Mirrors the logic from create_miztake.rs (lines 109-139)
65
+ *
66
+ * @param user - User's public key
67
+ * @param seasonNumber - Season number
68
+ * @param windowNumber - Window number
69
+ * @param seasonMembershipId - Season membership ID
70
+ * @param miztakeId - The miztake ID to associate
71
+ * @returns Initialized/Updated UserWindowParticipation object
72
+ */
73
+ export declare function initializeUserWindowParticipation(user: PublicKey, seasonNumber: BN, windowNumber: BN, seasonMembershipId: BN, miztakeId: BN): UserWindowParticipation;
74
+ /**
75
+ * Initialize RewardWindow
76
+ * Mirrors the logic from season_helpers::initialize_window
77
+ *
78
+ * @param seasonNumber - Season number
79
+ * @param windowNumber - Window number
80
+ * @param season - Current season state
81
+ * @param windowDuration - Duration of each window in seconds
82
+ * @returns Initialized RewardWindow object
83
+ */
84
+ export declare function initializeRewardWindow(seasonNumber: BN, windowNumber: BN, season: Season, windowDuration: BN): RewardWindow;
85
+ /**
86
+ * Update Miztake to mark it as used in a season/window
87
+ * Mirrors mark_as_used from miztake.rs
88
+ *
89
+ * @param miztake - Current miztake
90
+ * @param seasonNumber - Season number
91
+ * @param windowNumber - Window number
92
+ * @returns Updated Miztake object
93
+ */
94
+ export declare function updateMiztakeForSeasonUse(miztake: Miztake, seasonNumber: BN, windowNumber: BN): Miztake;
95
+ /**
96
+ * Update SeasonMembership after joining
97
+ * Mirrors the initialization from join_season.rs (lines 84-96)
98
+ *
99
+ * @param user - User's public key
100
+ * @param seasonMembershipId - Membership ID
101
+ * @param seasonNumber - Season number
102
+ * @param depositTier - Tier chosen at join time
103
+ * @param depositAmount - Active deposit amount (participates in rewards/penalties)
104
+ * @param depositEscrowedAmount - Escrowed deposit amount (always refundable)
105
+ * @param joinedAt - Timestamp when joined
106
+ * @param joinedWindowNumber - Window number when joined
107
+ * @returns Initialized SeasonMembership object
108
+ */
109
+ export declare function initializeSeasonMembership(user: PublicKey, seasonMembershipId: BN, seasonNumber: BN, depositTier: SeasonDepositTier, referrer: PublicKey, depositAmount: BN, depositEscrowedAmount: BN, joinedAt: BN, joinedWindowNumber: BN, bump: number): SeasonMembership;
110
+ /**
111
+ * Update Season after a user joins
112
+ * Mirrors the update from join_season.rs (lines 98-104)
113
+ *
114
+ * @param season - Current season
115
+ * @param depositActive - Active deposit amount added to season totals
116
+ * @returns Updated Season object
117
+ */
118
+ export declare function updateSeasonForJoin(season: Season, depositActive: BN, depositTier: SeasonDepositTier, joinedWindowNumber: BN, totalWindowsPerSeason?: number): Season;
119
+ /**
120
+ * Update RewardWindow after post confirmation
121
+ * Mirrors confirmed_post_on_x.rs logic
122
+ *
123
+ * @param window - Current window
124
+ * @param isOnTime - Whether the post was on time
125
+ * @param penaltyAmount - Penalty amount if late (REQUIRED when isOnTime=false)
126
+ * @returns Updated RewardWindow object
127
+ *
128
+ * @throws Error if penaltyAmount missing when isOnTime is false
129
+ */
130
+ export declare function updateWindowForConfirmation(window: RewardWindow, isOnTime: boolean, stakeAmount?: BN): RewardWindow;
131
+ /**
132
+ * Update UserWindowParticipation after post confirmation
133
+ * Mirrors confirmed_post_on_x.rs logic
134
+ *
135
+ * @param participation - Current participation
136
+ * @param isOnTime - Whether the post was on time
137
+ * @returns Updated UserWindowParticipation object
138
+ */
139
+ export declare function updateParticipationForConfirmation(participation: UserWindowParticipation, isOnTime: boolean): UserWindowParticipation;
140
+ /**
141
+ * Update SeasonMembership after post confirmation
142
+ * Mirrors confirmed_post_on_x.rs logic
143
+ *
144
+ * @param membership - Current membership
145
+ * @param isOnTime - Whether the post was on time
146
+ * @param penaltyAmount - Penalty amount if late (REQUIRED when isOnTime=false)
147
+ * @returns Updated SeasonMembership object
148
+ *
149
+ * @throws Error if penaltyAmount missing when isOnTime is false
150
+ */
151
+ export declare function updateMembershipForConfirmation(membership: SeasonMembership, isOnTime: boolean, penaltyAmount?: BN): SeasonMembership;
152
+ /**
153
+ * Update Season after post confirmation
154
+ * Mirrors confirmed_post_on_x.rs logic
155
+ *
156
+ * @param season - Current season
157
+ * @param isOnTime - Whether the post was on time
158
+ * @param penaltyAmount - Penalty amount if late (REQUIRED when isOnTime=false)
159
+ * @returns Updated Season object
160
+ *
161
+ * @throws Error if penaltyAmount missing when isOnTime is false
162
+ */
163
+ export declare function updateSeasonForConfirmation(season: Season, isOnTime: boolean, _stakeAmount?: BN): Season;
164
+ /**
165
+ * Finalize RewardWindow and calculate rewards
166
+ * Mirrors claim_window_rewards.rs finalization logic (lines 22-86)
167
+ *
168
+ * @param window - Current window
169
+ * @returns Updated finalized RewardWindow object
170
+ */
171
+ export declare function updateWindowForFinalization(window: RewardWindow, eligibleStakeX: BN): RewardWindow;
172
+ /**
173
+ * Update UserWindowParticipation after claiming window rewards
174
+ * Mirrors claim_window_rewards.rs logic
175
+ *
176
+ * @param participation - Current participation
177
+ * @param rewardAmount - Reward amount claimed
178
+ * @returns Updated UserWindowParticipation object
179
+ */
180
+ export declare function updateParticipationForClaim(participation: UserWindowParticipation, rewardAmount: BN): UserWindowParticipation;
181
+ /**
182
+ * Update SeasonMembership after claiming window rewards
183
+ * Mirrors claim_window_rewards.rs logic (lines 156-165)
184
+ *
185
+ * @param membership - Current membership
186
+ * @param rewardAmount - Total reward amount
187
+ * (Penalties are tier-derived on-chain; settings no longer carry penalty_per_window.)
188
+ * @returns Updated SeasonMembership object
189
+ *
190
+ * @throws Error if invalid inputs provided
191
+ */
192
+ export declare function updateMembershipForClaim(membership: SeasonMembership, rewardAmount: BN): SeasonMembership;
193
+ /**
194
+ * Initialize ReferralPenaltyClaim
195
+ * Mirrors claim_referral_penalty_for_window.rs (write fields + amount calc)
196
+ *
197
+ * @param referredUser - The user who missed the window
198
+ * @param seasonNumber - Season number
199
+ * @param windowNumber - Window number
200
+ * @param seasonMembershipId - Referred user's membership id
201
+ * @param claimant - Referrer (or root admin if no referrer)
202
+ * @param perWindowPenalty - Tier penalty per window (base units)
203
+ * @param claimedAt - Unix timestamp in seconds (i64 on-chain, represented as BN in SDK)
204
+ */
205
+ export declare function initializeReferralPenaltyClaim(params: {
206
+ referredUser: PublicKey;
207
+ seasonNumber: BN;
208
+ windowNumber: BN;
209
+ seasonMembershipId: BN;
210
+ claimant: PublicKey;
211
+ perWindowPenalty: BN;
212
+ claimedAt?: BN;
213
+ }): ReferralPenaltyClaim;
214
+ /**
215
+ * Calculate withdrawal amount for season deposit
216
+ * Mirrors withdraw_season_deposit.rs logic (lines 55-87)
217
+ *
218
+ * @param membership - Current membership
219
+ * @param season - Current season
220
+ * @param settings - Season settings
221
+ * @returns Withdrawal amount and updated accounts
222
+ *
223
+ * @throws Error if invalid inputs provided
224
+ */
225
+ export declare function calculateWithdrawalAmount(membership: SeasonMembership, season: Season, settings: SeasonSettings): {
226
+ withdrawalAmount: BN;
227
+ updatedMembership: SeasonMembership;
228
+ updatedSeason: Season;
229
+ updatedSettings: SeasonSettings;
230
+ };
231
+ /**
232
+ * Update SeasonSettings after toggling pause
233
+ *
234
+ * @param settings - Current settings
235
+ * @returns Updated SeasonSettings object
236
+ */
237
+ export declare function updateSeasonSettingsForPauseToggle(settings: SeasonSettings): SeasonSettings;
238
+ /**
239
+ * Update SeasonSettings after admin update
240
+ *
241
+ * @param settings - Current settings
242
+ * @param newAdmin - New admin public key
243
+ * @returns Updated SeasonSettings object
244
+ */
245
+ export declare function updateSeasonSettingsForAdminUpdate(settings: SeasonSettings, newAdmin: PublicKey): SeasonSettings;