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:
parent
f3383dce01
commit
ca8e4737fe
4 changed files with 21 additions and 25 deletions
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue