@logswap/sdk 0.5.98 → 0.5.100
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 +46 -31
- package/dist/actions.d.ts +8 -8
- package/dist/actions.js +8 -8
- package/dist/client.d.ts +2 -2
- package/dist/client.js +11 -2
- package/dist/fees.js +2 -24
- package/dist/fpool.d.ts +10 -6
- package/dist/fpool.js +12 -23
- package/dist/generated.d.ts +84 -47
- package/dist/generated.js +88 -37
- package/dist/history.d.ts +1 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -1
- package/dist/liquidity.d.ts +2 -1
- package/dist/liquidity.js +2 -1
- package/dist/positions.js +2 -13
- package/package.json +1 -1
- package/src/actions.ts +12 -12
- package/src/client.ts +11 -2
- package/src/fees.ts +2 -22
- package/src/fpool.ts +16 -24
- package/src/generated.ts +88 -37
- package/src/history.ts +1 -1
- package/src/index.ts +0 -1
- package/src/liquidity.ts +2 -1
- package/src/positions.ts +3 -14
- package/dist/views.d.ts +0 -281
- package/dist/views.js +0 -188
- package/src/views.ts +0 -480
package/src/fpool.ts
CHANGED
|
@@ -48,7 +48,6 @@ import { clientChainId, type LogswapClient } from "./client.js";
|
|
|
48
48
|
import { findQuoteResult } from "./quote.js";
|
|
49
49
|
import { fallBackUnlessRejected, signerFor } from "./write.js";
|
|
50
50
|
import { getEventLogs } from "./history.js";
|
|
51
|
-
import { poolHolders } from "./views.js";
|
|
52
51
|
|
|
53
52
|
const WAD = 10n ** 18n;
|
|
54
53
|
const ZERO_ADDRESS = "0x0000000000000000000000000000000000000000" as const;
|
|
@@ -508,8 +507,9 @@ export async function fPoolMint(
|
|
|
508
507
|
/** `maxQuoteIn` is required: the quote leg is Q·dL/L at landing, and Q moves with every swap. */
|
|
509
508
|
a: { poolId: Hex; dL: bigint; maxQuoteIn: bigint; account: Address; to?: Address },
|
|
510
509
|
) {
|
|
511
|
-
// shares go to `to` (the account by default); on a gated pool `to` must be allowed
|
|
512
|
-
|
|
510
|
+
// shares go to `to` (the account by default); on a gated pool `to` must be allowed. `payer` (F 42, decision 107) is the
|
|
511
|
+
// account the caller declares as funding the mint, read by `SharesMinted` alone: on this direct call, the sender itself.
|
|
512
|
+
return writeFPool(c, a.poolId, "mint", [a.account, a.to ?? a.account, a.dL, a.maxQuoteIn], a.account);
|
|
513
513
|
}
|
|
514
514
|
|
|
515
515
|
/**
|
|
@@ -698,13 +698,14 @@ export async function fPoolHarvest(c: LogswapClient, a: { poolId: Hex; extra?: b
|
|
|
698
698
|
}
|
|
699
699
|
|
|
700
700
|
/**
|
|
701
|
-
* Pull
|
|
701
|
+
* Pull an owner's settled dividend on a generation's shares without moving them;
|
|
702
702
|
* anyone with shares. `gen` defaults to the live generation; a retired generation's harvests
|
|
703
|
-
* stay claimable under its own id.
|
|
703
|
+
* stay claimable under its own id. By owner (F 42), as {@link fPoolBurn} and {@link fPoolRedeem}: the account claims its
|
|
704
|
+
* own, and an ERC-6909 operator may pass another `owner`. Paid to `to` (the account by default).
|
|
704
705
|
*/
|
|
705
|
-
export async function fPoolClaim(c: LogswapClient, a: { poolId: Hex; gen?: bigint | number; to?: Address; account: Address }) {
|
|
706
|
+
export async function fPoolClaim(c: LogswapClient, a: { poolId: Hex; gen?: bigint | number; owner?: Address; to?: Address; account: Address }) {
|
|
706
707
|
const gen = a.gen ?? (await fPoolGen(c, a.poolId));
|
|
707
|
-
return writeFPool(c, a.poolId, "claim", [BigInt(gen), a.to ?? a.account], a.account);
|
|
708
|
+
return writeFPool(c, a.poolId, "claim", [BigInt(gen), a.owner ?? a.account, a.to ?? a.account], a.account);
|
|
708
709
|
}
|
|
709
710
|
|
|
710
711
|
/**
|
|
@@ -1893,6 +1894,8 @@ export interface DiscoveredFPool {
|
|
|
1893
1894
|
policy: Address;
|
|
1894
1895
|
/** The key's salt: zero under an open policy. */
|
|
1895
1896
|
salt: Hex;
|
|
1897
|
+
/** The account that created the pool (`PoolCreated.creator`, F 42): the one the policy judged. Not a key field. */
|
|
1898
|
+
creator: Address;
|
|
1896
1899
|
/** The block the pool was initialized in — its age, for annualising realized income. */
|
|
1897
1900
|
block: bigint;
|
|
1898
1901
|
/** Whether `deployLiquidity` has run; an unfunded pool has no floor and no float, so nothing to show. */
|
|
@@ -1910,7 +1913,7 @@ export interface DiscoveredFPool {
|
|
|
1910
1913
|
|
|
1911
1914
|
/**
|
|
1912
1915
|
* Every F pool ever created, from `PoolCreated` logs alone — plus the terms of each distinct policy, read once and cached.
|
|
1913
|
-
* Possible only because the event carries the full key (quote, policy, bases, swapFeeIdx, salt) — the poolId is a hash and
|
|
1916
|
+
* Possible only because the event carries the full key (quote, policy, bases, swapFeeIdx, salt) and the creator — the poolId is a hash and
|
|
1914
1917
|
* could never be inverted; contracts PR #17 exists for exactly this call. With `indexer`, the logs come from it (the node
|
|
1915
1918
|
* when it fails): a scan from block 0 per call is what made the first load wait on the node.
|
|
1916
1919
|
*/
|
|
@@ -1937,7 +1940,7 @@ export async function discoverFPools(
|
|
|
1937
1940
|
}
|
|
1938
1941
|
return Promise.all(
|
|
1939
1942
|
logs.map(async (l) => {
|
|
1940
|
-
const a = l.args as { poolId: Hex; quote: Address; policy: Address; bases: readonly Address[]; swapFeeIdx: number | bigint; salt: Hex };
|
|
1943
|
+
const a = l.args as { poolId: Hex; quote: Address; creator: Address; policy: Address; bases: readonly Address[]; swapFeeIdx: number | bigint; salt: Hex };
|
|
1941
1944
|
const g0 = first.get(a.poolId.toLowerCase());
|
|
1942
1945
|
const kind = await fPoolKindOfPolicy(c, a.policy); // one read per distinct policy, cached
|
|
1943
1946
|
const swapFeeIdx = Number(a.swapFeeIdx);
|
|
@@ -1953,6 +1956,7 @@ export async function discoverFPools(
|
|
|
1953
1956
|
kind,
|
|
1954
1957
|
policy: a.policy,
|
|
1955
1958
|
salt: a.salt,
|
|
1959
|
+
creator: a.creator,
|
|
1956
1960
|
block: l.blockNumber,
|
|
1957
1961
|
seeded: g0 !== undefined,
|
|
1958
1962
|
q0: g0?.q0 ?? 0n,
|
|
@@ -2004,9 +2008,9 @@ export async function fPoolsControlledBy(
|
|
|
2004
2008
|
/**
|
|
2005
2009
|
* Every holder of a pool's shares, from the ERC-6909 Transfer stream — the id is an indexed
|
|
2006
2010
|
* topic, so one filtered log query aggregates the whole ledger. The 0xdead entry is the
|
|
2007
|
-
* MIN_SHARES lock from seeding; callers usually label rather than hide it. Pass `indexer`: the
|
|
2008
|
-
* prunes its logs (anvil keeps about a day), and a ledger rebuilt from a pruned stream loses every
|
|
2009
|
-
* holder minted before the cut.
|
|
2011
|
+
* MIN_SHARES lock from seeding; callers usually label rather than hide it. Pass `indexer`: the Transfer rows come from
|
|
2012
|
+
* its tables — a node prunes its logs (anvil keeps about a day), and a ledger rebuilt from a pruned stream loses every
|
|
2013
|
+
* holder minted before the cut. (The indexer's derived views are read by the app's `@logswap/base`, not here.)
|
|
2010
2014
|
*/
|
|
2011
2015
|
export async function fPoolShareHolders(
|
|
2012
2016
|
c: LogswapClient,
|
|
@@ -2017,18 +2021,6 @@ export async function fPoolShareHolders(
|
|
|
2017
2021
|
const ev = managerFAbi.find((x): x is Ev => x.type === "event" && x.name === "Transfer");
|
|
2018
2022
|
if (!ev) throw new Error("logswap: 6909 Transfer event missing from the generated ABI");
|
|
2019
2023
|
const gen = opts.gen ?? (await fPoolGen(c, poolIdHex));
|
|
2020
|
-
const indexer = opts.indexer ?? c.indexerUrl;
|
|
2021
|
-
if (indexer) {
|
|
2022
|
-
try {
|
|
2023
|
-
const rows = await poolHolders(indexer, { condition: { side: "F", poolId: poolIdHex.toLowerCase(), gen: Number(gen), manager: c.addresses.managerF.toLowerCase() } });
|
|
2024
|
-
return rows
|
|
2025
|
-
.filter((r) => r.balance > 0n)
|
|
2026
|
-
.map((r) => ({ holder: r.holder, shares: r.balance }))
|
|
2027
|
-
.sort((a, b) => (b.shares > a.shares ? 1 : -1));
|
|
2028
|
-
} catch {
|
|
2029
|
-
/* the view is a cache: the Transfer replay below answers the same */
|
|
2030
|
-
}
|
|
2031
|
-
}
|
|
2032
2024
|
const id = fPoolShareId(poolIdHex, gen);
|
|
2033
2025
|
const { logs } = await getEventLogs(c, { indexer: opts.indexer, address: c.addresses.managerF, event: ev, args: { id }, fromBlock: opts.fromBlock });
|
|
2034
2026
|
const bal = new Map<string, bigint>();
|
package/src/generated.ts
CHANGED
|
@@ -785,6 +785,7 @@ export const managerCAbi = [
|
|
|
785
785
|
type: 'function',
|
|
786
786
|
inputs: [
|
|
787
787
|
{ name: 'poolId', internalType: 'bytes32', type: 'bytes32' },
|
|
788
|
+
{ name: 'payer', internalType: 'address', type: 'address' },
|
|
788
789
|
{ name: 'to', internalType: 'address', type: 'address' },
|
|
789
790
|
{ name: 'floor', internalType: 'int256', type: 'int256' },
|
|
790
791
|
{ name: 'cap', internalType: 'int256', type: 'int256' },
|
|
@@ -1031,13 +1032,13 @@ export const managerCAbi = [
|
|
|
1031
1032
|
type: 'event',
|
|
1032
1033
|
anonymous: false,
|
|
1033
1034
|
inputs: [
|
|
1034
|
-
{ name: 'id', internalType: 'uint256', type: 'uint256', indexed: true },
|
|
1035
1035
|
{
|
|
1036
1036
|
name: 'poolId',
|
|
1037
1037
|
internalType: 'bytes32',
|
|
1038
1038
|
type: 'bytes32',
|
|
1039
1039
|
indexed: true,
|
|
1040
1040
|
},
|
|
1041
|
+
{ name: 'id', internalType: 'uint256', type: 'uint256', indexed: true },
|
|
1041
1042
|
{ name: 'floor', internalType: 'int256', type: 'int256', indexed: false },
|
|
1042
1043
|
{ name: 'cap', internalType: 'int256', type: 'int256', indexed: false },
|
|
1043
1044
|
{ name: 'capped', internalType: 'bool', type: 'bool', indexed: false },
|
|
@@ -1055,7 +1056,7 @@ export const managerCAbi = [
|
|
|
1055
1056
|
indexed: true,
|
|
1056
1057
|
},
|
|
1057
1058
|
{
|
|
1058
|
-
name: '
|
|
1059
|
+
name: 'owner',
|
|
1059
1060
|
internalType: 'address',
|
|
1060
1061
|
type: 'address',
|
|
1061
1062
|
indexed: true,
|
|
@@ -1193,7 +1194,12 @@ export const managerCAbi = [
|
|
|
1193
1194
|
type: 'bytes32',
|
|
1194
1195
|
indexed: true,
|
|
1195
1196
|
},
|
|
1196
|
-
{
|
|
1197
|
+
{
|
|
1198
|
+
name: 'owner',
|
|
1199
|
+
internalType: 'address',
|
|
1200
|
+
type: 'address',
|
|
1201
|
+
indexed: true,
|
|
1202
|
+
},
|
|
1197
1203
|
{ name: 'id', internalType: 'uint256', type: 'uint256', indexed: true },
|
|
1198
1204
|
{
|
|
1199
1205
|
name: 'shares',
|
|
@@ -1234,6 +1240,18 @@ export const managerCAbi = [
|
|
|
1234
1240
|
},
|
|
1235
1241
|
{ name: 'to', internalType: 'address', type: 'address', indexed: true },
|
|
1236
1242
|
{ name: 'id', internalType: 'uint256', type: 'uint256', indexed: true },
|
|
1243
|
+
{
|
|
1244
|
+
name: 'sender',
|
|
1245
|
+
internalType: 'address',
|
|
1246
|
+
type: 'address',
|
|
1247
|
+
indexed: false,
|
|
1248
|
+
},
|
|
1249
|
+
{
|
|
1250
|
+
name: 'payer',
|
|
1251
|
+
internalType: 'address',
|
|
1252
|
+
type: 'address',
|
|
1253
|
+
indexed: false,
|
|
1254
|
+
},
|
|
1237
1255
|
{
|
|
1238
1256
|
name: 'shares',
|
|
1239
1257
|
internalType: 'uint256',
|
|
@@ -1266,7 +1284,7 @@ export const managerCAbi = [
|
|
|
1266
1284
|
indexed: true,
|
|
1267
1285
|
},
|
|
1268
1286
|
{
|
|
1269
|
-
name: '
|
|
1287
|
+
name: 'owner',
|
|
1270
1288
|
internalType: 'address',
|
|
1271
1289
|
type: 'address',
|
|
1272
1290
|
indexed: true,
|
|
@@ -1321,6 +1339,12 @@ export const managerCAbi = [
|
|
|
1321
1339
|
type: 'bytes32',
|
|
1322
1340
|
indexed: true,
|
|
1323
1341
|
},
|
|
1342
|
+
{
|
|
1343
|
+
name: 'sender',
|
|
1344
|
+
internalType: 'address',
|
|
1345
|
+
type: 'address',
|
|
1346
|
+
indexed: true,
|
|
1347
|
+
},
|
|
1324
1348
|
{ name: 'to', internalType: 'address', type: 'address', indexed: true },
|
|
1325
1349
|
{
|
|
1326
1350
|
name: 'amount',
|
|
@@ -1611,6 +1635,7 @@ export const managerFAbi = [
|
|
|
1611
1635
|
inputs: [
|
|
1612
1636
|
{ name: 'poolId', internalType: 'bytes32', type: 'bytes32' },
|
|
1613
1637
|
{ name: 'gen', internalType: 'uint256', type: 'uint256' },
|
|
1638
|
+
{ name: 'owner', internalType: 'address', type: 'address' },
|
|
1614
1639
|
{ name: 'to', internalType: 'address', type: 'address' },
|
|
1615
1640
|
],
|
|
1616
1641
|
name: 'claim',
|
|
@@ -1792,6 +1817,7 @@ export const managerFAbi = [
|
|
|
1792
1817
|
type: 'function',
|
|
1793
1818
|
inputs: [
|
|
1794
1819
|
{ name: 'poolId', internalType: 'bytes32', type: 'bytes32' },
|
|
1820
|
+
{ name: 'payer', internalType: 'address', type: 'address' },
|
|
1795
1821
|
{ name: 'to', internalType: 'address', type: 'address' },
|
|
1796
1822
|
{ name: 'L', internalType: 'uint256', type: 'uint256' },
|
|
1797
1823
|
{ name: 'maxQuoteIn', internalType: 'uint256', type: 'uint256' },
|
|
@@ -2071,7 +2097,7 @@ export const managerFAbi = [
|
|
|
2071
2097
|
},
|
|
2072
2098
|
{ name: 'gen', internalType: 'uint256', type: 'uint256', indexed: true },
|
|
2073
2099
|
{
|
|
2074
|
-
name: '
|
|
2100
|
+
name: 'owner',
|
|
2075
2101
|
internalType: 'address',
|
|
2076
2102
|
type: 'address',
|
|
2077
2103
|
indexed: true,
|
|
@@ -2117,6 +2143,12 @@ export const managerFAbi = [
|
|
|
2117
2143
|
indexed: true,
|
|
2118
2144
|
},
|
|
2119
2145
|
{ name: 'gen', internalType: 'uint256', type: 'uint256', indexed: true },
|
|
2146
|
+
{
|
|
2147
|
+
name: 'operator',
|
|
2148
|
+
internalType: 'address',
|
|
2149
|
+
type: 'address',
|
|
2150
|
+
indexed: true,
|
|
2151
|
+
},
|
|
2120
2152
|
{
|
|
2121
2153
|
name: 'supply',
|
|
2122
2154
|
internalType: 'uint256',
|
|
@@ -2143,6 +2175,12 @@ export const managerFAbi = [
|
|
|
2143
2175
|
indexed: true,
|
|
2144
2176
|
},
|
|
2145
2177
|
{ name: 'to', internalType: 'address', type: 'address', indexed: true },
|
|
2178
|
+
{
|
|
2179
|
+
name: 'operator',
|
|
2180
|
+
internalType: 'address',
|
|
2181
|
+
type: 'address',
|
|
2182
|
+
indexed: true,
|
|
2183
|
+
},
|
|
2146
2184
|
{ name: 'gen', internalType: 'uint256', type: 'uint256', indexed: false },
|
|
2147
2185
|
{
|
|
2148
2186
|
name: 'income',
|
|
@@ -2243,6 +2281,12 @@ export const managerFAbi = [
|
|
|
2243
2281
|
indexed: true,
|
|
2244
2282
|
},
|
|
2245
2283
|
{ name: 'gen', internalType: 'uint256', type: 'uint256', indexed: true },
|
|
2284
|
+
{
|
|
2285
|
+
name: 'operator',
|
|
2286
|
+
internalType: 'address',
|
|
2287
|
+
type: 'address',
|
|
2288
|
+
indexed: true,
|
|
2289
|
+
},
|
|
2246
2290
|
{
|
|
2247
2291
|
name: 'quoteAmount',
|
|
2248
2292
|
internalType: 'uint256',
|
|
@@ -2306,11 +2350,17 @@ export const managerFAbi = [
|
|
|
2306
2350
|
indexed: true,
|
|
2307
2351
|
},
|
|
2308
2352
|
{
|
|
2309
|
-
name: '
|
|
2353
|
+
name: 'creator',
|
|
2310
2354
|
internalType: 'address',
|
|
2311
2355
|
type: 'address',
|
|
2312
2356
|
indexed: true,
|
|
2313
2357
|
},
|
|
2358
|
+
{
|
|
2359
|
+
name: 'policy',
|
|
2360
|
+
internalType: 'address',
|
|
2361
|
+
type: 'address',
|
|
2362
|
+
indexed: false,
|
|
2363
|
+
},
|
|
2314
2364
|
{
|
|
2315
2365
|
name: 'bases',
|
|
2316
2366
|
internalType: 'address[]',
|
|
@@ -2362,8 +2412,13 @@ export const managerFAbi = [
|
|
|
2362
2412
|
type: 'bytes32',
|
|
2363
2413
|
indexed: true,
|
|
2364
2414
|
},
|
|
2365
|
-
{
|
|
2366
|
-
|
|
2415
|
+
{
|
|
2416
|
+
name: 'owner',
|
|
2417
|
+
internalType: 'address',
|
|
2418
|
+
type: 'address',
|
|
2419
|
+
indexed: true,
|
|
2420
|
+
},
|
|
2421
|
+
{ name: 'gen', internalType: 'uint256', type: 'uint256', indexed: true },
|
|
2367
2422
|
{ name: 'L', internalType: 'uint256', type: 'uint256', indexed: false },
|
|
2368
2423
|
{
|
|
2369
2424
|
name: 'shares',
|
|
@@ -2403,7 +2458,19 @@ export const managerFAbi = [
|
|
|
2403
2458
|
indexed: true,
|
|
2404
2459
|
},
|
|
2405
2460
|
{ name: 'to', internalType: 'address', type: 'address', indexed: true },
|
|
2406
|
-
{ name: 'gen', internalType: 'uint256', type: 'uint256', indexed:
|
|
2461
|
+
{ name: 'gen', internalType: 'uint256', type: 'uint256', indexed: true },
|
|
2462
|
+
{
|
|
2463
|
+
name: 'sender',
|
|
2464
|
+
internalType: 'address',
|
|
2465
|
+
type: 'address',
|
|
2466
|
+
indexed: false,
|
|
2467
|
+
},
|
|
2468
|
+
{
|
|
2469
|
+
name: 'payer',
|
|
2470
|
+
internalType: 'address',
|
|
2471
|
+
type: 'address',
|
|
2472
|
+
indexed: false,
|
|
2473
|
+
},
|
|
2407
2474
|
{ name: 'L', internalType: 'uint256', type: 'uint256', indexed: false },
|
|
2408
2475
|
{
|
|
2409
2476
|
name: 'shares',
|
|
@@ -3591,7 +3658,7 @@ export const routerCAbi = [
|
|
|
3591
3658
|
{ name: 'shares', internalType: 'uint256[]', type: 'uint256[]' },
|
|
3592
3659
|
{ name: 'minBaseOut', internalType: 'uint256', type: 'uint256' },
|
|
3593
3660
|
{ name: 'minQuoteOut', internalType: 'uint256', type: 'uint256' },
|
|
3594
|
-
{ name: '
|
|
3661
|
+
{ name: 'to', internalType: 'address', type: 'address' },
|
|
3595
3662
|
{ name: 'deadline', internalType: 'uint256', type: 'uint256' },
|
|
3596
3663
|
],
|
|
3597
3664
|
name: 'burn',
|
|
@@ -3607,7 +3674,7 @@ export const routerCAbi = [
|
|
|
3607
3674
|
{ name: 'poolId', internalType: 'bytes32', type: 'bytes32' },
|
|
3608
3675
|
{ name: 'quote', internalType: 'address', type: 'address' },
|
|
3609
3676
|
{ name: 'ids', internalType: 'uint256[]', type: 'uint256[]' },
|
|
3610
|
-
{ name: '
|
|
3677
|
+
{ name: 'to', internalType: 'address', type: 'address' },
|
|
3611
3678
|
{ name: 'deadline', internalType: 'uint256', type: 'uint256' },
|
|
3612
3679
|
],
|
|
3613
3680
|
name: 'claim',
|
|
@@ -3637,7 +3704,7 @@ export const routerCAbi = [
|
|
|
3637
3704
|
{ name: 'L', internalType: 'uint256', type: 'uint256' },
|
|
3638
3705
|
{ name: 'maxBaseIn', internalType: 'uint256', type: 'uint256' },
|
|
3639
3706
|
{ name: 'maxQuoteIn', internalType: 'uint256', type: 'uint256' },
|
|
3640
|
-
{ name: '
|
|
3707
|
+
{ name: 'to', internalType: 'address', type: 'address' },
|
|
3641
3708
|
{ name: 'deadline', internalType: 'uint256', type: 'uint256' },
|
|
3642
3709
|
],
|
|
3643
3710
|
name: 'createMarket',
|
|
@@ -3668,7 +3735,7 @@ export const routerCAbi = [
|
|
|
3668
3735
|
{ name: 'tokens', internalType: 'address[]', type: 'address[]' },
|
|
3669
3736
|
{ name: 'maxIn', internalType: 'uint256[]', type: 'uint256[]' },
|
|
3670
3737
|
{ name: 'minOut', internalType: 'uint256[]', type: 'uint256[]' },
|
|
3671
|
-
{ name: '
|
|
3738
|
+
{ name: 'to', internalType: 'address', type: 'address' },
|
|
3672
3739
|
],
|
|
3673
3740
|
},
|
|
3674
3741
|
{ name: 'deadline', internalType: 'uint256', type: 'uint256' },
|
|
@@ -3698,7 +3765,7 @@ export const routerCAbi = [
|
|
|
3698
3765
|
{ name: 'L', internalType: 'uint256', type: 'uint256' },
|
|
3699
3766
|
{ name: 'maxBaseIn', internalType: 'uint256', type: 'uint256' },
|
|
3700
3767
|
{ name: 'maxQuoteIn', internalType: 'uint256', type: 'uint256' },
|
|
3701
|
-
{ name: '
|
|
3768
|
+
{ name: 'to', internalType: 'address', type: 'address' },
|
|
3702
3769
|
{ name: 'deadline', internalType: 'uint256', type: 'uint256' },
|
|
3703
3770
|
],
|
|
3704
3771
|
name: 'mintBlended',
|
|
@@ -3720,7 +3787,7 @@ export const routerCAbi = [
|
|
|
3720
3787
|
{ name: 'toCap', internalType: 'int256', type: 'int256' },
|
|
3721
3788
|
{ name: 'maxBaseIn', internalType: 'uint256', type: 'uint256' },
|
|
3722
3789
|
{ name: 'maxQuoteIn', internalType: 'uint256', type: 'uint256' },
|
|
3723
|
-
{ name: '
|
|
3790
|
+
{ name: 'to', internalType: 'address', type: 'address' },
|
|
3724
3791
|
{ name: 'deadline', internalType: 'uint256', type: 'uint256' },
|
|
3725
3792
|
],
|
|
3726
3793
|
name: 'move',
|
|
@@ -3767,7 +3834,7 @@ export const routerCAbi = [
|
|
|
3767
3834
|
{ name: 'baseIn', internalType: 'bool', type: 'bool' },
|
|
3768
3835
|
{ name: 'amountIn', internalType: 'uint256', type: 'uint256' },
|
|
3769
3836
|
{ name: 'minOut', internalType: 'uint256', type: 'uint256' },
|
|
3770
|
-
{ name: '
|
|
3837
|
+
{ name: 'to', internalType: 'address', type: 'address' },
|
|
3771
3838
|
{ name: 'deadline', internalType: 'uint256', type: 'uint256' },
|
|
3772
3839
|
],
|
|
3773
3840
|
name: 'swapExactIn',
|
|
@@ -3790,7 +3857,7 @@ export const routerCAbi = [
|
|
|
3790
3857
|
{ name: 'tokenOut', internalType: 'address', type: 'address' },
|
|
3791
3858
|
{ name: 'amountIn', internalType: 'uint256', type: 'uint256' },
|
|
3792
3859
|
{ name: 'minOut', internalType: 'uint256', type: 'uint256' },
|
|
3793
|
-
{ name: '
|
|
3860
|
+
{ name: 'to', internalType: 'address', type: 'address' },
|
|
3794
3861
|
{ name: 'deadline', internalType: 'uint256', type: 'uint256' },
|
|
3795
3862
|
],
|
|
3796
3863
|
name: 'swapExactInPath',
|
|
@@ -3806,7 +3873,7 @@ export const routerCAbi = [
|
|
|
3806
3873
|
{ name: 'baseOut', internalType: 'bool', type: 'bool' },
|
|
3807
3874
|
{ name: 'amountOut', internalType: 'uint256', type: 'uint256' },
|
|
3808
3875
|
{ name: 'maxIn', internalType: 'uint256', type: 'uint256' },
|
|
3809
|
-
{ name: '
|
|
3876
|
+
{ name: 'to', internalType: 'address', type: 'address' },
|
|
3810
3877
|
{ name: 'deadline', internalType: 'uint256', type: 'uint256' },
|
|
3811
3878
|
],
|
|
3812
3879
|
name: 'swapExactOut',
|
|
@@ -3833,7 +3900,7 @@ export const routerCAbi = [
|
|
|
3833
3900
|
{ name: 'newL', internalType: 'uint256', type: 'uint256' },
|
|
3834
3901
|
{ name: 'maxBaseIn', internalType: 'uint256', type: 'uint256' },
|
|
3835
3902
|
{ name: 'maxQuoteIn', internalType: 'uint256', type: 'uint256' },
|
|
3836
|
-
{ name: '
|
|
3903
|
+
{ name: 'to', internalType: 'address', type: 'address' },
|
|
3837
3904
|
{ name: 'deadline', internalType: 'uint256', type: 'uint256' },
|
|
3838
3905
|
],
|
|
3839
3906
|
name: 'update',
|
|
@@ -3864,7 +3931,7 @@ export const routerCAbi = [
|
|
|
3864
3931
|
{ name: 'cap', internalType: 'int256', type: 'int256' },
|
|
3865
3932
|
{ name: 'L', internalType: 'uint256', type: 'uint256' },
|
|
3866
3933
|
{ name: 'maxIn', internalType: 'uint256', type: 'uint256' },
|
|
3867
|
-
{ name: '
|
|
3934
|
+
{ name: 'to', internalType: 'address', type: 'address' },
|
|
3868
3935
|
{ name: 'deadline', internalType: 'uint256', type: 'uint256' },
|
|
3869
3936
|
],
|
|
3870
3937
|
name: 'zapIn',
|
|
@@ -3874,14 +3941,6 @@ export const routerCAbi = [
|
|
|
3874
3941
|
],
|
|
3875
3942
|
stateMutability: 'nonpayable',
|
|
3876
3943
|
},
|
|
3877
|
-
{
|
|
3878
|
-
type: 'event',
|
|
3879
|
-
anonymous: false,
|
|
3880
|
-
inputs: [
|
|
3881
|
-
{ name: 'user', internalType: 'address', type: 'address', indexed: true },
|
|
3882
|
-
],
|
|
3883
|
-
name: 'RouterCall',
|
|
3884
|
-
},
|
|
3885
3944
|
{ type: 'error', inputs: [], name: 'BadFloor' },
|
|
3886
3945
|
{ type: 'error', inputs: [], name: 'BadRecipient' },
|
|
3887
3946
|
{ type: 'error', inputs: [], name: 'DeadlineExceeded' },
|
|
@@ -4045,16 +4104,7 @@ export const routerFAbi = [
|
|
|
4045
4104
|
outputs: [{ name: 'amountOut', internalType: 'uint256', type: 'uint256' }],
|
|
4046
4105
|
stateMutability: 'nonpayable',
|
|
4047
4106
|
},
|
|
4048
|
-
{
|
|
4049
|
-
type: 'event',
|
|
4050
|
-
anonymous: false,
|
|
4051
|
-
inputs: [
|
|
4052
|
-
{ name: 'user', internalType: 'address', type: 'address', indexed: true },
|
|
4053
|
-
],
|
|
4054
|
-
name: 'RouterCall',
|
|
4055
|
-
},
|
|
4056
4107
|
{ type: 'error', inputs: [], name: 'BadRecipient' },
|
|
4057
|
-
{ type: 'error', inputs: [], name: 'BadToken' },
|
|
4058
4108
|
{ type: 'error', inputs: [], name: 'DeadlineExceeded' },
|
|
4059
4109
|
{ type: 'error', inputs: [], name: 'DrainsBase' },
|
|
4060
4110
|
{ type: 'error', inputs: [], name: 'NotManager' },
|
|
@@ -4066,6 +4116,7 @@ export const routerFAbi = [
|
|
|
4066
4116
|
{ type: 'error', inputs: [], name: 'SlippageIn' },
|
|
4067
4117
|
{ type: 'error', inputs: [], name: 'SlippageOut' },
|
|
4068
4118
|
{ type: 'error', inputs: [], name: 'UnsupportedOp' },
|
|
4119
|
+
{ type: 'error', inputs: [], name: 'WrongToken' },
|
|
4069
4120
|
{ type: 'error', inputs: [], name: 'ZeroAmount' },
|
|
4070
4121
|
] as const
|
|
4071
4122
|
|
package/src/history.ts
CHANGED
|
@@ -55,7 +55,7 @@ export interface EventLogsQuery {
|
|
|
55
55
|
* On the chain path the node is asked for the last {@link LATEST_SCAN_BLOCKS} blocks only.
|
|
56
56
|
*/
|
|
57
57
|
latest?: number;
|
|
58
|
-
/** Only events from these transactions — e.g. the
|
|
58
|
+
/** Only events from these transactions — e.g. the other events of a page of swaps. */
|
|
59
59
|
transactionHashes?: Hex[];
|
|
60
60
|
signal?: AbortSignal;
|
|
61
61
|
}
|
package/src/index.ts
CHANGED
|
@@ -22,6 +22,5 @@ export * from "./tokencache.js";
|
|
|
22
22
|
export * from "./fpool.js";
|
|
23
23
|
export * from "./fees.js";
|
|
24
24
|
export * from "./history.js";
|
|
25
|
-
export * from "./views.js";
|
|
26
25
|
export { managerCAbi, managerFAbi, lensCAbi, lensFAbi, routerCAbi, routerFAbi, routerActionsAbi, policyFAbi, policyRegistryAbi, sponsorPolicyCAbi } from "./generated.js";
|
|
27
26
|
export * from "./admin.js";
|
package/src/liquidity.ts
CHANGED
|
@@ -390,7 +390,8 @@ export async function floor(c: LogswapClient, a: EditArgs & { rungs: bigint }):
|
|
|
390
390
|
*
|
|
391
391
|
* ΔQ = L (ξ' − ξ), ΔR = 0
|
|
392
392
|
*
|
|
393
|
-
* because $R = Le^{-x}$ depends on neither the floor nor the withdrawal. No base moves
|
|
393
|
+
* because $R = Le^{-x}$ depends on neither the floor nor the withdrawal. No base moves beyond one
|
|
394
|
+
* wei (the edit's mint half rounds what it pays in up; the preview returns it), the price
|
|
394
395
|
* does not move, and depth is unchanged. **The cost, which a UI must show:** the position stops
|
|
395
396
|
* bidding below ξ'. `settleIn: "base"` swaps the proceeds into base in the same batch.
|
|
396
397
|
*/
|
package/src/positions.ts
CHANGED
|
@@ -17,7 +17,6 @@ const C_POSITIONS_SLOT = 4n;
|
|
|
17
17
|
const U128 = (1n << 128n) - 1n;
|
|
18
18
|
import { isPosition, NO_CAP, positionId, unpackFloorCap } from "./ids.js";
|
|
19
19
|
import { getEventLogs } from "./history.js";
|
|
20
|
-
import { poolHolders } from "./views.js";
|
|
21
20
|
|
|
22
21
|
/** A class's aggregate state — the whole class, not one holder's slice. */
|
|
23
22
|
export interface PositionClass {
|
|
@@ -261,17 +260,7 @@ export async function positionsOf(c: LogswapClient, key: PoolKey, owner: Address
|
|
|
261
260
|
return rows.map((r) => ({ id: r.id, floor: r.floor, cap: NO_CAP, capped: false, shares: r.shares, L: r.L, fees: r.fees }));
|
|
262
261
|
}
|
|
263
262
|
|
|
264
|
-
const ID_REGISTERED = parseAbiItem("event ClassRegistered(
|
|
265
|
-
|
|
266
|
-
/** The class ids `owner` holds in `pool`, from the indexer's `pool_holder` view; null when the indexer cannot answer. */
|
|
267
|
-
async function heldIdsFromView(c: LogswapClient, indexer: string, pool: Hex, owner: Address): Promise<bigint[] | null> {
|
|
268
|
-
try {
|
|
269
|
-
const rows = await poolHolders(indexer, { condition: { side: "C", poolId: pool.toLowerCase(), holder: owner.toLowerCase(), manager: managerC(c).toLowerCase() } });
|
|
270
|
-
return rows.filter((r) => r.balance > 0n && !r.isBackstop).map((r) => r.id);
|
|
271
|
-
} catch {
|
|
272
|
-
return null; // the view is a cache: the ClassRegistered replay below answers the same
|
|
273
|
-
}
|
|
274
|
-
}
|
|
263
|
+
const ID_REGISTERED = parseAbiItem("event ClassRegistered(bytes32 indexed poolId, uint256 indexed id, int256 floor, int256 cap, bool capped)") // C 17: poolId first;
|
|
275
264
|
|
|
276
265
|
/** Every class id ever registered in `pool` (`ClassRegistered`), from the indexer's table or the node. */
|
|
277
266
|
async function registeredIds(c: LogswapClient, pool: Hex, fromBlock?: bigint, indexer?: string): Promise<bigint[]> {
|
|
@@ -289,10 +278,10 @@ async function registeredIds(c: LogswapClient, pool: Hex, fromBlock?: bigint, in
|
|
|
289
278
|
* holder's slice is L · shares_owner / shares_class, and fees from the lens. One log query plus
|
|
290
279
|
* a read per registered class; fine for a pool's lifetime of classes.
|
|
291
280
|
*/
|
|
292
|
-
export async function holdingsOf(c: LogswapClient, key: PoolKey, owner: Address, fromBlock?: bigint, opts: { /** The rindexer GraphQL endpoint: the
|
|
281
|
+
export async function holdingsOf(c: LogswapClient, key: PoolKey, owner: Address, fromBlock?: bigint, opts: { /** The rindexer GraphQL endpoint: the class registry from its tables, the node otherwise. Defaults to the client's. */ indexer?: string } = {}): Promise<HeldPositionRow[]> {
|
|
293
282
|
const pool = poolId(key);
|
|
294
283
|
const indexer = opts.indexer ?? c.indexerUrl;
|
|
295
|
-
const ids =
|
|
284
|
+
const ids = await registeredIds(c, pool, fromBlock, indexer);
|
|
296
285
|
if (ids.length === 0) return [];
|
|
297
286
|
// one lens call: balance, class L, fees, floor and cap for every id the owner holds
|
|
298
287
|
const rows = (await c.public.readContract({
|