fix: feat: Anvil snapshot/revert and ethPerToken helpers (#519)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
openhands 2026-03-09 01:23:36 +00:00
parent 866474510b
commit e01ef23560

View file

@ -97,7 +97,9 @@ export async function getFloorState(
}
const lmTotalEth = lmEthBalance + lmWethBalance;
const ethPerToken = supply === 0n ? 0n : lmTotalEth / supply;
// Scale by 1e18 (WAD) before dividing so the result is in wei-per-token
// rather than always 0n. Example: 100 ETH / 1M KRK = 1e20 * 1e18 / 1e24 = 1e14 wei/token.
const ethPerToken = supply === 0n ? 0n : (lmTotalEth * 10n ** 18n) / supply;
return { ethPerToken, lmEthBalance, lmWethBalance, outstandingSupply: supply };
}