@nradko/metric-omm-sdk-v1 0.4.3 → 0.4.4
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 +48 -17
- package/dist/abis/DepositAllowlistExtension.d.ts +43 -0
- package/dist/abis/DepositAllowlistExtension.d.ts.map +1 -1
- package/dist/abis/DepositAllowlistExtension.js +56 -0
- package/dist/abis/DepositAllowlistExtension.js.map +1 -1
- package/dist/abis/MetricOmmPoolFactory.d.ts +12 -0
- package/dist/abis/MetricOmmPoolFactory.d.ts.map +1 -1
- package/dist/abis/MetricOmmPoolFactory.js +16 -0
- package/dist/abis/MetricOmmPoolFactory.js.map +1 -1
- package/dist/abis/MetricOmmPoolLiquidityAdder.d.ts +116 -5
- package/dist/abis/MetricOmmPoolLiquidityAdder.d.ts.map +1 -1
- package/dist/abis/MetricOmmPoolLiquidityAdder.js +150 -5
- package/dist/abis/MetricOmmPoolLiquidityAdder.js.map +1 -1
- package/dist/abis/MetricOmmSimpleRouter.d.ts +0 -12
- package/dist/abis/MetricOmmSimpleRouter.d.ts.map +1 -1
- package/dist/abis/MetricOmmSimpleRouter.js +0 -16
- package/dist/abis/MetricOmmSimpleRouter.js.map +1 -1
- package/dist/abis/MetricOmmSwapQuoter.d.ts +0 -12
- package/dist/abis/MetricOmmSwapQuoter.d.ts.map +1 -1
- package/dist/abis/MetricOmmSwapQuoter.js +0 -16
- package/dist/abis/MetricOmmSwapQuoter.js.map +1 -1
- package/dist/abis/SwapAllowlistExtension.d.ts +43 -0
- package/dist/abis/SwapAllowlistExtension.d.ts.map +1 -1
- package/dist/abis/SwapAllowlistExtension.js +56 -0
- package/dist/abis/SwapAllowlistExtension.js.map +1 -1
- package/dist/abis/index.d.ts +2 -2
- package/dist/abis/index.d.ts.map +1 -1
- package/dist/abis/index.js +2 -2
- package/dist/abis/index.js.map +1 -1
- package/dist/addresses.d.ts +2 -2
- package/dist/addresses.d.ts.map +1 -1
- package/dist/addresses.js +11 -11
- package/dist/addresses.js.map +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -1
- package/dist/index.js.map +1 -1
- package/dist/peripheryPayments/index.d.ts +2 -0
- package/dist/peripheryPayments/index.d.ts.map +1 -0
- package/dist/peripheryPayments/index.js +2 -0
- package/dist/peripheryPayments/index.js.map +1 -0
- package/dist/{router/utils.d.ts → peripheryPayments/simpleRouter.d.ts} +2 -2
- package/dist/peripheryPayments/simpleRouter.d.ts.map +1 -0
- package/dist/{router/utils.js → peripheryPayments/simpleRouter.js} +2 -2
- package/dist/peripheryPayments/simpleRouter.js.map +1 -0
- package/dist/pool/cursorBounds.d.ts +29 -0
- package/dist/pool/cursorBounds.d.ts.map +1 -0
- package/dist/pool/cursorBounds.js +76 -0
- package/dist/pool/cursorBounds.js.map +1 -0
- package/dist/pool/index.d.ts +3 -1
- package/dist/pool/index.d.ts.map +1 -1
- package/dist/pool/index.js +3 -1
- package/dist/pool/index.js.map +1 -1
- package/dist/pool/liquidity.d.ts +39 -8
- package/dist/pool/liquidity.d.ts.map +1 -1
- package/dist/pool/liquidity.js +41 -16
- package/dist/pool/liquidity.js.map +1 -1
- package/dist/pool/nativeLiquidity.d.ts +32 -0
- package/dist/pool/nativeLiquidity.d.ts.map +1 -0
- package/dist/pool/nativeLiquidity.js +47 -0
- package/dist/pool/nativeLiquidity.js.map +1 -0
- package/dist/router/index.d.ts +1 -1
- package/dist/router/index.d.ts.map +1 -1
- package/dist/router/index.js +1 -1
- package/dist/router/index.js.map +1 -1
- package/dist/router/nativeSwap.js +1 -1
- package/dist/router/nativeSwap.js.map +1 -1
- package/package.json +2 -2
- package/src/abis/DepositAllowlistExtension.ts +56 -0
- package/src/abis/MetricOmmPoolFactory.ts +16 -0
- package/src/abis/MetricOmmPoolLiquidityAdder.ts +150 -5
- package/src/abis/MetricOmmSimpleRouter.ts +0 -16
- package/src/abis/MetricOmmSwapQuoter.ts +0 -16
- package/src/abis/SwapAllowlistExtension.ts +56 -0
- package/src/abis/index.ts +2 -2
- package/src/addresses.ts +12 -12
- package/src/index.ts +19 -3
- package/src/peripheryPayments/index.ts +5 -0
- package/src/{router/utils.ts → peripheryPayments/simpleRouter.ts} +1 -1
- package/src/pool/cursorBounds.ts +112 -0
- package/src/pool/index.ts +15 -0
- package/src/pool/liquidity.ts +49 -16
- package/src/pool/nativeLiquidity.ts +71 -0
- package/src/router/index.ts +1 -1
- package/src/router/nativeSwap.ts +1 -1
- package/dist/router/utils.d.ts.map +0 -1
- package/dist/router/utils.js.map +0 -1
|
@@ -1,9 +1,26 @@
|
|
|
1
1
|
export const MetricOmmPoolLiquidityAdderAbi = [
|
|
2
2
|
{
|
|
3
|
-
inputs: [
|
|
3
|
+
inputs: [
|
|
4
|
+
{
|
|
5
|
+
internalType: "address",
|
|
6
|
+
name: "weth",
|
|
7
|
+
type: "address",
|
|
8
|
+
},
|
|
9
|
+
],
|
|
4
10
|
stateMutability: "nonpayable",
|
|
5
11
|
type: "constructor",
|
|
6
12
|
},
|
|
13
|
+
{
|
|
14
|
+
inputs: [
|
|
15
|
+
{
|
|
16
|
+
internalType: "address",
|
|
17
|
+
name: "target",
|
|
18
|
+
type: "address",
|
|
19
|
+
},
|
|
20
|
+
],
|
|
21
|
+
name: "AddressEmptyCode",
|
|
22
|
+
type: "error",
|
|
23
|
+
},
|
|
7
24
|
{
|
|
8
25
|
inputs: [],
|
|
9
26
|
name: "CallbackContextNotActive",
|
|
@@ -45,11 +62,58 @@ export const MetricOmmPoolLiquidityAdderAbi = [
|
|
|
45
62
|
name: "CursorOutOfBounds",
|
|
46
63
|
type: "error",
|
|
47
64
|
},
|
|
65
|
+
{
|
|
66
|
+
inputs: [],
|
|
67
|
+
name: "ETHTransferFailed",
|
|
68
|
+
type: "error",
|
|
69
|
+
},
|
|
48
70
|
{
|
|
49
71
|
inputs: [],
|
|
50
72
|
name: "EmptyLiquidityDelta",
|
|
51
73
|
type: "error",
|
|
52
74
|
},
|
|
75
|
+
{
|
|
76
|
+
inputs: [],
|
|
77
|
+
name: "FailedCall",
|
|
78
|
+
type: "error",
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
inputs: [
|
|
82
|
+
{
|
|
83
|
+
internalType: "address",
|
|
84
|
+
name: "token",
|
|
85
|
+
type: "address",
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
internalType: "uint256",
|
|
89
|
+
name: "required",
|
|
90
|
+
type: "uint256",
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
internalType: "uint256",
|
|
94
|
+
name: "available",
|
|
95
|
+
type: "uint256",
|
|
96
|
+
},
|
|
97
|
+
],
|
|
98
|
+
name: "InsufficientToken",
|
|
99
|
+
type: "error",
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
inputs: [
|
|
103
|
+
{
|
|
104
|
+
internalType: "uint256",
|
|
105
|
+
name: "required",
|
|
106
|
+
type: "uint256",
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
internalType: "uint256",
|
|
110
|
+
name: "available",
|
|
111
|
+
type: "uint256",
|
|
112
|
+
},
|
|
113
|
+
],
|
|
114
|
+
name: "InsufficientWETH",
|
|
115
|
+
type: "error",
|
|
116
|
+
},
|
|
53
117
|
{
|
|
54
118
|
inputs: [
|
|
55
119
|
{
|
|
@@ -76,6 +140,11 @@ export const MetricOmmPoolLiquidityAdderAbi = [
|
|
|
76
140
|
name: "InvalidPositionOwner",
|
|
77
141
|
type: "error",
|
|
78
142
|
},
|
|
143
|
+
{
|
|
144
|
+
inputs: [],
|
|
145
|
+
name: "InvalidWETH",
|
|
146
|
+
type: "error",
|
|
147
|
+
},
|
|
79
148
|
{
|
|
80
149
|
inputs: [],
|
|
81
150
|
name: "LiquidityDeltaLengthMismatch",
|
|
@@ -123,6 +192,11 @@ export const MetricOmmPoolLiquidityAdderAbi = [
|
|
|
123
192
|
name: "MaxAmountExceeded",
|
|
124
193
|
type: "error",
|
|
125
194
|
},
|
|
195
|
+
{
|
|
196
|
+
inputs: [],
|
|
197
|
+
name: "NotWETH",
|
|
198
|
+
type: "error",
|
|
199
|
+
},
|
|
126
200
|
{
|
|
127
201
|
inputs: [],
|
|
128
202
|
name: "PayContextAlreadyActive",
|
|
@@ -228,7 +302,7 @@ export const MetricOmmPoolLiquidityAdderAbi = [
|
|
|
228
302
|
type: "uint256",
|
|
229
303
|
},
|
|
230
304
|
],
|
|
231
|
-
stateMutability: "
|
|
305
|
+
stateMutability: "payable",
|
|
232
306
|
type: "function",
|
|
233
307
|
},
|
|
234
308
|
{
|
|
@@ -289,7 +363,7 @@ export const MetricOmmPoolLiquidityAdderAbi = [
|
|
|
289
363
|
type: "uint256",
|
|
290
364
|
},
|
|
291
365
|
],
|
|
292
|
-
stateMutability: "
|
|
366
|
+
stateMutability: "payable",
|
|
293
367
|
type: "function",
|
|
294
368
|
},
|
|
295
369
|
{
|
|
@@ -370,7 +444,7 @@ export const MetricOmmPoolLiquidityAdderAbi = [
|
|
|
370
444
|
type: "uint256",
|
|
371
445
|
},
|
|
372
446
|
],
|
|
373
|
-
stateMutability: "
|
|
447
|
+
stateMutability: "payable",
|
|
374
448
|
type: "function",
|
|
375
449
|
},
|
|
376
450
|
{
|
|
@@ -456,7 +530,7 @@ export const MetricOmmPoolLiquidityAdderAbi = [
|
|
|
456
530
|
type: "uint256",
|
|
457
531
|
},
|
|
458
532
|
],
|
|
459
|
-
stateMutability: "
|
|
533
|
+
stateMutability: "payable",
|
|
460
534
|
type: "function",
|
|
461
535
|
},
|
|
462
536
|
{
|
|
@@ -482,4 +556,75 @@ export const MetricOmmPoolLiquidityAdderAbi = [
|
|
|
482
556
|
stateMutability: "nonpayable",
|
|
483
557
|
type: "function",
|
|
484
558
|
},
|
|
559
|
+
{
|
|
560
|
+
inputs: [
|
|
561
|
+
{
|
|
562
|
+
internalType: "bytes[]",
|
|
563
|
+
name: "data",
|
|
564
|
+
type: "bytes[]",
|
|
565
|
+
},
|
|
566
|
+
],
|
|
567
|
+
name: "multicall",
|
|
568
|
+
outputs: [
|
|
569
|
+
{
|
|
570
|
+
internalType: "bytes[]",
|
|
571
|
+
name: "results",
|
|
572
|
+
type: "bytes[]",
|
|
573
|
+
},
|
|
574
|
+
],
|
|
575
|
+
stateMutability: "payable",
|
|
576
|
+
type: "function",
|
|
577
|
+
},
|
|
578
|
+
{
|
|
579
|
+
inputs: [],
|
|
580
|
+
name: "refundETH",
|
|
581
|
+
outputs: [],
|
|
582
|
+
stateMutability: "payable",
|
|
583
|
+
type: "function",
|
|
584
|
+
},
|
|
585
|
+
{
|
|
586
|
+
inputs: [
|
|
587
|
+
{
|
|
588
|
+
internalType: "address",
|
|
589
|
+
name: "token",
|
|
590
|
+
type: "address",
|
|
591
|
+
},
|
|
592
|
+
{
|
|
593
|
+
internalType: "uint256",
|
|
594
|
+
name: "amountMinimum",
|
|
595
|
+
type: "uint256",
|
|
596
|
+
},
|
|
597
|
+
{
|
|
598
|
+
internalType: "address",
|
|
599
|
+
name: "recipient",
|
|
600
|
+
type: "address",
|
|
601
|
+
},
|
|
602
|
+
],
|
|
603
|
+
name: "sweepToken",
|
|
604
|
+
outputs: [],
|
|
605
|
+
stateMutability: "payable",
|
|
606
|
+
type: "function",
|
|
607
|
+
},
|
|
608
|
+
{
|
|
609
|
+
inputs: [
|
|
610
|
+
{
|
|
611
|
+
internalType: "uint256",
|
|
612
|
+
name: "amountMinimum",
|
|
613
|
+
type: "uint256",
|
|
614
|
+
},
|
|
615
|
+
{
|
|
616
|
+
internalType: "address",
|
|
617
|
+
name: "recipient",
|
|
618
|
+
type: "address",
|
|
619
|
+
},
|
|
620
|
+
],
|
|
621
|
+
name: "unwrapWETH9",
|
|
622
|
+
outputs: [],
|
|
623
|
+
stateMutability: "payable",
|
|
624
|
+
type: "function",
|
|
625
|
+
},
|
|
626
|
+
{
|
|
627
|
+
stateMutability: "payable",
|
|
628
|
+
type: "receive",
|
|
629
|
+
},
|
|
485
630
|
] as const;
|
|
@@ -238,22 +238,6 @@ export const MetricOmmSimpleRouterAbi = [
|
|
|
238
238
|
name: "InvalidPriceLimitForDirection",
|
|
239
239
|
type: "error",
|
|
240
240
|
},
|
|
241
|
-
{
|
|
242
|
-
inputs: [
|
|
243
|
-
{
|
|
244
|
-
internalType: "bool",
|
|
245
|
-
name: "zeroForOne",
|
|
246
|
-
type: "bool",
|
|
247
|
-
},
|
|
248
|
-
{
|
|
249
|
-
internalType: "uint128",
|
|
250
|
-
name: "priceLimitX64",
|
|
251
|
-
type: "uint128",
|
|
252
|
-
},
|
|
253
|
-
],
|
|
254
|
-
name: "InvalidPriceLimitForDirection",
|
|
255
|
-
type: "error",
|
|
256
|
-
},
|
|
257
241
|
{
|
|
258
242
|
inputs: [],
|
|
259
243
|
name: "InvalidSwapDeltas",
|
|
@@ -89,22 +89,6 @@ export const MetricOmmSwapQuoterAbi = [
|
|
|
89
89
|
name: "InvalidPriceLimitForDirection",
|
|
90
90
|
type: "error",
|
|
91
91
|
},
|
|
92
|
-
{
|
|
93
|
-
inputs: [
|
|
94
|
-
{
|
|
95
|
-
internalType: "bool",
|
|
96
|
-
name: "zeroForOne",
|
|
97
|
-
type: "bool",
|
|
98
|
-
},
|
|
99
|
-
{
|
|
100
|
-
internalType: "uint128",
|
|
101
|
-
name: "priceLimitX64",
|
|
102
|
-
type: "uint128",
|
|
103
|
-
},
|
|
104
|
-
],
|
|
105
|
-
name: "InvalidPriceLimitForDirection",
|
|
106
|
-
type: "error",
|
|
107
|
-
},
|
|
108
92
|
{
|
|
109
93
|
inputs: [],
|
|
110
94
|
name: "InvalidSwapDeltas",
|
|
@@ -73,6 +73,25 @@ export const SwapAllowlistExtensionAbi = [
|
|
|
73
73
|
name: "OnlyPoolAdmin",
|
|
74
74
|
type: "error",
|
|
75
75
|
},
|
|
76
|
+
{
|
|
77
|
+
anonymous: false,
|
|
78
|
+
inputs: [
|
|
79
|
+
{
|
|
80
|
+
indexed: true,
|
|
81
|
+
internalType: "address",
|
|
82
|
+
name: "pool",
|
|
83
|
+
type: "address",
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
indexed: false,
|
|
87
|
+
internalType: "bool",
|
|
88
|
+
name: "allowed",
|
|
89
|
+
type: "bool",
|
|
90
|
+
},
|
|
91
|
+
],
|
|
92
|
+
name: "AllowAllSwappersSet",
|
|
93
|
+
type: "event",
|
|
94
|
+
},
|
|
76
95
|
{
|
|
77
96
|
anonymous: false,
|
|
78
97
|
inputs: [
|
|
@@ -312,6 +331,25 @@ export const SwapAllowlistExtensionAbi = [
|
|
|
312
331
|
stateMutability: "nonpayable",
|
|
313
332
|
type: "function",
|
|
314
333
|
},
|
|
334
|
+
{
|
|
335
|
+
inputs: [
|
|
336
|
+
{
|
|
337
|
+
internalType: "address",
|
|
338
|
+
name: "pool",
|
|
339
|
+
type: "address",
|
|
340
|
+
},
|
|
341
|
+
],
|
|
342
|
+
name: "allowAllSwappers",
|
|
343
|
+
outputs: [
|
|
344
|
+
{
|
|
345
|
+
internalType: "bool",
|
|
346
|
+
name: "",
|
|
347
|
+
type: "bool",
|
|
348
|
+
},
|
|
349
|
+
],
|
|
350
|
+
stateMutability: "view",
|
|
351
|
+
type: "function",
|
|
352
|
+
},
|
|
315
353
|
{
|
|
316
354
|
inputs: [
|
|
317
355
|
{
|
|
@@ -545,6 +583,24 @@ export const SwapAllowlistExtensionAbi = [
|
|
|
545
583
|
stateMutability: "view",
|
|
546
584
|
type: "function",
|
|
547
585
|
},
|
|
586
|
+
{
|
|
587
|
+
inputs: [
|
|
588
|
+
{
|
|
589
|
+
internalType: "address",
|
|
590
|
+
name: "pool_",
|
|
591
|
+
type: "address",
|
|
592
|
+
},
|
|
593
|
+
{
|
|
594
|
+
internalType: "bool",
|
|
595
|
+
name: "allowed",
|
|
596
|
+
type: "bool",
|
|
597
|
+
},
|
|
598
|
+
],
|
|
599
|
+
name: "setAllowAllSwappers",
|
|
600
|
+
outputs: [],
|
|
601
|
+
stateMutability: "nonpayable",
|
|
602
|
+
type: "function",
|
|
603
|
+
},
|
|
548
604
|
{
|
|
549
605
|
inputs: [
|
|
550
606
|
{
|
package/src/abis/index.ts
CHANGED
|
@@ -4,13 +4,13 @@
|
|
|
4
4
|
|
|
5
5
|
export { MetricOmmPoolAbi } from "./MetricOmmPool.js";
|
|
6
6
|
export { MetricOmmPoolDataProviderAbi } from "./MetricOmmPoolDataProvider.js";
|
|
7
|
-
export { MetricOmmSwapQuoterAbi } from "./MetricOmmSwapQuoter.js";
|
|
8
7
|
export { MetricOmmSimpleRouterAbi } from "./MetricOmmSimpleRouter.js";
|
|
8
|
+
export { MetricOmmSwapQuoterAbi } from "./MetricOmmSwapQuoter.js";
|
|
9
9
|
export { MetricOmmPoolLiquidityAdderAbi } from "./MetricOmmPoolLiquidityAdder.js";
|
|
10
10
|
export { MetricOmmPoolFactoryAbi } from "./MetricOmmPoolFactory.js";
|
|
11
11
|
export { DepositAllowlistExtensionAbi } from "./DepositAllowlistExtension.js";
|
|
12
12
|
export { SwapAllowlistExtensionAbi } from "./SwapAllowlistExtension.js";
|
|
13
|
-
export { PriceVelocityGuardExtensionAbi } from "./PriceVelocityGuardExtension.js";
|
|
14
13
|
export { OracleValueStopLossExtensionAbi } from "./OracleValueStopLossExtension.js";
|
|
14
|
+
export { PriceVelocityGuardExtensionAbi } from "./PriceVelocityGuardExtension.js";
|
|
15
15
|
export { PriceProviderAbi } from "./PriceProvider.js";
|
|
16
16
|
export { OracleProviderAbi } from "./OracleProvider.js";
|
package/src/addresses.ts
CHANGED
|
@@ -38,7 +38,7 @@ export interface ChainAddresses {
|
|
|
38
38
|
liquidityAdder: Address;
|
|
39
39
|
/** MetricOmmPoolDataProvider (pool reads, swap depth, revert quotes). */
|
|
40
40
|
dataProvider: Address;
|
|
41
|
-
/** MetricOmmSimpleRouter (single- and multi-hop
|
|
41
|
+
/** MetricOmmSimpleRouter (single- and multi-hop swaps). */
|
|
42
42
|
simpleRouter: Address;
|
|
43
43
|
/** MetricOmmSwapQuoter (live pool quotes via revert callback). */
|
|
44
44
|
quoter: Address;
|
|
@@ -58,21 +58,21 @@ export interface ChainAddresses {
|
|
|
58
58
|
|
|
59
59
|
/** Shared protocol deployment (Ethereum + Base). */
|
|
60
60
|
const PROTOCOL_ADDRESSES = {
|
|
61
|
-
factory: "
|
|
62
|
-
poolDeployer: "
|
|
63
|
-
liquidityAdder: "
|
|
64
|
-
dataProvider: "
|
|
65
|
-
simpleRouter: "
|
|
66
|
-
quoter: "
|
|
61
|
+
factory: "0xf98aD80FE666B9a23075CdF64aF5971802844Fd8",
|
|
62
|
+
poolDeployer: "0xf93e1ea4516E99A4Ee81D4979C8D3C8Ab636e397",
|
|
63
|
+
liquidityAdder: "0xdd615506d83e2d94f30aaf17e846330164ab599e",
|
|
64
|
+
dataProvider: "0x7dc8eD16661A5003D9708B55f768484f9E963AdB",
|
|
65
|
+
simpleRouter: "0xa4d4be6a6b6d9f6532cacfe61fc666ef2f9997ed",
|
|
66
|
+
quoter: "0xfa13b57b570B43c8b9A61ba8D2C1781aB064f617",
|
|
67
67
|
extensions: {
|
|
68
|
-
depositAllowlistExtension: "
|
|
69
|
-
swapAllowlistExtension: "
|
|
70
|
-
oracleValueStopLossExtension: "
|
|
71
|
-
priceVelocityGuardExtension: "
|
|
68
|
+
depositAllowlistExtension: "0xC93BdA96021650DBfCEab6470c5329a0F391C160",
|
|
69
|
+
swapAllowlistExtension: "0x50c58A0bf9711Ae091c3aF5C3eab49544062662e",
|
|
70
|
+
oracleValueStopLossExtension: "0x34822E3D4265a8E42284Ce9807A1a804b7552838",
|
|
71
|
+
priceVelocityGuardExtension: "0x07A5c4821cd84a9A6162a6b1f756aA458B7616E3",
|
|
72
72
|
},
|
|
73
73
|
} as const satisfies Omit<ChainAddresses, "wrappedNative">;
|
|
74
74
|
|
|
75
|
-
/**
|
|
75
|
+
/** Periphery deployment — Ethereum mainnet and Base (CREATE2, same protocol addresses). */
|
|
76
76
|
export const ADDRESSES: Record<DeployedChainId, ChainAddresses> = {
|
|
77
77
|
[ChainId.ETHEREUM]: {
|
|
78
78
|
...PROTOCOL_ADDRESSES,
|
package/src/index.ts
CHANGED
|
@@ -130,6 +130,25 @@ export {
|
|
|
130
130
|
type BinRemovalSpec,
|
|
131
131
|
} from "./pool/liquidity.js";
|
|
132
132
|
|
|
133
|
+
export {
|
|
134
|
+
prepareAddLiquidityExactSharesSelfSupportingNativePaymentCalldata,
|
|
135
|
+
prepareAddLiquidityExactSharesWithOwnerSupportingNativePaymentCalldata,
|
|
136
|
+
prepareAddLiquidityWeightedSelfSupportingNativePaymentCalldata,
|
|
137
|
+
prepareAddLiquidityWeightedWithOwnerSupportingNativePaymentCalldata,
|
|
138
|
+
UNCONSTRAINED_LIQUIDITY_CURSOR_BOUNDS,
|
|
139
|
+
type LiquidityCursorBounds,
|
|
140
|
+
prepareLiquidityCursorBounds,
|
|
141
|
+
computeLiquidityCursorBounds,
|
|
142
|
+
cursorMovementToPositionDelta,
|
|
143
|
+
} from "./pool/index.js";
|
|
144
|
+
|
|
145
|
+
// ============ PeripheryPayments ============
|
|
146
|
+
export {
|
|
147
|
+
encodeMulticallCalldata,
|
|
148
|
+
encodeRefundETHCalldata,
|
|
149
|
+
encodeUnwrapWETH9Calldata,
|
|
150
|
+
} from "./peripheryPayments/index.js";
|
|
151
|
+
|
|
133
152
|
// ============ Quoter Functions ============
|
|
134
153
|
export {
|
|
135
154
|
quoteLiveExactInSingle,
|
|
@@ -168,9 +187,6 @@ export {
|
|
|
168
187
|
prepareExactOutputSingleCalldata,
|
|
169
188
|
prepareExactInputCalldata,
|
|
170
189
|
prepareExactOutputCalldata,
|
|
171
|
-
encodeMulticallCalldata,
|
|
172
|
-
encodeRefundETHCalldata,
|
|
173
|
-
encodeUnwrapWETH9Calldata,
|
|
174
190
|
prepareExactInputSingleAndUnwrapCalldata,
|
|
175
191
|
prepareExactInputAndUnwrapCalldata,
|
|
176
192
|
prepareExactInputSingleSupportingNativePaymentCalldata,
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Helpers for weighted-add LiquidityAdder cursor bounds.
|
|
3
|
+
*
|
|
4
|
+
* Cursor position is measured in linear units: each bin spans MAX_UINT104 + 1
|
|
5
|
+
* positions (0 … MAX_UINT104). Movement can cross bin boundaries; distance is
|
|
6
|
+
* summed across bins.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import type { Address, PublicClient } from "viem";
|
|
10
|
+
import { MAX_UINT104 } from "../constants.js";
|
|
11
|
+
import { getSlot0 } from "../dataProvider/read.js";
|
|
12
|
+
import { getAddressesOrThrow } from "../addresses.js";
|
|
13
|
+
import { UNCONSTRAINED_LIQUIDITY_CURSOR_BOUNDS, type LiquidityCursorBounds } from "./liquidity.js";
|
|
14
|
+
|
|
15
|
+
const POSITIONS_PER_BIN = MAX_UINT104 + 1n;
|
|
16
|
+
const CURSOR_MOVEMENT_SCALE = 1_000_000_000n;
|
|
17
|
+
|
|
18
|
+
function floorDiv(a: bigint, b: bigint): bigint {
|
|
19
|
+
const q = a / b;
|
|
20
|
+
const r = a % b;
|
|
21
|
+
if (r !== 0n && a < 0n) return q - 1n;
|
|
22
|
+
return q;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function floorMod(a: bigint, b: bigint): bigint {
|
|
26
|
+
return a - floorDiv(a, b) * b;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function cursorToLinear(curBinIdx: number, curPosInBin: bigint): bigint {
|
|
30
|
+
return BigInt(curBinIdx) * POSITIONS_PER_BIN + curPosInBin;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function linearToCursor(linear: bigint): { curBinIdx: number; curPosInBin: bigint } {
|
|
34
|
+
return {
|
|
35
|
+
curBinIdx: Number(floorDiv(linear, POSITIONS_PER_BIN)),
|
|
36
|
+
curPosInBin: floorMod(linear, POSITIONS_PER_BIN),
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/** Convert a movement factor to position units (1.0 = MAX_UINT104 positions). */
|
|
41
|
+
export function cursorMovementToPositionDelta(maximalCursorMovement: number): bigint {
|
|
42
|
+
if (!Number.isFinite(maximalCursorMovement) || maximalCursorMovement < 0) {
|
|
43
|
+
throw new Error("maximalCursorMovement must be a non-negative finite number");
|
|
44
|
+
}
|
|
45
|
+
const scaledMovement = BigInt(Math.round(maximalCursorMovement * Number(CURSOR_MOVEMENT_SCALE)));
|
|
46
|
+
return (scaledMovement * MAX_UINT104) / CURSOR_MOVEMENT_SCALE;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Build LiquidityCursorBounds around a cursor by allowing up to
|
|
51
|
+
* `maximalCursorMovement * MAX_UINT104` positions of movement left or right.
|
|
52
|
+
*/
|
|
53
|
+
export function computeLiquidityCursorBounds(
|
|
54
|
+
curBinIdx: number,
|
|
55
|
+
curPosInBin: bigint,
|
|
56
|
+
maximalCursorMovement: number,
|
|
57
|
+
): LiquidityCursorBounds {
|
|
58
|
+
const delta = cursorMovementToPositionDelta(maximalCursorMovement);
|
|
59
|
+
const currentLinear = cursorToLinear(curBinIdx, curPosInBin);
|
|
60
|
+
|
|
61
|
+
const protocolMinLinear = cursorToLinear(
|
|
62
|
+
UNCONSTRAINED_LIQUIDITY_CURSOR_BOUNDS.minimalCurBin,
|
|
63
|
+
UNCONSTRAINED_LIQUIDITY_CURSOR_BOUNDS.minimalPosition,
|
|
64
|
+
);
|
|
65
|
+
const protocolMaxLinear = cursorToLinear(
|
|
66
|
+
UNCONSTRAINED_LIQUIDITY_CURSOR_BOUNDS.maximalCurBin,
|
|
67
|
+
UNCONSTRAINED_LIQUIDITY_CURSOR_BOUNDS.maximalPosition,
|
|
68
|
+
);
|
|
69
|
+
|
|
70
|
+
const clampedMinLinear =
|
|
71
|
+
currentLinear - delta < protocolMinLinear ? protocolMinLinear : currentLinear - delta;
|
|
72
|
+
const clampedMaxLinear =
|
|
73
|
+
currentLinear + delta > protocolMaxLinear ? protocolMaxLinear : currentLinear + delta;
|
|
74
|
+
|
|
75
|
+
const minimal = linearToCursor(clampedMinLinear);
|
|
76
|
+
const maximal = linearToCursor(clampedMaxLinear);
|
|
77
|
+
|
|
78
|
+
return {
|
|
79
|
+
minimalCurBin: minimal.curBinIdx,
|
|
80
|
+
minimalPosition: minimal.curPosInBin,
|
|
81
|
+
maximalCurBin: maximal.curBinIdx,
|
|
82
|
+
maximalPosition: maximal.curPosInBin,
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Read the pool cursor and return LiquidityCursorBounds for weighted add encoders.
|
|
88
|
+
*
|
|
89
|
+
* @param maximalCursorMovement - 1.0 allows up to MAX_UINT104 positions of movement
|
|
90
|
+
* left or right from the current cursor (summing across bin boundaries).
|
|
91
|
+
*/
|
|
92
|
+
export async function prepareLiquidityCursorBounds(params: {
|
|
93
|
+
publicClient: PublicClient;
|
|
94
|
+
pool: Address;
|
|
95
|
+
maximalCursorMovement: number;
|
|
96
|
+
dataProviderAddress?: Address;
|
|
97
|
+
}): Promise<LiquidityCursorBounds> {
|
|
98
|
+
const chainId = params.publicClient.chain?.id;
|
|
99
|
+
if (chainId === undefined) {
|
|
100
|
+
throw new Error("publicClient.chain.id is required to resolve dataProvider address");
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
const dataProviderAddress =
|
|
104
|
+
params.dataProviderAddress ?? getAddressesOrThrow(chainId).dataProvider;
|
|
105
|
+
const slot0 = await getSlot0(params.publicClient, dataProviderAddress, params.pool);
|
|
106
|
+
|
|
107
|
+
return computeLiquidityCursorBounds(
|
|
108
|
+
slot0.curBinIdx,
|
|
109
|
+
slot0.curPosInBin,
|
|
110
|
+
params.maximalCursorMovement,
|
|
111
|
+
);
|
|
112
|
+
}
|
package/src/pool/index.ts
CHANGED
|
@@ -39,6 +39,8 @@ export {
|
|
|
39
39
|
encodeAddLiquidityWeightedSelfCalldata,
|
|
40
40
|
encodeAddLiquidityWeightedWithOwnerCalldata,
|
|
41
41
|
encodeRemoveLiquidityCalldata,
|
|
42
|
+
UNCONSTRAINED_LIQUIDITY_CURSOR_BOUNDS,
|
|
43
|
+
type LiquidityCursorBounds,
|
|
42
44
|
getPositionShares,
|
|
43
45
|
getPositionSharesForBins,
|
|
44
46
|
NO_SLIPPAGE_LIMIT,
|
|
@@ -52,3 +54,16 @@ export {
|
|
|
52
54
|
type RemoveLiquidityParams,
|
|
53
55
|
type BinRemovalSpec,
|
|
54
56
|
} from "./liquidity.js";
|
|
57
|
+
|
|
58
|
+
export {
|
|
59
|
+
prepareAddLiquidityExactSharesSelfSupportingNativePaymentCalldata,
|
|
60
|
+
prepareAddLiquidityExactSharesWithOwnerSupportingNativePaymentCalldata,
|
|
61
|
+
prepareAddLiquidityWeightedSelfSupportingNativePaymentCalldata,
|
|
62
|
+
prepareAddLiquidityWeightedWithOwnerSupportingNativePaymentCalldata,
|
|
63
|
+
} from "./nativeLiquidity.js";
|
|
64
|
+
|
|
65
|
+
export {
|
|
66
|
+
prepareLiquidityCursorBounds,
|
|
67
|
+
computeLiquidityCursorBounds,
|
|
68
|
+
cursorMovementToPositionDelta,
|
|
69
|
+
} from "./cursorBounds.js";
|