lpsignal 0.9.0 → 0.10.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 +54 -0
- package/README.zh.md +17 -0
- package/dist/liquidity/core.d.ts +361 -0
- package/dist/liquidity/core.js +366 -0
- package/dist/liquidity/core.js.map +1 -0
- package/dist/liquidity/index.d.ts +164 -0
- package/dist/liquidity/index.js +331 -0
- package/dist/liquidity/index.js.map +1 -0
- package/package.json +15 -2
|
@@ -0,0 +1,331 @@
|
|
|
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
|
+
import { defineChain } from 'viem';
|
|
15
|
+
import { CHAIN_ID, COLLECT_ABI, ERC20, isSlipstream, NPM, NPM_READ, otherAmount, planMint, rangeTicks, removeAmounts, removeCall, SLOT0, } from './core.js';
|
|
16
|
+
export * from './core.js';
|
|
17
|
+
const MULTICALL3 = '0xcA11bde05977b3631167028862bE2a173976CA11';
|
|
18
|
+
const DEFAULT_SLIPPAGE_BPS = 50;
|
|
19
|
+
const DEFAULT_DEADLINE_S = 20 * 60;
|
|
20
|
+
function lpPool(p) {
|
|
21
|
+
if (!NPM[p.chain]?.[p.dex])
|
|
22
|
+
throw new Error(`adding liquidity is not supported for ${p.dex} on ${p.chain} (Uniswap v4: use the Uniswap app)`);
|
|
23
|
+
return { chain: p.chain, dex: p.dex, address: p.address, token0: p.token0, token1: p.token1, decimals0: p.decimals0, decimals1: p.decimals1, fee: p.fee, tickSpacing: p.tickSpacing };
|
|
24
|
+
}
|
|
25
|
+
async function assertChain(client, chain) {
|
|
26
|
+
const id = await client.getChainId();
|
|
27
|
+
if (id !== CHAIN_ID[chain])
|
|
28
|
+
throw new Error(`the client is on chain ${id}, the pool on ${chain} (${CHAIN_ID[chain]})`);
|
|
29
|
+
}
|
|
30
|
+
const bind = (c, chain, from) => ({ ...c, chainId: CHAIN_ID[chain], from });
|
|
31
|
+
/** the approvals (exact amounts) and the mint for adding liquidity now, read from the chain */
|
|
32
|
+
export async function planAddLiquidity(client, pool, o) {
|
|
33
|
+
const lp = lpPool(pool);
|
|
34
|
+
await assertChain(client, lp.chain);
|
|
35
|
+
const npm = NPM[lp.chain][lp.dex];
|
|
36
|
+
const [[sqrtPriceX96, tick], allowance0, allowance1] = await Promise.all([
|
|
37
|
+
client.readContract({ address: lp.address, abi: SLOT0, functionName: 'slot0' }),
|
|
38
|
+
client.readContract({ address: lp.token0, abi: ERC20, functionName: 'allowance', args: [o.owner, npm] }),
|
|
39
|
+
client.readContract({ address: lp.token1, abi: ERC20, functionName: 'allowance', args: [o.owner, npm] }),
|
|
40
|
+
]);
|
|
41
|
+
let amount0 = o.amount0, amount1 = o.amount1;
|
|
42
|
+
if (amount0 === undefined && amount1 === undefined)
|
|
43
|
+
throw new Error('give amount0 or amount1');
|
|
44
|
+
const [lo, hi] = rangeTicks(tick, o.rangeBp, lp.tickSpacing);
|
|
45
|
+
if (amount1 === undefined)
|
|
46
|
+
amount1 = otherAmount(0, amount0, sqrtPriceX96, lo, hi) ?? 0n;
|
|
47
|
+
if (amount0 === undefined)
|
|
48
|
+
amount0 = otherAmount(1, amount1, sqrtPriceX96, lo, hi) ?? 0n;
|
|
49
|
+
const deadline = Math.floor(Date.now() / 1000) + (o.deadlineS ?? DEFAULT_DEADLINE_S);
|
|
50
|
+
const plan = planMint(lp, { sqrtPriceX96, tick }, {
|
|
51
|
+
rangeBp: o.rangeBp, desired0: amount0, desired1: amount1, slippageBps: o.slippageBps ?? DEFAULT_SLIPPAGE_BPS, nativeSide: o.nativeSide ?? null,
|
|
52
|
+
recipient: o.owner, deadline: BigInt(deadline), allowance0, allowance1,
|
|
53
|
+
});
|
|
54
|
+
return { ...plan, approvals: plan.approvals.map((c) => bind(c, lp.chain, o.owner)), mint: bind(plan.mint, lp.chain, o.owner), amount0, amount1, deadline };
|
|
55
|
+
}
|
|
56
|
+
/** NFTs read per multicall page */
|
|
57
|
+
const PAGE = 200;
|
|
58
|
+
const FACTORY = [{ type: 'function', name: 'factory', stateMutability: 'view', inputs: [], outputs: [{ type: 'address' }] }];
|
|
59
|
+
const GET_POOL_FEE = [{ type: 'function', name: 'getPool', stateMutability: 'view', inputs: [{ type: 'address' }, { type: 'address' }, { type: 'uint24' }], outputs: [{ type: 'address' }] }];
|
|
60
|
+
const GET_POOL_SPACING = [{ type: 'function', name: 'getPool', stateMutability: 'view', inputs: [{ type: 'address' }, { type: 'address' }, { type: 'int24' }], outputs: [{ type: 'address' }] }];
|
|
61
|
+
/**
|
|
62
|
+
* The wallet's positions on one chain's position managers that still hold liquidity or fees, each with its pool
|
|
63
|
+
* (from the manager's factory). Positions staked in a Slipstream gauge belong to the gauge and are not listed.
|
|
64
|
+
*/
|
|
65
|
+
export async function positions(client, chain, owner) {
|
|
66
|
+
await assertChain(client, chain);
|
|
67
|
+
const out = [];
|
|
68
|
+
// one snapshot for every read: NFTs moving between pages (ERC721Enumerable swaps the last one into a hole) could
|
|
69
|
+
// otherwise hide a live position or fail the walk
|
|
70
|
+
const blockNumber = await client.getBlockNumber({ cacheTime: 0 });
|
|
71
|
+
for (const [dex, npm] of Object.entries(NPM[chain] ?? {})) {
|
|
72
|
+
const n = await client.readContract({ address: npm, abi: NPM_READ, functionName: 'balanceOf', args: [owner], blockNumber });
|
|
73
|
+
if (n === 0n)
|
|
74
|
+
continue;
|
|
75
|
+
// every NFT the wallet holds, a page at a time (emptied positions are never burned: they keep their indexes, so
|
|
76
|
+
// stopping at the first N could hide a live position behind them)
|
|
77
|
+
const readPositions = (part) => client.multicall({ contracts: part.map((id) => ({ address: npm, abi: NPM_READ, functionName: 'positions', args: [id] })), allowFailure: false, multicallAddress: MULTICALL3, blockNumber });
|
|
78
|
+
const ids = [];
|
|
79
|
+
const raw = [];
|
|
80
|
+
for (let from = 0n; from < n; from += BigInt(PAGE)) {
|
|
81
|
+
const count = Number(n - from < BigInt(PAGE) ? n - from : BigInt(PAGE));
|
|
82
|
+
const part = await client.multicall({
|
|
83
|
+
contracts: Array.from({ length: count }, (_, i) => ({ address: npm, abi: NPM_READ, functionName: 'tokenOfOwnerByIndex', args: [owner, from + BigInt(i)] })),
|
|
84
|
+
allowFailure: false, multicallAddress: MULTICALL3, blockNumber,
|
|
85
|
+
});
|
|
86
|
+
ids.push(...part);
|
|
87
|
+
raw.push(...await readPositions(part));
|
|
88
|
+
}
|
|
89
|
+
const live = raw.map((p, i) => ({ id: ids[i], p })).filter(({ p }) => p[7] > 0n || p[10] > 0n || p[11] > 0n);
|
|
90
|
+
if (!live.length)
|
|
91
|
+
continue;
|
|
92
|
+
const factory = await client.readContract({ address: npm, abi: FACTORY, functionName: 'factory', blockNumber });
|
|
93
|
+
const pools = await client.multicall({
|
|
94
|
+
contracts: live.map(({ p }) => (isSlipstream(dex)
|
|
95
|
+
? { address: factory, abi: GET_POOL_SPACING, functionName: 'getPool', args: [p[2], p[3], p[4]] }
|
|
96
|
+
: { address: factory, abi: GET_POOL_FEE, functionName: 'getPool', args: [p[2], p[3], p[4]] })),
|
|
97
|
+
allowFailure: false, multicallAddress: MULTICALL3, blockNumber,
|
|
98
|
+
});
|
|
99
|
+
live.forEach(({ id, p }, i) => out.push({
|
|
100
|
+
chain, dex, npm, pool: pools[i].toLowerCase(),
|
|
101
|
+
tokenId: id, token0: p[2], token1: p[3], feeOrSpacing: p[4], tickLower: p[5], tickUpper: p[6], liquidity: p[7],
|
|
102
|
+
}));
|
|
103
|
+
}
|
|
104
|
+
return out;
|
|
105
|
+
}
|
|
106
|
+
/** what collecting now would pay (fees owed, incl. those accrued since the last update) */
|
|
107
|
+
export async function uncollectedFees(client, pos, owner) {
|
|
108
|
+
const MAX = (1n << 128n) - 1n;
|
|
109
|
+
const { result } = await client.simulateContract({ address: pos.npm, abi: COLLECT_ABI, functionName: 'collect', args: [{ tokenId: pos.tokenId, recipient: owner, amount0Max: MAX, amount1Max: MAX }], account: owner });
|
|
110
|
+
return result;
|
|
111
|
+
}
|
|
112
|
+
/** the RPC is behind a block this plan must see */
|
|
113
|
+
export class StaleRead extends Error {
|
|
114
|
+
head;
|
|
115
|
+
minBlock;
|
|
116
|
+
constructor(head, minBlock) {
|
|
117
|
+
super(`the RPC is at block ${head}, behind ${minBlock}: try again shortly`);
|
|
118
|
+
this.head = head;
|
|
119
|
+
this.minBlock = minBlock;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* One transaction: decrease `shareBps` of what the position holds NOW (read from the chain) and collect it all —
|
|
124
|
+
* principal and fees — to the owner. A repeated partial removal would take that share again: send it once.
|
|
125
|
+
*/
|
|
126
|
+
export async function planRemoveLiquidity(client, pos, o) {
|
|
127
|
+
await assertChain(client, pos.chain);
|
|
128
|
+
const OWNER_OF = [{ type: 'function', name: 'ownerOf', stateMutability: 'view', inputs: [{ type: 'uint256' }], outputs: [{ type: 'address' }] }];
|
|
129
|
+
// one explicit block for every read, no older than the caller's last removal
|
|
130
|
+
const blockNumber = await client.getBlockNumber({ cacheTime: 0 });
|
|
131
|
+
if (o.minBlock !== undefined && blockNumber < o.minBlock)
|
|
132
|
+
throw new StaleRead(blockNumber, o.minBlock);
|
|
133
|
+
const [now, holder, [sqrtPriceX96]] = await Promise.all([
|
|
134
|
+
client.readContract({ address: pos.npm, abi: NPM_READ, functionName: 'positions', args: [pos.tokenId], blockNumber }),
|
|
135
|
+
client.readContract({ address: pos.npm, abi: OWNER_OF, functionName: 'ownerOf', args: [pos.tokenId], blockNumber }),
|
|
136
|
+
client.readContract({ address: pos.pool, abi: SLOT0, functionName: 'slot0', blockNumber }),
|
|
137
|
+
]);
|
|
138
|
+
if (holder.toLowerCase() !== o.owner.toLowerCase())
|
|
139
|
+
throw new Error(`position ${pos.tokenId} is held by ${holder}, not ${o.owner}`);
|
|
140
|
+
const live = { ...pos, liquidity: now[7] };
|
|
141
|
+
const deadline = Math.floor(Date.now() / 1000) + (o.deadlineS ?? DEFAULT_DEADLINE_S);
|
|
142
|
+
const a = o.shareBps === 0 || live.liquidity === 0n
|
|
143
|
+
? { liquidity: 0n, amount0: 0n, amount1: 0n, amount0Min: 0n, amount1Min: 0n }
|
|
144
|
+
: removeAmounts(sqrtPriceX96, live, o.shareBps, o.slippageBps ?? DEFAULT_SLIPPAGE_BPS);
|
|
145
|
+
return { ...a, deadline, call: bind(removeCall(pos.chain, pos.dex, pos.tokenId, a, o.owner, BigInt(deadline)), pos.chain, o.owner) };
|
|
146
|
+
}
|
|
147
|
+
/** a transaction was sent but its receipt was not seen in time: it may still land — do not send it again blindly */
|
|
148
|
+
export class TxPending extends Error {
|
|
149
|
+
hash;
|
|
150
|
+
constructor(hash, cause) {
|
|
151
|
+
super(`transaction ${hash} sent, its outcome not confirmed yet: check it before sending again`, cause === undefined ? undefined : { cause });
|
|
152
|
+
this.hash = hash;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
/** a transaction that landed and reverted */
|
|
156
|
+
export class TxReverted extends Error {
|
|
157
|
+
hash;
|
|
158
|
+
constructor(hash) {
|
|
159
|
+
super(`transaction ${hash} reverted`);
|
|
160
|
+
this.hash = hash;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* the wallet failed while sending, without saying whether the transaction went out (no hash): it may have been
|
|
165
|
+
* broadcast. Check whether `nonce` of `from` was used (your wallet's history, or the account's nonce on chain) before
|
|
166
|
+
* sending anything again.
|
|
167
|
+
*/
|
|
168
|
+
export class TxUnknown extends Error {
|
|
169
|
+
from;
|
|
170
|
+
nonce;
|
|
171
|
+
/** `nonce` null = the account's nonce manager chose it: check the wallet's history */
|
|
172
|
+
constructor(from, nonce, cause) {
|
|
173
|
+
super(`sending from ${from} failed with an unknown outcome (${nonce === null ? 'nonce chosen by your nonce manager' : `nonce ${nonce}`}): check whether it went out before sending again`, { cause });
|
|
174
|
+
this.from = from;
|
|
175
|
+
this.nonce = nonce;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* 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
|
|
180
|
+
* process until you have checked what became of it and call `unblock` — a queued plan would otherwise read the same
|
|
181
|
+
* nonce and replace or duplicate it.
|
|
182
|
+
*/
|
|
183
|
+
export class AccountBlocked extends Error {
|
|
184
|
+
chainId;
|
|
185
|
+
account;
|
|
186
|
+
reason;
|
|
187
|
+
constructor(chainId, account, reason) {
|
|
188
|
+
super(`sending from ${account} on chain ${chainId} is blocked after an unknown outcome (${reason.message}); check it, then call unblock(${chainId}, '${account}')`);
|
|
189
|
+
this.chainId = chainId;
|
|
190
|
+
this.account = account;
|
|
191
|
+
this.reason = reason;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
const blocked = new Map();
|
|
195
|
+
const keyOf = (chainId, account) => `${chainId}:${account.toLowerCase()}`;
|
|
196
|
+
/** you checked the transaction that made sending from this account unsafe: sending may go on */
|
|
197
|
+
export function unblock(chainId, account) { blocked.delete(keyOf(chainId, account)); }
|
|
198
|
+
/** plans of one account on one chain run one after another in this process (they would race for the same nonce) */
|
|
199
|
+
const accountQueues = new Map();
|
|
200
|
+
function inQueue(key, fn) {
|
|
201
|
+
const run = (accountQueues.get(key) ?? Promise.resolve()).then(fn, fn);
|
|
202
|
+
const tail = run.catch(() => undefined);
|
|
203
|
+
accountQueues.set(key, tail);
|
|
204
|
+
void tail.then(() => { if (accountQueues.get(key) === tail)
|
|
205
|
+
accountQueues.delete(key); });
|
|
206
|
+
return run;
|
|
207
|
+
}
|
|
208
|
+
/** a transaction cancelled or replaced by a different one in the wallet: the plan stops (a speed-up is fine) */
|
|
209
|
+
export class TxReplaced extends Error {
|
|
210
|
+
hash;
|
|
211
|
+
reason;
|
|
212
|
+
replacement;
|
|
213
|
+
constructor(hash, reason, replacement) {
|
|
214
|
+
super(`transaction ${hash} was ${reason} by ${replacement}: the plan stopped`);
|
|
215
|
+
this.hash = hash;
|
|
216
|
+
this.reason = reason;
|
|
217
|
+
this.replacement = replacement;
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
/** any failure here (RPC error, receipt gone after a reorg, timeout) is TxPending with the hash: never a bare error */
|
|
221
|
+
/** the user declined in the wallet (EIP-1193 4001 anywhere in the cause chain) */
|
|
222
|
+
function declined(e) {
|
|
223
|
+
for (let x = e, i = 0; x && i < 6; x = x.cause, i++) {
|
|
224
|
+
if (x.code === 4001 || x.name === 'UserRejectedRequestError')
|
|
225
|
+
return true;
|
|
226
|
+
}
|
|
227
|
+
return false;
|
|
228
|
+
}
|
|
229
|
+
async function waitFinal(client, block, hash, timeoutMs = 60 * 60_000, requireSuccess = true) {
|
|
230
|
+
const until = Date.now() + timeoutMs;
|
|
231
|
+
try {
|
|
232
|
+
for (;;) {
|
|
233
|
+
const fin = await client.getBlock({ blockTag: 'finalized' });
|
|
234
|
+
if (fin.number >= block) {
|
|
235
|
+
const rc = await client.getTransactionReceipt({ hash });
|
|
236
|
+
if (rc.blockNumber !== block || (await client.getBlock({ blockNumber: block })).hash !== rc.blockHash)
|
|
237
|
+
throw new TxPending(hash); // reorged: unknown again
|
|
238
|
+
// re-executed after a reorg it may have failed this time: only a final, canonical SUCCESS counts
|
|
239
|
+
if (requireSuccess && rc.status !== 'success')
|
|
240
|
+
throw new TxReverted(hash);
|
|
241
|
+
return;
|
|
242
|
+
}
|
|
243
|
+
if (Date.now() > until)
|
|
244
|
+
throw new TxPending(hash);
|
|
245
|
+
await new Promise((r) => setTimeout(r, 6_000));
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
catch (e) {
|
|
249
|
+
throw e instanceof TxPending || e instanceof TxReverted ? e : new TxPending(hash, e);
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* Sends a plan's calls in order from your wallet, each after the previous one's receipt (approvals before the mint).
|
|
254
|
+
* Every call must be for the chain and the account the wallet is on (refused otherwise). Returns each one's hash and
|
|
255
|
+
* block (pass the last block as `minBlock` to your next removal from the same position). Throws TxReverted, TxReplaced
|
|
256
|
+
* (cancelled or replaced in the wallet; a speed-up of the same call is accepted), or TxPending if a receipt is not seen.
|
|
257
|
+
*/
|
|
258
|
+
export async function sendPlan(wallet, client, calls, opts = {}) {
|
|
259
|
+
if (!wallet.account)
|
|
260
|
+
throw new Error('the wallet client needs an account');
|
|
261
|
+
const account = wallet.account;
|
|
262
|
+
const chainId = calls[0]?.chainId ?? 0, key = keyOf(chainId, account.address);
|
|
263
|
+
return inQueue(key, async () => {
|
|
264
|
+
const why = blocked.get(key);
|
|
265
|
+
if (why)
|
|
266
|
+
throw new AccountBlocked(chainId, account.address, why);
|
|
267
|
+
try {
|
|
268
|
+
return await sendQueued(wallet, client, calls, opts);
|
|
269
|
+
}
|
|
270
|
+
catch (e) {
|
|
271
|
+
// an outcome the caller must look at before anything else goes out from this account
|
|
272
|
+
if (e instanceof TxUnknown || e instanceof TxPending || e instanceof TxReplaced)
|
|
273
|
+
blocked.set(key, e);
|
|
274
|
+
throw e;
|
|
275
|
+
}
|
|
276
|
+
});
|
|
277
|
+
}
|
|
278
|
+
async function sendQueued(wallet, client, calls, opts) {
|
|
279
|
+
if (!wallet.account)
|
|
280
|
+
throw new Error('the wallet client needs an account');
|
|
281
|
+
const sent = [];
|
|
282
|
+
for (const c of calls) {
|
|
283
|
+
const [walletChain, clientChain] = await Promise.all([wallet.getChainId(), client.getChainId()]);
|
|
284
|
+
if (walletChain !== c.chainId || clientChain !== c.chainId)
|
|
285
|
+
throw new Error(`the call is for chain ${c.chainId}; the wallet is on ${walletChain}, the public client on ${clientChain}`);
|
|
286
|
+
if (wallet.account.address.toLowerCase() !== c.from.toLowerCase())
|
|
287
|
+
throw new Error(`the call was planned for ${c.from}, the wallet is ${wallet.account.address}`);
|
|
288
|
+
// the send itself carries the planned chain: viem checks the wallet is on it and signs/sends with that chainId
|
|
289
|
+
const chain = wallet.chain?.id === c.chainId ? wallet.chain : defineChain({ id: c.chainId, name: `chain ${c.chainId}`, nativeCurrency: { name: 'native', symbol: 'native', decimals: 18 }, rpcUrls: { default: { http: [] } } });
|
|
290
|
+
// the nonce: the account's own nonce manager, if it has one (never overridden); otherwise the account's next one,
|
|
291
|
+
// pinned in the transaction so TxUnknown names the one it used (plans of an account are queued, see inQueue)
|
|
292
|
+
const managed = 'nonceManager' in wallet.account && !!wallet.account.nonceManager;
|
|
293
|
+
const nonce = managed ? null : await client.getTransactionCount({ address: c.from, blockTag: 'pending' });
|
|
294
|
+
let hash;
|
|
295
|
+
try {
|
|
296
|
+
hash = await wallet.sendTransaction({ account: wallet.account, chain, to: c.to, data: c.data, value: c.value, ...(nonce === null ? {} : { nonce }) });
|
|
297
|
+
}
|
|
298
|
+
catch (e) {
|
|
299
|
+
if (declined(e))
|
|
300
|
+
throw e; // declined in the wallet: certainly not sent
|
|
301
|
+
throw new TxUnknown(c.from, nonce, e);
|
|
302
|
+
}
|
|
303
|
+
let replaced = null;
|
|
304
|
+
const rc = await client.waitForTransactionReceipt({
|
|
305
|
+
hash, timeout: opts.timeoutMs ?? 180_000,
|
|
306
|
+
// a speed-up (same call, new fee) counts; a cancel or another transaction in its place stops the plan
|
|
307
|
+
onReplaced: (x) => { if (x.reason !== 'repriced')
|
|
308
|
+
replaced = { reason: x.reason, hash: x.transaction.hash }; },
|
|
309
|
+
}).catch(() => null);
|
|
310
|
+
// finalized: the final canonical receipt decides (a first revert may re-run and succeed after a reorg, and the
|
|
311
|
+
// other way round): a resend on a first, unfinal outcome could double the operation
|
|
312
|
+
if (opts.finalized && rc && !replaced) {
|
|
313
|
+
await waitFinal(client, rc.blockNumber, rc.transactionHash);
|
|
314
|
+
sent.push({ hash: rc.transactionHash, blockNumber: rc.blockNumber });
|
|
315
|
+
continue;
|
|
316
|
+
}
|
|
317
|
+
if (replaced && rc && opts.finalized) {
|
|
318
|
+
// the replacement must be final too: a reorg dropping a cancel could let the original run after all
|
|
319
|
+
await waitFinal(client, rc.blockNumber, rc.transactionHash, undefined, false);
|
|
320
|
+
}
|
|
321
|
+
if (replaced)
|
|
322
|
+
throw new TxReplaced(hash, replaced.reason, replaced.hash);
|
|
323
|
+
if (!rc)
|
|
324
|
+
throw new TxPending(hash);
|
|
325
|
+
if (rc.status !== 'success')
|
|
326
|
+
throw new TxReverted(rc.transactionHash);
|
|
327
|
+
sent.push({ hash: rc.transactionHash, blockNumber: rc.blockNumber });
|
|
328
|
+
}
|
|
329
|
+
return sent;
|
|
330
|
+
}
|
|
331
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/liquidity/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,EAAE,WAAW,EAAgE,MAAM,MAAM,CAAC;AACjG,OAAO,EACL,QAAQ,EAAE,WAAW,EAAE,KAAK,EAAE,YAAY,EAAE,GAAG,EAAE,QAAQ,EAAE,WAAW,EAAE,QAAQ,EAAE,UAAU,EAAE,aAAa,EAAE,UAAU,EAAE,KAAK,GAE/H,MAAM,WAAW,CAAC;AAEnB,cAAc,WAAW,CAAC;AAK1B,MAAM,U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IAAI,UAAU,CAAC,IAAI,EAAG,QAAiD,CAAC,MAAM,EAAG,QAA0B,CAAC,IAAI,CAAC,CAAC;QACtI,IAAI,CAAC,EAAE;YAAE,MAAM,IAAI,SAAS,CAAC,IAAI,CAAC,CAAC;QACnC,IAAI,EAAE,CAAC,MAAM,KAAK,SAAS;YAAE,MAAM,IAAI,UAAU,CAAC,EAAE,CAAC,eAAe,CAAC,CAAC;QACtE,IAAI,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,EAAE,CAAC,eAAe,EAAE,WAAW,EAAE,EAAE,CAAC,WAAW,EAAE,CAAC,CAAC;IACvE,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lpsignal",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Official LPSignal SDK: net-of-IL APR signals for concentrated-liquidity pools, a WebSocket stream that never misses a signal, webhook verification and the REST API.",
|
|
3
|
+
"version": "0.10.0",
|
|
4
|
+
"description": "Official LPSignal SDK: net-of-IL APR signals for concentrated-liquidity pools, a WebSocket stream that never misses a signal, webhook verification and the REST API, and adding / removing liquidity from your own wallet (lpsignal/liquidity).",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
7
7
|
"types": "./dist/index.d.ts",
|
|
@@ -9,6 +9,10 @@
|
|
|
9
9
|
".": {
|
|
10
10
|
"types": "./dist/index.d.ts",
|
|
11
11
|
"import": "./dist/index.js"
|
|
12
|
+
},
|
|
13
|
+
"./liquidity": {
|
|
14
|
+
"types": "./dist/liquidity/index.d.ts",
|
|
15
|
+
"import": "./dist/liquidity/index.js"
|
|
12
16
|
}
|
|
13
17
|
},
|
|
14
18
|
"files": [
|
|
@@ -51,6 +55,15 @@
|
|
|
51
55
|
"@types/node": "^22.0.0",
|
|
52
56
|
"@types/ws": "^8.5.12",
|
|
53
57
|
"typescript": "^5.6.0",
|
|
58
|
+
"viem": "^2.57.2",
|
|
54
59
|
"vitest": "^3.2.0"
|
|
60
|
+
},
|
|
61
|
+
"peerDependencies": {
|
|
62
|
+
"viem": "^2.21.0"
|
|
63
|
+
},
|
|
64
|
+
"peerDependenciesMeta": {
|
|
65
|
+
"viem": {
|
|
66
|
+
"optional": true
|
|
67
|
+
}
|
|
55
68
|
}
|
|
56
69
|
}
|