From 08796b58774dbba3f6e9e38b90c46b2b03ede75a Mon Sep 17 00:00:00 2001 From: Konsta Purtsi Date: Sun, 8 Dec 2024 17:41:17 +0200 Subject: [PATCH] feat: Add interest in my assets positions calculation (WIP) --- src/components/AssetsModal/PositionsView.tsx | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/components/AssetsModal/PositionsView.tsx b/src/components/AssetsModal/PositionsView.tsx index 05d2fd7..fe3ae1a 100644 --- a/src/components/AssetsModal/PositionsView.tsx +++ b/src/components/AssetsModal/PositionsView.tsx @@ -55,12 +55,26 @@ interface TableRowProps { const TableRow = ({ receivables, ticker, onWithdraw }: TableRowProps) => { const { prices, pools } = usePools(); + /* Pointti on siis se et receivablesiin ei lisätä korkoa. + * Korko lisätään vaan total balanceen. + * Ni sit jos käyttäjä on deponnu 100 ja sil on 100 sharea. + * Jos hän on ainut käyttäjä ja poolis totalsharet on silloin myös 100, + * mut total balance on noussu koron takia 120 niin käyttäjä saa 100/100*120=120 */ + if (receivables === 0n) return null; const { icon, name } = CURRENCY_BINDINGS[ticker]; const price = prices?.[ticker]; const pool = pools?.[ticker]; + if (!pool) { + console.warn('PoolState is not loaded'); + return null; + } + + // FIXME: Doesn't add interest + const shares = (receivables * pool.totalShares) / pool.totalBalance; + const handleWithdrawClick = () => onWithdraw(ticker); return ( @@ -77,8 +91,8 @@ const TableRow = ({ receivables, ticker, onWithdraw }: TableRowProps) => { -

{formatAmount(receivables)}

-

{!isNil(price) && toDollarsFormatted(price, receivables)}

+

{formatAmount(shares)}

+

{!isNil(price) && toDollarsFormatted(price, shares)}

{pool && formatAPY(pool.annualInterestRate)}