Skip to content

Improve precision of forked tests#190

Merged
jribbink merged 1 commit intofeature/forked-simulationsfrom
jribbink/forked-precision-improvements
Feb 27, 2026
Merged

Improve precision of forked tests#190
jribbink merged 1 commit intofeature/forked-simulationsfrom
jribbink/forked-precision-improvements

Conversation

@jribbink
Copy link

@jribbink jribbink commented Feb 27, 2026

Closes #193

Description

Significantly improves precision in forked tests by significantly increasing liquidity in EVM state helpers & removing tick-rounding from the Uniswap V3 state manipulation helper. EVM state manipulation is now able to set prices with only minor UFix64 rounding losses (i.e.0.00000001) for reasonably sized amounts.

Improved Scenario #1 Final Output

12:24PM INF LOG: "[TEST] Captured Position ID from event: 5"
12:24PM INF LOG: "[TEST] YieldVault ID: 208"
12:24PM INF LOG: "[TEST] Initial yield vault balance: 999.83077766"
12:24PM INF LOG: "[TEST] YieldVault balance before flow price 0.50000000 999.83077766"
12:24PM INF LOG: "[TEST] YieldVault balance before flow price 0.50000000 rebalance: 999.99999994"
12:24PM INF LOG: "[TEST] YieldVault balance after flow before 0.50000000: 999.99999991"
12:24PM INF LOG: "\n=== SCENARIO 1 DETAILS for Flow Price 0.50000000 ==="
12:24PM INF LOG: "YieldVault Balance:          999.99999991"
12:24PM INF LOG: "Yield Tokens Before:   615.38461537"
12:24PM INF LOG: "Yield Tokens After:    307.69230767"
12:24PM INF LOG: "Expected Yield Tokens: 307.69230769"
12:24PM INF LOG: "Precision Difference:  -0.00000002"
12:24PM INF LOG: "Percent Difference:    -0.00000000%"
12:24PM INF LOG: "Yield Token Change:    -307.69230770"
12:24PM INF LOG: "Current Value Before:  615.38461537"
12:24PM INF LOG: "Current Value After:   307.69230767"
12:24PM INF LOG: "Value Change:          -307.69230770"
12:24PM INF LOG: "=============================================\n"
12:24PM INF LOG: "[TEST] YieldVault balance before flow price 0.80000000 999.83077766"
12:24PM INF LOG: "[TEST] YieldVault balance before flow price 0.80000000 rebalance: 999.99999996"
12:24PM INF LOG: "[TEST] YieldVault balance after flow before 0.80000000: 999.99999994"
12:24PM INF LOG: "\n=== SCENARIO 1 DETAILS for Flow Price 0.80000000 ==="
12:24PM INF LOG: "YieldVault Balance:          999.99999994"
12:24PM INF LOG: "Yield Tokens Before:   615.38461537"
12:24PM INF LOG: "Yield Tokens After:    492.30769228"
12:24PM INF LOG: "Expected Yield Tokens: 492.30769231"
12:24PM INF LOG: "Precision Difference:  -0.00000003"
12:24PM INF LOG: "Percent Difference:    -0.00000000%"
12:24PM INF LOG: "Yield Token Change:    -123.07692309"
12:24PM INF LOG: "Current Value Before:  615.38461537"
12:24PM INF LOG: "Current Value After:   492.30769228"
12:24PM INF LOG: "Value Change:          -123.07692309"
12:24PM INF LOG: "=============================================\n"
12:24PM INF LOG: "[TEST] YieldVault balance before flow price 1.00000000 999.83077766"
12:24PM INF LOG: "[TEST] YieldVault balance before flow price 1.00000000 rebalance: 999.83077766"
12:24PM INF LOG: "[TEST] YieldVault balance after flow before 1.00000000: 999.83077766"
12:24PM INF LOG: "\n=== SCENARIO 1 DETAILS for Flow Price 1.00000000 ==="
12:24PM INF LOG: "YieldVault Balance:          999.83077766"
12:24PM INF LOG: "Yield Tokens Before:   615.38461537"
12:24PM INF LOG: "Yield Tokens After:    615.38461537"
12:24PM INF LOG: "Expected Yield Tokens: 615.38461538"
12:24PM INF LOG: "Precision Difference:  -0.00000001"
12:24PM INF LOG: "Percent Difference:    -0.00000000%"
12:24PM INF LOG: "Yield Token Change:    -0.00000000"
12:24PM INF LOG: "Current Value Before:  615.38461537"
12:24PM INF LOG: "Current Value After:   615.38461537"
12:24PM INF LOG: "Value Change:          -0.00000000"
12:24PM INF LOG: "=============================================\n"
12:24PM INF LOG: "[TEST] YieldVault balance before flow price 1.20000000 999.83077766"
12:24PM INF LOG: "[TEST] YieldVault balance before flow price 1.20000000 rebalance: 999.85898138"
12:24PM INF LOG: "[TEST] YieldVault balance after flow before 1.20000000: 999.83077766"
12:24PM INF LOG: "\n=== SCENARIO 1 DETAILS for Flow Price 1.20000000 ==="
12:24PM INF LOG: "YieldVault Balance:          999.83077766"
12:24PM INF LOG: "Yield Tokens Before:   615.38461537"
12:24PM INF LOG: "Yield Tokens After:    738.46153844"
12:24PM INF LOG: "Expected Yield Tokens: 738.46153846"
12:24PM INF LOG: "Precision Difference:  -0.00000002"
12:24PM INF LOG: "Percent Difference:    -0.00000000%"
12:24PM INF LOG: "Yield Token Change:    +123.07692307"
12:24PM INF LOG: "Current Value Before:  615.38461537"
12:24PM INF LOG: "Current Value After:   738.46153844"
12:24PM INF LOG: "Value Change:          +123.07692307"
12:24PM INF LOG: "=============================================\n"
12:24PM INF LOG: "[TEST] YieldVault balance before flow price 1.50000000 999.83077766"
12:24PM INF LOG: "[TEST] YieldVault balance before flow price 1.50000000 rebalance: 999.88718510"
12:24PM INF LOG: "[TEST] YieldVault balance after flow before 1.50000000: 999.83077766"
12:24PM INF LOG: "\n=== SCENARIO 1 DETAILS for Flow Price 1.50000000 ==="
12:24PM INF LOG: "YieldVault Balance:          999.83077766"
12:24PM INF LOG: "Yield Tokens Before:   615.38461537"
12:24PM INF LOG: "Yield Tokens After:    923.07692305"
12:24PM INF LOG: "Expected Yield Tokens: 923.07692308"
12:24PM INF LOG: "Precision Difference:  -0.00000003"
12:24PM INF LOG: "Percent Difference:    -0.00000000%"
12:24PM INF LOG: "Yield Token Change:    +307.69230768"
12:24PM INF LOG: "Current Value Before:  615.38461537"
12:24PM INF LOG: "Current Value After:   923.07692305"
12:24PM INF LOG: "Value Change:          +307.69230768"
12:24PM INF LOG: "=============================================\n"
12:24PM INF LOG: "[TEST] YieldVault balance before flow price 2.00000000 999.83077766"
12:24PM INF LOG: "[TEST] YieldVault balance before flow price 2.00000000 rebalance: 999.91538883"
12:24PM INF LOG: "[TEST] YieldVault balance after flow before 2.00000000: 999.83077767"
12:24PM INF LOG: "\n=== SCENARIO 1 DETAILS for Flow Price 2.00000000 ==="
12:24PM INF LOG: "YieldVault Balance:          999.83077767"
12:24PM INF LOG: "Yield Tokens Before:   615.38461537"
12:24PM INF LOG: "Yield Tokens After:    1230.76923074"
12:24PM INF LOG: "Expected Yield Tokens: 1230.76923077"
12:24PM INF LOG: "Precision Difference:  -0.00000003"
12:24PM INF LOG: "Percent Difference:    -0.00000000%"
12:24PM INF LOG: "Yield Token Change:    +615.38461537"
12:24PM INF LOG: "Current Value Before:  615.38461537"
12:24PM INF LOG: "Current Value After:   1230.76923074"
12:24PM INF LOG: "Value Change:          +615.38461537"
12:24PM INF LOG: "=============================================\n"
12:24PM INF LOG: "[TEST] YieldVault balance before flow price 3.00000000 999.83077766"
12:24PM INF LOG: "[TEST] YieldVault balance before flow price 3.00000000 rebalance: 999.94359255"
12:24PM INF LOG: "[TEST] YieldVault balance after flow before 3.00000000: 999.83077767"
12:24PM INF LOG: "\n=== SCENARIO 1 DETAILS for Flow Price 3.00000000 ==="
12:24PM INF LOG: "YieldVault Balance:          999.83077767"
12:24PM INF LOG: "Yield Tokens Before:   615.38461537"
12:24PM INF LOG: "Yield Tokens After:    1846.15384613"
12:24PM INF LOG: "Expected Yield Tokens: 1846.15384615"
12:24PM INF LOG: "Precision Difference:  -0.00000002"
12:24PM INF LOG: "Percent Difference:    -0.00000000%"
12:24PM INF LOG: "Yield Token Change:    +1230.76923076"
12:24PM INF LOG: "Current Value Before:  615.38461537"
12:24PM INF LOG: "Current Value After:   1846.15384613"
12:24PM INF LOG: "Value Change:          +1230.76923076"
12:24PM INF LOG: "=============================================\n"
12:24PM INF LOG: "[TEST] YieldVault balance before flow price 5.00000000 999.83077766"
12:24PM INF LOG: "[TEST] YieldVault balance before flow price 5.00000000 rebalance: 999.96615553"
12:24PM INF LOG: "[TEST] YieldVault balance after flow before 5.00000000: 999.83077768"
12:24PM INF LOG: "\n=== SCENARIO 1 DETAILS for Flow Price 5.00000000 ==="
12:24PM INF LOG: "YieldVault Balance:          999.83077768"
12:24PM INF LOG: "Yield Tokens Before:   615.38461537"
12:24PM INF LOG: "Yield Tokens After:    3076.92307690"
12:24PM INF LOG: "Expected Yield Tokens: 3076.92307692"
12:24PM INF LOG: "Precision Difference:  -0.00000002"
12:24PM INF LOG: "Percent Difference:    -0.00000000%"
12:24PM INF LOG: "Yield Token Change:    +2461.53846153"
12:24PM INF LOG: "Current Value Before:  615.38461537"
12:24PM INF LOG: "Current Value After:   3076.92307690"
12:24PM INF LOG: "Value Change:          +2461.53846153"
12:24PM INF LOG: "=============================================\n"
12:24PM INF LOG: "[TEST] flow balance after 0.00100000"

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 requested a review from RZhang05 February 27, 2026 17:00
@jribbink jribbink requested a review from a team as a code owner February 27, 2026 17:00
@jribbink jribbink force-pushed the jribbink/forked-precision-improvements branch 2 times, most recently from 5c555ef to accbdf1 Compare February 27, 2026 17:05
@jribbink jribbink marked this pull request as draft February 27, 2026 17:16
@jribbink jribbink force-pushed the jribbink/forked-precision-improvements branch 4 times, most recently from dd4cdc0 to 37e2f75 Compare February 27, 2026 20:34
@jribbink jribbink force-pushed the jribbink/forked-precision-improvements branch from 37e2f75 to 7a1c8f8 Compare February 27, 2026 21:01
@jribbink jribbink marked this pull request as ready for review February 27, 2026 21:01
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.

👏

@jribbink jribbink merged commit 8ef7d24 into feature/forked-simulations Feb 27, 2026
5 checks passed
@jribbink jribbink deleted the jribbink/forked-precision-improvements branch February 27, 2026 21:29
@jribbink jribbink linked an issue Feb 27, 2026 that may be closed by this pull request
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.

Improve precision on forked mainnet EVM state manipulations

2 participants