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

Commit

Permalink
fix: remove curve label suffix in a non invasive manner
Browse files Browse the repository at this point in the history
  • Loading branch information
xdrdak committed Jun 27, 2022
1 parent 7bf3ed5 commit c3be480
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/apps/curve/helpers/curve.pool.token-helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,15 @@ type CurvePoolTokenHelperParams<T = CurveToken, V = Erc20> = {
}) => Promise<number>;
};

const labelAllowList = ['3pool', '2pool', 'tricrypto2', 'tricrypto'];
function rebindLabel(opt: { expectedLabel?: string; fallbackLabel: string }) {
if (opt.expectedLabel && labelAllowList.includes(opt.expectedLabel.toLowerCase())) {
return opt.expectedLabel;
}

return opt.fallbackLabel;
}

const isMetaPool = (token: Token) =>
token.type === ContractType.APP_TOKEN &&
token.appId === CURVE_DEFINITION.id &&
Expand Down Expand Up @@ -142,7 +151,10 @@ export class CurvePoolTokenHelper {

// Display Properties
const underlyingLabels = tokens.map(v => (isMetaPool(v) ? getLabelFromToken(v) : v.symbol)); // Flatten metapool label
const label = definition.label ?? underlyingLabels.join(' / ');
const label = rebindLabel({
expectedLabel: definition.label,
fallbackLabel: underlyingLabels.join(' / '),
});
const secondaryLabel = reservePercentages.map(p => `${Math.floor(p * 100)}%`).join(' / ');
const images = underlyingTokens.map(t => getImagesFromToken(t)).flat();

Expand Down

0 comments on commit c3be480

Please sign in to comment.