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

Commit

Permalink
fix: add groupLabels and liquidity to stats (#600)
Browse files Browse the repository at this point in the history
  • Loading branch information
xdrdak committed Jun 8, 2022
1 parent 8096038 commit 913c112
Show file tree
Hide file tree
Showing 63 changed files with 239 additions and 110 deletions.
10 changes: 8 additions & 2 deletions src/apps/across/ethereum/across.pool.token-fetcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,14 @@ export class EthereumAcrossPoolTokenFetcher implements PositionFetcher<AppTokenP
const tokens = [underlyingToken];
const secondaryLabel = buildDollarDisplayItem(price);
const images = [getAppImg(ACROSS_DEFINITION.id)];
const dataProps = {};
const displayProps = { label, secondaryLabel, images };
const liquidity = price * supply;
const dataProps = { liquidity };
const displayProps = {
label,
secondaryLabel,
images,
statsItems: [{ label: 'Liquidity', value: buildDollarDisplayItem(liquidity) }],
};

const token: AppTokenPosition = {
type: ContractType.APP_TOKEN,
Expand Down
2 changes: 1 addition & 1 deletion src/apps/aelin/aelin.definition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export const AELIN_DEFINITION = appDefinition({
groups: {
pool: { id: 'pool', type: GroupType.TOKEN, label: 'Pools' },
vAelin: { id: 'v-aelin', type: GroupType.TOKEN, label: 'vAELIN' },
farm: { id: 'farm', type: GroupType.POSITION, label: 'Staking' },
farm: { id: 'farm', type: GroupType.POSITION, label: 'Staking', groupLabel: 'Farms' },
},
url: 'https://aelin.xyz/',
links: {
Expand Down
4 changes: 2 additions & 2 deletions src/apps/airswap/airswap.definition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ export const AIRSWAP_DEFINITION = appDefinition({
medium: 'https://airswap.medium.com/',
},
groups: {
sASTv2: { id: 's-ast-v2', type: GroupType.TOKEN, label: 'Staking' },
sASTv3: { id: 's-ast-v3', type: GroupType.TOKEN, label: 'Staking' },
sASTv2: { id: 's-ast-v2', type: GroupType.TOKEN, label: 'Staking', groupLabel: 'Farms' },
sASTv3: { id: 's-ast-v3', type: GroupType.TOKEN, label: 'Staking', groupLabel: 'Farms' },
},
tags: [AppTag.DECENTRALIZED_EXCHANGE],
supportedNetworks: {
Expand Down
9 changes: 8 additions & 1 deletion src/apps/airswap/ethereum/airswap.s-ast-v2.token-fetcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export class EthereumAirswapSAstV2TokenFetcher implements PositionFetcher<AppTok
}

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

const token: AppTokenPosition = {
type: ContractType.APP_TOKEN,
Expand All @@ -55,11 +56,17 @@ export class EthereumAirswapSAstV2TokenFetcher implements PositionFetcher<AppTok
tokens: [underlyingToken],
price: underlyingToken.price,
pricePerShare: 1,
dataProps: {},
dataProps: { liquidity },
displayProps: {
label: 'sAST v2',
secondaryLabel: buildDollarDisplayItem(underlyingToken.price),
images: [getTokenImg(underlyingToken.address, network)],
statsItems: [
{
label: 'Liquidity',
value: buildDollarDisplayItem(liquidity),
},
],
},
};

Expand Down
11 changes: 10 additions & 1 deletion src/apps/airswap/ethereum/airswap.s-ast-v3.token-fetcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export class EthereumAirswapSAstV3TokenFetcher implements PositionFetcher<AppTok
}

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

const token: AppTokenPosition = {
type: ContractType.APP_TOKEN,
Expand All @@ -55,11 +56,19 @@ export class EthereumAirswapSAstV3TokenFetcher implements PositionFetcher<AppTok
tokens: [underlyingToken],
price: underlyingToken.price,
pricePerShare: 1,
dataProps: {},
dataProps: {
liquidity,
},
displayProps: {
label: 'sAST v3',
secondaryLabel: buildDollarDisplayItem(underlyingToken.price),
images: [getTokenImg(underlyingToken.address, network)],
statsItems: [
{
label: 'Liquidity',
value: buildDollarDisplayItem(liquidity),
},
],
},
};

Expand Down
8 changes: 7 additions & 1 deletion src/apps/alpha-v1/ethereum/alpha-v1.lending.token-fetcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { AlphaV1ContractFactory } from '../contracts';
type AlphaV1LendingTokenDataProps = {
supplyApy: number;
reserve: number;
liquidity: number;
};

const appId = ALPHA_V1_DEFINITION.id;
Expand Down Expand Up @@ -70,12 +71,16 @@ export class EthereumAlphaV1LendingTokenFetcher implements PositionFetcher<AppTo
const utilizationRate = new BigNumber(totalDebtValueRaw.div(totalEthRaw).toString());
const supplyApy = this.tripleSlope(utilizationRate).times(utilizationRate).times(0.9).toNumber();
const tokens = [ethToken];
const liquidity = price * supply;

// Display Props
const label = symbol;
const secondaryLabel = buildDollarDisplayItem(price);
const images = [getTokenImg(ethToken.address, network)];
const statsItems = [{ label: 'Supply APY', value: buildPercentageDisplayItem(supplyApy) }];
const statsItems = [
{ label: 'Supply APY', value: buildPercentageDisplayItem(supplyApy) },
{ label: 'Liquidity', value: buildDollarDisplayItem(liquidity) },
];

const token: AppTokenPosition<AlphaV1LendingTokenDataProps> = {
type: ContractType.APP_TOKEN,
Expand All @@ -93,6 +98,7 @@ export class EthereumAlphaV1LendingTokenFetcher implements PositionFetcher<AppTo
dataProps: {
supplyApy,
reserve,
liquidity,
},

displayProps: {
Expand Down
2 changes: 1 addition & 1 deletion src/apps/balancer-v2/balancer-v2.definition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export const BALANCER_V2_DEFINITION = appDefinition({
},
groups: {
pool: { id: 'pool', type: GroupType.TOKEN, label: 'Pools' },
farm: { id: 'farm', type: GroupType.POSITION, label: 'Staked' },
farm: { id: 'farm', type: GroupType.POSITION, label: 'Staked', groupLabel: 'Farms' },
votingEscrow: { id: 'voting-escrow', type: GroupType.POSITION, label: 'Voting Escrow' },
claimable: { id: 'claimable', type: GroupType.POSITION, label: 'Claimable' },
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,10 @@ export class CompoundBorrowContractPositionHelper {
const tertiaryLabel = isNumber(borrowApy) ? `${(borrowApy * 100).toFixed(3)}% APR` : '';
const images = appToken.displayProps.images;
const statsItems = isNumber(borrowApy)
? [{ label: 'Borrow APR', value: buildPercentageDisplayItem(borrowApy) }]
? [
{ label: 'Borrow APR', value: buildPercentageDisplayItem(borrowApy) },
{ label: 'Liquidity', value: buildDollarDisplayItem(dataProps.liquidity) },
]
: [];

const contractPosition: ContractPosition<CompoundSupplyTokenDataProps> = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Inject } from '@nestjs/common';

import { IAppToolkit, APP_TOOLKIT } from '~app-toolkit/app-toolkit.interface';
import { Register } from '~app-toolkit/decorators';
import { buildDollarDisplayItem } from '~app-toolkit/helpers/presentation/display-item.present';
import { getAppImg } from '~app-toolkit/helpers/presentation/image.present';
import { ContractType } from '~position/contract.interface';
import { PositionFetcher } from '~position/position-fetcher.interface';
Expand Down Expand Up @@ -40,6 +41,7 @@ export class EthereumConcentratorAcrvTokenFetcher implements PositionFetcher<App
const supply = Number(supplyRaw) / 10 ** decimals;
const pricePerShare = Number(underlyingRaw) / Number(supplyRaw);
const price = underlyingToken.price * pricePerShare;
const liquidity = price * supply;

// TODO: add additional properties from https://concentrator-api.aladdin.club/apy/
const label = `Concentrator aCRV`;
Expand All @@ -57,10 +59,11 @@ export class EthereumConcentratorAcrvTokenFetcher implements PositionFetcher<App
tokens: [underlyingToken],
price,
pricePerShare,
dataProps: {},
dataProps: { liquidity },
displayProps: {
label,
images,
statsItems: [{ label: 'Liquidity', value: buildDollarDisplayItem(liquidity) }],
},
};

Expand Down
2 changes: 1 addition & 1 deletion src/apps/curve/curve.definition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export const CURVE_DEFINITION = appDefinition({
telegram: 'https://t.me/curvefi',
},
groups: {
farm: { id: 'farm', type: GroupType.POSITION, label: 'Staking' },
farm: { id: 'farm', type: GroupType.POSITION, label: 'Staking', groupLabel: 'Farms' },
pool: { id: 'pool', type: GroupType.TOKEN, label: 'Pools' },
votingEscrow: { id: 'votingEscrow', type: GroupType.POSITION, label: 'Voting Escrow' },
vestingEscrow: { id: 'vestingEscrow', type: GroupType.POSITION, label: 'Vesting' },
Expand Down
4 changes: 2 additions & 2 deletions src/apps/dfx/dfx.definition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ export const DFX_DEFINITION = appDefinition({
medium: 'https://medium.com/dfxfinance',
},
groups: {
dfxCurve: { id: 'dfx-curve', type: GroupType.TOKEN, label: 'DFX Curves' },
staking: { id: 'staking', type: GroupType.POSITION, label: 'DFX Staking' },
dfxCurve: { id: 'dfx-curve', type: GroupType.TOKEN, label: 'DFX Curves', groupLabel: 'Pools' },
staking: { id: 'staking', type: GroupType.POSITION, label: 'DFX Staking', groupLabel: 'Farms' },
},
tags: [AppTag.DECENTRALIZED_EXCHANGE, AppTag.LIQUIDITY_POOL, AppTag.STABLECOIN],
supportedNetworks: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ export class EthereumDfxStakingContractPositionFetcher implements PositionFetche
const label = `Staked ${getLabelFromToken(stakedToken)}`;
const images = getImagesFromToken(stakedToken);
const secondaryLabel = buildDollarDisplayItem(stakedToken.price);
const statsItems = [{ label: 'Liquidity', value: buildDollarDisplayItem(liquidity) }];

const position: ContractPosition<DfxCurveContractPositionDataProps> = {
type: ContractType.POSITION,
Expand All @@ -82,6 +83,7 @@ export class EthereumDfxStakingContractPositionFetcher implements PositionFetche
label,
secondaryLabel,
images,
statsItems,
},
};
return position;
Expand Down
2 changes: 2 additions & 0 deletions src/apps/dfx/polygon/dfx.staking.contract-position-fetcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ export class PolygonDfxStakingContractPositionFetcher implements PositionFetcher
const label = `Staked ${getLabelFromToken(stakedToken)}`;
const images = getImagesFromToken(stakedToken);
const secondaryLabel = buildDollarDisplayItem(stakedToken.price);
const statsItems = [{ label: 'Liquidity', value: buildDollarDisplayItem(liquidity) }];

const position: ContractPosition<DfxCurveContractPositionDataProps> = {
type: ContractType.POSITION,
Expand All @@ -82,6 +83,7 @@ export class PolygonDfxStakingContractPositionFetcher implements PositionFetcher
label,
secondaryLabel,
images,
statsItems,
},
};
return position;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,18 @@ export class EthereumEnzymeFinanceVaultTokenFetcher implements PositionFetcher<A
const pricePerShare = 1;
const price = totalAssetUnderManagement / supply;
const tokens = compact(underlyingTokens);
const liquidity = price * supply;

const label = name;
const secondaryLabel = buildDollarDisplayItem(price);
const images = [getAppImg(appId)];
const dataProps = {};
const displayProps = { label, secondaryLabel, images };
const dataProps = { liquidity };
const displayProps = {
label,
secondaryLabel,
images,
statsItems: [{ label: 'Liquidity', value: buildDollarDisplayItem(liquidity) }],
};

const token: AppTokenPosition = {
type: ContractType.APP_TOKEN,
Expand Down
25 changes: 17 additions & 8 deletions src/apps/euler/ethereum/euler.d-token.token-fetcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,13 @@ export class EthereumEulerDTokenTokenFetcher implements PositionFetcher<AppToken

if (totalSupply.isZero() || !underlyingToken) return null;

const liquidity = Number(totalSupply) * underlyingToken.price;
const dataProps = {
name: `Euler D token ${market.name}`,
liquidity: Number(totalSupply) * underlyingToken.price,
interestRate: Number(market.interestRate) / 10 ** 18,
borrowAPY: Number(market.borrowAPY) / 10 ** 18,
supplyAPY: Number(market.borrowAPY) / 10 ** 18,
};

return {
address: market.dTokenAddress,
Expand All @@ -96,20 +102,23 @@ export class EthereumEulerDTokenTokenFetcher implements PositionFetcher<AppToken
network,
decimals: 18,
tokens: [underlyingToken],
dataProps: {
name: `Euler D token ${market.name}`,
interestRate: Number(market.interestRate) / 10 ** 18,
borrowAPY: Number(market.borrowAPY) / 10 ** 18,
supplyAPY: Number(market.borrowAPY) / 10 ** 18,
},
dataProps,
displayProps: {
label: `Euler D token ${market.name}`,
secondaryLabel: buildDollarDisplayItem(underlyingToken.price),
images: getImagesFromToken(underlyingToken),
statsItems: [
{
label: 'Liquidity',
value: buildDollarDisplayItem(liquidity),
value: buildDollarDisplayItem(dataProps.liquidity),
},
{
label: 'Borrow APY',
value: buildDollarDisplayItem(dataProps.borrowAPY),
},
{
label: 'Supply APY',
value: buildDollarDisplayItem(dataProps.supplyAPY),
},
],
},
Expand Down
31 changes: 20 additions & 11 deletions src/apps/euler/ethereum/euler.e-token.token-fetcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,16 @@ export class EthereumEulerETokenTokenFetcher implements PositionFetcher<AppToken

const pricePerShare = Number(totalSupply.toString()) / Number(market.totalBalances);

const liquidity = Number(totalSupply) * pricePerShare;
const dataProps = {
name: `Euler E token ${market.name}`,
liquidity: Number(totalSupply) * underlyingToken.price,
underlyingAddress: market.id,
interestRate: Number(market.interestRate) / 10 ** 18,
borrowAPY: Number(market.borrowAPY) / 10 ** 18,
supplyAPY: Number(market.borrowAPY) / 10 ** 18,
totalSupply: totalSupply.toString(),
totalBalances: market.totalBalances,
};

return {
address: market.eTokenAddress,
Expand All @@ -100,23 +109,23 @@ export class EthereumEulerETokenTokenFetcher implements PositionFetcher<AppToken
network,
decimals: 18,
tokens: [underlyingToken],
dataProps: {
name: `Euler E token ${market.name}`,
underlyingAddress: market.id,
interestRate: Number(market.interestRate) / 10 ** 18,
borrowAPY: Number(market.borrowAPY) / 10 ** 18,
supplyAPY: Number(market.borrowAPY) / 10 ** 18,
totalSupply: totalSupply.toString(),
totalBalances: market.totalBalances,
},
dataProps,
displayProps: {
label: `Euler E token ${market.name}`,
secondaryLabel: buildDollarDisplayItem(pricePerShare),
images: getImagesFromToken(underlyingToken),
statsItems: [
{
label: 'Liquidity',
value: buildDollarDisplayItem(liquidity),
value: buildDollarDisplayItem(dataProps.liquidity),
},
{
label: 'Borrow APY',
value: buildDollarDisplayItem(dataProps.borrowAPY),
},
{
label: 'Supply APY',
value: buildDollarDisplayItem(dataProps.supplyAPY),
},
],
},
Expand Down
25 changes: 17 additions & 8 deletions src/apps/euler/ethereum/euler.p-token.token-fetcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,13 @@ export class EthereumEulerPTokenTokenFetcher implements PositionFetcher<AppToken

if (totalSupply.isZero() || !underlyingToken) return null;

const liquidity = Number(totalSupply) * underlyingToken.price;
const dataProps = {
name: market.name,
liquidity: Number(totalSupply) * underlyingToken.price,
interestRate: Number(market.interestRate) / 10 ** 18,
borrowAPY: Number(market.borrowAPY) / 10 ** 18,
supplyAPY: Number(market.borrowAPY) / 10 ** 18,
};

return {
address: market.pTokenAddress,
Expand All @@ -96,20 +102,23 @@ export class EthereumEulerPTokenTokenFetcher implements PositionFetcher<AppToken
network,
decimals: 18,
tokens: [underlyingToken],
dataProps: {
name: market.name,
interestRate: Number(market.interestRate) / 10 ** 18,
borrowAPY: Number(market.borrowAPY) / 10 ** 18,
supplyAPY: Number(market.borrowAPY) / 10 ** 18,
},
dataProps,
displayProps: {
label: `Euler P token ${market.name}`,
secondaryLabel: buildDollarDisplayItem(underlyingToken.price),
images: getImagesFromToken(underlyingToken),
statsItems: [
{
label: 'Liquidity',
value: buildDollarDisplayItem(liquidity),
value: buildDollarDisplayItem(dataProps.liquidity),
},
{
label: 'Borrow APY',
value: buildDollarDisplayItem(dataProps.borrowAPY),
},
{
label: 'Supply APY',
value: buildDollarDisplayItem(dataProps.supplyAPY),
},
],
},
Expand Down
Loading

0 comments on commit 913c112

Please sign in to comment.