From f2e3499d1f3d93322037ee2ebdf4dab8f94dcd75 Mon Sep 17 00:00:00 2001 From: bigboydiamonds <57741810+bigboydiamonds@users.noreply.github.com> Date: Fri, 20 Sep 2024 17:55:29 -0700 Subject: [PATCH] fix: formatted bridge fee amount --- .../src/controllers/bridgeController.ts | 29 ++++++++++++------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/packages/rest-api/src/controllers/bridgeController.ts b/packages/rest-api/src/controllers/bridgeController.ts index 7bb703631b..568c4eb0fc 100644 --- a/packages/rest-api/src/controllers/bridgeController.ts +++ b/packages/rest-api/src/controllers/bridgeController.ts @@ -25,17 +25,24 @@ export const bridgeController = async (req, res) => { toToken, amountInWei ) - const payload = resp.map((quote) => ({ - ...quote, - maxAmountOutStr: formatBNToString( - quote.maxAmountOut, - toTokenInfo.decimals - ), - bridgeFeeFormatted: formatBNToString( - quote.feeAmount, - toTokenInfo.decimals - ), - })) + + const payload = resp.map((quote) => { + const originQueryTokenOutInfo = tokenAddressToToken( + fromChain.toString(), + quote.originQuery.tokenOut + ) + return { + ...quote, + maxAmountOutStr: formatBNToString( + quote.maxAmountOut, + toTokenInfo.decimals + ), + bridgeFeeFormatted: formatBNToString( + quote.feeAmount, + originQueryTokenOutInfo.decimals + ), + } + }) res.json(payload) } catch (err) { res.status(500).json({