From 9bab77277b72122e869166f1047302a96a367ca9 Mon Sep 17 00:00:00 2001 From: toniocodo Date: Wed, 19 Feb 2025 15:09:56 +0100 Subject: [PATCH] feat: add curve AMO collateral --- libs/analytics/super/src/hooks.ts | 33 +- .../super/src/views/CollateralsView.tsx | 8 +- .../contracts/src/abis/CurveAMOStrategy.ts | 539 ++++++++++++++++++ libs/shared/contracts/src/contracts.ts | 7 + 4 files changed, 584 insertions(+), 3 deletions(-) create mode 100644 libs/shared/contracts/src/abis/CurveAMOStrategy.ts diff --git a/libs/analytics/super/src/hooks.ts b/libs/analytics/super/src/hooks.ts index b432f3662..b0bf26bce 100644 --- a/libs/analytics/super/src/hooks.ts +++ b/libs/analytics/super/src/hooks.ts @@ -1,5 +1,6 @@ import { useTheme } from '@mui/material'; import { contracts, tokens } from '@origin/shared/contracts'; +import { Curve, ETH, wOETH } from '@origin/shared/icons'; import { useQuery } from '@tanstack/react-query'; import { readContracts } from '@wagmi/core'; import { add, from, gt, sub, toNumber } from 'dnum'; @@ -44,6 +45,13 @@ export const useSuperCollaterals = () => { functionName: 'balanceOf', args: [contracts.base.superOETHbStrategyAero.address], }, + { + address: contracts.base.superOETHbCurveAMOStrategy.address, + abi: contracts.base.superOETHbCurveAMOStrategy.abi, + chainId: contracts.base.superOETHbCurveAMOStrategy.chainId, + functionName: 'checkBalance', + args: [tokens.base.WETH.address], + }, ], }); @@ -67,6 +75,10 @@ export const useSuperCollaterals = () => { data?.[3]?.status === 'success' ? ([data[3].result, tokens.base.WETH.decimals] as Dnum) : from(0); + const curveAmoSuper = + data?.[4]?.status === 'success' + ? ([data[4].result, tokens.base.WETH.decimals] as Dnum) + : from(0); const balanceAmo = [balanceAmoWeth, pendingAmoWeth].reduce( (acc, curr) => add(acc, curr), @@ -76,11 +88,15 @@ export const useSuperCollaterals = () => { balanceAmoWeth, balanceAmoSuper, pendingAmoWeth, + curveAmoSuper, ].reduce( (acc, curr) => add(acc, curr), from(0, tokens.base.WETH.decimals), ); - const circulating = add(fullAmoBalanceWeth, balanceBridge); + const circulating = [fullAmoBalanceWeth, balanceBridge].reduce( + (acc, curr) => add(curr, acc), + from(0, tokens.base.WETH.decimals), + ); const unallocatedBalance = gt( sub(superOethVaultTotalValue, circulating), 0, @@ -90,6 +106,7 @@ export const useSuperCollaterals = () => { const computedTotal = [ balanceAmo, balanceBridge, + curveAmoSuper, unallocatedBalance, ].reduce((acc, curr) => add(acc, curr), from(0, 18)); @@ -98,6 +115,7 @@ export const useSuperCollaterals = () => { label: intl.formatMessage({ defaultMessage: 'Liquid Staking', }), + icon: wOETH, value: toNumber(balanceBridge), color: theme.palette.primary.main, token: tokens.mainnet.ETH, @@ -108,16 +126,29 @@ export const useSuperCollaterals = () => { label: intl.formatMessage({ defaultMessage: 'Aerodrome AMO', }), + icon: ETH, value: toNumber(balanceAmo), color: theme.palette.chart6, token: tokens.mainnet.ETH, total: toNumber(computedTotal), href: 'https://basescan.org/address/0xcDD21c5544A5B07fab409284cEE6c6097091B589', }, + { + label: intl.formatMessage({ + defaultMessage: 'Curve AMO', + }), + icon: Curve, + value: toNumber(curveAmoSuper), + color: theme.palette.chart5, + token: tokens.mainnet.ETH, + total: toNumber(computedTotal), + href: 'https://basescan.org/address/0xcDD21c5544A5B07fab409284cEE6c6097091B589', + }, { label: intl.formatMessage({ defaultMessage: 'Unallocated', }), + icon: ETH, value: Math.max(toNumber(unallocatedBalance), 0), color: theme.palette.chart1, token: tokens.mainnet.ETH, diff --git a/libs/analytics/super/src/views/CollateralsView.tsx b/libs/analytics/super/src/views/CollateralsView.tsx index 5d9b7354d..496721aef 100644 --- a/libs/analytics/super/src/views/CollateralsView.tsx +++ b/libs/analytics/super/src/views/CollateralsView.tsx @@ -6,6 +6,7 @@ import { Divider, Grid2, Stack, + SvgIcon, Typography, } from '@mui/material'; import { useLayout } from '@origin/analytics/shared'; @@ -25,8 +26,9 @@ import { useIntl } from 'react-intl'; import { useSuperCollaterals } from '../hooks'; -import type { StackProps } from '@mui/material'; +import type { StackProps, SvgIconProps } from '@mui/material'; import type { Token } from '@origin/shared/contracts'; +import type { ComponentType } from 'react'; export const CollateralsView = () => { const intl = useIntl(); @@ -151,6 +153,7 @@ export const CollateralsView = () => { type CollateralCardProps = { value: number; + icon: ComponentType; label?: string; token: Token; href?: string; @@ -160,6 +163,7 @@ type CollateralCardProps = { const CollateralCard = ({ value, + icon, label, total, title, @@ -186,7 +190,7 @@ const CollateralCard = ({ ...(Array.isArray(rest?.sx) ? rest.sx : [rest.sx]), ]} > - + {label?.length || href?.length ? (