@nradko/metric-omm-sdk-v1 0.0.16
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 +111 -0
- package/dist/abis/MetricOmmPool.d.ts +784 -0
- package/dist/abis/MetricOmmPool.d.ts.map +1 -0
- package/dist/abis/MetricOmmPool.js +1008 -0
- package/dist/abis/MetricOmmPool.js.map +1 -0
- package/dist/abis/MetricOmmPoolFactory.d.ts +1365 -0
- package/dist/abis/MetricOmmPoolFactory.d.ts.map +1 -0
- package/dist/abis/MetricOmmPoolFactory.js +1754 -0
- package/dist/abis/MetricOmmPoolFactory.js.map +1 -0
- package/dist/abis/MetricOmmPoolLiquidityAdder.d.ts +308 -0
- package/dist/abis/MetricOmmPoolLiquidityAdder.d.ts.map +1 -0
- package/dist/abis/MetricOmmPoolLiquidityAdder.js +401 -0
- package/dist/abis/MetricOmmPoolLiquidityAdder.js.map +1 -0
- package/dist/abis/MetricOmmPoolStateView.d.ts +538 -0
- package/dist/abis/MetricOmmPoolStateView.d.ts.map +1 -0
- package/dist/abis/MetricOmmPoolStateView.js +717 -0
- package/dist/abis/MetricOmmPoolStateView.js.map +1 -0
- package/dist/abis/MetricOmmPoolSwapper.d.ts +557 -0
- package/dist/abis/MetricOmmPoolSwapper.d.ts.map +1 -0
- package/dist/abis/MetricOmmPoolSwapper.js +723 -0
- package/dist/abis/MetricOmmPoolSwapper.js.map +1 -0
- package/dist/abis/Multicall3.d.ts +333 -0
- package/dist/abis/Multicall3.d.ts.map +1 -0
- package/dist/abis/Multicall3.js +441 -0
- package/dist/abis/Multicall3.js.map +1 -0
- package/dist/abis/PriceProvider.d.ts +142 -0
- package/dist/abis/PriceProvider.d.ts.map +1 -0
- package/dist/abis/PriceProvider.js +184 -0
- package/dist/abis/PriceProvider.js.map +1 -0
- package/dist/abis/PriceProviderUi.d.ts +433 -0
- package/dist/abis/PriceProviderUi.d.ts.map +1 -0
- package/dist/abis/PriceProviderUi.js +318 -0
- package/dist/abis/PriceProviderUi.js.map +1 -0
- package/dist/abis/index.d.ts +11 -0
- package/dist/abis/index.d.ts.map +1 -0
- package/dist/abis/index.js +11 -0
- package/dist/abis/index.js.map +1 -0
- package/dist/addresses.d.ts +52 -0
- package/dist/addresses.d.ts.map +1 -0
- package/dist/addresses.js +58 -0
- package/dist/addresses.js.map +1 -0
- package/dist/constants.d.ts +20 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +26 -0
- package/dist/constants.js.map +1 -0
- package/dist/factory/collectFees.d.ts +41 -0
- package/dist/factory/collectFees.d.ts.map +1 -0
- package/dist/factory/collectFees.js +120 -0
- package/dist/factory/collectFees.js.map +1 -0
- package/dist/factory/index.d.ts +5 -0
- package/dist/factory/index.d.ts.map +1 -0
- package/dist/factory/index.js +5 -0
- package/dist/factory/index.js.map +1 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +24 -0
- package/dist/index.js.map +1 -0
- package/dist/pool/create.d.ts +80 -0
- package/dist/pool/create.d.ts.map +1 -0
- package/dist/pool/create.js +80 -0
- package/dist/pool/create.js.map +1 -0
- package/dist/pool/index.d.ts +7 -0
- package/dist/pool/index.d.ts.map +1 -0
- package/dist/pool/index.js +10 -0
- package/dist/pool/index.js.map +1 -0
- package/dist/pool/liquidity.d.ts +165 -0
- package/dist/pool/liquidity.d.ts.map +1 -0
- package/dist/pool/liquidity.js +508 -0
- package/dist/pool/liquidity.js.map +1 -0
- package/dist/pool/read.d.ts +22 -0
- package/dist/pool/read.d.ts.map +1 -0
- package/dist/pool/read.js +88 -0
- package/dist/pool/read.js.map +1 -0
- package/dist/router/index.d.ts +5 -0
- package/dist/router/index.d.ts.map +1 -0
- package/dist/router/index.js +5 -0
- package/dist/router/index.js.map +1 -0
- package/dist/router/swap.d.ts +117 -0
- package/dist/router/swap.d.ts.map +1 -0
- package/dist/router/swap.js +298 -0
- package/dist/router/swap.js.map +1 -0
- package/dist/stateView/index.d.ts +5 -0
- package/dist/stateView/index.d.ts.map +1 -0
- package/dist/stateView/index.js +5 -0
- package/dist/stateView/index.js.map +1 -0
- package/dist/stateView/read.d.ts +80 -0
- package/dist/stateView/read.d.ts.map +1 -0
- package/dist/stateView/read.js +249 -0
- package/dist/stateView/read.js.map +1 -0
- package/dist/types.d.ts +134 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +6 -0
- package/dist/types.js.map +1 -0
- package/dist/utils/binData.d.ts +65 -0
- package/dist/utils/binData.d.ts.map +1 -0
- package/dist/utils/binData.js +109 -0
- package/dist/utils/binData.js.map +1 -0
- package/dist/utils/index.d.ts +7 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +10 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/liquidityMath.d.ts +10 -0
- package/dist/utils/liquidityMath.d.ts.map +1 -0
- package/dist/utils/liquidityMath.js +31 -0
- package/dist/utils/liquidityMath.js.map +1 -0
- package/dist/utils/price.d.ts +13 -0
- package/dist/utils/price.d.ts.map +1 -0
- package/dist/utils/price.js +21 -0
- package/dist/utils/price.js.map +1 -0
- package/package.json +74 -0
- package/src/abis/MetricOmmPool.ts +1007 -0
- package/src/abis/MetricOmmPoolFactory.ts +1753 -0
- package/src/abis/MetricOmmPoolLiquidityAdder.ts +400 -0
- package/src/abis/MetricOmmPoolStateView.ts +716 -0
- package/src/abis/MetricOmmPoolSwapper.ts +722 -0
- package/src/abis/Multicall3.ts +440 -0
- package/src/abis/PriceProvider.ts +183 -0
- package/src/abis/PriceProviderUi.ts +317 -0
- package/src/abis/index.ts +11 -0
- package/src/addresses.ts +100 -0
- package/src/constants.ts +35 -0
- package/src/factory/collectFees.ts +197 -0
- package/src/factory/index.ts +12 -0
- package/src/index.ts +157 -0
- package/src/pool/create.ts +158 -0
- package/src/pool/index.ts +47 -0
- package/src/pool/liquidity.ts +839 -0
- package/src/pool/read.ts +131 -0
- package/src/router/index.ts +27 -0
- package/src/router/swap.ts +507 -0
- package/src/stateView/index.ts +18 -0
- package/src/stateView/read.ts +355 -0
- package/src/types.ts +162 -0
- package/src/utils/binData.ts +127 -0
- package/src/utils/index.ts +26 -0
- package/src/utils/liquidityMath.ts +47 -0
- package/src/utils/price.ts +23 -0
package/README.md
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
# @nradko/metric-omm-sdk-v1
|
|
2
|
+
|
|
3
|
+
TypeScript SDK for **v1** Metric OMM contracts: **Swapper**, **LiquidityAdder**, pool `addLiquidity` / `removeLiquidity`, and factory-backed reads.
|
|
4
|
+
|
|
5
|
+
Pinned to the same commits as [`dev_metric-deploy/versions.env`](../../../dev_metric-deploy/versions.env).
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install @nradko/metric-omm-sdk-v1 viem
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Or via the combined package:
|
|
14
|
+
|
|
15
|
+
```typescript
|
|
16
|
+
import { v1 } from "@nradko/metric-omm-sdk";
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Ethereum mainnet addresses
|
|
20
|
+
|
|
21
|
+
| Contract | Address |
|
|
22
|
+
| -------- | ------- |
|
|
23
|
+
| MetricOmmPoolFactory | `0x93e314a9a65a15f3c3bc039bb4261dbbbc343fba` |
|
|
24
|
+
| MetricOmmPoolDeployer | `0xe56e89c4faeec39364b5a2cbde13c572a876afb6` |
|
|
25
|
+
| MetricOmmPoolLiquidityAdder | `0x1f2a03dc43947c6bdebb2e6136222997e49fa3e9` |
|
|
26
|
+
| MetricOmmPoolSwapDataProvider | `0x404bdb6d2b9ed34a5637211a8d52177c38c39d02` |
|
|
27
|
+
| DepositAllowlist | `0xea700fcd860533474e1ff920b76914113ae56681` |
|
|
28
|
+
| SwapAllowlist | `0x5269d78af4a288e1649be6bf169a51bb94b6eb78` |
|
|
29
|
+
| MetricOmmPoolSwapper | `0x85e4ff47427f1a62ed19a3abf97b80c333da266c` |
|
|
30
|
+
| WETH | `0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2` |
|
|
31
|
+
|
|
32
|
+
`stateView` is **not** in the deploy bundle — deploy `MetricOmmPoolStateView` from metric-core (constructor: factory) and pass its address into read helpers.
|
|
33
|
+
|
|
34
|
+
```typescript
|
|
35
|
+
import { getAddressesOrThrow, ChainId } from "@nradko/metric-omm-sdk-v1";
|
|
36
|
+
|
|
37
|
+
const a = getAddressesOrThrow(ChainId.ETHEREUM);
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Swaps (Swapper)
|
|
41
|
+
|
|
42
|
+
```typescript
|
|
43
|
+
import {
|
|
44
|
+
buildArgsAndExpectedAmountsForSwapExactInput,
|
|
45
|
+
getAddressesOrThrow,
|
|
46
|
+
ChainId,
|
|
47
|
+
} from "@nradko/metric-omm-sdk-v1";
|
|
48
|
+
import { MetricOmmPoolSwapperAbi } from "@nradko/metric-omm-sdk-v1/abis";
|
|
49
|
+
|
|
50
|
+
const addresses = getAddressesOrThrow(ChainId.ETHEREUM);
|
|
51
|
+
|
|
52
|
+
const { args, expectedInput, expectedOutput } =
|
|
53
|
+
await buildArgsAndExpectedAmountsForSwapExactInput({
|
|
54
|
+
publicClient,
|
|
55
|
+
swapperAddress: addresses.swapper,
|
|
56
|
+
pool: poolAddress,
|
|
57
|
+
recipient: account,
|
|
58
|
+
zeroForOne: true,
|
|
59
|
+
amountIn: 1_000_000_000_000_000_000n,
|
|
60
|
+
slippagePercent: 0.5,
|
|
61
|
+
deadline: BigInt(Math.floor(Date.now() / 1000) + 1200),
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
await walletClient.writeContract({
|
|
65
|
+
address: addresses.swapper,
|
|
66
|
+
abi: MetricOmmPoolSwapperAbi,
|
|
67
|
+
functionName: "swapExactInput",
|
|
68
|
+
args,
|
|
69
|
+
account,
|
|
70
|
+
});
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
Quote without building tx args: `quoteSwap`, `quoteExpectedAmountsForSwapExactInput`.
|
|
74
|
+
|
|
75
|
+
## Liquidity
|
|
76
|
+
|
|
77
|
+
- **Add (EOA):** approve **LiquidityAdder**, then `addLiquidityExactShares` / `addLiquidityWeighted` on the adder (see `encodeAddLiquidity*` helpers).
|
|
78
|
+
- **Remove:** `removeLiquidity` on the pool — build deltas with `buildModifyLiquidityArgsForRemoval` / `encodeRemoveLiquidityCalldata`.
|
|
79
|
+
|
|
80
|
+
SDK builders still use internal names like `buildModifyLiquidityArgsForUniformAddition` where the math is shared; encoders target v1 pool/adder ABIs.
|
|
81
|
+
|
|
82
|
+
## Pool reads
|
|
83
|
+
|
|
84
|
+
```typescript
|
|
85
|
+
import { getPoolImmutables, getPoolState, getSlot0 } from "@nradko/metric-omm-sdk-v1";
|
|
86
|
+
|
|
87
|
+
const imm = await getPoolImmutables(publicClient, addresses.factory, poolAddress);
|
|
88
|
+
const state = await getPoolState(publicClient, stateViewAddress, poolAddress);
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
## ABIs
|
|
92
|
+
|
|
93
|
+
```typescript
|
|
94
|
+
import {
|
|
95
|
+
MetricOmmPoolAbi,
|
|
96
|
+
MetricOmmPoolSwapperAbi,
|
|
97
|
+
MetricOmmPoolLiquidityAdderAbi,
|
|
98
|
+
} from "@nradko/metric-omm-sdk-v1/abis";
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
ABIs are committed under `src/abis/` and copied to `dist/abis/` on build.
|
|
102
|
+
|
|
103
|
+
## Development
|
|
104
|
+
|
|
105
|
+
```bash
|
|
106
|
+
npm run setup:contracts # submodules + hardhat + sync ABIs
|
|
107
|
+
npm run build
|
|
108
|
+
npm test
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
From repo root: `npm test -w @nradko/metric-omm-sdk-v1` (fork tests need `ETHEREUM_RPC_URL`).
|