Skip to content
Merged

v3.0.3 #1685

Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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": "3.0.2",
"version": "3.0.3",
"homepage": "./",
"private": false,
"license": "SEE LICENSE IN LICENSE FILE",
Expand Down
6 changes: 4 additions & 2 deletions src/api/campaign/getCampaignApys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@ import { fetchWithTimeout } from 'utils/fetch'
import { convertAprToApy } from 'utils/parsers'

function processApyData(aprOrApy: number, isApr: boolean, isPercent: boolean): number {
if (!isApr && isPercent) return aprOrApy
const percentApr = isPercent ? aprOrApy : aprOrApy * 100
// Ensure the value is a number (API might return strings)
const numericValue = typeof aprOrApy === 'string' ? parseFloat(aprOrApy) : aprOrApy
if (!isApr && isPercent) return numericValue
const percentApr = isPercent ? numericValue : numericValue * 100
const apy = isApr ? convertAprToApy(percentApr, 365) : percentApr
return apy
}
Expand Down
5 changes: 5 additions & 0 deletions src/chains/neutron/neutron-1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,11 @@ const Neutron1: ChainConfig = {
campaignIds: ['lido'],
campaignDenom: 'stETH',
},
{
denom: 'ibc/0E293A7622DC9A6439DB60E6D234B5AF446962E27CA3AB44D0590603DFF6968E',
campaignIds: ['ntrn-rewards'],
campaignDenom: 'wbtc',
},
],
deprecated: [
'ibc/3649CE0C8A2C79048D8C6F31FF18FA69C9BC7EB193512E0BD03B733011290445',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export default function Apy(props: Props) {
return (
<div className='flex justify-end my-auto text-xs'>
{hasLstApy ? (
<Tooltip content='Includes underlying staking APY from Liquid Staking Token' type='info'>
<Tooltip content='Includes underlying staking or rewards APY' type='info'>
<div className='border-b border-dashed hover:cursor-help border-white/40 hover:border-transparent'>
<FormattedNumber
amount={totalApy}
Expand Down
4 changes: 1 addition & 3 deletions src/components/portfolio/Account/Summary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,7 @@ function Content(props: Props) {
title: (
<Tooltip
type='info'
content={
hasLstApy ? 'Includes underlying staking APY from Liquid Staking Tokens' : undefined
}
content={hasLstApy ? 'Includes underlying staking or rewards APY' : undefined}
>
<div className='flex w-full justify-center'>
<div
Expand Down
23 changes: 22 additions & 1 deletion src/constants/campaigns.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Droplet, Lido, MilkyWay, Stride } from 'components/common/Icons'
import { Droplet, Lido, MilkyWay, Neutron, Stride } from 'components/common/Icons'

export const CAMPAIGNS: AssetCampaign[] = [
{
Expand Down Expand Up @@ -96,6 +96,25 @@ export const CAMPAIGNS: AssetCampaign[] = [
tooltip: 'Your deposit will still earn the underlying Milkyway staking APY.',
enabledOnV1: true,
},
{
id: 'ntrn-rewards',
name: 'Neutron Rewards',
type: 'apy',
apyApi: {
url: 'https://cache.marsprotocol.io/api/ntrn-rewards-mars',
isApr: false,
isPercent: true,
apyStructure: ['ntrnRewardsDataMars', 'apy'],
denomStructure: ['denom'],
},
incentiveCopy: '+##APY##% APY',
classNames: 'ntrn-rewards',
bgClassNames: 'gradient-ntrn-rewards',
detailedIncentiveCopy: 'Deposits earn additional ##APY##% APY via Neutron (NTRN) Rewards.',
tooltip:
"Your deposit will earn additional Neutron (NTRN) Rewards. ATTENTION: Don't reduce or withdraw your position after depositing, as this would forfeit your NTRN rewards. You can still add to your position safely.",
enabledOnV1: true,
},
]

export function CampaignLogo({ campaignId }: { campaignId: AssetCampaignId }) {
Expand All @@ -109,6 +128,8 @@ export function CampaignLogo({ campaignId }: { campaignId: AssetCampaignId }) {
return <Lido />
case 'milkyway':
return <MilkyWay />
case 'ntrn-rewards':
return <Neutron />
default:
return null
}
Expand Down
2 changes: 1 addition & 1 deletion src/types/app.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1878,7 +1878,7 @@ interface StakedAstroLpRewards {
rewards: BNCoin[]
}

type AssetCampaignId = 'stride' | 'drop' | 'lido' | 'drop_apy' | 'milkyway'
type AssetCampaignId = 'stride' | 'drop' | 'lido' | 'drop_apy' | 'milkyway' | 'ntrn-rewards'
type AssetCampaignType = 'points_with_multiplier' | 'apy'
type AssetCampaignPointBase = 'value' | 'amount'

Expand Down
20 changes: 15 additions & 5 deletions src/utils/accounts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { MarketResponse } from 'types/generated/mars-perps/MarsPerps.types'
import { Positions } from 'types/generated/mars-rover-health-computer/MarsRoverHealthComputer.types'
import { byDenom } from 'utils/array'
import { getCoinValue } from 'utils/formatters'
import { BN, mergeBNCoinArrays } from 'utils/helpers'
import { BN } from 'utils/helpers'
import { convertAprToApy } from 'utils/parsers'

export const calculateAccountBalanceValue = (
Expand Down Expand Up @@ -203,12 +203,22 @@ export const calculateAccountApy = (
if (!asset) return BN_ZERO
const price = asset.price?.amount ?? BN_ZERO
const amount = lend.amount.shiftedBy(-asset.decimals)
const apy = lendingAssetsData.find((lendingAsset) => lendingAsset.asset.denom === lend.denom)
?.apy.deposit
const marketApy = lendingAssetsData.find(
(lendingAsset) => lendingAsset.asset.denom === lend.denom,
)?.apy.deposit

if (!apy) return
if (!marketApy) return

const positionInterest = amount.multipliedBy(price).multipliedBy(apy).dividedBy(100)
// Add campaign APY if available
let campaignApy = 0
asset.campaigns?.forEach((campaign) => {
if (campaign.type === 'apy') {
campaignApy += campaign.apy ?? 0
}
})

const totalApy = marketApy + campaignApy
const positionInterest = amount.multipliedBy(price).multipliedBy(totalApy).dividedBy(100)

totalLendsInterestValue = totalLendsInterestValue.plus(positionInterest)
})
Expand Down
11 changes: 11 additions & 0 deletions tailwind.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,12 @@ module.exports = {
'gradient-stride',
'gradient-lido',
'gradient-milkyway',
'gradient-ntrn-rewards',
'droplets',
'stride',
'lido',
'milkyway',
'ntrn-rewards',
],
theme: {
extend: {
Expand Down Expand Up @@ -479,6 +481,9 @@ module.exports = {
background:
'linear-gradient(270deg, hsl(var(--color-active-tab-primary) /0.765) 0%, hsl(var(--color-active-tab-secondary) /0.886) 23.77%, hsl(var(--color-active-tab-tertiary) /0.26) 99.2%)',
},
'.gradient-ntrn-rewards': {
background: 'linear-gradient(90deg, #ff4b2f, #ff9382)',
},
'.gradient-droplets': {
background: 'linear-gradient(90deg, #6039FF, #E8B8FF)',
},
Expand Down Expand Up @@ -581,6 +586,12 @@ module.exports = {
'-webkit-text-fill-color': 'transparent',
fontWeight: 'bold',
},
'.ntrn-rewards': {
background: 'linear-gradient(90deg, #ff4b2f, #ff9382)',
'-webkit-background-clip': 'text',
'-webkit-text-fill-color': 'transparent',
fontWeight: 'bold',
},
'.stride': {
background: 'linear-gradient(90deg, #E50571, #FB5DA9)',
'-webkit-background-clip': 'text',
Expand Down