|
@@ -1,6 +1,6 @@
|
|
|
import { ethers } from 'ethers'
|
|
|
import { Router__factory, RouterETH, RouterETH__factory, StargateFeeLibraryV07__factory } from '../contract'
|
|
|
-import { chainInfoMap } from '../config/chain'
|
|
|
+import { ChainId, chainInfoMap } from '../config/chain'
|
|
|
import polly from 'polly-js'
|
|
|
import { newLogger } from '../utils/logger'
|
|
|
|
|
@@ -45,6 +45,7 @@ export class StargateClient {
|
|
|
}
|
|
|
|
|
|
async bridge(toChainId: number) {
|
|
|
+ if(toChainId === ChainId.ZKSYNC) throw new Error('Unsupported.')
|
|
|
return await polly()
|
|
|
.waitAndRetry([1000 * 60, 1000 * 60 * 2, 1000 * 60 * 3])
|
|
|
.executeForPromise(async info => {
|
|
@@ -60,9 +61,10 @@ export class StargateClient {
|
|
|
if (info.count > 0) {
|
|
|
StargateClient.logger.info(`${this.wallet.address}: Retry ${info.count} times`)
|
|
|
}
|
|
|
- // add 30% gas cost for each retry
|
|
|
- cost = (cost * 120n) / 100n
|
|
|
- limit = (limit * 120n) / 100n
|
|
|
+ const rate = BigInt(info.count) * 30n + 100n
|
|
|
+ // add 20% gas cost for each retry
|
|
|
+ cost = (cost * rate) / 100n
|
|
|
+ limit = (limit * rate) / 100n
|
|
|
const sendAmount = balance - lzGasCost - cost
|
|
|
// const sendAmount = ethers.parseEther('0.01')
|
|
|
const minReceiveAmount = (sendAmount * 995n) / 1000n
|
|
@@ -101,6 +103,6 @@ export class StargateClient {
|
|
|
},
|
|
|
)
|
|
|
// const gasCost = ((this.chainId === 110 ? gasPrice : ethers.parseUnits('0.6', 'gwei')) * gasLimit * 110n) / 100n
|
|
|
- return { gasCost: ethers.parseEther('0.0004'), gasPrice, gasLimit }
|
|
|
+ return { gasCost: ethers.parseEther('0.0001'), gasPrice, gasLimit: (gasLimit * 150n) / 100n }
|
|
|
}
|
|
|
}
|