@logswap/sdk 0.5.79 → 0.5.80
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/dist/admin.d.ts +702 -51
- package/dist/admin.js +53 -46
- package/dist/client.d.ts +2 -2
- package/dist/client.js +2 -2
- package/dist/fpool.d.ts +185 -119
- package/dist/fpool.js +41 -42
- package/dist/generated.d.ts +1280 -670
- package/dist/generated.js +781 -465
- package/dist/history.d.ts +1 -2
- package/dist/history.js +3 -5
- package/dist/indexer.js +2 -1
- package/dist/keys.d.ts +6 -0
- package/dist/keys.js +2 -0
- package/dist/pools.d.ts +3 -3
- package/dist/pools.js +2 -1
- package/package.json +1 -1
- package/src/admin.ts +64 -54
- package/src/client.ts +2 -2
- package/src/fpool.ts +59 -55
- package/src/generated.ts +781 -465
- package/src/history.ts +3 -4
- package/src/indexer.ts +3 -2
- package/src/keys.ts +8 -0
- package/src/pools.ts +6 -5
package/src/history.ts
CHANGED
|
@@ -103,17 +103,16 @@ function contractName(c: LogswapClient, address: Address, event: string): string
|
|
|
103
103
|
}
|
|
104
104
|
|
|
105
105
|
/**
|
|
106
|
-
* A policy's name in the indexer for one of its events: `Policy
|
|
107
|
-
* two-signature `Listed`. Pass it as {@link EventLogsQuery.contract} for a policy outside the artifact.
|
|
106
|
+
* A policy's name in the indexer for one of its events: `Policy`. Pass it as {@link EventLogsQuery.contract} for a policy outside the artifact.
|
|
108
107
|
*/
|
|
109
108
|
export function indexedContractOf(kind: FPoolKind, event: string): string {
|
|
110
|
-
|
|
109
|
+
void kind; // `Listed` was the public and the private policy's since 064; the public policy dropped its asset list in F 33 (073), so it is unshared
|
|
111
110
|
return "Policy";
|
|
112
111
|
}
|
|
113
112
|
|
|
114
113
|
/** Events whose name two indexed contracts share: postgraphile prefixes their tables. */
|
|
115
114
|
// `CollectorProposed` / `CollectorAccepted` are C 7 / F 26 and older; `TreasuryProposed` / `TreasuryAccepted` replace them (066).
|
|
116
|
-
const SHARED = new Set(["Swap", "Transfer", "Approval", "OperatorSet", "CollectorProposed", "CollectorAccepted", "TreasuryProposed", "TreasuryAccepted", "Approved"
|
|
115
|
+
const SHARED = new Set(["Swap", "Transfer", "Approval", "OperatorSet", "CollectorProposed", "CollectorAccepted", "TreasuryProposed", "TreasuryAccepted", "Approved"]);
|
|
117
116
|
|
|
118
117
|
const plural = (n: string) => (/(s|x|ch|sh)$/.test(n) ? `${n}es` : `${n}s`);
|
|
119
118
|
/** A column's GraphQL name: postgraphile camelCases the snake_case rindexer writes (`F` → `f`). */
|
package/src/indexer.ts
CHANGED
|
@@ -184,15 +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; swapFee: string;
|
|
187
|
+
poolId: Hex; base: Hex; quote: Hex; tickSpacing: string; swapFee: string; policy: Hex;
|
|
188
188
|
x0: string; blockNumber: string; txHash: Hex; contractAddress: Hex;
|
|
189
189
|
};
|
|
190
|
-
const nodes = await gqlAll<Row>(url, "allMarketCreateds", "poolId base quote tickSpacing swapFee x0 blockNumber txHash contractAddress", { signal });
|
|
190
|
+
const nodes = await gqlAll<Row>(url, "allMarketCreateds", "poolId base quote tickSpacing swapFee policy 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
|
+
policy: n.policy as Address,
|
|
196
197
|
swapFee: BigInt(n.swapFee), // rindexer names the column after the event's field: `swapFee` since C version 6 (logswap-be #40)
|
|
197
198
|
};
|
|
198
199
|
return {
|
package/src/keys.ts
CHANGED
|
@@ -34,6 +34,12 @@ export interface PoolKey {
|
|
|
34
34
|
quote: Address;
|
|
35
35
|
/** Log-tick spacing, WAD. The LP-boundary ladder — position floors and caps. */
|
|
36
36
|
tickSpacing: bigint;
|
|
37
|
+
/**
|
|
38
|
+
* The C policy that admits this market (C version 10, decision 073): `PoolKey.policy`, a registry-approved
|
|
39
|
+
* policy, fixed for the market's life. Part of the id: the same pair under two policies is two markets.
|
|
40
|
+
* `address(0)` is a bare deployment with no registry.
|
|
41
|
+
*/
|
|
42
|
+
policy: Address;
|
|
37
43
|
/**
|
|
38
44
|
* The swap fee, WAD, fixed for the life of the market: {@link FEE_MIN} (1 bp) ≤ φ ≤ {@link FEE_MAX} (1%),
|
|
39
45
|
* or `0n`, which since C version 7 is NO fee (decisions 065; `DEFAULT_FEE` is gone). The gate
|
|
@@ -52,6 +58,7 @@ const POOL_KEY_ABI = [
|
|
|
52
58
|
{ name: "base", type: "address" },
|
|
53
59
|
{ name: "quote", type: "address" },
|
|
54
60
|
{ name: "tickSpacing", type: "int256" },
|
|
61
|
+
{ name: "policy", type: "address" },
|
|
55
62
|
{ name: "swapFee", type: "uint256" },
|
|
56
63
|
],
|
|
57
64
|
},
|
|
@@ -71,6 +78,7 @@ export function poolId(key: PoolKey): Hex {
|
|
|
71
78
|
base: key.base,
|
|
72
79
|
quote: key.quote,
|
|
73
80
|
tickSpacing: key.tickSpacing,
|
|
81
|
+
policy: key.policy,
|
|
74
82
|
swapFee: key.swapFee,
|
|
75
83
|
},
|
|
76
84
|
]),
|
package/src/pools.ts
CHANGED
|
@@ -37,7 +37,7 @@ export interface PoolState {
|
|
|
37
37
|
/** Fee-per-unit-L accumulator: $\phi \cdot \mathrm{TV}(\log p)$. */
|
|
38
38
|
F: bigint;
|
|
39
39
|
/** Quadratic variation of log-price, $\Sigma = \sum_{\text{swaps}} (\Delta x_{\text{swap}})^2$ — one term per swap. */
|
|
40
|
-
|
|
40
|
+
realizedVariance: bigint;
|
|
41
41
|
currentK: bigint;
|
|
42
42
|
protocolOwed: bigint;
|
|
43
43
|
minBackstopL: bigint;
|
|
@@ -140,8 +140,8 @@ export function cListable(price: number, baseDecimals: number, quoteDecimals: nu
|
|
|
140
140
|
*
|
|
141
141
|
* Signed: negative means variation has outrun fee income over the pool's life.
|
|
142
142
|
*/
|
|
143
|
-
export function lpEdge(state: Pick<PoolState, "F" | "
|
|
144
|
-
return state.F - state.
|
|
143
|
+
export function lpEdge(state: Pick<PoolState, "F" | "realizedVariance">): bigint {
|
|
144
|
+
return state.F - state.realizedVariance / 2n;
|
|
145
145
|
}
|
|
146
146
|
|
|
147
147
|
/** A market discovered from a `MarketCreated` log — the full key, plus where it was created. */
|
|
@@ -176,7 +176,7 @@ export async function discoverMarkets(
|
|
|
176
176
|
const args: Record<string, unknown> = {};
|
|
177
177
|
if (opts.base) args.base = opts.base;
|
|
178
178
|
if (opts.quote) args.quote = opts.quote;
|
|
179
|
-
const { logs } = await getEventLogs<{ base: Address; quote: Address; tickSpacing: bigint; swapFee: bigint; x0: bigint }>(c, {
|
|
179
|
+
const { logs } = await getEventLogs<{ base: Address; quote: Address; tickSpacing: bigint; policy: Address; swapFee: bigint; x0: bigint }>(c, {
|
|
180
180
|
indexer: opts.indexer,
|
|
181
181
|
address: c.addresses.cPoolManager,
|
|
182
182
|
event: ev,
|
|
@@ -191,6 +191,7 @@ export async function discoverMarkets(
|
|
|
191
191
|
base: a.base,
|
|
192
192
|
quote: a.quote,
|
|
193
193
|
tickSpacing: a.tickSpacing,
|
|
194
|
+
policy: a.policy,
|
|
194
195
|
swapFee: a.swapFee,
|
|
195
196
|
};
|
|
196
197
|
return {
|
|
@@ -373,7 +374,7 @@ export function feesQuote(state: Pick<PoolState, "F" | "lActive">): bigint {
|
|
|
373
374
|
}
|
|
374
375
|
|
|
375
376
|
/** The LP edge in QUOTE units: $(F - \tfrac12\Sigma) \cdot L$. Signed. */
|
|
376
|
-
export function edgeQuote(state: Pick<PoolState, "F" | "
|
|
377
|
+
export function edgeQuote(state: Pick<PoolState, "F" | "realizedVariance" | "lActive">): bigint {
|
|
377
378
|
return (lpEdge(state) * state.lActive) / WAD;
|
|
378
379
|
}
|
|
379
380
|
|