Skip to content

Commit

Permalink
fix vault balance
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasmagnus committed Dec 6, 2023
1 parent f6f5976 commit d3483f8
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
3 changes: 2 additions & 1 deletion frontend/src/app/core/pages/contracts-detail/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,8 @@ export const ContractsDetail: React.FC = () => {

setValue('amount', '')
await getProfile()
await getHistory(contract.id)
const history = await getHistory(contract.id)
setHistory(history)

toast({
title: 'Deposit success!',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ export const Deposit: React.FC<IDeposit> = ({
} = useForm()

const [amount, setAmount] = useState<string>()
const [isLimitExceded, setLimitExceded] = useState(false)
const [isLimitExceeded, setLimitExceeded] = useState(false)

const limitExceded = (amount: string): void => {
setLimitExceded(Number(toNumber(amount)) > Number(currentBalance))
const limitExceeded = (amount: string): void => {
setLimitExceeded(Number(toNumber(amount)) > Number(currentBalance))
}

return (
Expand Down Expand Up @@ -100,7 +100,7 @@ export const Deposit: React.FC<IDeposit> = ({
autoComplete="off"
onChange={(target): void => {
setAmount(toNumber(target.currentTarget.value))
limitExceded(target.currentTarget.value)
limitExceeded(target.currentTarget.value)
}}
/>
<FormErrorMessage>Required</FormErrorMessage>
Expand All @@ -113,7 +113,7 @@ export const Deposit: React.FC<IDeposit> = ({
variant="primary"
isLoading={loading}
mt="1.5rem"
isDisabled={Number(currentBalance) === 0 || isLimitExceded}
isDisabled={Number(currentBalance) === 0 || isLimitExceeded}
>
Deposit
</Button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,10 @@ export const Withdraw: React.FC<IWithdraw> = ({

const insuficientBalance = (): boolean => {
if (!isDone) {
return contractData.estimatedPrematureWithdraw > Number(currentInVault)
return (
contractData.estimatedPrematureWithdraw / 10000000 >
Number(currentInVault)
)
}
return contractData.position > Number(currentInVault)
}
Expand Down

0 comments on commit d3483f8

Please sign in to comment.