Skip to content

Commit

Permalink
update noble gas price
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryz0nd committed May 13, 2024
1 parent ea5a836 commit b8adf4a
Showing 1 changed file with 21 additions and 4 deletions.
25 changes: 21 additions & 4 deletions src/lib/abacus/dydxChainTransactions.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { EncodeObject } from '@cosmjs/proto-signing';
import type { IndexedTx } from '@cosmjs/stargate';
import { GasPrice, type IndexedTx } from '@cosmjs/stargate';
import Abacus, { type Nullable } from '@dydxprotocol/v4-abacus';
import { GAS_MULTIPLIER, encodeJson } from '@dydxprotocol/v4-client-js';
import {
Expand Down Expand Up @@ -30,8 +30,9 @@ import {
type HumanReadableTransferPayload,
} from '@/constants/abacus';
import { DEFAULT_TRANSACTION_MEMO } from '@/constants/analytics';
import { DydxChainId, isTestnet } from '@/constants/networks';
import { DydxChainId, isMainnet, isTestnet } from '@/constants/networks';
import { UNCOMMITTED_ORDER_TIMEOUT_MS } from '@/constants/trade';
import { NOBLE_MAINNET_CHAIN_INFO, NOBLE_TESTNET_CHAIN_INFO } from '@/constants/wallets';

import { RootStore } from '@/state/_store';
import { addUncommittedOrderClientId, removeUncommittedOrderClientId } from '@/state/account';
Expand Down Expand Up @@ -378,7 +379,15 @@ class DydxChainTransactions implements AbacusDYDXChainTransactionsProtocol {
: undefined,
},
};
const fee = await this.nobleClient.simulateTransaction([ibcMsg]);

const averageGasPriceStep = (
isMainnet ? NOBLE_MAINNET_CHAIN_INFO : NOBLE_TESTNET_CHAIN_INFO
).feeCurrencies.find((currency) => currency.coinMinimalDenom === 'uusdc')?.gasPriceStep
?.average;
const nobleGasPrice = averageGasPriceStep
? GasPrice.fromString(`${averageGasPriceStep}uusdc`)
: undefined;
const fee = await this.nobleClient.simulateTransaction([ibcMsg], nobleGasPrice);

// take out fee from amount before sweeping
const amount =
Expand Down Expand Up @@ -467,7 +476,15 @@ class DydxChainTransactions implements AbacusDYDXChainTransactionsProtocol {
typeUrl: params.typeUrl, // '/circle.cctp.v1.MsgDepositForBurn',
value: params.value,
};
const fee = await this.nobleClient.simulateTransaction([ibcMsg]);

const averageGasPriceStep = (
isMainnet ? NOBLE_MAINNET_CHAIN_INFO : NOBLE_TESTNET_CHAIN_INFO
).feeCurrencies.find((currency) => currency.coinMinimalDenom === 'uusdc')?.gasPriceStep
?.average;
const nobleGasPrice = averageGasPriceStep
? GasPrice.fromString(`${averageGasPriceStep}uusdc`)
: undefined;
const fee = await this.nobleClient.simulateTransaction([ibcMsg], nobleGasPrice);

// take out fee from amount before sweeping
const amount =
Expand Down

0 comments on commit b8adf4a

Please sign in to comment.