@steerprotocol/liquidity-meter 1.0.0 → 2.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/README.md CHANGED
@@ -4,6 +4,10 @@ Liquidity Depth CLI
4
4
  - Estimate price impact for given USD trade sizes.
5
5
  - Batch over many pools from CSV.
6
6
  - Simulate Steer vault withdrawals on a fork and re-run the analysis “after” to see slippage effects.
7
+ - Published package surface:
8
+ - `@steerprotocol/liquidity-meter` exports pure depth helpers only.
9
+ - `@steerprotocol/liquidity-meter/api` exports `analyzePool`.
10
+ - `@steerprotocol/liquidity-meter/withdraw` exports withdraw simulation helpers.
7
11
 
8
12
  Requirements
9
13
 
@@ -12,20 +16,24 @@ Requirements
12
16
 
13
17
  Install
14
18
 
15
- - Node module consumers (after publish):
16
- - `npm install liquidity-meter`
17
- - ESM-only: import from `liquidity-meter` in Node 18+
18
- - Local (from this repo):
19
+ - From the repo root:
19
20
  - `npm install`
20
- - `npm run generate && npm run build`
21
21
  - `npm link` (optional; installs `liquidity-depth` in your PATH)
22
+ - As a package dependency:
23
+ - `npm install @steerprotocol/liquidity-meter`
22
24
 
23
- ESM Only
25
+ Library Usage
24
26
 
25
- - This package ships ESM only. Use Node 18+ and `import` syntax.
26
- - Exports:
27
- - `import { analyzePool, fetchPoolSnapshotViem, computeMarketDepthBands, simulateVaultWithdraw } from 'liquidity-meter'`
28
- - CLI subpath: `node ./node_modules/liquidity-meter/dist/cli/liquidity-depth.js --help`
27
+ ```js
28
+ import { computeMarketDepthBands } from '@steerprotocol/liquidity-meter';
29
+ import { analyzePool } from '@steerprotocol/liquidity-meter/api';
30
+ import { simulateVaultWithdraw } from '@steerprotocol/liquidity-meter/withdraw';
31
+ ```
32
+
33
+ Breaking Change
34
+
35
+ - `analyzePool` is no longer exported from `@steerprotocol/liquidity-meter`.
36
+ - Migrate root imports to `@steerprotocol/liquidity-meter/api`.
29
37
 
30
38
  Quick Start
31
39
 
@@ -49,9 +57,6 @@ Batch via CSV
49
57
 
50
58
  - Run the CLI over many pools and write a per-pool report:
51
59
  - `liquidity-depth --csv "/path/to/file.csv" --outdir ./reports --rpc <URL>`
52
- - Reliability flags for large batches / flaky providers:
53
- - `--throttle-ms N` add delay between rows and retries
54
- - `--retries N` retry transient JSON-RPC failures (e.g., `-32000`, proof window, `429`)
55
60
  - CSV header expectations:
56
61
  - Pool address: prefer one of `pool`, `address`, `pool_address`, `id` (addresses embedded in URLs are auto-detected).
57
62
  - If no pool address is present, provide `token0`, `token1`, and `fee`, and with `--rpc` the tool will resolve the pool using the Uniswap v3 factory.
@@ -115,8 +120,6 @@ Options (Reference)
115
120
  - `--usd-sizes`: Comma-separated USD sizes for price impact (token1 buys, token0 sells).
116
121
  - `--prices`: `reserve|dexscreener|llama|coingecko|auto` (default: `auto`; env `PRICES_SOURCE`).
117
122
  - `--reserve-limit`: Limit for Reserve API (default: `100`; env `RESERVE_LIMIT`).
118
- - `--throttle-ms`: Delay between CSV rows & retries (ms).
119
- - `--retries`: Retries per row on transient RPC errors (default: `0`).
120
123
  - `--csv`: CSV file with pool/vault rows.
121
124
  - `--outdir`: Output directory (default: `reports`).
122
125
  - `--json` / `-j`: Emit machine-readable JSON.
@@ -141,7 +144,6 @@ Troubleshooting
141
144
  - If owner has 0 vault shares at the forked block, the withdraw step is skipped.
142
145
  - If a vault does not expose `pool()` or withdraw reverts, the run fails for that row only.
143
146
  - Logs: Reports strip noisy EVM logs; use `--debug` for pricing diagnostics.
144
- - zsh/newlines: keep command arguments on a single line (e.g., do not split `--rpc` URL across lines).
145
147
 
146
148
  Examples
147
149
 
@@ -149,49 +151,9 @@ Examples
149
151
  - `liquidity-depth --pool 0x8ad599c3a0ff1de082011efddc58f1908eb6e6d8 --rpc https://mainnet.infura.io/v3/<KEY> --usd-sizes 1000,5000,10000`
150
152
  - Batch CSV:
151
153
  - `liquidity-depth --csv "/path/to/file.csv" --outdir ./reports --rpc https://developer-access-mainnet.base.org --usd-sizes 1000,5000,10000,25000,50000,100000`
152
- - With backoff and retries:
153
- - `liquidity-depth --csv "/path/to/file.csv" --outdir ./reports --rpc https://developer-access-mainnet.base.org --usd-sizes 1000,5000,10000,25000,50000,100000 --throttle-ms 500 --retries 2`
154
154
  - Batch with withdraw simulation for a single owner across all rows:
155
155
  - `OWNER=0xYourOwner liquidity-depth --csv "/path/to/file.csv" --outdir ./reports --rpc https://developer-access-mainnet.base.org --withdraw-pct 25 --usd-sizes 1000,5000,10000`
156
156
 
157
- Programmatic API
158
-
159
- - One-call analysis (before/after) with price inference and optional withdraw simulation:
160
-
161
- ```
162
- import { analyzePool } from 'liquidity-meter'
163
-
164
- const res = await analyzePool({
165
- poolAddress: '0x11e26bbd1a5547895a50fc39a2d4c0025dec0bda',
166
- source: 'tevm', // or 'subgraph' | 'auto'
167
- rpcUrl: 'https://developer-access-mainnet.base.org',
168
- percentBuckets: [1, 2, 5, 10],
169
- usdSizes: [1000, 5000, 10000, 25000],
170
- prices: 'auto', // reserve | dexscreener | llama | coingecko | auto
171
- withdraw: { // optional; TEVM only
172
- vault: '0xYourVault',
173
- owner: '0xYourOwner',
174
- withdrawPct: 25, // or: withdrawShares: '1230000000000000000'
175
- },
176
- })
177
-
178
- console.log(res.before.metrics.depthPlus2USD)
179
- console.log(res.after?.metrics.depthPlus2USD)
180
- ```
181
-
182
- - Lower-level building blocks (for custom flows):
183
-
184
- ```
185
- import {
186
- fetchPoolSnapshotViem, // TEVM on-chain snapshot
187
- fetchPoolSnapshot as fetchFromSubgraph,
188
- computeMarketDepthBands,
189
- computePriceImpactsBySizes,
190
- fetchTokenUSDPrices,
191
- simulateVaultWithdraw, // TEVM withdraw sim
192
- } from 'liquidity-meter'
193
- ```
194
-
195
157
  Notes & Limitations
196
158
 
197
159
  - No transactions are sent to mainnet; all simulations run on a local fork.