From 0150784583f7dd2e1a1ce8a6036a424048d438d3 Mon Sep 17 00:00:00 2001 From: SidharthK2 Date: Mon, 14 Oct 2024 10:48:33 +0530 Subject: [PATCH 1/6] fetch fxtl convex lps --- src/utils/treasury-utils.ts | 59 +++++++++++++++++++++++++++++-------- 1 file changed, 46 insertions(+), 13 deletions(-) diff --git a/src/utils/treasury-utils.ts b/src/utils/treasury-utils.ts index 66ed5017..d5c7356d 100644 --- a/src/utils/treasury-utils.ts +++ b/src/utils/treasury-utils.ts @@ -10,12 +10,18 @@ import { fraxLendQueryObject } from '@/services/treasury/queries' import { store } from '@/store/store' import { getProtocolDetails, - getTokenInfo, getWalletTokens, } from '@/services/treasury/restApi' const TOKEN_MINIMUM_VALUE = 4000 +type FraxConvexDetails = { + name: string + pool: { controller: any } + stats: { asset_usd_value: any } + detail: { supply_token_list: { amount: number; symbol: string }[] } +} + const SUPPORTED_LP_TOKENS_ADDRESSES = [ '0x7af00cf8d3a8a75210a5ed74f2254e2ec43b5b5b', '0x41a5881c17185383e19df6fa4ec158a6f4851a69:32', @@ -37,6 +43,15 @@ const SUPPORTED_LP_TOKENS_ADDRESSES = [ const FRAXTAL_TOKENS = [ '0xfc00000000000000000000000000000000000008', '0x8c279f6bfa31c47f29e5d05a68796f2a6c216892', + '0x124189d975bd59f85a0be1845b556d9249096522', + '0x1872621050cc3c267c1982c6d199b7d6a4d0e87a', + '0x22c4649ea0937e86ab64366ddfb39d6769874b17', + '0x331b9182088e2a7d6d3fe4742aba1fb231aecc56', + '0x8c279f6bfa31c47f29e5d05a68796f2a6c216892', + '0xab4b7c5c9a7c8ebb97877085a6c3550ad4ed3f97', + '0xed634f2dd6632d0eb017d44639ae77798a315c0f', + '0xfc00000000000000000000000000000000000002', + '0xfc00000000000000000000000000000000000008', ] const PROTOCOLS = ['fraxlend', 'convex', 'frax', 'eigenlayer'] @@ -83,21 +98,23 @@ const getTreasuryPayload = (protocol: string) => { } export const getTreasuryDetails = async () => { - const [{ data: tokens }, { data: fraxtalTokens }] = await Promise.all([ + const [ + { data: tokens }, + { data: fraxtalTokens }, + { data: fraxConvexDetails }, + ] = await Promise.all([ store.dispatch(getWalletTokens.initiate(config.treasuryAddress as string)), store.dispatch( getWalletTokens.initiate(config.fraxtalTreasuryAddress as string), ), + store.dispatch( + getProtocolDetails.initiate({ + protocolId: 'frax_convex', + id: '0x5493f3dbe06accd1f51568213de839498a2a3b83', + }), + ), ]) - const { data: tokenInfo } = await store.dispatch( - getTokenInfo.initiate({ - chain: 'frax', - ids: '0xefb4b26fc242478c9008274f9e81db89fa6adab9', - }), - ) - const cvxFXSPrice = tokenInfo[0]?.price || 0 - const { data: protocolDetails } = await store.dispatch( getProtocolDetails.initiate({ protocolId: 'apestake', @@ -122,11 +139,10 @@ export const getTreasuryDetails = async () => { value += contractProtocoldetails?.amount } - const dollarValue = - token.symbol === 'stkcvxFxs' ? cvxFXSPrice * value : token.price * value + const dollarValue = token.price * value const tokenDetails = { id: FRAXTAL_TOKENS.includes(token.id) - ? `${token.symbol} Fraxtal` + ? `${token.symbol} FXTL` : token.symbol, contractAddress: token.id, token: value, @@ -156,6 +172,23 @@ export const getTreasuryDetails = async () => { } }) + // Add Frax Convex holdings + if (fraxConvexDetails) { + fraxConvexDetails.forEach((item: FraxConvexDetails) => { + additionalTreasuryData.push({ + id: `FXTL CVX ${item.name}`, + contractAddress: item.pool.controller, + raw_dollar: Number(item.stats.asset_usd_value), + token: item.detail.supply_token_list.map( + (supply: { amount: number; symbol: string }) => ({ + amount: supply.amount, + symbol: supply.symbol, + }), + ), + }) + }) + } + const allTreasureDetails = [...treasuryDetails, ...additionalTreasuryData] return allTreasureDetails From db166c32f537897971537d931ef41155acf42d5c Mon Sep 17 00:00:00 2001 From: SidharthK2 Date: Mon, 14 Oct 2024 10:48:44 +0530 Subject: [PATCH 2/6] lint --- src/components/dashboard/TreasuryGraphTable.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/dashboard/TreasuryGraphTable.tsx b/src/components/dashboard/TreasuryGraphTable.tsx index 9939922f..2702a0c2 100644 --- a/src/components/dashboard/TreasuryGraphTable.tsx +++ b/src/components/dashboard/TreasuryGraphTable.tsx @@ -1,3 +1,4 @@ +import React, { useCallback, useState, useEffect, useRef } from 'react' import { TOKEN_KEYS, TOKENS, PIE_CHART_COLORS } from '@/data/treasury-data' import { TreasuryTokenType } from '@/types/TreasuryTokenType' import { formatValue } from '@/utils/LockOverviewUtils' @@ -18,7 +19,6 @@ import { Th, Tbody, } from '@chakra-ui/react' -import React, { useCallback, useState, useEffect, useRef } from 'react' import PageHeader from './PageHeader' import { ChartDataType, OnPieEnter } from '@/types/chartType' import Chart from '../elements/PieChart/Chart' @@ -107,7 +107,7 @@ export const TreasuryGraphTable = ({ formatPieData(treasuryValuePlusYield, totalAccountValue) setTokenData(treasuryValuePlusYield) setTokenDataToShow(treasuryValuePlusYield) - }, []) + }, [rate, userTotalIQLocked, totalHiiqSupply, fraxAprData, fraxEthSummary]) useEffect(() => { if (!isTokenFetched.current) { From e2ca1014a65fbe6f9d988234d2e69a1fdc6d5d46 Mon Sep 17 00:00:00 2001 From: SidharthK2 Date: Mon, 14 Oct 2024 11:56:56 +0530 Subject: [PATCH 3/6] Add token details --- src/data/treasury-data.ts | 20 ++++++++++++++++++- src/utils/treasury-utils.ts | 40 ++++++++++++++++++------------------- 2 files changed, 39 insertions(+), 21 deletions(-) diff --git a/src/data/treasury-data.ts b/src/data/treasury-data.ts index 8dd4387b..88c9c797 100644 --- a/src/data/treasury-data.ts +++ b/src/data/treasury-data.ts @@ -206,12 +206,30 @@ export const TOKENS: TokensType = { address: '0xe035e27a8ed6842b478933820f90093d205f7098', image: '/svgs/fxb.svg', }, - 'stkcvxFxs Fraxtal': { + '0x8c279f6bfa31c47f29e5d05a68796f2a6c216892': { id: 'stkcvxFxs Fraxtal', name: 'cvxFxs Fraxtal', address: '0x8c279f6bfa31c47f29e5d05a68796f2a6c216892', image: '/svgs/stkcvx.svg', }, + '0x1872621050cc3c267c1982c6d199b7d6a4d0e87a': { + id: 'FXB20551231', + name: 'FXB20551231', + address: '0x1872621050cc3c267c1982c6d199b7d6a4d0e87a', + image: '/svgs/FXB.svg', + }, + '0x22c4649ea0937e86ab64366ddfb39d6769874b17': { + id: 'FXB20251231', + name: 'FXB20251231', + address: '0x22c4649ea0937e86ab64366ddfb39d6769874b17', + image: '/svgs/FXB.svg', + }, + '0xed634f2dd6632d0eb017d44639ae77798a315c0f': { + id: 'FXB20291231', + name: 'FXB20291231', + address: '0xed634f2dd6632d0eb017d44639ae77798a315c0f', + image: '/svgs/FXB.svg', + }, } export const tokenIds = Object.values(TOKENS).map((tok) => tok.id) diff --git a/src/utils/treasury-utils.ts b/src/utils/treasury-utils.ts index d5c7356d..9b55baaa 100644 --- a/src/utils/treasury-utils.ts +++ b/src/utils/treasury-utils.ts @@ -15,13 +15,6 @@ import { const TOKEN_MINIMUM_VALUE = 4000 -type FraxConvexDetails = { - name: string - pool: { controller: any } - stats: { asset_usd_value: any } - detail: { supply_token_list: { amount: number; symbol: string }[] } -} - const SUPPORTED_LP_TOKENS_ADDRESSES = [ '0x7af00cf8d3a8a75210a5ed74f2254e2ec43b5b5b', '0x41a5881c17185383e19df6fa4ec158a6f4851a69:32', @@ -174,19 +167,26 @@ export const getTreasuryDetails = async () => { // Add Frax Convex holdings if (fraxConvexDetails) { - fraxConvexDetails.forEach((item: FraxConvexDetails) => { - additionalTreasuryData.push({ - id: `FXTL CVX ${item.name}`, - contractAddress: item.pool.controller, - raw_dollar: Number(item.stats.asset_usd_value), - token: item.detail.supply_token_list.map( - (supply: { amount: number; symbol: string }) => ({ - amount: supply.amount, - symbol: supply.symbol, - }), - ), - }) - }) + console.log(fraxConvexDetails) + fraxConvexDetails.forEach( + (item: { + pool: { adapter_id: any; controller: any; id: any } + stats: { asset_usd_value: any } + detail: { supply_token_list: { amount: number; symbol: string }[] } + }) => { + additionalTreasuryData.push({ + id: item.pool.id, + contractAddress: item.pool.id, + raw_dollar: Number(item.stats.asset_usd_value), + token: item.detail.supply_token_list.map( + (supply: { amount: number; symbol: string }) => ({ + amount: supply.amount, + symbol: supply.symbol, + }), + ), + }) + }, + ) } const allTreasureDetails = [...treasuryDetails, ...additionalTreasuryData] From ba049bf8623ae2d0117bf1c9550217eb1688aa18 Mon Sep 17 00:00:00 2001 From: SidharthK2 Date: Wed, 16 Oct 2024 12:55:21 +0530 Subject: [PATCH 4/6] remove duplicate tokens --- src/utils/treasury-utils.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/utils/treasury-utils.ts b/src/utils/treasury-utils.ts index 9b55baaa..10499f67 100644 --- a/src/utils/treasury-utils.ts +++ b/src/utils/treasury-utils.ts @@ -40,11 +40,9 @@ const FRAXTAL_TOKENS = [ '0x1872621050cc3c267c1982c6d199b7d6a4d0e87a', '0x22c4649ea0937e86ab64366ddfb39d6769874b17', '0x331b9182088e2a7d6d3fe4742aba1fb231aecc56', - '0x8c279f6bfa31c47f29e5d05a68796f2a6c216892', '0xab4b7c5c9a7c8ebb97877085a6c3550ad4ed3f97', '0xed634f2dd6632d0eb017d44639ae77798a315c0f', '0xfc00000000000000000000000000000000000002', - '0xfc00000000000000000000000000000000000008', ] const PROTOCOLS = ['fraxlend', 'convex', 'frax', 'eigenlayer'] From 6d59938abb7d1c1d2779babe6f686c951c800a01 Mon Sep 17 00:00:00 2001 From: SidharthK2 Date: Wed, 16 Oct 2024 13:48:00 +0530 Subject: [PATCH 5/6] Fix codeclimate warnings --- src/utils/treasury-utils.ts | 78 ++++++++++++++++++------------------- 1 file changed, 38 insertions(+), 40 deletions(-) diff --git a/src/utils/treasury-utils.ts b/src/utils/treasury-utils.ts index 10499f67..464829c4 100644 --- a/src/utils/treasury-utils.ts +++ b/src/utils/treasury-utils.ts @@ -145,48 +145,46 @@ export const getTreasuryDetails = async () => { }, ) - const additionalTreasuryData: TreasuryTokenType[] = [] - const allLpTokens = walletDetails.map(({ data }) => data) - allLpTokens.flat().forEach((lp) => { - if (SUPPORTED_LP_TOKENS_ADDRESSES.includes(lp.pool.id)) { - additionalTreasuryData.push({ - id: lp.pool.adapter_id, - contractAddress: lp.pool.controller, - raw_dollar: Number(lp.stats.asset_usd_value), - token: lp.detail.supply_token_list.map( - (supply: { amount: number; symbol: string }) => ({ - amount: supply.amount, - symbol: supply.symbol, - }), - ), - }) - } - }) - - // Add Frax Convex holdings - if (fraxConvexDetails) { - console.log(fraxConvexDetails) - fraxConvexDetails.forEach( - (item: { - pool: { adapter_id: any; controller: any; id: any } - stats: { asset_usd_value: any } - detail: { supply_token_list: { amount: number; symbol: string }[] } - }) => { - additionalTreasuryData.push({ - id: item.pool.id, - contractAddress: item.pool.id, - raw_dollar: Number(item.stats.asset_usd_value), - token: item.detail.supply_token_list.map( - (supply: { amount: number; symbol: string }) => ({ - amount: supply.amount, - symbol: supply.symbol, - }), - ), - }) - }, - ) + const processTreasuryData = (data: any[], supportedAddresses: string[]) => { + return data.flatMap((item) => { + if (supportedAddresses.includes(item.pool.id)) { + return [ + { + id: + item.pool?.chain === 'frax' + ? item.pool.id + : item.pool.adapter_id || item.pool.id, + contractAddress: + item.pool?.chain === 'frax' + ? item.pool.id + : item.pool.controller || item.pool.id, + raw_dollar: Number(item.stats.asset_usd_value), + token: item.detail.supply_token_list.map( + (supply: { amount: number; symbol: string }) => ({ + amount: supply.amount, + symbol: supply.symbol, + }), + ), + }, + ] + } + return [] + }) } + const additionalTreasuryData: TreasuryTokenType[] = [ + ...processTreasuryData( + walletDetails.flatMap(({ data }) => data), + SUPPORTED_LP_TOKENS_ADDRESSES, + ), + ...processTreasuryData( + fraxConvexDetails || [], + fraxConvexDetails + ? fraxConvexDetails.map((item: any) => item.pool.id) + : [], + ), + ] + const allTreasureDetails = [...treasuryDetails, ...additionalTreasuryData] return allTreasureDetails From a23c27c48b212f0f0a2e455d6741dba142677f1a Mon Sep 17 00:00:00 2001 From: SidharthK2 Date: Wed, 16 Oct 2024 13:48:25 +0530 Subject: [PATCH 6/6] update token details --- src/data/treasury-data.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/data/treasury-data.ts b/src/data/treasury-data.ts index 88c9c797..9f90f05d 100644 --- a/src/data/treasury-data.ts +++ b/src/data/treasury-data.ts @@ -208,25 +208,25 @@ export const TOKENS: TokensType = { }, '0x8c279f6bfa31c47f29e5d05a68796f2a6c216892': { id: 'stkcvxFxs Fraxtal', - name: 'cvxFxs Fraxtal', + name: 'cvxFxs FXTL', address: '0x8c279f6bfa31c47f29e5d05a68796f2a6c216892', image: '/svgs/stkcvx.svg', }, '0x1872621050cc3c267c1982c6d199b7d6a4d0e87a': { id: 'FXB20551231', - name: 'FXB20551231', + name: 'FXB20551231 FXTL', address: '0x1872621050cc3c267c1982c6d199b7d6a4d0e87a', image: '/svgs/FXB.svg', }, '0x22c4649ea0937e86ab64366ddfb39d6769874b17': { id: 'FXB20251231', - name: 'FXB20251231', + name: 'FXB20251231 FXTL', address: '0x22c4649ea0937e86ab64366ddfb39d6769874b17', image: '/svgs/FXB.svg', }, '0xed634f2dd6632d0eb017d44639ae77798a315c0f': { id: 'FXB20291231', - name: 'FXB20291231', + name: 'FXB20291231 FXTL', address: '0xed634f2dd6632d0eb017d44639ae77798a315c0f', image: '/svgs/FXB.svg', },