@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.
Files changed (87) hide show
  1. package/README.md +48 -17
  2. package/dist/abis/DepositAllowlistExtension.d.ts +43 -0
  3. package/dist/abis/DepositAllowlistExtension.d.ts.map +1 -1
  4. package/dist/abis/DepositAllowlistExtension.js +56 -0
  5. package/dist/abis/DepositAllowlistExtension.js.map +1 -1
  6. package/dist/abis/MetricOmmPoolFactory.d.ts +12 -0
  7. package/dist/abis/MetricOmmPoolFactory.d.ts.map +1 -1
  8. package/dist/abis/MetricOmmPoolFactory.js +16 -0
  9. package/dist/abis/MetricOmmPoolFactory.js.map +1 -1
  10. package/dist/abis/MetricOmmPoolLiquidityAdder.d.ts +116 -5
  11. package/dist/abis/MetricOmmPoolLiquidityAdder.d.ts.map +1 -1
  12. package/dist/abis/MetricOmmPoolLiquidityAdder.js +150 -5
  13. package/dist/abis/MetricOmmPoolLiquidityAdder.js.map +1 -1
  14. package/dist/abis/MetricOmmSimpleRouter.d.ts +0 -12
  15. package/dist/abis/MetricOmmSimpleRouter.d.ts.map +1 -1
  16. package/dist/abis/MetricOmmSimpleRouter.js +0 -16
  17. package/dist/abis/MetricOmmSimpleRouter.js.map +1 -1
  18. package/dist/abis/MetricOmmSwapQuoter.d.ts +0 -12
  19. package/dist/abis/MetricOmmSwapQuoter.d.ts.map +1 -1
  20. package/dist/abis/MetricOmmSwapQuoter.js +0 -16
  21. package/dist/abis/MetricOmmSwapQuoter.js.map +1 -1
  22. package/dist/abis/SwapAllowlistExtension.d.ts +43 -0
  23. package/dist/abis/SwapAllowlistExtension.d.ts.map +1 -1
  24. package/dist/abis/SwapAllowlistExtension.js +56 -0
  25. package/dist/abis/SwapAllowlistExtension.js.map +1 -1
  26. package/dist/abis/index.d.ts +2 -2
  27. package/dist/abis/index.d.ts.map +1 -1
  28. package/dist/abis/index.js +2 -2
  29. package/dist/abis/index.js.map +1 -1
  30. package/dist/addresses.d.ts +2 -2
  31. package/dist/addresses.d.ts.map +1 -1
  32. package/dist/addresses.js +11 -11
  33. package/dist/addresses.js.map +1 -1
  34. package/dist/index.d.ts +3 -1
  35. package/dist/index.d.ts.map +1 -1
  36. package/dist/index.js +4 -1
  37. package/dist/index.js.map +1 -1
  38. package/dist/peripheryPayments/index.d.ts +2 -0
  39. package/dist/peripheryPayments/index.d.ts.map +1 -0
  40. package/dist/peripheryPayments/index.js +2 -0
  41. package/dist/peripheryPayments/index.js.map +1 -0
  42. package/dist/{router/utils.d.ts → peripheryPayments/simpleRouter.d.ts} +2 -2
  43. package/dist/peripheryPayments/simpleRouter.d.ts.map +1 -0
  44. package/dist/{router/utils.js → peripheryPayments/simpleRouter.js} +2 -2
  45. package/dist/peripheryPayments/simpleRouter.js.map +1 -0
  46. package/dist/pool/cursorBounds.d.ts +29 -0
  47. package/dist/pool/cursorBounds.d.ts.map +1 -0
  48. package/dist/pool/cursorBounds.js +76 -0
  49. package/dist/pool/cursorBounds.js.map +1 -0
  50. package/dist/pool/index.d.ts +3 -1
  51. package/dist/pool/index.d.ts.map +1 -1
  52. package/dist/pool/index.js +3 -1
  53. package/dist/pool/index.js.map +1 -1
  54. package/dist/pool/liquidity.d.ts +39 -8
  55. package/dist/pool/liquidity.d.ts.map +1 -1
  56. package/dist/pool/liquidity.js +41 -16
  57. package/dist/pool/liquidity.js.map +1 -1
  58. package/dist/pool/nativeLiquidity.d.ts +32 -0
  59. package/dist/pool/nativeLiquidity.d.ts.map +1 -0
  60. package/dist/pool/nativeLiquidity.js +47 -0
  61. package/dist/pool/nativeLiquidity.js.map +1 -0
  62. package/dist/router/index.d.ts +1 -1
  63. package/dist/router/index.d.ts.map +1 -1
  64. package/dist/router/index.js +1 -1
  65. package/dist/router/index.js.map +1 -1
  66. package/dist/router/nativeSwap.js +1 -1
  67. package/dist/router/nativeSwap.js.map +1 -1
  68. package/package.json +2 -2
  69. package/src/abis/DepositAllowlistExtension.ts +56 -0
  70. package/src/abis/MetricOmmPoolFactory.ts +16 -0
  71. package/src/abis/MetricOmmPoolLiquidityAdder.ts +150 -5
  72. package/src/abis/MetricOmmSimpleRouter.ts +0 -16
  73. package/src/abis/MetricOmmSwapQuoter.ts +0 -16
  74. package/src/abis/SwapAllowlistExtension.ts +56 -0
  75. package/src/abis/index.ts +2 -2
  76. package/src/addresses.ts +12 -12
  77. package/src/index.ts +19 -3
  78. package/src/peripheryPayments/index.ts +5 -0
  79. package/src/{router/utils.ts → peripheryPayments/simpleRouter.ts} +1 -1
  80. package/src/pool/cursorBounds.ts +112 -0
  81. package/src/pool/index.ts +15 -0
  82. package/src/pool/liquidity.ts +49 -16
  83. package/src/pool/nativeLiquidity.ts +71 -0
  84. package/src/router/index.ts +1 -1
  85. package/src/router/nativeSwap.ts +1 -1
  86. package/dist/router/utils.d.ts.map +0 -1
  87. package/dist/router/utils.js.map +0 -1
@@ -4,9 +4,15 @@
4
4
  * **Add liquidity (recommended path):**
5
5
  * 1. `buildModifyLiquidityArgsForAddition` / `ForUniformAddition` / `ForUniformAdditionWithTotalTokenAmount`
6
6
  * 2. `buildAddLiquidityExactSharesParamsFromBinTargets` (optional convenience)
7
- * 3. `encodeAddLiquidityExactSharesSelfCalldata` target `addresses.liquidityAdder`
7
+ * 3. `encodeAddLiquidityExactSharesSelfCalldata` or `encodeAddLiquidityExactSharesWithOwnerCalldata`
8
+ * — target `addresses.liquidityAdder`
8
9
  * 4. Approve token0 and token1 on the LiquidityAdder for `maxAmountToken0` / `maxAmountToken1`
9
10
  *
11
+ * **Self vs WithOwner encoders:**
12
+ * - `*SelfCalldata` — credits liquidity to **`msg.sender`** (the transaction sender owns the position).
13
+ * - `*WithOwnerCalldata` — credits liquidity to **`owner`** (e.g. router, vault, or relayer paying on behalf of a user).
14
+ * The caller still supplies tokens and must approve the LiquidityAdder; only the position owner differs.
15
+ *
10
16
  * **Remove liquidity:** `buildModifyLiquidityArgsForRemoval` → `buildRemoveLiquidityPoolDelta`
11
17
  * → `encodeRemoveLiquidityCalldata` — call the **pool** directly (no adder approval).
12
18
  *
@@ -772,10 +778,26 @@ export async function buildAddLiquidityExactSharesParamsFromBinTargets(
772
778
  };
773
779
  }
774
780
 
781
+ /** Cursor bounds that disable weighted-add cursor checks (matches on-chain test helpers). */
782
+ export const UNCONSTRAINED_LIQUIDITY_CURSOR_BOUNDS = {
783
+ minimalCurBin: -128,
784
+ minimalPosition: 0n,
785
+ maximalCurBin: 127,
786
+ maximalPosition: MAX_UINT104,
787
+ } as const;
788
+
789
+ export type LiquidityCursorBounds = {
790
+ minimalCurBin: number;
791
+ minimalPosition: bigint;
792
+ maximalCurBin: number;
793
+ maximalPosition: bigint;
794
+ };
795
+
775
796
  /**
776
- * Encode `LiquidityAdder.addLiquidityExactShares(pool, salt, deltas, max0, max1, ext)`
777
- * for `msg.sender` as position owner.
778
- * Approve both pool tokens on the LiquidityAdder before sending.
797
+ * Encode `LiquidityAdder.addLiquidityExactShares` for the transaction sender.
798
+ *
799
+ * Creates or increases the position `(msg.sender, salt)` liquidity is credited to whoever
800
+ * sends the transaction. Approve both pool tokens on the LiquidityAdder before sending.
779
801
  */
780
802
  export function encodeAddLiquidityExactSharesSelfCalldata(params: {
781
803
  pool: Address;
@@ -800,8 +822,11 @@ export function encodeAddLiquidityExactSharesSelfCalldata(params: {
800
822
  }
801
823
 
802
824
  /**
803
- * Same as {@link encodeAddLiquidityExactSharesSelfCalldata} but credits liquidity to `owner`
804
- * (e.g. router or vault acting on behalf of a user).
825
+ * Encode `LiquidityAdder.addLiquidityExactShares` for an explicit position owner.
826
+ *
827
+ * Creates or increases the position `(owner, salt)` while `msg.sender` pays for the deposit
828
+ * (e.g. router, vault, or meta-transaction relayer acting on behalf of `owner`).
829
+ * Approve both pool tokens on the LiquidityAdder before sending.
805
830
  */
806
831
  export function encodeAddLiquidityExactSharesWithOwnerCalldata(params: {
807
832
  pool: Address;
@@ -828,8 +853,11 @@ export function encodeAddLiquidityExactSharesWithOwnerCalldata(params: {
828
853
  }
829
854
 
830
855
  /**
831
- * Encode weighted add: `weightDeltas` are relative share weights; the adder scales to fit
856
+ * Encode weighted add for the transaction sender.
857
+ *
858
+ * `weightDeltas` are relative share weights; the adder scales to fit
832
859
  * `maxAmountToken0` / `maxAmountToken1`. Use {@link scaleWeightedPoolDeltasToFitCaps} to pre-scale.
860
+ * Creates or increases the position `(msg.sender, salt)`.
833
861
  */
834
862
  export function encodeAddLiquidityWeightedSelfCalldata(params: {
835
863
  pool: Address;
@@ -852,16 +880,21 @@ export function encodeAddLiquidityWeightedSelfCalldata(params: {
852
880
  { binIdxs: [...params.weightDeltas.binIdxs], shares: [...params.weightDeltas.shares] },
853
881
  params.maxAmountToken0,
854
882
  params.maxAmountToken1,
855
- params.minimalCurBin ?? -128,
856
- params.minimalPosition ?? 0n,
857
- params.maximalCurBin ?? 127,
858
- params.maximalPosition ?? MAX_UINT104,
883
+ params.minimalCurBin ?? UNCONSTRAINED_LIQUIDITY_CURSOR_BOUNDS.minimalCurBin,
884
+ params.minimalPosition ?? UNCONSTRAINED_LIQUIDITY_CURSOR_BOUNDS.minimalPosition,
885
+ params.maximalCurBin ?? UNCONSTRAINED_LIQUIDITY_CURSOR_BOUNDS.maximalCurBin,
886
+ params.maximalPosition ?? UNCONSTRAINED_LIQUIDITY_CURSOR_BOUNDS.maximalPosition,
859
887
  params.extensionData ?? EMPTY_EXTENSION_DATA,
860
888
  ],
861
889
  });
862
890
  }
863
891
 
864
- /** Weighted add with explicit `owner` (7-arg overload on LiquidityAdder). */
892
+ /**
893
+ * Encode weighted add for an explicit position owner.
894
+ *
895
+ * Same as {@link encodeAddLiquidityWeightedSelfCalldata} but credits liquidity to `(owner, salt)`
896
+ * while `msg.sender` pays for the deposit.
897
+ */
865
898
  export function encodeAddLiquidityWeightedWithOwnerCalldata(params: {
866
899
  pool: Address;
867
900
  owner: Address;
@@ -885,10 +918,10 @@ export function encodeAddLiquidityWeightedWithOwnerCalldata(params: {
885
918
  { binIdxs: [...params.weightDeltas.binIdxs], shares: [...params.weightDeltas.shares] },
886
919
  params.maxAmountToken0,
887
920
  params.maxAmountToken1,
888
- params.minimalCurBin ?? -128,
889
- params.minimalPosition ?? 0n,
890
- params.maximalCurBin ?? 127,
891
- params.maximalPosition ?? MAX_UINT104,
921
+ params.minimalCurBin ?? UNCONSTRAINED_LIQUIDITY_CURSOR_BOUNDS.minimalCurBin,
922
+ params.minimalPosition ?? UNCONSTRAINED_LIQUIDITY_CURSOR_BOUNDS.minimalPosition,
923
+ params.maximalCurBin ?? UNCONSTRAINED_LIQUIDITY_CURSOR_BOUNDS.maximalCurBin,
924
+ params.maximalPosition ?? UNCONSTRAINED_LIQUIDITY_CURSOR_BOUNDS.maximalPosition,
892
925
  params.extensionData ?? EMPTY_EXTENSION_DATA,
893
926
  ],
894
927
  });
@@ -0,0 +1,71 @@
1
+ import type { Hex } from "viem";
2
+ import {
3
+ encodeAddLiquidityExactSharesSelfCalldata,
4
+ encodeAddLiquidityExactSharesWithOwnerCalldata,
5
+ encodeAddLiquidityWeightedSelfCalldata,
6
+ encodeAddLiquidityWeightedWithOwnerCalldata,
7
+ } from "./liquidity.js";
8
+ import { encodeMulticallCalldata, encodeRefundETHCalldata } from "../peripheryPayments/index.js";
9
+
10
+ type ExactSharesSelfParams = Parameters<typeof encodeAddLiquidityExactSharesSelfCalldata>[0];
11
+ type ExactSharesWithOwnerParams = Parameters<
12
+ typeof encodeAddLiquidityExactSharesWithOwnerCalldata
13
+ >[0];
14
+ type WeightedSelfParams = Parameters<typeof encodeAddLiquidityWeightedSelfCalldata>[0];
15
+ type WeightedWithOwnerParams = Parameters<typeof encodeAddLiquidityWeightedWithOwnerCalldata>[0];
16
+
17
+ /**
18
+ * Exact-shares add with native ETH for the pool WETH leg.
19
+ * Credits liquidity to `(msg.sender, salt)`. Set `msg.value` on the transaction;
20
+ * unused ETH is refunded to the caller.
21
+ */
22
+ export function prepareAddLiquidityExactSharesSelfSupportingNativePaymentCalldata(
23
+ params: ExactSharesSelfParams,
24
+ ): Hex {
25
+ return encodeMulticallCalldata([
26
+ encodeAddLiquidityExactSharesSelfCalldata(params),
27
+ encodeRefundETHCalldata(),
28
+ ]);
29
+ }
30
+
31
+ /**
32
+ * Exact-shares add with native ETH for the pool WETH leg.
33
+ * Credits liquidity to `(owner, salt)` while `msg.sender` pays. Set `msg.value` on the
34
+ * transaction; unused ETH is refunded to the caller.
35
+ */
36
+ export function prepareAddLiquidityExactSharesWithOwnerSupportingNativePaymentCalldata(
37
+ params: ExactSharesWithOwnerParams,
38
+ ): Hex {
39
+ return encodeMulticallCalldata([
40
+ encodeAddLiquidityExactSharesWithOwnerCalldata(params),
41
+ encodeRefundETHCalldata(),
42
+ ]);
43
+ }
44
+
45
+ /**
46
+ * Weighted add with native ETH for the pool WETH leg.
47
+ * Credits liquidity to `(msg.sender, salt)`. Set `msg.value` on the transaction;
48
+ * unused ETH is refunded to the caller.
49
+ */
50
+ export function prepareAddLiquidityWeightedSelfSupportingNativePaymentCalldata(
51
+ params: WeightedSelfParams,
52
+ ): Hex {
53
+ return encodeMulticallCalldata([
54
+ encodeAddLiquidityWeightedSelfCalldata(params),
55
+ encodeRefundETHCalldata(),
56
+ ]);
57
+ }
58
+
59
+ /**
60
+ * Weighted add with native ETH for the pool WETH leg.
61
+ * Credits liquidity to `(owner, salt)` while `msg.sender` pays. Set `msg.value` on the
62
+ * transaction; unused ETH is refunded to the caller.
63
+ */
64
+ export function prepareAddLiquidityWeightedWithOwnerSupportingNativePaymentCalldata(
65
+ params: WeightedWithOwnerParams,
66
+ ): Hex {
67
+ return encodeMulticallCalldata([
68
+ encodeAddLiquidityWeightedWithOwnerCalldata(params),
69
+ encodeRefundETHCalldata(),
70
+ ]);
71
+ }
@@ -51,7 +51,7 @@ export {
51
51
  encodeMulticallCalldata,
52
52
  encodeRefundETHCalldata,
53
53
  encodeUnwrapWETH9Calldata,
54
- } from "./utils.js";
54
+ } from "../peripheryPayments/index.js";
55
55
 
56
56
  export {
57
57
  prepareExactInputSingleAndUnwrapCalldata,
@@ -7,7 +7,7 @@ import {
7
7
  encodeMulticallCalldata,
8
8
  encodeRefundETHCalldata,
9
9
  encodeUnwrapWETH9Calldata,
10
- } from "./utils.js";
10
+ } from "../peripheryPayments/index.js";
11
11
 
12
12
  function withRouterRecipient<T extends { recipient: Address }>(
13
13
  params: T,
@@ -1 +0,0 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/router/utils.ts"],"names":[],"mappings":"AAAA,sEAAsE;AAEtE,OAAO,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,MAAM,CAAC;AAIzC,4BAA4B;AAC5B,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,SAAS,GAAG,EAAE,GAAG,GAAG,CAMlE;AAED,0EAA0E;AAC1E,wBAAgB,uBAAuB,IAAI,GAAG,CAK7C;AAED,+CAA+C;AAC/C,wBAAgB,yBAAyB,CAAC,aAAa,EAAE,MAAM,EAAE,SAAS,EAAE,OAAO,GAAG,GAAG,CAMxF"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/router/utils.ts"],"names":[],"mappings":"AAAA,sEAAsE;AAGtE,OAAO,EAAE,kBAAkB,EAAE,MAAM,MAAM,CAAC;AAC1C,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAEpD,4BAA4B;AAC5B,MAAM,UAAU,uBAAuB,CAAC,KAAqB;IAC3D,OAAO,kBAAkB,CAAC;QACxB,GAAG,EAAE,iBAAiB;QACtB,YAAY,EAAE,WAAW;QACzB,IAAI,EAAE,CAAC,KAAK,CAAC;KACd,CAAC,CAAC;AACL,CAAC;AAED,0EAA0E;AAC1E,MAAM,UAAU,uBAAuB;IACrC,OAAO,kBAAkB,CAAC;QACxB,GAAG,EAAE,iBAAiB;QACtB,YAAY,EAAE,WAAW;KAC1B,CAAC,CAAC;AACL,CAAC;AAED,+CAA+C;AAC/C,MAAM,UAAU,yBAAyB,CAAC,aAAqB,EAAE,SAAkB;IACjF,OAAO,kBAAkB,CAAC;QACxB,GAAG,EAAE,iBAAiB;QACtB,YAAY,EAAE,aAAa;QAC3B,IAAI,EAAE,CAAC,aAAa,EAAE,SAAS,CAAC;KACjC,CAAC,CAAC;AACL,CAAC"}