@logswap/sdk 0.5.44 → 0.5.45
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 +3 -3
- package/dist/admin.d.ts +6 -3
- package/dist/admin.js +7 -4
- package/dist/client.d.ts +6 -1
- package/dist/client.js +6 -1
- package/dist/generated.d.ts +70 -464
- package/dist/generated.js +72 -178
- package/dist/indexer.js +3 -5
- package/dist/keys.d.ts +9 -8
- package/dist/keys.js +4 -8
- package/dist/pools.d.ts +7 -4
- package/dist/pools.js +8 -6
- package/package.json +1 -1
- package/src/admin.ts +7 -4
- package/src/client.ts +6 -1
- package/src/generated.ts +72 -178
- package/src/indexer.ts +5 -7
- package/src/keys.ts +11 -14
- package/src/pools.ts +9 -8
package/dist/indexer.js
CHANGED
|
@@ -100,7 +100,7 @@ export async function indexerHealthy(url, signal) {
|
|
|
100
100
|
*/
|
|
101
101
|
export async function discoverMarketsIndexed(url, signal) {
|
|
102
102
|
const q = `{ allInitializes(first: 1000) { nodes {
|
|
103
|
-
poolId base quote tickSpacing
|
|
103
|
+
poolId base quote tickSpacing phi x0 blockNumber txHash
|
|
104
104
|
} } }`;
|
|
105
105
|
const d = await gql(url, q, undefined, signal);
|
|
106
106
|
return d.allInitializes.nodes.map((n) => {
|
|
@@ -108,9 +108,7 @@ export async function discoverMarketsIndexed(url, signal) {
|
|
|
108
108
|
base: n.base,
|
|
109
109
|
quote: n.quote,
|
|
110
110
|
tickSpacing: BigInt(n.tickSpacing),
|
|
111
|
-
|
|
112
|
-
kappa: BigInt(n.kappa),
|
|
113
|
-
alpha: BigInt(n.alpha),
|
|
111
|
+
phi: BigInt(n.phi),
|
|
114
112
|
};
|
|
115
113
|
return {
|
|
116
114
|
key,
|
|
@@ -142,7 +140,7 @@ export async function discoverMarketsBest(c, url, signal) {
|
|
|
142
140
|
await c.public.readContract({
|
|
143
141
|
address: c.addresses.cPoolManager,
|
|
144
142
|
abi: cPoolManagerAbi,
|
|
145
|
-
functionName: "
|
|
143
|
+
functionName: "phiOf",
|
|
146
144
|
args: [m.key],
|
|
147
145
|
});
|
|
148
146
|
return m;
|
package/dist/keys.d.ts
CHANGED
|
@@ -20,18 +20,19 @@ export interface PoolKey {
|
|
|
20
20
|
quote: Address;
|
|
21
21
|
/** Log-tick spacing, WAD. The LP-boundary ladder — position floors and caps. */
|
|
22
22
|
tickSpacing: bigint;
|
|
23
|
-
/**
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
23
|
+
/**
|
|
24
|
+
* The swap fee, WAD, fixed for the life of the market: `FEE_MIN` (1 bp) ≤ φ ≤ `FEE_MAX` (25%),
|
|
25
|
+
* or `0n`, which selects `DEFAULT_FEE` (2 bp) at read time. Four fields since C version 4
|
|
26
|
+
* (decisions 042): `kappa` and `alpha` left with the variance kernel, and `phiMin` — a floor with
|
|
27
|
+
* nothing above it — became `phi`. Every pool id changed with the shape.
|
|
28
|
+
*/
|
|
29
|
+
phi: bigint;
|
|
29
30
|
}
|
|
30
31
|
/**
|
|
31
32
|
* `poolId = keccak256(abi.encode(key))` — the primary key of the entire read model.
|
|
32
33
|
*
|
|
33
|
-
* Note the zero-vs-default caveat the Solidity type documents:
|
|
34
|
-
*
|
|
34
|
+
* Note the zero-vs-default caveat the Solidity type documents: a `phi` of `0` resolves to
|
|
35
|
+
* `DEFAULT_FEE` at READ time, so a key carrying `0n` and one carrying the resolved default are
|
|
35
36
|
* DIFFERENT markets with different ids, even though they behave identically. Always address a
|
|
36
37
|
* market by the key it was initialized with.
|
|
37
38
|
*/
|
package/dist/keys.js
CHANGED
|
@@ -18,17 +18,15 @@ const POOL_KEY_ABI = [
|
|
|
18
18
|
{ name: "base", type: "address" },
|
|
19
19
|
{ name: "quote", type: "address" },
|
|
20
20
|
{ name: "tickSpacing", type: "int256" },
|
|
21
|
-
{ name: "
|
|
22
|
-
{ name: "kappa", type: "uint256" },
|
|
23
|
-
{ name: "alpha", type: "uint256" },
|
|
21
|
+
{ name: "phi", type: "uint256" },
|
|
24
22
|
],
|
|
25
23
|
},
|
|
26
24
|
];
|
|
27
25
|
/**
|
|
28
26
|
* `poolId = keccak256(abi.encode(key))` — the primary key of the entire read model.
|
|
29
27
|
*
|
|
30
|
-
* Note the zero-vs-default caveat the Solidity type documents:
|
|
31
|
-
*
|
|
28
|
+
* Note the zero-vs-default caveat the Solidity type documents: a `phi` of `0` resolves to
|
|
29
|
+
* `DEFAULT_FEE` at READ time, so a key carrying `0n` and one carrying the resolved default are
|
|
32
30
|
* DIFFERENT markets with different ids, even though they behave identically. Always address a
|
|
33
31
|
* market by the key it was initialized with.
|
|
34
32
|
*/
|
|
@@ -38,9 +36,7 @@ export function poolId(key) {
|
|
|
38
36
|
base: key.base,
|
|
39
37
|
quote: key.quote,
|
|
40
38
|
tickSpacing: key.tickSpacing,
|
|
41
|
-
|
|
42
|
-
kappa: key.kappa,
|
|
43
|
-
alpha: key.alpha,
|
|
39
|
+
phi: key.phi,
|
|
44
40
|
},
|
|
45
41
|
]));
|
|
46
42
|
}
|
package/dist/pools.d.ts
CHANGED
|
@@ -26,9 +26,8 @@ export interface PoolState {
|
|
|
26
26
|
reserveQuote: bigint;
|
|
27
27
|
/** Fee-per-unit-L accumulator: $\phi \cdot \mathrm{TV}(\log p)$. */
|
|
28
28
|
F: bigint;
|
|
29
|
-
/** Quadratic variation of log-price, $\Sigma = \
|
|
29
|
+
/** Quadratic variation of log-price, $\Sigma = \sum_{\text{swaps}} (\Delta x_{\text{swap}})^2$ — one term per swap (decisions 042). */
|
|
30
30
|
bigSigma: bigint;
|
|
31
|
-
sigma2Ema: bigint;
|
|
32
31
|
currentK: bigint;
|
|
33
32
|
protocolOwed: bigint;
|
|
34
33
|
minBackstopL: bigint;
|
|
@@ -36,8 +35,12 @@ export interface PoolState {
|
|
|
36
35
|
}
|
|
37
36
|
/** Read a market's full state by key. */
|
|
38
37
|
export declare function getPool(c: LogswapClient, key: PoolKey): Promise<PoolState>;
|
|
39
|
-
/**
|
|
40
|
-
|
|
38
|
+
/**
|
|
39
|
+
* The market's fee: the key's `phi` with `0n` resolved to `DEFAULT_FEE`. Constant for the market's
|
|
40
|
+
* life (C version 4, decisions 042 — `phiEff` and the variance kernel before). Reverts for a key
|
|
41
|
+
* nobody initialized, which `discoverMarkets` relies on to drop a stale indexer's rows.
|
|
42
|
+
*/
|
|
43
|
+
export declare function phiOf(c: LogswapClient, key: PoolKey): Promise<bigint>;
|
|
41
44
|
/**
|
|
42
45
|
* Price from the stored log-price. **Lossy** — `x` is exact and this is a float, so use it for
|
|
43
46
|
* display and never for arithmetic you intend to send back on-chain.
|
package/dist/pools.js
CHANGED
|
@@ -25,12 +25,16 @@ export async function getPool(c, key) {
|
|
|
25
25
|
});
|
|
26
26
|
return v;
|
|
27
27
|
}
|
|
28
|
-
/**
|
|
29
|
-
|
|
28
|
+
/**
|
|
29
|
+
* The market's fee: the key's `phi` with `0n` resolved to `DEFAULT_FEE`. Constant for the market's
|
|
30
|
+
* life (C version 4, decisions 042 — `phiEff` and the variance kernel before). Reverts for a key
|
|
31
|
+
* nobody initialized, which `discoverMarkets` relies on to drop a stale indexer's rows.
|
|
32
|
+
*/
|
|
33
|
+
export async function phiOf(c, key) {
|
|
30
34
|
return c.public.readContract({
|
|
31
35
|
address: c.addresses.cPoolManager,
|
|
32
36
|
abi: cPoolManagerAbi,
|
|
33
|
-
functionName: "
|
|
37
|
+
functionName: "phiOf",
|
|
34
38
|
args: [key],
|
|
35
39
|
});
|
|
36
40
|
}
|
|
@@ -88,9 +92,7 @@ export async function discoverMarkets(c, opts = {}) {
|
|
|
88
92
|
base: a.base,
|
|
89
93
|
quote: a.quote,
|
|
90
94
|
tickSpacing: a.tickSpacing,
|
|
91
|
-
|
|
92
|
-
kappa: a.kappa,
|
|
93
|
-
alpha: a.alpha,
|
|
95
|
+
phi: a.phi,
|
|
94
96
|
};
|
|
95
97
|
return {
|
|
96
98
|
key,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@logswap/sdk",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.45",
|
|
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/admin.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* admin — the protocol's (feeCollector's) writes: the protocol's cuts, the harvest-cut exemption,
|
|
3
3
|
* and the two-step collector handover, on both managers. Plain writes to the managers; no router.
|
|
4
|
-
* One vocabulary (decisions 040): the
|
|
5
|
-
*
|
|
4
|
+
* One vocabulary (decisions 040): both managers call the protocol's cut of the mint fee
|
|
5
|
+
* `MINT_FEE_PROTOCOL_CUT` and set it through `setFeeParams` — one cut on C (since version 4,
|
|
6
|
+
* decisions 042; `setProtocolFeeCut` / `PROTOCOL_FEE_CUT` before), two on F.
|
|
6
7
|
*/
|
|
7
8
|
|
|
8
9
|
import type { Address, Hash, Hex } from "viem";
|
|
@@ -14,9 +15,11 @@ function wallet(c: LogswapClient) {
|
|
|
14
15
|
return c.wallet;
|
|
15
16
|
}
|
|
16
17
|
|
|
17
|
-
|
|
18
|
-
|
|
18
|
+
/** The C manager's `setFeeParams(mintFeeProtocolCut)` — one cut. */
|
|
19
|
+
export async function setFeeParamsC(c: LogswapClient, mintFeeProtocolCutWad: bigint): Promise<Hash> {
|
|
20
|
+
return wallet(c).writeContract({ address: c.addresses.cPoolManager, abi: cPoolManagerAbi, functionName: "setFeeParams", args: [mintFeeProtocolCutWad], chain: c.wallet!.chain, account: c.wallet!.account! } as never);
|
|
19
21
|
}
|
|
22
|
+
/** The F manager's `setFeeParams(mintFeeProtocolCut, harvestProtocolCut)` — two cuts. */
|
|
20
23
|
export async function setFeeParams(c: LogswapClient, mintFeeProtocolCutWad: bigint, harvestProtocolCutWad: bigint): Promise<Hash> {
|
|
21
24
|
return wallet(c).writeContract({ address: c.addresses.fPoolManager as Address, abi: fPoolManagerAbi, functionName: "setFeeParams", args: [mintFeeProtocolCutWad, harvestProtocolCutWad], chain: c.wallet!.chain, account: c.wallet!.account! } as never);
|
|
22
25
|
}
|
package/src/client.ts
CHANGED
|
@@ -58,8 +58,13 @@ export function createLogswapClient(args: {
|
|
|
58
58
|
* **3** since 2026-09-03 (contracts `d8406fb`): `burnById` and `update` take an `owner`, `update`
|
|
59
59
|
* mints to `to`, `positions()` returns `aps` as uint128 — and a returned quote flow now carries the
|
|
60
60
|
* swept fees (decisions 018), which is why `exit`'s settle-to-one-asset math changed with it.
|
|
61
|
+
*
|
|
62
|
+
* **4** since 2026-09-18 (decisions 042 + 040): `PoolKey` is `(base, quote, tickSpacing, phi)` —
|
|
63
|
+
* the variance kernel and its two key fields are gone, so every pool id changed; `phiEff` is
|
|
64
|
+
* `phiOf`; `getPool` lost `sigma2Ema`; `Initialize` lost two fields; the cut is
|
|
65
|
+
* `MINT_FEE_PROTOCOL_CUT` / `setFeeParams`.
|
|
61
66
|
*/
|
|
62
|
-
export const EXPECTED_VERSION =
|
|
67
|
+
export const EXPECTED_VERSION = 4n;
|
|
63
68
|
/**
|
|
64
69
|
* The F manager's own tag (contracts 25a7bcf: 5 — the key's salt, pool names, the sponsor registry;
|
|
65
70
|
* 4 was the income-only harvest cut).
|