diff --git a/packages/swapper/src/swappers/PortalsSwapper/getPortalsTradeRate/getPortalsTradeRate.tsx b/packages/swapper/src/swappers/PortalsSwapper/getPortalsTradeRate/getPortalsTradeRate.tsx index db6b8a95efc..0aa2ff7d347 100644 --- a/packages/swapper/src/swappers/PortalsSwapper/getPortalsTradeRate/getPortalsTradeRate.tsx +++ b/packages/swapper/src/swappers/PortalsSwapper/getPortalsTradeRate/getPortalsTradeRate.tsx @@ -25,7 +25,7 @@ import { getPortalsRouterAddressByChainId, isSupportedChainId } from '../utils/h export async function getPortalsTradeRate( input: GetEvmTradeRateInput, - _assertGetEvmChainAdapter: (chainId: ChainId) => EvmChainAdapter, + assertGetEvmChainAdapter: (chainId: ChainId) => EvmChainAdapter, swapperConfig: SwapperConfig, ): Promise> { const { @@ -38,6 +38,7 @@ export async function getPortalsTradeRate( sellAmountIncludingProtocolFeesCryptoBaseUnit, receiveAddress, } = input + const adapter = assertGetEvmChainAdapter(chainId) const sellAssetChainId = sellAsset.chainId const buyAssetChainId = buyAsset.chainId @@ -130,6 +131,11 @@ export async function getPortalsTradeRate( .div(bn(1).minus(slippageTolerancePercentageDecimal ?? 0)) .toFixed(0) + const gasLimit = quoteEstimateResponse.context.gasLimit + const { average } = await adapter.getGasFeeData() + + const networkFeeCryptoBaseUnit = bnOrZero(average.gasPrice).times(gasLimit).toFixed(0) + const tradeRate = { id: uuid(), quoteOrRate: 'rate' as const, @@ -158,7 +164,7 @@ export async function getPortalsTradeRate( sellAmountIncludingProtocolFeesCryptoBaseUnit: input.sellAmountIncludingProtocolFeesCryptoBaseUnit, feeData: { - networkFeeCryptoBaseUnit: undefined, + networkFeeCryptoBaseUnit, protocolFees: undefined, // We don't have protocol fees on Portals during the estimate step }, source: SwapperName.Portals, diff --git a/packages/swapper/src/swappers/PortalsSwapper/utils/fetchPortalsTradeOrder.ts b/packages/swapper/src/swappers/PortalsSwapper/utils/fetchPortalsTradeOrder.ts index f35cef54893..3ea9ee303e7 100644 --- a/packages/swapper/src/swappers/PortalsSwapper/utils/fetchPortalsTradeOrder.ts +++ b/packages/swapper/src/swappers/PortalsSwapper/utils/fetchPortalsTradeOrder.ts @@ -80,6 +80,7 @@ type PortalsTradeOrderEstimateResponse = { outputAmount: string outputAmountUsd: number minOutputAmountUsd: number + gasLimit: number sender?: string } }