@logswap/sdk 0.5.102 → 0.5.104
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 +14 -418
- package/dist/actions.d.ts +0 -39
- package/dist/actions.js +0 -39
- package/dist/admin.d.ts +0 -106
- package/dist/admin.js +1 -96
- package/dist/chains.d.ts +0 -49
- package/dist/chains.js +0 -30
- package/dist/claims.d.ts +0 -32
- package/dist/claims.js +0 -30
- package/dist/client.d.ts +0 -116
- package/dist/client.js +1 -231
- package/dist/fees.d.ts +1 -45
- package/dist/fees.js +0 -44
- package/dist/fpool.d.ts +4 -612
- package/dist/fpool.js +14 -490
- package/dist/generated.js +0 -30
- package/dist/history.d.ts +0 -61
- package/dist/history.js +5 -74
- package/dist/ids.d.ts +0 -30
- package/dist/ids.js +0 -31
- package/dist/index.d.ts +0 -7
- package/dist/index.js +0 -7
- package/dist/indexer.d.ts +0 -68
- package/dist/indexer.js +1 -77
- package/dist/keys.d.ts +0 -50
- package/dist/keys.js +0 -35
- package/dist/liquidity.d.ts +0 -128
- package/dist/liquidity.js +1 -107
- package/dist/onboard.d.ts +0 -52
- package/dist/onboard.js +1 -59
- package/dist/pools.d.ts +3 -157
- package/dist/pools.js +1 -164
- package/dist/positions.d.ts +0 -102
- package/dist/positions.js +1 -90
- package/dist/quote.d.ts +0 -14
- package/dist/quote.js +0 -14
- package/dist/swap.d.ts +0 -31
- package/dist/swap.js +5 -37
- package/dist/tokencache.d.ts +0 -48
- package/dist/tokencache.js +1 -73
- package/dist/write.d.ts +1 -87
- package/dist/write.js +1 -87
- package/package.json +3 -8
- package/src/actions.ts +0 -208
- package/src/admin.ts +0 -350
- package/src/chains.ts +0 -278
- package/src/claims.ts +0 -111
- package/src/client.ts +0 -436
- package/src/fees.ts +0 -138
- package/src/fpool.ts +0 -2049
- package/src/generated.ts +0 -4345
- package/src/history.ts +0 -383
- package/src/ids.ts +0 -78
- package/src/index.ts +0 -26
- package/src/indexer.ts +0 -264
- package/src/keys.ts +0 -138
- package/src/liquidity.ts +0 -456
- package/src/onboard.ts +0 -253
- package/src/pools.ts +0 -465
- package/src/positions.ts +0 -297
- package/src/quote.ts +0 -36
- package/src/swap.ts +0 -181
- package/src/tokencache.ts +0 -178
- package/src/write.ts +0 -236
package/dist/indexer.d.ts
CHANGED
|
@@ -1,12 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* indexer.ts — reads the rindexer GraphQL that state cannot answer.
|
|
3
|
-
*
|
|
4
|
-
* The division of labour matters and is not arbitrary: **the indexer enumerates, the chain
|
|
5
|
-
* values.** ERC-6909 has no enumeration, so there is no way to ask a node "which positions exist in
|
|
6
|
-
* this pool" — only the `ClassRegistered` log knows. But an indexed row is a historical fact, and `L`
|
|
7
|
-
* changes with every mint, burn and harvest afterwards. So ids come from here and the current `L`
|
|
8
|
-
* is read on-chain, rather than trusting a number that was true at index time.
|
|
9
|
-
*/
|
|
10
1
|
import type { Hex } from "viem";
|
|
11
2
|
import { type LogswapClient } from "./client.js";
|
|
12
3
|
import { type DiscoveredMarket } from "./pools.js";
|
|
@@ -14,25 +5,9 @@ import { type PoolKey } from "./keys.js";
|
|
|
14
5
|
export interface IndexerError {
|
|
15
6
|
message: string;
|
|
16
7
|
}
|
|
17
|
-
/**
|
|
18
|
-
* A `bytea` column renders as `0x…` but FILTERS as `\x…`.
|
|
19
|
-
*
|
|
20
|
-
* Passing back the exact value the API just gave you returns zero rows, with no error — the query
|
|
21
|
-
* is valid, the comparison simply never matches. Every filter on a hash goes through here.
|
|
22
|
-
*
|
|
23
|
-
* The result is passed as a **variable**, never interpolated into query text: `\x` is not a legal
|
|
24
|
-
* escape inside a GraphQL string literal, so an interpolated filter fails with
|
|
25
|
-
* `Syntax Error: Invalid character escape sequence`. Variables carry the value untouched.
|
|
26
|
-
*/
|
|
27
8
|
export declare function bytea(hex: Hex): string;
|
|
28
|
-
/** How long an indexer call may take before the caller falls back (to the chain, or an empty view). */
|
|
29
9
|
export declare const INDEXER_TIMEOUT_MS = 8000;
|
|
30
10
|
export declare function gql<T>(url: string, query: string, variables?: Record<string, unknown>, signal?: AbortSignal): Promise<T>;
|
|
31
|
-
/**
|
|
32
|
-
* Every row of a connection, page by page. A single `first: 1000` silently drops row 1001 onward —
|
|
33
|
-
* a pool's 1001st position class, a deployment's 1001st market — with nothing to say so. Pages by
|
|
34
|
-
* cursor in primary-key order, so rows inserted while paging cannot shift the window.
|
|
35
|
-
*/
|
|
36
11
|
export declare function gqlAll<N>(url: string, field: string, selection: string, opts?: {
|
|
37
12
|
vars?: Record<string, {
|
|
38
13
|
type: string;
|
|
@@ -41,66 +16,23 @@ export declare function gqlAll<N>(url: string, field: string, selection: string,
|
|
|
41
16
|
condition?: string;
|
|
42
17
|
signal?: AbortSignal;
|
|
43
18
|
}): Promise<N[]>;
|
|
44
|
-
/** A position class as the chain registered it: the floor/cap geometry, fixed for the id's life. */
|
|
45
19
|
export interface RegisteredId {
|
|
46
20
|
id: bigint;
|
|
47
21
|
floor: bigint;
|
|
48
22
|
cap: bigint;
|
|
49
23
|
capped: boolean;
|
|
50
24
|
}
|
|
51
|
-
/** Every position class ever registered in a pool. Historical — some may since have burnt to zero. */
|
|
52
25
|
export declare function registeredIds(url: string, poolId: Hex, signal?: AbortSignal): Promise<RegisteredId[]>;
|
|
53
26
|
export interface PoolPosition extends RegisteredId {
|
|
54
|
-
/** Total exposure across every holder, read from the chain — not from the indexed row. */
|
|
55
27
|
L: bigint;
|
|
56
28
|
shares: bigint;
|
|
57
|
-
/** Spot is inside this position's range, so it is earning fees. */
|
|
58
29
|
active: boolean;
|
|
59
30
|
}
|
|
60
|
-
/**
|
|
61
|
-
* Every live position class in a pool, split by whether it is earning.
|
|
62
|
-
*
|
|
63
|
-
* A position is **active** when spot sits at or above its floor and, if capped, below its cap —
|
|
64
|
-
* the same condition the tick ladder applies when it steps `lActive`.
|
|
65
|
-
*
|
|
66
|
-
* Classes that have burnt to `L = 0` are dropped: they are registered forever, but a list of
|
|
67
|
-
* positions should show positions, not the history of ones that existed.
|
|
68
|
-
*/
|
|
69
31
|
export declare function poolPositions(c: LogswapClient, url: string, poolId: Hex, x: bigint, signal?: AbortSignal): Promise<PoolPosition[]>;
|
|
70
|
-
/** Is the indexer answering? Used to degrade a screen rather than fail it. */
|
|
71
32
|
export declare function indexerHealthy(url: string, signal?: AbortSignal): Promise<boolean>;
|
|
72
|
-
/**
|
|
73
|
-
* Markets, from the indexer rather than a log scan.
|
|
74
|
-
*
|
|
75
|
-
* `discoverMarkets` reads `MarketCreated` logs straight from the node, which is correct until the node
|
|
76
|
-
* stops keeping them. anvil's `--prune-history` drops historical transactions and receipts beyond a
|
|
77
|
-
* window, so on a devnet that mines steadily the deployment's own logs age out and a scan from
|
|
78
|
-
* block 0 returns nothing — while the contracts remain perfectly alive. Any real chain has the same
|
|
79
|
-
* shape in a different form: archive-depth `getLogs` is exactly what public RPCs refuse.
|
|
80
|
-
*
|
|
81
|
-
* An indexer does not have that problem, because it recorded the event when it happened. This is
|
|
82
|
-
* the more durable path and should be preferred wherever an indexer is configured, with the log
|
|
83
|
-
* scan as the fallback for when it is not.
|
|
84
|
-
*
|
|
85
|
-
* `PoolCreated` (the C manager's) carries every field of the `PoolKey` (C 18: quote, base, swapFeeIdx, spacingIdx, policy, salt), so the key is rebuilt exactly and `poolId` is
|
|
86
|
-
* recomputed locally rather than trusted from the row — the same offline derivation the SDK uses
|
|
87
|
-
* everywhere else, so a wrong id fails loudly instead of addressing the wrong pool.
|
|
88
|
-
*/
|
|
89
33
|
export declare function discoverMarketsIndexed(url: string, signal?: AbortSignal): Promise<DiscoveredMarket[]>;
|
|
90
|
-
/**
|
|
91
|
-
* Markets, preferring the indexer and falling back to a log scan.
|
|
92
|
-
*
|
|
93
|
-
* The order matters: the indexer is authoritative for history, the node is authoritative for state.
|
|
94
|
-
* A market the node can no longer tell you about is still a market.
|
|
95
|
-
*/
|
|
96
34
|
export declare function discoverMarketsBest(c: LogswapClient, url?: string | undefined, signal?: AbortSignal): Promise<{
|
|
97
35
|
markets: DiscoveredMarket[];
|
|
98
36
|
source: "indexer" | "chain";
|
|
99
37
|
}>;
|
|
100
|
-
/**
|
|
101
|
-
* The UNCAPPED position classes of a pool, from the CHAIN alone: the lens enumerates live floors
|
|
102
|
-
* (one bitmap bit each), and an uncapped id is a pure function of (key, floor). No indexer.
|
|
103
|
-
* Capped classes need `ClassRegistered` replay and are absent here — callers that also want those
|
|
104
|
-
* use the indexed `poolPositions` and fall back to this when the indexer is missing or stale.
|
|
105
|
-
*/
|
|
106
38
|
export declare function poolPositionsFromChain(c: LogswapClient, key: PoolKey, x: bigint): Promise<PoolPosition[]>;
|
package/dist/indexer.js
CHANGED
|
@@ -1,36 +1,14 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* indexer.ts — reads the rindexer GraphQL that state cannot answer.
|
|
3
|
-
*
|
|
4
|
-
* The division of labour matters and is not arbitrary: **the indexer enumerates, the chain
|
|
5
|
-
* values.** ERC-6909 has no enumeration, so there is no way to ask a node "which positions exist in
|
|
6
|
-
* this pool" — only the `ClassRegistered` log knows. But an indexed row is a historical fact, and `L`
|
|
7
|
-
* changes with every mint, burn and harvest afterwards. So ids come from here and the current `L`
|
|
8
|
-
* is read on-chain, rather than trusting a number that was true at index time.
|
|
9
|
-
*/
|
|
10
1
|
import { managerC, lensC } from "./client.js";
|
|
11
2
|
import { managerCAbi } from "./generated.js";
|
|
12
3
|
import { getPositionClass } from "./positions.js";
|
|
13
4
|
import { discoverMarkets } from "./pools.js";
|
|
14
5
|
import { poolId } from "./keys.js";
|
|
15
6
|
import { NO_CAP } from "./ids.js";
|
|
16
|
-
/**
|
|
17
|
-
* A `bytea` column renders as `0x…` but FILTERS as `\x…`.
|
|
18
|
-
*
|
|
19
|
-
* Passing back the exact value the API just gave you returns zero rows, with no error — the query
|
|
20
|
-
* is valid, the comparison simply never matches. Every filter on a hash goes through here.
|
|
21
|
-
*
|
|
22
|
-
* The result is passed as a **variable**, never interpolated into query text: `\x` is not a legal
|
|
23
|
-
* escape inside a GraphQL string literal, so an interpolated filter fails with
|
|
24
|
-
* `Syntax Error: Invalid character escape sequence`. Variables carry the value untouched.
|
|
25
|
-
*/
|
|
26
7
|
export function bytea(hex) {
|
|
27
8
|
return `\\x${hex.replace(/^0x/, "")}`;
|
|
28
9
|
}
|
|
29
|
-
/** How long an indexer call may take before the caller falls back (to the chain, or an empty view). */
|
|
30
10
|
export const INDEXER_TIMEOUT_MS = 8_000;
|
|
31
11
|
export async function gql(url, query, variables, signal) {
|
|
32
|
-
// A hung indexer must not hang its caller: every consumer has a fallback, and it only runs when
|
|
33
|
-
// this call ends. The caller's signal, if any, still wins.
|
|
34
12
|
const res = await fetch(url, {
|
|
35
13
|
method: "POST",
|
|
36
14
|
headers: { "content-type": "application/json" },
|
|
@@ -39,8 +17,6 @@ export async function gql(url, query, variables, signal) {
|
|
|
39
17
|
});
|
|
40
18
|
if (!res.ok)
|
|
41
19
|
throw new Error(`indexer: HTTP ${res.status} from ${url}`);
|
|
42
|
-
// an Access login page or a proxy's error page answers 200 with HTML; say so, rather than
|
|
43
|
-
// "Unexpected token <"
|
|
44
20
|
const ct = res.headers.get("content-type") ?? "";
|
|
45
21
|
if (!ct.includes("json"))
|
|
46
22
|
throw new Error(`indexer: ${url} answered ${ct || "no content-type"}, not JSON (a login page?)`);
|
|
@@ -53,11 +29,6 @@ export async function gql(url, query, variables, signal) {
|
|
|
53
29
|
}
|
|
54
30
|
const PAGE = 1000;
|
|
55
31
|
const MAX_PAGES = 100;
|
|
56
|
-
/**
|
|
57
|
-
* Every row of a connection, page by page. A single `first: 1000` silently drops row 1001 onward —
|
|
58
|
-
* a pool's 1001st position class, a deployment's 1001st market — with nothing to say so. Pages by
|
|
59
|
-
* cursor in primary-key order, so rows inserted while paging cannot shift the window.
|
|
60
|
-
*/
|
|
61
32
|
export async function gqlAll(url, field, selection, opts = {}) {
|
|
62
33
|
const vars = opts.vars ?? {};
|
|
63
34
|
const decl = Object.entries(vars).map(([k, v]) => `, $${k}: ${v.type}`).join("");
|
|
@@ -80,7 +51,6 @@ export async function gqlAll(url, field, selection, opts = {}) {
|
|
|
80
51
|
}
|
|
81
52
|
throw new Error(`indexer: ${field} has more than ${PAGE * MAX_PAGES} rows`);
|
|
82
53
|
}
|
|
83
|
-
/** Every position class ever registered in a pool. Historical — some may since have burnt to zero. */
|
|
84
54
|
export async function registeredIds(url, poolId, signal) {
|
|
85
55
|
const nodes = await gqlAll(url, "allClassRegistereds", "id floor cap capped", {
|
|
86
56
|
vars: { pool: { type: "String!", value: bytea(poolId) } },
|
|
@@ -94,15 +64,6 @@ export async function registeredIds(url, poolId, signal) {
|
|
|
94
64
|
capped: n.capped,
|
|
95
65
|
}));
|
|
96
66
|
}
|
|
97
|
-
/**
|
|
98
|
-
* Every live position class in a pool, split by whether it is earning.
|
|
99
|
-
*
|
|
100
|
-
* A position is **active** when spot sits at or above its floor and, if capped, below its cap —
|
|
101
|
-
* the same condition the tick ladder applies when it steps `lActive`.
|
|
102
|
-
*
|
|
103
|
-
* Classes that have burnt to `L = 0` are dropped: they are registered forever, but a list of
|
|
104
|
-
* positions should show positions, not the history of ones that existed.
|
|
105
|
-
*/
|
|
106
67
|
export async function poolPositions(c, url, poolId, x, signal) {
|
|
107
68
|
const ids = await registeredIds(url, poolId, signal);
|
|
108
69
|
const rows = await Promise.all(ids.map(async (r) => {
|
|
@@ -111,7 +72,6 @@ export async function poolPositions(c, url, poolId, x, signal) {
|
|
|
111
72
|
}));
|
|
112
73
|
return rows.filter((r) => r.L > 0n).sort((a, b) => (b.L > a.L ? 1 : b.L < a.L ? -1 : 0));
|
|
113
74
|
}
|
|
114
|
-
/** Is the indexer answering? Used to degrade a screen rather than fail it. */
|
|
115
75
|
export async function indexerHealthy(url, signal) {
|
|
116
76
|
try {
|
|
117
77
|
await gql(url, "{ __typename }", undefined, signal);
|
|
@@ -121,27 +81,9 @@ export async function indexerHealthy(url, signal) {
|
|
|
121
81
|
return false;
|
|
122
82
|
}
|
|
123
83
|
}
|
|
124
|
-
/**
|
|
125
|
-
* Markets, from the indexer rather than a log scan.
|
|
126
|
-
*
|
|
127
|
-
* `discoverMarkets` reads `MarketCreated` logs straight from the node, which is correct until the node
|
|
128
|
-
* stops keeping them. anvil's `--prune-history` drops historical transactions and receipts beyond a
|
|
129
|
-
* window, so on a devnet that mines steadily the deployment's own logs age out and a scan from
|
|
130
|
-
* block 0 returns nothing — while the contracts remain perfectly alive. Any real chain has the same
|
|
131
|
-
* shape in a different form: archive-depth `getLogs` is exactly what public RPCs refuse.
|
|
132
|
-
*
|
|
133
|
-
* An indexer does not have that problem, because it recorded the event when it happened. This is
|
|
134
|
-
* the more durable path and should be preferred wherever an indexer is configured, with the log
|
|
135
|
-
* scan as the fallback for when it is not.
|
|
136
|
-
*
|
|
137
|
-
* `PoolCreated` (the C manager's) carries every field of the `PoolKey` (C 18: quote, base, swapFeeIdx, spacingIdx, policy, salt), so the key is rebuilt exactly and `poolId` is
|
|
138
|
-
* recomputed locally rather than trusted from the row — the same offline derivation the SDK uses
|
|
139
|
-
* everywhere else, so a wrong id fails loudly instead of addressing the wrong pool.
|
|
140
|
-
*/
|
|
141
84
|
export async function discoverMarketsIndexed(url, signal) {
|
|
142
85
|
const nodes = await gqlAll(url, "allCPoolManagerPoolCreateds", "poolId base quote creator salt swapFeeIdx spacingIdx policy initialLogPrice blockNumber txHash contractAddress", { signal });
|
|
143
86
|
return nodes.map((n) => {
|
|
144
|
-
// rindexer names a column after the event's field: `swapFeeIdx` / `spacingIdx` since C 18 (decision 099)
|
|
145
87
|
const key = { quote: n.quote, base: n.base, swapFeeIdx: Number(n.swapFeeIdx), spacingIdx: Number(n.spacingIdx), policy: n.policy, salt: n.salt };
|
|
146
88
|
return {
|
|
147
89
|
key,
|
|
@@ -154,38 +96,20 @@ export async function discoverMarketsIndexed(url, signal) {
|
|
|
154
96
|
};
|
|
155
97
|
});
|
|
156
98
|
}
|
|
157
|
-
/**
|
|
158
|
-
* Markets, preferring the indexer and falling back to a log scan.
|
|
159
|
-
*
|
|
160
|
-
* The order matters: the indexer is authoritative for history, the node is authoritative for state.
|
|
161
|
-
* A market the node can no longer tell you about is still a market.
|
|
162
|
-
*/
|
|
163
99
|
export async function discoverMarketsBest(c, url = c.indexerUrl, signal) {
|
|
164
100
|
if (url) {
|
|
165
101
|
try {
|
|
166
102
|
const markets = await discoverMarketsIndexed(url, signal);
|
|
167
|
-
// The indexer is a CACHE and the chain is the truth. After a redeploy it keeps serving the
|
|
168
|
-
// previous deployment's markets, and calling the new manager with those keys makes every
|
|
169
|
-
// read revert, refresh-proof. Each row names the manager that emitted it, so keep only the
|
|
170
|
-
// rows of the manager this client is pointed at — no read per row. None left means the
|
|
171
|
-
// indexer has not seen this deployment: the chain scan is the answer.
|
|
172
103
|
const mine = managerC(c).toLowerCase();
|
|
173
104
|
const alive = markets.filter((m) => m.manager?.toLowerCase() === mine);
|
|
174
105
|
if (alive.length)
|
|
175
106
|
return { markets: alive, source: "indexer" };
|
|
176
107
|
}
|
|
177
108
|
catch {
|
|
178
|
-
/* fall through — a missing indexer must not cost you the market list */
|
|
179
109
|
}
|
|
180
110
|
}
|
|
181
111
|
return { markets: await discoverMarkets(c), source: "chain" };
|
|
182
112
|
}
|
|
183
|
-
/**
|
|
184
|
-
* The UNCAPPED position classes of a pool, from the CHAIN alone: the lens enumerates live floors
|
|
185
|
-
* (one bitmap bit each), and an uncapped id is a pure function of (key, floor). No indexer.
|
|
186
|
-
* Capped classes need `ClassRegistered` replay and are absent here — callers that also want those
|
|
187
|
-
* use the indexed `poolPositions` and fall back to this when the indexer is missing or stale.
|
|
188
|
-
*/
|
|
189
113
|
export async function poolPositionsFromChain(c, key, x) {
|
|
190
114
|
const { lensCAbi } = await import("./generated.js");
|
|
191
115
|
const floors = (await c.public.readContract({
|
|
@@ -202,7 +126,7 @@ export async function poolPositionsFromChain(c, key, x) {
|
|
|
202
126
|
functionName: "idOf",
|
|
203
127
|
args: [pool, floor],
|
|
204
128
|
}));
|
|
205
|
-
const { L, shares } = await getPositionClass(c, id);
|
|
129
|
+
const { L, shares } = await getPositionClass(c, id);
|
|
206
130
|
if (L === 0n)
|
|
207
131
|
return null;
|
|
208
132
|
return { id, poolId: pool, floor, cap: NO_CAP, capped: false, L, shares, active: x >= floor };
|
package/dist/keys.d.ts
CHANGED
|
@@ -1,74 +1,24 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* keys.ts — market identity, computed OFFLINE.
|
|
3
|
-
*
|
|
4
|
-
* A market is a `PoolKey`, and its id is the hash of that key. Both are **tier-1 frozen**
|
|
5
|
-
* (docs/app.md): the key is in every keyed signature *and* `poolId = keccak256(abi.encode(key))`,
|
|
6
|
-
* so adding a field would change every selector and re-identify every market, orphaning all
|
|
7
|
-
* indexed history.
|
|
8
|
-
*
|
|
9
|
-
* This module reimplements `PoolKeyLib.toId` in TypeScript so a client can address a market with no
|
|
10
|
-
* RPC at all. `test/derivation.test.ts` pins it against vectors generated by the contract itself —
|
|
11
|
-
* if the two ever disagree, that test fails rather than the SDK silently addressing the wrong pool.
|
|
12
|
-
*/
|
|
13
1
|
import { type Address, type Hex } from "viem";
|
|
14
|
-
/**
|
|
15
|
-
* `FeeParams.FEE_LIST` in bp: the eight swap fees a C market or an F pool may be born with, one list for both managers
|
|
16
|
-
* (decisions 099, 102). A key carries the index; the list is the whole fee domain, with no fee-free entry.
|
|
17
|
-
*/
|
|
18
2
|
export declare const FEE_LIST_BP: readonly [1, 2, 5, 10, 20, 50, 100, 200];
|
|
19
|
-
/** {@link FEE_LIST_BP} in WAD. */
|
|
20
3
|
export declare const FEE_LIST: readonly bigint[];
|
|
21
|
-
/** The least and the most swap fee of the family, WAD: the ends of {@link FEE_LIST} (1 bp, 200 bp). */
|
|
22
4
|
export declare const FEE_MIN: bigint;
|
|
23
5
|
export declare const FEE_MAX: bigint;
|
|
24
|
-
/** The most a mint fee is, WAD (2%): the top of {@link FEE_LIST}, which a 200 bp swap fee mints at. */
|
|
25
6
|
export declare const MINT_FEE_MAX: bigint;
|
|
26
|
-
/**
|
|
27
|
-
* `MarketParams.SPACING_LIST` (decision 099): the log-tick spacings a C market may be born on, WAD steps of log-price
|
|
28
|
-
* (0.1%, about 1% and about 10.5%). A key names one by `spacingIdx`.
|
|
29
|
-
*/
|
|
30
7
|
export declare const SPACING_LIST: readonly bigint[];
|
|
31
|
-
/**
|
|
32
|
-
* The tuple that IS the market (`PoolKeyC`, C 18, decision 099: quote, base, swapFeeIdx, spacingIdx, policy, salt). Field
|
|
33
|
-
* order is load-bearing: it is the ABI encoding order, so it must match `src/types/PoolKeyC.sol` exactly. The resolved
|
|
34
|
-
* swap fee, mint fee and tick spacing are no key fields: {@link swapFeeOfKey}, {@link mintFeeOfKey}, {@link tickSpacingOf}.
|
|
35
|
-
*/
|
|
36
8
|
export interface PoolKey {
|
|
37
9
|
quote: Address;
|
|
38
10
|
base: Address;
|
|
39
|
-
/** The swap fee, as its index into {@link FEE_LIST}; fixed for the life of the market. The mint fee is the next entry (the same at the top). */
|
|
40
11
|
swapFeeIdx: number;
|
|
41
|
-
/** The log-tick spacing (the LP-boundary ladder: position floors and caps), as its index into {@link SPACING_LIST}. */
|
|
42
12
|
spacingIdx: number;
|
|
43
|
-
/**
|
|
44
|
-
* The C policy that admits this market (`PolicyC`, decision 100): registry-approved, fixed for the market's life. Part
|
|
45
|
-
* of the id: the same pair under two policies is two markets.
|
|
46
|
-
*/
|
|
47
13
|
policy: Address;
|
|
48
|
-
/**
|
|
49
|
-
* A second market of one shape under a closed policy. Part of the id. Zero on an open policy, which refuses any other
|
|
50
|
-
* value (`NotCanonical`): a public market is canonical per exact key.
|
|
51
|
-
*/
|
|
52
14
|
salt: Hex;
|
|
53
15
|
}
|
|
54
|
-
/** The swap fee at `idx` of {@link FEE_LIST}, WAD. Throws off the list. */
|
|
55
16
|
export declare function feeOfIdx(idx: number): bigint;
|
|
56
|
-
/** The index in {@link FEE_LIST} of the mint fee a swap fee at `swapFeeIdx` goes with: the next entry, the same at the top. */
|
|
57
17
|
export declare function mintFeeIdxOf(swapFeeIdx: number): number;
|
|
58
|
-
/** The index of `fee` (WAD) in {@link FEE_LIST}. Throws for a fee off the list. */
|
|
59
18
|
export declare function feeIdxOf(fee: bigint): number;
|
|
60
|
-
/** The index of `tickSpacing` (WAD) in {@link SPACING_LIST}. Throws for a spacing off the list. */
|
|
61
19
|
export declare function spacingIdxOf(tickSpacing: bigint): number;
|
|
62
|
-
/** A market's swap fee, WAD: `FEE_LIST[key.swapFeeIdx]`, what the manager resolves at `initialize`. */
|
|
63
20
|
export declare function swapFeeOfKey(key: Pick<PoolKey, "swapFeeIdx">): bigint;
|
|
64
|
-
/** A market's mint fee, WAD of newly earning L: the list's next entry after the swap fee (the same at the top). */
|
|
65
21
|
export declare function mintFeeOfKey(key: Pick<PoolKey, "swapFeeIdx">): bigint;
|
|
66
|
-
/** A market's log-tick spacing, WAD: `SPACING_LIST[key.spacingIdx]`. */
|
|
67
22
|
export declare function tickSpacingOf(key: Pick<PoolKey, "spacingIdx">): bigint;
|
|
68
|
-
/**
|
|
69
|
-
* `poolId = keccak256(abi.encode(key))` — the primary key of the entire read model. Always address a market by the key
|
|
70
|
-
* it was initialized with. Throws for an index off its list: the manager refuses such a key (`BadParam`).
|
|
71
|
-
*/
|
|
72
23
|
export declare function poolId(key: PoolKey): Hex;
|
|
73
|
-
/** Structural equality of two keys — i.e. "the same market". */
|
|
74
24
|
export declare function sameMarket(a: PoolKey, b: PoolKey): boolean;
|
package/dist/keys.js
CHANGED
|
@@ -1,32 +1,9 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* keys.ts — market identity, computed OFFLINE.
|
|
3
|
-
*
|
|
4
|
-
* A market is a `PoolKey`, and its id is the hash of that key. Both are **tier-1 frozen**
|
|
5
|
-
* (docs/app.md): the key is in every keyed signature *and* `poolId = keccak256(abi.encode(key))`,
|
|
6
|
-
* so adding a field would change every selector and re-identify every market, orphaning all
|
|
7
|
-
* indexed history.
|
|
8
|
-
*
|
|
9
|
-
* This module reimplements `PoolKeyLib.toId` in TypeScript so a client can address a market with no
|
|
10
|
-
* RPC at all. `test/derivation.test.ts` pins it against vectors generated by the contract itself —
|
|
11
|
-
* if the two ever disagree, that test fails rather than the SDK silently addressing the wrong pool.
|
|
12
|
-
*/
|
|
13
1
|
import { encodeAbiParameters, keccak256 } from "viem";
|
|
14
|
-
/**
|
|
15
|
-
* `FeeParams.FEE_LIST` in bp: the eight swap fees a C market or an F pool may be born with, one list for both managers
|
|
16
|
-
* (decisions 099, 102). A key carries the index; the list is the whole fee domain, with no fee-free entry.
|
|
17
|
-
*/
|
|
18
2
|
export const FEE_LIST_BP = [1, 2, 5, 10, 20, 50, 100, 200];
|
|
19
|
-
/** {@link FEE_LIST_BP} in WAD. */
|
|
20
3
|
export const FEE_LIST = FEE_LIST_BP.map((bp) => BigInt(bp) * 10n ** 14n);
|
|
21
|
-
/** The least and the most swap fee of the family, WAD: the ends of {@link FEE_LIST} (1 bp, 200 bp). */
|
|
22
4
|
export const FEE_MIN = 10n ** 14n;
|
|
23
5
|
export const FEE_MAX = 2n * 10n ** 16n;
|
|
24
|
-
/** The most a mint fee is, WAD (2%): the top of {@link FEE_LIST}, which a 200 bp swap fee mints at. */
|
|
25
6
|
export const MINT_FEE_MAX = 2n * 10n ** 16n;
|
|
26
|
-
/**
|
|
27
|
-
* `MarketParams.SPACING_LIST` (decision 099): the log-tick spacings a C market may be born on, WAD steps of log-price
|
|
28
|
-
* (0.1%, about 1% and about 10.5%). A key names one by `spacingIdx`.
|
|
29
|
-
*/
|
|
30
7
|
export const SPACING_LIST = [10n ** 15n, 10n ** 16n, 10n ** 17n];
|
|
31
8
|
function listed(list, idx, what) {
|
|
32
9
|
const v = Number.isInteger(idx) ? list[idx] : undefined;
|
|
@@ -34,38 +11,31 @@ function listed(list, idx, what) {
|
|
|
34
11
|
throw new Error(`logswap: ${what} index ${idx} is off the list (0..${list.length - 1})`);
|
|
35
12
|
return v;
|
|
36
13
|
}
|
|
37
|
-
/** The swap fee at `idx` of {@link FEE_LIST}, WAD. Throws off the list. */
|
|
38
14
|
export function feeOfIdx(idx) {
|
|
39
15
|
return listed(FEE_LIST, idx, "swap fee");
|
|
40
16
|
}
|
|
41
|
-
/** The index in {@link FEE_LIST} of the mint fee a swap fee at `swapFeeIdx` goes with: the next entry, the same at the top. */
|
|
42
17
|
export function mintFeeIdxOf(swapFeeIdx) {
|
|
43
18
|
feeOfIdx(swapFeeIdx);
|
|
44
19
|
return Math.min(swapFeeIdx + 1, FEE_LIST.length - 1);
|
|
45
20
|
}
|
|
46
|
-
/** The index of `fee` (WAD) in {@link FEE_LIST}. Throws for a fee off the list. */
|
|
47
21
|
export function feeIdxOf(fee) {
|
|
48
22
|
const idx = FEE_LIST.indexOf(fee);
|
|
49
23
|
if (idx < 0)
|
|
50
24
|
throw new Error(`logswap: swap fee ${fee} is not on the fee list (${FEE_LIST_BP.join(", ")} bp)`);
|
|
51
25
|
return idx;
|
|
52
26
|
}
|
|
53
|
-
/** The index of `tickSpacing` (WAD) in {@link SPACING_LIST}. Throws for a spacing off the list. */
|
|
54
27
|
export function spacingIdxOf(tickSpacing) {
|
|
55
28
|
const idx = SPACING_LIST.indexOf(tickSpacing);
|
|
56
29
|
if (idx < 0)
|
|
57
30
|
throw new Error(`logswap: tick spacing ${tickSpacing} is not on the spacing list (${SPACING_LIST.join(", ")})`);
|
|
58
31
|
return idx;
|
|
59
32
|
}
|
|
60
|
-
/** A market's swap fee, WAD: `FEE_LIST[key.swapFeeIdx]`, what the manager resolves at `initialize`. */
|
|
61
33
|
export function swapFeeOfKey(key) {
|
|
62
34
|
return feeOfIdx(key.swapFeeIdx);
|
|
63
35
|
}
|
|
64
|
-
/** A market's mint fee, WAD of newly earning L: the list's next entry after the swap fee (the same at the top). */
|
|
65
36
|
export function mintFeeOfKey(key) {
|
|
66
37
|
return feeOfIdx(mintFeeIdxOf(key.swapFeeIdx));
|
|
67
38
|
}
|
|
68
|
-
/** A market's log-tick spacing, WAD: `SPACING_LIST[key.spacingIdx]`. */
|
|
69
39
|
export function tickSpacingOf(key) {
|
|
70
40
|
return listed(SPACING_LIST, key.spacingIdx, "spacing");
|
|
71
41
|
}
|
|
@@ -82,10 +52,6 @@ const POOL_KEY_ABI = [
|
|
|
82
52
|
],
|
|
83
53
|
},
|
|
84
54
|
];
|
|
85
|
-
/**
|
|
86
|
-
* `poolId = keccak256(abi.encode(key))` — the primary key of the entire read model. Always address a market by the key
|
|
87
|
-
* it was initialized with. Throws for an index off its list: the manager refuses such a key (`BadParam`).
|
|
88
|
-
*/
|
|
89
55
|
export function poolId(key) {
|
|
90
56
|
swapFeeOfKey(key);
|
|
91
57
|
tickSpacingOf(key);
|
|
@@ -93,7 +59,6 @@ export function poolId(key) {
|
|
|
93
59
|
{ quote: key.quote, base: key.base, swapFeeIdx: key.swapFeeIdx, spacingIdx: key.spacingIdx, policy: key.policy, salt: key.salt },
|
|
94
60
|
]));
|
|
95
61
|
}
|
|
96
|
-
/** Structural equality of two keys — i.e. "the same market". */
|
|
97
62
|
export function sameMarket(a, b) {
|
|
98
63
|
return poolId(a) === poolId(b);
|
|
99
64
|
}
|
package/dist/liquidity.d.ts
CHANGED
|
@@ -1,26 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* liquidity.ts — providing, editing and exiting a C position.
|
|
3
|
-
*
|
|
4
|
-
* A class is (ξ, μ, L): floor, cap, exposure. One primitive sets all three — `update` — and every
|
|
5
|
-
* edit is a constraint on it. The vocabulary follows the geometry: **the verb
|
|
6
|
-
* names the axis, the direction is a signed rung count**, and only two direction-words survive,
|
|
7
|
-
* because each names a wallet flow the user must see.
|
|
8
|
-
*
|
|
9
|
-
* update(ξ', μ', L') the primitive
|
|
10
|
-
* ├─ move(ξ', μ') L pinned
|
|
11
|
-
* │ ├─ floor(±n) μ pinned · ↑ harvest (receive quote) · ↓ deepen (pay quote)
|
|
12
|
-
* │ ├─ cap(±n) ξ pinned · no direction words
|
|
13
|
-
* │ └─ shift(±n) width pinned — the translation
|
|
14
|
-
* ├─ resize(L') ξ, μ pinned; L' = 0 is the exit
|
|
15
|
-
* └─ reprice(ξ') R pinned: L' = L·e^{ξ' − ξ}, dormant only
|
|
16
|
-
* mint · burn · claim
|
|
17
|
-
*
|
|
18
|
-
* Every edit is ONE action of the router's batch (`actions.ts`), which is what
|
|
19
|
-
* lets it settle in kind, or in base, or in quote: `settleIn` appends the one swap that nets the
|
|
20
|
-
* other side, and the batch moves a single token. `previewEdit` is the lens's `previewUpdate` —
|
|
21
|
-
* the exact flows, mint fee and swept fees included — and is what an editor shows before its one
|
|
22
|
-
* apply.
|
|
23
|
-
*/
|
|
24
1
|
import type { Address, Hash } from "viem";
|
|
25
2
|
import { type LogswapClient } from "./client.js";
|
|
26
3
|
import { type PoolKey } from "./keys.js";
|
|
@@ -28,52 +5,23 @@ import { type PairBounds } from "./actions.js";
|
|
|
28
5
|
import { type WriteOptions } from "./write.js";
|
|
29
6
|
export interface MintArgs extends WriteOptions {
|
|
30
7
|
key: PoolKey;
|
|
31
|
-
/** Log-price floor. Need not be on the grid — see the blending note below. */
|
|
32
8
|
targetFloor: bigint;
|
|
33
9
|
cap?: bigint;
|
|
34
|
-
/** Exposure to add. */
|
|
35
10
|
L: bigint;
|
|
36
|
-
/**
|
|
37
|
-
* The most the mint may pull, per token. REQUIRED: the pulled amounts depend on spot when the
|
|
38
|
-
* transaction lands, so an unbounded mint can be sandwiched into depositing far more than the
|
|
39
|
-
* preview showed. Derive them from the preview with {@link withSlippage} (`"input"`); pass
|
|
40
|
-
* {@link UNBOUNDED} only where the price cannot move under you.
|
|
41
|
-
*/
|
|
42
11
|
maxBaseIn: bigint;
|
|
43
12
|
maxQuoteIn: bigint;
|
|
44
13
|
}
|
|
45
|
-
/**
|
|
46
|
-
* Mint at `targetFloor`, blending across the two adjacent rungs when it is off-grid.
|
|
47
|
-
*
|
|
48
|
-
* This is why the floor ladder can be coarse without the UX being coarse: a blend of two adjacent
|
|
49
|
-
* classes IS exactly one position at the weighted-mean floor, so a continuous floor slider works
|
|
50
|
-
* over a discrete ladder. The router settles once per token, not once per rung.
|
|
51
|
-
*
|
|
52
|
-
* **A mint at floor == spot costs zero quote** ($Q(\xi) = 0$), and one above spot is dormant and
|
|
53
|
-
* costs zero quote too — that is what makes single-asset entry possible in both directions.
|
|
54
|
-
*/
|
|
55
14
|
export declare function mint(c: LogswapClient, a: MintArgs): Promise<Hash>;
|
|
56
15
|
export interface ZapArgs extends WriteOptions {
|
|
57
16
|
key: PoolKey;
|
|
58
|
-
/** Fund entirely from base (true) or entirely from quote (false). */
|
|
59
17
|
fundWithBase: boolean;
|
|
60
18
|
amountIn: bigint;
|
|
61
|
-
/** The least the swap leg may return: the zap's own slippage bound, as `swapExactIn`'s. Required. */
|
|
62
19
|
minSwapOut: bigint;
|
|
63
20
|
targetFloor: bigint;
|
|
64
21
|
cap?: bigint;
|
|
65
22
|
L: bigint;
|
|
66
|
-
/** The most of the funding token the zap may pull. Required. */
|
|
67
23
|
maxIn: bigint;
|
|
68
24
|
}
|
|
69
|
-
/**
|
|
70
|
-
* Fund a mint from a single asset: the router swaps the imbalanced part through the curve, then
|
|
71
|
-
* mints, all inside one lock — the two-action batch `[swapExactIn, mint]`.
|
|
72
|
-
*
|
|
73
|
-
* Routing the imbalanced part through the CURVE is the point, not an implementation detail. A
|
|
74
|
-
* pro-rata deposit of one asset would be a zero-slippage, zero-fee swap at stale spot — a subsidy
|
|
75
|
-
* paid by the incumbent LPs. Paying the curve removes it.
|
|
76
|
-
*/
|
|
77
25
|
export declare function zapIn(c: LogswapClient, a: ZapArgs): Promise<Hash>;
|
|
78
26
|
export interface UpdateArgs extends WriteOptions {
|
|
79
27
|
key: PoolKey;
|
|
@@ -81,13 +29,10 @@ export interface UpdateArgs extends WriteOptions {
|
|
|
81
29
|
shares: bigint;
|
|
82
30
|
toFloor: bigint;
|
|
83
31
|
toCap?: bigint;
|
|
84
|
-
/** New exposure. `0n` exits the position entirely. */
|
|
85
32
|
newL: bigint;
|
|
86
|
-
/** Required: see {@link MintArgs}. {@link previewEdit} gives the exact flows to bound. */
|
|
87
33
|
maxBaseIn: bigint;
|
|
88
34
|
maxQuoteIn: bigint;
|
|
89
35
|
}
|
|
90
|
-
/** The primitive, through the router's named entry: resize and reposition in one call, in kind. */
|
|
91
36
|
export declare function update(c: LogswapClient, a: UpdateArgs): Promise<Hash>;
|
|
92
37
|
export interface MoveArgs extends WriteOptions {
|
|
93
38
|
key: PoolKey;
|
|
@@ -95,43 +40,23 @@ export interface MoveArgs extends WriteOptions {
|
|
|
95
40
|
shares: bigint;
|
|
96
41
|
toFloor: bigint;
|
|
97
42
|
toCap?: bigint;
|
|
98
|
-
/** Required: see {@link MintArgs}. */
|
|
99
43
|
maxBaseIn: bigint;
|
|
100
44
|
maxQuoteIn: bigint;
|
|
101
45
|
}
|
|
102
|
-
/**
|
|
103
|
-
* Reposition at constant exposure — the L-pinned parent of `floor`, `cap` and `shift`; in kind.
|
|
104
|
-
*
|
|
105
|
-
* **Bound it.** The router used to settle this entry with no limit, which meant a reposition that
|
|
106
|
-
* priced differently by inclusion time could pull the whole allowance.
|
|
107
|
-
* The bounds are required; {@link UNBOUNDED} is an explicit, visible opt-out.
|
|
108
|
-
*/
|
|
109
46
|
export declare function move(c: LogswapClient, a: MoveArgs): Promise<Hash>;
|
|
110
|
-
/** Which token the edit settles in. `kind` moves both legs; `base` / `quote` nets the other side through the curve. */
|
|
111
47
|
export type SettleIn = "kind" | "base" | "quote";
|
|
112
48
|
export interface EditArgs extends WriteOptions, PairBounds {
|
|
113
49
|
key: PoolKey;
|
|
114
50
|
fromId: bigint;
|
|
115
|
-
/** The shares to edit — all of a holding, or part of it. */
|
|
116
51
|
shares: bigint;
|
|
117
|
-
/** Default `kind`. */
|
|
118
52
|
settleIn?: SettleIn;
|
|
119
|
-
/**
|
|
120
|
-
* Tolerance in basis points, applied to the flows the edit is expected to move (the lens's
|
|
121
|
-
* exact preview, plus a quote of the netting swap when `settleIn` is one token). Required: an
|
|
122
|
-
* edit's flows depend on spot when it lands. An explicit bound in `PairBounds` overrides the one
|
|
123
|
-
* derived for that token.
|
|
124
|
-
*/
|
|
125
53
|
slippageBps: number;
|
|
126
54
|
}
|
|
127
55
|
export interface EditPreview {
|
|
128
|
-
/** Signed, + = the caller deposits; the mint fee is inside `dQuote`. */
|
|
129
56
|
dBase: bigint;
|
|
130
57
|
dQuote: bigint;
|
|
131
|
-
/** Accrued fees the edit sweeps, delivered in the same settlement. */
|
|
132
58
|
fees: bigint;
|
|
133
59
|
}
|
|
134
|
-
/** The exact flows of an edit before it is sent — the lens's `previewUpdate`. */
|
|
135
60
|
export declare function previewEdit(c: LogswapClient, a: {
|
|
136
61
|
key: PoolKey;
|
|
137
62
|
fromId: bigint;
|
|
@@ -141,93 +66,40 @@ export declare function previewEdit(c: LogswapClient, a: {
|
|
|
141
66
|
toCap?: bigint;
|
|
142
67
|
newL: bigint;
|
|
143
68
|
}): Promise<EditPreview>;
|
|
144
|
-
/**
|
|
145
|
-
* Bounds for a pair of signed flows (+ = the caller pays, − = the caller receives), at `bps` of
|
|
146
|
-
* tolerance: a payment is capped from above, a receipt floored from below, and a token that does
|
|
147
|
-
* not move in that direction is bound to zero.
|
|
148
|
-
*/
|
|
149
69
|
export declare function boundsFromFlows(dBase: bigint, dQuote: bigint, bps: number): Required<PairBounds>;
|
|
150
|
-
/**
|
|
151
|
-
* The general edit as a batch: `[update]`, plus — when `settleIn` is one token — the one swap that
|
|
152
|
-
* nets the other. The other side's flow is read off the preview: released → sold with an exact-in
|
|
153
|
-
* of `OPEN_DELTA`; owed → bought with an exact-out of `OPEN_DELTA`. The settlement then binds the
|
|
154
|
-
* other token to zero both ways, so a stale preview fails loudly rather than moving it.
|
|
155
|
-
*
|
|
156
|
-
* **Bounded by default.** The preview gives the edit's exact flows at today's state; `slippageBps`
|
|
157
|
-
* turns them into the settlement's bounds. With `settleIn` one token, the netting swap is quoted
|
|
158
|
-
* on today's curve, before the update changes the active liquidity — close for a small edit, and
|
|
159
|
-
* for a large one a bound that reverts rather than one that lets a sandwich through.
|
|
160
|
-
*/
|
|
161
70
|
export declare function edit(c: LogswapClient, a: EditArgs & {
|
|
162
71
|
toFloor: bigint;
|
|
163
72
|
toCap?: bigint;
|
|
164
73
|
newL: bigint;
|
|
165
74
|
}): Promise<Hash>;
|
|
166
|
-
/** Move the floor by `rungs` (signed), cap and L pinned. Positive = harvest, negative = deepen. */
|
|
167
75
|
export declare function floor(c: LogswapClient, a: EditArgs & {
|
|
168
76
|
rungs: bigint;
|
|
169
77
|
}): Promise<Hash>;
|
|
170
|
-
/**
|
|
171
|
-
* Raise the floor by `rungs` (default 1) and withdraw PURE QUOTE — the base leg untouched.
|
|
172
|
-
*
|
|
173
|
-
* A burn is in kind: it returns base and quote pro rata, so taking α of the proceeds also takes α
|
|
174
|
-
* of the unsold inventory off the market. Raising the floor instead releases
|
|
175
|
-
*
|
|
176
|
-
* ΔQ = L (ξ' − ξ), ΔR = 0
|
|
177
|
-
*
|
|
178
|
-
* because $R = Le^{-x}$ depends on neither the floor nor the withdrawal. No base moves beyond one
|
|
179
|
-
* wei (the edit's mint half rounds what it pays in up; the preview returns it), the price
|
|
180
|
-
* does not move, and depth is unchanged. **The cost, which a UI must show:** the position stops
|
|
181
|
-
* bidding below ξ'. `settleIn: "base"` swaps the proceeds into base in the same batch.
|
|
182
|
-
*/
|
|
183
78
|
export declare function harvest(c: LogswapClient, a: EditArgs & {
|
|
184
79
|
rungs?: bigint;
|
|
185
80
|
}): Promise<Hash>;
|
|
186
|
-
/**
|
|
187
|
-
* Lower the floor by `rungs` (default 1), paying L·Δξ of quote for the deeper bid — harvest's
|
|
188
|
-
* mirror. `settleIn: "base"` pays it in base instead (an exact-out of the quote owed).
|
|
189
|
-
*/
|
|
190
81
|
export declare function deepen(c: LogswapClient, a: EditArgs & {
|
|
191
82
|
rungs?: bigint;
|
|
192
83
|
}): Promise<Hash>;
|
|
193
|
-
/** Move the cap by `rungs` (signed), floor and L pinned. Base flows while the class converts; quote once capped out. */
|
|
194
84
|
export declare function cap(c: LogswapClient, a: EditArgs & {
|
|
195
85
|
rungs: bigint;
|
|
196
86
|
}): Promise<Hash>;
|
|
197
|
-
/** Translate the class by `rungs` (signed): floor and cap together, width and L pinned. */
|
|
198
87
|
export declare function shift(c: LogswapClient, a: EditArgs & {
|
|
199
88
|
rungs: bigint;
|
|
200
89
|
}): Promise<Hash>;
|
|
201
|
-
/** Set the exposure to `newL`, floor and cap pinned; both legs pro rata. The mint fee bites on an increase only. */
|
|
202
90
|
export declare function resize(c: LogswapClient, a: EditArgs & {
|
|
203
91
|
newL: bigint;
|
|
204
92
|
}): Promise<Hash>;
|
|
205
|
-
/** Exit `shares` — `resize(0)`. `settleIn: "quote"` (or `"base"`) leaves with one asset. */
|
|
206
93
|
export declare function exit(c: LogswapClient, a: EditArgs): Promise<Hash>;
|
|
207
|
-
/**
|
|
208
|
-
* Re-express a DORMANT class's base at a new trigger price: the base is pinned, so
|
|
209
|
-
* L' = L·e^{ξ' − ξ} and nothing moves but the trigger. `toFloor` must stay above spot.
|
|
210
|
-
*
|
|
211
|
-
* The exponential is evaluated in double precision (~1e-16 relative), which is far inside the
|
|
212
|
-
* wei-rounding of the class it produces; an exact L' is not what a trigger edit is about.
|
|
213
|
-
*/
|
|
214
94
|
export declare function reprice(c: LogswapClient, a: EditArgs & {
|
|
215
95
|
toFloor: bigint;
|
|
216
96
|
}): Promise<Hash>;
|
|
217
|
-
/** Quote released by a harvest, exactly: ΔQ = L(ξ' − ξ). Base is untouched. */
|
|
218
97
|
export declare function harvestProceeds(L: bigint, fromFloor: bigint, toFloor: bigint): bigint;
|
|
219
98
|
export interface BurnArgs extends WriteOptions {
|
|
220
99
|
key: PoolKey;
|
|
221
100
|
ids: readonly bigint[];
|
|
222
101
|
shares: readonly bigint[];
|
|
223
|
-
/** The least of each token the burn must return. Required: a burn's legs depend on spot. */
|
|
224
102
|
minBaseOut: bigint;
|
|
225
103
|
minQuoteOut: bigint;
|
|
226
104
|
}
|
|
227
|
-
/**
|
|
228
|
-
* Exit, in kind, across one or more classes. Accrued fees are swept into the same settlement.
|
|
229
|
-
*
|
|
230
|
-
* In kind means both legs, pro rata. To take proceeds while leaving inventory in the market, that
|
|
231
|
-
* is {@link harvest}; to leave with one asset, {@link exit} with `settleIn`.
|
|
232
|
-
*/
|
|
233
105
|
export declare function burn(c: LogswapClient, a: BurnArgs): Promise<Hash>;
|