erc_4626.vault_protocol.gains.testing

Documentation for eth_defi.erc_4626.vault_protocol.gains.testing Python module.

Gains vault testing helpers.

Includes Anvil-based simulation helpers for testing the Ostium V1.5 async deposit/settlement/claim/withdraw cycle without real funds.

See also scripts/erc-4626/ostium-v15.py for the CLI script that uses these helpers in SIMULATE=true mode.

Functions

force_next_gains_epoch(vault, any_account[, ...])

Advance Gains vault to a next epoch by using Anvil hacks.

force_ostium_v15_settlement(vault, any_account)

Force a settlement on Ostium V1.5 by advancing Anvil time and calling tryNewSettlement().

setup_ostium_simulation(json_rpc_url[, ...])

Set up an Anvil fork environment for Ostium V1.5 simulation.

simulate_ostium_v15_cycle(web3, hot_wallet, ...)

Simulate a full Ostium V1.5 deposit/settlement/claim/withdraw cycle on Anvil.

Classes

OstiumSimulationResult

Result of a simulated Ostium V1.5 deposit/withdrawal cycle.

class OstiumSimulationResult

Bases: object

Result of a simulated Ostium V1.5 deposit/withdrawal cycle.

__init__(deposit_amount, shares_received, share_price, usdc_withdrawn, settlements_forced)
Parameters
Return type

None

force_next_gains_epoch(vault, any_account, padding_seconds=1, gas_limit=3000000)

Advance Gains vault to a next epoch by using Anvil hacks.

Parameters
force_ostium_v15_settlement(vault, any_account, padding_seconds=1, gas_limit=3000000)

Force a settlement on Ostium V1.5 by advancing Anvil time and calling tryNewSettlement().

tryNewSettlement() is public and permissionless — it executes when block.timestamp >= lastSettlementTs + maxSettlementInterval.

Parameters
setup_ostium_simulation(json_rpc_url, vault_address='0x20d419a8e12c45f88fda7c5760bb6923cee27f98', fund_amount=Decimal('100'))

Set up an Anvil fork environment for Ostium V1.5 simulation.

Creates an Anvil fork of Arbitrum, a funded test wallet, and an Ostium vault instance.

Parameters
  • json_rpc_url (str) – Arbitrum RPC URL to fork from.

  • vault_address (str) – Ostium vault address.

  • fund_amount (decimal.Decimal) – USDC amount to fund the test wallet with.

Returns

Tuple of (web3, hot_wallet, anvil_launch, vault).

Return type

tuple[web3.main.Web3, ‘HotWallet’, ‘AnvilLaunch’, ‘OstiumVault’]

simulate_ostium_v15_cycle(web3, hot_wallet, vault, deposit_amount=Decimal('50'))

Simulate a full Ostium V1.5 deposit/settlement/claim/withdraw cycle on Anvil.

Runs the complete async lifecycle:

  1. Approve USDC to vault

  2. Call requestDeposit(amount)

  3. Force settlement via tryNewSettlement()

  4. Claim deposit via claimDeposit(settlementId)

  5. Verify OLP shares received

  6. Call requestWithdraw(shares)

  7. Force settlement(s) for withdrawal

  8. Claim withdrawal via claimWithdraw(settlementId)

  9. Verify USDC returned

Parameters
  • web3 (web3.main.Web3) – Web3 connected to an Anvil fork.

  • hot_wallet (HotWallet) – Funded test wallet.

  • vault (OstiumVault) – Ostium V1.5 vault instance.

  • deposit_amount (decimal.Decimal) – USDC amount to deposit.

Returns

Simulation result with amounts and prices.

Return type

eth_defi.erc_4626.vault_protocol.gains.testing.OstiumSimulationResult