Просмотр исходного кода

increase gas limit when retrying... try to resolve consecutive revert issue... damn

Shawn Lu 1 год назад
Родитель
Сommit
0f2e03d7ff
1 измененных файлов с 3 добавлено и 1 удалено
  1. 3 1
      src/bridge/StargateClient.ts

+ 3 - 1
src/bridge/StargateClient.ts

@@ -49,6 +49,7 @@ export class StargateClient {
     const lzGasCost = await this.getL0GasCost(toChainId)
     const { gasCost, gasPrice, gasLimit } = await this.calculateGasCost(toChainId, routerEth, lzGasCost)
     let cost = gasCost
+    let limit = gasLimit
     return await polly()
       .retry(5)
       .executeForPromise(async info => {
@@ -61,6 +62,7 @@ export class StargateClient {
           }
           // add 30% gas cost for each retry
           cost = (cost * 120n) / 100n
+          limit = (limit * 120n) / 100n
           const sendAmount = balance - lzGasCost - cost
           // const sendAmount = ethers.parseEther('0.01')
           const minReceiveAmount = (sendAmount * 995n) / 1000n
@@ -70,7 +72,7 @@ export class StargateClient {
             this.wallet.address,
             sendAmount,
             minReceiveAmount,
-            { value: sendAmount + lzGasCost, gasLimit, gasPrice },
+            { value: sendAmount + lzGasCost, gasLimit: limit, gasPrice },
           )
           const receipt = await res.wait()
           if (!receipt.status) {