proof-of-take-sdk 3.1.2 → 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.
- package/dist/getters/getSeasonLaunchpadPool.d.ts +31 -0
- package/dist/getters/getSeasonLaunchpadPool.js +49 -0
- package/dist/getters/index.d.ts +1 -0
- package/dist/getters/index.js +1 -0
- package/dist/idl/proof_of_take.json +4490 -1674
- package/dist/index.d.ts +14 -7
- package/dist/index.js +20 -3
- package/dist/instructions/buyMizd.d.ts +19 -0
- package/dist/instructions/buyMizd.js +41 -0
- package/dist/instructions/claimReferralPenaltyForWindow.d.ts +53 -2
- package/dist/instructions/claimReferralPenaltyForWindow.js +45 -3
- package/dist/instructions/claimSignupRewards.d.ts +30 -0
- package/dist/instructions/claimSignupRewards.js +37 -3
- package/dist/instructions/claimWindowRewards.d.ts +42 -1
- package/dist/instructions/claimWindowRewards.js +47 -3
- package/dist/instructions/confirmedPostOnX.d.ts +2 -0
- package/dist/instructions/confirmedPostOnX.js +10 -0
- package/dist/instructions/createMiztake.d.ts +3 -2
- package/dist/instructions/createMiztake.js +5 -2
- package/dist/instructions/initializeBondingCurve.d.ts +24 -0
- package/dist/instructions/initializeBondingCurve.js +37 -0
- package/dist/instructions/initializeRewardWindow.d.ts +2 -0
- package/dist/instructions/initializeRewardWindow.js +5 -2
- package/dist/instructions/initializeSeasonVault.d.ts +1 -1
- package/dist/instructions/initializeSeasonVault.js +3 -2
- package/dist/instructions/joinSeason.d.ts +92 -3
- package/dist/instructions/joinSeason.js +117 -40
- package/dist/instructions/sellMizd.d.ts +19 -0
- package/dist/instructions/sellMizd.js +41 -0
- package/dist/instructions/viewSeasonMembershipStatus.d.ts +1 -1
- package/dist/instructions/viewSeasonMembershipStatus.js +13 -8
- package/dist/instructions/withdrawSeasonDeposit.d.ts +2 -0
- package/dist/instructions/withdrawSeasonDeposit.js +6 -1
- package/dist/optimistic/index.d.ts +1 -0
- package/dist/optimistic/index.js +5 -1
- package/dist/optimistic/joinSeasonOptimistic.d.ts +31 -0
- package/dist/optimistic/joinSeasonOptimistic.js +55 -0
- package/dist/types/accountTypes.d.ts +72 -18
- package/dist/types/anchorAccounts.d.ts +2 -0
- package/dist/types/proof_of_take.d.ts +4471 -1655
- package/dist/types.d.ts +10 -2
- package/dist/utils/accountConverters.js +7 -1
- package/dist/utils/accountUpdates.d.ts +38 -8
- package/dist/utils/accountUpdates.js +109 -19
- package/dist/utils/constants.d.ts +11 -0
- package/dist/utils/constants.js +14 -1
- package/dist/utils/pdaManager.d.ts +42 -2
- package/dist/utils/pdaManager.js +70 -28
- package/dist/utils/pdas.d.ts +46 -8
- package/dist/utils/pdas.js +111 -11
- package/dist/utils/remainingAccounts.d.ts +1 -0
- package/dist/utils/remainingAccounts.js +3 -2
- package/dist/utils/seedRegistry.d.ts +10 -0
- package/dist/utils/seedRegistry.js +10 -0
- package/package.json +1 -1
- package/dist/instructions/initializeEscrowVault.d.ts +0 -12
- package/dist/instructions/initializeEscrowVault.js +0 -37
package/dist/index.d.ts
CHANGED
|
@@ -11,19 +11,26 @@ export type { CreateMiztakeOptions, CreateMiztakeResult, CreateMiztakePdas, Crea
|
|
|
11
11
|
export { initializeStatistics, isInitialized, } from "./instructions/initializeStatistics";
|
|
12
12
|
export { initializeSeasonSettings } from "./instructions/initializeSeasonSettings";
|
|
13
13
|
export { initializeSeasonVault } from "./instructions/initializeSeasonVault";
|
|
14
|
-
export {
|
|
15
|
-
export {
|
|
16
|
-
export type { JoinSeasonOptions } from "./instructions/joinSeason";
|
|
14
|
+
export { joinSeason, joinSeasonClassic, joinSeasonLaunchpad, joinSeasonAndInitialize, joinSeasonLaunchpadAndInitialize, } from "./instructions/joinSeason";
|
|
15
|
+
export type { JoinSeasonOptions, JoinSeasonClassicOptions, JoinSeasonLaunchpadOptions, JoinSeasonAndInitializeOptions, } from "./instructions/joinSeason";
|
|
17
16
|
export { confirmedPostOnX } from "./instructions/confirmedPostOnX";
|
|
18
17
|
export type { ConfirmedPostOnXOptions } from "./instructions/confirmedPostOnX";
|
|
19
|
-
export { claimWindowRewards } from "./instructions/claimWindowRewards";
|
|
20
|
-
export type { ClaimWindowRewardsOptions } from "./instructions/claimWindowRewards";
|
|
18
|
+
export { claimWindowRewards, claimWindowRewardsClassic, claimWindowRewardsLaunchpad, } from "./instructions/claimWindowRewards";
|
|
19
|
+
export type { ClaimWindowRewardsOptions, ClaimWindowRewardsClassicOptions, ClaimWindowRewardsLaunchpadOptions, } from "./instructions/claimWindowRewards";
|
|
21
20
|
export { claimReferralPenaltyForWindow } from "./instructions/claimReferralPenaltyForWindow";
|
|
22
|
-
export
|
|
21
|
+
export { claimReferralPenaltyForWindowClassic, claimReferralPenaltyForWindowLaunchpad, } from "./instructions/claimReferralPenaltyForWindow";
|
|
22
|
+
export type { ClaimReferralPenaltyForWindowOptions, ClaimReferralPenaltyForWindowClassicOptions, ClaimReferralPenaltyForWindowLaunchpadOptions, } from "./instructions/claimReferralPenaltyForWindow";
|
|
23
23
|
export { claimSignupRewards } from "./instructions/claimSignupRewards";
|
|
24
|
-
export
|
|
24
|
+
export { claimSignupRewardsClassic, claimSignupRewardsLaunchpad, } from "./instructions/claimSignupRewards";
|
|
25
|
+
export type { ClaimSignupRewardsOptions, ClaimSignupRewardsClassicOptions, ClaimSignupRewardsLaunchpadOptions, } from "./instructions/claimSignupRewards";
|
|
25
26
|
export { withdrawSeasonDeposit } from "./instructions/withdrawSeasonDeposit";
|
|
26
27
|
export type { WithdrawSeasonDepositOptions } from "./instructions/withdrawSeasonDeposit";
|
|
28
|
+
export { initializeBondingCurve } from "./instructions/initializeBondingCurve";
|
|
29
|
+
export type { InitializeBondingCurveOptions } from "./instructions/initializeBondingCurve";
|
|
30
|
+
export { buyMizd } from "./instructions/buyMizd";
|
|
31
|
+
export type { BuyMizdOptions } from "./instructions/buyMizd";
|
|
32
|
+
export { sellMizd } from "./instructions/sellMizd";
|
|
33
|
+
export type { SellMizdOptions } from "./instructions/sellMizd";
|
|
27
34
|
export { initializeRewardWindow } from "./instructions/initializeRewardWindow";
|
|
28
35
|
export type { InitializeRewardWindowOptions, InitializeRewardWindowPdas, } from "./instructions/initializeRewardWindow";
|
|
29
36
|
export { toggleSeasonPause } from "./instructions/toggleSeasonPause";
|
package/dist/index.js
CHANGED
|
@@ -21,7 +21,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
21
21
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
22
22
|
};
|
|
23
23
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
|
-
exports.VERSION = exports.closeReferralPenaltyClaim = exports.closeUserWindowParticipation = exports.closeRewardWindow = exports.closeSeasonMembership = exports.closeUserStats = exports.closeMiztake = exports.getUserStatsByPda = exports.getProgramReadOnly = exports.createProgramWithId = exports.createProgram = exports.ANCHOR_IDL = exports.IDL = exports.WindowState = exports.SeasonState = exports.PDAManager = exports.getProgram = exports.viewCurrentSeason = exports.viewWindowStatus = exports.viewSeasonMembershipStatus = exports.updateSeasonAdmin = exports.toggleSeasonPause = exports.initializeRewardWindow = exports.withdrawSeasonDeposit = exports.claimSignupRewards = exports.claimReferralPenaltyForWindow = exports.claimWindowRewards = exports.confirmedPostOnX = exports.
|
|
24
|
+
exports.VERSION = exports.closeReferralPenaltyClaim = exports.closeUserWindowParticipation = exports.closeRewardWindow = exports.closeSeasonMembership = exports.closeUserStats = exports.closeMiztake = exports.getUserStatsByPda = exports.getProgramReadOnly = exports.createProgramWithId = exports.createProgram = exports.ANCHOR_IDL = exports.IDL = exports.WindowState = exports.SeasonState = exports.PDAManager = exports.getProgram = exports.viewCurrentSeason = exports.viewWindowStatus = exports.viewSeasonMembershipStatus = exports.updateSeasonAdmin = exports.toggleSeasonPause = exports.initializeRewardWindow = exports.sellMizd = exports.buyMizd = exports.initializeBondingCurve = exports.withdrawSeasonDeposit = exports.claimSignupRewardsLaunchpad = exports.claimSignupRewardsClassic = exports.claimSignupRewards = exports.claimReferralPenaltyForWindowLaunchpad = exports.claimReferralPenaltyForWindowClassic = exports.claimReferralPenaltyForWindow = exports.claimWindowRewardsLaunchpad = exports.claimWindowRewardsClassic = exports.claimWindowRewards = exports.confirmedPostOnX = exports.joinSeasonLaunchpadAndInitialize = exports.joinSeasonAndInitialize = exports.joinSeasonLaunchpad = exports.joinSeasonClassic = exports.joinSeason = exports.initializeSeasonVault = exports.initializeSeasonSettings = exports.isInitialized = exports.initializeStatistics = exports.getMiztakePdaForParams = exports.createMiztake = void 0;
|
|
25
25
|
// NOTE:
|
|
26
26
|
// We intentionally export `getProgram` via a local const assignment (instead of `export * from ...`)
|
|
27
27
|
// so that the compiled CommonJS output uses a writable property. This makes it possible to mock
|
|
@@ -40,21 +40,38 @@ var initializeSeasonSettings_1 = require("./instructions/initializeSeasonSetting
|
|
|
40
40
|
Object.defineProperty(exports, "initializeSeasonSettings", { enumerable: true, get: function () { return initializeSeasonSettings_1.initializeSeasonSettings; } });
|
|
41
41
|
var initializeSeasonVault_1 = require("./instructions/initializeSeasonVault");
|
|
42
42
|
Object.defineProperty(exports, "initializeSeasonVault", { enumerable: true, get: function () { return initializeSeasonVault_1.initializeSeasonVault; } });
|
|
43
|
-
var initializeEscrowVault_1 = require("./instructions/initializeEscrowVault");
|
|
44
|
-
Object.defineProperty(exports, "initializeEscrowVault", { enumerable: true, get: function () { return initializeEscrowVault_1.initializeEscrowVault; } });
|
|
45
43
|
// Season membership instructions
|
|
46
44
|
var joinSeason_1 = require("./instructions/joinSeason");
|
|
47
45
|
Object.defineProperty(exports, "joinSeason", { enumerable: true, get: function () { return joinSeason_1.joinSeason; } });
|
|
46
|
+
Object.defineProperty(exports, "joinSeasonClassic", { enumerable: true, get: function () { return joinSeason_1.joinSeasonClassic; } });
|
|
47
|
+
Object.defineProperty(exports, "joinSeasonLaunchpad", { enumerable: true, get: function () { return joinSeason_1.joinSeasonLaunchpad; } });
|
|
48
|
+
Object.defineProperty(exports, "joinSeasonAndInitialize", { enumerable: true, get: function () { return joinSeason_1.joinSeasonAndInitialize; } });
|
|
49
|
+
Object.defineProperty(exports, "joinSeasonLaunchpadAndInitialize", { enumerable: true, get: function () { return joinSeason_1.joinSeasonLaunchpadAndInitialize; } });
|
|
48
50
|
var confirmedPostOnX_1 = require("./instructions/confirmedPostOnX");
|
|
49
51
|
Object.defineProperty(exports, "confirmedPostOnX", { enumerable: true, get: function () { return confirmedPostOnX_1.confirmedPostOnX; } });
|
|
50
52
|
var claimWindowRewards_1 = require("./instructions/claimWindowRewards");
|
|
51
53
|
Object.defineProperty(exports, "claimWindowRewards", { enumerable: true, get: function () { return claimWindowRewards_1.claimWindowRewards; } });
|
|
54
|
+
Object.defineProperty(exports, "claimWindowRewardsClassic", { enumerable: true, get: function () { return claimWindowRewards_1.claimWindowRewardsClassic; } });
|
|
55
|
+
Object.defineProperty(exports, "claimWindowRewardsLaunchpad", { enumerable: true, get: function () { return claimWindowRewards_1.claimWindowRewardsLaunchpad; } });
|
|
52
56
|
var claimReferralPenaltyForWindow_1 = require("./instructions/claimReferralPenaltyForWindow");
|
|
53
57
|
Object.defineProperty(exports, "claimReferralPenaltyForWindow", { enumerable: true, get: function () { return claimReferralPenaltyForWindow_1.claimReferralPenaltyForWindow; } });
|
|
58
|
+
var claimReferralPenaltyForWindow_2 = require("./instructions/claimReferralPenaltyForWindow");
|
|
59
|
+
Object.defineProperty(exports, "claimReferralPenaltyForWindowClassic", { enumerable: true, get: function () { return claimReferralPenaltyForWindow_2.claimReferralPenaltyForWindowClassic; } });
|
|
60
|
+
Object.defineProperty(exports, "claimReferralPenaltyForWindowLaunchpad", { enumerable: true, get: function () { return claimReferralPenaltyForWindow_2.claimReferralPenaltyForWindowLaunchpad; } });
|
|
54
61
|
var claimSignupRewards_1 = require("./instructions/claimSignupRewards");
|
|
55
62
|
Object.defineProperty(exports, "claimSignupRewards", { enumerable: true, get: function () { return claimSignupRewards_1.claimSignupRewards; } });
|
|
63
|
+
var claimSignupRewards_2 = require("./instructions/claimSignupRewards");
|
|
64
|
+
Object.defineProperty(exports, "claimSignupRewardsClassic", { enumerable: true, get: function () { return claimSignupRewards_2.claimSignupRewardsClassic; } });
|
|
65
|
+
Object.defineProperty(exports, "claimSignupRewardsLaunchpad", { enumerable: true, get: function () { return claimSignupRewards_2.claimSignupRewardsLaunchpad; } });
|
|
56
66
|
var withdrawSeasonDeposit_1 = require("./instructions/withdrawSeasonDeposit");
|
|
57
67
|
Object.defineProperty(exports, "withdrawSeasonDeposit", { enumerable: true, get: function () { return withdrawSeasonDeposit_1.withdrawSeasonDeposit; } });
|
|
68
|
+
// Bonding curve instructions (SOL↔MIZD)
|
|
69
|
+
var initializeBondingCurve_1 = require("./instructions/initializeBondingCurve");
|
|
70
|
+
Object.defineProperty(exports, "initializeBondingCurve", { enumerable: true, get: function () { return initializeBondingCurve_1.initializeBondingCurve; } });
|
|
71
|
+
var buyMizd_1 = require("./instructions/buyMizd");
|
|
72
|
+
Object.defineProperty(exports, "buyMizd", { enumerable: true, get: function () { return buyMizd_1.buyMizd; } });
|
|
73
|
+
var sellMizd_1 = require("./instructions/sellMizd");
|
|
74
|
+
Object.defineProperty(exports, "sellMizd", { enumerable: true, get: function () { return sellMizd_1.sellMizd; } });
|
|
58
75
|
// Season admin instructions
|
|
59
76
|
var initializeRewardWindow_1 = require("./instructions/initializeRewardWindow");
|
|
60
77
|
Object.defineProperty(exports, "initializeRewardWindow", { enumerable: true, get: function () { return initializeRewardWindow_1.initializeRewardWindow; } });
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { BN } from "@coral-xyz/anchor";
|
|
2
|
+
import { Connection, PublicKey } from "@solana/web3.js";
|
|
3
|
+
import { StandardInstructionResultWithPdas } from "../types/instructionResults";
|
|
4
|
+
export interface BuyMizdOptions {
|
|
5
|
+
connection: Connection;
|
|
6
|
+
user: PublicKey;
|
|
7
|
+
/** SOL input (lamports). */
|
|
8
|
+
solInLamports: BN;
|
|
9
|
+
/** Slippage protection: minimum MIZD out (base units). */
|
|
10
|
+
minMizdOutUnits: BN;
|
|
11
|
+
/** Must be the on-chain root admin (ADMIN_PUBLIC_KEY); required signer on-chain. */
|
|
12
|
+
admin?: PublicKey;
|
|
13
|
+
feePayer?: PublicKey;
|
|
14
|
+
}
|
|
15
|
+
export declare function buyMizd(opts: BuyMizdOptions): Promise<StandardInstructionResultWithPdas<{
|
|
16
|
+
bondingCurve: PublicKey;
|
|
17
|
+
mizdVault: PublicKey;
|
|
18
|
+
userMizdAta: PublicKey;
|
|
19
|
+
}>>;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.buyMizd = buyMizd;
|
|
4
|
+
const web3_js_1 = require("@solana/web3.js");
|
|
5
|
+
const spl_token_1 = require("@solana/spl-token");
|
|
6
|
+
const instructionResultHelpers_1 = require("../utils/instructionResultHelpers");
|
|
7
|
+
const constants_1 = require("../utils/constants");
|
|
8
|
+
const pdaManager_1 = require("../utils/pdaManager");
|
|
9
|
+
const programHelpers_1 = require("../utils/programHelpers");
|
|
10
|
+
const signerHelpers_1 = require("../utils/signerHelpers");
|
|
11
|
+
async function buyMizd(opts) {
|
|
12
|
+
const program = (0, programHelpers_1.getProgram)(opts.connection);
|
|
13
|
+
const admin = opts.admin ?? constants_1.ADMIN_PUBLIC_KEY;
|
|
14
|
+
const pdas = pdaManager_1.PDAManager.deriveBondingCurvePdas();
|
|
15
|
+
const userMizdAta = (0, spl_token_1.getAssociatedTokenAddressSync)(constants_1.MIZD_TOKEN_MINT, opts.user);
|
|
16
|
+
const accounts = {
|
|
17
|
+
bondingCurve: pdas.bondingCurve,
|
|
18
|
+
mizdVault: pdas.mizdVault,
|
|
19
|
+
mizdMint: constants_1.MIZD_TOKEN_MINT,
|
|
20
|
+
admin,
|
|
21
|
+
user: opts.user,
|
|
22
|
+
userMizdAta,
|
|
23
|
+
associatedTokenProgram: spl_token_1.ASSOCIATED_TOKEN_PROGRAM_ID,
|
|
24
|
+
tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
|
|
25
|
+
systemProgram: web3_js_1.SystemProgram.programId,
|
|
26
|
+
};
|
|
27
|
+
const instruction = await program.methods
|
|
28
|
+
.buyMizd(opts.solInLamports, opts.minMizdOutUnits)
|
|
29
|
+
.accounts(accounts)
|
|
30
|
+
.instruction();
|
|
31
|
+
const feePayer = (0, signerHelpers_1.resolveFeePayer)({ feePayer: opts.feePayer, admin });
|
|
32
|
+
const signers = (0, signerHelpers_1.buildSigners)([(0, signerHelpers_1.asAdminSigner)(admin), (0, signerHelpers_1.asUserSigner)(opts.user)], feePayer);
|
|
33
|
+
return (0, instructionResultHelpers_1.singleInstruction)(instruction, {
|
|
34
|
+
signers,
|
|
35
|
+
pdas: {
|
|
36
|
+
bondingCurve: pdas.bondingCurve,
|
|
37
|
+
mizdVault: pdas.mizdVault,
|
|
38
|
+
userMizdAta,
|
|
39
|
+
},
|
|
40
|
+
});
|
|
41
|
+
}
|
|
@@ -6,13 +6,22 @@ export interface ClaimReferralPenaltyForWindowOptions {
|
|
|
6
6
|
connection: Connection;
|
|
7
7
|
/** Referrer (or root admin if no referrer) */
|
|
8
8
|
claimant: PublicKey;
|
|
9
|
-
/** Token account owned by claimant (receives the 20% payout) */
|
|
10
|
-
recipientTokenAccount
|
|
9
|
+
/** Token account owned by claimant (receives the 20% payout) - required when launchpad=false. */
|
|
10
|
+
recipientTokenAccount?: PublicKey;
|
|
11
11
|
referredUser: PublicKey;
|
|
12
12
|
seasonNumber: BN;
|
|
13
|
+
/** Token mint this season is scoped to (used for PDA derivation). Defaults to MIZD_TOKEN_MINT. */
|
|
14
|
+
tokenMint?: PublicKey;
|
|
13
15
|
windowNumber: WindowNumberLike;
|
|
14
16
|
/** Tier number: 0=copper, 1=silver, 2=gold, 3=platinum, 4=mithril */
|
|
15
17
|
tier: TierNumber;
|
|
18
|
+
/** If true, claim uses launchpad mode (SOL payout; token accounts can be omitted). */
|
|
19
|
+
launchpad?: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Launchpad-only: minimum SOL out (lamports) for the virtual-token sell.
|
|
22
|
+
* Defaults to 0 (no sell-side slippage protection).
|
|
23
|
+
*/
|
|
24
|
+
minSolOutLamports?: BN;
|
|
16
25
|
feePayer?: PublicKey;
|
|
17
26
|
/**
|
|
18
27
|
* Optional timestamp override (Unix seconds) for optimistic `claimedAt`.
|
|
@@ -28,6 +37,16 @@ export interface ClaimReferralPenaltyForWindowOptions {
|
|
|
28
37
|
userWindowParticipation?: UserWindowParticipation;
|
|
29
38
|
};
|
|
30
39
|
}
|
|
40
|
+
export type ClaimReferralPenaltyForWindowClassicOptions = Omit<ClaimReferralPenaltyForWindowOptions, "launchpad" | "recipientTokenAccount" | "minSolOutLamports"> & {
|
|
41
|
+
launchpad?: never;
|
|
42
|
+
recipientTokenAccount: PublicKey;
|
|
43
|
+
minSolOutLamports?: never;
|
|
44
|
+
};
|
|
45
|
+
export type ClaimReferralPenaltyForWindowLaunchpadOptions = Omit<ClaimReferralPenaltyForWindowOptions, "launchpad" | "recipientTokenAccount"> & {
|
|
46
|
+
launchpad?: never;
|
|
47
|
+
recipientTokenAccount?: never;
|
|
48
|
+
minSolOutLamports?: BN;
|
|
49
|
+
};
|
|
31
50
|
export declare function claimReferralPenaltyForWindow(options: ClaimReferralPenaltyForWindowOptions): Promise<StandardInstructionResultWithPdas<{
|
|
32
51
|
seasonSettings: PublicKey;
|
|
33
52
|
season: PublicKey;
|
|
@@ -40,3 +59,35 @@ export declare function claimReferralPenaltyForWindow(options: ClaimReferralPena
|
|
|
40
59
|
referralPenaltyClaim?: ReferralPenaltyClaim;
|
|
41
60
|
seasonMembership?: SeasonMembership;
|
|
42
61
|
}>>;
|
|
62
|
+
/**
|
|
63
|
+
* Convenience wrapper: classic (non-launchpad) claimReferralPenaltyForWindow.
|
|
64
|
+
* App code never passes nullable optional accounts.
|
|
65
|
+
*/
|
|
66
|
+
export declare function claimReferralPenaltyForWindowClassic(options: ClaimReferralPenaltyForWindowClassicOptions): Promise<StandardInstructionResultWithPdas<{
|
|
67
|
+
seasonSettings: PublicKey;
|
|
68
|
+
season: PublicKey;
|
|
69
|
+
seasonMembership: PublicKey;
|
|
70
|
+
userWindowParticipation: PublicKey;
|
|
71
|
+
referralPenaltyClaim: PublicKey;
|
|
72
|
+
seasonDepositVault: PublicKey;
|
|
73
|
+
}, {
|
|
74
|
+
userWindowParticipation?: UserWindowParticipation;
|
|
75
|
+
referralPenaltyClaim?: ReferralPenaltyClaim;
|
|
76
|
+
seasonMembership?: SeasonMembership;
|
|
77
|
+
}>>;
|
|
78
|
+
/**
|
|
79
|
+
* Convenience wrapper: launchpad claimReferralPenaltyForWindow (SOL payout).
|
|
80
|
+
* App code never passes nullable optional accounts.
|
|
81
|
+
*/
|
|
82
|
+
export declare function claimReferralPenaltyForWindowLaunchpad(options: ClaimReferralPenaltyForWindowLaunchpadOptions): Promise<StandardInstructionResultWithPdas<{
|
|
83
|
+
seasonSettings: PublicKey;
|
|
84
|
+
season: PublicKey;
|
|
85
|
+
seasonMembership: PublicKey;
|
|
86
|
+
userWindowParticipation: PublicKey;
|
|
87
|
+
referralPenaltyClaim: PublicKey;
|
|
88
|
+
seasonDepositVault: PublicKey;
|
|
89
|
+
}, {
|
|
90
|
+
userWindowParticipation?: UserWindowParticipation;
|
|
91
|
+
referralPenaltyClaim?: ReferralPenaltyClaim;
|
|
92
|
+
seasonMembership?: SeasonMembership;
|
|
93
|
+
}>>;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.claimReferralPenaltyForWindow = claimReferralPenaltyForWindow;
|
|
4
|
+
exports.claimReferralPenaltyForWindowClassic = claimReferralPenaltyForWindowClassic;
|
|
5
|
+
exports.claimReferralPenaltyForWindowLaunchpad = claimReferralPenaltyForWindowLaunchpad;
|
|
4
6
|
const anchor_1 = require("@coral-xyz/anchor");
|
|
5
7
|
const web3_js_1 = require("@solana/web3.js");
|
|
6
8
|
const spl_token_1 = require("@solana/spl-token");
|
|
@@ -14,11 +16,14 @@ const conversions_1 = require("../utils/conversions");
|
|
|
14
16
|
async function claimReferralPenaltyForWindow(options) {
|
|
15
17
|
const windowNumber = (0, conversions_1.toWindowNumberBn)(options.windowNumber);
|
|
16
18
|
const program = (0, programHelpers_1.getProgram)(options.connection);
|
|
19
|
+
const tokenMint = options.tokenMint ?? constants_1.MIZD_TOKEN_MINT;
|
|
20
|
+
const launchpad = options.launchpad ?? false;
|
|
17
21
|
const pdas = pdaManager_1.PDAManager.deriveClaimReferralPenaltyForWindowPdas({
|
|
18
22
|
referredUser: options.referredUser,
|
|
19
23
|
seasonNumber: options.seasonNumber,
|
|
20
24
|
windowNumber,
|
|
21
25
|
tier: options.tier,
|
|
26
|
+
tokenMint,
|
|
22
27
|
});
|
|
23
28
|
const accounts = {
|
|
24
29
|
seasonSettings: pdas.seasonSettings,
|
|
@@ -26,17 +31,26 @@ async function claimReferralPenaltyForWindow(options) {
|
|
|
26
31
|
seasonMembership: pdas.seasonMembership,
|
|
27
32
|
userWindowParticipation: pdas.userWindowParticipation,
|
|
28
33
|
referralPenaltyClaim: pdas.referralPenaltyClaim,
|
|
29
|
-
|
|
34
|
+
moonpool: launchpad ? pdas.moonpool : null,
|
|
35
|
+
moonpoolTreasury: launchpad ? pdas.moonpoolTreasury : null,
|
|
36
|
+
seasonDepositVault: launchpad ? null : pdas.seasonDepositVault,
|
|
30
37
|
mizdMint: constants_1.MIZD_TOKEN_MINT,
|
|
31
|
-
|
|
38
|
+
tokenMint,
|
|
39
|
+
recipientTokenAccount: launchpad
|
|
40
|
+
? null
|
|
41
|
+
: options.recipientTokenAccount ?? null,
|
|
32
42
|
claimant: options.claimant,
|
|
43
|
+
associatedTokenProgram: spl_token_1.ASSOCIATED_TOKEN_PROGRAM_ID,
|
|
33
44
|
tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
|
|
34
45
|
systemProgram: web3_js_1.SystemProgram.programId,
|
|
35
46
|
};
|
|
47
|
+
if (!launchpad && !accounts.recipientTokenAccount) {
|
|
48
|
+
throw new Error("recipientTokenAccount is required when launchpad=false");
|
|
49
|
+
}
|
|
36
50
|
const instruction = await program.methods
|
|
37
51
|
.claimReferralPenaltyForWindow(
|
|
38
52
|
// Anchor expects BN for u64 args.
|
|
39
|
-
options.seasonNumber, windowNumber, options.referredUser, options.tier)
|
|
53
|
+
options.seasonNumber, windowNumber, options.referredUser, options.tier, launchpad ? options.minSolOutLamports ?? new anchor_1.BN(0) : new anchor_1.BN(0))
|
|
40
54
|
.accounts(accounts)
|
|
41
55
|
.instruction();
|
|
42
56
|
const feePayer = (0, signerHelpers_1.getDefaultFeePayer)(options.feePayer);
|
|
@@ -45,6 +59,14 @@ async function claimReferralPenaltyForWindow(options) {
|
|
|
45
59
|
let updatedAccounts = undefined;
|
|
46
60
|
const curr = options.currentAccounts;
|
|
47
61
|
if (curr?.seasonMembership) {
|
|
62
|
+
if (launchpad) {
|
|
63
|
+
// Launchpad mode payout depends on pool reserves; SDK does not compute optimistic SOL here.
|
|
64
|
+
return {
|
|
65
|
+
instructions: [instruction],
|
|
66
|
+
signers,
|
|
67
|
+
pdas,
|
|
68
|
+
};
|
|
69
|
+
}
|
|
48
70
|
const claimedAt = (0, optimistic_1.getCurrentTimestamp)(options.now);
|
|
49
71
|
// The program `init_if_needed` for participation; if caller doesn't provide it, assume it doesn't exist.
|
|
50
72
|
const participation = curr.userWindowParticipation ??
|
|
@@ -74,3 +96,23 @@ async function claimReferralPenaltyForWindow(options) {
|
|
|
74
96
|
...(updatedAccounts && { updatedAccounts }),
|
|
75
97
|
};
|
|
76
98
|
}
|
|
99
|
+
/**
|
|
100
|
+
* Convenience wrapper: classic (non-launchpad) claimReferralPenaltyForWindow.
|
|
101
|
+
* App code never passes nullable optional accounts.
|
|
102
|
+
*/
|
|
103
|
+
async function claimReferralPenaltyForWindowClassic(options) {
|
|
104
|
+
return claimReferralPenaltyForWindow({
|
|
105
|
+
...options,
|
|
106
|
+
launchpad: false,
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Convenience wrapper: launchpad claimReferralPenaltyForWindow (SOL payout).
|
|
111
|
+
* App code never passes nullable optional accounts.
|
|
112
|
+
*/
|
|
113
|
+
async function claimReferralPenaltyForWindowLaunchpad(options) {
|
|
114
|
+
return claimReferralPenaltyForWindow({
|
|
115
|
+
...options,
|
|
116
|
+
launchpad: true,
|
|
117
|
+
});
|
|
118
|
+
}
|
|
@@ -4,6 +4,9 @@ import { TierNumber } from "../types";
|
|
|
4
4
|
import { StandardInstructionResultWithPdas } from "../types/instructionResults";
|
|
5
5
|
type ClaimSignupRewardsPdas = {
|
|
6
6
|
seasonMembership: PublicKey;
|
|
7
|
+
season: PublicKey;
|
|
8
|
+
moonpool: PublicKey;
|
|
9
|
+
moonpoolTreasury: PublicKey;
|
|
7
10
|
signupRewardsPda: PublicKey;
|
|
8
11
|
};
|
|
9
12
|
/**
|
|
@@ -13,10 +16,27 @@ export interface ClaimSignupRewardsOptions {
|
|
|
13
16
|
connection: Connection;
|
|
14
17
|
user: PublicKey;
|
|
15
18
|
seasonNumber: BN;
|
|
19
|
+
/** Token mint this season is scoped to (used for PDA derivation). Defaults to MIZD_TOKEN_MINT. */
|
|
20
|
+
tokenMint?: PublicKey;
|
|
16
21
|
/** Tier number: 0=copper, 1=silver, 2=gold, 3=platinum, 4=mithril */
|
|
17
22
|
tier: TierNumber;
|
|
23
|
+
/** If true, claim uses launchpad mode (SOL payout; token accounts can be omitted). */
|
|
24
|
+
launchpad?: boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Launchpad-only: minimum SOL out (lamports) for the virtual-token sell.
|
|
27
|
+
* Defaults to 0 (no sell-side slippage protection).
|
|
28
|
+
*/
|
|
29
|
+
minSolOutLamports?: BN;
|
|
18
30
|
feePayer?: PublicKey;
|
|
19
31
|
}
|
|
32
|
+
export type ClaimSignupRewardsClassicOptions = Omit<ClaimSignupRewardsOptions, "launchpad" | "minSolOutLamports"> & {
|
|
33
|
+
launchpad?: never;
|
|
34
|
+
minSolOutLamports?: never;
|
|
35
|
+
};
|
|
36
|
+
export type ClaimSignupRewardsLaunchpadOptions = Omit<ClaimSignupRewardsOptions, "launchpad"> & {
|
|
37
|
+
launchpad?: never;
|
|
38
|
+
minSolOutLamports?: BN;
|
|
39
|
+
};
|
|
20
40
|
/**
|
|
21
41
|
* Claim signup referral rewards accrued for a SeasonMembership.
|
|
22
42
|
*
|
|
@@ -25,4 +45,14 @@ export interface ClaimSignupRewardsOptions {
|
|
|
25
45
|
* User pays only for creating their own MIZD ATA (if missing).
|
|
26
46
|
*/
|
|
27
47
|
export declare function claimSignupRewards(options: ClaimSignupRewardsOptions): Promise<StandardInstructionResultWithPdas<ClaimSignupRewardsPdas, never>>;
|
|
48
|
+
/**
|
|
49
|
+
* Convenience wrapper: classic (non-launchpad) claimSignupRewards.
|
|
50
|
+
* App code never passes nullable optional accounts.
|
|
51
|
+
*/
|
|
52
|
+
export declare function claimSignupRewardsClassic(options: ClaimSignupRewardsClassicOptions): Promise<StandardInstructionResultWithPdas<ClaimSignupRewardsPdas, never>>;
|
|
53
|
+
/**
|
|
54
|
+
* Convenience wrapper: launchpad claimSignupRewards (SOL payout).
|
|
55
|
+
* App code never passes nullable optional accounts.
|
|
56
|
+
*/
|
|
57
|
+
export declare function claimSignupRewardsLaunchpad(options: ClaimSignupRewardsLaunchpadOptions): Promise<StandardInstructionResultWithPdas<ClaimSignupRewardsPdas, never>>;
|
|
28
58
|
export {};
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.claimSignupRewards = claimSignupRewards;
|
|
4
|
+
exports.claimSignupRewardsClassic = claimSignupRewardsClassic;
|
|
5
|
+
exports.claimSignupRewardsLaunchpad = claimSignupRewardsLaunchpad;
|
|
6
|
+
const anchor_1 = require("@coral-xyz/anchor");
|
|
4
7
|
const web3_js_1 = require("@solana/web3.js");
|
|
5
8
|
const spl_token_1 = require("@solana/spl-token");
|
|
6
9
|
const pdaManager_1 = require("../utils/pdaManager");
|
|
@@ -16,19 +19,30 @@ const signerHelpers_1 = require("../utils/signerHelpers");
|
|
|
16
19
|
*/
|
|
17
20
|
async function claimSignupRewards(options) {
|
|
18
21
|
const program = (0, programHelpers_1.getProgram)(options.connection);
|
|
22
|
+
const tokenMint = options.tokenMint ?? constants_1.MIZD_TOKEN_MINT;
|
|
23
|
+
const launchpad = options.launchpad ?? false;
|
|
19
24
|
const pdas = pdaManager_1.PDAManager.deriveClaimSignupRewardsPdas({
|
|
20
25
|
user: options.user,
|
|
21
26
|
seasonNumber: options.seasonNumber,
|
|
22
27
|
tier: options.tier,
|
|
28
|
+
tokenMint,
|
|
23
29
|
});
|
|
24
30
|
// IMPORTANT: PDA owners are off-curve; allowOwnerOffCurve must be true.
|
|
25
|
-
const signupRewardsMizdAta =
|
|
26
|
-
|
|
31
|
+
const signupRewardsMizdAta = launchpad
|
|
32
|
+
? null
|
|
33
|
+
: (0, spl_token_1.getAssociatedTokenAddressSync)(constants_1.MIZD_TOKEN_MINT, pdas.signupRewardsPda, true);
|
|
34
|
+
const userMizdAta = launchpad
|
|
35
|
+
? null
|
|
36
|
+
: (0, spl_token_1.getAssociatedTokenAddressSync)(constants_1.MIZD_TOKEN_MINT, options.user);
|
|
27
37
|
const accounts = {
|
|
28
38
|
seasonMembership: pdas.seasonMembership,
|
|
39
|
+
season: pdas.season,
|
|
40
|
+
moonpool: launchpad ? pdas.moonpool : null,
|
|
41
|
+
moonpoolTreasury: launchpad ? pdas.moonpoolTreasury : null,
|
|
29
42
|
signupRewardsPda: pdas.signupRewardsPda,
|
|
30
43
|
signupRewardsMizdAta,
|
|
31
44
|
mizdMint: constants_1.MIZD_TOKEN_MINT,
|
|
45
|
+
tokenMint,
|
|
32
46
|
userMizdAta,
|
|
33
47
|
user: options.user,
|
|
34
48
|
associatedTokenProgram: spl_token_1.ASSOCIATED_TOKEN_PROGRAM_ID,
|
|
@@ -36,7 +50,7 @@ async function claimSignupRewards(options) {
|
|
|
36
50
|
systemProgram: web3_js_1.SystemProgram.programId,
|
|
37
51
|
};
|
|
38
52
|
const instruction = await program.methods
|
|
39
|
-
.claimSignupRewards(options.seasonNumber, options.tier)
|
|
53
|
+
.claimSignupRewards(options.seasonNumber, options.tier, launchpad ? options.minSolOutLamports ?? new anchor_1.BN(0) : new anchor_1.BN(0))
|
|
40
54
|
.accounts(accounts)
|
|
41
55
|
.instruction();
|
|
42
56
|
const feePayer = (0, signerHelpers_1.getDefaultFeePayer)(options.feePayer);
|
|
@@ -47,3 +61,23 @@ async function claimSignupRewards(options) {
|
|
|
47
61
|
pdas,
|
|
48
62
|
};
|
|
49
63
|
}
|
|
64
|
+
/**
|
|
65
|
+
* Convenience wrapper: classic (non-launchpad) claimSignupRewards.
|
|
66
|
+
* App code never passes nullable optional accounts.
|
|
67
|
+
*/
|
|
68
|
+
async function claimSignupRewardsClassic(options) {
|
|
69
|
+
return claimSignupRewards({
|
|
70
|
+
...options,
|
|
71
|
+
launchpad: false,
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Convenience wrapper: launchpad claimSignupRewards (SOL payout).
|
|
76
|
+
* App code never passes nullable optional accounts.
|
|
77
|
+
*/
|
|
78
|
+
async function claimSignupRewardsLaunchpad(options) {
|
|
79
|
+
return claimSignupRewards({
|
|
80
|
+
...options,
|
|
81
|
+
launchpad: true,
|
|
82
|
+
});
|
|
83
|
+
}
|
|
@@ -16,6 +16,7 @@ type ClaimWindowRewardsPdas = {
|
|
|
16
16
|
userWindowParticipation: PublicKey;
|
|
17
17
|
seasonMembership: PublicKey;
|
|
18
18
|
seasonDepositVault: PublicKey;
|
|
19
|
+
moonpoolTreasury: PublicKey;
|
|
19
20
|
};
|
|
20
21
|
/**
|
|
21
22
|
* Options for claimWindowRewards instruction
|
|
@@ -23,11 +24,23 @@ type ClaimWindowRewardsPdas = {
|
|
|
23
24
|
export interface ClaimWindowRewardsOptions {
|
|
24
25
|
connection: Connection;
|
|
25
26
|
user: PublicKey;
|
|
26
|
-
|
|
27
|
+
/** User MIZD ATA (required when claiming in non-launchpad mode). */
|
|
28
|
+
userTokenAccount?: PublicKey;
|
|
27
29
|
seasonNumber: BN;
|
|
30
|
+
/** Token mint this season is scoped to (used for PDA derivation). Defaults to MIZD_TOKEN_MINT. */
|
|
31
|
+
tokenMint?: PublicKey;
|
|
28
32
|
windowNumber: WindowNumberLike;
|
|
29
33
|
/** Tier number: 0=copper, 1=silver, 2=gold, 3=platinum, 4=mithril */
|
|
30
34
|
tier: TierNumber;
|
|
35
|
+
/** If true, claim uses launchpad mode (SOL payout; token accounts can be omitted). */
|
|
36
|
+
launchpad?: boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Launchpad-only: minimum SOL out (lamports) for the virtual-token sell.
|
|
39
|
+
* Use this to protect against unfavorable price movement between quote and execution.
|
|
40
|
+
*
|
|
41
|
+
* Defaults to 0 (no sell-side slippage protection).
|
|
42
|
+
*/
|
|
43
|
+
minSolOutLamports?: BN;
|
|
31
44
|
feePayer?: PublicKey;
|
|
32
45
|
currentAccounts?: {
|
|
33
46
|
seasonSettings?: SeasonSettings;
|
|
@@ -37,6 +50,24 @@ export interface ClaimWindowRewardsOptions {
|
|
|
37
50
|
seasonMembership?: SeasonMembership;
|
|
38
51
|
};
|
|
39
52
|
}
|
|
53
|
+
/**
|
|
54
|
+
* Options for the classic (non-launchpad) claimWindowRewards wrapper.
|
|
55
|
+
* Requires the user's MIZD ATA.
|
|
56
|
+
*/
|
|
57
|
+
export type ClaimWindowRewardsClassicOptions = Omit<ClaimWindowRewardsOptions, "launchpad" | "minSolOutLamports"> & {
|
|
58
|
+
launchpad?: never;
|
|
59
|
+
userTokenAccount: PublicKey;
|
|
60
|
+
minSolOutLamports?: never;
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* Options for the launchpad claimWindowRewards wrapper.
|
|
64
|
+
* No token accounts are required (SOL payout).
|
|
65
|
+
*/
|
|
66
|
+
export type ClaimWindowRewardsLaunchpadOptions = Omit<ClaimWindowRewardsOptions, "launchpad" | "userTokenAccount"> & {
|
|
67
|
+
launchpad?: never;
|
|
68
|
+
userTokenAccount?: never;
|
|
69
|
+
minSolOutLamports?: BN;
|
|
70
|
+
};
|
|
40
71
|
/**
|
|
41
72
|
* Claim window rewards
|
|
42
73
|
*
|
|
@@ -48,4 +79,14 @@ export interface ClaimWindowRewardsOptions {
|
|
|
48
79
|
* @returns Instructions, signers, and optimistically updated accounts
|
|
49
80
|
*/
|
|
50
81
|
export declare function claimWindowRewards(options: ClaimWindowRewardsOptions): Promise<StandardInstructionResultWithPdas<ClaimWindowRewardsPdas, ClaimWindowRewardsUpdatedAccounts>>;
|
|
82
|
+
/**
|
|
83
|
+
* Convenience wrapper: classic (non-launchpad) claimWindowRewards.
|
|
84
|
+
* App code never passes nullable optional accounts.
|
|
85
|
+
*/
|
|
86
|
+
export declare function claimWindowRewardsClassic(options: ClaimWindowRewardsClassicOptions): Promise<StandardInstructionResultWithPdas<ClaimWindowRewardsPdas, ClaimWindowRewardsUpdatedAccounts>>;
|
|
87
|
+
/**
|
|
88
|
+
* Convenience wrapper: launchpad claimWindowRewards (SOL payout).
|
|
89
|
+
* App code never passes nullable optional accounts.
|
|
90
|
+
*/
|
|
91
|
+
export declare function claimWindowRewardsLaunchpad(options: ClaimWindowRewardsLaunchpadOptions): Promise<StandardInstructionResultWithPdas<ClaimWindowRewardsPdas, ClaimWindowRewardsUpdatedAccounts>>;
|
|
51
92
|
export {};
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.claimWindowRewards = claimWindowRewards;
|
|
4
|
+
exports.claimWindowRewardsClassic = claimWindowRewardsClassic;
|
|
5
|
+
exports.claimWindowRewardsLaunchpad = claimWindowRewardsLaunchpad;
|
|
4
6
|
const anchor_1 = require("@coral-xyz/anchor");
|
|
5
7
|
const spl_token_1 = require("@solana/spl-token");
|
|
8
|
+
const web3_js_1 = require("@solana/web3.js");
|
|
6
9
|
const pdaManager_1 = require("../utils/pdaManager");
|
|
7
10
|
const constants_1 = require("../utils/constants");
|
|
8
11
|
const programHelpers_1 = require("../utils/programHelpers");
|
|
@@ -22,11 +25,14 @@ const conversions_1 = require("../utils/conversions");
|
|
|
22
25
|
async function claimWindowRewards(options) {
|
|
23
26
|
const program = (0, programHelpers_1.getProgram)(options.connection);
|
|
24
27
|
const windowNumber = (0, conversions_1.toWindowNumberBn)(options.windowNumber);
|
|
28
|
+
const tokenMint = options.tokenMint ?? constants_1.MIZD_TOKEN_MINT;
|
|
29
|
+
const launchpad = options.launchpad ?? false;
|
|
25
30
|
const pdas = pdaManager_1.PDAManager.deriveClaimWindowRewardsPdas({
|
|
26
31
|
user: options.user,
|
|
27
32
|
seasonNumber: options.seasonNumber,
|
|
28
33
|
windowNumber,
|
|
29
34
|
tier: options.tier,
|
|
35
|
+
tokenMint,
|
|
30
36
|
});
|
|
31
37
|
const accounts = {
|
|
32
38
|
seasonSettings: pdas.seasonSettings,
|
|
@@ -34,15 +40,23 @@ async function claimWindowRewards(options) {
|
|
|
34
40
|
rewardWindow: pdas.rewardWindow,
|
|
35
41
|
userWindowParticipation: pdas.userWindowParticipation,
|
|
36
42
|
seasonMembership: pdas.seasonMembership,
|
|
37
|
-
|
|
43
|
+
moonpool: launchpad ? pdas.moonpool : null,
|
|
44
|
+
moonpoolTreasury: launchpad ? pdas.moonpoolTreasury : null,
|
|
45
|
+
seasonDepositVault: launchpad ? null : pdas.seasonDepositVault,
|
|
38
46
|
mizdMint: constants_1.MIZD_TOKEN_MINT,
|
|
39
|
-
|
|
47
|
+
tokenMint,
|
|
48
|
+
userTokenAccount: launchpad ? null : options.userTokenAccount ?? null,
|
|
40
49
|
user: options.user,
|
|
50
|
+
associatedTokenProgram: spl_token_1.ASSOCIATED_TOKEN_PROGRAM_ID,
|
|
41
51
|
tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
|
|
52
|
+
systemProgram: web3_js_1.SystemProgram.programId,
|
|
42
53
|
};
|
|
54
|
+
if (!launchpad && !accounts.userTokenAccount) {
|
|
55
|
+
throw new Error("userTokenAccount is required when launchpad=false");
|
|
56
|
+
}
|
|
43
57
|
const instruction = await program.methods
|
|
44
58
|
// Anchor expects BN for u64 args.
|
|
45
|
-
.claimWindowRewards(options.seasonNumber, windowNumber, options.tier)
|
|
59
|
+
.claimWindowRewards(options.seasonNumber, windowNumber, options.tier, launchpad ? options.minSolOutLamports ?? new anchor_1.BN(0) : new anchor_1.BN(0))
|
|
46
60
|
.accounts(accounts)
|
|
47
61
|
.instruction();
|
|
48
62
|
const feePayer = (0, signerHelpers_1.getDefaultFeePayer)(options.feePayer);
|
|
@@ -50,6 +64,14 @@ async function claimWindowRewards(options) {
|
|
|
50
64
|
// OPTIMISTIC UPDATES
|
|
51
65
|
const curr = options.currentAccounts || {};
|
|
52
66
|
let updatedAccounts = undefined;
|
|
67
|
+
if (launchpad) {
|
|
68
|
+
// Launchpad mode payout depends on pool reserves; SDK does not compute optimistic SOL here.
|
|
69
|
+
return {
|
|
70
|
+
instructions: [instruction],
|
|
71
|
+
signers,
|
|
72
|
+
pdas,
|
|
73
|
+
};
|
|
74
|
+
}
|
|
53
75
|
if (curr.rewardWindow && curr.seasonSettings && curr.season) {
|
|
54
76
|
const idx = (0, conversions_1.assertWindowIndex)(windowNumber);
|
|
55
77
|
const eligibleStakeX = curr.season.eligibleStakePerWindow[idx] ?? new anchor_1.BN(0);
|
|
@@ -84,3 +106,25 @@ async function claimWindowRewards(options) {
|
|
|
84
106
|
...(updatedAccounts && { updatedAccounts }),
|
|
85
107
|
};
|
|
86
108
|
}
|
|
109
|
+
/**
|
|
110
|
+
* Convenience wrapper: classic (non-launchpad) claimWindowRewards.
|
|
111
|
+
* App code never passes nullable optional accounts.
|
|
112
|
+
*/
|
|
113
|
+
async function claimWindowRewardsClassic(options) {
|
|
114
|
+
return claimWindowRewards({
|
|
115
|
+
...options,
|
|
116
|
+
launchpad: false,
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Convenience wrapper: launchpad claimWindowRewards (SOL payout).
|
|
121
|
+
* App code never passes nullable optional accounts.
|
|
122
|
+
*/
|
|
123
|
+
async function claimWindowRewardsLaunchpad(options) {
|
|
124
|
+
// IMPORTANT: With `exactOptionalPropertyTypes`, we must OMIT optional props (not set them to `undefined`).
|
|
125
|
+
const { userTokenAccount: _ignored, ...rest } = options;
|
|
126
|
+
return claimWindowRewards({
|
|
127
|
+
...rest,
|
|
128
|
+
launchpad: true,
|
|
129
|
+
});
|
|
130
|
+
}
|
|
@@ -18,6 +18,8 @@ export interface ConfirmedPostOnXOptions {
|
|
|
18
18
|
adminKey: PublicKey;
|
|
19
19
|
user: PublicKey;
|
|
20
20
|
seasonNumber: BN;
|
|
21
|
+
/** Token mint this season is scoped to (used for PDA derivation). Defaults to MIZD_TOKEN_MINT. */
|
|
22
|
+
tokenMint?: PublicKey;
|
|
21
23
|
/** Tier number: 0=copper, 1=silver, 2=gold, 3=platinum, 4=mithril */
|
|
22
24
|
tier: TierNumber;
|
|
23
25
|
windowNumber: WindowNumberLike;
|