Skip to content
Draft
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
node_modules/
.worktrees/
.idea/
*.iml
lerna-debug.log
Expand Down
18 changes: 13 additions & 5 deletions modules/abstract-eth/src/abstractEthLikeNewCoins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,11 @@ export const optionalDeps = {
export abstract class AbstractEthLikeNewCoins extends AbstractEthLikeCoin {
static hopTransactionSalt = 'bitgoHopAddressRequestSalt';
protected readonly sendMethodName: 'sendMultiSig' | 'sendMultiSigToken';
protected readonly coinFamiliesWithL1Fees: ReadonlyArray<'opeth' | 'dogeos' | 'morpheth'> = [
'opeth',
'dogeos',
'morpheth',
];

readonly staticsCoin?: Readonly<StaticsBaseCoin>;

Expand Down Expand Up @@ -1516,10 +1521,9 @@ export abstract class AbstractEthLikeNewCoins extends AbstractEthLikeCoin {
const backupKeyBalance = await this.queryAddressBalance(backupKeyAddress, params.apiKey);
let totalGasNeeded = gasPrice.mul(gasLimit);

// On optimism chain, L1 fees is to be paid as well apart from L2 fees
// So we are adding the amount that can be used up as l1 fees
if (this.staticsCoin?.family === 'opeth') {
totalGasNeeded = totalGasNeeded.add(new optionalDeps.ethUtil.BN(ethGasConfigs.opethGasL1Fees));
// On L2 chains with L1 data fees, add buffer for L1 fees
if (this.staticsCoin?.family !== undefined && this.coinFamiliesWithL1Fees.includes(this.staticsCoin.family)) {
totalGasNeeded = totalGasNeeded.add(new optionalDeps.ethUtil.BN(ethGasConfigs.l1GasFeeBuffer));
}

const weiToGwei = 10 ** 9;
Expand Down Expand Up @@ -2515,7 +2519,11 @@ export abstract class AbstractEthLikeNewCoins extends AbstractEthLikeCoin {

async validateBalanceAndGetTxAmount(baseAddress: string, gasPrice: BN, gasLimit: BN, apiKey?: string) {
const baseAddressBalance = await this.queryAddressBalance(baseAddress, apiKey);
const totalGasNeeded = gasPrice.mul(gasLimit);
let totalGasNeeded = gasPrice.mul(gasLimit);
// On L2 chains with L1 data fees, add buffer for L1 fees
if (this.staticsCoin?.family !== undefined && this.coinFamiliesWithL1Fees.includes(this.staticsCoin.family)) {
totalGasNeeded = totalGasNeeded.add(new optionalDeps.ethUtil.BN(ethGasConfigs.l1GasFeeBuffer));
}
const weiToGwei = new BN(10 ** 9);
if (baseAddressBalance.lt(totalGasNeeded)) {
throw new Error(
Expand Down
7 changes: 3 additions & 4 deletions modules/abstract-eth/src/ethLikeToken.ts
Original file line number Diff line number Diff line change
Expand Up @@ -276,10 +276,9 @@ export class EthLikeToken extends AbstractEthLikeNewCoins {

let totalGasNeeded = gasPrice.mul(gasLimit);

// On optimism chain, L1 fees is to be paid as well apart from L2 fees
// So we are adding the amount that can be used up as l1 fees
if (this.staticsCoin?.family === 'opeth') {
totalGasNeeded = totalGasNeeded.add(new optionalDeps.ethUtil.BN(ethGasConfigs.opethGasL1Fees));
// On L2 chains with L1 data fees (opeth, morpheth, dogeos), add buffer for L1 fees
if (['opeth', 'morpheth', 'dogeos'].includes(this.staticsCoin?.family ?? '')) {
totalGasNeeded = totalGasNeeded.add(new optionalDeps.ethUtil.BN(ethGasConfigs.l1GasFeeBuffer));
}

const weiToGwei = 10 ** 9;
Expand Down
2 changes: 1 addition & 1 deletion modules/statics/src/tokenConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ export const ethGasConfigs = {
minimumGasLimit: 30000, // minimum gas limit a user can set for a send
maximumGasLimit: 20000000, // Customers cannot set gas limits beyond this amount
newEthLikeCoinsMinGasLimit: 400000, // minimum gas limit a user can set for a send for eth like coins like arbitrum, optimism, etc
opethGasL1Fees: 1000000000000000, // Buffer for opeth L1 gas fees
l1GasFeeBuffer: 1000000000000000, // Buffer for L1 data fees
};

function getStellarTokenConfig(coin: StellarCoin): StellarTokenConfig {
Expand Down
Loading