import type { Abi, Address, PublicClient, WalletClient, GetContractReturnType } from 'viem'; import { getContract } from 'viem'; /** * UniswapV2Pair_json ABI * * This ABI is typed using viem's type system for full type safety. */ export const UniswapV2Pair_jsonAbi = [ { "inputs": [], "payable": false, "stateMutability": "nonpayable", "type": "constructor" }, { "anonymous": false, "inputs": [ { "indexed": true, "internalType": "address", "name": "owner", "type": "address" }, { "indexed": true, "internalType": "address", "name": "spender", "type": "address" }, { "indexed": false, "internalType": "uint256", "name": "value", "type": "uint256" } ], "name": "Approval", "type": "event" }, { "anonymous": false, "inputs": [ { "indexed": true, "internalType": "address", "name": "sender", "type": "address" }, { "indexed": false, "internalType": "uint256", "name": "amount0", "type": "uint256" }, { "indexed": false, "internalType": "uint256", "name": "amount1", "type": "uint256" }, { "indexed": true, "internalType": "address", "name": "to", "type": "address" } ], "name": "Burn", "type": "event" }, { "anonymous": false, "inputs": [ { "indexed": true, "internalType": "address", "name": "sender", "type": "address" }, { "indexed": false, "internalType": "uint256", "name": "amount0", "type": "uint256" }, { "indexed": false, "internalType": "uint256", "name": "amount1", "type": "uint256" } ], "name": "Mint", "type": "event" }, { "anonymous": false, "inputs": [ { "indexed": true, "internalType": "address", "name": "sender", "type": "address" }, { "indexed": false, "internalType": "uint256", "name": "amount0In", "type": "uint256" }, { "indexed": false, "internalType": "uint256", "name": "amount1In", "type": "uint256" }, { "indexed": false, "internalType": "uint256", "name": "amount0Out", "type": "uint256" }, { "indexed": false, "internalType": "uint256", "name": "amount1Out", "type": "uint256" }, { "indexed": true, "internalType": "address", "name": "to", "type": "address" } ], "name": "Swap", "type": "event" }, { "anonymous": false, "inputs": [ { "indexed": false, "internalType": "uint112", "name": "reserve0", "type": "uint112" }, { "indexed": false, "internalType": "uint112", "name": "reserve1", "type": "uint112" } ], "name": "Sync", "type": "event" }, { "anonymous": false, "inputs": [ { "indexed": true, "internalType": "address", "name": "from", "type": "address" }, { "indexed": true, "internalType": "address", "name": "to", "type": "address" }, { "indexed": false, "internalType": "uint256", "name": "value", "type": "uint256" } ], "name": "Transfer", "type": "event" }, { "constant": true, "inputs": [], "name": "DOMAIN_SEPARATOR", "outputs": [ { "internalType": "bytes32", "name": "", "type": "bytes32" } ], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": true, "inputs": [], "name": "MINIMUM_LIQUIDITY", "outputs": [ { "internalType": "uint256", "name": "", "type": "uint256" } ], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": true, "inputs": [], "name": "PERMIT_TYPEHASH", "outputs": [ { "internalType": "bytes32", "name": "", "type": "bytes32" } ], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": true, "inputs": [ { "internalType": "address", "name": "", "type": "address" }, { "internalType": "address", "name": "", "type": "address" } ], "name": "allowance", "outputs": [ { "internalType": "uint256", "name": "", "type": "uint256" } ], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": false, "inputs": [ { "internalType": "address", "name": "spender", "type": "address" }, { "internalType": "uint256", "name": "value", "type": "uint256" } ], "name": "approve", "outputs": [ { "internalType": "bool", "name": "", "type": "bool" } ], "payable": false, "stateMutability": "nonpayable", "type": "function" }, { "constant": true, "inputs": [ { "internalType": "address", "name": "", "type": "address" } ], "name": "balanceOf", "outputs": [ { "internalType": "uint256", "name": "", "type": "uint256" } ], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": false, "inputs": [ { "internalType": "address", "name": "to", "type": "address" } ], "name": "burn", "outputs": [ { "internalType": "uint256", "name": "amount0", "type": "uint256" }, { "internalType": "uint256", "name": "amount1", "type": "uint256" } ], "payable": false, "stateMutability": "nonpayable", "type": "function" }, { "constant": true, "inputs": [], "name": "decimals", "outputs": [ { "internalType": "uint8", "name": "", "type": "uint8" } ], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": true, "inputs": [], "name": "factory", "outputs": [ { "internalType": "address", "name": "", "type": "address" } ], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": true, "inputs": [], "name": "getReserves", "outputs": [ { "internalType": "uint112", "name": "_reserve0", "type": "uint112" }, { "internalType": "uint112", "name": "_reserve1", "type": "uint112" }, { "internalType": "uint32", "name": "_blockTimestampLast", "type": "uint32" } ], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": false, "inputs": [ { "internalType": "address", "name": "_token0", "type": "address" }, { "internalType": "address", "name": "_token1", "type": "address" } ], "name": "initialize", "outputs": [], "payable": false, "stateMutability": "nonpayable", "type": "function" }, { "constant": true, "inputs": [], "name": "kLast", "outputs": [ { "internalType": "uint256", "name": "", "type": "uint256" } ], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": false, "inputs": [ { "internalType": "address", "name": "to", "type": "address" } ], "name": "mint", "outputs": [ { "internalType": "uint256", "name": "liquidity", "type": "uint256" } ], "payable": false, "stateMutability": "nonpayable", "type": "function" }, { "constant": true, "inputs": [], "name": "name", "outputs": [ { "internalType": "string", "name": "", "type": "string" } ], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": true, "inputs": [ { "internalType": "address", "name": "", "type": "address" } ], "name": "nonces", "outputs": [ { "internalType": "uint256", "name": "", "type": "uint256" } ], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": false, "inputs": [ { "internalType": "address", "name": "owner", "type": "address" }, { "internalType": "address", "name": "spender", "type": "address" }, { "internalType": "uint256", "name": "value", "type": "uint256" }, { "internalType": "uint256", "name": "deadline", "type": "uint256" }, { "internalType": "uint8", "name": "v", "type": "uint8" }, { "internalType": "bytes32", "name": "r", "type": "bytes32" }, { "internalType": "bytes32", "name": "s", "type": "bytes32" } ], "name": "permit", "outputs": [], "payable": false, "stateMutability": "nonpayable", "type": "function" }, { "constant": true, "inputs": [], "name": "price0CumulativeLast", "outputs": [ { "internalType": "uint256", "name": "", "type": "uint256" } ], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": true, "inputs": [], "name": "price1CumulativeLast", "outputs": [ { "internalType": "uint256", "name": "", "type": "uint256" } ], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": false, "inputs": [ { "internalType": "address", "name": "to", "type": "address" } ], "name": "skim", "outputs": [], "payable": false, "stateMutability": "nonpayable", "type": "function" }, { "constant": false, "inputs": [ { "internalType": "uint256", "name": "amount0Out", "type": "uint256" }, { "internalType": "uint256", "name": "amount1Out", "type": "uint256" }, { "internalType": "address", "name": "to", "type": "address" }, { "internalType": "bytes", "name": "data", "type": "bytes" } ], "name": "swap", "outputs": [], "payable": false, "stateMutability": "nonpayable", "type": "function" }, { "constant": true, "inputs": [], "name": "symbol", "outputs": [ { "internalType": "string", "name": "", "type": "string" } ], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": false, "inputs": [], "name": "sync", "outputs": [], "payable": false, "stateMutability": "nonpayable", "type": "function" }, { "constant": true, "inputs": [], "name": "token0", "outputs": [ { "internalType": "address", "name": "", "type": "address" } ], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": true, "inputs": [], "name": "token1", "outputs": [ { "internalType": "address", "name": "", "type": "address" } ], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": true, "inputs": [], "name": "totalSupply", "outputs": [ { "internalType": "uint256", "name": "", "type": "uint256" } ], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": false, "inputs": [ { "internalType": "address", "name": "to", "type": "address" }, { "internalType": "uint256", "name": "value", "type": "uint256" } ], "name": "transfer", "outputs": [ { "internalType": "bool", "name": "", "type": "bool" } ], "payable": false, "stateMutability": "nonpayable", "type": "function" }, { "constant": false, "inputs": [ { "internalType": "address", "name": "from", "type": "address" }, { "internalType": "address", "name": "to", "type": "address" }, { "internalType": "uint256", "name": "value", "type": "uint256" } ], "name": "transferFrom", "outputs": [ { "internalType": "bool", "name": "", "type": "bool" } ], "payable": false, "stateMutability": "nonpayable", "type": "function" } ] as const satisfies Abi; /** * Type-safe ABI for UniswapV2Pair_json */ export type UniswapV2Pair_jsonAbi = typeof UniswapV2Pair_jsonAbi; /** * Contract instance type for UniswapV2Pair_json */ // Use any for contract type to avoid complex viem type issues // The runtime behavior is type-safe through viem's ABI typing export type UniswapV2Pair_jsonContract = any; /** * UniswapV2Pair_json Contract Class * * Provides a class-based API similar to TypeChain for interacting with the contract. * * @example * ```typescript * import { createPublicClient, createWalletClient, http } from 'viem'; * import { mainnet } from 'viem/chains'; * import { UniswapV2Pair_json } from 'UniswapV2Pair_json'; * * const publicClient = createPublicClient({ chain: mainnet, transport: http() }); * const walletClient = createWalletClient({ chain: mainnet, transport: http() }); * * const contract = new UniswapV2Pair_json('0x...', { publicClient, walletClient }); * * // Read functions * const result = await contract.balanceOf('0x...'); * * // Write functions * const hash = await contract.transfer('0x...', 1000n); * * // Simulate transactions (dry-run) * const simulation = await contract.simulate.transfer('0x...', 1000n); * console.log('Gas estimate:', simulation.request.gas); * * // Watch events * const unwatch = contract.watch.Transfer((event) => { * console.log('Transfer event:', event); * }); * ``` */ export class UniswapV2Pair_json { private contract: UniswapV2Pair_jsonContract; private contractAddress: Address; private publicClient: PublicClient; constructor( address: Address, clients: { publicClient: PublicClient; walletClient?: WalletClient; } ) { this.contractAddress = address; this.publicClient = clients.publicClient; this.contract = getContract({ address, abi: UniswapV2Pair_jsonAbi, client: { public: clients.publicClient, wallet: clients.walletClient, }, }); } /** * Get the contract address */ get address(): Address { return this.contractAddress; } /** * Get the underlying viem contract instance */ getContract(): UniswapV2Pair_jsonContract { return this.contract; } /** * DOMAIN_SEPARATOR * view */ async DOMAIN_SEPARATOR(): Promise<`0x${string}`> { return this.contract.read.DOMAIN_SEPARATOR() as Promise<`0x${string}`>; } /** * MINIMUM_LIQUIDITY * view */ async MINIMUM_LIQUIDITY(): Promise { return this.contract.read.MINIMUM_LIQUIDITY() as Promise; } /** * PERMIT_TYPEHASH * view */ async PERMIT_TYPEHASH(): Promise<`0x${string}`> { return this.contract.read.PERMIT_TYPEHASH() as Promise<`0x${string}`>; } /** * allowance * view */ async allowance(arg0: `0x${string}`, arg1: `0x${string}`): Promise { return this.contract.read.allowance([arg0, arg1] as const) as Promise; } /** * balanceOf * view */ async balanceOf(arg0: `0x${string}`): Promise { return this.contract.read.balanceOf([arg0] as const) as Promise; } /** * decimals * view */ async decimals(): Promise { return this.contract.read.decimals() as Promise; } /** * factory * view */ async factory(): Promise<`0x${string}`> { return this.contract.read.factory() as Promise<`0x${string}`>; } /** * getReserves * view */ async getReserves(): Promise<[bigint, bigint, bigint]> { return this.contract.read.getReserves() as Promise<[bigint, bigint, bigint]>; } /** * kLast * view */ async kLast(): Promise { return this.contract.read.kLast() as Promise; } /** * name * view */ async name(): Promise { return this.contract.read.name() as Promise; } /** * nonces * view */ async nonces(arg0: `0x${string}`): Promise { return this.contract.read.nonces([arg0] as const) as Promise; } /** * price0CumulativeLast * view */ async price0CumulativeLast(): Promise { return this.contract.read.price0CumulativeLast() as Promise; } /** * price1CumulativeLast * view */ async price1CumulativeLast(): Promise { return this.contract.read.price1CumulativeLast() as Promise; } /** * symbol * view */ async symbol(): Promise { return this.contract.read.symbol() as Promise; } /** * token0 * view */ async token0(): Promise<`0x${string}`> { return this.contract.read.token0() as Promise<`0x${string}`>; } /** * token1 * view */ async token1(): Promise<`0x${string}`> { return this.contract.read.token1() as Promise<`0x${string}`>; } /** * totalSupply * view */ async totalSupply(): Promise { return this.contract.read.totalSupply() as Promise; } /** * approve * nonpayable * @param options Optional transaction parameters (value, gas, nonce, etc.) */ async approve(spender: `0x${string}`, value: bigint, options?: { accessList?: import('viem').AccessList; authorizationList?: import('viem').AuthorizationList; chain?: import('viem').Chain | null; dataSuffix?: `0x${string}`; gas?: bigint; gasPrice?: bigint; maxFeePerGas?: bigint; maxPriorityFeePerGas?: bigint; nonce?: number; value?: bigint; }): Promise<`0x${string}`> { if (!this.contract.write) { throw new Error('Wallet client is required for write operations'); } return this.contract.write.approve([spender, value] as const, options) as Promise<`0x${string}`>; } /** * burn * nonpayable * @param options Optional transaction parameters (value, gas, nonce, etc.) */ async burn(to: `0x${string}`, options?: { accessList?: import('viem').AccessList; authorizationList?: import('viem').AuthorizationList; chain?: import('viem').Chain | null; dataSuffix?: `0x${string}`; gas?: bigint; gasPrice?: bigint; maxFeePerGas?: bigint; maxPriorityFeePerGas?: bigint; nonce?: number; value?: bigint; }): Promise<`0x${string}`> { if (!this.contract.write) { throw new Error('Wallet client is required for write operations'); } return this.contract.write.burn([to] as const, options) as Promise<`0x${string}`>; } /** * initialize * nonpayable * @param options Optional transaction parameters (value, gas, nonce, etc.) */ async initialize(_token0: `0x${string}`, _token1: `0x${string}`, options?: { accessList?: import('viem').AccessList; authorizationList?: import('viem').AuthorizationList; chain?: import('viem').Chain | null; dataSuffix?: `0x${string}`; gas?: bigint; gasPrice?: bigint; maxFeePerGas?: bigint; maxPriorityFeePerGas?: bigint; nonce?: number; value?: bigint; }): Promise<`0x${string}`> { if (!this.contract.write) { throw new Error('Wallet client is required for write operations'); } return this.contract.write.initialize([_token0, _token1] as const, options) as Promise<`0x${string}`>; } /** * mint * nonpayable * @param options Optional transaction parameters (value, gas, nonce, etc.) */ async mint(to: `0x${string}`, options?: { accessList?: import('viem').AccessList; authorizationList?: import('viem').AuthorizationList; chain?: import('viem').Chain | null; dataSuffix?: `0x${string}`; gas?: bigint; gasPrice?: bigint; maxFeePerGas?: bigint; maxPriorityFeePerGas?: bigint; nonce?: number; value?: bigint; }): Promise<`0x${string}`> { if (!this.contract.write) { throw new Error('Wallet client is required for write operations'); } return this.contract.write.mint([to] as const, options) as Promise<`0x${string}`>; } /** * permit * nonpayable * @param options Optional transaction parameters (value, gas, nonce, etc.) */ async permit(owner: `0x${string}`, spender: `0x${string}`, value: bigint, deadline: bigint, v: bigint, r: `0x${string}`, s: `0x${string}`, options?: { accessList?: import('viem').AccessList; authorizationList?: import('viem').AuthorizationList; chain?: import('viem').Chain | null; dataSuffix?: `0x${string}`; gas?: bigint; gasPrice?: bigint; maxFeePerGas?: bigint; maxPriorityFeePerGas?: bigint; nonce?: number; value?: bigint; }): Promise<`0x${string}`> { if (!this.contract.write) { throw new Error('Wallet client is required for write operations'); } return this.contract.write.permit([owner, spender, value, deadline, v, r, s] as const, options) as Promise<`0x${string}`>; } /** * skim * nonpayable * @param options Optional transaction parameters (value, gas, nonce, etc.) */ async skim(to: `0x${string}`, options?: { accessList?: import('viem').AccessList; authorizationList?: import('viem').AuthorizationList; chain?: import('viem').Chain | null; dataSuffix?: `0x${string}`; gas?: bigint; gasPrice?: bigint; maxFeePerGas?: bigint; maxPriorityFeePerGas?: bigint; nonce?: number; value?: bigint; }): Promise<`0x${string}`> { if (!this.contract.write) { throw new Error('Wallet client is required for write operations'); } return this.contract.write.skim([to] as const, options) as Promise<`0x${string}`>; } /** * swap * nonpayable * @param options Optional transaction parameters (value, gas, nonce, etc.) */ async swap(amount0Out: bigint, amount1Out: bigint, to: `0x${string}`, data: `0x${string}`, options?: { accessList?: import('viem').AccessList; authorizationList?: import('viem').AuthorizationList; chain?: import('viem').Chain | null; dataSuffix?: `0x${string}`; gas?: bigint; gasPrice?: bigint; maxFeePerGas?: bigint; maxPriorityFeePerGas?: bigint; nonce?: number; value?: bigint; }): Promise<`0x${string}`> { if (!this.contract.write) { throw new Error('Wallet client is required for write operations'); } return this.contract.write.swap([amount0Out, amount1Out, to, data] as const, options) as Promise<`0x${string}`>; } /** * sync * nonpayable * @param options Optional transaction parameters (value, gas, nonce, etc.) */ async sync(options?: { accessList?: import('viem').AccessList; authorizationList?: import('viem').AuthorizationList; chain?: import('viem').Chain | null; dataSuffix?: `0x${string}`; gas?: bigint; gasPrice?: bigint; maxFeePerGas?: bigint; maxPriorityFeePerGas?: bigint; nonce?: number; value?: bigint; }): Promise<`0x${string}`> { if (!this.contract.write) { throw new Error('Wallet client is required for write operations'); } return this.contract.write.sync(options) as Promise<`0x${string}`>; } /** * transfer * nonpayable * @param options Optional transaction parameters (value, gas, nonce, etc.) */ async transfer(to: `0x${string}`, value: bigint, options?: { accessList?: import('viem').AccessList; authorizationList?: import('viem').AuthorizationList; chain?: import('viem').Chain | null; dataSuffix?: `0x${string}`; gas?: bigint; gasPrice?: bigint; maxFeePerGas?: bigint; maxPriorityFeePerGas?: bigint; nonce?: number; value?: bigint; }): Promise<`0x${string}`> { if (!this.contract.write) { throw new Error('Wallet client is required for write operations'); } return this.contract.write.transfer([to, value] as const, options) as Promise<`0x${string}`>; } /** * transferFrom * nonpayable * @param options Optional transaction parameters (value, gas, nonce, etc.) */ async transferFrom(from: `0x${string}`, to: `0x${string}`, value: bigint, options?: { accessList?: import('viem').AccessList; authorizationList?: import('viem').AuthorizationList; chain?: import('viem').Chain | null; dataSuffix?: `0x${string}`; gas?: bigint; gasPrice?: bigint; maxFeePerGas?: bigint; maxPriorityFeePerGas?: bigint; nonce?: number; value?: bigint; }): Promise<`0x${string}`> { if (!this.contract.write) { throw new Error('Wallet client is required for write operations'); } return this.contract.write.transferFrom([from, to, value] as const, options) as Promise<`0x${string}`>; } /** * Simulate contract write operations (dry-run without sending transaction) * * @example * const result = await contract.simulate.transfer('0x...', 1000n); * console.log('Gas estimate:', result.request.gas); * console.log('Would succeed:', result.result); */ get simulate() { const contract = this.contract; if (!contract.simulate) { throw new Error('Public client is required for simulation'); } return { /** * Simulate approve * Returns gas estimate and result without sending transaction * @param options Optional transaction parameters (value, gas, nonce, etc.) */ async approve(spender: `0x${string}`, value: bigint, options?: { accessList?: import('viem').AccessList; authorizationList?: import('viem').AuthorizationList; chain?: import('viem').Chain | null; dataSuffix?: `0x${string}`; gas?: bigint; gasPrice?: bigint; maxFeePerGas?: bigint; maxPriorityFeePerGas?: bigint; nonce?: number; value?: bigint; }): Promise { return contract.simulate.approve([spender, value] as const, options) as Promise; }, /** * Simulate burn * Returns gas estimate and result without sending transaction * @param options Optional transaction parameters (value, gas, nonce, etc.) */ async burn(to: `0x${string}`, options?: { accessList?: import('viem').AccessList; authorizationList?: import('viem').AuthorizationList; chain?: import('viem').Chain | null; dataSuffix?: `0x${string}`; gas?: bigint; gasPrice?: bigint; maxFeePerGas?: bigint; maxPriorityFeePerGas?: bigint; nonce?: number; value?: bigint; }): Promise<[bigint, bigint]> { return contract.simulate.burn([to] as const, options) as Promise<[bigint, bigint]>; }, /** * Simulate initialize * Returns gas estimate and result without sending transaction * @param options Optional transaction parameters (value, gas, nonce, etc.) */ async initialize(_token0: `0x${string}`, _token1: `0x${string}`, options?: { accessList?: import('viem').AccessList; authorizationList?: import('viem').AuthorizationList; chain?: import('viem').Chain | null; dataSuffix?: `0x${string}`; gas?: bigint; gasPrice?: bigint; maxFeePerGas?: bigint; maxPriorityFeePerGas?: bigint; nonce?: number; value?: bigint; }): Promise { return contract.simulate.initialize([_token0, _token1] as const, options) as Promise; }, /** * Simulate mint * Returns gas estimate and result without sending transaction * @param options Optional transaction parameters (value, gas, nonce, etc.) */ async mint(to: `0x${string}`, options?: { accessList?: import('viem').AccessList; authorizationList?: import('viem').AuthorizationList; chain?: import('viem').Chain | null; dataSuffix?: `0x${string}`; gas?: bigint; gasPrice?: bigint; maxFeePerGas?: bigint; maxPriorityFeePerGas?: bigint; nonce?: number; value?: bigint; }): Promise { return contract.simulate.mint([to] as const, options) as Promise; }, /** * Simulate permit * Returns gas estimate and result without sending transaction * @param options Optional transaction parameters (value, gas, nonce, etc.) */ async permit(owner: `0x${string}`, spender: `0x${string}`, value: bigint, deadline: bigint, v: bigint, r: `0x${string}`, s: `0x${string}`, options?: { accessList?: import('viem').AccessList; authorizationList?: import('viem').AuthorizationList; chain?: import('viem').Chain | null; dataSuffix?: `0x${string}`; gas?: bigint; gasPrice?: bigint; maxFeePerGas?: bigint; maxPriorityFeePerGas?: bigint; nonce?: number; value?: bigint; }): Promise { return contract.simulate.permit([owner, spender, value, deadline, v, r, s] as const, options) as Promise; }, /** * Simulate skim * Returns gas estimate and result without sending transaction * @param options Optional transaction parameters (value, gas, nonce, etc.) */ async skim(to: `0x${string}`, options?: { accessList?: import('viem').AccessList; authorizationList?: import('viem').AuthorizationList; chain?: import('viem').Chain | null; dataSuffix?: `0x${string}`; gas?: bigint; gasPrice?: bigint; maxFeePerGas?: bigint; maxPriorityFeePerGas?: bigint; nonce?: number; value?: bigint; }): Promise { return contract.simulate.skim([to] as const, options) as Promise; }, /** * Simulate swap * Returns gas estimate and result without sending transaction * @param options Optional transaction parameters (value, gas, nonce, etc.) */ async swap(amount0Out: bigint, amount1Out: bigint, to: `0x${string}`, data: `0x${string}`, options?: { accessList?: import('viem').AccessList; authorizationList?: import('viem').AuthorizationList; chain?: import('viem').Chain | null; dataSuffix?: `0x${string}`; gas?: bigint; gasPrice?: bigint; maxFeePerGas?: bigint; maxPriorityFeePerGas?: bigint; nonce?: number; value?: bigint; }): Promise { return contract.simulate.swap([amount0Out, amount1Out, to, data] as const, options) as Promise; }, /** * Simulate sync * Returns gas estimate and result without sending transaction * @param options Optional transaction parameters (value, gas, nonce, etc.) */ async sync(options?: { accessList?: import('viem').AccessList; authorizationList?: import('viem').AuthorizationList; chain?: import('viem').Chain | null; dataSuffix?: `0x${string}`; gas?: bigint; gasPrice?: bigint; maxFeePerGas?: bigint; maxPriorityFeePerGas?: bigint; nonce?: number; value?: bigint; }): Promise { return contract.simulate.sync(options) as Promise; }, /** * Simulate transfer * Returns gas estimate and result without sending transaction * @param options Optional transaction parameters (value, gas, nonce, etc.) */ async transfer(to: `0x${string}`, value: bigint, options?: { accessList?: import('viem').AccessList; authorizationList?: import('viem').AuthorizationList; chain?: import('viem').Chain | null; dataSuffix?: `0x${string}`; gas?: bigint; gasPrice?: bigint; maxFeePerGas?: bigint; maxPriorityFeePerGas?: bigint; nonce?: number; value?: bigint; }): Promise { return contract.simulate.transfer([to, value] as const, options) as Promise; }, /** * Simulate transferFrom * Returns gas estimate and result without sending transaction * @param options Optional transaction parameters (value, gas, nonce, etc.) */ async transferFrom(from: `0x${string}`, to: `0x${string}`, value: bigint, options?: { accessList?: import('viem').AccessList; authorizationList?: import('viem').AuthorizationList; chain?: import('viem').Chain | null; dataSuffix?: `0x${string}`; gas?: bigint; gasPrice?: bigint; maxFeePerGas?: bigint; maxPriorityFeePerGas?: bigint; nonce?: number; value?: bigint; }): Promise { return contract.simulate.transferFrom([from, to, value] as const, options) as Promise; } }; } /** * Watch contract events * * @example * // Watch all Transfer events * const unwatch = contract.watch.Transfer((event) => { * console.log('Transfer:', event); * }); * * // Stop watching * unwatch(); */ get watch() { return { /** * Watch Approval events * @param callback Function to call when event is emitted * @param filter Optional filter for indexed parameters * @returns Unwatch function to stop listening */ Approval: (callback: (event: { owner: `0x${string}`; spender: `0x${string}`; value: bigint }) => void, filter?: { owner: `0x${string}`; spender: `0x${string}` }) => { return this.publicClient.watchContractEvent({ address: this.contractAddress, abi: UniswapV2Pair_jsonAbi, eventName: 'Approval', args: filter, onLogs: (logs: any[]) => { logs.forEach((log: any) => { callback(log.args as any); }); }, }) as () => void; }, /** * Watch Burn events * @param callback Function to call when event is emitted * @param filter Optional filter for indexed parameters * @returns Unwatch function to stop listening */ Burn: (callback: (event: { sender: `0x${string}`; to: `0x${string}`; amount0: bigint; amount1: bigint }) => void, filter?: { sender: `0x${string}`; to: `0x${string}` }) => { return this.publicClient.watchContractEvent({ address: this.contractAddress, abi: UniswapV2Pair_jsonAbi, eventName: 'Burn', args: filter, onLogs: (logs: any[]) => { logs.forEach((log: any) => { callback(log.args as any); }); }, }) as () => void; }, /** * Watch Mint events * @param callback Function to call when event is emitted * @param filter Optional filter for indexed parameters * @returns Unwatch function to stop listening */ Mint: (callback: (event: { sender: `0x${string}`; amount0: bigint; amount1: bigint }) => void, filter?: { sender: `0x${string}` }) => { return this.publicClient.watchContractEvent({ address: this.contractAddress, abi: UniswapV2Pair_jsonAbi, eventName: 'Mint', args: filter, onLogs: (logs: any[]) => { logs.forEach((log: any) => { callback(log.args as any); }); }, }) as () => void; }, /** * Watch Swap events * @param callback Function to call when event is emitted * @param filter Optional filter for indexed parameters * @returns Unwatch function to stop listening */ Swap: (callback: (event: { sender: `0x${string}`; to: `0x${string}`; amount0In: bigint; amount1In: bigint; amount0Out: bigint; amount1Out: bigint }) => void, filter?: { sender: `0x${string}`; to: `0x${string}` }) => { return this.publicClient.watchContractEvent({ address: this.contractAddress, abi: UniswapV2Pair_jsonAbi, eventName: 'Swap', args: filter, onLogs: (logs: any[]) => { logs.forEach((log: any) => { callback(log.args as any); }); }, }) as () => void; }, /** * Watch Sync events * @param callback Function to call when event is emitted * @param filter Optional filter for indexed parameters * @returns Unwatch function to stop listening */ Sync: (callback: (event: { reserve0: bigint; reserve1: bigint }) => void) => { return this.publicClient.watchContractEvent({ address: this.contractAddress, abi: UniswapV2Pair_jsonAbi, eventName: 'Sync', onLogs: (logs: any[]) => { logs.forEach((log: any) => { callback(log.args as any); }); }, }) as () => void; }, /** * Watch Transfer events * @param callback Function to call when event is emitted * @param filter Optional filter for indexed parameters * @returns Unwatch function to stop listening */ Transfer: (callback: (event: { from: `0x${string}`; to: `0x${string}`; value: bigint }) => void, filter?: { from: `0x${string}`; to: `0x${string}` }) => { return this.publicClient.watchContractEvent({ address: this.contractAddress, abi: UniswapV2Pair_jsonAbi, eventName: 'Transfer', args: filter, onLogs: (logs: any[]) => { logs.forEach((log: any) => { callback(log.args as any); }); }, }) as () => void; } }; } }