Skip to content

Commit

Permalink
Merge pull request #1173 from mars-protocol/develop
Browse files Browse the repository at this point in the history
v2.7.3
  • Loading branch information
StefChatz authored Oct 10, 2024
2 parents 3b35e4e + ae0800c commit 48050cc
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 17 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.7.2",
"version": "2.7.3",
"homepage": "./",
"private": false,
"license": "SEE LICENSE IN LICENSE FILE",
Expand Down
4 changes: 1 addition & 3 deletions src/api/hls/getHlsFarms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,5 @@ export default async function getHlsFarms(
}
})

//TODO: uncomment this line
//return hlsFarms
return []
return hlsFarms
}
5 changes: 2 additions & 3 deletions src/components/hls/Farm/Table/Columns/Name.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import AssetImage from 'components/common/assets/AssetImage'
import DoubleLogo from 'components/common/DoubleLogo'
import Text from 'components/common/Text'
import { BN_ZERO } from 'constants/math'
import useCurrentAccount from 'hooks/accounts/useCurrentAccount'
import useAsset from 'hooks/assets/useAsset'
import usePoolAssets from 'hooks/assets/usePoolAssets'
import { useMemo } from 'react'
Expand All @@ -18,11 +17,11 @@ export const NAME_META = {

interface Props {
farm: AstroLp | DepositedAstroLp
account?: Account
}

export default function Name(props: Props) {
const { farm } = props
const account = useCurrentAccount()
const { farm, account } = props
const primaryAsset = useAsset(farm.denoms.primary)
const poolAssets = usePoolAssets()
const poolAsset = poolAssets.find(byDenom(farm.denoms.lp))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ export default function useActiveHlsFarmsColumns(assets: Asset[]) {
return [
{
...NAME_META,
cell: ({ row }) => <Name farm={row.original.farm as DepositedAstroLp} />,
cell: ({ row }) => (
<Name farm={row.original.farm as DepositedAstroLp} account={row.original.account} />
),
},
{ ...ACCOUNT_META, cell: ({ row }) => <Account account={row.original.account} /> },
{
Expand Down
4 changes: 0 additions & 4 deletions src/components/trade/TradeChart/DataFeed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,6 @@ export const datafeed = {
'720',
'D',
'1D',
'W',
'1W',
'M',
'1M',
] as ResolutionString[],
supports_marks: true,
supports_timescale_marks: false,
Expand Down
16 changes: 11 additions & 5 deletions src/utils/accounts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,14 +116,15 @@ export const calculateAccountApr = (
const debtsValue = calculateAccountValue('debts', account, assets)
const perpsValue = calculateAccountValue('perps', account, assets)
const stakedAstroLpsValue = calculateAccountValue('stakedAstroLps', account, assets)
const totalValue = depositValue

const totalDenominatorValue = depositValue
.plus(lendsValue)
.plus(vaultsValue)
.plus(perpsValue)
.plus(stakedAstroLpsValue)
const totalNetValue = totalValue.minus(debtsValue)
.plus(debtsValue.abs())

if (totalNetValue.isLessThanOrEqualTo(0)) return BN_ZERO
if (totalDenominatorValue.isLessThanOrEqualTo(0)) return BN_ZERO
const { vaults, lends, debts, deposits, stakedAstroLps } = account

let totalDepositsInterestValue = BN_ZERO
Expand Down Expand Up @@ -164,6 +165,7 @@ export const calculateAccountApr = (
.multipliedBy(price)
.multipliedBy(convertApyToApr(apy, 365))
.dividedBy(100)

totalLendsInterestValue = totalLendsInterestValue.plus(positionInterest)
})

Expand All @@ -172,6 +174,7 @@ export const calculateAccountApr = (
if (!apr) return
const lockedValue = vault.values.primary.plus(vault.values.secondary)
const positionInterest = lockedValue.multipliedBy(apr).dividedBy(100)

totalVaultsInterestValue = totalVaultsInterestValue.plus(positionInterest)
})

Expand Down Expand Up @@ -199,16 +202,19 @@ export const calculateAccountApr = (
const farmApr = farm.apr ?? 0
const farmValue = getCoinValue(stakedAstroLp, assets)
const positionInterest = farmValue.multipliedBy(farmApr).dividedBy(100)

totalAstroStakedLpsValue = totalAstroStakedLpsValue.plus(positionInterest)
})

const totalInterestValue = totalLendsInterestValue
.plus(totalVaultsInterestValue)
.minus(totalDebtInterestValue)
.plus(totalDepositsInterestValue)
.plus(totalAstroStakedLpsValue)
.minus(totalDebtInterestValue)

if (totalInterestValue.isEqualTo(0)) return BN_ZERO

return totalInterestValue.dividedBy(totalNetValue).times(100)
return totalInterestValue.dividedBy(totalDenominatorValue).times(100)
}

export function calculateAccountLeverage(account: Account, assets: Asset[]) {
Expand Down

0 comments on commit 48050cc

Please sign in to comment.