pyre-world-kit 2.0.9 → 2.0.11

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/index.d.ts CHANGED
@@ -7,7 +7,7 @@
7
7
  */
8
8
  export type { FactionStatus, FactionTier, Strategy, AgentHealth, FactionSummary, FactionDetail, Stronghold, AgentLink, Comms, WarChest, WarLoan, WarLoanWithAgent, Member, FactionListResult, MembersResult, CommsResult, AllWarLoansResult, WarLoanQuote, LaunchFactionParams, JoinFactionParams, DirectJoinFactionParams, DefectParams, MessageFactionParams, FudFactionParams, RallyParams, RequestWarLoanParams, RepayWarLoanParams, SiegeParams, TradeOnDexParams, ClaimSpoilsParams, CreateStrongholdParams, FundStrongholdParams, WithdrawFromStrongholdParams, RecruitAgentParams, ExileAgentParams, CoupParams, WithdrawAssetsParams, AscendParams, RazeParams, TitheParams, ConvertTitheParams, JoinFactionResult, LaunchFactionResult, TransactionResult, EphemeralAgent, SaidVerification, ConfirmResult, FactionSortOption, FactionStatusFilter, FactionListParams, FactionPower, AllianceCluster, RivalFaction, AgentProfile, AgentFactionPosition, WorldEventType, WorldEvent, WorldStats, RegistryProfile, RegistryWalletLink, CheckpointParams, RegisterAgentParams, LinkAgentWalletParams, UnlinkAgentWalletParams, TransferAgentAuthorityParams, } from './types';
9
9
  export { getFactions, getFaction, getMembers, getComms, getJoinQuote, getDefectQuote, getStronghold, getStrongholdForAgent, getAgentLink, getLinkedAgents, getWarChest, getWarLoan, getAllWarLoans, getMaxWarLoan, blacklistMints, isBlacklistedMint, getBlacklistedMints, launchFaction, joinFaction, directJoinFaction, defect, messageFaction, fudFaction, rally, requestWarLoan, repayWarLoan, tradeOnDex, claimSpoils, createStronghold, fundStronghold, withdrawFromStronghold, recruitAgent, exileAgent, coup, withdrawAssets, siege, ascend, raze, tithe, convertTithe, verifyAgent, confirmAction, createEphemeralAgent, getDexPool, getDexVaults, } from './actions';
10
- export { getFactionPower, getFactionLeaderboard, detectAlliances, getFactionRivals, getAgentProfile, getAgentFactions, getWorldFeed, getWorldStats, } from './intel';
10
+ export { getFactionPower, getFactionLeaderboard, detectAlliances, getFactionRivals, getAgentProfile, getAgentFactions, getWorldFeed, getWorldStats, getAgentSolLamports, startVaultPnlTracker, } from './intel';
11
11
  export { isPyreMint, grindPyreMint } from './vanity';
12
12
  export { REGISTRY_PROGRAM_ID, getAgentProfilePda, getAgentWalletLinkPda, getRegistryProfile, getRegistryWalletLink, buildRegisterAgentTransaction, buildCheckpointTransaction, buildLinkAgentWalletTransaction, buildUnlinkAgentWalletTransaction, buildTransferAgentAuthorityTransaction, } from './registry';
13
13
  export { PROGRAM_ID, LAMPORTS_PER_SOL, TOKEN_MULTIPLIER, TOTAL_SUPPLY } from 'torchsdk';
package/dist/index.js CHANGED
@@ -8,7 +8,7 @@
8
8
  */
9
9
  Object.defineProperty(exports, "__esModule", { value: true });
10
10
  exports.getAgentProfile = exports.getFactionRivals = exports.detectAlliances = exports.getFactionLeaderboard = exports.getFactionPower = exports.getDexVaults = exports.getDexPool = exports.createEphemeralAgent = exports.confirmAction = exports.verifyAgent = exports.convertTithe = exports.tithe = exports.raze = exports.ascend = exports.siege = exports.withdrawAssets = exports.coup = exports.exileAgent = exports.recruitAgent = exports.withdrawFromStronghold = exports.fundStronghold = exports.createStronghold = exports.claimSpoils = exports.tradeOnDex = exports.repayWarLoan = exports.requestWarLoan = exports.rally = exports.fudFaction = exports.messageFaction = exports.defect = exports.directJoinFaction = exports.joinFaction = exports.launchFaction = exports.getBlacklistedMints = exports.isBlacklistedMint = exports.blacklistMints = exports.getMaxWarLoan = exports.getAllWarLoans = exports.getWarLoan = exports.getWarChest = exports.getLinkedAgents = exports.getAgentLink = exports.getStrongholdForAgent = exports.getStronghold = exports.getDefectQuote = exports.getJoinQuote = exports.getComms = exports.getMembers = exports.getFaction = exports.getFactions = void 0;
11
- exports.TOTAL_SUPPLY = exports.TOKEN_MULTIPLIER = exports.LAMPORTS_PER_SOL = exports.PROGRAM_ID = exports.buildTransferAgentAuthorityTransaction = exports.buildUnlinkAgentWalletTransaction = exports.buildLinkAgentWalletTransaction = exports.buildCheckpointTransaction = exports.buildRegisterAgentTransaction = exports.getRegistryWalletLink = exports.getRegistryProfile = exports.getAgentWalletLinkPda = exports.getAgentProfilePda = exports.REGISTRY_PROGRAM_ID = exports.grindPyreMint = exports.isPyreMint = exports.getWorldStats = exports.getWorldFeed = exports.getAgentFactions = void 0;
11
+ exports.TOTAL_SUPPLY = exports.TOKEN_MULTIPLIER = exports.LAMPORTS_PER_SOL = exports.PROGRAM_ID = exports.buildTransferAgentAuthorityTransaction = exports.buildUnlinkAgentWalletTransaction = exports.buildLinkAgentWalletTransaction = exports.buildCheckpointTransaction = exports.buildRegisterAgentTransaction = exports.getRegistryWalletLink = exports.getRegistryProfile = exports.getAgentWalletLinkPda = exports.getAgentProfilePda = exports.REGISTRY_PROGRAM_ID = exports.grindPyreMint = exports.isPyreMint = exports.startVaultPnlTracker = exports.getAgentSolLamports = exports.getWorldStats = exports.getWorldFeed = exports.getAgentFactions = void 0;
12
12
  // ─── Actions ───────────────────────────────────────────────────────
13
13
  var actions_1 = require("./actions");
14
14
  // Read operations
@@ -73,6 +73,8 @@ Object.defineProperty(exports, "getAgentProfile", { enumerable: true, get: funct
73
73
  Object.defineProperty(exports, "getAgentFactions", { enumerable: true, get: function () { return intel_1.getAgentFactions; } });
74
74
  Object.defineProperty(exports, "getWorldFeed", { enumerable: true, get: function () { return intel_1.getWorldFeed; } });
75
75
  Object.defineProperty(exports, "getWorldStats", { enumerable: true, get: function () { return intel_1.getWorldStats; } });
76
+ Object.defineProperty(exports, "getAgentSolLamports", { enumerable: true, get: function () { return intel_1.getAgentSolLamports; } });
77
+ Object.defineProperty(exports, "startVaultPnlTracker", { enumerable: true, get: function () { return intel_1.startVaultPnlTracker; } });
76
78
  // ─── Vanity ─────────────────────────────────────────────────────────
77
79
  var vanity_1 = require("./vanity");
78
80
  Object.defineProperty(exports, "isPyreMint", { enumerable: true, get: function () { return vanity_1.isPyreMint; } });
package/dist/intel.d.ts CHANGED
@@ -60,3 +60,26 @@ export declare function getWorldFeed(connection: Connection, opts?: {
60
60
  * Global stats: total factions, total agents, total SOL locked.
61
61
  */
62
62
  export declare function getWorldStats(connection: Connection): Promise<WorldStats>;
63
+ /**
64
+ * Get total SOL balance in lamports for an agent: vault + wallet.
65
+ * Checks vault first (where most SOL flows), falls back to wallet if no vault.
66
+ * Returns the combined balance so P&L captures all SOL movement.
67
+ */
68
+ export declare function getAgentSolLamports(connection: Connection, wallet: string): Promise<number>;
69
+ /**
70
+ * Start tracking P&L for a single action/tick.
71
+ *
72
+ * Snapshots wallet + vault SOL before the action. Call `finish()` after
73
+ * to get the diff. Covers both vault and wallet flows so no SOL is missed.
74
+ *
75
+ * Usage:
76
+ * const pnl = await startVaultPnlTracker(connection, wallet)
77
+ * // ... do action ...
78
+ * const { spent, received } = await pnl.finish()
79
+ */
80
+ export declare function startVaultPnlTracker(connection: Connection, wallet: string): Promise<{
81
+ finish: () => Promise<{
82
+ spent: number;
83
+ received: number;
84
+ }>;
85
+ }>;
package/dist/intel.js CHANGED
@@ -47,6 +47,8 @@ exports.getAgentProfile = getAgentProfile;
47
47
  exports.getAgentFactions = getAgentFactions;
48
48
  exports.getWorldFeed = getWorldFeed;
49
49
  exports.getWorldStats = getWorldStats;
50
+ exports.getAgentSolLamports = getAgentSolLamports;
51
+ exports.startVaultPnlTracker = startVaultPnlTracker;
50
52
  const web3_js_1 = require("@solana/web3.js");
51
53
  const torchsdk_1 = require("torchsdk");
52
54
  const mappers_1 = require("./mappers");
@@ -269,15 +271,8 @@ async function getAgentFactions(connection, wallet, factionLimit = 50) {
269
271
  const faction = factionMap.get(mint);
270
272
  if (!faction)
271
273
  continue;
272
- // Get holder percentage from holders list
273
- let percentage = 0;
274
- try {
275
- const holders = await getPyreHolders(connection, mint, 100);
276
- const holding = holders.holders.find(h => h.address === wallet);
277
- if (holding)
278
- percentage = holding.percentage;
279
- }
280
- catch { }
274
+ // balance / 1B total supply
275
+ const percentage = (balance / 1_000_000_000) * 100;
281
276
  positions.push({
282
277
  mint,
283
278
  name: faction.name,
@@ -401,6 +396,51 @@ async function getPyreHolders(connection, mint, limit) {
401
396
  result.holders = result.holders.filter(h => !excluded.has(h.address)).slice(0, limit);
402
397
  return result;
403
398
  }
399
+ // ─── Vault P&L ────────────────────────────────────────────────────
400
+ /**
401
+ * Get total SOL balance in lamports for an agent: vault + wallet.
402
+ * Checks vault first (where most SOL flows), falls back to wallet if no vault.
403
+ * Returns the combined balance so P&L captures all SOL movement.
404
+ */
405
+ async function getAgentSolLamports(connection, wallet) {
406
+ const walletPk = new web3_js_1.PublicKey(wallet);
407
+ let total = 0;
408
+ try {
409
+ total += await connection.getBalance(walletPk);
410
+ }
411
+ catch { }
412
+ try {
413
+ const vault = await (0, torchsdk_1.getVaultForWallet)(connection, wallet);
414
+ if (vault)
415
+ total += Math.round(vault.sol_balance * 1e9);
416
+ }
417
+ catch { }
418
+ return total;
419
+ }
420
+ /**
421
+ * Start tracking P&L for a single action/tick.
422
+ *
423
+ * Snapshots wallet + vault SOL before the action. Call `finish()` after
424
+ * to get the diff. Covers both vault and wallet flows so no SOL is missed.
425
+ *
426
+ * Usage:
427
+ * const pnl = await startVaultPnlTracker(connection, wallet)
428
+ * // ... do action ...
429
+ * const { spent, received } = await pnl.finish()
430
+ */
431
+ async function startVaultPnlTracker(connection, wallet) {
432
+ const before = await getAgentSolLamports(connection, wallet);
433
+ return {
434
+ async finish() {
435
+ const after = await getAgentSolLamports(connection, wallet);
436
+ const diff = after - before;
437
+ return {
438
+ spent: diff < 0 ? Math.abs(diff) : 0,
439
+ received: diff > 0 ? diff : 0,
440
+ };
441
+ },
442
+ };
443
+ }
404
444
  // ─── Internal Helpers ──────────────────────────────────────────────
405
445
  function computePowerScore(t) {
406
446
  const mcWeight = 0.4;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pyre-world-kit",
3
- "version": "2.0.9",
3
+ "version": "2.0.11",
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/index.ts CHANGED
@@ -152,6 +152,8 @@ export {
152
152
  getAgentFactions,
153
153
  getWorldFeed,
154
154
  getWorldStats,
155
+ getAgentSolLamports,
156
+ startVaultPnlTracker,
155
157
  } from './intel';
156
158
 
157
159
  // ─── Vanity ─────────────────────────────────────────────────────────
package/src/intel.ts CHANGED
@@ -295,13 +295,8 @@ export async function getAgentFactions(
295
295
  const faction = factionMap.get(mint);
296
296
  if (!faction) continue;
297
297
 
298
- // Get holder percentage from holders list
299
- let percentage = 0;
300
- try {
301
- const holders = await getPyreHolders(connection, mint, 100);
302
- const holding = holders.holders.find(h => h.address === wallet);
303
- if (holding) percentage = holding.percentage;
304
- } catch {}
298
+ // balance / 1B total supply
299
+ const percentage = (balance / 1_000_000_000) * 100;
305
300
 
306
301
  positions.push({
307
302
  mint,
@@ -444,6 +439,57 @@ async function getPyreHolders(connection: Connection, mint: string, limit: numbe
444
439
  return result;
445
440
  }
446
441
 
442
+ // ─── Vault P&L ────────────────────────────────────────────────────
443
+
444
+ /**
445
+ * Get total SOL balance in lamports for an agent: vault + wallet.
446
+ * Checks vault first (where most SOL flows), falls back to wallet if no vault.
447
+ * Returns the combined balance so P&L captures all SOL movement.
448
+ */
449
+ export async function getAgentSolLamports(
450
+ connection: Connection,
451
+ wallet: string,
452
+ ): Promise<number> {
453
+ const walletPk = new PublicKey(wallet);
454
+ let total = 0;
455
+ try {
456
+ total += await connection.getBalance(walletPk);
457
+ } catch {}
458
+ try {
459
+ const vault = await getVaultForWallet(connection, wallet);
460
+ if (vault) total += Math.round(vault.sol_balance * 1e9);
461
+ } catch {}
462
+ return total;
463
+ }
464
+
465
+ /**
466
+ * Start tracking P&L for a single action/tick.
467
+ *
468
+ * Snapshots wallet + vault SOL before the action. Call `finish()` after
469
+ * to get the diff. Covers both vault and wallet flows so no SOL is missed.
470
+ *
471
+ * Usage:
472
+ * const pnl = await startVaultPnlTracker(connection, wallet)
473
+ * // ... do action ...
474
+ * const { spent, received } = await pnl.finish()
475
+ */
476
+ export async function startVaultPnlTracker(
477
+ connection: Connection,
478
+ wallet: string,
479
+ ): Promise<{ finish: () => Promise<{ spent: number; received: number }> }> {
480
+ const before = await getAgentSolLamports(connection, wallet);
481
+ return {
482
+ async finish() {
483
+ const after = await getAgentSolLamports(connection, wallet);
484
+ const diff = after - before;
485
+ return {
486
+ spent: diff < 0 ? Math.abs(diff) : 0,
487
+ received: diff > 0 ? diff : 0,
488
+ };
489
+ },
490
+ };
491
+ }
492
+
447
493
  // ─── Internal Helpers ──────────────────────────────────────────────
448
494
 
449
495
  function computePowerScore(t: TokenDetail): number {