Skip to content

Commit

Permalink
Merge branch 'next' into feat/oeth-withdrawal
Browse files Browse the repository at this point in the history
  • Loading branch information
toniocodo committed Jul 23, 2024
2 parents 3fe45ab + 8254258 commit 0b86e5c
Show file tree
Hide file tree
Showing 40 changed files with 3,103 additions and 2,258 deletions.
40 changes: 12 additions & 28 deletions apps/defi/src/lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -553,20 +553,6 @@
"value": "Amount to Stake"
}
],
"74CdrO": [
{
"type": 1,
"value": "apy_low"
},
{
"type": 0,
"value": " - "
},
{
"type": 1,
"value": "apy_high"
}
],
"7CPiAt": [
{
"type": 0,
Expand Down Expand Up @@ -829,20 +815,6 @@
"value": "Redeem via OETH Vault"
}
],
"Awi257": [
{
"type": 1,
"value": "amount"
},
{
"type": 0,
"value": " "
},
{
"type": 1,
"value": "symbol"
}
],
"B0mIqy": [
{
"type": 0,
Expand Down Expand Up @@ -2883,6 +2855,12 @@
"value": "Approval cancelled"
}
],
"oz/WEO": [
{
"type": 0,
"value": "30-day trailing APY"
}
],
"p1P+hQ": [
{
"type": 0,
Expand Down Expand Up @@ -3257,6 +3235,12 @@
"value": "Wrong Network"
}
],
"xXgeM8": [
{
"type": 0,
"value": "7-day trailing APY"
}
],
"xZIm6b": [
{
"type": 0,
Expand Down
12 changes: 6 additions & 6 deletions apps/defi/src/lang/extracts/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -215,9 +215,6 @@
"6fzXU+": {
"defaultMessage": "Amount to Stake"
},
"74CdrO": {
"defaultMessage": "{apy_low} - {apy_high}"
},
"7CPiAt": {
"defaultMessage": "Redeemed"
},
Expand Down Expand Up @@ -329,9 +326,6 @@
"AtWUBa": {
"defaultMessage": "Redeem via OETH Vault"
},
"Awi257": {
"defaultMessage": "{amount} {symbol}"
},
"B0mIqy": {
"defaultMessage": "Extending Stake"
},
Expand Down Expand Up @@ -1133,6 +1127,9 @@
"oy7udF": {
"defaultMessage": "Approval cancelled"
},
"oz/WEO": {
"defaultMessage": "30-day trailing APY"
},
"p1P+hQ": {
"defaultMessage": "Request"
},
Expand Down Expand Up @@ -1298,6 +1295,9 @@
"wqlXwW": {
"defaultMessage": "Wrong Network"
},
"xXgeM8": {
"defaultMessage": "7-day trailing APY"
},
"xZIm6b": {
"defaultMessage": "Your transaction may be frontrun"
},
Expand Down
12 changes: 12 additions & 0 deletions apps/prime/src/lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -505,6 +505,12 @@
"value": "symbolOut"
}
],
"EUPZOz": [
{
"type": 0,
"value": "blocks left"
}
],
"FdfIVU": [
{
"type": 0,
Expand Down Expand Up @@ -1047,6 +1053,12 @@
"value": "Withdrawal Process"
}
],
"cOKXho": [
{
"type": 0,
"value": "Claimable"
}
],
"cg1VJ2": [
{
"type": 0,
Expand Down
6 changes: 6 additions & 0 deletions apps/prime/src/lang/extracts/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,9 @@
"EEwopl": {
"defaultMessage": "{amountIn} {symbolIn} for {amountOut} {symbolOut}"
},
"EUPZOz": {
"defaultMessage": "blocks left"
},
"FdfIVU": {
"defaultMessage": "All your XP will be redeemable for YND tokens at the TGE."
},
Expand Down Expand Up @@ -446,6 +449,9 @@
"c7tNet": {
"defaultMessage": "Withdrawal Process"
},
"cOKXho": {
"defaultMessage": "Claimable"
},
"cg1VJ2": {
"defaultMessage": "Connect Wallet"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export const CurrentResultsCard = (props: CardProps) => {
proposal?.choices?.findIndex(
(c) => c!.toLowerCase() === choice.toLowerCase(),
) ?? -1;
const score = idx > -1 ? proposal?.scores?.at(idx) ?? 0 : 0;
const score = idx > -1 ? (proposal?.scores?.at(idx) ?? 0) : 0;

return (
<Grid2 key={choice} xs={12} sm={12 / governanceChoices.length}>
Expand Down
6 changes: 3 additions & 3 deletions libs/defi/governance/src/overview/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export const useProposals = (

const onChainProposals: Proposal[] =
res[0].status === 'fulfilled'
? res[0]?.value?.governanceProposals?.map(mapOnchainProposal) ?? []
? (res[0]?.value?.governanceProposals?.map(mapOnchainProposal) ?? [])
: [];

const offChainProposals = [];
Expand Down Expand Up @@ -109,7 +109,7 @@ export const useUserVotes = () => {

const onChainVotes =
res[0].status === 'fulfilled'
? (res[0].value as UserVotesQuery)?.governanceProposalVotes?.map(
? ((res[0].value as UserVotesQuery)?.governanceProposalVotes?.map(
(v) => {
const type: ProposalType =
v?.proposal?.address?.toLowerCase() ===
Expand All @@ -133,7 +133,7 @@ export const useUserVotes = () => {
},
};
},
) ?? []
) ?? [])
: [];

const offChainVotes = [];
Expand Down
74 changes: 50 additions & 24 deletions libs/defi/home/src/components/ProductCard.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
import { Box, Button, Card, Collapse, Stack, Typography } from '@mui/material';
import {
Box,
Button,
Card,
Collapse,
Stack,
Tooltip,
Typography,
} from '@mui/material';
import { useOTokenAddressQuery, useOTokenApyQuery } from '@origin/defi/shared';
import { LoadingLabel, TokenIcon, ValueLabel } from '@origin/shared/components';
import { FaArrowRightRegular } from '@origin/shared/icons';
import { useFormat, useTvl } from '@origin/shared/providers';
import { FaArrowRightRegular, FaCircleInfoRegular } from '@origin/shared/icons';
import { useTvl } from '@origin/shared/providers';
import {
formatAmount,
getFormatPrecision,
Expand All @@ -14,6 +22,7 @@ import { Link as RouterLink } from 'react-router-dom';
import { useAccount } from 'wagmi';

import type { CardProps } from '@mui/material';
import type { Dnum } from 'dnum';

import type { Product } from '../constants';

Expand All @@ -23,14 +32,13 @@ export type ProductCardProps = {

export const ProductCard = ({ product, ...rest }: ProductCardProps) => {
const intl = useIntl();
const { formatBalance } = useFormat();
const { address, isConnected } = useAccount();
const { data: tvl, isLoading: isTvlLoading } = useTvl(product.token);
const { data: apy, isLoading: isApyLoading } = useOTokenApyQuery(
const { data: apies, isLoading: isApiesLoading } = useOTokenApyQuery(
{ token: product.token.address, chainId: product.token.chainId },
{
select: (data) => {
return data?.oTokenApies[0].apy30DayAvg ?? 0;
return data?.oTokenApies[0];
},
},
);
Expand All @@ -43,7 +51,21 @@ export const ProductCard = ({ product, ...rest }: ProductCardProps) => {
{ enabled: isConnected, select: (data) => data?.oTokenAddresses?.[0] },
);

const bal = from(BigInt(user?.balance ?? 0));
const bal = [BigInt(user?.balance ?? 0), product.token.decimals] as Dnum;
const { apy, tooltip } =
(apies?.apy30DayAvg ?? 0) > (apies?.apy7DayAvg ?? 0)
? {
apy: apies?.apy30DayAvg,
tooltip: intl.formatMessage({
defaultMessage: '30-day trailing APY',
}),
}
: {
apy: apies?.apy7DayAvg,
tooltip: intl.formatMessage({
defaultMessage: '7-day trailing APY',
}),
};

return (
<Card
Expand Down Expand Up @@ -94,23 +116,27 @@ export const ProductCard = ({ product, ...rest }: ProductCardProps) => {
</Typography>
</Stack>
<Stack py={3} spacing={1}>
<Stack direction="row" spacing={1} alignItems="baseline">
<LoadingLabel
isLoading={isApyLoading}
variant="featured1"
color="primary"
fontWeight="bold"
>
{intl.formatNumber(apy ?? 0, {
minimumFractionDigits: 2,
maximumFractionDigits: 2,
style: 'percent',
})}
</LoadingLabel>
<Typography variant="body2" color="primary">
{intl.formatMessage({ defaultMessage: 'APY' })}
</Typography>
</Stack>
<Tooltip title={tooltip}>
<Stack direction="row" alignItems="baseline">
<LoadingLabel
isLoading={isApiesLoading}
variant="featured1"
color="primary"
fontWeight="bold"
mr={1}
>
{intl.formatNumber(apy ?? 0, {
minimumFractionDigits: 2,
maximumFractionDigits: 2,
style: 'percent',
})}
</LoadingLabel>
<Typography variant="body2" color="primary.main" mr={0.5}>
{intl.formatMessage({ defaultMessage: 'APY' })}
</Typography>
<FaCircleInfoRegular sx={{ fontSize: 14, color: 'primary.main' }} />
</Stack>
</Tooltip>
<LoadingLabel isLoading={isTvlLoading} sWidth={60}>
{intl.formatMessage(
{ defaultMessage: 'TVL: {tvl}' },
Expand Down
2 changes: 1 addition & 1 deletion libs/defi/oeth/src/bridge/components/BridgeCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ export const BridgeCard = () => {
const gasPrice = add(
txButton?.gasPrice?.gasCostEther ?? from(0),
(allowance ?? 0n) < amount
? approvalGasPrice?.gasCostEther ?? from(0)
? (approvalGasPrice?.gasCostEther ?? from(0))
: from(0),
);
const bridgeFee = [ccipTxParams?.data?.fee ?? 0n, 18] as Dnum;
Expand Down
43 changes: 23 additions & 20 deletions libs/defi/oeth/src/swap/components/PageTitleSection.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Stack, Typography } from '@mui/material';
import { ChainsChip, ColorChip, useOTokenApyQuery } from '@origin/defi/shared';
import { LoadingLabel } from '@origin/shared/components';
import { InfoTooltip, LoadingLabel } from '@origin/shared/components';
import { tokens } from '@origin/shared/contracts';
import { useIntl } from 'react-intl';
import { arbitrum, mainnet } from 'viem/chains';
Expand All @@ -16,16 +16,26 @@ export const PageTitleSection = (props: StackProps) => {
},
{
select: (data) => {
const apies = [
data?.oTokenApies?.[0].apy7DayAvg,
data?.oTokenApies?.[0].apy30DayAvg,
];

return apies.sort();
return data?.oTokenApies[0];
},
},
);

const { apy, tooltip } =
(apies?.apy30DayAvg ?? 0) > (apies?.apy7DayAvg ?? 0)
? {
apy: apies?.apy30DayAvg,
tooltip: intl.formatMessage({
defaultMessage: '30-day trailing APY',
}),
}
: {
apy: apies?.apy7DayAvg,
tooltip: intl.formatMessage({
defaultMessage: '7-day trailing APY',
}),
};

return (
<Stack
direction="row"
Expand All @@ -42,23 +52,16 @@ export const PageTitleSection = (props: StackProps) => {
fontWeight="bold"
sWidth={90}
>
{intl.formatMessage(
{ defaultMessage: '{apy_low} - {apy_high}' },
{
apy_low: intl.formatNumber(apies?.[0] ?? 0, {
style: 'percent',
minimumFractionDigits: 2,
}),
apy_high: intl.formatNumber(apies?.[1] ?? 0, {
style: 'percent',
minimumFractionDigits: 2,
}),
},
)}
{intl.formatNumber(apy ?? 0, {
minimumFractionDigits: 2,
maximumFractionDigits: 2,
style: 'percent',
})}
</LoadingLabel>
<Typography variant="caption1" color="inherit">
{intl.formatMessage({ defaultMessage: 'APY' })}
</Typography>
<InfoTooltip tooltipLabel={tooltip} iconColor="primary.main" />
</ColorChip>
<ChainsChip chainIds={[mainnet.id, arbitrum.id]} minHeight={40} />
</Stack>
Expand Down
Loading

0 comments on commit 0b86e5c

Please sign in to comment.