@logswap/sdk 0.5.88 → 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 +24 -2
- package/dist/actions.d.ts +1 -1
- package/dist/actions.js +13 -12
- package/dist/claims.d.ts +1 -1
- package/dist/claims.js +4 -3
- package/dist/client.d.ts +1 -1
- package/dist/client.js +12 -8
- package/dist/fpool.d.ts +2 -2
- package/dist/fpool.js +27 -27
- package/dist/generated.d.ts +2950 -3945
- package/dist/generated.js +1862 -2341
- package/dist/history.js +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +3 -1
- package/dist/indexer.d.ts +1 -1
- package/dist/indexer.js +7 -7
- package/dist/liquidity.d.ts +4 -4
- package/dist/liquidity.js +27 -16
- package/dist/onboard.js +2 -2
- package/dist/pools.d.ts +19 -19
- package/dist/pools.js +19 -19
- package/dist/positions.js +9 -9
- package/dist/swap.d.ts +1 -1
- package/dist/swap.js +32 -11
- package/package.json +1 -1
- package/src/actions.ts +13 -13
- package/src/claims.ts +4 -4
- package/src/client.ts +12 -8
- package/src/fpool.ts +29 -29
- package/src/generated.ts +1867 -2344
- package/src/history.ts +1 -1
- package/src/index.ts +3 -1
- package/src/indexer.ts +8 -8
- package/src/liquidity.ts +29 -19
- package/src/onboard.ts +2 -2
- package/src/pools.ts +39 -38
- package/src/positions.ts +9 -9
- package/src/swap.ts +32 -12
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,9 +19,9 @@
|
|
|
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
|
-
import type
|
|
24
|
+
import { poolId as keyId, type PoolKey } from "./keys.js";
|
|
25
25
|
import { NO_CAP } from "./ids.js";
|
|
26
26
|
import type { Hop } from "./swap.js";
|
|
27
27
|
import { resolveDeadline, resolveRecipient, sendRouterWriteWithPermits, simulateRouterWrite, type WriteOptions } from "./write.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
|
|
|
@@ -69,31 +69,31 @@ const enc = (encoder: string, value: unknown): Hex => encodeAbiParameters(payloa
|
|
|
69
69
|
|
|
70
70
|
/** Mint exposure `L` at `targetFloor` (off-grid blends the two adjacent rungs), `cap` optional. */
|
|
71
71
|
export function mintAction(a: { key: PoolKey; targetFloor: bigint; cap?: bigint; L: bigint }): Action {
|
|
72
|
-
return { op: Op.MintBlended, data: enc("encodeMint", {
|
|
72
|
+
return { op: Op.MintBlended, data: enc("encodeMint", { poolId: keyId(a.key), targetFloor: a.targetFloor, cap: a.cap ?? NO_CAP, L: a.L }) };
|
|
73
73
|
}
|
|
74
74
|
|
|
75
75
|
/** Burn `shares[i]` of `ids[i]`; accrued fees are swept into the same batch. Needs the operator grant. */
|
|
76
76
|
export function burnAction(a: { key: PoolKey; ids: readonly bigint[]; shares: readonly bigint[] }): Action {
|
|
77
77
|
if (a.ids.length !== a.shares.length) throw new Error("logswap: ids and shares length mismatch");
|
|
78
|
-
return { op: Op.Burn, data: enc("encodeBurn", {
|
|
78
|
+
return { op: Op.Burn, data: enc("encodeBurn", { poolId: keyId(a.key), ids: a.ids, shares: a.shares }) };
|
|
79
79
|
}
|
|
80
80
|
|
|
81
81
|
/** Exact-in swap. `amountIn` may be `OPEN_DELTA`: the input an earlier action left the router holding. */
|
|
82
82
|
export function swapExactInAction(a: { key: PoolKey; baseIn: boolean; amountIn: bigint; minOut?: bigint }): Action {
|
|
83
|
-
return { op: Op.SwapExactIn, data: enc("encodeSwap", {
|
|
83
|
+
return { op: Op.SwapExactIn, data: enc("encodeSwap", { poolId: keyId(a.key), baseSide: a.baseIn, amount: a.amountIn, limit: a.minOut ?? 0n }) };
|
|
84
84
|
}
|
|
85
85
|
|
|
86
86
|
/** Exact-out swap. `amountOut` may be `OPEN_DELTA`: the output an earlier action left the router owing. */
|
|
87
87
|
export function swapExactOutAction(a: { key: PoolKey; baseOut: boolean; amountOut: bigint; maxIn?: bigint }): Action {
|
|
88
88
|
return {
|
|
89
89
|
op: Op.SwapExactOut,
|
|
90
|
-
data: enc("encodeSwap", {
|
|
90
|
+
data: enc("encodeSwap", { poolId: keyId(a.key), baseSide: a.baseOut, amount: a.amountOut, limit: a.maxIn ?? UNBOUNDED }),
|
|
91
91
|
};
|
|
92
92
|
}
|
|
93
93
|
|
|
94
94
|
/** Collect the caller's fees on `ids`; positions untouched. */
|
|
95
95
|
export function claimAction(a: { key: PoolKey; ids: readonly bigint[] }): Action {
|
|
96
|
-
return { op: Op.Claim, data: enc("encodeClaim", {
|
|
96
|
+
return { op: Op.Claim, data: enc("encodeClaim", { poolId: keyId(a.key), ids: a.ids }) };
|
|
97
97
|
}
|
|
98
98
|
|
|
99
99
|
/** The general edit — set `shares` of `fromId` to (`toFloor`, `toCap`, `newL`); `newL = 0` exits. */
|
|
@@ -108,7 +108,7 @@ export function updateAction(a: {
|
|
|
108
108
|
return {
|
|
109
109
|
op: Op.Update,
|
|
110
110
|
data: enc("encodeUpdate", {
|
|
111
|
-
|
|
111
|
+
poolId: keyId(a.key),
|
|
112
112
|
fromId: a.fromId,
|
|
113
113
|
shares: a.shares,
|
|
114
114
|
toFloor: a.toFloor,
|
|
@@ -121,7 +121,7 @@ export function updateAction(a: {
|
|
|
121
121
|
/** Multi-hop exact-in route; `amountIn` may be `OPEN_DELTA`. Intermediate tokens never move. */
|
|
122
122
|
export function pathAction(a: { hops: readonly Hop[]; amountIn: bigint; minOut?: bigint }): Action {
|
|
123
123
|
if (a.hops.length === 0) throw new Error("logswap: empty path");
|
|
124
|
-
return { op: Op.Path, data: enc("encodePath", { hops: a.hops, amountIn: a.amountIn, minOut: a.minOut ?? 0n }) };
|
|
124
|
+
return { op: Op.Path, data: enc("encodePath", { hops: a.hops.map((h) => ({ poolId: keyId(h.key), baseIn: h.baseIn })), amountIn: a.amountIn, minOut: a.minOut ?? 0n }) };
|
|
125
125
|
}
|
|
126
126
|
|
|
127
127
|
/* settlement builders ======================================================= */
|
|
@@ -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,9 +7,9 @@
|
|
|
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
|
-
import type
|
|
12
|
+
import { poolId as keyId, type PoolKey } from "./keys.js";
|
|
13
13
|
import { isPosition } from "./ids.js";
|
|
14
14
|
import { requireWallet, resolveDeadline, resolveRecipient, sendRouterWrite, type WriteOptions } from "./write.js";
|
|
15
15
|
|
|
@@ -36,9 +36,9 @@ 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
|
-
args: [a.key, a.ids, resolveRecipient(c, a), resolveDeadline(a)],
|
|
41
|
+
args: [keyId(a.key), a.key.quote, a.ids, resolveRecipient(c, a), resolveDeadline(a)],
|
|
42
42
|
});
|
|
43
43
|
}
|
|
44
44
|
|
package/src/client.ts
CHANGED
|
@@ -184,7 +184,11 @@ function guardChain(wallet: WalletClient, pub: PublicClient): WalletClient {
|
|
|
184
184
|
// takes no separate mint fee, `createMarket` neither; `getPool` drops `mintFee` and the gates' mint-fee menus are gone.
|
|
185
185
|
// Every C pool id moved.
|
|
186
186
|
// 12 (decisions 079-081): `Action` ordinals, the key is `CPoolKey` (names only). No pool id moved.
|
|
187
|
-
|
|
187
|
+
// 13 (decisions 088-090): a C pool is addressed by its `bytes32 poolId` after `initialize` (the key rides in calldata at `initialize`
|
|
188
|
+
// only; no pool id moved), the router's named entries take the tokens the caller expects (`WrongToken`), `claimById` / `burnById` /
|
|
189
|
+
// `claimManyFor` are `claim` / `burn` / `claimMany`, `mint(poolId, to, floor, cap, L)`, `MarketCreated` is `PoolCreated` (in F's field
|
|
190
|
+
// order), `x0` is `initialLogPrice`, `PoolView.x` / `.F` are `logPrice` / `feeGrowth`, `swapFee` / `mintFee` are `uint56`.
|
|
191
|
+
export const EXPECTED_VERSION = 13n;
|
|
188
192
|
/**
|
|
189
193
|
* The F manager's own tag (5 — the key's salt, pool names, the sponsor registry;
|
|
190
194
|
* 4 was the income-only harvest cut).
|
|
@@ -283,7 +287,7 @@ export const EXPECTED_VERSION = 12n;
|
|
|
283
287
|
// id moved); `initialize(key)`; `seed` / `retire` / `setLegs` are gone for `deployLiquidity(poolId, baseAssets,
|
|
284
288
|
// quoteAmount, lnCapOverSeed, to)` (it SETS THE BOOK on an unfunded or a live pool), `close(poolId, to)` and
|
|
285
289
|
// `regenerate(poolId, to)`; asset membership is fixed by the key; `LiquidityDeployed` echoes the input,
|
|
286
|
-
// `GenerationSeeded` / `LegsSet` are gone; the lens `fPool` field is `baseLegs
|
|
290
|
+
// `GenerationSeeded` / `LegsSet` are gone; the lens `fPool` field is `baseAssets` (`baseLegs` before decision 090), the cap `lnCapOverSeed`; the pot and the
|
|
287
291
|
// income fee are the income and the income tax (`IncomeReleased`, `incomeHeld`, `incomeTax`); a pad is uncapped.
|
|
288
292
|
// 39 (decision 087): `swapFeeB4B` is gone; base-for-base pays `swapFee` once, not 2·swapFee.
|
|
289
293
|
// A breaking bump: raised in the same change.
|
|
@@ -323,18 +327,18 @@ export async function assertVersion(c: LogswapClient, expected = EXPECTED_VERSIO
|
|
|
323
327
|
* reverts because the router's Permit2 is not the one the user approved.
|
|
324
328
|
*/
|
|
325
329
|
export async function assertWiring(c: LogswapClient): Promise<void> {
|
|
326
|
-
const {
|
|
330
|
+
const { routerAbi, lensAbi } = await import("./generated.js");
|
|
327
331
|
const rd = (address: Address, abi: readonly unknown[], functionName: string) =>
|
|
328
332
|
c.public.readContract({ address, abi, functionName } as never) as Promise<Address>;
|
|
329
333
|
const ZERO = "0x0000000000000000000000000000000000000000";
|
|
330
334
|
const want: Array<[string, Promise<Address>, Address]> = [
|
|
331
|
-
["router.mgr()", rd(c.addresses.router,
|
|
332
|
-
["router.permit2()", rd(c.addresses.router,
|
|
333
|
-
["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],
|
|
334
338
|
];
|
|
335
339
|
if (c.addresses.fPoolManager) {
|
|
336
|
-
want.push(["router.fmgr()", rd(c.addresses.router,
|
|
337
|
-
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]);
|
|
338
342
|
}
|
|
339
343
|
const got = await Promise.all(want.map((w) => w[1]));
|
|
340
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`,
|
|
@@ -67,8 +67,8 @@ export interface FPoolState {
|
|
|
67
67
|
poolId: Hex;
|
|
68
68
|
quote: Address;
|
|
69
69
|
bases: Address[];
|
|
70
|
-
/** WAD
|
|
71
|
-
|
|
70
|
+
/** Each base asset's fraction of the pool's `L`, WAD, summing to WAD, derived at each deployment (`weights` before decision 090). `L_j = liquidityWeight_j · L`. */
|
|
71
|
+
liquidityWeights: bigint[];
|
|
72
72
|
/** Per-asset log prices, WAD. Price is derived; `x` is the state. */
|
|
73
73
|
x: bigint[];
|
|
74
74
|
/** Quote reserve. The one leg a base→quote swap can exhaust. */
|
|
@@ -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
|
});
|
|
@@ -164,9 +164,9 @@ export async function getFPool(c: LogswapClient, poolId: Hex): Promise<FPoolStat
|
|
|
164
164
|
return {
|
|
165
165
|
poolId,
|
|
166
166
|
quote: p.quote,
|
|
167
|
-
bases: v.
|
|
168
|
-
|
|
169
|
-
x: v.
|
|
167
|
+
bases: v.baseAssets.map((l) => l.base),
|
|
168
|
+
liquidityWeights: v.baseAssets.map((l) => l.liquidityWeight),
|
|
169
|
+
x: v.baseAssets.map((l) => l.x), // derived by the manager: x_j = ln(w_j·L / R̃_j)
|
|
170
170
|
Q: p.Q,
|
|
171
171
|
L: p.L,
|
|
172
172
|
swapFee: p.swapFee,
|
|
@@ -185,9 +185,9 @@ export async function getFPool(c: LogswapClient, poolId: Hex): Promise<FPoolStat
|
|
|
185
185
|
seeded: p.seeded,
|
|
186
186
|
gen: Number(p.gen),
|
|
187
187
|
totalSupply: p.shares,
|
|
188
|
-
reserves: v.
|
|
189
|
-
virtualReserves: v.
|
|
190
|
-
kappa: v.
|
|
188
|
+
reserves: v.baseAssets.map((l) => l.reserve), // the state
|
|
189
|
+
virtualReserves: v.baseAssets.map((l) => l.virtualReserve),
|
|
190
|
+
kappa: v.baseAssets.map((l) => l.kappa),
|
|
191
191
|
};
|
|
192
192
|
}
|
|
193
193
|
|
|
@@ -355,7 +355,7 @@ export function fPoolShareValue(s: FPoolState): bigint {
|
|
|
355
355
|
v = s.Q;
|
|
356
356
|
for (let j = 0; j < s.reserves.length; j++) {
|
|
357
357
|
const rv = s.virtualReserves[j]!;
|
|
358
|
-
if (rv !== 0n) v += (((s.
|
|
358
|
+
if (rv !== 0n) v += (((s.liquidityWeights[j]! * s.L) / WAD) * s.reserves[j]!) / rv;
|
|
359
359
|
}
|
|
360
360
|
}
|
|
361
361
|
return (v * WAD) / s.totalSupply;
|
|
@@ -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
|
}
|