Skip to content

Forked Rebalance Simulation 3d#172

Merged
jribbink merged 4 commits intofeature/forked-simulationsfrom
jribbink/fork-scenario-3d
Mar 3, 2026
Merged

Forked Rebalance Simulation 3d#172
jribbink merged 4 commits intofeature/forked-simulationsfrom
jribbink/fork-scenario-3d

Conversation

@jribbink
Copy link

@jribbink jribbink commented Feb 13, 2026

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
10:44AM INF Using fork height chainId=flow-mainnet forkBlockID=24806fa16bae3ee6f3852c41ba413319306e2f5620133dd0a0786d228201a712 forkHeight=143292255 host=access.mainnet.nodes.onflow.org:9000
10:44AM INF LOG: "[TEST] Captured Position ID from event: 5"
10:44AM INF LOG: "[TEST] YieldVault ID: 208"
10:44AM INF LOG: "\n=== PRECISION COMPARISON (Initial State) ==="
10:44AM INF LOG: "Expected Yield Tokens: 615.38461539"
10:44AM INF LOG: "Actual Yield Tokens:   615.38461537"
10:44AM INF LOG: "Difference:            -0.00000002"
10:44AM INF LOG: ""
10:44AM INF LOG: "Expected Flow Collateral Value: 1000.00000000"
10:44AM INF LOG: "Actual Flow Collateral Value:   1000.00000000"
10:44AM INF LOG: "Difference:                     -0.00000000"
10:44AM INF LOG: ""
10:44AM INF LOG: "Expected MOET Debt: 615.38461539"
10:44AM INF LOG: "Actual MOET Debt:   615.38461538"
10:44AM INF LOG: "Difference:         -0.00000001"
10:44AM INF LOG: "=========================================================\n"
10:44AM INF LOG: "\n=== FLOW PRICE \u{2192} 0.5x ==="
10:44AM INF LOG: "\n=== PRECISION COMPARISON (After Flow Price Decrease) ==="
10:44AM INF LOG: "Expected Yield Tokens: 307.69230769"
10:44AM INF LOG: "Actual Yield Tokens:   307.69230767"
10:44AM INF LOG: "Difference:            -0.00000002"
10:44AM INF LOG: ""
10:44AM INF LOG: "Expected Flow Collateral Value: 500.00000000"
10:44AM INF LOG: "Actual Flow Collateral Value:   500.00000000"
10:44AM INF LOG: "Actual Flow Collateral Amount:  1000.00000000 Flow tokens"
10:44AM INF LOG: "Difference:                     -0.00000000"
10:44AM INF LOG: ""
10:44AM INF LOG: "Expected MOET Debt: 307.69230769"
10:44AM INF LOG: "Actual MOET Debt:   307.69230769"
10:44AM INF LOG: "Difference:         -0.00000000"
10:44AM INF LOG: "=========================================================\n"
10:44AM INF LOG: "\n=== YIELD VAULT PRICE \u{2192} 1.5x ==="
10:44AM INF LOG: "\n=== PRECISION COMPARISON (After Yield Price Increase) ==="
10:44AM INF LOG: "Expected Yield Tokens: 268.24457594"
10:44AM INF LOG: "Actual Yield Tokens:   268.24457535"
10:44AM INF LOG: "Difference:            -0.00000059"
10:44AM INF LOG: ""
10:44AM INF LOG: "Expected Flow Collateral Value: 653.84615385"
10:44AM INF LOG: "Actual Flow Collateral Value:   653.84615245"
10:44AM INF LOG: "Actual Flow Collateral Amount:  1307.69230491 Flow tokens"
10:44AM INF LOG: "Difference:                     -0.00000140"
10:44AM INF LOG: ""
10:44AM INF LOG: "Expected MOET Debt: 402.36686391"
10:44AM INF LOG: "Actual MOET Debt:   402.36686304"
10:44AM INF LOG: "Difference:         -0.00000087"
10:44AM INF LOG: "=========================================================\n"
10:44AM INF LOG: "\n=== TEST COMPLETE ==="
______

For contributor use:

  • Targeted PR against master branch
  • Linked to Github issue with discussion and accepted design OR link to spec that describes this work.
  • Code follows the standards mentioned here.
  • Updated relevant documentation
  • Re-reviewed Files changed in the Github PR explorer
  • Added appropriate labels

@jribbink jribbink force-pushed the jribbink/fork-scenario-3d branch from d9f1702 to eef42c2 Compare February 24, 2026 16:40
@jribbink jribbink changed the base branch from jribbink/fork-scenario-3c to jribbink/evm-test-helpers February 24, 2026 16:40
@jribbink jribbink force-pushed the jribbink/fork-scenario-3d branch from eef42c2 to 6369838 Compare February 24, 2026 16:50
Base automatically changed from jribbink/evm-test-helpers to feature/forked-simulations February 25, 2026 18:00
@jribbink jribbink force-pushed the jribbink/fork-scenario-3d branch from 8009611 to 34e65b4 Compare February 25, 2026 18:06
@jribbink jribbink linked an issue Feb 25, 2026 that may be closed by this pull request
@codecov
Copy link

codecov bot commented Feb 25, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@jribbink jribbink force-pushed the jribbink/fork-scenario-3d branch from 82b2cd4 to 7e17711 Compare March 2, 2026 18:50
@jribbink jribbink changed the title [WIP] Forked Rebalance Simulation 3d Forked Rebalance Simulation 3d Mar 2, 2026
@jribbink jribbink marked this pull request as ready for review March 2, 2026 19:06
@jribbink jribbink requested a review from a team as a code owner March 2, 2026 19:06
@jribbink jribbink requested a review from RZhang05 March 2, 2026 21:56
Copy link

@RZhang05 RZhang05 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@jribbink
Copy link
Author

jribbink commented Mar 3, 2026

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

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.

@jribbink
Copy link
Author

jribbink commented Mar 3, 2026

Yeah, Band Oracle was the cause - fixed in 2338365

@jribbink jribbink merged commit 734e435 into feature/forked-simulations Mar 3, 2026
2 of 5 checks passed
@jribbink jribbink deleted the jribbink/fork-scenario-3d branch March 3, 2026 19:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Recreate Simulation Scenario 3d With Fork Testing Setup

2 participants