@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/src/indexer.ts
CHANGED
|
@@ -143,11 +143,11 @@ export async function indexerHealthy(url: string, signal?: AbortSignal): Promise
|
|
|
143
143
|
*/
|
|
144
144
|
export async function discoverMarketsIndexed(url: string, signal?: AbortSignal): Promise<DiscoveredMarket[]> {
|
|
145
145
|
const q = `{ allInitializes(first: 1000) { nodes {
|
|
146
|
-
poolId base quote tickSpacing
|
|
146
|
+
poolId base quote tickSpacing phi x0 blockNumber txHash
|
|
147
147
|
} } }`;
|
|
148
148
|
type Row = {
|
|
149
|
-
poolId: Hex; base: Hex; quote: Hex; tickSpacing: string;
|
|
150
|
-
|
|
149
|
+
poolId: Hex; base: Hex; quote: Hex; tickSpacing: string; phi: string;
|
|
150
|
+
x0: string; blockNumber: string; txHash: Hex;
|
|
151
151
|
};
|
|
152
152
|
const d = await gql<{ allInitializes: { nodes: Row[] } }>(url, q, undefined, signal);
|
|
153
153
|
return d.allInitializes.nodes.map((n) => {
|
|
@@ -155,9 +155,7 @@ export async function discoverMarketsIndexed(url: string, signal?: AbortSignal):
|
|
|
155
155
|
base: n.base as Address,
|
|
156
156
|
quote: n.quote as Address,
|
|
157
157
|
tickSpacing: BigInt(n.tickSpacing),
|
|
158
|
-
|
|
159
|
-
kappa: BigInt(n.kappa),
|
|
160
|
-
alpha: BigInt(n.alpha),
|
|
158
|
+
phi: BigInt(n.phi),
|
|
161
159
|
};
|
|
162
160
|
return {
|
|
163
161
|
key,
|
|
@@ -196,7 +194,7 @@ export async function discoverMarketsBest(
|
|
|
196
194
|
await c.public.readContract({
|
|
197
195
|
address: c.addresses.cPoolManager,
|
|
198
196
|
abi: cPoolManagerAbi,
|
|
199
|
-
functionName: "
|
|
197
|
+
functionName: "phiOf",
|
|
200
198
|
args: [m.key],
|
|
201
199
|
} as never);
|
|
202
200
|
return m;
|
package/src/keys.ts
CHANGED
|
@@ -22,12 +22,13 @@ export interface PoolKey {
|
|
|
22
22
|
quote: Address;
|
|
23
23
|
/** Log-tick spacing, WAD. The LP-boundary ladder — position floors and caps. */
|
|
24
24
|
tickSpacing: bigint;
|
|
25
|
-
/**
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
25
|
+
/**
|
|
26
|
+
* The swap fee, WAD, fixed for the life of the market: `FEE_MIN` (1 bp) ≤ φ ≤ `FEE_MAX` (25%),
|
|
27
|
+
* or `0n`, which selects `DEFAULT_FEE` (2 bp) at read time. Four fields since C version 4
|
|
28
|
+
* (decisions 042): `kappa` and `alpha` left with the variance kernel, and `phiMin` — a floor with
|
|
29
|
+
* nothing above it — became `phi`. Every pool id changed with the shape.
|
|
30
|
+
*/
|
|
31
|
+
phi: bigint;
|
|
31
32
|
}
|
|
32
33
|
|
|
33
34
|
const POOL_KEY_ABI = [
|
|
@@ -37,9 +38,7 @@ const POOL_KEY_ABI = [
|
|
|
37
38
|
{ name: "base", type: "address" },
|
|
38
39
|
{ name: "quote", type: "address" },
|
|
39
40
|
{ name: "tickSpacing", type: "int256" },
|
|
40
|
-
{ name: "
|
|
41
|
-
{ name: "kappa", type: "uint256" },
|
|
42
|
-
{ name: "alpha", type: "uint256" },
|
|
41
|
+
{ name: "phi", type: "uint256" },
|
|
43
42
|
],
|
|
44
43
|
},
|
|
45
44
|
] as const;
|
|
@@ -47,8 +46,8 @@ const POOL_KEY_ABI = [
|
|
|
47
46
|
/**
|
|
48
47
|
* `poolId = keccak256(abi.encode(key))` — the primary key of the entire read model.
|
|
49
48
|
*
|
|
50
|
-
* Note the zero-vs-default caveat the Solidity type documents:
|
|
51
|
-
*
|
|
49
|
+
* Note the zero-vs-default caveat the Solidity type documents: a `phi` of `0` resolves to
|
|
50
|
+
* `DEFAULT_FEE` at READ time, so a key carrying `0n` and one carrying the resolved default are
|
|
52
51
|
* DIFFERENT markets with different ids, even though they behave identically. Always address a
|
|
53
52
|
* market by the key it was initialized with.
|
|
54
53
|
*/
|
|
@@ -59,9 +58,7 @@ export function poolId(key: PoolKey): Hex {
|
|
|
59
58
|
base: key.base,
|
|
60
59
|
quote: key.quote,
|
|
61
60
|
tickSpacing: key.tickSpacing,
|
|
62
|
-
|
|
63
|
-
kappa: key.kappa,
|
|
64
|
-
alpha: key.alpha,
|
|
61
|
+
phi: key.phi,
|
|
65
62
|
},
|
|
66
63
|
]),
|
|
67
64
|
);
|
package/src/pools.ts
CHANGED
|
@@ -30,9 +30,8 @@ export interface PoolState {
|
|
|
30
30
|
reserveQuote: bigint;
|
|
31
31
|
/** Fee-per-unit-L accumulator: $\phi \cdot \mathrm{TV}(\log p)$. */
|
|
32
32
|
F: bigint;
|
|
33
|
-
/** Quadratic variation of log-price, $\Sigma = \
|
|
33
|
+
/** Quadratic variation of log-price, $\Sigma = \sum_{\text{swaps}} (\Delta x_{\text{swap}})^2$ — one term per swap (decisions 042). */
|
|
34
34
|
bigSigma: bigint;
|
|
35
|
-
sigma2Ema: bigint;
|
|
36
35
|
currentK: bigint;
|
|
37
36
|
protocolOwed: bigint;
|
|
38
37
|
minBackstopL: bigint;
|
|
@@ -50,12 +49,16 @@ export async function getPool(c: LogswapClient, key: PoolKey): Promise<PoolState
|
|
|
50
49
|
return v as unknown as PoolState;
|
|
51
50
|
}
|
|
52
51
|
|
|
53
|
-
/**
|
|
54
|
-
|
|
52
|
+
/**
|
|
53
|
+
* The market's fee: the key's `phi` with `0n` resolved to `DEFAULT_FEE`. Constant for the market's
|
|
54
|
+
* life (C version 4, decisions 042 — `phiEff` and the variance kernel before). Reverts for a key
|
|
55
|
+
* nobody initialized, which `discoverMarkets` relies on to drop a stale indexer's rows.
|
|
56
|
+
*/
|
|
57
|
+
export async function phiOf(c: LogswapClient, key: PoolKey): Promise<bigint> {
|
|
55
58
|
return c.public.readContract({
|
|
56
59
|
address: c.addresses.cPoolManager,
|
|
57
60
|
abi: cPoolManagerAbi,
|
|
58
|
-
functionName: "
|
|
61
|
+
functionName: "phiOf",
|
|
59
62
|
args: [key],
|
|
60
63
|
}) as Promise<bigint>;
|
|
61
64
|
}
|
|
@@ -134,9 +137,7 @@ export async function discoverMarkets(
|
|
|
134
137
|
base: a.base!,
|
|
135
138
|
quote: a.quote!,
|
|
136
139
|
tickSpacing: a.tickSpacing!,
|
|
137
|
-
|
|
138
|
-
kappa: a.kappa!,
|
|
139
|
-
alpha: a.alpha!,
|
|
140
|
+
phi: a.phi!,
|
|
140
141
|
};
|
|
141
142
|
return {
|
|
142
143
|
key,
|