proof-of-take-sdk 5.0.4 → 5.0.6
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/README.md +36 -0
- package/dist/instructions/joinSeason.d.ts +8 -10
- package/dist/instructions/joinSeason.js +28 -12
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -339,6 +339,42 @@ await claimReward(program, {
|
|
|
339
339
|
|
|
340
340
|
---
|
|
341
341
|
|
|
342
|
+
## Launchpad Integration (Moonpool/Sunpool)
|
|
343
|
+
|
|
344
|
+
For bot developers integrating the launchpad functionality with automatic keypair generation, see the comprehensive guide:
|
|
345
|
+
|
|
346
|
+
**📘 [LAUNCHPAD_BOT_INTEGRATION.md](../LAUNCHPAD_BOT_INTEGRATION.md)**
|
|
347
|
+
|
|
348
|
+
### Quick Example
|
|
349
|
+
|
|
350
|
+
```typescript
|
|
351
|
+
import { joinSeason } from "@proof-of-miztake/sdk";
|
|
352
|
+
import { BN } from "@coral-xyz/anchor";
|
|
353
|
+
|
|
354
|
+
// Call joinSeason with launchpad mode
|
|
355
|
+
const result = await joinSeason({
|
|
356
|
+
connection,
|
|
357
|
+
user: userPublicKey,
|
|
358
|
+
seasonNumber: new BN(1),
|
|
359
|
+
tier: 4,
|
|
360
|
+
launchpad: true, // Enable launchpad mode
|
|
361
|
+
});
|
|
362
|
+
|
|
363
|
+
// ✅ CRITICAL: Extract and use the auto-generated keypair
|
|
364
|
+
const signers = [adminWallet, userWallet];
|
|
365
|
+
if (result.meta?.launchpadTokenMintKeypair) {
|
|
366
|
+
signers.push(result.meta.launchpadTokenMintKeypair);
|
|
367
|
+
console.log("Added launchpad mint keypair");
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
// Sign and send transaction with all signers
|
|
371
|
+
tx.sign(...signers);
|
|
372
|
+
```
|
|
373
|
+
|
|
374
|
+
**Important:** The SDK auto-generates the launchpad mint keypair, but your bot must extract it from `result.meta.launchpadTokenMintKeypair` and include it when signing the transaction. See the full guide for details.
|
|
375
|
+
|
|
376
|
+
---
|
|
377
|
+
|
|
342
378
|
## Building from Source
|
|
343
379
|
|
|
344
380
|
```bash
|
|
@@ -21,16 +21,6 @@ export interface JoinSeasonOptions {
|
|
|
21
21
|
star?: boolean;
|
|
22
22
|
/** If true, join uses launchpad mode (SOL in, virtual tokens escrowed; no SPL token accounts needed). */
|
|
23
23
|
launchpad?: boolean;
|
|
24
|
-
/**
|
|
25
|
-
* Launchpad token mint keypair. OPTIONAL.
|
|
26
|
-
*
|
|
27
|
-
* - If NOT provided and launchpad=true: SDK will automatically generate a new keypair
|
|
28
|
-
* for the mint and return it in the result.
|
|
29
|
-
* - If provided: SDK will use this keypair (useful for testing with specific keys).
|
|
30
|
-
*
|
|
31
|
-
* The SDK automatically adds the keypair as a signer to the transaction.
|
|
32
|
-
*/
|
|
33
|
-
launchpadTokenMintKeypair?: Keypair;
|
|
34
24
|
/** Launchpad slippage cap (lamports). Only used when launchpad=true. Defaults to u64::MAX. */
|
|
35
25
|
maxSolInLamports?: BN;
|
|
36
26
|
/**
|
|
@@ -52,12 +42,20 @@ export interface JoinSeasonOptions {
|
|
|
52
42
|
* Only used when initializing a new pool (first join). Ignored when joining existing season.
|
|
53
43
|
*/
|
|
54
44
|
symbol?: string;
|
|
45
|
+
/**
|
|
46
|
+
* Force generating a new launchpad token mint keypair, even if a moonpool already exists on-chain.
|
|
47
|
+
* Use this when creating a NEW Moonpool (i.e., the on-chain moonpool account may exist but was
|
|
48
|
+
* never fully initialized, or you want to start fresh with a new token mint).
|
|
49
|
+
* Only applies to launchpad mode.
|
|
50
|
+
*/
|
|
51
|
+
forceNewLaunchpadMint?: boolean;
|
|
55
52
|
/** Optional injected timestamp (seconds) for optimistic state calculation */
|
|
56
53
|
now?: BN;
|
|
57
54
|
feePayer?: PublicKey;
|
|
58
55
|
currentAccounts?: {
|
|
59
56
|
seasonSettings?: SeasonSettings;
|
|
60
57
|
season?: Season;
|
|
58
|
+
moonpool?: any;
|
|
61
59
|
};
|
|
62
60
|
}
|
|
63
61
|
/**
|
|
@@ -38,26 +38,42 @@ async function joinSeason(options) {
|
|
|
38
38
|
tier: options.tier,
|
|
39
39
|
tokenMint,
|
|
40
40
|
});
|
|
41
|
-
// Auto-generate keypair for launchpad mode
|
|
42
|
-
let launchpadTokenMintKeypair
|
|
41
|
+
// Auto-generate keypair for launchpad mode when moonpool is being initialized
|
|
42
|
+
let launchpadTokenMintKeypair;
|
|
43
43
|
let launchpadTokenMintPubkey;
|
|
44
44
|
if (launchpad) {
|
|
45
|
-
|
|
46
|
-
|
|
45
|
+
// If forceNewLaunchpadMint is set, skip on-chain checks and always generate a new keypair
|
|
46
|
+
if (options.forceNewLaunchpadMint) {
|
|
47
|
+
launchpadTokenMintKeypair = web3_js_1.Keypair.generate();
|
|
47
48
|
launchpadTokenMintPubkey = launchpadTokenMintKeypair.publicKey;
|
|
49
|
+
console.log("[joinSeason] forceNewLaunchpadMint=true - generated new launchpad mint keypair:", launchpadTokenMintPubkey.toString());
|
|
48
50
|
}
|
|
49
51
|
else {
|
|
50
|
-
// Check if
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
52
|
+
// Check if moonpool is already initialized
|
|
53
|
+
// First check currentAccounts (for LiteSVM or optimistic updates)
|
|
54
|
+
let moonpoolData = options.currentAccounts?.moonpool ?? null;
|
|
55
|
+
// If not provided, try to fetch it from the network
|
|
56
|
+
if (!moonpoolData) {
|
|
57
|
+
try {
|
|
58
|
+
moonpoolData = await program.account.moonpool.fetch(pdasBase.moonpool);
|
|
59
|
+
console.log("[joinSeason] Moonpool data fetched, launchpadTokenMint:", moonpoolData.launchpadTokenMint.toString());
|
|
60
|
+
}
|
|
61
|
+
catch (error) {
|
|
62
|
+
// Moonpool doesn't exist (first join scenario) or network error - treat as first join
|
|
63
|
+
moonpoolData = null;
|
|
64
|
+
}
|
|
55
65
|
}
|
|
56
|
-
|
|
57
|
-
//
|
|
66
|
+
if (!moonpoolData || moonpoolData.launchpadTokenMint.equals(web3_js_1.PublicKey.default)) {
|
|
67
|
+
// Moonpool doesn't exist yet (first join) - generate a keypair for the mint
|
|
68
|
+
// The mint will be created and stored in the moonpool during initialization
|
|
58
69
|
launchpadTokenMintKeypair = web3_js_1.Keypair.generate();
|
|
59
70
|
launchpadTokenMintPubkey = launchpadTokenMintKeypair.publicKey;
|
|
60
|
-
console.log("[joinSeason]
|
|
71
|
+
console.log("[joinSeason] First join - generated launchpad mint keypair:", launchpadTokenMintPubkey.toString());
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
// Moonpool is already initialized - use the mint address stored in moonpool
|
|
75
|
+
launchpadTokenMintPubkey = moonpoolData.launchpadTokenMint;
|
|
76
|
+
console.log("[joinSeason] Moonpool exists - using stored mint address:", launchpadTokenMintPubkey.toString());
|
|
61
77
|
}
|
|
62
78
|
}
|
|
63
79
|
}
|