diff --git a/.gitignore b/.gitignore index f58d4fed..7240b5b9 100644 --- a/.gitignore +++ b/.gitignore @@ -25,5 +25,8 @@ db # logs run_logs/*.log +# python +__pycache__/ + # flow -.flow-fork-cache/ \ No newline at end of file +.flow-fork-cache/ diff --git a/cadence/tests/btc_daily_2025_helpers.cdc b/cadence/tests/btc_daily_2025_helpers.cdc deleted file mode 100644 index ffe944c0..00000000 --- a/cadence/tests/btc_daily_2025_helpers.cdc +++ /dev/null @@ -1,843 +0,0 @@ -import Test - -// AUTO-GENERATED from btc_daily_2025.json — do not edit manually -// Run: python3 generate_fixture.py generate - -access(all) struct SimAgent { - access(all) let count: Int - access(all) let initialHF: UFix64 - access(all) let rebalancingHF: UFix64 - access(all) let targetHF: UFix64 - access(all) let debtPerAgent: UFix64 - access(all) let totalSystemDebt: UFix64 - - init( - count: Int, - initialHF: UFix64, - rebalancingHF: UFix64, - targetHF: UFix64, - debtPerAgent: UFix64, - totalSystemDebt: UFix64 - ) { - self.count = count - self.initialHF = initialHF - self.rebalancingHF = rebalancingHF - self.targetHF = targetHF - self.debtPerAgent = debtPerAgent - self.totalSystemDebt = totalSystemDebt - } -} - -access(all) struct SimPool { - access(all) let size: UFix64 - access(all) let concentration: UFix64 - access(all) let feeTier: UFix64 - - init(size: UFix64, concentration: UFix64, feeTier: UFix64) { - self.size = size - self.concentration = concentration - self.feeTier = feeTier - } -} - -access(all) struct SimConstants { - access(all) let btcCollateralFactor: UFix64 - access(all) let btcLiquidationThreshold: UFix64 - access(all) let yieldAPR: UFix64 - access(all) let directMintYT: Bool - - init( - btcCollateralFactor: UFix64, - btcLiquidationThreshold: UFix64, - yieldAPR: UFix64, - directMintYT: Bool - ) { - self.btcCollateralFactor = btcCollateralFactor - self.btcLiquidationThreshold = btcLiquidationThreshold - self.yieldAPR = yieldAPR - self.directMintYT = directMintYT - } -} - -access(all) let btc_daily_2025_prices: [UFix64] = [ - 94419.76000000, - 96886.88000000, - 98107.43000000, - 98236.23000000, - 98314.96000000, - 102078.09000000, - 96922.71000000, - 95043.52000000, - 92484.04000000, - 94701.46000000, - 94566.59000000, - 94488.44000000, - 94516.53000000, - 96534.04000000, - 100504.49000000, - 99756.91000000, - 104462.04000000, - 104408.07000000, - 101089.61000000, - 102016.66000000, - 106146.26000000, - 103653.07000000, - 103960.17000000, - 104819.48000000, - 104714.65000000, - 102682.50000000, - 102087.69000000, - 101332.48000000, - 103703.21000000, - 104735.30000000, - 102405.03000000, - 100655.91000000, - 97688.98000000, - 101405.42000000, - 97871.82000000, - 96615.44000000, - 96593.30000000, - 96529.08000000, - 96482.45000000, - 96500.09000000, - 97437.56000000, - 95747.43000000, - 97885.86000000, - 96623.87000000, - 97508.97000000, - 97580.35000000, - 96175.03000000, - 95773.38000000, - 95539.54000000, - 96635.61000000, - 98333.94000000, - 96125.54000000, - 96577.76000000, - 96273.92000000, - 91418.17000000, - 88736.17000000, - 84347.02000000, - 84704.22000000, - 84373.01000000, - 86031.91000000, - 94248.35000000, - 86065.67000000, - 87222.19000000, - 90623.56000000, - 89961.73000000, - 86742.68000000, - 86154.59000000, - 80601.04000000, - 78532.00000000, - 82862.21000000, - 83722.36000000, - 81066.70000000, - 83969.10000000, - 84343.11000000, - 82579.69000000, - 84075.69000000, - 82718.50000000, - 86854.23000000, - 84167.19000000, - 84043.25000000, - 83832.49000000, - 86054.37000000, - 87498.91000000, - 87471.70000000, - 86900.89000000, - 87177.10000000, - 84353.15000000, - 82597.58000000, - 82334.52000000, - 82548.91000000, - 85169.17000000, - 82485.71000000, - 83102.83000000, - 83843.80000000, - 83504.80000000, - 78214.48000000, - 79235.33000000, - 76271.95000000, - 82573.95000000, - 79626.14000000, - 83404.84000000, - 85287.11000000, - 83684.98000000, - 84542.39000000, - 83668.99000000, - 84033.87000000, - 84895.75000000, - 84450.81000000, - 85063.41000000, - 85174.30000000, - 87518.91000000, - 93441.89000000, - 93699.11000000, - 93943.79000000, - 94720.50000000, - 94646.93000000, - 93754.85000000, - 94978.75000000, - 94284.79000000, - 94207.31000000, - 96492.34000000, - 96910.07000000, - 95891.80000000, - 94315.97000000, - 94748.05000000, - 96802.48000000, - 97032.32000000, - 103241.46000000, - 102970.85000000, - 104696.33000000, - 104106.36000000, - 102812.95000000, - 104169.81000000, - 103539.42000000, - 103744.64000000, - 103489.29000000, - 103191.09000000, - 106446.01000000, - 105606.18000000, - 106791.09000000, - 109678.08000000, - 111673.28000000, - 107287.80000000, - 107791.16000000, - 109035.39000000, - 109440.37000000, - 108994.64000000, - 107802.32000000, - 105641.76000000, - 103998.57000000, - 104638.09000000, - 105652.10000000, - 105881.53000000, - 105432.47000000, - 104731.98000000, - 101575.95000000, - 104390.35000000, - 105615.63000000, - 105793.65000000, - 110294.10000000, - 110257.24000000, - 108686.63000000, - 105929.05000000, - 106090.97000000, - 105472.41000000, - 105552.03000000, - 106796.76000000, - 104601.12000000, - 104883.33000000, - 104684.29000000, - 103309.60000000, - 102257.41000000, - 100987.14000000, - 105577.77000000, - 106045.63000000, - 107361.26000000, - 106960.00000000, - 107088.43000000, - 107327.70000000, - 108385.57000000, - 107135.33000000, - 105698.28000000, - 108859.32000000, - 109647.98000000, - 108034.34000000, - 108231.18000000, - 109232.07000000, - 108299.85000000, - 108950.28000000, - 111326.55000000, - 115987.21000000, - 117516.99000000, - 117435.23000000, - 119116.12000000, - 119849.71000000, - 117777.19000000, - 118738.51000000, - 119289.84000000, - 118003.22000000, - 117939.98000000, - 117300.79000000, - 117439.54000000, - 119995.42000000, - 118754.96000000, - 118368.00000000, - 117635.88000000, - 117947.37000000, - 119448.49000000, - 117924.47000000, - 117922.15000000, - 117831.19000000, - 115758.20000000, - 113320.09000000, - 112526.91000000, - 114217.67000000, - 115071.88000000, - 114141.44000000, - 115028.00000000, - 117496.90000000, - 116688.73000000, - 116500.36000000, - 119306.76000000, - 118731.45000000, - 120172.91000000, - 123344.06000000, - 118359.58000000, - 117398.35000000, - 117491.35000000, - 117453.06000000, - 116252.31000000, - 112831.18000000, - 114274.74000000, - 112419.03000000, - 116874.09000000, - 115374.33000000, - 113458.43000000, - 110124.35000000, - 111802.66000000, - 111222.06000000, - 112544.80000000, - 108410.84000000, - 108808.07000000, - 108236.71000000, - 109250.59000000, - 111200.59000000, - 111723.21000000, - 110723.60000000, - 110650.99000000, - 110224.70000000, - 111167.62000000, - 112071.43000000, - 111530.55000000, - 113955.36000000, - 115507.54000000, - 116101.58000000, - 115950.51000000, - 115407.65000000, - 115444.87000000, - 116843.18000000, - 116468.51000000, - 117137.20000000, - 115688.86000000, - 115721.96000000, - 115306.10000000, - 112748.51000000, - 112014.50000000, - 113328.63000000, - 109049.29000000, - 109712.83000000, - 109681.94000000, - 112122.64000000, - 114400.39000000, - 114056.08000000, - 118648.93000000, - 120681.26000000, - 122266.53000000, - 122425.43000000, - 123513.47000000, - 124752.53000000, - 121451.38000000, - 123354.87000000, - 121705.58000000, - 113214.37000000, - 110807.88000000, - 115169.76000000, - 115271.08000000, - 113118.67000000, - 110783.17000000, - 108186.04000000, - 106467.79000000, - 107198.27000000, - 108666.71000000, - 110588.93000000, - 108476.89000000, - 107688.59000000, - 110069.72000000, - 111033.92000000, - 111641.73000000, - 114472.44000000, - 114119.32000000, - 112956.17000000, - 110055.30000000, - 108305.55000000, - 109556.16000000, - 110064.02000000, - 110639.63000000, - 106547.52000000, - 101590.52000000, - 103891.84000000, - 101301.29000000, - 103372.41000000, - 102282.11000000, - 104719.64000000, - 105996.60000000, - 102997.47000000, - 101663.19000000, - 99697.49000000, - 94397.79000000, - 95549.15000000, - 94177.07000000, - 92093.87000000, - 92948.87000000, - 91465.99000000, - 86631.90000000, - 85090.69000000, - 84648.36000000, - 86805.01000000, - 88270.56000000, - 87341.89000000, - 90518.37000000, - 91285.37000000, - 90919.27000000, - 90851.75000000, - 90394.31000000, - 86321.57000000, - 91350.21000000, - 93527.80000000, - 92141.62000000, - 89387.75000000, - 89272.37000000, - 90405.64000000, - 90640.21000000, - 92691.71000000, - 92020.95000000, - 92511.34000000, - 90270.41000000, - 90298.71000000, - 88175.18000000, - 86419.78000000, - 87843.99000000, - 86143.76000000, - 85462.51000000, - 88103.38000000, - 88344.00000000, - 88621.75000000, - 88490.02000000, - 87414.00000000, - 87611.96000000, - 87234.74000000, - 87301.43000000, - 87802.16000000, - 87835.83000000, - 87138.14000000, - 88430.14000000, - 87508.83000000 -] - -access(all) let btc_daily_2025_dates: [String] = [ - "2025-01-01", - "2025-01-02", - "2025-01-03", - "2025-01-04", - "2025-01-05", - "2025-01-06", - "2025-01-07", - "2025-01-08", - "2025-01-09", - "2025-01-10", - "2025-01-11", - "2025-01-12", - "2025-01-13", - "2025-01-14", - "2025-01-15", - "2025-01-16", - "2025-01-17", - "2025-01-18", - "2025-01-19", - "2025-01-20", - "2025-01-21", - "2025-01-22", - "2025-01-23", - "2025-01-24", - "2025-01-25", - "2025-01-26", - "2025-01-27", - "2025-01-28", - "2025-01-29", - "2025-01-30", - "2025-01-31", - "2025-02-01", - "2025-02-02", - "2025-02-03", - "2025-02-04", - "2025-02-05", - "2025-02-06", - "2025-02-07", - "2025-02-08", - "2025-02-09", - "2025-02-10", - "2025-02-11", - "2025-02-12", - "2025-02-13", - "2025-02-14", - "2025-02-15", - "2025-02-16", - "2025-02-17", - "2025-02-18", - "2025-02-19", - "2025-02-20", - "2025-02-21", - "2025-02-22", - "2025-02-23", - "2025-02-24", - "2025-02-25", - "2025-02-26", - "2025-02-27", - "2025-02-28", - "2025-03-01", - "2025-03-02", - "2025-03-03", - "2025-03-04", - "2025-03-05", - "2025-03-06", - "2025-03-07", - "2025-03-08", - "2025-03-09", - "2025-03-10", - "2025-03-11", - "2025-03-12", - "2025-03-13", - "2025-03-14", - "2025-03-15", - "2025-03-16", - "2025-03-17", - "2025-03-18", - "2025-03-19", - "2025-03-20", - "2025-03-21", - "2025-03-22", - "2025-03-23", - "2025-03-24", - "2025-03-25", - "2025-03-26", - "2025-03-27", - "2025-03-28", - "2025-03-29", - "2025-03-30", - "2025-03-31", - "2025-04-01", - "2025-04-02", - "2025-04-03", - "2025-04-04", - "2025-04-05", - "2025-04-06", - "2025-04-07", - "2025-04-08", - "2025-04-09", - "2025-04-10", - "2025-04-11", - "2025-04-12", - "2025-04-13", - "2025-04-14", - "2025-04-15", - "2025-04-16", - "2025-04-17", - "2025-04-18", - "2025-04-19", - "2025-04-20", - "2025-04-21", - "2025-04-22", - "2025-04-23", - "2025-04-24", - "2025-04-25", - "2025-04-26", - "2025-04-27", - "2025-04-28", - "2025-04-29", - "2025-04-30", - "2025-05-01", - "2025-05-02", - "2025-05-03", - "2025-05-04", - "2025-05-05", - "2025-05-06", - "2025-05-07", - "2025-05-08", - "2025-05-09", - "2025-05-10", - "2025-05-11", - "2025-05-12", - "2025-05-13", - "2025-05-14", - "2025-05-15", - "2025-05-16", - "2025-05-17", - "2025-05-18", - "2025-05-19", - "2025-05-20", - "2025-05-21", - "2025-05-22", - "2025-05-23", - "2025-05-24", - "2025-05-25", - "2025-05-26", - "2025-05-27", - "2025-05-28", - "2025-05-29", - "2025-05-30", - "2025-05-31", - "2025-06-01", - "2025-06-02", - "2025-06-03", - "2025-06-04", - "2025-06-05", - "2025-06-06", - "2025-06-07", - "2025-06-08", - "2025-06-09", - "2025-06-10", - "2025-06-11", - "2025-06-12", - "2025-06-13", - "2025-06-14", - "2025-06-15", - "2025-06-16", - "2025-06-17", - "2025-06-18", - "2025-06-19", - "2025-06-20", - "2025-06-21", - "2025-06-22", - "2025-06-23", - "2025-06-24", - "2025-06-25", - "2025-06-26", - "2025-06-27", - "2025-06-28", - "2025-06-29", - "2025-06-30", - "2025-07-01", - "2025-07-02", - "2025-07-03", - "2025-07-04", - "2025-07-05", - "2025-07-06", - "2025-07-07", - "2025-07-08", - "2025-07-09", - "2025-07-10", - "2025-07-11", - "2025-07-12", - "2025-07-13", - "2025-07-14", - "2025-07-15", - "2025-07-16", - "2025-07-17", - "2025-07-18", - "2025-07-19", - "2025-07-20", - "2025-07-21", - "2025-07-22", - "2025-07-23", - "2025-07-24", - "2025-07-25", - "2025-07-26", - "2025-07-27", - "2025-07-28", - "2025-07-29", - "2025-07-30", - "2025-07-31", - "2025-08-01", - "2025-08-02", - "2025-08-03", - "2025-08-04", - "2025-08-05", - "2025-08-06", - "2025-08-07", - "2025-08-08", - "2025-08-09", - "2025-08-10", - "2025-08-11", - "2025-08-12", - "2025-08-13", - "2025-08-14", - "2025-08-15", - "2025-08-16", - "2025-08-17", - "2025-08-18", - "2025-08-19", - "2025-08-20", - "2025-08-21", - "2025-08-22", - "2025-08-23", - "2025-08-24", - "2025-08-25", - "2025-08-26", - "2025-08-27", - "2025-08-28", - "2025-08-29", - "2025-08-30", - "2025-08-31", - "2025-09-01", - "2025-09-02", - "2025-09-03", - "2025-09-04", - "2025-09-05", - "2025-09-06", - "2025-09-07", - "2025-09-08", - "2025-09-09", - "2025-09-10", - "2025-09-11", - "2025-09-12", - "2025-09-13", - "2025-09-14", - "2025-09-15", - "2025-09-16", - "2025-09-17", - "2025-09-18", - "2025-09-19", - "2025-09-20", - "2025-09-21", - "2025-09-22", - "2025-09-23", - "2025-09-24", - "2025-09-25", - "2025-09-26", - "2025-09-27", - "2025-09-28", - "2025-09-29", - "2025-09-30", - "2025-10-01", - "2025-10-02", - "2025-10-03", - "2025-10-04", - "2025-10-05", - "2025-10-06", - "2025-10-07", - "2025-10-08", - "2025-10-09", - "2025-10-10", - "2025-10-11", - "2025-10-12", - "2025-10-13", - "2025-10-14", - "2025-10-15", - "2025-10-16", - "2025-10-17", - "2025-10-18", - "2025-10-19", - "2025-10-20", - "2025-10-21", - "2025-10-22", - "2025-10-23", - "2025-10-24", - "2025-10-25", - "2025-10-26", - "2025-10-27", - "2025-10-28", - "2025-10-29", - "2025-10-30", - "2025-10-31", - "2025-11-01", - "2025-11-02", - "2025-11-03", - "2025-11-04", - "2025-11-05", - "2025-11-06", - "2025-11-07", - "2025-11-08", - "2025-11-09", - "2025-11-10", - "2025-11-11", - "2025-11-12", - "2025-11-13", - "2025-11-14", - "2025-11-15", - "2025-11-16", - "2025-11-17", - "2025-11-18", - "2025-11-19", - "2025-11-20", - "2025-11-21", - "2025-11-22", - "2025-11-23", - "2025-11-24", - "2025-11-25", - "2025-11-26", - "2025-11-27", - "2025-11-28", - "2025-11-29", - "2025-11-30", - "2025-12-01", - "2025-12-02", - "2025-12-03", - "2025-12-04", - "2025-12-05", - "2025-12-06", - "2025-12-07", - "2025-12-08", - "2025-12-09", - "2025-12-10", - "2025-12-11", - "2025-12-12", - "2025-12-13", - "2025-12-14", - "2025-12-15", - "2025-12-16", - "2025-12-17", - "2025-12-18", - "2025-12-19", - "2025-12-20", - "2025-12-21", - "2025-12-22", - "2025-12-23", - "2025-12-24", - "2025-12-25", - "2025-12-26", - "2025-12-27", - "2025-12-28", - "2025-12-29", - "2025-12-30", - "2025-12-31" -] - -access(all) let btc_daily_2025_agents: [SimAgent] = [ - SimAgent( - count: 1, - initialHF: 1.15000000, - rebalancingHF: 1.05000000, - targetHF: 1.08000000, - debtPerAgent: 133333.00000000, - totalSystemDebt: 20000000.00000000 - ) -] - -access(all) let btc_daily_2025_pools: {String: SimPool} = { - "moet_yt": SimPool( - size: 500000.00000000, - concentration: 0.95000000, - feeTier: 0.00050000 - ), - "moet_btc": SimPool( - size: 5000000.00000000, - concentration: 0.80000000, - feeTier: 0.00300000 - ), - "pyusd_btc": SimPool( - size: 10000000.00000000, - concentration: 0.80000000, - feeTier: 0.00300000 - ), - "moet_fusdev": SimPool( - size: 500000.00000000, - concentration: 0.95000000, - feeTier: 0.00010000 - ) -} - -access(all) let btc_daily_2025_constants: SimConstants = SimConstants( - btcCollateralFactor: 0.80000000, - btcLiquidationThreshold: 0.85000000, - yieldAPR: 0.10000000, - directMintYT: true -) - -access(all) let btc_daily_2025_expectedLiquidationCount: Int = 0 -access(all) let btc_daily_2025_expectedAllAgentsSurvive: Bool = true - -access(all) let btc_daily_2025_durationDays: Int = 365 -access(all) let btc_daily_2025_notes: String = "Daily BTC/USD close prices from CoinMarketCap, 2025-01-01 to 2025-12-31. 365 data points." diff --git a/cadence/tests/scripts/simulations/btc_daily_2021_mixed.json b/cadence/tests/scripts/simulations/btc_daily_2021_mixed.json new file mode 100644 index 00000000..b8cf8083 --- /dev/null +++ b/cadence/tests/scripts/simulations/btc_daily_2021_mixed.json @@ -0,0 +1,778 @@ +{ + "scenario": "btc_daily_2021_mixed", + "duration_days": 365, + "btc_prices": [ + 29374.15, + 32127.27, + 32782.02, + 31971.91, + 33992.43, + 36824.36, + 39371.04, + 40797.61, + 40254.55, + 38356.44, + 35566.66, + 33922.96, + 37316.36, + 39187.33, + 36825.37, + 36178.14, + 35791.28, + 36630.08, + 36069.81, + 35547.75, + 30825.7, + 33005.76, + 32067.64, + 32289.38, + 32366.39, + 32569.85, + 30432.55, + 33466.1, + 34316.39, + 34269.52, + 33114.36, + 33537.18, + 35510.29, + 37472.09, + 36926.06, + 38144.31, + 39266.01, + 38903.44, + 46196.46, + 46481.1, + 44918.18, + 47909.33, + 47504.85, + 47105.52, + 48717.29, + 47945.06, + 49199.87, + 52149.01, + 51679.8, + 55888.13, + 56099.52, + 57539.94, + 54207.32, + 48824.43, + 49705.33, + 47093.85, + 46339.76, + 46188.45, + 45137.77, + 49631.24, + 48378.99, + 50538.24, + 48561.17, + 48927.3, + 48912.38, + 51206.69, + 52246.52, + 54824.12, + 56008.55, + 57805.12, + 57332.09, + 61243.08, + 59302.32, + 55907.2, + 56804.9, + 58870.89, + 57858.92, + 58346.65, + 58313.64, + 57523.42, + 54529.15, + 54738.94, + 52774.26, + 51704.16, + 55137.31, + 55973.51, + 55950.75, + 57750.2, + 58917.69, + 58918.83, + 59095.81, + 59384.31, + 57603.89, + 58758.56, + 59057.88, + 58192.36, + 56048.94, + 58323.95, + 58245.0, + 59793.24, + 60204.96, + 59893.45, + 63503.46, + 63109.7, + 63314.01, + 61572.79, + 60683.82, + 56216.19, + 55724.27, + 56473.03, + 53906.09, + 51762.27, + 51093.65, + 50050.87, + 49004.25, + 54021.75, + 55033.12, + 54824.7, + 53555.11, + 57750.18, + 57828.05, + 56631.08, + 57200.29, + 53333.54, + 57424.01, + 56396.51, + 57356.4, + 58803.78, + 58232.32, + 55859.8, + 56704.57, + 49150.53, + 49716.19, + 49880.53, + 46760.19, + 46456.06, + 43537.51, + 42909.4, + 37002.44, + 40782.74, + 37304.69, + 37536.63, + 34770.58, + 38705.98, + 38402.22, + 39294.2, + 38436.97, + 35697.61, + 34616.07, + 35678.13, + 37332.85, + 36684.92, + 37575.18, + 39208.77, + 36894.41, + 35551.96, + 35862.38, + 33560.71, + 33472.63, + 37345.12, + 36702.6, + 37334.4, + 35552.52, + 39097.86, + 40218.48, + 40406.27, + 38347.06, + 38053.5, + 35787.24, + 35615.87, + 35698.3, + 31676.69, + 32505.66, + 33723.03, + 34662.44, + 31637.78, + 32186.28, + 34649.64, + 34434.34, + 35867.78, + 35040.84, + 33572.12, + 33897.05, + 34668.55, + 35287.78, + 33746.0, + 34235.19, + 33855.33, + 32877.37, + 33798.01, + 33520.52, + 34240.19, + 33155.85, + 32702.03, + 32822.35, + 31780.73, + 31421.54, + 31533.07, + 31796.81, + 30817.83, + 29807.35, + 32110.69, + 32313.11, + 33581.55, + 34292.45, + 35350.19, + 37337.53, + 39406.94, + 39995.91, + 40008.42, + 42235.55, + 41626.2, + 39974.9, + 39201.95, + 38152.98, + 39747.51, + 40869.55, + 42816.5, + 44555.8, + 43798.12, + 46365.4, + 45585.03, + 45593.64, + 44428.29, + 47793.32, + 47096.95, + 47047.0, + 46004.48, + 44695.36, + 44801.19, + 46717.58, + 49339.18, + 48905.49, + 49321.65, + 49546.15, + 47706.12, + 48960.79, + 46942.22, + 49058.67, + 48902.4, + 48829.83, + 47054.98, + 47166.69, + 48847.03, + 49327.72, + 50025.37, + 49944.63, + 51753.41, + 52633.54, + 46811.13, + 46091.39, + 46391.42, + 44883.91, + 45201.46, + 46063.27, + 44963.07, + 47092.49, + 48176.35, + 47783.36, + 47267.52, + 48278.36, + 47260.22, + 42843.8, + 40693.68, + 43574.51, + 44895.1, + 42839.75, + 42716.59, + 43208.54, + 42235.73, + 41034.54, + 41564.36, + 43790.9, + 48116.94, + 47711.49, + 48199.95, + 49112.9, + 51514.81, + 55361.45, + 53805.99, + 53967.85, + 54968.22, + 54771.58, + 57484.79, + 56041.06, + 57401.1, + 57321.53, + 61593.95, + 60892.18, + 61553.62, + 62026.08, + 64261.99, + 65992.84, + 62210.17, + 60692.26, + 61393.62, + 60930.84, + 63039.83, + 60363.79, + 58482.39, + 60622.14, + 62227.96, + 61888.83, + 61318.96, + 61004.41, + 63226.4, + 62970.05, + 61452.23, + 61125.67, + 61527.48, + 63326.99, + 67566.83, + 66971.83, + 64995.23, + 64949.96, + 64155.94, + 64469.53, + 65466.84, + 63557.87, + 60161.25, + 60368.01, + 56942.14, + 58119.58, + 59697.2, + 58730.48, + 56289.29, + 57569.07, + 56280.43, + 57274.68, + 53569.76, + 54815.08, + 57248.46, + 57806.57, + 57005.43, + 57229.83, + 56477.82, + 53598.25, + 49200.7, + 49368.85, + 50582.63, + 50700.08, + 50504.8, + 47672.12, + 47243.31, + 49362.51, + 50098.34, + 46737.48, + 46612.63, + 48896.72, + 47665.43, + 46202.14, + 46848.78, + 46707.01, + 46880.28, + 48936.61, + 48628.51, + 50784.54, + 50822.2, + 50429.86, + 50809.52, + 50640.42, + 47588.85, + 46444.71, + 47178.13, + 46306.45 + ], + "dates": [ + "2021-01-01", + "2021-01-02", + "2021-01-03", + "2021-01-04", + "2021-01-05", + "2021-01-06", + "2021-01-07", + "2021-01-08", + "2021-01-09", + "2021-01-10", + "2021-01-11", + "2021-01-12", + "2021-01-13", + "2021-01-14", + "2021-01-15", + "2021-01-16", + "2021-01-17", + "2021-01-18", + "2021-01-19", + "2021-01-20", + "2021-01-21", + "2021-01-22", + "2021-01-23", + "2021-01-24", + "2021-01-25", + "2021-01-26", + "2021-01-27", + "2021-01-28", + "2021-01-29", + "2021-01-30", + "2021-01-31", + "2021-02-01", + "2021-02-02", + "2021-02-03", + "2021-02-04", + "2021-02-05", + "2021-02-06", + "2021-02-07", + "2021-02-08", + "2021-02-09", + "2021-02-10", + "2021-02-11", + "2021-02-12", + "2021-02-13", + "2021-02-14", + "2021-02-15", + "2021-02-16", + "2021-02-17", + "2021-02-18", + "2021-02-19", + "2021-02-20", + "2021-02-21", + "2021-02-22", + "2021-02-23", + "2021-02-24", + "2021-02-25", + "2021-02-26", + "2021-02-27", + "2021-02-28", + "2021-03-01", + "2021-03-02", + "2021-03-03", + "2021-03-04", + "2021-03-05", + "2021-03-06", + "2021-03-07", + "2021-03-08", + "2021-03-09", + "2021-03-10", + "2021-03-11", + "2021-03-12", + "2021-03-13", + "2021-03-14", + "2021-03-15", + "2021-03-16", + "2021-03-17", + "2021-03-18", + "2021-03-19", + "2021-03-20", + "2021-03-21", + "2021-03-22", + "2021-03-23", + "2021-03-24", + "2021-03-25", + "2021-03-26", + "2021-03-27", + "2021-03-28", + "2021-03-29", + "2021-03-30", + "2021-03-31", + "2021-04-01", + "2021-04-02", + "2021-04-03", + "2021-04-04", + "2021-04-05", + "2021-04-06", + "2021-04-07", + "2021-04-08", + "2021-04-09", + "2021-04-10", + "2021-04-11", + "2021-04-12", + "2021-04-13", + "2021-04-14", + "2021-04-15", + "2021-04-16", + "2021-04-17", + "2021-04-18", + "2021-04-19", + "2021-04-20", + "2021-04-21", + "2021-04-22", + "2021-04-23", + "2021-04-24", + "2021-04-25", + "2021-04-26", + "2021-04-27", + "2021-04-28", + "2021-04-29", + "2021-04-30", + "2021-05-01", + "2021-05-02", + "2021-05-03", + "2021-05-04", + "2021-05-05", + "2021-05-06", + "2021-05-07", + "2021-05-08", + "2021-05-09", + "2021-05-10", + "2021-05-11", + "2021-05-12", + "2021-05-13", + "2021-05-14", + "2021-05-15", + "2021-05-16", + "2021-05-17", + "2021-05-18", + "2021-05-19", + "2021-05-20", + "2021-05-21", + "2021-05-22", + "2021-05-23", + "2021-05-24", + "2021-05-25", + "2021-05-26", + "2021-05-27", + "2021-05-28", + "2021-05-29", + "2021-05-30", + "2021-05-31", + "2021-06-01", + "2021-06-02", + "2021-06-03", + "2021-06-04", + "2021-06-05", + "2021-06-06", + "2021-06-07", + "2021-06-08", + "2021-06-09", + "2021-06-10", + "2021-06-11", + "2021-06-12", + "2021-06-13", + "2021-06-14", + "2021-06-15", + "2021-06-16", + "2021-06-17", + "2021-06-18", + "2021-06-19", + "2021-06-20", + "2021-06-21", + "2021-06-22", + "2021-06-23", + "2021-06-24", + "2021-06-25", + "2021-06-26", + "2021-06-27", + "2021-06-28", + "2021-06-29", + "2021-06-30", + "2021-07-01", + "2021-07-02", + "2021-07-03", + "2021-07-04", + "2021-07-05", + "2021-07-06", + "2021-07-07", + "2021-07-08", + "2021-07-09", + "2021-07-10", + "2021-07-11", + "2021-07-12", + "2021-07-13", + "2021-07-14", + "2021-07-15", + "2021-07-16", + "2021-07-17", + "2021-07-18", + "2021-07-19", + "2021-07-20", + "2021-07-21", + "2021-07-22", + "2021-07-23", + "2021-07-24", + "2021-07-25", + "2021-07-26", + "2021-07-27", + "2021-07-28", + "2021-07-29", + "2021-07-30", + "2021-07-31", + "2021-08-01", + "2021-08-02", + "2021-08-03", + "2021-08-04", + "2021-08-05", + "2021-08-06", + "2021-08-07", + "2021-08-08", + "2021-08-09", + "2021-08-10", + "2021-08-11", + "2021-08-12", + "2021-08-13", + "2021-08-14", + "2021-08-15", + "2021-08-16", + "2021-08-17", + "2021-08-18", + "2021-08-19", + "2021-08-20", + "2021-08-21", + "2021-08-22", + "2021-08-23", + "2021-08-24", + "2021-08-25", + "2021-08-26", + "2021-08-27", + "2021-08-28", + "2021-08-29", + "2021-08-30", + "2021-08-31", + "2021-09-01", + "2021-09-02", + "2021-09-03", + "2021-09-04", + "2021-09-05", + "2021-09-06", + "2021-09-07", + "2021-09-08", + "2021-09-09", + "2021-09-10", + "2021-09-11", + "2021-09-12", + "2021-09-13", + "2021-09-14", + "2021-09-15", + "2021-09-16", + "2021-09-17", + "2021-09-18", + "2021-09-19", + "2021-09-20", + "2021-09-21", + "2021-09-22", + "2021-09-23", + "2021-09-24", + "2021-09-25", + "2021-09-26", + "2021-09-27", + "2021-09-28", + "2021-09-29", + "2021-09-30", + "2021-10-01", + "2021-10-02", + "2021-10-03", + "2021-10-04", + "2021-10-05", + "2021-10-06", + "2021-10-07", + "2021-10-08", + "2021-10-09", + "2021-10-10", + "2021-10-11", + "2021-10-12", + "2021-10-13", + "2021-10-14", + "2021-10-15", + "2021-10-16", + "2021-10-17", + "2021-10-18", + "2021-10-19", + "2021-10-20", + "2021-10-21", + "2021-10-22", + "2021-10-23", + "2021-10-24", + "2021-10-25", + "2021-10-26", + "2021-10-27", + "2021-10-28", + "2021-10-29", + "2021-10-30", + "2021-10-31", + "2021-11-01", + "2021-11-02", + "2021-11-03", + "2021-11-04", + "2021-11-05", + "2021-11-06", + "2021-11-07", + "2021-11-08", + "2021-11-09", + "2021-11-10", + "2021-11-11", + "2021-11-12", + "2021-11-13", + "2021-11-14", + "2021-11-15", + "2021-11-16", + "2021-11-17", + "2021-11-18", + "2021-11-19", + "2021-11-20", + "2021-11-21", + "2021-11-22", + "2021-11-23", + "2021-11-24", + "2021-11-25", + "2021-11-26", + "2021-11-27", + "2021-11-28", + "2021-11-29", + "2021-11-30", + "2021-12-01", + "2021-12-02", + "2021-12-03", + "2021-12-04", + "2021-12-05", + "2021-12-06", + "2021-12-07", + "2021-12-08", + "2021-12-09", + "2021-12-10", + "2021-12-11", + "2021-12-12", + "2021-12-13", + "2021-12-14", + "2021-12-15", + "2021-12-16", + "2021-12-17", + "2021-12-18", + "2021-12-19", + "2021-12-20", + "2021-12-21", + "2021-12-22", + "2021-12-23", + "2021-12-24", + "2021-12-25", + "2021-12-26", + "2021-12-27", + "2021-12-28", + "2021-12-29", + "2021-12-30", + "2021-12-31" + ], + "agents": [ + { + "count": 1, + "debt_per_agent": 133333, + "total_system_debt": 20000000 + } + ], + "pools": { + "moet_yt": { + "size": 500000, + "concentration": 0.95, + "fee_tier": 0.0005 + }, + "moet_btc": { + "size": 5000000, + "concentration": 0.8, + "fee_tier": 0.003 + }, + "pyusd_btc": { + "size": 10000000, + "concentration": 0.8, + "fee_tier": 0.003 + }, + "moet_fusdev": { + "size": 500000, + "concentration": 0.95, + "fee_tier": 0.0001 + } + }, + "constants": { + "btc_collateral_factor": 0.8, + "btc_liquidation_threshold": 0.85, + "yield_apr": 0.1, + "direct_mint_yt": true + }, + "expected": { + "liquidation_count": 0, + "all_agents_survive": true + }, + "notes": "Daily BTC/USD close prices from CoinMarketCap, 2021-01-01 to 2021-12-31. 365 data points." +} \ No newline at end of file diff --git a/cadence/tests/scripts/simulations/btc_daily_2022_bear.json b/cadence/tests/scripts/simulations/btc_daily_2022_bear.json new file mode 100644 index 00000000..e4968423 --- /dev/null +++ b/cadence/tests/scripts/simulations/btc_daily_2022_bear.json @@ -0,0 +1,778 @@ +{ + "scenario": "btc_daily_2022_bear", + "duration_days": 365, + "btc_prices": [ + 47686.81, + 47345.22, + 46458.12, + 45897.58, + 43569.0, + 43160.93, + 41557.9, + 41733.94, + 41911.6, + 41821.26, + 42735.85, + 43949.1, + 42591.57, + 43099.7, + 43177.4, + 43113.88, + 42250.55, + 42375.63, + 41744.33, + 40680.42, + 36457.32, + 35030.25, + 36276.8, + 36654.33, + 36954.0, + 36852.12, + 37138.23, + 37784.33, + 38138.18, + 37917.6, + 38483.13, + 38743.27, + 36952.98, + 37154.6, + 41500.88, + 41441.16, + 42412.43, + 43840.29, + 44118.45, + 44338.8, + 43565.11, + 42407.94, + 42244.47, + 42197.52, + 42586.92, + 44575.2, + 43961.86, + 40538.01, + 40030.98, + 40122.15, + 38431.38, + 37075.28, + 38286.03, + 37296.57, + 38332.61, + 39214.22, + 39105.15, + 37709.78, + 43193.23, + 44354.64, + 43924.12, + 42451.79, + 39137.6, + 39400.58, + 38419.98, + 38062.04, + 38737.27, + 41982.93, + 39437.46, + 38794.97, + 38904.01, + 37849.66, + 39666.76, + 39338.79, + 41143.93, + 40951.38, + 41801.15, + 42190.65, + 41247.82, + 41078.0, + 42358.81, + 42892.96, + 43960.93, + 44348.73, + 44500.83, + 46820.49, + 47128.01, + 47465.73, + 47062.66, + 45538.68, + 46281.64, + 45868.95, + 46453.57, + 46622.67, + 45555.99, + 43206.74, + 43503.85, + 42287.66, + 42782.14, + 42207.67, + 39521.9, + 40127.18, + 41166.73, + 39935.52, + 40553.46, + 40424.48, + 39716.95, + 40826.21, + 41502.75, + 41374.38, + 40527.36, + 39740.32, + 39486.73, + 39469.29, + 40458.31, + 38117.46, + 39241.12, + 39773.83, + 38609.82, + 37714.88, + 38469.09, + 38529.33, + 37750.45, + 39698.37, + 36575.14, + 36040.92, + 35501.95, + 34059.26, + 30296.95, + 31022.91, + 28936.36, + 29047.75, + 29283.1, + 30101.27, + 31305.11, + 29862.92, + 30425.86, + 28720.27, + 30314.33, + 29200.74, + 29432.23, + 30323.72, + 29098.91, + 29655.59, + 29562.36, + 29267.22, + 28627.57, + 29023.49, + 29445.96, + 31726.39, + 31792.31, + 29799.08, + 30467.49, + 29704.39, + 29832.91, + 29906.66, + 31370.67, + 31155.48, + 30214.36, + 30112.0, + 29083.8, + 28360.81, + 26762.65, + 22487.39, + 22206.79, + 22572.84, + 20381.65, + 20471.48, + 19017.64, + 20553.27, + 20599.54, + 20710.6, + 19987.03, + 21085.88, + 21231.66, + 21502.34, + 21027.3, + 20735.48, + 20280.64, + 20104.02, + 19784.73, + 19269.37, + 19242.26, + 19297.08, + 20231.26, + 20190.11, + 20548.25, + 21637.59, + 21731.12, + 21592.21, + 20860.45, + 19970.56, + 19323.91, + 20212.07, + 20569.92, + 20836.33, + 21190.32, + 20779.34, + 22485.69, + 23389.43, + 23231.73, + 23164.63, + 22714.98, + 22465.48, + 22609.16, + 21361.7, + 21239.75, + 22930.55, + 23843.89, + 23804.63, + 23656.21, + 23336.9, + 23314.2, + 22978.12, + 22846.51, + 22630.96, + 23289.31, + 22961.28, + 23175.89, + 23809.49, + 23164.32, + 23947.64, + 23957.53, + 24402.82, + 24424.07, + 24319.33, + 24136.97, + 23883.29, + 23336.0, + 23212.74, + 20877.55, + 21166.06, + 21534.12, + 21398.91, + 21528.09, + 21395.02, + 21600.91, + 20260.02, + 20041.74, + 19616.81, + 20297.99, + 19796.81, + 20049.76, + 20127.14, + 19969.77, + 19832.09, + 19986.71, + 19812.37, + 18837.67, + 19290.32, + 19329.83, + 21381.15, + 21680.54, + 21769.26, + 22370.45, + 20296.71, + 20241.09, + 19701.21, + 19772.58, + 20127.58, + 19419.51, + 19544.13, + 18890.79, + 18547.4, + 19413.55, + 19297.64, + 18937.01, + 18802.1, + 19222.67, + 19110.55, + 19426.72, + 19573.05, + 19431.79, + 19312.09, + 19044.11, + 19623.58, + 20336.84, + 20160.72, + 19955.44, + 19546.85, + 19416.57, + 19446.43, + 19141.48, + 19051.42, + 19157.45, + 19382.9, + 19185.66, + 19067.64, + 19268.09, + 19550.76, + 19334.42, + 19139.53, + 19053.74, + 19172.47, + 19208.19, + 19567.01, + 19345.57, + 20095.86, + 20770.44, + 20285.84, + 20595.35, + 20818.48, + 20635.6, + 20495.77, + 20485.27, + 20159.5, + 20209.99, + 21147.23, + 21282.69, + 20926.49, + 20602.82, + 18541.27, + 15880.78, + 17586.77, + 17034.29, + 16799.18, + 16353.37, + 16618.2, + 16884.61, + 16669.44, + 16687.52, + 16697.78, + 16711.55, + 16291.83, + 15787.28, + 16189.77, + 16610.71, + 16604.47, + 16521.84, + 16464.28, + 16444.63, + 16217.32, + 16444.98, + 17168.57, + 16967.13, + 17088.66, + 16908.24, + 17130.49, + 16974.83, + 17089.5, + 16848.13, + 17233.47, + 17133.15, + 17128.72, + 17104.19, + 17206.44, + 17781.32, + 17652.1, + 17364.86, + 16647.48, + 16795.09, + 16757.98, + 16439.68, + 16906.31, + 16817.53, + 16830.34, + 16796.95, + 16847.76, + 16841.99, + 16919.81, + 16717.17, + 16552.57, + 16642.34, + 16602.59, + 16547.5 + ], + "dates": [ + "2022-01-01", + "2022-01-02", + "2022-01-03", + "2022-01-04", + "2022-01-05", + "2022-01-06", + "2022-01-07", + "2022-01-08", + "2022-01-09", + "2022-01-10", + "2022-01-11", + "2022-01-12", + "2022-01-13", + "2022-01-14", + "2022-01-15", + "2022-01-16", + "2022-01-17", + "2022-01-18", + "2022-01-19", + "2022-01-20", + "2022-01-21", + "2022-01-22", + "2022-01-23", + "2022-01-24", + "2022-01-25", + "2022-01-26", + "2022-01-27", + "2022-01-28", + "2022-01-29", + "2022-01-30", + "2022-01-31", + "2022-02-01", + "2022-02-02", + "2022-02-03", + "2022-02-04", + "2022-02-05", + "2022-02-06", + "2022-02-07", + "2022-02-08", + "2022-02-09", + "2022-02-10", + "2022-02-11", + "2022-02-12", + "2022-02-13", + "2022-02-14", + "2022-02-15", + "2022-02-16", + "2022-02-17", + "2022-02-18", + "2022-02-19", + "2022-02-20", + "2022-02-21", + "2022-02-22", + "2022-02-23", + "2022-02-24", + "2022-02-25", + "2022-02-26", + "2022-02-27", + "2022-02-28", + "2022-03-01", + "2022-03-02", + "2022-03-03", + "2022-03-04", + "2022-03-05", + "2022-03-06", + "2022-03-07", + "2022-03-08", + "2022-03-09", + "2022-03-10", + "2022-03-11", + "2022-03-12", + "2022-03-13", + "2022-03-14", + "2022-03-15", + "2022-03-16", + "2022-03-17", + "2022-03-18", + "2022-03-19", + "2022-03-20", + "2022-03-21", + "2022-03-22", + "2022-03-23", + "2022-03-24", + "2022-03-25", + "2022-03-26", + "2022-03-27", + "2022-03-28", + "2022-03-29", + "2022-03-30", + "2022-03-31", + "2022-04-01", + "2022-04-02", + "2022-04-03", + "2022-04-04", + "2022-04-05", + "2022-04-06", + "2022-04-07", + "2022-04-08", + "2022-04-09", + "2022-04-10", + "2022-04-11", + "2022-04-12", + "2022-04-13", + "2022-04-14", + "2022-04-15", + "2022-04-16", + "2022-04-17", + "2022-04-18", + "2022-04-19", + "2022-04-20", + "2022-04-21", + "2022-04-22", + "2022-04-23", + "2022-04-24", + "2022-04-25", + "2022-04-26", + "2022-04-27", + "2022-04-28", + "2022-04-29", + "2022-04-30", + "2022-05-01", + "2022-05-02", + "2022-05-03", + "2022-05-04", + "2022-05-05", + "2022-05-06", + "2022-05-07", + "2022-05-08", + "2022-05-09", + "2022-05-10", + "2022-05-11", + "2022-05-12", + "2022-05-13", + "2022-05-14", + "2022-05-15", + "2022-05-16", + "2022-05-17", + "2022-05-18", + "2022-05-19", + "2022-05-20", + "2022-05-21", + "2022-05-22", + "2022-05-23", + "2022-05-24", + "2022-05-25", + "2022-05-26", + "2022-05-27", + "2022-05-28", + "2022-05-29", + "2022-05-30", + "2022-05-31", + "2022-06-01", + "2022-06-02", + "2022-06-03", + "2022-06-04", + "2022-06-05", + "2022-06-06", + "2022-06-07", + "2022-06-08", + "2022-06-09", + "2022-06-10", + "2022-06-11", + "2022-06-12", + "2022-06-13", + "2022-06-14", + "2022-06-15", + "2022-06-16", + "2022-06-17", + "2022-06-18", + "2022-06-19", + "2022-06-20", + "2022-06-21", + "2022-06-22", + "2022-06-23", + "2022-06-24", + "2022-06-25", + "2022-06-26", + "2022-06-27", + "2022-06-28", + "2022-06-29", + "2022-06-30", + "2022-07-01", + "2022-07-02", + "2022-07-03", + "2022-07-04", + "2022-07-05", + "2022-07-06", + "2022-07-07", + "2022-07-08", + "2022-07-09", + "2022-07-10", + "2022-07-11", + "2022-07-12", + "2022-07-13", + "2022-07-14", + "2022-07-15", + "2022-07-16", + "2022-07-17", + "2022-07-18", + "2022-07-19", + "2022-07-20", + "2022-07-21", + "2022-07-22", + "2022-07-23", + "2022-07-24", + "2022-07-25", + "2022-07-26", + "2022-07-27", + "2022-07-28", + "2022-07-29", + "2022-07-30", + "2022-07-31", + "2022-08-01", + "2022-08-02", + "2022-08-03", + "2022-08-04", + "2022-08-05", + "2022-08-06", + "2022-08-07", + "2022-08-08", + "2022-08-09", + "2022-08-10", + "2022-08-11", + "2022-08-12", + "2022-08-13", + "2022-08-14", + "2022-08-15", + "2022-08-16", + "2022-08-17", + "2022-08-18", + "2022-08-19", + "2022-08-20", + "2022-08-21", + "2022-08-22", + "2022-08-23", + "2022-08-24", + "2022-08-25", + "2022-08-26", + "2022-08-27", + "2022-08-28", + "2022-08-29", + "2022-08-30", + "2022-08-31", + "2022-09-01", + "2022-09-02", + "2022-09-03", + "2022-09-04", + "2022-09-05", + "2022-09-06", + "2022-09-07", + "2022-09-08", + "2022-09-09", + "2022-09-10", + "2022-09-11", + "2022-09-12", + "2022-09-13", + "2022-09-14", + "2022-09-15", + "2022-09-16", + "2022-09-17", + "2022-09-18", + "2022-09-19", + "2022-09-20", + "2022-09-21", + "2022-09-22", + "2022-09-23", + "2022-09-24", + "2022-09-25", + "2022-09-26", + "2022-09-27", + "2022-09-28", + "2022-09-29", + "2022-09-30", + "2022-10-01", + "2022-10-02", + "2022-10-03", + "2022-10-04", + "2022-10-05", + "2022-10-06", + "2022-10-07", + "2022-10-08", + "2022-10-09", + "2022-10-10", + "2022-10-11", + "2022-10-12", + "2022-10-13", + "2022-10-14", + "2022-10-15", + "2022-10-16", + "2022-10-17", + "2022-10-18", + "2022-10-19", + "2022-10-20", + "2022-10-21", + "2022-10-22", + "2022-10-23", + "2022-10-24", + "2022-10-25", + "2022-10-26", + "2022-10-27", + "2022-10-28", + "2022-10-29", + "2022-10-30", + "2022-10-31", + "2022-11-01", + "2022-11-02", + "2022-11-03", + "2022-11-04", + "2022-11-05", + "2022-11-06", + "2022-11-07", + "2022-11-08", + "2022-11-09", + "2022-11-10", + "2022-11-11", + "2022-11-12", + "2022-11-13", + "2022-11-14", + "2022-11-15", + "2022-11-16", + "2022-11-17", + "2022-11-18", + "2022-11-19", + "2022-11-20", + "2022-11-21", + "2022-11-22", + "2022-11-23", + "2022-11-24", + "2022-11-25", + "2022-11-26", + "2022-11-27", + "2022-11-28", + "2022-11-29", + "2022-11-30", + "2022-12-01", + "2022-12-02", + "2022-12-03", + "2022-12-04", + "2022-12-05", + "2022-12-06", + "2022-12-07", + "2022-12-08", + "2022-12-09", + "2022-12-10", + "2022-12-11", + "2022-12-12", + "2022-12-13", + "2022-12-14", + "2022-12-15", + "2022-12-16", + "2022-12-17", + "2022-12-18", + "2022-12-19", + "2022-12-20", + "2022-12-21", + "2022-12-22", + "2022-12-23", + "2022-12-24", + "2022-12-25", + "2022-12-26", + "2022-12-27", + "2022-12-28", + "2022-12-29", + "2022-12-30", + "2022-12-31" + ], + "agents": [ + { + "count": 1, + "debt_per_agent": 133333, + "total_system_debt": 20000000 + } + ], + "pools": { + "moet_yt": { + "size": 500000, + "concentration": 0.95, + "fee_tier": 0.0005 + }, + "moet_btc": { + "size": 5000000, + "concentration": 0.8, + "fee_tier": 0.003 + }, + "pyusd_btc": { + "size": 10000000, + "concentration": 0.8, + "fee_tier": 0.003 + }, + "moet_fusdev": { + "size": 500000, + "concentration": 0.95, + "fee_tier": 0.0001 + } + }, + "constants": { + "btc_collateral_factor": 0.8, + "btc_liquidation_threshold": 0.85, + "yield_apr": 0.1, + "direct_mint_yt": true + }, + "expected": { + "liquidation_count": 0, + "all_agents_survive": true + }, + "notes": "Daily BTC/USD close prices from CoinMarketCap, 2022-01-01 to 2022-12-31. 365 data points." +} \ No newline at end of file diff --git a/cadence/tests/scripts/simulations/btc_daily_2023_bull.json b/cadence/tests/scripts/simulations/btc_daily_2023_bull.json new file mode 100644 index 00000000..2d2afea7 --- /dev/null +++ b/cadence/tests/scripts/simulations/btc_daily_2023_bull.json @@ -0,0 +1,778 @@ +{ + "scenario": "btc_daily_2023_bull", + "duration_days": 365, + "btc_prices": [ + 16625.08, + 16688.47, + 16679.86, + 16863.24, + 16836.74, + 16951.97, + 16955.08, + 17091.14, + 17196.55, + 17446.29, + 17943.9, + 18869.59, + 19909.57, + 20976.3, + 20880.8, + 21169.63, + 21161.52, + 20688.78, + 21086.79, + 22676.55, + 22777.63, + 22720.42, + 22934.43, + 22636.47, + 23117.86, + 23032.78, + 23078.73, + 23031.09, + 23774.57, + 22840.14, + 23139.28, + 23723.77, + 23471.87, + 23449.32, + 23331.85, + 22955.67, + 22760.11, + 23264.29, + 22939.4, + 21819.04, + 21651.18, + 21870.87, + 21788.2, + 21808.1, + 22220.8, + 24307.84, + 23623.47, + 24565.6, + 24641.28, + 24327.64, + 24829.15, + 24436.35, + 24188.84, + 23947.49, + 23198.13, + 23175.38, + 23561.21, + 23522.87, + 23147.35, + 23646.55, + 23475.47, + 22362.68, + 22353.35, + 22435.51, + 22429.76, + 22219.77, + 21718.08, + 20363.02, + 20187.24, + 20632.41, + 22163.95, + 24197.53, + 24746.07, + 24375.96, + 25052.79, + 27423.93, + 26965.88, + 28038.67, + 27767.24, + 28175.82, + 27307.44, + 28333.97, + 27493.29, + 27494.71, + 27994.33, + 27139.89, + 27268.13, + 28348.44, + 28033.56, + 28478.48, + 28411.03, + 28199.31, + 27790.22, + 28168.09, + 28177.98, + 28044.14, + 27925.86, + 27947.79, + 28333.05, + 29652.98, + 30235.06, + 30139.05, + 30399.07, + 30485.7, + 30318.5, + 30315.36, + 29445.04, + 30397.55, + 28822.68, + 28245.99, + 27276.91, + 27817.5, + 27591.38, + 27525.34, + 28307.6, + 28422.7, + 29473.79, + 29340.26, + 29248.49, + 29268.81, + 28091.57, + 28680.54, + 29006.31, + 28847.71, + 29534.38, + 28904.62, + 28454.98, + 27694.27, + 27658.77, + 27621.76, + 27000.79, + 26804.99, + 26784.08, + 26930.64, + 27192.69, + 27036.65, + 27398.8, + 26832.21, + 26890.13, + 27129.59, + 26753.83, + 26851.28, + 27225.73, + 26334.82, + 26476.21, + 26719.29, + 26868.35, + 28085.65, + 27745.88, + 27702.35, + 27219.66, + 26819.97, + 27249.59, + 27075.13, + 27119.07, + 25760.1, + 27238.78, + 26346.0, + 26508.22, + 26480.38, + 25851.24, + 25940.17, + 25902.5, + 25918.73, + 25124.68, + 25576.39, + 26327.46, + 26510.68, + 26336.21, + 26851.03, + 28327.49, + 30027.3, + 29912.28, + 30695.47, + 30548.69, + 30480.26, + 30271.13, + 30688.16, + 30086.25, + 30445.35, + 30477.25, + 30590.08, + 30620.77, + 31156.44, + 30777.58, + 30514.17, + 29909.34, + 30342.26, + 30292.54, + 30171.23, + 30414.47, + 30620.95, + 30391.65, + 31476.05, + 30334.07, + 30295.81, + 30249.13, + 30145.89, + 29856.56, + 29913.92, + 29792.02, + 29908.74, + 29771.8, + 30084.54, + 29176.92, + 29227.39, + 29354.97, + 29210.69, + 29319.25, + 29356.92, + 29275.31, + 29230.11, + 29675.73, + 29151.96, + 29178.68, + 29074.09, + 29042.13, + 29041.86, + 29180.58, + 29765.49, + 29561.49, + 29429.59, + 29397.72, + 29415.96, + 29282.91, + 29408.44, + 29170.35, + 28701.78, + 26664.55, + 26049.56, + 26096.2, + 26189.58, + 26124.14, + 26031.66, + 26431.64, + 26162.37, + 26047.67, + 26008.46, + 26089.69, + 26106.15, + 27727.39, + 27297.27, + 25931.47, + 25800.72, + 25868.8, + 25969.57, + 25812.42, + 25779.98, + 25753.24, + 26240.19, + 25905.65, + 25895.68, + 25832.23, + 25162.66, + 25833.34, + 26228.32, + 26539.67, + 26608.69, + 26568.28, + 26534.19, + 26754.28, + 27211.12, + 27132.01, + 26567.63, + 26579.57, + 26579.39, + 26256.83, + 26298.48, + 26217.25, + 26352.72, + 27021.55, + 26911.72, + 26967.92, + 27983.75, + 27530.78, + 27429.98, + 27799.39, + 27415.91, + 27946.6, + 27968.84, + 27935.09, + 27583.68, + 27391.02, + 26873.32, + 26756.8, + 26862.38, + 26861.71, + 27159.65, + 28519.47, + 28415.75, + 28328.34, + 28719.81, + 29682.95, + 29918.41, + 29993.9, + 33086.23, + 33901.53, + 34502.82, + 34156.65, + 33909.8, + 34089.58, + 34538.48, + 34502.36, + 34667.78, + 35437.25, + 34938.24, + 34732.33, + 35082.2, + 35049.36, + 35037.37, + 35443.56, + 35655.28, + 36693.12, + 37313.97, + 37138.05, + 37054.52, + 36502.36, + 35537.64, + 37880.58, + 36154.77, + 36596.68, + 36585.7, + 37386.55, + 37476.96, + 35813.81, + 37432.34, + 37289.62, + 37720.28, + 37796.79, + 37479.12, + 37254.17, + 37831.09, + 37858.49, + 37712.75, + 38688.75, + 39476.33, + 39978.39, + 41980.1, + 44080.65, + 43746.45, + 43292.66, + 44166.6, + 43725.99, + 43779.7, + 41243.83, + 41450.22, + 42890.74, + 43023.97, + 41929.76, + 42240.12, + 41364.67, + 42623.54, + 42270.53, + 43652.25, + 43869.15, + 43997.9, + 43739.54, + 43016.12, + 43613.14, + 42520.4, + 43442.85, + 42627.85, + 42099.4, + 42156.9, + 42265.19 + ], + "dates": [ + "2023-01-01", + "2023-01-02", + "2023-01-03", + "2023-01-04", + "2023-01-05", + "2023-01-06", + "2023-01-07", + "2023-01-08", + "2023-01-09", + "2023-01-10", + "2023-01-11", + "2023-01-12", + "2023-01-13", + "2023-01-14", + "2023-01-15", + "2023-01-16", + "2023-01-17", + "2023-01-18", + "2023-01-19", + "2023-01-20", + "2023-01-21", + "2023-01-22", + "2023-01-23", + "2023-01-24", + "2023-01-25", + "2023-01-26", + "2023-01-27", + "2023-01-28", + "2023-01-29", + "2023-01-30", + "2023-01-31", + "2023-02-01", + "2023-02-02", + "2023-02-03", + "2023-02-04", + "2023-02-05", + "2023-02-06", + "2023-02-07", + "2023-02-08", + "2023-02-09", + "2023-02-10", + "2023-02-11", + "2023-02-12", + "2023-02-13", + "2023-02-14", + "2023-02-15", + "2023-02-16", + "2023-02-17", + "2023-02-18", + "2023-02-19", + "2023-02-20", + "2023-02-21", + "2023-02-22", + "2023-02-23", + "2023-02-24", + "2023-02-25", + "2023-02-26", + "2023-02-27", + "2023-02-28", + "2023-03-01", + "2023-03-02", + "2023-03-03", + "2023-03-04", + "2023-03-05", + "2023-03-06", + "2023-03-07", + "2023-03-08", + "2023-03-09", + "2023-03-10", + "2023-03-11", + "2023-03-12", + "2023-03-13", + "2023-03-14", + "2023-03-15", + "2023-03-16", + "2023-03-17", + "2023-03-18", + "2023-03-19", + "2023-03-20", + "2023-03-21", + "2023-03-22", + "2023-03-23", + "2023-03-24", + "2023-03-25", + "2023-03-26", + "2023-03-27", + "2023-03-28", + "2023-03-29", + "2023-03-30", + "2023-03-31", + "2023-04-01", + "2023-04-02", + "2023-04-03", + "2023-04-04", + "2023-04-05", + "2023-04-06", + "2023-04-07", + "2023-04-08", + "2023-04-09", + "2023-04-10", + "2023-04-11", + "2023-04-12", + "2023-04-13", + "2023-04-14", + "2023-04-15", + "2023-04-16", + "2023-04-17", + "2023-04-18", + "2023-04-19", + "2023-04-20", + "2023-04-21", + "2023-04-22", + "2023-04-23", + "2023-04-24", + "2023-04-25", + "2023-04-26", + "2023-04-27", + "2023-04-28", + "2023-04-29", + "2023-04-30", + "2023-05-01", + "2023-05-02", + "2023-05-03", + "2023-05-04", + "2023-05-05", + "2023-05-06", + "2023-05-07", + "2023-05-08", + "2023-05-09", + "2023-05-10", + "2023-05-11", + "2023-05-12", + "2023-05-13", + "2023-05-14", + "2023-05-15", + "2023-05-16", + "2023-05-17", + "2023-05-18", + "2023-05-19", + "2023-05-20", + "2023-05-21", + "2023-05-22", + "2023-05-23", + "2023-05-24", + "2023-05-25", + "2023-05-26", + "2023-05-27", + "2023-05-28", + "2023-05-29", + "2023-05-30", + "2023-05-31", + "2023-06-01", + "2023-06-02", + "2023-06-03", + "2023-06-04", + "2023-06-05", + "2023-06-06", + "2023-06-07", + "2023-06-08", + "2023-06-09", + "2023-06-10", + "2023-06-11", + "2023-06-12", + "2023-06-13", + "2023-06-14", + "2023-06-15", + "2023-06-16", + "2023-06-17", + "2023-06-18", + "2023-06-19", + "2023-06-20", + "2023-06-21", + "2023-06-22", + "2023-06-23", + "2023-06-24", + "2023-06-25", + "2023-06-26", + "2023-06-27", + "2023-06-28", + "2023-06-29", + "2023-06-30", + "2023-07-01", + "2023-07-02", + "2023-07-03", + "2023-07-04", + "2023-07-05", + "2023-07-06", + "2023-07-07", + "2023-07-08", + "2023-07-09", + "2023-07-10", + "2023-07-11", + "2023-07-12", + "2023-07-13", + "2023-07-14", + "2023-07-15", + "2023-07-16", + "2023-07-17", + "2023-07-18", + "2023-07-19", + "2023-07-20", + "2023-07-21", + "2023-07-22", + "2023-07-23", + "2023-07-24", + "2023-07-25", + "2023-07-26", + "2023-07-27", + "2023-07-28", + "2023-07-29", + "2023-07-30", + "2023-07-31", + "2023-08-01", + "2023-08-02", + "2023-08-03", + "2023-08-04", + "2023-08-05", + "2023-08-06", + "2023-08-07", + "2023-08-08", + "2023-08-09", + "2023-08-10", + "2023-08-11", + "2023-08-12", + "2023-08-13", + "2023-08-14", + "2023-08-15", + "2023-08-16", + "2023-08-17", + "2023-08-18", + "2023-08-19", + "2023-08-20", + "2023-08-21", + "2023-08-22", + "2023-08-23", + "2023-08-24", + "2023-08-25", + "2023-08-26", + "2023-08-27", + "2023-08-28", + "2023-08-29", + "2023-08-30", + "2023-08-31", + "2023-09-01", + "2023-09-02", + "2023-09-03", + "2023-09-04", + "2023-09-05", + "2023-09-06", + "2023-09-07", + "2023-09-08", + "2023-09-09", + "2023-09-10", + "2023-09-11", + "2023-09-12", + "2023-09-13", + "2023-09-14", + "2023-09-15", + "2023-09-16", + "2023-09-17", + "2023-09-18", + "2023-09-19", + "2023-09-20", + "2023-09-21", + "2023-09-22", + "2023-09-23", + "2023-09-24", + "2023-09-25", + "2023-09-26", + "2023-09-27", + "2023-09-28", + "2023-09-29", + "2023-09-30", + "2023-10-01", + "2023-10-02", + "2023-10-03", + "2023-10-04", + "2023-10-05", + "2023-10-06", + "2023-10-07", + "2023-10-08", + "2023-10-09", + "2023-10-10", + "2023-10-11", + "2023-10-12", + "2023-10-13", + "2023-10-14", + "2023-10-15", + "2023-10-16", + "2023-10-17", + "2023-10-18", + "2023-10-19", + "2023-10-20", + "2023-10-21", + "2023-10-22", + "2023-10-23", + "2023-10-24", + "2023-10-25", + "2023-10-26", + "2023-10-27", + "2023-10-28", + "2023-10-29", + "2023-10-30", + "2023-10-31", + "2023-11-01", + "2023-11-02", + "2023-11-03", + "2023-11-04", + "2023-11-05", + "2023-11-06", + "2023-11-07", + "2023-11-08", + "2023-11-09", + "2023-11-10", + "2023-11-11", + "2023-11-12", + "2023-11-13", + "2023-11-14", + "2023-11-15", + "2023-11-16", + "2023-11-17", + "2023-11-18", + "2023-11-19", + "2023-11-20", + "2023-11-21", + "2023-11-22", + "2023-11-23", + "2023-11-24", + "2023-11-25", + "2023-11-26", + "2023-11-27", + "2023-11-28", + "2023-11-29", + "2023-11-30", + "2023-12-01", + "2023-12-02", + "2023-12-03", + "2023-12-04", + "2023-12-05", + "2023-12-06", + "2023-12-07", + "2023-12-08", + "2023-12-09", + "2023-12-10", + "2023-12-11", + "2023-12-12", + "2023-12-13", + "2023-12-14", + "2023-12-15", + "2023-12-16", + "2023-12-17", + "2023-12-18", + "2023-12-19", + "2023-12-20", + "2023-12-21", + "2023-12-22", + "2023-12-23", + "2023-12-24", + "2023-12-25", + "2023-12-26", + "2023-12-27", + "2023-12-28", + "2023-12-29", + "2023-12-30", + "2023-12-31" + ], + "agents": [ + { + "count": 1, + "debt_per_agent": 133333, + "total_system_debt": 20000000 + } + ], + "pools": { + "moet_yt": { + "size": 500000, + "concentration": 0.95, + "fee_tier": 0.0005 + }, + "moet_btc": { + "size": 5000000, + "concentration": 0.8, + "fee_tier": 0.003 + }, + "pyusd_btc": { + "size": 10000000, + "concentration": 0.8, + "fee_tier": 0.003 + }, + "moet_fusdev": { + "size": 500000, + "concentration": 0.95, + "fee_tier": 0.0001 + } + }, + "constants": { + "btc_collateral_factor": 0.8, + "btc_liquidation_threshold": 0.85, + "yield_apr": 0.1, + "direct_mint_yt": true + }, + "expected": { + "liquidation_count": 0, + "all_agents_survive": true + }, + "notes": "Daily BTC/USD close prices from CoinMarketCap, 2023-01-01 to 2023-12-31. 365 data points." +} \ No newline at end of file diff --git a/cadence/tests/scripts/simulations/btc_daily_2024_bull.json b/cadence/tests/scripts/simulations/btc_daily_2024_bull.json new file mode 100644 index 00000000..efddd606 --- /dev/null +++ b/cadence/tests/scripts/simulations/btc_daily_2024_bull.json @@ -0,0 +1,780 @@ +{ + "scenario": "btc_daily_2024_bull", + "duration_days": 366, + "btc_prices": [ + 44167.33, + 44957.97, + 42848.18, + 44179.92, + 44162.69, + 43989.19, + 43943.1, + 46970.5, + 46139.73, + 46627.78, + 46368.59, + 42853.17, + 42842.38, + 41796.27, + 42511.97, + 43154.94, + 42742.65, + 41262.06, + 41618.41, + 41665.58, + 41545.78, + 39507.37, + 39845.55, + 40077.07, + 39933.81, + 41816.87, + 42120.06, + 42035.59, + 43288.25, + 42952.61, + 42582.61, + 43075.77, + 43185.86, + 42992.25, + 42583.58, + 42658.67, + 43084.67, + 44318.22, + 45301.57, + 47147.2, + 47771.28, + 48293.92, + 49958.22, + 49742.44, + 51826.7, + 51938.56, + 52160.2, + 51663.0, + 52122.55, + 51779.14, + 52284.87, + 51839.18, + 51304.97, + 50731.95, + 51571.1, + 51733.24, + 54522.4, + 57085.37, + 62504.79, + 61198.38, + 62440.63, + 62029.85, + 63167.37, + 68330.42, + 63801.2, + 66106.8, + 66925.48, + 68300.1, + 68498.88, + 69019.79, + 72123.9, + 71481.29, + 73083.5, + 71396.59, + 69403.77, + 65315.12, + 68390.62, + 67548.59, + 61912.77, + 67913.67, + 65491.39, + 63778.76, + 64062.2, + 67234.17, + 69958.81, + 69987.84, + 69455.34, + 70744.95, + 69892.83, + 69645.31, + 71333.65, + 69702.15, + 65446.97, + 65980.81, + 68508.84, + 67837.64, + 68896.11, + 69362.55, + 71631.36, + 69139.02, + 70587.88, + 70060.61, + 67195.86, + 63821.47, + 65738.72, + 63426.21, + 63811.86, + 61276.69, + 63512.75, + 63843.57, + 64994.44, + 64926.64, + 66837.68, + 66407.27, + 64276.9, + 64481.71, + 63755.32, + 63419.14, + 63113.23, + 63841.12, + 60636.86, + 58254.01, + 59123.43, + 62889.84, + 63891.47, + 64031.13, + 63161.95, + 62334.82, + 61187.94, + 63049.96, + 60792.78, + 60793.71, + 61448.39, + 62901.45, + 61552.79, + 66267.49, + 65231.58, + 67051.87, + 66940.8, + 66278.37, + 71448.2, + 70136.53, + 69122.34, + 67929.56, + 68526.1, + 69265.94, + 68518.09, + 69394.55, + 68296.22, + 67578.09, + 68364.99, + 67489.61, + 67706.94, + 67751.6, + 68804.78, + 70567.77, + 71082.82, + 70757.17, + 69342.59, + 69305.77, + 69647.99, + 69512.28, + 67332.03, + 68241.18, + 66756.4, + 66011.09, + 66191.0, + 66639.05, + 66490.29, + 65140.74, + 64960.3, + 64828.66, + 64096.2, + 64252.58, + 63180.8, + 60277.41, + 61804.64, + 60811.28, + 61604.8, + 60320.14, + 60887.38, + 62678.29, + 62851.98, + 62029.02, + 60173.92, + 56977.7, + 56662.37, + 58303.54, + 55849.11, + 56705.1, + 58009.23, + 57742.49, + 57344.91, + 57899.47, + 59231.95, + 60787.79, + 64870.15, + 65097.15, + 64118.79, + 63974.07, + 66710.15, + 67163.64, + 68154.52, + 67585.25, + 65927.67, + 65372.13, + 65777.22, + 67912.06, + 67813.34, + 68255.87, + 66819.92, + 66201.02, + 64619.25, + 65357.5, + 61415.06, + 60680.09, + 58116.98, + 53991.46, + 56034.32, + 55027.46, + 61710.14, + 60880.11, + 60945.81, + 58719.48, + 59354.51, + 60609.57, + 58737.27, + 57560.1, + 58894.1, + 59478.97, + 58483.96, + 59493.45, + 59012.79, + 61175.19, + 60381.91, + 64094.36, + 64178.99, + 64333.54, + 62880.66, + 59504.13, + 59027.63, + 59388.18, + 59119.47, + 58969.9, + 57325.49, + 59112.48, + 57431.02, + 57971.54, + 56160.49, + 53948.75, + 54139.69, + 54841.57, + 57019.53, + 57648.71, + 57343.17, + 58127.01, + 60571.3, + 60005.12, + 59182.84, + 58192.51, + 60308.54, + 61649.68, + 62940.46, + 63192.98, + 63394.84, + 63648.71, + 63329.8, + 64301.97, + 63143.15, + 65181.02, + 65790.66, + 65887.65, + 65635.31, + 63329.5, + 60837.01, + 60632.79, + 60759.4, + 62067.48, + 62089.95, + 62818.95, + 62236.66, + 62131.97, + 60582.1, + 60274.5, + 62445.09, + 63193.02, + 62851.37, + 66046.13, + 67041.11, + 67612.72, + 67399.83, + 68418.79, + 68362.73, + 69001.71, + 67367.85, + 67361.4, + 66432.2, + 68161.05, + 66642.41, + 67014.7, + 67929.3, + 69907.75, + 72720.49, + 72339.54, + 70215.19, + 69482.47, + 69289.28, + 68741.12, + 67811.51, + 69359.57, + 75639.08, + 75904.86, + 76545.48, + 76778.87, + 80474.19, + 88701.49, + 87955.81, + 90584.17, + 87250.43, + 91066.01, + 90558.48, + 89845.85, + 90542.64, + 92343.79, + 94339.5, + 98504.73, + 98997.66, + 97777.28, + 98013.82, + 93102.3, + 91985.32, + 95962.53, + 95652.47, + 97461.52, + 96449.06, + 97279.79, + 95865.3, + 96002.16, + 98768.53, + 96593.57, + 99920.71, + 99923.34, + 101236.01, + 97432.72, + 96675.43, + 101173.03, + 100043.0, + 101459.25, + 101372.97, + 104298.7, + 106029.72, + 106140.6, + 100041.54, + 97490.95, + 97755.93, + 97224.73, + 95104.93, + 94686.24, + 98676.1, + 99299.19, + 95795.52, + 94164.86, + 95163.93, + 93530.23, + 92643.21, + 93429.2 + ], + "dates": [ + "2024-01-01", + "2024-01-02", + "2024-01-03", + "2024-01-04", + "2024-01-05", + "2024-01-06", + "2024-01-07", + "2024-01-08", + "2024-01-09", + "2024-01-10", + "2024-01-11", + "2024-01-12", + "2024-01-13", + "2024-01-14", + "2024-01-15", + "2024-01-16", + "2024-01-17", + "2024-01-18", + "2024-01-19", + "2024-01-20", + "2024-01-21", + "2024-01-22", + "2024-01-23", + "2024-01-24", + "2024-01-25", + "2024-01-26", + "2024-01-27", + "2024-01-28", + "2024-01-29", + "2024-01-30", + "2024-01-31", + "2024-02-01", + "2024-02-02", + "2024-02-03", + "2024-02-04", + "2024-02-05", + "2024-02-06", + "2024-02-07", + "2024-02-08", + "2024-02-09", + "2024-02-10", + "2024-02-11", + "2024-02-12", + "2024-02-13", + "2024-02-14", + "2024-02-15", + "2024-02-16", + "2024-02-17", + "2024-02-18", + "2024-02-19", + "2024-02-20", + "2024-02-21", + "2024-02-22", + "2024-02-23", + "2024-02-24", + "2024-02-25", + "2024-02-26", + "2024-02-27", + "2024-02-28", + "2024-02-29", + "2024-03-01", + "2024-03-02", + "2024-03-03", + "2024-03-04", + "2024-03-05", + "2024-03-06", + "2024-03-07", + "2024-03-08", + "2024-03-09", + "2024-03-10", + "2024-03-11", + "2024-03-12", + "2024-03-13", + "2024-03-14", + "2024-03-15", + "2024-03-16", + "2024-03-17", + "2024-03-18", + "2024-03-19", + "2024-03-20", + "2024-03-21", + "2024-03-22", + "2024-03-23", + "2024-03-24", + "2024-03-25", + "2024-03-26", + "2024-03-27", + "2024-03-28", + "2024-03-29", + "2024-03-30", + "2024-03-31", + "2024-04-01", + "2024-04-02", + "2024-04-03", + "2024-04-04", + "2024-04-05", + "2024-04-06", + "2024-04-07", + "2024-04-08", + "2024-04-09", + "2024-04-10", + "2024-04-11", + "2024-04-12", + "2024-04-13", + "2024-04-14", + "2024-04-15", + "2024-04-16", + "2024-04-17", + "2024-04-18", + "2024-04-19", + "2024-04-20", + "2024-04-21", + "2024-04-22", + "2024-04-23", + "2024-04-24", + "2024-04-25", + "2024-04-26", + "2024-04-27", + "2024-04-28", + "2024-04-29", + "2024-04-30", + "2024-05-01", + "2024-05-02", + "2024-05-03", + "2024-05-04", + "2024-05-05", + "2024-05-06", + "2024-05-07", + "2024-05-08", + "2024-05-09", + "2024-05-10", + "2024-05-11", + "2024-05-12", + "2024-05-13", + "2024-05-14", + "2024-05-15", + "2024-05-16", + "2024-05-17", + "2024-05-18", + "2024-05-19", + "2024-05-20", + "2024-05-21", + "2024-05-22", + "2024-05-23", + "2024-05-24", + "2024-05-25", + "2024-05-26", + "2024-05-27", + "2024-05-28", + "2024-05-29", + "2024-05-30", + "2024-05-31", + "2024-06-01", + "2024-06-02", + "2024-06-03", + "2024-06-04", + "2024-06-05", + "2024-06-06", + "2024-06-07", + "2024-06-08", + "2024-06-09", + "2024-06-10", + "2024-06-11", + "2024-06-12", + "2024-06-13", + "2024-06-14", + "2024-06-15", + "2024-06-16", + "2024-06-17", + "2024-06-18", + "2024-06-19", + "2024-06-20", + "2024-06-21", + "2024-06-22", + "2024-06-23", + "2024-06-24", + "2024-06-25", + "2024-06-26", + "2024-06-27", + "2024-06-28", + "2024-06-29", + "2024-06-30", + "2024-07-01", + "2024-07-02", + "2024-07-03", + "2024-07-04", + "2024-07-05", + "2024-07-06", + "2024-07-07", + "2024-07-08", + "2024-07-09", + "2024-07-10", + "2024-07-11", + "2024-07-12", + "2024-07-13", + "2024-07-14", + "2024-07-15", + "2024-07-16", + "2024-07-17", + "2024-07-18", + "2024-07-19", + "2024-07-20", + "2024-07-21", + "2024-07-22", + "2024-07-23", + "2024-07-24", + "2024-07-25", + "2024-07-26", + "2024-07-27", + "2024-07-28", + "2024-07-29", + "2024-07-30", + "2024-07-31", + "2024-08-01", + "2024-08-02", + "2024-08-03", + "2024-08-04", + "2024-08-05", + "2024-08-06", + "2024-08-07", + "2024-08-08", + "2024-08-09", + "2024-08-10", + "2024-08-11", + "2024-08-12", + "2024-08-13", + "2024-08-14", + "2024-08-15", + "2024-08-16", + "2024-08-17", + "2024-08-18", + "2024-08-19", + "2024-08-20", + "2024-08-21", + "2024-08-22", + "2024-08-23", + "2024-08-24", + "2024-08-25", + "2024-08-26", + "2024-08-27", + "2024-08-28", + "2024-08-29", + "2024-08-30", + "2024-08-31", + "2024-09-01", + "2024-09-02", + "2024-09-03", + "2024-09-04", + "2024-09-05", + "2024-09-06", + "2024-09-07", + "2024-09-08", + "2024-09-09", + "2024-09-10", + "2024-09-11", + "2024-09-12", + "2024-09-13", + "2024-09-14", + "2024-09-15", + "2024-09-16", + "2024-09-17", + "2024-09-18", + "2024-09-19", + "2024-09-20", + "2024-09-21", + "2024-09-22", + "2024-09-23", + "2024-09-24", + "2024-09-25", + "2024-09-26", + "2024-09-27", + "2024-09-28", + "2024-09-29", + "2024-09-30", + "2024-10-01", + "2024-10-02", + "2024-10-03", + "2024-10-04", + "2024-10-05", + "2024-10-06", + "2024-10-07", + "2024-10-08", + "2024-10-09", + "2024-10-10", + "2024-10-11", + "2024-10-12", + "2024-10-13", + "2024-10-14", + "2024-10-15", + "2024-10-16", + "2024-10-17", + "2024-10-18", + "2024-10-19", + "2024-10-20", + "2024-10-21", + "2024-10-22", + "2024-10-23", + "2024-10-24", + "2024-10-25", + "2024-10-26", + "2024-10-27", + "2024-10-28", + "2024-10-29", + "2024-10-30", + "2024-10-31", + "2024-11-01", + "2024-11-02", + "2024-11-03", + "2024-11-04", + "2024-11-05", + "2024-11-06", + "2024-11-07", + "2024-11-08", + "2024-11-09", + "2024-11-10", + "2024-11-11", + "2024-11-12", + "2024-11-13", + "2024-11-14", + "2024-11-15", + "2024-11-16", + "2024-11-17", + "2024-11-18", + "2024-11-19", + "2024-11-20", + "2024-11-21", + "2024-11-22", + "2024-11-23", + "2024-11-24", + "2024-11-25", + "2024-11-26", + "2024-11-27", + "2024-11-28", + "2024-11-29", + "2024-11-30", + "2024-12-01", + "2024-12-02", + "2024-12-03", + "2024-12-04", + "2024-12-05", + "2024-12-06", + "2024-12-07", + "2024-12-08", + "2024-12-09", + "2024-12-10", + "2024-12-11", + "2024-12-12", + "2024-12-13", + "2024-12-14", + "2024-12-15", + "2024-12-16", + "2024-12-17", + "2024-12-18", + "2024-12-19", + "2024-12-20", + "2024-12-21", + "2024-12-22", + "2024-12-23", + "2024-12-24", + "2024-12-25", + "2024-12-26", + "2024-12-27", + "2024-12-28", + "2024-12-29", + "2024-12-30", + "2024-12-31" + ], + "agents": [ + { + "count": 1, + "debt_per_agent": 133333, + "total_system_debt": 20000000 + } + ], + "pools": { + "moet_yt": { + "size": 500000, + "concentration": 0.95, + "fee_tier": 0.0005 + }, + "moet_btc": { + "size": 5000000, + "concentration": 0.8, + "fee_tier": 0.003 + }, + "pyusd_btc": { + "size": 10000000, + "concentration": 0.8, + "fee_tier": 0.003 + }, + "moet_fusdev": { + "size": 500000, + "concentration": 0.95, + "fee_tier": 0.0001 + } + }, + "constants": { + "btc_collateral_factor": 0.8, + "btc_liquidation_threshold": 0.85, + "yield_apr": 0.1, + "direct_mint_yt": true + }, + "expected": { + "liquidation_count": 0, + "all_agents_survive": true + }, + "notes": "Daily BTC/USD close prices from CoinMarketCap, 2024-01-01 to 2024-12-31. 366 data points." +} \ No newline at end of file diff --git a/cadence/tests/scripts/simulations/btc_daily_2025.json b/cadence/tests/scripts/simulations/btc_daily_2025.json deleted file mode 100644 index 1a37d105..00000000 --- a/cadence/tests/scripts/simulations/btc_daily_2025.json +++ /dev/null @@ -1,781 +0,0 @@ -{ - "scenario": "btc_daily_2025", - "duration_days": 365, - "btc_prices": [ - 94419.76, - 96886.88, - 98107.43, - 98236.23, - 98314.96, - 102078.09, - 96922.71, - 95043.52, - 92484.04, - 94701.46, - 94566.59, - 94488.44, - 94516.53, - 96534.04, - 100504.49, - 99756.91, - 104462.04, - 104408.07, - 101089.61, - 102016.66, - 106146.26, - 103653.07, - 103960.17, - 104819.48, - 104714.65, - 102682.5, - 102087.69, - 101332.48, - 103703.21, - 104735.3, - 102405.03, - 100655.91, - 97688.98, - 101405.42, - 97871.82, - 96615.44, - 96593.3, - 96529.08, - 96482.45, - 96500.09, - 97437.56, - 95747.43, - 97885.86, - 96623.87, - 97508.97, - 97580.35, - 96175.03, - 95773.38, - 95539.54, - 96635.61, - 98333.94, - 96125.54, - 96577.76, - 96273.92, - 91418.17, - 88736.17, - 84347.02, - 84704.22, - 84373.01, - 86031.91, - 94248.35, - 86065.67, - 87222.19, - 90623.56, - 89961.73, - 86742.68, - 86154.59, - 80601.04, - 78532.0, - 82862.21, - 83722.36, - 81066.7, - 83969.1, - 84343.11, - 82579.69, - 84075.69, - 82718.5, - 86854.23, - 84167.19, - 84043.25, - 83832.49, - 86054.37, - 87498.91, - 87471.7, - 86900.89, - 87177.1, - 84353.15, - 82597.58, - 82334.52, - 82548.91, - 85169.17, - 82485.71, - 83102.83, - 83843.8, - 83504.8, - 78214.48, - 79235.33, - 76271.95, - 82573.95, - 79626.14, - 83404.84, - 85287.11, - 83684.98, - 84542.39, - 83668.99, - 84033.87, - 84895.75, - 84450.81, - 85063.41, - 85174.3, - 87518.91, - 93441.89, - 93699.11, - 93943.79, - 94720.5, - 94646.93, - 93754.85, - 94978.75, - 94284.79, - 94207.31, - 96492.34, - 96910.07, - 95891.8, - 94315.97, - 94748.05, - 96802.48, - 97032.32, - 103241.46, - 102970.85, - 104696.33, - 104106.36, - 102812.95, - 104169.81, - 103539.42, - 103744.64, - 103489.29, - 103191.09, - 106446.01, - 105606.18, - 106791.09, - 109678.08, - 111673.28, - 107287.8, - 107791.16, - 109035.39, - 109440.37, - 108994.64, - 107802.32, - 105641.76, - 103998.57, - 104638.09, - 105652.1, - 105881.53, - 105432.47, - 104731.98, - 101575.95, - 104390.35, - 105615.63, - 105793.65, - 110294.1, - 110257.24, - 108686.63, - 105929.05, - 106090.97, - 105472.41, - 105552.03, - 106796.76, - 104601.12, - 104883.33, - 104684.29, - 103309.6, - 102257.41, - 100987.14, - 105577.77, - 106045.63, - 107361.26, - 106960.0, - 107088.43, - 107327.7, - 108385.57, - 107135.33, - 105698.28, - 108859.32, - 109647.98, - 108034.34, - 108231.18, - 109232.07, - 108299.85, - 108950.28, - 111326.55, - 115987.21, - 117516.99, - 117435.23, - 119116.12, - 119849.71, - 117777.19, - 118738.51, - 119289.84, - 118003.22, - 117939.98, - 117300.79, - 117439.54, - 119995.42, - 118754.96, - 118368.0, - 117635.88, - 117947.37, - 119448.49, - 117924.47, - 117922.15, - 117831.19, - 115758.2, - 113320.09, - 112526.91, - 114217.67, - 115071.88, - 114141.44, - 115028.0, - 117496.9, - 116688.73, - 116500.36, - 119306.76, - 118731.45, - 120172.91, - 123344.06, - 118359.58, - 117398.35, - 117491.35, - 117453.06, - 116252.31, - 112831.18, - 114274.74, - 112419.03, - 116874.09, - 115374.33, - 113458.43, - 110124.35, - 111802.66, - 111222.06, - 112544.8, - 108410.84, - 108808.07, - 108236.71, - 109250.59, - 111200.59, - 111723.21, - 110723.6, - 110650.99, - 110224.7, - 111167.62, - 112071.43, - 111530.55, - 113955.36, - 115507.54, - 116101.58, - 115950.51, - 115407.65, - 115444.87, - 116843.18, - 116468.51, - 117137.2, - 115688.86, - 115721.96, - 115306.1, - 112748.51, - 112014.5, - 113328.63, - 109049.29, - 109712.83, - 109681.94, - 112122.64, - 114400.39, - 114056.08, - 118648.93, - 120681.26, - 122266.53, - 122425.43, - 123513.47, - 124752.53, - 121451.38, - 123354.87, - 121705.58, - 113214.37, - 110807.88, - 115169.76, - 115271.08, - 113118.67, - 110783.17, - 108186.04, - 106467.79, - 107198.27, - 108666.71, - 110588.93, - 108476.89, - 107688.59, - 110069.72, - 111033.92, - 111641.73, - 114472.44, - 114119.32, - 112956.17, - 110055.3, - 108305.55, - 109556.16, - 110064.02, - 110639.63, - 106547.52, - 101590.52, - 103891.84, - 101301.29, - 103372.41, - 102282.11, - 104719.64, - 105996.6, - 102997.47, - 101663.19, - 99697.49, - 94397.79, - 95549.15, - 94177.07, - 92093.87, - 92948.87, - 91465.99, - 86631.9, - 85090.69, - 84648.36, - 86805.01, - 88270.56, - 87341.89, - 90518.37, - 91285.37, - 90919.27, - 90851.75, - 90394.31, - 86321.57, - 91350.21, - 93527.8, - 92141.62, - 89387.75, - 89272.37, - 90405.64, - 90640.21, - 92691.71, - 92020.95, - 92511.34, - 90270.41, - 90298.71, - 88175.18, - 86419.78, - 87843.99, - 86143.76, - 85462.51, - 88103.38, - 88344.0, - 88621.75, - 88490.02, - 87414.0, - 87611.96, - 87234.74, - 87301.43, - 87802.16, - 87835.83, - 87138.14, - 88430.14, - 87508.83 - ], - "dates": [ - "2025-01-01", - "2025-01-02", - "2025-01-03", - "2025-01-04", - "2025-01-05", - "2025-01-06", - "2025-01-07", - "2025-01-08", - "2025-01-09", - "2025-01-10", - "2025-01-11", - "2025-01-12", - "2025-01-13", - "2025-01-14", - "2025-01-15", - "2025-01-16", - "2025-01-17", - "2025-01-18", - "2025-01-19", - "2025-01-20", - "2025-01-21", - "2025-01-22", - "2025-01-23", - "2025-01-24", - "2025-01-25", - "2025-01-26", - "2025-01-27", - "2025-01-28", - "2025-01-29", - "2025-01-30", - "2025-01-31", - "2025-02-01", - "2025-02-02", - "2025-02-03", - "2025-02-04", - "2025-02-05", - "2025-02-06", - "2025-02-07", - "2025-02-08", - "2025-02-09", - "2025-02-10", - "2025-02-11", - "2025-02-12", - "2025-02-13", - "2025-02-14", - "2025-02-15", - "2025-02-16", - "2025-02-17", - "2025-02-18", - "2025-02-19", - "2025-02-20", - "2025-02-21", - "2025-02-22", - "2025-02-23", - "2025-02-24", - "2025-02-25", - "2025-02-26", - "2025-02-27", - "2025-02-28", - "2025-03-01", - "2025-03-02", - "2025-03-03", - "2025-03-04", - "2025-03-05", - "2025-03-06", - "2025-03-07", - "2025-03-08", - "2025-03-09", - "2025-03-10", - "2025-03-11", - "2025-03-12", - "2025-03-13", - "2025-03-14", - "2025-03-15", - "2025-03-16", - "2025-03-17", - "2025-03-18", - "2025-03-19", - "2025-03-20", - "2025-03-21", - "2025-03-22", - "2025-03-23", - "2025-03-24", - "2025-03-25", - "2025-03-26", - "2025-03-27", - "2025-03-28", - "2025-03-29", - "2025-03-30", - "2025-03-31", - "2025-04-01", - "2025-04-02", - "2025-04-03", - "2025-04-04", - "2025-04-05", - "2025-04-06", - "2025-04-07", - "2025-04-08", - "2025-04-09", - "2025-04-10", - "2025-04-11", - "2025-04-12", - "2025-04-13", - "2025-04-14", - "2025-04-15", - "2025-04-16", - "2025-04-17", - "2025-04-18", - "2025-04-19", - "2025-04-20", - "2025-04-21", - "2025-04-22", - "2025-04-23", - "2025-04-24", - "2025-04-25", - "2025-04-26", - "2025-04-27", - "2025-04-28", - "2025-04-29", - "2025-04-30", - "2025-05-01", - "2025-05-02", - "2025-05-03", - "2025-05-04", - "2025-05-05", - "2025-05-06", - "2025-05-07", - "2025-05-08", - "2025-05-09", - "2025-05-10", - "2025-05-11", - "2025-05-12", - "2025-05-13", - "2025-05-14", - "2025-05-15", - "2025-05-16", - "2025-05-17", - "2025-05-18", - "2025-05-19", - "2025-05-20", - "2025-05-21", - "2025-05-22", - "2025-05-23", - "2025-05-24", - "2025-05-25", - "2025-05-26", - "2025-05-27", - "2025-05-28", - "2025-05-29", - "2025-05-30", - "2025-05-31", - "2025-06-01", - "2025-06-02", - "2025-06-03", - "2025-06-04", - "2025-06-05", - "2025-06-06", - "2025-06-07", - "2025-06-08", - "2025-06-09", - "2025-06-10", - "2025-06-11", - "2025-06-12", - "2025-06-13", - "2025-06-14", - "2025-06-15", - "2025-06-16", - "2025-06-17", - "2025-06-18", - "2025-06-19", - "2025-06-20", - "2025-06-21", - "2025-06-22", - "2025-06-23", - "2025-06-24", - "2025-06-25", - "2025-06-26", - "2025-06-27", - "2025-06-28", - "2025-06-29", - "2025-06-30", - "2025-07-01", - "2025-07-02", - "2025-07-03", - "2025-07-04", - "2025-07-05", - "2025-07-06", - "2025-07-07", - "2025-07-08", - "2025-07-09", - "2025-07-10", - "2025-07-11", - "2025-07-12", - "2025-07-13", - "2025-07-14", - "2025-07-15", - "2025-07-16", - "2025-07-17", - "2025-07-18", - "2025-07-19", - "2025-07-20", - "2025-07-21", - "2025-07-22", - "2025-07-23", - "2025-07-24", - "2025-07-25", - "2025-07-26", - "2025-07-27", - "2025-07-28", - "2025-07-29", - "2025-07-30", - "2025-07-31", - "2025-08-01", - "2025-08-02", - "2025-08-03", - "2025-08-04", - "2025-08-05", - "2025-08-06", - "2025-08-07", - "2025-08-08", - "2025-08-09", - "2025-08-10", - "2025-08-11", - "2025-08-12", - "2025-08-13", - "2025-08-14", - "2025-08-15", - "2025-08-16", - "2025-08-17", - "2025-08-18", - "2025-08-19", - "2025-08-20", - "2025-08-21", - "2025-08-22", - "2025-08-23", - "2025-08-24", - "2025-08-25", - "2025-08-26", - "2025-08-27", - "2025-08-28", - "2025-08-29", - "2025-08-30", - "2025-08-31", - "2025-09-01", - "2025-09-02", - "2025-09-03", - "2025-09-04", - "2025-09-05", - "2025-09-06", - "2025-09-07", - "2025-09-08", - "2025-09-09", - "2025-09-10", - "2025-09-11", - "2025-09-12", - "2025-09-13", - "2025-09-14", - "2025-09-15", - "2025-09-16", - "2025-09-17", - "2025-09-18", - "2025-09-19", - "2025-09-20", - "2025-09-21", - "2025-09-22", - "2025-09-23", - "2025-09-24", - "2025-09-25", - "2025-09-26", - "2025-09-27", - "2025-09-28", - "2025-09-29", - "2025-09-30", - "2025-10-01", - "2025-10-02", - "2025-10-03", - "2025-10-04", - "2025-10-05", - "2025-10-06", - "2025-10-07", - "2025-10-08", - "2025-10-09", - "2025-10-10", - "2025-10-11", - "2025-10-12", - "2025-10-13", - "2025-10-14", - "2025-10-15", - "2025-10-16", - "2025-10-17", - "2025-10-18", - "2025-10-19", - "2025-10-20", - "2025-10-21", - "2025-10-22", - "2025-10-23", - "2025-10-24", - "2025-10-25", - "2025-10-26", - "2025-10-27", - "2025-10-28", - "2025-10-29", - "2025-10-30", - "2025-10-31", - "2025-11-01", - "2025-11-02", - "2025-11-03", - "2025-11-04", - "2025-11-05", - "2025-11-06", - "2025-11-07", - "2025-11-08", - "2025-11-09", - "2025-11-10", - "2025-11-11", - "2025-11-12", - "2025-11-13", - "2025-11-14", - "2025-11-15", - "2025-11-16", - "2025-11-17", - "2025-11-18", - "2025-11-19", - "2025-11-20", - "2025-11-21", - "2025-11-22", - "2025-11-23", - "2025-11-24", - "2025-11-25", - "2025-11-26", - "2025-11-27", - "2025-11-28", - "2025-11-29", - "2025-11-30", - "2025-12-01", - "2025-12-02", - "2025-12-03", - "2025-12-04", - "2025-12-05", - "2025-12-06", - "2025-12-07", - "2025-12-08", - "2025-12-09", - "2025-12-10", - "2025-12-11", - "2025-12-12", - "2025-12-13", - "2025-12-14", - "2025-12-15", - "2025-12-16", - "2025-12-17", - "2025-12-18", - "2025-12-19", - "2025-12-20", - "2025-12-21", - "2025-12-22", - "2025-12-23", - "2025-12-24", - "2025-12-25", - "2025-12-26", - "2025-12-27", - "2025-12-28", - "2025-12-29", - "2025-12-30", - "2025-12-31" - ], - "agents": [ - { - "count": 1, - "initial_hf": 1.15, - "rebalancing_hf": 1.05, - "target_hf": 1.08, - "debt_per_agent": 133333, - "total_system_debt": 20000000 - } - ], - "pools": { - "moet_yt": { - "size": 500000, - "concentration": 0.95, - "fee_tier": 0.0005 - }, - "moet_btc": { - "size": 5000000, - "concentration": 0.8, - "fee_tier": 0.003 - }, - "pyusd_btc": { - "size": 10000000, - "concentration": 0.8, - "fee_tier": 0.003 - }, - "moet_fusdev": { - "size": 500000, - "concentration": 0.95, - "fee_tier": 0.0001 - } - }, - "constants": { - "btc_collateral_factor": 0.8, - "btc_liquidation_threshold": 0.85, - "yield_apr": 0.1, - "direct_mint_yt": true - }, - "expected": { - "liquidation_count": 0, - "all_agents_survive": true - }, - "notes": "Daily BTC/USD close prices from CoinMarketCap, 2025-01-01 to 2025-12-31. 365 data points." -} \ No newline at end of file diff --git a/cadence/tests/scripts/simulations/btc_daily_2025_mixed.json b/cadence/tests/scripts/simulations/btc_daily_2025_mixed.json new file mode 100644 index 00000000..39024284 --- /dev/null +++ b/cadence/tests/scripts/simulations/btc_daily_2025_mixed.json @@ -0,0 +1,778 @@ +{ + "scenario": "btc_daily_2025", + "duration_days": 365, + "btc_prices": [ + 94419.76, + 96886.88, + 98107.43, + 98236.23, + 98314.96, + 102078.09, + 96922.71, + 95043.52, + 92484.04, + 94701.46, + 94566.59, + 94488.44, + 94516.53, + 96534.04, + 100504.49, + 99756.91, + 104462.04, + 104408.07, + 101089.61, + 102016.66, + 106146.26, + 103653.07, + 103960.17, + 104819.48, + 104714.65, + 102682.5, + 102087.69, + 101332.48, + 103703.21, + 104735.3, + 102405.03, + 100655.91, + 97688.98, + 101405.42, + 97871.82, + 96615.44, + 96593.3, + 96529.08, + 96482.45, + 96500.09, + 97437.56, + 95747.43, + 97885.86, + 96623.87, + 97508.97, + 97580.35, + 96175.03, + 95773.38, + 95539.54, + 96635.61, + 98333.94, + 96125.54, + 96577.76, + 96273.92, + 91418.17, + 88736.17, + 84347.02, + 84704.22, + 84373.01, + 86031.91, + 94248.35, + 86065.67, + 87222.19, + 90623.56, + 89961.73, + 86742.68, + 86154.59, + 80601.04, + 78532.0, + 82862.21, + 83722.36, + 81066.7, + 83969.1, + 84343.11, + 82579.69, + 84075.69, + 82718.5, + 86854.23, + 84167.19, + 84043.25, + 83832.49, + 86054.37, + 87498.91, + 87471.7, + 86900.89, + 87177.1, + 84353.15, + 82597.58, + 82334.52, + 82548.91, + 85169.17, + 82485.71, + 83102.83, + 83843.8, + 83504.8, + 78214.48, + 79235.33, + 76271.95, + 82573.95, + 79626.14, + 83404.84, + 85287.11, + 83684.98, + 84542.39, + 83668.99, + 84033.87, + 84895.75, + 84450.81, + 85063.41, + 85174.3, + 87518.91, + 93441.89, + 93699.11, + 93943.79, + 94720.5, + 94646.93, + 93754.85, + 94978.75, + 94284.79, + 94207.31, + 96492.34, + 96910.07, + 95891.8, + 94315.97, + 94748.05, + 96802.48, + 97032.32, + 103241.46, + 102970.85, + 104696.33, + 104106.36, + 102812.95, + 104169.81, + 103539.42, + 103744.64, + 103489.29, + 103191.09, + 106446.01, + 105606.18, + 106791.09, + 109678.08, + 111673.28, + 107287.8, + 107791.16, + 109035.39, + 109440.37, + 108994.64, + 107802.32, + 105641.76, + 103998.57, + 104638.09, + 105652.1, + 105881.53, + 105432.47, + 104731.98, + 101575.95, + 104390.35, + 105615.63, + 105793.65, + 110294.1, + 110257.24, + 108686.63, + 105929.05, + 106090.97, + 105472.41, + 105552.03, + 106796.76, + 104601.12, + 104883.33, + 104684.29, + 103309.6, + 102257.41, + 100987.14, + 105577.77, + 106045.63, + 107361.26, + 106960.0, + 107088.43, + 107327.7, + 108385.57, + 107135.33, + 105698.28, + 108859.32, + 109647.98, + 108034.34, + 108231.18, + 109232.07, + 108299.85, + 108950.28, + 111326.55, + 115987.21, + 117516.99, + 117435.23, + 119116.12, + 119849.71, + 117777.19, + 118738.51, + 119289.84, + 118003.22, + 117939.98, + 117300.79, + 117439.54, + 119995.42, + 118754.96, + 118368.0, + 117635.88, + 117947.37, + 119448.49, + 117924.47, + 117922.15, + 117831.19, + 115758.2, + 113320.09, + 112526.91, + 114217.67, + 115071.88, + 114141.44, + 115028.0, + 117496.9, + 116688.73, + 116500.36, + 119306.76, + 118731.45, + 120172.91, + 123344.06, + 118359.58, + 117398.35, + 117491.35, + 117453.06, + 116252.31, + 112831.18, + 114274.74, + 112419.03, + 116874.09, + 115374.33, + 113458.43, + 110124.35, + 111802.66, + 111222.06, + 112544.8, + 108410.84, + 108808.07, + 108236.71, + 109250.59, + 111200.59, + 111723.21, + 110723.6, + 110650.99, + 110224.7, + 111167.62, + 112071.43, + 111530.55, + 113955.36, + 115507.54, + 116101.58, + 115950.51, + 115407.65, + 115444.87, + 116843.18, + 116468.51, + 117137.2, + 115688.86, + 115721.96, + 115306.1, + 112748.51, + 112014.5, + 113328.63, + 109049.29, + 109712.83, + 109681.94, + 112122.64, + 114400.39, + 114056.08, + 118648.93, + 120681.26, + 122266.53, + 122425.43, + 123513.47, + 124752.53, + 121451.38, + 123354.87, + 121705.58, + 113214.37, + 110807.88, + 115169.76, + 115271.08, + 113118.67, + 110783.17, + 108186.04, + 106467.79, + 107198.27, + 108666.71, + 110588.93, + 108476.89, + 107688.59, + 110069.72, + 111033.92, + 111641.73, + 114472.44, + 114119.32, + 112956.17, + 110055.3, + 108305.55, + 109556.16, + 110064.02, + 110639.63, + 106547.52, + 101590.52, + 103891.84, + 101301.29, + 103372.41, + 102282.11, + 104719.64, + 105996.6, + 102997.47, + 101663.19, + 99697.49, + 94397.79, + 95549.15, + 94177.07, + 92093.87, + 92948.87, + 91465.99, + 86631.9, + 85090.69, + 84648.36, + 86805.01, + 88270.56, + 87341.89, + 90518.37, + 91285.37, + 90919.27, + 90851.75, + 90394.31, + 86321.57, + 91350.21, + 93527.8, + 92141.62, + 89387.75, + 89272.37, + 90405.64, + 90640.21, + 92691.71, + 92020.95, + 92511.34, + 90270.41, + 90298.71, + 88175.18, + 86419.78, + 87843.99, + 86143.76, + 85462.51, + 88103.38, + 88344.0, + 88621.75, + 88490.02, + 87414.0, + 87611.96, + 87234.74, + 87301.43, + 87802.16, + 87835.83, + 87138.14, + 88430.14, + 87508.83 + ], + "dates": [ + "2025-01-01", + "2025-01-02", + "2025-01-03", + "2025-01-04", + "2025-01-05", + "2025-01-06", + "2025-01-07", + "2025-01-08", + "2025-01-09", + "2025-01-10", + "2025-01-11", + "2025-01-12", + "2025-01-13", + "2025-01-14", + "2025-01-15", + "2025-01-16", + "2025-01-17", + "2025-01-18", + "2025-01-19", + "2025-01-20", + "2025-01-21", + "2025-01-22", + "2025-01-23", + "2025-01-24", + "2025-01-25", + "2025-01-26", + "2025-01-27", + "2025-01-28", + "2025-01-29", + "2025-01-30", + "2025-01-31", + "2025-02-01", + "2025-02-02", + "2025-02-03", + "2025-02-04", + "2025-02-05", + "2025-02-06", + "2025-02-07", + "2025-02-08", + "2025-02-09", + "2025-02-10", + "2025-02-11", + "2025-02-12", + "2025-02-13", + "2025-02-14", + "2025-02-15", + "2025-02-16", + "2025-02-17", + "2025-02-18", + "2025-02-19", + "2025-02-20", + "2025-02-21", + "2025-02-22", + "2025-02-23", + "2025-02-24", + "2025-02-25", + "2025-02-26", + "2025-02-27", + "2025-02-28", + "2025-03-01", + "2025-03-02", + "2025-03-03", + "2025-03-04", + "2025-03-05", + "2025-03-06", + "2025-03-07", + "2025-03-08", + "2025-03-09", + "2025-03-10", + "2025-03-11", + "2025-03-12", + "2025-03-13", + "2025-03-14", + "2025-03-15", + "2025-03-16", + "2025-03-17", + "2025-03-18", + "2025-03-19", + "2025-03-20", + "2025-03-21", + "2025-03-22", + "2025-03-23", + "2025-03-24", + "2025-03-25", + "2025-03-26", + "2025-03-27", + "2025-03-28", + "2025-03-29", + "2025-03-30", + "2025-03-31", + "2025-04-01", + "2025-04-02", + "2025-04-03", + "2025-04-04", + "2025-04-05", + "2025-04-06", + "2025-04-07", + "2025-04-08", + "2025-04-09", + "2025-04-10", + "2025-04-11", + "2025-04-12", + "2025-04-13", + "2025-04-14", + "2025-04-15", + "2025-04-16", + "2025-04-17", + "2025-04-18", + "2025-04-19", + "2025-04-20", + "2025-04-21", + "2025-04-22", + "2025-04-23", + "2025-04-24", + "2025-04-25", + "2025-04-26", + "2025-04-27", + "2025-04-28", + "2025-04-29", + "2025-04-30", + "2025-05-01", + "2025-05-02", + "2025-05-03", + "2025-05-04", + "2025-05-05", + "2025-05-06", + "2025-05-07", + "2025-05-08", + "2025-05-09", + "2025-05-10", + "2025-05-11", + "2025-05-12", + "2025-05-13", + "2025-05-14", + "2025-05-15", + "2025-05-16", + "2025-05-17", + "2025-05-18", + "2025-05-19", + "2025-05-20", + "2025-05-21", + "2025-05-22", + "2025-05-23", + "2025-05-24", + "2025-05-25", + "2025-05-26", + "2025-05-27", + "2025-05-28", + "2025-05-29", + "2025-05-30", + "2025-05-31", + "2025-06-01", + "2025-06-02", + "2025-06-03", + "2025-06-04", + "2025-06-05", + "2025-06-06", + "2025-06-07", + "2025-06-08", + "2025-06-09", + "2025-06-10", + "2025-06-11", + "2025-06-12", + "2025-06-13", + "2025-06-14", + "2025-06-15", + "2025-06-16", + "2025-06-17", + "2025-06-18", + "2025-06-19", + "2025-06-20", + "2025-06-21", + "2025-06-22", + "2025-06-23", + "2025-06-24", + "2025-06-25", + "2025-06-26", + "2025-06-27", + "2025-06-28", + "2025-06-29", + "2025-06-30", + "2025-07-01", + "2025-07-02", + "2025-07-03", + "2025-07-04", + "2025-07-05", + "2025-07-06", + "2025-07-07", + "2025-07-08", + "2025-07-09", + "2025-07-10", + "2025-07-11", + "2025-07-12", + "2025-07-13", + "2025-07-14", + "2025-07-15", + "2025-07-16", + "2025-07-17", + "2025-07-18", + "2025-07-19", + "2025-07-20", + "2025-07-21", + "2025-07-22", + "2025-07-23", + "2025-07-24", + "2025-07-25", + "2025-07-26", + "2025-07-27", + "2025-07-28", + "2025-07-29", + "2025-07-30", + "2025-07-31", + "2025-08-01", + "2025-08-02", + "2025-08-03", + "2025-08-04", + "2025-08-05", + "2025-08-06", + "2025-08-07", + "2025-08-08", + "2025-08-09", + "2025-08-10", + "2025-08-11", + "2025-08-12", + "2025-08-13", + "2025-08-14", + "2025-08-15", + "2025-08-16", + "2025-08-17", + "2025-08-18", + "2025-08-19", + "2025-08-20", + "2025-08-21", + "2025-08-22", + "2025-08-23", + "2025-08-24", + "2025-08-25", + "2025-08-26", + "2025-08-27", + "2025-08-28", + "2025-08-29", + "2025-08-30", + "2025-08-31", + "2025-09-01", + "2025-09-02", + "2025-09-03", + "2025-09-04", + "2025-09-05", + "2025-09-06", + "2025-09-07", + "2025-09-08", + "2025-09-09", + "2025-09-10", + "2025-09-11", + "2025-09-12", + "2025-09-13", + "2025-09-14", + "2025-09-15", + "2025-09-16", + "2025-09-17", + "2025-09-18", + "2025-09-19", + "2025-09-20", + "2025-09-21", + "2025-09-22", + "2025-09-23", + "2025-09-24", + "2025-09-25", + "2025-09-26", + "2025-09-27", + "2025-09-28", + "2025-09-29", + "2025-09-30", + "2025-10-01", + "2025-10-02", + "2025-10-03", + "2025-10-04", + "2025-10-05", + "2025-10-06", + "2025-10-07", + "2025-10-08", + "2025-10-09", + "2025-10-10", + "2025-10-11", + "2025-10-12", + "2025-10-13", + "2025-10-14", + "2025-10-15", + "2025-10-16", + "2025-10-17", + "2025-10-18", + "2025-10-19", + "2025-10-20", + "2025-10-21", + "2025-10-22", + "2025-10-23", + "2025-10-24", + "2025-10-25", + "2025-10-26", + "2025-10-27", + "2025-10-28", + "2025-10-29", + "2025-10-30", + "2025-10-31", + "2025-11-01", + "2025-11-02", + "2025-11-03", + "2025-11-04", + "2025-11-05", + "2025-11-06", + "2025-11-07", + "2025-11-08", + "2025-11-09", + "2025-11-10", + "2025-11-11", + "2025-11-12", + "2025-11-13", + "2025-11-14", + "2025-11-15", + "2025-11-16", + "2025-11-17", + "2025-11-18", + "2025-11-19", + "2025-11-20", + "2025-11-21", + "2025-11-22", + "2025-11-23", + "2025-11-24", + "2025-11-25", + "2025-11-26", + "2025-11-27", + "2025-11-28", + "2025-11-29", + "2025-11-30", + "2025-12-01", + "2025-12-02", + "2025-12-03", + "2025-12-04", + "2025-12-05", + "2025-12-06", + "2025-12-07", + "2025-12-08", + "2025-12-09", + "2025-12-10", + "2025-12-11", + "2025-12-12", + "2025-12-13", + "2025-12-14", + "2025-12-15", + "2025-12-16", + "2025-12-17", + "2025-12-18", + "2025-12-19", + "2025-12-20", + "2025-12-21", + "2025-12-22", + "2025-12-23", + "2025-12-24", + "2025-12-25", + "2025-12-26", + "2025-12-27", + "2025-12-28", + "2025-12-29", + "2025-12-30", + "2025-12-31" + ], + "agents": [ + { + "count": 1, + "debt_per_agent": 133333, + "total_system_debt": 20000000 + } + ], + "pools": { + "moet_yt": { + "size": 500000, + "concentration": 0.95, + "fee_tier": 0.0005 + }, + "moet_btc": { + "size": 5000000, + "concentration": 0.8, + "fee_tier": 0.003 + }, + "pyusd_btc": { + "size": 10000000, + "concentration": 0.8, + "fee_tier": 0.003 + }, + "moet_fusdev": { + "size": 500000, + "concentration": 0.95, + "fee_tier": 0.0001 + } + }, + "constants": { + "btc_collateral_factor": 0.8, + "btc_liquidation_threshold": 0.85, + "yield_apr": 0.1, + "direct_mint_yt": true + }, + "expected": { + "liquidation_count": 0, + "all_agents_survive": true + }, + "notes": "Daily BTC/USD close prices from CoinMarketCap, 2025-01-01 to 2025-12-31. 365 data points." +} \ No newline at end of file diff --git a/cadence/tests/scripts/simulations/generate_fixture.py b/cadence/tests/scripts/simulations/generate_fixture.py index 209408ce..8e28fa23 100644 --- a/cadence/tests/scripts/simulations/generate_fixture.py +++ b/cadence/tests/scripts/simulations/generate_fixture.py @@ -3,8 +3,9 @@ Subcommands ----------- -fetch Scrape daily BTC/USD close prices from CoinMarketCap and write a fixture JSON. -generate Convert a fixture JSON into a Cadence test-helper (.cdc) file. +fetch Scrape daily BTC/USD close prices from CoinMarketCap and write a fixture JSON. +generate Convert a fixture JSON into a Cadence test-helper (.cdc) file. +generate-all Combine multiple fixture JSONs into one Cadence helper file (structs emitted once). Examples -------- @@ -15,6 +16,12 @@ # Convert to Cadence helpers python3 generate_fixture.py generate btc_daily_2025.json \\ ../../btc_daily_2025_helpers.cdc + + # Combine all BTC daily fixtures into one helper + python3 generate_fixture.py generate-all \\ + btc_daily_2021_mixed.json btc_daily_2022_bear.json \\ + btc_daily_2024_bull.json btc_daily_2025.json \\ + --output ../../btc_daily_helpers.cdc """ import argparse @@ -142,8 +149,16 @@ def fetch_daily_prices(start: str, end: str) -> list[dict]: return deduped -def build_fixture(daily: list[dict], scenario: str, start: str, end: str) -> dict: - """Assemble a fixture dict from daily price data.""" +def build_fixture( + daily: list[dict], + scenario: str, + start: str, + end: str, +) -> dict: + """Assemble a fixture dict from daily price data. + + Health factor thresholds are defined in the Cadence test file, not here. + """ return { "scenario": scenario, "duration_days": len(daily), @@ -152,9 +167,6 @@ def build_fixture(daily: list[dict], scenario: str, start: str, end: str) -> dic "agents": [ { "count": 1, - "initial_hf": 1.15, - "rebalancing_hf": 1.05, - "target_hf": 1.08, "debt_per_agent": 133333, "total_system_debt": 20000000, } @@ -210,7 +222,12 @@ def cmd_fetch(args: argparse.Namespace) -> None: print(f" Last: {daily[-1]['date']} ${daily[-1]['price']:,.2f}") scenario = args.scenario or f"btc_daily_{args.start[:4]}" - fixture = build_fixture(daily, scenario, args.start, args.end) + fixture = build_fixture( + daily, + scenario, + args.start, + args.end, + ) os.makedirs(os.path.dirname(args.output) or ".", exist_ok=True) with open(args.output, "w") as f: @@ -223,46 +240,25 @@ def cmd_fetch(args: argparse.Namespace) -> None: # --------------------------------------------------------------------------- -def generate_cdc(data: dict) -> str: - scenario = data["scenario"] - is_daily = "duration_days" in data - +def _struct_definitions() -> list[str]: + """Return Cadence lines for SimAgent, SimPool, and SimConstants struct definitions.""" lines: list[str] = [] - lines.append("import Test") - lines.append("") - lines.append(f"// AUTO-GENERATED from {scenario}.json — do not edit manually") - lines.append( - "// Run: python3 generate_fixture.py generate " - ) - lines.append("") - - # --- Inline struct definitions --- lines.append("access(all) struct SimAgent {") lines.append(" access(all) let count: Int") - lines.append(" access(all) let initialHF: UFix64") - lines.append(" access(all) let rebalancingHF: UFix64") - lines.append(" access(all) let targetHF: UFix64") lines.append(" access(all) let debtPerAgent: UFix64") lines.append(" access(all) let totalSystemDebt: UFix64") lines.append("") lines.append(" init(") lines.append(" count: Int,") - lines.append(" initialHF: UFix64,") - lines.append(" rebalancingHF: UFix64,") - lines.append(" targetHF: UFix64,") lines.append(" debtPerAgent: UFix64,") lines.append(" totalSystemDebt: UFix64") lines.append(" ) {") lines.append(" self.count = count") - lines.append(" self.initialHF = initialHF") - lines.append(" self.rebalancingHF = rebalancingHF") - lines.append(" self.targetHF = targetHF") lines.append(" self.debtPerAgent = debtPerAgent") lines.append(" self.totalSystemDebt = totalSystemDebt") lines.append(" }") lines.append("}") lines.append("") - lines.append("access(all) struct SimPool {") lines.append(" access(all) let size: UFix64") lines.append(" access(all) let concentration: UFix64") @@ -275,7 +271,6 @@ def generate_cdc(data: dict) -> str: lines.append(" }") lines.append("}") lines.append("") - lines.append("access(all) struct SimConstants {") lines.append(" access(all) let btcCollateralFactor: UFix64") lines.append(" access(all) let btcLiquidationThreshold: UFix64") @@ -295,6 +290,14 @@ def generate_cdc(data: dict) -> str: lines.append(" }") lines.append("}") lines.append("") + return lines + + +def _scenario_data(data: dict) -> list[str]: + """Return Cadence lines for a single scenario's data (prices, agents, pools, etc.).""" + scenario = data["scenario"] + is_daily = "duration_days" in data + lines: list[str] = [] # --- Price array --- lines.append(f"access(all) let {scenario}_prices: [UFix64] = [") @@ -325,9 +328,6 @@ def generate_cdc(data: dict) -> str: total_debt = agent.get("total_system_debt", 0) lines.append(" SimAgent(") lines.append(f" count: {agent['count']},") - lines.append(f" initialHF: {to_ufix64(agent['initial_hf'])},") - lines.append(f" rebalancingHF: {to_ufix64(agent['rebalancing_hf'])},") - lines.append(f" targetHF: {to_ufix64(agent['target_hf'])},") lines.append(f" debtPerAgent: {to_ufix64(float(debt))},") lines.append(f" totalSystemDebt: {to_ufix64(float(total_debt))}") lines.append(f" ){comma}") @@ -381,6 +381,21 @@ def generate_cdc(data: dict) -> str: lines.append(f'access(all) let {scenario}_notes: String = "{data["notes"]}"') lines.append("") + return lines + + +def generate_cdc(data: dict) -> str: + scenario = data["scenario"] + lines: list[str] = [] + lines.append("import Test") + lines.append("") + lines.append(f"// AUTO-GENERATED from {scenario}.json — do not edit manually") + lines.append( + "// Run: python3 generate_fixture.py generate " + ) + lines.append("") + lines.extend(_struct_definitions()) + lines.extend(_scenario_data(data)) return "\n".join(lines) @@ -399,6 +414,41 @@ def cmd_generate(args: argparse.Namespace) -> None: print(f"Generated {args.output} ({n_prices} prices, scenario: {scenario})") +def cmd_generate_all(args: argparse.Namespace) -> None: + datasets = [] + for path in args.inputs: + with open(path) as f: + datasets.append(json.load(f)) + + source_names = [os.path.basename(p) for p in args.inputs] + lines: list[str] = [] + lines.append("import Test") + lines.append("") + lines.append( + f"// AUTO-GENERATED from [{', '.join(source_names)}] — do not edit manually" + ) + lines.append( + "// Run: python3 generate_fixture.py generate-all --output " + ) + lines.append("") + lines.extend(_struct_definitions()) + + for data in datasets: + lines.append(f"// ---- {data['scenario']} ----") + lines.append("") + lines.extend(_scenario_data(data)) + + cdc = "\n".join(lines) + os.makedirs(os.path.dirname(args.output) or ".", exist_ok=True) + with open(args.output, "w") as f: + f.write(cdc) + + total_prices = sum(len(d["btc_prices"]) for d in datasets) + print( + f"Generated {args.output} ({len(datasets)} scenarios, {total_prices} total price points)" + ) + + # --------------------------------------------------------------------------- # CLI # --------------------------------------------------------------------------- @@ -428,12 +478,22 @@ def main() -> None: gen_p.add_argument("input", help="Input fixture JSON path") gen_p.add_argument("output", help="Output .cdc path") + # -- generate-all -- + gen_all_p = sub.add_parser( + "generate-all", + help="Combine multiple fixture JSONs into one Cadence helper file", + ) + gen_all_p.add_argument("inputs", nargs="+", help="Input fixture JSON paths") + gen_all_p.add_argument("--output", required=True, help="Output .cdc path") + args = parser.parse_args() if args.command == "fetch": cmd_fetch(args) elif args.command == "generate": cmd_generate(args) + elif args.command == "generate-all": + cmd_generate_all(args) if __name__ == "__main__": diff --git a/cadence/tests/simulation_btc_daily_2025.cdc b/cadence/tests/simulation_btc_daily_historical.cdc similarity index 50% rename from cadence/tests/simulation_btc_daily_2025.cdc rename to cadence/tests/simulation_btc_daily_historical.cdc index 1615a630..c819094f 100644 --- a/cadence/tests/simulation_btc_daily_2025.cdc +++ b/cadence/tests/simulation_btc_daily_historical.cdc @@ -5,7 +5,7 @@ import BlockchainHelpers import "test_helpers.cdc" import "evm_state_helpers.cdc" -import "btc_daily_2025_helpers.cdc" +import "simulation_btc_daily_historical_helpers.cdc" import "FlowYieldVaults" import "FlowToken" @@ -14,7 +14,6 @@ import "FlowYieldVaultsStrategiesV2" import "FlowALPv0" import "DeFiActions" - // ============================================================================ // CADENCE ACCOUNTS // ============================================================================ @@ -29,12 +28,8 @@ access(all) let coaOwnerAccount = Test.getAccount(0xe467b9dd11fa00df) access(all) let WBTC_TOKEN_ID = "A.1e4aa0b87d10b141.EVMVMBridgedToken_717dae2baf7656be9a9b01dee31d571a9d4c9579.Vault" access(all) let WBTC_TYPE = CompositeType(WBTC_TOKEN_ID)! -// 0x01b7e73CDAd95D407e8696E04194a75F19744801 - access(all) var strategyIdentifier = Type<@FlowYieldVaultsStrategiesV2.FUSDEVStrategy>().identifier access(all) var wbtcTokenIdentifier = WBTC_TOKEN_ID -access(all) let MOET_TYPE = Type<@MOET.Vault>() -access(all) var moetTokenIdentifier = MOET_TYPE.identifier // ============================================================================ // PROTOCOL ADDRESSES @@ -64,16 +59,10 @@ access(all) let morphoVaultTotalSupplySlot = 11 as UInt256 access(all) let morphoVaultTotalAssetsSlot = 15 as UInt256 // ============================================================================ -// SIMULATION CONFIG +// SIMULATION CONSTANTS // ============================================================================ -access(all) let numAgents = 1 - access(all) let fundingPerAgent = 1.0 - -access(all) let initialPrice = btc_daily_2025_prices[0] - -access(all) let yieldAPR = btc_daily_2025_constants.yieldAPR access(all) let daysPerYear = 365.0 access(all) let secondsPerDay = 86400.0 @@ -101,6 +90,20 @@ access(all) let collateralFactor = 0.8 access(all) let vaultLowerThreshold = 0.95 access(all) let vaultUpperThreshold = 1.05 +// Liquidation parameters. +// liquidationTargetHF: the max post-liquidation effective HF the contract allows (FlowALPv0 default: 1.05). +// liquidationDiscount: fraction of fair-value BTC to seize (must be < 1.0 to beat the DEX quote). +access(all) let liquidationTargetHF = 1.05 +access(all) let liquidationDiscount = 0.95 + +// Position health factor thresholds shared across all BTC historical simulations. +access(all) let simInitialHF: UFix64 = 1.3 +access(all) let simMinHF: UFix64 = 1.1 +access(all) let simTargetHF: UFix64 = 1.3 +access(all) let simMaxHF: UFix64 = 1.5 + +access(all) var snapshot: UInt64 = 0 + // ============================================================================ // SETUP // ============================================================================ @@ -109,6 +112,11 @@ access(all) fun setup() { deployContractsForFork() + snapshot = getCurrentBlockHeight() +} + +access(all) +fun setupInitialState() { // it removes all the existing scheduled transactions, it is useful to speed up the tests, // because otherwise, the existing 41 scheduled transactions will be executed every time we // move the time forward, and each taking about 40ms, which make the tests very slow @@ -117,6 +125,30 @@ fun setup() { // transaction can also be created by the tests. resetTransactionScheduler() + setInfiniteLiquidity() + + let reserveAmount = 100_000_00.0 + transferFlow(signer: whaleFlowAccount, recipient: flowALPAccount.address, amount: reserveAmount) + mintMoet(signer: flowALPAccount, to: flowALPAccount.address, amount: reserveAmount, beFailed: false) + + transferFlow(signer: whaleFlowAccount, recipient: flowYieldVaultsAccount.address, amount: reserveAmount) + transferFlow(signer: whaleFlowAccount, recipient: coaOwnerAccount.address, amount: reserveAmount) +} + +// ============================================================================ +// HELPERS +// ============================================================================ + +access(all) +fun safeReset() { + let cur = getCurrentBlockHeight() + if cur > snapshot { + Test.reset(to: snapshot) + } +} + +access(all) +fun setInfiniteLiquidity() { setPoolToPrice( factoryAddress: factoryAddress, tokenAAddress: pyusd0Address, @@ -149,19 +181,8 @@ fun setup() { tokenBBalanceSlot: pyusd0BalanceSlot, signer: coaOwnerAccount ) - - let reserveAmount = 100_000_00.0 - transferFlow(signer: whaleFlowAccount, recipient: flowALPAccount.address, amount: reserveAmount) - mintMoet(signer: flowALPAccount, to: flowALPAccount.address, amount: reserveAmount, beFailed: false) - - transferFlow(signer: whaleFlowAccount, recipient: flowYieldVaultsAccount.address, amount: reserveAmount) - transferFlow(signer: whaleFlowAccount, recipient: coaOwnerAccount.address, amount: reserveAmount) } -// ============================================================================ -// HELPERS -// ============================================================================ - access(all) fun getBTCCollateralFromPosition(pid: UInt64): UFix64 { let positionDetails = getPositionDetails(pid: pid, beFailed: false) for balance in positionDetails.balances { @@ -176,25 +197,25 @@ access(all) fun getBTCCollateralFromPosition(pid: UInt64): UFix64 { /// Compute deterministic YT (ERC4626 vault share) price at a given day. /// price = 1.0 + yieldAPR * (day / 365) -access(all) fun ytPriceAtDay(_ day: Int): UFix64 { +access(all) fun ytPriceAtDay(_ day: Int, yieldAPR: UFix64): UFix64 { return 1.0 + yieldAPR * (UFix64(day) / daysPerYear) } /// Update all prices for a given simulation day. -access(all) fun applyPriceTick(btcPrice: UFix64, ytPrice: UFix64, user: Test.TestAccount) { - setBandOraclePrices(signer: bandOracleAccount, symbolPrices: { - "BTC": btcPrice, - "USD": 1.0 - }) - - let btcPool = btc_daily_2025_pools["pyusd_btc"]! - let ytPool = btc_daily_2025_pools["moet_fusdev"]! +access(all) fun applyPriceTick( + btcPrice: UFix64, + ytPrice: UFix64, + user: Test.TestAccount, + pools: {String: SimPool} +) { + let btcPool = pools["pyusd_btc"]! + let ytPool = pools["moet_fusdev"]! setPoolToPriceWithTVL( factoryAddress: factoryAddress, tokenAAddress: wbtcAddress, tokenBAddress: pyusd0Address, - fee: 3000, + fee: UInt64(btcPool.feeTier * 1_000_000.0), priceTokenBPerTokenA: UFix128(btcPrice), tokenABalanceSlot: wbtcBalanceSlot, tokenBBalanceSlot: pyusd0BalanceSlot, @@ -208,7 +229,7 @@ access(all) fun applyPriceTick(btcPrice: UFix64, ytPrice: UFix64, user: Test.Tes factoryAddress: factoryAddress, tokenAAddress: moetAddress, tokenBAddress: morphoVaultAddress, - fee: 100, + fee: UInt64(ytPool.feeTier * 1_000_000.0), priceTokenBPerTokenA: UFix128(ytPrice), tokenABalanceSlot: moetBalanceSlot, tokenBBalanceSlot: fusdevBalanceSlot, @@ -218,6 +239,28 @@ access(all) fun applyPriceTick(btcPrice: UFix64, ytPrice: UFix64, user: Test.Tes signer: coaOwnerAccount ) + setPoolToPrice( + factoryAddress: factoryAddress, + tokenAAddress: pyusd0Address, + tokenBAddress: morphoVaultAddress, + fee: 100, + priceTokenBPerTokenA: 1.0, + tokenABalanceSlot: pyusd0BalanceSlot, + tokenBBalanceSlot: fusdevBalanceSlot, + signer: coaOwnerAccount + ) + + setPoolToPrice( + factoryAddress: factoryAddress, + tokenAAddress: moetAddress, + tokenBAddress: pyusd0Address, + fee: 100, + priceTokenBPerTokenA: 1.0, + tokenABalanceSlot: moetBalanceSlot, + tokenBBalanceSlot: pyusd0BalanceSlot, + signer: coaOwnerAccount + ) + setVaultSharePrice( vaultAddress: morphoVaultAddress, assetAddress: pyusd0Address, @@ -227,16 +270,39 @@ access(all) fun applyPriceTick(btcPrice: UFix64, ytPrice: UFix64, user: Test.Tes priceMultiplier: ytPrice, signer: user ) + + setBandOraclePrices(signer: bandOracleAccount, symbolPrices: { + "BTC": btcPrice, + "USD": 1.0 + }) } // ============================================================================ -// TEST: BTC Daily 2025 -- Daily Rebalancing with Real Prices +// CORE SIMULATION // ============================================================================ access(all) -fun test_BtcDaily2025_DailyRebalancing() { - let prices = btc_daily_2025_prices - let dates = btc_daily_2025_dates +fun runDailySimulation( + scenarioName: String, + prices: [UFix64], + dates: [String], + agents: [SimAgent], + pools: {String: SimPool}, + constants: SimConstants, + expectedLiquidationCount: Int, + durationDays: Int, + notes: String, + initialHF: UFix64, + minHF: UFix64, + targetHF: UFix64, + maxHF: UFix64 +) { + safeReset() + setupInitialState() + + let initialPrice = prices[0] + let numAgents = agents[0].count + let yieldAPR = constants.yieldAPR // Create agents let users: [Test.TestAccount] = [] @@ -244,7 +310,7 @@ fun test_BtcDaily2025_DailyRebalancing() { let vaultIds: [UInt64] = [] // Apply initial pricing - applyPriceTick(btcPrice: initialPrice, ytPrice: ytPriceAtDay(0), user: coaOwnerAccount) + applyPriceTick(btcPrice: initialPrice, ytPrice: ytPriceAtDay(0, yieldAPR: yieldAPR), user: coaOwnerAccount, pools: pools) var i = 0 while i < numAgents { @@ -275,6 +341,32 @@ fun test_BtcDaily2025_DailyRebalancing() { let yieldVaultIDs = getYieldVaultIDs(address: user.address)! let vaultId = yieldVaultIDs[0] + let agent = agents[i] + + // forced initial rebalance needs infinite liquidity + setInfiniteLiquidity() + + // Step 1: Coerce position to the desired initial HF. + // Set temporary health params with targetHealth=initialHF, then force-rebalance. + // This makes the on-chain rebalancer push the position to exactly initialHF. + setPositionHealthParams( + signer: flowALPAccount, + pid: pid, + targetHealth: initialHF, + minHealth: initialHF - 0.01, + maxHealth: initialHF + 0.01 + ) + rebalancePosition(signer: flowALPAccount, pid: pid, force: true, beFailed: false) + + // Step 2: Set the real health thresholds for the simulation. + setPositionHealthParams( + signer: flowALPAccount, + pid: pid, + targetHealth: targetHF, + minHealth: minHF, + maxHealth: maxHF + ) + users.append(user) pids.append(pid) vaultIds.append(vaultId) @@ -283,32 +375,41 @@ fun test_BtcDaily2025_DailyRebalancing() { i = i + 1 } - log("\n=== BTC DAILY 2025 SIMULATION ===") + log("\n=== \(scenarioName) SIMULATION ===") log("Agents: \(numAgents)") log("Funding per agent: \(fundingPerAgent) BTC (~\(fundingPerAgent * initialPrice) MOET)") - log("Duration: \(btc_daily_2025_durationDays) days") + log("Duration: \(durationDays) days") log("Price points: \(prices.length)") log("Initial BTC price: $\(prices[0])") - log("Notes: \(btc_daily_2025_notes)") + log("Notes: \(notes)") log("") log("Rebalance Triggers:") - log(" HF (Position): triggers when HF < 1.1 or HF > 1.5, rebalances to HF = 1.3") - log(" VR (Vault): triggers when VR < 0.95 or VR > 1.05, rebalances to VR ~ 1.0") + log(" HF (Position): triggers when HF < \(minHF) or HF > \(maxHF), rebalances to HF = \(targetHF)") + log(" VR (Vault): triggers when VR < \(vaultLowerThreshold) or VR > \(vaultUpperThreshold), rebalances to VR ~ 1.0") + + // Liquidator account: pre-funded with MOET so it can attempt manual liquidations + let liquidator = Test.createAccount() + transferFlow(signer: whaleFlowAccount, recipient: liquidator.address, amount: 10.0) + setupMoetVault(liquidator, beFailed: false) + setupGenericVault(signer: liquidator, vaultIdentifier: WBTC_TOKEN_ID) + let liquidatorMOETReserve = 100_000.0 + mintMoet(signer: flowALPAccount, to: liquidator.address, amount: liquidatorMOETReserve, beFailed: false) var liquidationCount = 0 var previousBTCPrice = initialPrice var lowestPrice = initialPrice var highestPrice = initialPrice var lowestHF = 100.0 - var prevVaultRebalanceCount = 0 - var prevPositionRebalanceCount = 0 + // Snapshot event counts after agent setup so day 0 doesn't count setup rebalances + var prevVaultRebalanceCount = Test.eventsOfType(Type()).length + var prevPositionRebalanceCount = Test.eventsOfType(Type()).length let startTimestamp = getCurrentBlockTimestamp() var day = 0 while day < prices.length { let absolutePrice = prices[day] - let ytPrice = ytPriceAtDay(day) + let ytPrice = ytPriceAtDay(day, yieldAPR: yieldAPR) if absolutePrice < lowestPrice { lowestPrice = absolutePrice @@ -325,33 +426,88 @@ fun test_BtcDaily2025_DailyRebalancing() { } // Apply all price updates - applyPriceTick(btcPrice: absolutePrice, ytPrice: ytPrice, user: users[0]) + applyPriceTick(btcPrice: absolutePrice, ytPrice: ytPrice, user: users[0], pools: pools) // Calculate HF BEFORE rebalancing to see pre-rebalance state // effectiveHF = (collateralValue * collateralFactor) / debt // This is what determines rebalance triggers (minHealth=1.1, maxHealth=1.5) - var preRebalanceHF: UFix64 = 0.0 + var preRebalanceHFs: [UFix64] = [] + // Calculate vault ratio BEFORE rebalancing (single script call for efficiency) + // vaultRatio = currentValue / valueOfDeposits + // Triggers when ratio < 0.95 or ratio > 1.05 + var preVaultRatios: [UFix64] = [] var a = 0 while a < numAgents { - if a == 0 { - let btcCollateral = getBTCCollateralFromPosition(pid: pids[a]) - let btcCollateralValue = btcCollateral * absolutePrice - let effectiveCollateral = btcCollateralValue * collateralFactor + // Calculate HF BEFORE rebalancing + var preRebalanceHF: UFix64 = UFix64(getPositionHealth(pid: pids[a], beFailed: false)) + preRebalanceHFs.append(preRebalanceHF) + var preVaultRatio: UFix64 = 1.0 + let preMetrics = getAutoBalancerMetrics(id: vaultIds[a]) ?? [0.0, 0.0] + if preMetrics[1] > 0.0 { + preVaultRatio = preMetrics[0] / preMetrics[1] + } + preVaultRatios.append(preVaultRatio) + + // Liquidation occurs when effectiveHF < 1.0 (check pre-rebalance) + if preRebalanceHF < 1.0 && preRebalanceHF > 0.0 { + liquidationCount = liquidationCount + 1 + log(" *** LIQUIDATION agent=\(a) on day \(day) (\(dates[day]))! HF=\(preRebalanceHF) price=\(absolutePrice) previousPrice=\(previousBTCPrice)***") + let debt = getMOETDebtFromPosition(pid: pids[a]) - if debt > 0.0 { - preRebalanceHF = effectiveCollateral / debt + let btcCollateral = getBTCCollateralFromPosition(pid: pids[a]) + + // Compute how much debt to repay to bring position to liquidationTargetHF. + // + // postHF = (Ce_pre - Ce_seize) / (De_pre - repayAmount) + // Ce_pre = btcCollateral * btcPrice * collateralFactor + // De_pre = debt (borrowFactor=1, MOET price=1) + // seizeAmount = repayAmount / btcPrice * discount (must beat DEX) + // Ce_seize = seizeAmount * btcPrice * collateralFactor = repayAmount * discount * collateralFactor + // + // Solving for repayAmount: + // repayAmount = (Ce_pre - targetHF * De_pre) / (discount * collateralFactor - targetHF) + + // leave a small buffer so liquidation succeeds (constraint says post liquidation HF <= liquidationTargetHF) + let targetHF = liquidationTargetHF - 0.01 + let Ce_pre = btcCollateral * absolutePrice * collateralFactor + let De_pre = debt + let numerator = targetHF * De_pre - Ce_pre + let denominator = targetHF - liquidationDiscount * collateralFactor + var repayAmount = numerator / denominator + + // Clamp: can't repay more than the position's debt + if repayAmount > debt { + repayAmount = debt + } + + let seizeAmount = repayAmount / absolutePrice * liquidationDiscount + + // Register/update MockDexSwapper pair so manualLiquidation's DEX price check passes + let setDexRes = _executeTransaction( + "../../lib/FlowALP/cadence/tests/transactions/mock-dex-swapper/set_mock_dex_price_for_pair.cdc", + [WBTC_TOKEN_ID, Type<@MOET.Vault>().identifier, MOET.VaultStoragePath, absolutePrice], + liquidator + ) + if setDexRes.error != nil { + log(" MockDexSwapper setup failed: \(setDexRes.error!.message)") + } + + let liqRes = _executeTransaction( + "../../lib/FlowALP/cadence/transactions/flow-alp/pool-management/manual_liquidation.cdc", + [pids[a], Type<@MOET.Vault>().identifier, WBTC_TOKEN_ID, seizeAmount, repayAmount], + liquidator + ) + if liqRes.error == nil { + let Ce_post = Ce_pre - seizeAmount * absolutePrice * collateralFactor + let De_post = De_pre - repayAmount + let expectedPostHF = Ce_post / De_post + log(" Liquidation succeeded: repaid \(repayAmount) MOET, seized \(seizeAmount) BTC, expected post-HF=\(expectedPostHF)") + } else { + log(" Liquidation failed: \(liqRes.error!.message)") } } - a = a + 1 - } - // Calculate vault ratio BEFORE rebalancing (single script call for efficiency) - // vaultRatio = currentValue / valueOfDeposits - // Triggers when ratio < 0.95 or ratio > 1.05 - var preVaultRatio: UFix64 = 1.0 - let preMetrics = getAutoBalancerMetrics(id: vaultIds[0]) ?? [0.0, 0.0] - if preMetrics[1] > 0.0 { - preVaultRatio = preMetrics[0] / preMetrics[1] + a = a + 1 } // Potentially rebalance all agents (not forced) @@ -370,41 +526,29 @@ fun test_BtcDaily2025_DailyRebalancing() { prevVaultRebalanceCount = currentVaultRebalanceCount prevPositionRebalanceCount = currentPositionRebalanceCount - // Calculate vault ratio AFTER rebalancing (single script call for efficiency) - var postVaultRatio: UFix64 = 1.0 - let postMetrics = getAutoBalancerMetrics(id: vaultIds[0]) ?? [0.0, 0.0] - if postMetrics[1] > 0.0 { - postVaultRatio = postMetrics[0] / postMetrics[1] - } - - // Calculate HF AFTER rebalancing a = 0 while a < numAgents { - let btcCollateral = getBTCCollateralFromPosition(pid: pids[a]) - let btcCollateralValue = btcCollateral * absolutePrice - let effectiveCollateral = btcCollateralValue * collateralFactor - let debt = getMOETDebtFromPosition(pid: pids[a]) - - if debt > 0.0 { - let postRebalanceHF = effectiveCollateral / debt - // Track lowest HF (use pre-rebalance to capture the actual low point) - if preRebalanceHF < lowestHF && preRebalanceHF > 0.0 { - lowestHF = preRebalanceHF - } - - // Log weekly + at price extremes - // Show both pre and post values to see rebalance effects: - // HF: position health factor (triggers at <1.1 or >1.5) - // VR: vault ratio (triggers at <0.95 or >1.05) - if a == 0 && (day % 7 == 0 || absolutePrice == lowestPrice || absolutePrice == highestPrice) { - log(" [day \(day)] \(dates[day]) price=$\(absolutePrice) yt=\(ytPrice) HF=\(preRebalanceHF)->\(postRebalanceHF) VR=\(preVaultRatio)->\(postVaultRatio) vaultRebalances=\(dayVaultRebalances) positionRebalances=\(dayPositionRebalances)") - } + // Calculate HF AFTER rebalancing + let postRebalanceHF = UFix64(getPositionHealth(pid: pids[a], beFailed: false)) + let preRebalanceHF = preRebalanceHFs[a] + let preVaultRatio = preVaultRatios[a] + // Calculate vault ratio AFTER rebalancing (single script call for efficiency) + var postVaultRatio: UFix64 = 1.0 + let postMetrics = getAutoBalancerMetrics(id: vaultIds[0]) ?? [0.0, 0.0] + if postMetrics[1] > 0.0 { + postVaultRatio = postMetrics[0] / postMetrics[1] + } + // Track lowest HF (use pre-rebalance to capture the actual low point) + if preRebalanceHF < lowestHF && preRebalanceHF > 0.0 { + lowestHF = preRebalanceHF + } - // Liquidation occurs when effectiveHF < 1.0 (check pre-rebalance) - if preRebalanceHF < 1.0 && preRebalanceHF > 0.0 { - liquidationCount = liquidationCount + 1 - log(" *** LIQUIDATION agent=\(a) on day \(day) (\(dates[day]))! HF=\(preRebalanceHF) ***") - } + // Log weekly + at price extremes + // Show both pre and post values to see rebalance effects: + // HF: position health factor (triggers at <1.1 or >1.5) + // VR: vault ratio (triggers at <0.95 or >1.05) + if a == 0 && (day % 7 == 0 || absolutePrice == lowestPrice || absolutePrice == highestPrice) { + log(" [day \(day)] \(dates[day]) price=$\(absolutePrice) yt=\(ytPrice) HF=\(preRebalanceHF)->\(postRebalanceHF) VR=\(preVaultRatio)->\(postVaultRatio) vaultRebalances=\(dayVaultRebalances) positionRebalances=\(dayPositionRebalances)") } a = a + 1 } @@ -423,23 +567,23 @@ fun test_BtcDaily2025_DailyRebalancing() { let finalBTCCollateral = getBTCCollateralFromPosition(pid: pids[0]) let finalDebt = getMOETDebtFromPosition(pid: pids[0]) let finalYieldTokens = getAutoBalancerBalance(id: vaultIds[0])! - let finalYtPrice = ytPriceAtDay(prices.length - 1) + let finalYtPrice = ytPriceAtDay(prices.length - 1, yieldAPR: yieldAPR) // Compute effective HF to match contract's rebalancing logic let finalEffectiveHF = (finalBTCCollateral * previousBTCPrice * collateralFactor) / finalDebt - // P&L: net equity = collateral_value + yt_value - debt (all in stablecoin/MOET terms) - let collateralValueMOET = finalBTCCollateral * previousBTCPrice - let ytValueMOET = finalYieldTokens * finalYtPrice - let netEquityMOET = collateralValueMOET + ytValueMOET - finalDebt - let initialDepositMOET = fundingPerAgent * initialPrice + // Final position values in USD (MOET ~ 1 USD) + let finalCollateralValueUSD = finalBTCCollateral * previousBTCPrice + let finalYtValueUSD = finalYieldTokens * finalYtPrice + let finalNetEquityUSD = finalCollateralValueUSD + finalYtValueUSD - finalDebt + let initialDepositUSD = fundingPerAgent * initialPrice - // UFix64 is unsigned, so track sign separately to avoid underflow - let moetProfit = netEquityMOET >= initialDepositMOET - let pnlMOETAbs = moetProfit ? (netEquityMOET - initialDepositMOET) : (initialDepositMOET - netEquityMOET) - let pnlPctMOETAbs = pnlMOETAbs / initialDepositMOET + // P&L vs initial deposit + let moetProfit = finalNetEquityUSD >= initialDepositUSD + let pnlMOETAbs = moetProfit ? (finalNetEquityUSD - initialDepositUSD) : (initialDepositUSD - finalNetEquityUSD) + let pnlPctMOETAbs = pnlMOETAbs / initialDepositUSD let pnlMOETSign = moetProfit ? "+" : "-" - let netEquityBTC = netEquityMOET / previousBTCPrice + let netEquityBTC = finalNetEquityUSD / previousBTCPrice let btcProfit = netEquityBTC >= fundingPerAgent let pnlBTCAbs = btcProfit ? (netEquityBTC - fundingPerAgent) : (fundingPerAgent - netEquityBTC) let pnlPctBTCAbs = pnlBTCAbs / fundingPerAgent @@ -468,19 +612,121 @@ fun test_BtcDaily2025_DailyRebalancing() { log("--- Position (effective HF with collateralFactor=\(collateralFactor)) ---") log("Lowest HF observed: \(lowestHF)") log("Final HF (agent 0): \(finalEffectiveHF)") - log("Final collateral: \(finalBTCCollateral) BTC (value: \(collateralValueMOET) MOET)") + log("Final collateral: \(finalBTCCollateral) BTC ($\(finalCollateralValueUSD))") log("Final debt: \(finalDebt) MOET") - log("Final yield tokens: \(finalYieldTokens) (value: \(ytValueMOET) MOET @ yt=\(finalYtPrice))") + log("Final yield tokens: \(finalYieldTokens) ($\(finalYtValueUSD) @ yt=\(finalYtPrice))") log("") log("--- P&L ---") - log("Initial deposit: \(fundingPerAgent) BTC (~\(fundingPerAgent * initialPrice) MOET)") - log("Net equity (MOET): \(netEquityMOET) (P&L: \(pnlMOETSign)\(pnlMOETAbs), \(pnlMOETSign)\(pnlPctMOETAbs))") - log("Net equity (BTC): \(netEquityBTC) (P&L: \(pnlBTCSign)\(pnlBTCAbs), \(pnlBTCSign)\(pnlPctBTCAbs))") + log("Initial deposit: \(fundingPerAgent) BTC (~$\(initialDepositUSD))") + log("Net equity (USD): $\(finalNetEquityUSD) (P&L: \(pnlMOETSign)$\(pnlMOETAbs), \(pnlMOETSign)\(pnlPctMOETAbs))") + log("Net equity (BTC): \(netEquityBTC) BTC (P&L: \(pnlBTCSign)\(pnlBTCAbs) BTC, \(pnlBTCSign)\(pnlPctBTCAbs))") log("===========================\n") - Test.assertEqual(btc_daily_2025_expectedLiquidationCount, liquidationCount) - Test.assert(finalEffectiveHF > 1.0, message: "Expected final effective HF > 1.0 but got \(finalEffectiveHF)") - Test.assert(lowestHF > 1.0, message: "Expected lowest effective HF > 1.0 but got \(lowestHF)") + Test.assertEqual(expectedLiquidationCount, liquidationCount) + if expectedLiquidationCount == 0 { + Test.assert(finalEffectiveHF > 1.0, message: "Expected final HF > 1.0 but got \(finalEffectiveHF)") + Test.assert(lowestHF > 1.0, message: "Expected lowest HF > 1.0 but got \(lowestHF)") + } + + log("=== TEST PASSED: \(liquidationCount) liquidations (expected \(expectedLiquidationCount)) over \(prices.length) days of real BTC prices (\(numAgents) agents) ===") +} + +// ============================================================================ +// TEST CASES +// Edit the json files to change the simulation parameters. These are in the scripts/simulations folder. +// Then run the generate_fixture.py script to generate the helpers.cdc file. +// ============================================================================ + +access(all) +fun test_BTC_2021() { + runDailySimulation( + scenarioName: "BTC Daily 2021 Mixed", + prices: btc_daily_2021_mixed_prices, + dates: btc_daily_2021_mixed_dates, + agents: btc_daily_2021_mixed_agents, + pools: btc_daily_2021_mixed_pools, + constants: btc_daily_2021_mixed_constants, + expectedLiquidationCount: btc_daily_2021_mixed_expectedLiquidationCount, + durationDays: btc_daily_2021_mixed_durationDays, + notes: btc_daily_2021_mixed_notes, + initialHF: simInitialHF, + minHF: simMinHF, + targetHF: simTargetHF, + maxHF: simMaxHF + ) +} + +access(all) +fun test_BTC_2022() { + // Example of HFs that would encounter 0 liquidations in the 2022 bear market: + // initialHF: 1.2, minHF: 1.1, targetHF: 1.2, maxHF: 1.3 + runDailySimulation( + scenarioName: "BTC Daily 2022 Bear", + prices: btc_daily_2022_bear_prices, + dates: btc_daily_2022_bear_dates, + agents: btc_daily_2022_bear_agents, + pools: btc_daily_2022_bear_pools, + constants: btc_daily_2022_bear_constants, + expectedLiquidationCount: btc_daily_2022_bear_expectedLiquidationCount, + durationDays: btc_daily_2022_bear_durationDays, + notes: btc_daily_2022_bear_notes, + initialHF: simInitialHF, + minHF: simMinHF, + targetHF: simTargetHF, + maxHF: simMaxHF + ) +} + +access(all) +fun test_BTC_2023() { + runDailySimulation( + scenarioName: "BTC Daily 2023 Bull", + prices: btc_daily_2023_bull_prices, + dates: btc_daily_2023_bull_dates, + agents: btc_daily_2023_bull_agents, + pools: btc_daily_2023_bull_pools, + constants: btc_daily_2023_bull_constants, + expectedLiquidationCount: btc_daily_2023_bull_expectedLiquidationCount, + durationDays: btc_daily_2023_bull_durationDays, + notes: btc_daily_2023_bull_notes, + initialHF: simInitialHF, minHF: simMinHF, targetHF: simTargetHF, maxHF: simMaxHF + ) +} + +access(all) +fun test_BTC_2024() { + runDailySimulation( + scenarioName: "BTC Daily 2024 Bull", + prices: btc_daily_2024_bull_prices, + dates: btc_daily_2024_bull_dates, + agents: btc_daily_2024_bull_agents, + pools: btc_daily_2024_bull_pools, + constants: btc_daily_2024_bull_constants, + expectedLiquidationCount: btc_daily_2024_bull_expectedLiquidationCount, + durationDays: btc_daily_2024_bull_durationDays, + notes: btc_daily_2024_bull_notes, + initialHF: simInitialHF, + minHF: simMinHF, + targetHF: simTargetHF, + maxHF: simMaxHF + ) +} - log("=== TEST PASSED: Zero liquidations over 1 year of real BTC prices (\(numAgents) agents) ===") +access(all) +fun test_BTC_2025() { + runDailySimulation( + scenarioName: "BTC Daily 2025", + prices: btc_daily_2025_prices, + dates: btc_daily_2025_dates, + agents: btc_daily_2025_agents, + pools: btc_daily_2025_pools, + constants: btc_daily_2025_constants, + expectedLiquidationCount: btc_daily_2025_expectedLiquidationCount, + durationDays: btc_daily_2025_durationDays, + notes: btc_daily_2025_notes, + initialHF: simInitialHF, + minHF: simMinHF, + targetHF: simTargetHF, + maxHF: simMaxHF + ) } diff --git a/cadence/tests/simulation_btc_daily_historical_helpers.cdc b/cadence/tests/simulation_btc_daily_historical_helpers.cdc new file mode 100644 index 00000000..b1712306 --- /dev/null +++ b/cadence/tests/simulation_btc_daily_historical_helpers.cdc @@ -0,0 +1,3963 @@ +import Test + +// AUTO-GENERATED from [btc_daily_2021_mixed.json, btc_daily_2022_bear.json, btc_daily_2023_bull.json, btc_daily_2024_bull.json, btc_daily_2025_mixed.json] — do not edit manually +// Run: python3 generate_fixture.py generate-all --output + +access(all) struct SimAgent { + access(all) let count: Int + access(all) let debtPerAgent: UFix64 + access(all) let totalSystemDebt: UFix64 + + init( + count: Int, + debtPerAgent: UFix64, + totalSystemDebt: UFix64 + ) { + self.count = count + self.debtPerAgent = debtPerAgent + self.totalSystemDebt = totalSystemDebt + } +} + +access(all) struct SimPool { + access(all) let size: UFix64 + access(all) let concentration: UFix64 + access(all) let feeTier: UFix64 + + init(size: UFix64, concentration: UFix64, feeTier: UFix64) { + self.size = size + self.concentration = concentration + self.feeTier = feeTier + } +} + +access(all) struct SimConstants { + access(all) let btcCollateralFactor: UFix64 + access(all) let btcLiquidationThreshold: UFix64 + access(all) let yieldAPR: UFix64 + access(all) let directMintYT: Bool + + init( + btcCollateralFactor: UFix64, + btcLiquidationThreshold: UFix64, + yieldAPR: UFix64, + directMintYT: Bool + ) { + self.btcCollateralFactor = btcCollateralFactor + self.btcLiquidationThreshold = btcLiquidationThreshold + self.yieldAPR = yieldAPR + self.directMintYT = directMintYT + } +} + +// ---- btc_daily_2021_mixed ---- + +access(all) let btc_daily_2021_mixed_prices: [UFix64] = [ + 29374.15000000, + 32127.27000000, + 32782.02000000, + 31971.91000000, + 33992.43000000, + 36824.36000000, + 39371.04000000, + 40797.61000000, + 40254.55000000, + 38356.44000000, + 35566.66000000, + 33922.96000000, + 37316.36000000, + 39187.33000000, + 36825.37000000, + 36178.14000000, + 35791.28000000, + 36630.08000000, + 36069.81000000, + 35547.75000000, + 30825.70000000, + 33005.76000000, + 32067.64000000, + 32289.38000000, + 32366.39000000, + 32569.85000000, + 30432.55000000, + 33466.10000000, + 34316.39000000, + 34269.52000000, + 33114.36000000, + 33537.18000000, + 35510.29000000, + 37472.09000000, + 36926.06000000, + 38144.31000000, + 39266.01000000, + 38903.44000000, + 46196.46000000, + 46481.10000000, + 44918.18000000, + 47909.33000000, + 47504.85000000, + 47105.52000000, + 48717.29000000, + 47945.06000000, + 49199.87000000, + 52149.01000000, + 51679.80000000, + 55888.13000000, + 56099.52000000, + 57539.94000000, + 54207.32000000, + 48824.43000000, + 49705.33000000, + 47093.85000000, + 46339.76000000, + 46188.45000000, + 45137.77000000, + 49631.24000000, + 48378.99000000, + 50538.24000000, + 48561.17000000, + 48927.30000000, + 48912.38000000, + 51206.69000000, + 52246.52000000, + 54824.12000000, + 56008.55000000, + 57805.12000000, + 57332.09000000, + 61243.08000000, + 59302.32000000, + 55907.20000000, + 56804.90000000, + 58870.89000000, + 57858.92000000, + 58346.65000000, + 58313.64000000, + 57523.42000000, + 54529.15000000, + 54738.94000000, + 52774.26000000, + 51704.16000000, + 55137.31000000, + 55973.51000000, + 55950.75000000, + 57750.20000000, + 58917.69000000, + 58918.83000000, + 59095.81000000, + 59384.31000000, + 57603.89000000, + 58758.56000000, + 59057.88000000, + 58192.36000000, + 56048.94000000, + 58323.95000000, + 58245.00000000, + 59793.24000000, + 60204.96000000, + 59893.45000000, + 63503.46000000, + 63109.70000000, + 63314.01000000, + 61572.79000000, + 60683.82000000, + 56216.19000000, + 55724.27000000, + 56473.03000000, + 53906.09000000, + 51762.27000000, + 51093.65000000, + 50050.87000000, + 49004.25000000, + 54021.75000000, + 55033.12000000, + 54824.70000000, + 53555.11000000, + 57750.18000000, + 57828.05000000, + 56631.08000000, + 57200.29000000, + 53333.54000000, + 57424.01000000, + 56396.51000000, + 57356.40000000, + 58803.78000000, + 58232.32000000, + 55859.80000000, + 56704.57000000, + 49150.53000000, + 49716.19000000, + 49880.53000000, + 46760.19000000, + 46456.06000000, + 43537.51000000, + 42909.40000000, + 37002.44000000, + 40782.74000000, + 37304.69000000, + 37536.63000000, + 34770.58000000, + 38705.98000000, + 38402.22000000, + 39294.20000000, + 38436.97000000, + 35697.61000000, + 34616.07000000, + 35678.13000000, + 37332.85000000, + 36684.92000000, + 37575.18000000, + 39208.77000000, + 36894.41000000, + 35551.96000000, + 35862.38000000, + 33560.71000000, + 33472.63000000, + 37345.12000000, + 36702.60000000, + 37334.40000000, + 35552.52000000, + 39097.86000000, + 40218.48000000, + 40406.27000000, + 38347.06000000, + 38053.50000000, + 35787.24000000, + 35615.87000000, + 35698.30000000, + 31676.69000000, + 32505.66000000, + 33723.03000000, + 34662.44000000, + 31637.78000000, + 32186.28000000, + 34649.64000000, + 34434.34000000, + 35867.78000000, + 35040.84000000, + 33572.12000000, + 33897.05000000, + 34668.55000000, + 35287.78000000, + 33746.00000000, + 34235.19000000, + 33855.33000000, + 32877.37000000, + 33798.01000000, + 33520.52000000, + 34240.19000000, + 33155.85000000, + 32702.03000000, + 32822.35000000, + 31780.73000000, + 31421.54000000, + 31533.07000000, + 31796.81000000, + 30817.83000000, + 29807.35000000, + 32110.69000000, + 32313.11000000, + 33581.55000000, + 34292.45000000, + 35350.19000000, + 37337.53000000, + 39406.94000000, + 39995.91000000, + 40008.42000000, + 42235.55000000, + 41626.20000000, + 39974.90000000, + 39201.95000000, + 38152.98000000, + 39747.51000000, + 40869.55000000, + 42816.50000000, + 44555.80000000, + 43798.12000000, + 46365.40000000, + 45585.03000000, + 45593.64000000, + 44428.29000000, + 47793.32000000, + 47096.95000000, + 47047.00000000, + 46004.48000000, + 44695.36000000, + 44801.19000000, + 46717.58000000, + 49339.18000000, + 48905.49000000, + 49321.65000000, + 49546.15000000, + 47706.12000000, + 48960.79000000, + 46942.22000000, + 49058.67000000, + 48902.40000000, + 48829.83000000, + 47054.98000000, + 47166.69000000, + 48847.03000000, + 49327.72000000, + 50025.37000000, + 49944.63000000, + 51753.41000000, + 52633.54000000, + 46811.13000000, + 46091.39000000, + 46391.42000000, + 44883.91000000, + 45201.46000000, + 46063.27000000, + 44963.07000000, + 47092.49000000, + 48176.35000000, + 47783.36000000, + 47267.52000000, + 48278.36000000, + 47260.22000000, + 42843.80000000, + 40693.68000000, + 43574.51000000, + 44895.10000000, + 42839.75000000, + 42716.59000000, + 43208.54000000, + 42235.73000000, + 41034.54000000, + 41564.36000000, + 43790.90000000, + 48116.94000000, + 47711.49000000, + 48199.95000000, + 49112.90000000, + 51514.81000000, + 55361.45000000, + 53805.99000000, + 53967.85000000, + 54968.22000000, + 54771.58000000, + 57484.79000000, + 56041.06000000, + 57401.10000000, + 57321.53000000, + 61593.95000000, + 60892.18000000, + 61553.62000000, + 62026.08000000, + 64261.99000000, + 65992.84000000, + 62210.17000000, + 60692.26000000, + 61393.62000000, + 60930.84000000, + 63039.83000000, + 60363.79000000, + 58482.39000000, + 60622.14000000, + 62227.96000000, + 61888.83000000, + 61318.96000000, + 61004.41000000, + 63226.40000000, + 62970.05000000, + 61452.23000000, + 61125.67000000, + 61527.48000000, + 63326.99000000, + 67566.83000000, + 66971.83000000, + 64995.23000000, + 64949.96000000, + 64155.94000000, + 64469.53000000, + 65466.84000000, + 63557.87000000, + 60161.25000000, + 60368.01000000, + 56942.14000000, + 58119.58000000, + 59697.20000000, + 58730.48000000, + 56289.29000000, + 57569.07000000, + 56280.43000000, + 57274.68000000, + 53569.76000000, + 54815.08000000, + 57248.46000000, + 57806.57000000, + 57005.43000000, + 57229.83000000, + 56477.82000000, + 53598.25000000, + 49200.70000000, + 49368.85000000, + 50582.63000000, + 50700.08000000, + 50504.80000000, + 47672.12000000, + 47243.31000000, + 49362.51000000, + 50098.34000000, + 46737.48000000, + 46612.63000000, + 48896.72000000, + 47665.43000000, + 46202.14000000, + 46848.78000000, + 46707.01000000, + 46880.28000000, + 48936.61000000, + 48628.51000000, + 50784.54000000, + 50822.20000000, + 50429.86000000, + 50809.52000000, + 50640.42000000, + 47588.85000000, + 46444.71000000, + 47178.13000000, + 46306.45000000 +] + +access(all) let btc_daily_2021_mixed_dates: [String] = [ + "2021-01-01", + "2021-01-02", + "2021-01-03", + "2021-01-04", + "2021-01-05", + "2021-01-06", + "2021-01-07", + "2021-01-08", + "2021-01-09", + "2021-01-10", + "2021-01-11", + "2021-01-12", + "2021-01-13", + "2021-01-14", + "2021-01-15", + "2021-01-16", + "2021-01-17", + "2021-01-18", + "2021-01-19", + "2021-01-20", + "2021-01-21", + "2021-01-22", + "2021-01-23", + "2021-01-24", + "2021-01-25", + "2021-01-26", + "2021-01-27", + "2021-01-28", + "2021-01-29", + "2021-01-30", + "2021-01-31", + "2021-02-01", + "2021-02-02", + "2021-02-03", + "2021-02-04", + "2021-02-05", + "2021-02-06", + "2021-02-07", + "2021-02-08", + "2021-02-09", + "2021-02-10", + "2021-02-11", + "2021-02-12", + "2021-02-13", + "2021-02-14", + "2021-02-15", + "2021-02-16", + "2021-02-17", + "2021-02-18", + "2021-02-19", + "2021-02-20", + "2021-02-21", + "2021-02-22", + "2021-02-23", + "2021-02-24", + "2021-02-25", + "2021-02-26", + "2021-02-27", + "2021-02-28", + "2021-03-01", + "2021-03-02", + "2021-03-03", + "2021-03-04", + "2021-03-05", + "2021-03-06", + "2021-03-07", + "2021-03-08", + "2021-03-09", + "2021-03-10", + "2021-03-11", + "2021-03-12", + "2021-03-13", + "2021-03-14", + "2021-03-15", + "2021-03-16", + "2021-03-17", + "2021-03-18", + "2021-03-19", + "2021-03-20", + "2021-03-21", + "2021-03-22", + "2021-03-23", + "2021-03-24", + "2021-03-25", + "2021-03-26", + "2021-03-27", + "2021-03-28", + "2021-03-29", + "2021-03-30", + "2021-03-31", + "2021-04-01", + "2021-04-02", + "2021-04-03", + "2021-04-04", + "2021-04-05", + "2021-04-06", + "2021-04-07", + "2021-04-08", + "2021-04-09", + "2021-04-10", + "2021-04-11", + "2021-04-12", + "2021-04-13", + "2021-04-14", + "2021-04-15", + "2021-04-16", + "2021-04-17", + "2021-04-18", + "2021-04-19", + "2021-04-20", + "2021-04-21", + "2021-04-22", + "2021-04-23", + "2021-04-24", + "2021-04-25", + "2021-04-26", + "2021-04-27", + "2021-04-28", + "2021-04-29", + "2021-04-30", + "2021-05-01", + "2021-05-02", + "2021-05-03", + "2021-05-04", + "2021-05-05", + "2021-05-06", + "2021-05-07", + "2021-05-08", + "2021-05-09", + "2021-05-10", + "2021-05-11", + "2021-05-12", + "2021-05-13", + "2021-05-14", + "2021-05-15", + "2021-05-16", + "2021-05-17", + "2021-05-18", + "2021-05-19", + "2021-05-20", + "2021-05-21", + "2021-05-22", + "2021-05-23", + "2021-05-24", + "2021-05-25", + "2021-05-26", + "2021-05-27", + "2021-05-28", + "2021-05-29", + "2021-05-30", + "2021-05-31", + "2021-06-01", + "2021-06-02", + "2021-06-03", + "2021-06-04", + "2021-06-05", + "2021-06-06", + "2021-06-07", + "2021-06-08", + "2021-06-09", + "2021-06-10", + "2021-06-11", + "2021-06-12", + "2021-06-13", + "2021-06-14", + "2021-06-15", + "2021-06-16", + "2021-06-17", + "2021-06-18", + "2021-06-19", + "2021-06-20", + "2021-06-21", + "2021-06-22", + "2021-06-23", + "2021-06-24", + "2021-06-25", + "2021-06-26", + "2021-06-27", + "2021-06-28", + "2021-06-29", + "2021-06-30", + "2021-07-01", + "2021-07-02", + "2021-07-03", + "2021-07-04", + "2021-07-05", + "2021-07-06", + "2021-07-07", + "2021-07-08", + "2021-07-09", + "2021-07-10", + "2021-07-11", + "2021-07-12", + "2021-07-13", + "2021-07-14", + "2021-07-15", + "2021-07-16", + "2021-07-17", + "2021-07-18", + "2021-07-19", + "2021-07-20", + "2021-07-21", + "2021-07-22", + "2021-07-23", + "2021-07-24", + "2021-07-25", + "2021-07-26", + "2021-07-27", + "2021-07-28", + "2021-07-29", + "2021-07-30", + "2021-07-31", + "2021-08-01", + "2021-08-02", + "2021-08-03", + "2021-08-04", + "2021-08-05", + "2021-08-06", + "2021-08-07", + "2021-08-08", + "2021-08-09", + "2021-08-10", + "2021-08-11", + "2021-08-12", + "2021-08-13", + "2021-08-14", + "2021-08-15", + "2021-08-16", + "2021-08-17", + "2021-08-18", + "2021-08-19", + "2021-08-20", + "2021-08-21", + "2021-08-22", + "2021-08-23", + "2021-08-24", + "2021-08-25", + "2021-08-26", + "2021-08-27", + "2021-08-28", + "2021-08-29", + "2021-08-30", + "2021-08-31", + "2021-09-01", + "2021-09-02", + "2021-09-03", + "2021-09-04", + "2021-09-05", + "2021-09-06", + "2021-09-07", + "2021-09-08", + "2021-09-09", + "2021-09-10", + "2021-09-11", + "2021-09-12", + "2021-09-13", + "2021-09-14", + "2021-09-15", + "2021-09-16", + "2021-09-17", + "2021-09-18", + "2021-09-19", + "2021-09-20", + "2021-09-21", + "2021-09-22", + "2021-09-23", + "2021-09-24", + "2021-09-25", + "2021-09-26", + "2021-09-27", + "2021-09-28", + "2021-09-29", + "2021-09-30", + "2021-10-01", + "2021-10-02", + "2021-10-03", + "2021-10-04", + "2021-10-05", + "2021-10-06", + "2021-10-07", + "2021-10-08", + "2021-10-09", + "2021-10-10", + "2021-10-11", + "2021-10-12", + "2021-10-13", + "2021-10-14", + "2021-10-15", + "2021-10-16", + "2021-10-17", + "2021-10-18", + "2021-10-19", + "2021-10-20", + "2021-10-21", + "2021-10-22", + "2021-10-23", + "2021-10-24", + "2021-10-25", + "2021-10-26", + "2021-10-27", + "2021-10-28", + "2021-10-29", + "2021-10-30", + "2021-10-31", + "2021-11-01", + "2021-11-02", + "2021-11-03", + "2021-11-04", + "2021-11-05", + "2021-11-06", + "2021-11-07", + "2021-11-08", + "2021-11-09", + "2021-11-10", + "2021-11-11", + "2021-11-12", + "2021-11-13", + "2021-11-14", + "2021-11-15", + "2021-11-16", + "2021-11-17", + "2021-11-18", + "2021-11-19", + "2021-11-20", + "2021-11-21", + "2021-11-22", + "2021-11-23", + "2021-11-24", + "2021-11-25", + "2021-11-26", + "2021-11-27", + "2021-11-28", + "2021-11-29", + "2021-11-30", + "2021-12-01", + "2021-12-02", + "2021-12-03", + "2021-12-04", + "2021-12-05", + "2021-12-06", + "2021-12-07", + "2021-12-08", + "2021-12-09", + "2021-12-10", + "2021-12-11", + "2021-12-12", + "2021-12-13", + "2021-12-14", + "2021-12-15", + "2021-12-16", + "2021-12-17", + "2021-12-18", + "2021-12-19", + "2021-12-20", + "2021-12-21", + "2021-12-22", + "2021-12-23", + "2021-12-24", + "2021-12-25", + "2021-12-26", + "2021-12-27", + "2021-12-28", + "2021-12-29", + "2021-12-30", + "2021-12-31" +] + +access(all) let btc_daily_2021_mixed_agents: [SimAgent] = [ + SimAgent( + count: 1, + debtPerAgent: 133333.00000000, + totalSystemDebt: 20000000.00000000 + ) +] + +access(all) let btc_daily_2021_mixed_pools: {String: SimPool} = { + "moet_yt": SimPool( + size: 500000.00000000, + concentration: 0.95000000, + feeTier: 0.00050000 + ), + "moet_btc": SimPool( + size: 5000000.00000000, + concentration: 0.80000000, + feeTier: 0.00300000 + ), + "pyusd_btc": SimPool( + size: 10000000.00000000, + concentration: 0.80000000, + feeTier: 0.00300000 + ), + "moet_fusdev": SimPool( + size: 500000.00000000, + concentration: 0.95000000, + feeTier: 0.00010000 + ) +} + +access(all) let btc_daily_2021_mixed_constants: SimConstants = SimConstants( + btcCollateralFactor: 0.80000000, + btcLiquidationThreshold: 0.85000000, + yieldAPR: 0.10000000, + directMintYT: true +) + +access(all) let btc_daily_2021_mixed_expectedLiquidationCount: Int = 0 +access(all) let btc_daily_2021_mixed_expectedAllAgentsSurvive: Bool = true + +access(all) let btc_daily_2021_mixed_durationDays: Int = 365 +access(all) let btc_daily_2021_mixed_notes: String = "Daily BTC/USD close prices from CoinMarketCap, 2021-01-01 to 2021-12-31. 365 data points." + +// ---- btc_daily_2022_bear ---- + +access(all) let btc_daily_2022_bear_prices: [UFix64] = [ + 47686.81000000, + 47345.22000000, + 46458.12000000, + 45897.58000000, + 43569.00000000, + 43160.93000000, + 41557.90000000, + 41733.94000000, + 41911.60000000, + 41821.26000000, + 42735.85000000, + 43949.10000000, + 42591.57000000, + 43099.70000000, + 43177.40000000, + 43113.88000000, + 42250.55000000, + 42375.63000000, + 41744.33000000, + 40680.42000000, + 36457.32000000, + 35030.25000000, + 36276.80000000, + 36654.33000000, + 36954.00000000, + 36852.12000000, + 37138.23000000, + 37784.33000000, + 38138.18000000, + 37917.60000000, + 38483.13000000, + 38743.27000000, + 36952.98000000, + 37154.60000000, + 41500.88000000, + 41441.16000000, + 42412.43000000, + 43840.29000000, + 44118.45000000, + 44338.80000000, + 43565.11000000, + 42407.94000000, + 42244.47000000, + 42197.52000000, + 42586.92000000, + 44575.20000000, + 43961.86000000, + 40538.01000000, + 40030.98000000, + 40122.15000000, + 38431.38000000, + 37075.28000000, + 38286.03000000, + 37296.57000000, + 38332.61000000, + 39214.22000000, + 39105.15000000, + 37709.78000000, + 43193.23000000, + 44354.64000000, + 43924.12000000, + 42451.79000000, + 39137.60000000, + 39400.58000000, + 38419.98000000, + 38062.04000000, + 38737.27000000, + 41982.93000000, + 39437.46000000, + 38794.97000000, + 38904.01000000, + 37849.66000000, + 39666.76000000, + 39338.79000000, + 41143.93000000, + 40951.38000000, + 41801.15000000, + 42190.65000000, + 41247.82000000, + 41078.00000000, + 42358.81000000, + 42892.96000000, + 43960.93000000, + 44348.73000000, + 44500.83000000, + 46820.49000000, + 47128.01000000, + 47465.73000000, + 47062.66000000, + 45538.68000000, + 46281.64000000, + 45868.95000000, + 46453.57000000, + 46622.67000000, + 45555.99000000, + 43206.74000000, + 43503.85000000, + 42287.66000000, + 42782.14000000, + 42207.67000000, + 39521.90000000, + 40127.18000000, + 41166.73000000, + 39935.52000000, + 40553.46000000, + 40424.48000000, + 39716.95000000, + 40826.21000000, + 41502.75000000, + 41374.38000000, + 40527.36000000, + 39740.32000000, + 39486.73000000, + 39469.29000000, + 40458.31000000, + 38117.46000000, + 39241.12000000, + 39773.83000000, + 38609.82000000, + 37714.88000000, + 38469.09000000, + 38529.33000000, + 37750.45000000, + 39698.37000000, + 36575.14000000, + 36040.92000000, + 35501.95000000, + 34059.26000000, + 30296.95000000, + 31022.91000000, + 28936.36000000, + 29047.75000000, + 29283.10000000, + 30101.27000000, + 31305.11000000, + 29862.92000000, + 30425.86000000, + 28720.27000000, + 30314.33000000, + 29200.74000000, + 29432.23000000, + 30323.72000000, + 29098.91000000, + 29655.59000000, + 29562.36000000, + 29267.22000000, + 28627.57000000, + 29023.49000000, + 29445.96000000, + 31726.39000000, + 31792.31000000, + 29799.08000000, + 30467.49000000, + 29704.39000000, + 29832.91000000, + 29906.66000000, + 31370.67000000, + 31155.48000000, + 30214.36000000, + 30112.00000000, + 29083.80000000, + 28360.81000000, + 26762.65000000, + 22487.39000000, + 22206.79000000, + 22572.84000000, + 20381.65000000, + 20471.48000000, + 19017.64000000, + 20553.27000000, + 20599.54000000, + 20710.60000000, + 19987.03000000, + 21085.88000000, + 21231.66000000, + 21502.34000000, + 21027.30000000, + 20735.48000000, + 20280.64000000, + 20104.02000000, + 19784.73000000, + 19269.37000000, + 19242.26000000, + 19297.08000000, + 20231.26000000, + 20190.11000000, + 20548.25000000, + 21637.59000000, + 21731.12000000, + 21592.21000000, + 20860.45000000, + 19970.56000000, + 19323.91000000, + 20212.07000000, + 20569.92000000, + 20836.33000000, + 21190.32000000, + 20779.34000000, + 22485.69000000, + 23389.43000000, + 23231.73000000, + 23164.63000000, + 22714.98000000, + 22465.48000000, + 22609.16000000, + 21361.70000000, + 21239.75000000, + 22930.55000000, + 23843.89000000, + 23804.63000000, + 23656.21000000, + 23336.90000000, + 23314.20000000, + 22978.12000000, + 22846.51000000, + 22630.96000000, + 23289.31000000, + 22961.28000000, + 23175.89000000, + 23809.49000000, + 23164.32000000, + 23947.64000000, + 23957.53000000, + 24402.82000000, + 24424.07000000, + 24319.33000000, + 24136.97000000, + 23883.29000000, + 23336.00000000, + 23212.74000000, + 20877.55000000, + 21166.06000000, + 21534.12000000, + 21398.91000000, + 21528.09000000, + 21395.02000000, + 21600.91000000, + 20260.02000000, + 20041.74000000, + 19616.81000000, + 20297.99000000, + 19796.81000000, + 20049.76000000, + 20127.14000000, + 19969.77000000, + 19832.09000000, + 19986.71000000, + 19812.37000000, + 18837.67000000, + 19290.32000000, + 19329.83000000, + 21381.15000000, + 21680.54000000, + 21769.26000000, + 22370.45000000, + 20296.71000000, + 20241.09000000, + 19701.21000000, + 19772.58000000, + 20127.58000000, + 19419.51000000, + 19544.13000000, + 18890.79000000, + 18547.40000000, + 19413.55000000, + 19297.64000000, + 18937.01000000, + 18802.10000000, + 19222.67000000, + 19110.55000000, + 19426.72000000, + 19573.05000000, + 19431.79000000, + 19312.09000000, + 19044.11000000, + 19623.58000000, + 20336.84000000, + 20160.72000000, + 19955.44000000, + 19546.85000000, + 19416.57000000, + 19446.43000000, + 19141.48000000, + 19051.42000000, + 19157.45000000, + 19382.90000000, + 19185.66000000, + 19067.64000000, + 19268.09000000, + 19550.76000000, + 19334.42000000, + 19139.53000000, + 19053.74000000, + 19172.47000000, + 19208.19000000, + 19567.01000000, + 19345.57000000, + 20095.86000000, + 20770.44000000, + 20285.84000000, + 20595.35000000, + 20818.48000000, + 20635.60000000, + 20495.77000000, + 20485.27000000, + 20159.50000000, + 20209.99000000, + 21147.23000000, + 21282.69000000, + 20926.49000000, + 20602.82000000, + 18541.27000000, + 15880.78000000, + 17586.77000000, + 17034.29000000, + 16799.18000000, + 16353.37000000, + 16618.20000000, + 16884.61000000, + 16669.44000000, + 16687.52000000, + 16697.78000000, + 16711.55000000, + 16291.83000000, + 15787.28000000, + 16189.77000000, + 16610.71000000, + 16604.47000000, + 16521.84000000, + 16464.28000000, + 16444.63000000, + 16217.32000000, + 16444.98000000, + 17168.57000000, + 16967.13000000, + 17088.66000000, + 16908.24000000, + 17130.49000000, + 16974.83000000, + 17089.50000000, + 16848.13000000, + 17233.47000000, + 17133.15000000, + 17128.72000000, + 17104.19000000, + 17206.44000000, + 17781.32000000, + 17652.10000000, + 17364.86000000, + 16647.48000000, + 16795.09000000, + 16757.98000000, + 16439.68000000, + 16906.31000000, + 16817.53000000, + 16830.34000000, + 16796.95000000, + 16847.76000000, + 16841.99000000, + 16919.81000000, + 16717.17000000, + 16552.57000000, + 16642.34000000, + 16602.59000000, + 16547.50000000 +] + +access(all) let btc_daily_2022_bear_dates: [String] = [ + "2022-01-01", + "2022-01-02", + "2022-01-03", + "2022-01-04", + "2022-01-05", + "2022-01-06", + "2022-01-07", + "2022-01-08", + "2022-01-09", + "2022-01-10", + "2022-01-11", + "2022-01-12", + "2022-01-13", + "2022-01-14", + "2022-01-15", + "2022-01-16", + "2022-01-17", + "2022-01-18", + "2022-01-19", + "2022-01-20", + "2022-01-21", + "2022-01-22", + "2022-01-23", + "2022-01-24", + "2022-01-25", + "2022-01-26", + "2022-01-27", + "2022-01-28", + "2022-01-29", + "2022-01-30", + "2022-01-31", + "2022-02-01", + "2022-02-02", + "2022-02-03", + "2022-02-04", + "2022-02-05", + "2022-02-06", + "2022-02-07", + "2022-02-08", + "2022-02-09", + "2022-02-10", + "2022-02-11", + "2022-02-12", + "2022-02-13", + "2022-02-14", + "2022-02-15", + "2022-02-16", + "2022-02-17", + "2022-02-18", + "2022-02-19", + "2022-02-20", + "2022-02-21", + "2022-02-22", + "2022-02-23", + "2022-02-24", + "2022-02-25", + "2022-02-26", + "2022-02-27", + "2022-02-28", + "2022-03-01", + "2022-03-02", + "2022-03-03", + "2022-03-04", + "2022-03-05", + "2022-03-06", + "2022-03-07", + "2022-03-08", + "2022-03-09", + "2022-03-10", + "2022-03-11", + "2022-03-12", + "2022-03-13", + "2022-03-14", + "2022-03-15", + "2022-03-16", + "2022-03-17", + "2022-03-18", + "2022-03-19", + "2022-03-20", + "2022-03-21", + "2022-03-22", + "2022-03-23", + "2022-03-24", + "2022-03-25", + "2022-03-26", + "2022-03-27", + "2022-03-28", + "2022-03-29", + "2022-03-30", + "2022-03-31", + "2022-04-01", + "2022-04-02", + "2022-04-03", + "2022-04-04", + "2022-04-05", + "2022-04-06", + "2022-04-07", + "2022-04-08", + "2022-04-09", + "2022-04-10", + "2022-04-11", + "2022-04-12", + "2022-04-13", + "2022-04-14", + "2022-04-15", + "2022-04-16", + "2022-04-17", + "2022-04-18", + "2022-04-19", + "2022-04-20", + "2022-04-21", + "2022-04-22", + "2022-04-23", + "2022-04-24", + "2022-04-25", + "2022-04-26", + "2022-04-27", + "2022-04-28", + "2022-04-29", + "2022-04-30", + "2022-05-01", + "2022-05-02", + "2022-05-03", + "2022-05-04", + "2022-05-05", + "2022-05-06", + "2022-05-07", + "2022-05-08", + "2022-05-09", + "2022-05-10", + "2022-05-11", + "2022-05-12", + "2022-05-13", + "2022-05-14", + "2022-05-15", + "2022-05-16", + "2022-05-17", + "2022-05-18", + "2022-05-19", + "2022-05-20", + "2022-05-21", + "2022-05-22", + "2022-05-23", + "2022-05-24", + "2022-05-25", + "2022-05-26", + "2022-05-27", + "2022-05-28", + "2022-05-29", + "2022-05-30", + "2022-05-31", + "2022-06-01", + "2022-06-02", + "2022-06-03", + "2022-06-04", + "2022-06-05", + "2022-06-06", + "2022-06-07", + "2022-06-08", + "2022-06-09", + "2022-06-10", + "2022-06-11", + "2022-06-12", + "2022-06-13", + "2022-06-14", + "2022-06-15", + "2022-06-16", + "2022-06-17", + "2022-06-18", + "2022-06-19", + "2022-06-20", + "2022-06-21", + "2022-06-22", + "2022-06-23", + "2022-06-24", + "2022-06-25", + "2022-06-26", + "2022-06-27", + "2022-06-28", + "2022-06-29", + "2022-06-30", + "2022-07-01", + "2022-07-02", + "2022-07-03", + "2022-07-04", + "2022-07-05", + "2022-07-06", + "2022-07-07", + "2022-07-08", + "2022-07-09", + "2022-07-10", + "2022-07-11", + "2022-07-12", + "2022-07-13", + "2022-07-14", + "2022-07-15", + "2022-07-16", + "2022-07-17", + "2022-07-18", + "2022-07-19", + "2022-07-20", + "2022-07-21", + "2022-07-22", + "2022-07-23", + "2022-07-24", + "2022-07-25", + "2022-07-26", + "2022-07-27", + "2022-07-28", + "2022-07-29", + "2022-07-30", + "2022-07-31", + "2022-08-01", + "2022-08-02", + "2022-08-03", + "2022-08-04", + "2022-08-05", + "2022-08-06", + "2022-08-07", + "2022-08-08", + "2022-08-09", + "2022-08-10", + "2022-08-11", + "2022-08-12", + "2022-08-13", + "2022-08-14", + "2022-08-15", + "2022-08-16", + "2022-08-17", + "2022-08-18", + "2022-08-19", + "2022-08-20", + "2022-08-21", + "2022-08-22", + "2022-08-23", + "2022-08-24", + "2022-08-25", + "2022-08-26", + "2022-08-27", + "2022-08-28", + "2022-08-29", + "2022-08-30", + "2022-08-31", + "2022-09-01", + "2022-09-02", + "2022-09-03", + "2022-09-04", + "2022-09-05", + "2022-09-06", + "2022-09-07", + "2022-09-08", + "2022-09-09", + "2022-09-10", + "2022-09-11", + "2022-09-12", + "2022-09-13", + "2022-09-14", + "2022-09-15", + "2022-09-16", + "2022-09-17", + "2022-09-18", + "2022-09-19", + "2022-09-20", + "2022-09-21", + "2022-09-22", + "2022-09-23", + "2022-09-24", + "2022-09-25", + "2022-09-26", + "2022-09-27", + "2022-09-28", + "2022-09-29", + "2022-09-30", + "2022-10-01", + "2022-10-02", + "2022-10-03", + "2022-10-04", + "2022-10-05", + "2022-10-06", + "2022-10-07", + "2022-10-08", + "2022-10-09", + "2022-10-10", + "2022-10-11", + "2022-10-12", + "2022-10-13", + "2022-10-14", + "2022-10-15", + "2022-10-16", + "2022-10-17", + "2022-10-18", + "2022-10-19", + "2022-10-20", + "2022-10-21", + "2022-10-22", + "2022-10-23", + "2022-10-24", + "2022-10-25", + "2022-10-26", + "2022-10-27", + "2022-10-28", + "2022-10-29", + "2022-10-30", + "2022-10-31", + "2022-11-01", + "2022-11-02", + "2022-11-03", + "2022-11-04", + "2022-11-05", + "2022-11-06", + "2022-11-07", + "2022-11-08", + "2022-11-09", + "2022-11-10", + "2022-11-11", + "2022-11-12", + "2022-11-13", + "2022-11-14", + "2022-11-15", + "2022-11-16", + "2022-11-17", + "2022-11-18", + "2022-11-19", + "2022-11-20", + "2022-11-21", + "2022-11-22", + "2022-11-23", + "2022-11-24", + "2022-11-25", + "2022-11-26", + "2022-11-27", + "2022-11-28", + "2022-11-29", + "2022-11-30", + "2022-12-01", + "2022-12-02", + "2022-12-03", + "2022-12-04", + "2022-12-05", + "2022-12-06", + "2022-12-07", + "2022-12-08", + "2022-12-09", + "2022-12-10", + "2022-12-11", + "2022-12-12", + "2022-12-13", + "2022-12-14", + "2022-12-15", + "2022-12-16", + "2022-12-17", + "2022-12-18", + "2022-12-19", + "2022-12-20", + "2022-12-21", + "2022-12-22", + "2022-12-23", + "2022-12-24", + "2022-12-25", + "2022-12-26", + "2022-12-27", + "2022-12-28", + "2022-12-29", + "2022-12-30", + "2022-12-31" +] + +access(all) let btc_daily_2022_bear_agents: [SimAgent] = [ + SimAgent( + count: 1, + debtPerAgent: 133333.00000000, + totalSystemDebt: 20000000.00000000 + ) +] + +access(all) let btc_daily_2022_bear_pools: {String: SimPool} = { + "moet_yt": SimPool( + size: 500000.00000000, + concentration: 0.95000000, + feeTier: 0.00050000 + ), + "moet_btc": SimPool( + size: 5000000.00000000, + concentration: 0.80000000, + feeTier: 0.00300000 + ), + "pyusd_btc": SimPool( + size: 10000000.00000000, + concentration: 0.80000000, + feeTier: 0.00300000 + ), + "moet_fusdev": SimPool( + size: 500000.00000000, + concentration: 0.95000000, + feeTier: 0.00010000 + ) +} + +access(all) let btc_daily_2022_bear_constants: SimConstants = SimConstants( + btcCollateralFactor: 0.80000000, + btcLiquidationThreshold: 0.85000000, + yieldAPR: 0.10000000, + directMintYT: true +) + +access(all) let btc_daily_2022_bear_expectedLiquidationCount: Int = 0 +access(all) let btc_daily_2022_bear_expectedAllAgentsSurvive: Bool = true + +access(all) let btc_daily_2022_bear_durationDays: Int = 365 +access(all) let btc_daily_2022_bear_notes: String = "Daily BTC/USD close prices from CoinMarketCap, 2022-01-01 to 2022-12-31. 365 data points." + +// ---- btc_daily_2023_bull ---- + +access(all) let btc_daily_2023_bull_prices: [UFix64] = [ + 16625.08000000, + 16688.47000000, + 16679.86000000, + 16863.24000000, + 16836.74000000, + 16951.97000000, + 16955.08000000, + 17091.14000000, + 17196.55000000, + 17446.29000000, + 17943.90000000, + 18869.59000000, + 19909.57000000, + 20976.30000000, + 20880.80000000, + 21169.63000000, + 21161.52000000, + 20688.78000000, + 21086.79000000, + 22676.55000000, + 22777.63000000, + 22720.42000000, + 22934.43000000, + 22636.47000000, + 23117.86000000, + 23032.78000000, + 23078.73000000, + 23031.09000000, + 23774.57000000, + 22840.14000000, + 23139.28000000, + 23723.77000000, + 23471.87000000, + 23449.32000000, + 23331.85000000, + 22955.67000000, + 22760.11000000, + 23264.29000000, + 22939.40000000, + 21819.04000000, + 21651.18000000, + 21870.87000000, + 21788.20000000, + 21808.10000000, + 22220.80000000, + 24307.84000000, + 23623.47000000, + 24565.60000000, + 24641.28000000, + 24327.64000000, + 24829.15000000, + 24436.35000000, + 24188.84000000, + 23947.49000000, + 23198.13000000, + 23175.38000000, + 23561.21000000, + 23522.87000000, + 23147.35000000, + 23646.55000000, + 23475.47000000, + 22362.68000000, + 22353.35000000, + 22435.51000000, + 22429.76000000, + 22219.77000000, + 21718.08000000, + 20363.02000000, + 20187.24000000, + 20632.41000000, + 22163.95000000, + 24197.53000000, + 24746.07000000, + 24375.96000000, + 25052.79000000, + 27423.93000000, + 26965.88000000, + 28038.67000000, + 27767.24000000, + 28175.82000000, + 27307.44000000, + 28333.97000000, + 27493.29000000, + 27494.71000000, + 27994.33000000, + 27139.89000000, + 27268.13000000, + 28348.44000000, + 28033.56000000, + 28478.48000000, + 28411.03000000, + 28199.31000000, + 27790.22000000, + 28168.09000000, + 28177.98000000, + 28044.14000000, + 27925.86000000, + 27947.79000000, + 28333.05000000, + 29652.98000000, + 30235.06000000, + 30139.05000000, + 30399.07000000, + 30485.70000000, + 30318.50000000, + 30315.36000000, + 29445.04000000, + 30397.55000000, + 28822.68000000, + 28245.99000000, + 27276.91000000, + 27817.50000000, + 27591.38000000, + 27525.34000000, + 28307.60000000, + 28422.70000000, + 29473.79000000, + 29340.26000000, + 29248.49000000, + 29268.81000000, + 28091.57000000, + 28680.54000000, + 29006.31000000, + 28847.71000000, + 29534.38000000, + 28904.62000000, + 28454.98000000, + 27694.27000000, + 27658.77000000, + 27621.76000000, + 27000.79000000, + 26804.99000000, + 26784.08000000, + 26930.64000000, + 27192.69000000, + 27036.65000000, + 27398.80000000, + 26832.21000000, + 26890.13000000, + 27129.59000000, + 26753.83000000, + 26851.28000000, + 27225.73000000, + 26334.82000000, + 26476.21000000, + 26719.29000000, + 26868.35000000, + 28085.65000000, + 27745.88000000, + 27702.35000000, + 27219.66000000, + 26819.97000000, + 27249.59000000, + 27075.13000000, + 27119.07000000, + 25760.10000000, + 27238.78000000, + 26346.00000000, + 26508.22000000, + 26480.38000000, + 25851.24000000, + 25940.17000000, + 25902.50000000, + 25918.73000000, + 25124.68000000, + 25576.39000000, + 26327.46000000, + 26510.68000000, + 26336.21000000, + 26851.03000000, + 28327.49000000, + 30027.30000000, + 29912.28000000, + 30695.47000000, + 30548.69000000, + 30480.26000000, + 30271.13000000, + 30688.16000000, + 30086.25000000, + 30445.35000000, + 30477.25000000, + 30590.08000000, + 30620.77000000, + 31156.44000000, + 30777.58000000, + 30514.17000000, + 29909.34000000, + 30342.26000000, + 30292.54000000, + 30171.23000000, + 30414.47000000, + 30620.95000000, + 30391.65000000, + 31476.05000000, + 30334.07000000, + 30295.81000000, + 30249.13000000, + 30145.89000000, + 29856.56000000, + 29913.92000000, + 29792.02000000, + 29908.74000000, + 29771.80000000, + 30084.54000000, + 29176.92000000, + 29227.39000000, + 29354.97000000, + 29210.69000000, + 29319.25000000, + 29356.92000000, + 29275.31000000, + 29230.11000000, + 29675.73000000, + 29151.96000000, + 29178.68000000, + 29074.09000000, + 29042.13000000, + 29041.86000000, + 29180.58000000, + 29765.49000000, + 29561.49000000, + 29429.59000000, + 29397.72000000, + 29415.96000000, + 29282.91000000, + 29408.44000000, + 29170.35000000, + 28701.78000000, + 26664.55000000, + 26049.56000000, + 26096.20000000, + 26189.58000000, + 26124.14000000, + 26031.66000000, + 26431.64000000, + 26162.37000000, + 26047.67000000, + 26008.46000000, + 26089.69000000, + 26106.15000000, + 27727.39000000, + 27297.27000000, + 25931.47000000, + 25800.72000000, + 25868.80000000, + 25969.57000000, + 25812.42000000, + 25779.98000000, + 25753.24000000, + 26240.19000000, + 25905.65000000, + 25895.68000000, + 25832.23000000, + 25162.66000000, + 25833.34000000, + 26228.32000000, + 26539.67000000, + 26608.69000000, + 26568.28000000, + 26534.19000000, + 26754.28000000, + 27211.12000000, + 27132.01000000, + 26567.63000000, + 26579.57000000, + 26579.39000000, + 26256.83000000, + 26298.48000000, + 26217.25000000, + 26352.72000000, + 27021.55000000, + 26911.72000000, + 26967.92000000, + 27983.75000000, + 27530.78000000, + 27429.98000000, + 27799.39000000, + 27415.91000000, + 27946.60000000, + 27968.84000000, + 27935.09000000, + 27583.68000000, + 27391.02000000, + 26873.32000000, + 26756.80000000, + 26862.38000000, + 26861.71000000, + 27159.65000000, + 28519.47000000, + 28415.75000000, + 28328.34000000, + 28719.81000000, + 29682.95000000, + 29918.41000000, + 29993.90000000, + 33086.23000000, + 33901.53000000, + 34502.82000000, + 34156.65000000, + 33909.80000000, + 34089.58000000, + 34538.48000000, + 34502.36000000, + 34667.78000000, + 35437.25000000, + 34938.24000000, + 34732.33000000, + 35082.20000000, + 35049.36000000, + 35037.37000000, + 35443.56000000, + 35655.28000000, + 36693.12000000, + 37313.97000000, + 37138.05000000, + 37054.52000000, + 36502.36000000, + 35537.64000000, + 37880.58000000, + 36154.77000000, + 36596.68000000, + 36585.70000000, + 37386.55000000, + 37476.96000000, + 35813.81000000, + 37432.34000000, + 37289.62000000, + 37720.28000000, + 37796.79000000, + 37479.12000000, + 37254.17000000, + 37831.09000000, + 37858.49000000, + 37712.75000000, + 38688.75000000, + 39476.33000000, + 39978.39000000, + 41980.10000000, + 44080.65000000, + 43746.45000000, + 43292.66000000, + 44166.60000000, + 43725.99000000, + 43779.70000000, + 41243.83000000, + 41450.22000000, + 42890.74000000, + 43023.97000000, + 41929.76000000, + 42240.12000000, + 41364.67000000, + 42623.54000000, + 42270.53000000, + 43652.25000000, + 43869.15000000, + 43997.90000000, + 43739.54000000, + 43016.12000000, + 43613.14000000, + 42520.40000000, + 43442.85000000, + 42627.85000000, + 42099.40000000, + 42156.90000000, + 42265.19000000 +] + +access(all) let btc_daily_2023_bull_dates: [String] = [ + "2023-01-01", + "2023-01-02", + "2023-01-03", + "2023-01-04", + "2023-01-05", + "2023-01-06", + "2023-01-07", + "2023-01-08", + "2023-01-09", + "2023-01-10", + "2023-01-11", + "2023-01-12", + "2023-01-13", + "2023-01-14", + "2023-01-15", + "2023-01-16", + "2023-01-17", + "2023-01-18", + "2023-01-19", + "2023-01-20", + "2023-01-21", + "2023-01-22", + "2023-01-23", + "2023-01-24", + "2023-01-25", + "2023-01-26", + "2023-01-27", + "2023-01-28", + "2023-01-29", + "2023-01-30", + "2023-01-31", + "2023-02-01", + "2023-02-02", + "2023-02-03", + "2023-02-04", + "2023-02-05", + "2023-02-06", + "2023-02-07", + "2023-02-08", + "2023-02-09", + "2023-02-10", + "2023-02-11", + "2023-02-12", + "2023-02-13", + "2023-02-14", + "2023-02-15", + "2023-02-16", + "2023-02-17", + "2023-02-18", + "2023-02-19", + "2023-02-20", + "2023-02-21", + "2023-02-22", + "2023-02-23", + "2023-02-24", + "2023-02-25", + "2023-02-26", + "2023-02-27", + "2023-02-28", + "2023-03-01", + "2023-03-02", + "2023-03-03", + "2023-03-04", + "2023-03-05", + "2023-03-06", + "2023-03-07", + "2023-03-08", + "2023-03-09", + "2023-03-10", + "2023-03-11", + "2023-03-12", + "2023-03-13", + "2023-03-14", + "2023-03-15", + "2023-03-16", + "2023-03-17", + "2023-03-18", + "2023-03-19", + "2023-03-20", + "2023-03-21", + "2023-03-22", + "2023-03-23", + "2023-03-24", + "2023-03-25", + "2023-03-26", + "2023-03-27", + "2023-03-28", + "2023-03-29", + "2023-03-30", + "2023-03-31", + "2023-04-01", + "2023-04-02", + "2023-04-03", + "2023-04-04", + "2023-04-05", + "2023-04-06", + "2023-04-07", + "2023-04-08", + "2023-04-09", + "2023-04-10", + "2023-04-11", + "2023-04-12", + "2023-04-13", + "2023-04-14", + "2023-04-15", + "2023-04-16", + "2023-04-17", + "2023-04-18", + "2023-04-19", + "2023-04-20", + "2023-04-21", + "2023-04-22", + "2023-04-23", + "2023-04-24", + "2023-04-25", + "2023-04-26", + "2023-04-27", + "2023-04-28", + "2023-04-29", + "2023-04-30", + "2023-05-01", + "2023-05-02", + "2023-05-03", + "2023-05-04", + "2023-05-05", + "2023-05-06", + "2023-05-07", + "2023-05-08", + "2023-05-09", + "2023-05-10", + "2023-05-11", + "2023-05-12", + "2023-05-13", + "2023-05-14", + "2023-05-15", + "2023-05-16", + "2023-05-17", + "2023-05-18", + "2023-05-19", + "2023-05-20", + "2023-05-21", + "2023-05-22", + "2023-05-23", + "2023-05-24", + "2023-05-25", + "2023-05-26", + "2023-05-27", + "2023-05-28", + "2023-05-29", + "2023-05-30", + "2023-05-31", + "2023-06-01", + "2023-06-02", + "2023-06-03", + "2023-06-04", + "2023-06-05", + "2023-06-06", + "2023-06-07", + "2023-06-08", + "2023-06-09", + "2023-06-10", + "2023-06-11", + "2023-06-12", + "2023-06-13", + "2023-06-14", + "2023-06-15", + "2023-06-16", + "2023-06-17", + "2023-06-18", + "2023-06-19", + "2023-06-20", + "2023-06-21", + "2023-06-22", + "2023-06-23", + "2023-06-24", + "2023-06-25", + "2023-06-26", + "2023-06-27", + "2023-06-28", + "2023-06-29", + "2023-06-30", + "2023-07-01", + "2023-07-02", + "2023-07-03", + "2023-07-04", + "2023-07-05", + "2023-07-06", + "2023-07-07", + "2023-07-08", + "2023-07-09", + "2023-07-10", + "2023-07-11", + "2023-07-12", + "2023-07-13", + "2023-07-14", + "2023-07-15", + "2023-07-16", + "2023-07-17", + "2023-07-18", + "2023-07-19", + "2023-07-20", + "2023-07-21", + "2023-07-22", + "2023-07-23", + "2023-07-24", + "2023-07-25", + "2023-07-26", + "2023-07-27", + "2023-07-28", + "2023-07-29", + "2023-07-30", + "2023-07-31", + "2023-08-01", + "2023-08-02", + "2023-08-03", + "2023-08-04", + "2023-08-05", + "2023-08-06", + "2023-08-07", + "2023-08-08", + "2023-08-09", + "2023-08-10", + "2023-08-11", + "2023-08-12", + "2023-08-13", + "2023-08-14", + "2023-08-15", + "2023-08-16", + "2023-08-17", + "2023-08-18", + "2023-08-19", + "2023-08-20", + "2023-08-21", + "2023-08-22", + "2023-08-23", + "2023-08-24", + "2023-08-25", + "2023-08-26", + "2023-08-27", + "2023-08-28", + "2023-08-29", + "2023-08-30", + "2023-08-31", + "2023-09-01", + "2023-09-02", + "2023-09-03", + "2023-09-04", + "2023-09-05", + "2023-09-06", + "2023-09-07", + "2023-09-08", + "2023-09-09", + "2023-09-10", + "2023-09-11", + "2023-09-12", + "2023-09-13", + "2023-09-14", + "2023-09-15", + "2023-09-16", + "2023-09-17", + "2023-09-18", + "2023-09-19", + "2023-09-20", + "2023-09-21", + "2023-09-22", + "2023-09-23", + "2023-09-24", + "2023-09-25", + "2023-09-26", + "2023-09-27", + "2023-09-28", + "2023-09-29", + "2023-09-30", + "2023-10-01", + "2023-10-02", + "2023-10-03", + "2023-10-04", + "2023-10-05", + "2023-10-06", + "2023-10-07", + "2023-10-08", + "2023-10-09", + "2023-10-10", + "2023-10-11", + "2023-10-12", + "2023-10-13", + "2023-10-14", + "2023-10-15", + "2023-10-16", + "2023-10-17", + "2023-10-18", + "2023-10-19", + "2023-10-20", + "2023-10-21", + "2023-10-22", + "2023-10-23", + "2023-10-24", + "2023-10-25", + "2023-10-26", + "2023-10-27", + "2023-10-28", + "2023-10-29", + "2023-10-30", + "2023-10-31", + "2023-11-01", + "2023-11-02", + "2023-11-03", + "2023-11-04", + "2023-11-05", + "2023-11-06", + "2023-11-07", + "2023-11-08", + "2023-11-09", + "2023-11-10", + "2023-11-11", + "2023-11-12", + "2023-11-13", + "2023-11-14", + "2023-11-15", + "2023-11-16", + "2023-11-17", + "2023-11-18", + "2023-11-19", + "2023-11-20", + "2023-11-21", + "2023-11-22", + "2023-11-23", + "2023-11-24", + "2023-11-25", + "2023-11-26", + "2023-11-27", + "2023-11-28", + "2023-11-29", + "2023-11-30", + "2023-12-01", + "2023-12-02", + "2023-12-03", + "2023-12-04", + "2023-12-05", + "2023-12-06", + "2023-12-07", + "2023-12-08", + "2023-12-09", + "2023-12-10", + "2023-12-11", + "2023-12-12", + "2023-12-13", + "2023-12-14", + "2023-12-15", + "2023-12-16", + "2023-12-17", + "2023-12-18", + "2023-12-19", + "2023-12-20", + "2023-12-21", + "2023-12-22", + "2023-12-23", + "2023-12-24", + "2023-12-25", + "2023-12-26", + "2023-12-27", + "2023-12-28", + "2023-12-29", + "2023-12-30", + "2023-12-31" +] + +access(all) let btc_daily_2023_bull_agents: [SimAgent] = [ + SimAgent( + count: 1, + debtPerAgent: 133333.00000000, + totalSystemDebt: 20000000.00000000 + ) +] + +access(all) let btc_daily_2023_bull_pools: {String: SimPool} = { + "moet_yt": SimPool( + size: 500000.00000000, + concentration: 0.95000000, + feeTier: 0.00050000 + ), + "moet_btc": SimPool( + size: 5000000.00000000, + concentration: 0.80000000, + feeTier: 0.00300000 + ), + "pyusd_btc": SimPool( + size: 10000000.00000000, + concentration: 0.80000000, + feeTier: 0.00300000 + ), + "moet_fusdev": SimPool( + size: 500000.00000000, + concentration: 0.95000000, + feeTier: 0.00010000 + ) +} + +access(all) let btc_daily_2023_bull_constants: SimConstants = SimConstants( + btcCollateralFactor: 0.80000000, + btcLiquidationThreshold: 0.85000000, + yieldAPR: 0.10000000, + directMintYT: true +) + +access(all) let btc_daily_2023_bull_expectedLiquidationCount: Int = 0 +access(all) let btc_daily_2023_bull_expectedAllAgentsSurvive: Bool = true + +access(all) let btc_daily_2023_bull_durationDays: Int = 365 +access(all) let btc_daily_2023_bull_notes: String = "Daily BTC/USD close prices from CoinMarketCap, 2023-01-01 to 2023-12-31. 365 data points." + +// ---- btc_daily_2024_bull ---- + +access(all) let btc_daily_2024_bull_prices: [UFix64] = [ + 44167.33000000, + 44957.97000000, + 42848.18000000, + 44179.92000000, + 44162.69000000, + 43989.19000000, + 43943.10000000, + 46970.50000000, + 46139.73000000, + 46627.78000000, + 46368.59000000, + 42853.17000000, + 42842.38000000, + 41796.27000000, + 42511.97000000, + 43154.94000000, + 42742.65000000, + 41262.06000000, + 41618.41000000, + 41665.58000000, + 41545.78000000, + 39507.37000000, + 39845.55000000, + 40077.07000000, + 39933.81000000, + 41816.87000000, + 42120.06000000, + 42035.59000000, + 43288.25000000, + 42952.61000000, + 42582.61000000, + 43075.77000000, + 43185.86000000, + 42992.25000000, + 42583.58000000, + 42658.67000000, + 43084.67000000, + 44318.22000000, + 45301.57000000, + 47147.20000000, + 47771.28000000, + 48293.92000000, + 49958.22000000, + 49742.44000000, + 51826.70000000, + 51938.56000000, + 52160.20000000, + 51663.00000000, + 52122.55000000, + 51779.14000000, + 52284.87000000, + 51839.18000000, + 51304.97000000, + 50731.95000000, + 51571.10000000, + 51733.24000000, + 54522.40000000, + 57085.37000000, + 62504.79000000, + 61198.38000000, + 62440.63000000, + 62029.85000000, + 63167.37000000, + 68330.42000000, + 63801.20000000, + 66106.80000000, + 66925.48000000, + 68300.10000000, + 68498.88000000, + 69019.79000000, + 72123.90000000, + 71481.29000000, + 73083.50000000, + 71396.59000000, + 69403.77000000, + 65315.12000000, + 68390.62000000, + 67548.59000000, + 61912.77000000, + 67913.67000000, + 65491.39000000, + 63778.76000000, + 64062.20000000, + 67234.17000000, + 69958.81000000, + 69987.84000000, + 69455.34000000, + 70744.95000000, + 69892.83000000, + 69645.31000000, + 71333.65000000, + 69702.15000000, + 65446.97000000, + 65980.81000000, + 68508.84000000, + 67837.64000000, + 68896.11000000, + 69362.55000000, + 71631.36000000, + 69139.02000000, + 70587.88000000, + 70060.61000000, + 67195.86000000, + 63821.47000000, + 65738.72000000, + 63426.21000000, + 63811.86000000, + 61276.69000000, + 63512.75000000, + 63843.57000000, + 64994.44000000, + 64926.64000000, + 66837.68000000, + 66407.27000000, + 64276.90000000, + 64481.71000000, + 63755.32000000, + 63419.14000000, + 63113.23000000, + 63841.12000000, + 60636.86000000, + 58254.01000000, + 59123.43000000, + 62889.84000000, + 63891.47000000, + 64031.13000000, + 63161.95000000, + 62334.82000000, + 61187.94000000, + 63049.96000000, + 60792.78000000, + 60793.71000000, + 61448.39000000, + 62901.45000000, + 61552.79000000, + 66267.49000000, + 65231.58000000, + 67051.87000000, + 66940.80000000, + 66278.37000000, + 71448.20000000, + 70136.53000000, + 69122.34000000, + 67929.56000000, + 68526.10000000, + 69265.94000000, + 68518.09000000, + 69394.55000000, + 68296.22000000, + 67578.09000000, + 68364.99000000, + 67489.61000000, + 67706.94000000, + 67751.60000000, + 68804.78000000, + 70567.77000000, + 71082.82000000, + 70757.17000000, + 69342.59000000, + 69305.77000000, + 69647.99000000, + 69512.28000000, + 67332.03000000, + 68241.18000000, + 66756.40000000, + 66011.09000000, + 66191.00000000, + 66639.05000000, + 66490.29000000, + 65140.74000000, + 64960.30000000, + 64828.66000000, + 64096.20000000, + 64252.58000000, + 63180.80000000, + 60277.41000000, + 61804.64000000, + 60811.28000000, + 61604.80000000, + 60320.14000000, + 60887.38000000, + 62678.29000000, + 62851.98000000, + 62029.02000000, + 60173.92000000, + 56977.70000000, + 56662.37000000, + 58303.54000000, + 55849.11000000, + 56705.10000000, + 58009.23000000, + 57742.49000000, + 57344.91000000, + 57899.47000000, + 59231.95000000, + 60787.79000000, + 64870.15000000, + 65097.15000000, + 64118.79000000, + 63974.07000000, + 66710.15000000, + 67163.64000000, + 68154.52000000, + 67585.25000000, + 65927.67000000, + 65372.13000000, + 65777.22000000, + 67912.06000000, + 67813.34000000, + 68255.87000000, + 66819.92000000, + 66201.02000000, + 64619.25000000, + 65357.50000000, + 61415.06000000, + 60680.09000000, + 58116.98000000, + 53991.46000000, + 56034.32000000, + 55027.46000000, + 61710.14000000, + 60880.11000000, + 60945.81000000, + 58719.48000000, + 59354.51000000, + 60609.57000000, + 58737.27000000, + 57560.10000000, + 58894.10000000, + 59478.97000000, + 58483.96000000, + 59493.45000000, + 59012.79000000, + 61175.19000000, + 60381.91000000, + 64094.36000000, + 64178.99000000, + 64333.54000000, + 62880.66000000, + 59504.13000000, + 59027.63000000, + 59388.18000000, + 59119.47000000, + 58969.90000000, + 57325.49000000, + 59112.48000000, + 57431.02000000, + 57971.54000000, + 56160.49000000, + 53948.75000000, + 54139.69000000, + 54841.57000000, + 57019.53000000, + 57648.71000000, + 57343.17000000, + 58127.01000000, + 60571.30000000, + 60005.12000000, + 59182.84000000, + 58192.51000000, + 60308.54000000, + 61649.68000000, + 62940.46000000, + 63192.98000000, + 63394.84000000, + 63648.71000000, + 63329.80000000, + 64301.97000000, + 63143.15000000, + 65181.02000000, + 65790.66000000, + 65887.65000000, + 65635.31000000, + 63329.50000000, + 60837.01000000, + 60632.79000000, + 60759.40000000, + 62067.48000000, + 62089.95000000, + 62818.95000000, + 62236.66000000, + 62131.97000000, + 60582.10000000, + 60274.50000000, + 62445.09000000, + 63193.02000000, + 62851.37000000, + 66046.13000000, + 67041.11000000, + 67612.72000000, + 67399.83000000, + 68418.79000000, + 68362.73000000, + 69001.71000000, + 67367.85000000, + 67361.40000000, + 66432.20000000, + 68161.05000000, + 66642.41000000, + 67014.70000000, + 67929.30000000, + 69907.75000000, + 72720.49000000, + 72339.54000000, + 70215.19000000, + 69482.47000000, + 69289.28000000, + 68741.12000000, + 67811.51000000, + 69359.57000000, + 75639.08000000, + 75904.86000000, + 76545.48000000, + 76778.87000000, + 80474.19000000, + 88701.49000000, + 87955.81000000, + 90584.17000000, + 87250.43000000, + 91066.01000000, + 90558.48000000, + 89845.85000000, + 90542.64000000, + 92343.79000000, + 94339.50000000, + 98504.73000000, + 98997.66000000, + 97777.28000000, + 98013.82000000, + 93102.30000000, + 91985.32000000, + 95962.53000000, + 95652.47000000, + 97461.52000000, + 96449.06000000, + 97279.79000000, + 95865.30000000, + 96002.16000000, + 98768.53000000, + 96593.57000000, + 99920.71000000, + 99923.34000000, + 101236.01000000, + 97432.72000000, + 96675.43000000, + 101173.03000000, + 100043.00000000, + 101459.25000000, + 101372.97000000, + 104298.70000000, + 106029.72000000, + 106140.60000000, + 100041.54000000, + 97490.95000000, + 97755.93000000, + 97224.73000000, + 95104.93000000, + 94686.24000000, + 98676.10000000, + 99299.19000000, + 95795.52000000, + 94164.86000000, + 95163.93000000, + 93530.23000000, + 92643.21000000, + 93429.20000000 +] + +access(all) let btc_daily_2024_bull_dates: [String] = [ + "2024-01-01", + "2024-01-02", + "2024-01-03", + "2024-01-04", + "2024-01-05", + "2024-01-06", + "2024-01-07", + "2024-01-08", + "2024-01-09", + "2024-01-10", + "2024-01-11", + "2024-01-12", + "2024-01-13", + "2024-01-14", + "2024-01-15", + "2024-01-16", + "2024-01-17", + "2024-01-18", + "2024-01-19", + "2024-01-20", + "2024-01-21", + "2024-01-22", + "2024-01-23", + "2024-01-24", + "2024-01-25", + "2024-01-26", + "2024-01-27", + "2024-01-28", + "2024-01-29", + "2024-01-30", + "2024-01-31", + "2024-02-01", + "2024-02-02", + "2024-02-03", + "2024-02-04", + "2024-02-05", + "2024-02-06", + "2024-02-07", + "2024-02-08", + "2024-02-09", + "2024-02-10", + "2024-02-11", + "2024-02-12", + "2024-02-13", + "2024-02-14", + "2024-02-15", + "2024-02-16", + "2024-02-17", + "2024-02-18", + "2024-02-19", + "2024-02-20", + "2024-02-21", + "2024-02-22", + "2024-02-23", + "2024-02-24", + "2024-02-25", + "2024-02-26", + "2024-02-27", + "2024-02-28", + "2024-02-29", + "2024-03-01", + "2024-03-02", + "2024-03-03", + "2024-03-04", + "2024-03-05", + "2024-03-06", + "2024-03-07", + "2024-03-08", + "2024-03-09", + "2024-03-10", + "2024-03-11", + "2024-03-12", + "2024-03-13", + "2024-03-14", + "2024-03-15", + "2024-03-16", + "2024-03-17", + "2024-03-18", + "2024-03-19", + "2024-03-20", + "2024-03-21", + "2024-03-22", + "2024-03-23", + "2024-03-24", + "2024-03-25", + "2024-03-26", + "2024-03-27", + "2024-03-28", + "2024-03-29", + "2024-03-30", + "2024-03-31", + "2024-04-01", + "2024-04-02", + "2024-04-03", + "2024-04-04", + "2024-04-05", + "2024-04-06", + "2024-04-07", + "2024-04-08", + "2024-04-09", + "2024-04-10", + "2024-04-11", + "2024-04-12", + "2024-04-13", + "2024-04-14", + "2024-04-15", + "2024-04-16", + "2024-04-17", + "2024-04-18", + "2024-04-19", + "2024-04-20", + "2024-04-21", + "2024-04-22", + "2024-04-23", + "2024-04-24", + "2024-04-25", + "2024-04-26", + "2024-04-27", + "2024-04-28", + "2024-04-29", + "2024-04-30", + "2024-05-01", + "2024-05-02", + "2024-05-03", + "2024-05-04", + "2024-05-05", + "2024-05-06", + "2024-05-07", + "2024-05-08", + "2024-05-09", + "2024-05-10", + "2024-05-11", + "2024-05-12", + "2024-05-13", + "2024-05-14", + "2024-05-15", + "2024-05-16", + "2024-05-17", + "2024-05-18", + "2024-05-19", + "2024-05-20", + "2024-05-21", + "2024-05-22", + "2024-05-23", + "2024-05-24", + "2024-05-25", + "2024-05-26", + "2024-05-27", + "2024-05-28", + "2024-05-29", + "2024-05-30", + "2024-05-31", + "2024-06-01", + "2024-06-02", + "2024-06-03", + "2024-06-04", + "2024-06-05", + "2024-06-06", + "2024-06-07", + "2024-06-08", + "2024-06-09", + "2024-06-10", + "2024-06-11", + "2024-06-12", + "2024-06-13", + "2024-06-14", + "2024-06-15", + "2024-06-16", + "2024-06-17", + "2024-06-18", + "2024-06-19", + "2024-06-20", + "2024-06-21", + "2024-06-22", + "2024-06-23", + "2024-06-24", + "2024-06-25", + "2024-06-26", + "2024-06-27", + "2024-06-28", + "2024-06-29", + "2024-06-30", + "2024-07-01", + "2024-07-02", + "2024-07-03", + "2024-07-04", + "2024-07-05", + "2024-07-06", + "2024-07-07", + "2024-07-08", + "2024-07-09", + "2024-07-10", + "2024-07-11", + "2024-07-12", + "2024-07-13", + "2024-07-14", + "2024-07-15", + "2024-07-16", + "2024-07-17", + "2024-07-18", + "2024-07-19", + "2024-07-20", + "2024-07-21", + "2024-07-22", + "2024-07-23", + "2024-07-24", + "2024-07-25", + "2024-07-26", + "2024-07-27", + "2024-07-28", + "2024-07-29", + "2024-07-30", + "2024-07-31", + "2024-08-01", + "2024-08-02", + "2024-08-03", + "2024-08-04", + "2024-08-05", + "2024-08-06", + "2024-08-07", + "2024-08-08", + "2024-08-09", + "2024-08-10", + "2024-08-11", + "2024-08-12", + "2024-08-13", + "2024-08-14", + "2024-08-15", + "2024-08-16", + "2024-08-17", + "2024-08-18", + "2024-08-19", + "2024-08-20", + "2024-08-21", + "2024-08-22", + "2024-08-23", + "2024-08-24", + "2024-08-25", + "2024-08-26", + "2024-08-27", + "2024-08-28", + "2024-08-29", + "2024-08-30", + "2024-08-31", + "2024-09-01", + "2024-09-02", + "2024-09-03", + "2024-09-04", + "2024-09-05", + "2024-09-06", + "2024-09-07", + "2024-09-08", + "2024-09-09", + "2024-09-10", + "2024-09-11", + "2024-09-12", + "2024-09-13", + "2024-09-14", + "2024-09-15", + "2024-09-16", + "2024-09-17", + "2024-09-18", + "2024-09-19", + "2024-09-20", + "2024-09-21", + "2024-09-22", + "2024-09-23", + "2024-09-24", + "2024-09-25", + "2024-09-26", + "2024-09-27", + "2024-09-28", + "2024-09-29", + "2024-09-30", + "2024-10-01", + "2024-10-02", + "2024-10-03", + "2024-10-04", + "2024-10-05", + "2024-10-06", + "2024-10-07", + "2024-10-08", + "2024-10-09", + "2024-10-10", + "2024-10-11", + "2024-10-12", + "2024-10-13", + "2024-10-14", + "2024-10-15", + "2024-10-16", + "2024-10-17", + "2024-10-18", + "2024-10-19", + "2024-10-20", + "2024-10-21", + "2024-10-22", + "2024-10-23", + "2024-10-24", + "2024-10-25", + "2024-10-26", + "2024-10-27", + "2024-10-28", + "2024-10-29", + "2024-10-30", + "2024-10-31", + "2024-11-01", + "2024-11-02", + "2024-11-03", + "2024-11-04", + "2024-11-05", + "2024-11-06", + "2024-11-07", + "2024-11-08", + "2024-11-09", + "2024-11-10", + "2024-11-11", + "2024-11-12", + "2024-11-13", + "2024-11-14", + "2024-11-15", + "2024-11-16", + "2024-11-17", + "2024-11-18", + "2024-11-19", + "2024-11-20", + "2024-11-21", + "2024-11-22", + "2024-11-23", + "2024-11-24", + "2024-11-25", + "2024-11-26", + "2024-11-27", + "2024-11-28", + "2024-11-29", + "2024-11-30", + "2024-12-01", + "2024-12-02", + "2024-12-03", + "2024-12-04", + "2024-12-05", + "2024-12-06", + "2024-12-07", + "2024-12-08", + "2024-12-09", + "2024-12-10", + "2024-12-11", + "2024-12-12", + "2024-12-13", + "2024-12-14", + "2024-12-15", + "2024-12-16", + "2024-12-17", + "2024-12-18", + "2024-12-19", + "2024-12-20", + "2024-12-21", + "2024-12-22", + "2024-12-23", + "2024-12-24", + "2024-12-25", + "2024-12-26", + "2024-12-27", + "2024-12-28", + "2024-12-29", + "2024-12-30", + "2024-12-31" +] + +access(all) let btc_daily_2024_bull_agents: [SimAgent] = [ + SimAgent( + count: 1, + debtPerAgent: 133333.00000000, + totalSystemDebt: 20000000.00000000 + ) +] + +access(all) let btc_daily_2024_bull_pools: {String: SimPool} = { + "moet_yt": SimPool( + size: 500000.00000000, + concentration: 0.95000000, + feeTier: 0.00050000 + ), + "moet_btc": SimPool( + size: 5000000.00000000, + concentration: 0.80000000, + feeTier: 0.00300000 + ), + "pyusd_btc": SimPool( + size: 10000000.00000000, + concentration: 0.80000000, + feeTier: 0.00300000 + ), + "moet_fusdev": SimPool( + size: 500000.00000000, + concentration: 0.95000000, + feeTier: 0.00010000 + ) +} + +access(all) let btc_daily_2024_bull_constants: SimConstants = SimConstants( + btcCollateralFactor: 0.80000000, + btcLiquidationThreshold: 0.85000000, + yieldAPR: 0.10000000, + directMintYT: true +) + +access(all) let btc_daily_2024_bull_expectedLiquidationCount: Int = 0 +access(all) let btc_daily_2024_bull_expectedAllAgentsSurvive: Bool = true + +access(all) let btc_daily_2024_bull_durationDays: Int = 366 +access(all) let btc_daily_2024_bull_notes: String = "Daily BTC/USD close prices from CoinMarketCap, 2024-01-01 to 2024-12-31. 366 data points." + +// ---- btc_daily_2025 ---- + +access(all) let btc_daily_2025_prices: [UFix64] = [ + 94419.76000000, + 96886.88000000, + 98107.43000000, + 98236.23000000, + 98314.96000000, + 102078.09000000, + 96922.71000000, + 95043.52000000, + 92484.04000000, + 94701.46000000, + 94566.59000000, + 94488.44000000, + 94516.53000000, + 96534.04000000, + 100504.49000000, + 99756.91000000, + 104462.04000000, + 104408.07000000, + 101089.61000000, + 102016.66000000, + 106146.26000000, + 103653.07000000, + 103960.17000000, + 104819.48000000, + 104714.65000000, + 102682.50000000, + 102087.69000000, + 101332.48000000, + 103703.21000000, + 104735.30000000, + 102405.03000000, + 100655.91000000, + 97688.98000000, + 101405.42000000, + 97871.82000000, + 96615.44000000, + 96593.30000000, + 96529.08000000, + 96482.45000000, + 96500.09000000, + 97437.56000000, + 95747.43000000, + 97885.86000000, + 96623.87000000, + 97508.97000000, + 97580.35000000, + 96175.03000000, + 95773.38000000, + 95539.54000000, + 96635.61000000, + 98333.94000000, + 96125.54000000, + 96577.76000000, + 96273.92000000, + 91418.17000000, + 88736.17000000, + 84347.02000000, + 84704.22000000, + 84373.01000000, + 86031.91000000, + 94248.35000000, + 86065.67000000, + 87222.19000000, + 90623.56000000, + 89961.73000000, + 86742.68000000, + 86154.59000000, + 80601.04000000, + 78532.00000000, + 82862.21000000, + 83722.36000000, + 81066.70000000, + 83969.10000000, + 84343.11000000, + 82579.69000000, + 84075.69000000, + 82718.50000000, + 86854.23000000, + 84167.19000000, + 84043.25000000, + 83832.49000000, + 86054.37000000, + 87498.91000000, + 87471.70000000, + 86900.89000000, + 87177.10000000, + 84353.15000000, + 82597.58000000, + 82334.52000000, + 82548.91000000, + 85169.17000000, + 82485.71000000, + 83102.83000000, + 83843.80000000, + 83504.80000000, + 78214.48000000, + 79235.33000000, + 76271.95000000, + 82573.95000000, + 79626.14000000, + 83404.84000000, + 85287.11000000, + 83684.98000000, + 84542.39000000, + 83668.99000000, + 84033.87000000, + 84895.75000000, + 84450.81000000, + 85063.41000000, + 85174.30000000, + 87518.91000000, + 93441.89000000, + 93699.11000000, + 93943.79000000, + 94720.50000000, + 94646.93000000, + 93754.85000000, + 94978.75000000, + 94284.79000000, + 94207.31000000, + 96492.34000000, + 96910.07000000, + 95891.80000000, + 94315.97000000, + 94748.05000000, + 96802.48000000, + 97032.32000000, + 103241.46000000, + 102970.85000000, + 104696.33000000, + 104106.36000000, + 102812.95000000, + 104169.81000000, + 103539.42000000, + 103744.64000000, + 103489.29000000, + 103191.09000000, + 106446.01000000, + 105606.18000000, + 106791.09000000, + 109678.08000000, + 111673.28000000, + 107287.80000000, + 107791.16000000, + 109035.39000000, + 109440.37000000, + 108994.64000000, + 107802.32000000, + 105641.76000000, + 103998.57000000, + 104638.09000000, + 105652.10000000, + 105881.53000000, + 105432.47000000, + 104731.98000000, + 101575.95000000, + 104390.35000000, + 105615.63000000, + 105793.65000000, + 110294.10000000, + 110257.24000000, + 108686.63000000, + 105929.05000000, + 106090.97000000, + 105472.41000000, + 105552.03000000, + 106796.76000000, + 104601.12000000, + 104883.33000000, + 104684.29000000, + 103309.60000000, + 102257.41000000, + 100987.14000000, + 105577.77000000, + 106045.63000000, + 107361.26000000, + 106960.00000000, + 107088.43000000, + 107327.70000000, + 108385.57000000, + 107135.33000000, + 105698.28000000, + 108859.32000000, + 109647.98000000, + 108034.34000000, + 108231.18000000, + 109232.07000000, + 108299.85000000, + 108950.28000000, + 111326.55000000, + 115987.21000000, + 117516.99000000, + 117435.23000000, + 119116.12000000, + 119849.71000000, + 117777.19000000, + 118738.51000000, + 119289.84000000, + 118003.22000000, + 117939.98000000, + 117300.79000000, + 117439.54000000, + 119995.42000000, + 118754.96000000, + 118368.00000000, + 117635.88000000, + 117947.37000000, + 119448.49000000, + 117924.47000000, + 117922.15000000, + 117831.19000000, + 115758.20000000, + 113320.09000000, + 112526.91000000, + 114217.67000000, + 115071.88000000, + 114141.44000000, + 115028.00000000, + 117496.90000000, + 116688.73000000, + 116500.36000000, + 119306.76000000, + 118731.45000000, + 120172.91000000, + 123344.06000000, + 118359.58000000, + 117398.35000000, + 117491.35000000, + 117453.06000000, + 116252.31000000, + 112831.18000000, + 114274.74000000, + 112419.03000000, + 116874.09000000, + 115374.33000000, + 113458.43000000, + 110124.35000000, + 111802.66000000, + 111222.06000000, + 112544.80000000, + 108410.84000000, + 108808.07000000, + 108236.71000000, + 109250.59000000, + 111200.59000000, + 111723.21000000, + 110723.60000000, + 110650.99000000, + 110224.70000000, + 111167.62000000, + 112071.43000000, + 111530.55000000, + 113955.36000000, + 115507.54000000, + 116101.58000000, + 115950.51000000, + 115407.65000000, + 115444.87000000, + 116843.18000000, + 116468.51000000, + 117137.20000000, + 115688.86000000, + 115721.96000000, + 115306.10000000, + 112748.51000000, + 112014.50000000, + 113328.63000000, + 109049.29000000, + 109712.83000000, + 109681.94000000, + 112122.64000000, + 114400.39000000, + 114056.08000000, + 118648.93000000, + 120681.26000000, + 122266.53000000, + 122425.43000000, + 123513.47000000, + 124752.53000000, + 121451.38000000, + 123354.87000000, + 121705.58000000, + 113214.37000000, + 110807.88000000, + 115169.76000000, + 115271.08000000, + 113118.67000000, + 110783.17000000, + 108186.04000000, + 106467.79000000, + 107198.27000000, + 108666.71000000, + 110588.93000000, + 108476.89000000, + 107688.59000000, + 110069.72000000, + 111033.92000000, + 111641.73000000, + 114472.44000000, + 114119.32000000, + 112956.17000000, + 110055.30000000, + 108305.55000000, + 109556.16000000, + 110064.02000000, + 110639.63000000, + 106547.52000000, + 101590.52000000, + 103891.84000000, + 101301.29000000, + 103372.41000000, + 102282.11000000, + 104719.64000000, + 105996.60000000, + 102997.47000000, + 101663.19000000, + 99697.49000000, + 94397.79000000, + 95549.15000000, + 94177.07000000, + 92093.87000000, + 92948.87000000, + 91465.99000000, + 86631.90000000, + 85090.69000000, + 84648.36000000, + 86805.01000000, + 88270.56000000, + 87341.89000000, + 90518.37000000, + 91285.37000000, + 90919.27000000, + 90851.75000000, + 90394.31000000, + 86321.57000000, + 91350.21000000, + 93527.80000000, + 92141.62000000, + 89387.75000000, + 89272.37000000, + 90405.64000000, + 90640.21000000, + 92691.71000000, + 92020.95000000, + 92511.34000000, + 90270.41000000, + 90298.71000000, + 88175.18000000, + 86419.78000000, + 87843.99000000, + 86143.76000000, + 85462.51000000, + 88103.38000000, + 88344.00000000, + 88621.75000000, + 88490.02000000, + 87414.00000000, + 87611.96000000, + 87234.74000000, + 87301.43000000, + 87802.16000000, + 87835.83000000, + 87138.14000000, + 88430.14000000, + 87508.83000000 +] + +access(all) let btc_daily_2025_dates: [String] = [ + "2025-01-01", + "2025-01-02", + "2025-01-03", + "2025-01-04", + "2025-01-05", + "2025-01-06", + "2025-01-07", + "2025-01-08", + "2025-01-09", + "2025-01-10", + "2025-01-11", + "2025-01-12", + "2025-01-13", + "2025-01-14", + "2025-01-15", + "2025-01-16", + "2025-01-17", + "2025-01-18", + "2025-01-19", + "2025-01-20", + "2025-01-21", + "2025-01-22", + "2025-01-23", + "2025-01-24", + "2025-01-25", + "2025-01-26", + "2025-01-27", + "2025-01-28", + "2025-01-29", + "2025-01-30", + "2025-01-31", + "2025-02-01", + "2025-02-02", + "2025-02-03", + "2025-02-04", + "2025-02-05", + "2025-02-06", + "2025-02-07", + "2025-02-08", + "2025-02-09", + "2025-02-10", + "2025-02-11", + "2025-02-12", + "2025-02-13", + "2025-02-14", + "2025-02-15", + "2025-02-16", + "2025-02-17", + "2025-02-18", + "2025-02-19", + "2025-02-20", + "2025-02-21", + "2025-02-22", + "2025-02-23", + "2025-02-24", + "2025-02-25", + "2025-02-26", + "2025-02-27", + "2025-02-28", + "2025-03-01", + "2025-03-02", + "2025-03-03", + "2025-03-04", + "2025-03-05", + "2025-03-06", + "2025-03-07", + "2025-03-08", + "2025-03-09", + "2025-03-10", + "2025-03-11", + "2025-03-12", + "2025-03-13", + "2025-03-14", + "2025-03-15", + "2025-03-16", + "2025-03-17", + "2025-03-18", + "2025-03-19", + "2025-03-20", + "2025-03-21", + "2025-03-22", + "2025-03-23", + "2025-03-24", + "2025-03-25", + "2025-03-26", + "2025-03-27", + "2025-03-28", + "2025-03-29", + "2025-03-30", + "2025-03-31", + "2025-04-01", + "2025-04-02", + "2025-04-03", + "2025-04-04", + "2025-04-05", + "2025-04-06", + "2025-04-07", + "2025-04-08", + "2025-04-09", + "2025-04-10", + "2025-04-11", + "2025-04-12", + "2025-04-13", + "2025-04-14", + "2025-04-15", + "2025-04-16", + "2025-04-17", + "2025-04-18", + "2025-04-19", + "2025-04-20", + "2025-04-21", + "2025-04-22", + "2025-04-23", + "2025-04-24", + "2025-04-25", + "2025-04-26", + "2025-04-27", + "2025-04-28", + "2025-04-29", + "2025-04-30", + "2025-05-01", + "2025-05-02", + "2025-05-03", + "2025-05-04", + "2025-05-05", + "2025-05-06", + "2025-05-07", + "2025-05-08", + "2025-05-09", + "2025-05-10", + "2025-05-11", + "2025-05-12", + "2025-05-13", + "2025-05-14", + "2025-05-15", + "2025-05-16", + "2025-05-17", + "2025-05-18", + "2025-05-19", + "2025-05-20", + "2025-05-21", + "2025-05-22", + "2025-05-23", + "2025-05-24", + "2025-05-25", + "2025-05-26", + "2025-05-27", + "2025-05-28", + "2025-05-29", + "2025-05-30", + "2025-05-31", + "2025-06-01", + "2025-06-02", + "2025-06-03", + "2025-06-04", + "2025-06-05", + "2025-06-06", + "2025-06-07", + "2025-06-08", + "2025-06-09", + "2025-06-10", + "2025-06-11", + "2025-06-12", + "2025-06-13", + "2025-06-14", + "2025-06-15", + "2025-06-16", + "2025-06-17", + "2025-06-18", + "2025-06-19", + "2025-06-20", + "2025-06-21", + "2025-06-22", + "2025-06-23", + "2025-06-24", + "2025-06-25", + "2025-06-26", + "2025-06-27", + "2025-06-28", + "2025-06-29", + "2025-06-30", + "2025-07-01", + "2025-07-02", + "2025-07-03", + "2025-07-04", + "2025-07-05", + "2025-07-06", + "2025-07-07", + "2025-07-08", + "2025-07-09", + "2025-07-10", + "2025-07-11", + "2025-07-12", + "2025-07-13", + "2025-07-14", + "2025-07-15", + "2025-07-16", + "2025-07-17", + "2025-07-18", + "2025-07-19", + "2025-07-20", + "2025-07-21", + "2025-07-22", + "2025-07-23", + "2025-07-24", + "2025-07-25", + "2025-07-26", + "2025-07-27", + "2025-07-28", + "2025-07-29", + "2025-07-30", + "2025-07-31", + "2025-08-01", + "2025-08-02", + "2025-08-03", + "2025-08-04", + "2025-08-05", + "2025-08-06", + "2025-08-07", + "2025-08-08", + "2025-08-09", + "2025-08-10", + "2025-08-11", + "2025-08-12", + "2025-08-13", + "2025-08-14", + "2025-08-15", + "2025-08-16", + "2025-08-17", + "2025-08-18", + "2025-08-19", + "2025-08-20", + "2025-08-21", + "2025-08-22", + "2025-08-23", + "2025-08-24", + "2025-08-25", + "2025-08-26", + "2025-08-27", + "2025-08-28", + "2025-08-29", + "2025-08-30", + "2025-08-31", + "2025-09-01", + "2025-09-02", + "2025-09-03", + "2025-09-04", + "2025-09-05", + "2025-09-06", + "2025-09-07", + "2025-09-08", + "2025-09-09", + "2025-09-10", + "2025-09-11", + "2025-09-12", + "2025-09-13", + "2025-09-14", + "2025-09-15", + "2025-09-16", + "2025-09-17", + "2025-09-18", + "2025-09-19", + "2025-09-20", + "2025-09-21", + "2025-09-22", + "2025-09-23", + "2025-09-24", + "2025-09-25", + "2025-09-26", + "2025-09-27", + "2025-09-28", + "2025-09-29", + "2025-09-30", + "2025-10-01", + "2025-10-02", + "2025-10-03", + "2025-10-04", + "2025-10-05", + "2025-10-06", + "2025-10-07", + "2025-10-08", + "2025-10-09", + "2025-10-10", + "2025-10-11", + "2025-10-12", + "2025-10-13", + "2025-10-14", + "2025-10-15", + "2025-10-16", + "2025-10-17", + "2025-10-18", + "2025-10-19", + "2025-10-20", + "2025-10-21", + "2025-10-22", + "2025-10-23", + "2025-10-24", + "2025-10-25", + "2025-10-26", + "2025-10-27", + "2025-10-28", + "2025-10-29", + "2025-10-30", + "2025-10-31", + "2025-11-01", + "2025-11-02", + "2025-11-03", + "2025-11-04", + "2025-11-05", + "2025-11-06", + "2025-11-07", + "2025-11-08", + "2025-11-09", + "2025-11-10", + "2025-11-11", + "2025-11-12", + "2025-11-13", + "2025-11-14", + "2025-11-15", + "2025-11-16", + "2025-11-17", + "2025-11-18", + "2025-11-19", + "2025-11-20", + "2025-11-21", + "2025-11-22", + "2025-11-23", + "2025-11-24", + "2025-11-25", + "2025-11-26", + "2025-11-27", + "2025-11-28", + "2025-11-29", + "2025-11-30", + "2025-12-01", + "2025-12-02", + "2025-12-03", + "2025-12-04", + "2025-12-05", + "2025-12-06", + "2025-12-07", + "2025-12-08", + "2025-12-09", + "2025-12-10", + "2025-12-11", + "2025-12-12", + "2025-12-13", + "2025-12-14", + "2025-12-15", + "2025-12-16", + "2025-12-17", + "2025-12-18", + "2025-12-19", + "2025-12-20", + "2025-12-21", + "2025-12-22", + "2025-12-23", + "2025-12-24", + "2025-12-25", + "2025-12-26", + "2025-12-27", + "2025-12-28", + "2025-12-29", + "2025-12-30", + "2025-12-31" +] + +access(all) let btc_daily_2025_agents: [SimAgent] = [ + SimAgent( + count: 1, + debtPerAgent: 133333.00000000, + totalSystemDebt: 20000000.00000000 + ) +] + +access(all) let btc_daily_2025_pools: {String: SimPool} = { + "moet_yt": SimPool( + size: 500000.00000000, + concentration: 0.95000000, + feeTier: 0.00050000 + ), + "moet_btc": SimPool( + size: 5000000.00000000, + concentration: 0.80000000, + feeTier: 0.00300000 + ), + "pyusd_btc": SimPool( + size: 10000000.00000000, + concentration: 0.80000000, + feeTier: 0.00300000 + ), + "moet_fusdev": SimPool( + size: 500000.00000000, + concentration: 0.95000000, + feeTier: 0.00010000 + ) +} + +access(all) let btc_daily_2025_constants: SimConstants = SimConstants( + btcCollateralFactor: 0.80000000, + btcLiquidationThreshold: 0.85000000, + yieldAPR: 0.10000000, + directMintYT: true +) + +access(all) let btc_daily_2025_expectedLiquidationCount: Int = 0 +access(all) let btc_daily_2025_expectedAllAgentsSurvive: Bool = true + +access(all) let btc_daily_2025_durationDays: Int = 365 +access(all) let btc_daily_2025_notes: String = "Daily BTC/USD close prices from CoinMarketCap, 2025-01-01 to 2025-12-31. 365 data points." diff --git a/cadence/tests/test_helpers.cdc b/cadence/tests/test_helpers.cdc index 462f7b1e..141eb232 100644 --- a/cadence/tests/test_helpers.cdc +++ b/cadence/tests/test_helpers.cdc @@ -699,6 +699,34 @@ fun rebalancePosition(signer: Test.TestAccount, pid: UInt64, force: Bool, beFail Test.expect(rebalanceRes, beFailed ? Test.beFailed() : Test.beSucceeded()) } +access(all) +fun manualLiquidation( + signer: Test.TestAccount, + pid: UInt64, + debtVaultIdentifier: String, + seizeVaultIdentifier: String, + seizeAmount: UFix64, + repayAmount: UFix64, + beFailed: Bool +) { + let res = _executeTransaction( + "../../lib/FlowALP/cadence/transactions/flow-alp/pool-management/manual_liquidation.cdc", + [pid, debtVaultIdentifier, seizeVaultIdentifier, seizeAmount, repayAmount], + signer + ) + Test.expect(res, beFailed ? Test.beFailed() : Test.beSucceeded()) +} + +access(all) +fun setPositionHealthParams(signer: Test.TestAccount, pid: UInt64, targetHealth: UFix64, minHealth: UFix64, maxHealth: UFix64) { + let res = _executeTransaction( + "transactions/set_position_health_params.cdc", + [ pid, targetHealth, minHealth, maxHealth ], + signer + ) + Test.expect(res, Test.beSucceeded()) +} + access(all) fun setupMoetVault(_ signer: Test.TestAccount, beFailed: Bool) { let setupRes = _executeTransaction("../../lib/FlowALP/cadence/transactions/moet/setup_vault.cdc", [], signer) diff --git a/cadence/tests/transactions/set_position_health_params.cdc b/cadence/tests/transactions/set_position_health_params.cdc new file mode 100644 index 00000000..61ec4299 --- /dev/null +++ b/cadence/tests/transactions/set_position_health_params.cdc @@ -0,0 +1,31 @@ +import "FlowALPv0" + +/// Sets target, min, and max health params on a Pool's InternalPosition directly. +/// Must be signed by the Pool owner (flowALPAccount). +transaction(pid: UInt64, targetHealth: UFix64, minHealth: UFix64, maxHealth: UFix64) { + let pool: auth(FlowALPv0.EPosition) &FlowALPv0.Pool + + prepare(signer: auth(BorrowValue) &Account) { + self.pool = signer.storage.borrow(from: FlowALPv0.PoolStoragePath) + ?? panic("Could not borrow reference to Pool from storage") + } + + execute { + let pos = self.pool.borrowPosition(pid: pid) + let newTarget = UFix128(targetHealth) + let newMin = UFix128(minHealth) + let newMax = UFix128(maxHealth) + + // these calls enforce the constraints minHealth < targetHealth < maxHealth + // so we keep the widest constraints first, then tighten later + if newMax > pos.maxHealth { + pos.setMaxHealth(newMax) + } + if newMin < pos.minHealth { + pos.setMinHealth(newMin) + } + pos.setTargetHealth(newTarget) + pos.setMaxHealth(newMax) + pos.setMinHealth(newMin) + } +}