Skip to content

Commit c41d86d

Browse files
jribbinkclaude
andcommitted
Add flash crash severe simulation
25% BTC crash, same structure as moderate but harder. 10 agents, 60s ticks, rebalance every 5 min, finite pool liquidity. Includes shared infrastructure (test_helpers, evm_state_helpers, transaction). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent b0225ac commit c41d86d

5 files changed

Lines changed: 3727 additions & 37 deletions

File tree

cadence/tests/evm_state_helpers.cdc

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,7 @@ access(all) fun setVaultSharePrice(
2727

2828
/* --- Uniswap V3 Pool State Manipulation --- */
2929

30-
/// Set Uniswap V3 pool to a specific price via EVM.store
31-
/// Creates pool if it doesn't exist, then manipulates state
32-
/// Price is specified as UFix128 for high precision (24 decimal places)
30+
/// Set Uniswap V3 pool to a specific price with infinite liquidity (zero slippage).
3331
access(all) fun setPoolToPrice(
3432
factoryAddress: String,
3533
tokenAAddress: String,
@@ -45,7 +43,37 @@ access(all) fun setPoolToPrice(
4543
code: Test.readFile("transactions/set_uniswap_v3_pool_price.cdc"),
4644
authorizers: [signer.address],
4745
signers: [signer],
48-
arguments: [factoryAddress, tokenAAddress, tokenBAddress, fee, priceTokenBPerTokenA, tokenABalanceSlot, tokenBBalanceSlot]
46+
arguments: [factoryAddress, tokenAAddress, tokenBAddress, fee, priceTokenBPerTokenA, tokenABalanceSlot, tokenBBalanceSlot, 0.0, 0 as Int256, 0.0, 1.0]
47+
)
48+
)
49+
Test.expect(seedResult, Test.beSucceeded())
50+
}
51+
52+
/// Set Uniswap V3 pool to a specific price with finite TVL and concentrated liquidity.
53+
/// tvl: total pool TVL in USD (e.g. 500_000.0)
54+
/// tickRange: ±ticks from current price (e.g. 100 = ±1% for tick_spacing=10)
55+
/// tvlFraction: fraction of TVL placed as liquidity (e.g. 0.95 = 95%)
56+
/// tokenBPriceUSD: USD price of tokenB (1.0 for stablecoins)
57+
access(all) fun setPoolToPriceWithTVL(
58+
factoryAddress: String,
59+
tokenAAddress: String,
60+
tokenBAddress: String,
61+
fee: UInt64,
62+
priceTokenBPerTokenA: UFix128,
63+
tokenABalanceSlot: UInt256,
64+
tokenBBalanceSlot: UInt256,
65+
signer: Test.TestAccount,
66+
tvl: UFix64,
67+
tickRange: Int,
68+
tvlFraction: UFix64,
69+
tokenBPriceUSD: UFix64
70+
) {
71+
let seedResult = Test.executeTransaction(
72+
Test.Transaction(
73+
code: Test.readFile("transactions/set_uniswap_v3_pool_price.cdc"),
74+
authorizers: [signer.address],
75+
signers: [signer],
76+
arguments: [factoryAddress, tokenAAddress, tokenBAddress, fee, priceTokenBPerTokenA, tokenABalanceSlot, tokenBBalanceSlot, tvl, Int256(tickRange), tvlFraction, tokenBPriceUSD]
4977
)
5078
)
5179
Test.expect(seedResult, Test.beSucceeded())

0 commit comments

Comments
 (0)