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

Commit

Permalink
fix(curve): Replace helper references for app toolkit (#240)
Browse files Browse the repository at this point in the history
  • Loading branch information
JForsaken authored Apr 22, 2022
1 parent 2d4e54a commit c7a6064
Show file tree
Hide file tree
Showing 19 changed files with 68 additions and 91 deletions.
10 changes: 4 additions & 6 deletions src/apps/curve/arbitrum/curve.balance-fetcher.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { Inject } from '@nestjs/common';

import { SingleStakingContractPositionBalanceHelper, TokenBalanceHelper } from '~app-toolkit';
import { Register } from '~app-toolkit/decorators';
import { presentBalanceFetcherResponse } from '~app-toolkit/helpers/presentation/balance-fetcher-response.present';
import { BalanceFetcher } from '~balance/balance-fetcher.interface';
import { APP_TOOLKIT, IAppToolkit } from '~lib';
import { isClaimable } from '~position/position.utils';
import { Network } from '~types/network.interface';

Expand All @@ -13,14 +13,12 @@ import { CURVE_DEFINITION } from '../curve.definition';
@Register.BalanceFetcher(CURVE_DEFINITION.id, Network.ARBITRUM_MAINNET)
export class ArbitrumCurveBalanceFetcher implements BalanceFetcher {
constructor(
@Inject(TokenBalanceHelper) private readonly tokenBalanceHelper: TokenBalanceHelper,
@Inject(APP_TOOLKIT) private readonly appToolkit: IAppToolkit,
@Inject(CurveContractFactory) private readonly curveContractFactory: CurveContractFactory,
@Inject(SingleStakingContractPositionBalanceHelper)
private readonly singleStakingContractPositionBalanceHelper: SingleStakingContractPositionBalanceHelper,
) {}

private async getPoolTokenBalances(address: string) {
return this.tokenBalanceHelper.getTokenBalances({
return this.appToolkit.helpers.tokenBalanceHelper.getTokenBalances({
network: Network.ARBITRUM_MAINNET,
appId: CURVE_DEFINITION.id,
groupId: CURVE_DEFINITION.groups.pool.id,
Expand All @@ -29,7 +27,7 @@ export class ArbitrumCurveBalanceFetcher implements BalanceFetcher {
}

private async getStakedBalances(address: string) {
return this.singleStakingContractPositionBalanceHelper.getBalances<CurveGaugeV2>({
return this.appToolkit.helpers.singleStakingContractPositionBalanceHelper.getBalances<CurveGaugeV2>({
address,
appId: CURVE_DEFINITION.id,
groupId: CURVE_DEFINITION.groups.farm.id,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Inject } from '@nestjs/common';

import { SingleStakingFarmContractPositionHelper } from '~app-toolkit';
import { Register } from '~app-toolkit/decorators';
import { APP_TOOLKIT, IAppToolkit } from '~lib';
import { PositionFetcher } from '~position/position-fetcher.interface';
import { ContractPosition } from '~position/position.interface';
import { Network } from '~types/network.interface';
Expand All @@ -20,8 +20,7 @@ const network = Network.ARBITRUM_MAINNET;
@Register.ContractPositionFetcher({ appId, groupId, network })
export class ArbitrumCurveFarmContractPositionFetcher implements PositionFetcher<ContractPosition> {
constructor(
@Inject(SingleStakingFarmContractPositionHelper)
private readonly singleStakingFarmContractPositionHelper: SingleStakingFarmContractPositionHelper,
@Inject(APP_TOOLKIT) private readonly appToolkit: IAppToolkit,
@Inject(CurveContractFactory)
private readonly curveContractFactory: CurveContractFactory,
@Inject(CurveGaugeV2RoiStrategy)
Expand All @@ -32,7 +31,7 @@ export class ArbitrumCurveFarmContractPositionFetcher implements PositionFetcher

async getPositions() {
const definitions = [CURVE_V1_POOL_DEFINITIONS, CURVE_V2_POOL_DEFINITIONS].flat().filter(v => !!v.gaugeAddress);
return this.singleStakingFarmContractPositionHelper.getContractPositions<CurveGaugeV2>({
return this.appToolkit.helpers.singleStakingFarmContractPositionHelper.getContractPositions<CurveGaugeV2>({
network,
appId,
groupId,
Expand Down
10 changes: 4 additions & 6 deletions src/apps/curve/avalanche/curve.balance-fetcher.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { Inject } from '@nestjs/common';

import { SingleStakingContractPositionBalanceHelper, TokenBalanceHelper } from '~app-toolkit';
import { Register } from '~app-toolkit/decorators';
import { presentBalanceFetcherResponse } from '~app-toolkit/helpers/presentation/balance-fetcher-response.present';
import { BalanceFetcher } from '~balance/balance-fetcher.interface';
import { APP_TOOLKIT, IAppToolkit } from '~lib';
import { isClaimable } from '~position/position.utils';
import { Network } from '~types/network.interface';

Expand All @@ -13,14 +13,12 @@ import { CURVE_DEFINITION } from '../curve.definition';
@Register.BalanceFetcher(CURVE_DEFINITION.id, Network.AVALANCHE_MAINNET)
export class AvalancheCurveBalanceFetcher implements BalanceFetcher {
constructor(
@Inject(TokenBalanceHelper) private readonly tokenBalanceHelper: TokenBalanceHelper,
@Inject(APP_TOOLKIT) private readonly appToolkit: IAppToolkit,
@Inject(CurveContractFactory) private readonly curveContractFactory: CurveContractFactory,
@Inject(SingleStakingContractPositionBalanceHelper)
private readonly singleStakingContractPositionBalanceHelper: SingleStakingContractPositionBalanceHelper,
) {}

private async getPoolTokenBalances(address: string) {
return this.tokenBalanceHelper.getTokenBalances({
return this.appToolkit.helpers.tokenBalanceHelper.getTokenBalances({
network: Network.AVALANCHE_MAINNET,
appId: CURVE_DEFINITION.id,
groupId: CURVE_DEFINITION.groups.pool.id,
Expand All @@ -29,7 +27,7 @@ export class AvalancheCurveBalanceFetcher implements BalanceFetcher {
}

private async getStakedBalances(address: string) {
return this.singleStakingContractPositionBalanceHelper.getBalances<CurveGaugeV2>({
return this.appToolkit.helpers.singleStakingContractPositionBalanceHelper.getBalances<CurveGaugeV2>({
address,
appId: CURVE_DEFINITION.id,
groupId: CURVE_DEFINITION.groups.farm.id,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Inject } from '@nestjs/common';

import { SingleStakingFarmContractPositionHelper } from '~app-toolkit';
import { Register } from '~app-toolkit/decorators';
import { APP_TOOLKIT, IAppToolkit } from '~lib';
import { PositionFetcher } from '~position/position-fetcher.interface';
import { ContractPosition } from '~position/position.interface';
import { Network } from '~types/network.interface';
Expand All @@ -20,8 +20,7 @@ const network = Network.AVALANCHE_MAINNET;
@Register.ContractPositionFetcher({ appId, groupId, network })
export class AvalancheCurveFarmContractPositionFetcher implements PositionFetcher<ContractPosition> {
constructor(
@Inject(SingleStakingFarmContractPositionHelper)
private readonly singleStakingFarmContractPositionHelper: SingleStakingFarmContractPositionHelper,
@Inject(APP_TOOLKIT) private readonly appToolkit: IAppToolkit,
@Inject(CurveContractFactory)
private readonly curveContractFactory: CurveContractFactory,
@Inject(CurveGaugeV2RoiStrategy)
Expand All @@ -32,7 +31,7 @@ export class AvalancheCurveFarmContractPositionFetcher implements PositionFetche

async getPositions() {
const definitions = [CURVE_V1_POOL_DEFINITIONS, CURVE_V2_POOL_DEFINITIONS].flat().filter(v => !!v.gaugeAddress);
return this.singleStakingFarmContractPositionHelper.getContractPositions<CurveGaugeV2>({
return this.appToolkit.helpers.singleStakingFarmContractPositionHelper.getContractPositions<CurveGaugeV2>({
network,
appId,
groupId,
Expand Down
14 changes: 5 additions & 9 deletions src/apps/curve/ethereum/curve.balance-fetcher.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { Inject } from '@nestjs/common';

import { SingleStakingContractPositionBalanceHelper, TokenBalanceHelper } from '~app-toolkit';
import { Register } from '~app-toolkit/decorators';
import { presentBalanceFetcherResponse } from '~app-toolkit/helpers/presentation/balance-fetcher-response.present';
import { BalanceFetcher } from '~balance/balance-fetcher.interface';
Expand Down Expand Up @@ -32,14 +31,11 @@ export class EthereumCurveBalanceFetcher implements BalanceFetcher {
private readonly curveVotingEscrowContractPositionBalanceHelper: CurveVotingEscrowContractPositionBalanceHelper,
@Inject(CurveVestingEscrowContractPositionBalanceHelper)
private readonly curveVestingEscrowContractPositionBalanceHelper: CurveVestingEscrowContractPositionBalanceHelper,
@Inject(TokenBalanceHelper) private readonly tokenBalanceHelper: TokenBalanceHelper,
@Inject(CurveContractFactory) private readonly curveContractFactory: CurveContractFactory,
@Inject(SingleStakingContractPositionBalanceHelper)
private readonly singleStakingContractPositionBalanceHelper: SingleStakingContractPositionBalanceHelper,
) {}

private async getPoolTokenBalances(address: string) {
return this.tokenBalanceHelper.getTokenBalances({
return this.appToolkit.helpers.tokenBalanceHelper.getTokenBalances({
network,
appId: CURVE_DEFINITION.id,
groupId: CURVE_DEFINITION.groups.pool.id,
Expand All @@ -50,7 +46,7 @@ export class EthereumCurveBalanceFetcher implements BalanceFetcher {
private async getStakedBalances(address: string) {
return Promise.all([
// Single Gauge
this.singleStakingContractPositionBalanceHelper.getBalances<CurveGauge>({
this.appToolkit.helpers.singleStakingContractPositionBalanceHelper.getBalances<CurveGauge>({
address,
network,
appId: CURVE_DEFINITION.id,
Expand All @@ -62,7 +58,7 @@ export class EthereumCurveBalanceFetcher implements BalanceFetcher {
multicall.wrap(contract).claimable_tokens(address),
}),
// Double Gauge
this.singleStakingContractPositionBalanceHelper.getBalances<CurveDoubleGauge>({
this.appToolkit.helpers.singleStakingContractPositionBalanceHelper.getBalances<CurveDoubleGauge>({
address,
network,
appId: CURVE_DEFINITION.id,
Expand Down Expand Up @@ -92,7 +88,7 @@ export class EthereumCurveBalanceFetcher implements BalanceFetcher {
return rewardBalances;
},
}),
this.singleStakingContractPositionBalanceHelper.getBalances<CurveNGauge>({
this.appToolkit.helpers.singleStakingContractPositionBalanceHelper.getBalances<CurveNGauge>({
address,
network,
appId: CURVE_DEFINITION.id,
Expand All @@ -114,7 +110,7 @@ export class EthereumCurveBalanceFetcher implements BalanceFetcher {
return rewardBalances;
},
}),
this.singleStakingContractPositionBalanceHelper.getBalances<CurveGaugeV2>({
this.appToolkit.helpers.singleStakingContractPositionBalanceHelper.getBalances<CurveGaugeV2>({
address,
network,
appId: CURVE_DEFINITION.id,
Expand Down
13 changes: 6 additions & 7 deletions src/apps/curve/ethereum/curve.farm.contract-position-fetcher.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Inject } from '@nestjs/common';

import { SingleStakingFarmContractPositionHelper } from '~app-toolkit';
import { ZERO_ADDRESS } from '~app-toolkit/constants/address';
import { Register } from '~app-toolkit/decorators';
import { APP_TOOLKIT, IAppToolkit } from '~lib';
import { PositionFetcher } from '~position/position-fetcher.interface';
import { ContractPosition } from '~position/position.interface';
import { Network } from '~types/network.interface';
Expand Down Expand Up @@ -75,8 +75,7 @@ const network = Network.ETHEREUM_MAINNET;
@Register.ContractPositionFetcher({ appId, groupId, network })
export class EthereumCurveFarmContractPositionFetcher implements PositionFetcher<ContractPosition> {
constructor(
@Inject(SingleStakingFarmContractPositionHelper)
private readonly singleStakingFarmContractPositionHelper: SingleStakingFarmContractPositionHelper,
@Inject(APP_TOOLKIT) private readonly appToolkit: IAppToolkit,
@Inject(CurveContractFactory)
private readonly curveContractFactory: CurveContractFactory,
@Inject(CurveGaugeRoiStrategy)
Expand All @@ -88,7 +87,7 @@ export class EthereumCurveFarmContractPositionFetcher implements PositionFetcher
) {}

private async getSingleGaugeFarms() {
return this.singleStakingFarmContractPositionHelper.getContractPositions<CurveGauge>({
return this.appToolkit.helpers.singleStakingFarmContractPositionHelper.getContractPositions<CurveGauge>({
network,
appId,
groupId,
Expand Down Expand Up @@ -116,7 +115,7 @@ export class EthereumCurveFarmContractPositionFetcher implements PositionFetcher
}

private async getDoubleGaugeFarms() {
return this.singleStakingFarmContractPositionHelper.getContractPositions<CurveDoubleGauge>({
return this.appToolkit.helpers.singleStakingFarmContractPositionHelper.getContractPositions<CurveDoubleGauge>({
network,
appId,
groupId,
Expand Down Expand Up @@ -149,7 +148,7 @@ export class EthereumCurveFarmContractPositionFetcher implements PositionFetcher
}

private async getNGaugeFarms() {
return this.singleStakingFarmContractPositionHelper.getContractPositions<CurveNGauge>({
return this.appToolkit.helpers.singleStakingFarmContractPositionHelper.getContractPositions<CurveNGauge>({
network,
appId,
groupId,
Expand Down Expand Up @@ -189,7 +188,7 @@ export class EthereumCurveFarmContractPositionFetcher implements PositionFetcher
}

private async getNGaugeV2Farms() {
return this.singleStakingFarmContractPositionHelper.getContractPositions<CurveNGauge>({
return this.appToolkit.helpers.singleStakingFarmContractPositionHelper.getContractPositions<CurveNGauge>({
network,
appId,
groupId,
Expand Down
10 changes: 4 additions & 6 deletions src/apps/curve/fantom/curve.balance-fetcher.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { Inject } from '@nestjs/common';

import { SingleStakingContractPositionBalanceHelper, TokenBalanceHelper } from '~app-toolkit';
import { Register } from '~app-toolkit/decorators';
import { presentBalanceFetcherResponse } from '~app-toolkit/helpers/presentation/balance-fetcher-response.present';
import { BalanceFetcher } from '~balance/balance-fetcher.interface';
import { APP_TOOLKIT, IAppToolkit } from '~lib';
import { isClaimable } from '~position/position.utils';
import { Network } from '~types/network.interface';

Expand All @@ -13,14 +13,12 @@ import { CURVE_DEFINITION } from '../curve.definition';
@Register.BalanceFetcher(CURVE_DEFINITION.id, Network.FANTOM_OPERA_MAINNET)
export class FantomCurveBalanceFetcher implements BalanceFetcher {
constructor(
@Inject(TokenBalanceHelper) private readonly tokenBalanceHelper: TokenBalanceHelper,
@Inject(APP_TOOLKIT) private readonly appToolkit: IAppToolkit,
@Inject(CurveContractFactory) private readonly curveContractFactory: CurveContractFactory,
@Inject(SingleStakingContractPositionBalanceHelper)
private readonly singleStakingContractPositionBalanceHelper: SingleStakingContractPositionBalanceHelper,
) {}

private async getPoolTokenBalances(address: string) {
return this.tokenBalanceHelper.getTokenBalances({
return this.appToolkit.helpers.tokenBalanceHelper.getTokenBalances({
network: Network.FANTOM_OPERA_MAINNET,
appId: CURVE_DEFINITION.id,
groupId: CURVE_DEFINITION.groups.pool.id,
Expand All @@ -29,7 +27,7 @@ export class FantomCurveBalanceFetcher implements BalanceFetcher {
}

private async getStakedBalances(address: string) {
return this.singleStakingContractPositionBalanceHelper.getBalances<CurveGaugeV2>({
return this.appToolkit.helpers.singleStakingContractPositionBalanceHelper.getBalances<CurveGaugeV2>({
address,
appId: CURVE_DEFINITION.id,
groupId: CURVE_DEFINITION.groups.farm.id,
Expand Down
7 changes: 3 additions & 4 deletions src/apps/curve/fantom/curve.farm.contract-position-fetcher.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Inject } from '@nestjs/common';

import { SingleStakingFarmContractPositionHelper } from '~app-toolkit';
import { Register } from '~app-toolkit/decorators';
import { APP_TOOLKIT, IAppToolkit } from '~lib';
import { PositionFetcher } from '~position/position-fetcher.interface';
import { ContractPosition } from '~position/position.interface';
import { Network } from '~types/network.interface';
Expand All @@ -24,8 +24,7 @@ const network = Network.FANTOM_OPERA_MAINNET;
@Register.ContractPositionFetcher({ appId, groupId, network })
export class FantomCurveFarmContractPositionFetcher implements PositionFetcher<ContractPosition> {
constructor(
@Inject(SingleStakingFarmContractPositionHelper)
private readonly singleStakingFarmContractPositionHelper: SingleStakingFarmContractPositionHelper,
@Inject(APP_TOOLKIT) private readonly appToolkit: IAppToolkit,
@Inject(CurveContractFactory)
private readonly curveContractFactory: CurveContractFactory,
@Inject(CurveGaugeV2RoiStrategy)
Expand All @@ -38,7 +37,7 @@ export class FantomCurveFarmContractPositionFetcher implements PositionFetcher<C
const definitions = [CURVE_V1_POOL_DEFINITIONS, CURVE_V1_METAPOOL_DEFINITIONS, CURVE_V2_POOL_DEFINITIONS]
.flat()
.filter(v => !!v.gaugeAddress);
return this.singleStakingFarmContractPositionHelper.getContractPositions<CurveGaugeV2>({
return this.appToolkit.helpers.singleStakingFarmContractPositionHelper.getContractPositions<CurveGaugeV2>({
network,
appId,
groupId,
Expand Down
10 changes: 4 additions & 6 deletions src/apps/curve/gnosis/curve.balance-fetcher.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { Inject } from '@nestjs/common';

import { SingleStakingContractPositionBalanceHelper, TokenBalanceHelper } from '~app-toolkit';
import { Register } from '~app-toolkit/decorators';
import { presentBalanceFetcherResponse } from '~app-toolkit/helpers/presentation/balance-fetcher-response.present';
import { BalanceFetcher } from '~balance/balance-fetcher.interface';
import { APP_TOOLKIT, IAppToolkit } from '~lib';
import { isClaimable } from '~position/position.utils';
import { Network } from '~types/network.interface';

Expand All @@ -13,14 +13,12 @@ import { CURVE_DEFINITION } from '../curve.definition';
@Register.BalanceFetcher(CURVE_DEFINITION.id, Network.GNOSIS_MAINNET)
export class GnosisCurveBalanceFetcher implements BalanceFetcher {
constructor(
@Inject(TokenBalanceHelper) private readonly tokenBalanceHelper: TokenBalanceHelper,
@Inject(APP_TOOLKIT) private readonly appToolkit: IAppToolkit,
@Inject(CurveContractFactory) private readonly curveContractFactory: CurveContractFactory,
@Inject(SingleStakingContractPositionBalanceHelper)
private readonly singleStakingContractPositionBalanceHelper: SingleStakingContractPositionBalanceHelper,
) {}

private async getPoolTokenBalances(address: string) {
return this.tokenBalanceHelper.getTokenBalances({
return this.appToolkit.helpers.tokenBalanceHelper.getTokenBalances({
network: Network.GNOSIS_MAINNET,
appId: CURVE_DEFINITION.id,
groupId: CURVE_DEFINITION.groups.pool.id,
Expand All @@ -29,7 +27,7 @@ export class GnosisCurveBalanceFetcher implements BalanceFetcher {
}

private async getStakedBalances(address: string) {
return this.singleStakingContractPositionBalanceHelper.getBalances<CurveGaugeV2>({
return this.appToolkit.helpers.singleStakingContractPositionBalanceHelper.getBalances<CurveGaugeV2>({
address,
appId: CURVE_DEFINITION.id,
groupId: CURVE_DEFINITION.groups.farm.id,
Expand Down
7 changes: 3 additions & 4 deletions src/apps/curve/gnosis/curve.farm.contract-position-fetcher.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Inject } from '@nestjs/common';

import { SingleStakingFarmContractPositionHelper } from '~app-toolkit';
import { Register } from '~app-toolkit/decorators';
import { APP_TOOLKIT, IAppToolkit } from '~lib';
import { PositionFetcher } from '~position/position-fetcher.interface';
import { ContractPosition } from '~position/position.interface';
import { Network } from '~types/network.interface';
Expand All @@ -20,8 +20,7 @@ const network = Network.GNOSIS_MAINNET;
@Register.ContractPositionFetcher({ appId, groupId, network })
export class GnosisCurveFarmContractPositionFetcher implements PositionFetcher<ContractPosition> {
constructor(
@Inject(SingleStakingFarmContractPositionHelper)
private readonly singleStakingFarmContractPositionHelper: SingleStakingFarmContractPositionHelper,
@Inject(APP_TOOLKIT) private readonly appToolkit: IAppToolkit,
@Inject(CurveContractFactory)
private readonly curveContractFactory: CurveContractFactory,
@Inject(CurveGaugeV2RoiStrategy)
Expand All @@ -32,7 +31,7 @@ export class GnosisCurveFarmContractPositionFetcher implements PositionFetcher<C

async getPositions() {
const definitions = [CURVE_V1_POOL_DEFINITIONS].flat().filter(v => !!v.gaugeAddress);
return this.singleStakingFarmContractPositionHelper.getContractPositions<CurveGaugeV2>({
return this.appToolkit.helpers.singleStakingFarmContractPositionHelper.getContractPositions<CurveGaugeV2>({
network,
appId,
groupId,
Expand Down
Loading

0 comments on commit c7a6064

Please sign in to comment.