Quickstart
This page gets you from zero to a real swap quote on MegaETH in about a dozen lines of TypeScript.
What we're building
A script that:
Connects to MegaETH mainnet
Asks
QuoterV2for the price of swapping 1 WETH → USDC through the 0.3% poolPrints the result
Install
npm install @kumbaya_xyz/sdk-core @kumbaya_xyz/v3-sdk viemYou don't strictly need viem - any RPC client works - but the example below uses it because it's the most ergonomic.
The full script
import { createPublicClient, http, parseEther } from 'viem'
import { Token, ChainId } from '@kumbaya_xyz/sdk-core'
import { FeeAmount, Pool } from '@kumbaya_xyz/v3-sdk'
// 1. Network + RPC
const MEGAETH_MAINNET = {
id: 4326,
rpc: 'https://mainnet.megaeth.com/rpc',
}
// 2. Tokens (replace USDC with the real address from the token list / explorer)
// Note: `ChainId.MEGAETH` (= 4326). The mainnet enum is just `MEGAETH`.
const WETH = new Token(
ChainId.MEGAETH,
'0x4200000000000000000000000000000000000006',
18,
'WETH',
)
const USDC = new Token(
ChainId.MEGAETH,
'0xYOUR_USDC_ADDRESS_HERE', // get it from default-token-list
6,
'USDC',
)
// 3. Compute the pool address (Kumbaya's POOL_INIT_CODE_HASH is wired in already)
const poolAddress = Pool.getAddress(WETH, USDC, FeeAmount.MEDIUM) // 0.3%
// 4. Quote 1 WETH -> USDC via QuoterV2
const QUOTER_V2 = '0x1F1a8dC7E138C34b503Ca080962aC10B75384a27'
const quoterAbi = [{
type: 'function',
name: 'quoteExactInputSingle',
stateMutability: 'nonpayable',
inputs: [{ type: 'tuple', name: 'params', components: [
{ type: 'address', name: 'tokenIn' },
{ type: 'address', name: 'tokenOut' },
{ type: 'uint256', name: 'amountIn' },
{ type: 'uint24', name: 'fee' },
{ type: 'uint160', name: 'sqrtPriceLimitX96' },
]}],
outputs: [
{ type: 'uint256', name: 'amountOut' },
{ type: 'uint160', name: 'sqrtPriceX96After' },
{ type: 'uint32', name: 'initializedTicksCrossed' },
{ type: 'uint256', name: 'gasEstimate' },
],
}] as const
const client = createPublicClient({ transport: http(MEGAETH_MAINNET.rpc) })
const result = await client.simulateContract({
address: QUOTER_V2,
abi: quoterAbi,
functionName: 'quoteExactInputSingle',
args: [{
tokenIn: WETH.address as `0x${string}`,
tokenOut: USDC.address as `0x${string}`,
amountIn: parseEther('1'),
fee: FeeAmount.MEDIUM,
sqrtPriceLimitX96: 0n,
}],
})
console.log(`Pool address: ${poolAddress}`)
console.log(`1 WETH → ${result.result[0]} USDC (raw, 6 decimals)`)What just happened
Pool.getAddresscomputed the deterministic pool address using Kumbaya's init code hash. If you used@uniswap/v3-sdkinstead, the address would be wrong on MegaETH.QuoterV2is the standard V3 quoter, deployed at the address shown above. It does a real on-chain simulation and returns the exact output amount.No private key or signature involved - quoting is read-only.
Where to go from here
Executing swaps - turning this quote into a real on-chain trade
Smart Order Router - for multi-hop or multi-pool optimal routes
Exchange API quote endpoint - if you'd rather not run the SOR client-side
Reading pools and positions - querying live pool state directly
Kumbaya Agent Kit - building an LLM agent? Skip the SDK glue and use the ready-made MCP tools (
quote,swap,add_liquidity,ignite, …)
Don't do this
Don't use
@uniswap/v3-sdkdirectly for pool address derivation on MegaETH. It uses Uniswap's init code hash, not Kumbaya's. Use@kumbaya_xyz/v3-sdk.Don't reference Uniswap V2 or V4 docs when integrating Kumbaya. Stick to V3 protocol docs plus this site.
Last updated