Skip to content

Commit

Permalink
Merge pull request #149 from zikriya/develop
Browse files Browse the repository at this point in the history
Bug fixed for settledAmount conversion
  • Loading branch information
zikriya committed May 18, 2024
2 parents 28392ec + 0158296 commit cea452d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/constants/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export const numberIntoDecimals = function (amount: any, decimal: any) {
decimal = Big(10 ** Number(decimal));
let formattedValue = amount.mul(decimal);
formattedValue = removeExponential(formattedValue.toString());
formattedValue = parseInt(formattedValue);
formattedValue = removeDecimals(formattedValue);
formattedValue = removeExponential(formattedValue.toString());
return formattedValue;
};
Expand All @@ -80,6 +80,13 @@ export const decimalsIntoNumber = function (amount: any, decimal: any) {
return formattedValue;
};

export const removeDecimals = function (amount: any) {
if (amount.includes('.')) {
amount = amount.split('.')[0];
}
return amount;
};

export const withSlippage = function (value: any, slippage: number) {
let slippageProportion = 100 - slippage;
let valueWithSlippage = (value * slippageProportion) / 100;
Expand Down
2 changes: 2 additions & 0 deletions src/services/signature.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import {
decimals,
decimalsIntoNumber,
numberIntoDecimals,
removeDecimals,
withSlippage,
} from '../constants/utils';
import { getAggregateRouterTokenAddress } from './web3.service';
Expand Down Expand Up @@ -126,6 +127,7 @@ export const isValidSettledAmount = async (
web3Service.getFoundaryTokenAddress(destinationChainId),
);
let settledAmountInDesDeciamls = decimalsIntoNumber(settledAmount, dDecimal);
settledAmountInDesDeciamls = removeDecimals(settledAmountInDesDeciamls);
settledAmount = decimalsIntoNumber(settledAmount, sDecimal);
distributedFee = decimalsIntoNumber(distributedFee, sDecimal);
destinationAmountIn = decimalsIntoNumber(destinationAmountIn, dDecimal);
Expand Down

0 comments on commit cea452d

Please sign in to comment.