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

chore(apps): Linting #3172

Merged
merged 1 commit into from
Jan 3, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Inject } from '@nestjs/common';
import BigNumber from 'bignumber.js';
import { BigNumberish } from 'ethers';
import { range, sum } from 'lodash';
import moment from 'moment';
import { duration } from 'moment';

import { APP_TOOLKIT, IAppToolkit } from '~app-toolkit/app-toolkit.interface';
import { ZERO_ADDRESS } from '~app-toolkit/constants/address';
Expand Down Expand Up @@ -110,12 +110,12 @@ export abstract class CurveChildLiquidityGaugeContractPositionFetcher extends Co
// Calculate annual CRV rewards
const period = await contract.read.period();
const periodTimestamp = await contract.read.period_timestamp([period]);
const periodWeek = Math.floor(Number(periodTimestamp) / moment.duration(7, 'days').asSeconds()); // num weeks
const periodWeek = Math.floor(Number(periodTimestamp) / duration(7, 'days').asSeconds()); // num weeks

const crvToken = rewardTokens.find(v => v.address === this.crvTokenAddress)!;
const crvInflationRateRaw = await contract.read.inflation_rate([BigInt(periodWeek)]);
const crvInflationRate = Number(crvInflationRateRaw) / 10 ** crvToken.decimals;
const crvYearlyReward = crvInflationRate * moment.duration(1, 'year').asSeconds();
const crvYearlyReward = crvInflationRate * duration(1, 'year').asSeconds();
const crvYearlyRewardInUSD = crvYearlyReward * crvToken.price;

// Calculate annual bonus rewards
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Inject } from '@nestjs/common';
import { BigNumber, BigNumberish, ethers } from 'ethers';
import { range } from 'lodash';
import moment from 'moment';
import { duration } from 'moment';
import { Abi, GetContractReturnType, PublicClient } from 'viem';

import { APP_TOOLKIT, IAppToolkit } from '~app-toolkit/app-toolkit.interface';
Expand Down Expand Up @@ -199,7 +199,7 @@ export abstract class CurvePoolGaugeContractPositionFetcher<
const workingSupply = Number(workingSupplyRaw) / 10 ** 18;
const relativeWeight = Number(relativeWeightRaw) / 10 ** 18;

const secondsPerYear = moment.duration(1, 'year').asSeconds();
const secondsPerYear = duration(1, 'year').asSeconds();
const ratePerSecond = (inflationRate * relativeWeight * 0.4) / workingSupply;
const apy = ((ratePerSecond * secondsPerYear) / stakedToken.price) * rewardTokens[0].price * 100;
const isActive = Number(inflationRate) > 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ export class HiddenHandRewardsResolver {
constructor(
@Inject(APP_TOOLKIT) protected readonly appToolkit: IAppToolkit,
@Inject(HiddenHandViemContractFactory) protected readonly contractFactory: HiddenHandViemContractFactory,
) { }
) {}

@Cache({
key: `studio:hidden-hand:claimable-raw-data`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export abstract class HiddenHandRewardsContractPositionFetcher extends CustomCon
);
const market = marketEntry ? marketEntry[0] : '';

if (!distribution?.hasOwnProperty(market)) return [];
if (!distribution[market]) return [];

const claimableDistribution = distribution[market][neworkId] ?? {};
const claimableTokens = Object.keys(claimableDistribution);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,14 +161,14 @@ export class EthereumInverseFirmLoanContractPositionFetcher extends ContractPosi
if (isCvxFxsMarket) {
const stakeContract = this.contractFactory.stCvxFxs({ address: this.stCvxFxsAddress, network: this.network });
const result = await multicall.wrap(stakeContract).read.claimableRewards([personalEscrow]);
claimablesAsTuple = result.map((v, i) => ({ token: v.token, amount: v.amount }));
claimablesAsTuple = result.map(v => ({ token: v.token, amount: v.amount }));
} else {
const stakeContract = this.contractFactory.stCvxCrv({ address: this.stCvxCrvAddress, network: this.network });
const result = await multicall
.wrap(stakeContract)
.simulate.earned([personalEscrow])
.then(v => v.result);
claimablesAsTuple = result.map((v, i) => ({ token: v.token, amount: v.amount }));
claimablesAsTuple = result.map(v => ({ token: v.token, amount: v.amount }));
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Inject } from '@nestjs/common';
import { BigNumber, BigNumberish } from 'ethers';
import { compact, merge, reduce, sumBy, uniqBy } from 'lodash';
import moment from 'moment';
import { duration } from 'moment';
import 'moment-duration-format';

import { IAppToolkit, APP_TOOLKIT } from '~app-toolkit/app-toolkit.interface';
Expand Down Expand Up @@ -198,8 +198,8 @@ export abstract class MeanFinanceDcaPositionContractPositionFetcher extends Cust

// Display Properties
const formattedRate = rate < 0.001 ? '<0.001' : rate.toFixed(3);
const intervalMoment = moment.duration(swapInterval, 'seconds');
const remainingMoment = moment.duration(remainingSwaps * swapInterval, 'seconds');
const intervalMoment = duration(swapInterval, 'seconds');
const remainingMoment = duration(remainingSwaps * swapInterval, 'seconds');
const intervalLabel = intervalMoment.format('w [weeks], d [days], h [hours], m [minutes]', { trim: 'all' });
const remainingLabel = remainingMoment.format('w [weeks], d [days], h [hours], m [minutes]', {
trim: 'all',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Injectable } from '@nestjs/common';
import Axios from 'axios';
import moment from 'moment';
import { duration } from 'moment';

import { Cache } from '~cache/cache.decorator';
import { Network, NETWORK_IDS } from '~types/network.interface';
Expand Down Expand Up @@ -29,7 +29,7 @@ type V4ApiPrizePool = {
export class PoolTogetherV4ApiPrizePoolRegistry {
@Cache({
key: (network: Network) => `pool-together-v4:${network}:prize-pool-registry`,
ttl: moment.duration(30, 'minutes').asSeconds(),
ttl: duration(30, 'minutes').asSeconds(),
})
async getV4PrizePools(network: Network): Promise<V4PrizePool[]> {
const prizePoolUrl = `https://pooltogether-api.com/v4/addresses/prize-pools/${NETWORK_IDS[network]}`;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,6 @@ export class EthereumSpoolVaultContractPositionFetcher extends ContractPositionT
address,
contractPosition,
contract,
multicall,
}: GetTokenBalancesParams<SpoolVault, SpoolVaultDataProps>): Promise<BigNumberish[]> {
const strategies = contractPosition.dataProps.strategies;
const { result } = await contract.simulate.getUpdatedUser([strategies], { account: address });
Expand Down
Loading