@latchprotocol/widgets 0.1.0 → 0.1.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.
@@ -1,33 +1,33 @@
1
- import { encodeAbiParameters as A, encodeFunctionData as $, isAddressEqual as b, BaseError as J, ExecutionRevertedError as Z, decodeAbiParameters as Le, zeroAddress as Ie, parseUnits as Ae } from "viem";
2
- import { NATIVE_CURRENCY as Ce, quoterAbiFor as Te, isDynamicLPFee as Me, BIN_LAUNCH_GUARD_HOOK_ABI as ee, readBinPoolKeyParameters as te, binRawPriceFromId as ne, poolKeyToId as oe, readCLPoolKeyParameters as Ne, LAUNCHPAD_KIT_V2_ABI as Se, getDeployment as $e, CLOCK_MODE_CALLDATA as Pe, TIMESTAMP_CLOCK_MODE as Be, readContractClock as xe, readTokenMeta as De } from "@latchprotocol/sdk";
3
- import { B as O, b6 as F, A as C, t as j, u as G, p as Q, E as N, w as f, bj as L, P as ie, m as Oe, l as Ee, n as _e, aT as ae, W as E, a4 as Re, bu as Fe, aI as Ge, aJ as se, G as U, _ as qe, bA as Ue, X as re, ae as Ke, aN as Xe, aY as Ye, F as We, b$ as me, bF as P, b9 as He, ao as Ve, ap as je, bx as Qe, bq as ce, aj as ze, bL as Je } from "./scan-Dhu7f4Nl.js";
4
- import { useState as he, useEffect as Ze, useRef as et, useCallback as ue, useMemo as tt } from "react";
5
- import { describeTokenLocks as nt, describeLaunch as ot, summarizeTokenTrust as it, describeLiquidity as at, describeLpFee as st, describeProtocolFee as rt, describeCreatorTax as ye, describeRegistry as ct, formatTrustSource as ut, readTokenTrust as lt } from "@latchprotocol/sdk/trust";
6
- import { readFeeGate as le, readChainNow as dt, readPositionLocksOf as pt, readBeneficiaryLocks as mt } from "@latchprotocol/sdk/lock";
7
- function ht(t, e, o) {
8
- if (t > e)
9
- throw new RangeError(`binIdLower ${t} exceeds binIdUpper ${e}`);
1
+ import { encodeAbiParameters as C, encodeFunctionData as P, isAddressEqual as b, BaseError as J, ExecutionRevertedError as Z, decodeAbiParameters as It, zeroAddress as Lt, parseUnits as Ct } from "viem";
2
+ import { NATIVE_CURRENCY as At, quoterAbiFor as Tt, isDynamicLPFee as Mt, BIN_LAUNCH_GUARD_HOOK_ABI as tt, readBinPoolKeyParameters as et, binRawPriceFromId as nt, poolKeyToId as ot, readCLPoolKeyParameters as Nt, LAUNCHPAD_KIT_V2_ABI as St, getDeployment as Pt, CLOCK_MODE_CALLDATA as $t, TIMESTAMP_CLOCK_MODE as Bt, readContractClock as xt, readTokenMeta as Dt } from "@latchprotocol/sdk";
3
+ import { B as O, b6 as F, A, t as j, u as G, p as Q, E as N, w as f, bj as I, P as it, m as Ot, l as Et, n as _t, aT as at, W as E, a4 as Rt, bu as Ft, aI as Gt, aJ as st, G as U, _ as qt, bA as Ut, X as rt, ae as Kt, aN as Xt, aY as Yt, F as Wt, b$ as mt, bF as $, b9 as Ht, ao as Vt, ap as jt, bx as Qt, bq as ct, aj as zt, bL as Jt } from "./scan-Dhu7f4Nl.js";
4
+ import { useState as ht, useEffect as Zt, useRef as te, useCallback as ut, useMemo as ee } from "react";
5
+ import { describeTokenLocks as ne, describeLaunch as oe, summarizeTokenTrust as ie, describeLiquidity as ae, describeLpFee as se, describeProtocolFee as re, describeCreatorTax as yt, describeRegistry as ce, formatTrustSource as ue, readTokenTrust as le } from "@latchprotocol/sdk/trust";
6
+ import { readFeeGate as lt, readChainNow as de, readPositionLocksOf as pe, readBeneficiaryLocks as me } from "@latchprotocol/sdk/lock";
7
+ function he(e, t, o) {
8
+ if (e > t)
9
+ throw new RangeError(`binIdLower ${e} exceeds binIdUpper ${t}`);
10
10
  const n = [];
11
- for (let p = t; p <= e; p += 1) n.push(p);
12
- const a = n.filter((p) => p >= o).length, i = n.filter((p) => p <= o).length, s = e, r = Math.min(o, e), l = [];
11
+ for (let p = e; p <= t; p += 1) n.push(p);
12
+ const i = n.filter((p) => p >= o).length, a = n.filter((p) => p <= o).length, s = t, r = Math.min(o, t), l = [];
13
13
  let c = 0n, d = 0n;
14
14
  for (const p of n) {
15
- const m = p >= o && a > 0 ? O / BigInt(a) : 0n, u = p <= o && i > 0 ? O / BigInt(i) : 0n, h = p === s && m > 0n ? O - c : m, y = p === r && u > 0n ? O - d : u;
15
+ const m = p >= o && i > 0 ? O / BigInt(i) : 0n, u = p <= o && a > 0 ? O / BigInt(a) : 0n, h = p === s && m > 0n ? O - c : m, y = p === r && u > 0n ? O - d : u;
16
16
  c += h, d += y, l.push({ binId: p, deltaId: p - o, distributionX: h, distributionY: y });
17
17
  }
18
18
  return l;
19
19
  }
20
- class Et extends Error {
20
+ class Ee extends Error {
21
21
  constructor() {
22
22
  super(
23
23
  "[@latchprotocol/widgets] no sale adapter is configured. Latch has no sale contract - a launch is a pool with LaunchGuardHook attached, and buying into one is a swap. Set ProtocolAdapter.sale only if you run your own sale contract."
24
24
  ), this.name = "NoSaleAdapterError";
25
25
  }
26
26
  }
27
- function _t(t) {
28
- return t.sale !== void 0;
27
+ function _e(e) {
28
+ return e.sale !== void 0;
29
29
  }
30
- const yt = [
30
+ const ye = [
31
31
  { name: "poolKey", type: "tuple", components: j },
32
32
  { name: "tickLower", type: "int24" },
33
33
  { name: "tickUpper", type: "int24" },
@@ -36,31 +36,31 @@ const yt = [
36
36
  { name: "amount1Max", type: "uint128" },
37
37
  { name: "owner", type: "address" },
38
38
  { name: "hookData", type: "bytes" }
39
- ], ft = [
39
+ ], fe = [
40
40
  { name: "tokenId", type: "uint256" },
41
41
  { name: "liquidity", type: "uint256" },
42
42
  { name: "amount0", type: "uint128" },
43
43
  { name: "amount1", type: "uint128" },
44
44
  { name: "hookData", type: "bytes" }
45
- ], fe = [
45
+ ], ft = [
46
46
  { name: "currency0", type: "address" },
47
47
  { name: "currency1", type: "address" }
48
- ], ke = [
48
+ ], kt = [
49
49
  { name: "currency0", type: "address" },
50
50
  { name: "currency1", type: "address" },
51
51
  { name: "recipient", type: "address" }
52
- ], kt = [
52
+ ], ke = [
53
53
  { name: "currency", type: "address" },
54
54
  { name: "to", type: "address" }
55
55
  ];
56
- function be() {
56
+ function bt() {
57
57
  return [
58
- C.SWEEP,
59
- A(kt, [Ce, Q]),
58
+ A.SWEEP,
59
+ C(ke, [At, Q]),
60
60
  "sweep unspent native value back to the caller"
61
61
  ];
62
62
  }
63
- const bt = [
63
+ const be = [
64
64
  {
65
65
  name: "params",
66
66
  type: "tuple",
@@ -80,7 +80,7 @@ const bt = [
80
80
  { name: "hookData", type: "bytes" }
81
81
  ]
82
82
  }
83
- ], wt = [
83
+ ], we = [
84
84
  {
85
85
  name: "params",
86
86
  type: "tuple",
@@ -95,180 +95,180 @@ const bt = [
95
95
  ]
96
96
  }
97
97
  ];
98
- function z(t) {
98
+ function z(e) {
99
99
  return {
100
- currency0: t.currency0,
101
- currency1: t.currency1,
102
- hooks: t.hooks,
103
- poolManager: t.poolManager,
104
- fee: t.fee,
105
- parameters: t.parameters
100
+ currency0: e.currency0,
101
+ currency1: e.currency1,
102
+ hooks: e.hooks,
103
+ poolManager: e.poolManager,
104
+ fee: e.fee,
105
+ parameters: e.parameters
106
106
  };
107
107
  }
108
- function gt(t) {
109
- if (At(t.tickLower, t.tickUpper), t.liquidity <= 0n)
110
- throw new RangeError(`[@latchprotocol/widgets] liquidity must be positive: ${t.liquidity}`);
111
- const e = F().add(
112
- C.CL_MINT_POSITION,
113
- A(yt, [
114
- z(t.poolKey),
115
- t.tickLower,
116
- t.tickUpper,
117
- t.liquidity,
118
- t.amount0Max,
119
- t.amount1Max,
120
- t.owner,
121
- t.hookData ?? "0x"
108
+ function ge(e) {
109
+ if (Ce(e.tickLower, e.tickUpper), e.liquidity <= 0n)
110
+ throw new RangeError(`[@latchprotocol/widgets] liquidity must be positive: ${e.liquidity}`);
111
+ const t = F().add(
112
+ A.CL_MINT_POSITION,
113
+ C(ye, [
114
+ z(e.poolKey),
115
+ e.tickLower,
116
+ e.tickUpper,
117
+ e.liquidity,
118
+ e.amount0Max,
119
+ e.amount1Max,
120
+ e.owner,
121
+ e.hookData ?? "0x"
122
122
  ]),
123
- `mint CL position [${t.tickLower}, ${t.tickUpper}]`
123
+ `mint CL position [${e.tickLower}, ${e.tickUpper}]`
124
124
  ).add(
125
- C.SETTLE_PAIR,
126
- A(fe, [t.poolKey.currency0, t.poolKey.currency1]),
125
+ A.SETTLE_PAIR,
126
+ C(ft, [e.poolKey.currency0, e.poolKey.currency1]),
127
127
  "settle both currencies from the caller"
128
128
  );
129
- return (t.value ?? 0n) > 0n && e.add(...be()), {
130
- to: t.positionManager,
131
- data: $({
129
+ return (e.value ?? 0n) > 0n && t.add(...bt()), {
130
+ to: e.positionManager,
131
+ data: P({
132
132
  abi: G,
133
133
  functionName: "modifyLiquidities",
134
- args: [e.encode(), t.deadline]
134
+ args: [t.encode(), e.deadline]
135
135
  }),
136
- value: t.value ?? 0n,
137
- planTrace: e.describe()
136
+ value: e.value ?? 0n,
137
+ planTrace: t.describe()
138
138
  };
139
139
  }
140
- function vt(t) {
141
- if (t.liquidity <= 0n)
140
+ function ve(e) {
141
+ if (e.liquidity <= 0n)
142
142
  throw new RangeError(
143
- `[@latchprotocol/widgets] liquidity to remove must be positive: ${t.liquidity}`
143
+ `[@latchprotocol/widgets] liquidity to remove must be positive: ${e.liquidity}`
144
144
  );
145
- const e = t.recipient === t.owner ? Q : t.recipient, o = F().add(
146
- C.CL_DECREASE_LIQUIDITY,
147
- A(ft, [
148
- t.tokenId,
149
- t.liquidity,
150
- t.amount0Min,
151
- t.amount1Min,
152
- t.hookData ?? "0x"
145
+ const t = e.recipient === e.owner ? Q : e.recipient, o = F().add(
146
+ A.CL_DECREASE_LIQUIDITY,
147
+ C(fe, [
148
+ e.tokenId,
149
+ e.liquidity,
150
+ e.amount0Min,
151
+ e.amount1Min,
152
+ e.hookData ?? "0x"
153
153
  ]),
154
- `decrease CL position #${t.tokenId} by ${t.liquidity}`
154
+ `decrease CL position #${e.tokenId} by ${e.liquidity}`
155
155
  ).add(
156
- C.TAKE_PAIR,
157
- A(ke, [
158
- t.poolKey.currency0,
159
- t.poolKey.currency1,
160
- e
156
+ A.TAKE_PAIR,
157
+ C(kt, [
158
+ e.poolKey.currency0,
159
+ e.poolKey.currency1,
160
+ t
161
161
  ]),
162
162
  "take both currencies to the recipient"
163
163
  );
164
164
  return {
165
- to: t.positionManager,
166
- data: $({
165
+ to: e.positionManager,
166
+ data: P({
167
167
  abi: G,
168
168
  functionName: "modifyLiquidities",
169
- args: [o.encode(), t.deadline]
169
+ args: [o.encode(), e.deadline]
170
170
  }),
171
171
  value: 0n,
172
172
  planTrace: o.describe()
173
173
  };
174
174
  }
175
- function Lt(t) {
176
- const e = t.deltaIds.length;
177
- if (e === 0)
175
+ function Ie(e) {
176
+ const t = e.deltaIds.length;
177
+ if (t === 0)
178
178
  throw new RangeError("[@latchprotocol/widgets] a bin mint must target at least one bin");
179
- if (t.distributionX.length !== e || t.distributionY.length !== e)
179
+ if (e.distributionX.length !== t || e.distributionY.length !== t)
180
180
  throw new RangeError(
181
181
  "[@latchprotocol/widgets] deltaIds, distributionX and distributionY must be the same length"
182
182
  );
183
- if (!Number.isInteger(t.activeIdDesired) || t.activeIdDesired < 0)
183
+ if (!Number.isInteger(e.activeIdDesired) || e.activeIdDesired < 0)
184
184
  throw new RangeError(
185
- `[@latchprotocol/widgets] activeIdDesired must be a non-negative integer: ${t.activeIdDesired}`
185
+ `[@latchprotocol/widgets] activeIdDesired must be a non-negative integer: ${e.activeIdDesired}`
186
186
  );
187
187
  const o = F().add(
188
- C.BIN_ADD_LIQUIDITY,
189
- A(bt, [
188
+ A.BIN_ADD_LIQUIDITY,
189
+ C(be, [
190
190
  {
191
- poolKey: z(t.poolKey),
192
- amount0: t.amount0,
193
- amount1: t.amount1,
194
- amount0Max: t.amount0Max,
195
- amount1Max: t.amount1Max,
196
- activeIdDesired: BigInt(t.activeIdDesired),
197
- idSlippage: BigInt(t.idSlippage),
198
- deltaIds: t.deltaIds.map((n) => BigInt(n)),
199
- distributionX: [...t.distributionX],
200
- distributionY: [...t.distributionY],
191
+ poolKey: z(e.poolKey),
192
+ amount0: e.amount0,
193
+ amount1: e.amount1,
194
+ amount0Max: e.amount0Max,
195
+ amount1Max: e.amount1Max,
196
+ activeIdDesired: BigInt(e.activeIdDesired),
197
+ idSlippage: BigInt(e.idSlippage),
198
+ deltaIds: e.deltaIds.map((n) => BigInt(n)),
199
+ distributionX: [...e.distributionX],
200
+ distributionY: [...e.distributionY],
201
201
  // One entry per bin. Zero means "accept whatever the pool mints"; the
202
202
  // real slippage guard for a bin mint is idSlippage plus amountNMax.
203
- minLiquidities: t.deltaIds.map(() => 0n),
204
- to: t.to,
205
- hookData: t.hookData ?? "0x"
203
+ minLiquidities: e.deltaIds.map(() => 0n),
204
+ to: e.to,
205
+ hookData: e.hookData ?? "0x"
206
206
  }
207
207
  ]),
208
- `add bin liquidity across ${e} bins around id ${t.activeIdDesired}`
208
+ `add bin liquidity across ${t} bins around id ${e.activeIdDesired}`
209
209
  ).add(
210
- C.SETTLE_PAIR,
211
- A(fe, [t.poolKey.currency0, t.poolKey.currency1]),
210
+ A.SETTLE_PAIR,
211
+ C(ft, [e.poolKey.currency0, e.poolKey.currency1]),
212
212
  "settle both currencies from the caller"
213
213
  );
214
- return (t.value ?? 0n) > 0n && o.add(...be()), {
215
- to: t.positionManager,
216
- data: $({
214
+ return (e.value ?? 0n) > 0n && o.add(...bt()), {
215
+ to: e.positionManager,
216
+ data: P({
217
217
  abi: G,
218
218
  functionName: "modifyLiquidities",
219
- args: [o.encode(), t.deadline]
219
+ args: [o.encode(), e.deadline]
220
220
  }),
221
- value: t.value ?? 0n,
221
+ value: e.value ?? 0n,
222
222
  planTrace: o.describe()
223
223
  };
224
224
  }
225
- function It(t) {
226
- if (t.ids.length === 0)
225
+ function Le(e) {
226
+ if (e.ids.length === 0)
227
227
  throw new RangeError("[@latchprotocol/widgets] a bin burn must target at least one bin");
228
- if (t.ids.length !== t.amounts.length)
228
+ if (e.ids.length !== e.amounts.length)
229
229
  throw new RangeError("[@latchprotocol/widgets] ids and amounts must be the same length");
230
- const e = t.recipient === t.from ? Q : t.recipient, o = F().add(
231
- C.BIN_REMOVE_LIQUIDITY,
232
- A(wt, [
230
+ const t = e.recipient === e.from ? Q : e.recipient, o = F().add(
231
+ A.BIN_REMOVE_LIQUIDITY,
232
+ C(we, [
233
233
  {
234
- poolKey: z(t.poolKey),
235
- amount0Min: t.amount0Min,
236
- amount1Min: t.amount1Min,
237
- ids: t.ids.map((n) => BigInt(n)),
238
- amounts: [...t.amounts],
239
- from: t.from,
240
- hookData: t.hookData ?? "0x"
234
+ poolKey: z(e.poolKey),
235
+ amount0Min: e.amount0Min,
236
+ amount1Min: e.amount1Min,
237
+ ids: e.ids.map((n) => BigInt(n)),
238
+ amounts: [...e.amounts],
239
+ from: e.from,
240
+ hookData: e.hookData ?? "0x"
241
241
  }
242
242
  ]),
243
- `remove bin liquidity from ${t.ids.length} bins`
243
+ `remove bin liquidity from ${e.ids.length} bins`
244
244
  ).add(
245
- C.TAKE_PAIR,
246
- A(ke, [
247
- t.poolKey.currency0,
248
- t.poolKey.currency1,
249
- e
245
+ A.TAKE_PAIR,
246
+ C(kt, [
247
+ e.poolKey.currency0,
248
+ e.poolKey.currency1,
249
+ t
250
250
  ]),
251
251
  "take both currencies to the recipient"
252
252
  );
253
253
  return {
254
- to: t.positionManager,
255
- data: $({
254
+ to: e.positionManager,
255
+ data: P({
256
256
  abi: G,
257
257
  functionName: "modifyLiquidities",
258
- args: [o.encode(), t.deadline]
258
+ args: [o.encode(), e.deadline]
259
259
  }),
260
260
  value: 0n,
261
261
  planTrace: o.describe()
262
262
  };
263
263
  }
264
- function At(t, e) {
265
- if (!Number.isInteger(t) || !Number.isInteger(e))
264
+ function Ce(e, t) {
265
+ if (!Number.isInteger(e) || !Number.isInteger(t))
266
266
  throw new RangeError(
267
- `[@latchprotocol/widgets] ticks must be integers: [${t}, ${e}]`
267
+ `[@latchprotocol/widgets] ticks must be integers: [${e}, ${t}]`
268
268
  );
269
- if (t >= e)
269
+ if (e >= t)
270
270
  throw new RangeError(
271
- `[@latchprotocol/widgets] tickLower must be below tickUpper: [${t}, ${e}]`
271
+ `[@latchprotocol/widgets] tickLower must be below tickUpper: [${e}, ${t}]`
272
272
  );
273
273
  }
274
274
  const K = [
@@ -296,7 +296,7 @@ const K = [
296
296
  { name: "lpFee", type: "uint24" }
297
297
  ]
298
298
  }
299
- ], de = 2n ** 192n, _ = [
299
+ ], dt = 2n ** 192n, _ = [
300
300
  {
301
301
  type: "function",
302
302
  name: "getLiquidity",
@@ -335,7 +335,7 @@ const K = [
335
335
  }
336
336
  ]
337
337
  }
338
- ], pe = [
338
+ ], pt = [
339
339
  {
340
340
  type: "function",
341
341
  name: "getBin",
@@ -351,7 +351,7 @@ const K = [
351
351
  { name: "totalShares", type: "uint256" }
352
352
  ]
353
353
  }
354
- ], we = {
354
+ ], wt = {
355
355
  name: "poolKey",
356
356
  type: "tuple",
357
357
  components: [
@@ -376,7 +376,7 @@ const K = [
376
376
  stateMutability: "view",
377
377
  inputs: [{ name: "tokenId", type: "uint256" }],
378
378
  outputs: [
379
- we,
379
+ wt,
380
380
  { name: "tickLower", type: "int24" },
381
381
  { name: "tickUpper", type: "int24" },
382
382
  { name: "liquidity", type: "uint128" },
@@ -400,7 +400,7 @@ const K = [
400
400
  name: "positions",
401
401
  stateMutability: "view",
402
402
  inputs: [{ name: "tokenId", type: "uint256" }],
403
- outputs: [we, { name: "binId", type: "uint24" }]
403
+ outputs: [wt, { name: "binId", type: "uint24" }]
404
404
  },
405
405
  {
406
406
  type: "function",
@@ -424,31 +424,31 @@ const K = [
424
424
  ]
425
425
  }
426
426
  ], S = "0x0000000000000000000000000000000000000000";
427
- class Ct {
427
+ class Ae {
428
428
  kind = "viem";
429
429
  isMock = !1;
430
430
  chain;
431
- #t;
432
- constructor(e) {
433
- this.#t = e, this.chain = e.chain;
431
+ #e;
432
+ constructor(t) {
433
+ this.#e = t, this.chain = t.chain;
434
434
  }
435
- get #e() {
436
- return this.#t.publicClient;
435
+ get #t() {
436
+ return this.#e.publicClient;
437
437
  }
438
438
  get #n() {
439
- return this.#t.overrides ?? {};
439
+ return this.#e.overrides ?? {};
440
440
  }
441
441
  async getAccount() {
442
- const e = this.#t.wallet;
443
- return e === void 0 ? null : e.getAccount();
442
+ const t = this.#e.wallet;
443
+ return t === void 0 ? null : t.getAccount();
444
444
  }
445
445
  async listTokens() {
446
- return this.#t.tokens;
446
+ return this.#e.tokens;
447
447
  }
448
- async getToken(e) {
449
- const o = this.#t.tokens.find((s) => b(s.address, e));
448
+ async getToken(t) {
449
+ const o = this.#e.tokens.find((s) => b(s.address, t));
450
450
  if (o !== void 0) return o;
451
- if (b(e, S))
451
+ if (b(t, S))
452
452
  return {
453
453
  address: S,
454
454
  symbol: this.chain.nativeCurrency.symbol,
@@ -456,45 +456,45 @@ class Ct {
456
456
  decimals: this.chain.nativeCurrency.decimals,
457
457
  isNative: !0
458
458
  };
459
- const [n, a, i] = await Promise.all([
460
- this.#e.readContract({ address: e, abi: N, functionName: "symbol" }),
461
- this.#e.readContract({ address: e, abi: N, functionName: "name" }),
462
- this.#e.readContract({ address: e, abi: N, functionName: "decimals" })
459
+ const [n, i, a] = await Promise.all([
460
+ this.#t.readContract({ address: t, abi: N, functionName: "symbol" }),
461
+ this.#t.readContract({ address: t, abi: N, functionName: "name" }),
462
+ this.#t.readContract({ address: t, abi: N, functionName: "decimals" })
463
463
  ]);
464
- return { address: e, symbol: n, name: a, decimals: Number(i) };
464
+ return { address: t, symbol: n, name: i, decimals: Number(a) };
465
465
  }
466
- async getBalance(e, o) {
467
- return e.isNative === !0 || b(e.address, S) ? this.#e.getBalance({ address: o }) : this.#e.readContract({
468
- address: e.address,
466
+ async getBalance(t, o) {
467
+ return t.isNative === !0 || b(t.address, S) ? this.#t.getBalance({ address: o }) : this.#t.readContract({
468
+ address: t.address,
469
469
  abi: N,
470
470
  functionName: "balanceOf",
471
471
  args: [o]
472
472
  });
473
473
  }
474
474
  async listPools() {
475
- return this.#t.pools;
475
+ return this.#e.pools;
476
476
  }
477
477
  /**
478
478
  * The pool's live state from its manager's `getSlot0` (plus `getLiquidity`
479
479
  * for a CL pool). An uninitialised pool answers a zero price, which is
480
480
  * reported as an error rather than as tick 0.
481
481
  */
482
- async getPoolState(e) {
482
+ async getPoolState(t) {
483
483
  const o = this.#n.getPoolState;
484
- if (o !== void 0) return o(e);
485
- if (e.poolType === "CL") {
486
- const [[a, i], s] = await Promise.all([
487
- this.#e.readContract({ address: e.key.poolManager, abi: K, functionName: "getSlot0", args: [e.id] }),
488
- this.#e.readContract({ address: e.key.poolManager, abi: _, functionName: "getLiquidity", args: [e.id] })
484
+ if (o !== void 0) return o(t);
485
+ if (t.poolType === "CL") {
486
+ const [[i, a], s] = await Promise.all([
487
+ this.#t.readContract({ address: t.key.poolManager, abi: K, functionName: "getSlot0", args: [t.id] }),
488
+ this.#t.readContract({ address: t.key.poolManager, abi: _, functionName: "getLiquidity", args: [t.id] })
489
489
  ]);
490
- if (a === 0n)
491
- throw new f("getPoolState", `pool ${e.id} is not initialised on ${e.key.poolManager}`);
492
- return { poolId: e.id, poolType: "CL", currentTick: i, sqrtPriceX96: a, liquidity: s, source: "live" };
490
+ if (i === 0n)
491
+ throw new f("getPoolState", `pool ${t.id} is not initialised on ${t.key.poolManager}`);
492
+ return { poolId: t.id, poolType: "CL", currentTick: a, sqrtPriceX96: i, liquidity: s, source: "live" };
493
493
  }
494
- const [n] = await this.#e.readContract({ address: e.key.poolManager, abi: X, functionName: "getSlot0", args: [e.id] });
494
+ const [n] = await this.#t.readContract({ address: t.key.poolManager, abi: X, functionName: "getSlot0", args: [t.id] });
495
495
  if (n === 0)
496
- throw new f("getPoolState", `pool ${e.id} is not initialised on ${e.key.poolManager}`);
497
- return { poolId: e.id, poolType: "BIN", activeId: n, source: "live" };
496
+ throw new f("getPoolState", `pool ${t.id} is not initialised on ${t.key.poolManager}`);
497
+ return { poolId: t.id, poolType: "BIN", activeId: n, source: "live" };
498
498
  }
499
499
  /**
500
500
  * The two allowances `spender` needs before it can pull `token` through
@@ -503,55 +503,55 @@ class Ct {
503
503
  * liquidity add; the liquidity hooks pass it, because an allowance to the
504
504
  * router does nothing for a mint.
505
505
  */
506
- async getApprovalRequirements(e, o, n, a) {
507
- if (e.isNative === !0 || b(e.address, S)) return [];
508
- const i = L(this.chain, "permit2", "pull the input token for a swap"), s = a ?? L(this.chain, "universalRouter", "execute a swap"), r = [], l = await this.#e.readContract({
509
- address: e.address,
506
+ async getApprovalRequirements(t, o, n, i) {
507
+ if (t.isNative === !0 || b(t.address, S)) return [];
508
+ const a = I(this.chain, "permit2", "pull the input token for a swap"), s = i ?? I(this.chain, "universalRouter", "execute a swap"), r = [], l = await this.#t.readContract({
509
+ address: t.address,
510
510
  abi: N,
511
511
  functionName: "allowance",
512
- args: [o, i]
512
+ args: [o, a]
513
513
  });
514
514
  l < n && r.push({
515
515
  kind: "erc20-to-permit2",
516
- token: e,
517
- spender: i,
516
+ token: t,
517
+ spender: a,
518
518
  current: l,
519
519
  required: n
520
520
  });
521
- const [c, d] = await this.#e.readContract({
522
- address: i,
523
- abi: ie,
521
+ const [c, d] = await this.#t.readContract({
522
+ address: a,
523
+ abi: it,
524
524
  functionName: "allowance",
525
- args: [o, e.address, s]
525
+ args: [o, t.address, s]
526
526
  }), p = BigInt(Math.floor(Date.now() / 1e3)), m = BigInt(d) !== 0n && BigInt(d) <= p;
527
527
  return (BigInt(c) < n || m) && r.push({
528
528
  kind: "permit2-to-router",
529
- token: e,
529
+ token: t,
530
530
  spender: s,
531
531
  current: m ? 0n : BigInt(c),
532
532
  required: n
533
533
  }), r;
534
534
  }
535
- async buildApproval(e) {
536
- return e.kind === "erc20-to-permit2" ? {
537
- to: e.token.address,
538
- data: $({
535
+ async buildApproval(t) {
536
+ return t.kind === "erc20-to-permit2" ? {
537
+ to: t.token.address,
538
+ data: P({
539
539
  abi: N,
540
540
  functionName: "approve",
541
- args: [e.spender, Oe]
541
+ args: [t.spender, Ot]
542
542
  }),
543
543
  value: 0n,
544
- summary: `Approve ${e.token.symbol} for Permit2`,
544
+ summary: `Approve ${t.token.symbol} for Permit2`,
545
545
  source: "live"
546
546
  } : {
547
- to: L(this.chain, "permit2", "approve the router through Permit2"),
548
- data: $({
549
- abi: ie,
547
+ to: I(this.chain, "permit2", "approve the router through Permit2"),
548
+ data: P({
549
+ abi: it,
550
550
  functionName: "approve",
551
- args: [e.token.address, e.spender, Ee, Number(_e)]
551
+ args: [t.token.address, t.spender, Et, Number(_t)]
552
552
  }),
553
553
  value: 0n,
554
- summary: `Approve ${e.spender} to spend ${e.token.symbol} via Permit2`,
554
+ summary: `Approve ${t.spender} to spend ${t.token.symbol} via Permit2`,
555
555
  source: "live"
556
556
  };
557
557
  }
@@ -569,38 +569,38 @@ class Ct {
569
569
  * Any other dynamic pool is reported `lpFeeUnknown`, which the widget renders
570
570
  * as "dynamic" rather than as a rate it did not read.
571
571
  */
572
- async quoteSwap(e) {
572
+ async quoteSwap(t) {
573
573
  const o = this.#n.quoteSwap;
574
- if (o !== void 0) return o(e, this.#t.pools);
575
- const n = this.chain.contracts, a = this.#t.pools.filter(
576
- (u) => (e.poolId === void 0 || u.id === e.poolId) && (b(u.token0.address, e.tokenIn.address) && b(u.token1.address, e.tokenOut.address) || b(u.token1.address, e.tokenIn.address) && b(u.token0.address, e.tokenOut.address))
574
+ if (o !== void 0) return o(t, this.#e.pools);
575
+ const n = this.chain.contracts, i = this.#e.pools.filter(
576
+ (u) => (t.poolId === void 0 || u.id === t.poolId) && (b(u.token0.address, t.tokenIn.address) && b(u.token1.address, t.tokenOut.address) || b(u.token1.address, t.tokenIn.address) && b(u.token0.address, t.tokenOut.address))
577
577
  );
578
- if (a.length === 0)
578
+ if (i.length === 0)
579
579
  throw new f(
580
580
  "quoteSwap",
581
- e.poolId !== void 0 ? `pool ${e.poolId} is not a configured pool holding both ${e.tokenIn.symbol} and ${e.tokenOut.symbol}.` : `no configured pool holds both ${e.tokenIn.symbol} and ${e.tokenOut.symbol}. This adapter quotes direct pools only; supply \`overrides.quoteSwap\` for multi-hop routes.`
581
+ t.poolId !== void 0 ? `pool ${t.poolId} is not a configured pool holding both ${t.tokenIn.symbol} and ${t.tokenOut.symbol}.` : `no configured pool holds both ${t.tokenIn.symbol} and ${t.tokenOut.symbol}. This adapter quotes direct pools only; supply \`overrides.quoteSwap\` for multi-hop routes.`
582
582
  );
583
- const i = a.filter(
583
+ const a = i.filter(
584
584
  (u) => u.poolType === "CL" ? n.quoter !== void 0 : n.binQuoter !== void 0
585
585
  );
586
- if (i.length === 0)
586
+ if (a.length === 0)
587
587
  throw new f(
588
588
  "quoteSwap",
589
- `a pool for this pair exists but no quoter is configured for its type (${a.map((u) => u.poolType).join(", ")}). Set \`contracts.quoter\` (CL) / \`contracts.binQuoter\` (Bin), or supply \`overrides.quoteSwap\`. This adapter will not estimate a price it cannot verify.`
589
+ `a pool for this pair exists but no quoter is configured for its type (${i.map((u) => u.poolType).join(", ")}). Set \`contracts.quoter\` (CL) / \`contracts.binQuoter\` (Bin), or supply \`overrides.quoteSwap\`. This adapter will not estimate a price it cannot verify.`
590
590
  );
591
591
  const s = await Promise.all(
592
- i.map(async (u) => {
592
+ a.map(async (u) => {
593
593
  const h = u.poolType === "CL" ? n.quoter : n.binQuoter;
594
594
  try {
595
- const { result: y } = await this.#e.simulateContract({
595
+ const { result: y } = await this.#t.simulateContract({
596
596
  address: h,
597
- abi: Te(u.poolType),
597
+ abi: Tt(u.poolType),
598
598
  functionName: "quoteExactInputSingle",
599
599
  args: [
600
600
  {
601
601
  poolKey: u.key,
602
- zeroForOne: b(u.key.currency0, e.tokenIn.address),
603
- exactAmount: e.amountIn,
602
+ zeroForOne: b(u.key.currency0, t.tokenIn.address),
603
+ exactAmount: t.amountIn,
604
604
  hookData: "0x"
605
605
  }
606
606
  ]
@@ -620,26 +620,26 @@ class Ct {
620
620
  }
621
621
  const l = r.reduce((u, h) => h.amountOut > u.amountOut ? h : u), c = l.pool;
622
622
  let d = c.lpFeePips, p = !1;
623
- if (Me(c.lpFeePips)) {
623
+ if (Mt(c.lpFeePips)) {
624
624
  const u = await this.#c(c);
625
625
  u === null ? (d = 0, p = !0) : d = u;
626
626
  }
627
- const m = p ? null : await this.#u(c, e.tokenIn.address, e.amountIn, d);
627
+ const m = p ? null : await this.#u(c, t.tokenIn.address, t.amountIn, d);
628
628
  return {
629
629
  route: [
630
630
  {
631
631
  poolId: c.id,
632
632
  poolType: c.poolType,
633
- tokenIn: e.tokenIn,
634
- tokenOut: e.tokenOut,
633
+ tokenIn: t.tokenIn,
634
+ tokenOut: t.tokenOut,
635
635
  lpFeePips: d,
636
636
  hooks: c.hooks
637
637
  }
638
638
  ],
639
- amountIn: e.amountIn,
639
+ amountIn: t.amountIn,
640
640
  grossAmountOut: l.amountOut,
641
641
  spotAmountOut: m,
642
- lpFeeAmount: e.amountIn * BigInt(d) / 1000000n,
642
+ lpFeeAmount: t.amountIn * BigInt(d) / 1000000n,
643
643
  lpFeePips: d,
644
644
  ...p ? { lpFeeUnknown: p } : {},
645
645
  estimatedGas: l.gasEstimate,
@@ -654,91 +654,91 @@ class Ct {
654
654
  * `CLOCK_MODE`) is thrown: an unreachable RPC is an error state, never a
655
655
  * quote annotated "dynamic".
656
656
  */
657
- async #c(e) {
658
- const o = this.#o(e);
657
+ async #c(t) {
658
+ const o = this.#o(t);
659
659
  if (o === null) return null;
660
- const n = o.poolType === "CL" ? ae(await this.#r(o.hook, "CL")) : ee;
660
+ const n = o.poolType === "CL" ? at(await this.#r(o.hook, "CL")) : tt;
661
661
  try {
662
- const a = await this.#e.readContract({ address: o.hook, abi: n, functionName: "currentFee", args: [e.id] });
663
- return Number(a);
664
- } catch (a) {
665
- if (a instanceof J && a.walk((i) => i instanceof Z) !== null)
662
+ const i = await this.#t.readContract({ address: o.hook, abi: n, functionName: "currentFee", args: [t.id] });
663
+ return Number(i);
664
+ } catch (i) {
665
+ if (i instanceof J && i.walk((a) => a instanceof Z) !== null)
666
666
  return null;
667
- throw a;
667
+ throw i;
668
668
  }
669
669
  }
670
670
  /** The configured launch guard this pool names, if any, with the pool type it serves. */
671
- #o(e) {
671
+ #o(t) {
672
672
  const { launchGuardHook: o, binLaunchGuardHook: n } = this.chain.contracts;
673
- return e.poolType === "CL" && o !== void 0 && b(e.hooks, o) ? { hook: o, poolType: "CL" } : e.poolType === "BIN" && n !== void 0 && b(e.hooks, n) ? { hook: n, poolType: "BIN" } : null;
673
+ return t.poolType === "CL" && o !== void 0 && b(t.hooks, o) ? { hook: o, poolType: "CL" } : t.poolType === "BIN" && n !== void 0 && b(t.hooks, n) ? { hook: n, poolType: "BIN" } : null;
674
674
  }
675
675
  /** `amountIn` priced at the pool's spot from `getSlot0`, less `lpFeePips`; `null` when the read fails. */
676
- async #u(e, o, n, a) {
677
- const i = b(e.key.currency0, o), s = n * BigInt(1e6 - a) / 1000000n;
676
+ async #u(t, o, n, i) {
677
+ const a = b(t.key.currency0, o), s = n * BigInt(1e6 - i) / 1000000n;
678
678
  try {
679
- if (e.poolType === "CL") {
680
- const [m] = await this.#e.readContract({ address: e.key.poolManager, abi: K, functionName: "getSlot0", args: [e.id] });
679
+ if (t.poolType === "CL") {
680
+ const [m] = await this.#t.readContract({ address: t.key.poolManager, abi: K, functionName: "getSlot0", args: [t.id] });
681
681
  if (m === 0n) return null;
682
682
  const u = m * m;
683
- return i ? s * u / de : s * de / u;
683
+ return a ? s * u / dt : s * dt / u;
684
684
  }
685
- const [r] = await this.#e.readContract({ address: e.key.poolManager, abi: X, functionName: "getSlot0", args: [e.id] }), { binStep: l } = te(e.key), c = ne(Number(r), l);
685
+ const [r] = await this.#t.readContract({ address: t.key.poolManager, abi: X, functionName: "getSlot0", args: [t.id] }), { binStep: l } = et(t.key), c = nt(Number(r), l);
686
686
  if (!Number.isFinite(c) || c <= 0) return null;
687
687
  const d = 10n ** 18n, p = BigInt(Math.round(c * 1e18));
688
- return p === 0n ? null : i ? s * p / d : s * d / p;
688
+ return p === 0n ? null : a ? s * p / d : s * d / p;
689
689
  } catch {
690
690
  return null;
691
691
  }
692
692
  }
693
- async buildSwap(e) {
694
- const o = L(this.chain, "universalRouter", "execute a swap"), n = await this.getAccount();
693
+ async buildSwap(t) {
694
+ const o = I(this.chain, "universalRouter", "execute a swap"), n = await this.getAccount();
695
695
  if (n === null) throw new E("build a swap");
696
- const a = this.#l(e), i = Re({
696
+ const i = this.#l(t), a = Rt({
697
697
  router: o,
698
- hops: a,
699
- amountIn: e.amountIn,
700
- minAmountOutGross: e.minAmountOutGross,
701
- minAmountOutNet: e.minAmountOutNet,
702
- expectedAmountOutGross: e.quote.grossAmountOut,
703
- integrator: e.integrator,
704
- recipient: e.recipient,
698
+ hops: i,
699
+ amountIn: t.amountIn,
700
+ minAmountOutGross: t.minAmountOutGross,
701
+ minAmountOutNet: t.minAmountOutNet,
702
+ expectedAmountOutGross: t.quote.grossAmountOut,
703
+ integrator: t.integrator,
704
+ recipient: t.recipient,
705
705
  sender: n,
706
- deadline: e.deadline
706
+ deadline: t.deadline
707
707
  });
708
708
  return {
709
- to: i.to,
710
- data: i.data,
711
- value: i.value,
712
- summary: `Swap ${e.tokenIn.symbol} for ${e.tokenOut.symbol}`,
713
- ...i.integratorFee ? {
709
+ to: a.to,
710
+ data: a.data,
711
+ value: a.value,
712
+ summary: `Swap ${t.tokenIn.symbol} for ${t.tokenOut.symbol}`,
713
+ ...a.integratorFee ? {
714
714
  integratorFee: {
715
- referrer: i.integratorFee.referrer,
716
- feeBps: i.integratorFee.feeBps,
717
- currency: i.integratorFee.currency,
718
- expectedAmount: i.integratorFee.expectedAmount
715
+ referrer: a.integratorFee.referrer,
716
+ feeBps: a.integratorFee.feeBps,
717
+ currency: a.integratorFee.currency,
718
+ expectedAmount: a.integratorFee.expectedAmount
719
719
  }
720
720
  } : {},
721
721
  source: "live"
722
722
  };
723
723
  }
724
- #l(e) {
724
+ #l(t) {
725
725
  const o = this.#n.findRoute;
726
726
  if (o !== void 0)
727
- return o(e.tokenIn, e.tokenOut, this.#t.pools);
727
+ return o(t.tokenIn, t.tokenOut, this.#e.pools);
728
728
  const n = [];
729
- for (const a of e.quote.route) {
730
- const i = this.#t.pools.find((s) => s.id === a.poolId);
731
- if (i === void 0)
729
+ for (const i of t.quote.route) {
730
+ const a = this.#e.pools.find((s) => s.id === i.poolId);
731
+ if (a === void 0)
732
732
  throw new f(
733
733
  "buildSwap",
734
- `the quote routes through pool ${a.poolId}, which is not in the configured pool list`
734
+ `the quote routes through pool ${i.poolId}, which is not in the configured pool list`
735
735
  );
736
736
  n.push({
737
- poolKey: i.key,
738
- poolType: i.poolType,
739
- currencyIn: a.tokenIn.address,
740
- currencyOut: a.tokenOut.address,
741
- ...e.hookData ? { hookData: e.hookData } : {}
737
+ poolKey: a.key,
738
+ poolType: a.poolType,
739
+ currencyIn: i.tokenIn.address,
740
+ currencyOut: i.tokenOut.address,
741
+ ...t.hookData ? { hookData: t.hookData } : {}
742
742
  });
743
743
  }
744
744
  return n;
@@ -749,75 +749,75 @@ class Ct {
749
749
  * (`core/clMath.ts`; `adapters/binDistribution.ts`). The amounts reported
750
750
  * are what the position manager settles: an add rounds towards the pool.
751
751
  */
752
- async quoteAddLiquidity(e) {
752
+ async quoteAddLiquidity(t) {
753
753
  const o = this.#n.quoteAddLiquidity;
754
- if (o !== void 0) return o(e);
755
- const { pool: n, range: a } = e;
756
- if (a.type === "CL") {
754
+ if (o !== void 0) return o(t);
755
+ const { pool: n, range: i } = t;
756
+ if (i.type === "CL") {
757
757
  if (n.poolType !== "CL")
758
758
  throw new f("quoteAddLiquidity", "tick range given for a bin pool");
759
- const h = Fe(n);
760
- if (a.tickLower % h !== 0 || a.tickUpper % h !== 0)
759
+ const h = Ft(n);
760
+ if (i.tickLower % h !== 0 || i.tickUpper % h !== 0)
761
761
  throw new RangeError(
762
- `[@latchprotocol/widgets] ticks must be multiples of the pool's spacing ${h}: [${a.tickLower}, ${a.tickUpper}]`
762
+ `[@latchprotocol/widgets] ticks must be multiples of the pool's spacing ${h}: [${i.tickLower}, ${i.tickUpper}]`
763
763
  );
764
- const y = await this.getPoolState(n), w = y.sqrtPriceX96, k = Ge(
764
+ const y = await this.getPoolState(n), w = y.sqrtPriceX96, k = Gt(
765
765
  w,
766
- se(a.tickLower),
767
- se(a.tickUpper),
768
- e.amount0Desired,
769
- e.amount1Desired
766
+ st(i.tickLower),
767
+ st(i.tickUpper),
768
+ t.amount0Desired,
769
+ t.amount1Desired
770
770
  );
771
771
  if (k === 0n)
772
772
  throw new f(
773
773
  "quoteAddLiquidity",
774
774
  "these amounts mint no liquidity in this range: at the pool's price the range needs the other token, or the amounts are too small"
775
775
  );
776
- const T = U(w, a.tickLower, a.tickUpper, k, !0), B = y.currentTick >= a.tickLower && y.currentTick < a.tickUpper, g = y.liquidity ?? 0n, M = B ? Number(k * 10000n / (g + k)) : null;
777
- return { pool: n, range: a, amount0: T.amount0, amount1: T.amount1, liquidity: k, shareBps: M, source: "live" };
776
+ const T = U(w, i.tickLower, i.tickUpper, k, !0), B = y.currentTick >= i.tickLower && y.currentTick < i.tickUpper, g = y.liquidity ?? 0n, M = B ? Number(k * 10000n / (g + k)) : null;
777
+ return { pool: n, range: i, amount0: T.amount0, amount1: T.amount1, liquidity: k, shareBps: M, source: "live" };
778
778
  }
779
779
  if (n.poolType !== "BIN")
780
780
  throw new f("quoteAddLiquidity", "bin range given for a CL pool");
781
781
  const s = (await this.getPoolState(n)).activeId;
782
- if (Math.abs(s - a.activeIdDesired) > a.idSlippage)
782
+ if (Math.abs(s - i.activeIdDesired) > i.idSlippage)
783
783
  throw new f(
784
784
  "quoteAddLiquidity",
785
- `the active bin is ${s}, more than ${a.idSlippage} bins from the ${a.activeIdDesired} the range was built around; rebuild the range`
785
+ `the active bin is ${s}, more than ${i.idSlippage} bins from the ${i.activeIdDesired} the range was built around; rebuild the range`
786
786
  );
787
- const r = ht(a.binIdLower, a.binIdUpper, a.activeIdDesired), l = r.some((h) => h.distributionX > 0n), c = r.some((h) => h.distributionY > 0n), d = l ? e.amount0Desired : 0n, p = c ? e.amount1Desired : 0n;
787
+ const r = he(i.binIdLower, i.binIdUpper, i.activeIdDesired), l = r.some((h) => h.distributionX > 0n), c = r.some((h) => h.distributionY > 0n), d = l ? t.amount0Desired : 0n, p = c ? t.amount1Desired : 0n;
788
788
  if (d + p === 0n)
789
789
  throw new f(
790
790
  "quoteAddLiquidity",
791
791
  "nothing to deposit: the chosen bins take only the token whose amount is zero"
792
792
  );
793
- const m = qe(n);
793
+ const m = qt(n);
794
794
  let u = 0n;
795
795
  for (const h of r) {
796
- const y = d * h.distributionX / 10n ** 18n, w = p * h.distributionY / 10n ** 18n, k = ne(h.binId, m);
796
+ const y = d * h.distributionX / 10n ** 18n, w = p * h.distributionY / 10n ** 18n, k = nt(h.binId, m);
797
797
  u += BigInt(Math.floor(Number(y) * k)) + w;
798
798
  }
799
- return { pool: n, range: a, amount0: d, amount1: p, liquidity: u, shareBps: null, binDistribution: r, source: "live" };
799
+ return { pool: n, range: i, amount0: d, amount1: p, liquidity: u, shareBps: null, binDistribution: r, source: "live" };
800
800
  }
801
- async buildAddLiquidity(e) {
801
+ async buildAddLiquidity(t) {
802
802
  if (await this.getAccount() === null) throw new E("add liquidity");
803
- const { quote: n } = e, a = this.#d(n.pool, e.amount0Max, e.amount1Max);
803
+ const { quote: n } = t, i = this.#d(n.pool, t.amount0Max, t.amount1Max);
804
804
  if (n.range.type === "CL") {
805
- const l = L(
805
+ const l = I(
806
806
  this.chain,
807
807
  "clPositionManager",
808
808
  "mint a concentrated-liquidity position"
809
- ), c = gt({
809
+ ), c = ge({
810
810
  positionManager: l,
811
811
  poolKey: n.pool.key,
812
812
  tickLower: n.range.tickLower,
813
813
  tickUpper: n.range.tickUpper,
814
814
  liquidity: n.liquidity,
815
- amount0Max: e.amount0Max,
816
- amount1Max: e.amount1Max,
817
- owner: e.recipient,
818
- deadline: e.deadline,
819
- value: a,
820
- ...e.hookData ? { hookData: e.hookData } : {}
815
+ amount0Max: t.amount0Max,
816
+ amount1Max: t.amount1Max,
817
+ owner: t.recipient,
818
+ deadline: t.deadline,
819
+ value: i,
820
+ ...t.hookData ? { hookData: t.hookData } : {}
821
821
  });
822
822
  return {
823
823
  to: c.to,
@@ -827,7 +827,7 @@ class Ct {
827
827
  source: "live"
828
828
  };
829
829
  }
830
- const i = L(
830
+ const a = I(
831
831
  this.chain,
832
832
  "binPositionManager",
833
833
  "add liquidity to a bin pool"
@@ -837,22 +837,22 @@ class Ct {
837
837
  "buildAddLiquidity",
838
838
  "a bin mint needs a per-bin distribution; the quote did not supply one"
839
839
  );
840
- const r = Lt({
841
- positionManager: i,
840
+ const r = Ie({
841
+ positionManager: a,
842
842
  poolKey: n.pool.key,
843
843
  amount0: n.amount0,
844
844
  amount1: n.amount1,
845
- amount0Max: e.amount0Max,
846
- amount1Max: e.amount1Max,
845
+ amount0Max: t.amount0Max,
846
+ amount1Max: t.amount1Max,
847
847
  activeIdDesired: n.range.activeIdDesired,
848
848
  idSlippage: n.range.idSlippage,
849
849
  deltaIds: s.map((l) => l.deltaId),
850
850
  distributionX: s.map((l) => l.distributionX),
851
851
  distributionY: s.map((l) => l.distributionY),
852
- to: e.recipient,
853
- deadline: e.deadline,
854
- value: a,
855
- ...e.hookData ? { hookData: e.hookData } : {}
852
+ to: t.recipient,
853
+ deadline: t.deadline,
854
+ value: i,
855
+ ...t.hookData ? { hookData: t.hookData } : {}
856
856
  });
857
857
  return {
858
858
  to: r.to,
@@ -862,8 +862,8 @@ class Ct {
862
862
  source: "live"
863
863
  };
864
864
  }
865
- #d(e, o, n) {
866
- return b(e.token0.address, S) ? o : b(e.token1.address, S) ? n : 0n;
865
+ #d(t, o, n) {
866
+ return b(t.token0.address, S) ? o : b(t.token1.address, S) ? n : 0n;
867
867
  }
868
868
  /**
869
869
  * A holder's positions, reconstructed from position-manager logs and
@@ -877,52 +877,52 @@ class Ct {
877
877
  * reserves and share supply. A position on a pool not in the configured
878
878
  * list still appears, with its tokens read off their contracts.
879
879
  */
880
- async listPositions(e, o) {
880
+ async listPositions(t, o) {
881
881
  const n = this.#n.listPositions;
882
- if (n !== void 0) return n(e, o);
883
- const a = this.#t.positionsFromBlock;
884
- if (a === void 0)
882
+ if (n !== void 0) return n(t, o);
883
+ const i = this.#e.positionsFromBlock;
884
+ if (i === void 0)
885
885
  throw new f(
886
886
  "listPositions",
887
887
  "position enumeration scans the position managers' transfer logs and needs `positionsFromBlock` (the block they were deployed at) in the adapter options."
888
888
  );
889
- const i = o?.poolType, [s, r] = await Promise.all([
890
- i === "BIN" ? Promise.resolve([]) : this.#p(e, a, o),
891
- i === "CL" ? Promise.resolve([]) : this.#m(e, a, o)
889
+ const a = o?.poolType, [s, r] = await Promise.all([
890
+ a === "BIN" ? Promise.resolve([]) : this.#p(t, i, o),
891
+ a === "CL" ? Promise.resolve([]) : this.#m(t, i, o)
892
892
  ]);
893
893
  return [...s, ...r];
894
894
  }
895
- async #p(e, o, n) {
896
- const a = this.chain.contracts.clPositionManager;
897
- if (a === void 0) return [];
898
- const i = await this.#e.getLogs({
899
- address: a,
895
+ async #p(t, o, n) {
896
+ const i = this.chain.contracts.clPositionManager;
897
+ if (i === void 0) return [];
898
+ const a = await this.#t.getLogs({
899
+ address: i,
900
900
  event: Y[2],
901
- args: { to: e },
901
+ args: { to: t },
902
902
  fromBlock: o,
903
903
  toBlock: "latest"
904
- }), s = [...new Set(i.map((l) => l.args.id))], r = [];
904
+ }), s = [...new Set(a.map((l) => l.args.id))], r = [];
905
905
  for (const l of s) {
906
906
  let c;
907
907
  try {
908
- c = await this.#e.readContract({ address: a, abi: Y, functionName: "ownerOf", args: [l] });
908
+ c = await this.#t.readContract({ address: i, abi: Y, functionName: "ownerOf", args: [l] });
909
909
  } catch {
910
910
  continue;
911
911
  }
912
- if (!b(c, e)) continue;
913
- const [d, p, m, u, h, y] = await this.#e.readContract({
914
- address: a,
912
+ if (!b(c, t)) continue;
913
+ const [d, p, m, u, h, y] = await this.#t.readContract({
914
+ address: i,
915
915
  abi: Y,
916
916
  functionName: "positions",
917
917
  args: [l]
918
918
  }), w = await this.#a(d, "CL", n);
919
919
  if (w === null) continue;
920
920
  const [[k, T], [B, g], M, q] = await Promise.all([
921
- this.#e.readContract({ address: d.poolManager, abi: K, functionName: "getSlot0", args: [w.id] }),
922
- this.#e.readContract({ address: d.poolManager, abi: _, functionName: "getFeeGrowthGlobals", args: [w.id] }),
923
- this.#e.readContract({ address: d.poolManager, abi: _, functionName: "getPoolTickInfo", args: [w.id, p] }),
924
- this.#e.readContract({ address: d.poolManager, abi: _, functionName: "getPoolTickInfo", args: [w.id, m] })
925
- ]), D = U(k, p, m, u, !1), x = Ue({
921
+ this.#t.readContract({ address: d.poolManager, abi: K, functionName: "getSlot0", args: [w.id] }),
922
+ this.#t.readContract({ address: d.poolManager, abi: _, functionName: "getFeeGrowthGlobals", args: [w.id] }),
923
+ this.#t.readContract({ address: d.poolManager, abi: _, functionName: "getPoolTickInfo", args: [w.id, p] }),
924
+ this.#t.readContract({ address: d.poolManager, abi: _, functionName: "getPoolTickInfo", args: [w.id, m] })
925
+ ]), D = U(k, p, m, u, !1), x = Ut({
926
926
  liquidity: u,
927
927
  tickLower: p,
928
928
  tickUpper: m,
@@ -950,36 +950,36 @@ class Ct {
950
950
  }
951
951
  return r;
952
952
  }
953
- async #m(e, o, n) {
954
- const a = this.chain.contracts.binPositionManager;
955
- if (a === void 0) return [];
956
- const i = await this.#e.getLogs({
957
- address: a,
953
+ async #m(t, o, n) {
954
+ const i = this.chain.contracts.binPositionManager;
955
+ if (i === void 0) return [];
956
+ const a = await this.#t.getLogs({
957
+ address: i,
958
958
  event: W[2],
959
- args: { to: e },
959
+ args: { to: t },
960
960
  fromBlock: o,
961
961
  toBlock: "latest"
962
- }), s = [...new Set(i.flatMap((c) => c.args.ids ?? []))], r = /* @__PURE__ */ new Map();
962
+ }), s = [...new Set(a.flatMap((c) => c.args.ids ?? []))], r = /* @__PURE__ */ new Map();
963
963
  for (const c of s) {
964
- const d = await this.#e.readContract({ address: a, abi: W, functionName: "balanceOf", args: [e, c] });
964
+ const d = await this.#t.readContract({ address: i, abi: W, functionName: "balanceOf", args: [t, c] });
965
965
  if (d === 0n) continue;
966
- const [p, m] = await this.#e.readContract({ address: a, abi: W, functionName: "positions", args: [c] }), u = oe(p), h = r.get(u) ?? { key: p, bins: [] };
966
+ const [p, m] = await this.#t.readContract({ address: i, abi: W, functionName: "positions", args: [c] }), u = ot(p), h = r.get(u) ?? { key: p, bins: [] };
967
967
  h.bins.push({ binId: m, shares: d }), r.set(u, h);
968
968
  }
969
969
  const l = [];
970
970
  for (const [c, { key: d, bins: p }] of r) {
971
971
  const m = await this.#a(d, "BIN", n);
972
972
  if (m === null) continue;
973
- const [u] = await this.#e.readContract({ address: d.poolManager, abi: X, functionName: "getSlot0", args: [c] });
973
+ const [u] = await this.#t.readContract({ address: d.poolManager, abi: X, functionName: "getSlot0", args: [c] });
974
974
  let h = 0n, y = 0n, w = 0n;
975
975
  const k = [...p].sort((g, M) => g.binId - M.binId);
976
976
  for (const g of k) {
977
- const [M, q, , D] = await this.#e.readContract({
977
+ const [M, q, , D] = await this.#t.readContract({
978
978
  address: d.poolManager,
979
- abi: pe,
979
+ abi: pt,
980
980
  functionName: "getBin",
981
981
  args: [c, g.binId]
982
- }), x = re({ shares: g.shares, totalShares: D, reserveX: M, reserveY: q });
982
+ }), x = rt({ shares: g.shares, totalShares: D, reserveX: M, reserveY: q });
983
983
  h += x.amount0, y += x.amount1, w += g.shares;
984
984
  }
985
985
  const T = k[0], B = k[k.length - 1];
@@ -1005,15 +1005,15 @@ class Ct {
1005
1005
  * listed, else one built from the key with both tokens read off their
1006
1006
  * contracts. `null` when `only` names a different pool.
1007
1007
  */
1008
- async #a(e, o, n) {
1009
- const a = oe(e);
1010
- if (n !== void 0) return n.id.toLowerCase() === a.toLowerCase() ? n : null;
1011
- const i = this.#t.pools.find((c) => c.id.toLowerCase() === a.toLowerCase());
1012
- if (i !== void 0) return i;
1013
- const [s, r] = await Promise.all([this.getToken(e.currency0), this.getToken(e.currency1)]);
1008
+ async #a(t, o, n) {
1009
+ const i = ot(t);
1010
+ if (n !== void 0) return n.id.toLowerCase() === i.toLowerCase() ? n : null;
1011
+ const a = this.#e.pools.find((c) => c.id.toLowerCase() === i.toLowerCase());
1012
+ if (a !== void 0) return a;
1013
+ const [s, r] = await Promise.all([this.getToken(t.currency0), this.getToken(t.currency1)]);
1014
1014
  if (s === null || r === null) return null;
1015
- const l = o === "CL" ? { tickSpacing: Ne(e).tickSpacing } : { binStep: te(e).binStep };
1016
- return { id: a, key: e, poolType: o, token0: s, token1: r, lpFeePips: e.fee, hooks: e.hooks, ...l };
1015
+ const l = o === "CL" ? { tickSpacing: Nt(t).tickSpacing } : { binStep: et(t).binStep };
1016
+ return { id: i, key: t, poolType: o, token0: s, token1: r, lpFeePips: t.fee, hooks: t.hooks, ...l };
1017
1017
  }
1018
1018
  /**
1019
1019
  * What withdrawing `percentBps` of a position returns as PRINCIPAL, rounded
@@ -1023,35 +1023,35 @@ class Ct {
1023
1023
  * principal alone, and a floor that counted fees could revert an honest
1024
1024
  * withdrawal.
1025
1025
  */
1026
- async quoteRemoveLiquidity(e, o) {
1026
+ async quoteRemoveLiquidity(t, o) {
1027
1027
  const n = this.#n.quoteRemoveLiquidity;
1028
- if (n !== void 0) return n(e, o);
1028
+ if (n !== void 0) return n(t, o);
1029
1029
  if (!Number.isInteger(o) || o <= 0 || o > 1e4)
1030
1030
  throw new RangeError(`[@latchprotocol/widgets] percentBps must be an integer in (0, 10000]: ${o}`);
1031
- const { pool: a } = e;
1032
- if (e.range.type === "CL") {
1033
- const l = await this.getPoolState(a), c = e.liquidity * BigInt(o) / 10000n, d = U(l.sqrtPriceX96, e.range.tickLower, e.range.tickUpper, c, !1);
1034
- return { position: e, percentBps: o, amount0: d.amount0, amount1: d.amount1, source: "live" };
1031
+ const { pool: i } = t;
1032
+ if (t.range.type === "CL") {
1033
+ const l = await this.getPoolState(i), c = t.liquidity * BigInt(o) / 10000n, d = U(l.sqrtPriceX96, t.range.tickLower, t.range.tickUpper, c, !1);
1034
+ return { position: t, percentBps: o, amount0: d.amount0, amount1: d.amount1, source: "live" };
1035
1035
  }
1036
- const i = e.binAmounts ?? [];
1036
+ const a = t.binAmounts ?? [];
1037
1037
  let s = 0n, r = 0n;
1038
- for (const l of i) {
1039
- const [c, d, , p] = await this.#e.readContract({
1040
- address: a.key.poolManager,
1041
- abi: pe,
1038
+ for (const l of a) {
1039
+ const [c, d, , p] = await this.#t.readContract({
1040
+ address: i.key.poolManager,
1041
+ abi: pt,
1042
1042
  functionName: "getBin",
1043
- args: [a.id, l.binId]
1044
- }), m = re({ shares: l.amount * BigInt(o) / 10000n, totalShares: p, reserveX: c, reserveY: d });
1043
+ args: [i.id, l.binId]
1044
+ }), m = rt({ shares: l.amount * BigInt(o) / 10000n, totalShares: p, reserveX: c, reserveY: d });
1045
1045
  s += m.amount0, r += m.amount1;
1046
1046
  }
1047
- return { position: e, percentBps: o, amount0: s, amount1: r, source: "live" };
1047
+ return { position: t, percentBps: o, amount0: s, amount1: r, source: "live" };
1048
1048
  }
1049
- async buildRemoveLiquidity(e) {
1049
+ async buildRemoveLiquidity(t) {
1050
1050
  const o = await this.getAccount();
1051
1051
  if (o === null) throw new E("remove liquidity");
1052
- const { position: n } = e;
1052
+ const { position: n } = t;
1053
1053
  if (n.range.type === "CL") {
1054
- const r = L(
1054
+ const r = I(
1055
1055
  this.chain,
1056
1056
  "clPositionManager",
1057
1057
  "decrease a concentrated-liquidity position"
@@ -1061,55 +1061,55 @@ class Ct {
1061
1061
  "buildRemoveLiquidity",
1062
1062
  "a CL position must carry its ERC-721 tokenId"
1063
1063
  );
1064
- const l = n.liquidity * BigInt(e.percentBps) / 10000n, c = vt({
1064
+ const l = n.liquidity * BigInt(t.percentBps) / 10000n, c = ve({
1065
1065
  positionManager: r,
1066
1066
  poolKey: n.pool.key,
1067
1067
  tokenId: n.tokenId,
1068
1068
  liquidity: l,
1069
- amount0Min: e.amount0Min,
1070
- amount1Min: e.amount1Min,
1071
- recipient: e.recipient,
1069
+ amount0Min: t.amount0Min,
1070
+ amount1Min: t.amount1Min,
1071
+ recipient: t.recipient,
1072
1072
  owner: o,
1073
- deadline: e.deadline,
1074
- ...e.hookData ? { hookData: e.hookData } : {}
1073
+ deadline: t.deadline,
1074
+ ...t.hookData ? { hookData: t.hookData } : {}
1075
1075
  });
1076
1076
  return {
1077
1077
  to: c.to,
1078
1078
  data: c.data,
1079
1079
  value: c.value,
1080
- summary: `Remove ${e.percentBps / 100}% of position #${n.tokenId}`,
1080
+ summary: `Remove ${t.percentBps / 100}% of position #${n.tokenId}`,
1081
1081
  source: "live"
1082
1082
  };
1083
1083
  }
1084
- const a = L(
1084
+ const i = I(
1085
1085
  this.chain,
1086
1086
  "binPositionManager",
1087
1087
  "remove liquidity from a bin pool"
1088
- ), i = n.binAmounts;
1089
- if (i === void 0 || i.length === 0)
1088
+ ), a = n.binAmounts;
1089
+ if (a === void 0 || a.length === 0)
1090
1090
  throw new f(
1091
1091
  "buildRemoveLiquidity",
1092
1092
  "a bin burn needs the per-bin share amounts held by the position"
1093
1093
  );
1094
- const s = It({
1095
- positionManager: a,
1094
+ const s = Le({
1095
+ positionManager: i,
1096
1096
  poolKey: n.pool.key,
1097
- amount0Min: e.amount0Min,
1098
- amount1Min: e.amount1Min,
1099
- ids: i.map((r) => r.binId),
1100
- amounts: i.map(
1101
- (r) => r.amount * BigInt(e.percentBps) / 10000n
1097
+ amount0Min: t.amount0Min,
1098
+ amount1Min: t.amount1Min,
1099
+ ids: a.map((r) => r.binId),
1100
+ amounts: a.map(
1101
+ (r) => r.amount * BigInt(t.percentBps) / 10000n
1102
1102
  ),
1103
1103
  from: o,
1104
- recipient: e.recipient,
1105
- deadline: e.deadline,
1106
- ...e.hookData ? { hookData: e.hookData } : {}
1104
+ recipient: t.recipient,
1105
+ deadline: t.deadline,
1106
+ ...t.hookData ? { hookData: t.hookData } : {}
1107
1107
  });
1108
1108
  return {
1109
1109
  to: s.to,
1110
1110
  data: s.data,
1111
1111
  value: s.value,
1112
- summary: `Remove ${e.percentBps / 100}% of a bin position`,
1112
+ summary: `Remove ${t.percentBps / 100}% of a bin position`,
1113
1113
  source: "live"
1114
1114
  };
1115
1115
  }
@@ -1118,9 +1118,9 @@ class Ct {
1118
1118
  * here", signalled the way every missing contract is: `ChainConfigError`
1119
1119
  * naming `launchGuardHook`, which `isLaunchpadNotConfigured` recognises.
1120
1120
  */
1121
- #s(e) {
1121
+ #s(t) {
1122
1122
  const { launchGuardHook: o, binLaunchGuardHook: n } = this.chain.contracts;
1123
- o === void 0 && n === void 0 && L(this.chain, "launchGuardHook", e);
1123
+ o === void 0 && n === void 0 && I(this.chain, "launchGuardHook", t);
1124
1124
  }
1125
1125
  /**
1126
1126
  * Every configured pool whose key names one of the chain's launch guards:
@@ -1133,16 +1133,16 @@ class Ct {
1133
1133
  */
1134
1134
  async listLaunches() {
1135
1135
  this.#s("read a launch schedule");
1136
- const e = this.#t.pools.filter((n) => this.#o(n) !== null);
1137
- return (await Promise.all(e.map((n) => this.#i(n)))).filter((n) => n !== null);
1136
+ const t = this.#e.pools.filter((n) => this.#o(n) !== null);
1137
+ return (await Promise.all(t.map((n) => this.#i(n)))).filter((n) => n !== null);
1138
1138
  }
1139
- async getLaunch(e) {
1139
+ async getLaunch(t) {
1140
1140
  this.#s("read a launch schedule");
1141
- const o = this.#t.pools.find((n) => n.id === e);
1141
+ const o = this.#e.pools.find((n) => n.id === t);
1142
1142
  if (o === void 0)
1143
1143
  throw new f(
1144
1144
  "getLaunch",
1145
- `pool ${e} is not in the configured pool list. The singleton has no pool enumeration, so the widget can only read pools the host declared.`
1145
+ `pool ${t} is not in the configured pool list. The singleton has no pool enumeration, so the widget can only read pools the host declared.`
1146
1146
  );
1147
1147
  return this.#o(o) === null ? null : this.#i(o);
1148
1148
  }
@@ -1155,36 +1155,36 @@ class Ct {
1155
1155
  * swapped through anyway. A missing one is an error naming the id, not a
1156
1156
  * shorter list.
1157
1157
  */
1158
- async getLaunchesForToken(e) {
1159
- const o = L(this.chain, "launchpadKitV2", "look a launch up by its token"), n = await this.#e.readContract({
1158
+ async getLaunchesForToken(t) {
1159
+ const o = I(this.chain, "launchpadKitV2", "look a launch up by its token"), n = await this.#t.readContract({
1160
1160
  address: o,
1161
- abi: Se,
1161
+ abi: St,
1162
1162
  functionName: "legsOf",
1163
- args: [e]
1163
+ args: [t]
1164
1164
  });
1165
1165
  if (n.length === 0) return [];
1166
- const a = n.filter((r) => this.#t.pools.every((l) => l.id !== r));
1167
- if (a.length > 0)
1166
+ const i = n.filter((r) => this.#e.pools.every((l) => l.id !== r));
1167
+ if (i.length > 0)
1168
1168
  throw new f(
1169
1169
  "getLaunchesForToken",
1170
- `the kit lists ${n.length} pool(s) for ${e} but ${a.length} of them (${a.join(", ")}) are not in the configured pool list. Declare them (the pool manager's Initialize log carries the key) so the widget can read and route through them.`
1170
+ `the kit lists ${n.length} pool(s) for ${t} but ${i.length} of them (${i.join(", ")}) are not in the configured pool list. Declare them (the pool manager's Initialize log carries the key) so the widget can read and route through them.`
1171
1171
  );
1172
- const i = n.filter((r) => {
1173
- const l = this.#t.pools.find((c) => c.id === r);
1172
+ const a = n.filter((r) => {
1173
+ const l = this.#e.pools.find((c) => c.id === r);
1174
1174
  return this.#o(l) === null;
1175
1175
  });
1176
- if (i.length > 0)
1176
+ if (a.length > 0)
1177
1177
  throw new f(
1178
1178
  "getLaunchesForToken",
1179
- `${i.length} of the kit's pools for ${e} (${i.join(", ")}) name a launch guard this chain config does not declare. Set \`contracts.launchGuardHook\` (CL) and \`contracts.binLaunchGuardHook\` (Bin) to the kit's guards; a launch cannot be shown with a leg missing.`
1179
+ `${a.length} of the kit's pools for ${t} (${a.join(", ")}) name a launch guard this chain config does not declare. Set \`contracts.launchGuardHook\` (CL) and \`contracts.binLaunchGuardHook\` (Bin) to the kit's guards; a launch cannot be shown with a leg missing.`
1180
1180
  );
1181
1181
  return await Promise.all(
1182
1182
  n.map(async (r) => {
1183
- const l = this.#t.pools.find((d) => d.id === r), c = await this.#i(l);
1183
+ const l = this.#e.pools.find((d) => d.id === r), c = await this.#i(l);
1184
1184
  if (c === null)
1185
1185
  throw new f(
1186
1186
  "getLaunchesForToken",
1187
- `the kit lists pool ${r} for ${e} but its guard has no launch record for it`
1187
+ `the kit lists pool ${r} for ${t} but its guard has no launch record for it`
1188
1188
  );
1189
1189
  return c;
1190
1190
  })
@@ -1195,66 +1195,66 @@ class Ct {
1195
1195
  * address book, then the hook's own `CLOCK_MODE()` (a revert means the
1196
1196
  * block-numbered build). A transport failure throws; it is never a revert.
1197
1197
  */
1198
- async #r(e, o = "CL") {
1198
+ async #r(t, o = "CL") {
1199
1199
  if (o === "CL") {
1200
- const i = this.chain.contracts.launchGuardHookClock;
1201
- if (i !== void 0) return i;
1200
+ const a = this.chain.contracts.launchGuardHookClock;
1201
+ if (a !== void 0) return a;
1202
1202
  }
1203
- const n = $e(this.chain.chainId);
1204
- if (o === "CL" && n?.launchGuardHook && b(n.launchGuardHook, e)) {
1205
- const i = n.durationClocks.launchGuardHook;
1206
- if (i !== null) return i;
1203
+ const n = Pt(this.chain.chainId);
1204
+ if (o === "CL" && n?.launchGuardHook && b(n.launchGuardHook, t)) {
1205
+ const a = n.durationClocks.launchGuardHook;
1206
+ if (a !== null) return a;
1207
1207
  }
1208
- const a = n?.launchpadV2;
1209
- if (a !== void 0) {
1210
- const i = o === "CL" ? a.clLaunchGuardHook : a.binLaunchGuardHook;
1211
- if (i !== null && b(i, e)) return "timestamp";
1208
+ const i = n?.launchpadV2;
1209
+ if (i !== void 0) {
1210
+ const a = o === "CL" ? i.clLaunchGuardHook : i.binLaunchGuardHook;
1211
+ if (a !== null && b(a, t)) return "timestamp";
1212
1212
  }
1213
1213
  try {
1214
- const { data: i } = await this.#e.call({ to: e, data: Pe });
1215
- if (i === void 0 || i === "0x") return "contract-block";
1216
- const [s] = Le([{ type: "string" }], i);
1217
- if (s === Be) return "timestamp";
1218
- throw new f("getLaunch", `hook ${e} reports an unknown CLOCK_MODE "${s}"`);
1219
- } catch (i) {
1220
- if (i instanceof J && i.walk((s) => s instanceof Z) !== null)
1214
+ const { data: a } = await this.#t.call({ to: t, data: $t });
1215
+ if (a === void 0 || a === "0x") return "contract-block";
1216
+ const [s] = It([{ type: "string" }], a);
1217
+ if (s === Bt) return "timestamp";
1218
+ throw new f("getLaunch", `hook ${t} reports an unknown CLOCK_MODE "${s}"`);
1219
+ } catch (a) {
1220
+ if (a instanceof J && a.walk((s) => s instanceof Z) !== null)
1221
1221
  return "contract-block";
1222
- throw i;
1222
+ throw a;
1223
1223
  }
1224
1224
  }
1225
- async #i(e) {
1226
- const o = this.#o(e);
1225
+ async #i(t) {
1226
+ const o = this.#o(t);
1227
1227
  if (o === null) return null;
1228
- const n = o.hook, a = await this.#r(n, o.poolType);
1229
- if (o.poolType === "BIN" && a !== "timestamp")
1228
+ const n = o.hook, i = await this.#r(n, o.poolType);
1229
+ if (o.poolType === "BIN" && i !== "timestamp")
1230
1230
  throw new f(
1231
1231
  "getLaunch",
1232
1232
  `BinLaunchGuardHook ${n} answers as a block-numbered build; no such build exists, so this is not a Bin launch guard.`
1233
1233
  );
1234
- const i = o.poolType === "CL" ? ae(a) : ee, s = await this.#e.readContract({
1234
+ const a = o.poolType === "CL" ? at(i) : tt, s = await this.#t.readContract({
1235
1235
  address: n,
1236
- abi: i,
1236
+ abi: a,
1237
1237
  functionName: "getLaunch",
1238
- args: [e.id]
1239
- }), r = Ke(s, a);
1240
- if (!Xe(r)) return null;
1238
+ args: [t.id]
1239
+ }), r = Kt(s, i);
1240
+ if (!Xt(r)) return null;
1241
1241
  const [l, c] = await Promise.all([
1242
- this.#e.readContract({
1242
+ this.#t.readContract({
1243
1243
  address: n,
1244
- abi: i,
1244
+ abi: a,
1245
1245
  functionName: "currentFee",
1246
- args: [e.id]
1246
+ args: [t.id]
1247
1247
  }),
1248
1248
  /* "Now" on the HOOK's clock. The timestamp build compares with
1249
1249
  block.timestamp. The block-numbered build compares with the EVM's
1250
1250
  block.number, which on an Arbitrum chain (Robinhood, 4663) is
1251
1251
  Ethereum's block number while the RPC head is the L2 block; against
1252
1252
  the RPC head every unopened launch rendered as settled. */
1253
- xe(this.#e, this.chain.chainId)
1254
- ]), d = a === "timestamp" ? c.timestamp : c.contractBlockNumber, [p, m] = r.launchTokenIsCurrency0 ? [e.token0, e.token1] : [e.token1, e.token0];
1253
+ xt(this.#t, this.chain.chainId)
1254
+ ]), d = i === "timestamp" ? c.timestamp : c.contractBlockNumber, [p, m] = r.launchTokenIsCurrency0 ? [t.token0, t.token1] : [t.token1, t.token0];
1255
1255
  return {
1256
- poolId: e.id,
1257
- pool: e,
1256
+ poolId: t.id,
1257
+ pool: t,
1258
1258
  hook: n,
1259
1259
  launchToken: p,
1260
1260
  quoteToken: m,
@@ -1264,13 +1264,13 @@ class Ct {
1264
1264
  source: "live"
1265
1265
  };
1266
1266
  }
1267
- async sendTransaction(e) {
1268
- const o = this.#t.wallet;
1267
+ async sendTransaction(t) {
1268
+ const o = this.#e.wallet;
1269
1269
  if (o === void 0) throw new E("send a transaction");
1270
1270
  return o.sendTransaction({
1271
- to: e.to,
1272
- data: e.data,
1273
- value: e.value
1271
+ to: t.to,
1272
+ data: t.data,
1273
+ value: t.value
1274
1274
  });
1275
1275
  }
1276
1276
  /**
@@ -1280,276 +1280,276 @@ class Ct {
1280
1280
  * latest block's. See `nextBlockClock` for why the pending read matters.
1281
1281
  */
1282
1282
  async getBlockTimestamp() {
1283
- const [e, o] = await Promise.allSettled([
1284
- this.#e.getBlock({ blockTag: "pending" }),
1285
- this.#e.getBlock({ blockTag: "latest" })
1286
- ]), n = Ye(
1287
- e.status === "fulfilled" ? e.value.timestamp : null,
1283
+ const [t, o] = await Promise.allSettled([
1284
+ this.#t.getBlock({ blockTag: "pending" }),
1285
+ this.#t.getBlock({ blockTag: "latest" })
1286
+ ]), n = Yt(
1287
+ t.status === "fulfilled" ? t.value.timestamp : null,
1288
1288
  o.status === "fulfilled" ? o.value.timestamp : null
1289
1289
  );
1290
1290
  if (n === null) throw o.status === "rejected" ? o.reason : new Error("no block timestamp could be read");
1291
1291
  return n;
1292
1292
  }
1293
- async waitForTransaction(e) {
1294
- const o = await this.#e.waitForTransactionReceipt({ hash: e });
1293
+ async waitForTransaction(t) {
1294
+ const o = await this.#t.waitForTransactionReceipt({ hash: t });
1295
1295
  return {
1296
- hash: e,
1296
+ hash: t,
1297
1297
  status: o.status === "success" ? "success" : "reverted",
1298
1298
  blockNumber: o.blockNumber,
1299
1299
  source: "live"
1300
1300
  };
1301
1301
  }
1302
1302
  }
1303
- function Rt(t) {
1304
- return new Ct(t);
1303
+ function Re(e) {
1304
+ return new Ae(e);
1305
1305
  }
1306
- function Ft(t, e, o, n = {}) {
1307
- const a = n.native ?? me, i = n.lp ?? {};
1308
- return P(
1309
- () => Ve(t, e, o, { native: a, lp: i }),
1310
- [t, e, o, a.symbol, a.decimals, i.lpLocker, i.binLpLocker, i.poolType, i.lpLockerFromBlock, (i.lpLockerTokenIds ?? []).join(",")],
1311
- { enabled: He(e, i), refetchIntervalMs: n.refetchIntervalMs ?? 6e4 }
1306
+ function Fe(e, t, o, n = {}) {
1307
+ const i = n.native ?? mt, a = n.lp ?? {};
1308
+ return $(
1309
+ () => Vt(e, t, o, { native: i, lp: a }),
1310
+ [e, t, o, i.symbol, i.decimals, a.lpLocker, a.binLpLocker, a.poolType, a.lpLockerFromBlock, (a.lpLockerTokenIds ?? []).join(",")],
1311
+ { enabled: Ht(t, a), refetchIntervalMs: n.refetchIntervalMs ?? 6e4 }
1312
1312
  );
1313
1313
  }
1314
- function Gt(t, e, o, n = {}) {
1315
- const a = n.native ?? me, i = n.lp ?? {}, s = !!i.lpLocker || !!i.binLpLocker;
1316
- return P(
1317
- () => je(t, e, o, { native: a, lp: i }),
1318
- [t, e, o, a.symbol, a.decimals, i.lpLocker, i.binLpLocker, i.lpLockerFromBlock, (i.lpLockerTokenIds ?? []).join(",")],
1319
- { enabled: e !== null || s, refetchIntervalMs: n.refetchIntervalMs ?? 6e4 }
1314
+ function Ge(e, t, o, n = {}) {
1315
+ const i = n.native ?? mt, a = n.lp ?? {}, s = !!a.lpLocker || !!a.binLpLocker;
1316
+ return $(
1317
+ () => jt(e, t, o, { native: i, lp: a }),
1318
+ [e, t, o, i.symbol, i.decimals, a.lpLocker, a.binLpLocker, a.lpLockerFromBlock, (a.lpLockerTokenIds ?? []).join(",")],
1319
+ { enabled: t !== null || s, refetchIntervalMs: n.refetchIntervalMs ?? 6e4 }
1320
1320
  );
1321
1321
  }
1322
- function qt(t, e) {
1323
- const [o, n] = he(() => Date.now());
1324
- return Ze(() => {
1325
- if (t === null) return;
1326
- const a = setInterval(() => n(Date.now()), 1e3);
1327
- return () => clearInterval(a);
1328
- }, [t]), t === null || e === null ? null : We(t, e, o);
1322
+ function qe(e, t) {
1323
+ const [o, n] = ht(() => Date.now());
1324
+ return Zt(() => {
1325
+ if (e === null) return;
1326
+ const i = setInterval(() => n(Date.now()), 1e3);
1327
+ return () => clearInterval(i);
1328
+ }, [e]), e === null || t === null ? null : Wt(e, t, o);
1329
1329
  }
1330
- function I(t) {
1331
- return t.status === "read" ? t.sources ?? [] : t.status === "error" && t.source ? [t.source] : [];
1330
+ function L(e) {
1331
+ return e.status === "read" ? e.sources ?? [] : e.status === "error" && e.source ? [e.source] : [];
1332
1332
  }
1333
- function v(t, e, o, n, a) {
1334
- return { key: t, label: e, headline: o.headline, detail: o.detail, tone: o.tone, provenance: n.map((i) => ut(i, a.readAt)), sources: n };
1333
+ function v(e, t, o, n, i) {
1334
+ return { key: e, label: t, headline: o.headline, detail: o.detail, tone: o.tone, provenance: n.map((a) => ue(a, i.readAt).split(" · ")[0] ?? a.contract), sources: n };
1335
1335
  }
1336
- const ge = {
1336
+ const gt = {
1337
1337
  "launch-leg": "a Kit v2 launch leg",
1338
1338
  "lp-locker": "an LP-locker lock",
1339
1339
  "position-lock": "a LatchPositionLock time lock",
1340
1340
  given: "this page's pool list"
1341
1341
  };
1342
- function ve(t) {
1343
- return t.length <= 1 ? t[0] ?? "" : `${t.slice(0, -1).join(", ")} and ${t[t.length - 1]}`;
1342
+ function vt(e) {
1343
+ return e.length <= 1 ? e[0] ?? "" : `${e.slice(0, -1).join(", ")} and ${e[e.length - 1]}`;
1344
1344
  }
1345
- const Tt = (t, e) => t[e.toLowerCase()] ?? `${e.slice(0, 6)}…${e.slice(-4)}`;
1346
- function Mt(t, e, o) {
1345
+ const Te = (e, t) => e[t.toLowerCase()] ?? `${t.slice(0, 6)}…${t.slice(-4)}`;
1346
+ function Me(e, t, o) {
1347
1347
  const n = [
1348
1348
  {
1349
- ...v("liquidity", "Liquidity locks", at(t.liquidity, t.kind), I(t.liquidity), e),
1350
- share: t.liquidity.status !== "read" || !t.liquidity.measurable ? null : t.kind === "Bin" ? ce([{ key: "permanent", label: "Locked permanently (LP locker)", bps: t.liquidity.lockedActiveBps }], "of the active bin") : ce(
1349
+ ...v("liquidity", "Liquidity locks", ae(e.liquidity, e.kind), L(e.liquidity), t),
1350
+ share: e.liquidity.status !== "read" || !e.liquidity.measurable ? null : e.kind === "Bin" ? ct([{ key: "permanent", label: "Locked permanently (LP locker)", bps: e.liquidity.lockedActiveBps }], "of the active bin") : ct(
1351
1351
  [
1352
- { key: "permanent", label: "Locked permanently (LP locker)", bps: t.liquidity.permanentActiveBps },
1353
- { key: "time", label: "Time-locked until a date", bps: t.liquidity.timeLockedActiveBps }
1352
+ { key: "permanent", label: "Locked permanently (LP locker)", bps: e.liquidity.permanentActiveBps },
1353
+ { key: "time", label: "Time-locked until a date", bps: e.liquidity.timeLockedActiveBps }
1354
1354
  ],
1355
1355
  "of active liquidity"
1356
1356
  )
1357
1357
  },
1358
- v("lp-fee", "LP fee", st(t.lpFee), t.lpFee.kind === "error" ? [] : t.lpFee.source === null ? [] : [t.lpFee.source], e),
1359
- v("protocol-fee", "Protocol fee", rt(t.protocolFee), I(t.protocolFee), e)
1358
+ v("lp-fee", "LP fee", se(e.lpFee), e.lpFee.kind === "error" ? [] : e.lpFee.source === null ? [] : [e.lpFee.source], t),
1359
+ v("protocol-fee", "Protocol fee", re(e.protocolFee), L(e.protocolFee), t)
1360
1360
  ];
1361
- return t.tax.status !== "not-a-launch-pool" && n.push(v("tax", "Creator tax", ye(t.tax, e.readAt.chainNow), I(t.tax), e)), n.push(v("registry", "Hook in LatchRegistry", ct(t.registry), t.registry.status === "no-hook" ? [] : I(t.registry), e)), {
1362
- poolId: t.poolId,
1363
- title: `${e.symbol} / ${Tt(o, t.pairedWith)} · ${t.kind} pool`,
1364
- foundBy: `Found through ${ve(t.origins.map((a) => ge[a]))}.`,
1361
+ return e.tax.status !== "not-a-launch-pool" && n.push(v("tax", "Creator tax", yt(e.tax, t.readAt.chainNow), L(e.tax), t)), n.push(v("registry", "Hook in LatchRegistry", ce(e.registry), e.registry.status === "no-hook" ? [] : L(e.registry), t)), {
1362
+ poolId: e.poolId,
1363
+ title: `${t.symbol} / ${Te(o, e.pairedWith)} · ${e.kind} pool`,
1364
+ foundBy: `Found through ${vt(e.origins.map((i) => gt[i]))}.`,
1365
1365
  rows: n
1366
1366
  };
1367
1367
  }
1368
- function Nt(t) {
1369
- const e = t.launch;
1370
- if (e.status === "not-configured")
1371
- return v("tax", "Creator tax", { headline: "Coming soon", detail: "Latch launches are coming soon on this chain, so there is no creator tax to read.", tone: "missing" }, [], t);
1372
- if (e.status === "error")
1373
- return v("tax", "Creator tax", { headline: "Could not be read", detail: `The launch read failed: ${e.message}.`, tone: "error" }, I(e), t);
1374
- if (e.launch === null)
1375
- return v("tax", "Creator tax", { headline: "Not a Latch launch", detail: "LaunchpadKitV2 has no launch for this token, so no Latch launch guard takes a creator tax on it.", tone: "neutral" }, I(e), t);
1376
- const o = t.pools.filter((s) => s.origins.includes("launch-leg") && s.tax.status !== "not-a-launch-pool");
1368
+ function Ne(e) {
1369
+ const t = e.launch;
1370
+ if (t.status === "not-configured")
1371
+ return v("tax", "Creator tax", { headline: "Coming soon", detail: "Latch launches are coming soon on this chain, so there is no creator tax to read.", tone: "missing" }, [], e);
1372
+ if (t.status === "error")
1373
+ return v("tax", "Creator tax", { headline: "Could not be read", detail: `The launch read failed: ${t.message}.`, tone: "error" }, L(t), e);
1374
+ if (t.launch === null)
1375
+ return v("tax", "Creator tax", { headline: "Not a Latch launch", detail: "This token was not launched on Latch, so no Latch creator tax applies to it.", tone: "neutral" }, L(t), e);
1376
+ const o = e.pools.filter((s) => s.origins.includes("launch-leg") && s.tax.status !== "not-a-launch-pool");
1377
1377
  if (o.length === 0)
1378
- return v("tax", "Creator tax", { headline: "Could not be read", detail: "No launch pool of this token could be described, so its tax was not read.", tone: "error" }, I(e), t);
1379
- const n = o.map((s) => ye(s.tax, t.readAt.chainNow)), a = o.flatMap((s) => I(s.tax)).filter((s, r, l) => l.findIndex((c) => c.address.toLowerCase() === s.address.toLowerCase()) === r), i = n[0];
1380
- return n.every((s) => s.headline === i.headline && s.detail === i.detail) ? v("tax", "Creator tax", o.length === 1 ? i : { ...i, detail: `${i.detail ?? ""} Same on all ${o.length} launch pools.`.trim() }, a, t) : v("tax", "Creator tax", { headline: "Differs by pool", detail: "Each launch pool below carries its own terms.", tone: n.some((s) => s.tone === "caution") ? "caution" : "neutral" }, a, t);
1378
+ return v("tax", "Creator tax", { headline: "Could not be read", detail: "No launch pool of this token could be described, so its tax was not read.", tone: "error" }, L(t), e);
1379
+ const n = o.map((s) => yt(s.tax, e.readAt.chainNow)), i = o.flatMap((s) => L(s.tax)).filter((s, r, l) => l.findIndex((c) => c.address.toLowerCase() === s.address.toLowerCase()) === r), a = n[0];
1380
+ return n.every((s) => s.headline === a.headline && s.detail === a.detail) ? v("tax", "Creator tax", o.length === 1 ? a : { ...a, detail: `${a.detail ?? ""} Same on all ${o.length} launch pools.`.trim() }, i, e) : v("tax", "Creator tax", { headline: "Differs by pool", detail: "Each launch pool below carries its own terms.", tone: n.some((s) => s.tone === "caution") ? "caution" : "neutral" }, i, e);
1381
1381
  }
1382
- function Ut(t, e = {}) {
1383
- const o = t.discovery.searched.map((i) => ge[i]), n = `Pools listed are those found through ${o.length === 0 ? "no source yet: these reads are coming soon on this chain" : ve(o)}${t.discovery.truncated ? ", and only the first of them were read" : ""}${t.discovery.positionLocksTruncated ? " (newest position locks only)" : ""}. A pool of this token that no Latch launch or lock knows about is not listed.`, a = t.readAt.fromBlock === t.readAt.toBlock ? `block ${t.readAt.fromBlock.toLocaleString("en-US")}` : `blocks ${t.readAt.fromBlock.toLocaleString("en-US")}–${t.readAt.toBlock.toLocaleString("en-US")}`;
1382
+ function Ue(e, t = {}) {
1383
+ const o = e.discovery.searched.map((i) => gt[i]), n = `Pools listed are those found through ${o.length === 0 ? "no source yet: these reads are coming soon on this chain" : vt(o)}${e.discovery.truncated ? ", and only the first of them were read" : ""}${e.discovery.positionLocksTruncated ? " (newest position locks only)" : ""}. A pool of this token that no Latch launch or lock knows about is not listed.`;
1384
1384
  return {
1385
- summary: it(t),
1386
- launch: v("launch", "Latch launch", ot(t.launch, t.readAt), I(t.launch), t),
1385
+ summary: ie(e),
1386
+ launch: v("launch", "Latch launch", oe(e.launch, e.readAt), L(e.launch), e),
1387
1387
  tokenLocks: {
1388
- ...v("token-locks", "Token locks & vesting", nt(t.tokenLocks, t.symbol, t.decimals), I(t.tokenLocks), t),
1389
- share: t.tokenLocks.status === "read" && t.tokenLocks.lockCount > 0 ? Qe(t.tokenLocks) : null
1388
+ ...v("token-locks", "Token locks & vesting", ne(e.tokenLocks, e.symbol, e.decimals), L(e.tokenLocks), e),
1389
+ share: e.tokenLocks.status === "read" && e.tokenLocks.lockCount > 0 ? Qt(e.tokenLocks) : null
1390
1390
  },
1391
- creatorTax: Nt(t),
1392
- pools: t.pools.map((i) => Mt(i, t, e)),
1393
- failedPools: t.failedPools.map((i) => `${i.kind} pool ${i.poolId.slice(0, 10)}… could not be described: ${i.message}.`),
1391
+ creatorTax: Ne(e),
1392
+ pools: e.pools.map((i) => Me(i, e, t)),
1393
+ failedPools: e.failedPools.map((i) => `${i.kind} pool ${i.poolId.slice(0, 10)}… could not be described: ${i.message}.`),
1394
1394
  discoveryNote: n,
1395
- readAtNote: `Read from chain at ${a}; expiries judged against the chain's clock. Token units, never priced. A registry listing is what the registry records, not an audit.`
1395
+ readAtNote: "Live from the chain. Token units, never priced. A registry listing is what the registry records, not an audit."
1396
1396
  };
1397
1397
  }
1398
- async function St(t, e) {
1399
- const o = await lt(t, {
1400
- token: e.token,
1401
- contracts: e.contracts,
1402
- ...e.pools !== void 0 ? { pools: e.pools } : {},
1403
- ...e.lpLockerTokenIds !== void 0 ? { lpLockerTokenIds: e.lpLockerTokenIds } : {},
1404
- ...e.native !== void 0 ? { native: e.native } : {}
1405
- }), n = [...new Set(o.pools.map((r) => r.pairedWith.toLowerCase()))], a = e.native?.symbol ?? "ETH", i = await Promise.all(n.map((r) => r === Ie ? Promise.resolve({ symbol: a }) : De(t, r).catch(() => null))), s = {};
1398
+ async function Se(e, t) {
1399
+ const o = await le(e, {
1400
+ token: t.token,
1401
+ contracts: t.contracts,
1402
+ ...t.pools !== void 0 ? { pools: t.pools } : {},
1403
+ ...t.lpLockerTokenIds !== void 0 ? { lpLockerTokenIds: t.lpLockerTokenIds } : {},
1404
+ ...t.native !== void 0 ? { native: t.native } : {}
1405
+ }), n = [...new Set(o.pools.map((r) => r.pairedWith.toLowerCase()))], i = t.native?.symbol ?? "ETH", a = await Promise.all(n.map((r) => r === Lt ? Promise.resolve({ symbol: i }) : Dt(e, r).catch(() => null))), s = {};
1406
1406
  return n.forEach((r, l) => {
1407
- const c = i[l];
1407
+ const c = a[l];
1408
1408
  c && (s[r] = c.symbol);
1409
1409
  }), { trust: o, symbols: s };
1410
1410
  }
1411
- function Kt(t, e, o = {}) {
1412
- const n = e.contracts, a = n === null ? "none" : Object.entries(n).map(([i, s]) => `${i}:${String(s ?? "")}`).sort().join("|");
1413
- return P(
1414
- () => St(t, { ...e, contracts: n }),
1411
+ function Ke(e, t, o = {}) {
1412
+ const n = t.contracts, i = n === null ? "none" : Object.entries(n).map(([a, s]) => `${a}:${String(s ?? "")}`).sort().join("|");
1413
+ return $(
1414
+ () => Se(e, { ...t, contracts: n }),
1415
1415
  [
1416
- t,
1417
- e.token.toLowerCase(),
1418
- a,
1419
- (e.pools ?? []).map((i) => `${i.kind}${i.poolId}`).join(","),
1420
- (e.lpLockerTokenIds ?? []).join(","),
1421
- e.native?.symbol,
1422
- e.native?.decimals
1416
+ e,
1417
+ t.token.toLowerCase(),
1418
+ i,
1419
+ (t.pools ?? []).map((a) => `${a.kind}${a.poolId}`).join(","),
1420
+ (t.lpLockerTokenIds ?? []).join(","),
1421
+ t.native?.symbol,
1422
+ t.native?.decimals
1423
1423
  ],
1424
1424
  { enabled: n !== null, refetchIntervalMs: o.refetchIntervalMs ?? 6e4 }
1425
1425
  );
1426
1426
  }
1427
- function Xt(t, e) {
1428
- const o = t.trim().replace(/_/g, "");
1429
- if (!/^\d+(\.\d+)?$/.test(o) || (o.split(".")[1] ?? "").length > e) return null;
1427
+ function Xe(e, t) {
1428
+ const o = e.trim().replace(/_/g, "");
1429
+ if (!/^\d+(\.\d+)?$/.test(o) || (o.split(".")[1] ?? "").length > t) return null;
1430
1430
  try {
1431
- return Ae(o, e);
1431
+ return Ct(o, t);
1432
1432
  } catch {
1433
1433
  return null;
1434
1434
  }
1435
1435
  }
1436
- function Yt(t) {
1437
- const e = /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2})$/.exec(t.trim());
1438
- if (e === null) return null;
1439
- const o = Date.UTC(Number(e[1]), Number(e[2]) - 1, Number(e[3]), Number(e[4]), Number(e[5]));
1436
+ function Ye(e) {
1437
+ const t = /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2})$/.exec(e.trim());
1438
+ if (t === null) return null;
1439
+ const o = Date.UTC(Number(t[1]), Number(t[2]) - 1, Number(t[3]), Number(t[4]), Number(t[5]));
1440
1440
  return Number.isFinite(o) ? BigInt(Math.floor(o / 1e3)) : null;
1441
1441
  }
1442
- function Wt(t) {
1443
- return new Date(Number(t) * 1e3).toISOString().slice(0, 16);
1442
+ function We(e) {
1443
+ return new Date(Number(e) * 1e3).toISOString().slice(0, 16);
1444
1444
  }
1445
- function Ht(t) {
1446
- const e = t.trim();
1447
- return /^\d+$/.test(e) ? BigInt(e) * 86400n : null;
1445
+ function He(e) {
1446
+ const t = e.trim();
1447
+ return /^\d+$/.test(t) ? BigInt(t) * 86400n : null;
1448
1448
  }
1449
- function Vt(t, e) {
1450
- return t === "timelock" ? e.unlockAt === null ? null : { start: e.unlockAt, cliff: e.unlockAt, end: e.unlockAt } : e.start === null || e.cliffDays === null || e.durationDays === null ? null : { start: e.start, cliff: e.start + e.cliffDays, end: e.start + e.durationDays };
1449
+ function Ve(e, t) {
1450
+ return e === "timelock" ? t.unlockAt === null ? null : { start: t.unlockAt, cliff: t.unlockAt, end: t.unlockAt } : t.start === null || t.cliffDays === null || t.durationDays === null ? null : { start: t.start, cliff: t.start + t.cliffDays, end: t.start + t.durationDays };
1451
1451
  }
1452
- function H(t, e) {
1453
- if (t === 0n) return "0";
1454
- const o = 10n ** BigInt(e), n = t / o, a = (t % o).toString().padStart(e, "0").replace(/0+$/, "");
1455
- return a === "" ? n.toLocaleString("en-US") : `${n.toLocaleString("en-US")}.${a}`;
1452
+ function H(e, t) {
1453
+ if (e === 0n) return "0";
1454
+ const o = 10n ** BigInt(t), n = e / o, i = (e % o).toString().padStart(t, "0").replace(/0+$/, "");
1455
+ return i === "" ? n.toLocaleString("en-US") : `${n.toLocaleString("en-US")}.${i}`;
1456
1456
  }
1457
- function jt(t, e) {
1458
- const o = `${H(t.feeWei, e.decimals)} ${e.symbol} per lock`, n = t.pendingFee, a = n !== null && n.feeWei > t.feeWei, i = a ? n.feeWei : t.feeWei, s = n === null ? null : `${n.feeWei > t.feeWei ? "An increase" : "A change"} to ${H(n.feeWei, e.decimals)} ${e.symbol} applies from ${new Date(Number(n.effectiveAt) * 1e3).toISOString().replace("T", " ").slice(0, 16)} UTC.`;
1457
+ function je(e, t) {
1458
+ const o = `${H(e.feeWei, t.decimals)} ${t.symbol} per lock`, n = e.pendingFee, i = n !== null && n.feeWei > e.feeWei, a = i ? n.feeWei : e.feeWei, s = n === null ? null : `${n.feeWei > e.feeWei ? "An increase" : "A change"} to ${H(n.feeWei, t.decimals)} ${t.symbol} applies from ${new Date(Number(n.effectiveAt) * 1e3).toISOString().replace("T", " ").slice(0, 16)} UTC.`;
1459
1459
  return {
1460
1460
  fee: o,
1461
- sends: `${H(i, e.decimals)} ${e.symbol}`,
1461
+ sends: `${H(a, t.decimals)} ${t.symbol}`,
1462
1462
  pending: s,
1463
- note: `Charged by the lock contract itself and paid only to its fee recipient ${t.recipient.slice(0, 6)}…${t.recipient.slice(-4)}.${a ? " The transaction sends the announced higher fee in case it applies before it mines; the contract refunds any surplus in the same call." : ""}`
1463
+ note: `Charged by the lock contract itself and paid only to its fee recipient ${e.recipient.slice(0, 6)}…${e.recipient.slice(-4)}.${i ? " The transaction sends the announced higher fee in case it applies before it mines; the contract refunds any surplus in the same call." : ""}`
1464
1464
  };
1465
1465
  }
1466
- function Qt(t) {
1467
- const e = [];
1468
- return t.approved || e.push({ key: "approve", label: `Approve LatchPositionLock to move position #${t.tokenId} (this NFT only)` }), e.push({ key: "lock", label: `Lock position #${t.tokenId} until ${new Date(Number(t.unlockAt) * 1e3).toISOString().replace("T", " ").slice(0, 16)} UTC, paying the fee` }), e;
1466
+ function Qe(e) {
1467
+ const t = [];
1468
+ return e.approved || t.push({ key: "approve", label: `Approve LatchPositionLock to move position #${e.tokenId} (this NFT only)` }), t.push({ key: "lock", label: `Lock position #${e.tokenId} until ${new Date(Number(e.unlockAt) * 1e3).toISOString().replace("T", " ").slice(0, 16)} UTC, paying the fee` }), t;
1469
1469
  }
1470
- function zt(t) {
1471
- const e = [];
1472
- return !t.native && t.allowance < t.amount && e.push({ key: "approve", label: `Approve LatchTokenLock for exactly ${t.amountText} ${t.symbol}` }), e.push({ key: "lock", label: `Lock ${t.amountText} ${t.symbol}, paying the fee${t.native ? " (the amount is sent with it)" : ""}` }), e;
1470
+ function ze(e) {
1471
+ const t = [];
1472
+ return !e.native && e.allowance < e.amount && t.push({ key: "approve", label: `Approve LatchTokenLock for exactly ${e.amountText} ${e.symbol}` }), t.push({ key: "lock", label: `Lock ${e.amountText} ${e.symbol}, paying the fee${e.native ? " (the amount is sent with it)" : ""}` }), t;
1473
1473
  }
1474
- const R = (t, e) => t != null && e !== null && e !== void 0 && t.toLowerCase() === e.toLowerCase();
1475
- function Jt(t, e, o) {
1476
- if (t.withdrawn) return [];
1474
+ const R = (e, t) => e != null && t !== null && t !== void 0 && e.toLowerCase() === t.toLowerCase();
1475
+ function Je(e, t, o) {
1476
+ if (e.withdrawn) return [];
1477
1477
  const n = ["collect"];
1478
- return R(t.owner, e) && (n.push("extend"), o >= t.unlockAt && n.push("withdraw")), R(t.pendingOwner, e) && n.push("accept"), n;
1478
+ return R(e.owner, t) && (n.push("extend"), o >= e.unlockAt && n.push("withdraw")), R(e.pendingOwner, t) && n.push("accept"), n;
1479
1479
  }
1480
- function Zt(t, e) {
1480
+ function Ze(e, t) {
1481
1481
  const o = [];
1482
- return R(t.beneficiary, e) && t.claimable > 0n && o.push("claim"), R(t.pendingBeneficiary, e) && o.push("accept"), o;
1482
+ return R(e.beneficiary, t) && e.claimable > 0n && o.push("claim"), R(e.pendingBeneficiary, t) && o.push("accept"), o;
1483
1483
  }
1484
- const en = {
1484
+ const tn = {
1485
1485
  collect: "Collect fees",
1486
1486
  extend: "Extend",
1487
1487
  withdraw: "Withdraw",
1488
1488
  accept: "Accept lock"
1489
- }, tn = {
1489
+ }, en = {
1490
1490
  claim: "Claim vested",
1491
1491
  accept: "Accept lock"
1492
1492
  };
1493
- function nn(t) {
1494
- const e = Je();
1495
- return tt(() => {
1496
- if (t !== void 0) return t;
1497
- const o = e?.adapter;
1493
+ function nn(e) {
1494
+ const t = Jt();
1495
+ return ee(() => {
1496
+ if (e !== void 0) return e;
1497
+ const o = t?.adapter;
1498
1498
  return o === void 0 || o.isMock ? null : {
1499
1499
  getAccount: () => o.getAccount(),
1500
1500
  sendTransaction: (n) => o.sendTransaction({ ...n, summary: "Latch lock", source: "live" })
1501
1501
  };
1502
- }, [t, e?.adapter]);
1502
+ }, [e, t?.adapter]);
1503
1503
  }
1504
- function on(t) {
1505
- return P(() => t === null ? Promise.resolve(null) : t.getAccount(), [t], { refetchIntervalMs: 4e3 });
1504
+ function on(e) {
1505
+ return $(() => e === null ? Promise.resolve(null) : e.getAccount(), [e], { refetchIntervalMs: 4e3 });
1506
1506
  }
1507
- function an(t, e) {
1508
- return P(
1507
+ function an(e, t) {
1508
+ return $(
1509
1509
  async () => {
1510
1510
  const [o, n] = await Promise.all([
1511
- e.positionLock === null ? Promise.resolve(null) : le(t, e.positionLock),
1512
- e.tokenLock === null ? Promise.resolve(null) : le(t, e.tokenLock)
1511
+ t.positionLock === null ? Promise.resolve(null) : lt(e, t.positionLock),
1512
+ t.tokenLock === null ? Promise.resolve(null) : lt(e, t.tokenLock)
1513
1513
  ]);
1514
1514
  return { position: o, token: n };
1515
1515
  },
1516
- [t, e.positionLock, e.tokenLock],
1517
- { enabled: e.positionLock !== null || e.tokenLock !== null, refetchIntervalMs: 6e4 }
1516
+ [e, t.positionLock, t.tokenLock],
1517
+ { enabled: t.positionLock !== null || t.tokenLock !== null, refetchIntervalMs: 6e4 }
1518
1518
  );
1519
1519
  }
1520
- function sn(t, e, o) {
1521
- return P(
1520
+ function sn(e, t, o) {
1521
+ return $(
1522
1522
  async () => {
1523
- const n = o, [a, i, s] = await Promise.all([
1524
- dt(t),
1525
- e.positionLock === null ? Promise.resolve([]) : pt(t, e.positionLock, n),
1526
- e.tokenLock === null ? Promise.resolve({ locks: [] }) : mt(t, e.tokenLock, n)
1523
+ const n = o, [i, a, s] = await Promise.all([
1524
+ de(e),
1525
+ t.positionLock === null ? Promise.resolve([]) : pe(e, t.positionLock, n),
1526
+ t.tokenLock === null ? Promise.resolve({ locks: [] }) : me(e, t.tokenLock, n)
1527
1527
  ]);
1528
- return { positions: i, tokens: s.locks, now: a };
1528
+ return { positions: a, tokens: s.locks, now: i };
1529
1529
  },
1530
- [t, e.positionLock, e.tokenLock, o],
1531
- { enabled: o !== null && (e.positionLock !== null || e.tokenLock !== null), refetchIntervalMs: 6e4 }
1530
+ [e, t.positionLock, t.tokenLock, o],
1531
+ { enabled: o !== null && (t.positionLock !== null || t.tokenLock !== null), refetchIntervalMs: 6e4 }
1532
1532
  );
1533
1533
  }
1534
1534
  class V extends Error {
1535
1535
  hash;
1536
- constructor(e) {
1537
- super(`The transaction ${e.slice(0, 10)}… was mined and reverted.`), this.name = "TransactionRevertedError", this.hash = e;
1536
+ constructor(t) {
1537
+ super(`The transaction ${t.slice(0, 10)}… was mined and reverted.`), this.name = "TransactionRevertedError", this.hash = t;
1538
1538
  }
1539
1539
  }
1540
- async function rn(t, e, o, n) {
1541
- await t.call({ account: o, to: n.to, data: n.data, value: n.value });
1542
- const a = await e.sendTransaction({ to: n.to, data: n.data, value: n.value });
1543
- if ((await t.waitForTransactionReceipt({ hash: a })).status !== "success") throw new V(a);
1544
- return a;
1540
+ async function rn(e, t, o, n) {
1541
+ await e.call({ account: o, to: n.to, data: n.data, value: n.value });
1542
+ const i = await t.sendTransaction({ to: n.to, data: n.data, value: n.value });
1543
+ if ((await e.waitForTransactionReceipt({ hash: i })).status !== "success") throw new V(i);
1544
+ return i;
1545
1545
  }
1546
- function cn(t, e, o, n) {
1547
- const [a, i] = he({ k: "idle" }), s = et(!1), r = ue(
1546
+ function cn(e, t, o, n) {
1547
+ const [i, a] = ht({ k: "idle" }), s = te(!1), r = ut(
1548
1548
  async (c) => {
1549
1549
  if (s.current) return;
1550
1550
  const d = c.map((u) => u.label);
1551
- if (e === null || o === null) {
1552
- i({ k: "failed", labels: d, active: 0, message: "Connect a wallet first." });
1551
+ if (t === null || o === null) {
1552
+ a({ k: "failed", labels: d, active: 0, message: "Connect a wallet first." });
1553
1553
  return;
1554
1554
  }
1555
1555
  s.current = !0;
@@ -1557,57 +1557,57 @@ function cn(t, e, o, n) {
1557
1557
  let m = 0;
1558
1558
  try {
1559
1559
  for (; m < c.length; m++) {
1560
- i({ k: "running", labels: d, active: m, phase: "simulating" });
1560
+ a({ k: "running", labels: d, active: m, phase: "simulating" });
1561
1561
  const u = await c[m].build();
1562
- await t.call({ account: o, to: u.to, data: u.data, value: u.value }), i({ k: "running", labels: d, active: m, phase: "signing" });
1563
- const h = await e.sendTransaction({ to: u.to, data: u.data, value: u.value });
1564
- if (i({ k: "running", labels: d, active: m, phase: "confirming" }), (await t.waitForTransactionReceipt({ hash: h })).status !== "success") throw new V(h);
1562
+ await e.call({ account: o, to: u.to, data: u.data, value: u.value }), a({ k: "running", labels: d, active: m, phase: "signing" });
1563
+ const h = await t.sendTransaction({ to: u.to, data: u.data, value: u.value });
1564
+ if (a({ k: "running", labels: d, active: m, phase: "confirming" }), (await e.waitForTransactionReceipt({ hash: h })).status !== "success") throw new V(h);
1565
1565
  p.push(h);
1566
1566
  }
1567
- i({ k: "done", labels: d, hashes: p }), n?.();
1567
+ a({ k: "done", labels: d, hashes: p }), n?.();
1568
1568
  } catch (u) {
1569
- i({ k: "failed", labels: d, active: m, message: u instanceof V ? u.message : ze(u, "transaction") });
1569
+ a({ k: "failed", labels: d, active: m, message: u instanceof V ? u.message : zt(u, "transaction") });
1570
1570
  } finally {
1571
1571
  s.current = !1;
1572
1572
  }
1573
1573
  },
1574
- [t, e, o, n]
1575
- ), l = ue(() => i({ k: "idle" }), []);
1576
- return { state: a, run: r, reset: l };
1574
+ [e, t, o, n]
1575
+ ), l = ut(() => a({ k: "idle" }), []);
1576
+ return { state: i, run: r, reset: l };
1577
1577
  }
1578
1578
  export {
1579
1579
  sn as A,
1580
- Ft as B,
1581
- Gt as C,
1582
- Kt as D,
1583
- Et as N,
1584
- en as P,
1585
- tn as T,
1580
+ Fe as B,
1581
+ Ge as C,
1582
+ Ke as D,
1583
+ Ee as N,
1584
+ tn as P,
1585
+ en as T,
1586
1586
  V as a,
1587
- Lt as b,
1588
- It as c,
1589
- vt as d,
1590
- gt as e,
1591
- ht as f,
1592
- Rt as g,
1593
- St as h,
1594
- _t as i,
1595
- jt as j,
1596
- Xt as k,
1597
- Vt as l,
1598
- Yt as m,
1599
- Qt as n,
1600
- zt as o,
1601
- Ht as p,
1602
- Jt as q,
1603
- Zt as r,
1587
+ Ie as b,
1588
+ Le as c,
1589
+ ve as d,
1590
+ ge as e,
1591
+ he as f,
1592
+ Re as g,
1593
+ Se as h,
1594
+ _e as i,
1595
+ je as j,
1596
+ Xe as k,
1597
+ Ve as l,
1598
+ Ye as m,
1599
+ Qe as n,
1600
+ ze as o,
1601
+ He as p,
1602
+ Je as q,
1603
+ Ze as r,
1604
1604
  rn as s,
1605
- Wt as t,
1606
- Ut as u,
1607
- qt as v,
1605
+ We as t,
1606
+ Ue as u,
1607
+ qe as v,
1608
1608
  on as w,
1609
1609
  an as x,
1610
1610
  cn as y,
1611
1611
  nn as z
1612
1612
  };
1613
- //# sourceMappingURL=useLocker-D1c_NTk-.js.map
1613
+ //# sourceMappingURL=useLocker-CGpgCh75.js.map