pyre-world-kit 1.0.7 → 1.0.9
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 +5 -0
- package/dist/actions.js +10 -32
- package/dist/index.d.ts +1 -1
- package/dist/index.js +3 -2
- package/package.json +1 -1
- package/src/actions.ts +10 -35
- package/src/index.ts +1 -0
package/dist/actions.d.ts
CHANGED
|
@@ -81,3 +81,8 @@ export declare function confirmAction(connection: Connection, signature: string,
|
|
|
81
81
|
export { createEphemeralAgent } from 'torchsdk';
|
|
82
82
|
/** Get the Raydium pool state PDA for an ascended faction's DEX pool */
|
|
83
83
|
export declare function getDexPool(mint: string): PublicKey;
|
|
84
|
+
/** Get Raydium pool vault addresses for an ascended faction */
|
|
85
|
+
export declare function getDexVaults(mint: string): {
|
|
86
|
+
solVault: string;
|
|
87
|
+
tokenVault: string;
|
|
88
|
+
};
|
package/dist/actions.js
CHANGED
|
@@ -46,6 +46,7 @@ exports.convertTithe = convertTithe;
|
|
|
46
46
|
exports.verifyAgent = verifyAgent;
|
|
47
47
|
exports.confirmAction = confirmAction;
|
|
48
48
|
exports.getDexPool = getDexPool;
|
|
49
|
+
exports.getDexVaults = getDexVaults;
|
|
49
50
|
const web3_js_1 = require("@solana/web3.js");
|
|
50
51
|
const bs58_1 = __importDefault(require("bs58"));
|
|
51
52
|
const torchsdk_1 = require("torchsdk");
|
|
@@ -61,38 +62,7 @@ async function getFactions(connection, params) {
|
|
|
61
62
|
sort: params.sort,
|
|
62
63
|
} : undefined;
|
|
63
64
|
const result = await (0, torchsdk_1.getTokens)(connection, sdkParams);
|
|
64
|
-
|
|
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
|
+
return (0, mappers_1.mapTokenListResult)(result);
|
|
96
66
|
}
|
|
97
67
|
/** Get detailed info for a single faction */
|
|
98
68
|
async function getFaction(connection, mint) {
|
|
@@ -433,3 +403,11 @@ function getDexPool(mint) {
|
|
|
433
403
|
const { poolState } = (0, torchsdk_1.getRaydiumMigrationAccounts)(new web3_js_1.PublicKey(mint));
|
|
434
404
|
return poolState;
|
|
435
405
|
}
|
|
406
|
+
/** Get Raydium pool vault addresses for an ascended faction */
|
|
407
|
+
function getDexVaults(mint) {
|
|
408
|
+
const accts = (0, torchsdk_1.getRaydiumMigrationAccounts)(new web3_js_1.PublicKey(mint));
|
|
409
|
+
return {
|
|
410
|
+
solVault: (accts.isWsolToken0 ? accts.token0Vault : accts.token1Vault).toString(),
|
|
411
|
+
tokenVault: (accts.isWsolToken0 ? accts.token1Vault : accts.token0Vault).toString(),
|
|
412
|
+
};
|
|
413
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* so agents think in factions, not tokens.
|
|
7
7
|
*/
|
|
8
8
|
export type { FactionStatus, FactionTier, Strategy, AgentHealth, FactionSummary, FactionDetail, Stronghold, AgentLink, Comms, WarChest, WarLoan, WarLoanWithAgent, Member, FactionListResult, MembersResult, CommsResult, AllWarLoansResult, LaunchFactionParams, JoinFactionParams, DirectJoinFactionParams, DefectParams, RallyParams, RequestWarLoanParams, RepayWarLoanParams, SiegeParams, TradeOnDexParams, ClaimSpoilsParams, CreateStrongholdParams, FundStrongholdParams, WithdrawFromStrongholdParams, RecruitAgentParams, ExileAgentParams, CoupParams, WithdrawAssetsParams, AscendParams, RazeParams, TitheParams, ConvertTitheParams, JoinFactionResult, LaunchFactionResult, TransactionResult, EphemeralAgent, SaidVerification, ConfirmResult, FactionSortOption, FactionStatusFilter, FactionListParams, FactionPower, AllianceCluster, RivalFaction, AgentProfile, AgentFactionPosition, WorldEventType, WorldEvent, WorldStats, } from './types';
|
|
9
|
-
export { getFactions, getFaction, getMembers, getComms, getJoinQuote, getDefectQuote, getStronghold, getStrongholdForAgent, getAgentLink, getWarChest, getWarLoan, getAllWarLoans, launchFaction, joinFaction, directJoinFaction, defect, rally, requestWarLoan, repayWarLoan, tradeOnDex, claimSpoils, createStronghold, fundStronghold, withdrawFromStronghold, recruitAgent, exileAgent, coup, withdrawAssets, siege, ascend, raze, tithe, convertTithe, verifyAgent, confirmAction, createEphemeralAgent, getDexPool, } from './actions';
|
|
9
|
+
export { getFactions, getFaction, getMembers, getComms, getJoinQuote, getDefectQuote, getStronghold, getStrongholdForAgent, getAgentLink, getWarChest, getWarLoan, getAllWarLoans, launchFaction, joinFaction, directJoinFaction, defect, rally, requestWarLoan, repayWarLoan, tradeOnDex, claimSpoils, createStronghold, fundStronghold, withdrawFromStronghold, recruitAgent, exileAgent, coup, withdrawAssets, siege, ascend, raze, tithe, convertTithe, verifyAgent, confirmAction, createEphemeralAgent, getDexPool, getDexVaults, } from './actions';
|
|
10
10
|
export { getFactionPower, getFactionLeaderboard, detectAlliances, getFactionRivals, getAgentProfile, getAgentFactions, getWorldFeed, getWorldStats, } from './intel';
|
|
11
11
|
export { isPyreMint, grindPyreMint } from './vanity';
|
|
12
12
|
export { PROGRAM_ID, LAMPORTS_PER_SOL, TOKEN_MULTIPLIER, TOTAL_SUPPLY } from 'torchsdk';
|
package/dist/index.js
CHANGED
|
@@ -7,8 +7,8 @@
|
|
|
7
7
|
* so agents think in factions, not tokens.
|
|
8
8
|
*/
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
exports.
|
|
11
|
-
exports.TOTAL_SUPPLY = void 0;
|
|
10
|
+
exports.LAMPORTS_PER_SOL = exports.PROGRAM_ID = exports.grindPyreMint = exports.isPyreMint = exports.getWorldStats = exports.getWorldFeed = exports.getAgentFactions = exports.getAgentProfile = exports.getFactionRivals = exports.detectAlliances = exports.getFactionLeaderboard = exports.getFactionPower = exports.getDexVaults = exports.getDexPool = exports.createEphemeralAgent = exports.confirmAction = exports.verifyAgent = exports.convertTithe = exports.tithe = exports.raze = exports.ascend = exports.siege = exports.withdrawAssets = exports.coup = exports.exileAgent = exports.recruitAgent = exports.withdrawFromStronghold = exports.fundStronghold = exports.createStronghold = exports.claimSpoils = exports.tradeOnDex = exports.repayWarLoan = exports.requestWarLoan = exports.rally = exports.defect = exports.directJoinFaction = exports.joinFaction = exports.launchFaction = exports.getAllWarLoans = exports.getWarLoan = exports.getWarChest = exports.getAgentLink = exports.getStrongholdForAgent = exports.getStronghold = exports.getDefectQuote = exports.getJoinQuote = exports.getComms = exports.getMembers = exports.getFaction = exports.getFactions = void 0;
|
|
11
|
+
exports.TOTAL_SUPPLY = exports.TOKEN_MULTIPLIER = void 0;
|
|
12
12
|
// ─── Actions ───────────────────────────────────────────────────────
|
|
13
13
|
var actions_1 = require("./actions");
|
|
14
14
|
// Read operations
|
|
@@ -54,6 +54,7 @@ Object.defineProperty(exports, "confirmAction", { enumerable: true, get: functio
|
|
|
54
54
|
// Utility
|
|
55
55
|
Object.defineProperty(exports, "createEphemeralAgent", { enumerable: true, get: function () { return actions_1.createEphemeralAgent; } });
|
|
56
56
|
Object.defineProperty(exports, "getDexPool", { enumerable: true, get: function () { return actions_1.getDexPool; } });
|
|
57
|
+
Object.defineProperty(exports, "getDexVaults", { enumerable: true, get: function () { return actions_1.getDexVaults; } });
|
|
57
58
|
// ─── Intel ─────────────────────────────────────────────────────────
|
|
58
59
|
var intel_1 = require("./intel");
|
|
59
60
|
Object.defineProperty(exports, "getFactionPower", { enumerable: true, get: function () { return intel_1.getFactionPower; } });
|
package/package.json
CHANGED
package/src/actions.ts
CHANGED
|
@@ -119,41 +119,7 @@ export async function getFactions(
|
|
|
119
119
|
sort: params.sort,
|
|
120
120
|
} : undefined;
|
|
121
121
|
const result = await getTokens(connection, sdkParams);
|
|
122
|
-
|
|
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;
|
|
122
|
+
return mapTokenListResult(result);
|
|
157
123
|
}
|
|
158
124
|
|
|
159
125
|
/** Get detailed info for a single faction */
|
|
@@ -659,3 +625,12 @@ export function getDexPool(mint: string): PublicKey {
|
|
|
659
625
|
const { poolState } = getRaydiumMigrationAccounts(new PublicKey(mint));
|
|
660
626
|
return poolState;
|
|
661
627
|
}
|
|
628
|
+
|
|
629
|
+
/** Get Raydium pool vault addresses for an ascended faction */
|
|
630
|
+
export function getDexVaults(mint: string): { solVault: string; tokenVault: string } {
|
|
631
|
+
const accts = getRaydiumMigrationAccounts(new PublicKey(mint));
|
|
632
|
+
return {
|
|
633
|
+
solVault: (accts.isWsolToken0 ? accts.token0Vault : accts.token1Vault).toString(),
|
|
634
|
+
tokenVault: (accts.isWsolToken0 ? accts.token1Vault : accts.token0Vault).toString(),
|
|
635
|
+
};
|
|
636
|
+
}
|