compute_event_share_prices
Documentation for eth_defi.hyperliquid.trade_history.compute_event_share_prices function.
- compute_event_share_prices(fills, funding_payments, ledger_events, initial_total_assets=0.0)
Compute event-accurate share prices from actual ledger events.
Unlike the portfolio-history-derived share prices (which suffer from resolution artefacts — see
README-hyperliquid-vault-limitations.md), this function uses actual event data:Deposits: Exact amounts from
userNonFundingLedgerUpdatesWithdrawals: Exact amounts from
userNonFundingLedgerUpdatesTrading PnL: Realised PnL from individual fills (
closed_pnl)Funding payments: USD amounts from
userFunding
This eliminates the resolution-dependent netflow derivation that causes share price spikes in the current pipeline.
The share price model follows ERC-4626 mechanics:
share_price = total_assets / total_supplyDeposits mint shares:
shares_minted = deposit_amount / share_priceWithdrawals burn shares:
shares_burned = withdrawal_amount / share_pricePnL and funding change
total_assetsbut nottotal_supplyShare price starts at 1.00 at first deposit
- Parameters
fills (list[eth_defi.hyperliquid.position.Fill]) – List of fills sorted chronologically.
funding_payments (list[eth_defi.hyperliquid.trade_history.FundingPayment]) – List of funding payments sorted chronologically.
ledger_events (list) – List of VaultDepositEvent objects sorted chronologically. Import from
eth_defi.hyperliquid.deposit.initial_total_assets (float) – Starting total assets (usually 0 for a new vault).
- Returns
List of SharePriceEvent objects in chronological order.
- Return type