Skip to content

Commit

Permalink
Merge branch 'master' of github.com:etherspot/arka into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
nikhilkumar1612 committed Jan 25, 2025
2 parents a924657 + 8142feb commit 9b5723c
Show file tree
Hide file tree
Showing 10 changed files with 57 additions and 15 deletions.
40 changes: 40 additions & 0 deletions backend/config.json.default
Original file line number Diff line number Diff line change
Expand Up @@ -418,5 +418,45 @@
"thresholdValue": "0.016",
"MultiTokenPaymasterOracleUsed": "orochi",
"entryPoint": "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789"
},
{
"chainId": 44787,
"bundler": "https://testnet-rpc.etherspot.io/v1/44787",
"contracts": {
"etherspotPaymasterAddress": "0x590Cf408033f6516F5CBA15189033bF7452fDa0c"
},
"thresholdValue": "0.016",
"MultiTokenPaymasterOracleUsed": "chainlink",
"entryPoint": "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789"
},
{
"chainId": 44787,
"bundler": "https://testnet-rpc.etherspot.io/v2/44787",
"contracts": {
"etherspotPaymasterAddress": "0x18d9405bfdd22ea84c0b481e0aaa4638e4f71af4"
},
"thresholdValue": "0.016",
"MultiTokenPaymasterOracleUsed": "chainlink",
"entryPoint": "0x0000000071727De22E5E9d8BAf0edAc6f37da032"
},
{
"chainId": 42220,
"bundler": "https://rpc.etherspot.io/v1/42220",
"contracts": {
"etherspotPaymasterAddress": "0x46dC4A1804de656551Ff30A53dd39ED373B30520"
},
"thresholdValue": "0.016",
"MultiTokenPaymasterOracleUsed": "chainlink",
"entryPoint": "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789"
},
{
"chainId": 42220,
"bundler": "https://rpc.etherspot.io/v2/42220",
"contracts": {
"etherspotPaymasterAddress": "0x5952653f151e844346825050d7157a9a6b46a23a"
},
"thresholdValue": "0.016",
"MultiTokenPaymasterOracleUsed": "chainlink",
"entryPoint": "0x0000000071727De22E5E9d8BAf0edAc6f37da032"
}
]
1 change: 1 addition & 0 deletions backend/demo.env
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ WEBHOOK_URL=
# coingecko
COINGECKO_URL=
COINGECKO_API_KEY=
MTP_VGL_MARKUP=30000
4 changes: 3 additions & 1 deletion backend/src/paymaster/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ interface CoingeckoPriceCache {
export class Paymaster {
feeMarkUp: BigNumber;
multiTokenMarkUp: number;
MTP_VGL_MARKUP: string;
EP7_TOKEN_VGL: string;
EP7_TOKEN_PGL: string;
priceAndMetadata: Map<string, TokenPriceAndMetadataCache> = new Map();
Expand All @@ -58,13 +59,14 @@ export class Paymaster {
coingeckoService: CoingeckoService = new CoingeckoService();
sequelize: Sequelize;

constructor(feeMarkUp: string, multiTokenMarkUp: string, ep7TokenVGL: string, ep7TokenPGL: string, sequelize: Sequelize) {
constructor(feeMarkUp: string, multiTokenMarkUp: string, ep7TokenVGL: string, ep7TokenPGL: string, sequelize: Sequelize, mtpVglMarkup: string) {
this.feeMarkUp = ethers.utils.parseUnits(feeMarkUp, 'gwei');
if (isNaN(Number(multiTokenMarkUp))) this.multiTokenMarkUp = 1150000 // 15% more of the actual cost. Can be anything between 1e6 to 2e6
else this.multiTokenMarkUp = Number(multiTokenMarkUp);
this.EP7_TOKEN_PGL = ep7TokenPGL;
this.EP7_TOKEN_VGL = ep7TokenVGL;
this.sequelize = sequelize;
this.MTP_VGL_MARKUP = mtpVglMarkup;
}

packUint(high128: BigNumberish, low128: BigNumberish): string {
Expand Down
5 changes: 4 additions & 1 deletion backend/src/plugins/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ const ConfigSchema = Type.Strict(
DEFAULT_BUNDLER_API_KEY: Type.String(),
MULTI_TOKEN_PAYMASTERS: Type.String(),
MULTI_TOKEN_ORACLES: Type.String(),
MTP_VGL_MARKUP: Type.String() || '30000',
})
);

Expand Down Expand Up @@ -73,7 +74,8 @@ const configPlugin: FastifyPluginAsync = async (server) => {
USE_KMS: process.env.USE_KMS,
DEFAULT_BUNDLER_API_KEY: process.env.DEFAULT_BUNDLER_API_KEY,
MULTI_TOKEN_PAYMASTERS: process.env.MULTI_TOKEN_PAYMASTERS,
MULTI_TOKEN_ORACLES: process.env.MULTI_TOKEN_ORACLES
MULTI_TOKEN_ORACLES: process.env.MULTI_TOKEN_ORACLES,
MTP_VGL_MARKUP: process.env.MTP_VGL_MARKUP
}

const valid = validate(envVar);
Expand Down Expand Up @@ -109,6 +111,7 @@ const configPlugin: FastifyPluginAsync = async (server) => {
DEFAULT_BUNDLER_API_KEY: process.env.DEFAULT_BUNDLER_API_KEY ?? '',
MULTI_TOKEN_PAYMASTERS: process.env.MULTI_TOKEN_PAYMASTERS ?? '',
MULTI_TOKEN_ORACLES: process.env.MULTI_TOKEN_ORACLES ?? '',
MTP_VGL_MARKUP: process.env.MTP_VGL_MARKUP ?? '30000'
}

server.log.info(config, "config:");
Expand Down
2 changes: 1 addition & 1 deletion backend/src/routes/admin-routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { getNetworkConfig } from "../utils/common.js";
import { Paymaster } from "../paymaster/index.js";

const adminRoutes: FastifyPluginAsync = async (server) => {
const paymaster = new Paymaster(server.config.FEE_MARKUP, server.config.MULTI_TOKEN_MARKUP, server.config.EP7_TOKEN_VGL, server.config.EP7_TOKEN_PGL);
const paymaster = new Paymaster(server.config.FEE_MARKUP, server.config.MULTI_TOKEN_MARKUP, server.config.EP7_TOKEN_VGL, server.config.EP7_TOKEN_PGL, server.sequelize, server.config.MTP_VGL_MARKUP);

const prefixSecretId = 'arka_';

Expand Down
4 changes: 2 additions & 2 deletions backend/src/routes/deposit-route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { printRequest, getNetworkConfig } from "../utils/common.js";
import { APIKey } from "../models/api-key.js";

const depositRoutes: FastifyPluginAsync = async (server) => {
const paymaster = new Paymaster(server.config.FEE_MARKUP, server.config.MULTI_TOKEN_MARKUP, server.config.EP7_TOKEN_VGL, server.config.EP7_TOKEN_PGL, server.sequelize);
const paymaster = new Paymaster(server.config.FEE_MARKUP, server.config.MULTI_TOKEN_MARKUP, server.config.EP7_TOKEN_VGL, server.config.EP7_TOKEN_PGL, server.sequelize, server.config.MTP_VGL_MARKUP);

const SUPPORTED_ENTRYPOINTS = {
EPV_06: server.config.EPV_06,
Expand Down Expand Up @@ -178,4 +178,4 @@ const depositRoutes: FastifyPluginAsync = async (server) => {
)
};

export default depositRoutes;
export default depositRoutes;
7 changes: 2 additions & 5 deletions backend/src/routes/metadata-routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,10 +213,7 @@ const metadataRoutes: FastifyPluginAsync = async (server) => {
chainsSupported: chainsSupported,
tokenPaymasters: tokenPaymasterAddresses,
multiTokenPaymasters,
sponsorDetails: { name: sponsorName, icon: sponsorImage },
verifyingPaymaster: { address: verifyingPaymaster, deposit: verifyingPaymasterDeposit },
verifyingPaymasters: apiKeyEntity.verifyingPaymasters ? JSON.parse(apiKeyEntity.verifyingPaymasters) : undefined,
verifyingPaymastersV2: apiKeyEntity.verifyingPaymastersV2 ? JSON.parse(apiKeyEntity.verifyingPaymastersV2) : undefined,
sponsorDetails: { name: sponsorName, icon: sponsorImage }
})
} catch (err: any) {
request.log.error(err);
Expand All @@ -227,4 +224,4 @@ const metadataRoutes: FastifyPluginAsync = async (server) => {
})
}

export default metadataRoutes;
export default metadataRoutes;
2 changes: 1 addition & 1 deletion backend/src/routes/paymaster-routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -497,4 +497,4 @@ const paymasterRoutes: FastifyPluginAsync<PaymasterRoutesOpts> = async (server,
}
};

export default paymasterRoutes;
export default paymasterRoutes;
4 changes: 2 additions & 2 deletions backend/src/routes/whitelist-routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { APIKey } from "../models/api-key.js";
import { ContractWhitelistDto } from "../types/contractWhitelist-dto.js";

const whitelistRoutes: FastifyPluginAsync = async (server) => {
const paymaster = new Paymaster(server.config.FEE_MARKUP, server.config.MULTI_TOKEN_MARKUP, server.config.EP7_TOKEN_VGL, server.config.EP7_TOKEN_PGL, server.sequelize);
const paymaster = new Paymaster(server.config.FEE_MARKUP, server.config.MULTI_TOKEN_MARKUP, server.config.EP7_TOKEN_VGL, server.config.EP7_TOKEN_PGL, server.sequelize, server.config.MTP_VGL_MARKUP);

const SUPPORTED_ENTRYPOINTS = {
EPV_06: server.config.EPV_06,
Expand Down Expand Up @@ -801,4 +801,4 @@ const whitelistRoutes: FastifyPluginAsync = async (server) => {
)
};

export default whitelistRoutes;
export default whitelistRoutes;
3 changes: 1 addition & 2 deletions backend/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,13 @@ const initializeServer = async (): Promise<void> => {

// Register the sequelizePlugin
await server.register(sequelizePlugin);
const paymaster = new Paymaster(server.config.FEE_MARKUP, server.config.MULTI_TOKEN_MARKUP, server.config.EP7_TOKEN_VGL, server.config.EP7_TOKEN_PGL, server.sequelize, server.config.MTP_VGL_MARKUP);

// Synchronize all models
await server.sequelize.sync();

server.log.info('registered sequelizePlugin...')

const paymaster = new Paymaster(server.config.FEE_MARKUP, server.config.MULTI_TOKEN_MARKUP, server.config.EP7_TOKEN_VGL, server.config.EP7_TOKEN_PGL, server.sequelize);

await server.register(paymasterRoutes, { paymaster });

await server.register(adminRoutes);
Expand Down

0 comments on commit 9b5723c

Please sign in to comment.