@skate-org/amm-evm-v2
v2.0.0-beta.23
Published
Skate AMM v2 SDK — EVM clients, kernel/periphery readers, uniswap-v3 math, submitters
Readme
@skate-org/amm-evm-v2
EVM clients for the Skate AMM v2 SDK: viem chain definitions, kernel + periphery readers, action submitters, and the event-decoding framework.
Uniswap-v3 math (
getSqrtRatioAtTick,getTickAtSqrtRatio,MIN_TICK/MAX_TICK,mulDiv,getAmount0Delta,computePositionAmounts, …) lives in@skate-org/amm-core-v2since2.0.0-alpha.0— SVM/Sui peripheries needed it too. Function names are unchanged; import fromcore(or via the umbrella).
Surface
getKernelPublicClient(mode, transport?)/getSourcePublicClient(chain, mode, transport?)— viemPublicClientfactories with Skate's RPC defaults baked in.createDevConfig({...})— produces the DEV{ mode, config }tuple.- Readers (object-param,
modefield required):readPool({ kernelPool, mode, client? }),readPeripheryPool({ chain, kernelPool, mode, client? })→PeripheryPoolState,readUserPoolBalances({ user, poolKey, chain, mode, client? })→UserPoolBalances,readPosition,readTick,readTickBitmap. - Calldata builders →
Promise<CalldataCall>({ target, calldata }):buildSwap,buildMint,buildBurn,buildIncreaseLiquidity,buildDecreaseLiquidity. All accept a single object param includingmode. No RPC call. - Kernel simulators (object-param):
simulateSwap,simulateMint,simulateBurn,simulateDecreaseLiquidity. - Events:
parseKernelEventLog,parsePeripheryEventLog,watchKernelEvents,watchPeripheryEvents. - Submitters:
submitAction,submitApproval,submitSwap. - Errors:
EvmReadError,EvmWriteError(both extendSdkError).
SkateAmm class (headline entry point)
One object that composes AmmCore (pool catalog), AmmApi (quotes +
actions), and AmmEvm (build/submit/read). Expose escape hatches via
.core, .api, .vm.
const amm = new SkateAmm("PRODUCTION");
// Quotes
const quote = await amm.quote.swap({ poolKey: "USDC_USDT", ... });
const ranges = await amm.quote.boostedRange();
// Actions
const action = await amm.actions.get({ srcChain: CHAIN.ARBITRUM, srcHash: "0x..." });
await amm.actions.waitForExecuted({ srcChain: CHAIN.ARBITRUM, srcHash: "0x..." });
// Build + submit
const call = await amm.buildSwap({ poolKey: "USDC_USDT", chain: CHAIN.ARBITRUM, ... });
const hash = await amm.submitSwap(walletClient, { ... });
// Pool catalog
const keys = amm.pools.keys();
const info = amm.pools.byKey("USDC_USDT");
// EVM extras
const pool = await amm.readPool({ kernelPool: "0x2c23..." });
const sim = await amm.simulateSwap({ params: { ... } });AmmEvm class (env-bound)
Construct once; all methods take object params without the mode field:
const evm = new AmmEvm("PRODUCTION");
const pool = await evm.readPool({ kernelPool: "0x2c23..." });
const pPool = await evm.readPeripheryPool({ chain: CHAIN.ARBITRUM, kernelPool: "0x2c23..." });
const bals = await evm.readUserPoolBalances({ user: "0x...", poolKey: "USDC_USDT", chain: CHAIN.ARBITRUM });
const call = await evm.buildSwap({ poolKey: "USDC_USDT", chain: CHAIN.ARBITRUM, ... });
// call → { target: "0x...", calldata: "0x..." }Install
pnpm add @skate-org/amm-evm-v2Peer deps: @skate-org/amm-core-v2, @skate-org/amm-bindings, viem.
DEV defaults
- MegaETH RPC:
https://mainnet.megaeth.com/rpc - Kernel manager:
0x17B7207837e8884f7f687f1f4057751BDAf70a01 - USDC/USDT kernel pool:
0x2c23334eE3b030e6bacEDEDf7C511eEA08Cf7E7e
STAGING + PRODUCTION on-chain addresses alias DEV as of 2.0.0-beta.10.
See CHANGELOG.md for version history.
