@skate-org/amm-evm-v2 2.0.0-beta.2 → 2.0.0-beta.21

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,138 +1,64 @@
1
1
  # @skate-org/amm-evm-v2
2
2
 
3
- ## 2.0.0-beta.2 — 2026-05-17
3
+ ## 2.0.0-beta.13 — 2026-05-30
4
4
 
5
- Lockstep bump paired with the SVM Solana DEV wire-up
6
- (`@skate-org/amm-svm-v2`) and the SUI_ENV legacy-address wipe
7
- (`@skate-org/amm-sui-v2`). This package's source is unchanged versus
8
- `2.0.0-beta.1`.
5
+ Lockstep — no source changes. Paired with `@skate-org/amm-core-v2@2.0.0-beta.13`
6
+ fix for `getLiquidityForAmount0` canonical two-step `mulDiv`.
9
7
 
10
- ## 2.0.0-beta.1 — 2026-05-07
8
+ ## 2.0.0-beta.12 — 2026-05-30
11
9
 
12
- Lockstep bump paired with the `findTokensBySymbol` /
13
- `getTokenSymbol` additions in `@skate-org/amm-core-v2`. This package's
14
- source is unchanged versus `2.0.0-beta.0`.
10
+ Lockstep — no source changes. Paired with `@skate-org/amm-core-v2@2.0.0-beta.12`
11
+ hotfix for `normalizeAmount` / `deNormalizeAmount` on tokens with >18 decimals.
15
12
 
16
- ## 2.0.0-beta.0 — 2026-05-07
13
+ ## 2.0.0-beta.11 — 2026-05-30
17
14
 
18
- First **beta**. Promoted under the `beta` dist-tag; `latest` stays at
19
- `1.0.0` (v1 line) per the policy in `CLAUDE.md`. **Loose beta** —
20
- documented breaking changes are still allowed within `2.0.0-beta.x`;
21
- `2.0.0` final is the strict surface freeze.
15
+ Adds the periphery calldata-builder surface needed by the backend v1 v2
16
+ port (quote routes that need to mirror on-chain calldata without
17
+ submitting), plus a kernel-side balances reader.
22
18
 
23
- **Breaking internal-leak surface pull.**
19
+ - `periphery/calldata.ts` (new module): `getSwapCalldata`,
20
+ `getMintCalldata`, `getBurnCalldata`, `getIncreaseLiquidityCalldata`,
21
+ `getDecreaseLiquidityCalldata`. Pure ABI encoders over `PeripheryPoolABI`
22
+ — no client / no signing / no submission. Use submitters in `submit.ts`
23
+ for the full build-and-send flow.
24
+ - `kernel/reader.ts`: `readKernelBalances(kernelPool, mode)` returning
25
+ `{ balance0, balance1 }`. Parallel reads; mirrors the `readPool` style.
26
+ - Note: `getMintCalldata` uses correct camelCase (v1 was `getMintcalldata`,
27
+ a typo); the rest match v1 names verbatim.
24
28
 
25
- - `DEFAULT_DEV_API_ENDPOINT` is no longer re-exported from the package
26
- barrel. It was `createDevConfig`'s private default value and
27
- duplicated the canonical URL in `@skate-org/amm-api-v2`. Use
28
- `createDevConfig({...})` (which still accepts a custom
29
- `apiEndpoint`); the previously-public string was never needed.
29
+ ## 2.0.0-beta.10 2026-05-29
30
30
 
31
- Surface count: 28 27. See `STABILITY.md` (repo root) for the full
32
- classification.
31
+ Lockstep no source changes. `KernelManagerAddress(mode)` / `PeripheryDeploymentFor(chain, mode)`
32
+ re-exported from `@skate-org/amm-core-v2@2.0.0-beta.10` now resolve for STAGING/PRODUCTION
33
+ (alias DEV) instead of throwing `notDeployed`. EVM readers/writers that route on `EnvMode`
34
+ get coverage for all three modes without call-site changes.
33
35
 
34
- ## 2.0.0-alpha.8 — 2026-05-07
36
+ ## 2.0.0-beta.9 — 2026-05-26
35
37
 
36
- Lockstep bump paired with the api `streamSwapQuote` going live as a
37
- polling stub for the deferred WebSocket. This package's source is
38
- unchanged versus `2.0.0-alpha.7`.
38
+ Lockstep — no source changes. Paired with `@skate-org/amm-core-v2@2.0.0-beta.9`
39
+ which added STAGING/PRODUCTION env support to the deployment maps.
39
40
 
40
- ## 2.0.0-alpha.7 — 2026-05-07
41
+ ## 2.0.0-beta.8 — 2026-05-21
41
42
 
42
- Lockstep bump paired with the api action-by-user clients, polling
43
- `subscribeSwapQuote` helper, and svm browser-bundle build fix.
44
- This package's source is unchanged versus `2.0.0-alpha.6`.
43
+ Lockstep — no source changes. Paired with `@skate-org/amm-sui-v2@2.0.0-beta.8`.
45
44
 
46
- ## 2.0.0-alpha.6 — 2026-05-07
45
+ ## 2.0.0-beta.7 — 2026-05-21
47
46
 
48
- - `getKernelPublicClient(mode)` now reads the kernel chain from
49
- `KernelChain(mode)` (the new `KERNEL_CHAIN_BY_MODE` table in core)
50
- instead of hardcoding `megaethChain`. Default behavior is unchanged
51
- (every env still resolves to MegaETH today); future per-env kernel-chain
52
- switches are one-line edits in core.
53
- - Lens helpers + readers continue to call `KernelManagerAddress(mode)`,
54
- which now throws for STAGING / PRODUCTION (see `@skate-org/amm-core-v2`
55
- alpha.6 notes). DEV behavior unchanged.
47
+ Made `DEFAULT_DEV_API_ENDPOINT` module-private in `devConfig.ts`
48
+ (already off the barrel since beta.0; this drops the `export`
49
+ keyword). No public surface change.
56
50
 
57
- ## 2.0.0-alpha.5 2026-05-06
51
+ ## 2.0.0-beta (cumulative, 2026-05-07 → 2026-05-21)
58
52
 
59
- - **Kernel lens helpers ported from v1.** Adds `simulateSwap`,
60
- `simulateMint`, `simulateBurn`, `simulateDecreaseLiquidity`
61
- static-call wrappers around `KernelManager.lens{Swap,Mint,Burn,DecreaseLiquidity}`.
62
- Each returns named fields matching the ABI output (e.g.
63
- `simulateMint` `{ amount0Used, amount1Used, liquidityAmount, returnData }`)
64
- and accepts an optional viem client for test injection. Errors flow
65
- through the read-path (`EvmReadError`) since lens calls don't write
66
- state. Same DEV/STAGING/PRODUCTION mode handling as the readers.
67
- - Internal: extracted `resolveKernelClient` to `kernel/_client.ts` so
68
- readers and lens helpers share the same client-resolution logic.
69
- - Internal (tests): extracted the `mockKernelClient` helper to
70
- `test/_helpers.ts`. Reader and lens test suites now share one
71
- union-ABI mock transport instead of duplicating the implementation.
53
+ - **Surface pull (beta.0):** `DEFAULT_DEV_API_ENDPOINT` removed
54
+ from the package barrel; only the per-pool / per-chain DEV config
55
+ helpers are public.
56
+ - **Kernel lens helpers (alpha.5 beta):** `simulateSwap`,
57
+ `simulateMint`, `simulateBurn`, `simulateDecreaseLiquidity`
58
+ static-call wrappers over `KernelManager.lens*`. Now consumed by
59
+ the api package's quote routes.
60
+ - **Per-env kernel chain (alpha.6 beta):** `getKernelPublicClient(mode)`
61
+ reads `KernelChain(mode)` instead of hardcoding `megaethChain`.
62
+ DEV resolves to MegaETH today.
72
63
 
73
- ## 2.0.0-alpha.4 — 2026-05-06
74
-
75
- Lockstep bump — paired with the `SwapQuote` schema fix in
76
- `@skate-org/amm-api-v2`. This package's source is unchanged versus
77
- `2.0.0-alpha.3`.
78
-
79
- ## 2.0.0-alpha.3 — 2026-05-06
80
-
81
- Lockstep bump — paired with the SVM/Sui efficiency pass in
82
- `@skate-org/amm-svm-v2` and `@skate-org/amm-sui-v2`. This package's
83
- source is unchanged versus `2.0.0-alpha.2`.
84
-
85
- ## 2.0.0-alpha.2 — 2026-05-05
86
-
87
- Plan C of the SVM/Sui integration. Adds `@skate-org/amm-sui-v2` to
88
- the workspace; this package's source is unchanged versus
89
- `2.0.0-alpha.1` (re-versioned in lockstep).
90
-
91
- ## 2.0.0-alpha.1 — 2026-05-05
92
-
93
- Plan B of the SVM/Sui integration. Adds `@skate-org/amm-svm-v2` to
94
- the workspace; this package's source is unchanged versus
95
- `2.0.0-alpha.0` (re-versioned in lockstep).
96
-
97
- ## 2.0.0-alpha.0 — 2026-05-05
98
-
99
- Plan A of the SVM/Sui integration.
100
-
101
- - **Breaking:** uniswap-v3 math no longer ships from
102
- `@skate-org/amm-evm-v2`. Import from `@skate-org/amm-core-v2`
103
- instead. All function names unchanged. Top-level barrel re-exports
104
- via the umbrella (`@skate-org/amm-v2`) continue to work without
105
- callsite changes.
106
- - Removed: `packages/evm/src/math/` directory and corresponding
107
- tests (relocated to `core`).
108
-
109
- ## 1.0.0 — 2026-05-04
110
-
111
- Realigning all four `@skate-org/amm-*-v2` packages at a single version
112
- for the coherent v1 SDK release. No source changes vs 0.4.1 — purely a
113
- versioning realignment so the four packages move together going forward.
114
-
115
- ## 0.4.1 — 2026-04-29
116
-
117
- - Flip DEV MegaETH RPC default to `https://mainnet.megaeth.com/rpc` (the
118
- carrot.megaeth.com endpoint is no longer the canonical DEV RPC).
119
- - Extend DEV smoke to exercise `readPool` (kernel) and `readPeripheryPool`
120
- (Arbitrum) against real contracts.
121
-
122
- ## 0.4.0 — 2026-04-25
123
-
124
- - Phase 4: kernel + periphery event-decoding framework. `decodeKernel*`
125
- / `decodePeriphery*` helpers; `watch*` event subscription utilities.
126
-
127
- ## 0.3.0 — 2026-04-23
128
-
129
- - Phase 3: `readPool`, `readPeripheryPool`, `readPosition` reader helpers;
130
- uniswap-v3 tick math; action submitters.
131
-
132
- ## 0.2.0 — 2026-04-22
133
-
134
- - `createPublicClient` factory; `createDevConfig` for DEV mode tuples.
135
-
136
- ## 0.1.0 — 2026-04-21
137
-
138
- - Initial scaffold: viem chain definitions, RPC defaults, `chain-clients.ts`.
64
+ Surface count: 28 → 27 (one-time pull at beta.0).
package/README.md CHANGED
@@ -11,16 +11,66 @@ periphery readers, action submitters, and the event-decoding framework.
11
11
 
12
12
  ## Surface
13
13
 
14
- - `getKernelPublicClient(mode?)` / `getSourcePublicClient(chain, mode?)` —
14
+ - `getKernelPublicClient(mode, transport?)` / `getSourcePublicClient(chain, mode, transport?)` —
15
15
  viem `PublicClient` factories with Skate's RPC defaults baked in.
16
16
  - `createDevConfig({...})` — produces the DEV `{ mode, config }` tuple.
17
- - **Readers:** `readPool` (kernel side), `readPeripheryPool` (periphery
18
- side), `readPosition`, `readTick`, `readTickBitmap`, `readUserPoolBalances`.
17
+ - **Readers (object-param, `mode` field required):** `readPool({ kernelPool, mode, client? })`,
18
+ `readPeripheryPool({ chain, kernelPool, mode, client? })` `PeripheryPoolState`,
19
+ `readUserPoolBalances({ user, poolKey, chain, mode, client? })` → `UserPoolBalances`,
20
+ `readPosition`, `readTick`, `readTickBitmap`.
21
+ - **Calldata builders → `Promise<CalldataCall>` (`{ target, calldata }`):**
22
+ `buildSwap`, `buildMint`, `buildBurn`, `buildIncreaseLiquidity`, `buildDecreaseLiquidity`.
23
+ All accept a single object param including `mode`. No RPC call.
24
+ - **Kernel simulators (object-param):** `simulateSwap`, `simulateMint`,
25
+ `simulateBurn`, `simulateDecreaseLiquidity`.
19
26
  - **Events:** `parseKernelEventLog`, `parsePeripheryEventLog`,
20
27
  `watchKernelEvents`, `watchPeripheryEvents`.
21
28
  - **Submitters:** `submitAction`, `submitApproval`, `submitSwap`.
22
29
  - **Errors:** `EvmReadError`, `EvmWriteError` (both extend `SdkError`).
23
30
 
31
+ **`SkateAmm` class (headline entry point)**
32
+
33
+ One object that composes `AmmCore` (pool catalog), `AmmApi` (quotes +
34
+ actions), and `AmmEvm` (build/submit/read). Expose escape hatches via
35
+ `.core`, `.api`, `.vm`.
36
+
37
+ ```ts
38
+ const amm = new SkateAmm("PRODUCTION");
39
+
40
+ // Quotes
41
+ const quote = await amm.quote.swap({ poolKey: "USDC_USDT", ... });
42
+ const ranges = await amm.quote.boostedRange();
43
+
44
+ // Actions
45
+ const action = await amm.actions.get({ srcChain: CHAIN.ARBITRUM, srcHash: "0x..." });
46
+ await amm.actions.waitForExecuted({ srcChain: CHAIN.ARBITRUM, srcHash: "0x..." });
47
+
48
+ // Build + submit
49
+ const call = await amm.buildSwap({ poolKey: "USDC_USDT", chain: CHAIN.ARBITRUM, ... });
50
+ const hash = await amm.submitSwap(walletClient, { ... });
51
+
52
+ // Pool catalog
53
+ const keys = amm.pools.keys();
54
+ const info = amm.pools.byKey("USDC_USDT");
55
+
56
+ // EVM extras
57
+ const pool = await amm.readPool({ kernelPool: "0x2c23..." });
58
+ const sim = await amm.simulateSwap({ params: { ... } });
59
+ ```
60
+
61
+ **`AmmEvm` class (env-bound)**
62
+
63
+ Construct once; all methods take object params **without the `mode` field**:
64
+
65
+ ```ts
66
+ const evm = new AmmEvm("PRODUCTION");
67
+ const pool = await evm.readPool({ kernelPool: "0x2c23..." });
68
+ const pPool = await evm.readPeripheryPool({ chain: CHAIN.ARBITRUM, kernelPool: "0x2c23..." });
69
+ const bals = await evm.readUserPoolBalances({ user: "0x...", poolKey: "USDC_USDT", chain: CHAIN.ARBITRUM });
70
+ const call = await evm.buildSwap({ poolKey: "USDC_USDT", chain: CHAIN.ARBITRUM, ... });
71
+ // call → { target: "0x...", calldata: "0x..." }
72
+ ```
73
+
24
74
  ## Install
25
75
 
26
76
  ```bash
@@ -29,10 +79,12 @@ pnpm add @skate-org/amm-evm-v2
29
79
 
30
80
  Peer deps: `@skate-org/amm-core-v2`, `@skate-org/amm-bindings`, `viem`.
31
81
 
32
- ## DEV defaults (as of 2026-04-29)
82
+ ## DEV defaults
33
83
 
34
84
  - MegaETH RPC: `https://mainnet.megaeth.com/rpc`
35
85
  - Kernel manager: `0x17B7207837e8884f7f687f1f4057751BDAf70a01`
36
86
  - USDC/USDT kernel pool: `0x2c23334eE3b030e6bacEDEDf7C511eEA08Cf7E7e`
37
87
 
88
+ STAGING + PRODUCTION on-chain addresses alias DEV as of `2.0.0-beta.10`.
89
+
38
90
  See `CHANGELOG.md` for version history.
@@ -1 +1 @@
1
- {"version":3,"file":"chain-clients.d.ts","sourceRoot":"","sources":["../src/chain-clients.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,KAAK,EACV,KAAK,YAAY,EACjB,KAAK,SAAS,EACf,MAAM,MAAM,CAAC;AAEd,OAAO,EAEL,KAAK,EAKL,KAAK,iBAAiB,EACvB,MAAM,wBAAwB,CAAC;AAEhC;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,YAAY,EAAE,KAYzB,CAAC;AA4CH;;;;;;;;;;GAUG;AACH,wBAAgB,qBAAqB,CACnC,IAAI,EAAE,iBAAiB,EACvB,SAAS,CAAC,EAAE,SAAS,GACpB,YAAY,CAcd;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,qBAAqB,CACnC,KAAK,EAAE,KAAK,EACZ,IAAI,EAAE,iBAAiB,EACvB,SAAS,CAAC,EAAE,SAAS,GACpB,YAAY,CAsBd"}
1
+ {"version":3,"file":"chain-clients.d.ts","sourceRoot":"","sources":["../src/chain-clients.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,KAAK,EACV,KAAK,YAAY,EACjB,KAAK,SAAS,EACf,MAAM,MAAM,CAAC;AAEd,OAAO,EAEL,KAAK,EAKL,KAAK,iBAAiB,EACvB,MAAM,wBAAwB,CAAC;AAEhC;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,YAAY,EAAE,KAYzB,CAAC;AA+CH;;;;;;;;;;GAUG;AACH,wBAAgB,qBAAqB,CACnC,IAAI,EAAE,iBAAiB,EACvB,SAAS,CAAC,EAAE,SAAS,GACpB,YAAY,CAcd;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,qBAAqB,CACnC,KAAK,EAAE,KAAK,EACZ,IAAI,EAAE,iBAAiB,EACvB,SAAS,CAAC,EAAE,SAAS,GACpB,YAAY,CAsBd"}