torch-liquidation-bot 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/dist/index.d.ts +23 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +207 -0
- package/dist/index.js.map +1 -0
- package/package.json +34 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* torch-lending-monitor
|
|
3
|
+
*
|
|
4
|
+
* Monitors lending positions on migrated Torch tokens and can:
|
|
5
|
+
* 1. Display lending parameters (rates, LTV limits, available SOL).
|
|
6
|
+
* 2. Watch a wallet's loan health in real-time.
|
|
7
|
+
* 3. Auto-liquidate underwater positions for the liquidation bonus.
|
|
8
|
+
*
|
|
9
|
+
* Torch lending lets token holders borrow SOL against their tokens
|
|
10
|
+
* using community treasury liquidity. This bot watches those positions.
|
|
11
|
+
*
|
|
12
|
+
* Usage:
|
|
13
|
+
* # Monitor a token's lending stats
|
|
14
|
+
* MODE=info MINT=<token-mint> npx tsx src/index.ts
|
|
15
|
+
*
|
|
16
|
+
* # Watch your own loan health
|
|
17
|
+
* MODE=watch MINT=<token-mint> WALLET=<base58-key> npx tsx src/index.ts
|
|
18
|
+
*
|
|
19
|
+
* # Run as a liquidation bot (scans for liquidatable positions)
|
|
20
|
+
* MODE=liquidate MINT=<token-mint> WALLET=<base58-key> npx tsx src/index.ts
|
|
21
|
+
*/
|
|
22
|
+
export {};
|
|
23
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* torch-lending-monitor
|
|
4
|
+
*
|
|
5
|
+
* Monitors lending positions on migrated Torch tokens and can:
|
|
6
|
+
* 1. Display lending parameters (rates, LTV limits, available SOL).
|
|
7
|
+
* 2. Watch a wallet's loan health in real-time.
|
|
8
|
+
* 3. Auto-liquidate underwater positions for the liquidation bonus.
|
|
9
|
+
*
|
|
10
|
+
* Torch lending lets token holders borrow SOL against their tokens
|
|
11
|
+
* using community treasury liquidity. This bot watches those positions.
|
|
12
|
+
*
|
|
13
|
+
* Usage:
|
|
14
|
+
* # Monitor a token's lending stats
|
|
15
|
+
* MODE=info MINT=<token-mint> npx tsx src/index.ts
|
|
16
|
+
*
|
|
17
|
+
* # Watch your own loan health
|
|
18
|
+
* MODE=watch MINT=<token-mint> WALLET=<base58-key> npx tsx src/index.ts
|
|
19
|
+
*
|
|
20
|
+
* # Run as a liquidation bot (scans for liquidatable positions)
|
|
21
|
+
* MODE=liquidate MINT=<token-mint> WALLET=<base58-key> npx tsx src/index.ts
|
|
22
|
+
*/
|
|
23
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
24
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
25
|
+
};
|
|
26
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
|
+
const web3_js_1 = require("@solana/web3.js");
|
|
28
|
+
const bs58_1 = __importDefault(require("bs58"));
|
|
29
|
+
const torchsdk_1 = require("torchsdk");
|
|
30
|
+
// ---------------------------------------------------------------------------
|
|
31
|
+
// Config
|
|
32
|
+
// ---------------------------------------------------------------------------
|
|
33
|
+
const RPC_URL = process.env.RPC_URL ?? 'https://api.mainnet-beta.solana.com';
|
|
34
|
+
const MINT = process.env.MINT;
|
|
35
|
+
const MODE = process.env.MODE ?? 'info';
|
|
36
|
+
const POLL_INTERVAL_MS = Number(process.env.POLL_INTERVAL_MS ?? '15000');
|
|
37
|
+
// ---------------------------------------------------------------------------
|
|
38
|
+
// Helpers
|
|
39
|
+
// ---------------------------------------------------------------------------
|
|
40
|
+
function loadWallet() {
|
|
41
|
+
const key = process.env.WALLET;
|
|
42
|
+
if (!key)
|
|
43
|
+
throw new Error('Set WALLET env var to a base58-encoded private key');
|
|
44
|
+
return web3_js_1.Keypair.fromSecretKey(bs58_1.default.decode(key));
|
|
45
|
+
}
|
|
46
|
+
function sleep(ms) {
|
|
47
|
+
return new Promise((r) => setTimeout(r, ms));
|
|
48
|
+
}
|
|
49
|
+
function sol(lamports) {
|
|
50
|
+
return (lamports / torchsdk_1.LAMPORTS_PER_SOL).toFixed(4);
|
|
51
|
+
}
|
|
52
|
+
function bpsToPercent(bps) {
|
|
53
|
+
return (bps / 100).toFixed(2) + '%';
|
|
54
|
+
}
|
|
55
|
+
// ---------------------------------------------------------------------------
|
|
56
|
+
// Mode: info — display lending parameters for a token
|
|
57
|
+
// ---------------------------------------------------------------------------
|
|
58
|
+
async function showLendingInfo(connection, mint) {
|
|
59
|
+
const token = await (0, torchsdk_1.getToken)(connection, mint);
|
|
60
|
+
const lending = await (0, torchsdk_1.getLendingInfo)(connection, mint);
|
|
61
|
+
console.log(`\n=== lending info: ${token.name} (${token.symbol}) ===`);
|
|
62
|
+
console.log(`status: ${token.status}`);
|
|
63
|
+
console.log(`token price: ${sol(token.price_sol)} SOL`);
|
|
64
|
+
console.log(`interest rate: ${bpsToPercent(lending.interest_rate_bps)}`);
|
|
65
|
+
console.log(`max LTV: ${bpsToPercent(lending.max_ltv_bps)}`);
|
|
66
|
+
console.log(`liquidation threshold: ${bpsToPercent(lending.liquidation_threshold_bps)}`);
|
|
67
|
+
console.log(`liquidation bonus: ${bpsToPercent(lending.liquidation_bonus_bps)}`);
|
|
68
|
+
console.log(`treasury SOL avail: ${sol(lending.treasury_sol_available)} SOL`);
|
|
69
|
+
console.log(`total SOL lent: ${sol(lending.total_sol_lent)} SOL`);
|
|
70
|
+
console.log(`active loans: ${lending.active_loans}`);
|
|
71
|
+
}
|
|
72
|
+
// ---------------------------------------------------------------------------
|
|
73
|
+
// Mode: watch — monitor your own loan health
|
|
74
|
+
// ---------------------------------------------------------------------------
|
|
75
|
+
async function watchPosition(connection, mint, wallet) {
|
|
76
|
+
console.log(`\n=== watching loan: ${wallet.publicKey.toBase58()} ===`);
|
|
77
|
+
console.log(`mint: ${mint}\n`);
|
|
78
|
+
while (true) {
|
|
79
|
+
const pos = await (0, torchsdk_1.getLoanPosition)(connection, mint, wallet.publicKey.toBase58());
|
|
80
|
+
if (pos.health === 'none') {
|
|
81
|
+
console.log(`[${new Date().toISOString()}] no active loan`);
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
const healthColor = pos.health === 'healthy' ? 'OK' : pos.health === 'at_risk' ? 'WARNING' : 'DANGER';
|
|
85
|
+
console.log(`[${new Date().toISOString()}] health: ${healthColor} (${pos.health})`);
|
|
86
|
+
console.log(` collateral: ${pos.collateral_amount} tokens`);
|
|
87
|
+
console.log(` collat value: ${sol(pos.collateral_value_sol)} SOL`);
|
|
88
|
+
console.log(` borrowed: ${sol(pos.borrowed_amount)} SOL`);
|
|
89
|
+
console.log(` interest: ${sol(pos.accrued_interest)} SOL`);
|
|
90
|
+
console.log(` total owed: ${sol(pos.total_owed)} SOL`);
|
|
91
|
+
console.log(` current LTV: ${bpsToPercent(pos.current_ltv_bps)}`);
|
|
92
|
+
if (pos.health === 'at_risk') {
|
|
93
|
+
console.log(' --> consider adding collateral or repaying to avoid liquidation');
|
|
94
|
+
}
|
|
95
|
+
if (pos.health === 'liquidatable') {
|
|
96
|
+
console.log(' --> your position can be liquidated! repay immediately');
|
|
97
|
+
// auto-repay if enabled
|
|
98
|
+
if (process.env.AUTO_REPAY === 'true') {
|
|
99
|
+
console.log(' --> auto-repaying...');
|
|
100
|
+
const { transaction, message } = await (0, torchsdk_1.buildRepayTransaction)(connection, {
|
|
101
|
+
mint,
|
|
102
|
+
borrower: wallet.publicKey.toBase58(),
|
|
103
|
+
sol_amount: pos.total_owed,
|
|
104
|
+
});
|
|
105
|
+
console.log(` tx: ${message}`);
|
|
106
|
+
const sig = await (0, web3_js_1.sendAndConfirmTransaction)(connection, transaction, [wallet]);
|
|
107
|
+
console.log(` confirmed: ${sig}`);
|
|
108
|
+
const result = await (0, torchsdk_1.confirmTransaction)(connection, sig, wallet.publicKey.toBase58());
|
|
109
|
+
console.log(` SAID event: ${result.event_type}`);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
await sleep(POLL_INTERVAL_MS);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
// ---------------------------------------------------------------------------
|
|
117
|
+
// Mode: liquidate — scan holders for underwater positions
|
|
118
|
+
// ---------------------------------------------------------------------------
|
|
119
|
+
async function runLiquidator(connection, mint, wallet) {
|
|
120
|
+
console.log(`\n=== liquidation bot ===`);
|
|
121
|
+
console.log(`mint: ${mint}`);
|
|
122
|
+
console.log(`liquidator: ${wallet.publicKey.toBase58()}\n`);
|
|
123
|
+
const lending = await (0, torchsdk_1.getLendingInfo)(connection, mint);
|
|
124
|
+
console.log(`liquidation threshold: ${bpsToPercent(lending.liquidation_threshold_bps)}`);
|
|
125
|
+
console.log(`liquidation bonus: ${bpsToPercent(lending.liquidation_bonus_bps)}`);
|
|
126
|
+
console.log(`active loans: ${lending.active_loans}\n`);
|
|
127
|
+
while (true) {
|
|
128
|
+
console.log(`[${new Date().toISOString()}] scanning holders...`);
|
|
129
|
+
const { holders } = await (0, torchsdk_1.getHolders)(connection, mint, 100);
|
|
130
|
+
let liquidatable = 0;
|
|
131
|
+
for (const holder of holders) {
|
|
132
|
+
const pos = await (0, torchsdk_1.getLoanPosition)(connection, mint, holder.address);
|
|
133
|
+
if (pos.health === 'liquidatable') {
|
|
134
|
+
liquidatable++;
|
|
135
|
+
console.log(` LIQUIDATABLE: ${holder.address}`);
|
|
136
|
+
console.log(` collateral: ${pos.collateral_amount} tokens (${sol(pos.collateral_value_sol)} SOL)`);
|
|
137
|
+
console.log(` owes: ${sol(pos.total_owed)} SOL`);
|
|
138
|
+
console.log(` LTV: ${bpsToPercent(pos.current_ltv_bps)}`);
|
|
139
|
+
try {
|
|
140
|
+
const { transaction, message } = await (0, torchsdk_1.buildLiquidateTransaction)(connection, {
|
|
141
|
+
mint,
|
|
142
|
+
liquidator: wallet.publicKey.toBase58(),
|
|
143
|
+
borrower: holder.address,
|
|
144
|
+
});
|
|
145
|
+
console.log(` tx: ${message}`);
|
|
146
|
+
const sig = await (0, web3_js_1.sendAndConfirmTransaction)(connection, transaction, [wallet]);
|
|
147
|
+
console.log(` confirmed: ${sig}`);
|
|
148
|
+
const result = await (0, torchsdk_1.confirmTransaction)(connection, sig, wallet.publicKey.toBase58());
|
|
149
|
+
console.log(` SAID event: ${result.event_type}`);
|
|
150
|
+
}
|
|
151
|
+
catch (err) {
|
|
152
|
+
console.error(` failed: ${err instanceof Error ? err.message : err}`);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
if (liquidatable === 0) {
|
|
157
|
+
console.log(' no liquidatable positions found');
|
|
158
|
+
}
|
|
159
|
+
await sleep(POLL_INTERVAL_MS);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
// ---------------------------------------------------------------------------
|
|
163
|
+
// Main
|
|
164
|
+
// ---------------------------------------------------------------------------
|
|
165
|
+
async function main() {
|
|
166
|
+
if (!MINT) {
|
|
167
|
+
// If no mint is specified, show lending info for all migrated tokens
|
|
168
|
+
console.log('=== torch lending monitor ===\n');
|
|
169
|
+
console.log('no MINT specified — showing all migrated tokens with lending\n');
|
|
170
|
+
const connection = new web3_js_1.Connection(RPC_URL, 'confirmed');
|
|
171
|
+
const { tokens } = await (0, torchsdk_1.getTokens)(connection, {
|
|
172
|
+
status: 'migrated',
|
|
173
|
+
sort: 'volume',
|
|
174
|
+
limit: 10,
|
|
175
|
+
});
|
|
176
|
+
for (const t of tokens) {
|
|
177
|
+
try {
|
|
178
|
+
const lending = await (0, torchsdk_1.getLendingInfo)(connection, t.mint);
|
|
179
|
+
console.log(`${t.symbol.padEnd(10)} | ` +
|
|
180
|
+
`rate: ${bpsToPercent(lending.interest_rate_bps).padEnd(7)} | ` +
|
|
181
|
+
`loans: ${String(lending.active_loans).padEnd(4)} | ` +
|
|
182
|
+
`avail: ${sol(lending.treasury_sol_available)} SOL`);
|
|
183
|
+
}
|
|
184
|
+
catch {
|
|
185
|
+
// token may not have lending enabled yet
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
return;
|
|
189
|
+
}
|
|
190
|
+
const connection = new web3_js_1.Connection(RPC_URL, 'confirmed');
|
|
191
|
+
switch (MODE) {
|
|
192
|
+
case 'info':
|
|
193
|
+
await showLendingInfo(connection, MINT);
|
|
194
|
+
break;
|
|
195
|
+
case 'watch':
|
|
196
|
+
await watchPosition(connection, MINT, loadWallet());
|
|
197
|
+
break;
|
|
198
|
+
case 'liquidate':
|
|
199
|
+
await runLiquidator(connection, MINT, loadWallet());
|
|
200
|
+
break;
|
|
201
|
+
default:
|
|
202
|
+
console.error(`unknown MODE: ${MODE}. use info | watch | liquidate`);
|
|
203
|
+
process.exit(1);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
main();
|
|
207
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;;;AAEH,6CAAgF;AAChF,gDAAuB;AACvB,uCAaiB;AAEjB,8EAA8E;AAC9E,SAAS;AACT,8EAA8E;AAE9E,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,OAAO,IAAI,qCAAqC,CAAA;AAC5E,MAAM,IAAI,GAAG,OAAO,CAAC,GAAG,CAAC,IAAI,CAAA;AAC7B,MAAM,IAAI,GAAG,OAAO,CAAC,GAAG,CAAC,IAAI,IAAI,MAAM,CAAA;AACvC,MAAM,gBAAgB,GAAG,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,gBAAgB,IAAI,OAAO,CAAC,CAAA;AAExE,8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DED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "torch-liquidation-bot",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "lending position monitor and auto-liquidation bot using the torchsdk",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"files": [
|
|
8
|
+
"dist"
|
|
9
|
+
],
|
|
10
|
+
"scripts": {
|
|
11
|
+
"build": "tsc",
|
|
12
|
+
"clean": "rm -rf dist",
|
|
13
|
+
"test": "npx tsx tests/test_lending.ts",
|
|
14
|
+
"test:bot": "npx tsx tests/test_bot.ts",
|
|
15
|
+
"format": "prettier --write src/ tests/"
|
|
16
|
+
},
|
|
17
|
+
"dependencies": {
|
|
18
|
+
"@coral-xyz/anchor": "^0.32.1",
|
|
19
|
+
"@solana/spl-token": "^0.4.14",
|
|
20
|
+
"@solana/web3.js": "^1.98.4",
|
|
21
|
+
"bs58": "^6.0.0",
|
|
22
|
+
"torchsdk": "^1.0.0"
|
|
23
|
+
},
|
|
24
|
+
"devDependencies": {
|
|
25
|
+
"@types/node": "^20",
|
|
26
|
+
"prettier": "^3.5.3",
|
|
27
|
+
"typescript": "^5"
|
|
28
|
+
},
|
|
29
|
+
"peerDependencies": {
|
|
30
|
+
"@solana/web3.js": "^1.98.0"
|
|
31
|
+
},
|
|
32
|
+
"license": "MIT",
|
|
33
|
+
"packageManager": "pnpm@9.10.0+sha512.73a29afa36a0d092ece5271de5177ecbf8318d454ecd701343131b8ebc0c1a91c487da46ab77c8e596d6acf1461e3594ced4becedf8921b074fbd8653ed7051c"
|
|
34
|
+
}
|