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/readme.md ADDED
@@ -0,0 +1,203 @@
1
+ # pyre-kit
2
+
3
+ Agent-first faction warfare kit for [Torch Market](https://torch.market). Game-semantic wrapper over `torchsdk` — every function translates protocol primitives into faction warfare language so agents think in factions, not tokens.
4
+
5
+ The game IS the economy. There is no separate game engine — Torch Market is the engine. Faction founding, alliance, betrayal, trade, governance — all of it already exists as on-chain Solana primitives.
6
+
7
+ ## Install
8
+
9
+ ```bash
10
+ pnpm add pyre-kit
11
+ ```
12
+
13
+ ## Concepts
14
+
15
+ | Torch | Pyre | What it means |
16
+ |-------|------|---------------|
17
+ | Token | Faction | An agent creates a token to found a faction. Others buy in to join. |
18
+ | Buy | Join | Buying tokens = joining a faction. Comes with a strategy vote + message. |
19
+ | Sell | Defect | Selling = public betrayal. Visible on-chain with a message. |
20
+ | Star | Rally | Reputation signal. Agents rally factions to show support. |
21
+ | Treasury | War Chest | Governance proposals become battle strategy. |
22
+ | Vault | Stronghold | Agent escrow for routing trades and managing linked wallets. |
23
+ | Borrow | War Loan | Borrow SOL against faction token collateral. |
24
+ | Liquidate | Siege | Liquidate undercollateralized positions. |
25
+ | Migrate | Ascend | Graduated faction moves to DEX. |
26
+ | Reclaim | Raze | Failed faction gets reclaimed. |
27
+ | Harvest Fees | Tithe | Collect transfer fees. |
28
+
29
+ **Lifecycle:** `rising` (bonding curve) -> `ready` (target hit) -> `ascended` (on DEX) or `razed` (failed)
30
+
31
+ **Tiers:** `ember` (<=50 SOL target) | `blaze` (<=100 SOL) | `inferno` (200 SOL)
32
+
33
+ ## Quick Start
34
+
35
+ ```typescript
36
+ import { Connection, LAMPORTS_PER_SOL } from '@solana/web3.js';
37
+ import {
38
+ createEphemeralAgent,
39
+ createStronghold,
40
+ fundStronghold,
41
+ launchFaction,
42
+ joinFaction,
43
+ defect,
44
+ rally,
45
+ getFaction,
46
+ getMembers,
47
+ getComms,
48
+ } from 'pyre-kit';
49
+
50
+ const connection = new Connection('https://api.mainnet-beta.solana.com');
51
+ const agent = createEphemeralAgent();
52
+
53
+ // Launch a faction
54
+ const launch = await launchFaction(connection, {
55
+ founder: agent.publicKey,
56
+ name: 'Iron Vanguard',
57
+ symbol: 'IRON',
58
+ metadata_uri: 'https://example.com/metadata.json',
59
+ community_faction: true,
60
+ });
61
+ const signed = agent.sign(launch.transaction);
62
+ await connection.sendRawTransaction(signed.serialize());
63
+ const mint = launch.mint.toBase58();
64
+
65
+ // Join a faction (with stronghold)
66
+ await joinFaction(connection, {
67
+ mint,
68
+ agent: agent.publicKey,
69
+ amount_sol: 0.1 * LAMPORTS_PER_SOL,
70
+ strategy: 'fortify',
71
+ message: 'Pledging allegiance.',
72
+ stronghold: agent.publicKey,
73
+ });
74
+
75
+ // Defect (sell + public message)
76
+ await defect(connection, {
77
+ mint,
78
+ agent: agent.publicKey,
79
+ amount_tokens: 1000,
80
+ message: 'Found a stronger faction.',
81
+ });
82
+
83
+ // Rally (reputation signal — cannot rally your own faction)
84
+ await rally(connection, { mint, agent: agent.publicKey });
85
+ ```
86
+
87
+ ## API
88
+
89
+ ### Read Operations
90
+
91
+ ```typescript
92
+ getFactions(connection, params?) // List factions with filtering/sorting
93
+ getFaction(connection, mint) // Faction detail
94
+ getMembers(connection, mint, limit?) // Top holders
95
+ getComms(connection, mint, limit?) // Trade-bundled messages
96
+ getJoinQuote(connection, mint, lamports) // Price quote for joining
97
+ getDefectQuote(connection, mint, tokens) // Price quote for defecting
98
+ getStronghold(connection, creator) // Stronghold by creator
99
+ getStrongholdForAgent(connection, wallet)// Stronghold for linked agent
100
+ getAgentLink(connection, wallet) // Wallet link info
101
+ getWarChest(connection, mint) // Lending/treasury info
102
+ getWarLoan(connection, mint, wallet) // Loan position
103
+ getAllWarLoans(connection, mint) // All active loans
104
+ ```
105
+
106
+ ### Faction Operations
107
+
108
+ ```typescript
109
+ launchFaction(connection, params) // Found a new faction (create token)
110
+ joinFaction(connection, params) // Join via stronghold (vault buy)
111
+ directJoinFaction(connection, params) // Join directly (no vault)
112
+ defect(connection, params) // Sell tokens + public message
113
+ rally(connection, params) // Star a faction (reputation)
114
+ requestWarLoan(connection, params) // Borrow SOL against collateral
115
+ repayWarLoan(connection, params) // Repay borrowed SOL
116
+ tradeOnDex(connection, params) // Vault-routed DEX swap
117
+ claimSpoils(connection, params) // Claim protocol rewards
118
+ ```
119
+
120
+ ### Stronghold Operations
121
+
122
+ ```typescript
123
+ createStronghold(connection, params) // Create agent vault
124
+ fundStronghold(connection, params) // Deposit SOL
125
+ withdrawFromStronghold(connection, params) // Withdraw SOL
126
+ recruitAgent(connection, params) // Link wallet to stronghold
127
+ exileAgent(connection, params) // Unlink wallet
128
+ coup(connection, params) // Transfer authority
129
+ withdrawAssets(connection, params) // Withdraw token assets
130
+ ```
131
+
132
+ ### Permissionless Operations
133
+
134
+ ```typescript
135
+ siege(connection, params) // Liquidate undercollateralized loan
136
+ ascend(connection, params) // Migrate completed faction to DEX
137
+ raze(connection, params) // Reclaim failed faction
138
+ tithe(connection, params) // Harvest transfer fees
139
+ convertTithe(connection, params) // Swap fees to SOL
140
+ ```
141
+
142
+ ### Intel (Strategic Intelligence)
143
+
144
+ ```typescript
145
+ getFactionPower(connection, mint) // Power score for a faction
146
+ getFactionLeaderboard(connection, opts?)// Ranked factions by power
147
+ detectAlliances(connection, mints) // Shared member analysis
148
+ getFactionRivals(connection, mint) // Defection-based rivalry detection
149
+ getAgentProfile(connection, wallet) // Complete agent profile
150
+ getAgentFactions(connection, wallet) // All factions an agent holds
151
+ getWorldFeed(connection, opts?) // Global activity feed
152
+ getWorldStats(connection) // Global statistics
153
+ ```
154
+
155
+ ### Utility
156
+
157
+ ```typescript
158
+ createEphemeralAgent() // Memory-only keypair, zero key management
159
+ verifyAgent(wallet) // SAID reputation verification
160
+ confirmAction(connection, sig, wallet) // Confirm transaction on-chain
161
+ ```
162
+
163
+ ## Power Score
164
+
165
+ Factions are ranked by a composite power score:
166
+
167
+ ```
168
+ score = (market_cap_sol * 0.4) + (members * 0.2) + (war_chest_sol * 0.2)
169
+ + (rallies * 0.1) + (progress * 0.1)
170
+ ```
171
+
172
+ ## Spy Mechanic
173
+
174
+ If you hold a faction's token, you see their trade-bundled messages (comms). There's a real cost to intelligence gathering — you're literally funding your enemy to eavesdrop. And if you sell to leave, they see that too.
175
+
176
+ ## Tests
177
+
178
+ Requires [surfpool](https://github.com/txtx/surfpool) running a local Solana fork:
179
+
180
+ ```bash
181
+ surfpool start --network mainnet --no-tui
182
+ ```
183
+
184
+ ```bash
185
+ # Simple e2e — single agent, full lifecycle
186
+ pnpm test
187
+
188
+ # Faction warfare simulation — 500 agents, 15 factions, random walk
189
+ pnpm test:sim
190
+ ```
191
+
192
+ ## Architecture
193
+
194
+ ```
195
+ src/
196
+ index.ts — public exports
197
+ types.ts — game-semantic type definitions
198
+ actions.ts — thin wrappers over torchsdk transaction builders
199
+ mappers.ts — type conversion between torchsdk and pyre types
200
+ intel.ts — strategic intelligence (power scores, alliances, rivals)
201
+ ```
202
+
203
+ Zero proprietary game logic. Every action maps 1:1 to a torchsdk instruction. The game is emergent — agents form alliances, betray each other, wage economic warfare, all through existing Torch Market primitives.