From c529832325a36bc219d9ba04f8b831538d273f00 Mon Sep 17 00:00:00 2001 From: Zikriya Date: Wed, 21 Feb 2024 17:23:57 +0500 Subject: [PATCH] Interface added for forge. addBuffer function modified. configurations model updated for forge --- app/interfaces/forgeInterface.ts | 30 +++++++++++++++++++ .../gasFeeHelpers/gasEstimationHelper.ts | 16 ++++++++-- app/models/configurations.ts | 2 ++ 3 files changed, 46 insertions(+), 2 deletions(-) create mode 100644 app/interfaces/forgeInterface.ts diff --git a/app/interfaces/forgeInterface.ts b/app/interfaces/forgeInterface.ts new file mode 100644 index 0000000..d995d56 --- /dev/null +++ b/app/interfaces/forgeInterface.ts @@ -0,0 +1,30 @@ +export interface Contract { + rpcUrl: string; + contractAddress: string; +} + +export interface WithdrawSigned { + targetTokenAddress: string; + destinationWalletAddress: string; + destinationAmountIn: string; + salt: string; + signatureExpiry: number; + signature: string; +} + +export interface WithdrawSignedAndSwapOneInch { + destinationWalletAddress: string; + destinationAmountIn: string; + destinationAmountOut: string; + targetFoundryTokenAddress: string; + targetTokenAddress: string; + destinationOneInchData: string; + salt: string; + signatureExpiry: number; + signature: string; +} + +export interface DestinationGasEstimationResponse { + gasPriceInNumber: string; + gasPriceInMachine: string; +} diff --git a/app/lib/middlewares/helpers/gasFeeHelpers/gasEstimationHelper.ts b/app/lib/middlewares/helpers/gasFeeHelpers/gasEstimationHelper.ts index 6f37387..7f2c220 100644 --- a/app/lib/middlewares/helpers/gasFeeHelpers/gasEstimationHelper.ts +++ b/app/lib/middlewares/helpers/gasFeeHelpers/gasEstimationHelper.ts @@ -66,7 +66,19 @@ export const isAllowedDynamicGasValues = async ( return item?.isAllowedDynamicGasLimit ? true : false; }; -export const addBuffer = (amount: any): any => { +export const addBuffer = (amount: any, buffer: number): any => { console.log("beForBufferGasLimit", amount?.toString()); - return amount.mul(110).div(100); + buffer = 100 + buffer; + amount = amount.mul(buffer).div(100); + amount = parseInt(amount?.toString()); + console.log("afterBufferGasLimit", amount?.toString(), "buffer", buffer); + return amount; +}; + +export const addBuffer_ = (amount: any, buffer: number): any => { + console.log("beForBufferGasLimit", amount?.toString()); + buffer = 100 + buffer; + amount = amount.mul(buffer).div(100); + console.log("afterBufferGasLimit", amount?.toString(), "buffer", buffer); + return amount; }; diff --git a/app/models/configurations.ts b/app/models/configurations.ts index e6486d6..7b684a2 100644 --- a/app/models/configurations.ts +++ b/app/models/configurations.ts @@ -8,6 +8,8 @@ var schema = mongoose.Schema( slippage: { type: Number, default: 0 }, nativeTokens: [ { + chainId: { type: String, default: "" }, + symbol: { type: String, default: "" }, address: { type: String, default: "" }, wrappedAddress: { type: String, default: "" }, oneInchAddress: { type: String, default: "" },