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
|
Advance Gains vault to a next epoch by using Anvil hacks. |
|
Force a settlement on Ostium V1.5 by advancing Anvil time and calling |
|
Set up an Anvil fork environment for Ostium V1.5 simulation. |
|
Simulate a full Ostium V1.5 deposit/settlement/claim/withdraw cycle on Anvil. |
Classes
Result of a simulated Ostium V1.5 deposit/withdrawal cycle. |
- class OstiumSimulationResult
Bases:
objectResult of a simulated Ostium V1.5 deposit/withdrawal cycle.
- __init__(deposit_amount, shares_received, share_price, usdc_withdrawn, settlements_forced)
- Parameters
deposit_amount (decimal.Decimal) –
shares_received (decimal.Decimal) –
share_price (decimal.Decimal) –
usdc_withdrawn (decimal.Decimal) –
settlements_forced (int) –
- 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
any_account (eth_typing.evm.HexAddress) – Burn gas
vault (eth_defi.erc_4626.vault_protocol.gains.vault.GainsVault) –
padding_seconds (int) –
- 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 whenblock.timestamp >= lastSettlementTs + maxSettlementInterval.- Parameters
vault (eth_defi.erc_4626.vault_protocol.gains.vault.OstiumVault) – Ostium V1.5 vault instance.
any_account (eth_typing.evm.HexAddress) – Any account to pay gas for the transaction.
padding_seconds (int) – Extra seconds past the settlement threshold.
gas_limit (int) –
- 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:
Approve USDC to vault
Call
requestDeposit(amount)Force settlement via
tryNewSettlement()Claim deposit via
claimDeposit(settlementId)Verify OLP shares received
Call
requestWithdraw(shares)Force settlement(s) for withdrawal
Claim withdrawal via
claimWithdraw(settlementId)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