pyre-world-kit 1.0.5 → 1.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/dist/actions.js +32 -1
- package/package.json +1 -1
- package/src/actions.ts +33 -1
package/dist/actions.js
CHANGED
|
@@ -61,7 +61,38 @@ async function getFactions(connection, params) {
|
|
|
61
61
|
sort: params.sort,
|
|
62
62
|
} : undefined;
|
|
63
63
|
const result = await (0, torchsdk_1.getTokens)(connection, sdkParams);
|
|
64
|
-
|
|
64
|
+
const listResult = (0, mappers_1.mapTokenListResult)(result);
|
|
65
|
+
// Enrich ascended factions with live pool price (list endpoint only has stale bonding curve mcap)
|
|
66
|
+
const ascended = listResult.factions.filter(f => f.status === 'ascended');
|
|
67
|
+
if (ascended.length > 0) {
|
|
68
|
+
await Promise.all(ascended.map(async (faction) => {
|
|
69
|
+
try {
|
|
70
|
+
const mint = new web3_js_1.PublicKey(faction.mint);
|
|
71
|
+
const raydium = (0, torchsdk_1.getRaydiumMigrationAccounts)(mint);
|
|
72
|
+
const [vault0Info, vault1Info] = await Promise.all([
|
|
73
|
+
connection.getTokenAccountBalance(raydium.token0Vault),
|
|
74
|
+
connection.getTokenAccountBalance(raydium.token1Vault),
|
|
75
|
+
]);
|
|
76
|
+
const vault0 = Number(vault0Info.value.amount);
|
|
77
|
+
const vault1 = Number(vault1Info.value.amount);
|
|
78
|
+
const solReserves = raydium.isWsolToken0 ? vault0 : vault1;
|
|
79
|
+
const tokenReserves = raydium.isWsolToken0 ? vault1 : vault0;
|
|
80
|
+
if (tokenReserves > 0) {
|
|
81
|
+
// solReserves in lamports, tokenReserves in base units (10^6)
|
|
82
|
+
const LAMPORTS = 1_000_000_000;
|
|
83
|
+
const TOKEN_MUL = 1_000_000;
|
|
84
|
+
const priceInSol = (solReserves * TOKEN_MUL) / (tokenReserves * LAMPORTS);
|
|
85
|
+
const TOTAL_SUPPLY = 1_000_000_000 * TOKEN_MUL;
|
|
86
|
+
faction.price_sol = priceInSol;
|
|
87
|
+
faction.market_cap_sol = (priceInSol * TOTAL_SUPPLY) / TOKEN_MUL;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
catch {
|
|
91
|
+
// Pool may not exist yet — keep stale values
|
|
92
|
+
}
|
|
93
|
+
}));
|
|
94
|
+
}
|
|
95
|
+
return listResult;
|
|
65
96
|
}
|
|
66
97
|
/** Get detailed info for a single faction */
|
|
67
98
|
async function getFaction(connection, mint) {
|
package/package.json
CHANGED
package/src/actions.ts
CHANGED
|
@@ -119,7 +119,39 @@ export async function getFactions(
|
|
|
119
119
|
sort: params.sort,
|
|
120
120
|
} : undefined;
|
|
121
121
|
const result = await getTokens(connection, sdkParams);
|
|
122
|
-
|
|
122
|
+
const listResult = mapTokenListResult(result);
|
|
123
|
+
|
|
124
|
+
// Enrich ascended factions with live pool price (list endpoint only has stale bonding curve mcap)
|
|
125
|
+
const ascended = listResult.factions.filter(f => f.status === 'ascended');
|
|
126
|
+
if (ascended.length > 0) {
|
|
127
|
+
await Promise.all(ascended.map(async (faction) => {
|
|
128
|
+
try {
|
|
129
|
+
const mint = new PublicKey(faction.mint);
|
|
130
|
+
const raydium = getRaydiumMigrationAccounts(mint);
|
|
131
|
+
const [vault0Info, vault1Info] = await Promise.all([
|
|
132
|
+
connection.getTokenAccountBalance(raydium.token0Vault),
|
|
133
|
+
connection.getTokenAccountBalance(raydium.token1Vault),
|
|
134
|
+
]);
|
|
135
|
+
const vault0 = Number(vault0Info.value.amount);
|
|
136
|
+
const vault1 = Number(vault1Info.value.amount);
|
|
137
|
+
const solReserves = raydium.isWsolToken0 ? vault0 : vault1;
|
|
138
|
+
const tokenReserves = raydium.isWsolToken0 ? vault1 : vault0;
|
|
139
|
+
if (tokenReserves > 0) {
|
|
140
|
+
// solReserves in lamports, tokenReserves in base units (10^6)
|
|
141
|
+
const LAMPORTS = 1_000_000_000;
|
|
142
|
+
const TOKEN_MUL = 1_000_000;
|
|
143
|
+
const priceInSol = (solReserves * TOKEN_MUL) / (tokenReserves * LAMPORTS);
|
|
144
|
+
const TOTAL_SUPPLY = 1_000_000_000 * TOKEN_MUL;
|
|
145
|
+
faction.price_sol = priceInSol;
|
|
146
|
+
faction.market_cap_sol = (priceInSol * TOTAL_SUPPLY) / TOKEN_MUL;
|
|
147
|
+
}
|
|
148
|
+
} catch {
|
|
149
|
+
// Pool may not exist yet — keep stale values
|
|
150
|
+
}
|
|
151
|
+
}));
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
return listResult;
|
|
123
155
|
}
|
|
124
156
|
|
|
125
157
|
/** Get detailed info for a single faction */
|