fix: Fix collapse component formatting: taxPaid display, string coercion, BigInt precision (#260)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
openhands 2026-02-25 08:06:49 +00:00
parent f3383dce01
commit ca8e4737fe
4 changed files with 21 additions and 25 deletions

View file

@ -5,6 +5,8 @@
* This aligns with the Harberger tax economic model where stakers earn from protocol growth.
*/
import { formatUnits } from 'viem';
/**
* Calculate profit for an active position.
*
@ -31,8 +33,8 @@ export function calculateActivePositionProfit(totalSupplyInit: bigint, currentTo
}
// Convert to token units (assuming 18 decimals)
const initSupply = Number(totalSupplyInit) / 1e18;
const currentSupply = Number(currentTotalSupply) / 1e18;
const initSupply = Number(formatUnits(totalSupplyInit, 18));
const currentSupply = Number(formatUnits(currentTotalSupply, 18));
// Calculate new issuance since position creation
const newIssuance = currentSupply - initSupply;
@ -67,8 +69,8 @@ export function calculateClosedPositionProfit(totalSupplyInit: bigint, totalSupp
}
// Convert to token units (assuming 18 decimals)
const initSupply = Number(totalSupplyInit) / 1e18;
const endSupply = Number(totalSupplyEnd) / 1e18;
const initSupply = Number(formatUnits(totalSupplyInit, 18));
const endSupply = Number(formatUnits(totalSupplyEnd, 18));
// Calculate new issuance during position lifetime
const newIssuance = endSupply - initSupply;