pyre-world-kit 3.2.2 → 3.2.4
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/providers/intel.provider.js +10 -7
- package/package.json +1 -1
- package/readme.md +11 -0
- package/src/providers/intel.provider.ts +10 -7
|
@@ -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.
|
|
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,
|
|
81
|
+
await Promise.all([...balanceMap.entries()].map(async ([mint, rawBalance]) => {
|
|
80
82
|
try {
|
|
81
83
|
const faction = await this.actionProvider.getFaction(mint);
|
|
82
|
-
const
|
|
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:
|
|
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.
|
|
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
package/readme.md
CHANGED
|
@@ -221,6 +221,17 @@ await kit.state.getStronghold() // full vault info (resolved once, ca
|
|
|
221
221
|
- defect: -0.2, fud: -0.15, infiltrate: -0.5
|
|
222
222
|
- message: +0.05, war_loan: +0.1
|
|
223
223
|
|
|
224
|
+
### Unit Conventions
|
|
225
|
+
|
|
226
|
+
| Value | Unit | Example |
|
|
227
|
+
|-------|------|---------|
|
|
228
|
+
| **Token amounts** (holdings, defect, war loan collateral) | Raw (6 decimals) | `1500000000000` = 1,500,000 tokens |
|
|
229
|
+
| **SOL amounts** (price, market cap, vault balance) | SOL (not lamports) | `0.5` = 0.5 SOL |
|
|
230
|
+
| **SOL in transactions** (join amount_sol) | Lamports | `100000000` = 0.1 SOL |
|
|
231
|
+
| **P&L totals** (total_sol_spent, total_sol_received) | Lamports | `5000000000` = 5 SOL |
|
|
232
|
+
|
|
233
|
+
`TOKEN_MULTIPLIER = 1_000_000` (10^6). `getHoldings()` and `getBalance()` return raw token amounts. `getAgentFactions()` returns human-readable balance and SOL values for display.
|
|
234
|
+
|
|
224
235
|
### IntelProvider
|
|
225
236
|
|
|
226
237
|
Strategic intelligence composed from action + chain data. Includes social graph-based faction discovery.
|
|
@@ -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.
|
|
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,
|
|
69
|
+
[...balanceMap.entries()].map(async ([mint, rawBalance]) => {
|
|
68
70
|
try {
|
|
69
71
|
const faction = await this.actionProvider.getFaction(mint)
|
|
70
|
-
const
|
|
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:
|
|
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.
|
|
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
|
}
|