Skip to content

Commit

Permalink
bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
vignesha22 committed Sep 30, 2024
1 parent 484d88f commit 4632386
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
17 changes: 8 additions & 9 deletions backend/src/paymaster/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand All @@ -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)
})
}
}
Expand Down
1 change: 1 addition & 0 deletions backend/src/routes/paymaster-routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 4632386

Please sign in to comment.