@metric.xyz/metric-omm-sdk-v0 0.1.2
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 +101 -0
- package/dist/abis/MetricOmmPool.d.ts +756 -0
- package/dist/abis/MetricOmmPool.d.ts.map +1 -0
- package/dist/abis/MetricOmmPool.js +968 -0
- package/dist/abis/MetricOmmPool.js.map +1 -0
- package/dist/abis/MetricOmmPoolFactory.d.ts +365 -0
- package/dist/abis/MetricOmmPoolFactory.d.ts.map +1 -0
- package/dist/abis/MetricOmmPoolFactory.js +468 -0
- package/dist/abis/MetricOmmPoolFactory.js.map +1 -0
- package/dist/abis/MetricOmmPoolStateView.d.ts +500 -0
- package/dist/abis/MetricOmmPoolStateView.d.ts.map +1 -0
- package/dist/abis/MetricOmmPoolStateView.js +663 -0
- package/dist/abis/MetricOmmPoolStateView.js.map +1 -0
- package/dist/abis/MetricOmmSwapRouter.d.ts +529 -0
- package/dist/abis/MetricOmmSwapRouter.d.ts.map +1 -0
- package/dist/abis/MetricOmmSwapRouter.js +685 -0
- package/dist/abis/MetricOmmSwapRouter.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 +16 -0
- package/dist/abis/PriceProvider.d.ts.map +1 -0
- package/dist/abis/PriceProvider.js +21 -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 +13 -0
- package/dist/abis/index.d.ts.map +1 -0
- package/dist/abis/index.js +13 -0
- package/dist/abis/index.js.map +1 -0
- package/dist/addresses.d.ts +64 -0
- package/dist/addresses.d.ts.map +1 -0
- package/dist/addresses.js +141 -0
- package/dist/addresses.js.map +1 -0
- package/dist/constants.d.ts +19 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +25 -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 +22 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +38 -0
- package/dist/index.js.map +1 -0
- package/dist/pool/create.d.ts +175 -0
- package/dist/pool/create.d.ts.map +1 -0
- package/dist/pool/create.js +125 -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 +113 -0
- package/dist/pool/liquidity.d.ts.map +1 -0
- package/dist/pool/liquidity.js +413 -0
- package/dist/pool/liquidity.js.map +1 -0
- package/dist/pool/read.d.ts +23 -0
- package/dist/pool/read.d.ts.map +1 -0
- package/dist/pool/read.js +87 -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 +118 -0
- package/dist/router/swap.d.ts.map +1 -0
- package/dist/router/swap.js +299 -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 +241 -0
- package/dist/stateView/read.js.map +1 -0
- package/dist/types.d.ts +125 -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 +12 -0
- package/dist/utils/liquidityMath.d.ts.map +1 -0
- package/dist/utils/liquidityMath.js +43 -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 +83 -0
- package/src/abis/MetricOmmPool.ts +967 -0
- package/src/abis/MetricOmmPoolFactory.ts +467 -0
- package/src/abis/MetricOmmPoolStateView.ts +662 -0
- package/src/abis/MetricOmmSwapRouter.ts +684 -0
- package/src/abis/Multicall3.ts +440 -0
- package/src/abis/PriceProvider.ts +20 -0
- package/src/abis/PriceProviderUi.ts +317 -0
- package/src/abis/index.ts +13 -0
- package/src/addresses.ts +177 -0
- package/src/constants.ts +34 -0
- package/src/factory/collectFees.ts +197 -0
- package/src/factory/index.ts +12 -0
- package/src/index.ts +160 -0
- package/src/pool/create.ts +284 -0
- package/src/pool/index.ts +38 -0
- package/src/pool/liquidity.ts +688 -0
- package/src/pool/read.ts +128 -0
- package/src/router/index.ts +28 -0
- package/src/router/swap.ts +508 -0
- package/src/stateView/index.ts +18 -0
- package/src/stateView/read.ts +340 -0
- package/src/types.ts +152 -0
- package/src/utils/binData.ts +127 -0
- package/src/utils/index.ts +27 -0
- package/src/utils/liquidityMath.ts +61 -0
- package/src/utils/price.ts +23 -0
package/README.md
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
# @metric.xyz/metric-omm-sdk-v0
|
|
2
|
+
|
|
3
|
+
TypeScript SDK for **v0** Metric OMM contracts: **MetricOmmSwapRouter**, pool **`modifyLiquidity`**, and multi-chain deployed addresses.
|
|
4
|
+
|
|
5
|
+
Pinned to `metric-core@af10188` and `metric-periphery@e3154ea` (see `package.json`).
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install @metric.xyz/metric-omm-sdk-v0 viem
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Or via the combined package:
|
|
14
|
+
|
|
15
|
+
```typescript
|
|
16
|
+
import { v0 } from "@metric.xyz/metric-omm-sdk";
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Addresses
|
|
20
|
+
|
|
21
|
+
Multi-chain factory, deployer, state view (CREATE2), and per-chain router addresses are in `ADDRESSES` / `getAddressesOrThrow(chainId)`.
|
|
22
|
+
|
|
23
|
+
```typescript
|
|
24
|
+
import { ADDRESSES, ChainId, getAddressesOrThrow } from "@metric.xyz/metric-omm-sdk-v0";
|
|
25
|
+
|
|
26
|
+
const eth = getAddressesOrThrow(ChainId.ETHEREUM);
|
|
27
|
+
// eth.factory, eth.poolDeployer, eth.stateView, eth.router, ...
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## Swaps (Router)
|
|
31
|
+
|
|
32
|
+
```typescript
|
|
33
|
+
import {
|
|
34
|
+
buildArgsAndExpectedAmountsForSwapExactInput,
|
|
35
|
+
getAddressesOrThrow,
|
|
36
|
+
ChainId,
|
|
37
|
+
} from "@metric.xyz/metric-omm-sdk-v0";
|
|
38
|
+
import { MetricOmmSwapRouterAbi } from "@metric.xyz/metric-omm-sdk-v0/abis";
|
|
39
|
+
|
|
40
|
+
const addresses = getAddressesOrThrow(ChainId.ETHEREUM);
|
|
41
|
+
|
|
42
|
+
const { args } = await buildArgsAndExpectedAmountsForSwapExactInput({
|
|
43
|
+
publicClient,
|
|
44
|
+
routerAddress: addresses.router,
|
|
45
|
+
pool: poolAddress,
|
|
46
|
+
recipient: account,
|
|
47
|
+
zeroForOne: true,
|
|
48
|
+
amountIn: 1_000_000_000_000_000_000n,
|
|
49
|
+
slippagePercent: 0.5,
|
|
50
|
+
deadline: BigInt(Math.floor(Date.now() / 1000) + 1200),
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
await walletClient.writeContract({
|
|
54
|
+
address: addresses.router,
|
|
55
|
+
abi: MetricOmmSwapRouterAbi,
|
|
56
|
+
functionName: "swapExactInput",
|
|
57
|
+
args,
|
|
58
|
+
account,
|
|
59
|
+
});
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## Liquidity (`modifyLiquidity`)
|
|
63
|
+
|
|
64
|
+
```typescript
|
|
65
|
+
import {
|
|
66
|
+
buildModifyLiquidityArgsForUniformAddition,
|
|
67
|
+
encodeModifyLiquidityCalldata,
|
|
68
|
+
} from "@metric.xyz/metric-omm-sdk-v0";
|
|
69
|
+
|
|
70
|
+
const modifyArgs = await buildModifyLiquidityArgsForUniformAddition({ /* ... */ });
|
|
71
|
+
const data = encodeModifyLiquidityCalldata(modifyArgs);
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## What ships on npm
|
|
75
|
+
|
|
76
|
+
The published tarball includes only `dist/` and `src/` (see `package.json` `files`). Repo-only folders such as `exec/`, `ignition/`, and network deploy scripts are for maintainers and are not part of the npm package.
|
|
77
|
+
|
|
78
|
+
## Development
|
|
79
|
+
|
|
80
|
+
```bash
|
|
81
|
+
npm run build # tsc only (default prepare)
|
|
82
|
+
npm run setup:contracts # refresh ABIs from pinned git deps (maintainers)
|
|
83
|
+
npm test # Hardhat tests (needs matching @metric/* in node_modules)
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
### Tests in the monorepo
|
|
87
|
+
|
|
88
|
+
v0 has its own `package-lock.json` and `node_modules` (not hoisted with v1). From `dev_sdk/`:
|
|
89
|
+
|
|
90
|
+
```bash
|
|
91
|
+
npm run test:v0
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
Or from this directory after `npm ci` (no workspaces):
|
|
95
|
+
|
|
96
|
+
```bash
|
|
97
|
+
npm ci
|
|
98
|
+
npm test
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
CI uses `npm run test:v0` as part of root `npm test`.
|