Skip to content

Commit

Permalink
using charm contract data for geyser calc
Browse files Browse the repository at this point in the history
  • Loading branch information
aalavandhan committed May 15, 2024
1 parent 7388273 commit 067838d
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 10 deletions.
2 changes: 1 addition & 1 deletion frontend/src/components/GeyserFirst/MyStats.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export const MyStats = () => {
() => [
{
title: 'APY',
body: currentStake > 0 ? GET_APY_STAKE_MSG() : GET_APY_NO_STAKE_MSG({ days: safeNumeral(calcPeriodInDays||30, '0.0') }),
body: currentStake > 0 ? GET_APY_STAKE_MSG() : GET_APY_NO_STAKE_MSG(),
},
{
title: 'Reward Multiplier',
Expand Down
6 changes: 3 additions & 3 deletions frontend/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,10 @@ export const INITIAL_SUPPLY = 50000000

// tooltip messages
export const GET_APY_STAKE_MSG = () =>
'APY is estimated for your current deposits till the end of this program. The APY metric does not account for gains or losses from holding liquidity tokens, or gains from liquidity mining rewards distributed by the underlying platform for holding liquidity tokens.'
'APY is estimated for your current deposits till the end of the active program. The APY metric does not account for gains or losses from holding liquidity tokens, or gains from liquidity mining rewards distributed by the underlying platform for holding liquidity tokens.'

export const GET_APY_NO_STAKE_MSG = ({ days = '1' }) =>
`APY is estimated for an avg deposit (20,000 USD) over the next ${days} days. The APY metric does not account for gains or losses from holding liquidity tokens, or gains from liquidity mining rewards distributed by the underlying platform for holding liquidity tokens.`
export const GET_APY_NO_STAKE_MSG = () =>
`APY is estimated for an avg deposit (of 20,000 USD) till the end of the active program. The APY metric does not account for gains or losses from holding liquidity tokens, or gains from liquidity mining rewards distributed by the underlying platform for holding liquidity tokens.`

export const GET_REWARD_MULTIPLIER_MSG = ({ days = '30', multiplier = '3.0' }) =>
`Deposit liquidity tokens for ${days} days to achieve a ${multiplier}x reward multiplier.`
Expand Down
6 changes: 2 additions & 4 deletions frontend/src/utils/stakingToken.ts
Original file line number Diff line number Diff line change
Expand Up @@ -412,15 +412,13 @@ const getCharmV1 = async (tokenAddress: string, signerOrProvider: SignerOrProvid
const contract = new Contract(address, CHARM_V1_ABI, signerOrProvider)

const { name, symbol, decimals } = await getTokenInfo(address, signerOrProvider)
const poolBals = await contract.getTotalAmounts()
const totalSupply: BigNumber = await contract.totalSupply()
const totalSupplyNumber = parseFloat(formatUnits(totalSupply, decimals))

const vaultData = await fetch(`https://web-api.ampleforth.org/lp/charm-vault-info?chainID=1&vaultAddress=${tokenAddress}`);
const vault = await vaultData.json();

const tokenCompositions = await getTokenCompositionsWithBalances(
[await contract.token0(), await contract.token1()],
[vault.total0, vault.total1],
poolBals,
signerOrProvider,
[0.5, 0.5],
)
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/utils/stats.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export const defaultUserStats = (): UserStats => ({
apy: 0,
currentMultiplier: 1.0,
minMultiplier: 1.0,
maxMultiplier: 1.0,
maxMultiplier: 3.0,
currentReward: 0,
currentRewardShare: 0,
})
Expand Down Expand Up @@ -323,7 +323,7 @@ const getCurrentMultiplier = async (
const perc = Math.min(now - ts, st) / st
weightedStake += perc * amt
})
const fraction = weightedStake / totalStake
const fraction = (geyserVaultData.stakes.length > 0) ? weightedStake / totalStake : 0
const currentMultiplier = minMultiplier + fraction * (maxMultiplier - minMultiplier)
return [minMultiplier, currentMultiplier, maxMultiplier]
}
Expand Down

0 comments on commit 067838d

Please sign in to comment.