diff --git a/.eslintrc.json b/.eslintrc.json index 7488fe4..5be0d8b 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -14,6 +14,7 @@ "@next/next/no-img-element": 0, "react-hooks/rules-of-hooks": "error", // Checks rules of Hooks "react-hooks/exhaustive-deps": "warn", // Checks effect dependencies + "tailwindcss/no-custom-classname": 0, "@typescript-eslint/no-explicit-any": "error", "@typescript-eslint/no-unused-vars": [ 2, diff --git a/components/MangoProvider.tsx b/components/MangoProvider.tsx index d7f183c..53c3373 100644 --- a/components/MangoProvider.tsx +++ b/components/MangoProvider.tsx @@ -65,12 +65,12 @@ const HydrateStore = () => { // ) // refetch trade history and activity feed when switching accounts - useEffect(() => { - const actions = mangoStore.getState().actions - if (mangoAccountAddress) { - actions.fetchActivityFeed(mangoAccountAddress) - } - }, [mangoAccountAddress]) + // useEffect(() => { + // const actions = mangoStore.getState().actions + // if (mangoAccountAddress) { + // actions.fetchActivityFeed(mangoAccountAddress) + // } + // }, [mangoAccountAddress]) // reload and parse market fills from the event queue // useInterval( diff --git a/components/StakeForm.tsx b/components/StakeForm.tsx index f3eb661..929cc69 100644 --- a/components/StakeForm.tsx +++ b/components/StakeForm.tsx @@ -28,12 +28,13 @@ import LeverageSlider from './shared/LeverageSlider' import useMangoGroup from 'hooks/useMangoGroup' import FormatNumericValue from './shared/FormatNumericValue' import { stakeAndCreate } from 'utils/transactions' -import { MangoAccount } from '@blockworks-foundation/mango-v4' +// import { MangoAccount } from '@blockworks-foundation/mango-v4' import { AnchorProvider } from '@project-serum/anchor' import useBankRates from 'hooks/useBankRates' import { Disclosure } from '@headlessui/react' import SheenLoader from './shared/SheenLoader' import useLeverageMax from 'hooks/useLeverageMax' +import { STAKEABLE_TOKENS } from 'utils/constants' const set = mangoStore.getState().set @@ -65,18 +66,18 @@ export const walletBalanceForToken = ( } } -const getNextAccountNumber = (accounts: MangoAccount[]): number => { - if (accounts.length > 1) { - return ( - accounts - .map((a) => a.accountNum) - .reduce((a, b) => Math.max(a, b), -Infinity) + 1 - ) - } else if (accounts.length === 1) { - return accounts[0].accountNum + 1 - } - return 0 -} +// const getNextAccountNumber = (accounts: MangoAccount[]): number => { +// if (accounts.length > 1) { +// return ( +// accounts +// .map((a) => a.accountNum) +// .reduce((a, b) => Math.max(a, b), -Infinity) + 1 +// ) +// } else if (accounts.length === 1) { +// return accounts[0].accountNum + 1 +// } +// return 0 +// } function StakeForm({ token: selectedToken }: StakeFormProps) { const { t } = useTranslation(['common', 'account']) @@ -147,7 +148,7 @@ function StakeForm({ token: selectedToken }: StakeFormProps) { const client = mangoStore.getState().client const group = mangoStore.getState().group const actions = mangoStore.getState().actions - const mangoAccounts = mangoStore.getState().mangoAccounts + // const mangoAccounts = mangoStore.getState().mangoAccounts const mangoAccount = mangoStore.getState().mangoAccount.current if (!group || !stakeBank || !publicKey) return @@ -155,8 +156,11 @@ function StakeForm({ token: selectedToken }: StakeFormProps) { set((state) => { state.submittingBoost = true }) + const tokenNum = STAKEABLE_TOKENS.findIndex( + (t) => t.toLowerCase() === stakeBank.name.toLowerCase(), + ) try { - const newAccountNum = getNextAccountNumber(mangoAccounts) + // const newAccountNum = getNextAccountNumber(mangoAccounts) const { signature: tx, slot } = await stakeAndCreate( client, group, @@ -164,18 +168,16 @@ function StakeForm({ token: selectedToken }: StakeFormProps) { amountToBorrow, stakeBank.mint, parseFloat(inputAmount), - newAccountNum + 300, + 420 + tokenNum, ) notify({ title: 'Transaction confirmed', type: 'success', txid: tx, }) - if (!mangoAccount) { - await actions.fetchMangoAccounts( - (client.program.provider as AnchorProvider).wallet.publicKey, - ) - } + await actions.fetchMangoAccounts( + (client.program.provider as AnchorProvider).wallet.publicKey, + ) await actions.reloadMangoAccount(slot) await actions.fetchWalletTokens(publicKey) set((state) => { diff --git a/components/UnstakeForm.tsx b/components/UnstakeForm.tsx index 57507bf..8edd600 100644 --- a/components/UnstakeForm.tsx +++ b/components/UnstakeForm.tsx @@ -201,7 +201,7 @@ function UnstakeForm({ token: selectedToken }: UnstakeFormProps) { return ( <> setShowTokenList(false)} /> @@ -311,8 +311,8 @@ function UnstakeForm({ token: selectedToken }: UnstakeFormProps) { @@ -362,7 +362,7 @@ function UnstakeForm({ token: selectedToken }: UnstakeFormProps) { ) : showInsufficientBalance ? (
- + {t('swap:insufficient-balance', { symbol: formatTokenSymbol(selectedToken), })} diff --git a/public/locales/en/common.json b/public/locales/en/common.json index c20a54e..7d9b255 100644 --- a/public/locales/en/common.json +++ b/public/locales/en/common.json @@ -130,6 +130,7 @@ "rate": "Rate (APR)", "rates": "Rates (APR)", "refresh-data": "Manually refresh data", + "refresh-balance": "Refresh Balance", "remove": "Remove", "remove-delegate": "Remove Delegate", "repay": "Repay", diff --git a/utils/transactions.ts b/utils/transactions.ts index 7aaf82b..8d641c4 100644 --- a/utils/transactions.ts +++ b/utils/transactions.ts @@ -84,7 +84,10 @@ export const unstakeAndClose = async ( mangoAccountPk: mangoAccount.publicKey, owner: payer, inputMintPk: stakeBank.mint, - amountIn: toUiDecimals(selectedRoute.inAmount, stakeBank.mintDecimals), + amountIn: toUiDecimals( + selectedRoute.inAmount + 10, + stakeBank.mintDecimals, + ), outputMintPk: solBank.mint, userDefinedInstructions: jupiterIxs, userDefinedAlts: jupiterAlts,