Reputation: 77
I'm trying to get the best route to convert my WETH to DAI, on an Anvil fork using an Arbitrum provider (through Infura).
anvil --fork-url https://arbitrum-mainnet.infura.io/v3/<api_key> --auto-impersonate
The router.route method (which I'm calling through an arbitrum mainnet provider instead of the fork) gives me the following methodParameters.:
const router = new AlphaRouter({
chainId: CHAIN_ID,
provider: mainnetProvider,
gasPriceProvider: customGasPriceProvider,
});
const swapOptions: SwapOptionsUniversalRouter = {
type: SwapType.UNIVERSAL_ROUTER,
recipient: WALLET_ADDRESS,
slippageTolerance: SLIPPAGE_TOLERANCE, // Use the increased slippage tolerance
deadline: Math.floor(Date.now() / 1000 + 1800), // 30 minutes
version: UniversalRouterVersion.V2_0,
};
const route = await router.route(
amountInCurrency,
tokenOut,
TradeType.EXACT_INPUT,
swapOptions,
);
---
Quote: {
calldata: "0x24856bc30000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000100000000000000000000000000f39fd6e51aad88f6f4ce6ab8827279cfffb92266000000000000000000000000000000000000000000000000016345785d8a000000000000000000000000000000000000000000000000000d7a1480e25ad9e73a00000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002b82af49447d8a07e3bd95bd0d56f35241523fbab1000bb8da10009cbd5d07dd0cecc66161fc93d7c9000da1000000000000000000000000000000000000000000",
value: "0x00",
to: "0x5E325eDA8064b456f4781070C0738d849c824258"
}
On executing this transaction like below though (referring from https://docs.uniswap.org/contracts/universal-router/technical-reference), I get a CALL_EXCEPTION error, which has no specific details. I confirmed that the contract is accessible and that the code exists using provider.getCode(). I'm using Uniswap's Universal Router (https://github.com/Uniswap/universal-router/blob/main/deploy-addresses/arbitrum.json), and get the same error on each of the mentioned router addresses. I have approved the WETH token contract for permit2, for the max possible amount. Also, I get the same error without the auto-impersonate flag on anvil as well.
Am I using the calldata wrongly here? Am I supposed to parse the Command string and call the execute method of the Uniswap router on my own? How can I further debug this?
const txData: ethers.providers.TransactionRequest = {
to: UNIVERSAL_ROUTER_ADDRESS,
data: quote.methodParameters.calldata,
value: quote.methodParameters?.value,
};
const DEFAULT_GAS_LIMIT = 210000;
gasEstimate = ethers.BigNumber.from(DEFAULT_GAS_LIMIT);
const response = await signer.sendTransaction({
...txData,
gasLimit,
});
Error:
{
reason: "transaction failed",
code: "CALL_EXCEPTION",
transactionHash: "0xa30df757e65bb4c6cb256442aa92f0ecb1e8c7b6f090ffd37b8cdcf3254b21a4",
transaction: {
type: 2,
chainId: 42161,
nonce: 3710,
maxPriorityFeePerGas: BigNumber { _hex: "0x59682f00", _isBigNumber: true },
maxFeePerGas: BigNumber { _hex: "0x59d10b76", _isBigNumber: true },
gasPrice: null,
gasLimit: BigNumber { _hex: "0x03d860", _isBigNumber: true },
to: "0xeC8B0F7Ffe3ae75d7FfAb09429e3675bb63503e4",
value: BigNumber { _hex: "0x00", _isBigNumber: true },
data: "0x24856bc30000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000100000000000000000000000000f39fd6e51aad88f6f4ce6ab8827279cfffb92266000000000000000000000000000000000000000000000000016345785d8a000000000000000000000000000000000000000000000000000d785e1109975ea67400000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002b82af49447d8a07e3bd95bd0d56f35241523fbab1000bb8da10009cbd5d07dd0cecc66161fc93d7c9000da1000000000000000000000000000000000000000000",
accessList: [],
hash: "0xa30df757e65bb4c6cb256442aa92f0ecb1e8c7b6f090ffd37b8cdcf3254b21a4",
v: 1,
r: "0x4f08707258d9b26676e7bf5569188f350483eb1db4ee6f637375b1ecbcc7fc7d",
s: "0x4e9cd2da83097ddf5ad5af6fc1a26bd580d631ca7a2428644f720e05cb96ac46",
from: "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266",
confirmations: 0,
wait: [Function (anonymous)]
},
receipt: {
to: "0xeC8B0F7Ffe3ae75d7FfAb09429e3675bb63503e4",
from: "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266",
contractAddress: null,
transactionIndex: 0,
root: "0x0000000000000000000000000000000000000000000000000000000000000000",
gasUsed: BigNumber { _hex: "0x01c5ae", _isBigNumber: true },
logsBloom: "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
blockHash: "0x508005f081deeb7dfdbc89dc58956c782b611a38ec9d8ff6c193206c8a9b0899",
transactionHash: "0xa30df757e65bb4c6cb256442aa92f0ecb1e8c7b6f090ffd37b8cdcf3254b21a4",
logs: [],
blockNumber: 21025547,
confirmations: 245660339,
cumulativeGasUsed: BigNumber { _hex: "0x01c5ae", _isBigNumber: true },
effectiveGasPrice: BigNumber { _hex: "0x59960f74", _isBigNumber: true },
status: 0,
type: 2,
byzantium: true
}
}
Upvotes: 0
Views: 206