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

Commit

Permalink
fix: fixed liquidity and labels (#637)
Browse files Browse the repository at this point in the history
  • Loading branch information
wpoulin committed Jun 14, 2022
1 parent ae8c2d1 commit bab1e8a
Show file tree
Hide file tree
Showing 22 changed files with 58 additions and 155 deletions.
5 changes: 1 addition & 4 deletions src/apps/across/across.definition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { Network } from '~types/network.interface';

export const ACROSS_DEFINITION = appDefinition({
id: 'across',
name: 'across',
name: 'Across',
description: 'Across is the fastest, cheapest and most secure cross-chain bridge.',
url: 'https://across.to',
groups: {
Expand All @@ -22,9 +22,6 @@ export const ACROSS_DEFINITION = appDefinition({
},
supportedNetworks: {
[Network.ETHEREUM_MAINNET]: [AppAction.VIEW],
[Network.POLYGON_MAINNET]: [AppAction.VIEW],
[Network.ARBITRUM_MAINNET]: [AppAction.VIEW],
// [Network.BOBA_MAINNET]: [ProtocolAction.VIEW],
},
primaryColor: '#fff',
});
Expand Down
9 changes: 1 addition & 8 deletions src/apps/across/across.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,9 @@ import { AcrossAppDefinition, ACROSS_DEFINITION } from './across.definition';
import { AcrossContractFactory } from './contracts';
import { EthereumAcrossBalanceFetcher } from './ethereum/across.pool.balance-fetcher';
import { EthereumAcrossPoolTokenFetcher } from './ethereum/across.pool.token-fetcher';
import { EthereumAcrossTvlFetcher } from './ethereum/across.tvl-fetcher';

@Register.AppModule({
appId: ACROSS_DEFINITION.id,
providers: [
AcrossAppDefinition,
AcrossContractFactory,
EthereumAcrossTvlFetcher,
EthereumAcrossBalanceFetcher,
EthereumAcrossPoolTokenFetcher,
],
providers: [AcrossAppDefinition, AcrossContractFactory, EthereumAcrossBalanceFetcher, EthereumAcrossPoolTokenFetcher],
})
export class AcrossAppModule extends AbstractApp() {}
6 changes: 1 addition & 5 deletions src/apps/across/ethereum/across.pool.balance-fetcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,13 @@ import { BalanceFetcher } from '~balance/balance-fetcher.interface';
import { Network } from '~types/network.interface';

import ACROSS_DEFINITION from '../across.definition';
import { AcrossContractFactory } from '../contracts';

const appId = ACROSS_DEFINITION.id;
const network = Network.ETHEREUM_MAINNET;

@Register.BalanceFetcher(appId, network)
export class EthereumAcrossBalanceFetcher implements BalanceFetcher {
constructor(
@Inject(AcrossContractFactory) private readonly acrossContractFactory: AcrossContractFactory,
@Inject(APP_TOOLKIT) private readonly appToolkit: IAppToolkit,
) {}
constructor(@Inject(APP_TOOLKIT) private readonly appToolkit: IAppToolkit) {}

private async getPoolTokenBalances(address: string) {
return this.appToolkit.helpers.tokenBalanceHelper.getTokenBalances({
Expand Down
4 changes: 2 additions & 2 deletions src/apps/across/ethereum/across.pool.token-fetcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const appId = ACROSS_DEFINITION.id;
const groupId = ACROSS_DEFINITION.groups.pool.id;
const network = Network.ETHEREUM_MAINNET;

@Register.TokenPositionFetcher({ appId, groupId, network })
@Register.TokenPositionFetcher({ appId, groupId, network, options: { includeInTvl: true } })
export class EthereumAcrossPoolTokenFetcher implements PositionFetcher<AppTokenPosition> {
constructor(
@Inject(AcrossContractFactory) private readonly acrossContractFactory: AcrossContractFactory,
Expand Down Expand Up @@ -47,7 +47,7 @@ export class EthereumAcrossPoolTokenFetcher implements PositionFetcher<AppTokenP
if (!underlyingToken) return null;

const supply = Number(supplyRaw) / 10 ** decimals;
const pricePerShare = Number(pricePerShareRaw) / 10 ** 18;
const pricePerShare = Number(pricePerShareRaw) / 10 ** underlyingToken.decimals;
const price = underlyingToken.price * pricePerShare;
const tokens = [underlyingToken];
const secondaryLabel = buildDollarDisplayItem(price);
Expand Down
78 changes: 0 additions & 78 deletions src/apps/across/ethereum/across.tvl-fetcher.ts

This file was deleted.

6 changes: 4 additions & 2 deletions src/apps/aelin/ethereum/aelin.pool.token-fetcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ export class EthereumAelinPoolTokenFetcher implements PositionFetcher<AppTokenPo
const supply = Number(supplyRaw) / 10 ** decimals;
const pricePerShare = 1; // 1:1 with sUSD token
const price = underlyingToken.price;
const liquidity = supply * price;
const tokens = [underlyingToken];
const maybeName = name.replace(/^(aePool-|aeP-)/, '');
const labelPrefix = ethers.utils.isHexString(maybeName)
Expand All @@ -84,8 +85,9 @@ export class EthereumAelinPoolTokenFetcher implements PositionFetcher<AppTokenPo
const label = `${labelPrefix} Aelin Pool`;
const secondaryLabel = buildDollarDisplayItem(price);
const images = [getAppImg(AELIN_DEFINITION.id)];
const dataProps = {};
const displayProps = { label, secondaryLabel, images };
const statsItems = [{ label: 'Liquidity', value: buildDollarDisplayItem(liquidity) }];
const dataProps = { liquidity };
const displayProps = { label, secondaryLabel, images, statsItems };

const token: AppTokenPosition = {
type: ContractType.APP_TOKEN,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ import { Network } from '~types/network.interface';
import { AELIN_DEFINITION } from '../aelin.definition';
import { AelinContractFactory, AelinStaking } from '../contracts';

@Register.ContractPositionBalanceFetcher({
appId: AELIN_DEFINITION.id,
groupId: AELIN_DEFINITION.groups.farm.id,
network: Network.OPTIMISM_MAINNET,
})
const appId = AELIN_DEFINITION.id;
const groupId = AELIN_DEFINITION.groups.farm.id;
const network = Network.OPTIMISM_MAINNET;

@Register.ContractPositionBalanceFetcher({ appId, groupId, network })
export class OptimismAelinFarmContractPositionBalanceFetcher
implements PositionBalanceFetcher<ContractPositionBalance>
{
Expand All @@ -27,9 +27,9 @@ export class OptimismAelinFarmContractPositionBalanceFetcher
async getBalances(address: string) {
return this.appToolkit.helpers.singleStakingContractPositionBalanceHelper.getBalances<AelinStaking>({
address,
appId: AELIN_DEFINITION.id,
groupId: AELIN_DEFINITION.groups.farm.id,
network: Network.OPTIMISM_MAINNET,
appId,
groupId,
network,
resolveContract: ({ address, network }) => this.aelinContractFactory.aelinStaking({ address, network }),
resolveStakedTokenBalance: ({ contract, address, multicall }) => multicall.wrap(contract).balanceOf(address),
resolveRewardTokenBalances: ({ contract, address, multicall }) => multicall.wrap(contract).earned(address),
Expand Down
6 changes: 4 additions & 2 deletions src/apps/aelin/optimism/aelin.pool.token-fetcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ export class OptimismAelinPoolTokenFetcher implements PositionFetcher<AppTokenPo
const supply = Number(supplyRaw) / 10 ** decimals;
const pricePerShare = 1; // 1:1 with sUSD token
const price = underlyingToken.price;
const liquidity = supply * price;
const tokens = [underlyingToken];
const maybeName = name.replace(/^(aePool-|aeP-)/, '');
const labelPrefix = ethers.utils.isHexString(maybeName)
Expand All @@ -84,8 +85,9 @@ export class OptimismAelinPoolTokenFetcher implements PositionFetcher<AppTokenPo
const label = `${labelPrefix} Aelin Pool`;
const secondaryLabel = buildDollarDisplayItem(price);
const images = [getAppImg(AELIN_DEFINITION.id)];
const dataProps = {};
const displayProps = { label, secondaryLabel, images };
const statsItems = [{ label: 'Liquidity', value: buildDollarDisplayItem(liquidity) }];
const dataProps = { liquidity };
const displayProps = { label, secondaryLabel, images, statsItems };

const token: AppTokenPosition = {
type: ContractType.APP_TOKEN,
Expand Down
16 changes: 8 additions & 8 deletions src/apps/aelin/optimism/aelin.v-aelin.token-fetcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ import { Network } from '~types/network.interface';
import { AELIN_DEFINITION } from '../aelin.definition';
import { AelinContractFactory } from '../contracts';

@Register.TokenPositionFetcher({
appId: AELIN_DEFINITION.id,
groupId: AELIN_DEFINITION.groups.vAelin.id,
network: Network.OPTIMISM_MAINNET,
})
const appId = AELIN_DEFINITION.id;
const groupId = AELIN_DEFINITION.groups.vAelin.id;
const network = Network.OPTIMISM_MAINNET;

@Register.TokenPositionFetcher({ appId, groupId, network })
export class OptimismAelinVAelinTokenFetcher implements PositionFetcher<AppTokenPosition> {
constructor(
@Inject(APP_TOOLKIT) private readonly appToolkit: IAppToolkit,
Expand All @@ -22,9 +22,9 @@ export class OptimismAelinVAelinTokenFetcher implements PositionFetcher<AppToken

async getPositions() {
return this.appToolkit.helpers.vaultTokenHelper.getTokens({
appId: AELIN_DEFINITION.id,
groupId: AELIN_DEFINITION.groups.vAelin.id,
network: Network.OPTIMISM_MAINNET,
appId,
groupId,
network,
resolveContract: ({ address, network }) => this.aelinContractFactory.aelinVAelin({ address, network }),
resolveVaultAddresses: () => ['0x780f70882ff4929d1a658a4e8ec8d4316b24748a'],
resolveUnderlyingTokenAddress: () => '0x61baadcf22d2565b0f471b291c475db5555e0b76',
Expand Down
12 changes: 5 additions & 7 deletions src/apps/airswap/ethereum/airswap.s-ast-v2.token-fetcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export class EthereumAirswapSAstV2TokenFetcher implements PositionFetcher<AppTok
) {}

async getPositions() {
const address = '0x579120871266ccd8De6c85EF59E2fF6743E7CD15';
const address = '0x579120871266ccd8de6c85ef59e2ff6743e7cd15';
const multicall = this.appToolkit.getMulticall(network);
const contract = this.airswapContractFactory.stakingV2({ address, network });

Expand All @@ -36,13 +36,11 @@ export class EthereumAirswapSAstV2TokenFetcher implements PositionFetcher<AppTok

const baseTokenDependencies = await this.appToolkit.getBaseTokenPrices(network);
const underlyingToken = baseTokenDependencies.find(v => v.symbol === 'AST');

if (!underlyingToken) {
return [];
}
if (!underlyingToken) return [];

const supply = Number(supplyRaw) / 10 ** decimals;
const liquidity = underlyingToken.price * supply;
const price = underlyingToken.price;
const liquidity = price * supply;

const token: AppTokenPosition = {
type: ContractType.APP_TOKEN,
Expand All @@ -54,7 +52,7 @@ export class EthereumAirswapSAstV2TokenFetcher implements PositionFetcher<AppTok
decimals,
supply,
tokens: [underlyingToken],
price: underlyingToken.price,
price,
pricePerShare: 1,
dataProps: { liquidity },
displayProps: {
Expand Down
12 changes: 5 additions & 7 deletions src/apps/airswap/ethereum/airswap.s-ast-v3.token-fetcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export class EthereumAirswapSAstV3TokenFetcher implements PositionFetcher<AppTok
) {}

async getPositions() {
const address = '0x6d88B09805b90dad911E5C5A512eEDd984D6860B';
const address = '0x6d88b09805b90dad911e5c5a512eedd984d6860b';
const multicall = this.appToolkit.getMulticall(network);
const contract = this.airswapContractFactory.stakingV3({ address, network });

Expand All @@ -36,13 +36,11 @@ export class EthereumAirswapSAstV3TokenFetcher implements PositionFetcher<AppTok

const baseTokenDependencies = await this.appToolkit.getBaseTokenPrices(network);
const underlyingToken = baseTokenDependencies.find(v => v.symbol === 'AST');

if (!underlyingToken) {
return [];
}
if (!underlyingToken) return [];

const supply = Number(supplyRaw) / 10 ** decimals;
const liquidity = underlyingToken.price * supply;
const price = underlyingToken.price;
const liquidity = price * supply;

const token: AppTokenPosition = {
type: ContractType.APP_TOKEN,
Expand All @@ -54,7 +52,7 @@ export class EthereumAirswapSAstV3TokenFetcher implements PositionFetcher<AppTok
decimals,
supply,
tokens: [underlyingToken],
price: underlyingToken.price,
price,
pricePerShare: 1,
dataProps: {
liquidity,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { BadgerClaimableContractPositionBalanceHelper } from '../helpers/badger.

const appId = BADGER_DEFINITION.id;
const groupId = BADGER_DEFINITION.groups.claimable.id;
const network = Network.ETHEREUM_MAINNET;
const network = Network.ARBITRUM_MAINNET;

@Register.ContractPositionBalanceFetcher({ appId, groupId, network })
export class ArbitrumBadgerClaimableContractPositionBalanceFetcher
Expand All @@ -22,6 +22,6 @@ export class ArbitrumBadgerClaimableContractPositionBalanceFetcher
) {}

async getBalances(address: string) {
return this.badgerClaimableBalancesHelper.getBalances({ address, network: Network.ARBITRUM_MAINNET });
return this.badgerClaimableBalancesHelper.getBalances({ address, network });
}
}
7 changes: 1 addition & 6 deletions src/apps/badger/arbitrum/badger.vault.token-fetcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,7 @@ export type BadgerApiTokensResponseEntry = {

export type BadgerApiTokensResponse = Record<string, BadgerApiTokensResponseEntry>;

@Register.TokenPositionFetcher({
appId,
groupId,
network,
options: { includeInTvl: true },
})
@Register.TokenPositionFetcher({ appId, groupId, network, options: { includeInTvl: true } })
export class ArbitrumBadgerVaultTokenFetcher implements PositionFetcher<AppTokenPosition> {
constructor(@Inject(BadgerVaultTokenHelper) private readonly badgerVaultTokenHelper: BadgerVaultTokenHelper) {}

Expand Down
2 changes: 1 addition & 1 deletion src/apps/badger/badger.definition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ export const BADGER_DEFINITION = appDefinition({
id: 'claimable',
type: GroupType.POSITION,
label: 'Rewards',
isHiddenFromExplore: true,
},

vault: {
id: 'vault',
type: GroupType.TOKEN,
Expand Down
7 changes: 1 addition & 6 deletions src/apps/badger/ethereum/badger.vault.token-fetcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,7 @@ export type BadgerApiTokensResponseEntry = {

export type BadgerApiTokensResponse = Record<string, BadgerApiTokensResponseEntry>;

@Register.TokenPositionFetcher({
appId,
groupId,
network,
options: { includeInTvl: true },
})
@Register.TokenPositionFetcher({ appId, groupId, network, options: { includeInTvl: true } })
export class EthereumBadgerVaultTokenFetcher implements PositionFetcher<AppTokenPosition> {
constructor(@Inject(BadgerVaultTokenHelper) private readonly badgerVaultTokenHelper: BadgerVaultTokenHelper) {}

Expand Down
2 changes: 1 addition & 1 deletion src/apps/badger/helpers/badger.vault.token-helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export class BadgerVaultTokenHelper {
}

// Display Props
const label = `${getLabelFromToken(underlyingToken)} Sett Vault`;
const label = `${getLabelFromToken(underlyingToken)}`;
const secondaryLabel = buildDollarDisplayItem(price);
const images = getImagesFromToken(underlyingToken);

Expand Down
Loading

0 comments on commit bab1e8a

Please sign in to comment.