proof-of-take-sdk 3.0.8 → 3.0.9

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.
@@ -1,20 +1,23 @@
1
1
  /**
2
2
  * Season system constants
3
- * These values match the constants defined in the Rust program
3
+ *
4
+ * IMPORTANT:
5
+ * - These values are intended to mirror `programs/proof_of_take/src/constants.rs`.
6
+ * - Amounts are expressed in MIZD base units (7 decimals): 1 MIZD = 10_000_000.
4
7
  */
5
- export declare const SEASON_CONSTANTS: {
6
- /** Cost to join a season (100 MIZD with decimals) */
7
- readonly MEMBERSHIP_COST: any;
8
- /** Penalty per missed window (1.375 MIZD with decimals) */
9
- readonly PENALTY_PER_WINDOW: any;
10
- /** Duration of entire season in seconds (7 days) */
11
- readonly SEASON_DURATION: 604800;
12
- /** Duration of each window in seconds (8 hours) */
13
- readonly WINDOW_DURATION: 28800;
14
- /** Claim buffer duration in seconds (5 minutes) */
15
- readonly CLAIM_BUFFER_DURATION: 300;
16
- /** Total number of windows per season */
17
- readonly TOTAL_WINDOWS_PER_SEASON: 21;
18
- /** Maximum members allowed per season (DOS protection) */
19
- readonly MAX_MEMBERS_PER_SEASON: any;
20
- };
8
+ export declare const MIZD_DECIMALS = 10000000;
9
+ export declare const MIZD_DECIMALS_BN: any;
10
+ export declare const JOIN_FEE_TOTAL: any;
11
+ export declare const JOIN_FEE_REFERRER: any;
12
+ export declare const JOIN_FEE_ADMIN_WITH_REFERRER: any;
13
+ export declare const SEASON_DURATION_SECONDS = 604800;
14
+ export declare const WINDOW_DURATION_SECONDS = 28800;
15
+ /**
16
+ * Claim buffer duration in seconds (5 minutes).
17
+ *
18
+ * Note: user reward claims (`claim_window_rewards`) are gated by the window-duration buffer
19
+ * (see on-chain `claim_available_at`), while the missed-window referral-penalty claim uses
20
+ * this constant.
21
+ */
22
+ export declare const CLAIM_BUFFER_DURATION_SECONDS = 300;
23
+ export declare const TOTAL_WINDOWS_PER_SEASON = 21;
@@ -1,24 +1,30 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SEASON_CONSTANTS = void 0;
3
+ exports.TOTAL_WINDOWS_PER_SEASON = exports.CLAIM_BUFFER_DURATION_SECONDS = exports.WINDOW_DURATION_SECONDS = exports.SEASON_DURATION_SECONDS = exports.JOIN_FEE_ADMIN_WITH_REFERRER = exports.JOIN_FEE_REFERRER = exports.JOIN_FEE_TOTAL = exports.MIZD_DECIMALS_BN = exports.MIZD_DECIMALS = void 0;
4
4
  const anchor_1 = require("@coral-xyz/anchor");
5
5
  /**
6
6
  * Season system constants
7
- * These values match the constants defined in the Rust program
7
+ *
8
+ * IMPORTANT:
9
+ * - These values are intended to mirror `programs/proof_of_take/src/constants.rs`.
10
+ * - Amounts are expressed in MIZD base units (7 decimals): 1 MIZD = 10_000_000.
8
11
  */
9
- exports.SEASON_CONSTANTS = {
10
- /** Cost to join a season (100 MIZD with decimals) */
11
- MEMBERSHIP_COST: new anchor_1.BN(100000000000),
12
- /** Penalty per missed window (1.375 MIZD with decimals) */
13
- PENALTY_PER_WINDOW: new anchor_1.BN(1375000000),
14
- /** Duration of entire season in seconds (7 days) */
15
- SEASON_DURATION: 604800,
16
- /** Duration of each window in seconds (8 hours) */
17
- WINDOW_DURATION: 28800,
18
- /** Claim buffer duration in seconds (5 minutes) */
19
- CLAIM_BUFFER_DURATION: 300,
20
- /** Total number of windows per season */
21
- TOTAL_WINDOWS_PER_SEASON: 21,
22
- /** Maximum members allowed per season (DOS protection) */
23
- MAX_MEMBERS_PER_SEASON: new anchor_1.BN(10000),
24
- };
12
+ // ===== Token decimals =====
13
+ exports.MIZD_DECIMALS = 10000000;
14
+ exports.MIZD_DECIMALS_BN = new anchor_1.BN(exports.MIZD_DECIMALS);
15
+ // ===== Join fees (MIZD base units) =====
16
+ exports.JOIN_FEE_TOTAL = new anchor_1.BN(49000000); // 4.9 MIZD
17
+ exports.JOIN_FEE_REFERRER = new anchor_1.BN(7000000); // 0.7 MIZD
18
+ exports.JOIN_FEE_ADMIN_WITH_REFERRER = new anchor_1.BN(42000000); // 4.2 MIZD
19
+ // ===== Timing (seconds) =====
20
+ exports.SEASON_DURATION_SECONDS = 604800; // 7 days
21
+ exports.WINDOW_DURATION_SECONDS = 28800; // 8 hours
22
+ /**
23
+ * Claim buffer duration in seconds (5 minutes).
24
+ *
25
+ * Note: user reward claims (`claim_window_rewards`) are gated by the window-duration buffer
26
+ * (see on-chain `claim_available_at`), while the missed-window referral-penalty claim uses
27
+ * this constant.
28
+ */
29
+ exports.CLAIM_BUFFER_DURATION_SECONDS = 300;
30
+ exports.TOTAL_WINDOWS_PER_SEASON = 21;
@@ -308,10 +308,6 @@
308
308
  "name": "user_token_account",
309
309
  "writable": true
310
310
  },
311
- {
312
- "name": "referrer_token_account",
313
- "writable": true
314
- },
315
311
  {
316
312
  "name": "user",
317
313
  "signer": true
@@ -24,8 +24,6 @@ export interface ClaimWindowRewardsOptions {
24
24
  connection: Connection;
25
25
  user: PublicKey;
26
26
  userTokenAccount: PublicKey;
27
- /** Referrer token account to receive referral share (only used when membership.referrer != default) */
28
- referrerTokenAccount?: PublicKey;
29
27
  seasonNumber: BN;
30
28
  windowNumber: WindowNumberLike;
31
29
  /** Tier number: 0=copper, 1=silver, 2=gold, 3=platinum, 4=mithril */
@@ -2,11 +2,9 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.claimWindowRewards = claimWindowRewards;
4
4
  const anchor_1 = require("@coral-xyz/anchor");
5
- const web3_js_1 = require("@solana/web3.js");
6
5
  const spl_token_1 = require("@solana/spl-token");
7
6
  const pdaManager_1 = require("../utils/pdaManager");
8
7
  const constants_1 = require("../utils/constants");
9
- const tierPenalty_1 = require("../utils/tierPenalty");
10
8
  const programHelpers_1 = require("../utils/programHelpers");
11
9
  const signerHelpers_1 = require("../utils/signerHelpers");
12
10
  const optimistic_1 = require("../optimistic");
@@ -39,8 +37,6 @@ async function claimWindowRewards(options) {
39
37
  seasonDepositVault: pdas.seasonDepositVault,
40
38
  mizdMint: constants_1.MIZD_TOKEN_MINT,
41
39
  userTokenAccount: options.userTokenAccount,
42
- // Always provide something; on-chain will only validate/use when referrer exists.
43
- referrerTokenAccount: options.referrerTokenAccount ?? options.userTokenAccount,
44
40
  user: options.user,
45
41
  tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
46
42
  };
@@ -61,16 +57,8 @@ async function claimWindowRewards(options) {
61
57
  ? (0, optimistic_1.updateWindowForFinalization)(curr.rewardWindow, eligibleStakeX)
62
58
  : curr.rewardWindow;
63
59
  const rewardAmount = updatedRewardWindow.rewardPerPoster;
64
- const hasReferrer = !!curr.seasonMembership &&
65
- !curr.seasonMembership.referrer.equals(web3_js_1.PublicKey.default);
66
- const tierPenaltyPerWindow = curr.seasonMembership
67
- ? (0, tierPenalty_1.getTierPenaltyPerWindow)(curr.seasonMembership.depositTier)
68
- : new anchor_1.BN(0);
69
- const bonus = rewardAmount.gt(tierPenaltyPerWindow)
70
- ? rewardAmount.sub(tierPenaltyPerWindow)
71
- : new anchor_1.BN(0);
72
- const referralCut = hasReferrer ? bonus.divn(10) : new anchor_1.BN(0);
73
- const userRewardAmount = rewardAmount.sub(referralCut);
60
+ // Referral reward split removed on-chain: user always receives full rewardAmount.
61
+ const userRewardAmount = rewardAmount;
74
62
  const updatedSeason = !curr.rewardWindow.isFinalized
75
63
  ? {
76
64
  ...curr.season,
@@ -81,7 +81,6 @@ export interface ClaimWindowRewardsAccounts {
81
81
  seasonDepositVault: PublicKey;
82
82
  mizdMint: PublicKey;
83
83
  userTokenAccount: PublicKey;
84
- referrerTokenAccount: PublicKey;
85
84
  user: PublicKey;
86
85
  tokenProgram: PublicKey;
87
86
  }
@@ -314,10 +314,6 @@ export type ProofOfTake = {
314
314
  "name": "userTokenAccount";
315
315
  "writable": true;
316
316
  },
317
- {
318
- "name": "referrerTokenAccount";
319
- "writable": true;
320
- },
321
317
  {
322
318
  "name": "user";
323
319
  "signer": true;
@@ -3,8 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.assertValidTierNumber = assertValidTierNumber;
4
4
  exports.tierNumberToDepositTier = tierNumberToDepositTier;
5
5
  exports.getTierPenaltyPerWindow = getTierPenaltyPerWindow;
6
- const anchor_1 = require("@coral-xyz/anchor");
7
6
  const depositTier_1 = require("./depositTier");
7
+ const season_1 = require("../constants/season");
8
8
  /**
9
9
  * Validate and normalize a tier number (0..=4).
10
10
  */
@@ -40,17 +40,18 @@ function tierNumberToDepositTier(tier) {
40
40
  * to mirror on-chain accounting (refund vs bonus portions).
41
41
  */
42
42
  function getTierPenaltyPerWindow(tier) {
43
- // Base units (7 decimals): 1 MIZD = 10_000_000
43
+ // Base units (7 decimals): 1 MIZD = MIZD_DECIMALS
44
+ void season_1.MIZD_DECIMALS; // doc-only; keep TS/ESLint from flagging as unused in some configs
44
45
  switch ((0, depositTier_1.getDepositTierName)(tier)) {
45
46
  case "copper":
46
- return new anchor_1.BN(1000000); // 0.1 MIZD
47
+ return season_1.MIZD_DECIMALS_BN.divn(10); // 0.1 MIZD
47
48
  case "silver":
48
- return new anchor_1.BN(10000000); // 1 MIZD
49
+ return season_1.MIZD_DECIMALS_BN; // 1 MIZD
49
50
  case "gold":
50
- return new anchor_1.BN(100000000); // 10 MIZD
51
+ return season_1.MIZD_DECIMALS_BN.muln(10); // 10 MIZD
51
52
  case "platinum":
52
- return new anchor_1.BN(1000000000); // 100 MIZD
53
+ return season_1.MIZD_DECIMALS_BN.muln(100); // 100 MIZD
53
54
  case "mithril":
54
- return new anchor_1.BN(10000000000); // 1,000 MIZD
55
+ return season_1.MIZD_DECIMALS_BN.muln(1000); // 1,000 MIZD
55
56
  }
56
57
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "proof-of-take-sdk",
3
- "version": "3.0.8",
3
+ "version": "3.0.9",
4
4
  "description": "TypeScript SDK for Proof of Take Solana program",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",