Trading integration
Use production Classic on Arc Mainnet (5042). Choose the execution path before choosing a spender. The Router and PoolManager invoke the Hook; a wallet does not call the Hook's swap callback directly.
Through Arc Aggregator
Follow the Aggregator Quickstart and select the production network. Obtain a fresh route after graduation; pool creation, indexing and executable route availability are separate conditions.
Use the spender returned and validated by the selected Direct or Delegated flow. Confirm approvals, preserve the user's output/input limits and expiry, then simulate, send and confirm the receipt. Requote after expiry or a state change.
Verify the official pool
Use the Mainnet addresses from Contract Address. Save this read helper as v4-hooks.ts; it is also used by Pool structure.
import {
encodeAbiParameters, keccak256, parseAbiParameters, zeroHash,
type Address, type PublicClient,
} from "viem";
import { arcMainnetLaunchpadDeployment } from "@masterpeach/launchpad-sdk";
import { memeHookAbi } from "@masterpeach/launchpad-sdk/abi";
export async function readV4Pool(publicClient: PublicClient, token: Address) {
const deployment = arcMainnetLaunchpadDeployment;
if (await publicClient.getChainId() !== deployment.chainId) {
throw new Error("Use Arc Mainnet");
}
const address = deployment.contracts.memeHook;
const blockNumber = await publicClient.getBlockNumber();
const poolId = await publicClient.readContract({
address, abi: memeHookAbi, functionName: "poolForToken", args: [token], blockNumber,
});
if (poolId === zeroHash) throw new Error("No registered V4 pool");
const config = await publicClient.readContract({
address, abi: memeHookAbi, functionName: "poolConfig", args: [poolId], blockNumber,
});
if (config[11] !== 2 || config[0].toLowerCase() !== token.toLowerCase()) {
throw new Error("V4 pool is not active for this token");
}
const [currency0, currency1] = BigInt(token) < BigInt(config[1])
? [token, config[1]] : [config[1], token];
const key = { currency0, currency1, fee: 0, tickSpacing: config[9], hooks: address } as const;
const calculatedId = keccak256(encodeAbiParameters(
parseAbiParameters("address,address,uint24,int24,address"),
[key.currency0, key.currency1, key.fee, key.tickSpacing, key.hooks],
));
if (calculatedId !== poolId) throw new Error("PoolKey does not match the registered pool");
return { poolId, key, config, blockNumber };
}This reads a fixed block and validates the chain, registered pool, active status and PoolKey. It does not prove liquidity or simulate a swap.
Direct V4 Router integration
Select a production Router that enforces minimum output or maximum input, expiry, authorized payer/recipient and unlock settlement. Read its funding model to choose the allowance target. Forward the required Partner hookData only when the Router supports it.
Include Hook fees and Creator Tax in the final user limits. A square-root price boundary alone is not a net-output guarantee. If the Router can partially consume input, reconcile actual spending, output and refunds from the confirmed receipt.
For failures, first check graduation and Hook state, then PoolKey, balances, allowance and the Router's limits. A valid pool can still have no Aggregator route; obtain a current executable quote before offering a swap.
Last updated
Was this helpful?