@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
package/src/pool/liquidity.ts
CHANGED
|
@@ -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`
|
|
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
|
|
777
|
-
*
|
|
778
|
-
*
|
|
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
|
-
*
|
|
804
|
-
*
|
|
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
|
|
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 ??
|
|
856
|
-
params.minimalPosition ??
|
|
857
|
-
params.maximalCurBin ??
|
|
858
|
-
params.maximalPosition ??
|
|
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
|
-
/**
|
|
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 ??
|
|
889
|
-
params.minimalPosition ??
|
|
890
|
-
params.maximalCurBin ??
|
|
891
|
-
params.maximalPosition ??
|
|
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
|
+
}
|
package/src/router/index.ts
CHANGED
package/src/router/nativeSwap.ts
CHANGED
|
@@ -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"}
|
package/dist/router/utils.js.map
DELETED
|
@@ -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"}
|