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.
@@ -0,0 +1,353 @@
1
+ /**
2
+ * Pyre Kit Types
3
+ *
4
+ * Game-semantic wrappers over torchsdk types.
5
+ * Torch Market IS the game engine — these types translate
6
+ * protocol primitives into faction warfare language.
7
+ */
8
+ import type { Transaction, Keypair, PublicKey } from '@solana/web3.js';
9
+ import type { TokenSortOption, TransactionResult, CreateTokenResult, SaidVerification, ConfirmResult, EphemeralAgent } from 'torchsdk';
10
+ /** Faction lifecycle: rising (bonding) → ready (complete) → ascended (migrated) → razed (reclaimed) */
11
+ export type FactionStatus = 'rising' | 'ready' | 'ascended' | 'razed';
12
+ /** Faction tier based on SOL target: ember (spark) → blaze (flame) → inferno (torch) */
13
+ export type FactionTier = 'ember' | 'blaze' | 'inferno';
14
+ /** Governance strategy: scorched_earth (burn tokens) or fortify (return to treasury lock) */
15
+ export type Strategy = 'scorched_earth' | 'fortify';
16
+ /** Agent loan health status */
17
+ export type AgentHealth = 'healthy' | 'at_risk' | 'liquidatable' | 'none';
18
+ /** Summary view of a faction (wraps TokenSummary) */
19
+ export interface FactionSummary {
20
+ mint: string;
21
+ name: string;
22
+ symbol: string;
23
+ status: FactionStatus;
24
+ tier: FactionTier;
25
+ price_sol: number;
26
+ market_cap_sol: number;
27
+ progress_percent: number;
28
+ members: number | null;
29
+ created_at: number;
30
+ last_activity_at: number;
31
+ }
32
+ /** Detailed view of a faction (wraps TokenDetail) */
33
+ export interface FactionDetail {
34
+ mint: string;
35
+ name: string;
36
+ symbol: string;
37
+ description?: string;
38
+ image?: string;
39
+ status: FactionStatus;
40
+ tier: FactionTier;
41
+ price_sol: number;
42
+ price_usd?: number;
43
+ market_cap_sol: number;
44
+ market_cap_usd?: number;
45
+ progress_percent: number;
46
+ sol_raised: number;
47
+ sol_target: number;
48
+ total_supply: number;
49
+ circulating_supply: number;
50
+ tokens_in_curve: number;
51
+ tokens_in_vote_vault: number;
52
+ tokens_burned: number;
53
+ war_chest_sol: number;
54
+ war_chest_tokens: number;
55
+ total_bought_back: number;
56
+ buyback_count: number;
57
+ votes_scorched_earth: number;
58
+ votes_fortify: number;
59
+ founder: string;
60
+ members: number | null;
61
+ rallies: number;
62
+ created_at: number;
63
+ last_activity_at: number;
64
+ twitter?: string;
65
+ telegram?: string;
66
+ website?: string;
67
+ founder_verified?: boolean;
68
+ founder_trust_tier?: 'high' | 'medium' | 'low' | null;
69
+ founder_said_name?: string;
70
+ founder_badge_url?: string;
71
+ warnings?: string[];
72
+ }
73
+ /** Agent stronghold (wraps VaultInfo) */
74
+ export interface Stronghold {
75
+ address: string;
76
+ creator: string;
77
+ authority: string;
78
+ sol_balance: number;
79
+ total_deposited: number;
80
+ total_withdrawn: number;
81
+ total_spent: number;
82
+ total_received: number;
83
+ linked_agents: number;
84
+ created_at: number;
85
+ }
86
+ /** Agent wallet link (wraps VaultWalletLinkInfo) */
87
+ export interface AgentLink {
88
+ address: string;
89
+ stronghold: string;
90
+ wallet: string;
91
+ linked_at: number;
92
+ }
93
+ /** Faction communication (wraps TokenMessage) */
94
+ export interface Comms {
95
+ signature: string;
96
+ memo: string;
97
+ sender: string;
98
+ timestamp: number;
99
+ sender_verified?: boolean;
100
+ sender_trust_tier?: 'high' | 'medium' | 'low' | null;
101
+ sender_said_name?: string;
102
+ sender_badge_url?: string;
103
+ }
104
+ /** War chest lending info (wraps LendingInfo) */
105
+ export interface WarChest {
106
+ interest_rate_bps: number;
107
+ max_ltv_bps: number;
108
+ liquidation_threshold_bps: number;
109
+ liquidation_bonus_bps: number;
110
+ utilization_cap_bps: number;
111
+ borrow_share_multiplier: number;
112
+ total_sol_lent: number | null;
113
+ active_loans: number | null;
114
+ war_chest_sol_available: number;
115
+ warnings?: string[];
116
+ }
117
+ /** War loan position (wraps LoanPositionInfo) */
118
+ export interface WarLoan {
119
+ collateral_amount: number;
120
+ borrowed_amount: number;
121
+ accrued_interest: number;
122
+ total_owed: number;
123
+ collateral_value_sol: number | null;
124
+ current_ltv_bps: number | null;
125
+ health: AgentHealth;
126
+ warnings?: string[];
127
+ }
128
+ /** War loan with borrower key (wraps LoanPositionWithKey) */
129
+ export interface WarLoanWithAgent extends WarLoan {
130
+ borrower: string;
131
+ }
132
+ /** Faction member (wraps Holder) */
133
+ export interface Member {
134
+ address: string;
135
+ balance: number;
136
+ percentage: number;
137
+ }
138
+ export interface FactionListResult {
139
+ factions: FactionSummary[];
140
+ total: number;
141
+ limit: number;
142
+ offset: number;
143
+ }
144
+ export interface MembersResult {
145
+ members: Member[];
146
+ total_members: number;
147
+ }
148
+ export interface CommsResult {
149
+ comms: Comms[];
150
+ total: number;
151
+ }
152
+ export interface AllWarLoansResult {
153
+ positions: WarLoanWithAgent[];
154
+ pool_price_sol: number | null;
155
+ }
156
+ export interface LaunchFactionParams {
157
+ founder: string;
158
+ name: string;
159
+ symbol: string;
160
+ metadata_uri: string;
161
+ sol_target?: number;
162
+ community_faction?: boolean;
163
+ }
164
+ export interface JoinFactionParams {
165
+ mint: string;
166
+ agent: string;
167
+ amount_sol: number;
168
+ slippage_bps?: number;
169
+ strategy?: Strategy;
170
+ message?: string;
171
+ stronghold: string;
172
+ }
173
+ export interface DirectJoinFactionParams {
174
+ mint: string;
175
+ agent: string;
176
+ amount_sol: number;
177
+ slippage_bps?: number;
178
+ strategy?: Strategy;
179
+ message?: string;
180
+ }
181
+ export interface DefectParams {
182
+ mint: string;
183
+ agent: string;
184
+ amount_tokens: number;
185
+ slippage_bps?: number;
186
+ message?: string;
187
+ stronghold?: string;
188
+ }
189
+ export interface RallyParams {
190
+ mint: string;
191
+ agent: string;
192
+ stronghold?: string;
193
+ }
194
+ export interface RequestWarLoanParams {
195
+ mint: string;
196
+ borrower: string;
197
+ collateral_amount: number;
198
+ sol_to_borrow: number;
199
+ stronghold?: string;
200
+ }
201
+ export interface RepayWarLoanParams {
202
+ mint: string;
203
+ borrower: string;
204
+ sol_amount: number;
205
+ stronghold?: string;
206
+ }
207
+ export interface SiegeParams {
208
+ mint: string;
209
+ liquidator: string;
210
+ borrower: string;
211
+ stronghold?: string;
212
+ }
213
+ export interface TradeOnDexParams {
214
+ mint: string;
215
+ signer: string;
216
+ stronghold_creator: string;
217
+ amount_in: number;
218
+ minimum_amount_out: number;
219
+ is_buy: boolean;
220
+ }
221
+ export interface ClaimSpoilsParams {
222
+ agent: string;
223
+ stronghold?: string;
224
+ }
225
+ export interface CreateStrongholdParams {
226
+ creator: string;
227
+ }
228
+ export interface FundStrongholdParams {
229
+ depositor: string;
230
+ stronghold_creator: string;
231
+ amount_sol: number;
232
+ }
233
+ export interface WithdrawFromStrongholdParams {
234
+ authority: string;
235
+ stronghold_creator: string;
236
+ amount_sol: number;
237
+ }
238
+ export interface RecruitAgentParams {
239
+ authority: string;
240
+ stronghold_creator: string;
241
+ wallet_to_link: string;
242
+ }
243
+ export interface ExileAgentParams {
244
+ authority: string;
245
+ stronghold_creator: string;
246
+ wallet_to_unlink: string;
247
+ }
248
+ export interface CoupParams {
249
+ authority: string;
250
+ stronghold_creator: string;
251
+ new_authority: string;
252
+ }
253
+ export interface WithdrawAssetsParams {
254
+ authority: string;
255
+ stronghold_creator: string;
256
+ mint: string;
257
+ destination: string;
258
+ amount: number;
259
+ }
260
+ export interface AscendParams {
261
+ mint: string;
262
+ payer: string;
263
+ }
264
+ export interface RazeParams {
265
+ payer: string;
266
+ mint: string;
267
+ }
268
+ export interface TitheParams {
269
+ mint: string;
270
+ payer: string;
271
+ sources?: string[];
272
+ }
273
+ export interface ConvertTitheParams {
274
+ mint: string;
275
+ payer: string;
276
+ minimum_amount_out?: number;
277
+ harvest?: boolean;
278
+ sources?: string[];
279
+ }
280
+ /** Re-export base result types with game names */
281
+ export type { TransactionResult, CreateTokenResult, EphemeralAgent, SaidVerification, ConfirmResult };
282
+ export interface JoinFactionResult extends TransactionResult {
283
+ migrationTransaction?: Transaction;
284
+ }
285
+ export interface LaunchFactionResult extends TransactionResult {
286
+ mint: PublicKey;
287
+ mintKeypair: Keypair;
288
+ }
289
+ export type FactionSortOption = TokenSortOption;
290
+ export type FactionStatusFilter = 'rising' | 'ready' | 'ascended' | 'razed' | 'all';
291
+ export interface FactionListParams {
292
+ limit?: number;
293
+ offset?: number;
294
+ status?: FactionStatusFilter;
295
+ sort?: FactionSortOption;
296
+ }
297
+ export interface FactionPower {
298
+ mint: string;
299
+ name: string;
300
+ symbol: string;
301
+ score: number;
302
+ market_cap_sol: number;
303
+ members: number;
304
+ war_chest_sol: number;
305
+ rallies: number;
306
+ progress_percent: number;
307
+ status: FactionStatus;
308
+ }
309
+ export interface AllianceCluster {
310
+ factions: string[];
311
+ shared_members: number;
312
+ overlap_percent: number;
313
+ }
314
+ export interface RivalFaction {
315
+ mint: string;
316
+ name: string;
317
+ symbol: string;
318
+ defections_in: number;
319
+ defections_out: number;
320
+ }
321
+ export interface AgentProfile {
322
+ wallet: string;
323
+ stronghold: Stronghold | null;
324
+ factions_joined: AgentFactionPosition[];
325
+ factions_founded: string[];
326
+ said_verification: SaidVerification | null;
327
+ total_value_sol: number;
328
+ }
329
+ export interface AgentFactionPosition {
330
+ mint: string;
331
+ name: string;
332
+ symbol: string;
333
+ balance: number;
334
+ percentage: number;
335
+ value_sol: number;
336
+ }
337
+ export interface WorldEvent {
338
+ type: 'launch' | 'join' | 'defect' | 'rally' | 'ascend' | 'raze';
339
+ faction_mint: string;
340
+ faction_name: string;
341
+ agent?: string;
342
+ amount_sol?: number;
343
+ timestamp: number;
344
+ signature?: string;
345
+ message?: string;
346
+ }
347
+ export interface WorldStats {
348
+ total_factions: number;
349
+ rising_factions: number;
350
+ ascended_factions: number;
351
+ total_sol_locked: number;
352
+ most_powerful: FactionPower | null;
353
+ }
package/dist/types.js ADDED
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ /**
3
+ * Pyre Kit Types
4
+ *
5
+ * Game-semantic wrappers over torchsdk types.
6
+ * Torch Market IS the game engine — these types translate
7
+ * protocol primitives into faction warfare language.
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Pyre vanity mint address grinder
3
+ *
4
+ * Grinds for Solana keypairs whose base58 address ends with "pyre".
5
+ * This is how we distinguish pyre faction tokens from regular torch tokens —
6
+ * no registry program needed, just check the mint suffix.
7
+ */
8
+ import { Connection, Keypair } from '@solana/web3.js';
9
+ import type { CreateTokenResult, CreateTokenParams } from 'torchsdk';
10
+ /** Grind for a keypair whose base58 address ends with "py" */
11
+ export declare function grindPyreMint(maxAttempts?: number): Keypair;
12
+ /** Check if a mint address is a pyre faction (ends with "py") */
13
+ export declare function isPyreMint(mint: string): boolean;
14
+ export declare function buildCreateFactionTransaction(connection: Connection, params: CreateTokenParams): Promise<CreateTokenResult>;
package/dist/vanity.js ADDED
@@ -0,0 +1,115 @@
1
+ "use strict";
2
+ /**
3
+ * Pyre vanity mint address grinder
4
+ *
5
+ * Grinds for Solana keypairs whose base58 address ends with "pyre".
6
+ * This is how we distinguish pyre faction tokens from regular torch tokens —
7
+ * no registry program needed, just check the mint suffix.
8
+ */
9
+ var __importDefault = (this && this.__importDefault) || function (mod) {
10
+ return (mod && mod.__esModule) ? mod : { "default": mod };
11
+ };
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ exports.grindPyreMint = grindPyreMint;
14
+ exports.isPyreMint = isPyreMint;
15
+ exports.buildCreateFactionTransaction = buildCreateFactionTransaction;
16
+ const web3_js_1 = require("@solana/web3.js");
17
+ const spl_token_1 = require("@solana/spl-token");
18
+ const anchor_1 = require("@coral-xyz/anchor");
19
+ const torchsdk_1 = require("torchsdk");
20
+ // Token-2022 program ID
21
+ const TOKEN_2022_PROGRAM_ID = new web3_js_1.PublicKey('TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb');
22
+ // PDA seeds (must match the Rust program)
23
+ const GLOBAL_CONFIG_SEED = 'global_config';
24
+ const BONDING_CURVE_SEED = 'bonding_curve';
25
+ const TREASURY_SEED = 'treasury';
26
+ const TREASURY_LOCK_SEED = 'treasury_lock';
27
+ // IDL loaded from torchsdk dist
28
+ const torch_market_json_1 = __importDefault(require("torchsdk/dist/torch_market.json"));
29
+ // ── PDA helpers (copied from torchsdk internals) ──
30
+ const getGlobalConfigPda = () => web3_js_1.PublicKey.findProgramAddressSync([Buffer.from(GLOBAL_CONFIG_SEED)], torchsdk_1.PROGRAM_ID);
31
+ const getBondingCurvePda = (mint) => web3_js_1.PublicKey.findProgramAddressSync([Buffer.from(BONDING_CURVE_SEED), mint.toBuffer()], torchsdk_1.PROGRAM_ID);
32
+ const getTokenTreasuryPda = (mint) => web3_js_1.PublicKey.findProgramAddressSync([Buffer.from(TREASURY_SEED), mint.toBuffer()], torchsdk_1.PROGRAM_ID);
33
+ const getTreasuryTokenAccount = (mint, treasury) => (0, spl_token_1.getAssociatedTokenAddressSync)(mint, treasury, true, TOKEN_2022_PROGRAM_ID);
34
+ const getTreasuryLockPda = (mint) => web3_js_1.PublicKey.findProgramAddressSync([Buffer.from(TREASURY_LOCK_SEED), mint.toBuffer()], torchsdk_1.PROGRAM_ID);
35
+ const getTreasuryLockTokenAccount = (mint, treasuryLock) => (0, spl_token_1.getAssociatedTokenAddressSync)(mint, treasuryLock, true, TOKEN_2022_PROGRAM_ID);
36
+ const makeDummyProvider = (connection, payer) => {
37
+ const dummyWallet = {
38
+ publicKey: payer,
39
+ signTransaction: async (t) => t,
40
+ signAllTransactions: async (t) => t,
41
+ };
42
+ return new anchor_1.AnchorProvider(connection, dummyWallet, {});
43
+ };
44
+ const finalizeTransaction = async (connection, tx, feePayer) => {
45
+ const { blockhash } = await connection.getLatestBlockhash();
46
+ tx.recentBlockhash = blockhash;
47
+ tx.feePayer = feePayer;
48
+ };
49
+ // ── Vanity grinder ──
50
+ const PYRE_SUFFIX = 'py';
51
+ /** Grind for a keypair whose base58 address ends with "py" */
52
+ function grindPyreMint(maxAttempts = 500_000) {
53
+ for (let i = 0; i < maxAttempts; i++) {
54
+ const kp = web3_js_1.Keypair.generate();
55
+ if (kp.publicKey.toBase58().endsWith(PYRE_SUFFIX)) {
56
+ return kp;
57
+ }
58
+ }
59
+ // Fallback — return last generated keypair (should be extremely rare)
60
+ return web3_js_1.Keypair.generate();
61
+ }
62
+ /** Check if a mint address is a pyre faction (ends with "py") */
63
+ function isPyreMint(mint) {
64
+ return mint.endsWith(PYRE_SUFFIX);
65
+ }
66
+ // ── Build create transaction with pyre vanity address ──
67
+ async function buildCreateFactionTransaction(connection, params) {
68
+ const { creator: creatorStr, name, symbol, metadata_uri, sol_target = 0, community_token = true } = params;
69
+ const creator = new web3_js_1.PublicKey(creatorStr);
70
+ if (name.length > 32)
71
+ throw new Error('Name must be 32 characters or less');
72
+ if (symbol.length > 10)
73
+ throw new Error('Symbol must be 10 characters or less');
74
+ // Grind for "pyre" suffix instead of "tm"
75
+ const mint = grindPyreMint();
76
+ // Derive PDAs
77
+ const [globalConfig] = getGlobalConfigPda();
78
+ const [bondingCurve] = getBondingCurvePda(mint.publicKey);
79
+ const [treasury] = getTokenTreasuryPda(mint.publicKey);
80
+ const bondingCurveTokenAccount = (0, spl_token_1.getAssociatedTokenAddressSync)(mint.publicKey, bondingCurve, true, TOKEN_2022_PROGRAM_ID);
81
+ const treasuryTokenAccount = getTreasuryTokenAccount(mint.publicKey, treasury);
82
+ const [treasuryLock] = getTreasuryLockPda(mint.publicKey);
83
+ const treasuryLockTokenAccount = getTreasuryLockTokenAccount(mint.publicKey, treasuryLock);
84
+ const tx = new web3_js_1.Transaction();
85
+ const provider = makeDummyProvider(connection, creator);
86
+ const program = new anchor_1.Program(torch_market_json_1.default, provider);
87
+ const createIx = await program.methods
88
+ .createToken({ name, symbol, uri: metadata_uri, solTarget: new anchor_1.BN(sol_target), communityToken: community_token })
89
+ .accounts({
90
+ creator,
91
+ globalConfig,
92
+ mint: mint.publicKey,
93
+ bondingCurve,
94
+ tokenVault: bondingCurveTokenAccount,
95
+ treasury,
96
+ treasuryTokenAccount,
97
+ treasuryLock,
98
+ treasuryLockTokenAccount,
99
+ token2022Program: TOKEN_2022_PROGRAM_ID,
100
+ associatedTokenProgram: spl_token_1.ASSOCIATED_TOKEN_PROGRAM_ID,
101
+ systemProgram: web3_js_1.SystemProgram.programId,
102
+ rent: web3_js_1.SYSVAR_RENT_PUBKEY,
103
+ })
104
+ .instruction();
105
+ tx.add(createIx);
106
+ await finalizeTransaction(connection, tx, creator);
107
+ // Partially sign with mint keypair
108
+ tx.partialSign(mint);
109
+ return {
110
+ transaction: tx,
111
+ mint: mint.publicKey,
112
+ mintKeypair: mint,
113
+ message: `Create faction "${name}" ($${symbol}) [pyre:${mint.publicKey.toBase58()}]`,
114
+ };
115
+ }
package/package.json ADDED
@@ -0,0 +1,25 @@
1
+ {
2
+ "name": "pyre-world-kit",
3
+ "version": "1.0.0",
4
+ "description": "Agent-first faction warfare kit — game-semantic wrapper over torchsdk",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "scripts": {
8
+ "build": "tsc",
9
+ "test": "npx tsx tests/test_e2e.ts",
10
+ "test:sim": "npx tsx tests/test_sim.ts",
11
+ "test:devnet": "npx tsx tests/test_devnet_e2e.ts"
12
+ },
13
+ "dependencies": {
14
+ "torchsdk": "^3.7.30",
15
+ "@solana/web3.js": "^1.98.4",
16
+ "@solana/spl-token": "^0.4.6",
17
+ "@coral-xyz/anchor": "^0.32.1"
18
+ },
19
+ "devDependencies": {
20
+ "@types/node": "^22.15.0",
21
+ "typescript": "^5.9.3",
22
+ "tsx": "^4.19.4"
23
+ },
24
+ "packageManager": "pnpm@9.10.0+sha512.73a29afa36a0d092ece5271de5177ecbf8318d454ecd701343131b8ebc0c1a91c487da46ab77c8e596d6acf1461e3594ced4becedf8921b074fbd8653ed7051c"
25
+ }