lpsignal 0.9.0 → 0.11.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.
@@ -0,0 +1,366 @@
1
+ /**
2
+ * Concentrated-liquidity math and the official position-manager calls (Uniswap v3 / PancakeSwap v3
3
+ * NonfungiblePositionManager, Aerodrome / Velodrome Slipstream) — the same code the lpsignal.app web app runs, kept in
4
+ * step with it. Pure: nothing here signs or sends; recipients are always the caller's own address.
5
+ *
6
+ * Math is the pools' own, in integers: TickMath.getSqrtRatioAtTick, LiquidityAmounts, SqrtPriceMath (rounding as the
7
+ * contracts do), and the Uniswap SDK's slippage rule for the minimum amounts.
8
+ */
9
+ import { encodeFunctionData } from 'viem';
10
+ /** position managers per chain and dex — the ones whose factory created the pools we track (src/chains.ts `npms`) */
11
+ export const NPM = {
12
+ ethereum: { uniswap_v3: '0xc36442b4a4522e871399cd717abdd847ab11fe88', pancake_v3: '0x46a15b0b27311cedf172ab29e4f4766fbe7f4364' },
13
+ bsc: { uniswap_v3: '0x7b8a01b39d58278b5de7e48c8449c9f4f5170613', pancake_v3: '0x46a15b0b27311cedf172ab29e4f4766fbe7f4364' },
14
+ base: { uniswap_v3: '0x03a520b32c04bf3beef7beb72e919cf822ed34f1', pancake_v3: '0x46a15b0b27311cedf172ab29e4f4766fbe7f4364', aerodrome_cl: '0x827922686190790b37229fd06084350e74485b72' },
15
+ arbitrum: { uniswap_v3: '0xc36442b4a4522e871399cd717abdd847ab11fe88', pancake_v3: '0x46a15b0b27311cedf172ab29e4f4766fbe7f4364' },
16
+ optimism: { uniswap_v3: '0xc36442b4a4522e871399cd717abdd847ab11fe88', velodrome_cl: '0x416b433906b1b72fa758e166e239c43d68dc6f29' },
17
+ polygon: { uniswap_v3: '0xc36442b4a4522e871399cd717abdd847ab11fe88' },
18
+ };
19
+ export const CHAIN_ID = { ethereum: 1, bsc: 56, base: 8453, arbitrum: 42161, optimism: 10, polygon: 137 };
20
+ /** the wrapped native coin the position managers wrap msg.value into (their WETH9()) */
21
+ export const WRAPPED = {
22
+ ethereum: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', bsc: '0xbb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c', base: '0x4200000000000000000000000000000000000006',
23
+ arbitrum: '0x82af49447d8a07e3bd95bd0d56f35241523fbab1', optimism: '0x4200000000000000000000000000000000000006', polygon: '0x0d500b1d8e8ef31e21c99d1db9a6444d3adf1270',
24
+ };
25
+ export const EXPLORER = {
26
+ ethereum: 'https://etherscan.io', base: 'https://basescan.org', arbitrum: 'https://arbiscan.io', optimism: 'https://optimistic.etherscan.io',
27
+ bsc: 'https://bscscan.com', polygon: 'https://polygonscan.com',
28
+ };
29
+ export const NATIVE_SYMBOL = { ethereum: 'ETH', bsc: 'BNB', base: 'ETH', arbitrum: 'ETH', optimism: 'ETH', polygon: 'POL' };
30
+ /** USDT on Ethereum refuses to change a non-zero allowance to another non-zero one: reset it to 0 first */
31
+ export const ZERO_FIRST = { ethereum: ['0xdac17f958d2ee523a2206206994597c13d831ec7'] };
32
+ export const isSlipstream = (dex) => dex === 'aerodrome_cl' || dex === 'velodrome_cl';
33
+ export function npmOf(chain, dex) {
34
+ return NPM[chain]?.[dex] ?? null;
35
+ }
36
+ // ---- TickMath (Uniswap v3 core, exact) ----
37
+ export const MIN_TICK = -887272;
38
+ export const MAX_TICK = 887272;
39
+ export const MIN_SQRT_RATIO = 4295128739n;
40
+ export const MAX_SQRT_RATIO = 1461446703485210103287273052203988822378723970342n;
41
+ const Q96 = 1n << 96n;
42
+ const MAX_U256 = (1n << 256n) - 1n;
43
+ const RATIOS = [
44
+ [0x2, 0xfff97272373d413259a46990580e213an], [0x4, 0xfff2e50f5f656932ef12357cf3c7fdccn], [0x8, 0xffe5caca7e10e4e61c3624eaa0941cd0n],
45
+ [0x10, 0xffcb9843d60f6159c9db58835c926644n], [0x20, 0xff973b41fa98c081472e6896dfb254c0n], [0x40, 0xff2ea16466c96a3843ec78b326b52861n],
46
+ [0x80, 0xfe5dee046a99a2a811c461f1969c3053n], [0x100, 0xfcbe86c7900a88aedcffc83b479aa3a4n], [0x200, 0xf987a7253ac413176f2b074cf7815e54n],
47
+ [0x400, 0xf3392b0822b70005940c7a398e4b70f3n], [0x800, 0xe7159475a2c29b7443b29c7fa6e889d9n], [0x1000, 0xd097f3bdfd2022b8845ad8f792aa5825n],
48
+ [0x2000, 0xa9f746462d870fdf8a65dc1f90e061e5n], [0x4000, 0x70d869a156d2a1b890bb3df62baf32f7n], [0x8000, 0x31be135f97d08fd981231505542fcfa6n],
49
+ [0x10000, 0x9aa508b5b7a84e1c677de54f3e99bc9n], [0x20000, 0x5d6af8dedb81196699c329225ee604n], [0x40000, 0x2216e584f5fa1ea926041bedfe98n],
50
+ [0x80000, 0x48a170391f7dc42444e8fa2n],
51
+ ];
52
+ export function sqrtRatioAtTick(tick) {
53
+ if (!Number.isInteger(tick) || tick < MIN_TICK || tick > MAX_TICK)
54
+ throw new RangeError(`tick ${tick}`);
55
+ const abs = Math.abs(tick);
56
+ let ratio = abs & 0x1 ? 0xfffcb933bd6fad37aa2d162d1a594001n : 0x100000000000000000000000000000000n;
57
+ for (const [bit, mul] of RATIOS)
58
+ if (abs & bit)
59
+ ratio = (ratio * mul) >> 128n;
60
+ if (tick > 0)
61
+ ratio = MAX_U256 / ratio;
62
+ // Q128.128 → Q64.96, rounding up
63
+ return (ratio >> 32n) + (ratio % (1n << 32n) === 0n ? 0n : 1n);
64
+ }
65
+ // ---- ranges ----
66
+ const LN = Math.log(1.0001);
67
+ /** the full range: the extreme ticks rounded inward to the spacing (the widest legal position) */
68
+ export function fullRange(tickSpacing) {
69
+ const s = Math.max(1, tickSpacing);
70
+ return [Math.ceil(MIN_TICK / s) * s, Math.floor(MAX_TICK / s) * s];
71
+ }
72
+ /** ±rangeBp of price around `tick`, widened outward to the tick grid, always containing the price (0 = full range) — as the backtests */
73
+ export function rangeTicks(tick, rangeBp, tickSpacing) {
74
+ const s = Math.max(1, tickSpacing);
75
+ const [minT, maxT] = fullRange(s);
76
+ if (rangeBp === 0)
77
+ return [minT, maxT];
78
+ const r = rangeBp / 1e4;
79
+ let lo = Math.floor((tick - Math.log(1 + r) / LN) / s) * s;
80
+ let hi = Math.ceil((tick + Math.log(1 + r) / LN) / s) * s;
81
+ if (lo > tick)
82
+ lo = Math.floor(tick / s) * s;
83
+ if (hi <= tick)
84
+ hi = (Math.floor(tick / s) + 1) * s;
85
+ // (|| 0: no -0 from flooring a small negative)
86
+ return [Math.max(lo, minT) || 0, Math.min(hi, maxT) || 0];
87
+ }
88
+ // ---- LiquidityAmounts / SqrtPriceMath ----
89
+ const mulDiv = (a, b, d) => (a * b) / d;
90
+ const mulDivUp = (a, b, d) => { const p = a * b; return p / d + (p % d === 0n ? 0n : 1n); };
91
+ const sort2 = (a, b) => (a > b ? [b, a] : [a, b]);
92
+ function liquidityFor0(sa, sb, amount0) {
93
+ [sa, sb] = sort2(sa, sb);
94
+ return mulDiv(amount0, mulDiv(sa, sb, Q96), sb - sa);
95
+ }
96
+ function liquidityFor1(sa, sb, amount1) {
97
+ [sa, sb] = sort2(sa, sb);
98
+ return mulDiv(amount1, Q96, sb - sa);
99
+ }
100
+ /** the liquidity the position manager mints for these desired amounts (LiquidityAmounts.getLiquidityForAmounts) */
101
+ export function liquidityForAmounts(sp, sa, sb, amount0, amount1) {
102
+ [sa, sb] = sort2(sa, sb);
103
+ if (sp <= sa)
104
+ return liquidityFor0(sa, sb, amount0);
105
+ if (sp < sb) {
106
+ const l0 = liquidityFor0(sp, sb, amount0), l1 = liquidityFor1(sa, sp, amount1);
107
+ return l0 < l1 ? l0 : l1;
108
+ }
109
+ return liquidityFor1(sa, sb, amount1);
110
+ }
111
+ function amount0Delta(sa, sb, l, up) {
112
+ [sa, sb] = sort2(sa, sb);
113
+ const n1 = l << 96n, n2 = sb - sa;
114
+ return up ? (mulDivUp(mulDivUp(n1, n2, sb), 1n, sa)) : mulDiv(n1, n2, sb) / sa;
115
+ }
116
+ function amount1Delta(sa, sb, l, up) {
117
+ [sa, sb] = sort2(sa, sb);
118
+ return up ? mulDivUp(l, sb - sa, Q96) : mulDiv(l, sb - sa, Q96);
119
+ }
120
+ /** the token amounts liquidity `l` takes at price `sp` (rounded up = what a mint pulls; down = what it is worth) */
121
+ export function amountsForLiquidity(sp, sa, sb, l, up) {
122
+ [sa, sb] = sort2(sa, sb);
123
+ if (sp <= sa)
124
+ return [amount0Delta(sa, sb, l, up), 0n];
125
+ if (sp < sb)
126
+ return [amount0Delta(sp, sb, l, up), amount1Delta(sa, sp, l, up)];
127
+ return [0n, amount1Delta(sa, sb, l, up)];
128
+ }
129
+ /**
130
+ * Given one side's amount, the other side the range needs at the current price (0 when the range takes only one
131
+ * token at this price; null when the given side is not used at all there).
132
+ */
133
+ export function otherAmount(side, amount, sp, tickLower, tickUpper) {
134
+ const sa = sqrtRatioAtTick(tickLower), sb = sqrtRatioAtTick(tickUpper);
135
+ if (side === 0 && sp >= sb)
136
+ return null;
137
+ if (side === 1 && sp <= sa)
138
+ return null;
139
+ if (sp <= sa || sp >= sb)
140
+ return 0n;
141
+ const l = side === 0 ? liquidityFor0(sp, sb, amount) : liquidityFor1(sa, sp, amount);
142
+ return amountsForLiquidity(sp, sa, sb, l, true)[side === 0 ? 1 : 0];
143
+ }
144
+ /** which tokens a range takes at this price */
145
+ export function sidesUsed(sp, tickLower, tickUpper) {
146
+ const sa = sqrtRatioAtTick(tickLower), sb = sqrtRatioAtTick(tickUpper);
147
+ return { token0: sp < sb, token1: sp > sa };
148
+ }
149
+ const BPS = 10000n;
150
+ /** isqrt of a non-negative bigint */
151
+ function isqrt(n) {
152
+ if (n < 2n)
153
+ return n;
154
+ let x = BigInt(Math.floor(Math.sqrt(Number(n))));
155
+ while (x * x > n)
156
+ x--;
157
+ while ((x + 1n) * (x + 1n) <= n)
158
+ x++;
159
+ return x;
160
+ }
161
+ /** sqrt price after the price moves by `bps` (signed) — the price is the square: sp * sqrt(1 + bps/1e4) */
162
+ function movedSqrt(sp, bps) {
163
+ const s = (sp * isqrt((BPS + bps) * 10n ** 36n / BPS)) / 10n ** 18n;
164
+ return s < MIN_SQRT_RATIO ? MIN_SQRT_RATIO : s >= MAX_SQRT_RATIO ? MAX_SQRT_RATIO - 1n : s;
165
+ }
166
+ /**
167
+ * The amounts to send for these desired amounts, and the minimums under a price move of up to `slippageBps` before the
168
+ * transaction lands. The position manager re-derives the liquidity from the desired amounts AT THE PRICE IT MEETS, so
169
+ * the minimum of each token is what it would actually take at the worse end of the band — token0 at the upper price,
170
+ * token1 at the lower (each is monotonic in the price) — never the liquidity fixed now valued there (that is higher
171
+ * than what a moved price takes, and would revert a move well inside the tolerance).
172
+ */
173
+ export function mintAmounts(sp, tickLower, tickUpper, desired0, desired1, slippageBps) {
174
+ const sa = sqrtRatioAtTick(tickLower), sb = sqrtRatioAtTick(tickUpper);
175
+ const liquidity = liquidityForAmounts(sp, sa, sb, desired0, desired1);
176
+ const s = BigInt(Math.round(slippageBps));
177
+ if (s < 0n || s >= BPS)
178
+ throw new RangeError('slippage');
179
+ // what minting `liquidity` pulls at the current price (never more than desired)
180
+ const [use0, use1] = amountsForLiquidity(sp, sa, sb, liquidity, true);
181
+ const amount0Desired = use0 < desired0 ? use0 : desired0, amount1Desired = use1 < desired1 ? use1 : desired1;
182
+ const l = liquidityForAmounts(sp, sa, sb, amount0Desired, amount1Desired);
183
+ // what the manager would take at the band's ends (less token0 when the price rises, less token1 when it falls),
184
+ // rounded down below what it really pulls (it rounds up)
185
+ const up = movedSqrt(sp, s), down = movedSqrt(sp, -s);
186
+ const [min0] = amountsForLiquidity(up, sa, sb, liquidityForAmounts(up, sa, sb, amount0Desired, amount1Desired), false);
187
+ const [, min1] = amountsForLiquidity(down, sa, sb, liquidityForAmounts(down, sa, sb, amount0Desired, amount1Desired), false);
188
+ return { liquidity: l, amount0Desired, amount1Desired, amount0Min: min0 < amount0Desired ? min0 : amount0Desired, amount1Min: min1 < amount1Desired ? min1 : amount1Desired };
189
+ }
190
+ // ---- calls ----
191
+ const MINT_V3 = [{
192
+ type: 'function', name: 'mint', stateMutability: 'payable',
193
+ inputs: [{ name: 'params', type: 'tuple', components: [
194
+ { name: 'token0', type: 'address' }, { name: 'token1', type: 'address' }, { name: 'fee', type: 'uint24' },
195
+ { name: 'tickLower', type: 'int24' }, { name: 'tickUpper', type: 'int24' },
196
+ { name: 'amount0Desired', type: 'uint256' }, { name: 'amount1Desired', type: 'uint256' },
197
+ { name: 'amount0Min', type: 'uint256' }, { name: 'amount1Min', type: 'uint256' },
198
+ { name: 'recipient', type: 'address' }, { name: 'deadline', type: 'uint256' },
199
+ ] }],
200
+ outputs: [{ name: 'tokenId', type: 'uint256' }, { name: 'liquidity', type: 'uint128' }, { name: 'amount0', type: 'uint256' }, { name: 'amount1', type: 'uint256' }],
201
+ }];
202
+ const MINT_SLIPSTREAM = [{
203
+ type: 'function', name: 'mint', stateMutability: 'payable',
204
+ inputs: [{ name: 'params', type: 'tuple', components: [
205
+ { name: 'token0', type: 'address' }, { name: 'token1', type: 'address' }, { name: 'tickSpacing', type: 'int24' },
206
+ { name: 'tickLower', type: 'int24' }, { name: 'tickUpper', type: 'int24' },
207
+ { name: 'amount0Desired', type: 'uint256' }, { name: 'amount1Desired', type: 'uint256' },
208
+ { name: 'amount0Min', type: 'uint256' }, { name: 'amount1Min', type: 'uint256' },
209
+ { name: 'recipient', type: 'address' }, { name: 'deadline', type: 'uint256' }, { name: 'sqrtPriceX96', type: 'uint160' },
210
+ ] }],
211
+ outputs: [{ name: 'tokenId', type: 'uint256' }, { name: 'liquidity', type: 'uint128' }, { name: 'amount0', type: 'uint256' }, { name: 'amount1', type: 'uint256' }],
212
+ }];
213
+ const PERIPHERY = [
214
+ { type: 'function', name: 'multicall', stateMutability: 'payable', inputs: [{ name: 'data', type: 'bytes[]' }], outputs: [{ name: 'results', type: 'bytes[]' }] },
215
+ { type: 'function', name: 'refundETH', stateMutability: 'payable', inputs: [], outputs: [] },
216
+ ];
217
+ export const ERC20 = [
218
+ { type: 'function', name: 'approve', stateMutability: 'nonpayable', inputs: [{ name: 'spender', type: 'address' }, { name: 'amount', type: 'uint256' }], outputs: [{ type: 'bool' }] },
219
+ { type: 'function', name: 'allowance', stateMutability: 'view', inputs: [{ name: 'owner', type: 'address' }, { name: 'spender', type: 'address' }], outputs: [{ type: 'uint256' }] },
220
+ { type: 'function', name: 'balanceOf', stateMutability: 'view', inputs: [{ name: 'owner', type: 'address' }], outputs: [{ type: 'uint256' }] },
221
+ ];
222
+ /** the first two fields of slot0 — the same on Uniswap v3, PancakeSwap v3 and Slipstream (the rest differ) */
223
+ export const SLOT0 = [{ type: 'function', name: 'slot0', stateMutability: 'view', inputs: [], outputs: [{ name: 'sqrtPriceX96', type: 'uint160' }, { name: 'tick', type: 'int24' }] }];
224
+ /** the mint transaction (with the native coin: multicall(mint, refundETH) carrying the value) */
225
+ export function mintCall(m) {
226
+ const npm = npmOf(m.chain, m.dex);
227
+ if (!npm)
228
+ throw new Error(`no position manager for ${m.dex} on ${m.chain}`);
229
+ if (!(m.tickLower < m.tickUpper) || m.tickLower % m.tickSpacing !== 0 || m.tickUpper % m.tickSpacing !== 0)
230
+ throw new Error('range not on the tick grid');
231
+ if (m.nativeSide !== null && (m.nativeSide === 0 ? m.token0 : m.token1).toLowerCase() !== WRAPPED[m.chain]?.toLowerCase())
232
+ throw new Error('not the wrapped native token');
233
+ const a = m.amounts;
234
+ const common = {
235
+ token0: m.token0, token1: m.token1, tickLower: m.tickLower, tickUpper: m.tickUpper,
236
+ amount0Desired: a.amount0Desired, amount1Desired: a.amount1Desired, amount0Min: a.amount0Min, amount1Min: a.amount1Min,
237
+ recipient: m.recipient, deadline: m.deadline,
238
+ };
239
+ const mint = isSlipstream(m.dex)
240
+ // sqrtPriceX96 = 0: the pool exists (non-zero would ask the factory to create it, and revert)
241
+ ? encodeFunctionData({ abi: MINT_SLIPSTREAM, functionName: 'mint', args: [{ ...common, tickSpacing: m.tickSpacing, sqrtPriceX96: 0n }] })
242
+ : encodeFunctionData({ abi: MINT_V3, functionName: 'mint', args: [{ ...common, fee: m.fee }] });
243
+ if (m.nativeSide === null)
244
+ return { to: npm, data: mint, value: 0n };
245
+ const value = m.nativeSide === 0 ? a.amount0Desired : a.amount1Desired;
246
+ const refund = encodeFunctionData({ abi: PERIPHERY, functionName: 'refundETH' });
247
+ return { to: npm, data: encodeFunctionData({ abi: PERIPHERY, functionName: 'multicall', args: [[mint, refund]] }), value };
248
+ }
249
+ export function approveCall(token, spender, amount) {
250
+ return { to: token, data: encodeFunctionData({ abi: ERC20, functionName: 'approve', args: [spender, amount] }), value: 0n };
251
+ }
252
+ /** the approvals a mint needs, given the current allowances (exact amounts, never unlimited) */
253
+ export function approvalsNeeded(chain, npm, needs) {
254
+ const out = [];
255
+ for (const n of needs) {
256
+ if (n.amount === 0n || n.allowance >= n.amount)
257
+ continue;
258
+ if (n.allowance > 0n && (ZERO_FIRST[chain] ?? []).includes(n.token.toLowerCase()))
259
+ out.push(approveCall(n.token, npm, 0n));
260
+ out.push(approveCall(n.token, npm, n.amount));
261
+ }
262
+ return out;
263
+ }
264
+ /** token units ⇄ text, exact (no floats) */
265
+ export function parseUnits(text, decimals) {
266
+ const m = /^\s*(\d*)(?:\.(\d*))?\s*$/.exec(text);
267
+ if (!m || (!m[1] && !m[2]))
268
+ return null;
269
+ const frac = (m[2] ?? '');
270
+ if (frac.length > decimals)
271
+ return null;
272
+ return BigInt((m[1] || '0') + frac.padEnd(decimals, '0'));
273
+ }
274
+ export function formatUnits(v, decimals, maxFrac = 6) {
275
+ const neg = v < 0n, a = neg ? -v : v;
276
+ const base = 10n ** BigInt(decimals);
277
+ const int = a / base, frac = (a % base).toString().padStart(decimals, '0').slice(0, maxFrac).replace(/0+$/, '');
278
+ return `${neg ? '-' : ''}${int.toString()}${frac ? `.${frac}` : ''}`;
279
+ }
280
+ /** human price of token0 in token1 at a tick */
281
+ export const priceAtTick = (tick, decimals0, decimals1) => Math.exp(tick * LN) * 10 ** (decimals0 - decimals1);
282
+ /**
283
+ * Everything a mint needs, from the pool's live price and what the user wants to put in: the range (±rangeBp around
284
+ * the price, on the grid), the amounts and minimums, the approvals still missing (for the amounts the user entered,
285
+ * so a re-plan at a fresh price before the mint never needs another one), and the mint itself.
286
+ */
287
+ export function planMint(pool, slot0, input) {
288
+ const npm = npmOf(pool.chain, pool.dex);
289
+ if (!npm)
290
+ throw new Error(`no position manager for ${pool.dex} on ${pool.chain}`);
291
+ const [tickLower, tickUpper] = rangeTicks(slot0.tick, input.rangeBp, pool.tickSpacing);
292
+ const amounts = mintAmounts(slot0.sqrtPriceX96, tickLower, tickUpper, input.desired0, input.desired1, input.slippageBps);
293
+ if (amounts.liquidity === 0n)
294
+ throw new Error('amount too small');
295
+ const approvals = approvalsNeeded(pool.chain, npm, [
296
+ ...(input.nativeSide === 0 ? [] : [{ token: pool.token0, amount: input.desired0, allowance: input.allowance0 }]),
297
+ ...(input.nativeSide === 1 ? [] : [{ token: pool.token1, amount: input.desired1, allowance: input.allowance1 }]),
298
+ ]);
299
+ const mint = mintCall({ ...pool, tickLower, tickUpper, amounts, recipient: input.recipient, deadline: input.deadline, nativeSide: input.nativeSide });
300
+ return { tickLower, tickUpper, amounts, approvals, mint };
301
+ }
302
+ // ---- removing liquidity ----
303
+ const MAX_U128 = (1n << 128n) - 1n;
304
+ /** the position-manager calls for reading and removing a position (the same on Uniswap v3, PancakeSwap v3, Slipstream) */
305
+ export const NPM_READ = [
306
+ { type: 'function', name: 'balanceOf', stateMutability: 'view', inputs: [{ name: 'owner', type: 'address' }], outputs: [{ type: 'uint256' }] },
307
+ { type: 'function', name: 'tokenOfOwnerByIndex', stateMutability: 'view', inputs: [{ name: 'owner', type: 'address' }, { name: 'index', type: 'uint256' }], outputs: [{ type: 'uint256' }] },
308
+ // Uniswap / PancakeSwap: field 4 is the fee; Slipstream: the tick spacing (both fit an int24/uint24 word)
309
+ { type: 'function', name: 'positions', stateMutability: 'view', inputs: [{ name: 'tokenId', type: 'uint256' }], outputs: [
310
+ { name: 'nonce', type: 'uint96' }, { name: 'operator', type: 'address' }, { name: 'token0', type: 'address' }, { name: 'token1', type: 'address' },
311
+ { name: 'feeOrSpacing', type: 'int24' }, { name: 'tickLower', type: 'int24' }, { name: 'tickUpper', type: 'int24' }, { name: 'liquidity', type: 'uint128' },
312
+ { name: 'feeGrowthInside0LastX128', type: 'uint256' }, { name: 'feeGrowthInside1LastX128', type: 'uint256' }, { name: 'tokensOwed0', type: 'uint128' }, { name: 'tokensOwed1', type: 'uint128' },
313
+ ] },
314
+ ];
315
+ const NPM_WRITE = [
316
+ { type: 'function', name: 'decreaseLiquidity', stateMutability: 'payable', inputs: [{ name: 'params', type: 'tuple', components: [
317
+ { name: 'tokenId', type: 'uint256' }, { name: 'liquidity', type: 'uint128' }, { name: 'amount0Min', type: 'uint256' }, { name: 'amount1Min', type: 'uint256' }, { name: 'deadline', type: 'uint256' },
318
+ ] }], outputs: [{ name: 'amount0', type: 'uint256' }, { name: 'amount1', type: 'uint256' }] },
319
+ { type: 'function', name: 'collect', stateMutability: 'payable', inputs: [{ name: 'params', type: 'tuple', components: [
320
+ { name: 'tokenId', type: 'uint256' }, { name: 'recipient', type: 'address' }, { name: 'amount0Max', type: 'uint128' }, { name: 'amount1Max', type: 'uint128' },
321
+ ] }], outputs: [{ name: 'amount0', type: 'uint256' }, { name: 'amount1', type: 'uint256' }] },
322
+ { type: 'function', name: 'multicall', stateMutability: 'payable', inputs: [{ name: 'data', type: 'bytes[]' }], outputs: [{ name: 'results', type: 'bytes[]' }] },
323
+ ];
324
+ export const COLLECT_ABI = NPM_WRITE;
325
+ /** whether a position belongs to this pool (same tokens and fee — Slipstream: tick spacing) */
326
+ export function inPool(pos, pool) {
327
+ return pos.token0.toLowerCase() === pool.token0.toLowerCase() && pos.token1.toLowerCase() === pool.token1.toLowerCase()
328
+ && pos.feeOrSpacing === (isSlipstream(pool.dex) ? pool.tickSpacing : pool.fee);
329
+ }
330
+ /**
331
+ * Taking `share` (basis points of the position, 1..10000) out: the liquidity, what it is worth now, and the minimums
332
+ * under a price move of up to `slippageBps` (each token at its worse price, as the Uniswap SDK's burn rule).
333
+ */
334
+ export function removeAmounts(sp, pos, shareBps, slippageBps) {
335
+ if (!Number.isInteger(shareBps) || shareBps < 1 || shareBps > 10_000)
336
+ throw new RangeError('share');
337
+ const s = BigInt(Math.round(slippageBps));
338
+ if (s < 0n || s >= BPS)
339
+ throw new RangeError('slippage');
340
+ const liquidity = shareBps === 10_000 ? pos.liquidity : (pos.liquidity * BigInt(shareBps)) / BPS;
341
+ const sa = sqrtRatioAtTick(pos.tickLower), sb = sqrtRatioAtTick(pos.tickUpper);
342
+ const [amount0, amount1] = amountsForLiquidity(sp, sa, sb, liquidity, false);
343
+ // a rising price leaves less token0, a falling one less token1
344
+ const [min0] = amountsForLiquidity(movedSqrt(sp, s), sa, sb, liquidity, false);
345
+ const [, min1] = amountsForLiquidity(movedSqrt(sp, -s), sa, sb, liquidity, false);
346
+ return { liquidity, amount0, amount1, amount0Min: min0 < amount0 ? min0 : amount0, amount1Min: min1 < amount1 ? min1 : amount1 };
347
+ }
348
+ /** collect everything owed (fees + what was decreased) to the wallet — the same call simulated shows the uncollected fees */
349
+ export function collectCall(chain, dex, tokenId, recipient) {
350
+ const npm = npmOf(chain, dex);
351
+ if (!npm)
352
+ throw new Error(`no position manager for ${dex} on ${chain}`);
353
+ return { to: npm, data: encodeFunctionData({ abi: NPM_WRITE, functionName: 'collect', args: [{ tokenId, recipient, amount0Max: MAX_U128, amount1Max: MAX_U128 }] }), value: 0n };
354
+ }
355
+ /**
356
+ * One transaction: decrease the liquidity (with minimums and a deadline), then collect it all — principal and fees —
357
+ * to the wallet itself. `liquidity` 0 = fees only (collect).
358
+ */
359
+ export function removeCall(chain, dex, tokenId, amounts, recipient, deadline) {
360
+ const collect = collectCall(chain, dex, tokenId, recipient);
361
+ if (amounts.liquidity === 0n)
362
+ return collect;
363
+ const decrease = encodeFunctionData({ abi: NPM_WRITE, functionName: 'decreaseLiquidity', args: [{ tokenId, liquidity: amounts.liquidity, amount0Min: amounts.amount0Min, amount1Min: amounts.amount1Min, deadline }] });
364
+ return { to: collect.to, data: encodeFunctionData({ abi: NPM_WRITE, functionName: 'multicall', args: [[decrease, collect.data]] }), value: 0n };
365
+ }
366
+ //# sourceMappingURL=core.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"core.js","sourceRoot":"","sources":["../../src/liquidity/core.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAE,kBAAkB,EAA0B,MAAM,MAAM,CAAC;AAIlE,qHAAqH;AACrH,MAAM,CAAC,MAAM,GAAG,GAAoD;IAClE,QAAQ,EAAE,EAAE,UAAU,EAAE,4CAA4C,EAAE,UAAU,EAAE,4CAA4C,EAAE;IAChI,GAAG,EAAE,EAAE,UAAU,EAAE,4CAA4C,EAAE,UAAU,EAAE,4CAA4C,EAAE;IAC3H,IAAI,EAAE,EAAE,UAAU,EAAE,4CAA4C,EAAE,UAAU,EAAE,4CAA4C,EAAE,YAAY,EAAE,4CAA4C,EAAE;IACxL,QAAQ,EAAE,EAAE,UAAU,EAAE,4CAA4C,EAAE,UAAU,EAAE,4CAA4C,EAAE;IAChI,QAAQ,EAAE,EAAE,UAAU,EAAE,4CAA4C,EAAE,YAAY,EAAE,4CAA4C,EAAE;IAClI,OAAO,EAAE,EAAE,UAAU,EAAE,4CAA4C,EAAE;CACtE,CAAC;AACF,MAAM,CAAC,MAAM,QAAQ,GAA2B,EAAE,QAAQ,EAAE,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC;AAClI,wFAAwF;AACxF,MAAM,CAAC,MAAM,OAAO,GAA4B;IAC9C,QAAQ,EAAE,4CAA4C,EAAE,GAAG,EAAE,4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U,UAAU,CAAC,KAAa,EAAE,GAAW,EAAE,OAAe,EAAE,OAAsE,EAAE,SAAkB,EAAE,QAAgB;IAClL,MAAM,OAAO,GAAG,WAAW,CAAC,KAAK,EAAE,GAAG,EAAE,OAAO,EAAE,SAAS,CAAC,CAAC;IAC5D,IAAI,OAAO,CAAC,SAAS,KAAK,EAAE;QAAE,OAAO,OAAO,CAAC;IAC7C,MAAM,QAAQ,GAAG,kBAAkB,CAAC,EAAE,GAAG,EAAE,SAAS,EAAE,YAAY,EAAE,mBAAmB,EAAE,IAAI,EAAE,CAAC,EAAE,OAAO,EAAE,SAAS,EAAE,OAAO,CAAC,SAAS,EAAE,UAAU,EAAE,OAAO,CAAC,UAAU,EAAE,UAAU,EAAE,OAAO,CAAC,UAAU,EAAE,QAAQ,EAAE,CAAC,EAAE,CAAC,CAAC;IACxN,OAAO,EAAE,EAAE,EAAE,OAAO,CAAC,EAAE,EAAE,IAAI,EAAE,kBAAkB,CAAC,EAAE,GAAG,EAAE,SAAS,EAAE,YAAY,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC,CAAC,QAAQ,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC;AAClJ,CAAC"}
@@ -0,0 +1,211 @@
1
+ /**
2
+ * `lpsignal/liquidity` — add and remove concentrated liquidity from your own wallet, on the pools' official position
3
+ * managers (Uniswap v3, PancakeSwap v3, Aerodrome / Velodrome Slipstream): no LPSignal contract, no fee, the position
4
+ * always minted to / collected by your own address. Uses viem (a peer dependency): you pass a PublicClient to read the
5
+ * chain and, to send, your own WalletClient — your keys never reach this SDK.
6
+ *
7
+ * const pool = (await lps.pool('base', '0x…')).pool; // tokens, decimals, fee, tick spacing
8
+ * const plan = await planAddLiquidity(publicClient, pool, { owner, amount0: parseEther('1'), rangeBp: 500 });
9
+ * await sendPlan(walletClient, publicClient, [...plan.approvals, plan.mint]);
10
+ *
11
+ * Never re-send a mint whose receipt you have not seen: a second one would add the same amounts again (sendPlan
12
+ * throws TxPending with the hash instead of guessing).
13
+ *
14
+ * Swapping one pool token for the other (e.g. for the side you are short of) goes through the KyberSwap aggregator with
15
+ * LPSignal's fee (0.25%, 0.05% in stable pools, taken from the input) — planSwap checks every answer of the aggregator
16
+ * against the pool's own price and the calldata it builds, then sendPlan sends it like any other plan.
17
+ */
18
+ import { type Address, type Hex, type PublicClient, type WalletClient } from 'viem';
19
+ import { type Call, type MintPlan, type Position } from './core.js';
20
+ export * from './core.js';
21
+ export * from './swap.js';
22
+ /** a pool as the API returns it (`client.pool(chain, address).pool`) — only these fields are used */
23
+ export interface PoolInfo {
24
+ chain: string;
25
+ address: string;
26
+ dex: string;
27
+ token0: string;
28
+ token1: string;
29
+ decimals0: number;
30
+ decimals1: number;
31
+ fee: number;
32
+ tickSpacing: number;
33
+ pairClass?: string;
34
+ }
35
+ export interface AddOptions {
36
+ /** the wallet that pays and receives the position */
37
+ owner: Address;
38
+ /** what to put in, in raw units; give one side and the other is computed for the range at the current price */
39
+ amount0?: bigint;
40
+ amount1?: bigint;
41
+ /** half-width of the range in basis points of price around the current price (500 = ±5%); 0 = full range */
42
+ rangeBp: number;
43
+ /** the largest price move tolerated before the transaction lands (default 50 = 0.5%) */
44
+ slippageBps?: number;
45
+ /** pay this side in the chain's native coin (it must be the wrapped native token) */
46
+ nativeSide?: 0 | 1 | null;
47
+ /** seconds until the mint expires (default 20 minutes) */
48
+ deadlineS?: number;
49
+ }
50
+ /** a transaction of a plan, bound to the chain and the account it was planned for (sendPlan checks both) */
51
+ export interface PlanCall extends Call {
52
+ chainId: number;
53
+ from: Address;
54
+ }
55
+ export interface AddPlan extends Omit<MintPlan, 'approvals' | 'mint'> {
56
+ approvals: PlanCall[];
57
+ mint: PlanCall;
58
+ amount0: bigint;
59
+ amount1: bigint;
60
+ deadline: number;
61
+ }
62
+ /** the approvals (exact amounts) and the mint for adding liquidity now, read from the chain */
63
+ export declare function planAddLiquidity(client: PublicClient, pool: PoolInfo, o: AddOptions): Promise<AddPlan>;
64
+ export interface WalletPosition extends Position {
65
+ chain: string;
66
+ dex: string;
67
+ npm: Address;
68
+ pool: Address;
69
+ }
70
+ /**
71
+ * The wallet's positions on one chain's position managers that still hold liquidity or fees, each with its pool
72
+ * (from the manager's factory). Positions staked in a Slipstream gauge belong to the gauge and are not listed.
73
+ */
74
+ export declare function positions(client: PublicClient, chain: string, owner: Address): Promise<WalletPosition[]>;
75
+ /** what collecting now would pay (fees owed, incl. those accrued since the last update) */
76
+ export declare function uncollectedFees(client: PublicClient, pos: WalletPosition, owner: Address): Promise<[bigint, bigint]>;
77
+ export interface RemoveOptions {
78
+ owner: Address;
79
+ /** basis points of the position to take out (10000 = all); 0 = collect the fees only */
80
+ shareBps: number;
81
+ slippageBps?: number;
82
+ deadlineS?: number;
83
+ /**
84
+ * the block of your previous removal from this position (sendPlan's result): the position is read at a block at
85
+ * least this new, else StaleRead — a lagging RPC must never return the liquidity from before it (a repeated partial
86
+ * removal would take the original share again)
87
+ */
88
+ minBlock?: bigint;
89
+ }
90
+ /** the RPC is behind a block this plan must see */
91
+ export declare class StaleRead extends Error {
92
+ readonly head: bigint;
93
+ readonly minBlock: bigint;
94
+ constructor(head: bigint, minBlock: bigint);
95
+ }
96
+ export interface RemovePlan {
97
+ call: PlanCall;
98
+ liquidity: bigint;
99
+ amount0: bigint;
100
+ amount1: bigint;
101
+ amount0Min: bigint;
102
+ amount1Min: bigint;
103
+ deadline: number;
104
+ }
105
+ /**
106
+ * One transaction: decrease `shareBps` of what the position holds NOW (read from the chain) and collect it all —
107
+ * principal and fees — to the owner. A repeated partial removal would take that share again: send it once.
108
+ */
109
+ export declare function planRemoveLiquidity(client: PublicClient, pos: WalletPosition, o: RemoveOptions): Promise<RemovePlan>;
110
+ export interface SwapOptions {
111
+ /** the wallet that pays and receives */
112
+ owner: Address;
113
+ /** the pool token paid in (0 = token0, 1 = token1); the other one is bought */
114
+ fromSide: 0 | 1;
115
+ /** how much is paid in, raw units */
116
+ amountIn: bigint;
117
+ /** pay in / receive the chain's native coin instead of that side's wrapped token */
118
+ fromNative?: boolean;
119
+ toNative?: boolean;
120
+ /** the price move tolerated (default 50 = 0.5%) */
121
+ slippageBps?: number;
122
+ /** the least the swap must deliver (e.g. the shortfall it is for): refused (SwapRefused 'moved') below it */
123
+ minOut?: bigint;
124
+ /** seconds until it expires (default 10 minutes): send the plan right away, quotes move */
125
+ deadlineS?: number;
126
+ }
127
+ export interface SwapPlan {
128
+ /** an exact approval of the aggregator's router, if the allowance is short (none for a native input) */
129
+ approvals: PlanCall[];
130
+ swap: PlanCall;
131
+ amountIn: bigint;
132
+ quoteOut: bigint;
133
+ /** what the router guarantees to deliver or it reverts */
134
+ minReturn: bigint;
135
+ /** LPSignal's fee, bps of the input */
136
+ feeBps: number;
137
+ /** simulated from the owner before returning (not when an approval must land first) */
138
+ simulated: boolean;
139
+ deadline: number;
140
+ }
141
+ /**
142
+ * A swap between the pool's two tokens through the KyberSwap aggregator, with LPSignal's fee. The aggregator's answers
143
+ * are checked, never trusted: the quote must be within the allowed impact of the pool's own price (SwapRefused
144
+ * 'impact'), and the calldata is decoded — router, swap() only, tokens, amount, value, recipient = owner, exactly our
145
+ * fee, flags, no permit, the split, and a minimum no lower than the pool-price floor, `minOut` and the quote less the
146
+ * slippage (SwapRefused 'calldata'); then simulated (SwapRefused 'simulation'). The router itself pays at least that
147
+ * minimum or reverts. Send it with sendPlan; a swap's deadline is in calldata nobody can check, so a send of unknown
148
+ * outcome must be resolved by its own transaction before swapping again (sendPlan blocks the account meanwhile).
149
+ */
150
+ export declare function planSwap(client: PublicClient, pool: PoolInfo, o: SwapOptions): Promise<SwapPlan>;
151
+ /** a transaction was sent but its receipt was not seen in time: it may still land — do not send it again blindly */
152
+ export declare class TxPending extends Error {
153
+ readonly hash: Hex;
154
+ constructor(hash: Hex, cause?: unknown);
155
+ }
156
+ /** a transaction that landed and reverted */
157
+ export declare class TxReverted extends Error {
158
+ readonly hash: Hex;
159
+ constructor(hash: Hex);
160
+ }
161
+ /**
162
+ * the wallet failed while sending, without saying whether the transaction went out (no hash): it may have been
163
+ * broadcast. Check whether `nonce` of `from` was used (your wallet's history, or the account's nonce on chain) before
164
+ * sending anything again.
165
+ */
166
+ export declare class TxUnknown extends Error {
167
+ readonly from: Address;
168
+ readonly nonce: number | null;
169
+ /** `nonce` null = the account's nonce manager chose it: check the wallet's history */
170
+ constructor(from: Address, nonce: number | null, cause: unknown);
171
+ }
172
+ /**
173
+ * After a send of unknown outcome (TxUnknown, TxPending) or one replaced in the wallet (TxReplaced) nothing more is sent from that account on that chain in this
174
+ * process until you have checked what became of it and call `unblock` — a queued plan would otherwise read the same
175
+ * nonce and replace or duplicate it.
176
+ */
177
+ export declare class AccountBlocked extends Error {
178
+ readonly chainId: number;
179
+ readonly account: Address;
180
+ readonly reason: Error;
181
+ constructor(chainId: number, account: Address, reason: Error);
182
+ }
183
+ /** you checked the transaction that made sending from this account unsafe: sending may go on */
184
+ export declare function unblock(chainId: number, account: Address): void;
185
+ /** a transaction cancelled or replaced by a different one in the wallet: the plan stops (a speed-up is fine) */
186
+ export declare class TxReplaced extends Error {
187
+ readonly hash: Hex;
188
+ readonly reason: 'cancelled' | 'replaced';
189
+ readonly replacement: Hex;
190
+ constructor(hash: Hex, reason: 'cancelled' | 'replaced', replacement: Hex);
191
+ }
192
+ export interface SendOptions {
193
+ /** how long to wait for each receipt (default 3 min); then TxPending */
194
+ timeoutMs?: number;
195
+ /**
196
+ * also wait until each transaction's block is finalized and still canonical before the next one / returning
197
+ * (recommended before another PARTIAL removal from the same position: a reorg could otherwise drop the first one
198
+ * while the second reads the old liquidity, and both land)
199
+ */
200
+ finalized?: boolean;
201
+ }
202
+ /**
203
+ * Sends a plan's calls in order from your wallet, each after the previous one's receipt (approvals before the mint).
204
+ * Every call must be for the chain and the account the wallet is on (refused otherwise). Returns each one's hash and
205
+ * block (pass the last block as `minBlock` to your next removal from the same position). Throws TxReverted, TxReplaced
206
+ * (cancelled or replaced in the wallet; a speed-up of the same call is accepted), or TxPending if a receipt is not seen.
207
+ */
208
+ export declare function sendPlan(wallet: WalletClient, client: PublicClient, calls: PlanCall[], opts?: SendOptions): Promise<{
209
+ hash: Hex;
210
+ blockNumber: bigint;
211
+ }[]>;