Skip to content

Commit

Permalink
Merge pull request #160 from bnb-chain/feat/address
Browse files Browse the repository at this point in the history
fix: Solve solana native token fee issue
  • Loading branch information
wenty22 authored Dec 4, 2024
2 parents 354158f + 9bc9709 commit 01fd21a
Showing 1 changed file with 6 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,12 @@ export const useGetDeBridgeFees = () => {
value: `${formatNumber(Number(protocolFee), 8)} ${nativeToken}`,
});
// Make sure native token can cover the protocol fee
const totalNativeAmount =
selectedToken?.deBridge?.raw?.address === '0x0000000000000000000000000000000000000000'
? BigInt(fees?.fixFee) + parseUnits(sendValue, 18)
: BigInt(fees?.fixFee);
const totalNativeAmount = isNativeToken(
selectedToken?.deBridge?.raw?.address,
fromChain?.chainType,
)
? BigInt(fees?.fixFee) + parseUnits(sendValue, nativeDecimals)
: BigInt(fees?.fixFee);
if (nativeTokenBalance && nativeTokenBalance?.value < totalNativeAmount) {
dispatch(
setRouteError({
Expand Down Expand Up @@ -222,26 +224,6 @@ export const useGetDeBridgeFees = () => {
acc[symbol] += value;
return acc;
}, {} as { [key: string]: number });

if (
fromChain?.chainType === 'solana' &&
isNativeToken(selectedToken?.deBridge?.raw?.address, fromChain?.chainType) &&
nativeToken &&
nativeTokenBalance
) {
const totalNativeTokenCost = Number(result[nativeToken]) + Number(sendValue);
const userNativeTokenBalance = Number(nativeTokenBalance.formatted);

if (userNativeTokenBalance < totalNativeTokenCost) {
dispatch(
setRouteError({
deBridge: `Insufficient ${nativeToken} to cover protocol fee and market maker gas costs`,
}),
);
isDisplayError = true;
}
}

const resultString = Object.keys(result)
.map((symbol) => {
return `${formatFeeAmount(result[symbol])} ${symbol}`;
Expand Down

0 comments on commit 01fd21a

Please sign in to comment.