pyre-world-kit 1.0.9 → 1.0.11
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 +19 -1
- package/dist/actions.js +93 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +7 -2
- package/dist/types.d.ts +17 -0
- package/package.json +1 -1
- package/src/actions.ts +108 -0
- package/src/index.ts +6 -0
- package/src/types.ts +20 -0
package/dist/actions.d.ts
CHANGED
|
@@ -6,7 +6,13 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import { Connection, PublicKey } from '@solana/web3.js';
|
|
8
8
|
import type { BuyQuoteResult, SellQuoteResult, TransactionResult, SaidVerification, ConfirmResult } from 'torchsdk';
|
|
9
|
-
import type { FactionListParams, FactionListResult, FactionDetail, MembersResult, CommsResult, Stronghold, AgentLink, WarChest, WarLoan, AllWarLoansResult, LaunchFactionParams, JoinFactionParams, DirectJoinFactionParams, DefectParams, RallyParams, RequestWarLoanParams, RepayWarLoanParams, SiegeParams, TradeOnDexParams, ClaimSpoilsParams, CreateStrongholdParams, FundStrongholdParams, WithdrawFromStrongholdParams, RecruitAgentParams, ExileAgentParams, CoupParams, WithdrawAssetsParams, AscendParams, RazeParams, TitheParams, ConvertTitheParams, JoinFactionResult, LaunchFactionResult } from './types';
|
|
9
|
+
import type { FactionListParams, FactionListResult, FactionDetail, MembersResult, CommsResult, Stronghold, AgentLink, WarChest, WarLoan, WarLoanQuote, AllWarLoansResult, LaunchFactionParams, JoinFactionParams, DirectJoinFactionParams, DefectParams, RallyParams, RequestWarLoanParams, RepayWarLoanParams, SiegeParams, TradeOnDexParams, ClaimSpoilsParams, CreateStrongholdParams, FundStrongholdParams, WithdrawFromStrongholdParams, RecruitAgentParams, ExileAgentParams, CoupParams, WithdrawAssetsParams, AscendParams, RazeParams, TitheParams, ConvertTitheParams, JoinFactionResult, LaunchFactionResult } 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[];
|
|
10
16
|
/** List all factions with optional filtering and sorting */
|
|
11
17
|
export declare function getFactions(connection: Connection, params?: FactionListParams): Promise<FactionListResult>;
|
|
12
18
|
/** Get detailed info for a single faction */
|
|
@@ -31,6 +37,18 @@ export declare function getWarChest(connection: Connection, mint: string): Promi
|
|
|
31
37
|
export declare function getWarLoan(connection: Connection, mint: string, wallet: string): Promise<WarLoan>;
|
|
32
38
|
/** Get all war loans for a faction */
|
|
33
39
|
export declare function getAllWarLoans(connection: Connection, mint: string): Promise<AllWarLoansResult>;
|
|
40
|
+
/**
|
|
41
|
+
* Compute max borrowable SOL for a given collateral amount.
|
|
42
|
+
*
|
|
43
|
+
* Mirrors the burnfun LendingDashboard logic — effective max borrow is the
|
|
44
|
+
* minimum of three caps:
|
|
45
|
+
* 1. LTV limit: collateral_value_sol * (max_ltv_bps / 10000)
|
|
46
|
+
* 2. Pool available: treasury_sol * utilization_cap - total_lent
|
|
47
|
+
* 3. Per-user cap: (collateral / total_supply) * borrow_share_multiplier * max_lendable
|
|
48
|
+
*
|
|
49
|
+
* All values in lamports. Accounts for Token-2022 transfer fee (4 bps).
|
|
50
|
+
*/
|
|
51
|
+
export declare function getMaxWarLoan(connection: Connection, mint: string, collateralAmount: number): Promise<WarLoanQuote>;
|
|
34
52
|
/** Launch a new faction (create token) */
|
|
35
53
|
export declare function launchFaction(connection: Connection, params: LaunchFactionParams): Promise<LaunchFactionResult>;
|
|
36
54
|
/** Join a faction via stronghold (vault-funded buy) */
|
package/dist/actions.js
CHANGED
|
@@ -10,6 +10,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.createEphemeralAgent = void 0;
|
|
13
|
+
exports.blacklistMints = blacklistMints;
|
|
14
|
+
exports.isBlacklistedMint = isBlacklistedMint;
|
|
15
|
+
exports.getBlacklistedMints = getBlacklistedMints;
|
|
13
16
|
exports.getFactions = getFactions;
|
|
14
17
|
exports.getFaction = getFaction;
|
|
15
18
|
exports.getMembers = getMembers;
|
|
@@ -22,6 +25,7 @@ exports.getAgentLink = getAgentLink;
|
|
|
22
25
|
exports.getWarChest = getWarChest;
|
|
23
26
|
exports.getWarLoan = getWarLoan;
|
|
24
27
|
exports.getAllWarLoans = getAllWarLoans;
|
|
28
|
+
exports.getMaxWarLoan = getMaxWarLoan;
|
|
25
29
|
exports.launchFaction = launchFaction;
|
|
26
30
|
exports.joinFaction = joinFaction;
|
|
27
31
|
exports.directJoinFaction = directJoinFaction;
|
|
@@ -52,6 +56,48 @@ const bs58_1 = __importDefault(require("bs58"));
|
|
|
52
56
|
const torchsdk_1 = require("torchsdk");
|
|
53
57
|
const mappers_1 = require("./mappers");
|
|
54
58
|
const vanity_1 = require("./vanity");
|
|
59
|
+
// ─── Blacklist ──────────────────────────────────────────────────────
|
|
60
|
+
// Mints from previous swarm runs. Agents should skip these and only
|
|
61
|
+
// interact with freshly launched factions.
|
|
62
|
+
const DEFAULT_BLACKLIST = [
|
|
63
|
+
'E1SgYPW6JXhw5BabrvJkr6L2PyvfFenYaoCTePazyNpy', '6jWsyDC87RmfrZZRjuxSAxvUxE665HGZwZ2Z8j5z9epy',
|
|
64
|
+
'6J8PLgFxHb98cNURP2Yt2SKwgnUeEXpN6Us2kxaMz1py', '5A297UyPQstxWpJyydDnFvn2zN8whCEYdqvnfB5bF9py',
|
|
65
|
+
'8XdWfSKLJusAcRrYzK3bWJ7dy46AkbU8qxF3B55uSfpy', '7ZYrKcJbFFbG36keCYRvfc1j1HScQmJW1zRV3wVVD4py',
|
|
66
|
+
'ERQPyG2oqx5bdyuY2Nnm5ZbZY2zcB46TfUxqpzYWH5py', 'JCvpK3kTnh2EdQG71mqE8ZXcvzLU5EJNG5vgGZme4wpy',
|
|
67
|
+
'9RDFkGSjKpjHtXZ25uuug2MN5P7oSjzkLg16HcrKy3py', '2kWcX1ZetV4jUtBPbKKk265q4gS4nuut2kc1MbaZDfpy',
|
|
68
|
+
'3r9FnQim6GToR7NkY5om8igUNu7gfpq5fk2qtv3bV5py', '2498F79s1Ghyj3J4VhV1qy5hhznnM53ZwzTXM9iscopy',
|
|
69
|
+
'5VpotyDyc8QKKqLuzu8pfhtEa9gsRG1ww58DbqJUgTpy', 'GXi1opahTkavPfAqfUhkoUJRBjPoAmAMVW87kdbDwNpy',
|
|
70
|
+
'GKFAokGiyhXGXxUPgwQEo8fE5nBjRdJcVX6LVj7SgPpy', 'EKFVwfNk1xzqhpyFJSMNw8KDcLRemvqxiGoSyfRtBspy',
|
|
71
|
+
'GsZLHVt3mTwus5krUcifBWS52xMQSuXSy3RpPhEFtvpy', '9azKjXnt2w4RB5ykVcyaicWSssmxoapZ9SSQLMZc4Epy',
|
|
72
|
+
'BaLwryyMrqhtsMrELkrTSdWF9UYuNdjW4413hrQqbtpy', '5p9ibszMVe79mm95M8uubS6WttXem2xZfh3mWmBdvUpy',
|
|
73
|
+
'CTvoAmTggJcBTnbxcfy91Y1c6t6fU5xq3SRtYh3TgEpy', '2kqVCdQS9KSv2kxLiytGZfcLsx5xwKQT6rHTg4V18hpy',
|
|
74
|
+
'zV7XZcvY8DVk4scKUiw7GGN4L3eBPSXuD7Q1NPxfspy', '3UhzKfdU1wgnEN2VCykRURw88qVVqeu3ejRkUnjmhRpy',
|
|
75
|
+
'FRaS3dAdr1zo6u811XBVGUp9K2mSdQ2yG8qW4qP5hapy', '4NHzWVP7hzZhd9LhTrbyxzsSnT8EmNSYVP1DpAKXHYpy',
|
|
76
|
+
'Yt2rdfp6uzS7L52df3LPmetLoy3GvKChYJ4Lmvk6gpy', '9Ejju29KHPWMpda4WpFsJ6ZDHVUqNWyMZHteEisgw9py',
|
|
77
|
+
'2zPC4A7WR2cMNDfBzERp49fEbTBCyqXPKhcrgz3hWcpy', '7jBAriydb1qRy7Wg4WAz8woHP4pVxZJSnF7vw95tVQpy',
|
|
78
|
+
'HvPWKuMFpG3zAdkPMbaadyo78VoJbAMtpXaBYMK1Aqpy', 'GyNw9bkqz2rhR66Xx7P4p11PFBrjPi2r6XoCg5gPAdpy',
|
|
79
|
+
'6HveNEes9xtkkchb76JgjWWQ61sbXjESy2vr3A7Maipy', '8E3GETvTkTTaCLpzkyHJTnuNMfmGvzUEgAYnurZuLZpy',
|
|
80
|
+
'AeApaJqppwjW9S2KeZGPZpmg1kAdxZHkFRnXPZc8Kjpy', '8FfteyAMQm96upu4w6cJvE5T8RcMKRf5keJMdXbukXpy',
|
|
81
|
+
'BrEj2Q9XE13WesRU1u8USiprv2DkpBcJfaqQeqQ6grpy', 'Dtki37mAB3DiTW1bp8LnZQyv54UuC68Yo5pGZkPdVSpy',
|
|
82
|
+
'77UzTntZ7ThyXhN4hVvSx7m6tjit8uCw6U2LVQHPSqpy', 'ASV9kiC6vEpZy3X7xVExuyG257KHKd3Hutbji8AVRUpy',
|
|
83
|
+
'Fc1V6KcxSriJkUNeDLqz8w5Sm4mp1s8gxornZVLcHEpy', 'FEizyHEUoYenqfpF87kqiGnq3w1R2TReodEfsnTrrfpy',
|
|
84
|
+
'DmwgcVHoJxKeRiij5LtedY9LWDpqoqa3hGfUyVgBkgpy', 'GUGz1Em5KZ57aKFqEBSd4Y4Vb6WxBd3H2b16fPCC6upy',
|
|
85
|
+
'6ZWY3Bau5zw1j7vMQQ1czSw4rjBJrExHQ8Renor2vLpy',
|
|
86
|
+
];
|
|
87
|
+
const BLACKLISTED_MINTS = new Set(DEFAULT_BLACKLIST);
|
|
88
|
+
/** Add mints to the blacklist (call at startup with old mints) */
|
|
89
|
+
function blacklistMints(mints) {
|
|
90
|
+
for (const m of mints)
|
|
91
|
+
BLACKLISTED_MINTS.add(m);
|
|
92
|
+
}
|
|
93
|
+
/** Check if a mint is blacklisted */
|
|
94
|
+
function isBlacklistedMint(mint) {
|
|
95
|
+
return BLACKLISTED_MINTS.has(mint);
|
|
96
|
+
}
|
|
97
|
+
/** Get all blacklisted mints */
|
|
98
|
+
function getBlacklistedMints() {
|
|
99
|
+
return Array.from(BLACKLISTED_MINTS);
|
|
100
|
+
}
|
|
55
101
|
// ─── Read Operations ───────────────────────────────────────────────
|
|
56
102
|
/** List all factions with optional filtering and sorting */
|
|
57
103
|
async function getFactions(connection, params) {
|
|
@@ -191,6 +237,53 @@ async function getAllWarLoans(connection, mint) {
|
|
|
191
237
|
const result = await (0, torchsdk_1.getAllLoanPositions)(connection, mint);
|
|
192
238
|
return (0, mappers_1.mapAllLoansResult)(result);
|
|
193
239
|
}
|
|
240
|
+
/**
|
|
241
|
+
* Compute max borrowable SOL for a given collateral amount.
|
|
242
|
+
*
|
|
243
|
+
* Mirrors the burnfun LendingDashboard logic — effective max borrow is the
|
|
244
|
+
* minimum of three caps:
|
|
245
|
+
* 1. LTV limit: collateral_value_sol * (max_ltv_bps / 10000)
|
|
246
|
+
* 2. Pool available: treasury_sol * utilization_cap - total_lent
|
|
247
|
+
* 3. Per-user cap: (collateral / total_supply) * borrow_share_multiplier * max_lendable
|
|
248
|
+
*
|
|
249
|
+
* All values in lamports. Accounts for Token-2022 transfer fee (4 bps).
|
|
250
|
+
*/
|
|
251
|
+
async function getMaxWarLoan(connection, mint, collateralAmount) {
|
|
252
|
+
const TOTAL_SUPPLY = 1_000_000_000_000_000; // 1B tokens * 1e6 multiplier (base units)
|
|
253
|
+
const TRANSFER_FEE_BPS = 4;
|
|
254
|
+
const LAMPORTS_PER_SOL = 1_000_000_000;
|
|
255
|
+
const [lending, detail] = await Promise.all([
|
|
256
|
+
(0, torchsdk_1.getLendingInfo)(connection, mint),
|
|
257
|
+
(0, torchsdk_1.getToken)(connection, mint),
|
|
258
|
+
]);
|
|
259
|
+
// Price per base-unit token in SOL (lamports)
|
|
260
|
+
const pricePerToken = detail.price_sol; // SOL per display token
|
|
261
|
+
const TOKEN_MULTIPLIER = 1_000_000;
|
|
262
|
+
// Collateral value in SOL (lamports)
|
|
263
|
+
const collateralDisplayTokens = collateralAmount / TOKEN_MULTIPLIER;
|
|
264
|
+
const collateralValueSol = collateralDisplayTokens * pricePerToken * LAMPORTS_PER_SOL;
|
|
265
|
+
// 1. LTV cap
|
|
266
|
+
const ltvMaxSol = collateralValueSol * (lending.max_ltv_bps / 10000);
|
|
267
|
+
// 2. Pool available
|
|
268
|
+
const treasurySol = detail.treasury_sol_balance * LAMPORTS_PER_SOL;
|
|
269
|
+
const maxLendableSol = treasurySol * lending.utilization_cap_bps / 10000;
|
|
270
|
+
const totalLent = (lending.total_sol_lent ?? 0);
|
|
271
|
+
const poolAvailableSol = Math.max(0, maxLendableSol - totalLent);
|
|
272
|
+
// 3. Per-user cap (accounts for transfer fee reducing net collateral)
|
|
273
|
+
const netCollateral = collateralAmount * (1 - TRANSFER_FEE_BPS / 10000);
|
|
274
|
+
const borrowMultiplier = lending.borrow_share_multiplier || 3;
|
|
275
|
+
const perUserCapSol = maxLendableSol * netCollateral * borrowMultiplier / TOTAL_SUPPLY;
|
|
276
|
+
const maxBorrowSol = Math.max(0, Math.min(ltvMaxSol, poolAvailableSol, perUserCapSol));
|
|
277
|
+
return {
|
|
278
|
+
max_borrow_sol: Math.floor(maxBorrowSol),
|
|
279
|
+
collateral_value_sol: Math.floor(collateralValueSol),
|
|
280
|
+
ltv_max_sol: Math.floor(ltvMaxSol),
|
|
281
|
+
pool_available_sol: Math.floor(poolAvailableSol),
|
|
282
|
+
per_user_cap_sol: Math.floor(perUserCapSol),
|
|
283
|
+
interest_rate_bps: lending.interest_rate_bps,
|
|
284
|
+
liquidation_threshold_bps: lending.liquidation_threshold_bps,
|
|
285
|
+
};
|
|
286
|
+
}
|
|
194
287
|
// ─── Faction Operations (controller) ───────────────────────────────
|
|
195
288
|
/** Launch a new faction (create token) */
|
|
196
289
|
async function launchFaction(connection, params) {
|
package/dist/index.d.ts
CHANGED
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
* This kit translates protocol primitives into faction warfare language
|
|
6
6
|
* so agents think in factions, not tokens.
|
|
7
7
|
*/
|
|
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, getDexVaults, } from './actions';
|
|
8
|
+
export type { FactionStatus, FactionTier, Strategy, AgentHealth, FactionSummary, FactionDetail, Stronghold, AgentLink, Comms, WarChest, WarLoan, WarLoanWithAgent, Member, FactionListResult, MembersResult, CommsResult, AllWarLoansResult, WarLoanQuote, 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, getMaxWarLoan, blacklistMints, isBlacklistedMint, getBlacklistedMints, 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 = exports.TOKEN_MULTIPLIER = void 0;
|
|
10
|
+
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.getBlacklistedMints = exports.isBlacklistedMint = exports.blacklistMints = exports.getMaxWarLoan = 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 = exports.LAMPORTS_PER_SOL = exports.PROGRAM_ID = exports.grindPyreMint = exports.isPyreMint = void 0;
|
|
12
12
|
// ─── Actions ───────────────────────────────────────────────────────
|
|
13
13
|
var actions_1 = require("./actions");
|
|
14
14
|
// Read operations
|
|
@@ -24,6 +24,11 @@ Object.defineProperty(exports, "getAgentLink", { enumerable: true, get: function
|
|
|
24
24
|
Object.defineProperty(exports, "getWarChest", { enumerable: true, get: function () { return actions_1.getWarChest; } });
|
|
25
25
|
Object.defineProperty(exports, "getWarLoan", { enumerable: true, get: function () { return actions_1.getWarLoan; } });
|
|
26
26
|
Object.defineProperty(exports, "getAllWarLoans", { enumerable: true, get: function () { return actions_1.getAllWarLoans; } });
|
|
27
|
+
Object.defineProperty(exports, "getMaxWarLoan", { enumerable: true, get: function () { return actions_1.getMaxWarLoan; } });
|
|
28
|
+
// Blacklist
|
|
29
|
+
Object.defineProperty(exports, "blacklistMints", { enumerable: true, get: function () { return actions_1.blacklistMints; } });
|
|
30
|
+
Object.defineProperty(exports, "isBlacklistedMint", { enumerable: true, get: function () { return actions_1.isBlacklistedMint; } });
|
|
31
|
+
Object.defineProperty(exports, "getBlacklistedMints", { enumerable: true, get: function () { return actions_1.getBlacklistedMints; } });
|
|
27
32
|
// Faction operations
|
|
28
33
|
Object.defineProperty(exports, "launchFaction", { enumerable: true, get: function () { return actions_1.launchFaction; } });
|
|
29
34
|
Object.defineProperty(exports, "joinFaction", { enumerable: true, get: function () { return actions_1.joinFaction; } });
|
package/dist/types.d.ts
CHANGED
|
@@ -296,6 +296,23 @@ export interface FactionListParams {
|
|
|
296
296
|
status?: FactionStatusFilter;
|
|
297
297
|
sort?: FactionSortOption;
|
|
298
298
|
}
|
|
299
|
+
/** Result of computing max borrowable SOL for a given collateral amount */
|
|
300
|
+
export interface WarLoanQuote {
|
|
301
|
+
/** Max SOL borrowable (lamports) — minimum of LTV cap, pool available, per-user cap */
|
|
302
|
+
max_borrow_sol: number;
|
|
303
|
+
/** Collateral value in SOL (lamports) */
|
|
304
|
+
collateral_value_sol: number;
|
|
305
|
+
/** LTV-limited max borrow (lamports) */
|
|
306
|
+
ltv_max_sol: number;
|
|
307
|
+
/** Pool available SOL (lamports) */
|
|
308
|
+
pool_available_sol: number;
|
|
309
|
+
/** Per-user cap SOL (lamports) — based on share of supply * borrow_share_multiplier */
|
|
310
|
+
per_user_cap_sol: number;
|
|
311
|
+
/** Current interest rate in bps per epoch */
|
|
312
|
+
interest_rate_bps: number;
|
|
313
|
+
/** Liquidation threshold in bps */
|
|
314
|
+
liquidation_threshold_bps: number;
|
|
315
|
+
}
|
|
299
316
|
export interface FactionPower {
|
|
300
317
|
mint: string;
|
|
301
318
|
name: string;
|
package/package.json
CHANGED
package/src/actions.ts
CHANGED
|
@@ -61,6 +61,7 @@ import type {
|
|
|
61
61
|
AgentLink,
|
|
62
62
|
WarChest,
|
|
63
63
|
WarLoan,
|
|
64
|
+
WarLoanQuote,
|
|
64
65
|
AllWarLoansResult,
|
|
65
66
|
LaunchFactionParams,
|
|
66
67
|
JoinFactionParams,
|
|
@@ -105,6 +106,53 @@ import {
|
|
|
105
106
|
|
|
106
107
|
import { buildCreateFactionTransaction, isPyreMint } from './vanity';
|
|
107
108
|
|
|
109
|
+
// ─── Blacklist ──────────────────────────────────────────────────────
|
|
110
|
+
// Mints from previous swarm runs. Agents should skip these and only
|
|
111
|
+
// interact with freshly launched factions.
|
|
112
|
+
|
|
113
|
+
const DEFAULT_BLACKLIST = [
|
|
114
|
+
'E1SgYPW6JXhw5BabrvJkr6L2PyvfFenYaoCTePazyNpy','6jWsyDC87RmfrZZRjuxSAxvUxE665HGZwZ2Z8j5z9epy',
|
|
115
|
+
'6J8PLgFxHb98cNURP2Yt2SKwgnUeEXpN6Us2kxaMz1py','5A297UyPQstxWpJyydDnFvn2zN8whCEYdqvnfB5bF9py',
|
|
116
|
+
'8XdWfSKLJusAcRrYzK3bWJ7dy46AkbU8qxF3B55uSfpy','7ZYrKcJbFFbG36keCYRvfc1j1HScQmJW1zRV3wVVD4py',
|
|
117
|
+
'ERQPyG2oqx5bdyuY2Nnm5ZbZY2zcB46TfUxqpzYWH5py','JCvpK3kTnh2EdQG71mqE8ZXcvzLU5EJNG5vgGZme4wpy',
|
|
118
|
+
'9RDFkGSjKpjHtXZ25uuug2MN5P7oSjzkLg16HcrKy3py','2kWcX1ZetV4jUtBPbKKk265q4gS4nuut2kc1MbaZDfpy',
|
|
119
|
+
'3r9FnQim6GToR7NkY5om8igUNu7gfpq5fk2qtv3bV5py','2498F79s1Ghyj3J4VhV1qy5hhznnM53ZwzTXM9iscopy',
|
|
120
|
+
'5VpotyDyc8QKKqLuzu8pfhtEa9gsRG1ww58DbqJUgTpy','GXi1opahTkavPfAqfUhkoUJRBjPoAmAMVW87kdbDwNpy',
|
|
121
|
+
'GKFAokGiyhXGXxUPgwQEo8fE5nBjRdJcVX6LVj7SgPpy','EKFVwfNk1xzqhpyFJSMNw8KDcLRemvqxiGoSyfRtBspy',
|
|
122
|
+
'GsZLHVt3mTwus5krUcifBWS52xMQSuXSy3RpPhEFtvpy','9azKjXnt2w4RB5ykVcyaicWSssmxoapZ9SSQLMZc4Epy',
|
|
123
|
+
'BaLwryyMrqhtsMrELkrTSdWF9UYuNdjW4413hrQqbtpy','5p9ibszMVe79mm95M8uubS6WttXem2xZfh3mWmBdvUpy',
|
|
124
|
+
'CTvoAmTggJcBTnbxcfy91Y1c6t6fU5xq3SRtYh3TgEpy','2kqVCdQS9KSv2kxLiytGZfcLsx5xwKQT6rHTg4V18hpy',
|
|
125
|
+
'zV7XZcvY8DVk4scKUiw7GGN4L3eBPSXuD7Q1NPxfspy','3UhzKfdU1wgnEN2VCykRURw88qVVqeu3ejRkUnjmhRpy',
|
|
126
|
+
'FRaS3dAdr1zo6u811XBVGUp9K2mSdQ2yG8qW4qP5hapy','4NHzWVP7hzZhd9LhTrbyxzsSnT8EmNSYVP1DpAKXHYpy',
|
|
127
|
+
'Yt2rdfp6uzS7L52df3LPmetLoy3GvKChYJ4Lmvk6gpy','9Ejju29KHPWMpda4WpFsJ6ZDHVUqNWyMZHteEisgw9py',
|
|
128
|
+
'2zPC4A7WR2cMNDfBzERp49fEbTBCyqXPKhcrgz3hWcpy','7jBAriydb1qRy7Wg4WAz8woHP4pVxZJSnF7vw95tVQpy',
|
|
129
|
+
'HvPWKuMFpG3zAdkPMbaadyo78VoJbAMtpXaBYMK1Aqpy','GyNw9bkqz2rhR66Xx7P4p11PFBrjPi2r6XoCg5gPAdpy',
|
|
130
|
+
'6HveNEes9xtkkchb76JgjWWQ61sbXjESy2vr3A7Maipy','8E3GETvTkTTaCLpzkyHJTnuNMfmGvzUEgAYnurZuLZpy',
|
|
131
|
+
'AeApaJqppwjW9S2KeZGPZpmg1kAdxZHkFRnXPZc8Kjpy','8FfteyAMQm96upu4w6cJvE5T8RcMKRf5keJMdXbukXpy',
|
|
132
|
+
'BrEj2Q9XE13WesRU1u8USiprv2DkpBcJfaqQeqQ6grpy','Dtki37mAB3DiTW1bp8LnZQyv54UuC68Yo5pGZkPdVSpy',
|
|
133
|
+
'77UzTntZ7ThyXhN4hVvSx7m6tjit8uCw6U2LVQHPSqpy','ASV9kiC6vEpZy3X7xVExuyG257KHKd3Hutbji8AVRUpy',
|
|
134
|
+
'Fc1V6KcxSriJkUNeDLqz8w5Sm4mp1s8gxornZVLcHEpy','FEizyHEUoYenqfpF87kqiGnq3w1R2TReodEfsnTrrfpy',
|
|
135
|
+
'DmwgcVHoJxKeRiij5LtedY9LWDpqoqa3hGfUyVgBkgpy','GUGz1Em5KZ57aKFqEBSd4Y4Vb6WxBd3H2b16fPCC6upy',
|
|
136
|
+
'6ZWY3Bau5zw1j7vMQQ1czSw4rjBJrExHQ8Renor2vLpy',
|
|
137
|
+
];
|
|
138
|
+
|
|
139
|
+
const BLACKLISTED_MINTS = new Set<string>(DEFAULT_BLACKLIST);
|
|
140
|
+
|
|
141
|
+
/** Add mints to the blacklist (call at startup with old mints) */
|
|
142
|
+
export function blacklistMints(mints: string[]): void {
|
|
143
|
+
for (const m of mints) BLACKLISTED_MINTS.add(m);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/** Check if a mint is blacklisted */
|
|
147
|
+
export function isBlacklistedMint(mint: string): boolean {
|
|
148
|
+
return BLACKLISTED_MINTS.has(mint);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/** Get all blacklisted mints */
|
|
152
|
+
export function getBlacklistedMints(): string[] {
|
|
153
|
+
return Array.from(BLACKLISTED_MINTS);
|
|
154
|
+
}
|
|
155
|
+
|
|
108
156
|
// ─── Read Operations ───────────────────────────────────────────────
|
|
109
157
|
|
|
110
158
|
/** List all factions with optional filtering and sorting */
|
|
@@ -318,6 +366,66 @@ export async function getAllWarLoans(
|
|
|
318
366
|
return mapAllLoansResult(result);
|
|
319
367
|
}
|
|
320
368
|
|
|
369
|
+
/**
|
|
370
|
+
* Compute max borrowable SOL for a given collateral amount.
|
|
371
|
+
*
|
|
372
|
+
* Mirrors the burnfun LendingDashboard logic — effective max borrow is the
|
|
373
|
+
* minimum of three caps:
|
|
374
|
+
* 1. LTV limit: collateral_value_sol * (max_ltv_bps / 10000)
|
|
375
|
+
* 2. Pool available: treasury_sol * utilization_cap - total_lent
|
|
376
|
+
* 3. Per-user cap: (collateral / total_supply) * borrow_share_multiplier * max_lendable
|
|
377
|
+
*
|
|
378
|
+
* All values in lamports. Accounts for Token-2022 transfer fee (4 bps).
|
|
379
|
+
*/
|
|
380
|
+
export async function getMaxWarLoan(
|
|
381
|
+
connection: Connection,
|
|
382
|
+
mint: string,
|
|
383
|
+
collateralAmount: number,
|
|
384
|
+
): Promise<WarLoanQuote> {
|
|
385
|
+
const TOTAL_SUPPLY = 1_000_000_000_000_000; // 1B tokens * 1e6 multiplier (base units)
|
|
386
|
+
const TRANSFER_FEE_BPS = 4;
|
|
387
|
+
const LAMPORTS_PER_SOL = 1_000_000_000;
|
|
388
|
+
|
|
389
|
+
const [lending, detail] = await Promise.all([
|
|
390
|
+
getLendingInfo(connection, mint),
|
|
391
|
+
getToken(connection, mint),
|
|
392
|
+
]);
|
|
393
|
+
|
|
394
|
+
// Price per base-unit token in SOL (lamports)
|
|
395
|
+
const pricePerToken = detail.price_sol; // SOL per display token
|
|
396
|
+
const TOKEN_MULTIPLIER = 1_000_000;
|
|
397
|
+
|
|
398
|
+
// Collateral value in SOL (lamports)
|
|
399
|
+
const collateralDisplayTokens = collateralAmount / TOKEN_MULTIPLIER;
|
|
400
|
+
const collateralValueSol = collateralDisplayTokens * pricePerToken * LAMPORTS_PER_SOL;
|
|
401
|
+
|
|
402
|
+
// 1. LTV cap
|
|
403
|
+
const ltvMaxSol = collateralValueSol * (lending.max_ltv_bps / 10000);
|
|
404
|
+
|
|
405
|
+
// 2. Pool available
|
|
406
|
+
const treasurySol = detail.treasury_sol_balance * LAMPORTS_PER_SOL;
|
|
407
|
+
const maxLendableSol = treasurySol * lending.utilization_cap_bps / 10000;
|
|
408
|
+
const totalLent = (lending.total_sol_lent ?? 0);
|
|
409
|
+
const poolAvailableSol = Math.max(0, maxLendableSol - totalLent);
|
|
410
|
+
|
|
411
|
+
// 3. Per-user cap (accounts for transfer fee reducing net collateral)
|
|
412
|
+
const netCollateral = collateralAmount * (1 - TRANSFER_FEE_BPS / 10000);
|
|
413
|
+
const borrowMultiplier = lending.borrow_share_multiplier || 3;
|
|
414
|
+
const perUserCapSol = maxLendableSol * netCollateral * borrowMultiplier / TOTAL_SUPPLY;
|
|
415
|
+
|
|
416
|
+
const maxBorrowSol = Math.max(0, Math.min(ltvMaxSol, poolAvailableSol, perUserCapSol));
|
|
417
|
+
|
|
418
|
+
return {
|
|
419
|
+
max_borrow_sol: Math.floor(maxBorrowSol),
|
|
420
|
+
collateral_value_sol: Math.floor(collateralValueSol),
|
|
421
|
+
ltv_max_sol: Math.floor(ltvMaxSol),
|
|
422
|
+
pool_available_sol: Math.floor(poolAvailableSol),
|
|
423
|
+
per_user_cap_sol: Math.floor(perUserCapSol),
|
|
424
|
+
interest_rate_bps: lending.interest_rate_bps,
|
|
425
|
+
liquidation_threshold_bps: lending.liquidation_threshold_bps,
|
|
426
|
+
};
|
|
427
|
+
}
|
|
428
|
+
|
|
321
429
|
// ─── Faction Operations (controller) ───────────────────────────────
|
|
322
430
|
|
|
323
431
|
/** Launch a new faction (create token) */
|
package/src/index.ts
CHANGED
|
@@ -29,6 +29,7 @@ export type {
|
|
|
29
29
|
MembersResult,
|
|
30
30
|
CommsResult,
|
|
31
31
|
AllWarLoansResult,
|
|
32
|
+
WarLoanQuote,
|
|
32
33
|
// Params
|
|
33
34
|
LaunchFactionParams,
|
|
34
35
|
JoinFactionParams,
|
|
@@ -89,6 +90,11 @@ export {
|
|
|
89
90
|
getWarChest,
|
|
90
91
|
getWarLoan,
|
|
91
92
|
getAllWarLoans,
|
|
93
|
+
getMaxWarLoan,
|
|
94
|
+
// Blacklist
|
|
95
|
+
blacklistMints,
|
|
96
|
+
isBlacklistedMint,
|
|
97
|
+
getBlacklistedMints,
|
|
92
98
|
// Faction operations
|
|
93
99
|
launchFaction,
|
|
94
100
|
joinFaction,
|
package/src/types.ts
CHANGED
|
@@ -360,6 +360,26 @@ export interface FactionListParams {
|
|
|
360
360
|
sort?: FactionSortOption;
|
|
361
361
|
}
|
|
362
362
|
|
|
363
|
+
// ─── War Loan Quote ─────────────────────────────────────────────
|
|
364
|
+
|
|
365
|
+
/** Result of computing max borrowable SOL for a given collateral amount */
|
|
366
|
+
export interface WarLoanQuote {
|
|
367
|
+
/** Max SOL borrowable (lamports) — minimum of LTV cap, pool available, per-user cap */
|
|
368
|
+
max_borrow_sol: number;
|
|
369
|
+
/** Collateral value in SOL (lamports) */
|
|
370
|
+
collateral_value_sol: number;
|
|
371
|
+
/** LTV-limited max borrow (lamports) */
|
|
372
|
+
ltv_max_sol: number;
|
|
373
|
+
/** Pool available SOL (lamports) */
|
|
374
|
+
pool_available_sol: number;
|
|
375
|
+
/** Per-user cap SOL (lamports) — based on share of supply * borrow_share_multiplier */
|
|
376
|
+
per_user_cap_sol: number;
|
|
377
|
+
/** Current interest rate in bps per epoch */
|
|
378
|
+
interest_rate_bps: number;
|
|
379
|
+
/** Liquidation threshold in bps */
|
|
380
|
+
liquidation_threshold_bps: number;
|
|
381
|
+
}
|
|
382
|
+
|
|
363
383
|
// ─── Intel Types ───────────────────────────────────────────────────
|
|
364
384
|
|
|
365
385
|
export interface FactionPower {
|