torch-liquidation-bot 1.0.0 → 1.0.1
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/package.json +2 -2
- package/readme.md +140 -0
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "torch-liquidation-bot",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"description": "lending position monitor and auto-liquidation
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"description": "lending position monitor and auto-liquidation skill using the torchsdk",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
7
|
"files": [
|
package/readme.md
ADDED
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
# torch-liquidation-bot
|
|
2
|
+
|
|
3
|
+
Multi-token liquidation bot for [Torch Market](https://torch.market) lending on Solana. Discovers lending markets, profiles borrower wallets, predicts which loans are likely to fail, and executes profitable liquidations.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install torch-liquidation-bot
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## How It Works
|
|
12
|
+
|
|
13
|
+
Every migrated token on Torch has a built-in lending market. Holders borrow SOL against their tokens. When a borrower's loan-to-value ratio exceeds 65%, anyone can liquidate the position and collect a 10% bonus on the collateral.
|
|
14
|
+
|
|
15
|
+
This bot finds those opportunities before other bots do by **predicting** which positions will go underwater:
|
|
16
|
+
|
|
17
|
+
1. **Scan** -- discovers all tokens with active lending markets
|
|
18
|
+
2. **Profile** -- checks each borrower's SAID reputation and trade history
|
|
19
|
+
3. **Score** -- rates every loan on a 4-factor risk model (0-100)
|
|
20
|
+
4. **Liquidate** -- executes when a position crosses the threshold and the profit exceeds your minimum
|
|
21
|
+
|
|
22
|
+
## Quick Start
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
MODE=bot WALLET=<base58-private-key> RPC_URL=<rpc-endpoint> npx tsx src/index.ts
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Modes
|
|
29
|
+
|
|
30
|
+
### `bot` (default) -- full liquidation bot
|
|
31
|
+
|
|
32
|
+
Runs two concurrent loops:
|
|
33
|
+
- **Scan loop** (every 60s) -- finds tokens with active lending, snapshots prices
|
|
34
|
+
- **Score loop** (every 15s) -- profiles borrowers, scores loans, executes liquidations
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
MODE=bot WALLET=<key> RPC_URL=<rpc> npx tsx src/index.ts
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
### `info` -- display lending parameters
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
# all migrated tokens with lending
|
|
44
|
+
MODE=info RPC_URL=<rpc> npx tsx src/index.ts
|
|
45
|
+
|
|
46
|
+
# specific token
|
|
47
|
+
MODE=info MINT=<mint> RPC_URL=<rpc> npx tsx src/index.ts
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### `watch` -- monitor your own loan health
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
MODE=watch MINT=<mint> WALLET=<key> RPC_URL=<rpc> npx tsx src/index.ts
|
|
54
|
+
|
|
55
|
+
# with auto-repay if your position becomes liquidatable
|
|
56
|
+
MODE=watch MINT=<mint> WALLET=<key> AUTO_REPAY=true RPC_URL=<rpc> npx tsx src/index.ts
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## Risk Scoring
|
|
60
|
+
|
|
61
|
+
Every loan gets a composite score from four weighted factors:
|
|
62
|
+
|
|
63
|
+
| Factor | Weight | What It Measures |
|
|
64
|
+
|--------|--------|------------------|
|
|
65
|
+
| LTV proximity | 40% | How close to the 65% liquidation threshold |
|
|
66
|
+
| Price momentum | 30% | Collateral price trend (linear regression on recent snapshots) |
|
|
67
|
+
| Wallet risk | 20% | SAID trust tier + trade win/loss ratio |
|
|
68
|
+
| Interest burden | 10% | Accrued interest relative to collateral value |
|
|
69
|
+
|
|
70
|
+
Positions above the risk threshold (default: 60) are flagged and watched closely. Liquidatable positions with profit above your minimum are executed immediately, highest profit first.
|
|
71
|
+
|
|
72
|
+
## Configuration
|
|
73
|
+
|
|
74
|
+
| Variable | Required | Default | Description |
|
|
75
|
+
|----------|----------|---------|-------------|
|
|
76
|
+
| `RPC_URL` | yes | -- | Solana RPC endpoint |
|
|
77
|
+
| `WALLET` | bot/watch | -- | Base58 private key |
|
|
78
|
+
| `MODE` | no | `bot` | `bot`, `info`, or `watch` |
|
|
79
|
+
| `MINT` | info/watch | -- | Token mint address |
|
|
80
|
+
| `SCAN_INTERVAL_MS` | no | `60000` | Token discovery interval |
|
|
81
|
+
| `SCORE_INTERVAL_MS` | no | `15000` | Position scoring interval |
|
|
82
|
+
| `MIN_PROFIT_SOL` | no | `0.01` | Minimum profit to execute liquidation |
|
|
83
|
+
| `RISK_THRESHOLD` | no | `60` | Risk score cutoff for close monitoring |
|
|
84
|
+
| `PRICE_HISTORY` | no | `20` | Price snapshots to keep for momentum |
|
|
85
|
+
| `LOG_LEVEL` | no | `info` | `debug`, `info`, `warn`, `error` |
|
|
86
|
+
|
|
87
|
+
## Architecture
|
|
88
|
+
|
|
89
|
+
```
|
|
90
|
+
src/
|
|
91
|
+
├── types.ts — interfaces and contracts
|
|
92
|
+
├── config.ts — env vars → typed config
|
|
93
|
+
├── logger.ts — structured logging
|
|
94
|
+
├── utils.ts — shared helpers
|
|
95
|
+
├── scanner.ts — discovers tokens with active lending
|
|
96
|
+
├── wallet-profiler.ts — SAID reputation + trade history
|
|
97
|
+
├── risk-scorer.ts — 4-factor risk model
|
|
98
|
+
├── liquidator.ts — executes liquidation txs
|
|
99
|
+
├── monitor.ts — scan + score orchestration
|
|
100
|
+
└── index.ts — entry point
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
## Lending Parameters
|
|
104
|
+
|
|
105
|
+
| Parameter | Value |
|
|
106
|
+
|-----------|-------|
|
|
107
|
+
| Max LTV | 50% |
|
|
108
|
+
| Liquidation threshold | 65% LTV |
|
|
109
|
+
| Interest rate | 2% per epoch (~7 days) |
|
|
110
|
+
| Liquidation bonus | 10% of collateral |
|
|
111
|
+
| Min borrow | 0.1 SOL |
|
|
112
|
+
|
|
113
|
+
## Testing
|
|
114
|
+
|
|
115
|
+
Requires [Surfpool](https://github.com/nicholasgasior/surfpool) running a mainnet fork:
|
|
116
|
+
|
|
117
|
+
```bash
|
|
118
|
+
surfpool start --network mainnet --no-tui
|
|
119
|
+
pnpm test # lending lifecycle test
|
|
120
|
+
pnpm test:bot # bot module test (scanner, profiler, scorer, liquidator)
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
## Security
|
|
124
|
+
|
|
125
|
+
- Private keys loaded from env, never logged or transmitted
|
|
126
|
+
- All transactions built locally via [torchsdk](https://github.com/mrsirg97-rgb/torchsdk) Anchor IDL
|
|
127
|
+
- Unsigned transactions signed with your own keypair -- keys never leave your environment
|
|
128
|
+
- Minimum profit threshold prevents unprofitable executions
|
|
129
|
+
- Graceful shutdown on SIGINT
|
|
130
|
+
|
|
131
|
+
## Links
|
|
132
|
+
|
|
133
|
+
- [torchsdk](https://github.com/mrsirg97-rgb/torchsdk) -- the SDK this bot is built on
|
|
134
|
+
- [Torch Market](https://torch.market) -- the protocol
|
|
135
|
+
- [SAID Protocol](https://saidprotocol.com) -- wallet reputation layer
|
|
136
|
+
- [ClawHub](https://clawhub.ai/mrsirg97-rgb/torchliquidationbot) -- skill registry
|
|
137
|
+
|
|
138
|
+
## License
|
|
139
|
+
|
|
140
|
+
MIT
|