@logswap/sdk 0.5.89 → 0.5.90
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -2
- package/dist/actions.js +5 -5
- package/dist/claims.js +2 -2
- package/dist/client.js +6 -6
- package/dist/fpool.js +20 -20
- package/dist/generated.d.ts +2674 -2670
- package/dist/generated.js +1694 -1688
- package/dist/index.d.ts +3 -1
- package/dist/index.js +3 -1
- package/dist/indexer.js +2 -2
- package/dist/liquidity.js +8 -8
- package/dist/onboard.js +2 -2
- package/dist/pools.js +4 -4
- package/dist/positions.js +6 -6
- package/dist/swap.js +6 -6
- package/package.json +1 -1
- package/src/actions.ts +5 -5
- package/src/claims.ts +2 -2
- package/src/client.ts +6 -6
- package/src/fpool.ts +20 -20
- package/src/generated.ts +1696 -1688
- package/src/index.ts +3 -1
- package/src/indexer.ts +2 -2
- package/src/liquidity.ts +8 -8
- package/src/onboard.ts +2 -2
- package/src/pools.ts +4 -4
- package/src/positions.ts +6 -6
- package/src/swap.ts +6 -6
package/dist/index.d.ts
CHANGED
|
@@ -23,5 +23,7 @@ export * from "./fpool.js";
|
|
|
23
23
|
export * from "./fees.js";
|
|
24
24
|
export * from "./history.js";
|
|
25
25
|
export * from "./views.js";
|
|
26
|
-
export { cPoolManagerAbi, fPoolManagerAbi,
|
|
26
|
+
export { cPoolManagerAbi, fPoolManagerAbi, lensAbi, routerAbi, routerActionsAbi, padPolicyAbi, polPolicyAbi, policyRegistryAbi, privatePolicyAbi, publicPolicyAbi } from "./generated.js";
|
|
27
|
+
/** @deprecated the `Logswap` prefix is gone (decision 091): use `routerAbi` / `lensAbi`. Removed in the next minor. */
|
|
28
|
+
export { routerAbi as logswapRouterAbi, lensAbi as logswapLensAbi } from "./generated.js";
|
|
27
29
|
export * from "./admin.js";
|
package/dist/index.js
CHANGED
|
@@ -23,5 +23,7 @@ export * from "./fpool.js";
|
|
|
23
23
|
export * from "./fees.js";
|
|
24
24
|
export * from "./history.js";
|
|
25
25
|
export * from "./views.js";
|
|
26
|
-
export { cPoolManagerAbi, fPoolManagerAbi,
|
|
26
|
+
export { cPoolManagerAbi, fPoolManagerAbi, lensAbi, routerAbi, routerActionsAbi, padPolicyAbi, polPolicyAbi, policyRegistryAbi, privatePolicyAbi, publicPolicyAbi } from "./generated.js";
|
|
27
|
+
/** @deprecated the `Logswap` prefix is gone (decision 091): use `routerAbi` / `lensAbi`. Removed in the next minor. */
|
|
28
|
+
export { routerAbi as logswapRouterAbi, lensAbi as logswapLensAbi } from "./generated.js";
|
|
27
29
|
export * from "./admin.js";
|
package/dist/indexer.js
CHANGED
|
@@ -191,10 +191,10 @@ export async function discoverMarketsBest(c, url = c.indexerUrl, signal) {
|
|
|
191
191
|
* use the indexed `poolPositions` and fall back to this when the indexer is missing or stale.
|
|
192
192
|
*/
|
|
193
193
|
export async function poolPositionsFromChain(c, key, x) {
|
|
194
|
-
const {
|
|
194
|
+
const { lensAbi } = await import("./generated.js");
|
|
195
195
|
const floors = (await c.public.readContract({
|
|
196
196
|
address: c.addresses.lens,
|
|
197
|
-
abi:
|
|
197
|
+
abi: lensAbi,
|
|
198
198
|
functionName: "liveTicks",
|
|
199
199
|
args: [poolId(key)],
|
|
200
200
|
}));
|
package/dist/liquidity.js
CHANGED
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
* the exact flows, mint fee and swept fees included — and is what an editor shows before its one
|
|
22
22
|
* apply.
|
|
23
23
|
*/
|
|
24
|
-
import {
|
|
24
|
+
import { lensAbi, routerAbi } from "./generated.js";
|
|
25
25
|
import { poolId as keyId } from "./keys.js";
|
|
26
26
|
import { NO_CAP } from "./ids.js";
|
|
27
27
|
import { describeId, getPositionClass } from "./positions.js";
|
|
@@ -40,7 +40,7 @@ import { quoteExactIn, quoteExactOut } from "./swap.js";
|
|
|
40
40
|
*/
|
|
41
41
|
export async function mint(c, a) {
|
|
42
42
|
return sendRouterWriteWithPermits(c, {
|
|
43
|
-
abi:
|
|
43
|
+
abi: routerAbi,
|
|
44
44
|
functionName: "mintBlended",
|
|
45
45
|
args: [
|
|
46
46
|
keyId(a.key),
|
|
@@ -68,7 +68,7 @@ export async function mint(c, a) {
|
|
|
68
68
|
*/
|
|
69
69
|
export async function createMarket(c, a) {
|
|
70
70
|
return sendRouterWriteWithPermits(c, {
|
|
71
|
-
abi:
|
|
71
|
+
abi: routerAbi,
|
|
72
72
|
functionName: "createMarket",
|
|
73
73
|
args: [
|
|
74
74
|
a.key,
|
|
@@ -92,7 +92,7 @@ export async function createMarket(c, a) {
|
|
|
92
92
|
*/
|
|
93
93
|
export async function zapIn(c, a) {
|
|
94
94
|
return sendRouterWriteWithPermits(c, {
|
|
95
|
-
abi:
|
|
95
|
+
abi: routerAbi,
|
|
96
96
|
functionName: "zapIn",
|
|
97
97
|
args: [
|
|
98
98
|
keyId(a.key),
|
|
@@ -113,7 +113,7 @@ export async function zapIn(c, a) {
|
|
|
113
113
|
/** The primitive, through the router's named entry: resize and reposition in one call, in kind. */
|
|
114
114
|
export async function update(c, a) {
|
|
115
115
|
return sendRouterWriteWithPermits(c, {
|
|
116
|
-
abi:
|
|
116
|
+
abi: routerAbi,
|
|
117
117
|
functionName: "update",
|
|
118
118
|
args: [
|
|
119
119
|
keyId(a.key),
|
|
@@ -140,7 +140,7 @@ export async function update(c, a) {
|
|
|
140
140
|
*/
|
|
141
141
|
export async function move(c, a) {
|
|
142
142
|
return sendRouterWrite(c, {
|
|
143
|
-
abi:
|
|
143
|
+
abi: routerAbi,
|
|
144
144
|
functionName: "move",
|
|
145
145
|
args: [
|
|
146
146
|
keyId(a.key),
|
|
@@ -162,7 +162,7 @@ export async function previewEdit(c, a) {
|
|
|
162
162
|
const holder = a.holder ?? requireWallet(c).address;
|
|
163
163
|
const r = (await c.public.readContract({
|
|
164
164
|
address: c.addresses.lens,
|
|
165
|
-
abi:
|
|
165
|
+
abi: lensAbi,
|
|
166
166
|
functionName: "previewUpdate",
|
|
167
167
|
args: [keyId(a.key), a.fromId, holder, a.shares, a.toFloor, a.toCap ?? NO_CAP, a.newL],
|
|
168
168
|
}));
|
|
@@ -323,7 +323,7 @@ export async function burn(c, a) {
|
|
|
323
323
|
if (a.ids.length !== a.shares.length)
|
|
324
324
|
throw new Error("logswap: ids and shares length mismatch");
|
|
325
325
|
return sendRouterWrite(c, {
|
|
326
|
-
abi:
|
|
326
|
+
abi: routerAbi,
|
|
327
327
|
functionName: "burn",
|
|
328
328
|
args: [
|
|
329
329
|
keyId(a.key),
|
package/dist/onboard.js
CHANGED
|
@@ -191,9 +191,9 @@ export async function permit2SigCalls(c, tokens) {
|
|
|
191
191
|
message,
|
|
192
192
|
});
|
|
193
193
|
const { encodeFunctionData } = await import("viem");
|
|
194
|
-
const {
|
|
194
|
+
const { routerAbi } = await import("./generated.js");
|
|
195
195
|
calls.push(encodeFunctionData({
|
|
196
|
-
abi:
|
|
196
|
+
abi: routerAbi,
|
|
197
197
|
functionName: "applyPermit2",
|
|
198
198
|
args: [owner, message, signature],
|
|
199
199
|
}));
|
package/dist/pools.js
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
* conversion is. Prefer comparing in log space when precision matters.
|
|
13
13
|
*/
|
|
14
14
|
import { formatUnits } from "viem";
|
|
15
|
-
import {
|
|
15
|
+
import { lensAbi, cPoolManagerAbi } from "./generated.js";
|
|
16
16
|
import { clientChainId } from "./client.js";
|
|
17
17
|
import { signerFor } from "./write.js";
|
|
18
18
|
import { readCachedToken, registerCacheClear, writeCachedToken } from "./tokencache.js";
|
|
@@ -22,7 +22,7 @@ import { getEventLogs } from "./history.js";
|
|
|
22
22
|
export async function getPool(c, key) {
|
|
23
23
|
const v = (await c.public.readContract({
|
|
24
24
|
address: c.addresses.lens,
|
|
25
|
-
abi:
|
|
25
|
+
abi: lensAbi,
|
|
26
26
|
functionName: "getPools",
|
|
27
27
|
args: [[poolId(key)]],
|
|
28
28
|
}));
|
|
@@ -155,7 +155,7 @@ export async function discoverMarkets(c, opts = {}) {
|
|
|
155
155
|
export async function liveFloors(c, key) {
|
|
156
156
|
return c.public.readContract({
|
|
157
157
|
address: c.addresses.lens,
|
|
158
|
-
abi:
|
|
158
|
+
abi: lensAbi,
|
|
159
159
|
functionName: "liveTicks",
|
|
160
160
|
args: [poolId(key)],
|
|
161
161
|
});
|
|
@@ -164,7 +164,7 @@ export async function liveFloors(c, key) {
|
|
|
164
164
|
export async function isValidFloor(c, key, floor) {
|
|
165
165
|
return c.public.readContract({
|
|
166
166
|
address: c.addresses.lens,
|
|
167
|
-
abi:
|
|
167
|
+
abi: lensAbi,
|
|
168
168
|
functionName: "isValidFloor",
|
|
169
169
|
args: [poolId(key), floor],
|
|
170
170
|
});
|
package/dist/positions.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* accounts holding the same class can have different claimable amounts.
|
|
7
7
|
*/
|
|
8
8
|
import { encodeAbiParameters, keccak256, parseAbiItem } from "viem";
|
|
9
|
-
import {
|
|
9
|
+
import { lensAbi, cPoolManagerAbi } from "./generated.js";
|
|
10
10
|
import { MINT_FEE_MAX, poolId } from "./keys.js";
|
|
11
11
|
/** `CPoolState.POSITIONS_SLOT`: the manager's `positions` mapping (`forge inspect CPoolManager storageLayout`). */
|
|
12
12
|
const C_POSITIONS_SLOT = 4n;
|
|
@@ -50,7 +50,7 @@ export async function balanceOf(c, owner, id) {
|
|
|
50
50
|
export async function feesOf(c, id, owner) {
|
|
51
51
|
return c.public.readContract({
|
|
52
52
|
address: c.addresses.lens,
|
|
53
|
-
abi:
|
|
53
|
+
abi: lensAbi,
|
|
54
54
|
functionName: "feesOfById",
|
|
55
55
|
args: [id, owner],
|
|
56
56
|
});
|
|
@@ -92,7 +92,7 @@ export async function getHolderPosition(c, key, owner, floor, cap = NO_CAP) {
|
|
|
92
92
|
export async function describeId(c, id, tickSpacing) {
|
|
93
93
|
const r = (await c.public.readContract({
|
|
94
94
|
address: c.addresses.lens,
|
|
95
|
-
abi:
|
|
95
|
+
abi: lensAbi,
|
|
96
96
|
functionName: "unpack",
|
|
97
97
|
args: [id],
|
|
98
98
|
}));
|
|
@@ -175,7 +175,7 @@ export function mintFee(p, x, rate) {
|
|
|
175
175
|
export async function positionsOf(c, key, owner) {
|
|
176
176
|
const rows = (await c.public.readContract({
|
|
177
177
|
address: c.addresses.lens,
|
|
178
|
-
abi:
|
|
178
|
+
abi: lensAbi,
|
|
179
179
|
functionName: "positionsOf",
|
|
180
180
|
args: [poolId(key), owner],
|
|
181
181
|
}));
|
|
@@ -216,7 +216,7 @@ export async function holdingsOf(c, key, owner, fromBlock, opts = {}) {
|
|
|
216
216
|
// one lens call: balance, class L, fees, floor and cap for every id the owner holds
|
|
217
217
|
const rows = (await c.public.readContract({
|
|
218
218
|
address: c.addresses.lens,
|
|
219
|
-
abi:
|
|
219
|
+
abi: lensAbi,
|
|
220
220
|
functionName: "heldByIds",
|
|
221
221
|
args: [poolId(key), owner, ids],
|
|
222
222
|
}));
|
|
@@ -227,7 +227,7 @@ export async function holdingsOf(c, key, owner, fromBlock, opts = {}) {
|
|
|
227
227
|
export async function legsOf(c, key, id, holder) {
|
|
228
228
|
const [base, quote, fees, value] = (await c.public.readContract({
|
|
229
229
|
address: c.addresses.lens,
|
|
230
|
-
abi:
|
|
230
|
+
abi: lensAbi,
|
|
231
231
|
functionName: "legsOf",
|
|
232
232
|
args: [poolId(key), id, holder],
|
|
233
233
|
}));
|
package/dist/swap.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* merged `swap(key, baseSide, amount, limit)` uses a NEGATIVE amount for exact-out; that convention
|
|
6
6
|
* is deliberately not exposed here — callers say `swapExactOut`.
|
|
7
7
|
*/
|
|
8
|
-
import {
|
|
8
|
+
import { lensAbi, routerAbi } from "./generated.js";
|
|
9
9
|
import { poolId as keyId } from "./keys.js";
|
|
10
10
|
import { resolveDeadline, resolveRecipient, sendRouterWrite, sendRouterWriteWithPermits } from "./write.js";
|
|
11
11
|
/**
|
|
@@ -18,7 +18,7 @@ import { resolveDeadline, resolveRecipient, sendRouterWrite, sendRouterWriteWith
|
|
|
18
18
|
export async function quoteExactIn(c, key, baseIn, amountIn) {
|
|
19
19
|
const { result } = await c.public.simulateContract({
|
|
20
20
|
address: c.addresses.lens,
|
|
21
|
-
abi:
|
|
21
|
+
abi: lensAbi,
|
|
22
22
|
functionName: "previewSwapExactIn",
|
|
23
23
|
args: [keyId(key), baseIn, amountIn],
|
|
24
24
|
});
|
|
@@ -28,7 +28,7 @@ export async function quoteExactIn(c, key, baseIn, amountIn) {
|
|
|
28
28
|
export async function quoteExactOut(c, key, baseOut, amountOut) {
|
|
29
29
|
const { result } = await c.public.simulateContract({
|
|
30
30
|
address: c.addresses.lens,
|
|
31
|
-
abi:
|
|
31
|
+
abi: lensAbi,
|
|
32
32
|
functionName: "previewSwapExactOut",
|
|
33
33
|
args: [keyId(key), baseOut, amountOut],
|
|
34
34
|
});
|
|
@@ -36,7 +36,7 @@ export async function quoteExactOut(c, key, baseOut, amountOut) {
|
|
|
36
36
|
}
|
|
37
37
|
export async function swapExactIn(c, a) {
|
|
38
38
|
return sendRouterWriteWithPermits(c, {
|
|
39
|
-
abi:
|
|
39
|
+
abi: routerAbi,
|
|
40
40
|
functionName: "swapExactIn",
|
|
41
41
|
args: [
|
|
42
42
|
keyId(a.key),
|
|
@@ -52,7 +52,7 @@ export async function swapExactIn(c, a) {
|
|
|
52
52
|
}
|
|
53
53
|
export async function swapExactOut(c, a) {
|
|
54
54
|
return sendRouterWriteWithPermits(c, {
|
|
55
|
-
abi:
|
|
55
|
+
abi: routerAbi,
|
|
56
56
|
functionName: "swapExactOut",
|
|
57
57
|
args: [
|
|
58
58
|
keyId(a.key),
|
|
@@ -78,7 +78,7 @@ export async function swapExactInPath(c, a) {
|
|
|
78
78
|
if (a.hops.length === 0)
|
|
79
79
|
throw new Error("logswap: empty path");
|
|
80
80
|
return sendRouterWrite(c, {
|
|
81
|
-
abi:
|
|
81
|
+
abi: routerAbi,
|
|
82
82
|
functionName: "swapExactInPath",
|
|
83
83
|
args: [
|
|
84
84
|
a.hops.map((h) => ({ poolId: keyId(h.key), baseIn: h.baseIn })),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@logswap/sdk",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.90",
|
|
4
4
|
"description": "TypeScript SDK for Logswap, the liquidity primitive introducing the logarithmic invariant — typed wrappers over the CPoolManager / FPoolManager / Router / Lens surface.",
|
|
5
5
|
"license": "GPL-2.0-or-later",
|
|
6
6
|
"type": "module",
|
package/src/actions.ts
CHANGED
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
*/
|
|
20
20
|
|
|
21
21
|
import { encodeAbiParameters, type Address, type Hash, type Hex } from "viem";
|
|
22
|
-
import {
|
|
22
|
+
import { routerAbi, routerActionsAbi } from "./generated.js";
|
|
23
23
|
import type { LogswapClient } from "./client.js";
|
|
24
24
|
import { poolId as keyId, type PoolKey } from "./keys.js";
|
|
25
25
|
import { NO_CAP } from "./ids.js";
|
|
@@ -58,10 +58,10 @@ export interface Settle {
|
|
|
58
58
|
/* payload encoding ========================================================== */
|
|
59
59
|
|
|
60
60
|
function payloadType(encoder: string) {
|
|
61
|
-
const f = (
|
|
61
|
+
const f = (routerActionsAbi as readonly { type: string; name?: string; inputs?: readonly unknown[] }[]).find(
|
|
62
62
|
(x) => x.type === "function" && x.name === encoder,
|
|
63
63
|
);
|
|
64
|
-
if (!f?.inputs) throw new Error(`logswap:
|
|
64
|
+
if (!f?.inputs) throw new Error(`logswap: RouterActions has no ${encoder} — SDK and contracts disagree`);
|
|
65
65
|
return f.inputs;
|
|
66
66
|
}
|
|
67
67
|
|
|
@@ -186,7 +186,7 @@ export async function execute(c: LogswapClient, a: ExecuteArgs): Promise<Hash> {
|
|
|
186
186
|
const pull = a.pullTokens ?? settle.tokens.filter((_, i) => settle.maxIn[i]! > 0n);
|
|
187
187
|
return sendRouterWriteWithPermits(
|
|
188
188
|
c,
|
|
189
|
-
{ abi:
|
|
189
|
+
{ abi: routerAbi, functionName: "execute", args: [a.actions, settle, resolveDeadline(a)] },
|
|
190
190
|
[...pull],
|
|
191
191
|
);
|
|
192
192
|
}
|
|
@@ -198,7 +198,7 @@ export async function simulateExecute(
|
|
|
198
198
|
): Promise<{ results: readonly Hex[]; flows: readonly bigint[] }> {
|
|
199
199
|
const settle: Settle = { ...a.settle, recipient: a.settle.recipient ?? a.account ?? resolveRecipient(c, a) };
|
|
200
200
|
const [results, flows] = await simulateRouterWrite<readonly [readonly Hex[], readonly bigint[]]>(c, {
|
|
201
|
-
abi:
|
|
201
|
+
abi: routerAbi,
|
|
202
202
|
functionName: "execute",
|
|
203
203
|
args: [a.actions, settle, resolveDeadline(a)],
|
|
204
204
|
account: a.account,
|
package/src/claims.ts
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
import type { Address, Hash } from "viem";
|
|
10
|
-
import { cPoolManagerAbi,
|
|
10
|
+
import { cPoolManagerAbi, routerAbi } from "./generated.js";
|
|
11
11
|
import type { LogswapClient } from "./client.js";
|
|
12
12
|
import { poolId as keyId, type PoolKey } from "./keys.js";
|
|
13
13
|
import { isPosition } from "./ids.js";
|
|
@@ -36,7 +36,7 @@ export async function claimFees(c: LogswapClient, a: ClaimFeesArgs): Promise<Has
|
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
38
|
return sendRouterWrite(c, {
|
|
39
|
-
abi:
|
|
39
|
+
abi: routerAbi,
|
|
40
40
|
functionName: "claim",
|
|
41
41
|
args: [keyId(a.key), a.key.quote, a.ids, resolveRecipient(c, a), resolveDeadline(a)],
|
|
42
42
|
});
|
package/src/client.ts
CHANGED
|
@@ -327,18 +327,18 @@ export async function assertVersion(c: LogswapClient, expected = EXPECTED_VERSIO
|
|
|
327
327
|
* reverts because the router's Permit2 is not the one the user approved.
|
|
328
328
|
*/
|
|
329
329
|
export async function assertWiring(c: LogswapClient): Promise<void> {
|
|
330
|
-
const {
|
|
330
|
+
const { routerAbi, lensAbi } = await import("./generated.js");
|
|
331
331
|
const rd = (address: Address, abi: readonly unknown[], functionName: string) =>
|
|
332
332
|
c.public.readContract({ address, abi, functionName } as never) as Promise<Address>;
|
|
333
333
|
const ZERO = "0x0000000000000000000000000000000000000000";
|
|
334
334
|
const want: Array<[string, Promise<Address>, Address]> = [
|
|
335
|
-
["router.mgr()", rd(c.addresses.router,
|
|
336
|
-
["router.permit2()", rd(c.addresses.router,
|
|
337
|
-
["lens.mgr()", rd(c.addresses.lens,
|
|
335
|
+
["router.mgr()", rd(c.addresses.router, routerAbi, "mgr"), c.addresses.cPoolManager],
|
|
336
|
+
["router.permit2()", rd(c.addresses.router, routerAbi, "permit2"), c.addresses.permit2 ?? ZERO],
|
|
337
|
+
["lens.mgr()", rd(c.addresses.lens, lensAbi, "mgr"), c.addresses.cPoolManager],
|
|
338
338
|
];
|
|
339
339
|
if (c.addresses.fPoolManager) {
|
|
340
|
-
want.push(["router.fmgr()", rd(c.addresses.router,
|
|
341
|
-
want.push(["lens.fmgr()", rd(c.addresses.lens,
|
|
340
|
+
want.push(["router.fmgr()", rd(c.addresses.router, routerAbi, "fmgr"), c.addresses.fPoolManager]);
|
|
341
|
+
want.push(["lens.fmgr()", rd(c.addresses.lens, lensAbi, "fmgr"), c.addresses.fPoolManager]);
|
|
342
342
|
}
|
|
343
343
|
const got = await Promise.all(want.map((w) => w[1]));
|
|
344
344
|
const bad = want.flatMap(([what, , expected], i) =>
|
package/src/fpool.ts
CHANGED
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
*/
|
|
32
32
|
|
|
33
33
|
import { decodeAbiParameters, encodeAbiParameters, encodeFunctionData, erc20Abi, keccak256, toFunctionSelector, type Address, type Hash, type Hex } from "viem";
|
|
34
|
-
import { fPoolManagerAbi,
|
|
34
|
+
import { fPoolManagerAbi, lensAbi, routerAbi, padPolicyAbi, polPolicyAbi, policyRegistryAbi, privatePolicyAbi, publicPolicyAbi } from "./generated.js";
|
|
35
35
|
|
|
36
36
|
/**
|
|
37
37
|
* One contract, one ABI (F version 12): `harvest`, `claim`, `retire`, `regenerate`,
|
|
@@ -137,7 +137,7 @@ export interface FPoolState {
|
|
|
137
137
|
async function rawFPool(c: LogswapClient, poolId: Hex) {
|
|
138
138
|
const [p] = await c.public.readContract({
|
|
139
139
|
address: c.addresses.lens,
|
|
140
|
-
abi:
|
|
140
|
+
abi: lensAbi,
|
|
141
141
|
functionName: "getFPools",
|
|
142
142
|
args: [[poolId]],
|
|
143
143
|
});
|
|
@@ -149,7 +149,7 @@ async function rawFPool(c: LogswapClient, poolId: Hex) {
|
|
|
149
149
|
export async function getFPool(c: LogswapClient, poolId: Hex): Promise<FPoolState> {
|
|
150
150
|
const v = await c.public.readContract({
|
|
151
151
|
address: c.addresses.lens,
|
|
152
|
-
abi:
|
|
152
|
+
abi: lensAbi,
|
|
153
153
|
functionName: "fPool",
|
|
154
154
|
args: [poolId],
|
|
155
155
|
});
|
|
@@ -468,10 +468,10 @@ export function fPoolPreviewMintQuote(st: Pick<FPoolState, "Q" | "L">, dL: bigin
|
|
|
468
468
|
*/
|
|
469
469
|
export async function fPoolPreviewZapIn(c: LogswapClient, poolId: Hex, dL: bigint): Promise<bigint> {
|
|
470
470
|
// read-only lives on the LENS (the router's F flows moved to a facet; its previews came here)
|
|
471
|
-
const {
|
|
471
|
+
const { lensAbi } = await import("./generated.js");
|
|
472
472
|
return c.public.readContract({
|
|
473
473
|
address: c.addresses.lens,
|
|
474
|
-
abi:
|
|
474
|
+
abi: lensAbi,
|
|
475
475
|
functionName: "previewZapIn",
|
|
476
476
|
args: [poolId, dL],
|
|
477
477
|
} as never) as Promise<bigint>;
|
|
@@ -532,7 +532,7 @@ export async function fPoolPreviewZapOut(
|
|
|
532
532
|
): Promise<bigint> {
|
|
533
533
|
const { result } = await c.public.simulateContract({
|
|
534
534
|
address: c.addresses.router,
|
|
535
|
-
abi:
|
|
535
|
+
abi: routerAbi,
|
|
536
536
|
functionName: "zapOut",
|
|
537
537
|
args: [a.poolId, a.shares, a.tokenOut, 0n, a.account, defaultDeadline()],
|
|
538
538
|
account: a.account,
|
|
@@ -588,10 +588,10 @@ export async function fPoolPreviewRollIn(
|
|
|
588
588
|
holder: Address,
|
|
589
589
|
shares: bigint,
|
|
590
590
|
): Promise<{ dL: bigint; quoteShort: bigint; quoteExcess: bigint }> {
|
|
591
|
-
const {
|
|
591
|
+
const { lensAbi } = await import("./generated.js");
|
|
592
592
|
const [dL, quoteShort, quoteExcess] = (await c.public.readContract({
|
|
593
593
|
address: c.addresses.lens,
|
|
594
|
-
abi:
|
|
594
|
+
abi: lensAbi,
|
|
595
595
|
functionName: "previewRollIn",
|
|
596
596
|
args: [poolId, BigInt(gen), holder, shares],
|
|
597
597
|
} as never)) as readonly [bigint, bigint, bigint];
|
|
@@ -631,7 +631,7 @@ export async function fPoolDividendOf(c: LogswapClient, poolId: Hex, holder: Add
|
|
|
631
631
|
const g = gen ?? (await fPoolGen(c, poolId));
|
|
632
632
|
return c.public.readContract({
|
|
633
633
|
address: c.addresses.lens,
|
|
634
|
-
abi:
|
|
634
|
+
abi: lensAbi,
|
|
635
635
|
functionName: "fDividendOf",
|
|
636
636
|
args: [poolId, BigInt(g), holder],
|
|
637
637
|
});
|
|
@@ -660,7 +660,7 @@ export async function fPoolLienOf(c: LogswapClient, poolId: Hex, owner: Address,
|
|
|
660
660
|
const g = gen ?? (await fPoolGen(c, poolId));
|
|
661
661
|
const [locker, amount, owed] = await c.public.readContract({
|
|
662
662
|
address: c.addresses.lens,
|
|
663
|
-
abi:
|
|
663
|
+
abi: lensAbi,
|
|
664
664
|
functionName: "fLienOf",
|
|
665
665
|
args: [fPoolShareId(poolId, g), owner],
|
|
666
666
|
});
|
|
@@ -757,14 +757,14 @@ async function writeRouter(
|
|
|
757
757
|
const sigCalls = await permit2SigCalls(c, pullTokens).catch(fallBackUnlessRejected);
|
|
758
758
|
if (sigCalls.length) {
|
|
759
759
|
const { encodeFunctionData } = await import("viem");
|
|
760
|
-
const inner = encodeFunctionData({ abi:
|
|
760
|
+
const inner = encodeFunctionData({ abi: routerAbi, functionName, args } as never);
|
|
761
761
|
fn = "multicall";
|
|
762
762
|
sendArgs = [[...sigCalls, inner]];
|
|
763
763
|
}
|
|
764
764
|
}
|
|
765
765
|
const { request } = await c.public.simulateContract({
|
|
766
766
|
address: c.addresses.router,
|
|
767
|
-
abi:
|
|
767
|
+
abi: routerAbi,
|
|
768
768
|
functionName: fn,
|
|
769
769
|
args: sendArgs,
|
|
770
770
|
account: signerFor(c, account),
|
|
@@ -882,7 +882,7 @@ export async function fPoolBundleOf(
|
|
|
882
882
|
): Promise<{ supply: bigint; quote: bigint; base: bigint[] }> {
|
|
883
883
|
const [supply, quote, base] = await c.public.readContract({
|
|
884
884
|
address: c.addresses.lens,
|
|
885
|
-
abi:
|
|
885
|
+
abi: lensAbi,
|
|
886
886
|
functionName: "fBundleOf",
|
|
887
887
|
args: [poolId, BigInt(gen)],
|
|
888
888
|
});
|
|
@@ -900,10 +900,10 @@ export interface FPoolClaimRow {
|
|
|
900
900
|
|
|
901
901
|
/** A holder's claims on a pool's retired generations — one row per generation still held. */
|
|
902
902
|
export async function fPoolClaimsOf(c: LogswapClient, poolId: Hex, owner: Address): Promise<FPoolClaimRow[]> {
|
|
903
|
-
const {
|
|
903
|
+
const { lensAbi } = await import("./generated.js");
|
|
904
904
|
const rows = (await c.public.readContract({
|
|
905
905
|
address: c.addresses.lens,
|
|
906
|
-
abi:
|
|
906
|
+
abi: lensAbi,
|
|
907
907
|
functionName: "fClaimsOf",
|
|
908
908
|
args: [poolId, owner],
|
|
909
909
|
} as never)) as readonly { gen: bigint; shares: bigint; base: readonly bigint[]; quote: bigint; dividend: bigint }[];
|
|
@@ -954,7 +954,7 @@ export async function fPoolQuoteSwap(
|
|
|
954
954
|
try {
|
|
955
955
|
await c.public.simulateContract({
|
|
956
956
|
address: c.addresses.router,
|
|
957
|
-
abi:
|
|
957
|
+
abi: routerAbi,
|
|
958
958
|
functionName: "quoteSwap",
|
|
959
959
|
// the taker matters only on a gated pool: the connected account, or the zero address
|
|
960
960
|
args: [a.poolId, a.kind, BigInt(a.j), BigInt(a.k ?? 0), a.amountIn, a.taker ?? c.wallet?.account?.address ?? ZERO_ADDRESS],
|
|
@@ -2138,12 +2138,12 @@ export interface FPolicyTerms {
|
|
|
2138
2138
|
|
|
2139
2139
|
/** Every F pool's raw state in one lens call (the manager's `Pool` struct: quote, swapFee, policy, seeded, gen, n, restructureTime, asks, lnCapOverSeed, Q, realizedVariance, L, shares, refLogFloor). */
|
|
2140
2140
|
export async function getFPoolsRaw(c: LogswapClient, poolIds: Hex[]): Promise<readonly unknown[]> {
|
|
2141
|
-
const {
|
|
2142
|
-
return (await c.public.readContract({ address: c.addresses.lens, abi:
|
|
2141
|
+
const { lensAbi } = await import("./generated.js");
|
|
2142
|
+
return (await c.public.readContract({ address: c.addresses.lens, abi: lensAbi, functionName: "getFPools", args: [poolIds] } as never)) as readonly unknown[];
|
|
2143
2143
|
}
|
|
2144
2144
|
|
|
2145
2145
|
/** Share value from the lens — (L + Q)/shares, WAD per share — the same figure as `fPoolShareValue`, from one source. */
|
|
2146
2146
|
export async function shareValueOnChain(c: LogswapClient, poolId: Hex): Promise<bigint> {
|
|
2147
|
-
const {
|
|
2148
|
-
return (await c.public.readContract({ address: c.addresses.lens, abi:
|
|
2147
|
+
const { lensAbi } = await import("./generated.js");
|
|
2148
|
+
return (await c.public.readContract({ address: c.addresses.lens, abi: lensAbi, functionName: "shareValue", args: [poolId] } as never)) as bigint;
|
|
2149
2149
|
}
|