瀏覽代碼

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

Shawn Lu 1 年之前
父節點
當前提交
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 lzGasCost = await this.getL0GasCost(toChainId)
     const { gasCost, gasPrice, gasLimit } = await this.calculateGasCost(toChainId, routerEth, lzGasCost)
     const { gasCost, gasPrice, gasLimit } = await this.calculateGasCost(toChainId, routerEth, lzGasCost)
     let cost = gasCost
     let cost = gasCost
+    let limit = gasLimit
     return await polly()
     return await polly()
       .retry(5)
       .retry(5)
       .executeForPromise(async info => {
       .executeForPromise(async info => {
@@ -61,6 +62,7 @@ export class StargateClient {
           }
           }
           // add 30% gas cost for each retry
           // add 30% gas cost for each retry
           cost = (cost * 120n) / 100n
           cost = (cost * 120n) / 100n
+          limit = (limit * 120n) / 100n
           const sendAmount = balance - lzGasCost - cost
           const sendAmount = balance - lzGasCost - cost
           // const sendAmount = ethers.parseEther('0.01')
           // const sendAmount = ethers.parseEther('0.01')
           const minReceiveAmount = (sendAmount * 995n) / 1000n
           const minReceiveAmount = (sendAmount * 995n) / 1000n
@@ -70,7 +72,7 @@ export class StargateClient {
             this.wallet.address,
             this.wallet.address,
             sendAmount,
             sendAmount,
             minReceiveAmount,
             minReceiveAmount,
-            { value: sendAmount + lzGasCost, gasLimit, gasPrice },
+            { value: sendAmount + lzGasCost, gasLimit: limit, gasPrice },
           )
           )
           const receipt = await res.wait()
           const receipt = await res.wait()
           if (!receipt.status) {
           if (!receipt.status) {