Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions backend/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# Changelog
## [3.1.6] - 2025-04-02
### Fixes
- Fixed bug in paymaster estimation for multiTokenPaymaster getERC20Quotes API

## [3.1.5] - 2025-03-24
### Fixes
- Added all tokens used in multiTokenPaymaster to have decimals in constants rather than fetching from rpc
Expand Down
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": "3.1.5",
"version": "3.1.6",
"description": "ARKA - (Albanian for Cashier's case) is the first open source Paymaster as a service software",
"type": "module",
"directories": {
Expand Down
18 changes: 18 additions & 0 deletions backend/src/paymaster/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -550,6 +550,7 @@ export class Paymaster {
bundlerRpc: string,
oracleName: string,
nativeOracleAddress: string,
signer: Wallet,
log?: FastifyBaseLogger
) {
try {
Expand All @@ -574,6 +575,23 @@ export class Paymaster {
let ETHUSDPrice: any, ETHUSDPriceDecimal;
const paymasterKey = Object.keys(multiTokenPaymasters[chainId])[0];
let response, unaccountedCost;
const validUntil = new Date();
const validAfter = new Date();
const hex = (Number((validUntil.valueOf() / 1000).toFixed(0)) + 600).toString(16);
const hex1 = (Number((validAfter.valueOf() / 1000).toFixed(0)) - 60).toString(16);
let str = '0x'
let str1 = '0x'
for (let i = 0; i < 14 - hex.length; i++) {
str += '0';
}
for (let i = 0; i < 14 - hex1.length; i++) {
str1 += '0';
}
str += hex;
str1 += hex1;
const paymasterContract = new ethers.Contract(multiTokenPaymasters[chainId][paymasterKey], MultiTokenPaymasterAbi, provider);
// Assuming the token price is 1 USD since this is just used for the gas estimation and the paymasterAndData generated will not be sent on response
userOp.paymasterAndData = await this.getPaymasterAndDataForMultiTokenPaymaster(userOp, str, str1, paymasterKey, '100000000', paymasterContract, signer, chainId);
if (oracleName === "chainlink") {
const res = await this.getEstimateUserOperationGasAndData(
provider,
Expand Down
4 changes: 3 additions & 1 deletion backend/src/routes/paymaster-routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,9 @@ const paymasterRoutes: FastifyPluginAsync<PaymasterRoutesOpts> = async (server,
if (!multiTokenPaymasters[chainId]) return reply.code(ReturnCode.FAILURE).send({ error: ErrorMessage.MULTI_NOT_DEPLOYED + chainId })
if (networkConfig.MultiTokenPaymasterOracleUsed == "chainlink" && !NativeOracles[chainId])
throw new Error("Native Oracle address not set for this chainId")
result = await paymaster.getQuotesMultiToken(userOp, entryPoint, chainId, multiTokenPaymasters, tokens_list, multiTokenOracles, bundlerUrl, networkConfig.MultiTokenPaymasterOracleUsed, NativeOracles[chainId], server.log);
const provider = new providers.JsonRpcProvider(bundlerUrl);
const signer = new Wallet(privateKey, provider)
result = await paymaster.getQuotesMultiToken(userOp, entryPoint, chainId, multiTokenPaymasters, tokens_list, multiTokenOracles, bundlerUrl, networkConfig.MultiTokenPaymasterOracleUsed, NativeOracles[chainId], signer, server.log);
}
else {
if (gasToken && ethers.utils.isAddress(gasToken)) gasToken = ethers.utils.getAddress(gasToken)
Expand Down