Skip to content

Commit 9434e52

Browse files
committed
UI showing drip rate till the program ends
1 parent 60ebe3d commit 9434e52

File tree

3 files changed

+10
-9
lines changed

3 files changed

+10
-9
lines changed

frontend/src/components/GeyserFirst/MyStats.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export const MyStats = () => {
1414
const {
1515
userStats: { apy, currentMultiplier, maxMultiplier, currentReward },
1616
vaultStats: { currentStake },
17-
geyserStats: { calcPeriodInDays, duration },
17+
geyserStats: { calcPeriodInDays, duration, hasMultiplier },
1818
} = useContext(StatsContext)
1919
const {
2020
selectedGeyserInfo: {
@@ -80,7 +80,7 @@ export const MyStats = () => {
8080
}}
8181
/>
8282

83-
{calcPeriodInDays > 1 ? (
83+
{hasMultiplier ? (
8484
<GeyserStatsBox
8585
containerClassName="w-1/2"
8686
name="Multiplier"

frontend/src/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ export type GeyserStats = {
120120
unlockedRewards: number
121121
bonusRewards: RewardStats[]
122122
bonusRewardsVal: number
123+
hasMultiplier: boolean
123124
}
124125

125126
export type VaultTokenBalance = TokenInfo & {

frontend/src/utils/stats.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ export const defaultGeyserStats = (): GeyserStats => ({
4343
unlockedRewards: 0,
4444
bonusRewards: [],
4545
bonusRewardsVal: 0,
46+
hasMultiplier: true,
4647
})
4748

4849
export const defaultVaultStats = (): VaultStats => ({
@@ -65,9 +66,8 @@ const getGeyserDuration = (geyser: Geyser) => {
6566
}
6667

6768
export const getCalcPeriod = (geyser: Geyser) => {
68-
const { scalingTime } = geyser
6969
const geyserDuration = getGeyserDuration(geyser)
70-
return Math.max(Math.min(geyserDuration, parseInt(scalingTime, 10)), DAY_IN_SEC)
70+
return Math.max(geyserDuration, DAY_IN_SEC)
7171
}
7272

7373
export const getGeyserTotalDeposit = (geyser: Geyser, stakingTokenInfo: StakingTokenInfo) => {
@@ -93,6 +93,7 @@ export const getGeyserStats = async (
9393
ls.computeAndCache<GeyserStats>(
9494
async () => ({
9595
duration: getGeyserDuration(geyser),
96+
hasMultiplier: geyser.scalingFloor !== geyser.scalingCeiling,
9697
calcPeriodInDays: getCalcPeriod(geyser) / DAY_IN_SEC,
9798
totalDeposit: parseFloat(formatUnits(geyser.totalStake, stakingTokenInfo.decimals)),
9899
totalDepositVal: getGeyserTotalDeposit(geyser, stakingTokenInfo),
@@ -216,10 +217,10 @@ const calculateAPY = (inflow: number, outflow: number, periods: number) => (outf
216217
* APY = (1 + (outflow / inflow)) ** periods - 1
217218
*
218219
* inflow = (amount staked by vault * price of the staking token)
219-
* outflow = (reward that will be unlocked by vault in the next `scalingTime * price of reward token)
220+
* outflow = (reward that will be unlocked by vault in the next calcPeriod * price of reward token)
220221
* periods = number of `calcPeriod` in a year
221222
*
222-
* calcPeriod = max(min(geyserDuration, scalingTime), day)
223+
* calcPeriod = min(geyserDuration, 30 days)
223224
*/
224225
export const getUserAPY = async (
225226
geyser: Geyser,
@@ -233,14 +234,13 @@ export const getUserAPY = async (
233234
) =>
234235
ls.computeAndCache<number>(
235236
async function () {
236-
const { scalingTime } = geyser
237237
const { decimals: stakingTokenDecimals, price: stakingTokenPrice } = stakingTokenInfo
238238
const { decimals: rewardTokenDecimals, symbol: rewardTokenSymbol } = rewardTokenInfo
239239
const rewardTokenPrice = await getCurrentPrice(rewardTokenSymbol)
240240
const calcPeriod = getCalcPeriod(geyser)
241241
const drip = await (lock
242-
? getUserDrip(geyser, lock, additionalStakes, parseInt(scalingTime, 10), signerOrProvider)
243-
: getStakeDrip(geyser, additionalStakes, parseInt(scalingTime, 10), signerOrProvider))
242+
? getUserDrip(geyser, lock, additionalStakes, calcPeriod, signerOrProvider)
243+
: getStakeDrip(geyser, additionalStakes, calcPeriod, signerOrProvider))
244244

245245
const stakedAmount = BigNumber.from(additionalStakes)
246246
.add(lock ? lock.amount : '0')

0 commit comments

Comments
 (0)