diff --git a/backend/src/paymaster/index.ts b/backend/src/paymaster/index.ts index 732eaf4..200bc9a 100644 --- a/backend/src/paymaster/index.ts +++ b/backend/src/paymaster/index.ts @@ -236,12 +236,11 @@ export class Paymaster { result.gasEstimates.verificationGasLimit = response.verificationGasLimit; result.feeEstimates.maxFeePerGas = response.maxFeePerGas; result.feeEstimates.maxPriorityFeePerGas = response.maxPriorityFeePerGas; - if (!multiTokenPaymasters[chainId]) { - const paymasterAddress = multiTokenPaymasters[chainId][tokens_list[0]]; - result.paymasterAddress = paymasterAddress; - const paymasterContract = new ethers.Contract(paymasterAddress, MultiTokenPaymasterAbi, provider); - result.postOpGas = await paymasterContract.UNACCOUNTED_COST; - } + + const paymasterKey = Object.keys(multiTokenPaymasters[chainId])[0]; + result.paymasterAddress = multiTokenPaymasters[chainId][paymasterKey]; + const paymasterContract = new ethers.Contract(result.paymasterAddress , MultiTokenPaymasterAbi, provider); + result.postOpGas = await paymasterContract.UNACCOUNTED_COST; for (let i = 0; i < tokens_list.length; i++) { const gasToken = tokens_list[i]; @@ -267,17 +266,17 @@ export class Paymaster { ethPrice = Number(ethers.utils.formatUnits(result, decimals)).toFixed(0); } result.etherUSDExchangeRate = BigNumber.from(ethPrice).toHexString(); - const exchangeRate = 1000000; // This is for setting min tokens required for the txn that gets validated on estimate - const rate = ethers.BigNumber.from(exchangeRate).mul(ethPrice); const tokenContract = new ethers.Contract(gasToken, ERC20Abi, provider) const decimals = await tokenContract.decimals(); + const exchangeRate = 1000000; // This is for setting min tokens required for the txn that gets validated on estimate + const rate = ethers.BigNumber.from(exchangeRate).mul(ethPrice); const symbol = await tokenContract.symbol(); quotes.push({ token: gasToken, symbol: symbol, decimals: decimals, etherTokenExchangeRate: rate.toHexString(), - serviceFeePercent: this.multiTokenMarkUp - 1000000 + serviceFeePercent: (this.multiTokenMarkUp/10000 - 100) }) } } diff --git a/backend/src/routes/paymaster-routes.ts b/backend/src/routes/paymaster-routes.ts index a68c95e..08b469d 100644 --- a/backend/src/routes/paymaster-routes.ts +++ b/backend/src/routes/paymaster-routes.ts @@ -215,6 +215,7 @@ const paymasterRoutes: FastifyPluginAsync = async (server) => { if (!networkConfig.MultiTokenPaymasterOracleUsed || !(networkConfig.MultiTokenPaymasterOracleUsed == "orochi" || networkConfig.MultiTokenPaymasterOracleUsed == "chainlink" || networkConfig.MultiTokenPaymasterOracleUsed == "etherspotChainlink")) throw new Error("Oracle is not Defined/Invalid"); + if (!multiTokenPaymasters[chainId]) return reply.code(ReturnCode.FAILURE).send({ error: ErrorMessage.UNSUPPORTED_NETWORK }) result = await paymaster.getQuotesMultiToken(userOp, entryPoint, chainId, multiTokenPaymasters, tokens_list, multiTokenOracles, bundlerUrl, networkConfig.MultiTokenPaymasterOracleUsed, server.log); } else {