-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #82 from liquality/get-send-gas-limit-for-erc20
feat: getSendGasLimitERC20
- Loading branch information
Showing
6 changed files
with
87 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,30 @@ | ||
import { ChainId } from '../types' | ||
import { hasTokens } from '../chains' | ||
|
||
const sendGasLimits = { | ||
BTC: 290, | ||
NATIVE_EVM: 21000, // EVM -> ETH, RBTC, MATIC, BNB, AVAX, FUSE | ||
ERC20_EVM: 90000, // EVM -> ETH, RBTC, MATIC, BNB, AVAX, FUSE | ||
TERRA: 100000, // applies on both native and ERC2 Terra assets | ||
ARBETH: 620000, | ||
ARBETH: 620000, // for native asset is around ~420k and for ERC20 ~540k | ||
NEAR: 10000000000000, | ||
SOL: 1000000 | ||
} | ||
|
||
export { sendGasLimits } | ||
const getSendGasLimitERC20 = (chainId: ChainId): number | null => { | ||
if (!hasTokens(chainId)) { | ||
throw new Error(`Chain '${chainId}' doesn't support tokens!`) | ||
} | ||
|
||
switch (chainId) { | ||
case ChainId.Arbitrum: | ||
return sendGasLimits.ARBETH | ||
case ChainId.Terra: | ||
return sendGasLimits.TERRA | ||
default: | ||
// EVM standard gas limit | ||
return sendGasLimits.ERC20_EVM | ||
} | ||
} | ||
|
||
export { sendGasLimits, getSendGasLimitERC20 } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters