Skip to content

Commit 142fbc2

Browse files
committed
Add base case HT vs AAVE forked time series simulation
1 parent 72da2e4 commit 142fbc2

5 files changed

Lines changed: 941 additions & 9 deletions

File tree

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import "FlowYieldVaultsAutoBalancers"
2+
3+
/// Returns both currentValue and valueOfDeposits for the AutoBalancer in a single script call.
4+
/// This reduces script call overhead when both values are needed.
5+
///
6+
/// Returns: [currentValue, valueOfDeposits] or nil if AutoBalancer doesn't exist
7+
///
8+
access(all)
9+
fun main(id: UInt64): [UFix64]? {
10+
if let autoBalancer = FlowYieldVaultsAutoBalancers.borrowAutoBalancer(id: id) {
11+
let currentValue = autoBalancer.currentValue() ?? 0.0
12+
let valueOfDeposits = autoBalancer.valueOfDeposits()
13+
return [currentValue, valueOfDeposits]
14+
}
15+
return nil
16+
}
Lines changed: 288 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,288 @@
1+
import Test
2+
3+
// AUTO-GENERATED — do not edit manually
4+
// UnitZero sim: comprehensive_ht_vs_aave_analysis.py
5+
// UnitZero report: High_Tide_vs_AAVE_Executive_Summary_Clean.md
6+
//
7+
// BTC: $100K → $76,342.50 (-23.66%) over 60 minutes
8+
// Exponential decline: price[t] = 100000 * (76342.5/100000)^(t/60)
9+
10+
access(all) struct SimAgent {
11+
access(all) let count: Int
12+
access(all) let initialHF: UFix64
13+
access(all) let rebalancingHF: UFix64
14+
access(all) let targetHF: UFix64
15+
access(all) let debtPerAgent: UFix64
16+
access(all) let totalSystemDebt: UFix64
17+
18+
init(
19+
count: Int,
20+
initialHF: UFix64,
21+
rebalancingHF: UFix64,
22+
targetHF: UFix64,
23+
debtPerAgent: UFix64,
24+
totalSystemDebt: UFix64
25+
) {
26+
self.count = count
27+
self.initialHF = initialHF
28+
self.rebalancingHF = rebalancingHF
29+
self.targetHF = targetHF
30+
self.debtPerAgent = debtPerAgent
31+
self.totalSystemDebt = totalSystemDebt
32+
}
33+
}
34+
35+
access(all) struct SimPool {
36+
access(all) let size: UFix64
37+
access(all) let concentration: UFix64
38+
access(all) let feeTier: UFix64
39+
40+
init(size: UFix64, concentration: UFix64, feeTier: UFix64) {
41+
self.size = size
42+
self.concentration = concentration
43+
self.feeTier = feeTier
44+
}
45+
}
46+
47+
access(all) struct SimConstants {
48+
access(all) let btcCollateralFactor: UFix64
49+
access(all) let btcLiquidationThreshold: UFix64
50+
access(all) let yieldAPR: UFix64
51+
access(all) let directMintYT: Bool
52+
53+
init(
54+
btcCollateralFactor: UFix64,
55+
btcLiquidationThreshold: UFix64,
56+
yieldAPR: UFix64,
57+
directMintYT: Bool
58+
) {
59+
self.btcCollateralFactor = btcCollateralFactor
60+
self.btcLiquidationThreshold = btcLiquidationThreshold
61+
self.yieldAPR = yieldAPR
62+
self.directMintYT = directMintYT
63+
}
64+
}
65+
66+
// ============================================================================
67+
// SHARED PRICE CURVE — 61 ticks (minute 0..60)
68+
// ============================================================================
69+
70+
access(all) let simulation_ht_vs_aave_prices: [UFix64] = [
71+
100000.00000000,
72+
99551.10988532,
73+
99104.23479398,
74+
98659.36568076,
75+
98216.49354101,
76+
97775.60941052,
77+
97336.70436530,
78+
96899.76952145,
79+
96464.79603492,
80+
96031.77510137,
81+
95600.69795598,
82+
95171.55587329,
83+
94744.34016698,
84+
94319.04218975,
85+
93895.65333310,
86+
93474.16502717,
87+
93054.56874058,
88+
92636.85598024,
89+
92221.01829119,
90+
91807.04725642,
91+
91394.93449671,
92+
90984.67167043,
93+
90576.25047343,
94+
90169.66263880,
95+
89764.89993677,
96+
89361.95417450,
97+
88960.81719592,
98+
88561.48088159,
99+
88163.93714849,
100+
87768.17794992,
101+
87374.19527526,
102+
86981.98114989,
103+
86591.52763495,
104+
86202.82682725,
105+
85815.87085904,
106+
85430.65189793,
107+
85047.16214665,
108+
84665.39384295,
109+
84285.33925943,
110+
83906.99070337,
111+
83530.34051657,
112+
83155.38107523,
113+
82782.10478976,
114+
82410.50410463,
115+
82040.57149825,
116+
81672.29948276,
117+
81305.68060395,
118+
80940.70744104,
119+
80577.37260658,
120+
80215.66874628,
121+
79855.58853885,
122+
79497.12469588,
123+
79140.26996166,
124+
78785.01711307,
125+
78431.35895940,
126+
78079.28834222,
127+
77728.79813524,
128+
77379.88124414,
129+
77032.53060649,
130+
76686.73919150,
131+
76342.50000000
132+
]
133+
134+
// ============================================================================
135+
// SHARED PROTOCOL CONSTANTS
136+
// ============================================================================
137+
138+
access(all) let simulation_ht_vs_aave_constants: SimConstants = SimConstants(
139+
btcCollateralFactor: 0.75000000,
140+
btcLiquidationThreshold: 0.80000000,
141+
yieldAPR: 0.10000000,
142+
directMintYT: true
143+
)
144+
145+
access(all) let simulation_ht_vs_aave_pools: {String: SimPool} = {
146+
"moet_yt": SimPool(
147+
size: 500000.00000000,
148+
concentration: 0.95000000,
149+
feeTier: 0.00050000
150+
),
151+
"moet_btc": SimPool(
152+
size: 500000.00000000,
153+
concentration: 0.80000000,
154+
feeTier: 0.00300000
155+
)
156+
}
157+
158+
access(all) let simulation_ht_vs_aave_durationMinutes: Int = 60
159+
160+
// ============================================================================
161+
// SCENARIO 1: Aggressive (Target HF 1.01)
162+
// ============================================================================
163+
164+
access(all) let simulation_aggressive_1_01_agents: [SimAgent] = [
165+
SimAgent(
166+
count: 5,
167+
initialHF: 1.10000000,
168+
rebalancingHF: 1.05000000,
169+
targetHF: 1.01000000,
170+
debtPerAgent: 133333.00000000,
171+
totalSystemDebt: 666665.00000000
172+
),
173+
SimAgent(
174+
count: 5,
175+
initialHF: 1.20000000,
176+
rebalancingHF: 1.05000000,
177+
targetHF: 1.01000000,
178+
debtPerAgent: 133333.00000000,
179+
totalSystemDebt: 666665.00000000
180+
)
181+
]
182+
183+
access(all) let simulation_aggressive_1_01_expectedLiquidationCount: Int = 0
184+
access(all) let simulation_aggressive_1_01_expectedAllAgentsSurvive: Bool = true
185+
186+
// ============================================================================
187+
// SCENARIO 2: Moderate (Target HF 1.025)
188+
// ============================================================================
189+
190+
access(all) let simulation_moderate_1_025_agents: [SimAgent] = [
191+
SimAgent(
192+
count: 5,
193+
initialHF: 1.20000000,
194+
rebalancingHF: 1.05000000,
195+
targetHF: 1.02500000,
196+
debtPerAgent: 133333.00000000,
197+
totalSystemDebt: 666665.00000000
198+
),
199+
SimAgent(
200+
count: 5,
201+
initialHF: 1.40000000,
202+
rebalancingHF: 1.05000000,
203+
targetHF: 1.02500000,
204+
debtPerAgent: 133333.00000000,
205+
totalSystemDebt: 666665.00000000
206+
)
207+
]
208+
209+
access(all) let simulation_moderate_1_025_expectedLiquidationCount: Int = 0
210+
access(all) let simulation_moderate_1_025_expectedAllAgentsSurvive: Bool = true
211+
212+
// ============================================================================
213+
// SCENARIO 3: Conservative (Target HF 1.05)
214+
// ============================================================================
215+
216+
access(all) let simulation_conservative_1_05_agents: [SimAgent] = [
217+
SimAgent(
218+
count: 5,
219+
initialHF: 1.30000000,
220+
rebalancingHF: 1.10000000,
221+
targetHF: 1.05000000,
222+
debtPerAgent: 133333.00000000,
223+
totalSystemDebt: 666665.00000000
224+
),
225+
SimAgent(
226+
count: 5,
227+
initialHF: 1.50000000,
228+
rebalancingHF: 1.10000000,
229+
targetHF: 1.05000000,
230+
debtPerAgent: 133333.00000000,
231+
totalSystemDebt: 666665.00000000
232+
)
233+
]
234+
235+
access(all) let simulation_conservative_1_05_expectedLiquidationCount: Int = 0
236+
access(all) let simulation_conservative_1_05_expectedAllAgentsSurvive: Bool = true
237+
238+
// ============================================================================
239+
// SCENARIO 4: Mixed (Target HF 1.075)
240+
// ============================================================================
241+
242+
access(all) let simulation_mixed_1_075_agents: [SimAgent] = [
243+
SimAgent(
244+
count: 5,
245+
initialHF: 1.10000000,
246+
rebalancingHF: 1.05000000,
247+
targetHF: 1.07500000,
248+
debtPerAgent: 133333.00000000,
249+
totalSystemDebt: 666665.00000000
250+
),
251+
SimAgent(
252+
count: 5,
253+
initialHF: 1.50000000,
254+
rebalancingHF: 1.05000000,
255+
targetHF: 1.07500000,
256+
debtPerAgent: 133333.00000000,
257+
totalSystemDebt: 666665.00000000
258+
)
259+
]
260+
261+
access(all) let simulation_mixed_1_075_expectedLiquidationCount: Int = 0
262+
access(all) let simulation_mixed_1_075_expectedAllAgentsSurvive: Bool = true
263+
264+
// ============================================================================
265+
// SCENARIO 5: Balanced (Target HF 1.1)
266+
// ============================================================================
267+
268+
access(all) let simulation_balanced_1_1_agents: [SimAgent] = [
269+
SimAgent(
270+
count: 5,
271+
initialHF: 1.25000000,
272+
rebalancingHF: 1.10000000,
273+
targetHF: 1.10000000,
274+
debtPerAgent: 133333.00000000,
275+
totalSystemDebt: 666665.00000000
276+
),
277+
SimAgent(
278+
count: 5,
279+
initialHF: 1.45000000,
280+
rebalancingHF: 1.10000000,
281+
targetHF: 1.10000000,
282+
debtPerAgent: 133333.00000000,
283+
totalSystemDebt: 666665.00000000
284+
)
285+
]
286+
287+
access(all) let simulation_balanced_1_1_expectedLiquidationCount: Int = 0
288+
access(all) let simulation_balanced_1_1_expectedAllAgentsSurvive: Bool = true

0 commit comments

Comments
 (0)