remove deposit limit notification

This commit is contained in:
tjs 2023-02-25 15:02:21 -05:00
parent ebb0d546b7
commit dc33e98a8a
4 changed files with 4 additions and 71 deletions

View File

@ -1,4 +1,3 @@
import { Bank, toUiDecimalsForQuote } from '@blockworks-foundation/mango-v4'
import {
ArrowDownTrayIcon,
ArrowLeftIcon,
@ -14,7 +13,6 @@ import NumberFormat, { NumberFormatValues } from 'react-number-format'
import mangoStore from '@store/mangoStore'
import {
ACCOUNT_ACTION_MODAL_INNER_HEIGHT,
ALPHA_DEPOSIT_LIMIT,
INPUT_TOKEN_DEFAULT,
} from './../utils/constants'
import { notify } from './../utils/notifications'
@ -23,7 +21,6 @@ import ActionTokenList from './account/ActionTokenList'
import ButtonGroup from './forms/ButtonGroup'
import Label from './forms/Label'
import Button from './shared/Button'
import InlineNotification from './shared/InlineNotification'
import Loading from './shared/Loading'
import { EnterBottomExitBottom, FadeInFadeOut } from './shared/Transitions'
import { withValueLimit } from './swap/SwapForm'
@ -66,27 +63,6 @@ export const walletBalanceForToken = (
}
}
export const useAlphaMax = (inputAmount: string, bank: Bank | undefined) => {
const exceedsAlphaMax = useMemo(() => {
const mangoAccount = mangoStore.getState().mangoAccount.current
const group = mangoStore.getState().group
if (!group || !mangoAccount) return
if (
mangoAccount.owner.toString() ===
'8SSLjXBEVk9nesbhi9UMCA32uijbVBUqWoKPPQPTekzt'
)
return false
const accountValue = toUiDecimalsForQuote(
mangoAccount.getEquity(group).toNumber()
)
return (
parseFloat(inputAmount) * (bank?.uiPrice || 1) + accountValue >
ALPHA_DEPOSIT_LIMIT || accountValue > ALPHA_DEPOSIT_LIMIT
)
}, [inputAmount, bank])
return exceedsAlphaMax
}
function DepositForm({ onSuccess, token }: DepositFormProps) {
const { t } = useTranslation('common')
const [inputAmount, setInputAmount] = useState('')
@ -105,7 +81,6 @@ function DepositForm({ onSuccess, token }: DepositFormProps) {
const group = mangoStore.getState().group
return group?.banksMapByName.get(selectedToken)?.[0]
}, [selectedToken])
const exceedsAlphaMax = useAlphaMax(inputAmount, bank)
const logoUri = useMemo(() => {
let logoURI
@ -228,11 +203,6 @@ function DepositForm({ onSuccess, token }: DepositFormProps) {
style={{ height: ACCOUNT_ACTION_MODAL_INNER_HEIGHT }}
>
<div>
<InlineNotification
type="info"
desc={`There is a $${ALPHA_DEPOSIT_LIMIT} account value limit during alpha
testing.`}
/>
<SolBalanceWarnings
amount={inputAmount}
className="mt-2"
@ -341,10 +311,7 @@ function DepositForm({ onSuccess, token }: DepositFormProps) {
<Button
onClick={connected ? handleDeposit : handleConnect}
className="flex w-full items-center justify-center"
disabled={
connected &&
(!inputAmount || exceedsAlphaMax || showInsufficientBalance)
}
disabled={connected && (!inputAmount || showInsufficientBalance)}
size="large"
>
{!connected ? (

View File

@ -23,7 +23,7 @@ import { EnterBottomExitBottom, FadeInFadeOut } from './shared/Transitions'
import { withValueLimit } from './swap/SwapForm'
import MaxAmountButton from '@components/shared/MaxAmountButton'
import HealthImpactTokenChange from '@components/HealthImpactTokenChange'
import { useAlphaMax, walletBalanceForToken } from './DepositForm'
import { walletBalanceForToken } from './DepositForm'
import SolBalanceWarnings from '@components/shared/SolBalanceWarnings'
import useMangoAccount from 'hooks/useMangoAccount'
import useJupiterMints from 'hooks/useJupiterMints'
@ -174,8 +174,6 @@ function RepayForm({ onSuccess, token }: RepayFormProps) {
}
}, [token, banks, selectedToken])
const exceedsAlphaMax = useAlphaMax(inputAmount, bank)
const showInsufficientBalance = walletBalance.maxAmount < Number(inputAmount)
const outstandingAmount = borrowAmount.toNumber() - parseFloat(inputAmount)
@ -320,9 +318,7 @@ function RepayForm({ onSuccess, token }: RepayFormProps) {
<Button
onClick={() => handleDeposit(inputAmount)}
className="flex w-full items-center justify-center"
disabled={
!inputAmount || showInsufficientBalance || exceedsAlphaMax
}
disabled={!inputAmount || showInsufficientBalance}
size="large"
>
{submitting ? (

View File

@ -1,4 +1,3 @@
import { toUiDecimalsForQuote } from '@blockworks-foundation/mango-v4'
import { Transition } from '@headlessui/react'
import {
ArrowDownTrayIcon,
@ -11,7 +10,6 @@ import { useWallet } from '@solana/wallet-adapter-react'
import mangoStore from '@store/mangoStore'
import Decimal from 'decimal.js'
import useMangoAccount from 'hooks/useMangoAccount'
import useMangoGroup from 'hooks/useMangoGroup'
import useSolBalance from 'hooks/useSolBalance'
import { useTranslation } from 'next-i18next'
import Image from 'next/image'
@ -23,7 +21,6 @@ import {
useMemo,
useState,
} from 'react'
import { ALPHA_DEPOSIT_LIMIT } from 'utils/constants'
import { notify } from 'utils/notifications'
import ActionTokenList from '../account/ActionTokenList'
import ButtonGroup from '../forms/ButtonGroup'
@ -53,7 +50,6 @@ const UserSetupModal = ({
onClose: () => void
}) => {
const { t } = useTranslation(['common', 'onboarding', 'swap'])
const { group } = useMangoGroup()
const { connected, select, wallet, wallets, publicKey } = useWallet()
const { mangoAccount } = useMangoAccount()
const mangoAccountLoading = mangoStore((s) => s.mangoAccount.initialLoad)
@ -161,23 +157,6 @@ const UserSetupModal = ({
return banks.find((b) => b.bank.name === depositToken)?.bank
}, [depositToken, banks])
const exceedsAlphaMax = useMemo(() => {
const mangoAccount = mangoStore.getState().mangoAccount.current
if (!group || !mangoAccount) return
if (
mangoAccount.owner.toString() ===
'8SSLjXBEVk9nesbhi9UMCA32uijbVBUqWoKPPQPTekzt'
)
return false
const accountValue = toUiDecimalsForQuote(
mangoAccount.getEquity(group)!.toNumber()
)
return (
parseFloat(depositAmount) * (depositBank?.uiPrice || 1) >
ALPHA_DEPOSIT_LIMIT || accountValue > ALPHA_DEPOSIT_LIMIT
)
}, [depositAmount, depositBank, group])
const tokenMax = useMemo(() => {
const bank = banks.find((b) => b.bank.name === depositToken)
if (bank) {
@ -392,10 +371,6 @@ const UserSetupModal = ({
</h2>
<UserSetupTransition show={depositToken.length > 0}>
<div className="mb-4">
<InlineNotification
type="info"
desc={`There is a $${ALPHA_DEPOSIT_LIMIT} account value limit during alpha testing.`}
/>
<SolBalanceWarnings
amount={depositAmount}
className="mt-4"
@ -502,10 +477,7 @@ const UserSetupModal = ({
<Button
className="mb-6 mt-10 flex items-center justify-center"
disabled={
!depositAmount ||
!depositToken ||
exceedsAlphaMax ||
showInsufficientBalance
!depositAmount || !depositToken || showInsufficientBalance
}
onClick={handleDeposit}
size="large"

View File

@ -10,8 +10,6 @@ export const OUTPUT_TOKEN_DEFAULT = 'SOL'
export const JUPITER_V4_PROGRAM_ID =
'JUP4Fb2cqiRUcaTHdrPC8h2gNsA2ETXiPDD33WcGuJB'
export const ALPHA_DEPOSIT_LIMIT = 200
export const CONNECTION_COMMITMENT = 'processed'
// Local storage keys for settings