pyre-world-kit 1.0.18 → 1.0.20

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/actions.d.ts CHANGED
@@ -17,7 +17,7 @@ export declare function getBlacklistedMints(): string[];
17
17
  export declare function getFactions(connection: Connection, params?: FactionListParams): Promise<FactionListResult>;
18
18
  /** Get detailed info for a single faction */
19
19
  export declare function getFaction(connection: Connection, mint: string): Promise<FactionDetail>;
20
- /** Get faction members (top holders) */
20
+ /** Get faction members (top holders, excluding program-owned accounts) */
21
21
  export declare function getMembers(connection: Connection, mint: string, limit?: number): Promise<MembersResult>;
22
22
  /** Get faction comms (trade-bundled messages, including post-ascension DEX messages) */
23
23
  export declare function getComms(connection: Connection, mint: string, limit?: number): Promise<CommsResult>;
package/dist/actions.js CHANGED
@@ -113,9 +113,22 @@ async function getFaction(connection, mint) {
113
113
  const detail = await (0, torchsdk_1.getToken)(connection, mint);
114
114
  return (0, mappers_1.mapTokenDetailToFaction)(detail);
115
115
  }
116
- /** Get faction members (top holders) */
116
+ /** Get faction members (top holders, excluding program-owned accounts) */
117
117
  async function getMembers(connection, mint, limit) {
118
- const result = await (0, torchsdk_1.getHolders)(connection, mint, limit);
118
+ const mintPk = new web3_js_1.PublicKey(mint);
119
+ const [bondingCurve] = (0, vanity_1.getBondingCurvePda)(mintPk);
120
+ const [treasury] = (0, vanity_1.getTokenTreasuryPda)(mintPk);
121
+ const [treasuryLock] = (0, vanity_1.getTreasuryLockPda)(mintPk);
122
+ const excluded = new Set([
123
+ bondingCurve.toString(),
124
+ treasury.toString(),
125
+ treasuryLock.toString(),
126
+ ]);
127
+ // Fetch extra to compensate for filtered-out program accounts
128
+ const result = await (0, torchsdk_1.getHolders)(connection, mint, (limit ?? 10) + 5);
129
+ result.holders = result.holders.filter(h => !excluded.has(h.address));
130
+ if (limit)
131
+ result.holders = result.holders.slice(0, limit);
119
132
  return (0, mappers_1.mapHoldersResult)(result);
120
133
  }
121
134
  /** Get faction comms (trade-bundled messages, including post-ascension DEX messages) */
package/dist/intel.js CHANGED
@@ -14,6 +14,7 @@ exports.getAgentProfile = getAgentProfile;
14
14
  exports.getAgentFactions = getAgentFactions;
15
15
  exports.getWorldFeed = getWorldFeed;
16
16
  exports.getWorldStats = getWorldStats;
17
+ const web3_js_1 = require("@solana/web3.js");
17
18
  const torchsdk_1 = require("torchsdk");
18
19
  const mappers_1 = require("./mappers");
19
20
  const vanity_1 = require("./vanity");
@@ -54,7 +55,9 @@ async function getFactionLeaderboard(connection, opts) {
54
55
  razed: 'reclaimed',
55
56
  };
56
57
  const sdkStatus = opts?.status ? statusMap[opts.status] : 'all';
57
- const result = await (0, torchsdk_1.getTokens)(connection, { limit: opts?.limit ?? 100, status: sdkStatus });
58
+ // Fetch more than requested to account for non-pyre tokens being filtered out
59
+ const fetchLimit = Math.min((opts?.limit ?? 20) * 3, 100);
60
+ const result = await (0, torchsdk_1.getTokens)(connection, { limit: fetchLimit, status: sdkStatus });
58
61
  const pyreFactions = result.tokens.filter(t => (0, vanity_1.isPyreMint)(t.mint));
59
62
  const powers = pyreFactions.map((t) => ({
60
63
  mint: t.mint,
@@ -81,7 +84,7 @@ async function getFactionLeaderboard(connection, opts) {
81
84
  async function detectAlliances(connection, mints, holderLimit = 50) {
82
85
  // Fetch holders for each faction in parallel
83
86
  const holdersPerFaction = await Promise.all(mints.map(async (mint) => {
84
- const result = await (0, torchsdk_1.getHolders)(connection, mint, holderLimit);
87
+ const result = await getPyreHolders(connection, mint, holderLimit);
85
88
  return { mint, holders: new Set(result.holders.map(h => h.address)) };
86
89
  }));
87
90
  // Find overlapping holders between faction pairs
@@ -123,7 +126,7 @@ async function getFactionRivals(connection, mint, limit = 50) {
123
126
  for (const faction of allFactions.tokens.filter(t => (0, vanity_1.isPyreMint)(t.mint))) {
124
127
  if (faction.mint === mint)
125
128
  continue;
126
- const holders = await (0, torchsdk_1.getHolders)(connection, faction.mint, 50);
129
+ const holders = await getPyreHolders(connection, faction.mint, 50);
127
130
  const holderAddrs = new Set(holders.holders.map(h => h.address));
128
131
  const overlap = [...defectors].filter(d => holderAddrs.has(d)).length;
129
132
  if (overlap > 0) {
@@ -201,7 +204,7 @@ async function getAgentFactions(connection, wallet, factionLimit = 50) {
201
204
  // Check each faction for this holder
202
205
  await Promise.all(pyreFactions.map(async (faction) => {
203
206
  try {
204
- const holders = await (0, torchsdk_1.getHolders)(connection, faction.mint, 100);
207
+ const holders = await getPyreHolders(connection, faction.mint, 100);
205
208
  const holding = holders.holders.find(h => h.address === wallet);
206
209
  if (holding && holding.balance > 0) {
207
210
  positions.push({
@@ -286,14 +289,10 @@ async function getWorldFeed(connection, opts) {
286
289
  * Global stats: total factions, total agents, total SOL locked.
287
290
  */
288
291
  async function getWorldStats(connection) {
289
- const [all, rising, ascended] = await Promise.all([
290
- (0, torchsdk_1.getTokens)(connection, { limit: 200, status: 'all' }),
291
- (0, torchsdk_1.getTokens)(connection, { limit: 100, status: 'bonding' }),
292
- (0, torchsdk_1.getTokens)(connection, { limit: 100, status: 'migrated' }),
293
- ]);
292
+ const all = await (0, torchsdk_1.getTokens)(connection, { limit: 200, status: 'all' });
294
293
  const pyreAll = all.tokens.filter(t => (0, vanity_1.isPyreMint)(t.mint));
295
- const pyreRising = rising.tokens.filter(t => (0, vanity_1.isPyreMint)(t.mint));
296
- const pyreAscended = ascended.tokens.filter(t => (0, vanity_1.isPyreMint)(t.mint));
294
+ const pyreRising = pyreAll.filter(t => t.status === 'bonding');
295
+ const pyreAscended = pyreAll.filter(t => t.status === 'migrated');
297
296
  const allFactions = [...pyreRising, ...pyreAscended];
298
297
  const totalSolLocked = allFactions.reduce((sum, t) => sum + t.market_cap_sol, 0);
299
298
  // Find most powerful
@@ -325,6 +324,17 @@ async function getWorldStats(connection) {
325
324
  most_powerful: mostPowerful,
326
325
  };
327
326
  }
327
+ /** Fetch holders excluding program-owned accounts (bonding curve, treasury, treasury lock) */
328
+ async function getPyreHolders(connection, mint, limit) {
329
+ const mintPk = new web3_js_1.PublicKey(mint);
330
+ const [bondingCurve] = (0, vanity_1.getBondingCurvePda)(mintPk);
331
+ const [treasury] = (0, vanity_1.getTokenTreasuryPda)(mintPk);
332
+ const [treasuryLock] = (0, vanity_1.getTreasuryLockPda)(mintPk);
333
+ const excluded = new Set([bondingCurve.toString(), treasury.toString(), treasuryLock.toString()]);
334
+ const result = await (0, torchsdk_1.getHolders)(connection, mint, limit + 5);
335
+ result.holders = result.holders.filter(h => !excluded.has(h.address)).slice(0, limit);
336
+ return result;
337
+ }
328
338
  // ─── Internal Helpers ──────────────────────────────────────────────
329
339
  function computePowerScore(t) {
330
340
  const mcWeight = 0.4;
package/dist/vanity.d.ts CHANGED
@@ -5,8 +5,11 @@
5
5
  * This is how we distinguish pyre faction tokens from regular torch tokens —
6
6
  * no registry program needed, just check the mint suffix.
7
7
  */
8
- import { Connection, Keypair } from '@solana/web3.js';
8
+ import { Connection, PublicKey, Keypair } from '@solana/web3.js';
9
9
  import type { CreateTokenResult, CreateTokenParams } from 'torchsdk';
10
+ export declare const getBondingCurvePda: (mint: PublicKey) => [PublicKey, number];
11
+ export declare const getTokenTreasuryPda: (mint: PublicKey) => [PublicKey, number];
12
+ export declare const getTreasuryLockPda: (mint: PublicKey) => [PublicKey, number];
10
13
  /** Grind for a keypair whose base58 address ends with "py" */
11
14
  export declare function grindPyreMint(maxAttempts?: number): Keypair;
12
15
  /** Check if a mint address is a pyre faction (ends with "py") */
package/dist/vanity.js CHANGED
@@ -10,6 +10,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
10
10
  return (mod && mod.__esModule) ? mod : { "default": mod };
11
11
  };
12
12
  Object.defineProperty(exports, "__esModule", { value: true });
13
+ exports.getTreasuryLockPda = exports.getTokenTreasuryPda = exports.getBondingCurvePda = void 0;
13
14
  exports.grindPyreMint = grindPyreMint;
14
15
  exports.isPyreMint = isPyreMint;
15
16
  exports.buildCreateFactionTransaction = buildCreateFactionTransaction;
@@ -29,9 +30,12 @@ const torch_market_json_1 = __importDefault(require("torchsdk/dist/torch_market.
29
30
  // ── PDA helpers (copied from torchsdk internals) ──
30
31
  const getGlobalConfigPda = () => web3_js_1.PublicKey.findProgramAddressSync([Buffer.from(GLOBAL_CONFIG_SEED)], torchsdk_1.PROGRAM_ID);
31
32
  const getBondingCurvePda = (mint) => web3_js_1.PublicKey.findProgramAddressSync([Buffer.from(BONDING_CURVE_SEED), mint.toBuffer()], torchsdk_1.PROGRAM_ID);
33
+ exports.getBondingCurvePda = getBondingCurvePda;
32
34
  const getTokenTreasuryPda = (mint) => web3_js_1.PublicKey.findProgramAddressSync([Buffer.from(TREASURY_SEED), mint.toBuffer()], torchsdk_1.PROGRAM_ID);
35
+ exports.getTokenTreasuryPda = getTokenTreasuryPda;
33
36
  const getTreasuryTokenAccount = (mint, treasury) => (0, spl_token_1.getAssociatedTokenAddressSync)(mint, treasury, true, TOKEN_2022_PROGRAM_ID);
34
37
  const getTreasuryLockPda = (mint) => web3_js_1.PublicKey.findProgramAddressSync([Buffer.from(TREASURY_LOCK_SEED), mint.toBuffer()], torchsdk_1.PROGRAM_ID);
38
+ exports.getTreasuryLockPda = getTreasuryLockPda;
35
39
  const getTreasuryLockTokenAccount = (mint, treasuryLock) => (0, spl_token_1.getAssociatedTokenAddressSync)(mint, treasuryLock, true, TOKEN_2022_PROGRAM_ID);
36
40
  const makeDummyProvider = (connection, payer) => {
37
41
  const dummyWallet = {
@@ -75,11 +79,11 @@ async function buildCreateFactionTransaction(connection, params) {
75
79
  const mint = grindPyreMint();
76
80
  // Derive PDAs
77
81
  const [globalConfig] = getGlobalConfigPda();
78
- const [bondingCurve] = getBondingCurvePda(mint.publicKey);
79
- const [treasury] = getTokenTreasuryPda(mint.publicKey);
82
+ const [bondingCurve] = (0, exports.getBondingCurvePda)(mint.publicKey);
83
+ const [treasury] = (0, exports.getTokenTreasuryPda)(mint.publicKey);
80
84
  const bondingCurveTokenAccount = (0, spl_token_1.getAssociatedTokenAddressSync)(mint.publicKey, bondingCurve, true, TOKEN_2022_PROGRAM_ID);
81
85
  const treasuryTokenAccount = getTreasuryTokenAccount(mint.publicKey, treasury);
82
- const [treasuryLock] = getTreasuryLockPda(mint.publicKey);
86
+ const [treasuryLock] = (0, exports.getTreasuryLockPda)(mint.publicKey);
83
87
  const treasuryLockTokenAccount = getTreasuryLockTokenAccount(mint.publicKey, treasuryLock);
84
88
  const tx = new web3_js_1.Transaction();
85
89
  const provider = makeDummyProvider(connection, creator);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pyre-world-kit",
3
- "version": "1.0.18",
3
+ "version": "1.0.20",
4
4
  "description": "Agent-first faction warfare kit — game-semantic wrapper over torchsdk",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
package/src/actions.ts CHANGED
@@ -106,7 +106,7 @@ import {
106
106
  mapTokenStatusFilter,
107
107
  } from './mappers';
108
108
 
109
- import { buildCreateFactionTransaction, isPyreMint } from './vanity';
109
+ import { buildCreateFactionTransaction, isPyreMint, getBondingCurvePda, getTokenTreasuryPda, getTreasuryLockPda } from './vanity';
110
110
 
111
111
  // ─── Blacklist ──────────────────────────────────────────────────────
112
112
  // Mints from previous swarm runs. Agents should skip these and only
@@ -181,13 +181,26 @@ export async function getFaction(
181
181
  return mapTokenDetailToFaction(detail);
182
182
  }
183
183
 
184
- /** Get faction members (top holders) */
184
+ /** Get faction members (top holders, excluding program-owned accounts) */
185
185
  export async function getMembers(
186
186
  connection: Connection,
187
187
  mint: string,
188
188
  limit?: number,
189
189
  ): Promise<MembersResult> {
190
- const result = await getHolders(connection, mint, limit);
190
+ const mintPk = new PublicKey(mint);
191
+ const [bondingCurve] = getBondingCurvePda(mintPk);
192
+ const [treasury] = getTokenTreasuryPda(mintPk);
193
+ const [treasuryLock] = getTreasuryLockPda(mintPk);
194
+ const excluded = new Set([
195
+ bondingCurve.toString(),
196
+ treasury.toString(),
197
+ treasuryLock.toString(),
198
+ ]);
199
+
200
+ // Fetch extra to compensate for filtered-out program accounts
201
+ const result = await getHolders(connection, mint, (limit ?? 10) + 5);
202
+ result.holders = result.holders.filter(h => !excluded.has(h.address));
203
+ if (limit) result.holders = result.holders.slice(0, limit);
191
204
  return mapHoldersResult(result);
192
205
  }
193
206
 
package/src/intel.ts CHANGED
@@ -18,7 +18,7 @@ import {
18
18
  import type { TokenDetail, TokenSummary } from 'torchsdk';
19
19
 
20
20
  import { mapFactionStatus } from './mappers';
21
- import { isPyreMint } from './vanity';
21
+ import { isPyreMint, getBondingCurvePda, getTokenTreasuryPda, getTreasuryLockPda } from './vanity';
22
22
  import type {
23
23
  FactionPower,
24
24
  AllianceCluster,
@@ -75,7 +75,9 @@ export async function getFactionLeaderboard(
75
75
  razed: 'reclaimed',
76
76
  };
77
77
  const sdkStatus = opts?.status ? statusMap[opts.status] as any : 'all';
78
- const result = await getTokens(connection, { limit: opts?.limit ?? 100, status: sdkStatus });
78
+ // Fetch more than requested to account for non-pyre tokens being filtered out
79
+ const fetchLimit = Math.min((opts?.limit ?? 20) * 3, 100);
80
+ const result = await getTokens(connection, { limit: fetchLimit, status: sdkStatus });
79
81
  const pyreFactions = result.tokens.filter(t => isPyreMint(t.mint));
80
82
 
81
83
  const powers: FactionPower[] = pyreFactions.map((t) => ({
@@ -111,7 +113,7 @@ export async function detectAlliances(
111
113
  // Fetch holders for each faction in parallel
112
114
  const holdersPerFaction = await Promise.all(
113
115
  mints.map(async (mint) => {
114
- const result = await getHolders(connection, mint, holderLimit);
116
+ const result = await getPyreHolders(connection, mint, holderLimit);
115
117
  return { mint, holders: new Set(result.holders.map(h => h.address)) };
116
118
  })
117
119
  );
@@ -162,7 +164,7 @@ export async function getFactionRivals(
162
164
  const allFactions = await getTokens(connection, { limit: 20, sort: 'volume' });
163
165
  for (const faction of allFactions.tokens.filter(t => isPyreMint(t.mint))) {
164
166
  if (faction.mint === mint) continue;
165
- const holders = await getHolders(connection, faction.mint, 50);
167
+ const holders = await getPyreHolders(connection, faction.mint, 50);
166
168
  const holderAddrs = new Set(holders.holders.map(h => h.address));
167
169
  const overlap = [...defectors].filter(d => holderAddrs.has(d)).length;
168
170
  if (overlap > 0) {
@@ -258,7 +260,7 @@ export async function getAgentFactions(
258
260
  await Promise.all(
259
261
  pyreFactions.map(async (faction) => {
260
262
  try {
261
- const holders = await getHolders(connection, faction.mint, 100);
263
+ const holders = await getPyreHolders(connection, faction.mint, 100);
262
264
  const holding = holders.holders.find(h => h.address === wallet);
263
265
  if (holding && holding.balance > 0) {
264
266
  positions.push({
@@ -357,15 +359,10 @@ export async function getWorldFeed(
357
359
  export async function getWorldStats(
358
360
  connection: Connection,
359
361
  ): Promise<WorldStats> {
360
- const [all, rising, ascended] = await Promise.all([
361
- getTokens(connection, { limit: 200, status: 'all' }),
362
- getTokens(connection, { limit: 100, status: 'bonding' }),
363
- getTokens(connection, { limit: 100, status: 'migrated' }),
364
- ]);
365
-
362
+ const all = await getTokens(connection, { limit: 200, status: 'all' });
366
363
  const pyreAll = all.tokens.filter(t => isPyreMint(t.mint));
367
- const pyreRising = rising.tokens.filter(t => isPyreMint(t.mint));
368
- const pyreAscended = ascended.tokens.filter(t => isPyreMint(t.mint));
364
+ const pyreRising = pyreAll.filter(t => t.status === 'bonding');
365
+ const pyreAscended = pyreAll.filter(t => t.status === 'migrated');
369
366
  const allFactions = [...pyreRising, ...pyreAscended];
370
367
  const totalSolLocked = allFactions.reduce((sum, t) => sum + t.market_cap_sol, 0);
371
368
 
@@ -400,6 +397,18 @@ export async function getWorldStats(
400
397
  };
401
398
  }
402
399
 
400
+ /** Fetch holders excluding program-owned accounts (bonding curve, treasury, treasury lock) */
401
+ async function getPyreHolders(connection: Connection, mint: string, limit: number) {
402
+ const mintPk = new PublicKey(mint);
403
+ const [bondingCurve] = getBondingCurvePda(mintPk);
404
+ const [treasury] = getTokenTreasuryPda(mintPk);
405
+ const [treasuryLock] = getTreasuryLockPda(mintPk);
406
+ const excluded = new Set([bondingCurve.toString(), treasury.toString(), treasuryLock.toString()]);
407
+ const result = await getHolders(connection, mint, limit + 5);
408
+ result.holders = result.holders.filter(h => !excluded.has(h.address)).slice(0, limit);
409
+ return result;
410
+ }
411
+
403
412
  // ─── Internal Helpers ──────────────────────────────────────────────
404
413
 
405
414
  function computePowerScore(t: TokenDetail): number {
package/src/vanity.ts CHANGED
@@ -39,16 +39,16 @@ import idl from 'torchsdk/dist/torch_market.json'
39
39
  const getGlobalConfigPda = (): [PublicKey, number] =>
40
40
  PublicKey.findProgramAddressSync([Buffer.from(GLOBAL_CONFIG_SEED)], PROGRAM_ID)
41
41
 
42
- const getBondingCurvePda = (mint: PublicKey): [PublicKey, number] =>
42
+ export const getBondingCurvePda = (mint: PublicKey): [PublicKey, number] =>
43
43
  PublicKey.findProgramAddressSync([Buffer.from(BONDING_CURVE_SEED), mint.toBuffer()], PROGRAM_ID)
44
44
 
45
- const getTokenTreasuryPda = (mint: PublicKey): [PublicKey, number] =>
45
+ export const getTokenTreasuryPda = (mint: PublicKey): [PublicKey, number] =>
46
46
  PublicKey.findProgramAddressSync([Buffer.from(TREASURY_SEED), mint.toBuffer()], PROGRAM_ID)
47
47
 
48
48
  const getTreasuryTokenAccount = (mint: PublicKey, treasury: PublicKey): PublicKey =>
49
49
  getAssociatedTokenAddressSync(mint, treasury, true, TOKEN_2022_PROGRAM_ID)
50
50
 
51
- const getTreasuryLockPda = (mint: PublicKey): [PublicKey, number] =>
51
+ export const getTreasuryLockPda = (mint: PublicKey): [PublicKey, number] =>
52
52
  PublicKey.findProgramAddressSync([Buffer.from(TREASURY_LOCK_SEED), mint.toBuffer()], PROGRAM_ID)
53
53
 
54
54
  const getTreasuryLockTokenAccount = (mint: PublicKey, treasuryLock: PublicKey): PublicKey =>