@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/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
TypeScript SDK for [Logswap](https://logswap.org), the liquidity
|
|
4
4
|
primitive introducing the **logarithmic invariant** — typed wrappers over the `CPoolManager` /
|
|
5
|
-
`FPoolManager` / `
|
|
5
|
+
`FPoolManager` / `Router` / `Lens` surface.
|
|
6
6
|
|
|
7
7
|
**Status: identity, reads and writes for both singletons.** Indexer next.
|
|
8
8
|
|
|
@@ -58,7 +58,12 @@ What changes for a consumer:
|
|
|
58
58
|
longer an indexed topic, so `discoverMarkets({ base })` filters it client-side. Both managers emit `PoolCreated`, so an
|
|
59
59
|
indexer table is prefixed by its contract (`allCPoolManagerPoolCreateds`, `allFPoolManagerPoolCreateds`).
|
|
60
60
|
- **Router.** The named entries pass the tokens the caller expects (`WrongToken` on a mismatch); `execute` batches
|
|
61
|
-
carry the pool id in each action. `
|
|
61
|
+
carry the pool id in each action. `LogswapRouter` is `Router` and `LogswapLens` is `Lens` (the ABI exports are `routerAbi` / `lensAbi`;
|
|
62
|
+
the `logswap*` names stay as deprecated aliases for one minor). The router runs the trade path inline (swap, mint, zap-in, quote);
|
|
63
|
+
the management of an existing position (burn, claim, update, move, createMarket, F zap-out and roll-in) is `LiquidityFacet`, reached
|
|
64
|
+
by `fallback` at the same router address, so `routerAbi` is the merge and Permit2 still has one spender. `facetC()` is
|
|
65
|
+
`liquidityFacet()`; the `encode*` helpers left the contract for the ABI-only `routerActionsAbi`. Prefer the managers directly when
|
|
66
|
+
you need no recipient, deadline or Permit2 (decision 091).
|
|
62
67
|
- **Layout.** F `getPool` has `swapFee` / `mintFee` as `uint56`; the `extsload` words are in the contracts' `FPoolState`.
|
|
63
68
|
|
|
64
69
|
## Who may create what: the gate, the menus (C version 7, F version 26)
|
package/dist/actions.js
CHANGED
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
* hand-written and a struct change is a `tsc`/vector failure, not a runtime surprise.
|
|
19
19
|
*/
|
|
20
20
|
import { encodeAbiParameters } from "viem";
|
|
21
|
-
import {
|
|
21
|
+
import { routerAbi, routerActionsAbi } from "./generated.js";
|
|
22
22
|
import { poolId as keyId } from "./keys.js";
|
|
23
23
|
import { NO_CAP } from "./ids.js";
|
|
24
24
|
import { resolveDeadline, resolveRecipient, sendRouterWriteWithPermits, simulateRouterWrite } from "./write.js";
|
|
@@ -39,9 +39,9 @@ export var Op;
|
|
|
39
39
|
})(Op || (Op = {}));
|
|
40
40
|
/* payload encoding ========================================================== */
|
|
41
41
|
function payloadType(encoder) {
|
|
42
|
-
const f =
|
|
42
|
+
const f = routerActionsAbi.find((x) => x.type === "function" && x.name === encoder);
|
|
43
43
|
if (!f?.inputs)
|
|
44
|
-
throw new Error(`logswap:
|
|
44
|
+
throw new Error(`logswap: RouterActions has no ${encoder} — SDK and contracts disagree`);
|
|
45
45
|
return f.inputs;
|
|
46
46
|
}
|
|
47
47
|
const enc = (encoder, value) => encodeAbiParameters(payloadType(encoder), [value]);
|
|
@@ -126,13 +126,13 @@ export function settleOnly(key, recipient, side, b = {}) {
|
|
|
126
126
|
export async function execute(c, a) {
|
|
127
127
|
const settle = { ...a.settle, recipient: a.settle.recipient ?? resolveRecipient(c, a) };
|
|
128
128
|
const pull = a.pullTokens ?? settle.tokens.filter((_, i) => settle.maxIn[i] > 0n);
|
|
129
|
-
return sendRouterWriteWithPermits(c, { abi:
|
|
129
|
+
return sendRouterWriteWithPermits(c, { abi: routerAbi, functionName: "execute", args: [a.actions, settle, resolveDeadline(a)] }, [...pull]);
|
|
130
130
|
}
|
|
131
131
|
/** Simulate a batch: the per-action returns and the signed flows (+ = paid in), without sending. */
|
|
132
132
|
export async function simulateExecute(c, a) {
|
|
133
133
|
const settle = { ...a.settle, recipient: a.settle.recipient ?? a.account ?? resolveRecipient(c, a) };
|
|
134
134
|
const [results, flows] = await simulateRouterWrite(c, {
|
|
135
|
-
abi:
|
|
135
|
+
abi: routerAbi,
|
|
136
136
|
functionName: "execute",
|
|
137
137
|
args: [a.actions, settle, resolveDeadline(a)],
|
|
138
138
|
account: a.account,
|
package/dist/claims.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* - a FEE claim — `claimFees`, withdrawing accrued quote while the position stays whole
|
|
6
6
|
* - a TOKEN claim — a bearer IOU (bit-255-clear id) for inventory parked inside the manager
|
|
7
7
|
*/
|
|
8
|
-
import { cPoolManagerAbi,
|
|
8
|
+
import { cPoolManagerAbi, routerAbi } from "./generated.js";
|
|
9
9
|
import { poolId as keyId } from "./keys.js";
|
|
10
10
|
import { isPosition } from "./ids.js";
|
|
11
11
|
import { requireWallet, resolveDeadline, resolveRecipient, sendRouterWrite } from "./write.js";
|
|
@@ -25,7 +25,7 @@ export async function claimFees(c, a) {
|
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
27
|
return sendRouterWrite(c, {
|
|
28
|
-
abi:
|
|
28
|
+
abi: routerAbi,
|
|
29
29
|
functionName: "claim",
|
|
30
30
|
args: [keyId(a.key), a.key.quote, a.ids, resolveRecipient(c, a), resolveDeadline(a)],
|
|
31
31
|
});
|
package/dist/client.js
CHANGED
|
@@ -255,17 +255,17 @@ export async function assertVersion(c, expected = EXPECTED_VERSION) {
|
|
|
255
255
|
* reverts because the router's Permit2 is not the one the user approved.
|
|
256
256
|
*/
|
|
257
257
|
export async function assertWiring(c) {
|
|
258
|
-
const {
|
|
258
|
+
const { routerAbi, lensAbi } = await import("./generated.js");
|
|
259
259
|
const rd = (address, abi, functionName) => c.public.readContract({ address, abi, functionName });
|
|
260
260
|
const ZERO = "0x0000000000000000000000000000000000000000";
|
|
261
261
|
const want = [
|
|
262
|
-
["router.mgr()", rd(c.addresses.router,
|
|
263
|
-
["router.permit2()", rd(c.addresses.router,
|
|
264
|
-
["lens.mgr()", rd(c.addresses.lens,
|
|
262
|
+
["router.mgr()", rd(c.addresses.router, routerAbi, "mgr"), c.addresses.cPoolManager],
|
|
263
|
+
["router.permit2()", rd(c.addresses.router, routerAbi, "permit2"), c.addresses.permit2 ?? ZERO],
|
|
264
|
+
["lens.mgr()", rd(c.addresses.lens, lensAbi, "mgr"), c.addresses.cPoolManager],
|
|
265
265
|
];
|
|
266
266
|
if (c.addresses.fPoolManager) {
|
|
267
|
-
want.push(["router.fmgr()", rd(c.addresses.router,
|
|
268
|
-
want.push(["lens.fmgr()", rd(c.addresses.lens,
|
|
267
|
+
want.push(["router.fmgr()", rd(c.addresses.router, routerAbi, "fmgr"), c.addresses.fPoolManager]);
|
|
268
|
+
want.push(["lens.fmgr()", rd(c.addresses.lens, lensAbi, "fmgr"), c.addresses.fPoolManager]);
|
|
269
269
|
}
|
|
270
270
|
const got = await Promise.all(want.map((w) => w[1]));
|
|
271
271
|
const bad = want.flatMap(([what, , expected], i) => got[i].toLowerCase() === expected.toLowerCase() ? [] : [`${what} is ${got[i]}, expected ${expected}`]);
|
package/dist/fpool.js
CHANGED
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
* `addresses.router`.
|
|
31
31
|
*/
|
|
32
32
|
import { decodeAbiParameters, encodeAbiParameters, encodeFunctionData, erc20Abi, keccak256, toFunctionSelector } from "viem";
|
|
33
|
-
import { fPoolManagerAbi,
|
|
33
|
+
import { fPoolManagerAbi, lensAbi, routerAbi, padPolicyAbi, polPolicyAbi, policyRegistryAbi, privatePolicyAbi, publicPolicyAbi } from "./generated.js";
|
|
34
34
|
/**
|
|
35
35
|
* One contract, one ABI (F version 12): `harvest`, `claim`, `retire`, `regenerate`,
|
|
36
36
|
* `setLegs`, the names, the fee parameters are `FPoolManager`'s own code. The roles left it for
|
|
@@ -63,7 +63,7 @@ export const ASK_MINT = 2;
|
|
|
63
63
|
async function rawFPool(c, poolId) {
|
|
64
64
|
const [p] = await c.public.readContract({
|
|
65
65
|
address: c.addresses.lens,
|
|
66
|
-
abi:
|
|
66
|
+
abi: lensAbi,
|
|
67
67
|
functionName: "getFPools",
|
|
68
68
|
args: [[poolId]],
|
|
69
69
|
});
|
|
@@ -75,7 +75,7 @@ async function rawFPool(c, poolId) {
|
|
|
75
75
|
export async function getFPool(c, poolId) {
|
|
76
76
|
const v = await c.public.readContract({
|
|
77
77
|
address: c.addresses.lens,
|
|
78
|
-
abi:
|
|
78
|
+
abi: lensAbi,
|
|
79
79
|
functionName: "fPool",
|
|
80
80
|
args: [poolId],
|
|
81
81
|
});
|
|
@@ -283,10 +283,10 @@ export function fPoolPreviewMintQuote(st, dL) {
|
|
|
283
283
|
*/
|
|
284
284
|
export async function fPoolPreviewZapIn(c, poolId, dL) {
|
|
285
285
|
// read-only lives on the LENS (the router's F flows moved to a facet; its previews came here)
|
|
286
|
-
const {
|
|
286
|
+
const { lensAbi } = await import("./generated.js");
|
|
287
287
|
return c.public.readContract({
|
|
288
288
|
address: c.addresses.lens,
|
|
289
|
-
abi:
|
|
289
|
+
abi: lensAbi,
|
|
290
290
|
functionName: "previewZapIn",
|
|
291
291
|
args: [poolId, dL],
|
|
292
292
|
});
|
|
@@ -325,7 +325,7 @@ a) {
|
|
|
325
325
|
export async function fPoolPreviewZapOut(c, a) {
|
|
326
326
|
const { result } = await c.public.simulateContract({
|
|
327
327
|
address: c.addresses.router,
|
|
328
|
-
abi:
|
|
328
|
+
abi: routerAbi,
|
|
329
329
|
functionName: "zapOut",
|
|
330
330
|
args: [a.poolId, a.shares, a.tokenOut, 0n, a.account, defaultDeadline()],
|
|
331
331
|
account: a.account,
|
|
@@ -354,10 +354,10 @@ export async function fPoolRollIn(c, a) {
|
|
|
354
354
|
* seed.
|
|
355
355
|
*/
|
|
356
356
|
export async function fPoolPreviewRollIn(c, poolId, gen, holder, shares) {
|
|
357
|
-
const {
|
|
357
|
+
const { lensAbi } = await import("./generated.js");
|
|
358
358
|
const [dL, quoteShort, quoteExcess] = (await c.public.readContract({
|
|
359
359
|
address: c.addresses.lens,
|
|
360
|
-
abi:
|
|
360
|
+
abi: lensAbi,
|
|
361
361
|
functionName: "previewRollIn",
|
|
362
362
|
args: [poolId, BigInt(gen), holder, shares],
|
|
363
363
|
}));
|
|
@@ -393,7 +393,7 @@ export async function fPoolDividendOf(c, poolId, holder, gen) {
|
|
|
393
393
|
const g = gen ?? (await fPoolGen(c, poolId));
|
|
394
394
|
return c.public.readContract({
|
|
395
395
|
address: c.addresses.lens,
|
|
396
|
-
abi:
|
|
396
|
+
abi: lensAbi,
|
|
397
397
|
functionName: "fDividendOf",
|
|
398
398
|
args: [poolId, BigInt(g), holder],
|
|
399
399
|
});
|
|
@@ -407,7 +407,7 @@ export async function fPoolLienOf(c, poolId, owner, gen) {
|
|
|
407
407
|
const g = gen ?? (await fPoolGen(c, poolId));
|
|
408
408
|
const [locker, amount, owed] = await c.public.readContract({
|
|
409
409
|
address: c.addresses.lens,
|
|
410
|
-
abi:
|
|
410
|
+
abi: lensAbi,
|
|
411
411
|
functionName: "fLienOf",
|
|
412
412
|
args: [fPoolShareId(poolId, g), owner],
|
|
413
413
|
});
|
|
@@ -487,14 +487,14 @@ pullTokens = []) {
|
|
|
487
487
|
const sigCalls = await permit2SigCalls(c, pullTokens).catch(fallBackUnlessRejected);
|
|
488
488
|
if (sigCalls.length) {
|
|
489
489
|
const { encodeFunctionData } = await import("viem");
|
|
490
|
-
const inner = encodeFunctionData({ abi:
|
|
490
|
+
const inner = encodeFunctionData({ abi: routerAbi, functionName, args });
|
|
491
491
|
fn = "multicall";
|
|
492
492
|
sendArgs = [[...sigCalls, inner]];
|
|
493
493
|
}
|
|
494
494
|
}
|
|
495
495
|
const { request } = await c.public.simulateContract({
|
|
496
496
|
address: c.addresses.router,
|
|
497
|
-
abi:
|
|
497
|
+
abi: routerAbi,
|
|
498
498
|
functionName: fn,
|
|
499
499
|
args: sendArgs,
|
|
500
500
|
account: signerFor(c, account),
|
|
@@ -595,7 +595,7 @@ export async function fPoolShareBalance(c, poolId, owner, gen) {
|
|
|
595
595
|
export async function fPoolBundleOf(c, poolId, gen) {
|
|
596
596
|
const [supply, quote, base] = await c.public.readContract({
|
|
597
597
|
address: c.addresses.lens,
|
|
598
|
-
abi:
|
|
598
|
+
abi: lensAbi,
|
|
599
599
|
functionName: "fBundleOf",
|
|
600
600
|
args: [poolId, BigInt(gen)],
|
|
601
601
|
});
|
|
@@ -603,10 +603,10 @@ export async function fPoolBundleOf(c, poolId, gen) {
|
|
|
603
603
|
}
|
|
604
604
|
/** A holder's claims on a pool's retired generations — one row per generation still held. */
|
|
605
605
|
export async function fPoolClaimsOf(c, poolId, owner) {
|
|
606
|
-
const {
|
|
606
|
+
const { lensAbi } = await import("./generated.js");
|
|
607
607
|
const rows = (await c.public.readContract({
|
|
608
608
|
address: c.addresses.lens,
|
|
609
|
-
abi:
|
|
609
|
+
abi: lensAbi,
|
|
610
610
|
functionName: "fClaimsOf",
|
|
611
611
|
args: [poolId, owner],
|
|
612
612
|
}));
|
|
@@ -647,7 +647,7 @@ export async function fPoolQuoteSwap(c, a) {
|
|
|
647
647
|
try {
|
|
648
648
|
await c.public.simulateContract({
|
|
649
649
|
address: c.addresses.router,
|
|
650
|
-
abi:
|
|
650
|
+
abi: routerAbi,
|
|
651
651
|
functionName: "quoteSwap",
|
|
652
652
|
// the taker matters only on a gated pool: the connected account, or the zero address
|
|
653
653
|
args: [a.poolId, a.kind, BigInt(a.j), BigInt(a.k ?? 0), a.amountIn, a.taker ?? c.wallet?.account?.address ?? ZERO_ADDRESS],
|
|
@@ -1506,11 +1506,11 @@ export async function fPoolShareHolders(c, poolIdHex, opts = {}) {
|
|
|
1506
1506
|
}
|
|
1507
1507
|
/** 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). */
|
|
1508
1508
|
export async function getFPoolsRaw(c, poolIds) {
|
|
1509
|
-
const {
|
|
1510
|
-
return (await c.public.readContract({ address: c.addresses.lens, abi:
|
|
1509
|
+
const { lensAbi } = await import("./generated.js");
|
|
1510
|
+
return (await c.public.readContract({ address: c.addresses.lens, abi: lensAbi, functionName: "getFPools", args: [poolIds] }));
|
|
1511
1511
|
}
|
|
1512
1512
|
/** Share value from the lens — (L + Q)/shares, WAD per share — the same figure as `fPoolShareValue`, from one source. */
|
|
1513
1513
|
export async function shareValueOnChain(c, poolId) {
|
|
1514
|
-
const {
|
|
1515
|
-
return (await c.public.readContract({ address: c.addresses.lens, abi:
|
|
1514
|
+
const { lensAbi } = await import("./generated.js");
|
|
1515
|
+
return (await c.public.readContract({ address: c.addresses.lens, abi: lensAbi, functionName: "shareValue", args: [poolId] }));
|
|
1516
1516
|
}
|