Skip to content

Commit

Permalink
fix(metavault-trade): Re-brand assets added for MVLP and esMVX tokens…
Browse files Browse the repository at this point in the history
…. Native Link token added to MVLP tokens seperately.
  • Loading branch information
0xrmvdao committed Aug 18, 2022
1 parent 47fa025 commit 8fec90e
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 4 deletions.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/apps/metavault-trade/assets/logo.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,23 @@ import { Inject, Injectable } from '@nestjs/common';

import { APP_TOOLKIT, IAppToolkit } from '~app-toolkit/app-toolkit.interface';
import { buildDollarDisplayItem } from '~app-toolkit/helpers/presentation/display-item.present';
import { getTokenImg } from '~app-toolkit/helpers/presentation/image.present';
import { getAppAssetImage } from '~app-toolkit/helpers/presentation/image.present';
import { ContractType } from '~position/contract.interface';
import { AppTokenPosition } from '~position/position.interface';
import { Network } from '~types/network.interface';

import { MetavaultTradeContractFactory } from '../contracts';
import { METAVAULT_TRADE_DEFINITION } from '../metavault-trade.definition';

import { METAVAULT_TOKENS } from './../metavault-trade.definition';

type GetMetavaultTradeEsMvxTokenParams = {
network: Network;
esMvxTokenAddress: string;
};

const appId = METAVAULT_TRADE_DEFINITION.id;

@Injectable()
export class MetavaultTradeEsMvxTokenHelper {
constructor(
Expand Down Expand Up @@ -44,7 +48,7 @@ export class MetavaultTradeEsMvxTokenHelper {
// Display Props
const label = symbol;
const secondaryLabel = buildDollarDisplayItem(price);
const images = [getTokenImg(underlyingToken.address, network)];
const images = [getAppAssetImage(appId, METAVAULT_TOKENS.esMvx)];

const vaultToken: AppTokenPosition = {
type: ContractType.APP_TOKEN,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,18 @@ import { range } from 'lodash';

import { APP_TOOLKIT, IAppToolkit } from '~app-toolkit/app-toolkit.interface';
import { buildDollarDisplayItem } from '~app-toolkit/helpers/presentation/display-item.present';
import { getTokenImg } from '~app-toolkit/helpers/presentation/image.present';
import { getAppAssetImage } from '~app-toolkit/helpers/presentation/image.present';
import { ContractType } from '~position/contract.interface';
import { AppTokenPosition } from '~position/position.interface';
import { Network } from '~types/network.interface';

import { MetavaultTradeContractFactory } from '../contracts';
import { METAVAULT_TRADE_DEFINITION } from '../metavault-trade.definition';

const appId = METAVAULT_TRADE_DEFINITION.id;
const LINK_TOKEN = '0x53e0bca35ec356bd5dddfebbd1fc0fd03fabad39'; // Bridged Link Token
const WHITE_LISTED_LINK_TOKEN = '0xb0897686c545045afc77cf20ec7a532e3120e0f1'; // Native Link Token

type GetMetavaultTradeMvlpTokenParams = {
network: Network;
mvlpManagerAddress: string;
Expand Down Expand Up @@ -50,6 +54,7 @@ export class MetavaultTradeMvlpTokenHelper {
const mcVault = multicall.wrap(vaultContract);
const numTokens = await mcVault.allWhitelistedTokensLength();
const tokenAddressesRaw = await Promise.all(range(0, Number(numTokens)).map(i => mcVault.allWhitelistedTokens(i)));
const BASE_TOKEN_LINK = baseTokens.find(t2 => t2.address === LINK_TOKEN);
const tokensRaw = tokenAddressesRaw.map(t1 => baseTokens.find(t2 => t2.address === t1.toLowerCase()));
const tokensUnfiltered = _.compact(tokensRaw);
const tokens = tokensUnfiltered.filter(x => !blockedTokenAddresses.includes(x.address));
Expand All @@ -62,6 +67,21 @@ export class MetavaultTradeMvlpTokenHelper {
return Number(reserveRaw) / 10 ** token.decimals;
}),
);
// Add Native Link Token
const linkContract = this.contractFactory.erc20({
address: WHITE_LISTED_LINK_TOKEN,
network: Network.POLYGON_MAINNET,
});

const linkReserveRaw = await multicall.wrap(linkContract).balanceOf(vaultAddress);
const linkReserve = Number(linkReserveRaw) / 10 ** 18;

// Add LINK token to manipulate later
if (BASE_TOKEN_LINK) {
tokens.push(BASE_TOKEN_LINK);
// Add LINK reserve
reserves.push(linkReserve);
}

// Liquidity
const liquidity = tokens.reduce((acc, t, i) => acc + reserves[i] * t.price, 0);
Expand All @@ -72,7 +92,8 @@ export class MetavaultTradeMvlpTokenHelper {
// Display Props
const label = symbol;
const secondaryLabel = buildDollarDisplayItem(price);
const images = [getTokenImg(mvlpTokenAddress, network)];
const images = [getAppAssetImage(appId, mvlpTokenAddress)];

const statsItems = [{ label: 'Liquidity', value: buildDollarDisplayItem(liquidity) }];

const mvlpToken: AppTokenPosition = {
Expand Down
6 changes: 6 additions & 0 deletions src/apps/metavault-trade/metavault-trade.definition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ import { appDefinition, AppDefinition } from '~app/app.definition';
import { AppAction, AppTag, GroupType } from '~app/app.interface';
import { Network } from '~types/network.interface';

export const METAVAULT_TOKENS = {
mvx: '0x2760e46d9bb43dafcbecaad1f64b93207f9f0ed7',
mvlp: '0x9f4f8bc00f48663b7c204c96b932c29ccc43a2e8',
esMvx: '0xd1b2f8dff8437be57430ee98767d512f252ead61',
};

export const METAVAULT_TRADE_DEFINITION = appDefinition({
id: 'metavault-trade',
name: 'Metavault.Trade',
Expand Down

0 comments on commit 8fec90e

Please sign in to comment.