diff --git a/packages/bridge-ui/src/components/Transactions/Dialogs/DesktopDetailsDialog.svelte b/packages/bridge-ui/src/components/Transactions/Dialogs/DesktopDetailsDialog.svelte
index e10153a2476..940c1caac9d 100644
--- a/packages/bridge-ui/src/components/Transactions/Dialogs/DesktopDetailsDialog.svelte
+++ b/packages/bridge-ui/src/components/Transactions/Dialogs/DesktopDetailsDialog.svelte
@@ -227,7 +227,7 @@
Waiting for transaction to be processed
- Depending on your direction, this can take up to 24hs
+ Depending on your direction, this can take up to 4hs
diff --git a/packages/bridge-ui/src/components/Transactions/Rows/FungibleTransactionRow.svelte b/packages/bridge-ui/src/components/Transactions/Rows/FungibleTransactionRow.svelte
index 975c6be7e8a..6a76a5ca4ae 100644
--- a/packages/bridge-ui/src/components/Transactions/Rows/FungibleTransactionRow.svelte
+++ b/packages/bridge-ui/src/components/Transactions/Rows/FungibleTransactionRow.svelte
@@ -103,7 +103,7 @@
: mobileContainerClasses;
$: commonColumnClasses = classNames(' relative items-end');
- $: desktopColumnClasses = classNames(commonColumnClasses, 'w-1/6 f-row justify-center items-center');
+ $: desktopColumnClasses = classNames(commonColumnClasses, 'w-1/6 f-row justify-center md:justify-start items-center');
$: tabletColumnClasses = classNames(
commonColumnClasses,
'w-1/4 f-row text-left start items-center text-sm space-y-[10px]',
diff --git a/packages/bridge-ui/src/i18n/en.json b/packages/bridge-ui/src/i18n/en.json
index 63a7caeddc1..927488038db 100644
--- a/packages/bridge-ui/src/i18n/en.json
+++ b/packages/bridge-ui/src/i18n/en.json
@@ -40,7 +40,7 @@
},
"alerts": {
"not_enough_funds": "You do not have enough ETH to cover the processing fee and transaction fee. Please add more ETH to your wallet (>= 0.0015 ETH).",
- "slow_bridging": "Please note: Bridging to L1 will take around 24hrs!",
+ "slow_bridging": "Please note: Bridging to L1 will take around 4hs!",
"smart_contract_wallet": "It seems you are using a smart contract wallet. Please double check that the recipient matches your wallet on the destination or change it accordingly.",
"wrapped_eth": "You are bridging wrapped ETH. Please be aware that un-wrapping will only work on the original chain of the token, NOT on the destination."
},
diff --git a/packages/bridge-ui/src/libs/fee/recommendProcessingFee.ts b/packages/bridge-ui/src/libs/fee/recommendProcessingFee.ts
index a8b2cf6ade3..780031c07ff 100644
--- a/packages/bridge-ui/src/libs/fee/recommendProcessingFee.ts
+++ b/packages/bridge-ui/src/libs/fee/recommendProcessingFee.ts
@@ -94,20 +94,20 @@ export async function recommendProcessingFee({
if (!estimatedMsgGaslimit) throw new Error('Unable to calculate fee');
// Initial fee multiplicator and add fallback
- let feeMultiplicator: number = parseInt(PUBLIC_FEE_MULTIPLIER);
-
- if (gasPrice <= parseGwei('0.05')) {
- feeMultiplicator = 4;
- log(`gasPrice {formatGwei(gasPrice)} is less than 0.5 gwei, setting feeMultiplicator to 4`);
- } else if (gasPrice <= parseGwei('0.1') && gasPrice > parseGwei('0.05')) {
- feeMultiplicator = 3;
- log(
- `gasPrice ${formatGwei(gasPrice)} is less than 0.1 gwei and more than 0.05 gwei, setting feeMultiplicator to 3`,
- );
- } else {
- feeMultiplicator = 2;
- log(`gasPrice ${formatGwei(gasPrice)} is more than 0.1 gwei, setting feeMultiplicator to 2`);
- }
+ const feeMultiplicator: number = parseInt(PUBLIC_FEE_MULTIPLIER) || 1;
+
+ // if (gasPrice <= parseGwei('0.05')) {
+ // feeMultiplicator = 4;
+ // log(`gasPrice {formatGwei(gasPrice)} is less than 0.5 gwei, setting feeMultiplicator to 4`);
+ // } else if (gasPrice <= parseGwei('0.1') && gasPrice > parseGwei('0.05')) {
+ // feeMultiplicator = 3;
+ // log(
+ // `gasPrice ${formatGwei(gasPrice)} is less than 0.1 gwei and more than 0.05 gwei, setting feeMultiplicator to 3`,
+ // );
+ // } else {
+ // feeMultiplicator = 2;
+ // log(`gasPrice ${formatGwei(gasPrice)} is more than 0.1 gwei, setting feeMultiplicator to 2`);
+ // }
const fee = estimatedMsgGaslimit * Number(gasPrice) * feeMultiplicator;
return BigInt(fee);
diff --git a/packages/bridge-ui/src/libs/fee/recommendedProcessingFee.test.ts b/packages/bridge-ui/src/libs/fee/recommendedProcessingFee.test.ts
index 8f3f0f6cc32..22190579d79 100644
--- a/packages/bridge-ui/src/libs/fee/recommendedProcessingFee.test.ts
+++ b/packages/bridge-ui/src/libs/fee/recommendedProcessingFee.test.ts
@@ -28,644 +28,128 @@ describe('recommendedProcessingFee', () => {
});
describe('ETH fees', () => {
- describe('when gasPrice is less than 0.01 gwei', () => {
- const reportedGasPrice = parseGwei('0.005');
- const expectedFallbackGasPriceUsed = parseGwei('0.01');
- const expectedMultiplicatorUsed = 4;
+ it('should calculate the recommended processing fee for ETH when gasPrice is a normal value (0.15 gwei)', async () => {
+ // Given
+ const token = ETHToken;
+ const srcChainId = L1_CHAIN_ID;
+ const destChainId = L2_CHAIN_ID;
- it('should calculate the recommended processing fee for ETH', async () => {
- // Given
- const token = ETHToken;
- const srcChainId = L1_CHAIN_ID;
- const destChainId = L2_CHAIN_ID;
+ const gasLimit = gasLimitConfig.GAS_RESERVE;
- const gasLimit = gasLimitConfig.GAS_RESERVE;
-
- const expectedFee = gasLimit * Number(expectedFallbackGasPriceUsed) * expectedMultiplicatorUsed;
-
- vi.mocked(mockClient.getGasPrice).mockReturnValue(reportedGasPrice);
-
- // When
- const result = await recommendProcessingFee({ token, destChainId, srcChainId });
-
- // Then
- expect(result).toBe(BigInt(expectedFee));
- });
- });
-
- describe('when gasPrice is less than 0.1 gwei but more than 0.05 gwei', () => {
- const reportedGasPrice = parseGwei('0.09');
- const expectedMultiplicatorUsed = 3;
-
- it('should calculate the recommended processing fee for ETH', async () => {
- // Given
- const token = ETHToken;
- const srcChainId = L1_CHAIN_ID;
- const destChainId = L2_CHAIN_ID;
-
- const gasLimit = gasLimitConfig.GAS_RESERVE;
-
- const expectedFee = gasLimit * Number(reportedGasPrice) * expectedMultiplicatorUsed;
-
- vi.mocked(mockClient.getGasPrice).mockReturnValue(reportedGasPrice);
-
- // When
- const result = await recommendProcessingFee({ token, destChainId, srcChainId });
-
- // Then
- expect(result).toBe(BigInt(expectedFee));
- });
- });
-
- describe('when gasPrice is more than 0.1 gwei', () => {
const reportedGasPrice = parseGwei('0.15');
- const expectedMultiplicatorUsed = 2;
-
- it('should calculate the recommended processing fee for ETH', async () => {
- // Given
- const token = ETHToken;
- const srcChainId = L1_CHAIN_ID;
- const destChainId = L2_CHAIN_ID;
-
- const gasLimit = gasLimitConfig.GAS_RESERVE;
+ const feeMultiplicator = 1;
- const expectedFee = gasLimit * Number(reportedGasPrice) * expectedMultiplicatorUsed;
+ const expectedFee = gasLimit * Number(reportedGasPrice) * feeMultiplicator;
- vi.mocked(mockClient.getGasPrice).mockReturnValue(reportedGasPrice);
+ vi.mocked(mockClient.getGasPrice).mockReturnValue(reportedGasPrice);
- // When
- const result = await recommendProcessingFee({ token, destChainId, srcChainId });
+ // When
+ const result = await recommendProcessingFee({ token, destChainId, srcChainId });
- // Then
- expect(result).toBe(BigInt(expectedFee));
- });
+ // Then
+ expect(result).toBe(BigInt(expectedFee));
});
});
describe('ERC20 fees', () => {
- describe('when gasPrice is less than 0.01 gwei', () => {
- const reportedGasPrice = parseGwei('0.005');
- const expectedFallbackGasPriceUsed = parseGwei('0.01');
- const expectedMultiplicatorUsed = 4;
-
- beforeEach(() => {
- vi.mocked(mockClient.getGasPrice).mockReturnValue(reportedGasPrice);
- });
-
- it('should calculate the recommended processing fee for deployed ERC20', async () => {
- // Given
- const token = MOCK_ERC20;
- const srcChainId = L1_CHAIN_ID;
- const destChainId = L2_CHAIN_ID;
-
- const gasLimit = gasLimitConfig.GAS_RESERVE + gasLimitConfig.erc20DeployedGasLimit;
-
- const expectedFee = gasLimit * Number(expectedFallbackGasPriceUsed) * expectedMultiplicatorUsed;
-
- vi.mocked(getTokenAddresses).mockResolvedValue({
- bridged: {
- chainId: L1_CHAIN_ID,
- address: MOCK_ERC20.addresses[L1_CHAIN_ID],
- },
- canonical: {
- chainId: L2_CHAIN_ID,
- address: MOCK_ERC20.addresses[L2_CHAIN_ID],
- },
- });
-
- // When
- const result = await recommendProcessingFee({ token, destChainId, srcChainId });
-
- // Then
- expect(result).toBe(BigInt(expectedFee));
- });
-
- it('should calculate the recommended processing fee for not deployed ERC20', async () => {
- // Given
- const token = MOCK_ERC20;
- const srcChainId = L1_CHAIN_ID;
- const destChainId = L2_CHAIN_ID;
-
- const gasLimit = gasLimitConfig.GAS_RESERVE + gasLimitConfig.erc20NotDeployedGasLimit;
-
- const expectedFee = gasLimit * Number(expectedFallbackGasPriceUsed) * expectedMultiplicatorUsed;
-
- vi.mocked(getTokenAddresses).mockResolvedValue({
- bridged: null,
- canonical: {
- chainId: L2_CHAIN_ID,
- address: MOCK_ERC20.addresses[L2_CHAIN_ID],
- },
- });
-
- // When
- const result = await recommendProcessingFee({ token, destChainId, srcChainId });
-
- // Then
- expect(result).toBe(BigInt(expectedFee));
- });
- });
-
- describe('when gasPrice is less than 0.1 gwei but more than 0.05 gwei', () => {
- const reportedGasPrice = parseGwei('0.09');
- const expectedMultiplicatorUsed = 3;
-
- beforeEach(() => {
- vi.mocked(mockClient.getGasPrice).mockReturnValue(reportedGasPrice);
- });
+ it('should calculate the recommended processing fee for deployed ERC20', async () => {
+ // Given
+ const token = MOCK_ERC20;
+ const srcChainId = L1_CHAIN_ID;
+ const destChainId = L2_CHAIN_ID;
- it('should calculate the recommended processing fee for deployed ERC20', async () => {
- // Given
- const token = MOCK_ERC20;
- const srcChainId = L1_CHAIN_ID;
- const destChainId = L2_CHAIN_ID;
+ const gasLimit = gasLimitConfig.GAS_RESERVE + gasLimitConfig.erc20DeployedGasLimit;
- const gasLimit = gasLimitConfig.GAS_RESERVE + gasLimitConfig.erc20DeployedGasLimit;
-
- const expectedFee = gasLimit * Number(reportedGasPrice) * expectedMultiplicatorUsed;
-
- vi.mocked(getTokenAddresses).mockResolvedValue({
- bridged: {
- chainId: L1_CHAIN_ID,
- address: MOCK_ERC20.addresses[L1_CHAIN_ID],
- },
- canonical: {
- chainId: L2_CHAIN_ID,
- address: MOCK_ERC20.addresses[L2_CHAIN_ID],
- },
- });
-
- // When
- const result = await recommendProcessingFee({ token, destChainId, srcChainId });
-
- // Then
- expect(result).toBe(BigInt(expectedFee));
- });
-
- it('should calculate the recommended processing fee for not deployed ERC20', async () => {
- // Given
- const token = MOCK_ERC20;
- const srcChainId = L1_CHAIN_ID;
- const destChainId = L2_CHAIN_ID;
-
- const gasLimit = gasLimitConfig.GAS_RESERVE + gasLimitConfig.erc20NotDeployedGasLimit;
-
- const expectedFee = gasLimit * Number(reportedGasPrice) * expectedMultiplicatorUsed;
-
- vi.mocked(getTokenAddresses).mockResolvedValue({
- bridged: null,
- canonical: {
- chainId: L2_CHAIN_ID,
- address: MOCK_ERC20.addresses[L2_CHAIN_ID],
- },
- });
-
- // When
- const result = await recommendProcessingFee({ token, destChainId, srcChainId });
-
- // Then
- expect(result).toBe(BigInt(expectedFee));
- });
- });
-
- describe('when gasPrice is more than 0.1 gwei', () => {
- const reportedGasPrice = parseGwei('0.12');
- const expectedMultiplicatorUsed = 2;
-
- beforeEach(() => {
- vi.mocked(mockClient.getGasPrice).mockReturnValue(reportedGasPrice);
- });
-
- it('should calculate the recommended processing fee for deployed ERC20', async () => {
- // Given
- const token = MOCK_ERC20;
- const srcChainId = L1_CHAIN_ID;
- const destChainId = L2_CHAIN_ID;
-
- const gasLimit = gasLimitConfig.GAS_RESERVE + gasLimitConfig.erc20DeployedGasLimit;
-
- const expectedFee = gasLimit * Number(reportedGasPrice) * expectedMultiplicatorUsed;
-
- vi.mocked(getTokenAddresses).mockResolvedValue({
- bridged: {
- chainId: L1_CHAIN_ID,
- address: MOCK_ERC20.addresses[L1_CHAIN_ID],
- },
- canonical: {
- chainId: L2_CHAIN_ID,
- address: MOCK_ERC20.addresses[L2_CHAIN_ID],
- },
- });
+ const reportedGasPrice = parseGwei('0.15');
+ const feeMultiplicator = 1;
- // When
- const result = await recommendProcessingFee({ token, destChainId, srcChainId });
+ const expectedFee = gasLimit * Number(reportedGasPrice) * feeMultiplicator;
- // Then
- expect(result).toBe(BigInt(expectedFee));
+ vi.mocked(mockClient.getGasPrice).mockReturnValue(reportedGasPrice);
+ vi.mocked(getTokenAddresses).mockResolvedValue({
+ bridged: {
+ chainId: L1_CHAIN_ID,
+ address: MOCK_ERC20.addresses[L1_CHAIN_ID],
+ },
+ canonical: {
+ chainId: L2_CHAIN_ID,
+ address: MOCK_ERC20.addresses[L2_CHAIN_ID],
+ },
});
- it('should calculate the recommended processing fee for not deployed ERC20', async () => {
- // Given
- const token = MOCK_ERC20;
- const srcChainId = L1_CHAIN_ID;
- const destChainId = L2_CHAIN_ID;
-
- const gasLimit = gasLimitConfig.GAS_RESERVE + gasLimitConfig.erc20NotDeployedGasLimit;
-
- const expectedFee = gasLimit * Number(reportedGasPrice) * expectedMultiplicatorUsed;
-
- vi.mocked(getTokenAddresses).mockResolvedValue({
- bridged: null,
- canonical: {
- chainId: L2_CHAIN_ID,
- address: MOCK_ERC20.addresses[L2_CHAIN_ID],
- },
- });
+ // When
+ const result = await recommendProcessingFee({ token, destChainId, srcChainId });
- // When
- const result = await recommendProcessingFee({ token, destChainId, srcChainId });
-
- // Then
- expect(result).toBe(BigInt(expectedFee));
- });
+ // Then
+ expect(result).toBe(BigInt(expectedFee));
});
});
describe('ERC721 fees', () => {
- describe('when gasPrice is less than 0.01 gwei', () => {
- const reportedGasPrice = parseGwei('0.005');
- const expectedFallbackGasPriceUsed = parseGwei('0.01');
- const expectedMultiplicatorUsed = 4;
-
- beforeEach(() => {
- vi.mocked(mockClient.getGasPrice).mockReturnValue(reportedGasPrice);
- });
-
- it('should calculate the recommended processing fee for deployed ERC721', async () => {
- // Given
- const token = MOCK_ERC721;
- const srcChainId = L1_CHAIN_ID;
- const destChainId = L2_CHAIN_ID;
-
- const gasLimit = gasLimitConfig.GAS_RESERVE + gasLimitConfig.erc721DeployedGasLimit;
-
- const expectedFee = gasLimit * Number(expectedFallbackGasPriceUsed) * expectedMultiplicatorUsed;
-
- vi.mocked(getTokenAddresses).mockResolvedValue({
- bridged: {
- chainId: L1_CHAIN_ID,
- address: MOCK_ERC721.addresses[L1_CHAIN_ID],
- },
- canonical: {
- chainId: L2_CHAIN_ID,
- address: MOCK_ERC721.addresses[L2_CHAIN_ID],
- },
- });
-
- // When
- const result = await recommendProcessingFee({ token, destChainId, srcChainId });
-
- // Then
- expect(result).toBe(BigInt(expectedFee));
- });
-
- it('should calculate the recommended processing fee for not deployed ERC721', async () => {
- // Given
- const token = MOCK_ERC721;
- const srcChainId = L1_CHAIN_ID;
- const destChainId = L2_CHAIN_ID;
-
- const gasLimit = gasLimitConfig.GAS_RESERVE + gasLimitConfig.erc721NotDeployedGasLimit;
-
- const expectedFee = gasLimit * Number(expectedFallbackGasPriceUsed) * expectedMultiplicatorUsed;
+ it('should calculate the recommended processing fee for deployed ERC721', async () => {
+ // Given
+ const token = MOCK_ERC721;
+ const srcChainId = L1_CHAIN_ID;
+ const destChainId = L2_CHAIN_ID;
- vi.mocked(getTokenAddresses).mockResolvedValue({
- bridged: null,
- canonical: {
- chainId: L2_CHAIN_ID,
- address: MOCK_ERC721.addresses[L2_CHAIN_ID],
- },
- });
+ const gasLimit = gasLimitConfig.GAS_RESERVE + gasLimitConfig.erc721DeployedGasLimit;
- // When
- const result = await recommendProcessingFee({ token, destChainId, srcChainId });
-
- // Then
- expect(result).toBe(BigInt(expectedFee));
- });
- });
-
- describe('when gasPrice is less than 0.1 gwei but more than 0.05 gwei', () => {
- const reportedGasPrice = parseGwei('0.09');
- const expectedMultiplicatorUsed = 3;
-
- beforeEach(() => {
- vi.mocked(mockClient.getGasPrice).mockReturnValue(reportedGasPrice);
- });
-
- it('should calculate the recommended processing fee for deployed ERC721', async () => {
- // Given
- const token = MOCK_ERC721;
- const srcChainId = L1_CHAIN_ID;
- const destChainId = L2_CHAIN_ID;
-
- const gasLimit = gasLimitConfig.GAS_RESERVE + gasLimitConfig.erc721DeployedGasLimit;
-
- const expectedFee = gasLimit * Number(reportedGasPrice) * expectedMultiplicatorUsed;
-
- vi.mocked(getTokenAddresses).mockResolvedValue({
- bridged: {
- chainId: L1_CHAIN_ID,
- address: MOCK_ERC721.addresses[L1_CHAIN_ID],
- },
- canonical: {
- chainId: L2_CHAIN_ID,
- address: MOCK_ERC721.addresses[L2_CHAIN_ID],
- },
- });
-
- // When
- const result = await recommendProcessingFee({ token, destChainId, srcChainId });
-
- // Then
- expect(result).toBe(BigInt(expectedFee));
- });
-
- it('should calculate the recommended processing fee for not deployed ERC721', async () => {
- // Given
- const token = MOCK_ERC721;
- const srcChainId = L1_CHAIN_ID;
- const destChainId = L2_CHAIN_ID;
-
- const gasLimit = gasLimitConfig.GAS_RESERVE + gasLimitConfig.erc721NotDeployedGasLimit;
-
- const expectedFee = gasLimit * Number(reportedGasPrice) * expectedMultiplicatorUsed;
-
- vi.mocked(getTokenAddresses).mockResolvedValue({
- bridged: null,
- canonical: {
- chainId: L2_CHAIN_ID,
- address: MOCK_ERC721.addresses[L2_CHAIN_ID],
- },
- });
-
- // When
- const result = await recommendProcessingFee({ token, destChainId, srcChainId });
-
- // Then
- expect(result).toBe(BigInt(expectedFee));
- });
- });
-
- describe('when gasPrice is more than 0.1 gwei', () => {
const reportedGasPrice = parseGwei('0.12');
- const expectedMultiplicatorUsed = 2;
-
- beforeEach(() => {
- vi.mocked(mockClient.getGasPrice).mockReturnValue(reportedGasPrice);
- });
-
- it('should calculate the recommended processing fee for deployed ERC721', async () => {
- // Given
- const token = MOCK_ERC721;
- const srcChainId = L1_CHAIN_ID;
- const destChainId = L2_CHAIN_ID;
+ const feeMultiplicator = 1;
- const gasLimit = gasLimitConfig.GAS_RESERVE + gasLimitConfig.erc721DeployedGasLimit;
+ const expectedFee = gasLimit * Number(reportedGasPrice) * feeMultiplicator;
- const expectedFee = gasLimit * Number(reportedGasPrice) * expectedMultiplicatorUsed;
-
- vi.mocked(getTokenAddresses).mockResolvedValue({
- bridged: {
- chainId: L1_CHAIN_ID,
- address: MOCK_ERC721.addresses[L1_CHAIN_ID],
- },
- canonical: {
- chainId: L2_CHAIN_ID,
- address: MOCK_ERC721.addresses[L2_CHAIN_ID],
- },
- });
-
- // When
- const result = await recommendProcessingFee({ token, destChainId, srcChainId });
-
- // Then
- expect(result).toBe(BigInt(expectedFee));
+ vi.mocked(mockClient.getGasPrice).mockReturnValue(reportedGasPrice);
+ vi.mocked(getTokenAddresses).mockResolvedValue({
+ bridged: {
+ chainId: L1_CHAIN_ID,
+ address: MOCK_ERC721.addresses[L1_CHAIN_ID],
+ },
+ canonical: {
+ chainId: L2_CHAIN_ID,
+ address: MOCK_ERC721.addresses[L2_CHAIN_ID],
+ },
});
- it('should calculate the recommended processing fee for not deployed ERC721', async () => {
- // Given
- const token = MOCK_ERC721;
- const srcChainId = L1_CHAIN_ID;
- const destChainId = L2_CHAIN_ID;
-
- const gasLimit = gasLimitConfig.GAS_RESERVE + gasLimitConfig.erc721NotDeployedGasLimit;
-
- const expectedFee = gasLimit * Number(reportedGasPrice) * expectedMultiplicatorUsed;
+ // When
+ const result = await recommendProcessingFee({ token, destChainId, srcChainId });
- vi.mocked(getTokenAddresses).mockResolvedValue({
- bridged: null,
- canonical: {
- chainId: L2_CHAIN_ID,
- address: MOCK_ERC721.addresses[L2_CHAIN_ID],
- },
- });
-
- // When
- const result = await recommendProcessingFee({ token, destChainId, srcChainId });
-
- // Then
- expect(result).toBe(BigInt(expectedFee));
- });
+ // Then
+ expect(result).toBe(BigInt(expectedFee));
});
});
describe('ERC1155 fees', () => {
- describe('when gasPrice is less than 0.01 gwei', () => {
- const reportedGasPrice = parseGwei('0.005');
- const expectedFallbackGasPriceUsed = parseGwei('0.01');
- const expectedMultiplicatorUsed = 4;
-
- beforeEach(() => {
- vi.mocked(mockClient.getGasPrice).mockReturnValue(reportedGasPrice);
- });
-
- it('should calculate the recommended processing fee for deployed ERC1155', async () => {
- // Given
- const token = MOCK_ERC1155;
- const srcChainId = L1_CHAIN_ID;
- const destChainId = L2_CHAIN_ID;
-
- const gasLimit = gasLimitConfig.GAS_RESERVE + gasLimitConfig.erc1155DeployedGasLimit;
-
- const expectedFee = gasLimit * Number(expectedFallbackGasPriceUsed) * expectedMultiplicatorUsed;
-
- vi.mocked(getTokenAddresses).mockResolvedValue({
- bridged: {
- chainId: L1_CHAIN_ID,
- address: MOCK_ERC1155.addresses[L1_CHAIN_ID],
- },
- canonical: {
- chainId: L2_CHAIN_ID,
- address: MOCK_ERC1155.addresses[L2_CHAIN_ID],
- },
- });
+ it('should calculate the recommended processing fee for deployed ERC1155', async () => {
+ // Given
+ const token = MOCK_ERC1155;
+ const srcChainId = L1_CHAIN_ID;
+ const destChainId = L2_CHAIN_ID;
- // When
- const result = await recommendProcessingFee({ token, destChainId, srcChainId });
+ const gasLimit = gasLimitConfig.GAS_RESERVE + gasLimitConfig.erc1155DeployedGasLimit;
- // Then
- expect(result).toBe(BigInt(expectedFee));
- });
-
- it('should calculate the recommended processing fee for not deployed ERC1155', async () => {
- // Given
- const token = MOCK_ERC1155;
- const srcChainId = L1_CHAIN_ID;
- const destChainId = L2_CHAIN_ID;
-
- const gasLimit = gasLimitConfig.GAS_RESERVE + gasLimitConfig.erc1155NotDeployedGasLimit;
-
- const expectedFee = gasLimit * Number(expectedFallbackGasPriceUsed) * expectedMultiplicatorUsed;
-
- vi.mocked(getTokenAddresses).mockResolvedValue({
- bridged: null,
- canonical: {
- chainId: L2_CHAIN_ID,
- address: MOCK_ERC1155.addresses[L2_CHAIN_ID],
- },
- });
-
- // When
- const result = await recommendProcessingFee({ token, destChainId, srcChainId });
-
- // Then
- expect(result).toBe(BigInt(expectedFee));
- });
- });
-
- describe('when gasPrice is less than 0.1 gwei but more than 0.05 gwei', () => {
- const reportedGasPrice = parseGwei('0.09');
- const expectedMultiplicatorUsed = 3;
-
- beforeEach(() => {
- vi.mocked(mockClient.getGasPrice).mockReturnValue(reportedGasPrice);
- });
-
- it('should calculate the recommended processing fee for deployed ERC1155', async () => {
- // Given
- const token = MOCK_ERC1155;
- const srcChainId = L1_CHAIN_ID;
- const destChainId = L2_CHAIN_ID;
-
- const gasLimit = gasLimitConfig.GAS_RESERVE + gasLimitConfig.erc1155DeployedGasLimit;
-
- const expectedFee = gasLimit * Number(reportedGasPrice) * expectedMultiplicatorUsed;
-
- vi.mocked(getTokenAddresses).mockResolvedValue({
- bridged: {
- chainId: L1_CHAIN_ID,
- address: MOCK_ERC1155.addresses[L1_CHAIN_ID],
- },
- canonical: {
- chainId: L2_CHAIN_ID,
- address: MOCK_ERC1155.addresses[L2_CHAIN_ID],
- },
- });
-
- // When
- const result = await recommendProcessingFee({ token, destChainId, srcChainId });
-
- // Then
- expect(result).toBe(BigInt(expectedFee));
- });
-
- it('should calculate the recommended processing fee for not deployed ERC1155', async () => {
- // Given
- const token = MOCK_ERC1155;
- const srcChainId = L1_CHAIN_ID;
- const destChainId = L2_CHAIN_ID;
-
- const gasLimit = gasLimitConfig.GAS_RESERVE + gasLimitConfig.erc1155NotDeployedGasLimit;
-
- const expectedFee = gasLimit * Number(reportedGasPrice) * expectedMultiplicatorUsed;
-
- vi.mocked(getTokenAddresses).mockResolvedValue({
- bridged: null,
- canonical: {
- chainId: L2_CHAIN_ID,
- address: MOCK_ERC1155.addresses[L2_CHAIN_ID],
- },
- });
-
- // When
- const result = await recommendProcessingFee({ token, destChainId, srcChainId });
-
- // Then
- expect(result).toBe(BigInt(expectedFee));
- });
- });
-
- describe('when gasPrice is more than 0.1 gwei', () => {
const reportedGasPrice = parseGwei('0.12');
- const expectedMultiplicatorUsed = 2;
-
- beforeEach(() => {
- vi.mocked(mockClient.getGasPrice).mockReturnValue(reportedGasPrice);
- });
+ const feeMultiplicator = 1;
- it('should calculate the recommended processing fee for deployed ERC1155', async () => {
- // Given
- const token = MOCK_ERC1155;
- const srcChainId = L1_CHAIN_ID;
- const destChainId = L2_CHAIN_ID;
+ const expectedFee = gasLimit * Number(reportedGasPrice) * feeMultiplicator;
- const gasLimit = gasLimitConfig.GAS_RESERVE + gasLimitConfig.erc1155DeployedGasLimit;
-
- const expectedFee = gasLimit * Number(reportedGasPrice) * expectedMultiplicatorUsed;
-
- vi.mocked(getTokenAddresses).mockResolvedValue({
- bridged: {
- chainId: L1_CHAIN_ID,
- address: MOCK_ERC1155.addresses[L1_CHAIN_ID],
- },
- canonical: {
- chainId: L2_CHAIN_ID,
- address: MOCK_ERC1155.addresses[L2_CHAIN_ID],
- },
- });
-
- // When
- const result = await recommendProcessingFee({ token, destChainId, srcChainId });
-
- // Then
- expect(result).toBe(BigInt(expectedFee));
+ vi.mocked(mockClient.getGasPrice).mockReturnValue(reportedGasPrice);
+ vi.mocked(getTokenAddresses).mockResolvedValue({
+ bridged: {
+ chainId: L1_CHAIN_ID,
+ address: MOCK_ERC1155.addresses[L1_CHAIN_ID],
+ },
+ canonical: {
+ chainId: L2_CHAIN_ID,
+ address: MOCK_ERC1155.addresses[L2_CHAIN_ID],
+ },
});
- it('should calculate the recommended processing fee for not deployed ERC1155', async () => {
- // Given
- const token = MOCK_ERC1155;
- const srcChainId = L1_CHAIN_ID;
- const destChainId = L2_CHAIN_ID;
-
- const gasLimit = gasLimitConfig.GAS_RESERVE + gasLimitConfig.erc1155NotDeployedGasLimit;
+ // When
+ const result = await recommendProcessingFee({ token, destChainId, srcChainId });
- const expectedFee = gasLimit * Number(reportedGasPrice) * expectedMultiplicatorUsed;
-
- vi.mocked(getTokenAddresses).mockResolvedValue({
- bridged: null,
- canonical: {
- chainId: L2_CHAIN_ID,
- address: MOCK_ERC1155.addresses[L2_CHAIN_ID],
- },
- });
-
- // When
- const result = await recommendProcessingFee({ token, destChainId, srcChainId });
-
- // Then
- expect(result).toBe(BigInt(expectedFee));
- });
+ // Then
+ expect(result).toBe(BigInt(expectedFee));
});
});
});