Skip to content
This repository has been archived by the owner on Jan 24, 2024. It is now read-only.

Commit

Permalink
chore(apps): Clean up labels (#3098)
Browse files Browse the repository at this point in the history
  • Loading branch information
wpoulin authored Dec 5, 2023
1 parent dab6a2b commit d1a3dc3
Show file tree
Hide file tree
Showing 29 changed files with 65 additions and 55 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export class EthereumAaveSafetyModuleStkAbptClaimableContractPositionFetcher ext
}

async getLabel({ contractPosition }: GetDisplayPropsParams<AaveStkAbpt>) {
return `Claimable ${getLabelFromToken(contractPosition.tokens[0])}`;
return getLabelFromToken(contractPosition.tokens[0]);
}

async getTokenBalancesPerPosition({ address, contract }: GetTokenBalancesParams<AaveStkAbpt>) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { BigNumberish } from 'ethers';

import { APP_TOOLKIT, IAppToolkit } from '~app-toolkit/app-toolkit.interface';
import { buildDollarDisplayItem } from '~app-toolkit/helpers/presentation/display-item.present';
import { getLabelFromToken } from '~app-toolkit/helpers/presentation/image.present';
import { DisplayProps } from '~position/display.interface';
import { MetaType } from '~position/position.interface';
import { ContractPositionTemplatePositionFetcher } from '~position/template/contract-position.template.position-fetcher';
Expand Down Expand Up @@ -45,11 +46,10 @@ export abstract class AaveV2ClaimablePositionFetcher extends ContractPositionTem
];
}

async getLabel(
params: GetDisplayPropsParams<AaveStakedTokenIncentivesController, AaveV2ClaimableDataProps>,
): Promise<string> {
const rewardToken = params.contractPosition.tokens[0];
return `Claimable ${rewardToken.symbol}`;
async getLabel({
contractPosition,
}: GetDisplayPropsParams<AaveStakedTokenIncentivesController, AaveV2ClaimableDataProps>): Promise<string> {
return getLabelFromToken(contractPosition.tokens[0]);
}

getContract(address: string) {
Expand Down
2 changes: 1 addition & 1 deletion src/apps/across/common/across.pool-v1.token-fetcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,6 @@ export abstract class AcrossPoolV1TokenFetcher extends AppTokenTemplatePositionF
}

async getLabel({ appToken }: GetDisplayPropsParams<AcrossPoolV1>): Promise<string> {
return `${getLabelFromToken(appToken.tokens[0])} Pool (deprecated)`;
return getLabelFromToken(appToken.tokens[0]);
}
}
2 changes: 1 addition & 1 deletion src/apps/across/common/across.pool-v2.token-fetcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,6 @@ export abstract class AcrossPoolV2TokenFetcher extends AppTokenTemplatePositionF
}

async getLabel({ appToken }: GetDisplayPropsParams<AcrossPoolV2>): Promise<string> {
return `${getLabelFromToken(appToken.tokens[0])} Pool`;
return getLabelFromToken(appToken.tokens[0]);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export class EthereumApi3StakingContractPositionFetcher extends ContractPosition
}

async getLabel({ contractPosition }: GetDisplayPropsParams<Api3Staking>) {
return `Staked ${getLabelFromToken(contractPosition.tokens[0])}`;
return getLabelFromToken(contractPosition.tokens[0]);
}

async getTokenBalancesPerPosition({ address, contract }: GetTokenBalancesParams<Api3Staking>) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Inject } from '@nestjs/common';
import dayjs from 'dayjs';
import dayjs, { unix } from 'dayjs';

import { IAppToolkit, APP_TOOLKIT } from '~app-toolkit/app-toolkit.interface';
import { PositionTemplate } from '~app-toolkit/decorators/position-template.decorator';
Expand Down Expand Up @@ -65,7 +65,7 @@ export class EthereumArborFinanceBondTokenFetcher extends AppTokenTemplatePositi
async getPricePerShare({
definition,
}: GetPricePerShareParams<ArborFinanceBondToken, DefaultAppTokenDataProps, ArborFinanceBondTokenDefinition>) {
const m = dayjs.unix(definition.maturityDate);
const m = unix(definition.maturityDate);
const date = dayjs(new Date());
const yearsUntilMaturity = m.diff(date, 'year', true);
const ytm = 1 / definition.clearingPrice - 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,8 @@ export abstract class BadgerClaimableContractPositionFetcher extends ContractPos
];
}

async getLabel(params: GetDisplayPropsParams<BadgerTree>): Promise<string> {
const suppliedToken = params.contractPosition.tokens[0];
return `Claimable ${getLabelFromToken(suppliedToken)}`;
async getLabel({ contractPosition }: GetDisplayPropsParams<BadgerTree>): Promise<string> {
return getLabelFromToken(contractPosition.tokens[0]);
}

async getTokenBalancesPerPosition({
Expand Down
4 changes: 2 additions & 2 deletions src/apps/badger/common/badger.claimable.rewards-resolver.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Injectable } from '@nestjs/common';
import Axios from 'axios';
import { ethers } from 'ethers';
import { getAddress } from 'viem';

import { Cache } from '~cache/cache.decorator';
import { Network } from '~types/network.interface';
Expand All @@ -27,7 +27,7 @@ export class BadgerClaimableRewardsResolver {
ttl: 5 * 60, // 60 minutes
})
private async getCachedAccumulatedRewardsData(_network: Network, address: string) {
const checksumAddress = ethers.utils.getAddress(address);
const checksumAddress = getAddress(address);
const { data } = await Axios.get<RewardTreeResponse>(
`https://api.badger.finance/v2/reward/tree/${checksumAddress}`,
).catch(() => ({ data: { tokens: [] as string[], cumulativeAmounts: [] as string[] } }));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,17 @@ import { range } from 'lodash';

import { APP_TOOLKIT, IAppToolkit } from '~app-toolkit/app-toolkit.interface';
import { PositionTemplate } from '~app-toolkit/decorators/position-template.decorator';
import { getLabelFromToken } from '~app-toolkit/helpers/presentation/image.present';
import { DefaultDataProps } from '~position/display.interface';
import { MetaType } from '~position/position.interface';
import { isClaimable } from '~position/position.utils';
import { GetDefinitionsParams } from '~position/template/app-token.template.types';
import { ContractPositionTemplatePositionFetcher } from '~position/template/contract-position.template.position-fetcher';
import { GetTokenBalancesParams, GetTokenDefinitionsParams } from '~position/template/contract-position.template.types';
import {
GetDisplayPropsParams,
GetTokenBalancesParams,
GetTokenDefinitionsParams,
} from '~position/template/contract-position.template.types';

import { CamelotViemContractFactory } from '../contracts';
import { CamelotDividend } from '../contracts/viem';
Expand Down Expand Up @@ -75,8 +80,8 @@ export class ArbitrumCamelotDividendContractPositionFetcher extends ContractPosi
];
}

async getLabel() {
return `Dividends`;
async getLabel({ contractPosition }: GetDisplayPropsParams<CamelotDividend>) {
return getLabelFromToken(contractPosition.tokens[0]);
}

async getTokenBalancesPerPosition({ address, contract, contractPosition }: GetTokenBalancesParams<CamelotDividend>) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
import { Inject } from '@nestjs/common';

import { IAppToolkit, APP_TOOLKIT } from '~app-toolkit/app-toolkit.interface';
import { getLabelFromToken } from '~app-toolkit/helpers/presentation/image.present';
import { AppTokenTemplatePositionFetcher } from '~position/template/app-token.template.position-fetcher';
import { GetPricePerShareParams, GetUnderlyingTokensParams } from '~position/template/app-token.template.types';
import {
GetDisplayPropsParams,
GetPricePerShareParams,
GetUnderlyingTokensParams,
} from '~position/template/app-token.template.types';

import { CaskProtocolViemContractFactory } from '../contracts';
import { CaskVaultToken } from '../contracts/viem';
Expand Down Expand Up @@ -35,7 +40,7 @@ export abstract class CaskProtocolWalletTokenFetcher extends AppTokenTemplatePos
return [pricePerShare];
}

async getLabel() {
return 'Cask Wallet';
async getLabel({ appToken }: GetDisplayPropsParams<CaskVaultToken>) {
return getLabelFromToken(appToken.tokens[0]);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,14 @@ import _, { range } from 'lodash';
import { APP_TOOLKIT, IAppToolkit } from '~app-toolkit/app-toolkit.interface';
import { PositionTemplate } from '~app-toolkit/decorators/position-template.decorator';
import { drillBalance } from '~app-toolkit/helpers/drill-balance.helper';
import { getLabelFromToken } from '~app-toolkit/helpers/presentation/image.present';
import { DefaultDataProps } from '~position/display.interface';
import { ContractPositionBalance } from '~position/position-balance.interface';
import { MetaType } from '~position/position.interface';
import { DefaultContractPositionDefinition } from '~position/template/contract-position.template.types';
import {
DefaultContractPositionDefinition,
GetDisplayPropsParams,
} from '~position/template/contract-position.template.types';
import { CustomContractPositionTemplatePositionFetcher } from '~position/template/custom-contract-position.template.position-fetcher';

import { ChickenBondViemContractFactory } from '../contracts';
Expand Down Expand Up @@ -53,8 +57,8 @@ export class EthereumChickenBondBondContractPositionFetcher extends CustomContra
return this.contractFactory.chickenBondBondNft({ network: this.network, address });
}

async getLabel(): Promise<string> {
return `LUSD Bond`;
async getLabel({ contractPosition }: GetDisplayPropsParams<ChickenBondBondNft>): Promise<string> {
return getLabelFromToken(contractPosition.tokens[0]);
}

getTokenBalancesPerPosition(): never {
Expand Down
2 changes: 1 addition & 1 deletion src/apps/ease/common/ease.rca.token-fetcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,6 @@ export abstract class EaseRcaTokenFetcher extends AppTokenTemplatePositionFetche
}

async getLabel({ appToken }: GetDisplayPropsParams<EaseRcaShield>) {
return `${getLabelFromToken(appToken.tokens[0])} Ease Vault`;
return getLabelFromToken(appToken.tokens[0]);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export abstract class GainsNetworkLockedContractPositionFetcher extends CustomCo
}

async getLabel({ contractPosition }: GetDisplayPropsParams<GainsNetworkGToken>): Promise<string> {
return `${getLabelFromToken(contractPosition.tokens[0])}`;
return getLabelFromToken(contractPosition.tokens[0]);
}

getTokenBalancesPerPosition(): never {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { BigNumber } from 'ethers';
import { APP_TOOLKIT, IAppToolkit } from '~app-toolkit/app-toolkit.interface';
import { PositionTemplate } from '~app-toolkit/decorators/position-template.decorator';
import { buildDollarDisplayItem } from '~app-toolkit/helpers/presentation/display-item.present';
import { getTokenImg } from '~app-toolkit/helpers/presentation/image.present';
import { getLabelFromToken, getTokenImg } from '~app-toolkit/helpers/presentation/image.present';
import { DisplayProps } from '~position/display.interface';
import { MetaType } from '~position/position.interface';
import { ContractPositionTemplatePositionFetcher } from '~position/template/contract-position.template.position-fetcher';
Expand Down Expand Up @@ -47,8 +47,8 @@ export class FantomGeistIncentivesPositionFetcher extends ContractPositionTempla
];
}

async getLabel(): Promise<string> {
return 'Claimable GEIST';
async getLabel({ contractPosition }: GetDisplayPropsParams<GeistRewards>): Promise<string> {
return getLabelFromToken(contractPosition.tokens[0]);
}

async getSecondaryLabel(params: GetDisplayPropsParams<GeistRewards>): Promise<DisplayProps['secondaryLabel']> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export class EthereumHexStakeContractPositionFetcher extends ContractPositionTem
}

async getLabel({ contractPosition }: GetDisplayPropsParams<Hex>) {
return `Staked ${getLabelFromToken(contractPosition.tokens[0])}`;
return getLabelFromToken(contractPosition.tokens[0]);
}

async getTokenBalancesPerPosition({ address, contract }: GetTokenBalancesParams<Hex, DefaultDataProps>) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export class EthereumIdleBestYieldContractPositionFetcher extends ContractPositi
}

async getLabel({ contractPosition }: GetDisplayPropsParams<IdleToken>) {
return `${getLabelFromToken(contractPosition.tokens[0])}`;
return getLabelFromToken(contractPosition.tokens[0]);
}

async getTokenBalancesPerPosition({ address, contract }: GetTokenBalancesParams<IdleToken>) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,7 @@ export abstract class ImpermaxBorrowContractPositionFetcher extends ContractPosi
}

async getLabel({ contractPosition }: GetDisplayPropsParams<Borrowable>): Promise<DisplayProps['label']> {
const [underlyingToken] = contractPosition.tokens;
return getLabelFromToken(underlyingToken);
return getLabelFromToken(contractPosition.tokens[0]);
}

async getSecondaryLabel({
Expand Down
2 changes: 1 addition & 1 deletion src/apps/insurace/common/insurace.mining.token-fetcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,6 @@ export abstract class InsuraceMiningTokenFetcher extends AppTokenTemplatePositio
}

async getLabel({ appToken }: GetDisplayPropsParams<InsuracePoolToken>) {
return `${getLabelFromToken(appToken.tokens[0])} Pool`;
return getLabelFromToken(appToken.tokens[0]);
}
}
11 changes: 8 additions & 3 deletions src/apps/iq/ethereum/iq.hiiq.contract-position-fetcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,14 @@ import { ethers } from 'ethers';

import { IAppToolkit, APP_TOOLKIT } from '~app-toolkit/app-toolkit.interface';
import { PositionTemplate } from '~app-toolkit/decorators/position-template.decorator';
import { getLabelFromToken } from '~app-toolkit/helpers/presentation/image.present';
import { MetaType } from '~position/position.interface';
import { ContractPositionTemplatePositionFetcher } from '~position/template/contract-position.template.position-fetcher';
import { GetDataPropsParams, GetTokenBalancesParams } from '~position/template/contract-position.template.types';
import {
GetDataPropsParams,
GetDisplayPropsParams,
GetTokenBalancesParams,
} from '~position/template/contract-position.template.types';

import { IqViemContractFactory } from '../contracts';
import { IqHiiq } from '../contracts/viem';
Expand Down Expand Up @@ -39,8 +44,8 @@ export class EthereumIqHiiqContractPositionFetcher extends ContractPositionTempl
];
}

async getLabel() {
return `HiIQ Lock`;
async getLabel({ contractPosition }: GetDisplayPropsParams<IqHiiq>): Promise<string> {
return getLabelFromToken(contractPosition.tokens[0]);
}

async getDataProps(_params: GetDataPropsParams<IqHiiq>) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export abstract class LyraAvalonStkLyraClaimableContractPositionFetcher extends
}

async getLabel({ contractPosition }: GetDisplayPropsParams<LyraStkLyra>) {
return `Claimable ${getLabelFromToken(contractPosition.tokens[0])}`;
return getLabelFromToken(contractPosition.tokens[0]);
}

async getTokenBalancesPerPosition({ address, contract }: GetTokenBalancesParams<LyraStkLyra>) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,6 @@ export class EthereumOpnxContractPositionFetcher extends VotingEscrowTemplateCon
}

async getLabel({ contractPosition }: GetDisplayPropsParams<Veox>) {
return `Staked ${getLabelFromToken(contractPosition.tokens[0])}`;
return getLabelFromToken(contractPosition.tokens[0]);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export class AvalanchePenguinVaultClaimableContractPositionFetcher extends Contr
}

async getLabel({ contractPosition }: GetDisplayPropsParams<PenguinVault>) {
return `Claimable ${getLabelFromToken(contractPosition.tokens[0])}`;
return getLabelFromToken(contractPosition.tokens[0]);
}

async getTokenBalancesPerPosition({ address, contract }: GetTokenBalancesParams<PenguinVault>) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export class ArbitrumPlutusTgeClaimableContractPositionFetcher extends ContractP
}

async getLabel({ contractPosition }: GetDisplayPropsParams<PlutusPrivateTgeVester>) {
return `Claimable ${getLabelFromToken(contractPosition.tokens[0])}`;
return getLabelFromToken(contractPosition.tokens[0]);
}

async getTokenBalancesPerPosition({ address, contract }: GetTokenBalancesParams<PlutusPrivateTgeVester>) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,7 @@ export abstract class PoolTogetherV3AirdropContractPositionFetcher extends Contr
}

async getLabel({ contractPosition }: GetDisplayPropsParams<PoolTogetherMerkleDistributor>) {
const rewardToken = contractPosition.tokens[0];
return `Claimable ${getLabelFromToken(rewardToken)}`;
return getLabelFromToken(contractPosition.tokens[0]);
}

async getTokenBalancesPerPosition({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,7 @@ export abstract class PoolTogetherV3ClaimableContractPositionFetcher extends Con
}

async getLabel({ contractPosition }: GetDisplayPropsParams<PoolTogetherV3TokenFaucet>) {
const rewardToken = contractPosition.tokens[0];
return `Claimable ${getLabelFromToken(rewardToken)}`;
return getLabelFromToken(contractPosition.tokens[0]);
}

async getTokenBalancesPerPosition({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ export class EthereumRookClaimableContractPositionFetcher extends ContractPositi
}

async getLabel({ contractPosition }: GetDisplayPropsParams<RookLiquidityPoolDistributor>) {
return `Claimable ${getLabelFromToken(contractPosition.tokens[0])}`;
return getLabelFromToken(contractPosition.tokens[0]);
}

async getTokenBalancesPerPosition({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export abstract class SiloFinanceIncentivesContractPositionfetcher extends Contr
}

async getLabel({ contractPosition }: GetDisplayPropsParams<SiloIncentives>) {
return `Claimable ${getLabelFromToken(contractPosition.tokens[0])}`;
return getLabelFromToken(contractPosition.tokens[0]);
}

async getTokenBalancesPerPosition({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export class EthereumTokemakClaimableContractPositionFetcher extends ContractPos
}

async getLabel({ contractPosition }: GetDisplayPropsParams<TokemakRewards>) {
return `Claimable ${getLabelFromToken(contractPosition.tokens[0])}`;
return getLabelFromToken(contractPosition.tokens[0]);
}

async getTokenBalancesPerPosition({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,7 @@ export class EthereumZhartaLendingPoolCoreContractPositionFetcher extends Contra
return `${getLabelFromToken(suppliedToken)} Pool`;
}

async getTokenBalancesPerPosition({
address,
contractPosition,
contract,
multicall,
}: GetTokenBalancesParams<ZhartaLendingPoolCore>) {
async getTokenBalancesPerPosition({ address, contract }: GetTokenBalancesParams<ZhartaLendingPoolCore>) {
const [lenderFundsRaw, withdrawableAmountRaw] = await Promise.all([
contract.read.funds([address]),
contract.read.computeWithdrawableAmount([address]),
Expand Down

0 comments on commit d1a3dc3

Please sign in to comment.