@logswap/sdk 0.5.70 → 0.5.72
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 +21 -2
- package/dist/admin.d.ts +38 -16
- package/dist/admin.js +47 -18
- package/dist/client.d.ts +7 -2
- package/dist/client.js +15 -2
- package/dist/fees.d.ts +1 -1
- package/dist/fees.js +2 -2
- package/dist/fpool.d.ts +207 -27
- package/dist/fpool.js +190 -115
- package/dist/generated.d.ts +812 -446
- package/dist/generated.js +486 -246
- package/dist/indexer.js +1 -1
- package/dist/keys.d.ts +4 -3
- package/dist/keys.js +3 -3
- package/dist/pools.d.ts +5 -4
- package/dist/pools.js +7 -6
- package/dist/positions.d.ts +3 -2
- package/dist/positions.js +3 -2
- package/package.json +1 -1
- package/src/admin.ts +51 -18
- package/src/client.ts +15 -2
- package/src/fees.ts +2 -2
- package/src/fpool.ts +249 -155
- package/src/generated.ts +486 -246
- package/src/indexer.ts +1 -1
- package/src/keys.ts +6 -5
- package/src/pools.ts +7 -6
- package/src/positions.ts +3 -2
package/src/indexer.ts
CHANGED
|
@@ -193,7 +193,7 @@ export async function discoverMarketsIndexed(url: string, signal?: AbortSignal):
|
|
|
193
193
|
base: n.base as Address,
|
|
194
194
|
quote: n.quote as Address,
|
|
195
195
|
tickSpacing: BigInt(n.tickSpacing),
|
|
196
|
-
|
|
196
|
+
swapFee: BigInt(n.phi), // the indexer's column keeps the event's old name, `phi`
|
|
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
|
|
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
|
-
|
|
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: "
|
|
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 `
|
|
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
|
-
|
|
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 `
|
|
55
|
-
*
|
|
56
|
-
*
|
|
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
|
|
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: "
|
|
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
|
-
|
|
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`,
|
|
195
|
-
*
|
|
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`
|