@logswap/sdk 0.5.89 → 0.5.90
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 +7 -2
- package/dist/actions.js +5 -5
- package/dist/claims.js +2 -2
- package/dist/client.js +6 -6
- package/dist/fpool.js +20 -20
- package/dist/generated.d.ts +2674 -2670
- package/dist/generated.js +1694 -1688
- package/dist/index.d.ts +3 -1
- package/dist/index.js +3 -1
- package/dist/indexer.js +2 -2
- package/dist/liquidity.js +8 -8
- package/dist/onboard.js +2 -2
- package/dist/pools.js +4 -4
- package/dist/positions.js +6 -6
- package/dist/swap.js +6 -6
- package/package.json +1 -1
- package/src/actions.ts +5 -5
- package/src/claims.ts +2 -2
- package/src/client.ts +6 -6
- package/src/fpool.ts +20 -20
- package/src/generated.ts +1696 -1688
- package/src/index.ts +3 -1
- package/src/indexer.ts +2 -2
- package/src/liquidity.ts +8 -8
- package/src/onboard.ts +2 -2
- package/src/pools.ts +4 -4
- package/src/positions.ts +6 -6
- package/src/swap.ts +6 -6
package/src/index.ts
CHANGED
|
@@ -23,5 +23,7 @@ export * from "./fpool.js";
|
|
|
23
23
|
export * from "./fees.js";
|
|
24
24
|
export * from "./history.js";
|
|
25
25
|
export * from "./views.js";
|
|
26
|
-
export { cPoolManagerAbi, fPoolManagerAbi,
|
|
26
|
+
export { cPoolManagerAbi, fPoolManagerAbi, lensAbi, routerAbi, routerActionsAbi, padPolicyAbi, polPolicyAbi, policyRegistryAbi, privatePolicyAbi, publicPolicyAbi } from "./generated.js";
|
|
27
|
+
/** @deprecated the `Logswap` prefix is gone (decision 091): use `routerAbi` / `lensAbi`. Removed in the next minor. */
|
|
28
|
+
export { routerAbi as logswapRouterAbi, lensAbi as logswapLensAbi } from "./generated.js";
|
|
27
29
|
export * from "./admin.js";
|
package/src/indexer.ts
CHANGED
|
@@ -244,10 +244,10 @@ export async function discoverMarketsBest(
|
|
|
244
244
|
* use the indexed `poolPositions` and fall back to this when the indexer is missing or stale.
|
|
245
245
|
*/
|
|
246
246
|
export async function poolPositionsFromChain(c: LogswapClient, key: PoolKey, x: bigint): Promise<PoolPosition[]> {
|
|
247
|
-
const {
|
|
247
|
+
const { lensAbi } = await import("./generated.js");
|
|
248
248
|
const floors = (await c.public.readContract({
|
|
249
249
|
address: c.addresses.lens,
|
|
250
|
-
abi:
|
|
250
|
+
abi: lensAbi,
|
|
251
251
|
functionName: "liveTicks",
|
|
252
252
|
args: [poolId(key)],
|
|
253
253
|
} as never)) as readonly bigint[];
|
package/src/liquidity.ts
CHANGED
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
*/
|
|
24
24
|
|
|
25
25
|
import type { Address, Hash } from "viem";
|
|
26
|
-
import {
|
|
26
|
+
import { lensAbi, routerAbi } from "./generated.js";
|
|
27
27
|
import type { LogswapClient } from "./client.js";
|
|
28
28
|
import { poolId as keyId, type PoolKey } from "./keys.js";
|
|
29
29
|
import { NO_CAP } from "./ids.js";
|
|
@@ -82,7 +82,7 @@ export interface MintArgs extends WriteOptions {
|
|
|
82
82
|
*/
|
|
83
83
|
export async function mint(c: LogswapClient, a: MintArgs): Promise<Hash> {
|
|
84
84
|
return sendRouterWriteWithPermits(c, {
|
|
85
|
-
abi:
|
|
85
|
+
abi: routerAbi,
|
|
86
86
|
functionName: "mintBlended",
|
|
87
87
|
args: [
|
|
88
88
|
keyId(a.key),
|
|
@@ -124,7 +124,7 @@ export interface CreateMarketArgs extends WriteOptions {
|
|
|
124
124
|
*/
|
|
125
125
|
export async function createMarket(c: LogswapClient, a: CreateMarketArgs): Promise<Hash> {
|
|
126
126
|
return sendRouterWriteWithPermits(c, {
|
|
127
|
-
abi:
|
|
127
|
+
abi: routerAbi,
|
|
128
128
|
functionName: "createMarket",
|
|
129
129
|
args: [
|
|
130
130
|
a.key,
|
|
@@ -163,7 +163,7 @@ export interface ZapArgs extends WriteOptions {
|
|
|
163
163
|
*/
|
|
164
164
|
export async function zapIn(c: LogswapClient, a: ZapArgs): Promise<Hash> {
|
|
165
165
|
return sendRouterWriteWithPermits(c, {
|
|
166
|
-
abi:
|
|
166
|
+
abi: routerAbi,
|
|
167
167
|
functionName: "zapIn",
|
|
168
168
|
args: [
|
|
169
169
|
keyId(a.key),
|
|
@@ -200,7 +200,7 @@ export interface UpdateArgs extends WriteOptions {
|
|
|
200
200
|
/** The primitive, through the router's named entry: resize and reposition in one call, in kind. */
|
|
201
201
|
export async function update(c: LogswapClient, a: UpdateArgs): Promise<Hash> {
|
|
202
202
|
return sendRouterWriteWithPermits(c, {
|
|
203
|
-
abi:
|
|
203
|
+
abi: routerAbi,
|
|
204
204
|
functionName: "update",
|
|
205
205
|
args: [
|
|
206
206
|
keyId(a.key),
|
|
@@ -239,7 +239,7 @@ export interface MoveArgs extends WriteOptions {
|
|
|
239
239
|
*/
|
|
240
240
|
export async function move(c: LogswapClient, a: MoveArgs): Promise<Hash> {
|
|
241
241
|
return sendRouterWrite(c, {
|
|
242
|
-
abi:
|
|
242
|
+
abi: routerAbi,
|
|
243
243
|
functionName: "move",
|
|
244
244
|
args: [
|
|
245
245
|
keyId(a.key),
|
|
@@ -294,7 +294,7 @@ export async function previewEdit(
|
|
|
294
294
|
const holder = a.holder ?? requireWallet(c).address;
|
|
295
295
|
const r = (await c.public.readContract({
|
|
296
296
|
address: c.addresses.lens,
|
|
297
|
-
abi:
|
|
297
|
+
abi: lensAbi,
|
|
298
298
|
functionName: "previewUpdate",
|
|
299
299
|
args: [keyId(a.key), a.fromId, holder, a.shares, a.toFloor, a.toCap ?? NO_CAP, a.newL],
|
|
300
300
|
})) as readonly [bigint, bigint, bigint];
|
|
@@ -473,7 +473,7 @@ export interface BurnArgs extends WriteOptions {
|
|
|
473
473
|
export async function burn(c: LogswapClient, a: BurnArgs): Promise<Hash> {
|
|
474
474
|
if (a.ids.length !== a.shares.length) throw new Error("logswap: ids and shares length mismatch");
|
|
475
475
|
return sendRouterWrite(c, {
|
|
476
|
-
abi:
|
|
476
|
+
abi: routerAbi,
|
|
477
477
|
functionName: "burn",
|
|
478
478
|
args: [
|
|
479
479
|
keyId(a.key),
|
package/src/onboard.ts
CHANGED
|
@@ -232,10 +232,10 @@ export async function permit2SigCalls(c: LogswapClient, tokens: Address[]): Prom
|
|
|
232
232
|
message,
|
|
233
233
|
} as never);
|
|
234
234
|
const { encodeFunctionData } = await import("viem");
|
|
235
|
-
const {
|
|
235
|
+
const { routerAbi } = await import("./generated.js");
|
|
236
236
|
calls.push(
|
|
237
237
|
encodeFunctionData({
|
|
238
|
-
abi:
|
|
238
|
+
abi: routerAbi,
|
|
239
239
|
functionName: "applyPermit2",
|
|
240
240
|
args: [owner, message, signature],
|
|
241
241
|
} as never),
|
package/src/pools.ts
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
15
|
import { formatUnits, type Address, type Hex } from "viem";
|
|
16
|
-
import {
|
|
16
|
+
import { lensAbi, cPoolManagerAbi } from "./generated.js";
|
|
17
17
|
import { clientChainId, type LogswapClient } from "./client.js";
|
|
18
18
|
import { signerFor } from "./write.js";
|
|
19
19
|
import { readCachedToken, registerCacheClear, writeCachedToken } from "./tokencache.js";
|
|
@@ -49,7 +49,7 @@ export interface PoolState {
|
|
|
49
49
|
export async function getPool(c: LogswapClient, key: PoolKey): Promise<PoolState> {
|
|
50
50
|
const v = (await c.public.readContract({
|
|
51
51
|
address: c.addresses.lens,
|
|
52
|
-
abi:
|
|
52
|
+
abi: lensAbi,
|
|
53
53
|
functionName: "getPools",
|
|
54
54
|
args: [[poolId(key)]],
|
|
55
55
|
})) as readonly unknown[];
|
|
@@ -214,7 +214,7 @@ export async function discoverMarkets(
|
|
|
214
214
|
export async function liveFloors(c: LogswapClient, key: PoolKey): Promise<readonly bigint[]> {
|
|
215
215
|
return c.public.readContract({
|
|
216
216
|
address: c.addresses.lens,
|
|
217
|
-
abi:
|
|
217
|
+
abi: lensAbi,
|
|
218
218
|
functionName: "liveTicks",
|
|
219
219
|
args: [poolId(key)],
|
|
220
220
|
}) as Promise<readonly bigint[]>;
|
|
@@ -224,7 +224,7 @@ export async function liveFloors(c: LogswapClient, key: PoolKey): Promise<readon
|
|
|
224
224
|
export async function isValidFloor(c: LogswapClient, key: PoolKey, floor: bigint): Promise<boolean> {
|
|
225
225
|
return c.public.readContract({
|
|
226
226
|
address: c.addresses.lens,
|
|
227
|
-
abi:
|
|
227
|
+
abi: lensAbi,
|
|
228
228
|
functionName: "isValidFloor",
|
|
229
229
|
args: [poolId(key), floor],
|
|
230
230
|
}) as Promise<boolean>;
|
package/src/positions.ts
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
import { encodeAbiParameters, keccak256, parseAbiItem } from "viem";
|
|
10
10
|
import type { Address, Hex } from "viem";
|
|
11
|
-
import {
|
|
11
|
+
import { lensAbi, cPoolManagerAbi } from "./generated.js";
|
|
12
12
|
import type { LogswapClient } from "./client.js";
|
|
13
13
|
import { MINT_FEE_MAX, poolId, type PoolKey } from "./keys.js";
|
|
14
14
|
|
|
@@ -69,7 +69,7 @@ export async function balanceOf(c: LogswapClient, owner: Address, id: bigint): P
|
|
|
69
69
|
export async function feesOf(c: LogswapClient, id: bigint, owner: Address): Promise<bigint> {
|
|
70
70
|
return c.public.readContract({
|
|
71
71
|
address: c.addresses.lens,
|
|
72
|
-
abi:
|
|
72
|
+
abi: lensAbi,
|
|
73
73
|
functionName: "feesOfById",
|
|
74
74
|
args: [id, owner],
|
|
75
75
|
}) as Promise<bigint>;
|
|
@@ -143,7 +143,7 @@ export async function describeId(
|
|
|
143
143
|
}> {
|
|
144
144
|
const r = (await c.public.readContract({
|
|
145
145
|
address: c.addresses.lens,
|
|
146
|
-
abi:
|
|
146
|
+
abi: lensAbi,
|
|
147
147
|
functionName: "unpack",
|
|
148
148
|
args: [id],
|
|
149
149
|
})) as readonly [`0x${string}`, bigint, bigint, boolean];
|
|
@@ -254,7 +254,7 @@ export interface HeldPositionRow {
|
|
|
254
254
|
export async function positionsOf(c: LogswapClient, key: PoolKey, owner: Address): Promise<HeldPositionRow[]> {
|
|
255
255
|
const rows = (await c.public.readContract({
|
|
256
256
|
address: c.addresses.lens,
|
|
257
|
-
abi:
|
|
257
|
+
abi: lensAbi,
|
|
258
258
|
functionName: "positionsOf",
|
|
259
259
|
args: [poolId(key), owner],
|
|
260
260
|
} as never)) as readonly { id: bigint; floor: bigint; shares: bigint; L: bigint; fees: bigint }[];
|
|
@@ -297,7 +297,7 @@ export async function holdingsOf(c: LogswapClient, key: PoolKey, owner: Address,
|
|
|
297
297
|
// one lens call: balance, class L, fees, floor and cap for every id the owner holds
|
|
298
298
|
const rows = (await c.public.readContract({
|
|
299
299
|
address: c.addresses.lens,
|
|
300
|
-
abi:
|
|
300
|
+
abi: lensAbi,
|
|
301
301
|
functionName: "heldByIds",
|
|
302
302
|
args: [poolId(key), owner, ids],
|
|
303
303
|
} as never)) as readonly { id: bigint; floor: bigint; cap: bigint; capped: boolean; shares: bigint; L: bigint; fees: bigint }[];
|
|
@@ -309,7 +309,7 @@ export async function holdingsOf(c: LogswapClient, key: PoolKey, owner: Address,
|
|
|
309
309
|
export async function legsOf(c: LogswapClient, key: PoolKey, id: bigint, holder: Address): Promise<{ base: bigint; quote: bigint; fees: bigint; value: bigint }> {
|
|
310
310
|
const [base, quote, fees, value] = (await c.public.readContract({
|
|
311
311
|
address: c.addresses.lens,
|
|
312
|
-
abi:
|
|
312
|
+
abi: lensAbi,
|
|
313
313
|
functionName: "legsOf",
|
|
314
314
|
args: [poolId(key), id, holder],
|
|
315
315
|
} as never)) as readonly [bigint, bigint, bigint, bigint];
|
package/src/swap.ts
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
import type { Address, Hash } from "viem";
|
|
10
|
-
import {
|
|
10
|
+
import { lensAbi, routerAbi } from "./generated.js";
|
|
11
11
|
import type { LogswapClient } from "./client.js";
|
|
12
12
|
import { poolId as keyId, type PoolKey } from "./keys.js";
|
|
13
13
|
import { resolveDeadline, resolveRecipient, sendRouterWrite, type WriteOptions , sendRouterWriteWithPermits } from "./write.js";
|
|
@@ -27,7 +27,7 @@ export async function quoteExactIn(
|
|
|
27
27
|
): Promise<bigint> {
|
|
28
28
|
const { result } = await c.public.simulateContract({
|
|
29
29
|
address: c.addresses.lens,
|
|
30
|
-
abi:
|
|
30
|
+
abi: lensAbi,
|
|
31
31
|
functionName: "previewSwapExactIn",
|
|
32
32
|
args: [keyId(key), baseIn, amountIn],
|
|
33
33
|
});
|
|
@@ -43,7 +43,7 @@ export async function quoteExactOut(
|
|
|
43
43
|
): Promise<bigint> {
|
|
44
44
|
const { result } = await c.public.simulateContract({
|
|
45
45
|
address: c.addresses.lens,
|
|
46
|
-
abi:
|
|
46
|
+
abi: lensAbi,
|
|
47
47
|
functionName: "previewSwapExactOut",
|
|
48
48
|
args: [keyId(key), baseOut, amountOut],
|
|
49
49
|
});
|
|
@@ -61,7 +61,7 @@ export interface SwapExactInArgs extends WriteOptions {
|
|
|
61
61
|
|
|
62
62
|
export async function swapExactIn(c: LogswapClient, a: SwapExactInArgs): Promise<Hash> {
|
|
63
63
|
return sendRouterWriteWithPermits(c, {
|
|
64
|
-
abi:
|
|
64
|
+
abi: routerAbi,
|
|
65
65
|
functionName: "swapExactIn",
|
|
66
66
|
args: [
|
|
67
67
|
keyId(a.key),
|
|
@@ -87,7 +87,7 @@ export interface SwapExactOutArgs extends WriteOptions {
|
|
|
87
87
|
|
|
88
88
|
export async function swapExactOut(c: LogswapClient, a: SwapExactOutArgs): Promise<Hash> {
|
|
89
89
|
return sendRouterWriteWithPermits(c, {
|
|
90
|
-
abi:
|
|
90
|
+
abi: routerAbi,
|
|
91
91
|
functionName: "swapExactOut",
|
|
92
92
|
args: [
|
|
93
93
|
keyId(a.key),
|
|
@@ -125,7 +125,7 @@ export interface SwapPathArgs extends WriteOptions {
|
|
|
125
125
|
export async function swapExactInPath(c: LogswapClient, a: SwapPathArgs): Promise<Hash> {
|
|
126
126
|
if (a.hops.length === 0) throw new Error("logswap: empty path");
|
|
127
127
|
return sendRouterWrite(c, {
|
|
128
|
-
abi:
|
|
128
|
+
abi: routerAbi,
|
|
129
129
|
functionName: "swapExactInPath",
|
|
130
130
|
args: [
|
|
131
131
|
a.hops.map((h) => ({ poolId: keyId(h.key), baseIn: h.baseIn })),
|