@steerprotocol/liquidity-meter 1.0.0 → 2.0.4
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 +27 -56
- package/bin/liquidity-depth.js +795 -0
- package/package.json +42 -32
- package/src/api.js +568 -0
- package/src/depth.js +492 -0
- package/src/index.js +6 -0
- package/src/prices.js +188 -0
- package/src/uniswapv3-subgraph.js +141 -0
- package/src/viem-onchain.js +506 -0
- package/src/withdraw.js +333 -0
- package/templates/README.md +37 -0
- package/templates/pools_minimal.csv +3 -0
- package/templates/pools_with_vault.csv +3 -0
- package/dist/adapters/onchain.d.ts +0 -51
- package/dist/adapters/onchain.js +0 -158
- package/dist/adapters/uniswapv3-subgraph.d.ts +0 -44
- package/dist/adapters/uniswapv3-subgraph.js +0 -105
- package/dist/adapters/withdraw.d.ts +0 -14
- package/dist/adapters/withdraw.js +0 -150
- package/dist/api.d.ts +0 -72
- package/dist/api.js +0 -180
- package/dist/cli/liquidity-depth.d.ts +0 -2
- package/dist/cli/liquidity-depth.js +0 -1160
- package/dist/core/depth.d.ts +0 -48
- package/dist/core/depth.js +0 -314
- package/dist/handlers/cron.d.ts +0 -27
- package/dist/handlers/cron.js +0 -68
- package/dist/index.d.ts +0 -7
- package/dist/index.js +0 -7
- package/dist/prices.d.ts +0 -15
- package/dist/prices.js +0 -205
- package/dist/wagmi/config.d.ts +0 -2106
- package/dist/wagmi/config.js +0 -24
- package/dist/wagmi/generated.d.ts +0 -2019
- package/dist/wagmi/generated.js +0 -346
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,33 @@ Requirements
|
|
|
12
16
|
|
|
13
17
|
Install
|
|
14
18
|
|
|
15
|
-
-
|
|
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
|
-
|
|
25
|
+
Release Workflow
|
|
24
26
|
|
|
25
|
-
-
|
|
26
|
-
-
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
- Releases are automated with `semantic-release` on pushes to `master` or `main`.
|
|
28
|
+
- Commit messages are validated with `commitlint` using the Conventional Commits spec.
|
|
29
|
+
- CI runs unit tests on Node.js 20 and 22, then enforces coverage thresholds on Node.js 22.
|
|
30
|
+
- Required repository secrets:
|
|
31
|
+
- `NPM_TOKEN` for npm publishing.
|
|
32
|
+
- GitHub releases use the default `GITHUB_TOKEN` provided by Actions.
|
|
33
|
+
|
|
34
|
+
Library Usage
|
|
35
|
+
|
|
36
|
+
```js
|
|
37
|
+
import { computeMarketDepthBands } from '@steerprotocol/liquidity-meter';
|
|
38
|
+
import { analyzePool } from '@steerprotocol/liquidity-meter/api';
|
|
39
|
+
import { simulateVaultWithdraw } from '@steerprotocol/liquidity-meter/withdraw';
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
Breaking Change
|
|
43
|
+
|
|
44
|
+
- `analyzePool` is no longer exported from `@steerprotocol/liquidity-meter`.
|
|
45
|
+
- Migrate root imports to `@steerprotocol/liquidity-meter/api`.
|
|
29
46
|
|
|
30
47
|
Quick Start
|
|
31
48
|
|
|
@@ -49,9 +66,6 @@ Batch via CSV
|
|
|
49
66
|
|
|
50
67
|
- Run the CLI over many pools and write a per-pool report:
|
|
51
68
|
- `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
69
|
- CSV header expectations:
|
|
56
70
|
- Pool address: prefer one of `pool`, `address`, `pool_address`, `id` (addresses embedded in URLs are auto-detected).
|
|
57
71
|
- 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 +129,6 @@ Options (Reference)
|
|
|
115
129
|
- `--usd-sizes`: Comma-separated USD sizes for price impact (token1 buys, token0 sells).
|
|
116
130
|
- `--prices`: `reserve|dexscreener|llama|coingecko|auto` (default: `auto`; env `PRICES_SOURCE`).
|
|
117
131
|
- `--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
132
|
- `--csv`: CSV file with pool/vault rows.
|
|
121
133
|
- `--outdir`: Output directory (default: `reports`).
|
|
122
134
|
- `--json` / `-j`: Emit machine-readable JSON.
|
|
@@ -141,7 +153,6 @@ Troubleshooting
|
|
|
141
153
|
- If owner has 0 vault shares at the forked block, the withdraw step is skipped.
|
|
142
154
|
- If a vault does not expose `pool()` or withdraw reverts, the run fails for that row only.
|
|
143
155
|
- 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
156
|
|
|
146
157
|
Examples
|
|
147
158
|
|
|
@@ -149,49 +160,9 @@ Examples
|
|
|
149
160
|
- `liquidity-depth --pool 0x8ad599c3a0ff1de082011efddc58f1908eb6e6d8 --rpc https://mainnet.infura.io/v3/<KEY> --usd-sizes 1000,5000,10000`
|
|
150
161
|
- Batch CSV:
|
|
151
162
|
- `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
163
|
- Batch with withdraw simulation for a single owner across all rows:
|
|
155
164
|
- `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
165
|
|
|
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
166
|
Notes & Limitations
|
|
196
167
|
|
|
197
168
|
- No transactions are sent to mainnet; all simulations run on a local fork.
|