@nradko/metric-omm-sdk-v1 0.4.4 → 0.4.5
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 +16 -15
- package/dist/addresses.d.ts +7 -5
- package/dist/addresses.d.ts.map +1 -1
- package/dist/addresses.js +40 -18
- package/dist/addresses.js.map +1 -1
- package/dist/pool/cursorBounds.d.ts.map +1 -1
- package/dist/pool/cursorBounds.js +10 -4
- package/dist/pool/cursorBounds.js.map +1 -1
- package/package.json +1 -1
- package/src/addresses.ts +45 -19
- package/src/pool/cursorBounds.ts +9 -6
package/README.md
CHANGED
|
@@ -16,24 +16,26 @@ Or via the combined package:
|
|
|
16
16
|
import { v1 } from "@nradko/metric-omm-sdk";
|
|
17
17
|
```
|
|
18
18
|
|
|
19
|
-
## Ethereum
|
|
19
|
+
## Ethereum, Base, Robinhood, and HyperEVM addresses
|
|
20
20
|
|
|
21
|
-
Protocol contracts use the **same addresses** on Ethereum
|
|
21
|
+
Protocol contracts use the **same addresses** on Ethereum, Base, Robinhood (4663), and HyperEVM (CREATE2). Wrapped native differs per chain.
|
|
22
22
|
|
|
23
23
|
| Contract | Address |
|
|
24
24
|
| -------- | ------- |
|
|
25
|
-
| MetricOmmPoolFactory | `
|
|
26
|
-
| MetricOmmPoolDeployer | `
|
|
27
|
-
| MetricOmmPoolLiquidityAdder | `
|
|
28
|
-
| MetricOmmPoolDataProvider | `
|
|
29
|
-
| MetricOmmSimpleRouter | `
|
|
30
|
-
| MetricOmmSwapQuoter | `
|
|
31
|
-
| DepositAllowlistExtension | `
|
|
32
|
-
| SwapAllowlistExtension | `
|
|
33
|
-
| OracleValueStopLossExtension | `
|
|
34
|
-
| PriceVelocityGuardExtension | `
|
|
25
|
+
| MetricOmmPoolFactory | `0x622911384e7973439b8be305f5e3Fc3c5736EDe4` |
|
|
26
|
+
| MetricOmmPoolDeployer | `0x47D5C9df5e3419217471A9D12D932Dbed7B0B7f1` |
|
|
27
|
+
| MetricOmmPoolLiquidityAdder | `0x9aA238a8319D20F6D8C3bcca45CA2F5e27C1e00f` |
|
|
28
|
+
| MetricOmmPoolDataProvider | `0x19f85Eb0a450b429C9a700bE867CF284e7e685eC` |
|
|
29
|
+
| MetricOmmSimpleRouter | `0x292DecA668291262341f92B840830f78dB35b6E5` |
|
|
30
|
+
| MetricOmmSwapQuoter | `0xaB6C48D981B943F62A23bb4EB2db125182E6753c` |
|
|
31
|
+
| DepositAllowlistExtension | `0x2229c48864d9aC877d23591fE99C3718Ef992F66` |
|
|
32
|
+
| SwapAllowlistExtension | `0xAC6BA2d77279a7B26db57Be6f8bF234932547eEd` |
|
|
33
|
+
| OracleValueStopLossExtension | `0x7D5D12aa06A025Fa37410F522F166070bA998e11` |
|
|
34
|
+
| PriceVelocityGuardExtension | `0x225c402B55c63d081821aA9260179C0d35e25091` |
|
|
35
35
|
| WETH (Ethereum) | `0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2` |
|
|
36
36
|
| WETH (Base) | `0x4200000000000000000000000000000000000006` |
|
|
37
|
+
| WETH (Robinhood) | `0x0Bd7D308f8E1639FAb988df18A8011f41EAcAD73` |
|
|
38
|
+
| WHYPE (HyperEVM) | `0x5555555555555555555555555555555555555555` |
|
|
37
39
|
|
|
38
40
|
`MetricOmmPoolDataProvider` is the deployed lens: pool reads (`slot0`, `binStates`, `positionBinShares`, …). Pass `addresses.dataProvider` to read helpers and liquidity builders (`dataProviderAddress` param). There is no separate StateView deployment — use `dataProvider` for all lens reads.
|
|
39
41
|
|
|
@@ -42,10 +44,11 @@ import { getAddressesOrThrow, ChainId, isChainSupported } from "@nradko/metric-o
|
|
|
42
44
|
|
|
43
45
|
const a = getAddressesOrThrow(ChainId.ETHEREUM);
|
|
44
46
|
// getAddressesOrThrow(ChainId.BASE) — same protocol addresses as Ethereum
|
|
47
|
+
// getAddressesOrThrow(ChainId.ROBINHOOD) / ChainId.HYPEREVM — same protocol addresses
|
|
45
48
|
// isChainSupported(ChainId.ARBITRUM) === false — use DeployedChainId / getSupportedChainIds()
|
|
46
49
|
```
|
|
47
50
|
|
|
48
|
-
`ChainId` lists future chain IDs for typing; **Ethereum
|
|
51
|
+
`ChainId` lists future chain IDs for typing; **Ethereum, Base, Robinhood, and HyperEVM** have entries in `ADDRESSES` for this release.
|
|
49
52
|
|
|
50
53
|
## Swaps (SimpleRouter)
|
|
51
54
|
|
|
@@ -325,5 +328,3 @@ npm ci
|
|
|
325
328
|
npm run setup:contracts
|
|
326
329
|
npm test
|
|
327
330
|
```
|
|
328
|
-
|
|
329
|
-
Fork tests: set `ETHEREUM_RPC_URL` (optional `ETHEREUM_FORK_BLOCK_NUMBER`).
|
package/dist/addresses.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* MetricAMM SDK — v1 deployed addresses.
|
|
3
3
|
*
|
|
4
|
-
* Ethereum
|
|
5
|
-
* Pool state reads (slot0, bins, position shares) and
|
|
6
|
-
* (MetricOmmPoolDataProvider — the single
|
|
4
|
+
* Ethereum, Base, Robinhood, and HyperEVM share the same protocol deployment
|
|
5
|
+
* addresses (CREATE2). Pool state reads (slot0, bins, position shares) and
|
|
6
|
+
* depth/quote views use dataProvider (MetricOmmPoolDataProvider — the single
|
|
7
|
+
* deployed lens per factory).
|
|
7
8
|
*/
|
|
8
9
|
import type { Address } from "viem";
|
|
9
10
|
export declare const ChainId: {
|
|
@@ -16,10 +17,11 @@ export declare const ChainId: {
|
|
|
16
17
|
readonly MEGAETH: 4326;
|
|
17
18
|
readonly HYPEREVM: 999;
|
|
18
19
|
readonly MONAD: 143;
|
|
20
|
+
readonly ROBINHOOD: 4663;
|
|
19
21
|
};
|
|
20
22
|
export type ChainId = (typeof ChainId)[keyof typeof ChainId];
|
|
21
23
|
/** Chains that have entries in ADDRESSES for this SDK release. */
|
|
22
|
-
export type DeployedChainId = typeof ChainId.ETHEREUM | typeof ChainId.BASE;
|
|
24
|
+
export type DeployedChainId = typeof ChainId.ETHEREUM | typeof ChainId.BASE | typeof ChainId.ROBINHOOD | typeof ChainId.HYPEREVM;
|
|
23
25
|
export interface ChainAddresses {
|
|
24
26
|
/** MetricOmmPoolFactory */
|
|
25
27
|
factory: Address;
|
|
@@ -43,7 +45,7 @@ export interface ChainAddresses {
|
|
|
43
45
|
priceVelocityGuardExtension: Address;
|
|
44
46
|
};
|
|
45
47
|
}
|
|
46
|
-
/** Periphery deployment —
|
|
48
|
+
/** Periphery deployment — CREATE2, same protocol addresses on each chain below. */
|
|
47
49
|
export declare const ADDRESSES: Record<DeployedChainId, ChainAddresses>;
|
|
48
50
|
export declare function getAddresses(chainId: number): ChainAddresses | undefined;
|
|
49
51
|
export declare function getAddressesOrThrow(chainId: number): ChainAddresses;
|
package/dist/addresses.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"addresses.d.ts","sourceRoot":"","sources":["../src/addresses.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"addresses.d.ts","sourceRoot":"","sources":["../src/addresses.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAIpC,eAAO,MAAM,OAAO;;;;;;;;;;;CAWV,CAAC;AAEX,MAAM,MAAM,OAAO,GAAG,CAAC,OAAO,OAAO,CAAC,CAAC,MAAM,OAAO,OAAO,CAAC,CAAC;AAE7D,kEAAkE;AAClE,MAAM,MAAM,eAAe,GACvB,OAAO,OAAO,CAAC,QAAQ,GACvB,OAAO,OAAO,CAAC,IAAI,GACnB,OAAO,OAAO,CAAC,SAAS,GACxB,OAAO,OAAO,CAAC,QAAQ,CAAC;AAI5B,MAAM,WAAW,cAAc;IAC7B,2BAA2B;IAC3B,OAAO,EAAE,OAAO,CAAC;IACjB,4BAA4B;IAC5B,YAAY,EAAE,OAAO,CAAC;IACtB,kCAAkC;IAClC,cAAc,EAAE,OAAO,CAAC;IACxB,yEAAyE;IACzE,YAAY,EAAE,OAAO,CAAC;IACtB,2DAA2D;IAC3D,YAAY,EAAE,OAAO,CAAC;IACtB,kEAAkE;IAClE,MAAM,EAAE,OAAO,CAAC;IAChB,+CAA+C;IAC/C,aAAa,EAAE,OAAO,CAAC;IAEvB,wDAAwD;IACxD,UAAU,EAAE;QACV,yBAAyB,EAAE,OAAO,CAAC;QACnC,sBAAsB,EAAE,OAAO,CAAC;QAChC,4BAA4B,EAAE,OAAO,CAAC;QACtC,2BAA2B,EAAE,OAAO,CAAC;KACtC,CAAC;CACH;AAoBD,mFAAmF;AACnF,eAAO,MAAM,SAAS,EAAE,MAAM,CAAC,eAAe,EAAE,cAAc,CAiBpD,CAAC;AAWX,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,cAAc,GAAG,SAAS,CAMxE;AAED,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG,cAAc,CAQnE;AAED,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,IAAI,eAAe,CAO5E;AAED,wBAAgB,oBAAoB,IAAI,eAAe,EAAE,CAExD;AAED,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAIxD"}
|
package/dist/addresses.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* MetricAMM SDK — v1 deployed addresses.
|
|
3
3
|
*
|
|
4
|
-
* Ethereum
|
|
5
|
-
* Pool state reads (slot0, bins, position shares) and
|
|
6
|
-
* (MetricOmmPoolDataProvider — the single
|
|
4
|
+
* Ethereum, Base, Robinhood, and HyperEVM share the same protocol deployment
|
|
5
|
+
* addresses (CREATE2). Pool state reads (slot0, bins, position shares) and
|
|
6
|
+
* depth/quote views use dataProvider (MetricOmmPoolDataProvider — the single
|
|
7
|
+
* deployed lens per factory).
|
|
7
8
|
*/
|
|
8
9
|
// ============ Chain IDs ============
|
|
9
10
|
export const ChainId = {
|
|
@@ -16,24 +17,25 @@ export const ChainId = {
|
|
|
16
17
|
MEGAETH: 4326,
|
|
17
18
|
HYPEREVM: 999,
|
|
18
19
|
MONAD: 143,
|
|
20
|
+
ROBINHOOD: 4663,
|
|
19
21
|
};
|
|
20
22
|
// ============ Deployed addresses ============
|
|
21
|
-
/** Shared protocol deployment (Ethereum
|
|
23
|
+
/** Shared protocol deployment (Ethereum, Base, Robinhood, HyperEVM). */
|
|
22
24
|
const PROTOCOL_ADDRESSES = {
|
|
23
|
-
factory: "
|
|
24
|
-
poolDeployer: "
|
|
25
|
-
liquidityAdder: "
|
|
26
|
-
dataProvider: "
|
|
27
|
-
simpleRouter: "
|
|
28
|
-
quoter: "
|
|
25
|
+
factory: "0x622911384e7973439b8be305f5e3Fc3c5736EDe4",
|
|
26
|
+
poolDeployer: "0x47D5C9df5e3419217471A9D12D932Dbed7B0B7f1",
|
|
27
|
+
liquidityAdder: "0x9aA238a8319D20F6D8C3bcca45CA2F5e27C1e00f",
|
|
28
|
+
dataProvider: "0x19f85Eb0a450b429C9a700bE867CF284e7e685eC",
|
|
29
|
+
simpleRouter: "0x292DecA668291262341f92B840830f78dB35b6E5",
|
|
30
|
+
quoter: "0xaB6C48D981B943F62A23bb4EB2db125182E6753c",
|
|
29
31
|
extensions: {
|
|
30
|
-
depositAllowlistExtension: "
|
|
31
|
-
swapAllowlistExtension: "
|
|
32
|
-
oracleValueStopLossExtension: "
|
|
33
|
-
priceVelocityGuardExtension: "
|
|
32
|
+
depositAllowlistExtension: "0x2229c48864d9aC877d23591fE99C3718Ef992F66",
|
|
33
|
+
swapAllowlistExtension: "0xAC6BA2d77279a7B26db57Be6f8bF234932547eEd",
|
|
34
|
+
oracleValueStopLossExtension: "0x7D5D12aa06A025Fa37410F522F166070bA998e11",
|
|
35
|
+
priceVelocityGuardExtension: "0x225c402B55c63d081821aA9260179C0d35e25091",
|
|
34
36
|
},
|
|
35
37
|
};
|
|
36
|
-
/** Periphery deployment —
|
|
38
|
+
/** Periphery deployment — CREATE2, same protocol addresses on each chain below. */
|
|
37
39
|
export const ADDRESSES = {
|
|
38
40
|
[ChainId.ETHEREUM]: {
|
|
39
41
|
...PROTOCOL_ADDRESSES,
|
|
@@ -43,25 +45,45 @@ export const ADDRESSES = {
|
|
|
43
45
|
...PROTOCOL_ADDRESSES,
|
|
44
46
|
wrappedNative: "0x4200000000000000000000000000000000000006",
|
|
45
47
|
},
|
|
48
|
+
[ChainId.ROBINHOOD]: {
|
|
49
|
+
...PROTOCOL_ADDRESSES,
|
|
50
|
+
wrappedNative: "0x0Bd7D308f8E1639FAb988df18A8011f41EAcAD73",
|
|
51
|
+
},
|
|
52
|
+
[ChainId.HYPEREVM]: {
|
|
53
|
+
...PROTOCOL_ADDRESSES,
|
|
54
|
+
wrappedNative: "0x5555555555555555555555555555555555555555",
|
|
55
|
+
},
|
|
46
56
|
};
|
|
47
57
|
// ============ Helper Functions ============
|
|
48
|
-
const DEPLOYED_CHAIN_IDS = [
|
|
58
|
+
const DEPLOYED_CHAIN_IDS = [
|
|
59
|
+
ChainId.ETHEREUM,
|
|
60
|
+
ChainId.BASE,
|
|
61
|
+
ChainId.ROBINHOOD,
|
|
62
|
+
ChainId.HYPEREVM,
|
|
63
|
+
];
|
|
49
64
|
export function getAddresses(chainId) {
|
|
50
65
|
if (chainId === ChainId.ETHEREUM)
|
|
51
66
|
return ADDRESSES[ChainId.ETHEREUM];
|
|
52
67
|
if (chainId === ChainId.BASE)
|
|
53
68
|
return ADDRESSES[ChainId.BASE];
|
|
69
|
+
if (chainId === ChainId.ROBINHOOD)
|
|
70
|
+
return ADDRESSES[ChainId.ROBINHOOD];
|
|
71
|
+
if (chainId === ChainId.HYPEREVM)
|
|
72
|
+
return ADDRESSES[ChainId.HYPEREVM];
|
|
54
73
|
return undefined;
|
|
55
74
|
}
|
|
56
75
|
export function getAddressesOrThrow(chainId) {
|
|
57
76
|
const addresses = getAddresses(chainId);
|
|
58
77
|
if (!addresses) {
|
|
59
|
-
throw new Error(`Chain ${chainId} has no v1 deployment in this SDK (Ethereum and
|
|
78
|
+
throw new Error(`Chain ${chainId} has no v1 deployment in this SDK (Ethereum, Base, Robinhood, and HyperEVM are configured)`);
|
|
60
79
|
}
|
|
61
80
|
return addresses;
|
|
62
81
|
}
|
|
63
82
|
export function isChainSupported(chainId) {
|
|
64
|
-
return chainId === ChainId.ETHEREUM ||
|
|
83
|
+
return (chainId === ChainId.ETHEREUM ||
|
|
84
|
+
chainId === ChainId.BASE ||
|
|
85
|
+
chainId === ChainId.ROBINHOOD ||
|
|
86
|
+
chainId === ChainId.HYPEREVM);
|
|
65
87
|
}
|
|
66
88
|
export function getSupportedChainIds() {
|
|
67
89
|
return [...DEPLOYED_CHAIN_IDS];
|
package/dist/addresses.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"addresses.js","sourceRoot":"","sources":["../src/addresses.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"addresses.js","sourceRoot":"","sources":["../src/addresses.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,sCAAsC;AAEtC,MAAM,CAAC,MAAM,OAAO,GAAG;IACrB,QAAQ,EAAE,CAAC;IACX,IAAI,EAAE,IAAI;IACV,QAAQ,EAAE,KAAK;IACf,SAAS,EAAE,KAAK;IAChB,GAAG,EAAE,EAAE;IACP,OAAO,EAAE,GAAG;IACZ,OAAO,EAAE,IAAI;IACb,QAAQ,EAAE,GAAG;IACb,KAAK,EAAE,GAAG;IACV,SAAS,EAAE,IAAI;CACP,CAAC;AAsCX,+CAA+C;AAE/C,wEAAwE;AACxE,MAAM,kBAAkB,GAAG;IACzB,OAAO,EAAE,4CAA4C;IACrD,YAAY,EAAE,4CAA4C;IAC1D,cAAc,EAAE,4CAA4C;IAC5D,YAAY,EAAE,4CAA4C;IAC1D,YAAY,EAAE,4CAA4C;IAC1D,MAAM,EAAE,4CAA4C;IACpD,UAAU,EAAE;QACV,yBAAyB,EAAE,4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YAAY,EAAE,YAAY,CAAC;IAC3B,IAAI,EAAE,OAAO,CAAC;IACd,qBAAqB,EAAE,MAAM,CAAC;IAC9B,mBAAmB,CAAC,EAAE,OAAO,CAAC;CAC/B,GAAG,OAAO,CAAC,qBAAqB,CAAC,
|
|
1
|
+
{"version":3,"file":"cursorBounds.d.ts","sourceRoot":"","sources":["../../src/pool/cursorBounds.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,MAAM,CAAC;AAIlD,OAAO,EAAyC,KAAK,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AA2BnG,iFAAiF;AACjF,wBAAgB,6BAA6B,CAAC,qBAAqB,EAAE,MAAM,GAAG,MAAM,CAMnF;AAED;;;GAGG;AACH,wBAAgB,4BAA4B,CAC1C,SAAS,EAAE,MAAM,EACjB,WAAW,EAAE,MAAM,EACnB,qBAAqB,EAAE,MAAM,GAC5B,qBAAqB,CA2BvB;AAED;;;;;GAKG;AACH,wBAAsB,4BAA4B,CAAC,MAAM,EAAE;IACzD,YAAY,EAAE,YAAY,CAAC;IAC3B,IAAI,EAAE,OAAO,CAAC;IACd,qBAAqB,EAAE,MAAM,CAAC;IAC9B,mBAAmB,CAAC,EAAE,OAAO,CAAC;CAC/B,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAkBjC"}
|
|
@@ -65,11 +65,17 @@ export function computeLiquidityCursorBounds(curBinIdx, curPosInBin, maximalCurs
|
|
|
65
65
|
* left or right from the current cursor (summing across bin boundaries).
|
|
66
66
|
*/
|
|
67
67
|
export async function prepareLiquidityCursorBounds(params) {
|
|
68
|
-
|
|
69
|
-
if (
|
|
70
|
-
|
|
68
|
+
let dataProviderAddress;
|
|
69
|
+
if (params.dataProviderAddress) {
|
|
70
|
+
dataProviderAddress = params.dataProviderAddress;
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
const chainId = params.publicClient.chain?.id;
|
|
74
|
+
if (chainId === undefined) {
|
|
75
|
+
throw new Error("publicClient.chain.id is required to resolve dataProvider address");
|
|
76
|
+
}
|
|
77
|
+
dataProviderAddress = getAddressesOrThrow(chainId).dataProvider;
|
|
71
78
|
}
|
|
72
|
-
const dataProviderAddress = params.dataProviderAddress ?? getAddressesOrThrow(chainId).dataProvider;
|
|
73
79
|
const slot0 = await getSlot0(params.publicClient, dataProviderAddress, params.pool);
|
|
74
80
|
return computeLiquidityCursorBounds(slot0.curBinIdx, slot0.curPosInBin, params.maximalCursorMovement);
|
|
75
81
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cursorBounds.js","sourceRoot":"","sources":["../../src/pool/cursorBounds.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACnD,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,EAAE,qCAAqC,EAA8B,MAAM,gBAAgB,CAAC;AAEnG,MAAM,iBAAiB,GAAG,WAAW,GAAG,EAAE,CAAC;AAC3C,MAAM,qBAAqB,GAAG,WAAc,CAAC;AAE7C,SAAS,QAAQ,CAAC,CAAS,EAAE,CAAS;IACpC,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAChB,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAChB,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,GAAG,EAAE;QAAE,OAAO,CAAC,GAAG,EAAE,CAAC;IACtC,OAAO,CAAC,CAAC;AACX,CAAC;AAED,SAAS,QAAQ,CAAC,CAAS,EAAE,CAAS;IACpC,OAAO,CAAC,GAAG,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC;AAChC,CAAC;AAED,SAAS,cAAc,CAAC,SAAiB,EAAE,WAAmB;IAC5D,OAAO,M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J,CAAC"}
|
package/package.json
CHANGED
package/src/addresses.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* MetricAMM SDK — v1 deployed addresses.
|
|
3
3
|
*
|
|
4
|
-
* Ethereum
|
|
5
|
-
* Pool state reads (slot0, bins, position shares) and
|
|
6
|
-
* (MetricOmmPoolDataProvider — the single
|
|
4
|
+
* Ethereum, Base, Robinhood, and HyperEVM share the same protocol deployment
|
|
5
|
+
* addresses (CREATE2). Pool state reads (slot0, bins, position shares) and
|
|
6
|
+
* depth/quote views use dataProvider (MetricOmmPoolDataProvider — the single
|
|
7
|
+
* deployed lens per factory).
|
|
7
8
|
*/
|
|
8
9
|
|
|
9
10
|
import type { Address } from "viem";
|
|
@@ -20,12 +21,17 @@ export const ChainId = {
|
|
|
20
21
|
MEGAETH: 4326,
|
|
21
22
|
HYPEREVM: 999,
|
|
22
23
|
MONAD: 143,
|
|
24
|
+
ROBINHOOD: 4663,
|
|
23
25
|
} as const;
|
|
24
26
|
|
|
25
27
|
export type ChainId = (typeof ChainId)[keyof typeof ChainId];
|
|
26
28
|
|
|
27
29
|
/** Chains that have entries in ADDRESSES for this SDK release. */
|
|
28
|
-
export type DeployedChainId =
|
|
30
|
+
export type DeployedChainId =
|
|
31
|
+
| typeof ChainId.ETHEREUM
|
|
32
|
+
| typeof ChainId.BASE
|
|
33
|
+
| typeof ChainId.ROBINHOOD
|
|
34
|
+
| typeof ChainId.HYPEREVM;
|
|
29
35
|
|
|
30
36
|
// ============ Contract Address Types ============
|
|
31
37
|
|
|
@@ -56,23 +62,23 @@ export interface ChainAddresses {
|
|
|
56
62
|
|
|
57
63
|
// ============ Deployed addresses ============
|
|
58
64
|
|
|
59
|
-
/** Shared protocol deployment (Ethereum
|
|
65
|
+
/** Shared protocol deployment (Ethereum, Base, Robinhood, HyperEVM). */
|
|
60
66
|
const PROTOCOL_ADDRESSES = {
|
|
61
|
-
factory: "
|
|
62
|
-
poolDeployer: "
|
|
63
|
-
liquidityAdder: "
|
|
64
|
-
dataProvider: "
|
|
65
|
-
simpleRouter: "
|
|
66
|
-
quoter: "
|
|
67
|
+
factory: "0x622911384e7973439b8be305f5e3Fc3c5736EDe4",
|
|
68
|
+
poolDeployer: "0x47D5C9df5e3419217471A9D12D932Dbed7B0B7f1",
|
|
69
|
+
liquidityAdder: "0x9aA238a8319D20F6D8C3bcca45CA2F5e27C1e00f",
|
|
70
|
+
dataProvider: "0x19f85Eb0a450b429C9a700bE867CF284e7e685eC",
|
|
71
|
+
simpleRouter: "0x292DecA668291262341f92B840830f78dB35b6E5",
|
|
72
|
+
quoter: "0xaB6C48D981B943F62A23bb4EB2db125182E6753c",
|
|
67
73
|
extensions: {
|
|
68
|
-
depositAllowlistExtension: "
|
|
69
|
-
swapAllowlistExtension: "
|
|
70
|
-
oracleValueStopLossExtension: "
|
|
71
|
-
priceVelocityGuardExtension: "
|
|
74
|
+
depositAllowlistExtension: "0x2229c48864d9aC877d23591fE99C3718Ef992F66",
|
|
75
|
+
swapAllowlistExtension: "0xAC6BA2d77279a7B26db57Be6f8bF234932547eEd",
|
|
76
|
+
oracleValueStopLossExtension: "0x7D5D12aa06A025Fa37410F522F166070bA998e11",
|
|
77
|
+
priceVelocityGuardExtension: "0x225c402B55c63d081821aA9260179C0d35e25091",
|
|
72
78
|
},
|
|
73
79
|
} as const satisfies Omit<ChainAddresses, "wrappedNative">;
|
|
74
80
|
|
|
75
|
-
/** Periphery deployment —
|
|
81
|
+
/** Periphery deployment — CREATE2, same protocol addresses on each chain below. */
|
|
76
82
|
export const ADDRESSES: Record<DeployedChainId, ChainAddresses> = {
|
|
77
83
|
[ChainId.ETHEREUM]: {
|
|
78
84
|
...PROTOCOL_ADDRESSES,
|
|
@@ -82,15 +88,30 @@ export const ADDRESSES: Record<DeployedChainId, ChainAddresses> = {
|
|
|
82
88
|
...PROTOCOL_ADDRESSES,
|
|
83
89
|
wrappedNative: "0x4200000000000000000000000000000000000006",
|
|
84
90
|
},
|
|
91
|
+
[ChainId.ROBINHOOD]: {
|
|
92
|
+
...PROTOCOL_ADDRESSES,
|
|
93
|
+
wrappedNative: "0x0Bd7D308f8E1639FAb988df18A8011f41EAcAD73",
|
|
94
|
+
},
|
|
95
|
+
[ChainId.HYPEREVM]: {
|
|
96
|
+
...PROTOCOL_ADDRESSES,
|
|
97
|
+
wrappedNative: "0x5555555555555555555555555555555555555555",
|
|
98
|
+
},
|
|
85
99
|
} as const;
|
|
86
100
|
|
|
87
101
|
// ============ Helper Functions ============
|
|
88
102
|
|
|
89
|
-
const DEPLOYED_CHAIN_IDS: readonly DeployedChainId[] = [
|
|
103
|
+
const DEPLOYED_CHAIN_IDS: readonly DeployedChainId[] = [
|
|
104
|
+
ChainId.ETHEREUM,
|
|
105
|
+
ChainId.BASE,
|
|
106
|
+
ChainId.ROBINHOOD,
|
|
107
|
+
ChainId.HYPEREVM,
|
|
108
|
+
];
|
|
90
109
|
|
|
91
110
|
export function getAddresses(chainId: number): ChainAddresses | undefined {
|
|
92
111
|
if (chainId === ChainId.ETHEREUM) return ADDRESSES[ChainId.ETHEREUM];
|
|
93
112
|
if (chainId === ChainId.BASE) return ADDRESSES[ChainId.BASE];
|
|
113
|
+
if (chainId === ChainId.ROBINHOOD) return ADDRESSES[ChainId.ROBINHOOD];
|
|
114
|
+
if (chainId === ChainId.HYPEREVM) return ADDRESSES[ChainId.HYPEREVM];
|
|
94
115
|
return undefined;
|
|
95
116
|
}
|
|
96
117
|
|
|
@@ -98,14 +119,19 @@ export function getAddressesOrThrow(chainId: number): ChainAddresses {
|
|
|
98
119
|
const addresses = getAddresses(chainId);
|
|
99
120
|
if (!addresses) {
|
|
100
121
|
throw new Error(
|
|
101
|
-
`Chain ${chainId} has no v1 deployment in this SDK (Ethereum and
|
|
122
|
+
`Chain ${chainId} has no v1 deployment in this SDK (Ethereum, Base, Robinhood, and HyperEVM are configured)`,
|
|
102
123
|
);
|
|
103
124
|
}
|
|
104
125
|
return addresses;
|
|
105
126
|
}
|
|
106
127
|
|
|
107
128
|
export function isChainSupported(chainId: number): chainId is DeployedChainId {
|
|
108
|
-
return
|
|
129
|
+
return (
|
|
130
|
+
chainId === ChainId.ETHEREUM ||
|
|
131
|
+
chainId === ChainId.BASE ||
|
|
132
|
+
chainId === ChainId.ROBINHOOD ||
|
|
133
|
+
chainId === ChainId.HYPEREVM
|
|
134
|
+
);
|
|
109
135
|
}
|
|
110
136
|
|
|
111
137
|
export function getSupportedChainIds(): DeployedChainId[] {
|
package/src/pool/cursorBounds.ts
CHANGED
|
@@ -95,13 +95,16 @@ export async function prepareLiquidityCursorBounds(params: {
|
|
|
95
95
|
maximalCursorMovement: number;
|
|
96
96
|
dataProviderAddress?: Address;
|
|
97
97
|
}): Promise<LiquidityCursorBounds> {
|
|
98
|
-
|
|
99
|
-
if (
|
|
100
|
-
|
|
98
|
+
let dataProviderAddress: Address;
|
|
99
|
+
if (params.dataProviderAddress) {
|
|
100
|
+
dataProviderAddress = params.dataProviderAddress;
|
|
101
|
+
} else {
|
|
102
|
+
const chainId = params.publicClient.chain?.id;
|
|
103
|
+
if (chainId === undefined) {
|
|
104
|
+
throw new Error("publicClient.chain.id is required to resolve dataProvider address");
|
|
105
|
+
}
|
|
106
|
+
dataProviderAddress = getAddressesOrThrow(chainId).dataProvider;
|
|
101
107
|
}
|
|
102
|
-
|
|
103
|
-
const dataProviderAddress =
|
|
104
|
-
params.dataProviderAddress ?? getAddressesOrThrow(chainId).dataProvider;
|
|
105
108
|
const slot0 = await getSlot0(params.publicClient, dataProviderAddress, params.pool);
|
|
106
109
|
|
|
107
110
|
return computeLiquidityCursorBounds(
|