mirror of
https://github.com/zhigang1992/wallet.git
synced 2026-04-29 13:15:32 +08:00
fixup! feat(Swap): add review step
This commit is contained in:
@@ -25,6 +25,8 @@ import { SwapForm } from './components/swap-form';
|
||||
import { SwapAsset, SwapFormValues } from './hooks/use-swap';
|
||||
import { SwapContext, SwapProvider, SwapSubmissionData } from './swap.context';
|
||||
|
||||
const oneHundredMillion = 100_000_000;
|
||||
|
||||
export function SwapContainer() {
|
||||
const alexSDK = useState(() => new AlexSDK())[0];
|
||||
const { data: supportedCurrencies = [] } = useQuery(['alex-supported-currencies'], async () =>
|
||||
@@ -78,7 +80,7 @@ export function SwapContainer() {
|
||||
swapAssetFrom: values.swapAssetFrom,
|
||||
swapAssetTo: values.swapAssetTo,
|
||||
router: router.map(x => getAssetFromAlexCurrency(supportedCurrencies.find(y => y.id === x)!)),
|
||||
liquidityFee: new BigNumber(Number(lpFee)).dividedBy(1e8).toNumber(),
|
||||
liquidityFee: new BigNumber(Number(lpFee)).dividedBy(oneHundredMillion).toNumber(),
|
||||
slippage,
|
||||
});
|
||||
navigate(RouteUrls.SwapReview);
|
||||
@@ -90,11 +92,14 @@ export function SwapContainer() {
|
||||
return;
|
||||
}
|
||||
const fromAmount = BigInt(
|
||||
new BigNumber(swapSubmissionData.swapAmountFrom).multipliedBy(1e8).dp(0).toString()
|
||||
new BigNumber(swapSubmissionData.swapAmountFrom)
|
||||
.multipliedBy(oneHundredMillion)
|
||||
.dp(0)
|
||||
.toString()
|
||||
);
|
||||
const minToAmount = BigInt(
|
||||
new BigNumber(swapSubmissionData.swapAmountTo)
|
||||
.multipliedBy(1e8)
|
||||
.multipliedBy(oneHundredMillion)
|
||||
.multipliedBy(1 - slippage)
|
||||
.dp(0)
|
||||
.toString()
|
||||
@@ -128,10 +133,10 @@ export function SwapContainer() {
|
||||
): Promise<string> {
|
||||
const result = await alexSDK.getAmountTo(
|
||||
from.currency,
|
||||
BigInt(new BigNumber(fromAmount).multipliedBy(1e8).dp(0).toString()),
|
||||
BigInt(new BigNumber(fromAmount).multipliedBy(oneHundredMillion).dp(0).toString()),
|
||||
to.currency
|
||||
);
|
||||
return new BigNumber(Number(result)).dividedBy(1e8).toString();
|
||||
return new BigNumber(Number(result)).dividedBy(oneHundredMillion).toString();
|
||||
}
|
||||
const swapContextValue: SwapContext = {
|
||||
swapSubmissionData,
|
||||
|
||||
Reference in New Issue
Block a user