From 40ea600f377e69bc33ede5fc3d83860abbd8fddc Mon Sep 17 00:00:00 2001 From: saml33 Date: Mon, 18 Sep 2023 10:21:29 +1000 Subject: [PATCH] add apy to positions --- components/AccountStats.tsx | 7 +++---- components/Positions.tsx | 15 ++++++++++++++- components/StakeForm.tsx | 7 ++++--- components/UnstakeForm.tsx | 4 ++-- 4 files changed, 23 insertions(+), 10 deletions(-) diff --git a/components/AccountStats.tsx b/components/AccountStats.tsx index e122e0f..e1daba7 100644 --- a/components/AccountStats.tsx +++ b/components/AccountStats.tsx @@ -45,13 +45,12 @@ const AccountStats = ({ token }: { token: string }) => {

Max Est. APY

{loadingRates ? ( - -
+ +
) : stakeRates?.[token.toLowerCase()] ? ( `${(stakeRates?.[token.toLowerCase()] * 100).toFixed(2)}%` ) : null} - % SOL
@@ -68,7 +67,7 @@ const AccountStats = ({ token }: { token: string }) => {

Total Staked

{' '} - {token} + {formatTokenSymbol(token)}
diff --git a/components/Positions.tsx b/components/Positions.tsx index a6a472a..0ad97a8 100644 --- a/components/Positions.tsx +++ b/components/Positions.tsx @@ -7,6 +7,8 @@ import { formatTokenSymbol } from 'utils/tokens' import mangoStore from '@store/mangoStore' import Switch from './forms/Switch' import useLocalStorageState from 'hooks/useLocalStorageState' +import useStakeRates from 'hooks/useStakeRates' +import SheenLoader from './shared/SheenLoader' const set = mangoStore.getState().set @@ -16,6 +18,7 @@ const Positions = ({ setActiveTab: (tab: string) => void }) => { const { group } = useMangoGroup() + const { data: stakeRates, isLoading: loadingRates } = useStakeRates() const [showInactivePositions, setShowInactivePositions] = useLocalStorageState(SHOW_INACTIVE_POSITIONS_KEY, true) @@ -108,7 +111,17 @@ const Positions = ({

Est. APY

- 14.89% + + {loadingRates ? ( + +
+ + ) : stakeRates?.[bank.name.toLowerCase()] ? ( + `${(stakeRates?.[bank.name.toLowerCase()] * 100).toFixed( + 2, + )}%` + ) : null} +

Leverage

diff --git a/components/StakeForm.tsx b/components/StakeForm.tsx index ea4b862..6837960 100644 --- a/components/StakeForm.tsx +++ b/components/StakeForm.tsx @@ -339,7 +339,7 @@ function DepositForm({ onSuccess, token: selectedToken }: DepositFormProps) {
-

{selectedToken} Leveraged APY

+

{formatTokenSymbol(selectedToken)} Leveraged APY

-

{selectedToken} Deposit Rate

+

{formatTokenSymbol(selectedToken)} Deposit Rate

) : (
- Leverage Stake {inputAmount} {selectedToken} + Leverage Stake {inputAmount}{' '} + {formatTokenSymbol(selectedToken)}
)} diff --git a/components/UnstakeForm.tsx b/components/UnstakeForm.tsx index 1dbcc2e..28af816 100644 --- a/components/UnstakeForm.tsx +++ b/components/UnstakeForm.tsx @@ -305,12 +305,12 @@ function UnstakeForm({ onSuccess, token: selectedToken }: UnstakeFormProps) {
{t('swap:insufficient-balance', { - symbol: selectedToken, + symbol: formatTokenSymbol(selectedToken), })}
) : (
- Unstake {inputAmount} {selectedToken} + Unstake {inputAmount} {formatTokenSymbol(selectedToken)}
)}