Skip to content

Commit

Permalink
feat: Show APY in my assets
Browse files Browse the repository at this point in the history
  • Loading branch information
kovipu committed Dec 8, 2024
1 parent 3b2becf commit 102f6bf
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/components/AssetsModal/PositionsView.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Button } from '@components/Button';
import { usePools } from '@contexts/pool-context';
import { useWallet } from '@contexts/wallet-context';
import { formatAmount, toDollarsFormatted } from '@lib/formatting';
import { formatAPY, formatAmount, toDollarsFormatted } from '@lib/formatting';
import type { SupportedCurrency } from 'currencies';
import { isNil } from 'ramda';
import { CURRENCY_BINDINGS } from 'src/currency-bindings';
Expand All @@ -21,8 +21,8 @@ const PositionsView = ({ onClose, onWithdraw }: PositionsViewProps) => {
<tr>
<th className="w-20" />
<th>Asset</th>
<th>Amount</th>
<th>Value</th>
<th>Balance</th>
<th>APY</th>
<th />
</tr>
</thead>
Expand Down Expand Up @@ -53,12 +53,13 @@ interface TableRowProps {
}

const TableRow = ({ receivables, ticker, onWithdraw }: TableRowProps) => {
const { prices } = usePools();
const { prices, pools } = usePools();

if (receivables === 0n) return null;

const { icon, name } = CURRENCY_BINDINGS[ticker];
const price = prices?.[ticker];
const pool = pools?.[ticker];

const handleWithdrawClick = () => onWithdraw(ticker);

Expand All @@ -75,8 +76,11 @@ const TableRow = ({ receivables, ticker, onWithdraw }: TableRowProps) => {
<p className="text-base">{ticker}</p>
</div>
</td>
<td className="text-lg font-semibold">{formatAmount(receivables)}</td>
<td className="text-lg font-semibold">{!isNil(price) && toDollarsFormatted(price, receivables)}</td>
<td>
<p className="text-lg font-semibold leading-5">{formatAmount(receivables)}</p>
<p className="text-base">{!isNil(price) && toDollarsFormatted(price, receivables)}</p>
</td>
<td className="text-lg font-semibold">{pool && formatAPY(pool.apr)}</td>
<td>
<Button onClick={handleWithdrawClick}>Withdraw</Button>
</td>
Expand Down

0 comments on commit 102f6bf

Please sign in to comment.