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

feat: add pool ratio to statsItem #825

Merged
merged 1 commit into from
Jul 4, 2022
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
4 changes: 3 additions & 1 deletion src/apps/arrakis/helpers/arrakis.pool.token-helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,14 +97,16 @@ export class ArrakisPoolTokenHelper {
const price = liquidity / supply;
const pricePerShare = reserves.map(r => r / supply);
const reservePercentages = tokens.map((t, i) => reserves[i] * (t.price / liquidity));
const ratio = reservePercentages.map(p => `${Math.round(p * 100)}%`).join(' / ');

// Display Props
const label = tokens.map(v => v.symbol).join(' / ');
const secondaryLabel = reservePercentages.map(p => `${Math.round(p * 100)}%`).join(' / ');
const secondaryLabel = ratio;
const images = tokens.map(v => getTokenImg(v.address, network));
const statsItems = [
{ label: 'Liquidity', value: buildDollarDisplayItem(liquidity) },
{ label: 'Fee', value: buildPercentageDisplayItem(fee) },
{ label: 'Ratio', value: ratio },
];

const token: AppTokenPosition<ArrakisPoolTokenDataProps> = {
Expand Down
7 changes: 6 additions & 1 deletion src/apps/balancer-v1/ethereum/balancer-v1.token-fetcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ export class EthereumBalancerV1PoolTokenFetcher implements PositionFetcher<AppTo
const fee = Number(pool.swapFee);
const lastVolume = pool.swaps.length > 0 ? +pool.swaps[0].poolTotalSwapVolume : +pool.totalSwapVolume;
const volume = +pool.totalSwapVolume - lastVolume;
const secondaryLabel = weight.map(p => `${Math.round(p * 100)}%`).join(' / ');
const ratio = weight.map(p => `${Math.round(p * 100)}%`).join(' / ');
const secondaryLabel = ratio;

const displayProps = {
label,
Expand All @@ -95,6 +96,10 @@ export class EthereumBalancerV1PoolTokenFetcher implements PositionFetcher<AppTo
label: 'Fee',
value: buildPercentageDisplayItem(fee),
},
{
label: 'Ratio',
value: ratio,
},
],
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,8 @@ export class BalancerV2PoolTokensHelper {
labelStrategy === BalancerV2PoolLabelStrategy.POOL_NAME
? await multicall.wrap(poolContract).name()
: tokens.map(v => v.symbol).join(' / ');
const secondaryLabel = reservePercentages.map(p => `${Math.round(p * 100)}%`).join(' / ');
const ratio = reservePercentages.map(p => `${Math.round(p * 100)}%`).join(' / ');
const secondaryLabel = ratio;
const images = tokens.map(v => getTokenImg(v.address, network));

const token: AppTokenPosition<BalancerV2PoolTokenDataProps> = {
Expand Down Expand Up @@ -146,6 +147,10 @@ export class BalancerV2PoolTokensHelper {
label: 'Liquidity',
value: buildDollarDisplayItem(liquidity),
},
{
label: 'Ratio',
value: ratio,
},
],
},
};
Expand Down
7 changes: 6 additions & 1 deletion src/apps/curve/helpers/curve.pool.token-helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,10 +151,11 @@ export class CurvePoolTokenHelper {
const reservesUSD = tokens.map((t, i) => reserves[i] * t.price);
const liquidity = reservesUSD.reduce((total, r) => total + r, 0);
const reservePercentages = reservesUSD.map(reserveUSD => reserveUSD / liquidity);
const ratio = reservePercentages.map(p => `${Math.floor(p * 100)}%`).join(' / ');

// Display Properties
const label = await this.resolvePoolLabel(tokens);
const secondaryLabel = reservePercentages.map(p => `${Math.floor(p * 100)}%`).join(' / ');
const secondaryLabel = ratio;
const images = underlyingTokens.map(t => getImagesFromToken(t)).flat();

const curvePoolToken: AppTokenPosition<CurvePoolTokenDataProps> = {
Expand Down Expand Up @@ -198,6 +199,10 @@ export class CurvePoolTokenHelper {
label: 'Fee',
value: buildPercentageDisplayItem(fee),
},
{
label: 'Ratio',
value: ratio,
},
],
},
};
Expand Down
7 changes: 6 additions & 1 deletion src/apps/unagii/ethereum/unagii.pool.token-fetcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ export class EthereumUnagiiPoolTokenFetcher implements PositionFetcher<AppTokenP

const tokens = [{ ...underlyingToken, reserve }];
const reservePercentages = tokens.map(t => reserve * (t.price / liquidity));
const secondaryLabel = reservePercentages.map(p => `${Math.round(p * 100)}%`).join(' / ');
const ratio = reservePercentages.map(p => `${Math.round(p * 100)}%`).join(' / ');
const secondaryLabel = ratio;

const displayProps = {
label: symbol,
Expand All @@ -89,6 +90,10 @@ export class EthereumUnagiiPoolTokenFetcher implements PositionFetcher<AppTokenP
label: 'Supply',
value: buildNumberDisplayItem(supply),
},
{
label: 'Ratio',
value: ratio,
},
],
};

Expand Down
4 changes: 3 additions & 1 deletion src/apps/uniswap-v2/helpers/uniswap-v2.pool.token-helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,16 +178,18 @@ export class UniswapV2PoolTokenHelper {
const volume = poolVolumes.find(v => v.poolAddress === address)?.volumeChangeUSD ?? 0;
const volumeChangePercentage = poolVolumes.find(v => v.poolAddress === address)?.volumeChangePercentage ?? 0;
const isBlocked = blockedPools.includes(address);
const ratio = reservePercentages.map(p => `${Math.round(p * 100)}%`).join(' / ');

// Display Props
const label = `${resolveTokenDisplaySymbol(tokens[0])} / ${resolveTokenDisplaySymbol(tokens[1])}`;
const secondaryLabel = reservePercentages.map(p => `${Math.round(p * 100)}%`).join(' / ');
const secondaryLabel = ratio;
const images = tokens.map(v => getImagesFromToken(v)).flat();
const statsItems = [
{ label: 'Volume', value: buildDollarDisplayItem(volume) },
{ label: 'Fee', value: buildPercentageDisplayItem(fee) },
{ label: 'Reserves', value: reserves.map(v => (v < 0.01 ? '<0.01' : v.toFixed(2))).join(' / ') },
{ label: 'Liquidity', value: buildDollarDisplayItem(liquidity) },
{ label: 'Ratio', value: ratio },
];

const poolToken: AppTokenPosition<UniswapV2PoolTokenDataProps> = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,15 +163,17 @@ export class UniswapV2TheGraphPoolTokenBalanceHelper {
const volume = 0;
const volumeChangePercentage = 0;
const isBlocked = false;
const ratio = reservePercentages.map(p => `${Math.round(p * 100)}%`).join(' / ');

// Display Props
const label = `${tokens[0].symbol} / ${tokens[1].symbol}`;
const secondaryLabel = reservePercentages.map(p => `${Math.round(p * 100)}%`).join(' / ');
const secondaryLabel = ratio;
const images = [getTokenImg(tokens[0].address, network), getTokenImg(tokens[1].address, network)];
const statsItems = [
{ label: 'Liquidity', value: buildDollarDisplayItem(liquidity) },
{ label: 'Volume', value: buildDollarDisplayItem(volume) },
{ label: 'Fee', value: buildPercentageDisplayItem(fee) },
{ label: 'Ratio', value: ratio },
];

const poolToken: AppTokenPosition<UniswapV2PoolTokenDataProps> = {
Expand Down