Skip to content

Commit

Permalink
bug fixes (#141)
Browse files Browse the repository at this point in the history
* bug fixes

* updated package version
  • Loading branch information
vignesha22 authored Sep 30, 2024
1 parent 484d88f commit 3ef3de1
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion backend/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "arka",
"version": "1.6.0",
"version": "1.6.1",
"description": "ARKA - (Albanian for Cashier's case) is the first open source Paymaster as a service software",
"type": "module",
"directories": {
Expand Down
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 3ef3de1

Please sign in to comment.