@logswap/sdk 0.5.71 → 0.5.73

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/src/indexer.ts CHANGED
@@ -184,16 +184,16 @@ export async function indexerHealthy(url: string, signal?: AbortSignal): Promise
184
184
  */
185
185
  export async function discoverMarketsIndexed(url: string, signal?: AbortSignal): Promise<DiscoveredMarket[]> {
186
186
  type Row = {
187
- poolId: Hex; base: Hex; quote: Hex; tickSpacing: string; phi: string;
187
+ poolId: Hex; base: Hex; quote: Hex; tickSpacing: string; swapFee: string;
188
188
  x0: string; blockNumber: string; txHash: Hex; contractAddress: Hex;
189
189
  };
190
- const nodes = await gqlAll<Row>(url, "allInitializes", "poolId base quote tickSpacing phi x0 blockNumber txHash contractAddress", { signal });
190
+ const nodes = await gqlAll<Row>(url, "allInitializes", "poolId base quote tickSpacing swapFee x0 blockNumber txHash contractAddress", { signal });
191
191
  return nodes.map((n) => {
192
192
  const key: PoolKey = {
193
193
  base: n.base as Address,
194
194
  quote: n.quote as Address,
195
195
  tickSpacing: BigInt(n.tickSpacing),
196
- phi: BigInt(n.phi),
196
+ swapFee: BigInt(n.swapFee), // rindexer names the column after the event's field: `swapFee` since C version 6 (logswap-be #40)
197
197
  };
198
198
  return {
199
199
  key,
package/src/keys.ts CHANGED
@@ -36,9 +36,10 @@ export interface PoolKey {
36
36
  * The swap fee, WAD, fixed for the life of the market: {@link FEE_MIN} (1 bp) ≤ φ ≤ {@link FEE_MAX} (1%),
37
37
  * or `0n`, which selects `DEFAULT_FEE` (2 bp) at read time. Four fields since C version 4
38
38
  *: `kappa` and `alpha` left with the variance kernel, and `phiMin` — a floor with
39
- * nothing above it — became `phi`. Every pool id changed with the shape.
39
+ * nothing above it — became `phi`, named `swapFee` since C version 6 (decisions 059). The name
40
+ * is not part of the encoding: no pool id changed with it.
40
41
  */
41
- phi: bigint;
42
+ swapFee: bigint;
42
43
  }
43
44
 
44
45
  const POOL_KEY_ABI = [
@@ -48,7 +49,7 @@ const POOL_KEY_ABI = [
48
49
  { name: "base", type: "address" },
49
50
  { name: "quote", type: "address" },
50
51
  { name: "tickSpacing", type: "int256" },
51
- { name: "phi", type: "uint256" },
52
+ { name: "swapFee", type: "uint256" },
52
53
  ],
53
54
  },
54
55
  ] as const;
@@ -56,7 +57,7 @@ const POOL_KEY_ABI = [
56
57
  /**
57
58
  * `poolId = keccak256(abi.encode(key))` — the primary key of the entire read model.
58
59
  *
59
- * Note the zero-vs-default caveat the Solidity type documents: a `phi` of `0` resolves to
60
+ * Note the zero-vs-default caveat the Solidity type documents: a `swapFee` of `0` resolves to
60
61
  * `DEFAULT_FEE` at READ time, so a key carrying `0n` and one carrying the resolved default are
61
62
  * DIFFERENT markets with different ids, even though they behave identically. Always address a
62
63
  * market by the key it was initialized with.
@@ -68,7 +69,7 @@ export function poolId(key: PoolKey): Hex {
68
69
  base: key.base,
69
70
  quote: key.quote,
70
71
  tickSpacing: key.tickSpacing,
71
- phi: key.phi,
72
+ swapFee: key.swapFee,
72
73
  },
73
74
  ]),
74
75
  );
package/src/pools.ts CHANGED
@@ -51,15 +51,16 @@ export async function getPool(c: LogswapClient, key: PoolKey): Promise<PoolState
51
51
  }
52
52
 
53
53
  /**
54
- * The market's fee: the key's `phi` with `0n` resolved to `DEFAULT_FEE`. Constant for the market's
55
- * life (C version 4, — `phiEff` and the variance kernel before). Reverts for a key
56
- * nobody initialized, which `discoverMarkets` relies on to drop a stale indexer's rows.
54
+ * The market's swap fee: the key's `swapFee` with `0n` resolved to `DEFAULT_FEE` — the manager's
55
+ * `swapFeeOf` (`phiOf` before C version 6). Constant for the market's life (C version 4 — `phiEff`
56
+ * and the variance kernel before). Reverts for a key nobody initialized, which `discoverMarkets`
57
+ * relies on to drop a stale indexer's rows. (`swapFeeOf` in `fees.ts` is the fee one swap paid.)
57
58
  */
58
- export async function phiOf(c: LogswapClient, key: PoolKey): Promise<bigint> {
59
+ export async function marketSwapFee(c: LogswapClient, key: PoolKey): Promise<bigint> {
59
60
  return c.public.readContract({
60
61
  address: c.addresses.cPoolManager,
61
62
  abi: cPoolManagerAbi,
62
- functionName: "phiOf",
63
+ functionName: "swapFeeOf",
63
64
  args: [key],
64
65
  }) as Promise<bigint>;
65
66
  }
@@ -180,7 +181,7 @@ export async function discoverMarkets(
180
181
  base: a.base!,
181
182
  quote: a.quote!,
182
183
  tickSpacing: a.tickSpacing!,
183
- phi: a.phi!,
184
+ swapFee: a.swapFee!,
184
185
  };
185
186
  return {
186
187
  key,
package/src/positions.ts CHANGED
@@ -191,8 +191,9 @@ export const MINT_FEE = 2n * 10n ** 14n;
191
191
  * the position's own legs, so a mint's total quote pull is `positionQuote(p, x) + mintFee(p, x)`.
192
192
  *
193
193
  * Mirrors the manager's exemption cases: a DORMANT mint pays nothing — floor above spot, or a
194
- * capped class spot has already passed (`cap <= x`). Anything earning pays `MINT_FEE · L`, half
195
- * accrued through `F` to the LPs already earning, half to the protocol. This is NOT the swap fee:
194
+ * capped class spot has already passed (`cap <= x`). Anything earning pays `MINT_FEE · L`, all of
195
+ * it the protocol's since C version 6 (decisions 058); with no collector it goes through `F` to the
196
+ * LPs already earning, and with none earning it is not charged. This is NOT the swap fee:
196
197
  * that one is charged per unit of |Δ log p| on swaps; this is a flat charge on L, once, at mint.
197
198
  *
198
199
  * One rung of imprecision: for a floor or cap exactly AT spot the contract consults its `currentK`