Skip to content

Recreate scenario 1 using fork testing setup.#128

Draft
RZhang05 wants to merge 34 commits intofeature/forked-simulationsfrom
raymond/forked-scen1
Draft

Recreate scenario 1 using fork testing setup.#128
RZhang05 wants to merge 34 commits intofeature/forked-simulationsfrom
raymond/forked-scen1

Conversation

@RZhang05
Copy link

@RZhang05 RZhang05 commented Jan 8, 2026

Closes: #122

Depends on: #151

Description

Output

flow test cadence/tests/forked_rebalance_scenario1_test.cdc

❗   Version warning: a new version of Flow CLI is available (v2.14.2).
   Read the installation guide for upgrade instructions: https://developers.flow.com/tools/flow-cli/install 

2:56PM INF Using fork height chainId=flow-mainnet forkBlockID=24806fa16bae3ee6f3852c41ba413319306e2f5620133dd0a0786d228201a712 forkHeight=143292255 host=access.mainnet.nodes.onflow.org:9000
2:56PM INF LOG: "[TEST] Captured Position ID from event: 5"
2:56PM INF LOG: "[TEST] YieldVault ID: 208"
2:56PM INF LOG: "[TEST] Initial yield vault balance: 999.83077461"
2:56PM INF LOG: "[TEST] YieldVault balance before flow price 0.50000000 999.83077461"
2:56PM INF LOG: "[TEST] YieldVault balance before flow price 0.50000000 rebalance: 999.66154922"
2:56PM INF LOG: "[TEST] YieldVault balance after flow before 0.50000000: 999.66154644"
2:56PM INF LOG: "\n=== SCENARIO 1 DETAILS for Flow Price 0.50000000 ==="
2:56PM INF LOG: "YieldVault Balance:          999.66154644"
2:56PM INF LOG: "Yield Tokens Before:   615.31170390"
2:56PM INF LOG: "Yield Tokens After:    307.59430990"
2:56PM INF LOG: "Expected Yield Tokens: 307.69230769"
2:56PM INF LOG: "Precision Difference:  -0.09799779"
2:56PM INF LOG: "Percent Difference:    -0.03184900%"
2:56PM INF LOG: "Yield Token Change:    -307.71739400"
2:56PM INF LOG: "Current Value Before:  615.38623045"
2:56PM INF LOG: "Current Value After:   307.63156572"
2:56PM INF LOG: "Value Change:          -307.75466473"
2:56PM INF LOG: "=============================================\n"
2:56PM INF LOG: "[TEST] YieldVault balance before flow price 0.80000000 999.83077461"
2:56PM INF LOG: "[TEST] YieldVault balance before flow price 0.80000000 rebalance: 999.78846826"
2:56PM INF LOG: "[TEST] YieldVault balance after flow before 0.80000000: 999.78846652"
2:56PM INF LOG: "\n=== SCENARIO 1 DETAILS for Flow Price 0.80000000 ==="
2:56PM INF LOG: "YieldVault Balance:          999.78846652"
2:56PM INF LOG: "Yield Tokens Before:   615.31170390"
2:56PM INF LOG: "Yield Tokens After:    492.22474510"
2:56PM INF LOG: "Expected Yield Tokens: 492.30769231"
2:56PM INF LOG: "Precision Difference:  -0.08294721"
2:56PM INF LOG: "Percent Difference:    -0.01684800%"
2:56PM INF LOG: "Yield Token Change:    -123.08695880"
2:56PM INF LOG: "Current Value Before:  615.38623045"
2:56PM INF LOG: "Current Value After:   492.28436336"
2:56PM INF LOG: "Value Change:          -123.10186709"
2:56PM INF LOG: "=============================================\n"
2:56PM INF LOG: "[TEST] YieldVault balance before flow price 1.00000000 999.83077461"
2:56PM INF LOG: "[TEST] YieldVault balance before flow price 1.00000000 rebalance: 999.83077461"
2:56PM INF LOG: "[TEST] YieldVault balance after flow before 1.00000000: 999.83077461"
2:56PM INF LOG: "\n=== SCENARIO 1 DETAILS for Flow Price 1.00000000 ==="
2:56PM INF LOG: "YieldVault Balance:          999.83077461"
2:56PM INF LOG: "Yield Tokens Before:   615.31170390"
2:56PM INF LOG: "Yield Tokens After:    615.31170390"
2:56PM INF LOG: "Expected Yield Tokens: 615.38461538"
2:56PM INF LOG: "Precision Difference:  -0.07291148"
2:56PM INF LOG: "Percent Difference:    -0.01184800%"
2:56PM INF LOG: "Yield Token Change:    -0.00000000"
2:56PM INF LOG: "Current Value Before:  615.38623045"
2:56PM INF LOG: "Current Value After:   615.38623045"
2:56PM INF LOG: "Value Change:          -0.00000000"
2:56PM INF LOG: "=============================================\n"
2:56PM INF LOG: "[TEST] YieldVault balance before flow price 1.20000000 999.83077461"
2:56PM INF LOG: "[TEST] YieldVault balance before flow price 1.20000000 rebalance: 999.85897884"
2:56PM INF LOG: "[TEST] YieldVault balance after flow before 1.20000000: 999.83077471"
2:56PM INF LOG: "\n=== SCENARIO 1 DETAILS for Flow Price 1.20000000 ==="
2:56PM INF LOG: "YieldVault Balance:          999.83077471"
2:56PM INF LOG: "Yield Tokens Before:   615.31170390"
2:56PM INF LOG: "Yield Tokens After:    738.37404468"
2:56PM INF LOG: "Expected Yield Tokens: 738.46153846"
2:56PM INF LOG: "Precision Difference:  -0.08749378"
2:56PM INF LOG: "Percent Difference:    -0.01184800%"
2:56PM INF LOG: "Yield Token Change:    +123.06234078"
2:56PM INF LOG: "Current Value Before:  615.38623045"
2:56PM INF LOG: "Current Value After:   738.46347654"
2:56PM INF LOG: "Value Change:          +123.07724609"
2:56PM INF LOG: "=============================================\n"
2:56PM INF LOG: "[TEST] YieldVault balance before flow price 1.50000000 999.83077461"
2:56PM INF LOG: "[TEST] YieldVault balance before flow price 1.50000000 rebalance: 999.88718307"
2:56PM INF LOG: "[TEST] YieldVault balance after flow before 1.50000000: 999.83077533"
2:56PM INF LOG: "\n=== SCENARIO 1 DETAILS for Flow Price 1.50000000 ==="
2:56PM INF LOG: "YieldVault Balance:          999.83077533"
2:56PM INF LOG: "Yield Tokens Before:   615.31170390"
2:56PM INF LOG: "Yield Tokens After:    922.96755535"
2:56PM INF LOG: "Expected Yield Tokens: 923.07692308"
2:56PM INF LOG: "Precision Difference:  -0.10936773"
2:56PM INF LOG: "Percent Difference:    -0.01184800%"
2:56PM INF LOG: "Yield Token Change:    +307.65585145"
2:56PM INF LOG: "Current Value Before:  615.38623045"
2:56PM INF LOG: "Current Value After:   923.07934518"
2:56PM INF LOG: "Value Change:          +307.69311473"
2:56PM INF LOG: "=============================================\n"
2:56PM INF LOG: "[TEST] YieldVault balance before flow price 2.00000000 999.83077461"
2:56PM INF LOG: "[TEST] YieldVault balance before flow price 2.00000000 rebalance: 999.91538730"
2:56PM INF LOG: "[TEST] YieldVault balance after flow before 2.00000000: 999.83077582"
2:56PM INF LOG: "\n=== SCENARIO 1 DETAILS for Flow Price 2.00000000 ==="
2:56PM INF LOG: "YieldVault Balance:          999.83077582"
2:56PM INF LOG: "Yield Tokens Before:   615.31170390"
2:56PM INF LOG: "Yield Tokens After:    1230.62340780"
2:56PM INF LOG: "Expected Yield Tokens: 1230.76923077"
2:56PM INF LOG: "Precision Difference:  -0.14582297"
2:56PM INF LOG: "Percent Difference:    -0.01184800%"
2:56PM INF LOG: "Yield Token Change:    +615.31170390"
2:56PM INF LOG: "Current Value Before:  615.38623045"
2:56PM INF LOG: "Current Value After:   1230.77246090"
2:56PM INF LOG: "Value Change:          +615.38623045"
2:56PM INF LOG: "=============================================\n"
2:56PM INF LOG: "[TEST] YieldVault balance before flow price 3.00000000 999.83077461"
2:56PM INF LOG: "[TEST] YieldVault balance before flow price 3.00000000 rebalance: 999.94359153"
2:56PM INF LOG: "[TEST] YieldVault balance after flow before 3.00000000: 999.83077702"
2:56PM INF LOG: "\n=== SCENARIO 1 DETAILS for Flow Price 3.00000000 ==="
2:56PM INF LOG: "YieldVault Balance:          999.83077702"
2:56PM INF LOG: "Yield Tokens Before:   615.31170390"
2:56PM INF LOG: "Yield Tokens After:    1845.93511071"
2:56PM INF LOG: "Expected Yield Tokens: 1846.15384615"
2:56PM INF LOG: "Precision Difference:  -0.21873544"
2:56PM INF LOG: "Percent Difference:    -0.01184800%"
2:56PM INF LOG: "Yield Token Change:    +1230.62340681"
2:56PM INF LOG: "Current Value Before:  615.38623045"
2:56PM INF LOG: "Current Value After:   1846.15869037"
2:56PM INF LOG: "Value Change:          +1230.77245992"
2:56PM INF LOG: "=============================================\n"
2:56PM INF LOG: "[TEST] YieldVault balance before flow price 5.00000000 999.83077461"
2:56PM INF LOG: "[TEST] YieldVault balance before flow price 5.00000000 rebalance: 999.96615492"
2:56PM INF LOG: "[TEST] YieldVault balance after flow before 5.00000000: 999.83077697"
2:56PM INF LOG: "\n=== SCENARIO 1 DETAILS for Flow Price 5.00000000 ==="
2:56PM INF LOG: "YieldVault Balance:          999.83077697"
2:56PM INF LOG: "Yield Tokens Before:   615.31170390"
2:56PM INF LOG: "Yield Tokens After:    3076.55851451"
2:56PM INF LOG: "Expected Yield Tokens: 3076.92307692"
2:56PM INF LOG: "Precision Difference:  -0.36456241"
2:56PM INF LOG: "Percent Difference:    -0.01184800%"
2:56PM INF LOG: "Yield Token Change:    +2461.24681061"
2:56PM INF LOG: "Current Value Before:  615.38623045"
2:56PM INF LOG: "Current Value After:   3076.93114727"
2:56PM INF LOG: "Value Change:          +2461.54491682"
2:56PM INF LOG: "=============================================\n"
2:56PM INF LOG: "[TEST] flow balance after 0.00100000"

Test results: "cadence/tests/forked_rebalance_scenario1_test.cdc"
- PASS: test_ForkedRebalanceYieldVaultScenario1


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

@RZhang05 RZhang05 self-assigned this Jan 26, 2026

// Expected values from Google sheet calculations
let expectedYieldTokenValues: {UFix64: UFix64} = {
0.5: 307.69230769,
Copy link
Contributor

@liobrasil liobrasil Jan 27, 2026

Choose a reason for hiding this comment

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

The expectedYieldTokenValues are the debt notional (at target health factor) in the unit of account i.e MOET/USD: expectedYieldTokenValue = expectedDebt = fundingAmount * flowPrice * collateralFactor / targetHealthFactor. It doesn't not account for the fees associated with swapping (nor price impact) MOET to yieldToken on the DEX when we create the yieldVault (ie. yieldToMoetSwapper in the createStrategy), as a consequence: expectedYieldTokenValue < expectedDebt.The bridge fees are in FLOW and covered by the protocol.

@RZhang05 RZhang05 changed the base branch from main to feature/forked-simulations February 24, 2026 16:39
@RZhang05 RZhang05 changed the base branch from feature/forked-simulations to jribbink/evm-test-helpers February 24, 2026 18:55
@RZhang05 RZhang05 force-pushed the raymond/forked-scen1 branch from 1b21dd0 to e7a6683 Compare February 24, 2026 19:01
Base automatically changed from jribbink/evm-test-helpers to feature/forked-simulations February 25, 2026 18:00
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 Scenario 1 with Forked Testing Setup.

3 participants