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
19 changes: 19 additions & 0 deletions packages/relay-kit/src/packs/safe-4337/Safe4337Pack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,16 @@ export class Safe4337Pack extends RelayKitBasePack<{
})

if (estimateUserOperationGas) {
if (
feeEstimator.defaultVerificationGasLimitOverhead != null &&
estimateUserOperationGas.verificationGasLimit != null
) {
estimateUserOperationGas.verificationGasLimit = (
BigInt(estimateUserOperationGas.verificationGasLimit) +
BigInt(threshold) * feeEstimator.defaultVerificationGasLimitOverhead
).toString()
}

safeOperation.addEstimations(estimateUserOperationGas)
}

Expand All @@ -446,6 +456,15 @@ export class Safe4337Pack extends RelayKitBasePack<{
})

if (postEstimationData) {
if (
feeEstimator.defaultVerificationGasLimitOverhead != null &&
postEstimationData.verificationGasLimit != null
) {
postEstimationData.verificationGasLimit = (
BigInt(postEstimationData.verificationGasLimit) +
BigInt(threshold) * feeEstimator.defaultVerificationGasLimitOverhead
).toString()
}
safeOperation.addEstimations(postEstimationData)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,16 @@ export class GenericFeeEstimator implements IFeeEstimator {
nodeUrl: string
chainId: string
gasMultiplier: number
defaultVerificationGasLimitOverhead?: bigint

constructor(nodeUrl: string, chainId: string, gasMultiplier: number = 1.5) {
this.nodeUrl = nodeUrl
this.chainId = chainId
if (gasMultiplier <= 0) {
throw new Error("gasMultiplier can't be equal or less than 0.")
}
this.gasMultiplier = gasMultiplier
this.defaultVerificationGasLimitOverhead = 55_000n
}

async preEstimateUserOperationGas({
Expand Down
1 change: 1 addition & 0 deletions packages/relay-kit/src/packs/safe-4337/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ export type EstimateFeeFunction = ({
export interface IFeeEstimator {
preEstimateUserOperationGas?: EstimateFeeFunction
postEstimateUserOperationGas?: EstimateFeeFunction
defaultVerificationGasLimitOverhead?: bigint
}

export type EstimateFeeProps = {
Expand Down
Loading