torch-liquidation-agent 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,8 @@
1
+ /**
2
+ * config.ts — loads environment variables into a typed BotConfig.
3
+ *
4
+ * creates a SolanaAgentKit instance from the wallet key + RPC URL.
5
+ */
6
+ import type { BotConfig } from './types';
7
+ export declare function loadConfig(): BotConfig;
8
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAKH,OAAO,KAAK,EAAE,SAAS,EAAY,MAAM,SAAS,CAAA;AAIlD,wBAAgB,UAAU,IAAI,SAAS,CA0CtC"}
package/dist/config.js ADDED
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+ /**
3
+ * config.ts — loads environment variables into a typed BotConfig.
4
+ *
5
+ * creates a SolanaAgentKit instance from the wallet key + RPC URL.
6
+ */
7
+ var __importDefault = (this && this.__importDefault) || function (mod) {
8
+ return (mod && mod.__esModule) ? mod : { "default": mod };
9
+ };
10
+ Object.defineProperty(exports, "__esModule", { value: true });
11
+ exports.loadConfig = loadConfig;
12
+ const web3_js_1 = require("@solana/web3.js");
13
+ const solana_agent_kit_1 = require("solana-agent-kit");
14
+ const bs58_1 = __importDefault(require("bs58"));
15
+ const LOG_LEVELS = ['debug', 'info', 'warn', 'error'];
16
+ function loadConfig() {
17
+ const rpcUrl = process.env.RPC_URL;
18
+ if (!rpcUrl)
19
+ throw new Error('RPC_URL env var is required');
20
+ const walletKey = process.env.WALLET;
21
+ if (!walletKey)
22
+ throw new Error('WALLET env var is required (base58 private key)');
23
+ const logLevel = (process.env.LOG_LEVEL ?? 'info');
24
+ if (!LOG_LEVELS.includes(logLevel)) {
25
+ throw new Error(`LOG_LEVEL must be one of: ${LOG_LEVELS.join(', ')}`);
26
+ }
27
+ const minProfitSol = Number(process.env.MIN_PROFIT_SOL ?? '0.01');
28
+ const scanIntervalMs = Number(process.env.SCAN_INTERVAL_MS ?? '60000');
29
+ const scoreIntervalMs = Number(process.env.SCORE_INTERVAL_MS ?? '15000');
30
+ const riskThreshold = Number(process.env.RISK_THRESHOLD ?? '60');
31
+ const priceHistoryDepth = Number(process.env.PRICE_HISTORY ?? '20');
32
+ if (isNaN(scanIntervalMs) || scanIntervalMs < 1000)
33
+ throw new Error('SCAN_INTERVAL_MS must be >= 1000');
34
+ if (isNaN(scoreIntervalMs) || scoreIntervalMs < 1000)
35
+ throw new Error('SCORE_INTERVAL_MS must be >= 1000');
36
+ if (isNaN(riskThreshold) || riskThreshold < 0 || riskThreshold > 100)
37
+ throw new Error('RISK_THRESHOLD must be 0-100');
38
+ if (isNaN(priceHistoryDepth) || priceHistoryDepth < 2)
39
+ throw new Error('PRICE_HISTORY must be >= 2');
40
+ if (isNaN(minProfitSol) || minProfitSol < 0)
41
+ throw new Error('MIN_PROFIT_SOL must be >= 0');
42
+ const keypair = web3_js_1.Keypair.fromSecretKey(bs58_1.default.decode(walletKey));
43
+ const wallet = new solana_agent_kit_1.KeypairWallet(keypair, rpcUrl);
44
+ const agent = new solana_agent_kit_1.SolanaAgentKit(wallet, rpcUrl, {});
45
+ return {
46
+ agent,
47
+ scanIntervalMs,
48
+ scoreIntervalMs,
49
+ minProfitLamports: Math.floor(minProfitSol * web3_js_1.LAMPORTS_PER_SOL),
50
+ riskThreshold,
51
+ priceHistoryDepth,
52
+ logLevel,
53
+ };
54
+ }
55
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;AASH,gCA0CC;AAjDD,6CAA2D;AAC3D,uDAAgE;AAChE,gDAAuB;AAGvB,MAAM,UAAU,GAAe,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,CAAA;AAEjE,SAAgB,UAA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AAC,aAAa,CAAC,IAAI,aAAa,GAAG,CAAC,IAAI,aAAa,GAAG,GAAG;QAClE,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAA;IACjD,IAAI,KAAK,CAAC,iBAAiB,CAAC,IAAI,iBAAiB,GAAG,CAAC;QACnD,MAAM,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAA;IAC/C,IAAI,KAAK,CAAC,YAAY,CAAC,IAAI,YAAY,GAAG,CAAC;QACzC,MAAM,IAAI,KAAK,CAAC,6BAA6B,CAAC,CAAA;IAEhD,MAAM,OAAO,GAAG,iBAAO,CAAC,aAAa,CAAC,cAAI,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAA;IAC7D,MAAM,MAAM,GAAG,IAAI,gCAAa,CAAC,OAAO,EAAE,MAAM,CAAC,CAAA;IACjD,MAAM,KAAK,GAAG,IAAI,iCAAc,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,CAAC,CAAA;IAEpD,OAAO;QACL,KAAK;QACL,cAAc;QACd,eAAe;QACf,iBAAiB,EAAE,IAAI,CAAC,KAAK,CAAC,YAAY,GAAG,0BAAgB,CAAC;QAC9D,aAAa;QACb,iBAAiB;QACjB,QAAQ;KACT,CAAA;AACH,CAAC"}
@@ -0,0 +1,30 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * torch-liquidation-agent
4
+ *
5
+ * multi-token liquidation bot that discovers lending markets, profiles
6
+ * borrower wallets, predicts which loans will fail, and executes
7
+ * profitable liquidations.
8
+ *
9
+ * built on solana-agent-kit + solana-agent-kit-torch-market.
10
+ *
11
+ * modes:
12
+ * info — display lending parameters for a token (or all tokens) (default)
13
+ * watch — monitor your own loan health in real-time
14
+ * bot — run the full liquidation bot
15
+ *
16
+ * usage:
17
+ * # show all migrated tokens with lending
18
+ * RPC_URL=<rpc> npx tsx src/index.ts
19
+ *
20
+ * # show lending info for one token
21
+ * MODE=info MINT=<mint> RPC_URL=<rpc> npx tsx src/index.ts
22
+ *
23
+ * # watch your loan health
24
+ * MODE=watch MINT=<mint> WALLET=<key> RPC_URL=<rpc> npx tsx src/index.ts
25
+ *
26
+ * # run the liquidation bot
27
+ * MODE=bot WALLET=<key> RPC_URL=<rpc> npx tsx src/index.ts
28
+ */
29
+ export {};
30
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG"}
package/dist/index.js ADDED
@@ -0,0 +1,175 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ /**
4
+ * torch-liquidation-agent
5
+ *
6
+ * multi-token liquidation bot that discovers lending markets, profiles
7
+ * borrower wallets, predicts which loans will fail, and executes
8
+ * profitable liquidations.
9
+ *
10
+ * built on solana-agent-kit + solana-agent-kit-torch-market.
11
+ *
12
+ * modes:
13
+ * info — display lending parameters for a token (or all tokens) (default)
14
+ * watch — monitor your own loan health in real-time
15
+ * bot — run the full liquidation bot
16
+ *
17
+ * usage:
18
+ * # show all migrated tokens with lending
19
+ * RPC_URL=<rpc> npx tsx src/index.ts
20
+ *
21
+ * # show lending info for one token
22
+ * MODE=info MINT=<mint> RPC_URL=<rpc> npx tsx src/index.ts
23
+ *
24
+ * # watch your loan health
25
+ * MODE=watch MINT=<mint> WALLET=<key> RPC_URL=<rpc> npx tsx src/index.ts
26
+ *
27
+ * # run the liquidation bot
28
+ * MODE=bot WALLET=<key> RPC_URL=<rpc> npx tsx src/index.ts
29
+ */
30
+ var __importDefault = (this && this.__importDefault) || function (mod) {
31
+ return (mod && mod.__esModule) ? mod : { "default": mod };
32
+ };
33
+ Object.defineProperty(exports, "__esModule", { value: true });
34
+ const web3_js_1 = require("@solana/web3.js");
35
+ const solana_agent_kit_1 = require("solana-agent-kit");
36
+ const bs58_1 = __importDefault(require("bs58"));
37
+ const solana_agent_kit_torch_market_1 = require("solana-agent-kit-torch-market");
38
+ const monitor_1 = require("./monitor");
39
+ const config_1 = require("./config");
40
+ const utils_1 = require("./utils");
41
+ // ---------------------------------------------------------------------------
42
+ // helpers
43
+ // ---------------------------------------------------------------------------
44
+ function createAgent(rpcUrl, walletKey) {
45
+ const keypair = walletKey
46
+ ? web3_js_1.Keypair.fromSecretKey(bs58_1.default.decode(walletKey))
47
+ : web3_js_1.Keypair.generate(); // dummy keypair for read-only modes
48
+ const wallet = new solana_agent_kit_1.KeypairWallet(keypair, rpcUrl);
49
+ return new solana_agent_kit_1.SolanaAgentKit(wallet, rpcUrl, {});
50
+ }
51
+ // ---------------------------------------------------------------------------
52
+ // mode: info
53
+ // ---------------------------------------------------------------------------
54
+ async function showLendingInfo(agent, mint) {
55
+ const token = await (0, solana_agent_kit_torch_market_1.torchGetToken)(agent, mint);
56
+ const lending = await (0, solana_agent_kit_torch_market_1.torchGetLendingInfo)(agent, mint);
57
+ console.log(`\n=== lending info: ${token.name} (${token.symbol}) ===`);
58
+ console.log(`status: ${token.status}`);
59
+ console.log(`token price: ${(0, utils_1.sol)(token.price_sol)} SOL`);
60
+ console.log(`interest rate: ${(0, utils_1.bpsToPercent)(lending.interest_rate_bps)}`);
61
+ console.log(`max LTV: ${(0, utils_1.bpsToPercent)(lending.max_ltv_bps)}`);
62
+ console.log(`liquidation threshold: ${(0, utils_1.bpsToPercent)(lending.liquidation_threshold_bps)}`);
63
+ console.log(`liquidation bonus: ${(0, utils_1.bpsToPercent)(lending.liquidation_bonus_bps)}`);
64
+ console.log(`treasury SOL avail: ${(0, utils_1.sol)(lending.treasury_sol_available)} SOL`);
65
+ console.log(`total SOL lent: ${lending.total_sol_lent != null ? (0, utils_1.sol)(lending.total_sol_lent) + ' SOL' : 'unknown'}`);
66
+ console.log(`active loans: ${lending.active_loans ?? 'unknown'}`);
67
+ }
68
+ async function showAllLending(agent) {
69
+ console.log('=== torch lending agent ===\n');
70
+ console.log('no MINT specified — showing all migrated tokens with lending\n');
71
+ const tokens = await (0, solana_agent_kit_torch_market_1.torchListTokens)(agent, 'migrated', 'volume', 10);
72
+ for (const t of tokens) {
73
+ try {
74
+ const lending = await (0, solana_agent_kit_torch_market_1.torchGetLendingInfo)(agent, t.mint);
75
+ console.log(`${t.symbol.padEnd(10)} | ` +
76
+ `rate: ${(0, utils_1.bpsToPercent)(lending.interest_rate_bps).padEnd(7)} | ` +
77
+ `loans: ${String(lending.active_loans ?? '?').padEnd(4)} | ` +
78
+ `avail: ${(0, utils_1.sol)(lending.treasury_sol_available)} SOL`);
79
+ }
80
+ catch {
81
+ // token may not have lending enabled yet
82
+ }
83
+ }
84
+ }
85
+ // ---------------------------------------------------------------------------
86
+ // mode: watch
87
+ // ---------------------------------------------------------------------------
88
+ async function watchPosition(agent, mint) {
89
+ const pollMs = Number(process.env.POLL_INTERVAL_MS ?? '15000');
90
+ const walletAddr = agent.wallet.publicKey.toBase58();
91
+ console.log(`\n=== watching loan: ${walletAddr} ===`);
92
+ console.log(`mint: ${mint}\n`);
93
+ while (true) {
94
+ const pos = await (0, solana_agent_kit_torch_market_1.torchGetLoanPosition)(agent, mint, walletAddr);
95
+ if (pos.health === 'none') {
96
+ console.log(`[${new Date().toISOString()}] no active loan`);
97
+ }
98
+ else {
99
+ const healthColor = pos.health === 'healthy' ? 'OK' : pos.health === 'at_risk' ? 'WARNING' : 'DANGER';
100
+ console.log(`[${new Date().toISOString()}] health: ${healthColor} (${pos.health})`);
101
+ console.log(` collateral: ${pos.collateral_amount} tokens`);
102
+ console.log(` collat value: ${(0, utils_1.sol)(pos.collateral_value_sol ?? 0)} SOL`);
103
+ console.log(` borrowed: ${(0, utils_1.sol)(pos.borrowed_amount)} SOL`);
104
+ console.log(` interest: ${(0, utils_1.sol)(pos.accrued_interest)} SOL`);
105
+ console.log(` total owed: ${(0, utils_1.sol)(pos.total_owed)} SOL`);
106
+ console.log(` current LTV: ${(0, utils_1.bpsToPercent)(pos.current_ltv_bps ?? 0)}`);
107
+ if (pos.health === 'at_risk') {
108
+ console.log(' --> consider adding collateral or repaying to avoid liquidation');
109
+ }
110
+ if (pos.health === 'liquidatable') {
111
+ console.log(' --> your position can be liquidated! repay immediately');
112
+ if (process.env.AUTO_REPAY === 'true') {
113
+ console.log(' --> auto-repaying...');
114
+ const result = await (0, solana_agent_kit_torch_market_1.torchRepayLoan)(agent, mint, pos.total_owed);
115
+ const sig = typeof result === 'string' ? result : 'unknown';
116
+ console.log(` confirmed: ${sig}`);
117
+ try {
118
+ const confirmResult = await (0, solana_agent_kit_torch_market_1.torchConfirm)(agent, sig);
119
+ console.log(` SAID event: ${confirmResult.event_type}`);
120
+ }
121
+ catch {
122
+ console.log(' SAID confirmation failed — tx still went through');
123
+ }
124
+ }
125
+ }
126
+ }
127
+ await (0, utils_1.sleep)(pollMs);
128
+ }
129
+ }
130
+ // ---------------------------------------------------------------------------
131
+ // main
132
+ // ---------------------------------------------------------------------------
133
+ async function main() {
134
+ const MODE = process.env.MODE ?? 'info';
135
+ const MINT = process.env.MINT;
136
+ const RPC_URL = process.env.RPC_URL ?? 'https://api.mainnet-beta.solana.com';
137
+ // info mode: no wallet needed
138
+ if (MODE === 'info') {
139
+ const agent = createAgent(RPC_URL);
140
+ if (MINT) {
141
+ await showLendingInfo(agent, MINT);
142
+ }
143
+ else {
144
+ await showAllLending(agent);
145
+ }
146
+ return;
147
+ }
148
+ // watch mode: single token + wallet
149
+ if (MODE === 'watch') {
150
+ if (!MINT)
151
+ throw new Error('MINT env var required for watch mode');
152
+ const walletKey = process.env.WALLET;
153
+ if (!walletKey)
154
+ throw new Error('Set WALLET env var to a base58-encoded private key');
155
+ const agent = createAgent(RPC_URL, walletKey);
156
+ await watchPosition(agent, MINT);
157
+ return;
158
+ }
159
+ // bot mode: full liquidation bot
160
+ if (MODE === 'bot') {
161
+ const config = (0, config_1.loadConfig)();
162
+ const monitor = new monitor_1.Monitor(config);
163
+ // graceful shutdown
164
+ process.on('SIGINT', () => {
165
+ monitor.stop();
166
+ process.exit(0);
167
+ });
168
+ await monitor.start();
169
+ return;
170
+ }
171
+ console.error(`unknown MODE: ${MODE}. use info | watch | bot`);
172
+ process.exit(1);
173
+ }
174
+ main();
175
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;;;;;AAEH,6CAAyC;AACzC,uDAAgE;AAChE,gDAAuB;AACvB,iFASsC;AACtC,uCAAmC;AACnC,qCAAqC;AACrC,mCAAkD;AAElD,8EAA8E;AAC9E,UAAU;AACV,8EAA8E;AAE9E,SAAS,WAAW,CAAC,MAAc,EAAE,SAAkB;IACrD,MAAM,OAAO,GAAG,SAAS;QACvB,CAAC,CAAC,iBAAO,CAAC,aAAa,CAAC,cAAI,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;QAC/C,CAAC,CAAC,iBAAO,CAAC,QAAQ,EAAE,CAAA,CAAC,oCAAoC;IAC3D,MAAM,MAAM,GAAG,IAAI,gCAAa,CAAC,OAAO,EAAE,MAAM,CAAC,CAAA;IACjD,OAAO,IAAI,iCAAc,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,CAAC,CAAA;AAC/C,CAAC;AAED,8EAA8E;AAC9E,aAAa;AACb,8EAA8E;AAE9E,KAAK,UAAU,eAAe,CAAC,KAAqB,EAAE,IAAY;IAChE,MAAM,KAAK,GAAG,MAAM,IAAA,6CAAa,EAAC,KAAK,EAAE,IAAI,CAAC,CAAA;IAC9C,MAAM,OAAO,GAAqB,MAAM,IAAA,mDAAmB,EAAC,KAAK,EAAE,IAAI,CAAC,CAAA;IAExE,OAAO,CAAC,GAAG,CAAC,uBAAuB,KAAK,CAAC,IAAI,KAAK,KAAK,CAAC,MAAM,OAAO,CAAC,CAAA;IACtE,OAAO,CAAC,GAAG,CAAC,0BAA0B,KAAK,CAAC,MAAM,EAAE,CAAC,CAAA;IACrD,OAAO,CAAC,GAAG,CAAC,0BAA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C,IAAI;YAAE,MAAM,IAAI,KAAK,CAAC,sCAAsC,CAAC,CAAA;QAClE,MAAM,SAAS,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,CAAA;QACpC,IAAI,CAAC,SAAS;YAAE,MAAM,IAAI,KAAK,CAAC,oDAAoD,CAAC,CAAA;QACrF,MAAM,KAAK,GAAG,WAAW,CAAC,OAAO,EAAE,SAAS,CAAC,CAAA;QAC7C,MAAM,aAAa,CAAC,KAAK,EAAE,IAAI,CAAC,CAAA;QAChC,OAAM;IACR,CAAC;IAED,iCAAiC;IACjC,IAAI,IAAI,KAAK,KAAK,EAAE,CAAC;QACnB,MAAM,MAAM,GAAG,IAAA,mBAAU,GAAE,CAAA;QAC3B,MAAM,OAAO,GAAG,IAAI,iBAAO,CAAC,MAAM,CAAC,CAAA;QAEnC,oBAAoB;QACpB,OAAO,CAAC,EAAE,CAAC,QAAQ,EAAE,GAAG,EAAE;YACxB,OAAO,CAAC,IAAI,EAAE,CAAA;YACd,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;QACjB,CAAC,CAAC,CAAA;QAEF,MAAM,OAAO,CAAC,KAAK,EAAE,CAAA;QACrB,OAAM;IACR,CAAC;IAED,OAAO,CAAC,KAAK,CAAC,iBAAiB,IAAI,0BAA0B,CAAC,CAAA;IAC9D,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;AACjB,CAAC;AAED,IAAI,EAAE,CAAA"}
@@ -0,0 +1,16 @@
1
+ /**
2
+ * liquidator.ts — executes liquidation transactions.
3
+ *
4
+ * receives a target, calculates expected profit, calls the agent kit
5
+ * to sign + send the liquidation tx, then confirms via SAID for reputation.
6
+ */
7
+ import type { SolanaAgentKit } from 'solana-agent-kit';
8
+ import type { ScoredLoan, LiquidationResult, BotConfig } from './types';
9
+ import type { Logger } from './logger';
10
+ export declare class Liquidator {
11
+ private log;
12
+ private minProfitLamports;
13
+ constructor(config: BotConfig, log: Logger);
14
+ tryLiquidate(agent: SolanaAgentKit, loan: ScoredLoan): Promise<LiquidationResult | null>;
15
+ }
16
+ //# sourceMappingURL=liquidator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"liquidator.d.ts","sourceRoot":"","sources":["../src/liquidator.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AAEtD,OAAO,KAAK,EAAE,UAAU,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AACvE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AAGtC,qBAAa,UAAU;IACrB,OAAO,CAAC,GAAG,CAAQ;IACnB,OAAO,CAAC,iBAAiB,CAAQ;gBAErB,MAAM,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM;IAKpC,YAAY,CAAC,KAAK,EAAE,cAAc,EAAE,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC,iBAAiB,GAAG,IAAI,CAAC;CAkD/F"}
@@ -0,0 +1,65 @@
1
+ "use strict";
2
+ /**
3
+ * liquidator.ts — executes liquidation transactions.
4
+ *
5
+ * receives a target, calculates expected profit, calls the agent kit
6
+ * to sign + send the liquidation tx, then confirms via SAID for reputation.
7
+ */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.Liquidator = void 0;
10
+ const solana_agent_kit_torch_market_1 = require("solana-agent-kit-torch-market");
11
+ const utils_1 = require("./utils");
12
+ class Liquidator {
13
+ constructor(config, log) {
14
+ this.minProfitLamports = config.minProfitLamports;
15
+ this.log = log;
16
+ }
17
+ async tryLiquidate(agent, loan) {
18
+ if (loan.position.health !== 'liquidatable') {
19
+ this.log.debug(`skipping ${loan.borrower.slice(0, 8)}... — not liquidatable yet`);
20
+ return null;
21
+ }
22
+ if (loan.estimatedProfitLamports < this.minProfitLamports) {
23
+ this.log.debug(`skipping ${loan.borrower.slice(0, 8)}... — profit too low`, {
24
+ expected: (0, utils_1.sol)(loan.estimatedProfitLamports),
25
+ minimum: (0, utils_1.sol)(this.minProfitLamports),
26
+ });
27
+ return null;
28
+ }
29
+ this.log.info(`liquidating ${loan.borrower.slice(0, 8)}...`, {
30
+ token: loan.tokenName,
31
+ profit: `${(0, utils_1.sol)(loan.estimatedProfitLamports)} SOL`,
32
+ risk: loan.riskScore,
33
+ });
34
+ try {
35
+ const result = await (0, solana_agent_kit_torch_market_1.torchLiquidateLoan)(agent, loan.mint, loan.borrower);
36
+ const signature = typeof result === 'string' ? result : 'unknown';
37
+ this.log.info(`liquidation confirmed`, { sig: signature });
38
+ // confirm via SAID for reputation
39
+ let confirmed = false;
40
+ try {
41
+ const confirmResult = await (0, solana_agent_kit_torch_market_1.torchConfirm)(agent, signature);
42
+ confirmed = confirmResult.confirmed;
43
+ this.log.debug(`SAID confirmation`, { event: confirmResult.event_type });
44
+ }
45
+ catch {
46
+ this.log.warn('SAID confirmation failed — tx still went through');
47
+ }
48
+ return {
49
+ mint: loan.mint,
50
+ borrower: loan.borrower,
51
+ signature,
52
+ profitLamports: loan.estimatedProfitLamports,
53
+ timestamp: Date.now(),
54
+ confirmed,
55
+ };
56
+ }
57
+ catch (err) {
58
+ const msg = err instanceof Error ? err.message : String(err);
59
+ this.log.error(`liquidation failed for ${loan.borrower.slice(0, 8)}...`, { error: msg });
60
+ return null;
61
+ }
62
+ }
63
+ }
64
+ exports.Liquidator = Liquidator;
65
+ //# sourceMappingURL=liquidator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"liquidator.js","sourceRoot":"","sources":["../src/liquidator.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAGH,iFAAgF;AAGhF,mCAA6B;AAE7B,MAAa,UAAU;IAIrB,YAAY,MAAiB,EAAE,GAAW;QACxC,IAAI,CAAC,iBAAiB,GAAG,MAAM,CAAC,iBAAiB,CAAA;QACjD,IAAI,CAAC,GAAG,GAAG,GAAG,CAAA;IAChB,CAAC;IAED,KAAK,CAAC,YAAY,CAAC,KAAq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,EAAE,CAAC,CAAA;YAE1D,kCAAkC;YAClC,IAAI,SAAS,GAAG,KAAK,CAAA;YACrB,IAAI,CAAC;gBACH,MAAM,aAAa,GAAG,MAAM,IAAA,4CAAY,EAAC,KAAK,EAAE,SAAS,CAAC,CAAA;gBAC1D,SAAS,GAAG,aAAa,CAAC,SAAS,CAAA;gBACnC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,mBAAmB,EAAE,EAAE,KAAK,EAAE,aAAa,CAAC,UAAU,EAAE,CAAC,CAAA;YAC1E,CAAC;YAAC,MAAM,CAAC;gBACP,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,kDAAkD,CAAC,CAAA;YACnE,CAAC;YAED,OAAO;gBACL,IAAI,EAAE,IAAI,CAAC,IAAI;gBACf,QAAQ,EAAE,IAAI,CAAC,QAAQ;gBACvB,SAAS;gBACT,cAAc,EAAE,IAAI,CAAC,uBAAuB;gBAC5C,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE;gBACrB,SAAS;aACV,CAAA;QACH,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,MAAM,GAAG,GAAG,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAA;YAC5D,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,0BAA0B,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,CAAA;YACxF,OAAO,IAAI,CAAA;QACb,CAAC;IACH,CAAC;CACF;AA3DD,gCA2DC"}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * logger.ts — simple structured logging with levels.
3
+ */
4
+ import type { LogLevel } from './types';
5
+ export declare class Logger {
6
+ private module;
7
+ private minLevel;
8
+ constructor(module: string, level: LogLevel);
9
+ debug(msg: string, data?: Record<string, unknown>): void;
10
+ info(msg: string, data?: Record<string, unknown>): void;
11
+ warn(msg: string, data?: Record<string, unknown>): void;
12
+ error(msg: string, data?: Record<string, unknown>): void;
13
+ child(module: string): Logger;
14
+ private levelName;
15
+ private log;
16
+ }
17
+ //# sourceMappingURL=logger.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;AASvC,qBAAa,MAAM;IAIf,OAAO,CAAC,MAAM;IAHhB,OAAO,CAAC,QAAQ,CAAQ;gBAGd,MAAM,EAAE,MAAM,EACtB,KAAK,EAAE,QAAQ;IAKjB,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAIjD,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAIhD,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAIhD,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAIjD,KAAK,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM;IAI7B,OAAO,CAAC,SAAS;IAKjB,OAAO,CAAC,GAAG;CAeZ"}
package/dist/logger.js ADDED
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+ /**
3
+ * logger.ts — simple structured logging with levels.
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.Logger = void 0;
7
+ const LEVEL_PRIORITY = {
8
+ debug: 0,
9
+ info: 1,
10
+ warn: 2,
11
+ error: 3,
12
+ };
13
+ class Logger {
14
+ constructor(module, level) {
15
+ this.module = module;
16
+ this.minLevel = LEVEL_PRIORITY[level];
17
+ }
18
+ debug(msg, data) {
19
+ this.log('debug', msg, data);
20
+ }
21
+ info(msg, data) {
22
+ this.log('info', msg, data);
23
+ }
24
+ warn(msg, data) {
25
+ this.log('warn', msg, data);
26
+ }
27
+ error(msg, data) {
28
+ this.log('error', msg, data);
29
+ }
30
+ child(module) {
31
+ return new Logger(`${this.module}:${module}`, this.levelName());
32
+ }
33
+ levelName() {
34
+ const entry = Object.entries(LEVEL_PRIORITY).find(([, v]) => v === this.minLevel);
35
+ return (entry?.[0] ?? 'info');
36
+ }
37
+ log(level, msg, data) {
38
+ if (LEVEL_PRIORITY[level] < this.minLevel)
39
+ return;
40
+ const ts = new Date().toISOString();
41
+ const prefix = `[${ts}] [${level.toUpperCase().padEnd(5)}] [${this.module}]`;
42
+ if (data) {
43
+ const parts = Object.entries(data)
44
+ .map(([k, v]) => `${k}=${v}`)
45
+ .join(' ');
46
+ console.log(`${prefix} ${msg} | ${parts}`);
47
+ }
48
+ else {
49
+ console.log(`${prefix} ${msg}`);
50
+ }
51
+ }
52
+ }
53
+ exports.Logger = Logger;
54
+ //# sourceMappingURL=logger.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logger.js","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAIH,MAAM,cAAc,GAA6B;IAC/C,KAAK,EAAE,CAAC;IACR,IAAI,EAAE,CAAC;IACP,IAAI,EAAE,CAAC;IACP,KAAK,EAAE,CAAC;CACT,CAAA;AAED,MAAa,MAAM;IAGjB,YACU,MAAc,EACtB,KAAe;QADP,WAAM,GAAN,MAAM,CAAQ;QAGtB,IAAI,CAAC,QAAQ,GAAG,cAAc,CAAC,KAAK,CAAC,CAAA;IACvC,CAAC;IAED,KAAK,CAAC,GAAW,EAAE,IAA8B;QAC/C,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,GAAG,EAAE,IAAI,CAAC,CAAA;IAC9B,CAAC;IAED,IAAI,CAAC,GAAW,EAAE,I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E,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;iBAC5B,IAAI,CAAC,GAAG,CAAC,CAAA;YACZ,OAAO,CAAC,GAAG,CAAC,GAAG,MAAM,IAAI,GAAG,MAAM,KAAK,EAAE,CAAC,CAAA;QAC5C,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,GAAG,CAAC,GAAG,MAAM,IAAI,GAAG,EAAE,CAAC,CAAA;QACjC,CAAC;IACH,CAAC;CACF;AAlDD,wBAkDC"}
@@ -0,0 +1,29 @@
1
+ /**
2
+ * monitor.ts — main orchestration loop.
3
+ *
4
+ * two loops running on intervals:
5
+ * 1. scan loop: discover tokens with active lending
6
+ * 2. score loop: profile borrowers, score loans, execute liquidations
7
+ *
8
+ * uses solana RPC to find token holders (replaces torchsdk getHolders)
9
+ * since the agent kit plugin does not expose that function.
10
+ */
11
+ import type { BotConfig } from './types';
12
+ export declare class Monitor {
13
+ private agent;
14
+ private config;
15
+ private log;
16
+ private profiler;
17
+ private liquidator;
18
+ private tokens;
19
+ private running;
20
+ constructor(config: BotConfig);
21
+ start(): Promise<void>;
22
+ stop(): void;
23
+ private scanLoop;
24
+ private scan;
25
+ private scoreLoop;
26
+ private scoreAllPositions;
27
+ private scoreToken;
28
+ }
29
+ //# sourceMappingURL=monitor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"monitor.d.ts","sourceRoot":"","sources":["../src/monitor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAKH,OAAO,KAAK,EAAE,SAAS,EAA8B,MAAM,SAAS,CAAA;AAsCpE,qBAAa,OAAO;IAClB,OAAO,CAAC,KAAK,CAAgB;IAC7B,OAAO,CAAC,MAAM,CAAW;IACzB,OAAO,CAAC,GAAG,CAAQ;IACnB,OAAO,CAAC,QAAQ,CAAgB;IAChC,OAAO,CAAC,UAAU,CAAY;IAC9B,OAAO,CAAC,MAAM,CAAoC;IAClD,OAAO,CAAC,OAAO,CAAQ;gBAEX,MAAM,EAAE,SAAS;IAQvB,KAAK;IAmBX,IAAI;YAKU,QAAQ;YAOR,IAAI;YAcJ,SAAS;YAOT,iBAAiB;YAkDjB,UAAU;CA0BzB"}