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.
- package/dist/constants/season.d.ts +20 -17
- package/dist/constants/season.js +24 -18
- package/dist/idl/proof_of_take.json +0 -4
- package/dist/instructions/claimWindowRewards.d.ts +0 -2
- package/dist/instructions/claimWindowRewards.js +2 -14
- package/dist/types/accountTypes.d.ts +0 -1
- package/dist/types/proof_of_take.d.ts +0 -4
- package/dist/utils/tierPenalty.js +8 -7
- package/package.json +1 -1
|
@@ -1,20 +1,23 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Season system constants
|
|
3
|
-
*
|
|
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
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
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;
|
package/dist/constants/season.js
CHANGED
|
@@ -1,24 +1,30 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
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
|
-
*
|
|
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
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
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;
|
|
@@ -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
|
-
|
|
65
|
-
|
|
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,
|
|
@@ -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 =
|
|
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
|
|
47
|
+
return season_1.MIZD_DECIMALS_BN.divn(10); // 0.1 MIZD
|
|
47
48
|
case "silver":
|
|
48
|
-
return
|
|
49
|
+
return season_1.MIZD_DECIMALS_BN; // 1 MIZD
|
|
49
50
|
case "gold":
|
|
50
|
-
return
|
|
51
|
+
return season_1.MIZD_DECIMALS_BN.muln(10); // 10 MIZD
|
|
51
52
|
case "platinum":
|
|
52
|
-
return
|
|
53
|
+
return season_1.MIZD_DECIMALS_BN.muln(100); // 100 MIZD
|
|
53
54
|
case "mithril":
|
|
54
|
-
return
|
|
55
|
+
return season_1.MIZD_DECIMALS_BN.muln(1000); // 1,000 MIZD
|
|
55
56
|
}
|
|
56
57
|
}
|