Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 0 additions & 13 deletions frontend/src/hooks/ramp/useRampValidation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,21 +34,8 @@ function validateOnramp(
trackEvent: (event: TrackableEvent) => void;
},
): string | null {
const maxAmountUnits = multiplyByPowerOfTen(Big(fromToken.maxWithdrawalAmountRaw), -fromToken.decimals);
const minAmountUnits = multiplyByPowerOfTen(Big(fromToken.minWithdrawalAmountRaw), -fromToken.decimals);

if (inputAmount && maxAmountUnits.lt(inputAmount)) {
trackEvent({
event: 'form_error',
error_message: 'more_than_maximum_withdrawal',
input_amount: inputAmount ? inputAmount.toString() : '0',
});
return t('pages.swap.error.moreThanMaximumWithdrawal.buy', {
maxAmountUnits: stringifyBigWithSignificantDecimals(maxAmountUnits, 2),
assetSymbol: fromToken.fiat.symbol,
});
}

if (inputAmount && !inputAmount.eq(0) && minAmountUnits.gt(inputAmount)) {
trackEvent({
event: 'form_error',
Expand Down
8 changes: 5 additions & 3 deletions frontend/src/hooks/useRampUrlParams.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useEffect, useMemo, useRef } from 'react';
import { RampDirection } from '../components/RampToggle';
import { AssetHubToken, EvmToken, FiatToken, Networks, OnChainToken } from 'shared';
import { useRampDirectionToggle } from '../stores/rampDirectionStore';
import { useRampDirection, useRampDirectionToggle } from '../stores/rampDirectionStore';
import { useRampFormStoreActions } from '../stores/ramp/useRampFormStore';
import { useNetwork } from '../contexts/network';

Expand Down Expand Up @@ -73,6 +73,7 @@ function getNetworkFromParam(param?: string): Networks | undefined {
export const useRampUrlParams = (): RampUrlParams => {
const params = useMemo(() => new URLSearchParams(window.location.search), []);
const { selectedNetwork } = useNetwork();
const rampDirection = useRampDirection();

const urlParams = useMemo(() => {
const rampParam = params.get('ramp')?.toLowerCase();
Expand All @@ -81,7 +82,8 @@ export const useRampUrlParams = (): RampUrlParams => {
const fromTokenParam = params.get('from')?.toLowerCase();
const inputAmountParam = params.get('fromAmount');

const ramp = rampParam === 'buy' ? RampDirection.ONRAMP : RampDirection.OFFRAMP;
const ramp =
rampParam === undefined ? rampDirection : rampParam === 'buy' ? RampDirection.ONRAMP : RampDirection.OFFRAMP;

const from =
ramp === RampDirection.OFFRAMP
Expand All @@ -104,7 +106,7 @@ export const useRampUrlParams = (): RampUrlParams => {
to,
fromAmount: inputAmountParam || fromAmount || undefined,
};
}, [params, selectedNetwork]);
}, [params, rampDirection, selectedNetwork]);

return urlParams;
};
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/stores/ramp/useRampFormStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ interface RampFormActions {

export const DEFAULT_RAMP_FORM_STORE_VALUES: RampFormState = {
inputAmount: '20',
onChainToken: EvmToken.USDC,
onChainToken: EvmToken.USDT,
fiatToken: FiatToken.EURC,
taxId: undefined,
pixId: undefined,
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/stores/rampDirectionStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export interface RampDirectionStore {
}

export const useRampDirectionStore = create<RampDirectionStore>((set) => ({
activeDirection: RampDirection.OFFRAMP,
activeDirection: RampDirection.ONRAMP,
onToggle: (direction: RampDirection) => set({ activeDirection: direction }),
}));

Expand Down
Loading