Skip to content

handle the response when quote exceeds the pool size #661

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: staging
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
4 changes: 3 additions & 1 deletion frontend/src/components/AssetNumericInput/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export const AssetNumericInput: FC<AssetNumericInputProps> = ({
tokenSymbol,
onClick,
registerInput,
loading,
...rest
}) => (
<div
Expand All @@ -36,10 +37,11 @@ export const AssetNumericInput: FC<AssetNumericInputProps> = ({
<AssetButton disabled={rest.disabled} assetIcon={assetIcon} tokenSymbol={tokenSymbol} onClick={onClick} />
</div>

{rest.loading ? (
{loading ? (
<div className="loading loading-bars loading-md ml-auto mr-4"></div>
) : (
<NumericInput
loading={loading}
register={registerInput}
additionalStyle={cn('text-right text-lg', rest.readOnly && 'text-xl')}
{...rest}
Expand Down
4 changes: 3 additions & 1 deletion frontend/src/components/NumericInput/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ interface NumericInputProps {
defaultValue?: string;
autoFocus?: boolean;
disabled?: boolean;
loading?: boolean;
onChange?: (e: ChangeEvent) => void;
}

Expand All @@ -22,6 +23,7 @@ export const NumericInput = ({
defaultValue,
autoFocus,
onChange,
loading = false,
disabled = false,
}: NumericInputProps) => {
function handleOnChange(e: ChangeEvent): void {
Expand Down Expand Up @@ -61,7 +63,7 @@ export const NumericInput = ({
value={defaultValue}
autoFocus={autoFocus}
/>
{disabled && (
{disabled && loading && (
<span className="absolute top-1/2 right-3 -translate-y-1/2 loading loading-bars loading-sm text-primary"></span>
)}
</div>
Expand Down
6 changes: 5 additions & 1 deletion frontend/src/components/buttons/AssetButton/index.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { cn } from '../../../helpers/cn';
import { useGetAssetIcon } from '../../../hooks/useGetAssetIcon';
import { ChevronDownIcon } from '@heroicons/react/20/solid';

Expand All @@ -13,7 +14,10 @@ export function AssetButton({ assetIcon, tokenSymbol, onClick, disabled }: Asset

return (
<button
className="hover:bg-blue-200 cursor-pointer rounded-full h-8 flex text-base items-center mt-0.5 border border-blue-700 px-2 py-1 pr-3"
className={cn(
' cursor-pointer rounded-full h-8 flex text-base items-center mt-0.5 border border-blue-700 px-2 py-1 pr-3',
disabled ? 'cursor-not-allowed' : 'hover:bg-blue-200',
)}
onClick={onClick}
type="button"
disabled={disabled}
Expand Down
11 changes: 5 additions & 6 deletions frontend/src/hooks/offramp/useSubmitRamp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import { sep24First } from '../../services/anchor/sep24/first';
import { sep10 } from '../../services/anchor/sep10';
import { useRampActions } from '../../stores/rampStore';
import { useSep24Actions } from '../../stores/sep24Store';
import { SIGNING_SERVICE_URL } from '../../constants/constants';
import { RampExecutionInput } from '../../types/phases';
import { useToastMessage } from '../../helpers/notifications';
import { isValidCnpj, isValidCpf } from '../ramp/schema';
Expand All @@ -42,7 +41,7 @@ export const useSubmitRamp = () => {
setRampKycStarted,
setInitializeFailedMessage,
setRampSummaryVisible,
setRampKycLevel2Started
setRampKycLevel2Started,
} = useRampActions();

const {
Expand Down Expand Up @@ -94,20 +93,20 @@ export const useSubmitRamp = () => {
const { evmAddress: brlaEvmAddress } = await BrlaService.getUser(taxId);

const remainingLimitResponse = await BrlaService.getUserRemainingLimit(taxId);

const remainingLimitInUnits =
rampDirection === RampDirection.OFFRAMP
? remainingLimitResponse.remainingLimitOfframp
: remainingLimitResponse.remainingLimitOnramp;

const amountNum = Number(executionInput.quote.inputAmount);
const remainingLimitNum = Number(remainingLimitInUnits);
if (amountNum > remainingLimitNum) {
// Check for a kyc level 1 here is implicit, due to checks in `useRampAmountWithinAllowedLimits` and
// Check for a kyc level 1 here is implicit, due to checks in `useRampAmountWithinAllowedLimits` and
// handling of level 0 users.
setRampKycLevel2Started(true);
return;
}
}

// append EVM address to execution input
const updatedBrlaRampExecution = { ...executionInput, brlaEvmAddress };
Expand Down
Loading