|
| 1 | +import type { Abi } from "abitype"; |
| 2 | + |
| 3 | +export const SUPPORTED_NETWORKS = ["base-mainnet"]; |
| 4 | + |
| 5 | +/** |
| 6 | + * PumpClaw Factory contract ABI - minimal functions needed for PumpClaw interactions. |
| 7 | + */ |
| 8 | +export const PUMPCLAW_FACTORY_ABI: Abi = [ |
| 9 | + { |
| 10 | + type: "function", |
| 11 | + name: "createToken", |
| 12 | + inputs: [ |
| 13 | + { name: "name", type: "string", internalType: "string" }, |
| 14 | + { name: "symbol", type: "string", internalType: "string" }, |
| 15 | + { name: "imageUrl", type: "string", internalType: "string" }, |
| 16 | + { name: "totalSupply", type: "uint256", internalType: "uint256" }, |
| 17 | + { name: "initialFdv", type: "uint256", internalType: "uint256" }, |
| 18 | + { name: "creator", type: "address", internalType: "address" }, |
| 19 | + ], |
| 20 | + outputs: [{ name: "token", type: "address", internalType: "address" }], |
| 21 | + stateMutability: "payable", |
| 22 | + }, |
| 23 | + { |
| 24 | + type: "function", |
| 25 | + name: "getTokenInfo", |
| 26 | + inputs: [{ name: "token", type: "address", internalType: "address" }], |
| 27 | + outputs: [ |
| 28 | + { name: "name", type: "string", internalType: "string" }, |
| 29 | + { name: "symbol", type: "string", internalType: "string" }, |
| 30 | + { name: "imageUrl", type: "string", internalType: "string" }, |
| 31 | + { name: "totalSupply", type: "uint256", internalType: "uint256" }, |
| 32 | + { name: "creator", type: "address", internalType: "address" }, |
| 33 | + { name: "pool", type: "address", internalType: "address" }, |
| 34 | + { name: "createdAt", type: "uint256", internalType: "uint256" }, |
| 35 | + ], |
| 36 | + stateMutability: "view", |
| 37 | + }, |
| 38 | + { |
| 39 | + type: "function", |
| 40 | + name: "getTokenCount", |
| 41 | + inputs: [], |
| 42 | + outputs: [{ name: "", type: "uint256", internalType: "uint256" }], |
| 43 | + stateMutability: "view", |
| 44 | + }, |
| 45 | + { |
| 46 | + type: "function", |
| 47 | + name: "getTokens", |
| 48 | + inputs: [ |
| 49 | + { name: "offset", type: "uint256", internalType: "uint256" }, |
| 50 | + { name: "limit", type: "uint256", internalType: "uint256" }, |
| 51 | + ], |
| 52 | + outputs: [{ name: "", type: "address[]", internalType: "address[]" }], |
| 53 | + stateMutability: "view", |
| 54 | + }, |
| 55 | + { |
| 56 | + type: "function", |
| 57 | + name: "setImageUrl", |
| 58 | + inputs: [ |
| 59 | + { name: "token", type: "address", internalType: "address" }, |
| 60 | + { name: "imageUrl", type: "string", internalType: "string" }, |
| 61 | + ], |
| 62 | + outputs: [], |
| 63 | + stateMutability: "nonpayable", |
| 64 | + }, |
| 65 | +] as const; |
| 66 | + |
| 67 | +/** |
| 68 | + * PumpClaw SwapRouter contract ABI - minimal functions needed for swap interactions. |
| 69 | + */ |
| 70 | +export const PUMPCLAW_SWAPROUTER_ABI: Abi = [ |
| 71 | + { |
| 72 | + type: "function", |
| 73 | + name: "buyTokens", |
| 74 | + inputs: [ |
| 75 | + { name: "token", type: "address", internalType: "address" }, |
| 76 | + { name: "minTokensOut", type: "uint256", internalType: "uint256" }, |
| 77 | + ], |
| 78 | + outputs: [], |
| 79 | + stateMutability: "payable", |
| 80 | + }, |
| 81 | + { |
| 82 | + type: "function", |
| 83 | + name: "sellTokens", |
| 84 | + inputs: [ |
| 85 | + { name: "token", type: "address", internalType: "address" }, |
| 86 | + { name: "tokensIn", type: "uint256", internalType: "uint256" }, |
| 87 | + { name: "minEthOut", type: "uint256", internalType: "uint256" }, |
| 88 | + ], |
| 89 | + outputs: [], |
| 90 | + stateMutability: "nonpayable", |
| 91 | + }, |
| 92 | +] as const; |
| 93 | + |
| 94 | +/** |
| 95 | + * ERC20 token ABI - standard functions needed for token interactions. |
| 96 | + */ |
| 97 | +export const ERC20_ABI: Abi = [ |
| 98 | + { |
| 99 | + type: "function", |
| 100 | + name: "symbol", |
| 101 | + inputs: [], |
| 102 | + outputs: [{ name: "", type: "string", internalType: "string" }], |
| 103 | + stateMutability: "view", |
| 104 | + }, |
| 105 | + { |
| 106 | + type: "function", |
| 107 | + name: "decimals", |
| 108 | + inputs: [], |
| 109 | + outputs: [{ name: "", type: "uint8", internalType: "uint8" }], |
| 110 | + stateMutability: "view", |
| 111 | + }, |
| 112 | + { |
| 113 | + type: "function", |
| 114 | + name: "totalSupply", |
| 115 | + inputs: [], |
| 116 | + outputs: [{ name: "", type: "uint256", internalType: "uint256" }], |
| 117 | + stateMutability: "view", |
| 118 | + }, |
| 119 | + { |
| 120 | + type: "function", |
| 121 | + name: "balanceOf", |
| 122 | + inputs: [{ name: "account", type: "address", internalType: "address" }], |
| 123 | + outputs: [{ name: "", type: "uint256", internalType: "uint256" }], |
| 124 | + stateMutability: "view", |
| 125 | + }, |
| 126 | + { |
| 127 | + type: "function", |
| 128 | + name: "approve", |
| 129 | + inputs: [ |
| 130 | + { name: "spender", type: "address", internalType: "address" }, |
| 131 | + { name: "amount", type: "uint256", internalType: "uint256" }, |
| 132 | + ], |
| 133 | + outputs: [{ name: "", type: "bool", internalType: "bool" }], |
| 134 | + stateMutability: "nonpayable", |
| 135 | + }, |
| 136 | + { |
| 137 | + type: "function", |
| 138 | + name: "allowance", |
| 139 | + inputs: [ |
| 140 | + { name: "owner", type: "address", internalType: "address" }, |
| 141 | + { name: "spender", type: "address", internalType: "address" }, |
| 142 | + ], |
| 143 | + outputs: [{ name: "", type: "uint256", internalType: "uint256" }], |
| 144 | + stateMutability: "view", |
| 145 | + }, |
| 146 | +] as const; |
| 147 | + |
| 148 | +/** |
| 149 | + * Contract addresses on Base mainnet. |
| 150 | + */ |
| 151 | +export const PUMPCLAW_CONTRACT_ADDRESSES = { |
| 152 | + "base-mainnet": { |
| 153 | + Factory: "0xe5bCa0eDe9208f7Ee7FCAFa0415Ca3DC03e16a90", |
| 154 | + SwapRouter: "0x3A9c65f4510de85F1843145d637ae895a2Fe04BE", |
| 155 | + }, |
| 156 | +} as const; |
| 157 | + |
| 158 | +/** |
| 159 | + * Gets the PumpClaw Factory contract address for the specified network. |
| 160 | + * |
| 161 | + * @param network - The network ID to get the contract address for. |
| 162 | + * @returns The contract address for the specified network. |
| 163 | + * @throws Error if the specified network is not supported. |
| 164 | + */ |
| 165 | +export function getFactoryAddress(network: string): string { |
| 166 | + const addresses = |
| 167 | + PUMPCLAW_CONTRACT_ADDRESSES[ |
| 168 | + network.toLowerCase() as keyof typeof PUMPCLAW_CONTRACT_ADDRESSES |
| 169 | + ]; |
| 170 | + if (!addresses) { |
| 171 | + throw new Error( |
| 172 | + `Unsupported network: ${network}. Supported: ${Object.keys(PUMPCLAW_CONTRACT_ADDRESSES).join(", ")}`, |
| 173 | + ); |
| 174 | + } |
| 175 | + return addresses.Factory; |
| 176 | +} |
| 177 | + |
| 178 | +/** |
| 179 | + * Gets the PumpClaw SwapRouter contract address for the specified network. |
| 180 | + * |
| 181 | + * @param network - The network ID to get the contract address for. |
| 182 | + * @returns The contract address for the specified network. |
| 183 | + * @throws Error if the specified network is not supported. |
| 184 | + */ |
| 185 | +export function getSwapRouterAddress(network: string): string { |
| 186 | + const addresses = |
| 187 | + PUMPCLAW_CONTRACT_ADDRESSES[ |
| 188 | + network.toLowerCase() as keyof typeof PUMPCLAW_CONTRACT_ADDRESSES |
| 189 | + ]; |
| 190 | + if (!addresses) { |
| 191 | + throw new Error( |
| 192 | + `Unsupported network: ${network}. Supported: ${Object.keys(PUMPCLAW_CONTRACT_ADDRESSES).join(", ")}`, |
| 193 | + ); |
| 194 | + } |
| 195 | + return addresses.SwapRouter; |
| 196 | +} |
0 commit comments