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

Commit

Permalink
fix: Enabled pool together TVL (#752)
Browse files Browse the repository at this point in the history
* chore: cleanup pool together app

* fix: enabled pool-together TVL
  • Loading branch information
wpoulin authored Jun 27, 2022
1 parent 4588105 commit ceb020c
Show file tree
Hide file tree
Showing 21 changed files with 71 additions and 316 deletions.
45 changes: 13 additions & 32 deletions src/apps/pool-together/avalanche/pool-together.balance-fetcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,68 +7,49 @@ import { BalanceFetcher } from '~balance/balance-fetcher.interface';
import { Network } from '~types/network.interface';

import { PoolTogetherClaimableTokenBalancesHelper } from '../helpers/pool-together-v3.claimable.balance-helper';
import { PoolTogetherAirdropTokenBalancesHelper } from '../helpers/pool-together.airdrop.balance-helper';
import { POOL_TOGETHER_DEFINITION } from '../pool-together.definition';

@Register.BalanceFetcher(POOL_TOGETHER_DEFINITION.id, Network.AVALANCHE_MAINNET)
const network = Network.AVALANCHE_MAINNET;

@Register.BalanceFetcher(POOL_TOGETHER_DEFINITION.id, network)
export class AvalanchePoolTogetherBalanceFetcher implements BalanceFetcher {
constructor(
@Inject(APP_TOOLKIT) private readonly appToolkit: IAppToolkit,
@Inject(PoolTogetherClaimableTokenBalancesHelper)
private readonly claimableTokenBalancesHelper: PoolTogetherClaimableTokenBalancesHelper,
@Inject(PoolTogetherAirdropTokenBalancesHelper)
private readonly airdropTokenBalancesHelper: PoolTogetherAirdropTokenBalancesHelper,
) {}

async getV4TokenBalances(address: string) {
return this.appToolkit.helpers.tokenBalanceHelper.getTokenBalances({
network: Network.AVALANCHE_MAINNET,
network,
appId: POOL_TOGETHER_DEFINITION.id,
groupId: POOL_TOGETHER_DEFINITION.groups.v4.id,
address,
});
}

async getV3TokenBalances(address: string) {
return this.appToolkit.helpers.tokenBalanceHelper.getTokenBalances({
network: Network.AVALANCHE_MAINNET,
appId: POOL_TOGETHER_DEFINITION.id,
groupId: POOL_TOGETHER_DEFINITION.groups.v3.id,
address,
});
}

async getV3PodTokenBalances(address: string) {
return this.appToolkit.helpers.tokenBalanceHelper.getTokenBalances({
network: Network.AVALANCHE_MAINNET,
appId: POOL_TOGETHER_DEFINITION.id,
groupId: POOL_TOGETHER_DEFINITION.groups.v3Pod.id,
address,
});
}

async getClaimableBalances(address: string) {
return this.claimableTokenBalancesHelper.getBalances({
address,
network: Network.AVALANCHE_MAINNET,
});
}

async getAirdropBalances(address: string) {
return this.airdropTokenBalancesHelper.getBalances({
address,
network: Network.AVALANCHE_MAINNET,
network,
});
}

async getBalances(address: string) {
const [v4TokenBalance] = await Promise.all([this.getV4TokenBalances(address)]);
const [v4TokenBalance, claimableBalances] = await Promise.all([
this.getV4TokenBalances(address),
this.getClaimableBalances(address),
]);

return presentBalanceFetcherResponse([
{
label: 'PoolTogether',
assets: v4TokenBalance,
},
{
label: 'Rewards',
assets: claimableBalances,
},
]);
}
}
51 changes: 0 additions & 51 deletions src/apps/pool-together/avalanche/pool-together.tvl-fetcher.ts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const appId = POOL_TOGETHER_DEFINITION.id;
const groupId = POOL_TOGETHER_DEFINITION.groups.v4.id;
const network = Network.AVALANCHE_MAINNET;

@Register.TokenPositionFetcher({ appId, groupId, network })
@Register.TokenPositionFetcher({ appId, groupId, network, options: { includeInTvl: true } })
export class AvalanchePoolTogetherV4TicketTokenFetcher implements PositionFetcher<AppTokenPosition> {
constructor(
@Inject(PoolTogetherV4PrizePoolTokenHelper)
Expand All @@ -25,7 +25,7 @@ export class AvalanchePoolTogetherV4TicketTokenFetcher implements PositionFetche
const prizePools = await this.prizePoolRegistry.getV4PrizePools(network);

return this.poolTogetherV4PrizePoolTokenHelper.getAppTokens({
network: Network.AVALANCHE_MAINNET,
network,
prizePoolAddresses: prizePools?.map(prizePoolAddresses => prizePoolAddresses.prizePoolAddress) || [],
});
}
Expand Down
11 changes: 6 additions & 5 deletions src/apps/pool-together/celo/pool-together.balance-fetcher.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Inject } from '@nestjs/common';
import { compact } from 'lodash';

import { IAppToolkit, APP_TOOLKIT } from '~app-toolkit/app-toolkit.interface';
import { Register } from '~app-toolkit/decorators';
Expand All @@ -10,7 +9,9 @@ import { Network } from '~types/network.interface';
import { PoolTogetherClaimableTokenBalancesHelper } from '../helpers/pool-together-v3.claimable.balance-helper';
import { POOL_TOGETHER_DEFINITION } from '../pool-together.definition';

@Register.BalanceFetcher(POOL_TOGETHER_DEFINITION.id, Network.CELO_MAINNET)
const network = Network.CELO_MAINNET;

@Register.BalanceFetcher(POOL_TOGETHER_DEFINITION.id, network)
export class CeloPoolTogetherBalanceFetcher implements BalanceFetcher {
constructor(
@Inject(APP_TOOLKIT) private readonly appToolkit: IAppToolkit,
Expand All @@ -20,7 +21,7 @@ export class CeloPoolTogetherBalanceFetcher implements BalanceFetcher {

async getV3TokenBalances(address: string) {
return this.appToolkit.helpers.tokenBalanceHelper.getTokenBalances({
network: Network.CELO_MAINNET,
network,
appId: POOL_TOGETHER_DEFINITION.id,
groupId: POOL_TOGETHER_DEFINITION.groups.v3.id,
address,
Expand All @@ -30,7 +31,7 @@ export class CeloPoolTogetherBalanceFetcher implements BalanceFetcher {
async getClaimableBalances(address: string) {
return this.claimableTokenBalancesHelper.getBalances({
address,
network: Network.CELO_MAINNET,
network,
});
}

Expand All @@ -47,7 +48,7 @@ export class CeloPoolTogetherBalanceFetcher implements BalanceFetcher {
},
{
label: 'Rewards',
assets: compact(claimableBalances),
assets: claimableBalances,
},
]);
}
Expand Down
51 changes: 0 additions & 51 deletions src/apps/pool-together/celo/pool-together.tvl-fetcher.ts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,11 @@ import { PoolTogetherV3PrizePoolTokenHelper } from '../helpers/pool-together-v3.
import { PoolTogetherApiPrizePoolRegistry } from '../helpers/pool-together.api.prize-pool-registry';
import { POOL_TOGETHER_DEFINITION } from '../pool-together.definition';

const appId = POOL_TOGETHER_DEFINITION.id;
const groupId = POOL_TOGETHER_DEFINITION.groups.v3.id;
const network = Network.CELO_MAINNET;

@Register.TokenPositionFetcher({
appId: POOL_TOGETHER_DEFINITION.id,
groupId: POOL_TOGETHER_DEFINITION.groups.v3.id,
network,
})
@Register.TokenPositionFetcher({ appId, groupId, network, options: { includeInTvl: true } })
export class CeloPoolTogetherV3TicketTokenFetcher implements PositionFetcher<AppTokenPosition> {
constructor(
@Inject(PoolTogetherV3PrizePoolTokenHelper)
Expand All @@ -27,9 +25,8 @@ export class CeloPoolTogetherV3TicketTokenFetcher implements PositionFetcher<App
const prizePools = await this.prizePoolRegistry.getV3PrizePools(network);

return this.poolTogetherV3PrizePoolTokenHelper.getTokens({
network: Network.CELO_MAINNET,
network,
prizePools,
dependencies: [],
});
}
}
19 changes: 10 additions & 9 deletions src/apps/pool-together/ethereum/pool-together.balance-fetcher.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Inject } from '@nestjs/common';
import { compact } from 'lodash';

import { IAppToolkit, APP_TOOLKIT } from '~app-toolkit/app-toolkit.interface';
import { Register } from '~app-toolkit/decorators';
Expand All @@ -11,7 +10,9 @@ import { PoolTogetherClaimableTokenBalancesHelper } from '../helpers/pool-togeth
import { PoolTogetherAirdropTokenBalancesHelper } from '../helpers/pool-together.airdrop.balance-helper';
import { POOL_TOGETHER_DEFINITION } from '../pool-together.definition';

@Register.BalanceFetcher(POOL_TOGETHER_DEFINITION.id, Network.ETHEREUM_MAINNET)
const network = Network.ETHEREUM_MAINNET;

@Register.BalanceFetcher(POOL_TOGETHER_DEFINITION.id, network)
export class EthereumPoolTogetherBalanceFetcher implements BalanceFetcher {
constructor(
@Inject(APP_TOOLKIT) private readonly appToolkit: IAppToolkit,
Expand All @@ -23,7 +24,7 @@ export class EthereumPoolTogetherBalanceFetcher implements BalanceFetcher {

async getV4TokenBalances(address: string) {
return this.appToolkit.helpers.tokenBalanceHelper.getTokenBalances({
network: Network.ETHEREUM_MAINNET,
network,
appId: POOL_TOGETHER_DEFINITION.id,
groupId: POOL_TOGETHER_DEFINITION.groups.v4.id,
address,
Expand All @@ -32,7 +33,7 @@ export class EthereumPoolTogetherBalanceFetcher implements BalanceFetcher {

async getV3TokenBalances(address: string) {
return this.appToolkit.helpers.tokenBalanceHelper.getTokenBalances({
network: Network.ETHEREUM_MAINNET,
network,
appId: POOL_TOGETHER_DEFINITION.id,
groupId: POOL_TOGETHER_DEFINITION.groups.v3.id,
address,
Expand All @@ -41,7 +42,7 @@ export class EthereumPoolTogetherBalanceFetcher implements BalanceFetcher {

async getV3PodTokenBalances(address: string) {
return this.appToolkit.helpers.tokenBalanceHelper.getTokenBalances({
network: Network.ETHEREUM_MAINNET,
network,
appId: POOL_TOGETHER_DEFINITION.id,
groupId: POOL_TOGETHER_DEFINITION.groups.v3Pod.id,
address,
Expand All @@ -51,14 +52,14 @@ export class EthereumPoolTogetherBalanceFetcher implements BalanceFetcher {
async getClaimableBalances(address: string) {
return this.claimableTokenBalancesHelper.getBalances({
address,
network: Network.ETHEREUM_MAINNET,
network,
});
}

async getAirdropBalances(address: string) {
return this.airdropTokenBalancesHelper.getBalances({
address,
network: Network.ETHEREUM_MAINNET,
network,
});
}

Expand Down Expand Up @@ -86,11 +87,11 @@ export class EthereumPoolTogetherBalanceFetcher implements BalanceFetcher {
},
{
label: 'Rewards',
assets: compact(claimableBalances),
assets: claimableBalances,
},
{
label: 'Airdrops',
assets: compact(airdropBalances),
assets: airdropBalances,
},
]);
}
Expand Down
Loading

0 comments on commit ceb020c

Please sign in to comment.