pyre-world-kit 1.0.0
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.d.ts +81 -0
- package/dist/actions.js +318 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +74 -0
- package/dist/intel.d.ts +61 -0
- package/dist/intel.js +342 -0
- package/dist/mappers.d.ts +31 -0
- package/dist/mappers.js +258 -0
- package/dist/types.d.ts +353 -0
- package/dist/types.js +9 -0
- package/dist/vanity.d.ts +14 -0
- package/dist/vanity.js +115 -0
- package/package.json +25 -0
- package/readme.md +203 -0
- package/src/actions.ts +523 -0
- package/src/index.ts +141 -0
- package/src/intel.ts +424 -0
- package/src/mappers.ts +302 -0
- package/src/types.ts +425 -0
- package/src/vanity.ts +159 -0
- package/tests/test_devnet_e2e.ts +401 -0
- package/tests/test_e2e.ts +213 -0
- package/tests/test_sim.ts +458 -0
- package/tsconfig.json +17 -0
package/dist/intel.js
ADDED
|
@@ -0,0 +1,342 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Pyre Kit Intel
|
|
4
|
+
*
|
|
5
|
+
* Game-specific utility functions that compose torchsdk reads into
|
|
6
|
+
* strategic intelligence. Agents use these to reason about the world.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.getFactionPower = getFactionPower;
|
|
10
|
+
exports.getFactionLeaderboard = getFactionLeaderboard;
|
|
11
|
+
exports.detectAlliances = detectAlliances;
|
|
12
|
+
exports.getFactionRivals = getFactionRivals;
|
|
13
|
+
exports.getAgentProfile = getAgentProfile;
|
|
14
|
+
exports.getAgentFactions = getAgentFactions;
|
|
15
|
+
exports.getWorldFeed = getWorldFeed;
|
|
16
|
+
exports.getWorldStats = getWorldStats;
|
|
17
|
+
const torchsdk_1 = require("torchsdk");
|
|
18
|
+
const mappers_1 = require("./mappers");
|
|
19
|
+
// ─── Faction Power & Rankings ──────────────────────────────────────
|
|
20
|
+
/**
|
|
21
|
+
* Calculate a faction's power score.
|
|
22
|
+
*
|
|
23
|
+
* Score = (market_cap_sol * 0.4) + (members * 0.2) + (war_chest_sol * 0.2)
|
|
24
|
+
* + (rallies * 0.1) + (progress * 0.1)
|
|
25
|
+
*
|
|
26
|
+
* Normalized to make comparison easy. Higher = stronger.
|
|
27
|
+
*/
|
|
28
|
+
async function getFactionPower(connection, mint) {
|
|
29
|
+
const t = await (0, torchsdk_1.getToken)(connection, mint);
|
|
30
|
+
const score = computePowerScore(t);
|
|
31
|
+
return {
|
|
32
|
+
mint: t.mint,
|
|
33
|
+
name: t.name,
|
|
34
|
+
symbol: t.symbol,
|
|
35
|
+
score,
|
|
36
|
+
market_cap_sol: t.market_cap_sol,
|
|
37
|
+
members: t.holders ?? 0,
|
|
38
|
+
war_chest_sol: t.treasury_sol_balance,
|
|
39
|
+
rallies: t.stars,
|
|
40
|
+
progress_percent: t.progress_percent,
|
|
41
|
+
status: (0, mappers_1.mapFactionStatus)(t.status),
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Ranked leaderboard of all factions by power score.
|
|
46
|
+
*/
|
|
47
|
+
async function getFactionLeaderboard(connection, opts) {
|
|
48
|
+
// Fetch all tokens (up to 1000)
|
|
49
|
+
const statusMap = {
|
|
50
|
+
rising: 'bonding',
|
|
51
|
+
ready: 'complete',
|
|
52
|
+
ascended: 'migrated',
|
|
53
|
+
razed: 'reclaimed',
|
|
54
|
+
};
|
|
55
|
+
const sdkStatus = opts?.status ? statusMap[opts.status] : 'all';
|
|
56
|
+
const result = await (0, torchsdk_1.getTokens)(connection, { limit: opts?.limit ?? 100, status: sdkStatus });
|
|
57
|
+
const powers = result.tokens.map((t) => ({
|
|
58
|
+
mint: t.mint,
|
|
59
|
+
name: t.name,
|
|
60
|
+
symbol: t.symbol,
|
|
61
|
+
score: computePowerScoreFromSummary(t),
|
|
62
|
+
market_cap_sol: t.market_cap_sol,
|
|
63
|
+
members: t.holders ?? 0,
|
|
64
|
+
war_chest_sol: 0, // Not available in summary
|
|
65
|
+
rallies: 0, // Not available in summary
|
|
66
|
+
progress_percent: t.progress_percent,
|
|
67
|
+
status: (0, mappers_1.mapFactionStatus)(t.status),
|
|
68
|
+
}));
|
|
69
|
+
powers.sort((a, b) => b.score - a.score);
|
|
70
|
+
return powers;
|
|
71
|
+
}
|
|
72
|
+
// ─── Alliance & Rivalry Detection ──────────────────────────────────
|
|
73
|
+
/**
|
|
74
|
+
* Detect alliances: factions with shared members.
|
|
75
|
+
*
|
|
76
|
+
* Given a set of faction mints, finds wallets holding multiple faction tokens.
|
|
77
|
+
* Returns alliance clusters showing which factions share members.
|
|
78
|
+
*/
|
|
79
|
+
async function detectAlliances(connection, mints, holderLimit = 50) {
|
|
80
|
+
// Fetch holders for each faction in parallel
|
|
81
|
+
const holdersPerFaction = await Promise.all(mints.map(async (mint) => {
|
|
82
|
+
const result = await (0, torchsdk_1.getHolders)(connection, mint, holderLimit);
|
|
83
|
+
return { mint, holders: new Set(result.holders.map(h => h.address)) };
|
|
84
|
+
}));
|
|
85
|
+
// Find overlapping holders between faction pairs
|
|
86
|
+
const clusters = [];
|
|
87
|
+
for (let i = 0; i < holdersPerFaction.length; i++) {
|
|
88
|
+
for (let j = i + 1; j < holdersPerFaction.length; j++) {
|
|
89
|
+
const a = holdersPerFaction[i];
|
|
90
|
+
const b = holdersPerFaction[j];
|
|
91
|
+
const shared = [...a.holders].filter(h => b.holders.has(h));
|
|
92
|
+
if (shared.length > 0) {
|
|
93
|
+
const minSize = Math.min(a.holders.size, b.holders.size);
|
|
94
|
+
clusters.push({
|
|
95
|
+
factions: [a.mint, b.mint],
|
|
96
|
+
shared_members: shared.length,
|
|
97
|
+
overlap_percent: minSize > 0 ? (shared.length / minSize) * 100 : 0,
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
clusters.sort((a, b) => b.shared_members - a.shared_members);
|
|
103
|
+
return clusters;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Find rival factions based on recent defection activity.
|
|
107
|
+
*
|
|
108
|
+
* Looks at recent sell messages to detect agents who have defected
|
|
109
|
+
* from or to this faction.
|
|
110
|
+
*/
|
|
111
|
+
async function getFactionRivals(connection, mint, limit = 50) {
|
|
112
|
+
// Get recent messages (sells include defection messages)
|
|
113
|
+
const msgs = await (0, torchsdk_1.getMessages)(connection, mint, limit);
|
|
114
|
+
const defectors = new Set(msgs.messages.map(m => m.sender));
|
|
115
|
+
// For each defector, check what other factions they hold
|
|
116
|
+
// This is a heuristic — we look at the messages to find patterns
|
|
117
|
+
// In practice, agents would track this over time
|
|
118
|
+
const rivalCounts = new Map();
|
|
119
|
+
// Get all factions to cross-reference
|
|
120
|
+
const allFactions = await (0, torchsdk_1.getTokens)(connection, { limit: 20, sort: 'volume' });
|
|
121
|
+
for (const faction of allFactions.tokens) {
|
|
122
|
+
if (faction.mint === mint)
|
|
123
|
+
continue;
|
|
124
|
+
const holders = await (0, torchsdk_1.getHolders)(connection, faction.mint, 50);
|
|
125
|
+
const holderAddrs = new Set(holders.holders.map(h => h.address));
|
|
126
|
+
const overlap = [...defectors].filter(d => holderAddrs.has(d)).length;
|
|
127
|
+
if (overlap > 0) {
|
|
128
|
+
rivalCounts.set(faction.mint, {
|
|
129
|
+
in: overlap, // Agents from this faction who also hold rival
|
|
130
|
+
out: overlap,
|
|
131
|
+
...(rivalCounts.get(faction.mint) ?? {}),
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
const rivals = [];
|
|
136
|
+
for (const [rivalMint, counts] of rivalCounts) {
|
|
137
|
+
const faction = allFactions.tokens.find(t => t.mint === rivalMint);
|
|
138
|
+
if (faction) {
|
|
139
|
+
rivals.push({
|
|
140
|
+
mint: rivalMint,
|
|
141
|
+
name: faction.name,
|
|
142
|
+
symbol: faction.symbol,
|
|
143
|
+
defections_in: counts.in,
|
|
144
|
+
defections_out: counts.out,
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
rivals.sort((a, b) => (b.defections_in + b.defections_out) - (a.defections_in + a.defections_out));
|
|
149
|
+
return rivals;
|
|
150
|
+
}
|
|
151
|
+
// ─── Agent Intelligence ────────────────────────────────────────────
|
|
152
|
+
/**
|
|
153
|
+
* Build an aggregate profile for an agent wallet.
|
|
154
|
+
*/
|
|
155
|
+
async function getAgentProfile(connection, wallet) {
|
|
156
|
+
// Fetch stronghold and SAID verification in parallel
|
|
157
|
+
const [vault, said] = await Promise.all([
|
|
158
|
+
(0, torchsdk_1.getVaultForWallet)(connection, wallet).catch(() => null),
|
|
159
|
+
(0, torchsdk_1.verifySaid)(wallet).catch(() => null),
|
|
160
|
+
]);
|
|
161
|
+
// Get factions this agent holds — requires scanning
|
|
162
|
+
// For now, check top factions for this holder
|
|
163
|
+
const factions = await getAgentFactions(connection, wallet);
|
|
164
|
+
// Find factions this wallet created
|
|
165
|
+
const allFactions = await (0, torchsdk_1.getTokens)(connection, { limit: 100 });
|
|
166
|
+
const founded = allFactions.tokens
|
|
167
|
+
.filter(t => t.mint) // TokenSummary doesn't have creator, so we skip for now
|
|
168
|
+
.map(t => t.mint);
|
|
169
|
+
const totalValue = factions.reduce((sum, f) => sum + f.value_sol, 0);
|
|
170
|
+
return {
|
|
171
|
+
wallet,
|
|
172
|
+
stronghold: vault ? {
|
|
173
|
+
address: vault.address,
|
|
174
|
+
creator: vault.creator,
|
|
175
|
+
authority: vault.authority,
|
|
176
|
+
sol_balance: vault.sol_balance,
|
|
177
|
+
total_deposited: vault.total_deposited,
|
|
178
|
+
total_withdrawn: vault.total_withdrawn,
|
|
179
|
+
total_spent: vault.total_spent,
|
|
180
|
+
total_received: vault.total_received,
|
|
181
|
+
linked_agents: vault.linked_wallets,
|
|
182
|
+
created_at: vault.created_at,
|
|
183
|
+
} : null,
|
|
184
|
+
factions_joined: factions,
|
|
185
|
+
factions_founded: [], // Would need per-token creator lookup
|
|
186
|
+
said_verification: said,
|
|
187
|
+
total_value_sol: totalValue + (vault?.sol_balance ?? 0),
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* List all factions an agent holds tokens in.
|
|
192
|
+
*
|
|
193
|
+
* Checks top factions for this wallet's holdings.
|
|
194
|
+
*/
|
|
195
|
+
async function getAgentFactions(connection, wallet, factionLimit = 50) {
|
|
196
|
+
const allFactions = await (0, torchsdk_1.getTokens)(connection, { limit: factionLimit });
|
|
197
|
+
const positions = [];
|
|
198
|
+
// Check each faction for this holder
|
|
199
|
+
await Promise.all(allFactions.tokens.map(async (faction) => {
|
|
200
|
+
try {
|
|
201
|
+
const holders = await (0, torchsdk_1.getHolders)(connection, faction.mint, 100);
|
|
202
|
+
const holding = holders.holders.find(h => h.address === wallet);
|
|
203
|
+
if (holding && holding.balance > 0) {
|
|
204
|
+
positions.push({
|
|
205
|
+
mint: faction.mint,
|
|
206
|
+
name: faction.name,
|
|
207
|
+
symbol: faction.symbol,
|
|
208
|
+
balance: holding.balance,
|
|
209
|
+
percentage: holding.percentage,
|
|
210
|
+
value_sol: holding.balance * faction.price_sol,
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
catch {
|
|
215
|
+
// Skip factions we can't read
|
|
216
|
+
}
|
|
217
|
+
}));
|
|
218
|
+
positions.sort((a, b) => b.value_sol - a.value_sol);
|
|
219
|
+
return positions;
|
|
220
|
+
}
|
|
221
|
+
// ─── World State ───────────────────────────────────────────────────
|
|
222
|
+
/**
|
|
223
|
+
* Aggregated recent activity across ALL factions.
|
|
224
|
+
*
|
|
225
|
+
* The "Bloomberg terminal" feed — launches, joins, defections, rallies.
|
|
226
|
+
*/
|
|
227
|
+
async function getWorldFeed(connection, opts) {
|
|
228
|
+
const factionLimit = opts?.factionLimit ?? 20;
|
|
229
|
+
const msgLimit = opts?.limit ?? 5;
|
|
230
|
+
const allFactions = await (0, torchsdk_1.getTokens)(connection, { limit: factionLimit, sort: 'newest' });
|
|
231
|
+
const events = [];
|
|
232
|
+
// Add launch events for each faction
|
|
233
|
+
for (const faction of allFactions.tokens) {
|
|
234
|
+
events.push({
|
|
235
|
+
type: 'launch',
|
|
236
|
+
faction_mint: faction.mint,
|
|
237
|
+
faction_name: faction.name,
|
|
238
|
+
timestamp: faction.created_at,
|
|
239
|
+
});
|
|
240
|
+
// Map status to events
|
|
241
|
+
if (faction.status === 'migrated') {
|
|
242
|
+
events.push({
|
|
243
|
+
type: 'ascend',
|
|
244
|
+
faction_mint: faction.mint,
|
|
245
|
+
faction_name: faction.name,
|
|
246
|
+
timestamp: faction.last_activity_at,
|
|
247
|
+
});
|
|
248
|
+
}
|
|
249
|
+
else if (faction.status === 'reclaimed') {
|
|
250
|
+
events.push({
|
|
251
|
+
type: 'raze',
|
|
252
|
+
faction_mint: faction.mint,
|
|
253
|
+
faction_name: faction.name,
|
|
254
|
+
timestamp: faction.last_activity_at,
|
|
255
|
+
});
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
// Get recent messages from top factions (messages = trade activity)
|
|
259
|
+
const topFactions = allFactions.tokens.slice(0, 10);
|
|
260
|
+
await Promise.all(topFactions.map(async (faction) => {
|
|
261
|
+
try {
|
|
262
|
+
const msgs = await (0, torchsdk_1.getMessages)(connection, faction.mint, msgLimit);
|
|
263
|
+
for (const msg of msgs.messages) {
|
|
264
|
+
events.push({
|
|
265
|
+
type: 'join', // Messages are trade-bundled, most are buys
|
|
266
|
+
faction_mint: faction.mint,
|
|
267
|
+
faction_name: faction.name,
|
|
268
|
+
agent: msg.sender,
|
|
269
|
+
timestamp: msg.timestamp,
|
|
270
|
+
signature: msg.signature,
|
|
271
|
+
message: msg.memo,
|
|
272
|
+
});
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
catch {
|
|
276
|
+
// Skip factions with no messages
|
|
277
|
+
}
|
|
278
|
+
}));
|
|
279
|
+
events.sort((a, b) => b.timestamp - a.timestamp);
|
|
280
|
+
return events.slice(0, opts?.limit ?? 100);
|
|
281
|
+
}
|
|
282
|
+
/**
|
|
283
|
+
* Global stats: total factions, total agents, total SOL locked.
|
|
284
|
+
*/
|
|
285
|
+
async function getWorldStats(connection) {
|
|
286
|
+
const [all, rising, ascended] = await Promise.all([
|
|
287
|
+
(0, torchsdk_1.getTokens)(connection, { limit: 1, status: 'all' }),
|
|
288
|
+
(0, torchsdk_1.getTokens)(connection, { limit: 100, status: 'bonding' }),
|
|
289
|
+
(0, torchsdk_1.getTokens)(connection, { limit: 100, status: 'migrated' }),
|
|
290
|
+
]);
|
|
291
|
+
const allFactions = [...rising.tokens, ...ascended.tokens];
|
|
292
|
+
const totalSolLocked = allFactions.reduce((sum, t) => sum + t.market_cap_sol, 0);
|
|
293
|
+
// Find most powerful
|
|
294
|
+
let mostPowerful = null;
|
|
295
|
+
let maxScore = 0;
|
|
296
|
+
for (const t of allFactions) {
|
|
297
|
+
const score = computePowerScoreFromSummary(t);
|
|
298
|
+
if (score > maxScore) {
|
|
299
|
+
maxScore = score;
|
|
300
|
+
mostPowerful = {
|
|
301
|
+
mint: t.mint,
|
|
302
|
+
name: t.name,
|
|
303
|
+
symbol: t.symbol,
|
|
304
|
+
score,
|
|
305
|
+
market_cap_sol: t.market_cap_sol,
|
|
306
|
+
members: t.holders ?? 0,
|
|
307
|
+
war_chest_sol: 0,
|
|
308
|
+
rallies: 0,
|
|
309
|
+
progress_percent: t.progress_percent,
|
|
310
|
+
status: (0, mappers_1.mapFactionStatus)(t.status),
|
|
311
|
+
};
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
return {
|
|
315
|
+
total_factions: all.total,
|
|
316
|
+
rising_factions: rising.total,
|
|
317
|
+
ascended_factions: ascended.total,
|
|
318
|
+
total_sol_locked: totalSolLocked,
|
|
319
|
+
most_powerful: mostPowerful,
|
|
320
|
+
};
|
|
321
|
+
}
|
|
322
|
+
// ─── Internal Helpers ──────────────────────────────────────────────
|
|
323
|
+
function computePowerScore(t) {
|
|
324
|
+
const mcWeight = 0.4;
|
|
325
|
+
const memberWeight = 0.2;
|
|
326
|
+
const chestWeight = 0.2;
|
|
327
|
+
const rallyWeight = 0.1;
|
|
328
|
+
const progressWeight = 0.1;
|
|
329
|
+
return ((t.market_cap_sol * mcWeight) +
|
|
330
|
+
((t.holders ?? 0) * memberWeight) +
|
|
331
|
+
(t.treasury_sol_balance * chestWeight) +
|
|
332
|
+
(t.stars * rallyWeight) +
|
|
333
|
+
(t.progress_percent * progressWeight));
|
|
334
|
+
}
|
|
335
|
+
function computePowerScoreFromSummary(t) {
|
|
336
|
+
const mcWeight = 0.4;
|
|
337
|
+
const memberWeight = 0.2;
|
|
338
|
+
const progressWeight = 0.1;
|
|
339
|
+
return ((t.market_cap_sol * mcWeight) +
|
|
340
|
+
((t.holders ?? 0) * memberWeight) +
|
|
341
|
+
(t.progress_percent * progressWeight));
|
|
342
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pyre Kit Mappers
|
|
3
|
+
*
|
|
4
|
+
* Internal mapping functions between Torch SDK types and Pyre game types.
|
|
5
|
+
*/
|
|
6
|
+
import type { TokenStatus, TokenSummary, TokenDetail, TokenStatusFilter, VaultInfo, VaultWalletLinkInfo, TokenMessage, LendingInfo, LoanPositionInfo, LoanPositionWithKey, Holder, HoldersResult, MessagesResult, TokenListResult, AllLoanPositionsResult, BuyTransactionResult, CreateTokenResult } from 'torchsdk';
|
|
7
|
+
import type { FactionStatus, FactionTier, FactionStatusFilter, Strategy, FactionSummary, FactionDetail, Stronghold, AgentLink, Comms, WarChest, WarLoan, WarLoanWithAgent, Member, FactionListResult, MembersResult, CommsResult, AllWarLoansResult, JoinFactionResult, LaunchFactionResult } from './types';
|
|
8
|
+
export declare function mapFactionStatus(status: TokenStatus): FactionStatus;
|
|
9
|
+
export declare function mapTokenStatus(status: FactionStatus): TokenStatus;
|
|
10
|
+
export declare function mapTokenStatusFilter(status: FactionStatusFilter): TokenStatusFilter;
|
|
11
|
+
/** Map SOL target to faction tier */
|
|
12
|
+
export declare function mapFactionTier(sol_target: number): FactionTier;
|
|
13
|
+
/** Infer tier from sol_target in SOL (not lamports) */
|
|
14
|
+
export declare function mapFactionTierFromSol(sol_target: number): FactionTier;
|
|
15
|
+
export declare function mapStrategy(vote: 'burn' | 'return'): Strategy;
|
|
16
|
+
export declare function mapVote(strategy: Strategy): 'burn' | 'return';
|
|
17
|
+
export declare function mapTokenSummaryToFaction(t: TokenSummary): FactionSummary;
|
|
18
|
+
export declare function mapTokenDetailToFaction(t: TokenDetail): FactionDetail;
|
|
19
|
+
export declare function mapVaultToStronghold(v: VaultInfo): Stronghold;
|
|
20
|
+
export declare function mapWalletLinkToAgentLink(l: VaultWalletLinkInfo): AgentLink;
|
|
21
|
+
export declare function mapTokenMessageToComms(m: TokenMessage): Comms;
|
|
22
|
+
export declare function mapLendingToWarChest(l: LendingInfo): WarChest;
|
|
23
|
+
export declare function mapLoanToWarLoan(l: LoanPositionInfo): WarLoan;
|
|
24
|
+
export declare function mapLoanWithKeyToWarLoan(l: LoanPositionWithKey): WarLoanWithAgent;
|
|
25
|
+
export declare function mapHolderToMember(h: Holder): Member;
|
|
26
|
+
export declare function mapTokenListResult(r: TokenListResult): FactionListResult;
|
|
27
|
+
export declare function mapHoldersResult(r: HoldersResult): MembersResult;
|
|
28
|
+
export declare function mapMessagesResult(r: MessagesResult): CommsResult;
|
|
29
|
+
export declare function mapAllLoansResult(r: AllLoanPositionsResult): AllWarLoansResult;
|
|
30
|
+
export declare function mapBuyResult(r: BuyTransactionResult): JoinFactionResult;
|
|
31
|
+
export declare function mapCreateResult(r: CreateTokenResult): LaunchFactionResult;
|
package/dist/mappers.js
ADDED
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Pyre Kit Mappers
|
|
4
|
+
*
|
|
5
|
+
* Internal mapping functions between Torch SDK types and Pyre game types.
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.mapFactionStatus = mapFactionStatus;
|
|
9
|
+
exports.mapTokenStatus = mapTokenStatus;
|
|
10
|
+
exports.mapTokenStatusFilter = mapTokenStatusFilter;
|
|
11
|
+
exports.mapFactionTier = mapFactionTier;
|
|
12
|
+
exports.mapFactionTierFromSol = mapFactionTierFromSol;
|
|
13
|
+
exports.mapStrategy = mapStrategy;
|
|
14
|
+
exports.mapVote = mapVote;
|
|
15
|
+
exports.mapTokenSummaryToFaction = mapTokenSummaryToFaction;
|
|
16
|
+
exports.mapTokenDetailToFaction = mapTokenDetailToFaction;
|
|
17
|
+
exports.mapVaultToStronghold = mapVaultToStronghold;
|
|
18
|
+
exports.mapWalletLinkToAgentLink = mapWalletLinkToAgentLink;
|
|
19
|
+
exports.mapTokenMessageToComms = mapTokenMessageToComms;
|
|
20
|
+
exports.mapLendingToWarChest = mapLendingToWarChest;
|
|
21
|
+
exports.mapLoanToWarLoan = mapLoanToWarLoan;
|
|
22
|
+
exports.mapLoanWithKeyToWarLoan = mapLoanWithKeyToWarLoan;
|
|
23
|
+
exports.mapHolderToMember = mapHolderToMember;
|
|
24
|
+
exports.mapTokenListResult = mapTokenListResult;
|
|
25
|
+
exports.mapHoldersResult = mapHoldersResult;
|
|
26
|
+
exports.mapMessagesResult = mapMessagesResult;
|
|
27
|
+
exports.mapAllLoansResult = mapAllLoansResult;
|
|
28
|
+
exports.mapBuyResult = mapBuyResult;
|
|
29
|
+
exports.mapCreateResult = mapCreateResult;
|
|
30
|
+
// ─── Status Mapping ────────────────────────────────────────────────
|
|
31
|
+
const STATUS_MAP = {
|
|
32
|
+
bonding: 'rising',
|
|
33
|
+
complete: 'ready',
|
|
34
|
+
migrated: 'ascended',
|
|
35
|
+
reclaimed: 'razed',
|
|
36
|
+
};
|
|
37
|
+
const STATUS_REVERSE = {
|
|
38
|
+
rising: 'bonding',
|
|
39
|
+
ready: 'complete',
|
|
40
|
+
ascended: 'migrated',
|
|
41
|
+
razed: 'reclaimed',
|
|
42
|
+
};
|
|
43
|
+
const STATUS_FILTER_REVERSE = {
|
|
44
|
+
rising: 'bonding',
|
|
45
|
+
ready: 'complete',
|
|
46
|
+
ascended: 'migrated',
|
|
47
|
+
razed: 'reclaimed',
|
|
48
|
+
all: 'all',
|
|
49
|
+
};
|
|
50
|
+
function mapFactionStatus(status) {
|
|
51
|
+
return STATUS_MAP[status];
|
|
52
|
+
}
|
|
53
|
+
function mapTokenStatus(status) {
|
|
54
|
+
return STATUS_REVERSE[status];
|
|
55
|
+
}
|
|
56
|
+
function mapTokenStatusFilter(status) {
|
|
57
|
+
return STATUS_FILTER_REVERSE[status];
|
|
58
|
+
}
|
|
59
|
+
// ─── Tier Mapping ──────────────────────────────────────────────────
|
|
60
|
+
/** Map SOL target to faction tier */
|
|
61
|
+
function mapFactionTier(sol_target) {
|
|
62
|
+
// Torch tiers: spark (≤50 SOL), flame (≤100 SOL), torch (200 SOL default)
|
|
63
|
+
if (sol_target <= 50_000_000_000)
|
|
64
|
+
return 'ember'; // ≤50 SOL in lamports
|
|
65
|
+
if (sol_target <= 100_000_000_000)
|
|
66
|
+
return 'blaze'; // ≤100 SOL
|
|
67
|
+
return 'inferno'; // 200 SOL (default)
|
|
68
|
+
}
|
|
69
|
+
/** Infer tier from sol_target in SOL (not lamports) */
|
|
70
|
+
function mapFactionTierFromSol(sol_target) {
|
|
71
|
+
if (sol_target <= 50)
|
|
72
|
+
return 'ember';
|
|
73
|
+
if (sol_target <= 100)
|
|
74
|
+
return 'blaze';
|
|
75
|
+
return 'inferno';
|
|
76
|
+
}
|
|
77
|
+
// ─── Strategy Mapping ──────────────────────────────────────────────
|
|
78
|
+
function mapStrategy(vote) {
|
|
79
|
+
return vote === 'burn' ? 'scorched_earth' : 'fortify';
|
|
80
|
+
}
|
|
81
|
+
function mapVote(strategy) {
|
|
82
|
+
return strategy === 'scorched_earth' ? 'burn' : 'return';
|
|
83
|
+
}
|
|
84
|
+
// ─── Core Type Mappers ─────────────────────────────────────────────
|
|
85
|
+
function mapTokenSummaryToFaction(t) {
|
|
86
|
+
return {
|
|
87
|
+
mint: t.mint,
|
|
88
|
+
name: t.name,
|
|
89
|
+
symbol: t.symbol,
|
|
90
|
+
status: mapFactionStatus(t.status),
|
|
91
|
+
tier: mapFactionTierFromSol(t.market_cap_sol > 0 ? 200 : 200), // default tier from target
|
|
92
|
+
price_sol: t.price_sol,
|
|
93
|
+
market_cap_sol: t.market_cap_sol,
|
|
94
|
+
progress_percent: t.progress_percent,
|
|
95
|
+
members: t.holders,
|
|
96
|
+
created_at: t.created_at,
|
|
97
|
+
last_activity_at: t.last_activity_at,
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
function mapTokenDetailToFaction(t) {
|
|
101
|
+
return {
|
|
102
|
+
mint: t.mint,
|
|
103
|
+
name: t.name,
|
|
104
|
+
symbol: t.symbol,
|
|
105
|
+
description: t.description,
|
|
106
|
+
image: t.image,
|
|
107
|
+
status: mapFactionStatus(t.status),
|
|
108
|
+
tier: mapFactionTierFromSol(t.sol_target),
|
|
109
|
+
price_sol: t.price_sol,
|
|
110
|
+
price_usd: t.price_usd,
|
|
111
|
+
market_cap_sol: t.market_cap_sol,
|
|
112
|
+
market_cap_usd: t.market_cap_usd,
|
|
113
|
+
progress_percent: t.progress_percent,
|
|
114
|
+
sol_raised: t.sol_raised,
|
|
115
|
+
sol_target: t.sol_target,
|
|
116
|
+
total_supply: t.total_supply,
|
|
117
|
+
circulating_supply: t.circulating_supply,
|
|
118
|
+
tokens_in_curve: t.tokens_in_curve,
|
|
119
|
+
tokens_in_vote_vault: t.tokens_in_vote_vault,
|
|
120
|
+
tokens_burned: t.tokens_burned,
|
|
121
|
+
war_chest_sol: t.treasury_sol_balance,
|
|
122
|
+
war_chest_tokens: t.treasury_token_balance,
|
|
123
|
+
total_bought_back: t.total_bought_back,
|
|
124
|
+
buyback_count: t.buyback_count,
|
|
125
|
+
votes_scorched_earth: t.votes_burn,
|
|
126
|
+
votes_fortify: t.votes_return,
|
|
127
|
+
founder: t.creator,
|
|
128
|
+
members: t.holders,
|
|
129
|
+
rallies: t.stars,
|
|
130
|
+
created_at: t.created_at,
|
|
131
|
+
last_activity_at: t.last_activity_at,
|
|
132
|
+
twitter: t.twitter,
|
|
133
|
+
telegram: t.telegram,
|
|
134
|
+
website: t.website,
|
|
135
|
+
founder_verified: t.creator_verified,
|
|
136
|
+
founder_trust_tier: t.creator_trust_tier,
|
|
137
|
+
founder_said_name: t.creator_said_name,
|
|
138
|
+
founder_badge_url: t.creator_badge_url,
|
|
139
|
+
warnings: t.warnings,
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
function mapVaultToStronghold(v) {
|
|
143
|
+
return {
|
|
144
|
+
address: v.address,
|
|
145
|
+
creator: v.creator,
|
|
146
|
+
authority: v.authority,
|
|
147
|
+
sol_balance: v.sol_balance,
|
|
148
|
+
total_deposited: v.total_deposited,
|
|
149
|
+
total_withdrawn: v.total_withdrawn,
|
|
150
|
+
total_spent: v.total_spent,
|
|
151
|
+
total_received: v.total_received,
|
|
152
|
+
linked_agents: v.linked_wallets,
|
|
153
|
+
created_at: v.created_at,
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
function mapWalletLinkToAgentLink(l) {
|
|
157
|
+
return {
|
|
158
|
+
address: l.address,
|
|
159
|
+
stronghold: l.vault,
|
|
160
|
+
wallet: l.wallet,
|
|
161
|
+
linked_at: l.linked_at,
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
function mapTokenMessageToComms(m) {
|
|
165
|
+
return {
|
|
166
|
+
signature: m.signature,
|
|
167
|
+
memo: m.memo,
|
|
168
|
+
sender: m.sender,
|
|
169
|
+
timestamp: m.timestamp,
|
|
170
|
+
sender_verified: m.sender_verified,
|
|
171
|
+
sender_trust_tier: m.sender_trust_tier,
|
|
172
|
+
sender_said_name: m.sender_said_name,
|
|
173
|
+
sender_badge_url: m.sender_badge_url,
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
function mapLendingToWarChest(l) {
|
|
177
|
+
return {
|
|
178
|
+
interest_rate_bps: l.interest_rate_bps,
|
|
179
|
+
max_ltv_bps: l.max_ltv_bps,
|
|
180
|
+
liquidation_threshold_bps: l.liquidation_threshold_bps,
|
|
181
|
+
liquidation_bonus_bps: l.liquidation_bonus_bps,
|
|
182
|
+
utilization_cap_bps: l.utilization_cap_bps,
|
|
183
|
+
borrow_share_multiplier: l.borrow_share_multiplier,
|
|
184
|
+
total_sol_lent: l.total_sol_lent,
|
|
185
|
+
active_loans: l.active_loans,
|
|
186
|
+
war_chest_sol_available: l.treasury_sol_available,
|
|
187
|
+
warnings: l.warnings,
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
function mapLoanToWarLoan(l) {
|
|
191
|
+
return {
|
|
192
|
+
collateral_amount: l.collateral_amount,
|
|
193
|
+
borrowed_amount: l.borrowed_amount,
|
|
194
|
+
accrued_interest: l.accrued_interest,
|
|
195
|
+
total_owed: l.total_owed,
|
|
196
|
+
collateral_value_sol: l.collateral_value_sol,
|
|
197
|
+
current_ltv_bps: l.current_ltv_bps,
|
|
198
|
+
health: l.health,
|
|
199
|
+
warnings: l.warnings,
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
function mapLoanWithKeyToWarLoan(l) {
|
|
203
|
+
return {
|
|
204
|
+
...mapLoanToWarLoan(l),
|
|
205
|
+
borrower: l.borrower,
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
function mapHolderToMember(h) {
|
|
209
|
+
return {
|
|
210
|
+
address: h.address,
|
|
211
|
+
balance: h.balance,
|
|
212
|
+
percentage: h.percentage,
|
|
213
|
+
};
|
|
214
|
+
}
|
|
215
|
+
// ─── Result Mappers ────────────────────────────────────────────────
|
|
216
|
+
function mapTokenListResult(r) {
|
|
217
|
+
return {
|
|
218
|
+
factions: r.tokens.map(mapTokenSummaryToFaction),
|
|
219
|
+
total: r.total,
|
|
220
|
+
limit: r.limit,
|
|
221
|
+
offset: r.offset,
|
|
222
|
+
};
|
|
223
|
+
}
|
|
224
|
+
function mapHoldersResult(r) {
|
|
225
|
+
return {
|
|
226
|
+
members: r.holders.map(mapHolderToMember),
|
|
227
|
+
total_members: r.total_holders,
|
|
228
|
+
};
|
|
229
|
+
}
|
|
230
|
+
function mapMessagesResult(r) {
|
|
231
|
+
return {
|
|
232
|
+
comms: r.messages.map(mapTokenMessageToComms),
|
|
233
|
+
total: r.total,
|
|
234
|
+
};
|
|
235
|
+
}
|
|
236
|
+
function mapAllLoansResult(r) {
|
|
237
|
+
return {
|
|
238
|
+
positions: r.positions.map(mapLoanWithKeyToWarLoan),
|
|
239
|
+
pool_price_sol: r.pool_price_sol,
|
|
240
|
+
};
|
|
241
|
+
}
|
|
242
|
+
function mapBuyResult(r) {
|
|
243
|
+
return {
|
|
244
|
+
transaction: r.transaction,
|
|
245
|
+
additionalTransactions: r.additionalTransactions,
|
|
246
|
+
message: r.message,
|
|
247
|
+
migrationTransaction: r.migrationTransaction,
|
|
248
|
+
};
|
|
249
|
+
}
|
|
250
|
+
function mapCreateResult(r) {
|
|
251
|
+
return {
|
|
252
|
+
transaction: r.transaction,
|
|
253
|
+
additionalTransactions: r.additionalTransactions,
|
|
254
|
+
message: r.message,
|
|
255
|
+
mint: r.mint,
|
|
256
|
+
mintKeypair: r.mintKeypair,
|
|
257
|
+
};
|
|
258
|
+
}
|