@skate-org/amm-evm-v2 2.0.0-beta.1 → 2.0.0-beta.11

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/CHANGELOG.md CHANGED
@@ -1,131 +1,54 @@
1
1
  # @skate-org/amm-evm-v2
2
2
 
3
- ## 2.0.0-beta.1 — 2026-05-07
3
+ ## 2.0.0-beta.11 — 2026-05-30
4
4
 
5
- Lockstep bump paired with the `findTokensBySymbol` /
6
- `getTokenSymbol` additions in `@skate-org/amm-core-v2`. This package's
7
- source is unchanged versus `2.0.0-beta.0`.
5
+ Adds the periphery calldata-builder surface needed by the backend v1 → v2
6
+ port (quote routes that need to mirror on-chain calldata without
7
+ submitting), plus a kernel-side balances reader.
8
8
 
9
- ## 2.0.0-beta.0 2026-05-07
9
+ - `periphery/calldata.ts` (new module): `getSwapCalldata`,
10
+ `getMintCalldata`, `getBurnCalldata`, `getIncreaseLiquidityCalldata`,
11
+ `getDecreaseLiquidityCalldata`. Pure ABI encoders over `PeripheryPoolABI`
12
+ — no client / no signing / no submission. Use submitters in `submit.ts`
13
+ for the full build-and-send flow.
14
+ - `kernel/reader.ts`: `readKernelBalances(kernelPool, mode)` returning
15
+ `{ balance0, balance1 }`. Parallel reads; mirrors the `readPool` style.
16
+ - Note: `getMintCalldata` uses correct camelCase (v1 was `getMintcalldata`,
17
+ a typo); the rest match v1 names verbatim.
10
18
 
11
- First **beta**. Promoted under the `beta` dist-tag; `latest` stays at
12
- `1.0.0` (v1 line) per the policy in `CLAUDE.md`. **Loose beta** —
13
- documented breaking changes are still allowed within `2.0.0-beta.x`;
14
- `2.0.0` final is the strict surface freeze.
19
+ ## 2.0.0-beta.10 2026-05-29
15
20
 
16
- **Breakinginternal-leak surface pull.**
21
+ Lockstepno source changes. `KernelManagerAddress(mode)` / `PeripheryDeploymentFor(chain, mode)`
22
+ re-exported from `@skate-org/amm-core-v2@2.0.0-beta.10` now resolve for STAGING/PRODUCTION
23
+ (alias DEV) instead of throwing `notDeployed`. EVM readers/writers that route on `EnvMode`
24
+ get coverage for all three modes without call-site changes.
17
25
 
18
- - `DEFAULT_DEV_API_ENDPOINT` is no longer re-exported from the package
19
- barrel. It was `createDevConfig`'s private default value and
20
- duplicated the canonical URL in `@skate-org/amm-api-v2`. Use
21
- `createDevConfig({...})` (which still accepts a custom
22
- `apiEndpoint`); the previously-public string was never needed.
26
+ ## 2.0.0-beta.9 2026-05-26
23
27
 
24
- Surface count: 28 27. See `STABILITY.md` (repo root) for the full
25
- classification.
28
+ Lockstep no source changes. Paired with `@skate-org/amm-core-v2@2.0.0-beta.9`
29
+ which added STAGING/PRODUCTION env support to the deployment maps.
26
30
 
27
- ## 2.0.0-alpha.8 — 2026-05-07
31
+ ## 2.0.0-beta.8 — 2026-05-21
28
32
 
29
- Lockstep bump paired with the api `streamSwapQuote` going live as a
30
- polling stub for the deferred WebSocket. This package's source is
31
- unchanged versus `2.0.0-alpha.7`.
33
+ Lockstep — no source changes. Paired with `@skate-org/amm-sui-v2@2.0.0-beta.8`.
32
34
 
33
- ## 2.0.0-alpha.7 — 2026-05-07
35
+ ## 2.0.0-beta.7 — 2026-05-21
34
36
 
35
- Lockstep bump — paired with the api action-by-user clients, polling
36
- `subscribeSwapQuote` helper, and svm browser-bundle build fix.
37
- This package's source is unchanged versus `2.0.0-alpha.6`.
37
+ Made `DEFAULT_DEV_API_ENDPOINT` module-private in `devConfig.ts`
38
+ (already off the barrel since beta.0; this drops the `export`
39
+ keyword). No public surface change.
38
40
 
39
- ## 2.0.0-alpha.6 2026-05-07
41
+ ## 2.0.0-beta (cumulative, 2026-05-07 → 2026-05-21)
40
42
 
41
- - `getKernelPublicClient(mode)` now reads the kernel chain from
42
- `KernelChain(mode)` (the new `KERNEL_CHAIN_BY_MODE` table in core)
43
- instead of hardcoding `megaethChain`. Default behavior is unchanged
44
- (every env still resolves to MegaETH today); future per-env kernel-chain
45
- switches are one-line edits in core.
46
- - Lens helpers + readers continue to call `KernelManagerAddress(mode)`,
47
- which now throws for STAGING / PRODUCTION (see `@skate-org/amm-core-v2`
48
- alpha.6 notes). DEV behavior unchanged.
43
+ - **Surface pull (beta.0):** `DEFAULT_DEV_API_ENDPOINT` removed
44
+ from the package barrel; only the per-pool / per-chain DEV config
45
+ helpers are public.
46
+ - **Kernel lens helpers (alpha.5 beta):** `simulateSwap`,
47
+ `simulateMint`, `simulateBurn`, `simulateDecreaseLiquidity`
48
+ static-call wrappers over `KernelManager.lens*`. Now consumed by
49
+ the api package's quote routes.
50
+ - **Per-env kernel chain (alpha.6 → beta):** `getKernelPublicClient(mode)`
51
+ reads `KernelChain(mode)` instead of hardcoding `megaethChain`.
52
+ DEV resolves to MegaETH today.
49
53
 
50
- ## 2.0.0-alpha.5 — 2026-05-06
51
-
52
- - **Kernel lens helpers ported from v1.** Adds `simulateSwap`,
53
- `simulateMint`, `simulateBurn`, `simulateDecreaseLiquidity` —
54
- static-call wrappers around `KernelManager.lens{Swap,Mint,Burn,DecreaseLiquidity}`.
55
- Each returns named fields matching the ABI output (e.g.
56
- `simulateMint` → `{ amount0Used, amount1Used, liquidityAmount, returnData }`)
57
- and accepts an optional viem client for test injection. Errors flow
58
- through the read-path (`EvmReadError`) since lens calls don't write
59
- state. Same DEV/STAGING/PRODUCTION mode handling as the readers.
60
- - Internal: extracted `resolveKernelClient` to `kernel/_client.ts` so
61
- readers and lens helpers share the same client-resolution logic.
62
- - Internal (tests): extracted the `mockKernelClient` helper to
63
- `test/_helpers.ts`. Reader and lens test suites now share one
64
- union-ABI mock transport instead of duplicating the implementation.
65
-
66
- ## 2.0.0-alpha.4 — 2026-05-06
67
-
68
- Lockstep bump — paired with the `SwapQuote` schema fix in
69
- `@skate-org/amm-api-v2`. This package's source is unchanged versus
70
- `2.0.0-alpha.3`.
71
-
72
- ## 2.0.0-alpha.3 — 2026-05-06
73
-
74
- Lockstep bump — paired with the SVM/Sui efficiency pass in
75
- `@skate-org/amm-svm-v2` and `@skate-org/amm-sui-v2`. This package's
76
- source is unchanged versus `2.0.0-alpha.2`.
77
-
78
- ## 2.0.0-alpha.2 — 2026-05-05
79
-
80
- Plan C of the SVM/Sui integration. Adds `@skate-org/amm-sui-v2` to
81
- the workspace; this package's source is unchanged versus
82
- `2.0.0-alpha.1` (re-versioned in lockstep).
83
-
84
- ## 2.0.0-alpha.1 — 2026-05-05
85
-
86
- Plan B of the SVM/Sui integration. Adds `@skate-org/amm-svm-v2` to
87
- the workspace; this package's source is unchanged versus
88
- `2.0.0-alpha.0` (re-versioned in lockstep).
89
-
90
- ## 2.0.0-alpha.0 — 2026-05-05
91
-
92
- Plan A of the SVM/Sui integration.
93
-
94
- - **Breaking:** uniswap-v3 math no longer ships from
95
- `@skate-org/amm-evm-v2`. Import from `@skate-org/amm-core-v2`
96
- instead. All function names unchanged. Top-level barrel re-exports
97
- via the umbrella (`@skate-org/amm-v2`) continue to work without
98
- callsite changes.
99
- - Removed: `packages/evm/src/math/` directory and corresponding
100
- tests (relocated to `core`).
101
-
102
- ## 1.0.0 — 2026-05-04
103
-
104
- Realigning all four `@skate-org/amm-*-v2` packages at a single version
105
- for the coherent v1 SDK release. No source changes vs 0.4.1 — purely a
106
- versioning realignment so the four packages move together going forward.
107
-
108
- ## 0.4.1 — 2026-04-29
109
-
110
- - Flip DEV MegaETH RPC default to `https://mainnet.megaeth.com/rpc` (the
111
- carrot.megaeth.com endpoint is no longer the canonical DEV RPC).
112
- - Extend DEV smoke to exercise `readPool` (kernel) and `readPeripheryPool`
113
- (Arbitrum) against real contracts.
114
-
115
- ## 0.4.0 — 2026-04-25
116
-
117
- - Phase 4: kernel + periphery event-decoding framework. `decodeKernel*`
118
- / `decodePeriphery*` helpers; `watch*` event subscription utilities.
119
-
120
- ## 0.3.0 — 2026-04-23
121
-
122
- - Phase 3: `readPool`, `readPeripheryPool`, `readPosition` reader helpers;
123
- uniswap-v3 tick math; action submitters.
124
-
125
- ## 0.2.0 — 2026-04-22
126
-
127
- - `createPublicClient` factory; `createDevConfig` for DEV mode tuples.
128
-
129
- ## 0.1.0 — 2026-04-21
130
-
131
- - Initial scaffold: viem chain definitions, RPC defaults, `chain-clients.ts`.
54
+ Surface count: 28 → 27 (one-time pull at beta.0).
package/README.md CHANGED
@@ -29,10 +29,12 @@ pnpm add @skate-org/amm-evm-v2
29
29
 
30
30
  Peer deps: `@skate-org/amm-core-v2`, `@skate-org/amm-bindings`, `viem`.
31
31
 
32
- ## DEV defaults (as of 2026-04-29)
32
+ ## DEV defaults
33
33
 
34
34
  - MegaETH RPC: `https://mainnet.megaeth.com/rpc`
35
35
  - Kernel manager: `0x17B7207837e8884f7f687f1f4057751BDAf70a01`
36
36
  - USDC/USDT kernel pool: `0x2c23334eE3b030e6bacEDEDf7C511eEA08Cf7E7e`
37
37
 
38
+ STAGING + PRODUCTION on-chain addresses alias DEV as of `2.0.0-beta.10`.
39
+
38
40
  See `CHANGELOG.md` for version history.
@@ -1,6 +1,4 @@
1
1
  import type { DevModeConfig } from "@skate-org/amm-core-v2";
2
- /** Default DEV api endpoint — matches Phase 1's api client default. */
3
- export declare const DEFAULT_DEV_API_ENDPOINT = "https://dev.api.skatechain.org/amm-action-v2";
4
2
  /**
5
3
  * Convenience factory for the `{ mode: "DEV"; config: DevModeConfig }` tuple.
6
4
  *
@@ -1 +1 @@
1
- {"version":3,"file":"devConfig.d.ts","sourceRoot":"","sources":["../src/devConfig.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAE5D,uEAAuE;AACvE,eAAO,MAAM,wBAAwB,iDACW,CAAC;AAEjD;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,eAAe,CAC7B,SAAS,GAAE,OAAO,CAAC,aAAa,CAAM,GACrC;IAAE,IAAI,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,aAAa,CAAA;CAAE,CAUxC"}
1
+ {"version":3,"file":"devConfig.d.ts","sourceRoot":"","sources":["../src/devConfig.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAM5D;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,eAAe,CAC7B,SAAS,GAAE,OAAO,CAAC,aAAa,CAAM,GACrC;IAAE,IAAI,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,aAAa,CAAA;CAAE,CAUxC"}
package/dist/index.cjs CHANGED
@@ -27,11 +27,17 @@ __export(index_exports, {
27
27
  computePositionAmounts: () => computePositionAmounts,
28
28
  createDevConfig: () => createDevConfig,
29
29
  decodeTickBitmapWord: () => decodeTickBitmapWord,
30
+ getBurnCalldata: () => getBurnCalldata,
31
+ getDecreaseLiquidityCalldata: () => getDecreaseLiquidityCalldata,
32
+ getIncreaseLiquidityCalldata: () => getIncreaseLiquidityCalldata,
30
33
  getKernelPublicClient: () => getKernelPublicClient,
34
+ getMintCalldata: () => getMintCalldata,
31
35
  getSourcePublicClient: () => getSourcePublicClient,
36
+ getSwapCalldata: () => getSwapCalldata,
32
37
  megaethChain: () => megaethChain,
33
38
  parseKernelEventLog: () => parseKernelEventLog,
34
39
  parsePeripheryEventLog: () => parsePeripheryEventLog,
40
+ readKernelBalances: () => readKernelBalances,
35
41
  readPeripheryPool: () => readPeripheryPool,
36
42
  readPool: () => readPool,
37
43
  readPosition: () => readPosition,
@@ -212,6 +218,26 @@ async function readPool(kernelPool, mode, client) {
212
218
  throw wrapReadError(err, "readPool");
213
219
  }
214
220
  }
221
+ async function readKernelBalances(kernelPool, mode, client) {
222
+ const c = resolveKernelClient(mode, client);
223
+ try {
224
+ const [balance0, balance1] = await Promise.all([
225
+ c.readContract({
226
+ address: kernelPool,
227
+ abi: import_amm_bindings.KernelPoolABI,
228
+ functionName: "balance0"
229
+ }),
230
+ c.readContract({
231
+ address: kernelPool,
232
+ abi: import_amm_bindings.KernelPoolABI,
233
+ functionName: "balance1"
234
+ })
235
+ ]);
236
+ return { balance0, balance1 };
237
+ } catch (err) {
238
+ throw wrapReadError(err, "readKernelBalances");
239
+ }
240
+ }
215
241
  async function readPosition(tokenId, mode, client) {
216
242
  const { mode: baseMode } = (0, import_amm_core_v23.normalizeMode)(mode);
217
243
  const manager = (0, import_amm_core_v23.KernelManagerAddress)(baseMode);
@@ -584,9 +610,96 @@ async function submitApproval(wallet, params, mode) {
584
610
  }
585
611
  }
586
612
 
587
- // src/events/kernel.ts
613
+ // src/periphery/calldata.ts
588
614
  var import_viem2 = require("viem");
589
615
  var import_amm_bindings4 = require("@skate-org/amm-bindings");
616
+ function getSwapCalldata(params) {
617
+ const {
618
+ recipient,
619
+ zeroForOne,
620
+ amount,
621
+ sqrtPriceLimitX96,
622
+ destVmType,
623
+ destChainId,
624
+ minAmountOut,
625
+ deadline
626
+ } = params;
627
+ const extraData = (0, import_viem2.encodeAbiParameters)(
628
+ (0, import_viem2.parseAbiParameters)("uint256,uint256,uint256,uint256"),
629
+ [
630
+ minAmountOut ?? 0n,
631
+ BigInt(destChainId),
632
+ BigInt(destVmType),
633
+ deadline ?? import_viem2.maxUint256
634
+ ]
635
+ );
636
+ return (0, import_viem2.encodeFunctionData)({
637
+ abi: import_amm_bindings4.PeripheryPoolABI,
638
+ functionName: "swap",
639
+ args: [recipient, zeroForOne, amount, sqrtPriceLimitX96, extraData]
640
+ });
641
+ }
642
+ function getMintCalldata(params) {
643
+ const {
644
+ recipient,
645
+ tickLower,
646
+ tickUpper,
647
+ amount0,
648
+ amount1,
649
+ amount0Min,
650
+ amount1Min,
651
+ deadline
652
+ } = params;
653
+ const extraData = (0, import_viem2.encodeAbiParameters)(
654
+ (0, import_viem2.parseAbiParameters)("uint256,uint256,uint256"),
655
+ [amount0Min ?? 0n, amount1Min ?? 0n, deadline ?? import_viem2.maxUint256]
656
+ );
657
+ return (0, import_viem2.encodeFunctionData)({
658
+ abi: import_amm_bindings4.PeripheryPoolABI,
659
+ functionName: "mint",
660
+ args: [recipient, tickLower, tickUpper, amount0, amount1, extraData]
661
+ });
662
+ }
663
+ function getBurnCalldata(params) {
664
+ const { tokenId, amount0Min, amount1Min, deadline } = params;
665
+ const extraData = (0, import_viem2.encodeAbiParameters)(
666
+ (0, import_viem2.parseAbiParameters)("uint256,uint256,uint256"),
667
+ [amount0Min ?? 0n, amount1Min ?? 0n, deadline ?? import_viem2.maxUint256]
668
+ );
669
+ return (0, import_viem2.encodeFunctionData)({
670
+ abi: import_amm_bindings4.PeripheryPoolABI,
671
+ functionName: "burn",
672
+ args: [tokenId, extraData]
673
+ });
674
+ }
675
+ function getIncreaseLiquidityCalldata(params) {
676
+ const { tokenId, amount0, amount1, amount0Min, amount1Min, deadline } = params;
677
+ const extraData = (0, import_viem2.encodeAbiParameters)(
678
+ (0, import_viem2.parseAbiParameters)("uint256,uint256,uint256"),
679
+ [amount0Min ?? 0n, amount1Min ?? 0n, deadline ?? import_viem2.maxUint256]
680
+ );
681
+ return (0, import_viem2.encodeFunctionData)({
682
+ abi: import_amm_bindings4.PeripheryPoolABI,
683
+ functionName: "increaseLiquidity",
684
+ args: [tokenId, amount0, amount1, extraData]
685
+ });
686
+ }
687
+ function getDecreaseLiquidityCalldata(params) {
688
+ const { tokenId, liquidityAmount, amount0Min, amount1Min, deadline } = params;
689
+ const extraData = (0, import_viem2.encodeAbiParameters)(
690
+ (0, import_viem2.parseAbiParameters)("uint256,uint256,uint256"),
691
+ [amount0Min ?? 0n, amount1Min ?? 0n, deadline ?? import_viem2.maxUint256]
692
+ );
693
+ return (0, import_viem2.encodeFunctionData)({
694
+ abi: import_amm_bindings4.PeripheryPoolABI,
695
+ functionName: "decreaseLiquidity",
696
+ args: [tokenId, liquidityAmount, extraData]
697
+ });
698
+ }
699
+
700
+ // src/events/kernel.ts
701
+ var import_viem3 = require("viem");
702
+ var import_amm_bindings5 = require("@skate-org/amm-bindings");
590
703
  var KERNEL_EVENT_NAMES = [
591
704
  "Burn",
592
705
  "Collect",
@@ -603,8 +716,8 @@ var KERNEL_EVENT_NAMES = [
603
716
  ];
604
717
  function parseKernelEventLog(log) {
605
718
  try {
606
- const decoded = (0, import_viem2.decodeEventLog)({
607
- abi: import_amm_bindings4.KernelEventEmitterABI,
719
+ const decoded = (0, import_viem3.decodeEventLog)({
720
+ abi: import_amm_bindings5.KernelEventEmitterABI,
608
721
  data: log.data,
609
722
  topics: log.topics
610
723
  });
@@ -624,8 +737,8 @@ function parseKernelEventLog(log) {
624
737
  }
625
738
 
626
739
  // src/events/periphery.ts
627
- var import_viem3 = require("viem");
628
- var import_amm_bindings5 = require("@skate-org/amm-bindings");
740
+ var import_viem4 = require("viem");
741
+ var import_amm_bindings6 = require("@skate-org/amm-bindings");
629
742
  var PERIPHERY_EVENT_NAMES = [
630
743
  "AmountSettled",
631
744
  "Burned",
@@ -640,8 +753,8 @@ var PERIPHERY_EVENT_NAMES = [
640
753
  ];
641
754
  function parsePeripheryEventLog(log) {
642
755
  try {
643
- const decoded = (0, import_viem3.decodeEventLog)({
644
- abi: import_amm_bindings5.PeripheryEventEmitterABI,
756
+ const decoded = (0, import_viem4.decodeEventLog)({
757
+ abi: import_amm_bindings6.PeripheryEventEmitterABI,
645
758
  data: log.data,
646
759
  topics: log.topics
647
760
  });
@@ -661,10 +774,10 @@ function parsePeripheryEventLog(log) {
661
774
  }
662
775
 
663
776
  // src/events/watch.ts
664
- var import_amm_bindings6 = require("@skate-org/amm-bindings");
777
+ var import_amm_bindings7 = require("@skate-org/amm-bindings");
665
778
  function watchKernelEvents(client, address, opts) {
666
779
  return client.watchContractEvent({
667
- abi: import_amm_bindings6.KernelEventEmitterABI,
780
+ abi: import_amm_bindings7.KernelEventEmitterABI,
668
781
  address,
669
782
  onLogs: (logs) => {
670
783
  for (const log of logs) {
@@ -679,7 +792,7 @@ function watchKernelEvents(client, address, opts) {
679
792
  }
680
793
  function watchPeripheryEvents(client, address, opts) {
681
794
  return client.watchContractEvent({
682
- abi: import_amm_bindings6.PeripheryEventEmitterABI,
795
+ abi: import_amm_bindings7.PeripheryEventEmitterABI,
683
796
  address,
684
797
  onLogs: (logs) => {
685
798
  for (const log of logs) {
@@ -701,11 +814,17 @@ function watchPeripheryEvents(client, address, opts) {
701
814
  computePositionAmounts,
702
815
  createDevConfig,
703
816
  decodeTickBitmapWord,
817
+ getBurnCalldata,
818
+ getDecreaseLiquidityCalldata,
819
+ getIncreaseLiquidityCalldata,
704
820
  getKernelPublicClient,
821
+ getMintCalldata,
705
822
  getSourcePublicClient,
823
+ getSwapCalldata,
706
824
  megaethChain,
707
825
  parseKernelEventLog,
708
826
  parsePeripheryEventLog,
827
+ readKernelBalances,
709
828
  readPeripheryPool,
710
829
  readPool,
711
830
  readPosition,