proof-of-take-sdk 5.0.13 → 5.0.15
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/idl/proof_of_take.json +2 -1
- package/dist/index.d.ts +6 -2
- package/dist/index.js +7 -7
- package/dist/instructions/createMoonpool.d.ts +65 -0
- package/dist/instructions/createMoonpool.js +96 -0
- package/dist/instructions/joinMoonpoolSeason.d.ts +59 -0
- package/dist/instructions/joinMoonpoolSeason.js +76 -0
- package/dist/instructions/joinSunpool.d.ts +60 -0
- package/dist/instructions/joinSunpool.js +92 -0
- package/dist/types/proof_of_take.d.ts +2 -1
- package/package.json +1 -1
- package/dist/instructions/joinSeason.d.ts +0 -252
- package/dist/instructions/joinSeason.js +0 -331
|
@@ -2010,7 +2010,8 @@
|
|
|
2010
2010
|
{
|
|
2011
2011
|
"name": "token_mint",
|
|
2012
2012
|
"docs": [
|
|
2013
|
-
"Token mint this season is scoped to (used for PDA derivation)."
|
|
2013
|
+
"Token mint this season is scoped to (used for PDA derivation).",
|
|
2014
|
+
"Supports both SPL Token and Token-2022 mints via InterfaceAccount."
|
|
2014
2015
|
]
|
|
2015
2016
|
},
|
|
2016
2017
|
{
|
package/dist/index.d.ts
CHANGED
|
@@ -11,8 +11,12 @@ 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 { createMoonpool
|
|
15
|
-
export type { CreateMoonpoolOptions,
|
|
14
|
+
export { createMoonpool } from "./instructions/createMoonpool";
|
|
15
|
+
export type { CreateMoonpoolOptions, CreateMoonpoolPdas, CreateMoonpoolMeta, CreateMoonpoolUpdatedAccounts, } from "./instructions/createMoonpool";
|
|
16
|
+
export { joinMoonpoolSeason } from "./instructions/joinMoonpoolSeason";
|
|
17
|
+
export type { JoinMoonpoolSeasonOptions, JoinMoonpoolSeasonPdas, JoinMoonpoolSeasonUpdatedAccounts, } from "./instructions/joinMoonpoolSeason";
|
|
18
|
+
export { joinSunpool } from "./instructions/joinSunpool";
|
|
19
|
+
export type { JoinSunpoolOptions, JoinSunpoolPdas, JoinSunpoolUpdatedAccounts, } from "./instructions/joinSunpool";
|
|
16
20
|
export { confirmedPostOnX } from "./instructions/confirmedPostOnX";
|
|
17
21
|
export type { ConfirmedPostOnXOptions } from "./instructions/confirmedPostOnX";
|
|
18
22
|
export { claimWindowRewards, claimWindowRewardsClassic, claimWindowRewardsLaunchpad, } from "./instructions/claimWindowRewards";
|
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.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.
|
|
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.joinSunpool = exports.joinMoonpoolSeason = exports.createMoonpool = 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
|
|
@@ -41,12 +41,12 @@ Object.defineProperty(exports, "initializeSeasonSettings", { enumerable: true, g
|
|
|
41
41
|
var initializeSeasonVault_1 = require("./instructions/initializeSeasonVault");
|
|
42
42
|
Object.defineProperty(exports, "initializeSeasonVault", { enumerable: true, get: function () { return initializeSeasonVault_1.initializeSeasonVault; } });
|
|
43
43
|
// Season membership instructions
|
|
44
|
-
var
|
|
45
|
-
Object.defineProperty(exports, "createMoonpool", { enumerable: true, get: function () { return
|
|
46
|
-
|
|
47
|
-
Object.defineProperty(exports, "
|
|
48
|
-
|
|
49
|
-
Object.defineProperty(exports, "
|
|
44
|
+
var createMoonpool_1 = require("./instructions/createMoonpool");
|
|
45
|
+
Object.defineProperty(exports, "createMoonpool", { enumerable: true, get: function () { return createMoonpool_1.createMoonpool; } });
|
|
46
|
+
var joinMoonpoolSeason_1 = require("./instructions/joinMoonpoolSeason");
|
|
47
|
+
Object.defineProperty(exports, "joinMoonpoolSeason", { enumerable: true, get: function () { return joinMoonpoolSeason_1.joinMoonpoolSeason; } });
|
|
48
|
+
var joinSunpool_1 = require("./instructions/joinSunpool");
|
|
49
|
+
Object.defineProperty(exports, "joinSunpool", { enumerable: true, get: function () { return joinSunpool_1.joinSunpool; } });
|
|
50
50
|
var confirmedPostOnX_1 = require("./instructions/confirmedPostOnX");
|
|
51
51
|
Object.defineProperty(exports, "confirmedPostOnX", { enumerable: true, get: function () { return confirmedPostOnX_1.confirmedPostOnX; } });
|
|
52
52
|
var claimWindowRewards_1 = require("./instructions/claimWindowRewards");
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { BN } from "@coral-xyz/anchor";
|
|
2
|
+
import { Connection, Keypair, PublicKey } from "@solana/web3.js";
|
|
3
|
+
import { Season, SeasonMembership, SeasonSettings, TierNumber } from "../types";
|
|
4
|
+
import { StandardInstructionResultWithPdas } from "../types/instructionResults";
|
|
5
|
+
/**
|
|
6
|
+
* Options for createMoonpool instruction (creating a new Moonpool + first join)
|
|
7
|
+
*/
|
|
8
|
+
export interface CreateMoonpoolOptions {
|
|
9
|
+
connection: Connection;
|
|
10
|
+
user: PublicKey;
|
|
11
|
+
seasonNumber: BN;
|
|
12
|
+
/** Tier number: 0=copper, 1=silver, 2=gold, 3=platinum, 4=mithril */
|
|
13
|
+
tier: TierNumber;
|
|
14
|
+
/** Optional referrer (PublicKey.default means no referrer) */
|
|
15
|
+
referrer?: PublicKey;
|
|
16
|
+
/** If true, root admin funds the SOL for the join. */
|
|
17
|
+
star?: boolean;
|
|
18
|
+
/** Hard cap in lamports for slippage protection. */
|
|
19
|
+
maxSolInLamports?: BN;
|
|
20
|
+
/** Expected SOL in lamports for bps slippage protection. */
|
|
21
|
+
expectedSolInLamports?: BN;
|
|
22
|
+
/** Max slippage in basis points (0..=5000). */
|
|
23
|
+
maxSlippageBps?: number;
|
|
24
|
+
/** Star flag prompt: a short message (max 33 chars). REQUIRED for new Moonpool. */
|
|
25
|
+
starFlagPrompt: string;
|
|
26
|
+
/** Token symbol (max 4 chars). REQUIRED for new Moonpool. */
|
|
27
|
+
symbol: string;
|
|
28
|
+
/** Optional injected timestamp (seconds) for optimistic state calculation */
|
|
29
|
+
now?: BN;
|
|
30
|
+
feePayer?: PublicKey;
|
|
31
|
+
currentAccounts?: {
|
|
32
|
+
seasonSettings?: SeasonSettings;
|
|
33
|
+
season?: Season;
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
export type CreateMoonpoolPdas = {
|
|
37
|
+
seasonSettings: PublicKey;
|
|
38
|
+
season: PublicKey;
|
|
39
|
+
seasonMembership: PublicKey;
|
|
40
|
+
moonpool: PublicKey;
|
|
41
|
+
moonpoolTreasury: PublicKey;
|
|
42
|
+
launchpadTokenMint: PublicKey;
|
|
43
|
+
};
|
|
44
|
+
export type CreateMoonpoolMeta = {
|
|
45
|
+
/** The keypair used for the launchpad mint (always generated for createMoonpool) */
|
|
46
|
+
launchpadTokenMintKeypair: Keypair;
|
|
47
|
+
};
|
|
48
|
+
export type CreateMoonpoolUpdatedAccounts = {
|
|
49
|
+
seasonSettings?: SeasonSettings;
|
|
50
|
+
season?: Season;
|
|
51
|
+
seasonMembership?: SeasonMembership;
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* Create a new Moonpool and perform the first launchpad join.
|
|
55
|
+
*
|
|
56
|
+
* This instruction:
|
|
57
|
+
* - Creates a new launchpad_token_mint (SPL Token-2022)
|
|
58
|
+
* - Initializes the Moonpool
|
|
59
|
+
* - Initializes the Season (scoped to launchpad_token_mint)
|
|
60
|
+
* - Creates the first SeasonMembership
|
|
61
|
+
*
|
|
62
|
+
* @param options - CreateMoonpool options
|
|
63
|
+
* @returns Instructions, signers, PDAs, and metadata with the generated keypair
|
|
64
|
+
*/
|
|
65
|
+
export declare function createMoonpool(options: CreateMoonpoolOptions): Promise<StandardInstructionResultWithPdas<CreateMoonpoolPdas, CreateMoonpoolUpdatedAccounts, CreateMoonpoolMeta>>;
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createMoonpool = createMoonpool;
|
|
4
|
+
const anchor_1 = require("@coral-xyz/anchor");
|
|
5
|
+
const web3_js_1 = require("@solana/web3.js");
|
|
6
|
+
const spl_token_1 = require("@solana/spl-token");
|
|
7
|
+
const pdaManager_1 = require("../utils/pdaManager");
|
|
8
|
+
const pdas_1 = require("../utils/pdas");
|
|
9
|
+
const constants_1 = require("../utils/constants");
|
|
10
|
+
const programHelpers_1 = require("../utils/programHelpers");
|
|
11
|
+
const signerHelpers_1 = require("../utils/signerHelpers");
|
|
12
|
+
/**
|
|
13
|
+
* Create a new Moonpool and perform the first launchpad join.
|
|
14
|
+
*
|
|
15
|
+
* This instruction:
|
|
16
|
+
* - Creates a new launchpad_token_mint (SPL Token-2022)
|
|
17
|
+
* - Initializes the Moonpool
|
|
18
|
+
* - Initializes the Season (scoped to launchpad_token_mint)
|
|
19
|
+
* - Creates the first SeasonMembership
|
|
20
|
+
*
|
|
21
|
+
* @param options - CreateMoonpool options
|
|
22
|
+
* @returns Instructions, signers, PDAs, and metadata with the generated keypair
|
|
23
|
+
*/
|
|
24
|
+
async function createMoonpool(options) {
|
|
25
|
+
const program = (0, programHelpers_1.getProgram)(options.connection);
|
|
26
|
+
// Validate required fields
|
|
27
|
+
if (!options.starFlagPrompt || options.starFlagPrompt.length === 0) {
|
|
28
|
+
throw new Error("starFlagPrompt is required when creating a new Moonpool");
|
|
29
|
+
}
|
|
30
|
+
if (options.starFlagPrompt.length > 33) {
|
|
31
|
+
throw new Error("starFlagPrompt cannot exceed 33 characters");
|
|
32
|
+
}
|
|
33
|
+
if (!options.symbol || options.symbol.length === 0) {
|
|
34
|
+
throw new Error("symbol is required when creating a new Moonpool");
|
|
35
|
+
}
|
|
36
|
+
if (options.symbol.length > 4) {
|
|
37
|
+
throw new Error("symbol cannot exceed 4 characters");
|
|
38
|
+
}
|
|
39
|
+
// Generate a new keypair for the launchpad token mint
|
|
40
|
+
const launchpadTokenMintKeypair = web3_js_1.Keypair.generate();
|
|
41
|
+
const launchpadTokenMintPubkey = launchpadTokenMintKeypair.publicKey;
|
|
42
|
+
console.log("[createMoonpool] Generated new launchpad mint keypair:", launchpadTokenMintPubkey.toString());
|
|
43
|
+
// Derive PDAs with the new launchpadTokenMint
|
|
44
|
+
const pdasBase = pdaManager_1.PDAManager.deriveJoinSeasonPdas({
|
|
45
|
+
user: options.user,
|
|
46
|
+
seasonNumber: options.seasonNumber,
|
|
47
|
+
tier: options.tier,
|
|
48
|
+
tokenMint: constants_1.MIZD_TOKEN_MINT,
|
|
49
|
+
launchpadTokenMint: launchpadTokenMintPubkey,
|
|
50
|
+
});
|
|
51
|
+
// Derive Moonpool and Treasury PDAs
|
|
52
|
+
const [moonpoolPda] = (0, pdas_1.getMoonpoolPda)(launchpadTokenMintPubkey);
|
|
53
|
+
const [moonpoolTreasuryPda] = (0, pdas_1.getMoonpoolTreasuryPda)(launchpadTokenMintPubkey);
|
|
54
|
+
const pdas = {
|
|
55
|
+
seasonSettings: pdasBase.seasonSettings,
|
|
56
|
+
season: pdasBase.season,
|
|
57
|
+
seasonMembership: pdasBase.seasonMembership,
|
|
58
|
+
moonpool: moonpoolPda,
|
|
59
|
+
moonpoolTreasury: moonpoolTreasuryPda,
|
|
60
|
+
launchpadTokenMint: launchpadTokenMintPubkey,
|
|
61
|
+
};
|
|
62
|
+
const referrer = options.referrer ?? web3_js_1.PublicKey.default;
|
|
63
|
+
const accounts = {
|
|
64
|
+
seasonSettings: pdas.seasonSettings,
|
|
65
|
+
season: pdas.season,
|
|
66
|
+
seasonMembership: pdas.seasonMembership,
|
|
67
|
+
moonpool: moonpoolPda,
|
|
68
|
+
moonpoolTreasury: moonpoolTreasuryPda,
|
|
69
|
+
launchpadTokenMint: launchpadTokenMintPubkey,
|
|
70
|
+
rootAdmin: constants_1.ADMIN_PUBLIC_KEY,
|
|
71
|
+
user: options.user,
|
|
72
|
+
token2022Program: spl_token_1.TOKEN_2022_PROGRAM_ID,
|
|
73
|
+
systemProgram: web3_js_1.SystemProgram.programId,
|
|
74
|
+
};
|
|
75
|
+
const instruction = await program.methods
|
|
76
|
+
.createMoonpool(options.seasonNumber, options.tier, referrer, options.star ?? false, options.maxSolInLamports ?? new anchor_1.BN(0), options.expectedSolInLamports ?? new anchor_1.BN(0), options.maxSlippageBps ?? 0, options.starFlagPrompt, options.symbol)
|
|
77
|
+
.accounts(accounts)
|
|
78
|
+
.instruction();
|
|
79
|
+
// For star joins, root admin pays
|
|
80
|
+
const feePayer = options.star ? constants_1.ADMIN_PUBLIC_KEY : (0, signerHelpers_1.getDefaultFeePayer)(options.feePayer);
|
|
81
|
+
// Build signers array - must include the launchpad mint keypair
|
|
82
|
+
const signersList = [
|
|
83
|
+
(0, signerHelpers_1.asAdminSigner)(constants_1.ADMIN_PUBLIC_KEY),
|
|
84
|
+
(0, signerHelpers_1.asUserSigner)(options.user),
|
|
85
|
+
{ publicKey: launchpadTokenMintKeypair.publicKey, role: "payer" },
|
|
86
|
+
];
|
|
87
|
+
const signers = (0, signerHelpers_1.buildSigners)(signersList, feePayer);
|
|
88
|
+
return {
|
|
89
|
+
instructions: [instruction],
|
|
90
|
+
signers,
|
|
91
|
+
pdas,
|
|
92
|
+
metadata: {
|
|
93
|
+
launchpadTokenMintKeypair,
|
|
94
|
+
},
|
|
95
|
+
};
|
|
96
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { BN } from "@coral-xyz/anchor";
|
|
2
|
+
import { Connection, PublicKey } from "@solana/web3.js";
|
|
3
|
+
import { Season, SeasonMembership, SeasonSettings, TierNumber } from "../types";
|
|
4
|
+
import { StandardInstructionResultWithPdas } from "../types/instructionResults";
|
|
5
|
+
/**
|
|
6
|
+
* Options for joinMoonpoolSeason instruction (joining an existing Moonpool)
|
|
7
|
+
*/
|
|
8
|
+
export interface JoinMoonpoolSeasonOptions {
|
|
9
|
+
connection: Connection;
|
|
10
|
+
user: PublicKey;
|
|
11
|
+
seasonNumber: BN;
|
|
12
|
+
/** The launchpad token mint of the Moonpool to join. REQUIRED. */
|
|
13
|
+
launchpadTokenMint: PublicKey;
|
|
14
|
+
/** Tier number: 0=copper, 1=silver, 2=gold, 3=platinum, 4=mithril */
|
|
15
|
+
tier: TierNumber;
|
|
16
|
+
/** Optional referrer (PublicKey.default means no referrer) */
|
|
17
|
+
referrer?: PublicKey;
|
|
18
|
+
/** If true, root admin funds the SOL for the join. */
|
|
19
|
+
star?: boolean;
|
|
20
|
+
/** Hard cap in lamports for slippage protection. */
|
|
21
|
+
maxSolInLamports?: BN;
|
|
22
|
+
/** Expected SOL in lamports for bps slippage protection. */
|
|
23
|
+
expectedSolInLamports?: BN;
|
|
24
|
+
/** Max slippage in basis points (0..=5000). */
|
|
25
|
+
maxSlippageBps?: number;
|
|
26
|
+
/** Optional injected timestamp (seconds) for optimistic state calculation */
|
|
27
|
+
now?: BN;
|
|
28
|
+
feePayer?: PublicKey;
|
|
29
|
+
currentAccounts?: {
|
|
30
|
+
seasonSettings?: SeasonSettings;
|
|
31
|
+
season?: Season;
|
|
32
|
+
moonpool?: any;
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
export type JoinMoonpoolSeasonPdas = {
|
|
36
|
+
seasonSettings: PublicKey;
|
|
37
|
+
season: PublicKey;
|
|
38
|
+
seasonMembership: PublicKey;
|
|
39
|
+
moonpool: PublicKey;
|
|
40
|
+
moonpoolTreasury: PublicKey;
|
|
41
|
+
launchpadTokenMint: PublicKey;
|
|
42
|
+
};
|
|
43
|
+
export type JoinMoonpoolSeasonUpdatedAccounts = {
|
|
44
|
+
seasonSettings?: SeasonSettings;
|
|
45
|
+
season?: Season;
|
|
46
|
+
seasonMembership?: SeasonMembership;
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* Join an existing Moonpool season.
|
|
50
|
+
*
|
|
51
|
+
* This instruction:
|
|
52
|
+
* - Requires Moonpool to already exist
|
|
53
|
+
* - Lazily initializes Season if needed (for new seasons with existing Moonpool)
|
|
54
|
+
* - Creates new SeasonMembership
|
|
55
|
+
*
|
|
56
|
+
* @param options - JoinMoonpoolSeason options
|
|
57
|
+
* @returns Instructions, signers, and PDAs
|
|
58
|
+
*/
|
|
59
|
+
export declare function joinMoonpoolSeason(options: JoinMoonpoolSeasonOptions): Promise<StandardInstructionResultWithPdas<JoinMoonpoolSeasonPdas, JoinMoonpoolSeasonUpdatedAccounts>>;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.joinMoonpoolSeason = joinMoonpoolSeason;
|
|
4
|
+
const anchor_1 = require("@coral-xyz/anchor");
|
|
5
|
+
const web3_js_1 = require("@solana/web3.js");
|
|
6
|
+
const spl_token_1 = require("@solana/spl-token");
|
|
7
|
+
const pdaManager_1 = require("../utils/pdaManager");
|
|
8
|
+
const pdas_1 = require("../utils/pdas");
|
|
9
|
+
const constants_1 = require("../utils/constants");
|
|
10
|
+
const programHelpers_1 = require("../utils/programHelpers");
|
|
11
|
+
const signerHelpers_1 = require("../utils/signerHelpers");
|
|
12
|
+
/**
|
|
13
|
+
* Join an existing Moonpool season.
|
|
14
|
+
*
|
|
15
|
+
* This instruction:
|
|
16
|
+
* - Requires Moonpool to already exist
|
|
17
|
+
* - Lazily initializes Season if needed (for new seasons with existing Moonpool)
|
|
18
|
+
* - Creates new SeasonMembership
|
|
19
|
+
*
|
|
20
|
+
* @param options - JoinMoonpoolSeason options
|
|
21
|
+
* @returns Instructions, signers, and PDAs
|
|
22
|
+
*/
|
|
23
|
+
async function joinMoonpoolSeason(options) {
|
|
24
|
+
const program = (0, programHelpers_1.getProgram)(options.connection);
|
|
25
|
+
const launchpadTokenMintPubkey = options.launchpadTokenMint;
|
|
26
|
+
console.log("[joinMoonpoolSeason] Using existing launchpadTokenMint:", launchpadTokenMintPubkey.toString());
|
|
27
|
+
// Derive PDAs with the existing launchpadTokenMint
|
|
28
|
+
const pdasBase = pdaManager_1.PDAManager.deriveJoinSeasonPdas({
|
|
29
|
+
user: options.user,
|
|
30
|
+
seasonNumber: options.seasonNumber,
|
|
31
|
+
tier: options.tier,
|
|
32
|
+
tokenMint: constants_1.MIZD_TOKEN_MINT,
|
|
33
|
+
launchpadTokenMint: launchpadTokenMintPubkey,
|
|
34
|
+
});
|
|
35
|
+
// Derive Moonpool and Treasury PDAs
|
|
36
|
+
const [moonpoolPda] = (0, pdas_1.getMoonpoolPda)(launchpadTokenMintPubkey);
|
|
37
|
+
const [moonpoolTreasuryPda] = (0, pdas_1.getMoonpoolTreasuryPda)(launchpadTokenMintPubkey);
|
|
38
|
+
const pdas = {
|
|
39
|
+
seasonSettings: pdasBase.seasonSettings,
|
|
40
|
+
season: pdasBase.season,
|
|
41
|
+
seasonMembership: pdasBase.seasonMembership,
|
|
42
|
+
moonpool: moonpoolPda,
|
|
43
|
+
moonpoolTreasury: moonpoolTreasuryPda,
|
|
44
|
+
launchpadTokenMint: launchpadTokenMintPubkey,
|
|
45
|
+
};
|
|
46
|
+
const referrer = options.referrer ?? web3_js_1.PublicKey.default;
|
|
47
|
+
const accounts = {
|
|
48
|
+
seasonSettings: pdas.seasonSettings,
|
|
49
|
+
season: pdas.season,
|
|
50
|
+
seasonMembership: pdas.seasonMembership,
|
|
51
|
+
moonpool: moonpoolPda,
|
|
52
|
+
moonpoolTreasury: moonpoolTreasuryPda,
|
|
53
|
+
launchpadTokenMint: launchpadTokenMintPubkey,
|
|
54
|
+
rootAdmin: constants_1.ADMIN_PUBLIC_KEY,
|
|
55
|
+
user: options.user,
|
|
56
|
+
token2022Program: spl_token_1.TOKEN_2022_PROGRAM_ID,
|
|
57
|
+
systemProgram: web3_js_1.SystemProgram.programId,
|
|
58
|
+
};
|
|
59
|
+
const instruction = await program.methods
|
|
60
|
+
.joinMoonpoolSeason(options.seasonNumber, options.tier, referrer, options.star ?? false, options.maxSolInLamports ?? new anchor_1.BN(0), options.expectedSolInLamports ?? new anchor_1.BN(0), options.maxSlippageBps ?? 0)
|
|
61
|
+
.accounts(accounts)
|
|
62
|
+
.instruction();
|
|
63
|
+
// For star joins, root admin pays
|
|
64
|
+
const feePayer = options.star ? constants_1.ADMIN_PUBLIC_KEY : (0, signerHelpers_1.getDefaultFeePayer)(options.feePayer);
|
|
65
|
+
// Build signers array
|
|
66
|
+
const signersList = [
|
|
67
|
+
(0, signerHelpers_1.asAdminSigner)(constants_1.ADMIN_PUBLIC_KEY),
|
|
68
|
+
(0, signerHelpers_1.asUserSigner)(options.user),
|
|
69
|
+
];
|
|
70
|
+
const signers = (0, signerHelpers_1.buildSigners)(signersList, feePayer);
|
|
71
|
+
return {
|
|
72
|
+
instructions: [instruction],
|
|
73
|
+
signers,
|
|
74
|
+
pdas,
|
|
75
|
+
};
|
|
76
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { BN } from "@coral-xyz/anchor";
|
|
2
|
+
import { Connection, PublicKey } from "@solana/web3.js";
|
|
3
|
+
import { Season, SeasonMembership, SeasonSettings, TierNumber } from "../types";
|
|
4
|
+
import { StandardInstructionResultWithPdas } from "../types/instructionResults";
|
|
5
|
+
/**
|
|
6
|
+
* Options for joinSunpool instruction (classic mode with MIZD)
|
|
7
|
+
*/
|
|
8
|
+
export interface JoinSunpoolOptions {
|
|
9
|
+
connection: Connection;
|
|
10
|
+
user: PublicKey;
|
|
11
|
+
seasonNumber: BN;
|
|
12
|
+
/** Token mint this season is scoped to. Defaults to MIZD_TOKEN_MINT. */
|
|
13
|
+
tokenMint?: PublicKey;
|
|
14
|
+
/** Tier number: 0=copper, 1=silver, 2=gold, 3=platinum, 4=mithril */
|
|
15
|
+
tier: TierNumber;
|
|
16
|
+
/** Optional referrer (PublicKey.default means no referrer) */
|
|
17
|
+
referrer?: PublicKey;
|
|
18
|
+
/** Referrer's tier (required if referrer is provided) */
|
|
19
|
+
referrerTier?: TierNumber;
|
|
20
|
+
/** If true, root admin funds the MIZD for the join. */
|
|
21
|
+
star?: boolean;
|
|
22
|
+
/** Star flag prompt (max 33 chars). Required for first Sunpool initialization. */
|
|
23
|
+
starFlagPrompt?: string;
|
|
24
|
+
/** Token symbol (max 4 chars). Required for first Sunpool initialization. */
|
|
25
|
+
symbol?: string;
|
|
26
|
+
/** Optional injected timestamp (seconds) for optimistic state calculation */
|
|
27
|
+
now?: BN;
|
|
28
|
+
feePayer?: PublicKey;
|
|
29
|
+
currentAccounts?: {
|
|
30
|
+
seasonSettings?: SeasonSettings;
|
|
31
|
+
season?: Season;
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
export type JoinSunpoolPdas = {
|
|
35
|
+
seasonSettings: PublicKey;
|
|
36
|
+
season: PublicKey;
|
|
37
|
+
seasonMembership: PublicKey;
|
|
38
|
+
sunpool: PublicKey;
|
|
39
|
+
seasonDepositVault: PublicKey;
|
|
40
|
+
userJoinCredit: PublicKey;
|
|
41
|
+
userJoinCreditVault: PublicKey;
|
|
42
|
+
};
|
|
43
|
+
export type JoinSunpoolUpdatedAccounts = {
|
|
44
|
+
seasonSettings?: SeasonSettings;
|
|
45
|
+
season?: Season;
|
|
46
|
+
seasonMembership?: SeasonMembership;
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* Join a Sunpool season (classic mode with MIZD).
|
|
50
|
+
*
|
|
51
|
+
* This instruction:
|
|
52
|
+
* - Lazily initializes Sunpool if needed
|
|
53
|
+
* - Lazily initializes Season if needed
|
|
54
|
+
* - Creates SeasonMembership
|
|
55
|
+
* - Handles MIZD token transfers and join credit
|
|
56
|
+
*
|
|
57
|
+
* @param options - JoinSunpool options
|
|
58
|
+
* @returns Instructions, signers, and PDAs
|
|
59
|
+
*/
|
|
60
|
+
export declare function joinSunpool(options: JoinSunpoolOptions): Promise<StandardInstructionResultWithPdas<JoinSunpoolPdas, JoinSunpoolUpdatedAccounts>>;
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.joinSunpool = joinSunpool;
|
|
4
|
+
const web3_js_1 = require("@solana/web3.js");
|
|
5
|
+
const spl_token_1 = require("@solana/spl-token");
|
|
6
|
+
const pdaManager_1 = require("../utils/pdaManager");
|
|
7
|
+
const pdas_1 = require("../utils/pdas");
|
|
8
|
+
const constants_1 = require("../utils/constants");
|
|
9
|
+
const programHelpers_1 = require("../utils/programHelpers");
|
|
10
|
+
const signerHelpers_1 = require("../utils/signerHelpers");
|
|
11
|
+
/**
|
|
12
|
+
* Join a Sunpool season (classic mode with MIZD).
|
|
13
|
+
*
|
|
14
|
+
* This instruction:
|
|
15
|
+
* - Lazily initializes Sunpool if needed
|
|
16
|
+
* - Lazily initializes Season if needed
|
|
17
|
+
* - Creates SeasonMembership
|
|
18
|
+
* - Handles MIZD token transfers and join credit
|
|
19
|
+
*
|
|
20
|
+
* @param options - JoinSunpool options
|
|
21
|
+
* @returns Instructions, signers, and PDAs
|
|
22
|
+
*/
|
|
23
|
+
async function joinSunpool(options) {
|
|
24
|
+
const program = (0, programHelpers_1.getProgram)(options.connection);
|
|
25
|
+
const tokenMint = options.tokenMint ?? constants_1.MIZD_TOKEN_MINT;
|
|
26
|
+
console.log("[joinSunpool] Classic mode join with tokenMint:", tokenMint.toString());
|
|
27
|
+
// Derive PDAs - for Sunpool, use tokenMint for PDA derivation
|
|
28
|
+
const pdasBase = pdaManager_1.PDAManager.deriveJoinSeasonPdas({
|
|
29
|
+
user: options.user,
|
|
30
|
+
seasonNumber: options.seasonNumber,
|
|
31
|
+
tier: options.tier,
|
|
32
|
+
tokenMint,
|
|
33
|
+
launchpadTokenMint: tokenMint, // Sunpool uses tokenMint for Season/Membership PDAs
|
|
34
|
+
});
|
|
35
|
+
// Derive Sunpool PDA
|
|
36
|
+
const [sunpoolPda] = (0, pdas_1.getSunpoolPda)(tokenMint);
|
|
37
|
+
// User join credit vault ATA
|
|
38
|
+
const userJoinCreditVault = (0, spl_token_1.getAssociatedTokenAddressSync)(constants_1.MIZD_TOKEN_MINT, pdasBase.userJoinCredit, true);
|
|
39
|
+
// Token accounts
|
|
40
|
+
const rootAdminTokenAccount = (0, spl_token_1.getAssociatedTokenAddressSync)(constants_1.MIZD_TOKEN_MINT, constants_1.ADMIN_PUBLIC_KEY);
|
|
41
|
+
const userMizdAta = (0, spl_token_1.getAssociatedTokenAddressSync)(constants_1.MIZD_TOKEN_MINT, options.user);
|
|
42
|
+
const pdas = {
|
|
43
|
+
seasonSettings: pdasBase.seasonSettings,
|
|
44
|
+
season: pdasBase.season,
|
|
45
|
+
seasonMembership: pdasBase.seasonMembership,
|
|
46
|
+
sunpool: sunpoolPda,
|
|
47
|
+
seasonDepositVault: pdasBase.seasonDepositVault,
|
|
48
|
+
userJoinCredit: pdasBase.userJoinCredit,
|
|
49
|
+
userJoinCreditVault,
|
|
50
|
+
};
|
|
51
|
+
const referrer = options.referrer ?? web3_js_1.PublicKey.default;
|
|
52
|
+
const hasReferrer = !referrer.equals(web3_js_1.PublicKey.default);
|
|
53
|
+
// Validate referrer tier
|
|
54
|
+
if (hasReferrer && options.referrerTier === undefined) {
|
|
55
|
+
throw new Error("referrerTier is required when referrer is provided");
|
|
56
|
+
}
|
|
57
|
+
const accounts = {
|
|
58
|
+
seasonSettings: pdas.seasonSettings,
|
|
59
|
+
season: pdas.season,
|
|
60
|
+
seasonMembership: pdas.seasonMembership,
|
|
61
|
+
sunpool: sunpoolPda,
|
|
62
|
+
seasonDepositVault: pdas.seasonDepositVault,
|
|
63
|
+
userJoinCredit: pdas.userJoinCredit,
|
|
64
|
+
userJoinCreditVault,
|
|
65
|
+
mizdMint: constants_1.MIZD_TOKEN_MINT,
|
|
66
|
+
tokenMint,
|
|
67
|
+
rootAdmin: constants_1.ADMIN_PUBLIC_KEY,
|
|
68
|
+
rootAdminTokenAccount,
|
|
69
|
+
userTokenAccount: userMizdAta,
|
|
70
|
+
user: options.user,
|
|
71
|
+
associatedTokenProgram: spl_token_1.ASSOCIATED_TOKEN_PROGRAM_ID,
|
|
72
|
+
tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
|
|
73
|
+
systemProgram: web3_js_1.SystemProgram.programId,
|
|
74
|
+
};
|
|
75
|
+
const instruction = await program.methods
|
|
76
|
+
.joinSunpool(options.seasonNumber, options.tier, referrer, options.referrerTier ?? 0, options.star ?? false, options.starFlagPrompt ?? "", options.symbol ?? "")
|
|
77
|
+
.accounts(accounts)
|
|
78
|
+
.instruction();
|
|
79
|
+
// For star joins, root admin pays
|
|
80
|
+
const feePayer = options.star ? constants_1.ADMIN_PUBLIC_KEY : (0, signerHelpers_1.getDefaultFeePayer)(options.feePayer);
|
|
81
|
+
// Build signers array
|
|
82
|
+
const signersList = [
|
|
83
|
+
(0, signerHelpers_1.asAdminSigner)(constants_1.ADMIN_PUBLIC_KEY),
|
|
84
|
+
(0, signerHelpers_1.asUserSigner)(options.user),
|
|
85
|
+
];
|
|
86
|
+
const signers = (0, signerHelpers_1.buildSigners)(signersList, feePayer);
|
|
87
|
+
return {
|
|
88
|
+
instructions: [instruction],
|
|
89
|
+
signers,
|
|
90
|
+
pdas,
|
|
91
|
+
};
|
|
92
|
+
}
|
|
@@ -2016,7 +2016,8 @@ export type ProofOfTake = {
|
|
|
2016
2016
|
{
|
|
2017
2017
|
"name": "tokenMint";
|
|
2018
2018
|
"docs": [
|
|
2019
|
-
"Token mint this season is scoped to (used for PDA derivation)."
|
|
2019
|
+
"Token mint this season is scoped to (used for PDA derivation).",
|
|
2020
|
+
"Supports both SPL Token and Token-2022 mints via InterfaceAccount."
|
|
2020
2021
|
];
|
|
2021
2022
|
},
|
|
2022
2023
|
{
|
package/package.json
CHANGED
|
@@ -1,252 +0,0 @@
|
|
|
1
|
-
import { BN } from "@coral-xyz/anchor";
|
|
2
|
-
import { Connection, Keypair, PublicKey } from "@solana/web3.js";
|
|
3
|
-
import { Season, SeasonMembership, SeasonSettings, TierNumber } from "../types";
|
|
4
|
-
import { StandardInstructionResultWithPdas } from "../types/instructionResults";
|
|
5
|
-
/**
|
|
6
|
-
* Options for createMoonpool instruction (creating a new Moonpool + first join)
|
|
7
|
-
*/
|
|
8
|
-
export interface CreateMoonpoolOptions {
|
|
9
|
-
connection: Connection;
|
|
10
|
-
user: PublicKey;
|
|
11
|
-
seasonNumber: BN;
|
|
12
|
-
/** Tier number: 0=copper, 1=silver, 2=gold, 3=platinum, 4=mithril */
|
|
13
|
-
tier: TierNumber;
|
|
14
|
-
/** Optional referrer (PublicKey.default means no referrer) */
|
|
15
|
-
referrer?: PublicKey;
|
|
16
|
-
/** If true, root admin funds the SOL for the join. */
|
|
17
|
-
star?: boolean;
|
|
18
|
-
/** Hard cap in lamports for slippage protection. */
|
|
19
|
-
maxSolInLamports?: BN;
|
|
20
|
-
/** Expected SOL in lamports for bps slippage protection. */
|
|
21
|
-
expectedSolInLamports?: BN;
|
|
22
|
-
/** Max slippage in basis points (0..=5000). */
|
|
23
|
-
maxSlippageBps?: number;
|
|
24
|
-
/** Star flag prompt: a short message (max 33 chars). REQUIRED for new Moonpool. */
|
|
25
|
-
starFlagPrompt: string;
|
|
26
|
-
/** Token symbol (max 4 chars). REQUIRED for new Moonpool. */
|
|
27
|
-
symbol: string;
|
|
28
|
-
/** Optional injected timestamp (seconds) for optimistic state calculation */
|
|
29
|
-
now?: BN;
|
|
30
|
-
feePayer?: PublicKey;
|
|
31
|
-
currentAccounts?: {
|
|
32
|
-
seasonSettings?: SeasonSettings;
|
|
33
|
-
season?: Season;
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
type CreateMoonpoolPdas = {
|
|
37
|
-
seasonSettings: PublicKey;
|
|
38
|
-
season: PublicKey;
|
|
39
|
-
seasonMembership: PublicKey;
|
|
40
|
-
moonpool: PublicKey;
|
|
41
|
-
moonpoolTreasury: PublicKey;
|
|
42
|
-
launchpadTokenMint: PublicKey;
|
|
43
|
-
};
|
|
44
|
-
type CreateMoonpoolMeta = {
|
|
45
|
-
/** The keypair used for the launchpad mint (always generated for createMoonpool) */
|
|
46
|
-
launchpadTokenMintKeypair: Keypair;
|
|
47
|
-
};
|
|
48
|
-
type CreateMoonpoolUpdatedAccounts = {
|
|
49
|
-
seasonSettings?: SeasonSettings;
|
|
50
|
-
season?: Season;
|
|
51
|
-
seasonMembership?: SeasonMembership;
|
|
52
|
-
};
|
|
53
|
-
/**
|
|
54
|
-
* Create a new Moonpool and perform the first launchpad join.
|
|
55
|
-
*
|
|
56
|
-
* This instruction:
|
|
57
|
-
* - Creates a new launchpad_token_mint (SPL Token-2022)
|
|
58
|
-
* - Initializes the Moonpool
|
|
59
|
-
* - Initializes the Season (scoped to launchpad_token_mint)
|
|
60
|
-
* - Creates the first SeasonMembership
|
|
61
|
-
*
|
|
62
|
-
* @param options - CreateMoonpool options
|
|
63
|
-
* @returns Instructions, signers, PDAs, and metadata with the generated keypair
|
|
64
|
-
*/
|
|
65
|
-
export declare function createMoonpool(options: CreateMoonpoolOptions): Promise<StandardInstructionResultWithPdas<CreateMoonpoolPdas, CreateMoonpoolUpdatedAccounts, CreateMoonpoolMeta>>;
|
|
66
|
-
/**
|
|
67
|
-
* Options for joinMoonpoolSeason instruction (joining an existing Moonpool)
|
|
68
|
-
*/
|
|
69
|
-
export interface JoinMoonpoolSeasonOptions {
|
|
70
|
-
connection: Connection;
|
|
71
|
-
user: PublicKey;
|
|
72
|
-
seasonNumber: BN;
|
|
73
|
-
/** The launchpad token mint of the Moonpool to join. REQUIRED. */
|
|
74
|
-
launchpadTokenMint: PublicKey;
|
|
75
|
-
/** Tier number: 0=copper, 1=silver, 2=gold, 3=platinum, 4=mithril */
|
|
76
|
-
tier: TierNumber;
|
|
77
|
-
/** Optional referrer (PublicKey.default means no referrer) */
|
|
78
|
-
referrer?: PublicKey;
|
|
79
|
-
/** If true, root admin funds the SOL for the join. */
|
|
80
|
-
star?: boolean;
|
|
81
|
-
/** Hard cap in lamports for slippage protection. */
|
|
82
|
-
maxSolInLamports?: BN;
|
|
83
|
-
/** Expected SOL in lamports for bps slippage protection. */
|
|
84
|
-
expectedSolInLamports?: BN;
|
|
85
|
-
/** Max slippage in basis points (0..=5000). */
|
|
86
|
-
maxSlippageBps?: number;
|
|
87
|
-
/** Optional injected timestamp (seconds) for optimistic state calculation */
|
|
88
|
-
now?: BN;
|
|
89
|
-
feePayer?: PublicKey;
|
|
90
|
-
currentAccounts?: {
|
|
91
|
-
seasonSettings?: SeasonSettings;
|
|
92
|
-
season?: Season;
|
|
93
|
-
moonpool?: any;
|
|
94
|
-
};
|
|
95
|
-
}
|
|
96
|
-
type JoinMoonpoolSeasonPdas = {
|
|
97
|
-
seasonSettings: PublicKey;
|
|
98
|
-
season: PublicKey;
|
|
99
|
-
seasonMembership: PublicKey;
|
|
100
|
-
moonpool: PublicKey;
|
|
101
|
-
moonpoolTreasury: PublicKey;
|
|
102
|
-
launchpadTokenMint: PublicKey;
|
|
103
|
-
};
|
|
104
|
-
type JoinMoonpoolSeasonUpdatedAccounts = {
|
|
105
|
-
seasonSettings?: SeasonSettings;
|
|
106
|
-
season?: Season;
|
|
107
|
-
seasonMembership?: SeasonMembership;
|
|
108
|
-
};
|
|
109
|
-
/**
|
|
110
|
-
* Join an existing Moonpool season.
|
|
111
|
-
*
|
|
112
|
-
* This instruction:
|
|
113
|
-
* - Requires Moonpool to already exist
|
|
114
|
-
* - Lazily initializes Season if needed (for new seasons with existing Moonpool)
|
|
115
|
-
* - Creates new SeasonMembership
|
|
116
|
-
*
|
|
117
|
-
* @param options - JoinMoonpoolSeason options
|
|
118
|
-
* @returns Instructions, signers, and PDAs
|
|
119
|
-
*/
|
|
120
|
-
export declare function joinMoonpoolSeason(options: JoinMoonpoolSeasonOptions): Promise<StandardInstructionResultWithPdas<JoinMoonpoolSeasonPdas, JoinMoonpoolSeasonUpdatedAccounts>>;
|
|
121
|
-
/**
|
|
122
|
-
* Options for joinSunpool instruction (classic mode with MIZD)
|
|
123
|
-
*/
|
|
124
|
-
export interface JoinSunpoolOptions {
|
|
125
|
-
connection: Connection;
|
|
126
|
-
user: PublicKey;
|
|
127
|
-
seasonNumber: BN;
|
|
128
|
-
/** Token mint this season is scoped to. Defaults to MIZD_TOKEN_MINT. */
|
|
129
|
-
tokenMint?: PublicKey;
|
|
130
|
-
/** Tier number: 0=copper, 1=silver, 2=gold, 3=platinum, 4=mithril */
|
|
131
|
-
tier: TierNumber;
|
|
132
|
-
/** Optional referrer (PublicKey.default means no referrer) */
|
|
133
|
-
referrer?: PublicKey;
|
|
134
|
-
/** Referrer's tier (required if referrer is provided) */
|
|
135
|
-
referrerTier?: TierNumber;
|
|
136
|
-
/** If true, root admin funds the MIZD for the join. */
|
|
137
|
-
star?: boolean;
|
|
138
|
-
/** Star flag prompt (max 33 chars). Required for first Sunpool initialization. */
|
|
139
|
-
starFlagPrompt?: string;
|
|
140
|
-
/** Token symbol (max 4 chars). Required for first Sunpool initialization. */
|
|
141
|
-
symbol?: string;
|
|
142
|
-
/** Optional injected timestamp (seconds) for optimistic state calculation */
|
|
143
|
-
now?: BN;
|
|
144
|
-
feePayer?: PublicKey;
|
|
145
|
-
currentAccounts?: {
|
|
146
|
-
seasonSettings?: SeasonSettings;
|
|
147
|
-
season?: Season;
|
|
148
|
-
};
|
|
149
|
-
}
|
|
150
|
-
type JoinSunpoolPdas = {
|
|
151
|
-
seasonSettings: PublicKey;
|
|
152
|
-
season: PublicKey;
|
|
153
|
-
seasonMembership: PublicKey;
|
|
154
|
-
sunpool: PublicKey;
|
|
155
|
-
seasonDepositVault: PublicKey;
|
|
156
|
-
userJoinCredit: PublicKey;
|
|
157
|
-
userJoinCreditVault: PublicKey;
|
|
158
|
-
};
|
|
159
|
-
type JoinSunpoolUpdatedAccounts = {
|
|
160
|
-
seasonSettings?: SeasonSettings;
|
|
161
|
-
season?: Season;
|
|
162
|
-
seasonMembership?: SeasonMembership;
|
|
163
|
-
};
|
|
164
|
-
/**
|
|
165
|
-
* Join a Sunpool season (classic mode with MIZD).
|
|
166
|
-
*
|
|
167
|
-
* This instruction:
|
|
168
|
-
* - Lazily initializes Sunpool if needed
|
|
169
|
-
* - Lazily initializes Season if needed
|
|
170
|
-
* - Creates SeasonMembership
|
|
171
|
-
* - Handles MIZD token transfers and join credit
|
|
172
|
-
*
|
|
173
|
-
* @param options - JoinSunpool options
|
|
174
|
-
* @returns Instructions, signers, and PDAs
|
|
175
|
-
*/
|
|
176
|
-
export declare function joinSunpool(options: JoinSunpoolOptions): Promise<StandardInstructionResultWithPdas<JoinSunpoolPdas, JoinSunpoolUpdatedAccounts>>;
|
|
177
|
-
/**
|
|
178
|
-
* Options for the launchpad joinSeason wrapper.
|
|
179
|
-
* This is a convenience alias that routes to createMoonpool or joinMoonpoolSeason.
|
|
180
|
-
*/
|
|
181
|
-
export type JoinSeasonLaunchpadOptions = {
|
|
182
|
-
connection: Connection;
|
|
183
|
-
user: PublicKey;
|
|
184
|
-
seasonNumber: BN;
|
|
185
|
-
tier: TierNumber;
|
|
186
|
-
referrer?: PublicKey;
|
|
187
|
-
referrerTier?: TierNumber;
|
|
188
|
-
star?: boolean;
|
|
189
|
-
/** Hard cap in lamports for slippage protection. */
|
|
190
|
-
maxSolInLamports?: BN;
|
|
191
|
-
/** Expected SOL in lamports for bps slippage protection. */
|
|
192
|
-
expectedSolInLamports?: BN;
|
|
193
|
-
/** Max slippage in basis points (0..=5000). */
|
|
194
|
-
maxSlippageBps?: number;
|
|
195
|
-
/** Star flag prompt (max 33 chars). REQUIRED for creating new Moonpool. */
|
|
196
|
-
starFlagPrompt?: string;
|
|
197
|
-
/** Token symbol (max 4 chars). REQUIRED for creating new Moonpool. */
|
|
198
|
-
symbol?: string;
|
|
199
|
-
/** Force creating a new Moonpool (generates new launchpadTokenMint keypair). */
|
|
200
|
-
forceNewLaunchpadMint?: boolean;
|
|
201
|
-
now?: BN;
|
|
202
|
-
feePayer?: PublicKey;
|
|
203
|
-
currentAccounts?: {
|
|
204
|
-
seasonSettings?: SeasonSettings;
|
|
205
|
-
season?: Season;
|
|
206
|
-
moonpool?: any;
|
|
207
|
-
};
|
|
208
|
-
};
|
|
209
|
-
type JoinSeasonLaunchpadMeta = {
|
|
210
|
-
launchpadTokenMintKeypair?: Keypair;
|
|
211
|
-
};
|
|
212
|
-
/**
|
|
213
|
-
* Convenience wrapper for launchpad mode joins.
|
|
214
|
-
*
|
|
215
|
-
* This function automatically determines whether to call:
|
|
216
|
-
* - createMoonpool (if forceNewLaunchpadMint=true or no existing moonpool)
|
|
217
|
-
* - joinMoonpoolSeason (if joining an existing moonpool)
|
|
218
|
-
*
|
|
219
|
-
* @param options - Join options
|
|
220
|
-
* @returns Instructions, signers, PDAs, and metadata
|
|
221
|
-
*/
|
|
222
|
-
export declare function joinSeasonLaunchpad(options: JoinSeasonLaunchpadOptions): Promise<StandardInstructionResultWithPdas<any, any, JoinSeasonLaunchpadMeta>>;
|
|
223
|
-
/**
|
|
224
|
-
* Options for the classic (non-launchpad) joinSeason wrapper.
|
|
225
|
-
*/
|
|
226
|
-
export type JoinSeasonClassicOptions = {
|
|
227
|
-
connection: Connection;
|
|
228
|
-
user: PublicKey;
|
|
229
|
-
seasonNumber: BN;
|
|
230
|
-
tokenMint?: PublicKey;
|
|
231
|
-
tier: TierNumber;
|
|
232
|
-
referrer?: PublicKey;
|
|
233
|
-
referrerTier?: TierNumber;
|
|
234
|
-
star?: boolean;
|
|
235
|
-
starFlagPrompt?: string;
|
|
236
|
-
symbol?: string;
|
|
237
|
-
now?: BN;
|
|
238
|
-
feePayer?: PublicKey;
|
|
239
|
-
currentAccounts?: {
|
|
240
|
-
seasonSettings?: SeasonSettings;
|
|
241
|
-
season?: Season;
|
|
242
|
-
};
|
|
243
|
-
};
|
|
244
|
-
/**
|
|
245
|
-
* Convenience wrapper for classic (non-launchpad) mode joins.
|
|
246
|
-
* Routes to joinSunpool instruction.
|
|
247
|
-
*
|
|
248
|
-
* @param options - Join options
|
|
249
|
-
* @returns Instructions, signers, and PDAs
|
|
250
|
-
*/
|
|
251
|
-
export declare function joinSeasonClassic(options: JoinSeasonClassicOptions): Promise<StandardInstructionResultWithPdas<JoinSunpoolPdas, JoinSunpoolUpdatedAccounts>>;
|
|
252
|
-
export {};
|
|
@@ -1,331 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createMoonpool = createMoonpool;
|
|
4
|
-
exports.joinMoonpoolSeason = joinMoonpoolSeason;
|
|
5
|
-
exports.joinSunpool = joinSunpool;
|
|
6
|
-
exports.joinSeasonLaunchpad = joinSeasonLaunchpad;
|
|
7
|
-
exports.joinSeasonClassic = joinSeasonClassic;
|
|
8
|
-
const anchor_1 = require("@coral-xyz/anchor");
|
|
9
|
-
const web3_js_1 = require("@solana/web3.js");
|
|
10
|
-
const spl_token_1 = require("@solana/spl-token");
|
|
11
|
-
const pdaManager_1 = require("../utils/pdaManager");
|
|
12
|
-
const pdas_1 = require("../utils/pdas");
|
|
13
|
-
const constants_1 = require("../utils/constants");
|
|
14
|
-
const programHelpers_1 = require("../utils/programHelpers");
|
|
15
|
-
const signerHelpers_1 = require("../utils/signerHelpers");
|
|
16
|
-
/**
|
|
17
|
-
* Create a new Moonpool and perform the first launchpad join.
|
|
18
|
-
*
|
|
19
|
-
* This instruction:
|
|
20
|
-
* - Creates a new launchpad_token_mint (SPL Token-2022)
|
|
21
|
-
* - Initializes the Moonpool
|
|
22
|
-
* - Initializes the Season (scoped to launchpad_token_mint)
|
|
23
|
-
* - Creates the first SeasonMembership
|
|
24
|
-
*
|
|
25
|
-
* @param options - CreateMoonpool options
|
|
26
|
-
* @returns Instructions, signers, PDAs, and metadata with the generated keypair
|
|
27
|
-
*/
|
|
28
|
-
async function createMoonpool(options) {
|
|
29
|
-
const program = (0, programHelpers_1.getProgram)(options.connection);
|
|
30
|
-
// Validate required fields
|
|
31
|
-
if (!options.starFlagPrompt || options.starFlagPrompt.length === 0) {
|
|
32
|
-
throw new Error("starFlagPrompt is required when creating a new Moonpool");
|
|
33
|
-
}
|
|
34
|
-
if (options.starFlagPrompt.length > 33) {
|
|
35
|
-
throw new Error("starFlagPrompt cannot exceed 33 characters");
|
|
36
|
-
}
|
|
37
|
-
if (!options.symbol || options.symbol.length === 0) {
|
|
38
|
-
throw new Error("symbol is required when creating a new Moonpool");
|
|
39
|
-
}
|
|
40
|
-
if (options.symbol.length > 4) {
|
|
41
|
-
throw new Error("symbol cannot exceed 4 characters");
|
|
42
|
-
}
|
|
43
|
-
// Generate a new keypair for the launchpad token mint
|
|
44
|
-
const launchpadTokenMintKeypair = web3_js_1.Keypair.generate();
|
|
45
|
-
const launchpadTokenMintPubkey = launchpadTokenMintKeypair.publicKey;
|
|
46
|
-
console.log("[createMoonpool] Generated new launchpad mint keypair:", launchpadTokenMintPubkey.toString());
|
|
47
|
-
// Derive PDAs with the new launchpadTokenMint
|
|
48
|
-
const pdasBase = pdaManager_1.PDAManager.deriveJoinSeasonPdas({
|
|
49
|
-
user: options.user,
|
|
50
|
-
seasonNumber: options.seasonNumber,
|
|
51
|
-
tier: options.tier,
|
|
52
|
-
tokenMint: constants_1.MIZD_TOKEN_MINT,
|
|
53
|
-
launchpadTokenMint: launchpadTokenMintPubkey,
|
|
54
|
-
});
|
|
55
|
-
// Derive Moonpool and Treasury PDAs
|
|
56
|
-
const [moonpoolPda] = (0, pdas_1.getMoonpoolPda)(launchpadTokenMintPubkey);
|
|
57
|
-
const [moonpoolTreasuryPda] = (0, pdas_1.getMoonpoolTreasuryPda)(launchpadTokenMintPubkey);
|
|
58
|
-
const pdas = {
|
|
59
|
-
seasonSettings: pdasBase.seasonSettings,
|
|
60
|
-
season: pdasBase.season,
|
|
61
|
-
seasonMembership: pdasBase.seasonMembership,
|
|
62
|
-
moonpool: moonpoolPda,
|
|
63
|
-
moonpoolTreasury: moonpoolTreasuryPda,
|
|
64
|
-
launchpadTokenMint: launchpadTokenMintPubkey,
|
|
65
|
-
};
|
|
66
|
-
const referrer = options.referrer ?? web3_js_1.PublicKey.default;
|
|
67
|
-
const accounts = {
|
|
68
|
-
seasonSettings: pdas.seasonSettings,
|
|
69
|
-
season: pdas.season,
|
|
70
|
-
seasonMembership: pdas.seasonMembership,
|
|
71
|
-
moonpool: moonpoolPda,
|
|
72
|
-
moonpoolTreasury: moonpoolTreasuryPda,
|
|
73
|
-
launchpadTokenMint: launchpadTokenMintPubkey,
|
|
74
|
-
rootAdmin: constants_1.ADMIN_PUBLIC_KEY,
|
|
75
|
-
user: options.user,
|
|
76
|
-
token2022Program: spl_token_1.TOKEN_2022_PROGRAM_ID,
|
|
77
|
-
systemProgram: web3_js_1.SystemProgram.programId,
|
|
78
|
-
};
|
|
79
|
-
const instruction = await program.methods
|
|
80
|
-
.createMoonpool(options.seasonNumber, options.tier, referrer, options.star ?? false, options.maxSolInLamports ?? new anchor_1.BN(0), options.expectedSolInLamports ?? new anchor_1.BN(0), options.maxSlippageBps ?? 0, options.starFlagPrompt, options.symbol)
|
|
81
|
-
.accounts(accounts)
|
|
82
|
-
.instruction();
|
|
83
|
-
// For star joins, root admin pays
|
|
84
|
-
const feePayer = options.star ? constants_1.ADMIN_PUBLIC_KEY : (0, signerHelpers_1.getDefaultFeePayer)(options.feePayer);
|
|
85
|
-
// Build signers array - must include the launchpad mint keypair
|
|
86
|
-
const signersList = [
|
|
87
|
-
(0, signerHelpers_1.asAdminSigner)(constants_1.ADMIN_PUBLIC_KEY),
|
|
88
|
-
(0, signerHelpers_1.asUserSigner)(options.user),
|
|
89
|
-
{ publicKey: launchpadTokenMintKeypair.publicKey, role: "payer" },
|
|
90
|
-
];
|
|
91
|
-
const signers = (0, signerHelpers_1.buildSigners)(signersList, feePayer);
|
|
92
|
-
return {
|
|
93
|
-
instructions: [instruction],
|
|
94
|
-
signers,
|
|
95
|
-
pdas,
|
|
96
|
-
metadata: {
|
|
97
|
-
launchpadTokenMintKeypair,
|
|
98
|
-
},
|
|
99
|
-
};
|
|
100
|
-
}
|
|
101
|
-
/**
|
|
102
|
-
* Join an existing Moonpool season.
|
|
103
|
-
*
|
|
104
|
-
* This instruction:
|
|
105
|
-
* - Requires Moonpool to already exist
|
|
106
|
-
* - Lazily initializes Season if needed (for new seasons with existing Moonpool)
|
|
107
|
-
* - Creates new SeasonMembership
|
|
108
|
-
*
|
|
109
|
-
* @param options - JoinMoonpoolSeason options
|
|
110
|
-
* @returns Instructions, signers, and PDAs
|
|
111
|
-
*/
|
|
112
|
-
async function joinMoonpoolSeason(options) {
|
|
113
|
-
const program = (0, programHelpers_1.getProgram)(options.connection);
|
|
114
|
-
const launchpadTokenMintPubkey = options.launchpadTokenMint;
|
|
115
|
-
console.log("[joinMoonpoolSeason] Using existing launchpadTokenMint:", launchpadTokenMintPubkey.toString());
|
|
116
|
-
// Derive PDAs with the existing launchpadTokenMint
|
|
117
|
-
const pdasBase = pdaManager_1.PDAManager.deriveJoinSeasonPdas({
|
|
118
|
-
user: options.user,
|
|
119
|
-
seasonNumber: options.seasonNumber,
|
|
120
|
-
tier: options.tier,
|
|
121
|
-
tokenMint: constants_1.MIZD_TOKEN_MINT,
|
|
122
|
-
launchpadTokenMint: launchpadTokenMintPubkey,
|
|
123
|
-
});
|
|
124
|
-
// Derive Moonpool and Treasury PDAs
|
|
125
|
-
const [moonpoolPda] = (0, pdas_1.getMoonpoolPda)(launchpadTokenMintPubkey);
|
|
126
|
-
const [moonpoolTreasuryPda] = (0, pdas_1.getMoonpoolTreasuryPda)(launchpadTokenMintPubkey);
|
|
127
|
-
const pdas = {
|
|
128
|
-
seasonSettings: pdasBase.seasonSettings,
|
|
129
|
-
season: pdasBase.season,
|
|
130
|
-
seasonMembership: pdasBase.seasonMembership,
|
|
131
|
-
moonpool: moonpoolPda,
|
|
132
|
-
moonpoolTreasury: moonpoolTreasuryPda,
|
|
133
|
-
launchpadTokenMint: launchpadTokenMintPubkey,
|
|
134
|
-
};
|
|
135
|
-
const referrer = options.referrer ?? web3_js_1.PublicKey.default;
|
|
136
|
-
const accounts = {
|
|
137
|
-
seasonSettings: pdas.seasonSettings,
|
|
138
|
-
season: pdas.season,
|
|
139
|
-
seasonMembership: pdas.seasonMembership,
|
|
140
|
-
moonpool: moonpoolPda,
|
|
141
|
-
moonpoolTreasury: moonpoolTreasuryPda,
|
|
142
|
-
launchpadTokenMint: launchpadTokenMintPubkey,
|
|
143
|
-
rootAdmin: constants_1.ADMIN_PUBLIC_KEY,
|
|
144
|
-
user: options.user,
|
|
145
|
-
token2022Program: spl_token_1.TOKEN_2022_PROGRAM_ID,
|
|
146
|
-
systemProgram: web3_js_1.SystemProgram.programId,
|
|
147
|
-
};
|
|
148
|
-
const instruction = await program.methods
|
|
149
|
-
.joinMoonpoolSeason(options.seasonNumber, options.tier, referrer, options.star ?? false, options.maxSolInLamports ?? new anchor_1.BN(0), options.expectedSolInLamports ?? new anchor_1.BN(0), options.maxSlippageBps ?? 0)
|
|
150
|
-
.accounts(accounts)
|
|
151
|
-
.instruction();
|
|
152
|
-
// For star joins, root admin pays
|
|
153
|
-
const feePayer = options.star ? constants_1.ADMIN_PUBLIC_KEY : (0, signerHelpers_1.getDefaultFeePayer)(options.feePayer);
|
|
154
|
-
// Build signers array
|
|
155
|
-
const signersList = [
|
|
156
|
-
(0, signerHelpers_1.asAdminSigner)(constants_1.ADMIN_PUBLIC_KEY),
|
|
157
|
-
(0, signerHelpers_1.asUserSigner)(options.user),
|
|
158
|
-
];
|
|
159
|
-
const signers = (0, signerHelpers_1.buildSigners)(signersList, feePayer);
|
|
160
|
-
return {
|
|
161
|
-
instructions: [instruction],
|
|
162
|
-
signers,
|
|
163
|
-
pdas,
|
|
164
|
-
};
|
|
165
|
-
}
|
|
166
|
-
/**
|
|
167
|
-
* Join a Sunpool season (classic mode with MIZD).
|
|
168
|
-
*
|
|
169
|
-
* This instruction:
|
|
170
|
-
* - Lazily initializes Sunpool if needed
|
|
171
|
-
* - Lazily initializes Season if needed
|
|
172
|
-
* - Creates SeasonMembership
|
|
173
|
-
* - Handles MIZD token transfers and join credit
|
|
174
|
-
*
|
|
175
|
-
* @param options - JoinSunpool options
|
|
176
|
-
* @returns Instructions, signers, and PDAs
|
|
177
|
-
*/
|
|
178
|
-
async function joinSunpool(options) {
|
|
179
|
-
const program = (0, programHelpers_1.getProgram)(options.connection);
|
|
180
|
-
const tokenMint = options.tokenMint ?? constants_1.MIZD_TOKEN_MINT;
|
|
181
|
-
console.log("[joinSunpool] Classic mode join with tokenMint:", tokenMint.toString());
|
|
182
|
-
// Derive PDAs - for Sunpool, use tokenMint for PDA derivation
|
|
183
|
-
const pdasBase = pdaManager_1.PDAManager.deriveJoinSeasonPdas({
|
|
184
|
-
user: options.user,
|
|
185
|
-
seasonNumber: options.seasonNumber,
|
|
186
|
-
tier: options.tier,
|
|
187
|
-
tokenMint,
|
|
188
|
-
launchpadTokenMint: tokenMint, // Sunpool uses tokenMint for Season/Membership PDAs
|
|
189
|
-
});
|
|
190
|
-
// Derive Sunpool PDA
|
|
191
|
-
const [sunpoolPda] = (0, pdas_1.getSunpoolPda)(tokenMint);
|
|
192
|
-
// User join credit vault ATA
|
|
193
|
-
const userJoinCreditVault = (0, spl_token_1.getAssociatedTokenAddressSync)(constants_1.MIZD_TOKEN_MINT, pdasBase.userJoinCredit, true);
|
|
194
|
-
// Token accounts
|
|
195
|
-
const rootAdminTokenAccount = (0, spl_token_1.getAssociatedTokenAddressSync)(constants_1.MIZD_TOKEN_MINT, constants_1.ADMIN_PUBLIC_KEY);
|
|
196
|
-
const userMizdAta = (0, spl_token_1.getAssociatedTokenAddressSync)(constants_1.MIZD_TOKEN_MINT, options.user);
|
|
197
|
-
const pdas = {
|
|
198
|
-
seasonSettings: pdasBase.seasonSettings,
|
|
199
|
-
season: pdasBase.season,
|
|
200
|
-
seasonMembership: pdasBase.seasonMembership,
|
|
201
|
-
sunpool: sunpoolPda,
|
|
202
|
-
seasonDepositVault: pdasBase.seasonDepositVault,
|
|
203
|
-
userJoinCredit: pdasBase.userJoinCredit,
|
|
204
|
-
userJoinCreditVault,
|
|
205
|
-
};
|
|
206
|
-
const referrer = options.referrer ?? web3_js_1.PublicKey.default;
|
|
207
|
-
const hasReferrer = !referrer.equals(web3_js_1.PublicKey.default);
|
|
208
|
-
// Validate referrer tier
|
|
209
|
-
if (hasReferrer && options.referrerTier === undefined) {
|
|
210
|
-
throw new Error("referrerTier is required when referrer is provided");
|
|
211
|
-
}
|
|
212
|
-
const accounts = {
|
|
213
|
-
seasonSettings: pdas.seasonSettings,
|
|
214
|
-
season: pdas.season,
|
|
215
|
-
seasonMembership: pdas.seasonMembership,
|
|
216
|
-
sunpool: sunpoolPda,
|
|
217
|
-
seasonDepositVault: pdas.seasonDepositVault,
|
|
218
|
-
userJoinCredit: pdas.userJoinCredit,
|
|
219
|
-
userJoinCreditVault,
|
|
220
|
-
mizdMint: constants_1.MIZD_TOKEN_MINT,
|
|
221
|
-
tokenMint,
|
|
222
|
-
rootAdmin: constants_1.ADMIN_PUBLIC_KEY,
|
|
223
|
-
rootAdminTokenAccount,
|
|
224
|
-
userTokenAccount: userMizdAta,
|
|
225
|
-
user: options.user,
|
|
226
|
-
associatedTokenProgram: spl_token_1.ASSOCIATED_TOKEN_PROGRAM_ID,
|
|
227
|
-
tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
|
|
228
|
-
systemProgram: web3_js_1.SystemProgram.programId,
|
|
229
|
-
};
|
|
230
|
-
const instruction = await program.methods
|
|
231
|
-
.joinSunpool(options.seasonNumber, options.tier, referrer, options.referrerTier ?? 0, options.star ?? false, options.starFlagPrompt ?? "", options.symbol ?? "")
|
|
232
|
-
.accounts(accounts)
|
|
233
|
-
.instruction();
|
|
234
|
-
// For star joins, root admin pays
|
|
235
|
-
const feePayer = options.star ? constants_1.ADMIN_PUBLIC_KEY : (0, signerHelpers_1.getDefaultFeePayer)(options.feePayer);
|
|
236
|
-
// Build signers array
|
|
237
|
-
const signersList = [
|
|
238
|
-
(0, signerHelpers_1.asAdminSigner)(constants_1.ADMIN_PUBLIC_KEY),
|
|
239
|
-
(0, signerHelpers_1.asUserSigner)(options.user),
|
|
240
|
-
];
|
|
241
|
-
const signers = (0, signerHelpers_1.buildSigners)(signersList, feePayer);
|
|
242
|
-
return {
|
|
243
|
-
instructions: [instruction],
|
|
244
|
-
signers,
|
|
245
|
-
pdas,
|
|
246
|
-
};
|
|
247
|
-
}
|
|
248
|
-
/**
|
|
249
|
-
* Convenience wrapper for launchpad mode joins.
|
|
250
|
-
*
|
|
251
|
-
* This function automatically determines whether to call:
|
|
252
|
-
* - createMoonpool (if forceNewLaunchpadMint=true or no existing moonpool)
|
|
253
|
-
* - joinMoonpoolSeason (if joining an existing moonpool)
|
|
254
|
-
*
|
|
255
|
-
* @param options - Join options
|
|
256
|
-
* @returns Instructions, signers, PDAs, and metadata
|
|
257
|
-
*/
|
|
258
|
-
async function joinSeasonLaunchpad(options) {
|
|
259
|
-
// Determine if we're creating a new Moonpool or joining an existing one
|
|
260
|
-
const shouldCreateNewMoonpool = options.forceNewLaunchpadMint ||
|
|
261
|
-
!options.currentAccounts?.moonpool ||
|
|
262
|
-
options.currentAccounts.moonpool.launchpadTokenMint?.equals(web3_js_1.PublicKey.default);
|
|
263
|
-
if (shouldCreateNewMoonpool) {
|
|
264
|
-
// Creating a new Moonpool - starFlagPrompt and symbol are required
|
|
265
|
-
if (!options.starFlagPrompt) {
|
|
266
|
-
throw new Error("starFlagPrompt is required when creating a new Moonpool");
|
|
267
|
-
}
|
|
268
|
-
if (!options.symbol) {
|
|
269
|
-
throw new Error("symbol is required when creating a new Moonpool");
|
|
270
|
-
}
|
|
271
|
-
return createMoonpool({
|
|
272
|
-
connection: options.connection,
|
|
273
|
-
user: options.user,
|
|
274
|
-
seasonNumber: options.seasonNumber,
|
|
275
|
-
tier: options.tier,
|
|
276
|
-
starFlagPrompt: options.starFlagPrompt,
|
|
277
|
-
symbol: options.symbol,
|
|
278
|
-
...(options.referrer !== undefined && { referrer: options.referrer }),
|
|
279
|
-
...(options.star !== undefined && { star: options.star }),
|
|
280
|
-
...(options.maxSolInLamports !== undefined && { maxSolInLamports: options.maxSolInLamports }),
|
|
281
|
-
...(options.expectedSolInLamports !== undefined && { expectedSolInLamports: options.expectedSolInLamports }),
|
|
282
|
-
...(options.maxSlippageBps !== undefined && { maxSlippageBps: options.maxSlippageBps }),
|
|
283
|
-
...(options.now !== undefined && { now: options.now }),
|
|
284
|
-
...(options.feePayer !== undefined && { feePayer: options.feePayer }),
|
|
285
|
-
...(options.currentAccounts !== undefined && { currentAccounts: options.currentAccounts }),
|
|
286
|
-
});
|
|
287
|
-
}
|
|
288
|
-
else {
|
|
289
|
-
// Joining an existing Moonpool
|
|
290
|
-
const launchpadTokenMint = options.currentAccounts.moonpool.launchpadTokenMint;
|
|
291
|
-
return joinMoonpoolSeason({
|
|
292
|
-
connection: options.connection,
|
|
293
|
-
user: options.user,
|
|
294
|
-
seasonNumber: options.seasonNumber,
|
|
295
|
-
launchpadTokenMint,
|
|
296
|
-
tier: options.tier,
|
|
297
|
-
...(options.referrer !== undefined && { referrer: options.referrer }),
|
|
298
|
-
...(options.star !== undefined && { star: options.star }),
|
|
299
|
-
...(options.maxSolInLamports !== undefined && { maxSolInLamports: options.maxSolInLamports }),
|
|
300
|
-
...(options.expectedSolInLamports !== undefined && { expectedSolInLamports: options.expectedSolInLamports }),
|
|
301
|
-
...(options.maxSlippageBps !== undefined && { maxSlippageBps: options.maxSlippageBps }),
|
|
302
|
-
...(options.now !== undefined && { now: options.now }),
|
|
303
|
-
...(options.feePayer !== undefined && { feePayer: options.feePayer }),
|
|
304
|
-
...(options.currentAccounts !== undefined && { currentAccounts: options.currentAccounts }),
|
|
305
|
-
});
|
|
306
|
-
}
|
|
307
|
-
}
|
|
308
|
-
/**
|
|
309
|
-
* Convenience wrapper for classic (non-launchpad) mode joins.
|
|
310
|
-
* Routes to joinSunpool instruction.
|
|
311
|
-
*
|
|
312
|
-
* @param options - Join options
|
|
313
|
-
* @returns Instructions, signers, and PDAs
|
|
314
|
-
*/
|
|
315
|
-
async function joinSeasonClassic(options) {
|
|
316
|
-
return joinSunpool({
|
|
317
|
-
connection: options.connection,
|
|
318
|
-
user: options.user,
|
|
319
|
-
seasonNumber: options.seasonNumber,
|
|
320
|
-
tier: options.tier,
|
|
321
|
-
...(options.tokenMint !== undefined && { tokenMint: options.tokenMint }),
|
|
322
|
-
...(options.referrer !== undefined && { referrer: options.referrer }),
|
|
323
|
-
...(options.referrerTier !== undefined && { referrerTier: options.referrerTier }),
|
|
324
|
-
...(options.star !== undefined && { star: options.star }),
|
|
325
|
-
...(options.starFlagPrompt !== undefined && { starFlagPrompt: options.starFlagPrompt }),
|
|
326
|
-
...(options.symbol !== undefined && { symbol: options.symbol }),
|
|
327
|
-
...(options.now !== undefined && { now: options.now }),
|
|
328
|
-
...(options.feePayer !== undefined && { feePayer: options.feePayer }),
|
|
329
|
-
...(options.currentAccounts !== undefined && { currentAccounts: options.currentAccounts }),
|
|
330
|
-
});
|
|
331
|
-
}
|