pyre-world-kit 3.2.2 → 3.2.3

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.
@@ -63,11 +63,13 @@ class IntelProvider {
63
63
  .catch(() => [])
64
64
  : Promise.resolve([]);
65
65
  const [walletValues, vaultValues] = await Promise.all([scanWallet, scanVault]);
66
- // Merge balances from both sources
66
+ // Merge raw balances from both sources
67
+ const TOKEN_MULTIPLIER = 1_000_000;
68
+ const TOTAL_SUPPLY_RAW = 1_000_000_000 * TOKEN_MULTIPLIER;
67
69
  const balanceMap = new Map();
68
70
  for (const a of [...walletValues, ...vaultValues]) {
69
71
  const mint = a.account.data.parsed.info.mint;
70
- const balance = Number(a.account.data.parsed.info.tokenAmount.uiAmount ?? 0);
72
+ const balance = Number(a.account.data.parsed.info.tokenAmount.amount ?? 0);
71
73
  if (balance > 0 && (0, vanity_1.isPyreMint)(mint) && !(0, util_1.isBlacklistedMint)(mint)) {
72
74
  balanceMap.set(mint, (balanceMap.get(mint) ?? 0) + balance);
73
75
  }
@@ -76,17 +78,18 @@ class IntelProvider {
76
78
  return [];
77
79
  // Per-mint faction lookups (parallel)
78
80
  const positions = [];
79
- await Promise.all([...balanceMap.entries()].map(async ([mint, balance]) => {
81
+ await Promise.all([...balanceMap.entries()].map(async ([mint, rawBalance]) => {
80
82
  try {
81
83
  const faction = await this.actionProvider.getFaction(mint);
82
- const percentage = (balance / 1_000_000_000) * 100;
84
+ const uiBalance = rawBalance / TOKEN_MULTIPLIER;
85
+ const percentage = (rawBalance / TOTAL_SUPPLY_RAW) * 100;
83
86
  positions.push({
84
87
  mint,
85
88
  name: faction.name,
86
89
  symbol: faction.symbol,
87
- balance,
90
+ balance: uiBalance,
88
91
  percentage,
89
- value_sol: balance * faction.price_sol,
92
+ value_sol: uiBalance * faction.price_sol,
90
93
  });
91
94
  }
92
95
  catch { }
@@ -120,7 +123,7 @@ class IntelProvider {
120
123
  const accounts = await this.connection.getParsedTokenAccountsByOwner(new web3_js_1.PublicKey(address), { programId: TOKEN_2022_PROGRAM_ID });
121
124
  for (const a of accounts.value) {
122
125
  const mint = a.account.data.parsed.info.mint;
123
- const balance = Number(a.account.data.parsed.info.tokenAmount.uiAmount ?? 0);
126
+ const balance = Number(a.account.data.parsed.info.tokenAmount.amount ?? 0);
124
127
  if (balance > 0 && (0, vanity_1.isPyreMint)(mint) && !(0, util_1.isBlacklistedMint)(mint)) {
125
128
  mints.push(mint);
126
129
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pyre-world-kit",
3
- "version": "3.2.2",
3
+ "version": "3.2.3",
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",
@@ -49,11 +49,13 @@ export class IntelProvider implements Intel {
49
49
 
50
50
  const [walletValues, vaultValues] = await Promise.all([scanWallet, scanVault])
51
51
 
52
- // Merge balances from both sources
52
+ // Merge raw balances from both sources
53
+ const TOKEN_MULTIPLIER = 1_000_000
54
+ const TOTAL_SUPPLY_RAW = 1_000_000_000 * TOKEN_MULTIPLIER
53
55
  const balanceMap = new Map<string, number>()
54
56
  for (const a of [...walletValues, ...vaultValues]) {
55
57
  const mint = a.account.data.parsed.info.mint as string
56
- const balance = Number(a.account.data.parsed.info.tokenAmount.uiAmount ?? 0)
58
+ const balance = Number(a.account.data.parsed.info.tokenAmount.amount ?? 0)
57
59
  if (balance > 0 && isPyreMint(mint) && !isBlacklistedMint(mint)) {
58
60
  balanceMap.set(mint, (balanceMap.get(mint) ?? 0) + balance)
59
61
  }
@@ -64,17 +66,18 @@ export class IntelProvider implements Intel {
64
66
  // Per-mint faction lookups (parallel)
65
67
  const positions: AgentFactionPosition[] = []
66
68
  await Promise.all(
67
- [...balanceMap.entries()].map(async ([mint, balance]) => {
69
+ [...balanceMap.entries()].map(async ([mint, rawBalance]) => {
68
70
  try {
69
71
  const faction = await this.actionProvider.getFaction(mint)
70
- const percentage = (balance / 1_000_000_000) * 100
72
+ const uiBalance = rawBalance / TOKEN_MULTIPLIER
73
+ const percentage = (rawBalance / TOTAL_SUPPLY_RAW) * 100
71
74
  positions.push({
72
75
  mint,
73
76
  name: faction.name,
74
77
  symbol: faction.symbol,
75
- balance,
78
+ balance: uiBalance,
76
79
  percentage,
77
- value_sol: balance * faction.price_sol,
80
+ value_sol: uiBalance * faction.price_sol,
78
81
  })
79
82
  } catch {}
80
83
  }),
@@ -119,7 +122,7 @@ export class IntelProvider implements Intel {
119
122
  )
120
123
  for (const a of accounts.value) {
121
124
  const mint = a.account.data.parsed.info.mint as string
122
- const balance = Number(a.account.data.parsed.info.tokenAmount.uiAmount ?? 0)
125
+ const balance = Number(a.account.data.parsed.info.tokenAmount.amount ?? 0)
123
126
  if (balance > 0 && isPyreMint(mint) && !isBlacklistedMint(mint)) {
124
127
  mints.push(mint)
125
128
  }