pyre-world-kit 1.0.5 → 1.0.7
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 +35 -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
|
+
// Use Promise.allSettled so a single failure doesn't block/break the list
|
|
67
|
+
const ascended = listResult.factions.filter(f => f.status === 'ascended');
|
|
68
|
+
if (ascended.length > 0) {
|
|
69
|
+
const enrichPromise = Promise.allSettled(ascended.map(async (faction) => {
|
|
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
|
+
const LAMPORTS = 1_000_000_000;
|
|
82
|
+
const TOKEN_MUL = 1_000_000;
|
|
83
|
+
const priceInSol = (solReserves * TOKEN_MUL) / (tokenReserves * LAMPORTS);
|
|
84
|
+
const TOTAL_SUPPLY = 1_000_000_000 * TOKEN_MUL;
|
|
85
|
+
faction.price_sol = priceInSol;
|
|
86
|
+
faction.market_cap_sol = (priceInSol * TOTAL_SUPPLY) / TOKEN_MUL;
|
|
87
|
+
}
|
|
88
|
+
}));
|
|
89
|
+
// Race enrichment against a 3s timeout so the list always loads
|
|
90
|
+
await Promise.race([
|
|
91
|
+
enrichPromise,
|
|
92
|
+
new Promise(resolve => setTimeout(resolve, 3000)),
|
|
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,41 @@ 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
|
+
// Use Promise.allSettled so a single failure doesn't block/break the list
|
|
126
|
+
const ascended = listResult.factions.filter(f => f.status === 'ascended');
|
|
127
|
+
if (ascended.length > 0) {
|
|
128
|
+
const enrichPromise = Promise.allSettled(ascended.map(async (faction) => {
|
|
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
|
+
const LAMPORTS = 1_000_000_000;
|
|
141
|
+
const TOKEN_MUL = 1_000_000;
|
|
142
|
+
const priceInSol = (solReserves * TOKEN_MUL) / (tokenReserves * LAMPORTS);
|
|
143
|
+
const TOTAL_SUPPLY = 1_000_000_000 * TOKEN_MUL;
|
|
144
|
+
faction.price_sol = priceInSol;
|
|
145
|
+
faction.market_cap_sol = (priceInSol * TOTAL_SUPPLY) / TOKEN_MUL;
|
|
146
|
+
}
|
|
147
|
+
}));
|
|
148
|
+
|
|
149
|
+
// Race enrichment against a 3s timeout so the list always loads
|
|
150
|
+
await Promise.race([
|
|
151
|
+
enrichPromise,
|
|
152
|
+
new Promise(resolve => setTimeout(resolve, 3000)),
|
|
153
|
+
]);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
return listResult;
|
|
123
157
|
}
|
|
124
158
|
|
|
125
159
|
/** Get detailed info for a single faction */
|