@logswap/sdk 0.5.76 → 0.5.77
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 +59 -1
- package/dist/admin.d.ts +116 -39
- package/dist/admin.js +151 -59
- package/dist/chains.d.ts +155 -0
- package/dist/chains.js +186 -0
- package/dist/client.d.ts +36 -5
- package/dist/client.js +47 -5
- package/dist/fees.js +3 -2
- package/dist/fpool.d.ts +71 -45
- package/dist/fpool.js +77 -47
- package/dist/generated.d.ts +321 -271
- package/dist/generated.js +282 -243
- package/dist/history.d.ts +10 -1
- package/dist/history.js +35 -9
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/indexer.d.ts +1 -1
- package/dist/indexer.js +1 -1
- package/dist/pools.d.ts +5 -3
- package/dist/pools.js +5 -4
- package/dist/positions.d.ts +1 -1
- package/dist/positions.js +4 -3
- package/dist/tokencache.d.ts +2 -10
- package/dist/tokencache.js +14 -6
- package/dist/views.d.ts +1 -1
- package/dist/write.d.ts +2 -1
- package/dist/write.js +4 -3
- package/package.json +1 -1
- package/src/admin.ts +182 -73
- package/src/chains.ts +259 -0
- package/src/client.ts +71 -8
- package/src/fees.ts +3 -2
- package/src/fpool.ts +116 -73
- package/src/generated.ts +282 -243
- package/src/history.ts +40 -12
- package/src/index.ts +1 -0
- package/src/indexer.ts +1 -1
- package/src/pools.ts +7 -5
- package/src/positions.ts +5 -4
- package/src/tokencache.ts +15 -6
- package/src/views.ts +1 -1
- package/src/write.ts +4 -3
package/dist/history.d.ts
CHANGED
|
@@ -27,7 +27,7 @@ export interface HistoryLog<A = Record<string, unknown>> {
|
|
|
27
27
|
logIndex: number;
|
|
28
28
|
}
|
|
29
29
|
export interface EventLogsQuery {
|
|
30
|
-
/** The rindexer GraphQL endpoint; absent
|
|
30
|
+
/** The rindexer GraphQL endpoint; the client's `indexerUrl` when absent, the chain when neither is set. */
|
|
31
31
|
indexer?: string;
|
|
32
32
|
/** The emitter, or several: the four policies share one table per event (indexer phase 1). */
|
|
33
33
|
address: Address | readonly Address[];
|
|
@@ -40,6 +40,7 @@ export interface EventLogsQuery {
|
|
|
40
40
|
event: AbiEvent;
|
|
41
41
|
/** Indexed arguments to match, as `getLogs` takes them; an array matches any of its values. */
|
|
42
42
|
args?: Record<string, unknown>;
|
|
43
|
+
/** The client's `deployBlock` when absent (block 0 without one), on the chain path. */
|
|
43
44
|
fromBlock?: bigint;
|
|
44
45
|
toBlock?: bigint;
|
|
45
46
|
/** Unix seconds: only events at or after this time. On the chain path it becomes a block search. */
|
|
@@ -72,6 +73,14 @@ export declare function tableFor(c: LogswapClient, address: Address, event: stri
|
|
|
72
73
|
};
|
|
73
74
|
/** How far back the chain path looks for a `latest` tape: a tape is recent by definition. */
|
|
74
75
|
export declare const LATEST_SCAN_BLOCKS = 5000n;
|
|
76
|
+
/**
|
|
77
|
+
* `eth_getLogs` over [fromBlock, toBlock] in spans of the client's `maxLogRange` blocks, results in
|
|
78
|
+
* block order. Public endpoints refuse a wide range (or truncate it); a span this size they answer.
|
|
79
|
+
* At most {@link LOG_SPANS_IN_FLIGHT} spans are asked at once.
|
|
80
|
+
*/
|
|
81
|
+
export declare function getLogsChunked<L>(c: LogswapClient, params: Record<string, unknown>, fromBlock: bigint, toBlock: bigint): Promise<L[]>;
|
|
82
|
+
/** `eth_getLogs` calls in flight at once in {@link getLogsChunked}. */
|
|
83
|
+
export declare const LOG_SPANS_IN_FLIGHT = 4;
|
|
75
84
|
/** A row of {@link getEventsLogs}: one of the asked events, named. */
|
|
76
85
|
export interface NamedHistoryLog extends HistoryLog {
|
|
77
86
|
eventName: string;
|
package/dist/history.js
CHANGED
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
* With no indexer URL, or when the query fails, it asks the node and says so in `source`.
|
|
15
15
|
*/
|
|
16
16
|
import { getAddress, parseAbiItem } from "viem";
|
|
17
|
+
import { DEFAULT_MAX_LOG_RANGE } from "./chains.js";
|
|
17
18
|
import { bytea, gql } from "./indexer.js";
|
|
18
19
|
import { blockAtOrAfter } from "./fees.js";
|
|
19
20
|
/**
|
|
@@ -21,9 +22,10 @@ import { blockAtOrAfter } from "./fees.js";
|
|
|
21
22
|
* indexer's own lag — a few blocks at most on the devnet (logswap-health checks it).
|
|
22
23
|
*/
|
|
23
24
|
export async function getEventLogs(c, q) {
|
|
24
|
-
|
|
25
|
+
const indexer = q.indexer ?? c.indexerUrl;
|
|
26
|
+
if (indexer) {
|
|
25
27
|
try {
|
|
26
|
-
return { logs: await fromIndexer(c, q), source: "indexer" };
|
|
28
|
+
return { logs: await fromIndexer(c, { ...q, indexer }), source: "indexer" };
|
|
27
29
|
}
|
|
28
30
|
catch {
|
|
29
31
|
/* the indexer is a cache: when it cannot answer, the node can */
|
|
@@ -71,7 +73,8 @@ export function indexedContractOf(kind, event) {
|
|
|
71
73
|
return "Policy";
|
|
72
74
|
}
|
|
73
75
|
/** Events whose name two indexed contracts share: postgraphile prefixes their tables. */
|
|
74
|
-
|
|
76
|
+
// `CollectorProposed` / `CollectorAccepted` are C 7 / F 26 and older; `TreasuryProposed` / `TreasuryAccepted` replace them (066).
|
|
77
|
+
const SHARED = new Set(["Transfer", "Approval", "OperatorSet", "CollectorProposed", "CollectorAccepted", "TreasuryProposed", "TreasuryAccepted", "Approved", "Listed"]);
|
|
75
78
|
const plural = (n) => (/(s|x|ch|sh)$/.test(n) ? `${n}es` : `${n}s`);
|
|
76
79
|
/** A column's GraphQL name: postgraphile camelCases the snake_case rindexer writes (`F` → `f`). */
|
|
77
80
|
const column = (name) => name[0].toLowerCase() + name.slice(1);
|
|
@@ -181,8 +184,30 @@ async function fromIndexer(c, q) {
|
|
|
181
184
|
// ─── the chain path ──────────────────────────────────────────────────────────
|
|
182
185
|
/** How far back the chain path looks for a `latest` tape: a tape is recent by definition. */
|
|
183
186
|
export const LATEST_SCAN_BLOCKS = 5000n;
|
|
187
|
+
/**
|
|
188
|
+
* `eth_getLogs` over [fromBlock, toBlock] in spans of the client's `maxLogRange` blocks, results in
|
|
189
|
+
* block order. Public endpoints refuse a wide range (or truncate it); a span this size they answer.
|
|
190
|
+
* At most {@link LOG_SPANS_IN_FLIGHT} spans are asked at once.
|
|
191
|
+
*/
|
|
192
|
+
export async function getLogsChunked(c, params, fromBlock, toBlock) {
|
|
193
|
+
const span = c.maxLogRange ?? DEFAULT_MAX_LOG_RANGE;
|
|
194
|
+
if (span <= 0n)
|
|
195
|
+
throw new Error("logswap: maxLogRange must be positive");
|
|
196
|
+
const ranges = [];
|
|
197
|
+
for (let lo = fromBlock; lo <= toBlock; lo += span)
|
|
198
|
+
ranges.push([lo, lo + span - 1n < toBlock ? lo + span - 1n : toBlock]);
|
|
199
|
+
const out = [];
|
|
200
|
+
for (let i = 0; i < ranges.length; i += LOG_SPANS_IN_FLIGHT) {
|
|
201
|
+
const got = await Promise.all(ranges.slice(i, i + LOG_SPANS_IN_FLIGHT).map(([lo, hi]) => c.public.getLogs({ ...params, fromBlock: lo, toBlock: hi })));
|
|
202
|
+
for (const g of got)
|
|
203
|
+
out.push(...g);
|
|
204
|
+
}
|
|
205
|
+
return out;
|
|
206
|
+
}
|
|
207
|
+
/** `eth_getLogs` calls in flight at once in {@link getLogsChunked}. */
|
|
208
|
+
export const LOG_SPANS_IN_FLIGHT = 4;
|
|
184
209
|
async function fromChain(c, q) {
|
|
185
|
-
let fromBlock = q.fromBlock ?? 0n;
|
|
210
|
+
let fromBlock = q.fromBlock ?? c.deployBlock ?? 0n;
|
|
186
211
|
const toBlock = q.toBlock ?? (await c.public.getBlockNumber({ cacheTime: 0 })); // uncached: viem caches the head, and a scan bounded by a stale one misses the block just mined
|
|
187
212
|
if (q.since !== undefined)
|
|
188
213
|
fromBlock = await blockAtOrAfter(c, BigInt(q.since), fromBlock, toBlock);
|
|
@@ -191,7 +216,7 @@ async function fromChain(c, q) {
|
|
|
191
216
|
const all = emitters(q);
|
|
192
217
|
if (all.length === 0)
|
|
193
218
|
return [];
|
|
194
|
-
let logs =
|
|
219
|
+
let logs = await getLogsChunked(c, { address: Array.isArray(q.address) ? all : q.address, event: q.event, args: q.args }, fromBlock, toBlock);
|
|
195
220
|
if (q.transactionHashes) {
|
|
196
221
|
const want = new Set(q.transactionHashes.map((h) => h.toLowerCase()));
|
|
197
222
|
logs = logs.filter((l) => want.has(l.transactionHash.toLowerCase()));
|
|
@@ -214,11 +239,12 @@ async function fromChain(c, q) {
|
|
|
214
239
|
*/
|
|
215
240
|
export async function getEventsLogs(c, q) {
|
|
216
241
|
const order = (a, b) => (a.blockNumber === b.blockNumber ? a.logIndex - b.logIndex : a.blockNumber < b.blockNumber ? -1 : 1);
|
|
217
|
-
|
|
242
|
+
const indexer = q.indexer ?? c.indexerUrl;
|
|
243
|
+
if (indexer && q.events.length > 0) {
|
|
218
244
|
try {
|
|
219
245
|
const got = await Promise.all(q.events.map(async (event) => {
|
|
220
246
|
const contract = q.kind ? indexedContractOf(q.kind, event.name) : q.contract;
|
|
221
|
-
return (await fromIndexer(c, { ...q, event, contract })).map((l) => ({ ...l, eventName: event.name }));
|
|
247
|
+
return (await fromIndexer(c, { ...q, indexer, event, contract })).map((l) => ({ ...l, eventName: event.name }));
|
|
222
248
|
}));
|
|
223
249
|
return { logs: got.flat().sort(order), source: "indexer" };
|
|
224
250
|
}
|
|
@@ -229,11 +255,11 @@ export async function getEventsLogs(c, q) {
|
|
|
229
255
|
const all = emitters(q);
|
|
230
256
|
if (all.length === 0 || q.events.length === 0)
|
|
231
257
|
return { logs: [], source: "chain" };
|
|
232
|
-
let fromBlock = q.fromBlock ?? 0n;
|
|
258
|
+
let fromBlock = q.fromBlock ?? c.deployBlock ?? 0n;
|
|
233
259
|
const toBlock = q.toBlock ?? (await c.public.getBlockNumber({ cacheTime: 0 })); // uncached: viem caches the head, and a scan bounded by a stale one misses the block just mined
|
|
234
260
|
if (q.since !== undefined)
|
|
235
261
|
fromBlock = await blockAtOrAfter(c, BigInt(q.since), fromBlock, toBlock);
|
|
236
|
-
const logs =
|
|
262
|
+
const logs = await getLogsChunked(c, { address: Array.isArray(q.address) ? all : q.address, events: q.events }, fromBlock, toBlock);
|
|
237
263
|
return {
|
|
238
264
|
logs: logs
|
|
239
265
|
.map((l) => ({ eventName: l.eventName, address: l.address ? getAddress(l.address) : all[0], args: l.args, blockNumber: l.blockNumber, transactionHash: l.transactionHash, logIndex: l.logIndex }))
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
package/dist/indexer.d.ts
CHANGED
|
@@ -93,7 +93,7 @@ export declare function discoverMarketsIndexed(url: string, signal?: AbortSignal
|
|
|
93
93
|
* The order matters: the indexer is authoritative for history, the node is authoritative for state.
|
|
94
94
|
* A market the node can no longer tell you about is still a market.
|
|
95
95
|
*/
|
|
96
|
-
export declare function discoverMarketsBest(c: LogswapClient, url
|
|
96
|
+
export declare function discoverMarketsBest(c: LogswapClient, url?: string | undefined, signal?: AbortSignal): Promise<{
|
|
97
97
|
markets: DiscoveredMarket[];
|
|
98
98
|
source: "indexer" | "chain";
|
|
99
99
|
}>;
|
package/dist/indexer.js
CHANGED
|
@@ -162,7 +162,7 @@ export async function discoverMarketsIndexed(url, signal) {
|
|
|
162
162
|
* The order matters: the indexer is authoritative for history, the node is authoritative for state.
|
|
163
163
|
* A market the node can no longer tell you about is still a market.
|
|
164
164
|
*/
|
|
165
|
-
export async function discoverMarketsBest(c, url, signal) {
|
|
165
|
+
export async function discoverMarketsBest(c, url = c.indexerUrl, signal) {
|
|
166
166
|
if (url) {
|
|
167
167
|
try {
|
|
168
168
|
const markets = await discoverMarketsIndexed(url, signal);
|
package/dist/pools.d.ts
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
* conversion is. Prefer comparing in log space when precision matters.
|
|
13
13
|
*/
|
|
14
14
|
import { type Address, type Hex } from "viem";
|
|
15
|
-
import type
|
|
15
|
+
import { type LogswapClient } from "./client.js";
|
|
16
16
|
import { type PoolKey } from "./keys.js";
|
|
17
17
|
/**
|
|
18
18
|
* A market's scalar state, field-for-field with `CPoolState.PoolView` — what the manager's `getPool`
|
|
@@ -37,6 +37,8 @@ export interface PoolState {
|
|
|
37
37
|
backstopFloor: bigint;
|
|
38
38
|
/** The market's mint fee, WAD of newly-earning L: proposed at birth, the gate's answer (065). */
|
|
39
39
|
mintFee: bigint;
|
|
40
|
+
/** The market's swap-fee tax, WAD of every fee paid out: the gate's answer at birth, fixed for life (066). */
|
|
41
|
+
swapFeeTax: bigint;
|
|
40
42
|
}
|
|
41
43
|
/** Read a market's full state by key, through the lens (`getPools`; C version 7). All zero, `initialized` false, for a market nobody opened. */
|
|
42
44
|
export declare function getPool(c: LogswapClient, key: PoolKey): Promise<PoolState>;
|
|
@@ -112,8 +114,8 @@ export interface DiscoveredMarket {
|
|
|
112
114
|
* Enumerate markets from `Initialize` logs.
|
|
113
115
|
*
|
|
114
116
|
* This is the whole market registry: the event carries every key field rather than just the id,
|
|
115
|
-
* deliberately, so nothing downstream needs a configured list.
|
|
116
|
-
*
|
|
117
|
+
* deliberately, so nothing downstream needs a configured list. The scan starts at the client's
|
|
118
|
+
* `deployBlock` unless `fromBlock` says otherwise.
|
|
117
119
|
*/
|
|
118
120
|
export declare function discoverMarkets(c: LogswapClient, opts?: {
|
|
119
121
|
fromBlock?: bigint;
|
package/dist/pools.js
CHANGED
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
*/
|
|
14
14
|
import { formatUnits } from "viem";
|
|
15
15
|
import { logswapLensAbi, cPoolManagerAbi } from "./generated.js";
|
|
16
|
+
import { clientChainId } from "./client.js";
|
|
16
17
|
import { signerFor } from "./write.js";
|
|
17
18
|
import { readCachedToken, registerCacheClear, writeCachedToken } from "./tokencache.js";
|
|
18
19
|
import { poolId } from "./keys.js";
|
|
@@ -105,8 +106,8 @@ export function lpEdge(state) {
|
|
|
105
106
|
* Enumerate markets from `Initialize` logs.
|
|
106
107
|
*
|
|
107
108
|
* This is the whole market registry: the event carries every key field rather than just the id,
|
|
108
|
-
* deliberately, so nothing downstream needs a configured list.
|
|
109
|
-
*
|
|
109
|
+
* deliberately, so nothing downstream needs a configured list. The scan starts at the client's
|
|
110
|
+
* `deployBlock` unless `fromBlock` says otherwise.
|
|
110
111
|
*/
|
|
111
112
|
export async function discoverMarkets(c, opts = {}) {
|
|
112
113
|
const ev = cPoolManagerAbi.find((x) => x.type === "event" && x.name === "Initialize");
|
|
@@ -122,7 +123,7 @@ export async function discoverMarkets(c, opts = {}) {
|
|
|
122
123
|
address: c.addresses.cPoolManager,
|
|
123
124
|
event: ev,
|
|
124
125
|
args,
|
|
125
|
-
fromBlock: opts.fromBlock
|
|
126
|
+
fromBlock: opts.fromBlock, // the client's deployBlock when absent
|
|
126
127
|
toBlock: opts.toBlock,
|
|
127
128
|
});
|
|
128
129
|
return logs.map((l) => {
|
|
@@ -204,7 +205,7 @@ export async function marketTokens(c, key) {
|
|
|
204
205
|
{ type: "function", name: "decimals", stateMutability: "view", inputs: [], outputs: [{ type: "uint8" }] },
|
|
205
206
|
{ type: "function", name: "symbol", stateMutability: "view", inputs: [], outputs: [{ type: "string" }] },
|
|
206
207
|
];
|
|
207
|
-
const chainId =
|
|
208
|
+
const chainId = await clientChainId(c);
|
|
208
209
|
const readDecimals = async (address) => {
|
|
209
210
|
let last;
|
|
210
211
|
for (let attempt = 0; attempt < 3; attempt++) {
|
package/dist/positions.d.ts
CHANGED
|
@@ -123,7 +123,7 @@ export declare function presetMintFee(swapFee: bigint): bigint;
|
|
|
123
123
|
*
|
|
124
124
|
* Mirrors the manager's exemption cases: a DORMANT mint pays nothing — floor above spot, or a
|
|
125
125
|
* capped class spot has already passed (`cap <= x`). Anything earning pays `rate · L`, all of it
|
|
126
|
-
* the protocol's (decisions 058); with no
|
|
126
|
+
* the protocol's (decisions 058); with no treasury it goes through `F` to the LPs already
|
|
127
127
|
* earning, and with none earning it is not charged. This is NOT the swap fee: that one is charged
|
|
128
128
|
* per unit of |Δ log p| on swaps; this is a flat charge on L, once, at mint.
|
|
129
129
|
*
|
package/dist/positions.js
CHANGED
|
@@ -160,7 +160,7 @@ export function presetMintFee(swapFee) {
|
|
|
160
160
|
*
|
|
161
161
|
* Mirrors the manager's exemption cases: a DORMANT mint pays nothing — floor above spot, or a
|
|
162
162
|
* capped class spot has already passed (`cap <= x`). Anything earning pays `rate · L`, all of it
|
|
163
|
-
* the protocol's (decisions 058); with no
|
|
163
|
+
* the protocol's (decisions 058); with no treasury it goes through `F` to the LPs already
|
|
164
164
|
* earning, and with none earning it is not charged. This is NOT the swap fee: that one is charged
|
|
165
165
|
* per unit of |Δ log p| on swaps; this is a flat charge on L, once, at mint.
|
|
166
166
|
*
|
|
@@ -208,9 +208,10 @@ async function registeredIds(c, pool, fromBlock, indexer) {
|
|
|
208
208
|
* holder's slice is L · shares_owner / shares_class, and fees from the lens. One log query plus
|
|
209
209
|
* a read per registered class; fine for a pool's lifetime of classes.
|
|
210
210
|
*/
|
|
211
|
-
export async function holdingsOf(c, key, owner, fromBlock
|
|
211
|
+
export async function holdingsOf(c, key, owner, fromBlock, opts = {}) {
|
|
212
212
|
const pool = poolId(key);
|
|
213
|
-
const
|
|
213
|
+
const indexer = opts.indexer ?? c.indexerUrl;
|
|
214
|
+
const ids = (indexer ? await heldIdsFromView(c, indexer, pool, owner) : null) ?? (await registeredIds(c, pool, fromBlock, indexer));
|
|
214
215
|
if (ids.length === 0)
|
|
215
216
|
return [];
|
|
216
217
|
// one lens call: balance, class L, fees, floor and cap for every id the owner holds
|
package/dist/tokencache.d.ts
CHANGED
|
@@ -49,17 +49,9 @@ export declare const memoryStore: TokenStore;
|
|
|
49
49
|
export declare function browserStore(prefix?: string): TokenStore;
|
|
50
50
|
/** Swap the backing store. Call once at startup; `browserStore()` is the usual argument. */
|
|
51
51
|
export declare function setTokenStore(s: TokenStore): void;
|
|
52
|
-
/**
|
|
53
|
-
* Chains whose addresses are not permanent identities: a development node can be wiped and
|
|
54
|
-
* redeployed, and because deployment addresses are derived from a deterministic nonce sequence the
|
|
55
|
-
* SAME address comes back holding a different contract. 1337 is ganache's and hardhat's legacy id,
|
|
56
|
-
* 31337 anvil's and hardhat's default, 31338 and 31339 the unimod and logswap devnets — both
|
|
57
|
-
* persisted with `--state`, both documented as resettable by deleting that file.
|
|
58
|
-
*
|
|
59
|
-
* Add to this set rather than removing from it: a chain wrongly listed here costs some RPC round
|
|
60
|
-
* trips, while one wrongly absent silently serves a stale scale, which is the bug this exists for.
|
|
61
|
-
*/
|
|
62
52
|
export declare const RESETTABLE_CHAINS: ReadonlySet<number>;
|
|
53
|
+
/** Mark a development chain the registry does not list as resettable. There is no removal. */
|
|
54
|
+
export declare function addResettableChain(chainId: number): void;
|
|
63
55
|
/** True when a `(chainId, address)` pair cannot be trusted to name one contract forever. */
|
|
64
56
|
export declare function isResettableChain(chainId: number): boolean;
|
|
65
57
|
export declare function readCachedToken(chainId: number, address: Address): CachedToken | null;
|
package/dist/tokencache.js
CHANGED
|
@@ -28,6 +28,7 @@
|
|
|
28
28
|
* that did would break every integration, not just this one. That is what makes an unbounded TTL
|
|
29
29
|
* correct rather than merely convenient — on a chain whose addresses are permanent.
|
|
30
30
|
*/
|
|
31
|
+
import { LOGSWAP_CHAINS } from "./chains.js";
|
|
31
32
|
const memory = new Map();
|
|
32
33
|
/** The default: per-process, no persistence. Works in node, workers and a browser alike. */
|
|
33
34
|
export const memoryStore = {
|
|
@@ -88,14 +89,21 @@ const keyOf = (chainId, address) => `${chainId}:${address.toLowerCase()}`;
|
|
|
88
89
|
/**
|
|
89
90
|
* Chains whose addresses are not permanent identities: a development node can be wiped and
|
|
90
91
|
* redeployed, and because deployment addresses are derived from a deterministic nonce sequence the
|
|
91
|
-
* SAME address comes back holding a different contract.
|
|
92
|
-
* 31337 anvil's and hardhat's default,
|
|
93
|
-
* persisted with `--state
|
|
92
|
+
* SAME address comes back holding a different contract. Every chain the registry flags `devnet`
|
|
93
|
+
* (31337 anvil's and hardhat's default, 31339 the logswap devnet), plus 1337 (ganache's and
|
|
94
|
+
* hardhat's legacy id) and 31338 (the unimod devnet), persisted with `--state` and documented as
|
|
95
|
+
* resettable by deleting that file.
|
|
94
96
|
*
|
|
95
|
-
* Add to this set rather than removing from it: a chain wrongly listed
|
|
96
|
-
* trips, while one wrongly absent silently serves a stale scale, which is
|
|
97
|
+
* Add to this set rather than removing from it ({@link addResettableChain}): a chain wrongly listed
|
|
98
|
+
* here costs some RPC round trips, while one wrongly absent silently serves a stale scale, which is
|
|
99
|
+
* the bug this exists for.
|
|
97
100
|
*/
|
|
98
|
-
|
|
101
|
+
const resettable = new Set([1337, 31338, ...Object.values(LOGSWAP_CHAINS).filter((ch) => ch.devnet).map((ch) => ch.chainId)]);
|
|
102
|
+
export const RESETTABLE_CHAINS = resettable;
|
|
103
|
+
/** Mark a development chain the registry does not list as resettable. There is no removal. */
|
|
104
|
+
export function addResettableChain(chainId) {
|
|
105
|
+
resettable.add(chainId);
|
|
106
|
+
}
|
|
99
107
|
/** True when a `(chainId, address)` pair cannot be trusted to name one contract forever. */
|
|
100
108
|
export function isResettableChain(chainId) {
|
|
101
109
|
return RESETTABLE_CHAINS.has(chainId);
|
package/dist/views.d.ts
CHANGED
|
@@ -268,7 +268,7 @@ export interface PadStatusRow {
|
|
|
268
268
|
export declare function padStatuses(url: string, q?: ViewQuery): Promise<PadStatusRow[]>;
|
|
269
269
|
/**
|
|
270
270
|
* Protocol revenue per UTC day, side, source and token. Sources: F `mint_fee` (shares minted to the
|
|
271
|
-
*
|
|
271
|
+
* treasury, valued at the share value) and `pot_cut`; C `accrued` (the swap-fee tax and the mint fee
|
|
272
272
|
* together, from the snapshots) and `collected` — basis `collected`, cash moved, not revenue on top
|
|
273
273
|
* of `accrued`.
|
|
274
274
|
*/
|
package/dist/write.d.ts
CHANGED
|
@@ -68,7 +68,8 @@ type AbiError = {
|
|
|
68
68
|
};
|
|
69
69
|
/**
|
|
70
70
|
* Every custom error a router call can revert with that the router's own ABI does not declare: the
|
|
71
|
-
* C and F managers' (a mint, a swap or a settlement bubbles them up unchanged)
|
|
71
|
+
* C and F managers' (a mint, a swap or a settlement bubbles them up unchanged), the pad policy's
|
|
72
|
+
* (a launch's `NoThreshold`, `PadExists`, `OutOfRange`; a graduation's `NotGraduated`) and Permit2's.
|
|
72
73
|
* Without them viem can name only the router's errors, and anything raised in the manager comes
|
|
73
74
|
* back as a bare selector.
|
|
74
75
|
*/
|
package/dist/write.js
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
* raw `minOut`/`maxIn` the contract wants. `withSlippage()` derives one from a quote when that is
|
|
13
13
|
* what you have — but the bound is what ships.
|
|
14
14
|
*/
|
|
15
|
-
import { cPoolManagerAbi, fPoolManagerAbi } from "./generated.js";
|
|
15
|
+
import { cPoolManagerAbi, fPoolManagerAbi, padPolicyAbi } from "./generated.js";
|
|
16
16
|
/** Disables the deadline check. Deliberate opt-out, never a default. */
|
|
17
17
|
export const NEVER = (1n << 256n) - 1n;
|
|
18
18
|
/** Default deadline window: 20 minutes, the same order as every major DEX front end. */
|
|
@@ -81,14 +81,15 @@ const permit2Errors = [
|
|
|
81
81
|
const errorKey = (e) => `${e.name}(${e.inputs.map((i) => i.type).join(",")})`;
|
|
82
82
|
/**
|
|
83
83
|
* Every custom error a router call can revert with that the router's own ABI does not declare: the
|
|
84
|
-
* C and F managers' (a mint, a swap or a settlement bubbles them up unchanged)
|
|
84
|
+
* C and F managers' (a mint, a swap or a settlement bubbles them up unchanged), the pad policy's
|
|
85
|
+
* (a launch's `NoThreshold`, `PadExists`, `OutOfRange`; a graduation's `NotGraduated`) and Permit2's.
|
|
85
86
|
* Without them viem can name only the router's errors, and anything raised in the manager comes
|
|
86
87
|
* back as a bare selector.
|
|
87
88
|
*/
|
|
88
89
|
export const routerRevertErrors = (() => {
|
|
89
90
|
const seen = new Set();
|
|
90
91
|
const out = [];
|
|
91
|
-
for (const x of [...cPoolManagerAbi, ...fPoolManagerAbi, ...permit2Errors]) {
|
|
92
|
+
for (const x of [...cPoolManagerAbi, ...fPoolManagerAbi, ...padPolicyAbi, ...permit2Errors]) {
|
|
92
93
|
if (x.type !== "error")
|
|
93
94
|
continue;
|
|
94
95
|
const e = x;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@logswap/sdk",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.77",
|
|
4
4
|
"description": "TypeScript SDK for Logswap, the liquidity primitive introducing the logarithmic invariant — typed wrappers over the CPoolManager / FPoolManager / Router / Lens surface.",
|
|
5
5
|
"license": "GPL-2.0-or-later",
|
|
6
6
|
"type": "module",
|