11// Simulation spreadsheet: https://docs.google.com/spreadsheets/d/11DCzwZjz5K-78aKEWxt9NI-ut5LtkSyOT0TnRPUG7qY/edit?pli=1&gid=539924856#gid=539924856
22
3- #test_fork (network : " mainnet-fork" , height : 143292255 )
3+ #test_fork (network : " mainnet-fork" , height : 147316310 )
44
55import Test
66import BlockchainHelpers
@@ -12,7 +12,6 @@ import "evm_state_helpers.cdc"
1212import " FlowYieldVaults"
1313// other
1414import " FlowToken"
15- import " MOET"
1615import " FlowYieldVaultsStrategiesV2"
1716import " FlowALPv0"
1817
@@ -28,7 +27,6 @@ access(all) let coaOwnerAccount = Test.getAccount(0xe467b9dd11fa00df)
2827
2928access (all ) var strategyIdentifier = Type <@FlowYieldVaultsStrategiesV2.FUSDEVStrategy >().identifier
3029access (all ) var flowTokenIdentifier = Type <@FlowToken.Vault >().identifier
31- access (all ) var moetTokenIdentifier = Type <@MOET.Vault >().identifier
3230
3331// ============================================================================
3432// PROTOCOL ADDRESSES
@@ -48,9 +46,6 @@ access(all) let morphoVaultAddress = "0xd069d989e2F44B70c65347d1853C0c67e10a9F8D
4846// PYUSD0 - Stablecoin (FUSDEV's underlying asset)
4947access (all ) let pyusd0Address = " 0x99aF3EeA856556646C98c8B9b2548Fe815240750"
5048
51- // MOET - Flow ALP USD
52- access (all ) let moetAddress = " 0x213979bB8A9A86966999b3AA797C1fcf3B967ae2"
53-
5449// WFLOW - Wrapped Flow
5550access (all ) let wflowAddress = " 0xd3bF53DAC106A0290B0483EcBC89d40FcC961f3e"
5651
@@ -59,7 +54,6 @@ access(all) let wflowAddress = "0xd3bF53DAC106A0290B0483EcBC89d40FcC961f3e"
5954// ============================================================================
6055
6156// Token balanceOf mapping slots (for EVM.store to manipulate balances)
62- access (all ) let moetBalanceSlot = 0 as UInt256
6357access (all ) let pyusd0BalanceSlot = 1 as UInt256
6458access (all ) let fusdevBalanceSlot = 12 as UInt256
6559access (all ) let wflowBalanceSlot = 3 as UInt256
@@ -98,38 +92,16 @@ fun setup() {
9892 signer : coaOwnerAccount
9993 )
10094
101- setPoolToPrice (
102- factoryAddress : factoryAddress ,
103- tokenAAddress : moetAddress ,
104- tokenBAddress : morphoVaultAddress ,
105- fee : 100 ,
106- priceTokenBPerTokenA : feeAdjustedPrice (1.0 , fee : 100 , reverse : false ),
107- tokenABalanceSlot : moetBalanceSlot ,
108- tokenBBalanceSlot : fusdevBalanceSlot ,
109- signer : coaOwnerAccount
110- )
111-
112- setPoolToPrice (
113- factoryAddress : factoryAddress ,
114- tokenAAddress : moetAddress ,
115- tokenBAddress : pyusd0Address ,
116- fee : 100 ,
117- priceTokenBPerTokenA : feeAdjustedPrice (1.0 , fee : 100 , reverse : false ),
118- tokenABalanceSlot : moetBalanceSlot ,
119- tokenBBalanceSlot : pyusd0BalanceSlot ,
120- signer : coaOwnerAccount
121- )
122-
123- // BandOracle is only used for FLOW price for FlowALP collateral
95+ // BandOracle prices: FLOW for collateral, PYUSD for PYUSD0 debt token, USD for quote
12496 let symbolPrices : {String : UFix64 } = {
12597 " FLOW" : 1.0 ,
126- " USD" : 1.0
98+ " USD" : 1.0 ,
99+ " PYUSD" : 1.0
127100 }
128101 setBandOraclePrices (signer : bandOracleAccount , symbolPrices : symbolPrices )
129102
130103 let reserveAmount = 100_000_00.0
131104 transferFlow (signer : whaleFlowAccount , recipient : flowALPAccount .address , amount : reserveAmount )
132- mintMoet (signer : flowALPAccount , to : flowALPAccount .address , amount : reserveAmount , beFailed : false )
133105
134106 // Fund FlowYieldVaults account for scheduling fees (atomic initial scheduling)
135107 transferFlow (signer : whaleFlowAccount , recipient : flowYieldVaultsAccount .address , amount : 100.0 )
@@ -147,7 +119,7 @@ fun test_ForkedRebalanceYieldVaultScenario1() {
147119 // SCENARIO 1: FLOW price changes, Position rebalances to maintain Health = 1.3
148120 // ===================================================================================
149121 //
150- // Initial: Collateral=1000 FLOW, Debt=$ 615.38, YIELD=615.38, Health=1.3
122+ // Initial: Collateral=1000 FLOW, Debt=615.38 PYUSD0 , YIELD=615.38 FUSDEV , Health=1.3
151123 // Health = (1000 × FLOW_Price × 0.8) / 615.38
152124 //
153125 // Thresholds: minHealth=1.1, targetHealth=1.3, maxHealth=1.5
@@ -217,6 +189,9 @@ fun test_ForkedRebalanceYieldVaultScenario1() {
217189 signer : user
218190 )
219191
192+ // Refresh oracle prices to avoid stale timestamp (time advances between setup and here)
193+ setBandOraclePrices (signer : bandOracleAccount , symbolPrices : { " FLOW" : 1.0 , " USD" : 1.0 , " PYUSD" : 1.0 })
194+
220195 createYieldVault (
221196 signer : user ,
222197 strategyIdentifier : strategyIdentifier ,
@@ -253,7 +228,8 @@ fun test_ForkedRebalanceYieldVaultScenario1() {
253228 // === FLOW PRICE CHANGES ===
254229 setBandOraclePrices (signer : bandOracleAccount , symbolPrices : {
255230 " FLOW" : flowPrice ,
256- " USD" : 1.0
231+ " USD" : 1.0 ,
232+ " PYUSD" : 1.0
257233 })
258234
259235 // Update WFLOW/PYUSD0 pool to match new Flow price
@@ -270,16 +246,16 @@ fun test_ForkedRebalanceYieldVaultScenario1() {
270246 signer : coaOwnerAccount
271247 )
272248
273- // MOET /FUSDEV pool: fee adjustment direction depends on rebalance type
274- // Surplus (flowPrice > 1.0): swaps MOET →FUSDEV (forward)
275- // Deficit (flowPrice < 1.0): swaps FUSDEV→MOET (reverse)
249+ // PYUSD0 /FUSDEV pool: fee adjustment direction depends on rebalance type
250+ // Surplus (flowPrice > 1.0): swaps PYUSD0 →FUSDEV (forward)
251+ // Deficit (flowPrice < 1.0): swaps FUSDEV→PYUSD0 (reverse)
276252 setPoolToPrice (
277253 factoryAddress : factoryAddress ,
278- tokenAAddress : moetAddress ,
254+ tokenAAddress : pyusd0Address ,
279255 tokenBAddress : morphoVaultAddress ,
280256 fee : 100 ,
281257 priceTokenBPerTokenA : feeAdjustedPrice (1.0 , fee : 100 , reverse : flowPrice < 1.0 ),
282- tokenABalanceSlot : moetBalanceSlot ,
258+ tokenABalanceSlot : pyusd0BalanceSlot ,
283259 tokenBBalanceSlot : fusdevBalanceSlot ,
284260 signer : coaOwnerAccount
285261 )
0 commit comments