torch-liquidation-bot 1.0.4 → 2.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.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wallet-profiler.js","sourceRoot":"","sources":["../src/wallet-profiler.ts"],"names":[],"mappings":";AAAA;;;;;;;GAOG;;;AAGH,uCAAkD;AAGlD,mCAA+B;AAE/B,MAAM,mBAAmB,GAAG,CAAC,GAAG,EAAE,GAAG,IAAI,CAAA,CAAC,+BAA+B;AACzE,MAAM,gBAAgB,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAA,CAAC,kCAAkC;AAC1E,MAAM,cAAc,GAAG,IAAI,CAAA,CAAC,4BAA4B;AAExD,MAAa,cAAc;IAIzB,YAAY,GAAW;QAHf,UAAK,GAAG,IAAI,GAAG,EAAyB,CAAA;QAI9C,IAAI,CAAC,GAAG,GAAG,GAAG,CAAA;IAChB,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,UAAsB,EAAE,OAAe,EAAE,IAAY;QACjE,IAAI,CAAC,UAAU,EAAE,CAAA;QAEjB,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,CAAA;QACtC,IAAI,MAAM,IAAI,IAAI,CAAC,GAAG,EAAE,GAAG,MAAM,CAAC,WAAW,GAAG,mBAAmB,EAAE,CAAC;YACpE,OAAO,MAAM,CAAA;QACf,CAAC;QAED,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,oBAAoB,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,CAAA;QAE5D,kBAAkB;QAClB,MAAM,IAAI,GAAG,MAAM,IAAA,qBAAU,EAAC,OAAO,CAAC,CAAA;QAEtC,8BAA8B;QAC9B,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC,mBAAmB,CAAC,UAAU,EAAE,IAAI,EAAE,OAAO,CAAC,CAAA;QAE5E,o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,CAAC,GAAG,EAAE,OAAO,CAAC,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;YACxC,IAAI,GAAG,GAAG,OAAO,CAAC,WAAW,GAAG,gBAAgB,EAAE,CAAC;gBACjD,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAA;YACxB,CAAC;QACH,CAAC;QACD,qDAAqD;QACrD,IAAI,IAAI,CAAC,KAAK,CAAC,IAAI,GAAG,cAAc,EAAE,CAAC;YACrC,MAAM,MAAM,GAAG,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,WAAW,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,CAAA;YAC5F,MAAM,OAAO,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,GAAG,cAAc,CAAC,CAAA;YACjE,KAAK,MAAM,CAAC,GAAG,CAAC,IAAI,OAAO,EAAE,CAAC;gBAC5B,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAA;YACxB,CAAC;QACH,CAAC;IACH,CAAC;CACF;AAzHD,wCAyHC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "torch-liquidation-bot",
3
- "version": "1.0.4",
3
+ "version": "2.0.1",
4
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",
@@ -13,7 +13,8 @@
13
13
  "scripts": {
14
14
  "build": "tsc",
15
15
  "clean": "rm -rf dist",
16
- "test": "npx tsx tests/test_lending.ts",
16
+ "test": "npx tsx tests/test_readonly.ts",
17
+ "test:lending": "npx tsx tests/test_lending.ts",
17
18
  "test:bot": "npx tsx tests/test_bot.ts",
18
19
  "format": "prettier --write src/ tests/"
19
20
  },
@@ -22,7 +23,7 @@
22
23
  "@solana/spl-token": "^0.4.14",
23
24
  "@solana/web3.js": "^1.98.4",
24
25
  "bs58": "^6.0.0",
25
- "torchsdk": "^1.0.0"
26
+ "torchsdk": "^1.0.5"
26
27
  },
27
28
  "devDependencies": {
28
29
  "@types/node": "^20",
package/readme.md CHANGED
@@ -1,6 +1,8 @@
1
- # torch-liquidation-bot
1
+ # torch-liquidation-bot v2.0.0 (Read-Only)
2
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.
3
+ Read-only lending market scanner for [Torch Market](https://torch.market) on Solana. No wallet required. Only an RPC endpoint is needed.
4
+
5
+ > **v2.0.0 Breaking Change:** All wallet-dependent functionality (bot mode, watch mode, transaction signing) is deprecated. The entry point no longer imports or references any wallet, keypair, or signing code. Only read-only info mode is available.
4
6
 
5
7
  ## Install
6
8
 
@@ -8,98 +10,83 @@ Multi-token liquidation bot for [Torch Market](https://torch.market) lending on
8
10
  npm install torch-liquidation-bot
9
11
  ```
10
12
 
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
13
  ## Quick Start
23
14
 
24
15
  ```bash
25
- MODE=bot WALLET=<base58-private-key> RPC_URL=<rpc-endpoint> npx torch-liquidation-bot
26
- ```
27
-
28
- ## Modes
29
-
30
- ### `bot` (default) -- full liquidation bot
16
+ # show lending info for all migrated tokens
17
+ RPC_URL=<rpc> npx torch-liquidation-bot
31
18
 
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 torch-liquidation-bot
19
+ # show lending info for a specific token
20
+ MINT=<mint> RPC_URL=<rpc> npx torch-liquidation-bot
38
21
  ```
39
22
 
40
- ### `info` -- display lending parameters
41
-
42
- ```bash
43
- # all migrated tokens with lending
44
- MODE=info RPC_URL=<rpc> npx torch-liquidation-bot
23
+ ## What It Does
45
24
 
46
- # specific token
47
- MODE=info MINT=<mint> RPC_URL=<rpc> npx torch-liquidation-bot
48
- ```
25
+ Every migrated token on Torch has a built-in lending market. This skill discovers those markets and displays their parameters — interest rates, LTV thresholds, treasury balances, and active loan counts.
49
26
 
50
- ### `watch` -- monitor your own loan health
27
+ That's it. No wallet loaded. No transactions built. No state changes.
51
28
 
52
- ```bash
53
- MODE=watch MINT=<mint> WALLET=<key> RPC_URL=<rpc> npx torch-liquidation-bot
29
+ ## Configuration
54
30
 
55
- # with auto-repay if your position becomes liquidatable
56
- MODE=watch MINT=<mint> WALLET=<key> AUTO_REPAY=true RPC_URL=<rpc> npx torch-liquidation-bot
57
- ```
31
+ | Variable | Required | Default | Description |
32
+ |----------|----------|---------|-------------|
33
+ | `RPC_URL` | yes | -- | Solana RPC endpoint |
34
+ | `MINT` | no | -- | Token mint address (omit to show all tokens) |
35
+ | `LOG_LEVEL` | no | `info` | `debug`, `info`, `warn`, `error` |
58
36
 
59
- ## Risk Scoring
37
+ No `WALLET`, no `MODE`, no bot-specific config.
60
38
 
61
- Every loan gets a composite score from four weighted factors:
39
+ ## Programmatic Usage
62
40
 
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 |
41
+ ```typescript
42
+ import { loadReadOnlyConfig } from 'torch-liquidation-bot/config'
43
+ import { Connection } from '@solana/web3.js'
44
+ import { getTokens, getLendingInfo } from 'torchsdk'
69
45
 
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.
46
+ const config = loadReadOnlyConfig()
47
+ const connection = new Connection(config.rpcUrl, 'confirmed')
71
48
 
72
- ## Configuration
49
+ const { tokens } = await getTokens(connection, {
50
+ status: 'migrated',
51
+ sort: 'volume',
52
+ limit: 50,
53
+ })
73
54
 
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` |
55
+ for (const t of tokens) {
56
+ const lending = await getLendingInfo(connection, t.mint)
57
+ console.log(`${t.symbol}: ${lending.active_loans} active loans`)
58
+ }
59
+ ```
86
60
 
87
61
  ## Architecture
88
62
 
89
63
  ```
90
- src/
91
- ├── types.ts — interfaces and contracts
92
- ├── config.ts — env vars typed config
93
- ├── logger.ts — structured logging
64
+ packages/bot/src/
65
+ ├── types.ts — interfaces (ReadOnlyConfig + dormant BotConfig)
66
+ ├── config.ts — loadReadOnlyConfig() (active) + loadConfig() (dormant)
94
67
  ├── utils.ts — shared helpers
95
- ├── scanner.ts discovers tokens with active lending
68
+ └── index.ts read-only entry point
69
+
70
+ dormant (retained for future release, not imported by index.ts):
71
+ ├── logger.ts — structured logging
72
+ ├── scanner.ts — token discovery
96
73
  ├── wallet-profiler.ts — SAID reputation + trade history
97
74
  ├── risk-scorer.ts — 4-factor risk model
98
- ├── liquidator.ts — executes liquidation txs
99
- ├── monitor.ts — scan + score orchestration
100
- └── index.ts — entry point
75
+ ├── liquidator.ts — liquidation execution
76
+ └── monitor.ts — scan + score orchestration
101
77
  ```
102
78
 
79
+ ## Deprecated (v1.x)
80
+
81
+ The following functionality is preserved in the source files but is not imported or reachable from the entry point. It will be re-enabled in a future version after further security review.
82
+
83
+ - `bot` mode — scan, score, and liquidate positions
84
+ - `watch` mode — monitor loan health + auto-repay
85
+ - `loadConfig()` — wallet keypair decoding
86
+ - `loadWallet()` — private key loading
87
+ - All transaction signing (`sendAndConfirmTransaction`)
88
+ - All SAID Protocol write operations (`confirmTransaction`)
89
+
103
90
  ## Lending Parameters
104
91
 
105
92
  | Parameter | Value |
@@ -116,23 +103,22 @@ Requires [Surfpool](https://github.com/nicholasgasior/surfpool) running a mainne
116
103
 
117
104
  ```bash
118
105
  surfpool start --network mainnet --no-tui
119
- pnpm test # lending lifecycle test
120
- pnpm test:bot # bot module test (scanner, profiler, scorer, liquidator)
106
+ pnpm test # read-only test (default)
107
+ pnpm test:lending # v1.x lending lifecycle test (requires wallet)
108
+ pnpm test:bot # v1.x bot module test (requires wallet)
121
109
  ```
122
110
 
123
111
  ## Security
124
112
 
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
113
+ - No wallet loaded, no keypair decoded, no private key in memory
114
+ - No transaction building, no signing, no state changes
115
+ - Outbound connections: Solana RPC only (no SAID API in active codepath)
116
+ - Distributed via npm no post-install hooks, no remote code fetching
130
117
 
131
118
  ## Links
132
119
 
133
- - [torchsdk](https://github.com/mrsirg97-rgb/torchsdk) -- the SDK this bot is built on
120
+ - [torchsdk](https://github.com/mrsirg97-rgb/torchsdk) -- the SDK this skill reads from
134
121
  - [Torch Market](https://torch.market) -- the protocol
135
- - [SAID Protocol](https://saidprotocol.com) -- wallet reputation layer
136
122
  - [ClawHub](https://clawhub.ai/mrsirg97-rgb/torchliquidationbot) -- skill registry
137
123
 
138
124
  ## License