Skip to content

Commit

Permalink
Merge branch 'next'
Browse files Browse the repository at this point in the history
  • Loading branch information
toniocodo committed Feb 19, 2025
2 parents 4fd4557 + 9bab772 commit 7eb7ac8
Show file tree
Hide file tree
Showing 4 changed files with 584 additions and 3 deletions.
33 changes: 32 additions & 1 deletion libs/analytics/super/src/hooks.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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],
},
],
});

Expand All @@ -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),
Expand All @@ -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,
Expand All @@ -90,6 +106,7 @@ export const useSuperCollaterals = () => {
const computedTotal = [
balanceAmo,
balanceBridge,
curveAmoSuper,
unallocatedBalance,
].reduce((acc, curr) => add(acc, curr), from(0, 18));

Expand All @@ -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,
Expand All @@ -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,
Expand Down
8 changes: 6 additions & 2 deletions libs/analytics/super/src/views/CollateralsView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
Divider,
Grid2,
Stack,
SvgIcon,
Typography,
} from '@mui/material';
import { useLayout } from '@origin/analytics/shared';
Expand All @@ -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();
Expand Down Expand Up @@ -151,6 +153,7 @@ export const CollateralsView = () => {

type CollateralCardProps = {
value: number;
icon: ComponentType<SvgIconProps>;
label?: string;
token: Token;
href?: string;
Expand All @@ -160,6 +163,7 @@ type CollateralCardProps = {

const CollateralCard = ({
value,
icon,
label,
total,
title,
Expand All @@ -186,7 +190,7 @@ const CollateralCard = ({
...(Array.isArray(rest?.sx) ? rest.sx : [rest.sx]),
]}
>
<TokenIcon token={token} sx={{ fontSize: 36 }} />
<SvgIcon component={icon} sx={{ fontSize: 36 }} />
<Stack sx={{ flexGrow: 1 }}>
{label?.length || href?.length ? (
<Stack
Expand Down
Loading

0 comments on commit 7eb7ac8

Please sign in to comment.