Skip to content

Commit

Permalink
Merge pull request #1339 from mars-protocol/develop
Browse files Browse the repository at this point in the history
v2.8.10
  • Loading branch information
linkielink authored Jan 30, 2025
2 parents fee85cb + 27f26cb commit 64d27b4
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 8 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "mars-v2-frontend",
"version": "2.8.9",
"version": "2.8.10",
"homepage": "./",
"private": false,
"license": "SEE LICENSE IN LICENSE FILE",
Expand Down
22 changes: 17 additions & 5 deletions src/components/account/AccountList/AccountStats.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,19 @@ import Button from 'components/common/Button'
import { ArrowDownLine, ArrowUpLine, TrashBin } from 'components/common/Icons'
import SwitchAutoLend from 'components/common/Switch/SwitchAutoLend'
import useLendingMarketAssetsTableData from 'components/earn/lend/Table/useLendingMarketAssetsTableData'
import { BN_ZERO } from 'constants/math'
import { ORACLE_DENOM } from 'constants/oracle'
import useAccount from 'hooks/accounts/useAccount'
import useWhitelistedAssets from 'hooks/assets/useWhitelistedAssets'
import useAssets from 'hooks/assets/useAssets'
import useAstroLpAprs from 'hooks/astroLp/useAstroLpAprs'
import useHealthComputer from 'hooks/health-computer/useHealthComputer'
import usePerpsMarketStates from 'hooks/perps/usePerpsMarketStates'
import usePerpsVault from 'hooks/perps/usePerpsVault'
import useVaultAprs from 'hooks/vaults/useVaultAprs'
import useStore from 'store'
import { BNCoin } from 'types/classes/BNCoin'
import { calculateAccountApy, calculateAccountBalanceValue } from 'utils/accounts'
import { mergeBNCoinArrays } from 'utils/helpers'
import usePerpsMarketStates from 'hooks/perps/usePerpsMarketStates'

interface Props {
accountId: string
Expand All @@ -26,30 +29,39 @@ interface Props {

export default function AccountStats(props: Props) {
const { accountId, isActive, setShowMenu } = props
const assets = useWhitelistedAssets()
const { data: assets } = useAssets()
const { data: account } = useAccount(accountId)
const { data: vaultAprs } = useVaultAprs()
const { data: perpsVault } = usePerpsVault()
const astroLpAprs = useAstroLpAprs()
const perpsMarketStates = usePerpsMarketStates()

const positionBalance = useMemo(
() => (!account ? null : calculateAccountBalanceValue(account, assets)),
[account, assets],
)
const { health, healthFactor } = useHealthComputer(account)
const accountBalanceValue = useMemo(
() => (!account ? BN_ZERO : calculateAccountBalanceValue(account, assets)),
[account, assets],
)

const coin = BNCoin.fromDenomAndBigNumber(ORACLE_DENOM, accountBalanceValue)
const data = useBorrowMarketAssetsTableData()
const borrowAssetsData = useMemo(() => data?.allAssets || [], [data])

const { availableAssets: lendingAvailableAssets, accountLentAssets } =
useLendingMarketAssetsTableData()

const perpsMarketStates = usePerpsMarketStates()

const lendingAssetsData = useMemo(
() => [...lendingAvailableAssets, ...accountLentAssets],
[lendingAvailableAssets, accountLentAssets],
)
const apy = useMemo(
() =>
!account
? null
? BN_ZERO
: calculateAccountApy(
account,
borrowAssetsData,
Expand Down
1 change: 1 addition & 0 deletions src/components/account/AccountList/Skeleton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export default function Skeleton(props: Props) {
{positionBalance ? (
<DisplayCurrency
coin={BNCoin.fromDenomAndBigNumber(ORACLE_DENOM, positionBalance)}
options={{ abbreviated: false }}
className='w-full text-xl'
/>
) : (
Expand Down
9 changes: 7 additions & 2 deletions src/components/header/RewardsCenter/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,14 @@ export default function RewardsCenter(props: Props) {
const { isAutoLendEnabledForCurrentAccount: isAutoLend } = useAutoLend()

const { data: stakedAstroLpRewards } = useStakedAstroLpRewards()

const currentLpRewards = useMemo(() => {
if (stakedAstroLpRewards.length === 0) return []
return stakedAstroLpRewards[0].rewards
let currentLpRewardsArray = [] as BNCoin[]
if (stakedAstroLpRewards.length === 0) return currentLpRewardsArray
stakedAstroLpRewards.forEach((stakeAstroLpReward) => {
currentLpRewardsArray = mergeBNCoinArrays(currentLpRewardsArray, stakeAstroLpReward.rewards)
})
return currentLpRewardsArray
}, [stakedAstroLpRewards])

const rewards = useMemo(
Expand Down

0 comments on commit 64d27b4

Please sign in to comment.