From c6ceb9773feb90e65dc77d51d8ff0c20347cac8a Mon Sep 17 00:00:00 2001 From: Georges KABBOUCHI Date: Sat, 25 Sep 2021 01:19:32 +0300 Subject: [PATCH] wip --- components/protocols/yearn-v2/CardYearn.vue | 11 +++++++++-- composables/protocols/useYearnV2Position.ts | 21 ++++++++++++++++----- pages/mainnet/yearn-v2.vue | 1 + 3 files changed, 26 insertions(+), 7 deletions(-) diff --git a/components/protocols/yearn-v2/CardYearn.vue b/components/protocols/yearn-v2/CardYearn.vue index a6a3012..63f6803 100644 --- a/components/protocols/yearn-v2/CardYearn.vue +++ b/components/protocols/yearn-v2/CardYearn.vue @@ -5,7 +5,13 @@ >
- +
+ +
+
@@ -25,7 +31,7 @@
-

{{ formatPercent(netAPY) }}

+

{{ formatPercent(netAPY) }}

net APY

@@ -57,6 +63,7 @@ import { useToken } from "~/composables/useToken"; export default defineComponent({ props: { tokenKey: { type: String, required: true }, + tokenIcon: { type: String, required: false }, vault: { type: String, default: null }, supply: { type: String, required: true }, supplyUsd: { type: String, required: true }, diff --git a/composables/protocols/useYearnV2Position.ts b/composables/protocols/useYearnV2Position.ts index 3e3d2ee..a7a642d 100644 --- a/composables/protocols/useYearnV2Position.ts +++ b/composables/protocols/useYearnV2Position.ts @@ -10,7 +10,9 @@ import { useBigNumber } from "../useBigNumber"; const resolver = addresses.mainnet.resolver.yearnV2; -const wantAddresses = tokens.mainnet.allTokens.map((token) => token.address); +const allTokens = tokens.mainnet.allTokens.map(token => token.address); + +const wantAddresses = allTokens; const vaults = ref([]); @@ -39,7 +41,16 @@ export function useYearnV2Position() { resolver ); - const tokensArr = wantAddresses; // tokens.mainnet.allTokens.map(a => a.address); + // const tokensArr = wantAddresses; + + // allow user to add custom tokens + const tokensArr = [ + ...new Set( + availableVaults.filter(v => v.type === "v2").map(v => v.token.address) + .filter(a => allTokens.includes(a)) + ) + ]; + const rawData = await resolverInstance.methods .getPositionsForLatest(activeAccount.value.address, tokensArr) @@ -65,8 +76,8 @@ export function useYearnV2Position() { const v = availableVaults.find(v => v.address === vault); if (v) { const supply = new BigNumber(balanceOf) - .dividedBy(10 ** decimals) - .toFixed(); + .dividedBy(10 ** decimals) + .toFixed(); newVaults.push({ ...v, @@ -85,7 +96,7 @@ export function useYearnV2Position() { isDeprecated, emergencyShutdown, supply, - supplyUsd: times(supply, v.tvl.price).toFixed(), + supplyUsd: times(supply, v.tvl.price).toFixed() } }); } diff --git a/pages/mainnet/yearn-v2.vue b/pages/mainnet/yearn-v2.vue index 1c5b259..4b80100 100644 --- a/pages/mainnet/yearn-v2.vue +++ b/pages/mainnet/yearn-v2.vue @@ -48,6 +48,7 @@