torch-liquidation-bot 2.0.0 → 2.0.2

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/logger.js DELETED
@@ -1,54 +0,0 @@
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
@@ -1 +0,0 @@
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;I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GAAG,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAA;QACnC,MAAM,MAAM,GAAG,IAAI,EAAE,MAAM,KAAK,CAAC,WAAW,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,IAAI,CAAC,MAAM,GAAG,CAAA;QAE5E,IAAI,IAAI,EAAE,CAAC;YACT,MAAM,KAAK,GAAG,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC;iBAC/B,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,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"}
package/dist/monitor.d.ts DELETED
@@ -1,27 +0,0 @@
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
- import type { Connection } from '@solana/web3.js';
9
- import type { BotConfig } from './types';
10
- export declare class Monitor {
11
- private connection;
12
- private config;
13
- private log;
14
- private profiler;
15
- private liquidator;
16
- private tokens;
17
- private running;
18
- constructor(connection: Connection, config: BotConfig);
19
- start(): Promise<void>;
20
- stop(): void;
21
- private scanLoop;
22
- private scan;
23
- private scoreLoop;
24
- private scoreAllPositions;
25
- private scoreToken;
26
- }
27
- //# sourceMappingURL=monitor.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"monitor.d.ts","sourceRoot":"","sources":["../src/monitor.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAEjD,OAAO,KAAK,EAAE,SAAS,EAA8B,MAAM,SAAS,CAAA;AAQpE,qBAAa,OAAO;IAClB,OAAO,CAAC,UAAU,CAAY;IAC9B,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,UAAU,EAAE,UAAU,EAAE,MAAM,EAAE,SAAS;IAQ/C,KAAK;IAmBX,IAAI;YAKU,QAAQ;YAOR,IAAI;YAcJ,SAAS;YAOT,iBAAiB;YAkDjB,UAAU;CA0BzB"}
package/dist/monitor.js DELETED
@@ -1,136 +0,0 @@
1
- "use strict";
2
- /**
3
- * monitor.ts — main orchestration loop.
4
- *
5
- * two loops running on intervals:
6
- * 1. scan loop: discover tokens with active lending
7
- * 2. score loop: profile borrowers, score loans, execute liquidations
8
- */
9
- Object.defineProperty(exports, "__esModule", { value: true });
10
- exports.Monitor = void 0;
11
- const torchsdk_1 = require("torchsdk");
12
- const logger_1 = require("./logger");
13
- const wallet_profiler_1 = require("./wallet-profiler");
14
- const liquidator_1 = require("./liquidator");
15
- const scanner_1 = require("./scanner");
16
- const risk_scorer_1 = require("./risk-scorer");
17
- const utils_1 = require("./utils");
18
- class Monitor {
19
- constructor(connection, config) {
20
- this.tokens = new Map();
21
- this.running = false;
22
- this.connection = connection;
23
- this.config = config;
24
- this.log = new logger_1.Logger('monitor', config.logLevel);
25
- this.profiler = new wallet_profiler_1.WalletProfiler(this.log.child('profiler'));
26
- this.liquidator = new liquidator_1.Liquidator(config, this.log.child('liquidator'));
27
- }
28
- async start() {
29
- this.running = true;
30
- const wallet = this.config.walletKeypair.publicKey.toBase58();
31
- this.log.info('starting liquidation bot', {
32
- wallet: `${wallet.slice(0, 8)}...`,
33
- scanInterval: `${this.config.scanIntervalMs / 1000}s`,
34
- scoreInterval: `${this.config.scoreIntervalMs / 1000}s`,
35
- minProfit: `${(0, utils_1.sol)(this.config.minProfitLamports)} SOL`,
36
- riskThreshold: this.config.riskThreshold,
37
- });
38
- // initial scan before starting loops
39
- await this.scan();
40
- // run both loops concurrently
41
- await Promise.all([this.scanLoop(), this.scoreLoop()]);
42
- }
43
- stop() {
44
- this.running = false;
45
- this.log.info('stopping bot...');
46
- }
47
- async scanLoop() {
48
- while (this.running) {
49
- await (0, utils_1.sleep)(this.config.scanIntervalMs);
50
- await this.scan();
51
- }
52
- }
53
- async scan() {
54
- try {
55
- this.tokens = await (0, scanner_1.scanForLendingMarkets)(this.connection, this.tokens, this.config.priceHistoryDepth, this.log.child('scanner'));
56
- }
57
- catch (err) {
58
- const msg = err instanceof Error ? err.message : String(err);
59
- this.log.error('scan failed', { error: msg });
60
- }
61
- }
62
- async scoreLoop() {
63
- while (this.running) {
64
- await this.scoreAllPositions();
65
- await (0, utils_1.sleep)(this.config.scoreIntervalMs);
66
- }
67
- }
68
- async scoreAllPositions() {
69
- if (this.tokens.size === 0)
70
- return;
71
- const allScored = [];
72
- for (const token of this.tokens.values()) {
73
- try {
74
- const scored = await this.scoreToken(token);
75
- allScored.push(...scored);
76
- }
77
- catch (err) {
78
- const msg = err instanceof Error ? err.message : String(err);
79
- this.log.error(`failed scoring ${token.symbol}`, { error: msg });
80
- }
81
- }
82
- // sort by risk: highest risk first
83
- allScored.sort((a, b) => b.riskScore - a.riskScore);
84
- // log high-risk positions
85
- const highRisk = allScored.filter((l) => l.riskScore >= this.config.riskThreshold);
86
- if (highRisk.length > 0) {
87
- this.log.info(`${highRisk.length} high-risk positions detected`);
88
- for (const loan of highRisk) {
89
- this.log.info(` ${loan.tokenName} | ${loan.borrower.slice(0, 8)}...`, {
90
- risk: loan.riskScore,
91
- health: loan.position.health,
92
- ltv: (0, utils_1.bpsToPercent)(loan.position.current_ltv_bps),
93
- profit: `${(0, utils_1.sol)(loan.estimatedProfitLamports)} SOL`,
94
- });
95
- }
96
- }
97
- // attempt liquidations on any liquidatable positions (highest profit first)
98
- const liquidatable = allScored
99
- .filter((l) => l.position.health === 'liquidatable')
100
- .sort((a, b) => b.estimatedProfitLamports - a.estimatedProfitLamports);
101
- for (const loan of liquidatable) {
102
- const result = await this.liquidator.tryLiquidate(this.connection, loan);
103
- if (result) {
104
- this.log.info('liquidation successful!', {
105
- token: loan.tokenName,
106
- borrower: `${result.borrower.slice(0, 8)}...`,
107
- profit: `${(0, utils_1.sol)(result.profitLamports)} SOL`,
108
- sig: result.signature,
109
- });
110
- }
111
- }
112
- }
113
- async scoreToken(token) {
114
- const { holders } = await (0, torchsdk_1.getHolders)(this.connection, token.mint, 100);
115
- const scored = [];
116
- // update active borrowers list
117
- const borrowers = [];
118
- for (const holder of holders) {
119
- try {
120
- const position = await (0, torchsdk_1.getLoanPosition)(this.connection, token.mint, holder.address);
121
- if (position.health === 'none')
122
- continue;
123
- borrowers.push(holder.address);
124
- const profile = await this.profiler.profile(this.connection, holder.address, token.mint);
125
- scored.push((0, risk_scorer_1.scoreLoan)(token, holder.address, position, profile));
126
- }
127
- catch {
128
- // skip holders we can't score
129
- }
130
- }
131
- token.activeBorrowers = borrowers;
132
- return scored;
133
- }
134
- }
135
- exports.Monitor = Monitor;
136
- //# sourceMappingURL=monitor.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"monitor.js","sourceRoot":"","sources":["../src/monitor.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;AAGH,uCAAsD;AAEtD,qCAAiC;AACjC,uDAAkD;AAClD,6CAAyC;AACzC,uCAAiD;AACjD,+CAAyC;AACzC,mCAAkD;AAElD,MAAa,OAAO;IASlB,YAAY,UAAsB,EAAE,MAAiB;QAH7C,WAAM,GAAG,IAAI,GAAG,EAA0B,CAAA;QAC1C,YAAO,GAAG,KAAK,CAAA;QAGrB,IAAI,CAAC,UAAU,GAAG,UAAU,CAAA;QAC5B,IAAI,CAAC,MA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C7B,IAAI,CAAC;gBACH,MAAM,QAAQ,GAAG,MAAM,IAAA,0BAAe,EAAC,IAAI,CAAC,UAAU,EAAE,KAAK,CAAC,IAAI,EAAE,MAAM,CAAC,OAAO,CAAC,CAAA;gBAEnF,IAAI,QAAQ,CAAC,MAAM,KAAK,MAAM;oBAAE,SAAQ;gBAExC,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAA;gBAE9B,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,UAAU,EAAE,MAAM,CAAC,OAAO,EAAE,KAAK,CAAC,IAAI,CAAC,CAAA;gBAExF,MAAM,CAAC,IAAI,CAAC,IAAA,uBAAS,EAAC,KAAK,EAAE,MAAM,CAAC,OAAO,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC,CAAA;YAClE,CAAC;YAAC,MAAM,CAAC;gBACP,8BAA8B;YAChC,CAAC;QACH,CAAC;QAED,KAAK,CAAC,eAAe,GAAG,SAAS,CAAA;QACjC,OAAO,MAAM,CAAA;IACf,CAAC;CACF;AAjJD,0BAiJC"}
@@ -1,13 +0,0 @@
1
- /**
2
- * risk-scorer.ts — scores loan positions by likelihood of liquidation.
3
- *
4
- * four weighted factors:
5
- * - ltv proximity (40%): how close to the liquidation threshold
6
- * - price momentum (30%): is the collateral price trending down
7
- * - wallet risk (20%): borrower reputation + trade history
8
- * - interest burden (10%): is interest eating their margin
9
- */
10
- import type { LoanPositionInfo } from 'torchsdk';
11
- import type { WalletProfile, ScoredLoan, MonitoredToken } from './types';
12
- export declare function scoreLoan(token: MonitoredToken, borrower: string, position: LoanPositionInfo, profile: WalletProfile): ScoredLoan;
13
- //# sourceMappingURL=risk-scorer.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"risk-scorer.d.ts","sourceRoot":"","sources":["../src/risk-scorer.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAe,MAAM,UAAU,CAAA;AAC7D,OAAO,KAAK,EAAE,aAAa,EAAe,UAAU,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAUrF,wBAAgB,SAAS,CACvB,KAAK,EAAE,cAAc,EACrB,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,gBAAgB,EAC1B,OAAO,EAAE,aAAa,GACrB,UAAU,CAmCZ"}
@@ -1,102 +0,0 @@
1
- "use strict";
2
- /**
3
- * risk-scorer.ts — scores loan positions by likelihood of liquidation.
4
- *
5
- * four weighted factors:
6
- * - ltv proximity (40%): how close to the liquidation threshold
7
- * - price momentum (30%): is the collateral price trending down
8
- * - wallet risk (20%): borrower reputation + trade history
9
- * - interest burden (10%): is interest eating their margin
10
- */
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.scoreLoan = scoreLoan;
13
- const utils_1 = require("./utils");
14
- const WEIGHTS = {
15
- ltvProximity: 0.4,
16
- priceMomentum: 0.3,
17
- walletRisk: 0.2,
18
- interestBurden: 0.1,
19
- };
20
- function scoreLoan(token, borrower, position, profile) {
21
- const factors = computeFactors(position, token.lendingInfo, token.priceHistory, profile);
22
- const riskScore = (0, utils_1.clamp)(Math.round(factors.ltvProximity * WEIGHTS.ltvProximity +
23
- factors.priceMomentum * WEIGHTS.priceMomentum +
24
- factors.walletRisk * WEIGHTS.walletRisk +
25
- factors.interestBurden * WEIGHTS.interestBurden), 0, 100);
26
- // estimated profit = collateral value * liquidation bonus - fees
27
- const bonusPct = token.lendingInfo.liquidation_bonus_bps / 10000;
28
- const grossProfit = position.collateral_value_sol * bonusPct;
29
- const txFeeLamports = 5000; // ~0.000005 SOL per tx
30
- const transferFeeLamports = Math.floor(position.collateral_value_sol * 0.01); // Token-2022 1% fee
31
- const estimatedProfitLamports = Math.max(0, Math.floor(grossProfit) - txFeeLamports - transferFeeLamports);
32
- return {
33
- mint: token.mint,
34
- tokenName: token.name,
35
- borrower,
36
- position,
37
- walletProfile: profile,
38
- riskScore,
39
- factors,
40
- estimatedProfitLamports,
41
- lastScored: Date.now(),
42
- };
43
- }
44
- function computeFactors(position, lending, priceHistory, profile) {
45
- return {
46
- ltvProximity: computeLtvProximity(position, lending),
47
- priceMomentum: computePriceMomentum(priceHistory),
48
- walletRisk: profile.riskScore,
49
- interestBurden: computeInterestBurden(position),
50
- };
51
- }
52
- /**
53
- * how close is current LTV to the liquidation threshold?
54
- * at threshold = 100, at 0 LTV = 0
55
- */
56
- function computeLtvProximity(position, lending) {
57
- if (lending.liquidation_threshold_bps === 0)
58
- return 0;
59
- const ratio = position.current_ltv_bps / lending.liquidation_threshold_bps;
60
- return (0, utils_1.clamp)(Math.round(ratio * 100), 0, 100);
61
- }
62
- /**
63
- * is the price trending down?
64
- * uses simple slope of recent price history.
65
- * negative slope = price dropping = higher risk.
66
- */
67
- function computePriceMomentum(priceHistory) {
68
- if (priceHistory.length < 2)
69
- return 50; // not enough data, assume neutral
70
- // simple linear regression slope
71
- const n = priceHistory.length;
72
- let sumX = 0;
73
- let sumY = 0;
74
- let sumXY = 0;
75
- let sumX2 = 0;
76
- for (let i = 0; i < n; i++) {
77
- sumX += i;
78
- sumY += priceHistory[i];
79
- sumXY += i * priceHistory[i];
80
- sumX2 += i * i;
81
- }
82
- const slope = (n * sumXY - sumX * sumY) / (n * sumX2 - sumX * sumX);
83
- // normalize: negative slope = high risk, positive = low risk
84
- // use avg price as baseline for relative change
85
- const avgPrice = sumY / n;
86
- if (avgPrice === 0)
87
- return 50;
88
- const relativeSlopePerTick = slope / avgPrice;
89
- // scale: -5% per tick = 100 risk, +5% = 0 risk
90
- const score = 50 - relativeSlopePerTick * 1000;
91
- return (0, utils_1.clamp)(Math.round(score), 0, 100);
92
- }
93
- /**
94
- * how much is interest eating into the collateral margin?
95
- */
96
- function computeInterestBurden(position) {
97
- if (position.collateral_value_sol === 0)
98
- return 100;
99
- const ratio = position.accrued_interest / position.collateral_value_sol;
100
- return (0, utils_1.clamp)(Math.round(ratio * 1000), 0, 100); // 10% interest/collateral = 100
101
- }
102
- //# sourceMappingURL=risk-scorer.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"risk-scorer.js","sourceRoot":"","sources":["../src/risk-scorer.ts"],"names":[],"mappings":";AAAA;;;;;;;;GAQG;;AAaH,8BAwCC;AAjDD,mCAA+B;AAE/B,MAAM,OAAO,GAAG;IACd,YAAY,EAAE,GAAG;IACjB,aAAa,EAAE,GAAG;IAClB,UAAU,EAAE,GAAG;IACf,cAAc,EAAE,GAAG;CACpB,CAAA;AAED,SAAgB,SAAS,CACvB,KAAqB,EACrB,QAAgB,EAChB,QAA0B,EAC1B,OAAsB;IAEtB,MAAM,OAAO,GAAG,cAAc,CAAC,QAAQ,EAAE,KAAK,CAAC,WAAW,EAAE,KAAK,CAAC,YAAY,EAAE,OAAO,CAAC,CAAA;IAExF,MAAM,SAAS,GAAG,IAAA,aAAK,EACrB,IAAI,CAAC,KAAK,CACR,OAAO,CAAC,YAAY,GAAG,OAAO,CAAC,YAAY;QACzC,OAAO,CAAC,aAAa,GAAG,OAAO,CAAC,aAAa;QAC7C,OAAO,CAAC,UAAU,GAAG,OAAO,CAAC,UAAU;QACvC,OAAO,CAAC,cAAc,GAAG,OAAO,CAAC,cAAc,CAClD,EACD,CAAC,EACD,GAAG,CACJ,CAAA;IAED,iEAAiE;IACjE,MAAM,QAAQ,GAAG,KAAK,CAAC,WAAW,CAAC,qBAAqB,GAAG,KAAK,CAAA;IAChE,MAAM,WAAW,GAAG,QAAQ,CAAC,oBAAoB,GAAG,QAAQ,CAAA;IAC5D,MAAM,aAAa,GAAG,IAAI,CAAA,CAAC,uBAAuB;IAClD,MAAM,mBAAmB,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,oBAAoB,GAAG,IAAI,CAAC,CAAA,CAAC,oBAAoB;IACjG,MAAM,uBAAuB,GAAG,IAAI,CAAC,GAAG,CACtC,CAAC,EACD,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,GAA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scans all migrated tokens, checks which ones have active loans,
5
- * and returns them as MonitoredToken objects with price snapshots.
6
- */
7
- import type { Connection } from '@solana/web3.js';
8
- import type { MonitoredToken } from './types';
9
- import type { Logger } from './logger';
10
- export declare function scanForLendingMarkets(connection: Connection, existing: Map<string, MonitoredToken>, priceHistoryDepth: number, log: Logger): Promise<Map<string, MonitoredToken>>;
11
- //# sourceMappingURL=scanner.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"scanner.d.ts","sourceRoot":"","sources":["../src/scanner.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAEjD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAC7C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AAEtC,wBAAsB,qBAAqB,CACzC,UAAU,EAAE,UAAU,EACtB,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,cAAc,CAAC,EACrC,iBAAiB,EAAE,MAAM,EACzB,GAAG,EAAE,MAAM,GACV,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC,CAmDtC"}
package/dist/scanner.js DELETED
@@ -1,55 +0,0 @@
1
- "use strict";
2
- /**
3
- * scanner.ts — discovers tokens with active lending markets.
4
- *
5
- * scans all migrated tokens, checks which ones have active loans,
6
- * and returns them as MonitoredToken objects with price snapshots.
7
- */
8
- Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.scanForLendingMarkets = scanForLendingMarkets;
10
- const torchsdk_1 = require("torchsdk");
11
- async function scanForLendingMarkets(connection, existing, priceHistoryDepth, log) {
12
- log.info('scanning for tokens with active lending...');
13
- const { tokens } = await (0, torchsdk_1.getTokens)(connection, {
14
- status: 'migrated',
15
- sort: 'volume',
16
- limit: 50,
17
- });
18
- log.debug(`found ${tokens.length} migrated tokens`);
19
- const monitored = new Map(existing);
20
- for (const token of tokens) {
21
- try {
22
- const lending = await (0, torchsdk_1.getLendingInfo)(connection, token.mint);
23
- if (lending.active_loans === 0)
24
- continue;
25
- const priceSol = token.price_sol / torchsdk_1.LAMPORTS_PER_SOL;
26
- const prev = existing.get(token.mint);
27
- // build price history: append new price, trim to depth
28
- const priceHistory = prev?.priceHistory ?? [];
29
- priceHistory.push(priceSol);
30
- if (priceHistory.length > priceHistoryDepth) {
31
- priceHistory.splice(0, priceHistory.length - priceHistoryDepth);
32
- }
33
- monitored.set(token.mint, {
34
- mint: token.mint,
35
- name: token.name,
36
- symbol: token.symbol,
37
- lendingInfo: lending,
38
- priceSol,
39
- priceHistory,
40
- activeBorrowers: prev?.activeBorrowers ?? [],
41
- lastScanned: Date.now(),
42
- });
43
- log.info(`tracking: ${token.symbol}`, {
44
- loans: lending.active_loans,
45
- price: priceSol.toFixed(6),
46
- });
47
- }
48
- catch {
49
- // token may not have lending enabled — skip
50
- }
51
- }
52
- log.info(`monitoring ${monitored.size} tokens with active lending`);
53
- return monitored;
54
- }
55
- //# sourceMappingURL=scanner.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"scanner.js","sourceRoot":"","sources":["../src/scanner.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;AAOH,sDAwDC;AA5DD,uCAAsE;AAI/D,KAAK,UAAU,qBAAqB,CACzC,UAAsB,EACtB,QAAqC,EACrC,iBAAyB,EACzB,GAAW;IAEX,GAAG,CAAC,IAAI,CAAC,4CAA4C,CAAC,CAAA;IAEtD,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,IAAA,oBAAS,EAAC,UAAU,EAAE;QAC7C,MAAM,EAAE,UAAU;QAClB,IAAI,EAAE,QAAQ;QACd,KAAK,EAAE,EAAE;KACV,CAAC,CAAA;IAEF,GAAG,CAAC,KAAK,CAAC,SAAS,MAAM,CAAC,MAAM,kBAAkB,CAAC,CAAA;IAEnD,MAAM,SAAS,GAAG,IAAI,GAAG,CAAyB,QAAQ,CAAC,CAAA;IAE3D,KAAK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AAC,cAAc,SAAS,CAAC,IAAI,6BAA6B,CAAC,CAAA;IACnE,OAAO,SAAS,CAAA;AAClB,CAAC"}
package/dist/types.d.ts DELETED
@@ -1,69 +0,0 @@
1
- /**
2
- * types.ts — all interfaces and contracts for the liquidation bot.
3
- *
4
- * this is the blueprint. everything else implements these shapes.
5
- */
6
- import type { Keypair } from '@solana/web3.js';
7
- import type { LendingInfo, LoanPositionInfo } from 'torchsdk';
8
- export interface TradeStats {
9
- totalTrades: number;
10
- wins: number;
11
- losses: number;
12
- winRate: number;
13
- netPnlSol: number;
14
- }
15
- export interface WalletProfile {
16
- address: string;
17
- saidVerified: boolean;
18
- trustTier: 'high' | 'medium' | 'low' | null;
19
- tradeStats: TradeStats;
20
- riskScore: number;
21
- lastUpdated: number;
22
- }
23
- export interface RiskFactors {
24
- ltvProximity: number;
25
- priceMomentum: number;
26
- walletRisk: number;
27
- interestBurden: number;
28
- }
29
- export interface ScoredLoan {
30
- mint: string;
31
- tokenName: string;
32
- borrower: string;
33
- position: LoanPositionInfo;
34
- walletProfile: WalletProfile;
35
- riskScore: number;
36
- factors: RiskFactors;
37
- estimatedProfitLamports: number;
38
- lastScored: number;
39
- }
40
- export interface MonitoredToken {
41
- mint: string;
42
- name: string;
43
- symbol: string;
44
- lendingInfo: LendingInfo;
45
- priceSol: number;
46
- priceHistory: number[];
47
- activeBorrowers: string[];
48
- lastScanned: number;
49
- }
50
- export interface LiquidationResult {
51
- mint: string;
52
- borrower: string;
53
- signature: string;
54
- profitLamports: number;
55
- timestamp: number;
56
- confirmed: boolean;
57
- }
58
- export type LogLevel = 'debug' | 'info' | 'warn' | 'error';
59
- export interface BotConfig {
60
- rpcUrl: string;
61
- walletKeypair: Keypair;
62
- scanIntervalMs: number;
63
- scoreIntervalMs: number;
64
- minProfitLamports: number;
65
- riskThreshold: number;
66
- priceHistoryDepth: number;
67
- logLevel: LogLevel;
68
- }
69
- //# sourceMappingURL=types.d.ts.map
@@ -1 +0,0 @@
1
- {"version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IACxB,QAAQ,EAAE,MAAM,CAAA;IAChB,YAAY,EAAE,MAAM,EAAE,CAAA;IACtB,eAAe,EAAE,MAAM,EAAE,CAAA;IACzB,WAAW,EAAE,MAAM,CAAA;CACpB;AAMD,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,MAAM,CAAA;IACZ,QAAQ,EAAE,MAAM,CAAA;IAChB,SAAS,EAAE,MAAM,CAAA;IACjB,cAAc,EAAE,MAAM,CAAA;IACtB,SAAS,EAAE,MAAM,CAAA;IACjB,SAAS,EAAE,OAAO,CAAA;CACnB;AAMD,MAAM,MAAM,QAAQ,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAA;AAE1D,MAAM,WAAW,SAAS;IACxB,MAAM,EAAE,MAAM,CAAA;IACd,aAAa,EAAE,OAAO,CAAA;IACtB,cAAc,EAAE,MAAM,CAAA;IACtB,eAAe,EAAE,MAAM,CAAA;IACvB,iBAAiB,EAAE,MAAM,CAAA;IACzB,aAAa,EAAE,MAAM,CAAA;IACrB,iBAAiB,EAAE,MAAM,CAAA;IACzB,QAAQ,EAAE,QAAQ,CAAA;CACnB"}
package/dist/types.js DELETED
@@ -1,8 +0,0 @@
1
- "use strict";
2
- /**
3
- * types.ts — all interfaces and contracts for the liquidation bot.
4
- *
5
- * this is the blueprint. everything else implements these shapes.
6
- */
7
- Object.defineProperty(exports, "__esModule", { value: true });
8
- //# sourceMappingURL=types.js.map
package/dist/types.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";AAAA;;;;GAIG"}
package/dist/utils.d.ts DELETED
@@ -1,9 +0,0 @@
1
- /**
2
- * utils.ts — shared helpers used across modules.
3
- */
4
- export declare function sleep(ms: number): Promise<void>;
5
- export declare function sol(lamports: number): string;
6
- export declare function bpsToPercent(bps: number): string;
7
- /** clamp a value between min and max */
8
- export declare function clamp(value: number, min: number, max: number): number;
9
- //# sourceMappingURL=utils.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,wBAAgB,KAAK,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAE/C;AAED,wBAAgB,GAAG,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAE5C;AAED,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAEhD;AAED,wCAAwC;AACxC,wBAAgB,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAErE"}
package/dist/utils.js DELETED
@@ -1,24 +0,0 @@
1
- "use strict";
2
- /**
3
- * utils.ts — shared helpers used across modules.
4
- */
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.sleep = sleep;
7
- exports.sol = sol;
8
- exports.bpsToPercent = bpsToPercent;
9
- exports.clamp = clamp;
10
- const torchsdk_1 = require("torchsdk");
11
- function sleep(ms) {
12
- return new Promise((r) => setTimeout(r, ms));
13
- }
14
- function sol(lamports) {
15
- return (lamports / torchsdk_1.LAMPORTS_PER_SOL).toFixed(4);
16
- }
17
- function bpsToPercent(bps) {
18
- return (bps / 100).toFixed(2) + '%';
19
- }
20
- /** clamp a value between min and max */
21
- function clamp(value, min, max) {
22
- return Math.min(Math.max(value, min), max);
23
- }
24
- //# sourceMappingURL=utils.js.map
package/dist/utils.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";AAAA;;GAEG;;AAIH,sBAEC;AAED,kBAEC;AAED,oCAEC;AAGD,sBAEC;AAjBD,uCAA2C;AAE3C,SAAgB,KAAK,CAAC,EAAU;IAC9B,OAAO,IAAI,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,UAAU,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAA;AAC9C,CAAC;AAED,SAAgB,GAAG,CAAC,QAAgB;IAClC,OAAO,CAAC,QAAQ,GAAG,2BAAgB,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAA;AACjD,CAAC;AAED,SAAgB,YAAY,CAAC,GAAW;IACtC,OAAO,CAAC,GAAG,GAAG,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,GAAG,CAAA;AACrC,CAAC;AAED,wCAAwC;AACxC,SAAgB,KAAK,CAAC,KAAa,EAAE,GAAW,EAAE,GAAW;IAC3D,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,GAAG,CAAC,EAAE,GAAG,CAAC,CAAA;AAC5C,CAAC"}
@@ -1,21 +0,0 @@
1
- /**
2
- * wallet-profiler.ts — assesses wallet risk using SAID reputation + trade history.
3
- *
4
- * checks each borrower's trust tier and analyzes their trade messages
5
- * to determine if they tend to lose money (higher liquidation risk).
6
- *
7
- * profiles are cached in-memory with a cooldown to avoid hammering RPC.
8
- */
9
- import type { Connection } from '@solana/web3.js';
10
- import type { WalletProfile } from './types';
11
- import type { Logger } from './logger';
12
- export declare class WalletProfiler {
13
- private cache;
14
- private log;
15
- constructor(log: Logger);
16
- profile(connection: Connection, address: string, mint: string): Promise<WalletProfile>;
17
- private analyzeTradeHistory;
18
- private computeWalletRisk;
19
- private evictStale;
20
- }
21
- //# sourceMappingURL=wallet-profiler.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"wallet-profiler.d.ts","sourceRoot":"","sources":["../src/wallet-profiler.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAEjD,OAAO,KAAK,EAAE,aAAa,EAAc,MAAM,SAAS,CAAA;AACxD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AAOtC,qBAAa,cAAc;IACzB,OAAO,CAAC,KAAK,CAAmC;IAChD,OAAO,CAAC,GAAG,CAAQ;gBAEP,GAAG,EAAE,MAAM;IAIjB,OAAO,CAAC,UAAU,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC;YAgC9E,mBAAmB;IAsCjC,OAAO,CAAC,iBAAiB;IA2BzB,OAAO,CAAC,UAAU;CAgBnB"}