Forked Rebalance Simulation 3d#172
Conversation
d9f1702 to
eef42c2
Compare
eef42c2 to
6369838
Compare
8009611 to
34e65b4
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
82b2cd4 to
7e17711
Compare
There was a problem hiding this comment.
Any experience locally with inconsistent runs? First run did not trigger rebalance, this happens with scenario 3a and 3b as well. Mainly wondering if these tests could fail in CI.
Output
flow test cadence/tests/forked_rebalance_scenario3d_test.cdc
❗ Version warning: a new version of Flow CLI is available (v2.14.3).
Read the installation guide for upgrade instructions: https://developers.flow.com/tools/flow-cli/install
11:42AM INF Using fork height chainId=flow-mainnet forkBlockID=24806fa16bae3ee6f3852c41ba413319306e2f5620133dd0a0786d228201a712 forkHeight=143292255 host=access.mainnet.nodes.onflow.org:9000
11:42AM INF LOG: "[TEST] Captured Position ID from event: 5"
11:42AM INF LOG: "[TEST] YieldVault ID: 208"
11:42AM INF LOG: "\n=== PRECISION COMPARISON (Initial State) ==="
11:42AM INF LOG: "Expected Yield Tokens: 615.38461539"
11:42AM INF LOG: "Actual Yield Tokens: 615.38461537"
11:42AM INF LOG: "Difference: -0.00000002"
11:42AM INF LOG: ""
11:42AM INF LOG: "Expected Flow Collateral Value: 1000.00000000"
11:42AM INF LOG: "Actual Flow Collateral Value: 1000.00000000"
11:42AM INF LOG: "Difference: -0.00000000"
11:42AM INF LOG: ""
11:42AM INF LOG: "Expected MOET Debt: 615.38461539"
11:42AM INF LOG: "Actual MOET Debt: 615.38461538"
11:42AM INF LOG: "Difference: -0.00000001"
11:42AM INF LOG: "=========================================================\n"
11:42AM INF LOG: "\n=== FLOW PRICE \u{2192} 0.5x ==="
11:42AM INF LOG: "\n=== PRECISION COMPARISON (After Flow Price Decrease) ==="
11:42AM INF LOG: "Expected Yield Tokens: 307.69230769"
11:42AM INF LOG: "Actual Yield Tokens: 615.38461537"
11:42AM INF LOG: "Difference: +307.69230768"
11:42AM INF LOG: ""
11:42AM INF LOG: "Expected Flow Collateral Value: 500.00000000"
11:42AM INF LOG: "Actual Flow Collateral Value: 500.00000000"
11:42AM INF LOG: "Actual Flow Collateral Amount: 1000.00000000 Flow tokens"
11:42AM INF LOG: "Difference: -0.00000000"
11:42AM INF LOG: ""
11:42AM INF LOG: "Expected MOET Debt: 307.69230769"
11:42AM INF LOG: "Actual MOET Debt: 615.38461538"
11:42AM INF LOG: "Difference: +307.69230769"
11:42AM INF LOG: "=========================================================\n"
Test results: "cadence/tests/forked_rebalance_scenario3d_test.cdc"
- FAIL: test_ForkedRebalanceYieldVaultScenario3D
Execution failed:
error: assertion failed: Expected yield tokens after flow price decrease to be 307.69230769 but got 615.38461537
--> cadence/tests/forked_rebalance_scenario3d_test.cdc:281:4
No, I hadn't seen that, but I was able to reproduce.... very strange 🤔, the only things that I can think of that could cause this non-determinism would be randomness or a bug in the testing framework/runtime... EDIT: Thinking about this more, it could be a race condition with timestamps in the testing framework. I.e. the Band Oracle update relies on the current timestamp. If this does not advance between updates, subsequent updates may not be reflected here. |
|
Yeah, Band Oracle was the cause - fixed in 2338365 |
* Recreate scenario 1 using forked testnet. * Remove unused function. * Update for mainnet addresses. * Use mUSDC strategy with real oracles on testnet. * Update symbol prices. * Switch to mainnet. * Add option to transfer flow from whale account instead of minting. * Use fixed mainnet height, new FUSDEV strategy. * Add percent tolerance check to forked test. * Clean up forked scenario 1. * Remove unnecessary imports. * Create forked scenario 2 with placeholder yield token function. * [WIP] Modify EVM storage in forked scen2. Currently fails tolerance. * Add EVM State Manipulation Helpers For Forked Simulations * Clean up. * Prepare for updated strategy. * Fix bugs with decimal offsets & cleanup * tidy comments * Cleanup test helpers & fix precision * Account for fees in pool prices to stay in tolerance. * Update to newer CLI * Create forked scenario 3a, 3b. * address feedback * Add test for EVM state helpers * cleanup test assertion * cleanup test assertion * Fix percent tolerance * Run CI on feature/* branches * Update to new strategy and use new evm helpers. * Clean up. * Add EVM State Manipulation Helpers For Forked Simulations (#173) * Fix band oracle price helper (#188) * Fix merge. * Normalize comments. * Temporarily skip closing of yield vault. * Apply suggestions from code review Co-authored-by: Jordan Ribbink <17958158+jribbink@users.noreply.github.com> * Switch flow.json back to tab spacing. * Fix scenario 2. * Delete unused files. * Improve precision of forked tests * Improve precision of forked tests (#190) * Update scenario 2. * Improve scenario 2 fee accounting and tolerance. * Update forked scen 3a, 3b. * Fix fork height. * Add CI Caching for Forked Mainnet Simulation Tests (#192) * Apply suggestions from code review Co-authored-by: Jordan Ribbink <17958158+jribbink@users.noreply.github.com> * Add Forked Mainnet Simulation Scenario 3C (#169) * Improve final diagnostic precision. * Forked Rebalance Simulation 3d (#172) * Update Flow CLI Install to use Latest Version (#213) * Add forked rebalance scenario 4. (#196) * Add forked rebalance scenarios 4 and 5. * Update forked scenarios to match main. * Update scenarios 4,5. * add boundary test cases * Update fork test block height * Remove unused Test.reset * Restore commented out sections * Apply suggestion from @zhangchiqing Co-authored-by: Leo Zhang <zhangchiqing@gmail.com> * Remove unnecessary yield vault rebalances * Add note about Google Sheet * Update cadence/tests/forked_rebalance_scenario1_test.cdc Co-authored-by: Leo Zhang <zhangchiqing@gmail.com> * add comments and more assertion on forked rebalance tests * add more assertion and comments to forked_rebalance_scenario2_test.cdc --------- Co-authored-by: Raymond Zhang <zhangraymond05@gmail.com> Co-authored-by: Leo Zhang (zhangchiqing) <zhangchiqing@gmail.com>
Closes: #163
Description
Converts scenario 3d to a forked simulation.
Failing test is not related to this PR
https://github.com/onflow/FlowYieldVaults/actions/runs/22596031626/job/65466138035#step:9:1299
Test Output
For contributor use:
masterbranchFiles changedin the Github PR explorer