diff --git a/src/apps/abracadabra/arbitrum/abracadabra.arbitrum.constants.ts b/src/apps/abracadabra/arbitrum/abracadabra.arbitrum.constants.ts index fdc809095..cb75cbab6 100644 --- a/src/apps/abracadabra/arbitrum/abracadabra.arbitrum.constants.ts +++ b/src/apps/abracadabra/arbitrum/abracadabra.arbitrum.constants.ts @@ -7,6 +7,9 @@ export const ARBITRUM_CAULDRONS: AbracadabraCauldronContractPositionDefinition[] { version: 'V4', type: 'REGULAR', address: '0x726413d7402ff180609d0ebc79506df8633701b1' }, // magicGLP ]; +export const ARBITRUM_GLP_TOKEN_ADDRESS = '0x4277f8f2c384827b5273592ff7cebd9f2c1ac258'; +export const AVALANCHE_GLP_TOKEN_ADDRESS = '0x01234181085565ed162a948b6a5e88758cd7c7b8'; + export const CURVE_MIM_3POOL_FARM = '0x839de324a1ab773f76a53900d70ac1b913d2b387'; export const M_SPELL_ADDRESS = '0x1df188958a8674b5177f77667b8d173c3cdd9e51'; diff --git a/src/apps/abracadabra/arbitrum/abracadabra.magic-glp.token-fetcher.ts b/src/apps/abracadabra/arbitrum/abracadabra.magic-glp.token-fetcher.ts index f93ddeb8b..ec81c758e 100644 --- a/src/apps/abracadabra/arbitrum/abracadabra.magic-glp.token-fetcher.ts +++ b/src/apps/abracadabra/arbitrum/abracadabra.magic-glp.token-fetcher.ts @@ -3,6 +3,7 @@ import { PositionTemplate } from '~app-toolkit/decorators/position-template.deco import { AbracadabraMagicGlpTokenFetcher } from '../common/abracadabra.magic-glp.token-fetcher'; import { + ARBITRUM_GLP_TOKEN_ADDRESS, GLP_REWARD_TRACKER_ADDRESSES, MAGIC_GLP_ADDRESS, MAGIC_GLP_ANNUAL_HARVESTS, @@ -15,4 +16,5 @@ export class ArbitrumAbracadabraMagicGlpTokenFetcher extends AbracadabraMagicGlp rewardTrackerAddresses = GLP_REWARD_TRACKER_ADDRESSES; magicGlpHarvestorAddress = MAGIC_GLP_HARVESTOR_ADDRESS; magicGlpAnnualHarvests = MAGIC_GLP_ANNUAL_HARVESTS; + glpTokenAddress = ARBITRUM_GLP_TOKEN_ADDRESS; } diff --git a/src/apps/abracadabra/avalanche/abracadabra.magic-glp.token-fetcher.ts b/src/apps/abracadabra/avalanche/abracadabra.magic-glp.token-fetcher.ts index d1c2ad640..77cdd7c21 100644 --- a/src/apps/abracadabra/avalanche/abracadabra.magic-glp.token-fetcher.ts +++ b/src/apps/abracadabra/avalanche/abracadabra.magic-glp.token-fetcher.ts @@ -1,5 +1,6 @@ import { PositionTemplate } from '~app-toolkit/decorators/position-template.decorator'; +import { AVALANCHE_GLP_TOKEN_ADDRESS } from '../arbitrum/abracadabra.arbitrum.constants'; import { HOURS_PER_YEAR } from '../common/abracadabra.common.constants'; import { AbracadabraMagicGlpTokenFetcher } from '../common/abracadabra.magic-glp.token-fetcher'; @@ -9,4 +10,5 @@ export class AvalancheAbracadabraMagicGlpTokenFetcher extends AbracadabraMagicGl rewardTrackerAddresses = ['0xd2d1162512f927a7e282ef43a362659e4f2a728f', '0x9e295b5b976a184b14ad8cd72413ad846c299660']; magicGlpHarvestorAddress = '0x05b3b96df07b4630373ae7506e51777b547335b0'; magicGlpAnnualHarvests = HOURS_PER_YEAR; + glpTokenAddress = AVALANCHE_GLP_TOKEN_ADDRESS; } diff --git a/src/apps/abracadabra/common/abracadabra.magic-glp.token-fetcher.ts b/src/apps/abracadabra/common/abracadabra.magic-glp.token-fetcher.ts index c09f5deaa..7839a25a0 100644 --- a/src/apps/abracadabra/common/abracadabra.magic-glp.token-fetcher.ts +++ b/src/apps/abracadabra/common/abracadabra.magic-glp.token-fetcher.ts @@ -21,6 +21,7 @@ const BASIS_POINTS_DIVISOR = 10000; export abstract class AbracadabraMagicGlpTokenFetcher extends Erc4626VaultTemplateTokenFetcher { groupLabel = 'Magic GLP'; + abstract glpTokenAddress: string; abstract get rewardTrackerAddresses(): string[] | Promise[]; abstract get magicGlpHarvestorAddress(): string | Promise; abstract get magicGlpAnnualHarvests(): number | Promise; @@ -32,17 +33,9 @@ export abstract class AbracadabraMagicGlpTokenFetcher extends Erc4626VaultTempla super(appToolkit); } - // Override as the underlying is sGLP, but users expect to see GLP async getUnderlyingTokenDefinitions(): Promise { - const glpTokenDefinitions = await this.appToolkit.getAppTokenPositionsFromDatabase({ - appId: 'gmx', - groupIds: ['glp'], - network: this.network, - }); - - const glpUnderlying = glpTokenDefinitions[0]; - - return [{ address: glpUnderlying.address, network: this.network }]; + // Override as the underlying is sGLP, but users expect to see GLP + return [{ address: this.glpTokenAddress, network: this.network }]; } async getLabel({ contract }: GetDisplayPropsParams): Promise { diff --git a/src/apps/teahouse/arbitrum/teahouse.vaults.token-fetcher.ts b/src/apps/teahouse/arbitrum/teahouse.vaults.token-fetcher.ts index d016c9c4a..27ae57748 100644 --- a/src/apps/teahouse/arbitrum/teahouse.vaults.token-fetcher.ts +++ b/src/apps/teahouse/arbitrum/teahouse.vaults.token-fetcher.ts @@ -6,7 +6,7 @@ import { TeahouseVaultsTokenFetcher } from '../common/teahouse.vaults.token-fetc export class ArbitrumTeahouseVaultsTokenFetcher extends TeahouseVaultsTokenFetcher { groupLabel = 'Vault share'; - queryFilterFromBlock = 84086498; + fromBlock = 84086498; async getAddresses() { return ['0x9f4fff022ebff0cbfa3faf702911d0f658a4ba9b']; diff --git a/src/apps/teahouse/common/teahouse.vaults.token-fetcher.ts b/src/apps/teahouse/common/teahouse.vaults.token-fetcher.ts index a0de6fc98..610f47097 100644 --- a/src/apps/teahouse/common/teahouse.vaults.token-fetcher.ts +++ b/src/apps/teahouse/common/teahouse.vaults.token-fetcher.ts @@ -9,7 +9,7 @@ import { TeahouseViemContractFactory } from '../contracts'; import { TeahouseVault } from '../contracts/viem'; export abstract class TeahouseVaultsTokenFetcher extends AppTokenTemplatePositionFetcher { - fromBlock: number | null; + fromBlock: number; constructor( @Inject(APP_TOOLKIT) protected readonly appToolkit: IAppToolkit, @@ -32,13 +32,15 @@ export abstract class TeahouseVaultsTokenFetcher extends AppTokenTemplatePositio const globalState = await contract.read.globalState(); const currentIndex = globalState[2]; - const enterNextCycleEvent = await contract.getEvents.EnterNextCycle( + const enterNextCycleEvents = await contract.getEvents.EnterNextCycle( { cycleIndex: currentIndex - 1 }, - { fromBlock: this.fromBlock ? BigInt(this.fromBlock) : undefined, toBlock: 'latest' }, + { fromBlock: BigInt(this.fromBlock), toBlock: 'latest' }, ); - const priceNumerator = enterNextCycleEvent[0].args.priceNumerator; - const priceDenominator = enterNextCycleEvent[0].args.priceDenominator; + if (!enterNextCycleEvents.length) return [0]; + + const priceNumerator = enterNextCycleEvents[0].args.priceNumerator; + const priceDenominator = enterNextCycleEvents[0].args.priceDenominator; const pricePerShare = BigNumber.from(priceNumerator) .mul('1' + '0'.repeat(shareDecimals)) @@ -46,6 +48,7 @@ export abstract class TeahouseVaultsTokenFetcher extends AppTokenTemplatePositio .div(BigNumber.from(priceDenominator)) .div('1' + '0'.repeat(assetDecimals)) .toNumber() / 100000000; + return [pricePerShare]; } } diff --git a/src/apps/teahouse/ethereum/teahouse.vaults.token-fetcher.ts b/src/apps/teahouse/ethereum/teahouse.vaults.token-fetcher.ts index 83c708695..1cb02c1f5 100644 --- a/src/apps/teahouse/ethereum/teahouse.vaults.token-fetcher.ts +++ b/src/apps/teahouse/ethereum/teahouse.vaults.token-fetcher.ts @@ -5,6 +5,7 @@ import { TeahouseVaultsTokenFetcher } from '../common/teahouse.vaults.token-fetc @PositionTemplate() export class EthereumTeahouseVaultsTokenFetcher extends TeahouseVaultsTokenFetcher { groupLabel = 'Vault share'; + fromBlock = 15615676; async getAddresses() { return [ diff --git a/src/apps/teahouse/optimism/teahouse.vaults.token-fetcher.ts b/src/apps/teahouse/optimism/teahouse.vaults.token-fetcher.ts index a96afa480..16acb15ab 100644 --- a/src/apps/teahouse/optimism/teahouse.vaults.token-fetcher.ts +++ b/src/apps/teahouse/optimism/teahouse.vaults.token-fetcher.ts @@ -6,7 +6,7 @@ import { TeahouseVaultsTokenFetcher } from '../common/teahouse.vaults.token-fetc export class OptimismTeahouseVaultsTokenFetcher extends TeahouseVaultsTokenFetcher { groupLabel = 'Vault share'; - queryFilterFromBlock = 53274656; + fromBlock = 53274656; async getAddresses() { return ['0x9ae039f9de94542f6f1b3fba60223e6aa4f411af', '0xee1e02609a480bdc9d9651c200d90222b6691f03']; diff --git a/src/apps/umami-finance/arbitrum/umami-finance.compound.token-fetcher.ts b/src/apps/umami-finance/arbitrum/umami-finance.compound.token-fetcher.ts index 3182c7b69..ea713d730 100644 --- a/src/apps/umami-finance/arbitrum/umami-finance.compound.token-fetcher.ts +++ b/src/apps/umami-finance/arbitrum/umami-finance.compound.token-fetcher.ts @@ -10,7 +10,6 @@ import { GetDisplayPropsParams, } from '~position/template/app-token.template.types'; -import { UmamiFinanceYieldResolver } from '../common/umami-finance.yield-resolver'; import { UmamiFinanceViemContractFactory } from '../contracts'; import { UmamiFinanceCompound } from '../contracts/viem'; @@ -20,8 +19,6 @@ export class ArbitrumUmamiFinanceCompoundTokenFetcher extends AppTokenTemplatePo constructor( @Inject(APP_TOOLKIT) protected readonly appToolkit: IAppToolkit, - @Inject(UmamiFinanceYieldResolver) - private readonly yieldResolver: UmamiFinanceYieldResolver, @Inject(UmamiFinanceViemContractFactory) protected readonly contractFactory: UmamiFinanceViemContractFactory, ) { super(appToolkit); @@ -62,11 +59,6 @@ export class ArbitrumUmamiFinanceCompoundTokenFetcher extends AppTokenTemplatePo return [reserve]; } - async getApy(_params: GetDataPropsParams) { - const { apy } = await this.yieldResolver.getStakingYield(); - return Number(apy); - } - async getImages({ appToken }: GetDisplayPropsParams): Promise { return [getTokenImg(appToken.address, this.network)]; } diff --git a/src/apps/umami-finance/arbitrum/umami-finance.glp-vaults.token-fetcher.ts b/src/apps/umami-finance/arbitrum/umami-finance.glp-vaults.token-fetcher.ts index b8de601ee..f5e626612 100644 --- a/src/apps/umami-finance/arbitrum/umami-finance.glp-vaults.token-fetcher.ts +++ b/src/apps/umami-finance/arbitrum/umami-finance.glp-vaults.token-fetcher.ts @@ -11,11 +11,9 @@ import { GetPricePerShareParams, DefaultAppTokenDataProps, GetDisplayPropsParams, - GetDataPropsParams, } from '~position/template/app-token.template.types'; import { UmamiFinanceGlpVaultAddress } from '../common/umami-finance.constants'; -import { UmamiFinanceYieldResolver } from '../common/umami-finance.yield-resolver'; import { UmamiFinanceViemContractFactory } from '../contracts'; import { UmamiFinanceGlpVault } from '../contracts/viem/UmamiFinanceGlpVault'; @@ -35,8 +33,6 @@ export class ArbitrumUmamiFinanceGlpVaultsTokenFetcher extends AppTokenTemplateP constructor( @Inject(APP_TOOLKIT) protected readonly appToolkit: IAppToolkit, - @Inject(UmamiFinanceYieldResolver) - private readonly yieldResolver: UmamiFinanceYieldResolver, @Inject(UmamiFinanceViemContractFactory) private readonly umamiFinanceContractFactory: UmamiFinanceViemContractFactory, ) { @@ -93,10 +89,4 @@ export class ArbitrumUmamiFinanceGlpVaultsTokenFetcher extends AppTokenTemplateP >): Promise { return [getTokenImg(appToken.address, this.network)]; } - - async getApy( - _params: GetDataPropsParams, - ): Promise { - return this.yieldResolver.getVaultYield(_params.address); - } } diff --git a/src/apps/umami-finance/arbitrum/umami-finance.marinate-umami.token-fetcher.ts b/src/apps/umami-finance/arbitrum/umami-finance.marinate-umami.token-fetcher.ts index ad9b308fe..7663d8cc9 100644 --- a/src/apps/umami-finance/arbitrum/umami-finance.marinate-umami.token-fetcher.ts +++ b/src/apps/umami-finance/arbitrum/umami-finance.marinate-umami.token-fetcher.ts @@ -4,9 +4,8 @@ import { APP_TOOLKIT, IAppToolkit } from '~app-toolkit/app-toolkit.interface'; import { PositionTemplate } from '~app-toolkit/decorators/position-template.decorator'; import { getTokenImg } from '~app-toolkit/helpers/presentation/image.present'; import { AppTokenTemplatePositionFetcher } from '~position/template/app-token.template.position-fetcher'; -import { GetDataPropsParams, GetDisplayPropsParams } from '~position/template/app-token.template.types'; +import { GetDisplayPropsParams } from '~position/template/app-token.template.types'; -import { UmamiFinanceYieldResolver } from '../common/umami-finance.yield-resolver'; import { UmamiFinanceViemContractFactory } from '../contracts'; import { UmamiFinanceMarinate } from '../contracts/viem'; @@ -17,8 +16,6 @@ export class ArbitrumUmamiFinanceMarinateUmamiTokenFetcher extends AppTokenTempl constructor( @Inject(APP_TOOLKIT) protected readonly appToolkit: IAppToolkit, - @Inject(UmamiFinanceYieldResolver) - private readonly yieldResolver: UmamiFinanceYieldResolver, @Inject(UmamiFinanceViemContractFactory) protected readonly contractFactory: UmamiFinanceViemContractFactory, ) { super(appToolkit); @@ -40,11 +37,6 @@ export class ArbitrumUmamiFinanceMarinateUmamiTokenFetcher extends AppTokenTempl return [1]; } - async getApy(_params: GetDataPropsParams) { - const { apr } = await this.yieldResolver.getStakingYield(); - return Number(apr); - } - async getImages({ appToken }: GetDisplayPropsParams): Promise { return [getTokenImg(appToken.address, this.network)]; } diff --git a/src/apps/umami-finance/arbitrum/umami-finance.timelocked-glp-vaults.token-fetcher.ts b/src/apps/umami-finance/arbitrum/umami-finance.timelocked-glp-vaults.token-fetcher.ts index 670a53519..32756b85d 100644 --- a/src/apps/umami-finance/arbitrum/umami-finance.timelocked-glp-vaults.token-fetcher.ts +++ b/src/apps/umami-finance/arbitrum/umami-finance.timelocked-glp-vaults.token-fetcher.ts @@ -11,11 +11,9 @@ import { UnderlyingTokenDefinition, GetPricePerShareParams, GetDisplayPropsParams, - GetDataPropsParams, } from '~position/template/app-token.template.types'; import { UmamiFinanceTimelockedGlpVaultAddress } from '../common/umami-finance.constants'; -import { UmamiFinanceYieldResolver } from '../common/umami-finance.yield-resolver'; import { UmamiFinanceViemContractFactory } from '../contracts'; import { UmamiFinanceTimelockedGlpVault } from '../contracts/viem/UmamiFinanceTimelockedGlpVault'; @@ -25,8 +23,6 @@ export class ArbitrumUmamiFinanceTimelockedGlpVaultsTokenFetcher extends AppToke constructor( @Inject(APP_TOOLKIT) protected readonly appToolkit: IAppToolkit, - @Inject(UmamiFinanceYieldResolver) - private readonly yieldResolver: UmamiFinanceYieldResolver, @Inject(UmamiFinanceViemContractFactory) private readonly umamiFinanceContractFactory: UmamiFinanceViemContractFactory, ) { @@ -73,8 +69,4 @@ export class ArbitrumUmamiFinanceTimelockedGlpVaultsTokenFetcher extends AppToke async getImages({ appToken }: GetDisplayPropsParams): Promise { return [getTokenImg(appToken.address, this.network)]; } - - async getApy({ address }: GetDataPropsParams): Promise { - return this.yieldResolver.getVaultYield(address, true); - } } diff --git a/src/apps/umami-finance/common/umami-finance.yield-resolver.ts b/src/apps/umami-finance/common/umami-finance.yield-resolver.ts deleted file mode 100644 index 30360b30b..000000000 --- a/src/apps/umami-finance/common/umami-finance.yield-resolver.ts +++ /dev/null @@ -1,54 +0,0 @@ -import { Injectable } from '@nestjs/common'; -import Axios from 'axios'; - -import { Cache } from '~cache/cache.decorator'; - -import { getUmamiApiIdFromVaultAddress } from './umami-finance.helpers'; - -type UmamiStakingMetric = { - key: 'apy' | 'apr'; - label: string; - value: string; - context: string; -}; - -export type UmamiStakingApiResponse = { - metrics: Array; -}; - -export type UmamiVaultApiResponse = { - liquidApr: number; - boostedApr: number; -}; - -@Injectable() -export class UmamiFinanceYieldResolver { - @Cache({ - key: `studio:umami-finance:marinate`, - ttl: 5 * 60, // 60 minutes - }) - async getStakingYield() { - const { data } = await Axios.get( - `https://api.umami.finance/api/v2/staking/metrics/current?keys=apy&keys=apr`, - ); - return { - apy: data.metrics[0].value, - apr: data.metrics[1].value, - }; - } - - @Cache({ - key: (vaultAddress: string) => `studio:umami-finance:vault:${vaultAddress}`, - ttl: 5 * 60, // 60 minutes - }) - async getVaultYield(vaultAddress: string, isTimelockVault = false): Promise { - const vaultId = getUmamiApiIdFromVaultAddress(vaultAddress); - if (vaultId) { - const { data } = await Axios.get(`https://api.umami.finance/api/v2/vaults/${vaultId}`); - const vaultYield = isTimelockVault ? data.boostedApr : data.liquidApr; - - return vaultYield * 100; - } - return 0; - } -} diff --git a/src/apps/umami-finance/umami-finance.module.ts b/src/apps/umami-finance/umami-finance.module.ts index 0e9ea25fd..4f854ab82 100644 --- a/src/apps/umami-finance/umami-finance.module.ts +++ b/src/apps/umami-finance/umami-finance.module.ts @@ -7,7 +7,6 @@ import { ArbitrumUmamiFinanceGlpVaultsTokenFetcher } from './arbitrum/umami-fina import { ArbitrumUmamiFinanceMarinateUmamiTokenFetcher } from './arbitrum/umami-finance.marinate-umami.token-fetcher'; import { ArbitrumUmamiFinanceMarinateContractPositionFetcher } from './arbitrum/umami-finance.marinate.contract-position-fetcher'; import { ArbitrumUmamiFinanceTimelockedGlpVaultsTokenFetcher } from './arbitrum/umami-finance.timelocked-glp-vaults.token-fetcher'; -import { UmamiFinanceYieldResolver } from './common/umami-finance.yield-resolver'; import { UmamiFinanceViemContractFactory } from './contracts'; @Module({ @@ -18,7 +17,6 @@ import { UmamiFinanceViemContractFactory } from './contracts'; ArbitrumUmamiFinanceMarinateUmamiTokenFetcher, ArbitrumUmamiFinanceTimelockedGlpVaultsTokenFetcher, UmamiFinanceViemContractFactory, - UmamiFinanceYieldResolver, ], }) export class UmamiFinanceAppModule extends AbstractApp() {}