pyre-world-kit 3.0.3 → 3.0.5

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/index.d.ts CHANGED
@@ -12,6 +12,7 @@ import { Registry } from './types/registry.types';
12
12
  import { StateProvider } from './providers/state.provider';
13
13
  import type { CheckpointConfig } from './types/state.types';
14
14
  export declare class PyreKit {
15
+ readonly connection: Connection;
15
16
  readonly actions: Action;
16
17
  readonly intel: Intel;
17
18
  readonly registry: Registry;
package/dist/index.js CHANGED
@@ -14,11 +14,13 @@ const registry_provider_1 = require("./providers/registry.provider");
14
14
  const state_provider_1 = require("./providers/state.provider");
15
15
  // ─── Top-level Kit ────────────────────────────────────────────────
16
16
  class PyreKit {
17
+ connection;
17
18
  actions;
18
19
  intel;
19
20
  registry;
20
21
  state;
21
22
  constructor(connection, publicKey) {
23
+ this.connection = connection;
22
24
  this.registry = new registry_provider_1.RegistryProvider(connection);
23
25
  this.state = new state_provider_1.StateProvider(connection, this.registry, publicKey);
24
26
  this.actions = new action_provider_1.ActionProvider(connection, this.registry);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pyre-world-kit",
3
- "version": "3.0.3",
3
+ "version": "3.0.5",
4
4
  "description": "Agent-first faction warfare kit — game-semantic wrapper over torchsdk",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
package/src/index.ts CHANGED
@@ -22,12 +22,14 @@ import type { CheckpointConfig, TrackedAction } from './types/state.types'
22
22
  // ─── Top-level Kit ────────────────────────────────────────────────
23
23
 
24
24
  export class PyreKit {
25
+ readonly connection: Connection
25
26
  readonly actions: Action
26
27
  readonly intel: Intel
27
28
  readonly registry: Registry
28
29
  readonly state: StateProvider
29
30
 
30
31
  constructor(connection: Connection, publicKey: string) {
32
+ this.connection = connection
31
33
  this.registry = new RegistryProvider(connection)
32
34
  this.state = new StateProvider(connection, this.registry, publicKey)
33
35
  this.actions = new ActionProvider(connection, this.registry)
package/dist/actions.d.ts DELETED
@@ -1,102 +0,0 @@
1
- /**
2
- * Pyre Kit Actions
3
- *
4
- * Thin wrappers that call torchsdk functions and map params/results
5
- * into game-semantic Pyre types. No new on-chain logic.
6
- */
7
- import { Connection, PublicKey } from '@solana/web3.js';
8
- import type { BuyQuoteResult, SellQuoteResult, TransactionResult, SaidVerification, ConfirmResult } from 'torchsdk';
9
- import type { FactionListParams, FactionListResult, FactionDetail, MembersResult, CommsResult, Stronghold, AgentLink, WarChest, WarLoan, WarLoanQuote, AllWarLoansResult, LaunchFactionParams, JoinFactionParams, DirectJoinFactionParams, DefectParams, MessageFactionParams, FudFactionParams, RallyParams, RequestWarLoanParams, RepayWarLoanParams, SiegeParams, TradeOnDexParams, ClaimSpoilsParams, CreateStrongholdParams, FundStrongholdParams, WithdrawFromStrongholdParams, RecruitAgentParams, ExileAgentParams, CoupParams, WithdrawAssetsParams, AscendParams, RazeParams, TitheParams, ConvertTitheParams, JoinFactionResult, LaunchFactionResult, FactionStatus } from './types';
10
- /** Add mints to the blacklist (call at startup with old mints) */
11
- export declare function blacklistMints(mints: string[]): void;
12
- /** Check if a mint is blacklisted */
13
- export declare function isBlacklistedMint(mint: string): boolean;
14
- /** Get all blacklisted mints */
15
- export declare function getBlacklistedMints(): string[];
16
- /** List all factions with optional filtering and sorting */
17
- export declare function getFactions(connection: Connection, params?: FactionListParams): Promise<FactionListResult>;
18
- /** Get detailed info for a single faction */
19
- export declare function getFaction(connection: Connection, mint: string): Promise<FactionDetail>;
20
- /** Get faction members (top holders, excluding program-owned accounts) */
21
- export declare function getMembers(connection: Connection, mint: string, limit?: number): Promise<MembersResult>;
22
- /** Get faction comms (trade-bundled messages, including post-ascension DEX messages) */
23
- export declare function getComms(connection: Connection, mint: string, limit?: number, status?: FactionStatus): Promise<CommsResult>;
24
- /** Get a quote for joining a faction (buying tokens) */
25
- export declare function getJoinQuote(connection: Connection, mint: string, amountSolLamports: number): Promise<BuyQuoteResult>;
26
- /** Get a quote for defecting from a faction (selling tokens) */
27
- export declare function getDefectQuote(connection: Connection, mint: string, amountTokens: number): Promise<SellQuoteResult>;
28
- /** Get stronghold (vault) by creator */
29
- export declare function getStronghold(connection: Connection, creator: string): Promise<Stronghold | null>;
30
- /** Get stronghold for a linked agent wallet */
31
- export declare function getStrongholdForAgent(connection: Connection, wallet: string): Promise<Stronghold | null>;
32
- /** Get agent link info for a wallet */
33
- export declare function getAgentLink(connection: Connection, wallet: string): Promise<AgentLink | null>;
34
- /** Get all linked agents for a vault (via getProgramAccounts) */
35
- export declare function getLinkedAgents(connection: Connection, vaultAddress: string): Promise<AgentLink[]>;
36
- /** Get war chest (lending info) for a faction */
37
- export declare function getWarChest(connection: Connection, mint: string): Promise<WarChest>;
38
- /** Get war loan position for a specific agent on a faction */
39
- export declare function getWarLoan(connection: Connection, mint: string, wallet: string): Promise<WarLoan>;
40
- /** Get all war loans for a faction */
41
- export declare function getAllWarLoans(connection: Connection, mint: string): Promise<AllWarLoansResult>;
42
- /** Compute max borrowable SOL for a given collateral amount */
43
- export declare function getMaxWarLoan(connection: Connection, mint: string, collateralAmount: number): Promise<WarLoanQuote>;
44
- /** Launch a new faction (create token) */
45
- export declare function launchFaction(connection: Connection, params: LaunchFactionParams): Promise<LaunchFactionResult>;
46
- /** Join a faction via stronghold (vault-funded buy) */
47
- export declare function joinFaction(connection: Connection, params: JoinFactionParams): Promise<JoinFactionResult>;
48
- /** Join a faction directly (no vault) */
49
- export declare function directJoinFaction(connection: Connection, params: DirectJoinFactionParams): Promise<JoinFactionResult>;
50
- /** Defect from a faction (sell tokens) */
51
- export declare function defect(connection: Connection, params: DefectParams): Promise<TransactionResult>;
52
- /** "Said in" — micro buy (0.001 SOL) + message. Routes through bonding curve or DEX automatically. */
53
- export declare function messageFaction(connection: Connection, params: MessageFactionParams): Promise<TransactionResult>;
54
- /** "Argued in" — micro sell (100 tokens) + negative message. Routes through bonding curve or DEX automatically. */
55
- export declare function fudFaction(connection: Connection, params: FudFactionParams): Promise<TransactionResult>;
56
- /** Rally support for a faction (star) */
57
- export declare function rally(connection: Connection, params: RallyParams): Promise<TransactionResult>;
58
- /** Request a war loan (borrow SOL against token collateral) */
59
- export declare function requestWarLoan(connection: Connection, params: RequestWarLoanParams): Promise<TransactionResult>;
60
- /** Repay a war loan */
61
- export declare function repayWarLoan(connection: Connection, params: RepayWarLoanParams): Promise<TransactionResult>;
62
- /** Trade on DEX via stronghold (vault-routed Raydium swap) */
63
- export declare function tradeOnDex(connection: Connection, params: TradeOnDexParams): Promise<TransactionResult>;
64
- /** Claim spoils (protocol rewards) */
65
- export declare function claimSpoils(connection: Connection, params: ClaimSpoilsParams): Promise<TransactionResult>;
66
- /** Create a new stronghold (vault) */
67
- export declare function createStronghold(connection: Connection, params: CreateStrongholdParams): Promise<TransactionResult>;
68
- /** Fund a stronghold with SOL */
69
- export declare function fundStronghold(connection: Connection, params: FundStrongholdParams): Promise<TransactionResult>;
70
- /** Withdraw SOL from a stronghold */
71
- export declare function withdrawFromStronghold(connection: Connection, params: WithdrawFromStrongholdParams): Promise<TransactionResult>;
72
- /** Recruit an agent (link wallet to stronghold) */
73
- export declare function recruitAgent(connection: Connection, params: RecruitAgentParams): Promise<TransactionResult>;
74
- /** Exile an agent (unlink wallet from stronghold) */
75
- export declare function exileAgent(connection: Connection, params: ExileAgentParams): Promise<TransactionResult>;
76
- /** Coup — transfer stronghold authority */
77
- export declare function coup(connection: Connection, params: CoupParams): Promise<TransactionResult>;
78
- /** Withdraw token assets from stronghold */
79
- export declare function withdrawAssets(connection: Connection, params: WithdrawAssetsParams): Promise<TransactionResult>;
80
- /** Siege — liquidate an undercollateralized war loan */
81
- export declare function siege(connection: Connection, params: SiegeParams): Promise<TransactionResult>;
82
- /** Ascend — migrate a completed faction to DEX */
83
- export declare function ascend(connection: Connection, params: AscendParams): Promise<TransactionResult>;
84
- /** Raze — reclaim a failed faction */
85
- export declare function raze(connection: Connection, params: RazeParams): Promise<TransactionResult>;
86
- /** Tithe — harvest transfer fees */
87
- export declare function tithe(connection: Connection, params: TitheParams): Promise<TransactionResult>;
88
- /** Convert tithe — swap harvested fees to SOL */
89
- export declare function convertTithe(connection: Connection, params: ConvertTitheParams): Promise<TransactionResult>;
90
- /** Verify an agent's SAID reputation */
91
- export declare function verifyAgent(wallet: string): Promise<SaidVerification>;
92
- /** Confirm a transaction on-chain */
93
- export declare function confirmAction(connection: Connection, signature: string, wallet: string): Promise<ConfirmResult>;
94
- /** Create an ephemeral agent keypair (memory-only, zero key management) */
95
- export { createEphemeralAgent } from 'torchsdk';
96
- /** Get the Raydium pool state PDA for an ascended faction's DEX pool */
97
- export declare function getDexPool(mint: string): PublicKey;
98
- /** Get Raydium pool vault addresses for an ascended faction */
99
- export declare function getDexVaults(mint: string): {
100
- solVault: string;
101
- tokenVault: string;
102
- };
package/dist/actions.js DELETED
@@ -1,488 +0,0 @@
1
- "use strict";
2
- /**
3
- * Pyre Kit Actions
4
- *
5
- * Thin wrappers that call torchsdk functions and map params/results
6
- * into game-semantic Pyre types. No new on-chain logic.
7
- */
8
- Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.createEphemeralAgent = void 0;
10
- exports.blacklistMints = blacklistMints;
11
- exports.isBlacklistedMint = isBlacklistedMint;
12
- exports.getBlacklistedMints = getBlacklistedMints;
13
- exports.getFactions = getFactions;
14
- exports.getFaction = getFaction;
15
- exports.getMembers = getMembers;
16
- exports.getComms = getComms;
17
- exports.getJoinQuote = getJoinQuote;
18
- exports.getDefectQuote = getDefectQuote;
19
- exports.getStronghold = getStronghold;
20
- exports.getStrongholdForAgent = getStrongholdForAgent;
21
- exports.getAgentLink = getAgentLink;
22
- exports.getLinkedAgents = getLinkedAgents;
23
- exports.getWarChest = getWarChest;
24
- exports.getWarLoan = getWarLoan;
25
- exports.getAllWarLoans = getAllWarLoans;
26
- exports.getMaxWarLoan = getMaxWarLoan;
27
- exports.launchFaction = launchFaction;
28
- exports.joinFaction = joinFaction;
29
- exports.directJoinFaction = directJoinFaction;
30
- exports.defect = defect;
31
- exports.messageFaction = messageFaction;
32
- exports.fudFaction = fudFaction;
33
- exports.rally = rally;
34
- exports.requestWarLoan = requestWarLoan;
35
- exports.repayWarLoan = repayWarLoan;
36
- exports.tradeOnDex = tradeOnDex;
37
- exports.claimSpoils = claimSpoils;
38
- exports.createStronghold = createStronghold;
39
- exports.fundStronghold = fundStronghold;
40
- exports.withdrawFromStronghold = withdrawFromStronghold;
41
- exports.recruitAgent = recruitAgent;
42
- exports.exileAgent = exileAgent;
43
- exports.coup = coup;
44
- exports.withdrawAssets = withdrawAssets;
45
- exports.siege = siege;
46
- exports.ascend = ascend;
47
- exports.raze = raze;
48
- exports.tithe = tithe;
49
- exports.convertTithe = convertTithe;
50
- exports.verifyAgent = verifyAgent;
51
- exports.confirmAction = confirmAction;
52
- exports.getDexPool = getDexPool;
53
- exports.getDexVaults = getDexVaults;
54
- const web3_js_1 = require("@solana/web3.js");
55
- const torchsdk_1 = require("torchsdk");
56
- const mappers_1 = require("./mappers");
57
- const vanity_1 = require("./vanity");
58
- // ─── Blacklist ──────────────────────────────────────────────────────
59
- // Mints from previous swarm runs. Agents should skip these and only
60
- // interact with freshly launched factions.
61
- const DEFAULT_BLACKLIST = [
62
- 'E1SgYPW6JXhw5BabrvJkr6L2PyvfFenYaoCTePazyNpy', '6jWsyDC87RmfrZZRjuxSAxvUxE665HGZwZ2Z8j5z9epy',
63
- '6J8PLgFxHb98cNURP2Yt2SKwgnUeEXpN6Us2kxaMz1py', '5A297UyPQstxWpJyydDnFvn2zN8whCEYdqvnfB5bF9py',
64
- '8XdWfSKLJusAcRrYzK3bWJ7dy46AkbU8qxF3B55uSfpy', '7ZYrKcJbFFbG36keCYRvfc1j1HScQmJW1zRV3wVVD4py',
65
- 'ERQPyG2oqx5bdyuY2Nnm5ZbZY2zcB46TfUxqpzYWH5py', 'JCvpK3kTnh2EdQG71mqE8ZXcvzLU5EJNG5vgGZme4wpy',
66
- '9RDFkGSjKpjHtXZ25uuug2MN5P7oSjzkLg16HcrKy3py', '2kWcX1ZetV4jUtBPbKKk265q4gS4nuut2kc1MbaZDfpy',
67
- '3r9FnQim6GToR7NkY5om8igUNu7gfpq5fk2qtv3bV5py', '2498F79s1Ghyj3J4VhV1qy5hhznnM53ZwzTXM9iscopy',
68
- '5VpotyDyc8QKKqLuzu8pfhtEa9gsRG1ww58DbqJUgTpy', 'GXi1opahTkavPfAqfUhkoUJRBjPoAmAMVW87kdbDwNpy',
69
- 'GKFAokGiyhXGXxUPgwQEo8fE5nBjRdJcVX6LVj7SgPpy', 'EKFVwfNk1xzqhpyFJSMNw8KDcLRemvqxiGoSyfRtBspy',
70
- 'GsZLHVt3mTwus5krUcifBWS52xMQSuXSy3RpPhEFtvpy', '9azKjXnt2w4RB5ykVcyaicWSssmxoapZ9SSQLMZc4Epy',
71
- 'BaLwryyMrqhtsMrELkrTSdWF9UYuNdjW4413hrQqbtpy', '5p9ibszMVe79mm95M8uubS6WttXem2xZfh3mWmBdvUpy',
72
- 'CTvoAmTggJcBTnbxcfy91Y1c6t6fU5xq3SRtYh3TgEpy', '2kqVCdQS9KSv2kxLiytGZfcLsx5xwKQT6rHTg4V18hpy',
73
- 'zV7XZcvY8DVk4scKUiw7GGN4L3eBPSXuD7Q1NPxfspy', '3UhzKfdU1wgnEN2VCykRURw88qVVqeu3ejRkUnjmhRpy',
74
- 'FRaS3dAdr1zo6u811XBVGUp9K2mSdQ2yG8qW4qP5hapy', '4NHzWVP7hzZhd9LhTrbyxzsSnT8EmNSYVP1DpAKXHYpy',
75
- 'Yt2rdfp6uzS7L52df3LPmetLoy3GvKChYJ4Lmvk6gpy', '9Ejju29KHPWMpda4WpFsJ6ZDHVUqNWyMZHteEisgw9py',
76
- '2zPC4A7WR2cMNDfBzERp49fEbTBCyqXPKhcrgz3hWcpy', '7jBAriydb1qRy7Wg4WAz8woHP4pVxZJSnF7vw95tVQpy',
77
- 'HvPWKuMFpG3zAdkPMbaadyo78VoJbAMtpXaBYMK1Aqpy', 'GyNw9bkqz2rhR66Xx7P4p11PFBrjPi2r6XoCg5gPAdpy',
78
- '6HveNEes9xtkkchb76JgjWWQ61sbXjESy2vr3A7Maipy', '8E3GETvTkTTaCLpzkyHJTnuNMfmGvzUEgAYnurZuLZpy',
79
- 'AeApaJqppwjW9S2KeZGPZpmg1kAdxZHkFRnXPZc8Kjpy', '8FfteyAMQm96upu4w6cJvE5T8RcMKRf5keJMdXbukXpy',
80
- 'BrEj2Q9XE13WesRU1u8USiprv2DkpBcJfaqQeqQ6grpy', 'Dtki37mAB3DiTW1bp8LnZQyv54UuC68Yo5pGZkPdVSpy',
81
- '77UzTntZ7ThyXhN4hVvSx7m6tjit8uCw6U2LVQHPSqpy', 'ASV9kiC6vEpZy3X7xVExuyG257KHKd3Hutbji8AVRUpy',
82
- 'Fc1V6KcxSriJkUNeDLqz8w5Sm4mp1s8gxornZVLcHEpy', 'FEizyHEUoYenqfpF87kqiGnq3w1R2TReodEfsnTrrfpy',
83
- 'DmwgcVHoJxKeRiij5LtedY9LWDpqoqa3hGfUyVgBkgpy', 'GUGz1Em5KZ57aKFqEBSd4Y4Vb6WxBd3H2b16fPCC6upy',
84
- '6ZWY3Bau5zw1j7vMQQ1czSw4rjBJrExHQ8Renor2vLpy',
85
- // wave 3
86
- '4LyPhwUCZNLEp45RsGWdwtkX5tb3wmwydBKEu1V7fxpy', 'FYw8FZKzG6vVweUMQgSXBrY9ViHgquWyN4x5QthaK3py',
87
- 'DhFhRRpRMkPi2Vz3kErZWHNmWqxgQm5YwXT5pFpgVKpy', '6GLqPmACtuDi4LcMtVpFK43sYkG8yVouYiDfdfBSSVpy',
88
- '8YYYewvvCTGPZ2UddgrD6oWUZD7CYXe3DBbA9GBkapy', 'FpQT2uDi3oxEpnayKHAUCcWXVhtDaZCb85e7nZzoCUpy',
89
- '5EWX6grTtA46FQUHGC1kogCW3CsnVfXNvVgrYVtwvRpy', '8HSvBFkr6gu9qtbMKcTAZSjzkj4Ag1d1wkdiaMDHHapy',
90
- '2hgo2kdtNNQGNuvfEPSfydWDqfhSwfbFTzgeVb758wpy', 'DKvaEayFig3RHQ9rXHnCKBjvMnJCstzuBmSe77Ybf6py',
91
- 'Cws3YSPxWYxzrEEfguLi3p13ea2vPNi42mjJwwSMTTpy', 'GodcBg2dLzrypiYH5Aqo2bTJ7KiZa5G5XSDwNQ74iYpy',
92
- '46tUp7tMEhpLeenPXQwvzP8H8V5M4F63vi4M9k4bbbpy', 'a5iH2Soh5c8X81vTVbKZq7A7yPckhFdN1amv1Q2tapy',
93
- '2zTGWtQeJ5GtdHu888QikPzKkyHJPWVFYtoQjNeJJ7py', 'HNnpL7z1GKsXuxaEHs2a52zW7tTUjU4dZnrSEf8ZsMpy',
94
- 'EASit9Yrj1SBg6xchFxDSwVV9Rz11RKdDpB4tcNsekpy', 'F7VcdtqsXV6nkDL3yk6esUBu9qGvka4EY9XNTQ7PmZpy',
95
- '3huHC9Co5dy5Z5U6H8Vf7aVTcuukpKeUr8rDQx8s5Zpy', '97ymhwybP8Jh45VcYBJY1pwQ5xkPLX15u7Tg3P7TG7py',
96
- '92fMEzcYdcoEXX8A5T8i8vfz2S96P39abzoXXuBghfpy', '2ZeQsU13WjgX2152qV3wyzxURjLg7GwfXznAiA99Jjpy',
97
- 'FuUHck8jqaXxGiTuLym4gYXJQrueyEsgd8AMUQx2fMpy', 'trTuaGATQZwUeYkYTeyJfQnGGnKRvAriAZRgBWg7Epy',
98
- 'HEhemzeszztaFzFYR9DjpNwdhghVDD1y7cHxP93EPZpy', 'obuf6MkL1ev6WuUDDjH3bq2q6Ryr6MBNMRsA6dEW4py',
99
- '76ruUbqBpqSKsysoPesDrpaLsDSahWWphQmXrswiLbpy', '4ci4scCevt5tXCxkGr5xHoWyaeQY1dahp5nFsTnfYApy',
100
- 'shzuPKgqedBxJmxdrRyWAtajG3hSNyLr72SufvmEvpy',
101
- ];
102
- const BLACKLISTED_MINTS = new Set(DEFAULT_BLACKLIST);
103
- /** Add mints to the blacklist (call at startup with old mints) */
104
- function blacklistMints(mints) {
105
- for (const m of mints)
106
- BLACKLISTED_MINTS.add(m);
107
- }
108
- /** Check if a mint is blacklisted */
109
- function isBlacklistedMint(mint) {
110
- return BLACKLISTED_MINTS.has(mint);
111
- }
112
- /** Get all blacklisted mints */
113
- function getBlacklistedMints() {
114
- return Array.from(BLACKLISTED_MINTS);
115
- }
116
- // ─── Read Operations ───────────────────────────────────────────────
117
- /** List all factions with optional filtering and sorting */
118
- async function getFactions(connection, params) {
119
- const sdkParams = params ? {
120
- limit: params.limit,
121
- offset: params.offset,
122
- status: params.status ? (0, mappers_1.mapTokenStatusFilter)(params.status) : undefined,
123
- sort: params.sort,
124
- } : undefined;
125
- const result = await (0, torchsdk_1.getTokens)(connection, sdkParams);
126
- return (0, mappers_1.mapTokenListResult)(result);
127
- }
128
- /** Get detailed info for a single faction */
129
- async function getFaction(connection, mint) {
130
- const detail = await (0, torchsdk_1.getToken)(connection, mint);
131
- return (0, mappers_1.mapTokenDetailToFaction)(detail);
132
- }
133
- /** Get faction members (top holders, excluding program-owned accounts) */
134
- async function getMembers(connection, mint, limit) {
135
- const mintPk = new web3_js_1.PublicKey(mint);
136
- const [bondingCurve] = (0, vanity_1.getBondingCurvePda)(mintPk);
137
- const [treasury] = (0, vanity_1.getTokenTreasuryPda)(mintPk);
138
- const [treasuryLock] = (0, vanity_1.getTreasuryLockPda)(mintPk);
139
- const excluded = new Set([
140
- bondingCurve.toString(),
141
- treasury.toString(),
142
- treasuryLock.toString(),
143
- ]);
144
- // Fetch extra to compensate for filtered-out program accounts
145
- const result = await (0, torchsdk_1.getHolders)(connection, mint, (limit ?? 10) + 5);
146
- result.holders = result.holders.filter(h => !excluded.has(h.address));
147
- if (limit)
148
- result.holders = result.holders.slice(0, limit);
149
- return (0, mappers_1.mapHoldersResult)(result);
150
- }
151
- /** Get faction comms (trade-bundled messages, including post-ascension DEX messages) */
152
- async function getComms(connection, mint, limit, status) {
153
- // Non-ascended: bonding curve only (1 RPC call)
154
- // Ascended: pool only (1 RPC call) — bonding curve is stale post-migration
155
- const source = status === 'ascended' ? 'pool' : status ? 'bonding' : 'all';
156
- const result = await (0, torchsdk_1.getMessages)(connection, mint, limit, { source });
157
- return (0, mappers_1.mapMessagesResult)(result);
158
- }
159
- /** Get a quote for joining a faction (buying tokens) */
160
- async function getJoinQuote(connection, mint, amountSolLamports) {
161
- return (0, torchsdk_1.getBuyQuote)(connection, mint, amountSolLamports);
162
- }
163
- /** Get a quote for defecting from a faction (selling tokens) */
164
- async function getDefectQuote(connection, mint, amountTokens) {
165
- return (0, torchsdk_1.getSellQuote)(connection, mint, amountTokens);
166
- }
167
- /** Get stronghold (vault) by creator */
168
- async function getStronghold(connection, creator) {
169
- const vault = await (0, torchsdk_1.getVault)(connection, creator);
170
- return vault ? (0, mappers_1.mapVaultToStronghold)(vault) : null;
171
- }
172
- /** Get stronghold for a linked agent wallet */
173
- async function getStrongholdForAgent(connection, wallet) {
174
- const vault = await (0, torchsdk_1.getVaultForWallet)(connection, wallet);
175
- return vault ? (0, mappers_1.mapVaultToStronghold)(vault) : null;
176
- }
177
- /** Get agent link info for a wallet */
178
- async function getAgentLink(connection, wallet) {
179
- const link = await (0, torchsdk_1.getVaultWalletLink)(connection, wallet);
180
- return link ? (0, mappers_1.mapWalletLinkToAgentLink)(link) : null;
181
- }
182
- /** Get all linked agents for a vault (via getProgramAccounts) */
183
- async function getLinkedAgents(connection, vaultAddress) {
184
- // VaultWalletLink account layout: 8-byte discriminator + 32-byte vault + 32-byte wallet + 8-byte linked_at + 1-byte bump
185
- const DISCRIMINATOR = Buffer.from([111, 59, 70, 89, 148, 117, 217, 156]); // sha256("account:VaultWalletLink")[0..8]
186
- const vaultPubkey = new web3_js_1.PublicKey(vaultAddress);
187
- const filters = [
188
- { dataSize: 81 }, // 8 + 32 + 32 + 8 + 1
189
- { memcmp: { offset: 8, bytes: vaultPubkey.toBase58() } },
190
- ];
191
- const accounts = await connection.getProgramAccounts(torchsdk_1.PROGRAM_ID, { filters });
192
- return accounts.map((acc) => {
193
- const data = acc.account.data;
194
- const wallet = new web3_js_1.PublicKey(data.subarray(40, 72)).toBase58();
195
- const linked_at = Number(data.readBigInt64LE(72));
196
- return {
197
- address: acc.pubkey.toBase58(),
198
- stronghold: vaultAddress,
199
- wallet,
200
- linked_at,
201
- };
202
- });
203
- }
204
- /** Get war chest (lending info) for a faction */
205
- async function getWarChest(connection, mint) {
206
- const info = await (0, torchsdk_1.getLendingInfo)(connection, mint);
207
- return (0, mappers_1.mapLendingToWarChest)(info);
208
- }
209
- /** Get war loan position for a specific agent on a faction */
210
- async function getWarLoan(connection, mint, wallet) {
211
- const pos = await (0, torchsdk_1.getLoanPosition)(connection, mint, wallet);
212
- return (0, mappers_1.mapLoanToWarLoan)(pos);
213
- }
214
- /** Get all war loans for a faction */
215
- async function getAllWarLoans(connection, mint) {
216
- const result = await (0, torchsdk_1.getAllLoanPositions)(connection, mint);
217
- return (0, mappers_1.mapAllLoansResult)(result);
218
- }
219
- /** Compute max borrowable SOL for a given collateral amount */
220
- async function getMaxWarLoan(connection, mint, collateralAmount) {
221
- return (0, torchsdk_1.getBorrowQuote)(connection, mint, collateralAmount);
222
- }
223
- // ─── Faction Operations (controller) ───────────────────────────────
224
- /** Launch a new faction (create token) */
225
- async function launchFaction(connection, params) {
226
- const result = await (0, vanity_1.buildCreateFactionTransaction)(connection, {
227
- creator: params.founder,
228
- name: params.name,
229
- symbol: params.symbol,
230
- metadata_uri: params.metadata_uri,
231
- sol_target: params.sol_target,
232
- community_token: params.community_faction,
233
- });
234
- return (0, mappers_1.mapCreateResult)(result);
235
- }
236
- /** Join a faction via stronghold (vault-funded buy) */
237
- async function joinFaction(connection, params) {
238
- const result = await (0, torchsdk_1.buildBuyTransaction)(connection, {
239
- mint: params.mint,
240
- buyer: params.agent,
241
- amount_sol: params.amount_sol,
242
- slippage_bps: params.slippage_bps,
243
- vote: params.strategy ? (0, mappers_1.mapVote)(params.strategy) : undefined,
244
- message: params.message,
245
- vault: params.stronghold,
246
- });
247
- return (0, mappers_1.mapBuyResult)(result);
248
- }
249
- /** Join a faction directly (no vault) */
250
- async function directJoinFaction(connection, params) {
251
- const result = await (0, torchsdk_1.buildDirectBuyTransaction)(connection, {
252
- mint: params.mint,
253
- buyer: params.agent,
254
- amount_sol: params.amount_sol,
255
- slippage_bps: params.slippage_bps,
256
- vote: params.strategy ? (0, mappers_1.mapVote)(params.strategy) : undefined,
257
- message: params.message,
258
- });
259
- return (0, mappers_1.mapBuyResult)(result);
260
- }
261
- /** Defect from a faction (sell tokens) */
262
- async function defect(connection, params) {
263
- return (0, torchsdk_1.buildSellTransaction)(connection, {
264
- mint: params.mint,
265
- seller: params.agent,
266
- amount_tokens: params.amount_tokens,
267
- slippage_bps: params.slippage_bps,
268
- message: params.message,
269
- vault: params.stronghold,
270
- });
271
- }
272
- /** "Said in" — micro buy (0.001 SOL) + message. Routes through bonding curve or DEX automatically. */
273
- async function messageFaction(connection, params) {
274
- const MICRO_BUY_LAMPORTS = 1_000_000; // 0.001 SOL
275
- if (params.ascended) {
276
- return (0, torchsdk_1.buildVaultSwapTransaction)(connection, {
277
- mint: params.mint,
278
- signer: params.agent,
279
- vault_creator: params.stronghold,
280
- amount_in: MICRO_BUY_LAMPORTS,
281
- minimum_amount_out: 1,
282
- is_buy: true,
283
- message: params.message,
284
- });
285
- }
286
- const result = await (0, torchsdk_1.buildBuyTransaction)(connection, {
287
- mint: params.mint,
288
- buyer: params.agent,
289
- amount_sol: MICRO_BUY_LAMPORTS,
290
- message: params.message,
291
- vault: params.stronghold,
292
- vote: params.first_buy ? (0, mappers_1.mapVote)(Math.random() > 0.5 ? 'fortify' : 'scorched_earth') : undefined,
293
- });
294
- return (0, mappers_1.mapBuyResult)(result);
295
- }
296
- /** "Argued in" — micro sell (100 tokens) + negative message. Routes through bonding curve or DEX automatically. */
297
- async function fudFaction(connection, params) {
298
- const MICRO_SELL_TOKENS = 100;
299
- if (params.ascended) {
300
- return (0, torchsdk_1.buildVaultSwapTransaction)(connection, {
301
- mint: params.mint,
302
- signer: params.agent,
303
- vault_creator: params.stronghold,
304
- amount_in: MICRO_SELL_TOKENS,
305
- minimum_amount_out: 1,
306
- is_buy: false,
307
- message: params.message,
308
- });
309
- }
310
- return (0, torchsdk_1.buildSellTransaction)(connection, {
311
- mint: params.mint,
312
- seller: params.agent,
313
- amount_tokens: MICRO_SELL_TOKENS,
314
- message: params.message,
315
- vault: params.stronghold,
316
- });
317
- }
318
- /** Rally support for a faction (star) */
319
- async function rally(connection, params) {
320
- return (0, torchsdk_1.buildStarTransaction)(connection, {
321
- mint: params.mint,
322
- user: params.agent,
323
- vault: params.stronghold,
324
- });
325
- }
326
- /** Request a war loan (borrow SOL against token collateral) */
327
- async function requestWarLoan(connection, params) {
328
- return (0, torchsdk_1.buildBorrowTransaction)(connection, {
329
- mint: params.mint,
330
- borrower: params.borrower,
331
- collateral_amount: params.collateral_amount,
332
- sol_to_borrow: params.sol_to_borrow,
333
- vault: params.stronghold,
334
- });
335
- }
336
- /** Repay a war loan */
337
- async function repayWarLoan(connection, params) {
338
- return (0, torchsdk_1.buildRepayTransaction)(connection, {
339
- mint: params.mint,
340
- borrower: params.borrower,
341
- sol_amount: params.sol_amount,
342
- vault: params.stronghold,
343
- });
344
- }
345
- /** Trade on DEX via stronghold (vault-routed Raydium swap) */
346
- async function tradeOnDex(connection, params) {
347
- return (0, torchsdk_1.buildVaultSwapTransaction)(connection, {
348
- mint: params.mint,
349
- signer: params.signer,
350
- vault_creator: params.stronghold_creator,
351
- amount_in: params.amount_in,
352
- minimum_amount_out: params.minimum_amount_out,
353
- is_buy: params.is_buy,
354
- message: params.message,
355
- });
356
- }
357
- /** Claim spoils (protocol rewards) */
358
- async function claimSpoils(connection, params) {
359
- return (0, torchsdk_1.buildClaimProtocolRewardsTransaction)(connection, {
360
- user: params.agent,
361
- vault: params.stronghold,
362
- });
363
- }
364
- // ─── Stronghold Operations (authority) ─────────────────────────────
365
- /** Create a new stronghold (vault) */
366
- async function createStronghold(connection, params) {
367
- return (0, torchsdk_1.buildCreateVaultTransaction)(connection, {
368
- creator: params.creator,
369
- });
370
- }
371
- /** Fund a stronghold with SOL */
372
- async function fundStronghold(connection, params) {
373
- return (0, torchsdk_1.buildDepositVaultTransaction)(connection, {
374
- depositor: params.depositor,
375
- vault_creator: params.stronghold_creator,
376
- amount_sol: params.amount_sol,
377
- });
378
- }
379
- /** Withdraw SOL from a stronghold */
380
- async function withdrawFromStronghold(connection, params) {
381
- return (0, torchsdk_1.buildWithdrawVaultTransaction)(connection, {
382
- authority: params.authority,
383
- vault_creator: params.stronghold_creator,
384
- amount_sol: params.amount_sol,
385
- });
386
- }
387
- /** Recruit an agent (link wallet to stronghold) */
388
- async function recruitAgent(connection, params) {
389
- return (0, torchsdk_1.buildLinkWalletTransaction)(connection, {
390
- authority: params.authority,
391
- vault_creator: params.stronghold_creator,
392
- wallet_to_link: params.wallet_to_link,
393
- });
394
- }
395
- /** Exile an agent (unlink wallet from stronghold) */
396
- async function exileAgent(connection, params) {
397
- return (0, torchsdk_1.buildUnlinkWalletTransaction)(connection, {
398
- authority: params.authority,
399
- vault_creator: params.stronghold_creator,
400
- wallet_to_unlink: params.wallet_to_unlink,
401
- });
402
- }
403
- /** Coup — transfer stronghold authority */
404
- async function coup(connection, params) {
405
- return (0, torchsdk_1.buildTransferAuthorityTransaction)(connection, {
406
- authority: params.authority,
407
- vault_creator: params.stronghold_creator,
408
- new_authority: params.new_authority,
409
- });
410
- }
411
- /** Withdraw token assets from stronghold */
412
- async function withdrawAssets(connection, params) {
413
- return (0, torchsdk_1.buildWithdrawTokensTransaction)(connection, {
414
- authority: params.authority,
415
- vault_creator: params.stronghold_creator,
416
- mint: params.mint,
417
- destination: params.destination,
418
- amount: params.amount,
419
- });
420
- }
421
- // ─── Permissionless Operations ─────────────────────────────────────
422
- /** Siege — liquidate an undercollateralized war loan */
423
- async function siege(connection, params) {
424
- return (0, torchsdk_1.buildLiquidateTransaction)(connection, {
425
- mint: params.mint,
426
- liquidator: params.liquidator,
427
- borrower: params.borrower,
428
- vault: params.stronghold,
429
- });
430
- }
431
- /** Ascend — migrate a completed faction to DEX */
432
- async function ascend(connection, params) {
433
- return (0, torchsdk_1.buildMigrateTransaction)(connection, {
434
- mint: params.mint,
435
- payer: params.payer,
436
- });
437
- }
438
- /** Raze — reclaim a failed faction */
439
- async function raze(connection, params) {
440
- return (0, torchsdk_1.buildReclaimFailedTokenTransaction)(connection, {
441
- payer: params.payer,
442
- mint: params.mint,
443
- });
444
- }
445
- /** Tithe — harvest transfer fees */
446
- async function tithe(connection, params) {
447
- return (0, torchsdk_1.buildHarvestFeesTransaction)(connection, {
448
- mint: params.mint,
449
- payer: params.payer,
450
- sources: params.sources,
451
- });
452
- }
453
- /** Convert tithe — swap harvested fees to SOL */
454
- async function convertTithe(connection, params) {
455
- return (0, torchsdk_1.buildSwapFeesToSolTransaction)(connection, {
456
- mint: params.mint,
457
- payer: params.payer,
458
- minimum_amount_out: params.minimum_amount_out,
459
- harvest: params.harvest,
460
- sources: params.sources,
461
- });
462
- }
463
- // ─── SAID Operations ───────────────────────────────────────────────
464
- /** Verify an agent's SAID reputation */
465
- async function verifyAgent(wallet) {
466
- return (0, torchsdk_1.verifySaid)(wallet);
467
- }
468
- /** Confirm a transaction on-chain */
469
- async function confirmAction(connection, signature, wallet) {
470
- return (0, torchsdk_1.confirmTransaction)(connection, signature, wallet);
471
- }
472
- // ─── Utility ───────────────────────────────────────────────────────
473
- /** Create an ephemeral agent keypair (memory-only, zero key management) */
474
- var torchsdk_2 = require("torchsdk");
475
- Object.defineProperty(exports, "createEphemeralAgent", { enumerable: true, get: function () { return torchsdk_2.createEphemeralAgent; } });
476
- /** Get the Raydium pool state PDA for an ascended faction's DEX pool */
477
- function getDexPool(mint) {
478
- const { poolState } = (0, torchsdk_1.getRaydiumMigrationAccounts)(new web3_js_1.PublicKey(mint));
479
- return poolState;
480
- }
481
- /** Get Raydium pool vault addresses for an ascended faction */
482
- function getDexVaults(mint) {
483
- const accts = (0, torchsdk_1.getRaydiumMigrationAccounts)(new web3_js_1.PublicKey(mint));
484
- return {
485
- solVault: (accts.isWsolToken0 ? accts.token0Vault : accts.token1Vault).toString(),
486
- tokenVault: (accts.isWsolToken0 ? accts.token1Vault : accts.token0Vault).toString(),
487
- };
488
- }