Skip to content

Commit

Permalink
feat: Add interest in my assets positions calculation (WIP)
Browse files Browse the repository at this point in the history
  • Loading branch information
kovipu committed Dec 8, 2024
1 parent d75a84d commit 26e9664
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions src/components/AssetsModal/PositionsView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand All @@ -77,8 +91,8 @@ const TableRow = ({ receivables, ticker, onWithdraw }: TableRowProps) => {
</div>
</td>
<td>
<p className="text-lg font-semibold leading-5">{formatAmount(receivables)}</p>
<p className="text-base">{!isNil(price) && toDollarsFormatted(price, receivables)}</p>
<p className="text-lg font-semibold leading-5">{formatAmount(shares)}</p>
<p className="text-base">{!isNil(price) && toDollarsFormatted(price, shares)}</p>
</td>
<td className="text-lg font-semibold">{pool && formatAPY(pool.annualInterestRate)}</td>
<td>
Expand Down

0 comments on commit 26e9664

Please sign in to comment.