Skip to content

Commit

Permalink
fix: handling bridge amount when gho
Browse files Browse the repository at this point in the history
  • Loading branch information
foodaka committed Oct 17, 2024
1 parent 3cfc009 commit ab6dd97
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/components/transactions/Bridge/BridgeModalContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -207,12 +207,14 @@ export const BridgeModalContent = () => {
};

const bridgeActionsProps: BridgeActionProps = {
amountToBridge:
selectedFeeToken.address === constants.AddressZero
? amount // If it's network token (ETH), do not subtract the fee from the amount
: bridgeFee
? Number(formatUnits(parsedAmount.sub(bridgeFee), 18)).toFixed(2) // subtract the fee from the amount
: amount,
// amountToBridge:
// selectedFeeToken.address === constants.AddressZero
// ? amount // If it's network token (ETH), do not subtract the fee from the amount
// : bridgeFee
// ? Number(formatUnits(parsedAmount.add(bridgeFee), 18)).toFixed(2) // subtract the fee from the amount
// : amount,

amountToBridge: amount,
isWrongNetwork,
symbol: GHO_SYMBOL,
blocked:
Expand Down
13 changes: 13 additions & 0 deletions src/components/transactions/Bridge/useGetBridgeMessage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,19 @@ export const useGetBridgeMessage = ({
const destinationChainSelector = getChainSelectorFor(destinationChainId);
const fees: BigNumber = await sourceRouter.getFee(destinationChainSelector, message);

const amountBN = utils.parseUnits(amount, 18);
const updatedAmount = amountBN.sub(fees);

// If the fee token is not the native token, we need to update the tokenAmounts to subtract fees
if (feeToken !== constants.AddressZero) {
message.tokenAmounts = [
{
token: sourceTokenAddress,
amount: updatedAmount.toString(),
},
];
}

const sourceLaneConfig = laneConfig.find(
(config) => config.sourceChainId === sourceChainId
);
Expand Down

0 comments on commit ab6dd97

Please sign in to comment.