From 424acb285bb94f02a000e6f4ede3d038dfcedfb6 Mon Sep 17 00:00:00 2001 From: Dominic Romanowski Date: Wed, 15 Nov 2023 15:41:48 +1100 Subject: [PATCH 01/14] format liquidation tests --- src/feeds/LyraSpotDiffFeed.sol | 1 + .../liquidation/liquidationTests.json | 1428 +++++++++++++---- 2 files changed, 1093 insertions(+), 336 deletions(-) diff --git a/src/feeds/LyraSpotDiffFeed.sol b/src/feeds/LyraSpotDiffFeed.sol index af7391b5..4d44a425 100644 --- a/src/feeds/LyraSpotDiffFeed.sol +++ b/src/feeds/LyraSpotDiffFeed.sol @@ -2,6 +2,7 @@ pragma solidity ^0.8.18; // libraries +import "openzeppelin/utils/math/SignedMath.sol"; import "openzeppelin/utils/math/Math.sol"; import "openzeppelin/utils/math/SafeCast.sol"; import "lyra-utils/decimals/SignedDecimalMath.sol"; diff --git a/test/integration-tests/liquidation/liquidationTests.json b/test/integration-tests/liquidation/liquidationTests.json index 3e1551bd..8e8d95ec 100644 --- a/test/integration-tests/liquidation/liquidationTests.json +++ b/test/integration-tests/liquidation/liquidationTests.json @@ -3,13 +3,31 @@ "StartTime": 0, "IsForce": false, "InitialPortfolio": { - "OptionExpiries": [500400], - "OptionStrikes": [1500000000000000000000], - "OptionIsCall": [1], - "OptionAmounts": [-1000000000000000000], - "OptionVols": [1047884494084986240], - "SVIparams": [1, 1.5, -0.1, -0.05, 0.05], - "OptionVolConfidences": [1000000000000000000], + "OptionExpiries": [ + 500400 + ], + "OptionStrikes": [ + 1500000000000000000000 + ], + "OptionIsCall": [ + 1 + ], + "OptionAmounts": [ + -1000000000000000000 + ], + "OptionVols": [ + 1047884494084986240 + ], + "SVIparams": [ + 1, + 1.5, + -0.1, + -0.05, + 0.05 + ], + "OptionVolConfidences": [ + 1000000000000000000 + ], "Cash": 200000000000000000000, "Perps": 0, "Base": 0, @@ -17,21 +35,39 @@ "SpotConfidence": 1000000000000000000, "PerpPrice": 1505000000000000000000, "PerpConfidence": 1000000000000000000, - "FeedExpiries": [500400], - "Forwards": [1500833279310993817600], - "ForwardConfidences": [1000000000000000000], - "Rates": [0], - "RateConfidences": [1000000000000000000], + "FeedExpiries": [ + 500400 + ], + "Forwards": [ + 1500833279310993817600 + ], + "ForwardConfidences": [ + 1000000000000000000 + ], + "Rates": [ + 0 + ], + "RateConfidences": [ + 1000000000000000000 + ], "StableConfidence": 0, "StablePrice": 1000000000000000000, "UnrealisedPerpPNL": 0, "UnrealisedFunding": 0, - "VolShockUp": [1.7370684514926746], - "VolShockDown": [0.508621032338217], + "VolShockUp": [ + 1.7370684514926746 + ], + "VolShockDown": [ + 0.508621032338217 + ], "SettlementPrice": 1500833279310993817600, "PercentFixed": 0, - "ForwardsFixed": [0], - "ForwardsVariable": [1500833279310993817600] + "ForwardsFixed": [ + 0 + ], + "ForwardsVariable": [ + 1500833279310993817600 + ] }, "ActionCount": 1, "LiquidationFee": 1.322084630165343, @@ -39,13 +75,31 @@ { "Time": 0, "PortfolioAndFeeds": { - "OptionExpiries": [500400], - "OptionStrikes": [1500000000000000000000], - "OptionIsCall": [1], - "OptionAmounts": [-1000000000000000000], - "OptionVols": [1047884494084986240], - "SVIparams": [1, 1.5, -0.1, -0.05, 0.05], - "OptionVolConfidences": [1000000000000000000], + "OptionExpiries": [ + 500400 + ], + "OptionStrikes": [ + 1500000000000000000000 + ], + "OptionIsCall": [ + 1 + ], + "OptionAmounts": [ + -1000000000000000000 + ], + "OptionVols": [ + 1047884494084986240 + ], + "SVIparams": [ + 1, + 1.5, + -0.1, + -0.05, + 0.05 + ], + "OptionVolConfidences": [ + 1000000000000000000 + ], "Cash": 198677915369834676224, "Perps": 0, "Base": 0, @@ -53,21 +107,39 @@ "SpotConfidence": 1000000000000000000, "PerpPrice": 0, "PerpConfidence": 1000000000000000000, - "FeedExpiries": [500400], - "Forwards": [1500833279310993817600], - "ForwardConfidences": [1000000000000000000], - "Rates": [40000000000000000], - "RateConfidences": [1000000000000000000], + "FeedExpiries": [ + 500400 + ], + "Forwards": [ + 1500833279310993817600 + ], + "ForwardConfidences": [ + 1000000000000000000 + ], + "Rates": [ + 40000000000000000 + ], + "RateConfidences": [ + 1000000000000000000 + ], "StableConfidence": 0, "StablePrice": 1000000000000000000, "UnrealisedPerpPNL": 0, "UnrealisedFunding": 0, - "VolShockUp": [1.7370684514926746], - "VolShockDown": [0.508621032338217], + "VolShockUp": [ + 1.7370684514926746 + ], + "VolShockDown": [ + 0.508621032338217 + ], "SettlementPrice": 1500833279310993817600, "PercentFixed": 0, - "ForwardsFixed": [0], - "ForwardsVariable": [1500833279310993817600] + "ForwardsFixed": [ + 0 + ], + "ForwardsVariable": [ + 1500833279310993817600 + ] }, "Liquidator": { "PercentWant": 1000000000000000000 @@ -94,13 +166,31 @@ "StartTime": 0, "IsForce": false, "InitialPortfolio": { - "OptionExpiries": [500400], - "OptionStrikes": [1500000000000000000000], - "OptionIsCall": [1], - "OptionAmounts": [-1000000000000000000], - "OptionVols": [1047884494084986240], - "SVIparams": [1, 1.5, -0.1, -0.05, 0.05], - "OptionVolConfidences": [1000000000000000000], + "OptionExpiries": [ + 500400 + ], + "OptionStrikes": [ + 1500000000000000000000 + ], + "OptionIsCall": [ + 1 + ], + "OptionAmounts": [ + -1000000000000000000 + ], + "OptionVols": [ + 1047884494084986240 + ], + "SVIparams": [ + 1, + 1.5, + -0.1, + -0.05, + 0.05 + ], + "OptionVolConfidences": [ + 1000000000000000000 + ], "Cash": 200000000000000000000, "Perps": 0, "Base": 0, @@ -108,21 +198,39 @@ "SpotConfidence": 1000000000000000000, "PerpPrice": 1505000000000000000000, "PerpConfidence": 1000000000000000000, - "FeedExpiries": [500400], - "Forwards": [1500833279310993817600], - "ForwardConfidences": [1000000000000000000], - "Rates": [0], - "RateConfidences": [1000000000000000000], + "FeedExpiries": [ + 500400 + ], + "Forwards": [ + 1500833279310993817600 + ], + "ForwardConfidences": [ + 1000000000000000000 + ], + "Rates": [ + 0 + ], + "RateConfidences": [ + 1000000000000000000 + ], "StableConfidence": 0, "StablePrice": 1000000000000000000, "UnrealisedPerpPNL": 0, "UnrealisedFunding": 0, - "VolShockUp": [1.7370684514926746], - "VolShockDown": [0.508621032338217], + "VolShockUp": [ + 1.7370684514926746 + ], + "VolShockDown": [ + 0.508621032338217 + ], "SettlementPrice": 1500833279310993817600, "PercentFixed": 0, - "ForwardsFixed": [0], - "ForwardsVariable": [1500833279310993817600] + "ForwardsFixed": [ + 0 + ], + "ForwardsVariable": [ + 1500833279310993817600 + ] }, "ActionCount": 1, "LiquidationFee": 1.322084630165343, @@ -130,13 +238,31 @@ { "Time": 0, "PortfolioAndFeeds": { - "OptionExpiries": [500400], - "OptionStrikes": [1500000000000000000000], - "OptionIsCall": [1], - "OptionAmounts": [-1000000000000000000], - "OptionVols": [1047884494084986240], - "SVIparams": [1, 1.5, -0.1, -0.05, 0.05], - "OptionVolConfidences": [1000000000000000000], + "OptionExpiries": [ + 500400 + ], + "OptionStrikes": [ + 1500000000000000000000 + ], + "OptionIsCall": [ + 1 + ], + "OptionAmounts": [ + -1000000000000000000 + ], + "OptionVols": [ + 1047884494084986240 + ], + "SVIparams": [ + 1, + 1.5, + -0.1, + -0.05, + 0.05 + ], + "OptionVolConfidences": [ + 1000000000000000000 + ], "Cash": 198677915369834676224, "Perps": 0, "Base": 0, @@ -144,21 +270,39 @@ "SpotConfidence": 1000000000000000000, "PerpPrice": 0, "PerpConfidence": 1000000000000000000, - "FeedExpiries": [500400], - "Forwards": [1500833279310993817600], - "ForwardConfidences": [1000000000000000000], - "Rates": [40000000000000000], - "RateConfidences": [1000000000000000000], + "FeedExpiries": [ + 500400 + ], + "Forwards": [ + 1500833279310993817600 + ], + "ForwardConfidences": [ + 1000000000000000000 + ], + "Rates": [ + 40000000000000000 + ], + "RateConfidences": [ + 1000000000000000000 + ], "StableConfidence": 0, "StablePrice": 1000000000000000000, "UnrealisedPerpPNL": 0, "UnrealisedFunding": 0, - "VolShockUp": [1.7370684514926746], - "VolShockDown": [0.508621032338217], + "VolShockUp": [ + 1.7370684514926746 + ], + "VolShockDown": [ + 0.508621032338217 + ], "SettlementPrice": 1500833279310993817600, "PercentFixed": 0, - "ForwardsFixed": [0], - "ForwardsVariable": [1500833279310993817600] + "ForwardsFixed": [ + 0 + ], + "ForwardsVariable": [ + 1500833279310993817600 + ] }, "Liquidator": { "PercentWant": 50000000000000000 @@ -185,13 +329,31 @@ "StartTime": 0, "IsForce": false, "InitialPortfolio": { - "OptionExpiries": [500400], - "OptionStrikes": [1500000000000000000000], - "OptionIsCall": [1], - "OptionAmounts": [-1000000000000000000], - "OptionVols": [1047884494084986240], - "SVIparams": [1, 1.5, -0.1, -0.05, 0.05], - "OptionVolConfidences": [1000000000000000000], + "OptionExpiries": [ + 500400 + ], + "OptionStrikes": [ + 1500000000000000000000 + ], + "OptionIsCall": [ + 1 + ], + "OptionAmounts": [ + -1000000000000000000 + ], + "OptionVols": [ + 1047884494084986240 + ], + "SVIparams": [ + 1, + 1.5, + -0.1, + -0.05, + 0.05 + ], + "OptionVolConfidences": [ + 1000000000000000000 + ], "Cash": 200000000000000000000, "Perps": 0, "Base": 0, @@ -199,21 +361,39 @@ "SpotConfidence": 1000000000000000000, "PerpPrice": 1505000000000000000000, "PerpConfidence": 1000000000000000000, - "FeedExpiries": [500400], - "Forwards": [1500833279310993817600], - "ForwardConfidences": [1000000000000000000], - "Rates": [0], - "RateConfidences": [1000000000000000000], + "FeedExpiries": [ + 500400 + ], + "Forwards": [ + 1500833279310993817600 + ], + "ForwardConfidences": [ + 1000000000000000000 + ], + "Rates": [ + 0 + ], + "RateConfidences": [ + 1000000000000000000 + ], "StableConfidence": 0, "StablePrice": 1000000000000000000, "UnrealisedPerpPNL": 0, "UnrealisedFunding": 0, - "VolShockUp": [1.7370684514926746], - "VolShockDown": [0.508621032338217], + "VolShockUp": [ + 1.7370684514926746 + ], + "VolShockDown": [ + 0.508621032338217 + ], "SettlementPrice": 1500833279310993817600, "PercentFixed": 0, - "ForwardsFixed": [0], - "ForwardsVariable": [1500833279310993817600] + "ForwardsFixed": [ + 0 + ], + "ForwardsVariable": [ + 1500833279310993817600 + ] }, "ActionCount": 1, "LiquidationFee": 1.322084630165343, @@ -221,13 +401,31 @@ { "Time": 30, "PortfolioAndFeeds": { - "OptionExpiries": [500400], - "OptionStrikes": [1500000000000000000000], - "OptionIsCall": [1], - "OptionAmounts": [-1000000000000000000], - "OptionVols": [1047884508458193792], - "SVIparams": [1, 1.5, -0.1, -0.05, 0.05], - "OptionVolConfidences": [1000000000000000000], + "OptionExpiries": [ + 500400 + ], + "OptionStrikes": [ + 1500000000000000000000 + ], + "OptionIsCall": [ + 1 + ], + "OptionAmounts": [ + -1000000000000000000 + ], + "OptionVols": [ + 1047884508458193792 + ], + "SVIparams": [ + 1, + 1.5, + -0.1, + -0.05, + 0.05 + ], + "OptionVolConfidences": [ + 1000000000000000000 + ], "Cash": 198677915369834676224, "Perps": 0, "Base": 0, @@ -235,21 +433,39 @@ "SpotConfidence": 1000000000000000000, "PerpPrice": 0, "PerpConfidence": 1000000000000000000, - "FeedExpiries": [500400], - "Forwards": [1500833229340328329216], - "ForwardConfidences": [1000000000000000000], - "Rates": [40000000000000000], - "RateConfidences": [1000000000000000000], + "FeedExpiries": [ + 500400 + ], + "Forwards": [ + 1500833229340328329216 + ], + "ForwardConfidences": [ + 1000000000000000000 + ], + "Rates": [ + 40000000000000000 + ], + "RateConfidences": [ + 1000000000000000000 + ], "StableConfidence": 0, "StablePrice": 1000000000000000000, "UnrealisedPerpPNL": 0, "UnrealisedFunding": 0, - "VolShockUp": [1.737081708636119], - "VolShockDown": [0.5086121942425874], + "VolShockUp": [ + 1.737081708636119 + ], + "VolShockDown": [ + 0.5086121942425874 + ], "SettlementPrice": 1500833229340328329216, "PercentFixed": 0, - "ForwardsFixed": [0], - "ForwardsVariable": [1500833229340328329216] + "ForwardsFixed": [ + 0 + ], + "ForwardsVariable": [ + 1500833229340328329216 + ] }, "Liquidator": { "PercentWant": 150000000000000000 @@ -276,13 +492,31 @@ "StartTime": 0, "IsForce": false, "InitialPortfolio": { - "OptionExpiries": [500400], - "OptionStrikes": [1500000000000000000000], - "OptionIsCall": [1], - "OptionAmounts": [-1000000000000000000], - "OptionVols": [1047884494084986240], - "SVIparams": [1, 1.5, -0.1, -0.05, 0.05], - "OptionVolConfidences": [1000000000000000000], + "OptionExpiries": [ + 500400 + ], + "OptionStrikes": [ + 1500000000000000000000 + ], + "OptionIsCall": [ + 1 + ], + "OptionAmounts": [ + -1000000000000000000 + ], + "OptionVols": [ + 1047884494084986240 + ], + "SVIparams": [ + 1, + 1.5, + -0.1, + -0.05, + 0.05 + ], + "OptionVolConfidences": [ + 1000000000000000000 + ], "Cash": 200000000000000000000, "Perps": 0, "Base": 0, @@ -290,21 +524,39 @@ "SpotConfidence": 1000000000000000000, "PerpPrice": 1505000000000000000000, "PerpConfidence": 1000000000000000000, - "FeedExpiries": [500400], - "Forwards": [1500833279310993817600], - "ForwardConfidences": [1000000000000000000], - "Rates": [0], - "RateConfidences": [1000000000000000000], + "FeedExpiries": [ + 500400 + ], + "Forwards": [ + 1500833279310993817600 + ], + "ForwardConfidences": [ + 1000000000000000000 + ], + "Rates": [ + 0 + ], + "RateConfidences": [ + 1000000000000000000 + ], "StableConfidence": 0, "StablePrice": 1000000000000000000, "UnrealisedPerpPNL": 0, "UnrealisedFunding": 0, - "VolShockUp": [1.7370684514926746], - "VolShockDown": [0.508621032338217], + "VolShockUp": [ + 1.7370684514926746 + ], + "VolShockDown": [ + 0.508621032338217 + ], "SettlementPrice": 1500833279310993817600, "PercentFixed": 0, - "ForwardsFixed": [0], - "ForwardsVariable": [1500833279310993817600] + "ForwardsFixed": [ + 0 + ], + "ForwardsVariable": [ + 1500833279310993817600 + ] }, "ActionCount": 2, "LiquidationFee": 1.322084630165343, @@ -312,13 +564,31 @@ { "Time": 30, "PortfolioAndFeeds": { - "OptionExpiries": [500400], - "OptionStrikes": [1500000000000000000000], - "OptionIsCall": [1], - "OptionAmounts": [-1000000000000000000], - "OptionVols": [1047884508458193792], - "SVIparams": [1, 1.5, -0.1, -0.05, 0.05], - "OptionVolConfidences": [1000000000000000000], + "OptionExpiries": [ + 500400 + ], + "OptionStrikes": [ + 1500000000000000000000 + ], + "OptionIsCall": [ + 1 + ], + "OptionAmounts": [ + -1000000000000000000 + ], + "OptionVols": [ + 1047884508458193792 + ], + "SVIparams": [ + 1, + 1.5, + -0.1, + -0.05, + 0.05 + ], + "OptionVolConfidences": [ + 1000000000000000000 + ], "Cash": 198677915369834676224, "Perps": 0, "Base": 0, @@ -326,21 +596,39 @@ "SpotConfidence": 1000000000000000000, "PerpPrice": 0, "PerpConfidence": 1000000000000000000, - "FeedExpiries": [500400], - "Forwards": [1500833229340328329216], - "ForwardConfidences": [1000000000000000000], - "Rates": [40000000000000000], - "RateConfidences": [1000000000000000000], + "FeedExpiries": [ + 500400 + ], + "Forwards": [ + 1500833229340328329216 + ], + "ForwardConfidences": [ + 1000000000000000000 + ], + "Rates": [ + 40000000000000000 + ], + "RateConfidences": [ + 1000000000000000000 + ], "StableConfidence": 0, "StablePrice": 1000000000000000000, "UnrealisedPerpPNL": 0, "UnrealisedFunding": 0, - "VolShockUp": [1.737081708636119], - "VolShockDown": [0.5086121942425874], + "VolShockUp": [ + 1.737081708636119 + ], + "VolShockDown": [ + 0.5086121942425874 + ], "SettlementPrice": 1500833229340328329216, "PercentFixed": 0, - "ForwardsFixed": [0], - "ForwardsVariable": [1500833229340328329216] + "ForwardsFixed": [ + 0 + ], + "ForwardsVariable": [ + 1500833229340328329216 + ] }, "Liquidator": { "PercentWant": 100000000000000000 @@ -364,13 +652,31 @@ { "Time": 30, "PortfolioAndFeeds": { - "OptionExpiries": [500400], - "OptionStrikes": [1500000000000000000000], - "OptionIsCall": [1], - "OptionAmounts": [-900000000000000000], - "OptionVols": [1047884508458193792], - "SVIparams": [1, 1.5, -0.1, -0.05, 0.05], - "OptionVolConfidences": [1000000000000000000], + "OptionExpiries": [ + 500400 + ], + "OptionStrikes": [ + 1500000000000000000000 + ], + "OptionIsCall": [ + 1 + ], + "OptionAmounts": [ + -900000000000000000 + ], + "OptionVols": [ + 1047884508458193792 + ], + "SVIparams": [ + 1, + 1.5, + -0.1, + -0.05, + 0.05 + ], + "OptionVolConfidences": [ + 1000000000000000000 + ], "Cash": 189858111193486032896, "Perps": 0, "Base": 0, @@ -378,21 +684,39 @@ "SpotConfidence": 1000000000000000000, "PerpPrice": 0, "PerpConfidence": 1000000000000000000, - "FeedExpiries": [500400], - "Forwards": [1500833229340328329216], - "ForwardConfidences": [1000000000000000000], - "Rates": [40000000000000000], - "RateConfidences": [1000000000000000000], + "FeedExpiries": [ + 500400 + ], + "Forwards": [ + 1500833229340328329216 + ], + "ForwardConfidences": [ + 1000000000000000000 + ], + "Rates": [ + 40000000000000000 + ], + "RateConfidences": [ + 1000000000000000000 + ], "StableConfidence": 0, "StablePrice": 1000000000000000000, "UnrealisedPerpPNL": 0, "UnrealisedFunding": 0, - "VolShockUp": [1.737081708636119], - "VolShockDown": [0.5086121942425874], + "VolShockUp": [ + 1.737081708636119 + ], + "VolShockDown": [ + 0.5086121942425874 + ], "SettlementPrice": 1500833229340328329216, "PercentFixed": 0, - "ForwardsFixed": [0], - "ForwardsVariable": [1500833229340328329216] + "ForwardsFixed": [ + 0 + ], + "ForwardsVariable": [ + 1500833229340328329216 + ] }, "Liquidator": { "PercentWant": 111111111111111111 @@ -419,13 +743,31 @@ "StartTime": 0, "IsForce": false, "InitialPortfolio": { - "OptionExpiries": [500400], - "OptionStrikes": [1500000000000000000000], - "OptionIsCall": [1], - "OptionAmounts": [-1000000000000000000], - "OptionVols": [1047884494084986240], - "SVIparams": [1, 1.5, -0.1, -0.05, 0.05], - "OptionVolConfidences": [1000000000000000000], + "OptionExpiries": [ + 500400 + ], + "OptionStrikes": [ + 1500000000000000000000 + ], + "OptionIsCall": [ + 1 + ], + "OptionAmounts": [ + -1000000000000000000 + ], + "OptionVols": [ + 1047884494084986240 + ], + "SVIparams": [ + 1, + 1.5, + -0.1, + -0.05, + 0.05 + ], + "OptionVolConfidences": [ + 1000000000000000000 + ], "Cash": 200000000000000000000, "Perps": 0, "Base": 0, @@ -433,21 +775,39 @@ "SpotConfidence": 1000000000000000000, "PerpPrice": 1505000000000000000000, "PerpConfidence": 1000000000000000000, - "FeedExpiries": [500400], - "Forwards": [1500833279310993817600], - "ForwardConfidences": [1000000000000000000], - "Rates": [0], - "RateConfidences": [1000000000000000000], + "FeedExpiries": [ + 500400 + ], + "Forwards": [ + 1500833279310993817600 + ], + "ForwardConfidences": [ + 1000000000000000000 + ], + "Rates": [ + 0 + ], + "RateConfidences": [ + 1000000000000000000 + ], "StableConfidence": 0, "StablePrice": 1000000000000000000, "UnrealisedPerpPNL": 0, "UnrealisedFunding": 0, - "VolShockUp": [1.7370684514926746], - "VolShockDown": [0.508621032338217], + "VolShockUp": [ + 1.7370684514926746 + ], + "VolShockDown": [ + 0.508621032338217 + ], "SettlementPrice": 1500833279310993817600, "PercentFixed": 0, - "ForwardsFixed": [0], - "ForwardsVariable": [1500833279310993817600] + "ForwardsFixed": [ + 0 + ], + "ForwardsVariable": [ + 1500833279310993817600 + ] }, "ActionCount": 2, "LiquidationFee": 1.322084630165343, @@ -455,13 +815,31 @@ { "Time": 30, "PortfolioAndFeeds": { - "OptionExpiries": [500400], - "OptionStrikes": [1500000000000000000000], - "OptionIsCall": [1], - "OptionAmounts": [-1000000000000000000], - "OptionVols": [1040549342988285696], - "SVIparams": [1, 1.5, -0.1, -0.05, 0.05], - "OptionVolConfidences": [1000000000000000000], + "OptionExpiries": [ + 500400 + ], + "OptionStrikes": [ + 1500000000000000000000 + ], + "OptionIsCall": [ + 1 + ], + "OptionAmounts": [ + -1000000000000000000 + ], + "OptionVols": [ + 1040549342988285696 + ], + "SVIparams": [ + 1, + 1.5, + -0.1, + -0.05, + 0.05 + ], + "OptionVolConfidences": [ + 1000000000000000000 + ], "Cash": 198677915369834676224, "Perps": 0, "Base": 0, @@ -469,21 +847,39 @@ "SpotConfidence": 1000000000000000000, "PerpPrice": 0, "PerpConfidence": 1000000000000000000, - "FeedExpiries": [500400], - "Forwards": [1530849893927134953472], - "ForwardConfidences": [1000000000000000000], - "Rates": [40000000000000000], - "RateConfidences": [1000000000000000000], + "FeedExpiries": [ + 500400 + ], + "Forwards": [ + 1530849893927134953472 + ], + "ForwardConfidences": [ + 1000000000000000000 + ], + "Rates": [ + 40000000000000000 + ], + "RateConfidences": [ + 1000000000000000000 + ], "StableConfidence": 0, "StablePrice": 1000000000000000000, "UnrealisedPerpPNL": 0, "UnrealisedFunding": 0, - "VolShockUp": [1.737081708636119], - "VolShockDown": [0.5086121942425874], + "VolShockUp": [ + 1.737081708636119 + ], + "VolShockDown": [ + 0.5086121942425874 + ], "SettlementPrice": 1530849893927134953472, "PercentFixed": 0, - "ForwardsFixed": [0], - "ForwardsVariable": [1530849893927134953472] + "ForwardsFixed": [ + 0 + ], + "ForwardsVariable": [ + 1530849893927134953472 + ] }, "Liquidator": { "PercentWant": 100000000000000000 @@ -507,13 +903,31 @@ { "Time": 600, "PortfolioAndFeeds": { - "OptionExpiries": [500400], - "OptionStrikes": [1500000000000000000000], - "OptionIsCall": [1], - "OptionAmounts": [-900000000000000000], - "OptionVols": [1064560547131661312], - "SVIparams": [1, 1.5, -0.1, -0.05, 0.05], - "OptionVolConfidences": [1000000000000000000], + "OptionExpiries": [ + 500400 + ], + "OptionStrikes": [ + 1500000000000000000000 + ], + "OptionIsCall": [ + 1 + ], + "OptionAmounts": [ + -900000000000000000 + ], + "OptionVols": [ + 1064560547131661312 + ], + "SVIparams": [ + 1, + 1.5, + -0.1, + -0.05, + 0.05 + ], + "OptionVolConfidences": [ + 1000000000000000000 + ], "Cash": 188358750092439584768, "Perps": 0, "Base": 0, @@ -521,21 +935,39 @@ "SpotConfidence": 1000000000000000000, "PerpPrice": 0, "PerpConfidence": 1000000000000000000, - "FeedExpiries": [500400], - "Forwards": [1450804537234727370752], - "ForwardConfidences": [1000000000000000000], - "Rates": [40000000000000000], - "RateConfidences": [1000000000000000000], + "FeedExpiries": [ + 500400 + ], + "Forwards": [ + 1450804537234727370752 + ], + "ForwardConfidences": [ + 1000000000000000000 + ], + "Rates": [ + 40000000000000000 + ], + "RateConfidences": [ + 1000000000000000000 + ], "StableConfidence": 0, "StablePrice": 1000000000000000000, "UnrealisedPerpPNL": 0, "UnrealisedFunding": 0, - "VolShockUp": [1.7373337908573938], - "VolShockDown": [0.508444139428404], + "VolShockUp": [ + 1.7373337908573938 + ], + "VolShockDown": [ + 0.508444139428404 + ], "SettlementPrice": 1450804537234727370752, "PercentFixed": 0, - "ForwardsFixed": [0], - "ForwardsVariable": [1450804537234727370752] + "ForwardsFixed": [ + 0 + ], + "ForwardsVariable": [ + 1450804537234727370752 + ] }, "Liquidator": { "PercentWant": 555555555555555555 @@ -562,13 +994,31 @@ "StartTime": 0, "IsForce": false, "InitialPortfolio": { - "OptionExpiries": [500400], - "OptionStrikes": [1500000000000000000000], - "OptionIsCall": [1], - "OptionAmounts": [-1000000000000000000], - "OptionVols": [1047884494084986240], - "SVIparams": [1, 1.5, -0.1, -0.05, 0.05], - "OptionVolConfidences": [1000000000000000000], + "OptionExpiries": [ + 500400 + ], + "OptionStrikes": [ + 1500000000000000000000 + ], + "OptionIsCall": [ + 1 + ], + "OptionAmounts": [ + -1000000000000000000 + ], + "OptionVols": [ + 1047884494084986240 + ], + "SVIparams": [ + 1, + 1.5, + -0.1, + -0.05, + 0.05 + ], + "OptionVolConfidences": [ + 1000000000000000000 + ], "Cash": 200000000000000000000, "Perps": 0, "Base": 0, @@ -576,21 +1026,39 @@ "SpotConfidence": 1000000000000000000, "PerpPrice": 1505000000000000000000, "PerpConfidence": 1000000000000000000, - "FeedExpiries": [500400], - "Forwards": [1500833279310993817600], - "ForwardConfidences": [1000000000000000000], - "Rates": [0], - "RateConfidences": [1000000000000000000], + "FeedExpiries": [ + 500400 + ], + "Forwards": [ + 1500833279310993817600 + ], + "ForwardConfidences": [ + 1000000000000000000 + ], + "Rates": [ + 0 + ], + "RateConfidences": [ + 1000000000000000000 + ], "StableConfidence": 0, "StablePrice": 1000000000000000000, "UnrealisedPerpPNL": 0, "UnrealisedFunding": 0, - "VolShockUp": [1.7370684514926746], - "VolShockDown": [0.508621032338217], + "VolShockUp": [ + 1.7370684514926746 + ], + "VolShockDown": [ + 0.508621032338217 + ], "SettlementPrice": 1500833279310993817600, "PercentFixed": 0, - "ForwardsFixed": [0], - "ForwardsVariable": [1500833279310993817600] + "ForwardsFixed": [ + 0 + ], + "ForwardsVariable": [ + 1500833279310993817600 + ] }, "ActionCount": 3, "LiquidationFee": 1.322084630165343, @@ -598,13 +1066,31 @@ { "Time": 30, "PortfolioAndFeeds": { - "OptionExpiries": [500400], - "OptionStrikes": [1500000000000000000000], - "OptionIsCall": [1], - "OptionAmounts": [-1000000000000000000], - "OptionVols": [1040549342988285696], - "SVIparams": [1, 1.5, -0.1, -0.05, 0.05], - "OptionVolConfidences": [1000000000000000000], + "OptionExpiries": [ + 500400 + ], + "OptionStrikes": [ + 1500000000000000000000 + ], + "OptionIsCall": [ + 1 + ], + "OptionAmounts": [ + -1000000000000000000 + ], + "OptionVols": [ + 1040549342988285696 + ], + "SVIparams": [ + 1, + 1.5, + -0.1, + -0.05, + 0.05 + ], + "OptionVolConfidences": [ + 1000000000000000000 + ], "Cash": 198677915369834676224, "Perps": 0, "Base": 0, @@ -612,21 +1098,39 @@ "SpotConfidence": 1000000000000000000, "PerpPrice": 0, "PerpConfidence": 1000000000000000000, - "FeedExpiries": [500400], - "Forwards": [1530849893927134953472], - "ForwardConfidences": [1000000000000000000], - "Rates": [40000000000000000], - "RateConfidences": [1000000000000000000], + "FeedExpiries": [ + 500400 + ], + "Forwards": [ + 1530849893927134953472 + ], + "ForwardConfidences": [ + 1000000000000000000 + ], + "Rates": [ + 40000000000000000 + ], + "RateConfidences": [ + 1000000000000000000 + ], "StableConfidence": 0, "StablePrice": 1000000000000000000, "UnrealisedPerpPNL": 0, "UnrealisedFunding": 0, - "VolShockUp": [1.737081708636119], - "VolShockDown": [0.5086121942425874], + "VolShockUp": [ + 1.737081708636119 + ], + "VolShockDown": [ + 0.5086121942425874 + ], "SettlementPrice": 1530849893927134953472, "PercentFixed": 0, - "ForwardsFixed": [0], - "ForwardsVariable": [1530849893927134953472] + "ForwardsFixed": [ + 0 + ], + "ForwardsVariable": [ + 1530849893927134953472 + ] }, "Liquidator": { "PercentWant": 100000000000000000 @@ -650,13 +1154,31 @@ { "Time": 600, "PortfolioAndFeeds": { - "OptionExpiries": [500400], - "OptionStrikes": [1500000000000000000000], - "OptionIsCall": [1], - "OptionAmounts": [-900000000000000000], - "OptionVols": [1068668852270611200], - "SVIparams": [1, 1.5, -0.1, -0.05, 0.05], - "OptionVolConfidences": [1000000000000000000], + "OptionExpiries": [ + 500400 + ], + "OptionStrikes": [ + 1500000000000000000000 + ], + "OptionIsCall": [ + 1 + ], + "OptionAmounts": [ + -900000000000000000 + ], + "OptionVols": [ + 1068668852270611200 + ], + "SVIparams": [ + 1, + 1.5, + -0.1, + -0.05, + 0.05 + ], + "OptionVolConfidences": [ + 1000000000000000000 + ], "Cash": 188358750092439584768, "Perps": 0, "Base": 0, @@ -664,21 +1186,39 @@ "SpotConfidence": 1000000000000000000, "PerpPrice": 0, "PerpConfidence": 1000000000000000000, - "FeedExpiries": [500400], - "Forwards": [1439798433848808701952], - "ForwardConfidences": [1000000000000000000], - "Rates": [40000000000000000], - "RateConfidences": [1000000000000000000], + "FeedExpiries": [ + 500400 + ], + "Forwards": [ + 1439798433848808701952 + ], + "ForwardConfidences": [ + 1000000000000000000 + ], + "Rates": [ + 40000000000000000 + ], + "RateConfidences": [ + 1000000000000000000 + ], "StableConfidence": 0, "StablePrice": 1000000000000000000, "UnrealisedPerpPNL": 0, "UnrealisedFunding": 0, - "VolShockUp": [1.7373337908573938], - "VolShockDown": [0.508444139428404], + "VolShockUp": [ + 1.7373337908573938 + ], + "VolShockDown": [ + 0.508444139428404 + ], "SettlementPrice": 1439798433848808701952, "PercentFixed": 0, - "ForwardsFixed": [0], - "ForwardsVariable": [1439798433848808701952] + "ForwardsFixed": [ + 0 + ], + "ForwardsVariable": [ + 1439798433848808701952 + ] }, "Liquidator": { "PercentWant": 222222222222222222 @@ -702,13 +1242,31 @@ { "Time": 9000, "PortfolioAndFeeds": { - "OptionExpiries": [500400], - "OptionStrikes": [1500000000000000000000], - "OptionIsCall": [1], - "OptionAmounts": [-700000000000000128], - "OptionVols": [1042220856498288000], - "SVIparams": [1, 1.5, -0.1, -0.05, 0.05], - "OptionVolConfidences": [1000000000000000000], + "OptionExpiries": [ + 500400 + ], + "OptionStrikes": [ + 1500000000000000000000 + ], + "OptionIsCall": [ + 1 + ], + "OptionAmounts": [ + -700000000000000128 + ], + "OptionVols": [ + 1042220856498288000 + ], + "SVIparams": [ + 1, + 1.5, + -0.1, + -0.05, + 0.05 + ], + "OptionVolConfidences": [ + 1000000000000000000 + ], "Cash": 171222370901758509056, "Perps": 0, "Base": 0, @@ -716,21 +1274,39 @@ "SpotConfidence": 1000000000000000000, "PerpPrice": 0, "PerpConfidence": 1000000000000000000, - "FeedExpiries": [500400], - "Forwards": [1522830289745930354688], - "ForwardConfidences": [1000000000000000000], - "Rates": [40000000000000000], - "RateConfidences": [1000000000000000000], + "FeedExpiries": [ + 500400 + ], + "Forwards": [ + 1522830289745930354688 + ], + "ForwardConfidences": [ + 1000000000000000000 + ], + "Rates": [ + 40000000000000000 + ], + "RateConfidences": [ + 1000000000000000000 + ], "StableConfidence": 0, "StablePrice": 1000000000000000000, "UnrealisedPerpPNL": 0, "UnrealisedFunding": 0, - "VolShockUp": [1.7410925838661393], - "VolShockDown": [0.5059382774225738], + "VolShockUp": [ + 1.7410925838661393 + ], + "VolShockDown": [ + 0.5059382774225738 + ], "SettlementPrice": 1522830289745930354688, "PercentFixed": 0, - "ForwardsFixed": [0], - "ForwardsVariable": [1522830289745930354688] + "ForwardsFixed": [ + 0 + ], + "ForwardsVariable": [ + 1522830289745930354688 + ] }, "Liquidator": { "PercentWant": 428571428571428608 @@ -757,13 +1333,31 @@ "StartTime": 0, "IsForce": false, "InitialPortfolio": { - "OptionExpiries": [500400], - "OptionStrikes": [1500000000000000000000], - "OptionIsCall": [1], - "OptionAmounts": [-1000000000000000000], - "OptionVols": [1047884494084986240], - "SVIparams": [1, 1.5, -0.1, -0.05, 0.05], - "OptionVolConfidences": [1000000000000000000], + "OptionExpiries": [ + 500400 + ], + "OptionStrikes": [ + 1500000000000000000000 + ], + "OptionIsCall": [ + 1 + ], + "OptionAmounts": [ + -1000000000000000000 + ], + "OptionVols": [ + 1047884494084986240 + ], + "SVIparams": [ + 1, + 1.5, + -0.1, + -0.05, + 0.05 + ], + "OptionVolConfidences": [ + 1000000000000000000 + ], "Cash": 50000000000000000000, "Perps": 0, "Base": 0, @@ -771,21 +1365,39 @@ "SpotConfidence": 1000000000000000000, "PerpPrice": 1505000000000000000000, "PerpConfidence": 1000000000000000000, - "FeedExpiries": [500400], - "Forwards": [1500833279310993817600], - "ForwardConfidences": [1000000000000000000], - "Rates": [0], - "RateConfidences": [1000000000000000000], + "FeedExpiries": [ + 500400 + ], + "Forwards": [ + 1500833279310993817600 + ], + "ForwardConfidences": [ + 1000000000000000000 + ], + "Rates": [ + 0 + ], + "RateConfidences": [ + 1000000000000000000 + ], "StableConfidence": 0, "StablePrice": 1000000000000000000, "UnrealisedPerpPNL": 0, "UnrealisedFunding": 0, - "VolShockUp": [1.7370684514926746], - "VolShockDown": [0.508621032338217], + "VolShockUp": [ + 1.7370684514926746 + ], + "VolShockDown": [ + 0.508621032338217 + ], "SettlementPrice": 1500833279310993817600, "PercentFixed": 0, - "ForwardsFixed": [0], - "ForwardsVariable": [1500833279310993817600] + "ForwardsFixed": [ + 0 + ], + "ForwardsVariable": [ + 1500833279310993817600 + ] }, "ActionCount": 2, "LiquidationFee": 0, @@ -793,13 +1405,31 @@ { "Time": 30, "PortfolioAndFeeds": { - "OptionExpiries": [500400], - "OptionStrikes": [1500000000000000000000], - "OptionIsCall": [1], - "OptionAmounts": [-1000000000000000000], - "OptionVols": [1047884508458193792], - "SVIparams": [1, 1.5, -0.1, -0.05, 0.05], - "OptionVolConfidences": [1000000000000000000], + "OptionExpiries": [ + 500400 + ], + "OptionStrikes": [ + 1500000000000000000000 + ], + "OptionIsCall": [ + 1 + ], + "OptionAmounts": [ + -1000000000000000000 + ], + "OptionVols": [ + 1047884508458193792 + ], + "SVIparams": [ + 1, + 1.5, + -0.1, + -0.05, + 0.05 + ], + "OptionVolConfidences": [ + 1000000000000000000 + ], "Cash": 50000000000000000000, "Perps": 0, "Base": 0, @@ -807,21 +1437,39 @@ "SpotConfidence": 1000000000000000000, "PerpPrice": 0, "PerpConfidence": 1000000000000000000, - "FeedExpiries": [500400], - "Forwards": [1500833229340328329216], - "ForwardConfidences": [1000000000000000000], - "Rates": [40000000000000000], - "RateConfidences": [1000000000000000000], + "FeedExpiries": [ + 500400 + ], + "Forwards": [ + 1500833229340328329216 + ], + "ForwardConfidences": [ + 1000000000000000000 + ], + "Rates": [ + 40000000000000000 + ], + "RateConfidences": [ + 1000000000000000000 + ], "StableConfidence": 0, "StablePrice": 1000000000000000000, "UnrealisedPerpPNL": 0, "UnrealisedFunding": 0, - "VolShockUp": [1.737081708636119], - "VolShockDown": [0.5086121942425874], + "VolShockUp": [ + 1.737081708636119 + ], + "VolShockDown": [ + 0.5086121942425874 + ], "SettlementPrice": 1500833229340328329216, "PercentFixed": 0, - "ForwardsFixed": [0], - "ForwardsVariable": [1500833229340328329216] + "ForwardsFixed": [ + 0 + ], + "ForwardsVariable": [ + 1500833229340328329216 + ] }, "Liquidator": { "PercentWant": 100000000000000000 @@ -845,13 +1493,31 @@ { "Time": 100, "PortfolioAndFeeds": { - "OptionExpiries": [500400], - "OptionStrikes": [1500000000000000000000], - "OptionIsCall": [1], - "OptionAmounts": [-900000000000000000], - "OptionVols": [1047884541995699200], - "SVIparams": [1, 1.5, -0.1, -0.05, 0.05], - "OptionVolConfidences": [1000000000000000000], + "OptionExpiries": [ + 500400 + ], + "OptionStrikes": [ + 1500000000000000000000 + ], + "OptionIsCall": [ + 1 + ], + "OptionAmounts": [ + -900000000000000000 + ], + "OptionVols": [ + 1047884541995699200 + ], + "SVIparams": [ + 1, + 1.5, + -0.1, + -0.05, + 0.05 + ], + "OptionVolConfidences": [ + 1000000000000000000 + ], "Cash": 45000000000000000000, "Perps": 0, "Base": 0, @@ -859,21 +1525,39 @@ "SpotConfidence": 1000000000000000000, "PerpPrice": 0, "PerpConfidence": 1000000000000000000, - "FeedExpiries": [500400], - "Forwards": [1500833112742114623488], - "ForwardConfidences": [1000000000000000000], - "Rates": [40000000000000000], - "RateConfidences": [1000000000000000000], + "FeedExpiries": [ + 500400 + ], + "Forwards": [ + 1500833112742114623488 + ], + "ForwardConfidences": [ + 1000000000000000000 + ], + "Rates": [ + 40000000000000000 + ], + "RateConfidences": [ + 1000000000000000000 + ], "StableConfidence": 0, "StablePrice": 1000000000000000000, "UnrealisedPerpPNL": 0, "UnrealisedFunding": 0, - "VolShockUp": [1.7371126459895851], - "VolShockDown": [0.5085915693402766], + "VolShockUp": [ + 1.7371126459895851 + ], + "VolShockDown": [ + 0.5085915693402766 + ], "SettlementPrice": 1500833112742114623488, "PercentFixed": 0, - "ForwardsFixed": [0], - "ForwardsVariable": [1500833112742114623488] + "ForwardsFixed": [ + 0 + ], + "ForwardsVariable": [ + 1500833112742114623488 + ] }, "Liquidator": { "PercentWant": 500000000000000000 @@ -900,13 +1584,31 @@ "StartTime": 0, "IsForce": false, "InitialPortfolio": { - "OptionExpiries": [500400], - "OptionStrikes": [1500000000000000000000], - "OptionIsCall": [1], - "OptionAmounts": [-1000000000000000000], - "OptionVols": [1047884494084986240], - "SVIparams": [1, 1.5, -0.1, -0.05, 0.05], - "OptionVolConfidences": [1000000000000000000], + "OptionExpiries": [ + 500400 + ], + "OptionStrikes": [ + 1500000000000000000000 + ], + "OptionIsCall": [ + 1 + ], + "OptionAmounts": [ + -1000000000000000000 + ], + "OptionVols": [ + 1047884494084986240 + ], + "SVIparams": [ + 1, + 1.5, + -0.1, + -0.05, + 0.05 + ], + "OptionVolConfidences": [ + 1000000000000000000 + ], "Cash": 50000000000000000000, "Perps": 0, "Base": 0, @@ -914,21 +1616,39 @@ "SpotConfidence": 1000000000000000000, "PerpPrice": 1505000000000000000000, "PerpConfidence": 1000000000000000000, - "FeedExpiries": [500400], - "Forwards": [1500833279310993817600], - "ForwardConfidences": [1000000000000000000], - "Rates": [0], - "RateConfidences": [1000000000000000000], + "FeedExpiries": [ + 500400 + ], + "Forwards": [ + 1500833279310993817600 + ], + "ForwardConfidences": [ + 1000000000000000000 + ], + "Rates": [ + 0 + ], + "RateConfidences": [ + 1000000000000000000 + ], "StableConfidence": 0, "StablePrice": 1000000000000000000, "UnrealisedPerpPNL": 0, "UnrealisedFunding": 0, - "VolShockUp": [1.7370684514926746], - "VolShockDown": [0.508621032338217], + "VolShockUp": [ + 1.7370684514926746 + ], + "VolShockDown": [ + 0.508621032338217 + ], "SettlementPrice": 1500833279310993817600, "PercentFixed": 0, - "ForwardsFixed": [0], - "ForwardsVariable": [1500833279310993817600] + "ForwardsFixed": [ + 0 + ], + "ForwardsVariable": [ + 1500833279310993817600 + ] }, "ActionCount": 1, "LiquidationFee": 0, @@ -936,13 +1656,31 @@ { "Time": 100, "PortfolioAndFeeds": { - "OptionExpiries": [500400], - "OptionStrikes": [1500000000000000000000], - "OptionIsCall": [1], - "OptionAmounts": [-1000000000000000000], - "OptionVols": [1047884541995699200], - "SVIparams": [1, 1.5, -0.1, -0.05, 0.05], - "OptionVolConfidences": [1000000000000000000], + "OptionExpiries": [ + 500400 + ], + "OptionStrikes": [ + 1500000000000000000000 + ], + "OptionIsCall": [ + 1 + ], + "OptionAmounts": [ + -1000000000000000000 + ], + "OptionVols": [ + 1047884541995699200 + ], + "SVIparams": [ + 1, + 1.5, + -0.1, + -0.05, + 0.05 + ], + "OptionVolConfidences": [ + 1000000000000000000 + ], "Cash": 50000000000000000000, "Perps": 0, "Base": 0, @@ -950,21 +1688,39 @@ "SpotConfidence": 1000000000000000000, "PerpPrice": 0, "PerpConfidence": 1000000000000000000, - "FeedExpiries": [500400], - "Forwards": [1500833112742114623488], - "ForwardConfidences": [1000000000000000000], - "Rates": [40000000000000000], - "RateConfidences": [1000000000000000000], + "FeedExpiries": [ + 500400 + ], + "Forwards": [ + 1500833112742114623488 + ], + "ForwardConfidences": [ + 1000000000000000000 + ], + "Rates": [ + 40000000000000000 + ], + "RateConfidences": [ + 1000000000000000000 + ], "StableConfidence": 0, "StablePrice": 1000000000000000000, "UnrealisedPerpPNL": 0, "UnrealisedFunding": 0, - "VolShockUp": [1.7371126459895851], - "VolShockDown": [0.5085915693402766], + "VolShockUp": [ + 1.7371126459895851 + ], + "VolShockDown": [ + 0.5085915693402766 + ], "SettlementPrice": 1500833112742114623488, "PercentFixed": 0, - "ForwardsFixed": [0], - "ForwardsVariable": [1500833112742114623488] + "ForwardsFixed": [ + 0 + ], + "ForwardsVariable": [ + 1500833112742114623488 + ] }, "Liquidator": { "PercentWant": 1000000000000000000 From 3f979bdf7f54051e4f5c8393931fba2289c5f315 Mon Sep 17 00:00:00 2001 From: Dominic Romanowski Date: Thu, 16 Nov 2023 14:54:10 +1100 Subject: [PATCH 02/14] test changes --- .../liquidation/PM_liquidationSimTests.t.sol | 29 +- .../liquidation/liquidationTests.json | 1535 +++++++++++++++-- 2 files changed, 1448 insertions(+), 116 deletions(-) diff --git a/test/integration-tests/liquidation/PM_liquidationSimTests.t.sol b/test/integration-tests/liquidation/PM_liquidationSimTests.t.sol index ba1d6656..f0a8125c 100644 --- a/test/integration-tests/liquidation/PM_liquidationSimTests.t.sol +++ b/test/integration-tests/liquidation/PM_liquidationSimTests.t.sol @@ -33,6 +33,18 @@ contract LiquidationSimTests_PM is LiquidationSimBase { runLiquidationSim("Test6"); } + function testLiquidationSimLong_Box_Short_Cash() public { + runLiquidationSim("Long_Box_Short_Cash"); + } + + function testLiquidationSimSimple_Short_3_liquidators() public { + runLiquidationSim("Simple_Short_3_liquidators"); + } + + function testLiquidationSimPMRM_Other() public { + runLiquidationSim("PMRM_Other"); + } + // function testInsolventSim1() public { // runLiquidationSim("InsolventTest1"); // } @@ -92,24 +104,25 @@ contract LiquidationSimTests_PM is LiquidationSimBase { fMax = auction.getMaxProportion(aliceAcc, worstScenario); } - assertApproxEqAbs(mtm, data.Actions[actionId].Results.PreMtM, 1e6, "pre mtm"); - assertApproxEqAbs(mm, data.Actions[actionId].Results.PreMM, 1e6, "pre mm"); - assertApproxEqAbs(bm, data.Actions[actionId].Results.PreBM, 1e6, "pre bm"); - assertApproxEqAbs(fMax, data.Actions[actionId].Results.PreFMax, 1e6, "pre fmax"); + console2.log("pre mtm", mtm); + assertApproxEqRel(mtm, data.Actions[actionId].Results.PreMtM, 0.001e18, "pre mtm"); + assertApproxEqRel(mm, data.Actions[actionId].Results.PreMM, 0.001e18, "pre mm"); + assertApproxEqRel(bm, data.Actions[actionId].Results.PreBM, 0.001e18, "pre bm"); + assertApproxEqRel(fMax, data.Actions[actionId].Results.PreFMax, 0.001e18, "pre fmax"); } function checkPostLiquidation(LiquidationSim memory data, uint actionId) internal { uint worstScenario = getWorstScenario(aliceAcc); (int mm, int bm, int mtm) = auction.getMarginAndMarkToMarket(aliceAcc, worstScenario); - assertApproxEqAbs(mtm, data.Actions[actionId].Results.PostMtM, 1e6, "post mtm"); - assertApproxEqAbs(mm, data.Actions[actionId].Results.PostMM, 1e6, "post mm"); - assertApproxEqAbs(bm, data.Actions[actionId].Results.PostBM, 1e6, "post bm"); + assertApproxEqRel(mtm, data.Actions[actionId].Results.PostMtM, 0.001e18, "post mtm"); + assertApproxEqRel(mm, data.Actions[actionId].Results.PostMM, 0.001e18, "post mm"); + assertApproxEqRel(bm, data.Actions[actionId].Results.PostBM, 0.001e18, "post bm"); IDutchAuction.Auction memory auctionDetails = auction.getAuction(aliceAcc); if (auctionDetails.insolvent) {} else { uint fMax = auction.getMaxProportion(aliceAcc, worstScenario); - assertApproxEqAbs(fMax, data.Actions[actionId].Results.PostFMax, 1e6, "post fmax"); + assertApproxEqRel(fMax, data.Actions[actionId].Results.PostFMax, 0.001e18, "post fmax"); } } diff --git a/test/integration-tests/liquidation/liquidationTests.json b/test/integration-tests/liquidation/liquidationTests.json index 8e8d95ec..c6c1b2fd 100644 --- a/test/integration-tests/liquidation/liquidationTests.json +++ b/test/integration-tests/liquidation/liquidationTests.json @@ -50,10 +50,10 @@ "RateConfidences": [ 1000000000000000000 ], - "StableConfidence": 0, "StablePrice": 1000000000000000000, - "UnrealisedPerpPNL": 0, - "UnrealisedFunding": 0, + "StableConfidence": 1000000000000000000, + "UnrealizedPerpPNL": 0, + "UnrealizedFunding": 0, "VolShockUp": [ 1.7370684514926746 ], @@ -122,10 +122,10 @@ "RateConfidences": [ 1000000000000000000 ], - "StableConfidence": 0, "StablePrice": 1000000000000000000, - "UnrealisedPerpPNL": 0, - "UnrealisedFunding": 0, + "StableConfidence": 1000000000000000000, + "UnrealizedPerpPNL": 0, + "UnrealizedFunding": 0, "VolShockUp": [ 1.7370684514926746 ], @@ -213,10 +213,10 @@ "RateConfidences": [ 1000000000000000000 ], - "StableConfidence": 0, "StablePrice": 1000000000000000000, - "UnrealisedPerpPNL": 0, - "UnrealisedFunding": 0, + "StableConfidence": 1000000000000000000, + "UnrealizedPerpPNL": 0, + "UnrealizedFunding": 0, "VolShockUp": [ 1.7370684514926746 ], @@ -285,10 +285,10 @@ "RateConfidences": [ 1000000000000000000 ], - "StableConfidence": 0, "StablePrice": 1000000000000000000, - "UnrealisedPerpPNL": 0, - "UnrealisedFunding": 0, + "StableConfidence": 1000000000000000000, + "UnrealizedPerpPNL": 0, + "UnrealizedFunding": 0, "VolShockUp": [ 1.7370684514926746 ], @@ -376,10 +376,10 @@ "RateConfidences": [ 1000000000000000000 ], - "StableConfidence": 0, "StablePrice": 1000000000000000000, - "UnrealisedPerpPNL": 0, - "UnrealisedFunding": 0, + "StableConfidence": 1000000000000000000, + "UnrealizedPerpPNL": 0, + "UnrealizedFunding": 0, "VolShockUp": [ 1.7370684514926746 ], @@ -402,7 +402,7 @@ "Time": 30, "PortfolioAndFeeds": { "OptionExpiries": [ - 500400 + 500370 ], "OptionStrikes": [ 1500000000000000000000 @@ -434,7 +434,7 @@ "PerpPrice": 0, "PerpConfidence": 1000000000000000000, "FeedExpiries": [ - 500400 + 500370 ], "Forwards": [ 1500833229340328329216 @@ -448,10 +448,10 @@ "RateConfidences": [ 1000000000000000000 ], - "StableConfidence": 0, "StablePrice": 1000000000000000000, - "UnrealisedPerpPNL": 0, - "UnrealisedFunding": 0, + "StableConfidence": 1000000000000000000, + "UnrealizedPerpPNL": 0, + "UnrealizedFunding": 0, "VolShockUp": [ 1.737081708636119 ], @@ -539,10 +539,10 @@ "RateConfidences": [ 1000000000000000000 ], - "StableConfidence": 0, "StablePrice": 1000000000000000000, - "UnrealisedPerpPNL": 0, - "UnrealisedFunding": 0, + "StableConfidence": 1000000000000000000, + "UnrealizedPerpPNL": 0, + "UnrealizedFunding": 0, "VolShockUp": [ 1.7370684514926746 ], @@ -565,7 +565,7 @@ "Time": 30, "PortfolioAndFeeds": { "OptionExpiries": [ - 500400 + 500370 ], "OptionStrikes": [ 1500000000000000000000 @@ -597,7 +597,7 @@ "PerpPrice": 0, "PerpConfidence": 1000000000000000000, "FeedExpiries": [ - 500400 + 500370 ], "Forwards": [ 1500833229340328329216 @@ -611,10 +611,10 @@ "RateConfidences": [ 1000000000000000000 ], - "StableConfidence": 0, "StablePrice": 1000000000000000000, - "UnrealisedPerpPNL": 0, - "UnrealisedFunding": 0, + "StableConfidence": 1000000000000000000, + "UnrealizedPerpPNL": 0, + "UnrealizedFunding": 0, "VolShockUp": [ 1.737081708636119 ], @@ -653,7 +653,7 @@ "Time": 30, "PortfolioAndFeeds": { "OptionExpiries": [ - 500400 + 500370 ], "OptionStrikes": [ 1500000000000000000000 @@ -685,7 +685,7 @@ "PerpPrice": 0, "PerpConfidence": 1000000000000000000, "FeedExpiries": [ - 500400 + 500370 ], "Forwards": [ 1500833229340328329216 @@ -699,10 +699,10 @@ "RateConfidences": [ 1000000000000000000 ], - "StableConfidence": 0, "StablePrice": 1000000000000000000, - "UnrealisedPerpPNL": 0, - "UnrealisedFunding": 0, + "StableConfidence": 1000000000000000000, + "UnrealizedPerpPNL": 0, + "UnrealizedFunding": 0, "VolShockUp": [ 1.737081708636119 ], @@ -719,7 +719,7 @@ ] }, "Liquidator": { - "PercentWant": 111111111111111111 + "PercentWant": 100000000000000000 }, "Results": { "PreMtM": 118425834278252019712, @@ -728,7 +728,7 @@ "PreFMax": 524290585958138816, "ExpectedBidPrice": 11047987360634836992, "FinalPercentageReceived": 111111111111111120, - "fLiquidatedOfOriginal": 111111111111111111, + "fLiquidatedOfOriginal": 100000000000000000, "PostMtM": 117542949759151603712, "PostMM": -60374319541825396736, "PostBM": -95957773402020790272, @@ -790,10 +790,10 @@ "RateConfidences": [ 1000000000000000000 ], - "StableConfidence": 0, "StablePrice": 1000000000000000000, - "UnrealisedPerpPNL": 0, - "UnrealisedFunding": 0, + "StableConfidence": 1000000000000000000, + "UnrealizedPerpPNL": 0, + "UnrealizedFunding": 0, "VolShockUp": [ 1.7370684514926746 ], @@ -809,14 +809,14 @@ 1500833279310993817600 ] }, - "ActionCount": 2, + "ActionCount": 3, "LiquidationFee": 1.322084630165343, "Actions": [ { "Time": 30, "PortfolioAndFeeds": { "OptionExpiries": [ - 500400 + 500370 ], "OptionStrikes": [ 1500000000000000000000 @@ -828,7 +828,7 @@ -1000000000000000000 ], "OptionVols": [ - 1040549342988285696 + 1047884508458193792 ], "SVIparams": [ 1, @@ -843,15 +843,15 @@ "Cash": 198677915369834676224, "Perps": 0, "Base": 0, - "SpotPrice": 1530000000000000000000, + "SpotPrice": 1500000000000000000000, "SpotConfidence": 1000000000000000000, "PerpPrice": 0, "PerpConfidence": 1000000000000000000, "FeedExpiries": [ - 500400 + 500370 ], "Forwards": [ - 1530849893927134953472 + 1500833229340328329216 ], "ForwardConfidences": [ 1000000000000000000 @@ -862,49 +862,49 @@ "RateConfidences": [ 1000000000000000000 ], - "StableConfidence": 0, "StablePrice": 1000000000000000000, - "UnrealisedPerpPNL": 0, - "UnrealisedFunding": 0, + "StableConfidence": 1000000000000000000, + "UnrealizedPerpPNL": 0, + "UnrealizedFunding": 0, "VolShockUp": [ 1.737081708636119 ], "VolShockDown": [ 0.5086121942425874 ], - "SettlementPrice": 1530849893927134953472, + "SettlementPrice": 1500833229340328329216, "PercentFixed": 0, "ForwardsFixed": [ 0 ], "ForwardsVariable": [ - 1530849893927134953472 + 1500833229340328329216 ] }, "Liquidator": { "PercentWant": 100000000000000000 }, "Results": { - "PreMtM": 103116914250414571520, - "PreMM": -129478717730831056896, - "PreBM": -175997844127080185856, - "PreFMax": 648280469348716416, - "ExpectedBidPrice": 9548626259588390912, + "PreMtM": 119308718797352435712, + "PreMM": -103087867828868841472, + "PreBM": -147567185154113110016, + "PreFMax": 571861527362324864, + "ExpectedBidPrice": 11047987360634836992, "FinalPercentageReceived": 100000000000000000, "fLiquidatedOfOriginal": 100000000000000000, - "PostMtM": 102353849084961488896, - "PostMM": -106982219698159517696, - "PostBM": -148849433454783692800, - "PostFMax": 609200521498573696, + "PostMtM": 118425834278252019712, + "PostMM": -81731093685347155968, + "PostBM": -121762479278066974720, + "PostFMax": 524290585958138816, "Lowerbound": 0, "SMPayout": 0 } }, { - "Time": 600, + "Time": 30, "PortfolioAndFeeds": { "OptionExpiries": [ - 500400 + 500370 ], "OptionStrikes": [ 1500000000000000000000 @@ -916,7 +916,7 @@ -900000000000000000 ], "OptionVols": [ - 1064560547131661312 + 1047884508458193792 ], "SVIparams": [ 1, @@ -928,18 +928,18 @@ "OptionVolConfidences": [ 1000000000000000000 ], - "Cash": 188358750092439584768, + "Cash": 189858111193486032896, "Perps": 0, "Base": 0, - "SpotPrice": 1450000000000000000000, + "SpotPrice": 1500000000000000000000, "SpotConfidence": 1000000000000000000, "PerpPrice": 0, "PerpConfidence": 1000000000000000000, "FeedExpiries": [ - 500400 + 500370 ], "Forwards": [ - 1450804537234727370752 + 1500833229340328329216 ], "ForwardConfidences": [ 1000000000000000000 @@ -950,40 +950,128 @@ "RateConfidences": [ 1000000000000000000 ], - "StableConfidence": 0, "StablePrice": 1000000000000000000, - "UnrealisedPerpPNL": 0, - "UnrealisedFunding": 0, + "StableConfidence": 1000000000000000000, + "UnrealizedPerpPNL": 0, + "UnrealizedFunding": 0, "VolShockUp": [ - 1.7373337908573938 + 1.737081708636119 ], "VolShockDown": [ - 0.508444139428404 + 0.5086121942425874 ], - "SettlementPrice": 1450804537234727370752, + "SettlementPrice": 1500833229340328329216, "PercentFixed": 0, "ForwardsFixed": [ 0 ], "ForwardsVariable": [ - 1450804537234727370752 + 1500833229340328329216 ] }, "Liquidator": { - "PercentWant": 555555555555555555 + "PercentWant": 100000000000000000 }, "Results": { - "PreMtM": 137373409208035049472, - "PreMM": -46111362020362379264, - "PreBM": -82808316266041851904, - "PreFMax": 433401449711588160, - "ExpectedBidPrice": 42780683484503875584, - "FinalPercentageReceived": 390061304740429376, - "fLiquidatedOfOriginal": 433401449711588543, - "PostMtM": 124754646453613051904, - "PostMM": 20792441075602169856, - "PostBM": 0, - "PostFMax": 0, + "PreMtM": 118425834278252019712, + "PreMM": -81731093685347155968, + "PreBM": -121762479278066974720, + "PreFMax": 524290585958138816, + "ExpectedBidPrice": 11047987360634836992, + "FinalPercentageReceived": 111111111111111120, + "fLiquidatedOfOriginal": 100000000000000000, + "PostMtM": 117542949759151603712, + "PostMM": -60374319541825396736, + "PostBM": -95957773402020790272, + "PostFMax": 464826909202906112, + "Lowerbound": 0, + "SMPayout": 0 + } + }, + { + "Time": 30, + "PortfolioAndFeeds": { + "OptionExpiries": [ + 500370 + ], + "OptionStrikes": [ + 1500000000000000000000 + ], + "OptionIsCall": [ + 1 + ], + "OptionAmounts": [ + -799999999999999872 + ], + "OptionVols": [ + 1047884508458193792 + ], + "SVIparams": [ + 1, + 1.5, + -0.1, + -0.05, + 0.05 + ], + "OptionVolConfidences": [ + 1000000000000000000 + ], + "Cash": 181038307017137389568, + "Perps": 0, + "Base": 0, + "SpotPrice": 1500000000000000000000, + "SpotConfidence": 1000000000000000000, + "PerpPrice": 0, + "PerpConfidence": 1000000000000000000, + "FeedExpiries": [ + 500370 + ], + "Forwards": [ + 1500833229340328329216 + ], + "ForwardConfidences": [ + 1000000000000000000 + ], + "Rates": [ + 40000000000000000 + ], + "RateConfidences": [ + 1000000000000000000 + ], + "StablePrice": 1000000000000000000, + "StableConfidence": 1000000000000000000, + "UnrealizedPerpPNL": 0, + "UnrealizedFunding": 0, + "VolShockUp": [ + 1.737081708636119 + ], + "VolShockDown": [ + 0.5086121942425874 + ], + "SettlementPrice": 1500833229340328329216, + "PercentFixed": 0, + "ForwardsFixed": [ + 0 + ], + "ForwardsVariable": [ + 1500833229340328329216 + ] + }, + "Liquidator": { + "PercentWant": 100000000000000000 + }, + "Results": { + "PreMtM": 117542949759151603712, + "PreMM": -60374319541825396736, + "PreBM": -95957773402020790272, + "PreFMax": 464826909202906112, + "ExpectedBidPrice": 11047987360634834944, + "FinalPercentageReceived": 125000000000000000, + "fLiquidatedOfOriginal": 100000000000000000, + "PostMtM": 116660065240051187712, + "PostMM": -39017545398303694848, + "PostBM": -70153067525974679552, + "PostFMax": 388373610517607104, "Lowerbound": 0, "SMPayout": 0 } @@ -1041,10 +1129,10 @@ "RateConfidences": [ 1000000000000000000 ], - "StableConfidence": 0, "StablePrice": 1000000000000000000, - "UnrealisedPerpPNL": 0, - "UnrealisedFunding": 0, + "StableConfidence": 1000000000000000000, + "UnrealizedPerpPNL": 0, + "UnrealizedFunding": 0, "VolShockUp": [ 1.7370684514926746 ], @@ -1067,7 +1155,7 @@ "Time": 30, "PortfolioAndFeeds": { "OptionExpiries": [ - 500400 + 500370 ], "OptionStrikes": [ 1500000000000000000000 @@ -1099,7 +1187,7 @@ "PerpPrice": 0, "PerpConfidence": 1000000000000000000, "FeedExpiries": [ - 500400 + 500370 ], "Forwards": [ 1530849893927134953472 @@ -1113,10 +1201,10 @@ "RateConfidences": [ 1000000000000000000 ], - "StableConfidence": 0, "StablePrice": 1000000000000000000, - "UnrealisedPerpPNL": 0, - "UnrealisedFunding": 0, + "StableConfidence": 1000000000000000000, + "UnrealizedPerpPNL": 0, + "UnrealizedFunding": 0, "VolShockUp": [ 1.737081708636119 ], @@ -1155,7 +1243,7 @@ "Time": 600, "PortfolioAndFeeds": { "OptionExpiries": [ - 500400 + 499800 ], "OptionStrikes": [ 1500000000000000000000 @@ -1187,7 +1275,7 @@ "PerpPrice": 0, "PerpConfidence": 1000000000000000000, "FeedExpiries": [ - 500400 + 499800 ], "Forwards": [ 1439798433848808701952 @@ -1201,10 +1289,10 @@ "RateConfidences": [ 1000000000000000000 ], - "StableConfidence": 0, "StablePrice": 1000000000000000000, - "UnrealisedPerpPNL": 0, - "UnrealisedFunding": 0, + "StableConfidence": 1000000000000000000, + "UnrealizedPerpPNL": 0, + "UnrealizedFunding": 0, "VolShockUp": [ 1.7373337908573938 ], @@ -1221,7 +1309,7 @@ ] }, "Liquidator": { - "PercentWant": 222222222222222222 + "PercentWant": 200000000000000000 }, "Results": { "PreMtM": 141241828744923119616, @@ -1229,8 +1317,8 @@ "PreBM": -74294435474072059904, "PreFMax": 400423865535404544, "ExpectedBidPrice": 22599203883285839872, - "FinalPercentageReceived": 200000000000000000, - "fLiquidatedOfOriginal": 222222222222222240, + "FinalPercentageReceived": 222222222222222240, + "fLiquidatedOfOriginal": 200000000000000000, "PostMtM": 134575876520356806656, "PostMM": -5123553991954907136, "PostBM": -33063440094417244160, @@ -1243,7 +1331,7 @@ "Time": 9000, "PortfolioAndFeeds": { "OptionExpiries": [ - 500400 + 491400 ], "OptionStrikes": [ 1500000000000000000000 @@ -1275,7 +1363,7 @@ "PerpPrice": 0, "PerpConfidence": 1000000000000000000, "FeedExpiries": [ - 500400 + 491400 ], "Forwards": [ 1522830289745930354688 @@ -1289,10 +1377,10 @@ "RateConfidences": [ 1000000000000000000 ], - "StableConfidence": 0, "StablePrice": 1000000000000000000, - "UnrealisedPerpPNL": 0, - "UnrealisedFunding": 0, + "StableConfidence": 1000000000000000000, + "UnrealizedPerpPNL": 0, + "UnrealizedFunding": 0, "VolShockUp": [ 1.7410925838661393 ], @@ -1309,7 +1397,7 @@ ] }, "Liquidator": { - "PercentWant": 428571428571428608 + "PercentWant": 300000000000000000 }, "Results": { "PreMtM": 107989712946571624448, @@ -1317,8 +1405,8 @@ "PreBM": -85098725556266106880, "PreFMax": 606027945856190080, "ExpectedBidPrice": 9931675129055612928, - "FinalPercentageReceived": 300000000000000000, - "fLiquidatedOfOriginal": 428571428571428608, + "FinalPercentageReceived": 428571428571428608, + "fLiquidatedOfOriginal": 300000000000000000, "PostMtM": 85417724016899784704, "PostMM": -6529151460641997824, "PostBM": -24918526556150353920, @@ -1742,5 +1830,1236 @@ } } ] + }, + "Long_Box_Short_Cash": { + "StartTime": 0, + "IsForce": false, + "InitialPortfolio": { + "OptionExpiries": [ + 7758000, + 7758000, + 7758000, + 7758000 + ], + "OptionStrikes": [ + 1500000000000000000000, + 2500000000000000000000, + 1500000000000000000000, + 2500000000000000000000 + ], + "OptionIsCall": [ + 1, + 1, + 0, + 0 + ], + "OptionAmounts": [ + 1000000000000000000, + -1000000000000000000, + -1000000000000000000, + 1000000000000000000 + ], + "OptionVols": [ + 1044583332004474880, + 1322452025352536064, + 1044583332004474880, + 1322452025352536064 + ], + "SVIparams": [ + 1, + 1.5, + -0.1, + -0.05, + 0.05 + ], + "OptionVolConfidences": [ + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000 + ], + "Cash": -950000000000000000000, + "Perps": 0, + "Base": 0, + "SpotPrice": 1500000000000000000000, + "SpotConfidence": 1000000000000000000, + "PerpPrice": 1505000000000000000000, + "PerpConfidence": 1000000000000000000, + "FeedExpiries": [ + 7758000, + 7758000, + 7758000, + 7758000 + ], + "Forwards": [ + 1512971000787409567744, + 1512971000787409567744, + 1512971000787409567744, + 1512971000787409567744 + ], + "ForwardConfidences": [ + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000 + ], + "Rates": [ + 0, + 0, + 0, + 0 + ], + "RateConfidences": [ + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000 + ], + "StableConfidence": 0, + "StablePrice": 1000000000000000000, + "UnrealisedPerpPNL": 0, + "UnrealisedFunding": 0, + "VolShockUp": [ + 1.3902272493224166, + 1.3902272493224166, + 1.3902272493224166, + 1.3902272493224166 + ], + "VolShockDown": [ + 0.7398485004517223, + 0.7398485004517223, + 0.7398485004517223, + 0.7398485004517223 + ], + "SettlementPrice": 1512971000787409567744, + "PercentFixed": 0, + "ForwardsFixed": [ + 0, + 0, + 0, + 0 + ], + "ForwardsVariable": [ + 1512971000787409567744, + 1512971000787409567744, + 1512971000787409567744, + 1512971000787409567744 + ] + }, + "ActionCount": 1, + "LiquidationFee": 0.3237428736252539, + "Actions": [ + { + "Time": 30, + "PortfolioAndFeeds": { + "OptionExpiries": [ + 7757970, + 7757970, + 7757970, + 7757970 + ], + "OptionStrikes": [ + 1500000000000000000000, + 2500000000000000000000, + 1500000000000000000000, + 2500000000000000000000 + ], + "OptionIsCall": [ + 1, + 1, + 0, + 0 + ], + "OptionAmounts": [ + 1000000000000000000, + -1000000000000000000, + -1000000000000000000, + 1000000000000000000 + ], + "OptionVols": [ + 1044583344857694720, + 1322452042270033152, + 1044583344857694720, + 1322452042270033152 + ], + "SVIparams": [ + 1, + 1.5, + -0.1, + -0.05, + 0.05 + ], + "OptionVolConfidences": [ + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000 + ], + "Cash": -950323742873625296896, + "Perps": 0, + "Base": 0, + "SpotPrice": 1500000000000000000000, + "SpotConfidence": 1000000000000000000, + "PerpPrice": 0, + "PerpConfidence": 1000000000000000000, + "FeedExpiries": [ + 7757970, + 7757970, + 7757970, + 7757970 + ], + "Forwards": [ + 1512970950412615024640, + 1512970950412615024640, + 1512970950412615024640, + 1512970950412615024640 + ], + "ForwardConfidences": [ + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000 + ], + "Rates": [ + 70000000000000008, + 70000000000000008, + 70000000000000008, + 70000000000000008 + ], + "RateConfidences": [ + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000 + ], + "StableConfidence": 0, + "StablePrice": 1000000000000000000, + "UnrealisedPerpPNL": 0, + "UnrealisedFunding": 0, + "VolShockUp": [ + 1.3902274454927692, + 1.3902274454927692, + 1.3902274454927692, + 1.3902274454927692 + ], + "VolShockDown": [ + 0.7398483696714871, + 0.7398483696714871, + 0.7398483696714871, + 0.7398483696714871 + ], + "SettlementPrice": 1512970950412615024640, + "PercentFixed": 0, + "ForwardsFixed": [ + 0, + 0, + 0, + 0 + ], + "ForwardsVariable": [ + 1512970950412615024640, + 1512970950412615024640, + 1512970950412615024640, + 1512970950412615024640 + ] + }, + "Liquidator": { + "PercentWant": 1000000000000000000 + }, + "Results": { + "PreMtM": 49676257126374711296, + "PreMM": -74398461842264735744, + "PreBM": -99213405635992616960, + "PreFMax": 683223831325438208, + "ExpectedBidPrice": 31428442518524915712, + "FinalPercentageReceived": 683223831325438208, + "fLiquidatedOfOriginal": 683223831325438208, + "PostMtM": 47164696925110321152, + "PostMM": 7860782820851682304, + "PostBM": -42632, + "PostFMax": 926, + "Lowerbound": 0, + "SMPayout": 0 + } + } + ] + }, + "Simple_Short_3_liquidators": { + "StartTime": 0, + "IsForce": false, + "InitialPortfolio": { + "OptionExpiries": [ + 500400 + ], + "OptionStrikes": [ + 1500000000000000000000 + ], + "OptionIsCall": [ + 1 + ], + "OptionAmounts": [ + -1000000000000000000 + ], + "OptionVols": [ + 1047884494084986240 + ], + "SVIparams": [ + 1, + 1.5, + -0.1, + -0.05, + 0.05 + ], + "OptionVolConfidences": [ + 1000000000000000000 + ], + "Cash": 200000000000000000000, + "Perps": 0, + "Base": 0, + "SpotPrice": 1500000000000000000000, + "SpotConfidence": 1000000000000000000, + "PerpPrice": 1505000000000000000000, + "PerpConfidence": 1000000000000000000, + "FeedExpiries": [ + 500400 + ], + "Forwards": [ + 1500833279310993817600 + ], + "ForwardConfidences": [ + 1000000000000000000 + ], + "Rates": [ + 0 + ], + "RateConfidences": [ + 1000000000000000000 + ], + "StableConfidence": 0, + "StablePrice": 1000000000000000000, + "UnrealisedPerpPNL": 0, + "UnrealisedFunding": 0, + "VolShockUp": [ + 1.7370684514926746 + ], + "VolShockDown": [ + 0.508621032338217 + ], + "SettlementPrice": 1500833279310993817600, + "PercentFixed": 0, + "ForwardsFixed": [ + 0 + ], + "ForwardsVariable": [ + 1500833279310993817600 + ] + }, + "ActionCount": 3, + "LiquidationFee": 1.322084630165343, + "Actions": [ + { + "Time": 30, + "PortfolioAndFeeds": { + "OptionExpiries": [ + 500370 + ], + "OptionStrikes": [ + 1500000000000000000000 + ], + "OptionIsCall": [ + 1 + ], + "OptionAmounts": [ + -1000000000000000000 + ], + "OptionVols": [ + 1047884508458193792 + ], + "SVIparams": [ + 1, + 1.5, + -0.1, + -0.05, + 0.05 + ], + "OptionVolConfidences": [ + 1000000000000000000 + ], + "Cash": 198677915369834676224, + "Perps": 0, + "Base": 0, + "SpotPrice": 1500000000000000000000, + "SpotConfidence": 1000000000000000000, + "PerpPrice": 0, + "PerpConfidence": 1000000000000000000, + "FeedExpiries": [ + 500370 + ], + "Forwards": [ + 1500833229340328329216 + ], + "ForwardConfidences": [ + 1000000000000000000 + ], + "Rates": [ + 40000000000000000 + ], + "RateConfidences": [ + 1000000000000000000 + ], + "StableConfidence": 0, + "StablePrice": 1000000000000000000, + "UnrealisedPerpPNL": 0, + "UnrealisedFunding": 0, + "VolShockUp": [ + 1.737081708636119 + ], + "VolShockDown": [ + 0.5086121942425874 + ], + "SettlementPrice": 1500833229340328329216, + "PercentFixed": 0, + "ForwardsFixed": [ + 0 + ], + "ForwardsVariable": [ + 1500833229340328329216 + ] + }, + "Liquidator": { + "PercentWant": 190620509120774976 + }, + "Results": { + "PreMtM": 119308718797352435712, + "PreMM": -103087867828868841472, + "PreBM": -147567185154113110016, + "PreFMax": 571861527362324864, + "ExpectedBidPrice": 21059729754440994816, + "FinalPercentageReceived": 190620509120774976, + "fLiquidatedOfOriginal": 190620509120774976, + "PostMtM": 117625759832094736384, + "PostMM": -62377476224713719808, + "PostBM": -98378123436075417600, + "PostFMax": 471028760349993216, + "Lowerbound": 0, + "SMPayout": 0 + } + }, + { + "Time": 30, + "PortfolioAndFeeds": { + "OptionExpiries": [ + 500370 + ], + "OptionStrikes": [ + 1500000000000000000000 + ], + "OptionIsCall": [ + 1 + ], + "OptionAmounts": [ + -809379490879224960 + ], + "OptionVols": [ + 1047884508458193792 + ], + "SVIparams": [ + 1, + 1.5, + -0.1, + -0.05, + 0.05 + ], + "OptionVolConfidences": [ + 1000000000000000000 + ], + "Cash": 181865559745423540224, + "Perps": 0, + "Base": 0, + "SpotPrice": 1500000000000000000000, + "SpotConfidence": 1000000000000000000, + "PerpPrice": 0, + "PerpConfidence": 1000000000000000000, + "FeedExpiries": [ + 500370 + ], + "Forwards": [ + 1500833229340328329216 + ], + "ForwardConfidences": [ + 1000000000000000000 + ], + "Rates": [ + 40000000000000000 + ], + "RateConfidences": [ + 1000000000000000000 + ], + "StableConfidence": 0, + "StablePrice": 1000000000000000000, + "UnrealisedPerpPNL": 0, + "UnrealisedFunding": 0, + "VolShockUp": [ + 1.737081708636119 + ], + "VolShockDown": [ + 0.5086121942425874 + ], + "SettlementPrice": 1500833229340328329216, + "PercentFixed": 0, + "ForwardsFixed": [ + 0 + ], + "ForwardsVariable": [ + 1500833229340328329216 + ] + }, + "Liquidator": { + "PercentWant": 190620509120774976 + }, + "Results": { + "PreMtM": 117625759832094736384, + "PreMM": -62377476224713719808, + "PreBM": -98378123436075417600, + "PreFMax": 471028760349993216, + "ExpectedBidPrice": 21059729754440994816, + "FinalPercentageReceived": 235514380174996576, + "fLiquidatedOfOriginal": 190620509120774976, + "PostMtM": 115942800866837053440, + "PostMM": -21667084620558540800, + "PostBM": -49189061718037659648, + "PostFMax": 308069078171682880, + "Lowerbound": 0, + "SMPayout": 0 + } + }, + { + "Time": 30, + "PortfolioAndFeeds": { + "OptionExpiries": [ + 500370 + ], + "OptionStrikes": [ + 1500000000000000000000 + ], + "OptionIsCall": [ + 1 + ], + "OptionAmounts": [ + -618758981758450048 + ], + "OptionVols": [ + 1047884508458193792 + ], + "SVIparams": [ + 1, + 1.5, + -0.1, + -0.05, + 0.05 + ], + "OptionVolConfidences": [ + 1000000000000000000 + ], + "Cash": 165053204121012404224, + "Perps": 0, + "Base": 0, + "SpotPrice": 1500000000000000000000, + "SpotConfidence": 1000000000000000000, + "PerpPrice": 0, + "PerpConfidence": 1000000000000000000, + "FeedExpiries": [ + 500370 + ], + "Forwards": [ + 1500833229340328329216 + ], + "ForwardConfidences": [ + 1000000000000000000 + ], + "Rates": [ + 40000000000000000 + ], + "RateConfidences": [ + 1000000000000000000 + ], + "StableConfidence": 0, + "StablePrice": 1000000000000000000, + "UnrealisedPerpPNL": 0, + "UnrealisedFunding": 0, + "VolShockUp": [ + 1.737081708636119 + ], + "VolShockDown": [ + 0.5086121942425874 + ], + "SettlementPrice": 1500833229340328329216, + "PercentFixed": 0, + "ForwardsFixed": [ + 0 + ], + "ForwardsVariable": [ + 1500833229340328329216 + ] + }, + "Liquidator": { + "PercentWant": 190620509120774976 + }, + "Results": { + "PreMtM": 115942800866837053440, + "PreMM": -21667084620558540800, + "PreBM": -49189061718037659648, + "PreFMax": 308069078171682880, + "ExpectedBidPrice": 21059729754440986624, + "FinalPercentageReceived": 308069078171682880, + "fLiquidatedOfOriginal": 190620509120774816, + "PostMtM": 114259841901579370496, + "PostMM": 19043306983596552192, + "PostBM": -14210, + "PostFMax": 128, + "Lowerbound": 0, + "SMPayout": 0 + } + } + ] + }, + "PMRM_Other": { + "StartTime": 0, + "IsForce": false, + "InitialPortfolio": { + "OptionExpiries": [ + 1191600, + 500400, + 7758000, + 500400, + 2487600, + 1191600 + ], + "OptionStrikes": [ + 1600000000000000000000, + 1200000000000000000000, + 1900000000000000000000, + 1150000000000000000000, + 1550000000000000000000, + 1000000000000000000000 + ], + "OptionIsCall": [ + 1, + 0, + 1, + 0, + 1, + 1 + ], + "OptionAmounts": [ + -1000000000000000000, + -21000000000000000000, + -3000000000000000000, + 7000000000000000000, + -2000000000000000000, + -1600000000000000000 + ], + "OptionVols": [ + 1081048412239005184, + 1138939398828297472, + 1175456212663501056, + 1168496420216719616, + 1062799243592622592, + 1262509093212846848 + ], + "SVIparams": [ + 1, + 1.5, + -0.1, + -0.05, + 0.05 + ], + "OptionVolConfidences": [ + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000 + ], + "Cash": -4200000000000000000000, + "Perps": 0, + "Base": 5000000000000000000, + "SpotPrice": 1500000000000000000000, + "SpotConfidence": 1000000000000000000, + "PerpPrice": 1505000000000000000000, + "PerpConfidence": 1000000000000000000, + "FeedExpiries": [ + 1191600, + 500400, + 7758000, + 500400, + 2487600, + 1191600 + ], + "Forwards": [ + 1501985045187195830272, + 1500833279310993817600, + 1512971000787409567744, + 1500833279310993817600, + 1504146989085687808000, + 1501985045187195830272 + ], + "ForwardConfidences": [ + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000 + ], + "Rates": [ + 0, + 0, + 0, + 0, + 0, + 0 + ], + "RateConfidences": [ + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000 + ], + "StableConfidence": 0, + "StablePrice": 1000000000000000000, + "UnrealisedPerpPNL": 0, + "UnrealisedFunding": 0, + "VolShockUp": [ + 1.5681511166375728, + 1.7370684514926746, + 1.3902272493224166, + 1.7370684514926746, + 1.4555844040146944, + 1.5681511166375728 + ], + "VolShockDown": [ + 0.6212325889082848, + 0.508621032338217, + 0.7398485004517223, + 0.508621032338217, + 0.6962770639902038, + 0.6212325889082848 + ], + "SettlementPrice": 1500833279310993817600, + "PercentFixed": 0, + "ForwardsFixed": [ + 0, + 0, + 0, + 0, + 0, + 0 + ], + "ForwardsVariable": [ + 1501985045187195830272, + 1500833279310993817600, + 1512971000787409567744, + 1500833279310993817600, + 1504146989085687808000, + 1501985045187195830272 + ] + }, + "ActionCount": 3, + "LiquidationFee": 15.6941169723226, + "Actions": [ + { + "Time": 1, + "PortfolioAndFeeds": { + "OptionExpiries": [ + 1191599, + 500399, + 7757999, + 500399, + 2487599, + 1191599 + ], + "OptionStrikes": [ + 1600000000000000000000, + 1200000000000000000000, + 1900000000000000000000, + 1150000000000000000000, + 1550000000000000000000, + 1000000000000000000000 + ], + "OptionIsCall": [ + 1, + 0, + 1, + 0, + 1, + 1 + ], + "OptionAmounts": [ + -1000000000000000000, + -21000000000000000000, + -3000000000000000000, + 7000000000000000000, + -2000000000000000000, + -1600000000000000000 + ], + "OptionVols": [ + 1077307287018514688, + 1143578187182830720, + 1171703284439064064, + 1173072277125157120, + 1059335143046964608, + 1266806217053655296 + ], + "SVIparams": [ + 1, + 1.5, + -0.1, + -0.05, + 0.05 + ], + "OptionVolConfidences": [ + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000 + ], + "Cash": -4215694116972322095104, + "Perps": 0, + "Base": 5000000000000000000, + "SpotPrice": 1510000000000000000000, + "SpotConfidence": 1000000000000000000, + "PerpPrice": 0, + "PerpConfidence": 1000000000000000000, + "FeedExpiries": [ + 1191599, + 500399, + 7757999, + 500399, + 2487599, + 1191599 + ], + "Forwards": [ + 1511998277143696769024, + 1510838832829607444480, + 1523057472435638239232, + 1510838832829607444480, + 1514174633999096872960, + 1511998277143696769024 + ], + "ForwardConfidences": [ + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000 + ], + "Rates": [ + 50000000000000000, + 40000000000000000, + 70000000000000008, + 40000000000000000, + 60000000000000000, + 50000000000000000 + ], + "RateConfidences": [ + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000 + ], + "StableConfidence": 0, + "StablePrice": 1000000000000000000, + "UnrealisedPerpPNL": 0, + "UnrealisedFunding": 0, + "VolShockUp": [ + 1.5681512596767035, + 1.7370688933808094, + 1.3902272558614146, + 1.7370688933808094, + 1.4555844589573526, + 1.5681512596767035 + ], + "VolShockDown": [ + 0.6212324935488645, + 0.5086207377461271, + 0.7398484960923903, + 0.5086207377461271, + 0.6962770273617649, + 0.6212324935488645 + ], + "SettlementPrice": 1510838832829607444480, + "PercentFixed": 0, + "ForwardsFixed": [ + 0, + 0, + 0, + 0, + 0, + 0 + ], + "ForwardsVariable": [ + 1511998277143696769024, + 1510838832829607444480, + 1523057472435638239232, + 1510838832829607444480, + 1514174633999096872960, + 1511998277143696769024 + ] + }, + "Liquidator": { + "PercentWant": 200000000000000000 + }, + "Results": { + "PreMtM": 1320588088479097552896, + "PreMM": -1361157908172672335872, + "PreBM": -1897507107503025946624, + "PreFMax": 594959180462664448, + "ExpectedBidPrice": 258359853630050664448, + "FinalPercentageReceived": 200000000000000000, + "fLiquidatedOfOriginal": 200000000000000000, + "PostMtM": 1314830324413328523264, + "PostMM": -830566472908087230464, + "PostBM": -1259645832372370538496, + "PostFMax": 493698975578330752, + "Lowerbound": 0, + "SMPayout": 0 + } + }, + { + "Time": 300, + "PortfolioAndFeeds": { + "OptionExpiries": [ + 1191300, + 500100, + 7757700, + 500100, + 2487300, + 1191300 + ], + "OptionStrikes": [ + 1600000000000000000000, + 1200000000000000000000, + 1900000000000000000000, + 1150000000000000000000, + 1550000000000000000000, + 1000000000000000000000 + ], + "OptionIsCall": [ + 1, + 0, + 1, + 0, + 1, + 1 + ], + "OptionAmounts": [ + -800000000000000000, + -16800000000000000000, + -2400000000000000512, + 5600000000000001024, + -1600000000000000000, + -1280000000000000256 + ], + "OptionVols": [ + 1073625031002286976, + 1148178475668307328, + 1167966725683237376, + 1177605942516402432, + 1055994002402481024, + 1271061686714528000 + ], + "SVIparams": [ + 1, + 1.5, + -0.1, + -0.05, + 0.05 + ], + "OptionVolConfidences": [ + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000 + ], + "Cash": -3114195439947807195136, + "Perps": 0, + "Base": 4000000000000000000, + "SpotPrice": 1520000000000000000000, + "SpotConfidence": 1000000000000000000, + "PerpPrice": 0, + "PerpConfidence": 1000000000000000000, + "FeedExpiries": [ + 1191300, + 500100, + 7757700, + 500100, + 2487300, + 1191300 + ], + "Forwards": [ + 1522011005698423914496, + 1520843883332469784576, + 1533143437000065679360, + 1520843883332469784576, + 1524201774786140176384, + 1522011005698423914496 + ], + "ForwardConfidences": [ + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000 + ], + "Rates": [ + 50000000000000000, + 40000000000000000, + 70000000000000008, + 40000000000000000, + 60000000000000000, + 50000000000000000 + ], + "RateConfidences": [ + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000 + ], + "StableConfidence": 0, + "StablePrice": 1000000000000000000, + "UnrealisedPerpPNL": 0, + "UnrealisedFunding": 0, + "VolShockUp": [ + 1.5681940353769965, + 1.7372010694442017, + 1.3902292110645202, + 1.7372010694442017, + 1.455600888100079, + 1.5681940353769965 + ], + "VolShockDown": [ + 0.6212039764153356, + 0.5085326203705323, + 0.7398471926236532, + 0.5085326203705323, + 0.6962660745999473, + 0.6212039764153356 + ], + "SettlementPrice": 1520843883332469784576, + "PercentFixed": 0, + "ForwardsFixed": [ + 0, + 0, + 0, + 0, + 0, + 0 + ], + "ForwardsVariable": [ + 1522011005698423914496, + 1520843883332469784576, + 1533143437000065679360, + 1520843883332469784576, + 1524201774786140176384, + 1522011005698423914496 + ] + }, + "Liquidator": { + "PercentWant": 100000000000000000 + }, + "Results": { + "PreMtM": 1328127711998475239424, + "PreMM": -791807002400099401728, + "PreBM": -1215793945279814172672, + "PreFMax": 524482767533124608, + "ExpectedBidPrice": 105490997144664113152, + "FinalPercentageReceived": 125000000000000000, + "fLiquidatedOfOriginal": 100000000000000000, + "PostMtM": 1299897726847086755840, + "PostMM": -555045148251666448384, + "PostBM": -926033723271416905728, + "PostFMax": 456551734323570880, + "Lowerbound": 0, + "SMPayout": 0 + } + }, + { + "Time": 8000, + "PortfolioAndFeeds": { + "OptionExpiries": [ + 1183600, + 492400, + 7750000, + 492400, + 2479600, + 1183600 + ], + "OptionStrikes": [ + 1600000000000000000000, + 1200000000000000000000, + 1900000000000000000000, + 1150000000000000000000, + 1550000000000000000000, + 1000000000000000000000 + ], + "OptionIsCall": [ + 1, + 0, + 1, + 0, + 1, + 1 + ], + "OptionAmounts": [ + -700000000000000128, + -14700000000000002048, + -2100000000000000512, + 4900000000000000000, + -1400000000000000256, + -1120000000000000128 + ], + "OptionVols": [ + 1092574198714486144, + 1124794262461757312, + 1186817279412732672, + 1154508913406808832, + 1073774576826392448, + 1249356163864710912 + ], + "SVIparams": [ + 1, + 1.5, + -0.1, + -0.05, + 0.05 + ], + "OptionVolConfidences": [ + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000 + ], + "Cash": -2587135031105910996992, + "Perps": 0, + "Base": 3500000000000000000, + "SpotPrice": 1470000000000000000000, + "SpotConfidence": 1000000000000000000, + "PerpPrice": 0, + "PerpConfidence": 1000000000000000000, + "FeedExpiries": [ + 1183600, + 492400, + 7750000, + 492400, + 2479600, + 1183600 + ], + "Forwards": [ + 1471932275318880206848, + 1470803554781864656896, + 1482698416216880447488, + 1470803554781864656896, + 1474050961528051204096, + 1471932275318880206848 + ], + "ForwardConfidences": [ + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000 + ], + "Rates": [ + 50000000000000000, + 40000000000000000, + 70000000000000008, + 40000000000000000, + 60000000000000000, + 50000000000000000 + ], + "RateConfidences": [ + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000 + ], + "StableConfidence": 0, + "StablePrice": 1000000000000000000, + "UnrealisedPerpPNL": 0, + "UnrealisedFunding": 0, + "VolShockUp": [ + 1.5693004485466155, + 1.7406407439213831, + 1.390279591802785, + 1.7406407439213831, + 1.4560248662409134, + 1.5693004485466155 + ], + "VolShockDown": [ + 0.6204663676355897, + 0.5062395040524114, + 0.7398136054648099, + 0.5062395040524114, + 0.6959834225060578, + 0.6204663676355897 + ], + "SettlementPrice": 1470803554781864656896, + "PercentFixed": 0, + "ForwardsFixed": [ + 0, + 0, + 0, + 0, + 0, + 0 + ], + "ForwardsVariable": [ + 1471932275318880206848, + 1470803554781864656896, + 1482698416216880447488, + 1470803554781864656896, + 1474050961528051204096, + 1471932275318880206848 + ] + }, + "Liquidator": { + "PercentWant": 990000000000000000 + }, + "Results": { + "PreMtM": 1238413245736269381632, + "PreMM": -724848959009338163200, + "PreBM": -1117501399958459383808, + "PreFMax": 621812965979813888, + "ExpectedBidPrice": 196377363269191630848, + "FinalPercentageReceived": 621812965979813888, + "fLiquidatedOfOriginal": 435269076185869696, + "PostMtM": 890976372260007051264, + "PostMM": 148496062043334508544, + "PostBM": 0, + "PostFMax": 0, + "Lowerbound": 0, + "SMPayout": 0 + } + } + ] } } From 67824d4e385ea33d2fce53cf5201d9e158a8bd44 Mon Sep 17 00:00:00 2001 From: Dominic Romanowski Date: Thu, 16 Nov 2023 16:08:26 +1100 Subject: [PATCH 03/14] update testcases --- .../liquidation/PMRM_solvent.json | 2687 +++++++++++++++++ .../liquidation/PM_liquidationSimTests.t.sol | 39 +- .../liquidation/util/LiquidationSimBase.sol | 39 +- 3 files changed, 2737 insertions(+), 28 deletions(-) create mode 100644 test/integration-tests/liquidation/PMRM_solvent.json diff --git a/test/integration-tests/liquidation/PMRM_solvent.json b/test/integration-tests/liquidation/PMRM_solvent.json new file mode 100644 index 00000000..6962169b --- /dev/null +++ b/test/integration-tests/liquidation/PMRM_solvent.json @@ -0,0 +1,2687 @@ +{ + "Test1": { + "StartTime": 0, + "IsForce": false, + "InitialPortfolio": { + "OptionExpiries": [ + 500400 + ], + "OptionStrikes": [ + 1500000000000000000000 + ], + "OptionIsCall": [ + 1 + ], + "OptionAmounts": [ + -1000000000000000000 + ], + "OptionVols": [ + 1047884494084986240 + ], + "SVIparams": [ + 1, + 1.5, + -0.1, + -0.05, + 0.05 + ], + "OptionVolConfidences": [ + 1000000000000000000 + ], + "Cash": 200000000000000000000, + "Perps": 0, + "Base": 0, + "SpotPrice": 1500000000000000000000, + "SpotConfidence": 1000000000000000000, + "PerpPrice": 1505000000000000000000, + "PerpConfidence": 1000000000000000000, + "FeedExpiries": [ + 500400 + ], + "Forwards": [ + 1500833279310993817600 + ], + "ForwardConfidences": [ + 1000000000000000000 + ], + "Rates": [ + 0 + ], + "RateConfidences": [ + 1000000000000000000 + ], + "StablePrice": 1000000000000000000, + "UnrealisedPerpPNL": 0, + "UnrealisedFunding": 0, + "VolShockUp": [ + 1.7370684514926746 + ], + "VolShockDown": [ + 0.508621032338217 + ], + "SettlementPrice": 1500833279310993817600, + "PercentFixed": 0, + "ForwardsFixed": [ + 0 + ], + "ForwardsVariable": [ + 1500833279310993817600 + ] + }, + "ActionCount": 1, + "LiquidationFee": 1.322084630165343, + "Actions": [ + { + "Time": 0, + "PortfolioAndFeeds": { + "OptionExpiries": [ + 500400 + ], + "OptionStrikes": [ + 1500000000000000000000 + ], + "OptionIsCall": [ + 1 + ], + "OptionAmounts": [ + -1000000000000000000 + ], + "OptionVols": [ + 1047884494084986240 + ], + "SVIparams": [ + 1, + 1.5, + -0.1, + -0.05, + 0.05 + ], + "OptionVolConfidences": [ + 1000000000000000000 + ], + "Cash": 198677915369834676224, + "Perps": 0, + "Base": 0, + "SpotPrice": 1500000000000000000000, + "SpotConfidence": 1000000000000000000, + "PerpPrice": 1505000000000000000000, + "PerpConfidence": 1000000000000000000, + "FeedExpiries": [ + 500400 + ], + "Forwards": [ + 1500833279310993817600 + ], + "ForwardConfidences": [ + 1000000000000000000 + ], + "Rates": [ + 0 + ], + "RateConfidences": [ + 1000000000000000000 + ], + "StablePrice": 1000000000000000000, + "UnrealisedPerpPNL": 0, + "UnrealisedFunding": 0, + "VolShockUp": [ + 1.7370684514926746 + ], + "VolShockDown": [ + 0.508621032338217 + ], + "SettlementPrice": 1500833279310993817600, + "PercentFixed": 0, + "ForwardsFixed": [ + 0 + ], + "ForwardsVariable": [ + 1500833279310993817600 + ] + }, + "Liquidator": { + "PercentWant": 1000000000000000000 + }, + "Results": { + "PreMtM": 119306330180774723584, + "PreMM": -103090619490529640448, + "PreBM": -147570009424790470656, + "PreFMax": 557941285425569408, + "ExpectedBidPrice": 65234608676059463680, + "FinalPercentageReceived": 557941285425569408, + "fLiquidatedOfOriginal": 557941285425569408, + "PostMtM": 117975011636365344768, + "PostMM": 19662501939394220032, + "PostBM": 0, + "PostFMax": 0 + } + } + ] + }, + "Test2": { + "StartTime": 0, + "IsForce": false, + "InitialPortfolio": { + "OptionExpiries": [ + 500400 + ], + "OptionStrikes": [ + 1500000000000000000000 + ], + "OptionIsCall": [ + 1 + ], + "OptionAmounts": [ + -1000000000000000000 + ], + "OptionVols": [ + 1047884494084986240 + ], + "SVIparams": [ + 1, + 1.5, + -0.1, + -0.05, + 0.05 + ], + "OptionVolConfidences": [ + 1000000000000000000 + ], + "Cash": 200000000000000000000, + "Perps": 0, + "Base": 0, + "SpotPrice": 1500000000000000000000, + "SpotConfidence": 1000000000000000000, + "PerpPrice": 1505000000000000000000, + "PerpConfidence": 1000000000000000000, + "FeedExpiries": [ + 500400 + ], + "Forwards": [ + 1500833279310993817600 + ], + "ForwardConfidences": [ + 1000000000000000000 + ], + "Rates": [ + 0 + ], + "RateConfidences": [ + 1000000000000000000 + ], + "StablePrice": 1000000000000000000, + "UnrealisedPerpPNL": 0, + "UnrealisedFunding": 0, + "VolShockUp": [ + 1.7370684514926746 + ], + "VolShockDown": [ + 0.508621032338217 + ], + "SettlementPrice": 1500833279310993817600, + "PercentFixed": 0, + "ForwardsFixed": [ + 0 + ], + "ForwardsVariable": [ + 1500833279310993817600 + ] + }, + "ActionCount": 1, + "LiquidationFee": 1.322084630165343, + "Actions": [ + { + "Time": 0, + "PortfolioAndFeeds": { + "OptionExpiries": [ + 500400 + ], + "OptionStrikes": [ + 1500000000000000000000 + ], + "OptionIsCall": [ + 1 + ], + "OptionAmounts": [ + -1000000000000000000 + ], + "OptionVols": [ + 1047884494084986240 + ], + "SVIparams": [ + 1, + 1.5, + -0.1, + -0.05, + 0.05 + ], + "OptionVolConfidences": [ + 1000000000000000000 + ], + "Cash": 198677915369834676224, + "Perps": 0, + "Base": 0, + "SpotPrice": 1500000000000000000000, + "SpotConfidence": 1000000000000000000, + "PerpPrice": 1505000000000000000000, + "PerpConfidence": 1000000000000000000, + "FeedExpiries": [ + 500400 + ], + "Forwards": [ + 1500833279310993817600 + ], + "ForwardConfidences": [ + 1000000000000000000 + ], + "Rates": [ + 0 + ], + "RateConfidences": [ + 1000000000000000000 + ], + "StablePrice": 1000000000000000000, + "UnrealisedPerpPNL": 0, + "UnrealisedFunding": 0, + "VolShockUp": [ + 1.7370684514926746 + ], + "VolShockDown": [ + 0.508621032338217 + ], + "SettlementPrice": 1500833279310993817600, + "PercentFixed": 0, + "ForwardsFixed": [ + 0 + ], + "ForwardsVariable": [ + 1500833279310993817600 + ] + }, + "Liquidator": { + "PercentWant": 50000000000000000 + }, + "Results": { + "PreMtM": 119306330180774723584, + "PreMM": -103090619490529640448, + "PreBM": -147570009424790470656, + "PreFMax": 557941285425569408, + "ExpectedBidPrice": 5846010178857961472, + "FinalPercentageReceived": 50000000000000000, + "fLiquidatedOfOriginal": 50000000000000000, + "PostMtM": 119187023850593943552, + "PostMM": -92090078337145208832, + "PostBM": -134345498774693052416, + "PostFMax": 534675037290073152 + } + } + ] + }, + "Test3": { + "StartTime": 0, + "IsForce": false, + "InitialPortfolio": { + "OptionExpiries": [ + 500400 + ], + "OptionStrikes": [ + 1500000000000000000000 + ], + "OptionIsCall": [ + 1 + ], + "OptionAmounts": [ + -1000000000000000000 + ], + "OptionVols": [ + 1047884494084986240 + ], + "SVIparams": [ + 1, + 1.5, + -0.1, + -0.05, + 0.05 + ], + "OptionVolConfidences": [ + 1000000000000000000 + ], + "Cash": 200000000000000000000, + "Perps": 0, + "Base": 0, + "SpotPrice": 1500000000000000000000, + "SpotConfidence": 1000000000000000000, + "PerpPrice": 1505000000000000000000, + "PerpConfidence": 1000000000000000000, + "FeedExpiries": [ + 500400 + ], + "Forwards": [ + 1500833279310993817600 + ], + "ForwardConfidences": [ + 1000000000000000000 + ], + "Rates": [ + 0 + ], + "RateConfidences": [ + 1000000000000000000 + ], + "StablePrice": 1000000000000000000, + "UnrealisedPerpPNL": 0, + "UnrealisedFunding": 0, + "VolShockUp": [ + 1.7370684514926746 + ], + "VolShockDown": [ + 0.508621032338217 + ], + "SettlementPrice": 1500833279310993817600, + "PercentFixed": 0, + "ForwardsFixed": [ + 0 + ], + "ForwardsVariable": [ + 1500833279310993817600 + ] + }, + "ActionCount": 1, + "LiquidationFee": 1.322084630165343, + "Actions": [ + { + "Time": 30, + "PortfolioAndFeeds": { + "OptionExpiries": [ + 500370 + ], + "OptionStrikes": [ + 1500000000000000000000 + ], + "OptionIsCall": [ + 1 + ], + "OptionAmounts": [ + -1000000000000000000 + ], + "OptionVols": [ + 1047884508458193792 + ], + "SVIparams": [ + 1, + 1.5, + -0.1, + -0.05, + 0.05 + ], + "OptionVolConfidences": [ + 1000000000000000000 + ], + "Cash": 198677915369834676224, + "Perps": 0, + "Base": 0, + "SpotPrice": 1500000000000000000000, + "SpotConfidence": 1000000000000000000, + "PerpPrice": 1505000000000000000000, + "PerpConfidence": 1000000000000000000, + "FeedExpiries": [ + 500370 + ], + "Forwards": [ + 1500833229340328329216 + ], + "ForwardConfidences": [ + 1000000000000000000 + ], + "Rates": [ + 0 + ], + "RateConfidences": [ + 1000000000000000000 + ], + "StablePrice": 1000000000000000000, + "UnrealisedPerpPNL": 0, + "UnrealisedFunding": 0, + "VolShockUp": [ + 1.737081708636119 + ], + "VolShockDown": [ + 0.5086121942425874 + ], + "SettlementPrice": 1500833229340328329216, + "PercentFixed": 0, + "ForwardsFixed": [ + 0 + ], + "ForwardsVariable": [ + 1500833229340328329216 + ] + }, + "Liquidator": { + "PercentWant": 150000000000000000 + }, + "Results": { + "PreMtM": 119308718797352435712, + "PreMM": -103087867828868841472, + "PreBM": -147567185154113110016, + "PreFMax": 571861527362324864, + "ExpectedBidPrice": 16571981040952252416, + "FinalPercentageReceived": 150000000000000000, + "fLiquidatedOfOriginal": 150000000000000000, + "PostMtM": 117984392018701828096, + "PostMM": -71052706613586223104, + "PostBM": -108860126340043833344, + "PostFMax": 496307679249793920 + } + } + ] + }, + "Test4": { + "StartTime": 0, + "IsForce": false, + "InitialPortfolio": { + "OptionExpiries": [ + 500400 + ], + "OptionStrikes": [ + 1500000000000000000000 + ], + "OptionIsCall": [ + 1 + ], + "OptionAmounts": [ + -1000000000000000000 + ], + "OptionVols": [ + 1047884494084986240 + ], + "SVIparams": [ + 1, + 1.5, + -0.1, + -0.05, + 0.05 + ], + "OptionVolConfidences": [ + 1000000000000000000 + ], + "Cash": 200000000000000000000, + "Perps": 0, + "Base": 0, + "SpotPrice": 1500000000000000000000, + "SpotConfidence": 1000000000000000000, + "PerpPrice": 1505000000000000000000, + "PerpConfidence": 1000000000000000000, + "FeedExpiries": [ + 500400 + ], + "Forwards": [ + 1500833279310993817600 + ], + "ForwardConfidences": [ + 1000000000000000000 + ], + "Rates": [ + 0 + ], + "RateConfidences": [ + 1000000000000000000 + ], + "StablePrice": 1000000000000000000, + "UnrealisedPerpPNL": 0, + "UnrealisedFunding": 0, + "VolShockUp": [ + 1.7370684514926746 + ], + "VolShockDown": [ + 0.508621032338217 + ], + "SettlementPrice": 1500833279310993817600, + "PercentFixed": 0, + "ForwardsFixed": [ + 0 + ], + "ForwardsVariable": [ + 1500833279310993817600 + ] + }, + "ActionCount": 2, + "LiquidationFee": 1.322084630165343, + "Actions": [ + { + "Time": 30, + "PortfolioAndFeeds": { + "OptionExpiries": [ + 500370 + ], + "OptionStrikes": [ + 1500000000000000000000 + ], + "OptionIsCall": [ + 1 + ], + "OptionAmounts": [ + -1000000000000000000 + ], + "OptionVols": [ + 1047884508458193792 + ], + "SVIparams": [ + 1, + 1.5, + -0.1, + -0.05, + 0.05 + ], + "OptionVolConfidences": [ + 1000000000000000000 + ], + "Cash": 198677915369834676224, + "Perps": 0, + "Base": 0, + "SpotPrice": 1500000000000000000000, + "SpotConfidence": 1000000000000000000, + "PerpPrice": 1505000000000000000000, + "PerpConfidence": 1000000000000000000, + "FeedExpiries": [ + 500370 + ], + "Forwards": [ + 1500833229340328329216 + ], + "ForwardConfidences": [ + 1000000000000000000 + ], + "Rates": [ + 0 + ], + "RateConfidences": [ + 1000000000000000000 + ], + "StablePrice": 1000000000000000000, + "UnrealisedPerpPNL": 0, + "UnrealisedFunding": 0, + "VolShockUp": [ + 1.737081708636119 + ], + "VolShockDown": [ + 0.5086121942425874 + ], + "SettlementPrice": 1500833229340328329216, + "PercentFixed": 0, + "ForwardsFixed": [ + 0 + ], + "ForwardsVariable": [ + 1500833229340328329216 + ] + }, + "Liquidator": { + "PercentWant": 100000000000000000 + }, + "Results": { + "PreMtM": 119308718797352435712, + "PreMM": -103087867828868841472, + "PreBM": -147567185154113110016, + "PreFMax": 571861527362324864, + "ExpectedBidPrice": 11047987360634836992, + "FinalPercentageReceived": 100000000000000000, + "fLiquidatedOfOriginal": 100000000000000000, + "PostMtM": 118425834278252019712, + "PostMM": -81731093685347155968, + "PostBM": -121762479278066974720, + "PostFMax": 524290585958138816 + } + }, + { + "Time": 30, + "PortfolioAndFeeds": { + "OptionExpiries": [ + 500370 + ], + "OptionStrikes": [ + 1500000000000000000000 + ], + "OptionIsCall": [ + 1 + ], + "OptionAmounts": [ + -900000000000000000 + ], + "OptionVols": [ + 1047884508458193792 + ], + "SVIparams": [ + 1, + 1.5, + -0.1, + -0.05, + 0.05 + ], + "OptionVolConfidences": [ + 1000000000000000000 + ], + "Cash": 189858111193486032896, + "Perps": 0, + "Base": 0, + "SpotPrice": 1500000000000000000000, + "SpotConfidence": 1000000000000000000, + "PerpPrice": 1505000000000000000000, + "PerpConfidence": 1000000000000000000, + "FeedExpiries": [ + 500370 + ], + "Forwards": [ + 1500833229340328329216 + ], + "ForwardConfidences": [ + 1000000000000000000 + ], + "Rates": [ + 0 + ], + "RateConfidences": [ + 1000000000000000000 + ], + "StablePrice": 1000000000000000000, + "UnrealisedPerpPNL": 0, + "UnrealisedFunding": 0, + "VolShockUp": [ + 1.737081708636119 + ], + "VolShockDown": [ + 0.5086121942425874 + ], + "SettlementPrice": 1500833229340328329216, + "PercentFixed": 0, + "ForwardsFixed": [ + 0 + ], + "ForwardsVariable": [ + 1500833229340328329216 + ] + }, + "Liquidator": { + "PercentWant": 90000000000000000 + }, + "Results": { + "PreMtM": 118425834278252019712, + "PreMM": -81731093685347155968, + "PreBM": -121762479278066974720, + "PreFMax": 524290585958138816, + "ExpectedBidPrice": 9943188624571351040, + "FinalPercentageReceived": 99999999999999984, + "fLiquidatedOfOriginal": 90000000000000000, + "PostMtM": 117631238211061661696, + "PostMM": -62509996956177588224, + "PostBM": -98538243989625438208, + "PostFMax": 471433984397932032 + } + } + ] + }, + "Test5": { + "StartTime": 0, + "IsForce": false, + "InitialPortfolio": { + "OptionExpiries": [ + 500400 + ], + "OptionStrikes": [ + 1500000000000000000000 + ], + "OptionIsCall": [ + 1 + ], + "OptionAmounts": [ + -1000000000000000000 + ], + "OptionVols": [ + 1047884494084986240 + ], + "SVIparams": [ + 1, + 1.5, + -0.1, + -0.05, + 0.05 + ], + "OptionVolConfidences": [ + 1000000000000000000 + ], + "Cash": 200000000000000000000, + "Perps": 0, + "Base": 0, + "SpotPrice": 1500000000000000000000, + "SpotConfidence": 1000000000000000000, + "PerpPrice": 1505000000000000000000, + "PerpConfidence": 1000000000000000000, + "FeedExpiries": [ + 500400 + ], + "Forwards": [ + 1500833279310993817600 + ], + "ForwardConfidences": [ + 1000000000000000000 + ], + "Rates": [ + 0 + ], + "RateConfidences": [ + 1000000000000000000 + ], + "StablePrice": 1000000000000000000, + "UnrealisedPerpPNL": 0, + "UnrealisedFunding": 0, + "VolShockUp": [ + 1.7370684514926746 + ], + "VolShockDown": [ + 0.508621032338217 + ], + "SettlementPrice": 1500833279310993817600, + "PercentFixed": 0, + "ForwardsFixed": [ + 0 + ], + "ForwardsVariable": [ + 1500833279310993817600 + ] + }, + "ActionCount": 3, + "LiquidationFee": 1.322084630165343, + "Actions": [ + { + "Time": 30, + "PortfolioAndFeeds": { + "OptionExpiries": [ + 500370 + ], + "OptionStrikes": [ + 1500000000000000000000 + ], + "OptionIsCall": [ + 1 + ], + "OptionAmounts": [ + -1000000000000000000 + ], + "OptionVols": [ + 1047884508458193792 + ], + "SVIparams": [ + 1, + 1.5, + -0.1, + -0.05, + 0.05 + ], + "OptionVolConfidences": [ + 1000000000000000000 + ], + "Cash": 198677915369834676224, + "Perps": 0, + "Base": 0, + "SpotPrice": 1500000000000000000000, + "SpotConfidence": 1000000000000000000, + "PerpPrice": 1505000000000000000000, + "PerpConfidence": 1000000000000000000, + "FeedExpiries": [ + 500370 + ], + "Forwards": [ + 1500833229340328329216 + ], + "ForwardConfidences": [ + 1000000000000000000 + ], + "Rates": [ + 0 + ], + "RateConfidences": [ + 1000000000000000000 + ], + "StablePrice": 1000000000000000000, + "UnrealisedPerpPNL": 0, + "UnrealisedFunding": 0, + "VolShockUp": [ + 1.737081708636119 + ], + "VolShockDown": [ + 0.5086121942425874 + ], + "SettlementPrice": 1500833229340328329216, + "PercentFixed": 0, + "ForwardsFixed": [ + 0 + ], + "ForwardsVariable": [ + 1500833229340328329216 + ] + }, + "Liquidator": { + "PercentWant": 100000000000000000 + }, + "Results": { + "PreMtM": 119308718797352435712, + "PreMM": -103087867828868841472, + "PreBM": -147567185154113110016, + "PreFMax": 571861527362324864, + "ExpectedBidPrice": 11047987360634836992, + "FinalPercentageReceived": 100000000000000000, + "fLiquidatedOfOriginal": 100000000000000000, + "PostMtM": 118425834278252019712, + "PostMM": -81731093685347155968, + "PostBM": -121762479278066974720, + "PostFMax": 524290585958138816 + } + }, + { + "Time": 30, + "PortfolioAndFeeds": { + "OptionExpiries": [ + 500370 + ], + "OptionStrikes": [ + 1500000000000000000000 + ], + "OptionIsCall": [ + 1 + ], + "OptionAmounts": [ + -900000000000000000 + ], + "OptionVols": [ + 1047884508458193792 + ], + "SVIparams": [ + 1, + 1.5, + -0.1, + -0.05, + 0.05 + ], + "OptionVolConfidences": [ + 1000000000000000000 + ], + "Cash": 189858111193486032896, + "Perps": 0, + "Base": 0, + "SpotPrice": 1500000000000000000000, + "SpotConfidence": 1000000000000000000, + "PerpPrice": 1505000000000000000000, + "PerpConfidence": 1000000000000000000, + "FeedExpiries": [ + 500370 + ], + "Forwards": [ + 1500833229340328329216 + ], + "ForwardConfidences": [ + 1000000000000000000 + ], + "Rates": [ + 0 + ], + "RateConfidences": [ + 1000000000000000000 + ], + "StablePrice": 1000000000000000000, + "UnrealisedPerpPNL": 0, + "UnrealisedFunding": 0, + "VolShockUp": [ + 1.737081708636119 + ], + "VolShockDown": [ + 0.5086121942425874 + ], + "SettlementPrice": 1500833229340328329216, + "PercentFixed": 0, + "ForwardsFixed": [ + 0 + ], + "ForwardsVariable": [ + 1500833229340328329216 + ] + }, + "Liquidator": { + "PercentWant": 100000000000000000 + }, + "Results": { + "PreMtM": 118425834278252019712, + "PreMM": -81731093685347155968, + "PreBM": -121762479278066974720, + "PreFMax": 524290585958138816, + "ExpectedBidPrice": 11047987360634836992, + "FinalPercentageReceived": 111111111111111120, + "fLiquidatedOfOriginal": 100000000000000000, + "PostMtM": 117542949759151603712, + "PostMM": -60374319541825396736, + "PostBM": -95957773402020790272, + "PostFMax": 464826909202906112 + } + }, + { + "Time": 30, + "PortfolioAndFeeds": { + "OptionExpiries": [ + 500370 + ], + "OptionStrikes": [ + 1500000000000000000000 + ], + "OptionIsCall": [ + 1 + ], + "OptionAmounts": [ + -799999999999999872 + ], + "OptionVols": [ + 1047884508458193792 + ], + "SVIparams": [ + 1, + 1.5, + -0.1, + -0.05, + 0.05 + ], + "OptionVolConfidences": [ + 1000000000000000000 + ], + "Cash": 181038307017137389568, + "Perps": 0, + "Base": 0, + "SpotPrice": 1500000000000000000000, + "SpotConfidence": 1000000000000000000, + "PerpPrice": 1505000000000000000000, + "PerpConfidence": 1000000000000000000, + "FeedExpiries": [ + 500370 + ], + "Forwards": [ + 1500833229340328329216 + ], + "ForwardConfidences": [ + 1000000000000000000 + ], + "Rates": [ + 0 + ], + "RateConfidences": [ + 1000000000000000000 + ], + "StablePrice": 1000000000000000000, + "UnrealisedPerpPNL": 0, + "UnrealisedFunding": 0, + "VolShockUp": [ + 1.737081708636119 + ], + "VolShockDown": [ + 0.5086121942425874 + ], + "SettlementPrice": 1500833229340328329216, + "PercentFixed": 0, + "ForwardsFixed": [ + 0 + ], + "ForwardsVariable": [ + 1500833229340328329216 + ] + }, + "Liquidator": { + "PercentWant": 100000000000000000 + }, + "Results": { + "PreMtM": 117542949759151603712, + "PreMM": -60374319541825396736, + "PreBM": -95957773402020790272, + "PreFMax": 464826909202906112, + "ExpectedBidPrice": 11047987360634834944, + "FinalPercentageReceived": 125000000000000000, + "fLiquidatedOfOriginal": 100000000000000000, + "PostMtM": 116660065240051187712, + "PostMM": -39017545398303694848, + "PostBM": -70153067525974679552, + "PostFMax": 388373610517607104 + } + } + ] + }, + "Test6": { + "StartTime": 0, + "IsForce": false, + "InitialPortfolio": { + "OptionExpiries": [ + 500400 + ], + "OptionStrikes": [ + 1500000000000000000000 + ], + "OptionIsCall": [ + 1 + ], + "OptionAmounts": [ + -1000000000000000000 + ], + "OptionVols": [ + 1047884494084986240 + ], + "SVIparams": [ + 1, + 1.5, + -0.1, + -0.05, + 0.05 + ], + "OptionVolConfidences": [ + 1000000000000000000 + ], + "Cash": 200000000000000000000, + "Perps": 0, + "Base": 0, + "SpotPrice": 1500000000000000000000, + "SpotConfidence": 1000000000000000000, + "PerpPrice": 1505000000000000000000, + "PerpConfidence": 1000000000000000000, + "FeedExpiries": [ + 500400 + ], + "Forwards": [ + 1500833279310993817600 + ], + "ForwardConfidences": [ + 1000000000000000000 + ], + "Rates": [ + 0 + ], + "RateConfidences": [ + 1000000000000000000 + ], + "StablePrice": 1000000000000000000, + "UnrealisedPerpPNL": 0, + "UnrealisedFunding": 0, + "VolShockUp": [ + 1.7370684514926746 + ], + "VolShockDown": [ + 0.508621032338217 + ], + "SettlementPrice": 1500833279310993817600, + "PercentFixed": 0, + "ForwardsFixed": [ + 0 + ], + "ForwardsVariable": [ + 1500833279310993817600 + ] + }, + "ActionCount": 3, + "LiquidationFee": 1.322084630165343, + "Actions": [ + { + "Time": 30, + "PortfolioAndFeeds": { + "OptionExpiries": [ + 500370 + ], + "OptionStrikes": [ + 1500000000000000000000 + ], + "OptionIsCall": [ + 1 + ], + "OptionAmounts": [ + -1000000000000000000 + ], + "OptionVols": [ + 1040549342988285696 + ], + "SVIparams": [ + 1, + 1.5, + -0.1, + -0.05, + 0.05 + ], + "OptionVolConfidences": [ + 1000000000000000000 + ], + "Cash": 198677915369834676224, + "Perps": 0, + "Base": 0, + "SpotPrice": 1530000000000000000000, + "SpotConfidence": 1000000000000000000, + "PerpPrice": 1535000000000000000000, + "PerpConfidence": 1000000000000000000, + "FeedExpiries": [ + 500370 + ], + "Forwards": [ + 1530849893927134953472 + ], + "ForwardConfidences": [ + 1000000000000000000 + ], + "Rates": [ + 0 + ], + "RateConfidences": [ + 1000000000000000000 + ], + "StablePrice": 1000000000000000000, + "UnrealisedPerpPNL": 0, + "UnrealisedFunding": 0, + "VolShockUp": [ + 1.737081708636119 + ], + "VolShockDown": [ + 0.5086121942425874 + ], + "SettlementPrice": 1530849893927134953472, + "PercentFixed": 0, + "ForwardsFixed": [ + 0 + ], + "ForwardsVariable": [ + 1530849893927134953472 + ] + }, + "Liquidator": { + "PercentWant": 100000000000000000 + }, + "Results": { + "PreMtM": 103116914250414571520, + "PreMM": -129478717730831056896, + "PreBM": -175997844127080185856, + "PreFMax": 648280469348716416, + "ExpectedBidPrice": 9548626259588390912, + "FinalPercentageReceived": 100000000000000000, + "fLiquidatedOfOriginal": 100000000000000000, + "PostMtM": 102353849084961488896, + "PostMM": -106982219698159517696, + "PostBM": -148849433454783692800, + "PostFMax": 609200521498573696 + } + }, + { + "Time": 600, + "PortfolioAndFeeds": { + "OptionExpiries": [ + 499800 + ], + "OptionStrikes": [ + 1500000000000000000000 + ], + "OptionIsCall": [ + 1 + ], + "OptionAmounts": [ + -900000000000000000 + ], + "OptionVols": [ + 1068668852270611200 + ], + "SVIparams": [ + 1, + 1.5, + -0.1, + -0.05, + 0.05 + ], + "OptionVolConfidences": [ + 1000000000000000000 + ], + "Cash": 188358750092439584768, + "Perps": 0, + "Base": 0, + "SpotPrice": 1439000000000000000000, + "SpotConfidence": 1000000000000000000, + "PerpPrice": 1444000000000000000000, + "PerpConfidence": 1000000000000000000, + "FeedExpiries": [ + 499800 + ], + "Forwards": [ + 1439798433848808701952 + ], + "ForwardConfidences": [ + 1000000000000000000 + ], + "Rates": [ + 0 + ], + "RateConfidences": [ + 1000000000000000000 + ], + "StablePrice": 1000000000000000000, + "UnrealisedPerpPNL": 0, + "UnrealisedFunding": 0, + "VolShockUp": [ + 1.7373337908573938 + ], + "VolShockDown": [ + 0.508444139428404 + ], + "SettlementPrice": 1439798433848808701952, + "PercentFixed": 0, + "ForwardsFixed": [ + 0 + ], + "ForwardsVariable": [ + 1439798433848808701952 + ] + }, + "Liquidator": { + "PercentWant": 200000000000000000 + }, + "Results": { + "PreMtM": 141241828744923119616, + "PreMM": -38371724770906210304, + "PreBM": -74294435474072059904, + "PreFMax": 400423865535404544, + "ExpectedBidPrice": 22599203883285839872, + "FinalPercentageReceived": 222222222222222240, + "fLiquidatedOfOriginal": 200000000000000000, + "PostMtM": 134575876520356806656, + "PostMM": -5123553991954907136, + "PostBM": -33063440094417244160, + "PostFMax": 229116398545520192 + } + }, + { + "Time": 9000, + "PortfolioAndFeeds": { + "OptionExpiries": [ + 491400 + ], + "OptionStrikes": [ + 1500000000000000000000 + ], + "OptionIsCall": [ + 1 + ], + "OptionAmounts": [ + -700000000000000128 + ], + "OptionVols": [ + 1042220856498288000 + ], + "SVIparams": [ + 1, + 1.5, + -0.1, + -0.05, + 0.05 + ], + "OptionVolConfidences": [ + 1000000000000000000 + ], + "Cash": 171222370901758509056, + "Perps": 0, + "Base": 0, + "SpotPrice": 1522000000000000000000, + "SpotConfidence": 1000000000000000000, + "PerpPrice": 1527000000000000000000, + "PerpConfidence": 1000000000000000000, + "FeedExpiries": [ + 491400 + ], + "Forwards": [ + 1522830289745930354688 + ], + "ForwardConfidences": [ + 1000000000000000000 + ], + "Rates": [ + 0 + ], + "RateConfidences": [ + 1000000000000000000 + ], + "StablePrice": 1000000000000000000, + "UnrealisedPerpPNL": 0, + "UnrealisedFunding": 0, + "VolShockUp": [ + 1.7410925838661393 + ], + "VolShockDown": [ + 0.5059382774225738 + ], + "SettlementPrice": 1522830289745930354688, + "PercentFixed": 0, + "ForwardsFixed": [ + 0 + ], + "ForwardsVariable": [ + 1522830289745930354688 + ] + }, + "Liquidator": { + "PercentWant": 300000000000000000 + }, + "Results": { + "PreMtM": 107989712946571624448, + "PreMM": -52917319139126501376, + "PreBM": -85098725556266106880, + "PreFMax": 606027945856190080, + "ExpectedBidPrice": 9931675129055612928, + "FinalPercentageReceived": 428571428571428608, + "fLiquidatedOfOriginal": 300000000000000000, + "PostMtM": 85417724016899784704, + "PostMM": -6529151460641997824, + "PostBM": -24918526556150353920, + "PostFMax": 310548905248332864 + } + } + ] + }, + "Long_Box_Short_Cash": { + "StartTime": 0, + "IsForce": false, + "InitialPortfolio": { + "OptionExpiries": [ + 7758000, + 7758000, + 7758000, + 7758000 + ], + "OptionStrikes": [ + 1500000000000000000000, + 2500000000000000000000, + 1500000000000000000000, + 2500000000000000000000 + ], + "OptionIsCall": [ + 1, + 1, + 0, + 0 + ], + "OptionAmounts": [ + 1000000000000000000, + -1000000000000000000, + -1000000000000000000, + 1000000000000000000 + ], + "OptionVols": [ + 1044583332004474880, + 1322452025352536064, + 1044583332004474880, + 1322452025352536064 + ], + "SVIparams": [ + 1, + 1.5, + -0.1, + -0.05, + 0.05 + ], + "OptionVolConfidences": [ + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000 + ], + "Cash": -950000000000000000000, + "Perps": 0, + "Base": 0, + "SpotPrice": 1500000000000000000000, + "SpotConfidence": 1000000000000000000, + "PerpPrice": 1505000000000000000000, + "PerpConfidence": 1000000000000000000, + "FeedExpiries": [ + 7758000, + 7758000, + 7758000, + 7758000 + ], + "Forwards": [ + 1512971000787409567744, + 1512971000787409567744, + 1512971000787409567744, + 1512971000787409567744 + ], + "ForwardConfidences": [ + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000 + ], + "Rates": [ + 0, + 0, + 0, + 0 + ], + "RateConfidences": [ + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000 + ], + "StablePrice": 1000000000000000000, + "UnrealisedPerpPNL": 0, + "UnrealisedFunding": 0, + "VolShockUp": [ + 1.3902272493224166, + 1.3902272493224166, + 1.3902272493224166, + 1.3902272493224166 + ], + "VolShockDown": [ + 0.7398485004517223, + 0.7398485004517223, + 0.7398485004517223, + 0.7398485004517223 + ], + "SettlementPrice": 1512971000787409567744, + "PercentFixed": 0, + "ForwardsFixed": [ + 0, + 0, + 0, + 0 + ], + "ForwardsVariable": [ + 1512971000787409567744, + 1512971000787409567744, + 1512971000787409567744, + 1512971000787409567744 + ] + }, + "ActionCount": 1, + "LiquidationFee": 0.3237428736252539, + "Actions": [ + { + "Time": 30, + "PortfolioAndFeeds": { + "OptionExpiries": [ + 7757970, + 7757970, + 7757970, + 7757970 + ], + "OptionStrikes": [ + 1500000000000000000000, + 2500000000000000000000, + 1500000000000000000000, + 2500000000000000000000 + ], + "OptionIsCall": [ + 1, + 1, + 0, + 0 + ], + "OptionAmounts": [ + 1000000000000000000, + -1000000000000000000, + -1000000000000000000, + 1000000000000000000 + ], + "OptionVols": [ + 1044583344857694720, + 1322452042270033152, + 1044583344857694720, + 1322452042270033152 + ], + "SVIparams": [ + 1, + 1.5, + -0.1, + -0.05, + 0.05 + ], + "OptionVolConfidences": [ + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000 + ], + "Cash": -950323742873625296896, + "Perps": 0, + "Base": 0, + "SpotPrice": 1500000000000000000000, + "SpotConfidence": 1000000000000000000, + "PerpPrice": 1505000000000000000000, + "PerpConfidence": 1000000000000000000, + "FeedExpiries": [ + 7757970, + 7757970, + 7757970, + 7757970 + ], + "Forwards": [ + 1512970950412615024640, + 1512970950412615024640, + 1512970950412615024640, + 1512970950412615024640 + ], + "ForwardConfidences": [ + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000 + ], + "Rates": [ + 0, + 0, + 0, + 0 + ], + "RateConfidences": [ + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000 + ], + "StablePrice": 1000000000000000000, + "UnrealisedPerpPNL": 0, + "UnrealisedFunding": 0, + "VolShockUp": [ + 1.3902274454927692, + 1.3902274454927692, + 1.3902274454927692, + 1.3902274454927692 + ], + "VolShockDown": [ + 0.7398483696714871, + 0.7398483696714871, + 0.7398483696714871, + 0.7398483696714871 + ], + "SettlementPrice": 1512970950412615024640, + "PercentFixed": 0, + "ForwardsFixed": [ + 0, + 0, + 0, + 0 + ], + "ForwardsVariable": [ + 1512970950412615024640, + 1512970950412615024640, + 1512970950412615024640, + 1512970950412615024640 + ] + }, + "Liquidator": { + "PercentWant": 1000000000000000000 + }, + "Results": { + "PreMtM": 49676257126374711296, + "PreMM": -11937343466544234496, + "PreBM": -24260063585128022016, + "PreFMax": 345288467178951872, + "ExpectedBidPrice": 15883343416155256832, + "FinalPercentageReceived": 345288467178951872, + "fLiquidatedOfOriginal": 345288467178951872, + "PostMtM": 48406961864176648192, + "PostMM": 8067826977362642944, + "PostBM": -156319, + "PostFMax": 3398 + } + } + ] + }, + "liqs_same_price_same_amount": { + "StartTime": 0, + "IsForce": false, + "InitialPortfolio": { + "OptionExpiries": [ + 500400 + ], + "OptionStrikes": [ + 1500000000000000000000 + ], + "OptionIsCall": [ + 1 + ], + "OptionAmounts": [ + -1000000000000000000 + ], + "OptionVols": [ + 1047884494084986240 + ], + "SVIparams": [ + 1, + 1.5, + -0.1, + -0.05, + 0.05 + ], + "OptionVolConfidences": [ + 1000000000000000000 + ], + "Cash": 200000000000000000000, + "Perps": 0, + "Base": 0, + "SpotPrice": 1500000000000000000000, + "SpotConfidence": 1000000000000000000, + "PerpPrice": 1505000000000000000000, + "PerpConfidence": 1000000000000000000, + "FeedExpiries": [ + 500400 + ], + "Forwards": [ + 1500833279310993817600 + ], + "ForwardConfidences": [ + 1000000000000000000 + ], + "Rates": [ + 0 + ], + "RateConfidences": [ + 1000000000000000000 + ], + "StablePrice": 1000000000000000000, + "UnrealisedPerpPNL": 0, + "UnrealisedFunding": 0, + "VolShockUp": [ + 1.7370684514926746 + ], + "VolShockDown": [ + 0.508621032338217 + ], + "SettlementPrice": 1500833279310993817600, + "PercentFixed": 0, + "ForwardsFixed": [ + 0 + ], + "ForwardsVariable": [ + 1500833279310993817600 + ] + }, + "ActionCount": 3, + "LiquidationFee": 1.322084630165343, + "Actions": [ + { + "Time": 30, + "PortfolioAndFeeds": { + "OptionExpiries": [ + 500370 + ], + "OptionStrikes": [ + 1500000000000000000000 + ], + "OptionIsCall": [ + 1 + ], + "OptionAmounts": [ + -1000000000000000000 + ], + "OptionVols": [ + 1047884508458193792 + ], + "SVIparams": [ + 1, + 1.5, + -0.1, + -0.05, + 0.05 + ], + "OptionVolConfidences": [ + 1000000000000000000 + ], + "Cash": 198677915369834676224, + "Perps": 0, + "Base": 0, + "SpotPrice": 1500000000000000000000, + "SpotConfidence": 1000000000000000000, + "PerpPrice": 1505000000000000000000, + "PerpConfidence": 1000000000000000000, + "FeedExpiries": [ + 500370 + ], + "Forwards": [ + 1500833229340328329216 + ], + "ForwardConfidences": [ + 1000000000000000000 + ], + "Rates": [ + 0 + ], + "RateConfidences": [ + 1000000000000000000 + ], + "StablePrice": 1000000000000000000, + "UnrealisedPerpPNL": 0, + "UnrealisedFunding": 0, + "VolShockUp": [ + 1.737081708636119 + ], + "VolShockDown": [ + 0.5086121942425874 + ], + "SettlementPrice": 1500833229340328329216, + "PercentFixed": 0, + "ForwardsFixed": [ + 0 + ], + "ForwardsVariable": [ + 1500833229340328329216 + ] + }, + "Liquidator": { + "PercentWant": 190620509120774976 + }, + "Results": { + "PreMtM": 119308718797352435712, + "PreMM": -103087867828868841472, + "PreBM": -147567185154113110016, + "PreFMax": 571861527362324864, + "ExpectedBidPrice": 21059729754440994816, + "FinalPercentageReceived": 190620509120774976, + "fLiquidatedOfOriginal": 190620509120774976, + "PostMtM": 117625759832094736384, + "PostMM": -62377476224713719808, + "PostBM": -98378123436075417600, + "PostFMax": 471028760349993216 + } + }, + { + "Time": 30, + "PortfolioAndFeeds": { + "OptionExpiries": [ + 500370 + ], + "OptionStrikes": [ + 1500000000000000000000 + ], + "OptionIsCall": [ + 1 + ], + "OptionAmounts": [ + -809379490879224960 + ], + "OptionVols": [ + 1047884508458193792 + ], + "SVIparams": [ + 1, + 1.5, + -0.1, + -0.05, + 0.05 + ], + "OptionVolConfidences": [ + 1000000000000000000 + ], + "Cash": 181865559745423540224, + "Perps": 0, + "Base": 0, + "SpotPrice": 1500000000000000000000, + "SpotConfidence": 1000000000000000000, + "PerpPrice": 1505000000000000000000, + "PerpConfidence": 1000000000000000000, + "FeedExpiries": [ + 500370 + ], + "Forwards": [ + 1500833229340328329216 + ], + "ForwardConfidences": [ + 1000000000000000000 + ], + "Rates": [ + 0 + ], + "RateConfidences": [ + 1000000000000000000 + ], + "StablePrice": 1000000000000000000, + "UnrealisedPerpPNL": 0, + "UnrealisedFunding": 0, + "VolShockUp": [ + 1.737081708636119 + ], + "VolShockDown": [ + 0.5086121942425874 + ], + "SettlementPrice": 1500833229340328329216, + "PercentFixed": 0, + "ForwardsFixed": [ + 0 + ], + "ForwardsVariable": [ + 1500833229340328329216 + ] + }, + "Liquidator": { + "PercentWant": 190620509120774976 + }, + "Results": { + "PreMtM": 117625759832094736384, + "PreMM": -62377476224713719808, + "PreBM": -98378123436075417600, + "PreFMax": 471028760349993216, + "ExpectedBidPrice": 21059729754440994816, + "FinalPercentageReceived": 235514380174996576, + "fLiquidatedOfOriginal": 190620509120774976, + "PostMtM": 115942800866837053440, + "PostMM": -21667084620558540800, + "PostBM": -49189061718037659648, + "PostFMax": 308069078171682880 + } + }, + { + "Time": 30, + "PortfolioAndFeeds": { + "OptionExpiries": [ + 500370 + ], + "OptionStrikes": [ + 1500000000000000000000 + ], + "OptionIsCall": [ + 1 + ], + "OptionAmounts": [ + -618758981758450048 + ], + "OptionVols": [ + 1047884508458193792 + ], + "SVIparams": [ + 1, + 1.5, + -0.1, + -0.05, + 0.05 + ], + "OptionVolConfidences": [ + 1000000000000000000 + ], + "Cash": 165053204121012404224, + "Perps": 0, + "Base": 0, + "SpotPrice": 1500000000000000000000, + "SpotConfidence": 1000000000000000000, + "PerpPrice": 1505000000000000000000, + "PerpConfidence": 1000000000000000000, + "FeedExpiries": [ + 500370 + ], + "Forwards": [ + 1500833229340328329216 + ], + "ForwardConfidences": [ + 1000000000000000000 + ], + "Rates": [ + 0 + ], + "RateConfidences": [ + 1000000000000000000 + ], + "StablePrice": 1000000000000000000, + "UnrealisedPerpPNL": 0, + "UnrealisedFunding": 0, + "VolShockUp": [ + 1.737081708636119 + ], + "VolShockDown": [ + 0.5086121942425874 + ], + "SettlementPrice": 1500833229340328329216, + "PercentFixed": 0, + "ForwardsFixed": [ + 0 + ], + "ForwardsVariable": [ + 1500833229340328329216 + ] + }, + "Liquidator": { + "PercentWant": 190620509120774976 + }, + "Results": { + "PreMtM": 115942800866837053440, + "PreMM": -21667084620558540800, + "PreBM": -49189061718037659648, + "PreFMax": 308069078171682880, + "ExpectedBidPrice": 21059729754440986624, + "FinalPercentageReceived": 308069078171682880, + "fLiquidatedOfOriginal": 190620509120774816, + "PostMtM": 114259841901579370496, + "PostMM": 19043306983596552192, + "PostBM": -14210, + "PostFMax": 128 + } + } + ] + }, + "perp": { + "StartTime": 0, + "IsForce": false, + "InitialPortfolio": { + "OptionExpiries": [], + "OptionStrikes": [], + "OptionIsCall": [], + "OptionAmounts": [], + "OptionVols": [], + "SVIparams": [ + 1, + 1.5, + -0.1, + -0.05, + 0.05 + ], + "OptionVolConfidences": [], + "Cash": 100000000000000000000, + "Perps": 1000000000000000000, + "Base": 0, + "SpotPrice": 1500000000000000000000, + "SpotConfidence": 1000000000000000000, + "PerpPrice": 1505000000000000000000, + "PerpConfidence": 1000000000000000000, + "FeedExpiries": [], + "Forwards": [], + "ForwardConfidences": [], + "Rates": [], + "RateConfidences": [], + "StablePrice": 1000000000000000000, + "UnrealisedPerpPNL": -50000000000000000000, + "UnrealisedFunding": 0, + "VolShockUp": [], + "VolShockDown": [], + "SettlementPrice": null, + "PercentFixed": null, + "ForwardsFixed": [], + "ForwardsVariable": [] + }, + "ActionCount": 1, + "LiquidationFee": 0.8370804822417725, + "Actions": [ + { + "Time": 0, + "PortfolioAndFeeds": { + "OptionExpiries": [], + "OptionStrikes": [], + "OptionIsCall": [], + "OptionAmounts": [], + "OptionVols": [], + "SVIparams": [ + 1, + 1.5, + -0.1, + -0.05, + 0.05 + ], + "OptionVolConfidences": [], + "Cash": 99162919517758226432, + "Perps": 1000000000000000000, + "Base": 0, + "SpotPrice": 1500000000000000000000, + "SpotConfidence": 1000000000000000000, + "PerpPrice": 1505000000000000000000, + "PerpConfidence": 1000000000000000000, + "FeedExpiries": [], + "Forwards": [], + "ForwardConfidences": [], + "Rates": [], + "RateConfidences": [], + "StablePrice": 1000000000000000000, + "UnrealisedPerpPNL": -50000000000000000000, + "UnrealisedFunding": 0, + "VolShockUp": [], + "VolShockDown": [], + "SettlementPrice": null, + "PercentFixed": null, + "ForwardsFixed": [], + "ForwardsVariable": [] + }, + "Liquidator": { + "PercentWant": 1000000000000000000 + }, + "Results": { + "PreMtM": 49162919517758226432, + "PreMM": -206587080482241773568, + "PreBM": -257737080482241773568, + "PreFMax": 842507275430904192, + "ExpectedBidPrice": 40591715027632594944, + "FinalPercentageReceived": 842507275430904192, + "fLiquidatedOfOriginal": 842507275430904192, + "PostMtM": 48334517170255519744, + "PostMM": 8055752861709265920, + "PostBM": 14210, + "PostFMax": -294 + } + } + ] + }, + "test_Nov_04_general": { + "StartTime": 0, + "IsForce": false, + "InitialPortfolio": { + "OptionExpiries": [ + 1191600, + 500400, + 7758000, + 500400, + 2487600, + 1191600 + ], + "OptionStrikes": [ + 1600000000000000000000, + 1200000000000000000000, + 1900000000000000000000, + 1150000000000000000000, + 1550000000000000000000, + 1000000000000000000000 + ], + "OptionIsCall": [ + 1, + 0, + 1, + 0, + 1, + 1 + ], + "OptionAmounts": [ + -1000000000000000000, + -21000000000000000000, + -3000000000000000000, + 7000000000000000000, + -2000000000000000000, + -1600000000000000000 + ], + "OptionVols": [ + 1081048412239005184, + 1138939398828297472, + 1175456212663501056, + 1168496420216719616, + 1062799243592622592, + 1262509093212846848 + ], + "SVIparams": [ + 1, + 1.5, + -0.1, + -0.05, + 0.05 + ], + "OptionVolConfidences": [ + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000 + ], + "Cash": -4200000000000000000000, + "Perps": 1000000000000000000, + "Base": 5000000000000000000, + "SpotPrice": 1500000000000000000000, + "SpotConfidence": 1000000000000000000, + "PerpPrice": 1505000000000000000000, + "PerpConfidence": 1000000000000000000, + "FeedExpiries": [ + 1191600, + 500400, + 7758000, + 500400, + 2487600, + 1191600 + ], + "Forwards": [ + 1501985045187195830272, + 1500833279310993817600, + 1512971000787409567744, + 1500833279310993817600, + 1504146989085687808000, + 1501985045187195830272 + ], + "ForwardConfidences": [ + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000 + ], + "Rates": [ + 0, + 0, + 0, + 0, + 0, + 0 + ], + "RateConfidences": [ + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000 + ], + "StablePrice": 1000000000000000000, + "UnrealisedPerpPNL": -63000000000000000000, + "UnrealisedFunding": 0, + "VolShockUp": [ + 1.5681511166375728, + 1.7370684514926746, + 1.3902272493224166, + 1.7370684514926746, + 1.4555844040146944, + 1.5681511166375728 + ], + "VolShockDown": [ + 0.6212325889082848, + 0.508621032338217, + 0.7398485004517223, + 0.508621032338217, + 0.6962770639902038, + 0.6212325889082848 + ], + "SettlementPrice": 1500833279310993817600, + "PercentFixed": 0, + "ForwardsFixed": [ + 0, + 0, + 0, + 0, + 0, + 0 + ], + "ForwardsVariable": [ + 1501985045187195830272, + 1500833279310993817600, + 1512971000787409567744, + 1500833279310993817600, + 1504146989085687808000, + 1501985045187195830272 + ] + }, + "ActionCount": 3, + "LiquidationFee": 16.264543471042824, + "Actions": [ + { + "Time": 1, + "PortfolioAndFeeds": { + "OptionExpiries": [ + 1191599, + 500399, + 7757999, + 500399, + 2487599, + 1191599 + ], + "OptionStrikes": [ + 1600000000000000000000, + 1200000000000000000000, + 1900000000000000000000, + 1150000000000000000000, + 1550000000000000000000, + 1000000000000000000000 + ], + "OptionIsCall": [ + 1, + 0, + 1, + 0, + 1, + 1 + ], + "OptionAmounts": [ + -1000000000000000000, + -21000000000000000000, + -3000000000000000000, + 7000000000000000000, + -2000000000000000000, + -1600000000000000000 + ], + "OptionVols": [ + 1077307287018514688, + 1143578187182830720, + 1171703284439064064, + 1173072277125157120, + 1059335143046964608, + 1266806217053655296 + ], + "SVIparams": [ + 1, + 1.5, + -0.1, + -0.05, + 0.05 + ], + "OptionVolConfidences": [ + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000 + ], + "Cash": -4216264543471042822144, + "Perps": 1000000000000000000, + "Base": 5000000000000000000, + "SpotPrice": 1510000000000000000000, + "SpotConfidence": 1000000000000000000, + "PerpPrice": 1515000000000000000000, + "PerpConfidence": 1000000000000000000, + "FeedExpiries": [ + 1191599, + 500399, + 7757999, + 500399, + 2487599, + 1191599 + ], + "Forwards": [ + 1511998277143696769024, + 1510838832829607444480, + 1523057472435638239232, + 1510838832829607444480, + 1514174633999096872960, + 1511998277143696769024 + ], + "ForwardConfidences": [ + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000 + ], + "Rates": [ + 0, + 0, + 0, + 0, + 0, + 0 + ], + "RateConfidences": [ + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000 + ], + "StablePrice": 1000000000000000000, + "UnrealisedPerpPNL": -53000000000000000000, + "UnrealisedFunding": 0, + "VolShockUp": [ + 1.5681512596767035, + 1.7370688933808094, + 1.3902272558614146, + 1.7370688933808094, + 1.4555844589573526, + 1.5681512596767035 + ], + "VolShockDown": [ + 0.6212324935488645, + 0.5086207377461271, + 0.7398484960923903, + 0.5086207377461271, + 0.6962770273617649, + 0.6212324935488645 + ], + "SettlementPrice": 1510838832829607444480, + "PercentFixed": 0, + "ForwardsFixed": [ + 0, + 0, + 0, + 0, + 0, + 0 + ], + "ForwardsVariable": [ + 1511998277143696769024, + 1510838832829607444480, + 1523057472435638239232, + 1510838832829607444480, + 1514174633999096872960, + 1511998277143696769024 + ] + }, + "Liquidator": { + "PercentWant": 212000000000000000 + }, + "Results": { + "PreMtM": 1267017661980376825856, + "PreMM": -1672178334671392735232, + "PreBM": -2260017534001746804736, + "PreFMax": 645827386460660352, + "ExpectedBidPrice": 262752095513231392768, + "FinalPercentageReceived": 212000000000000000, + "fLiquidatedOfOriginal": 212000000000000000, + "PostMtM": 1261162013153768505344, + "PostMM": -1054924432207826386944, + "PostBM": -1518141721280145522688, + "PostFMax": 550542368604898816 + } + }, + { + "Time": 300, + "PortfolioAndFeeds": { + "OptionExpiries": [ + 1191300, + 500100, + 7757700, + 500100, + 2487300, + 1191300 + ], + "OptionStrikes": [ + 1600000000000000000000, + 1200000000000000000000, + 1900000000000000000000, + 1150000000000000000000, + 1550000000000000000000, + 1000000000000000000000 + ], + "OptionIsCall": [ + 1, + 0, + 1, + 0, + 1, + 1 + ], + "OptionAmounts": [ + -788000000000000000, + -16548000000000002048, + -2364000000000000000, + 5516000000000000000, + -1576000000000000000, + -1260800000000000256 + ], + "OptionVols": [ + 1073625031002286976, + 1148178475668307328, + 1167966725683237376, + 1177605942516402432, + 1055994002402481024, + 1271061686714528000 + ], + "SVIparams": [ + 1, + 1.5, + -0.1, + -0.05, + 0.05 + ], + "OptionVolConfidences": [ + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000 + ], + "Cash": -3059664364741950701568, + "Perps": 788000000000000000, + "Base": 3940000000000000512, + "SpotPrice": 1520000000000000000000, + "SpotConfidence": 1000000000000000000, + "PerpPrice": 1525000000000000000000, + "PerpConfidence": 1000000000000000000, + "FeedExpiries": [ + 1191300, + 500100, + 7757700, + 500100, + 2487300, + 1191300 + ], + "Forwards": [ + 1522011005698423914496, + 1520843883332469784576, + 1533143437000065679360, + 1520843883332469784576, + 1524201774786140176384, + 1522011005698423914496 + ], + "ForwardConfidences": [ + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000 + ], + "Rates": [ + 0, + 0, + 0, + 0, + 0, + 0 + ], + "RateConfidences": [ + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000 + ], + "StablePrice": 1000000000000000000, + "UnrealisedPerpPNL": -33884000000000000000, + "UnrealisedFunding": 0, + "VolShockUp": [ + 1.5681940353769965, + 1.7372010694442017, + 1.3902292110645202, + 1.7372010694442017, + 1.455600888100079, + 1.5681940353769965 + ], + "VolShockDown": [ + 0.6212039764153356, + 0.5085326203705323, + 0.7398471926236532, + 0.5085326203705323, + 0.6962660745999473, + 0.6212039764153356 + ], + "SettlementPrice": 1520843883332469784576, + "PercentFixed": 0, + "ForwardsFixed": [ + 0, + 0, + 0, + 0, + 0, + 0 + ], + "ForwardsVariable": [ + 1522011005698423914496, + 1520843883332469784576, + 1533143437000065679360, + 1520843883332469784576, + 1524201774786140176384, + 1522011005698423914496 + ] + }, + "Liquidator": { + "PercentWant": 140000000000000016 + }, + "Results": { + "PreMtM": 1282139939925138604032, + "PreMM": -1010205953757457809408, + "PreBM": -1468675132493976829952, + "PreFMax": 579219426304514560, + "ExpectedBidPrice": 142875284453671190528, + "FinalPercentageReceived": 177664974619289344, + "fLiquidatedOfOriginal": 140000000000000016, + "PostMtM": 1243905708874155950080, + "PostMM": -641170609788690366464, + "PostBM": -1018185873521259446272, + "PostFMax": 488310043098700096 + } + }, + { + "Time": 8000, + "PortfolioAndFeeds": { + "OptionExpiries": [ + 1183600, + 492400, + 7750000, + 492400, + 2479600, + 1183600 + ], + "OptionStrikes": [ + 1600000000000000000000, + 1200000000000000000000, + 1900000000000000000000, + 1150000000000000000000, + 1550000000000000000000, + 1000000000000000000000 + ], + "OptionIsCall": [ + 1, + 0, + 1, + 0, + 1, + 1 + ], + "OptionAmounts": [ + -648000000000000000, + -13608000000000002048, + -1944000000000000000, + 4536000000000000512, + -1296000000000000000, + -1036800000000000128 + ], + "OptionVols": [ + 1092574198714486144, + 1124794262461757312, + 1186817279412732672, + 1154508913406808832, + 1073774576826392448, + 1249356163864710912 + ], + "SVIparams": [ + 1, + 1.5, + -0.1, + -0.05, + 0.05 + ], + "OptionVolConfidences": [ + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000 + ], + "Cash": -2326512044202333569024, + "Perps": 648000000000000000, + "Base": 3240000000000000000, + "SpotPrice": 1470000000000000000000, + "SpotConfidence": 1000000000000000000, + "PerpPrice": 1475000000000000000000, + "PerpConfidence": 1000000000000000000, + "FeedExpiries": [ + 1183600, + 492400, + 7750000, + 492400, + 2479600, + 1183600 + ], + "Forwards": [ + 1471932275318880206848, + 1470803554781864656896, + 1482698416216880447488, + 1470803554781864656896, + 1474050961528051204096, + 1471932275318880206848 + ], + "ForwardConfidences": [ + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000 + ], + "Rates": [ + 0, + 0, + 0, + 0, + 0, + 0 + ], + "RateConfidences": [ + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000 + ], + "StablePrice": 1000000000000000000, + "UnrealisedPerpPNL": -60264000000000000000, + "UnrealisedFunding": 0, + "VolShockUp": [ + 1.5693004485466155, + 1.7406407439213831, + 1.390279591802785, + 1.7406407439213831, + 1.4560248662409134, + 1.5693004485466155 + ], + "VolShockDown": [ + 0.6204663676355897, + 0.5062395040524114, + 0.7398136054648099, + 0.5062395040524114, + 0.6959834225060578, + 0.6204663676355897 + ], + "SettlementPrice": 1470803554781864656896, + "PercentFixed": 0, + "ForwardsFixed": [ + 0, + 0, + 0, + 0, + 0, + 0 + ], + "ForwardsVariable": [ + 1471932275318880206848, + 1470803554781864656896, + 1482698416216880447488, + 1470803554781864656896, + 1474050961528051204096, + 1471932275318880206848 + ] + }, + "Liquidator": { + "PercentWant": 923900000000000000 + }, + "Results": { + "PreMtM": 1154588646360142053376, + "PreMM": -825252423175791443968, + "PreBM": -1221220637082977828864, + "PreFMax": 643660260808136960, + "ExpectedBidPrice": 174083218133451309056, + "FinalPercentageReceived": 643660260808136960, + "fLiquidatedOfOriginal": 417091849003672768, + "PostMtM": 846595260431728377856, + "PostMM": 141099210071954620416, + "PostBM": -113686, + "PostFMax": 168 + } + } + ] + } +} \ No newline at end of file diff --git a/test/integration-tests/liquidation/PM_liquidationSimTests.t.sol b/test/integration-tests/liquidation/PM_liquidationSimTests.t.sol index f0a8125c..837354ac 100644 --- a/test/integration-tests/liquidation/PM_liquidationSimTests.t.sol +++ b/test/integration-tests/liquidation/PM_liquidationSimTests.t.sol @@ -10,39 +10,39 @@ contract LiquidationSimTests_PM is LiquidationSimBase { using stdJson for string; function testLiquidationSim1() public { - runLiquidationSim("Test1"); + runLiquidationSim("PMRM_solvent", "Test1"); } function testLiquidationSim2() public { - runLiquidationSim("Test2"); + runLiquidationSim("PMRM_solvent", "Test2"); } function testLiquidationSim3() public { - runLiquidationSim("Test3"); + runLiquidationSim("PMRM_solvent", "Test3"); } function testLiquidationSim4() public { - runLiquidationSim("Test4"); + runLiquidationSim("PMRM_solvent", "Test4"); } function testLiquidationSim5() public { - runLiquidationSim("Test5"); + runLiquidationSim("PMRM_solvent", "Test5"); } function testLiquidationSim6() public { - runLiquidationSim("Test6"); + runLiquidationSim("PMRM_solvent", "Test6"); } function testLiquidationSimLong_Box_Short_Cash() public { - runLiquidationSim("Long_Box_Short_Cash"); + runLiquidationSim("PMRM_solvent", "Long_Box_Short_Cash"); } function testLiquidationSimSimple_Short_3_liquidators() public { - runLiquidationSim("Simple_Short_3_liquidators"); + runLiquidationSim("PMRM_solvent", "liqs_same_price_same_amount"); } - function testLiquidationSimPMRM_Other() public { - runLiquidationSim("PMRM_Other"); + function testLiquidationSimPMRM_perp() public { + runLiquidationSim("PMRM_solvent", "perp"); } // function testInsolventSim1() public { @@ -53,8 +53,8 @@ contract LiquidationSimTests_PM is LiquidationSimBase { // runLiquidationSim("InsolventTest2"); // } - function runLiquidationSim(string memory testName) internal { - LiquidationSim memory data = LiquidationSimBase.getTestData(testName); + function runLiquidationSim(string memory fileName, string memory testName) internal { + LiquidationSim memory data = LiquidationSimBase.getTestData(fileName, testName); setupTestScenario(data); vm.warp(data.StartTime); @@ -83,11 +83,11 @@ contract LiquidationSimTests_PM is LiquidationSimBase { IDutchAuction.Auction memory auctionDetails = auction.getAuction(aliceAcc); if (auctionDetails.insolvent) { - assertApproxEqAbs(int(cashToBidder), -data.Actions[actionId].Results.SMPayout, 1e6, "bid price insolvent"); + assertApproxEqRel(int(cashToBidder), -data.Actions[actionId].Results.SMPayout, 0.001e18, "bid price insolvent"); } else { - assertApproxEqAbs(int(cashFromBidder), data.Actions[actionId].Results.ExpectedBidPrice, 1e6, "bid price solvent"); - assertApproxEqAbs( - finalPercentage, data.Actions[actionId].Results.LiquidatedOfOriginal, 1e6, "liquidated of original" + assertApproxEqRel(int(cashFromBidder), data.Actions[actionId].Results.ExpectedBidPrice, 0.001e18, "bid price solvent"); + assertApproxEqRel( + finalPercentage, data.Actions[actionId].Results.LiquidatedOfOriginal, 0.001e18, "liquidated of original" ); } } @@ -104,7 +104,6 @@ contract LiquidationSimTests_PM is LiquidationSimBase { fMax = auction.getMaxProportion(aliceAcc, worstScenario); } - console2.log("pre mtm", mtm); assertApproxEqRel(mtm, data.Actions[actionId].Results.PreMtM, 0.001e18, "pre mtm"); assertApproxEqRel(mm, data.Actions[actionId].Results.PreMM, 0.001e18, "pre mm"); assertApproxEqRel(bm, data.Actions[actionId].Results.PreBM, 0.001e18, "pre bm"); @@ -117,7 +116,11 @@ contract LiquidationSimTests_PM is LiquidationSimBase { assertApproxEqRel(mtm, data.Actions[actionId].Results.PostMtM, 0.001e18, "post mtm"); assertApproxEqRel(mm, data.Actions[actionId].Results.PostMM, 0.001e18, "post mm"); - assertApproxEqRel(bm, data.Actions[actionId].Results.PostBM, 0.001e18, "post bm"); + if (data.Actions[actionId].Results.PostBM == 0) { + assertGt(bm, 0, "post bm"); + } else { + assertApproxEqRel(bm, data.Actions[actionId].Results.PostBM, 0.00001e18, "post bm"); + } IDutchAuction.Auction memory auctionDetails = auction.getAuction(aliceAcc); if (auctionDetails.insolvent) {} else { diff --git a/test/integration-tests/liquidation/util/LiquidationSimBase.sol b/test/integration-tests/liquidation/util/LiquidationSimBase.sol index c94425ac..831369b6 100644 --- a/test/integration-tests/liquidation/util/LiquidationSimBase.sol +++ b/test/integration-tests/liquidation/util/LiquidationSimBase.sol @@ -6,6 +6,12 @@ import "test/risk-managers/unit-tests/PMRM/utils/PMRMTestBase.sol"; import "lyra-utils/encoding/OptionEncoding.sol"; +contract TempReader { + function readInt(string memory json, string memory location) external pure returns (int) { + return stdJson.readInt(json, location); + } +} + contract LiquidationSimBase is PMRMTestBase { using stdJson for string; @@ -66,13 +72,17 @@ contract LiquidationSimBase is PMRMTestBase { int PostBM; uint PostFMax; int SMPayout; - int LowerBound; } - // uint PostFMax; - function getTestData(string memory testName) internal view returns (LiquidationSim memory sim) { + TempReader t; + + constructor() { + t = new TempReader(); + } + + function getTestData(string memory fileName, string memory testName) internal view returns (LiquidationSim memory sim) { testName = string.concat(".", testName); - string memory json = JsonMechIO.jsonFromRelPath("/test/integration-tests/liquidation/liquidationTests.json"); + string memory json = JsonMechIO.jsonFromRelPath(string.concat("/test/integration-tests/liquidation/", fileName, ".json")); sim.StartTime = json.readUint(string.concat(testName, ".StartTime")); sim.IsForce = json.readBool(string.concat(testName, ".IsForce")); sim.InitialPortfolio.Cash = json.readInt(string.concat(testName, ".InitialPortfolio.Cash")); @@ -86,8 +96,8 @@ contract LiquidationSimBase is PMRMTestBase { sim.InitialPortfolio.initialFeeds.StablePrice = json.readUint(string.concat(testName, ".InitialPortfolio.StablePrice")); - sim.InitialPortfolio.initialFeeds.StableConfidence = - json.readUint(string.concat(testName, ".InitialPortfolio.StableConfidence")); + // TODO: no stable confidence + sim.InitialPortfolio.initialFeeds.StableConfidence = 1e18; sim.InitialPortfolio.initialFeeds.SpotPrice = json.readUint(string.concat(testName, ".InitialPortfolio.SpotPrice")); sim.InitialPortfolio.initialFeeds.SpotConfidence = json.readUint(string.concat(testName, ".InitialPortfolio.SpotConfidence")); @@ -118,7 +128,7 @@ contract LiquidationSimBase is PMRMTestBase { function getActionData(string memory json, string memory testName, uint actionNum) internal - pure + view returns (LiquidationAction memory action) { // E.g. Test1.Actions[0] @@ -127,7 +137,8 @@ contract LiquidationSimBase is PMRMTestBase { action.Time = json.readUint(string.concat(baseActionIndex, ".Time")); action.Feeds.StablePrice = json.readUint(string.concat(baseActionIndex, ".PortfolioAndFeeds.StablePrice")); - action.Feeds.StableConfidence = json.readUint(string.concat(baseActionIndex, ".PortfolioAndFeeds.StableConfidence")); + // TODO: no stable confidence + action.Feeds.StableConfidence = 1e18; action.Feeds.SpotPrice = json.readUint(string.concat(baseActionIndex, ".PortfolioAndFeeds.SpotPrice")); action.Feeds.SpotConfidence = json.readUint(string.concat(baseActionIndex, ".PortfolioAndFeeds.SpotConfidence")); action.Feeds.FeedExpiries = json.readUintArray(string.concat(baseActionIndex, ".PortfolioAndFeeds.FeedExpiries")); @@ -156,12 +167,20 @@ contract LiquidationSimBase is PMRMTestBase { action.Results.PostMM = json.readInt(string.concat(baseActionIndex, ".Results.PostMM")); action.Results.PostBM = json.readInt(string.concat(baseActionIndex, ".Results.PostBM")); action.Results.PostFMax = json.readUint(string.concat(baseActionIndex, ".Results.PostFMax")); - action.Results.LowerBound = json.readInt(string.concat(baseActionIndex, ".Results.Lowerbound")); - action.Results.SMPayout = json.readInt(string.concat(baseActionIndex, ".Results.SMPayout")); + + action.Results.SMPayout = getSMPayout(json, string.concat(baseActionIndex, ".Results.SMPayout")); return action; } + function getSMPayout(string memory json, string memory location) internal view returns (int) { + try t.readInt(json, location) returns (int payout) { + return payout; + } catch { + return 0; + } + } + function lookupNum(uint num) internal pure returns (string memory) { // return the string version of num if (num == 0) { From 6dc0dad87f92e67f9126c37bb451d677117bfc7b Mon Sep 17 00:00:00 2001 From: Dominic Romanowski Date: Thu, 16 Nov 2023 16:15:45 +1100 Subject: [PATCH 04/14] more tests --- .../liquidation/PMRM_insolvent.json | 1946 +++++++++++++++++ .../liquidation/PMRM_solvent.json | 8 +- .../liquidation/PM_liquidationSimTests.t.sol | 30 +- 3 files changed, 1977 insertions(+), 7 deletions(-) create mode 100644 test/integration-tests/liquidation/PMRM_insolvent.json diff --git a/test/integration-tests/liquidation/PMRM_insolvent.json b/test/integration-tests/liquidation/PMRM_insolvent.json new file mode 100644 index 00000000..549389a6 --- /dev/null +++ b/test/integration-tests/liquidation/PMRM_insolvent.json @@ -0,0 +1,1946 @@ +{ + "test_Nov_01_Insolvent_basic": { + "StartTime": 0, + "IsForce": false, + "InitialPortfolio": { + "OptionExpiries": [ + 500400 + ], + "OptionStrikes": [ + 1500000000000000000000 + ], + "OptionIsCall": [ + 1 + ], + "OptionAmounts": [ + -1000000000000000000 + ], + "OptionVols": [ + 1047884494084986240 + ], + "SVIparams": [ + 1, + 1.5, + -0.1, + -0.05, + 0.05 + ], + "OptionVolConfidences": [ + 1000000000000000000 + ], + "Cash": 50000000000000000000, + "Perps": 0, + "Base": 0, + "SpotPrice": 1500000000000000000000, + "SpotConfidence": 1000000000000000000, + "PerpPrice": 1505000000000000000000, + "PerpConfidence": 1000000000000000000, + "FeedExpiries": [ + 500400 + ], + "Forwards": [ + 1500833279310993817600 + ], + "ForwardConfidences": [ + 1000000000000000000 + ], + "Rates": [ + 0 + ], + "RateConfidences": [ + 1000000000000000000 + ], + "StablePrice": 1000000000000000000, + "UnrealisedPerpPNL": 0, + "UnrealisedFunding": 0, + "VolShockUp": [ + 1.7370684514926746 + ], + "VolShockDown": [ + 0.508621032338217 + ], + "SettlementPrice": 1500833279310993817600, + "PercentFixed": 0, + "ForwardsFixed": [ + 0 + ], + "ForwardsVariable": [ + 1500833279310993817600 + ] + }, + "ActionCount": 1, + "LiquidationFee": 0, + "Actions": [ + { + "Time": 0, + "PortfolioAndFeeds": { + "OptionExpiries": [ + 500400 + ], + "OptionStrikes": [ + 1500000000000000000000 + ], + "OptionIsCall": [ + 1 + ], + "OptionAmounts": [ + -1000000000000000000 + ], + "OptionVols": [ + 1047884494084986240 + ], + "SVIparams": [ + 1, + 1.5, + -0.1, + -0.05, + 0.05 + ], + "OptionVolConfidences": [ + 1000000000000000000 + ], + "Cash": 50000000000000000000, + "Perps": 0, + "Base": 0, + "SpotPrice": 1500000000000000000000, + "SpotConfidence": 1000000000000000000, + "PerpPrice": 1505000000000000000000, + "PerpConfidence": 1000000000000000000, + "FeedExpiries": [ + 500400 + ], + "Forwards": [ + 1500833279310993817600 + ], + "ForwardConfidences": [ + 1000000000000000000 + ], + "Rates": [ + 0 + ], + "RateConfidences": [ + 1000000000000000000 + ], + "StablePrice": 1000000000000000000, + "UnrealisedPerpPNL": 0, + "UnrealisedFunding": 0, + "VolShockUp": [ + 1.7370684514926746 + ], + "VolShockDown": [ + 0.508621032338217 + ], + "SettlementPrice": 1500833279310993817600, + "PercentFixed": 0, + "ForwardsFixed": [ + 0 + ], + "ForwardsVariable": [ + 1500833279310993817600 + ] + }, + "Liquidator": { + "PercentWant": 1000000000000000000 + }, + "Results": { + "PreMtM": -29371585189059944448, + "PreMM": -251768534860364283904, + "PreBM": -296247924794625163264, + "PostMtM": 0, + "PostMM": 0, + "PostBM": 0, + "SMPayout": -29371585189059944448, + "PercentageReceived": 1000000000000000000, + "PercentReceivedCurrent": 1000000000000000000, + "LiqPrice": -29371585189059944448 + } + } + ] + }, + "test_Nov_02_Insolvent_basic_mtm_pos": { + "StartTime": 0, + "IsForce": false, + "InitialPortfolio": { + "OptionExpiries": [ + 500400 + ], + "OptionStrikes": [ + 1500000000000000000000 + ], + "OptionIsCall": [ + 1 + ], + "OptionAmounts": [ + -1000000000000000000 + ], + "OptionVols": [ + 1047884494084986240 + ], + "SVIparams": [ + 1, + 1.5, + -0.1, + -0.05, + 0.05 + ], + "OptionVolConfidences": [ + 1000000000000000000 + ], + "Cash": 90000000000000000000, + "Perps": 0, + "Base": 0, + "SpotPrice": 1500000000000000000000, + "SpotConfidence": 1000000000000000000, + "PerpPrice": 1505000000000000000000, + "PerpConfidence": 1000000000000000000, + "FeedExpiries": [ + 500400 + ], + "Forwards": [ + 1500833279310993817600 + ], + "ForwardConfidences": [ + 1000000000000000000 + ], + "Rates": [ + 0 + ], + "RateConfidences": [ + 1000000000000000000 + ], + "StablePrice": 1000000000000000000, + "UnrealisedPerpPNL": 0, + "UnrealisedFunding": 0, + "VolShockUp": [ + 1.7370684514926746 + ], + "VolShockDown": [ + 0.508621032338217 + ], + "SettlementPrice": 1500833279310993817600, + "PercentFixed": 0, + "ForwardsFixed": [ + 0 + ], + "ForwardsVariable": [ + 1500833279310993817600 + ] + }, + "ActionCount": 1, + "LiquidationFee": 0, + "Actions": [ + { + "Time": 0, + "PortfolioAndFeeds": { + "OptionExpiries": [ + 500400 + ], + "OptionStrikes": [ + 1500000000000000000000 + ], + "OptionIsCall": [ + 1 + ], + "OptionAmounts": [ + -1000000000000000000 + ], + "OptionVols": [ + 1047884494084986240 + ], + "SVIparams": [ + 1, + 1.5, + -0.1, + -0.05, + 0.05 + ], + "OptionVolConfidences": [ + 1000000000000000000 + ], + "Cash": 90000000000000000000, + "Perps": 0, + "Base": 0, + "SpotPrice": 1500000000000000000000, + "SpotConfidence": 1000000000000000000, + "PerpPrice": 1505000000000000000000, + "PerpConfidence": 1000000000000000000, + "FeedExpiries": [ + 500400 + ], + "Forwards": [ + 1500833279310993817600 + ], + "ForwardConfidences": [ + 1000000000000000000 + ], + "Rates": [ + 0 + ], + "RateConfidences": [ + 1000000000000000000 + ], + "StablePrice": 1000000000000000000, + "UnrealisedPerpPNL": 0, + "UnrealisedFunding": 0, + "VolShockUp": [ + 1.7370684514926746 + ], + "VolShockDown": [ + 0.508621032338217 + ], + "SettlementPrice": 1500833279310993817600, + "PercentFixed": 0, + "ForwardsFixed": [ + 0 + ], + "ForwardsVariable": [ + 1500833279310993817600 + ] + }, + "Liquidator": { + "PercentWant": 1000000000000000000 + }, + "Results": { + "PreMtM": 10628414810940057600, + "PreMM": -211768534860364283904, + "PreBM": -256247924794625130496, + "PostMtM": 0, + "PostMM": 0, + "PostBM": 0, + "SMPayout": 0, + "PercentageReceived": 1000000000000000000, + "PercentReceivedCurrent": 1000000000000000000, + "LiqPrice": 0 + } + } + ] + }, + "test_Nov_03_Insolvent_basic_at_end": { + "StartTime": 0, + "IsForce": false, + "InitialPortfolio": { + "OptionExpiries": [ + 500400 + ], + "OptionStrikes": [ + 1500000000000000000000 + ], + "OptionIsCall": [ + 1 + ], + "OptionAmounts": [ + -1000000000000000000 + ], + "OptionVols": [ + 1047884494084986240 + ], + "SVIparams": [ + 1, + 1.5, + -0.1, + -0.05, + 0.05 + ], + "OptionVolConfidences": [ + 1000000000000000000 + ], + "Cash": 90000000000000000000, + "Perps": 0, + "Base": 0, + "SpotPrice": 1500000000000000000000, + "SpotConfidence": 1000000000000000000, + "PerpPrice": 1505000000000000000000, + "PerpConfidence": 1000000000000000000, + "FeedExpiries": [ + 500400 + ], + "Forwards": [ + 1500833279310993817600 + ], + "ForwardConfidences": [ + 1000000000000000000 + ], + "Rates": [ + 0 + ], + "RateConfidences": [ + 1000000000000000000 + ], + "StablePrice": 1000000000000000000, + "UnrealisedPerpPNL": 0, + "UnrealisedFunding": 0, + "VolShockUp": [ + 1.7370684514926746 + ], + "VolShockDown": [ + 0.508621032338217 + ], + "SettlementPrice": 1500833279310993817600, + "PercentFixed": 0, + "ForwardsFixed": [ + 0 + ], + "ForwardsVariable": [ + 1500833279310993817600 + ] + }, + "ActionCount": 1, + "LiquidationFee": 0, + "Actions": [ + { + "Time": 100, + "PortfolioAndFeeds": { + "OptionExpiries": [ + 500300 + ], + "OptionStrikes": [ + 1500000000000000000000 + ], + "OptionIsCall": [ + 1 + ], + "OptionAmounts": [ + -1000000000000000000 + ], + "OptionVols": [ + 1047884541995699200 + ], + "SVIparams": [ + 1, + 1.5, + -0.1, + -0.05, + 0.05 + ], + "OptionVolConfidences": [ + 1000000000000000000 + ], + "Cash": 90000000000000000000, + "Perps": 0, + "Base": 0, + "SpotPrice": 1500000000000000000000, + "SpotConfidence": 1000000000000000000, + "PerpPrice": 1505000000000000000000, + "PerpConfidence": 1000000000000000000, + "FeedExpiries": [ + 500300 + ], + "Forwards": [ + 1500833112742114623488 + ], + "ForwardConfidences": [ + 1000000000000000000 + ], + "Rates": [ + 0 + ], + "RateConfidences": [ + 1000000000000000000 + ], + "StablePrice": 1000000000000000000, + "UnrealisedPerpPNL": 0, + "UnrealisedFunding": 0, + "VolShockUp": [ + 1.7371126459895851 + ], + "VolShockDown": [ + 0.5085915693402766 + ], + "SettlementPrice": 1500833112742114623488, + "PercentFixed": 0, + "ForwardsFixed": [ + 0 + ], + "ForwardsVariable": [ + 1500833112742114623488 + ] + }, + "Liquidator": { + "PercentWant": 1000000000000000000 + }, + "Results": { + "PreMtM": 10636377142865967104, + "PreMM": -211759362378998743040, + "PreBM": -256238510283371675648, + "PostMtM": 0, + "PostMM": 0, + "PostBM": 0, + "SMPayout": -211759362378998743040, + "PercentageReceived": 1000000000000000000, + "PercentReceivedCurrent": 1000000000000000000, + "LiqPrice": -211759362378998743040 + } + } + ] + }, + "test_Nov_04_Insolvent_two_liq_same_disc_same_amount": { + "StartTime": 0, + "IsForce": false, + "InitialPortfolio": { + "OptionExpiries": [ + 500400, + 500400, + 500400, + 500400, + 7758000 + ], + "OptionStrikes": [ + 1500000000000000000000, + 2500000000000000000000, + 1500000000000000000000, + 2500000000000000000000, + 600000000000000000000 + ], + "OptionIsCall": [ + 1, + 1, + 0, + 0, + 1 + ], + "OptionAmounts": [ + 410000000000000000, + -410000000000000000, + -1000000000000000000, + 410000000000000000, + 410000000000000000 + ], + "OptionVols": [ + 1047884494084986240, + 1326538658030860032, + 1047884494084986240, + 1326538658030860032, + 1563882292297486080 + ], + "SVIparams": [ + 1, + 1.5, + -0.1, + -0.05, + 0.05 + ], + "OptionVolConfidences": [ + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000 + ], + "Cash": -3000000000000000000000, + "Perps": 0, + "Base": 1000000000000000000, + "SpotPrice": 1500000000000000000000, + "SpotConfidence": 1000000000000000000, + "PerpPrice": 1505000000000000000000, + "PerpConfidence": 1000000000000000000, + "FeedExpiries": [ + 500400, + 500400, + 500400, + 500400, + 7758000 + ], + "Forwards": [ + 1500833279310993817600, + 1500833279310993817600, + 1500833279310993817600, + 1500833279310993817600, + 1512971000787409567744 + ], + "ForwardConfidences": [ + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000 + ], + "Rates": [ + 0, + 0, + 0, + 0, + 0 + ], + "RateConfidences": [ + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000 + ], + "StablePrice": 1000000000000000000, + "UnrealisedPerpPNL": 0, + "UnrealisedFunding": 0, + "VolShockUp": [ + 1.7370684514926746, + 1.7370684514926746, + 1.7370684514926746, + 1.7370684514926746, + 1.3902272493224166 + ], + "VolShockDown": [ + 0.508621032338217, + 0.508621032338217, + 0.508621032338217, + 0.508621032338217, + 0.7398485004517223 + ], + "SettlementPrice": 1500833279310993817600, + "PercentFixed": 0, + "ForwardsFixed": [ + 0, + 0, + 0, + 0, + 0 + ], + "ForwardsVariable": [ + 1500833279310993817600, + 1500833279310993817600, + 1500833279310993817600, + 1500833279310993817600, + 1512971000787409567744 + ] + }, + "ActionCount": 2, + "LiquidationFee": 0, + "Actions": [ + { + "Time": 30, + "PortfolioAndFeeds": { + "OptionExpiries": [ + 500370, + 500370, + 500370, + 500370, + 7757970 + ], + "OptionStrikes": [ + 1500000000000000000000, + 2500000000000000000000, + 1500000000000000000000, + 2500000000000000000000, + 600000000000000000000 + ], + "OptionIsCall": [ + 1, + 1, + 0, + 0, + 1 + ], + "OptionAmounts": [ + 410000000000000000, + -410000000000000000, + -1000000000000000000, + 410000000000000000, + 410000000000000000 + ], + "OptionVols": [ + 1047884508458193792, + 1326538674898416384, + 1047884508458193792, + 1326538674898416384, + 1563882274759127552 + ], + "SVIparams": [ + 1, + 1.5, + -0.1, + -0.05, + 0.05 + ], + "OptionVolConfidences": [ + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000 + ], + "Cash": -3000000000000000000000, + "Perps": 0, + "Base": 1000000000000000000, + "SpotPrice": 1500000000000000000000, + "SpotConfidence": 1000000000000000000, + "PerpPrice": 1505000000000000000000, + "PerpConfidence": 1000000000000000000, + "FeedExpiries": [ + 500370, + 500370, + 500370, + 500370, + 7757970 + ], + "Forwards": [ + 1500833229340328329216, + 1500833229340328329216, + 1500833229340328329216, + 1500833229340328329216, + 1512970950412615024640 + ], + "ForwardConfidences": [ + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000 + ], + "Rates": [ + 0, + 0, + 0, + 0, + 0 + ], + "RateConfidences": [ + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000 + ], + "StablePrice": 1000000000000000000, + "UnrealisedPerpPNL": 0, + "UnrealisedFunding": 0, + "VolShockUp": [ + 1.737081708636119, + 1.737081708636119, + 1.737081708636119, + 1.737081708636119, + 1.3902274454927692 + ], + "VolShockDown": [ + 0.5086121942425874, + 0.5086121942425874, + 0.5086121942425874, + 0.5086121942425874, + 0.7398483696714871 + ], + "SettlementPrice": 1500833229340328329216, + "PercentFixed": 0, + "ForwardsFixed": [ + 0, + 0, + 0, + 0, + 0 + ], + "ForwardsVariable": [ + 1500833229340328329216, + 1500833229340328329216, + 1500833229340328329216, + 1500833229340328329216, + 1512970950412615024640 + ] + }, + "Liquidator": { + "PercentWant": 100000000000000000 + }, + "Results": { + "PreMtM": -745601295246156496896, + "PreMM": -1228396399238205669376, + "PreBM": -1324955420036615634944, + "PostMtM": -671041165721540886528, + "PostMM": -1105556759314385076224, + "PostBM": -1192459878032953835520, + "SMPayout": -89043982644377141248, + "PercentageReceived": 100000000000000000, + "PercentReceivedCurrent": 100000000000000000, + "LiqPrice": -890439826443771314176 + } + }, + { + "Time": 30, + "PortfolioAndFeeds": { + "OptionExpiries": [ + 500370, + 500370, + 500370, + 500370, + 7757970 + ], + "OptionStrikes": [ + 1500000000000000000000, + 2500000000000000000000, + 1500000000000000000000, + 2500000000000000000000, + 600000000000000000000 + ], + "OptionIsCall": [ + 1, + 1, + 0, + 0, + 1 + ], + "OptionAmounts": [ + 369000000000000000, + -369000000000000000, + -900000000000000000, + 369000000000000000, + 369000000000000000 + ], + "OptionVols": [ + 1047884508458193792, + 1326538674898416384, + 1047884508458193792, + 1326538674898416384, + 1563882274759127552 + ], + "SVIparams": [ + 1, + 1.5, + -0.1, + -0.05, + 0.05 + ], + "OptionVolConfidences": [ + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000 + ], + "Cash": -2700000000000000000000, + "Perps": 0, + "Base": 900000000000000000, + "SpotPrice": 1500000000000000000000, + "SpotConfidence": 1000000000000000000, + "PerpPrice": 1505000000000000000000, + "PerpConfidence": 1000000000000000000, + "FeedExpiries": [ + 500370, + 500370, + 500370, + 500370, + 7757970 + ], + "Forwards": [ + 1500833229340328329216, + 1500833229340328329216, + 1500833229340328329216, + 1500833229340328329216, + 1512970950412615024640 + ], + "ForwardConfidences": [ + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000 + ], + "Rates": [ + 0, + 0, + 0, + 0, + 0 + ], + "RateConfidences": [ + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000 + ], + "StablePrice": 1000000000000000000, + "UnrealisedPerpPNL": 0, + "UnrealisedFunding": 0, + "VolShockUp": [ + 1.737081708636119, + 1.737081708636119, + 1.737081708636119, + 1.737081708636119, + 1.3902274454927692 + ], + "VolShockDown": [ + 0.5086121942425874, + 0.5086121942425874, + 0.5086121942425874, + 0.5086121942425874, + 0.7398483696714871 + ], + "SettlementPrice": 1500833229340328329216, + "PercentFixed": 0, + "ForwardsFixed": [ + 0, + 0, + 0, + 0, + 0 + ], + "ForwardsVariable": [ + 1500833229340328329216, + 1500833229340328329216, + 1500833229340328329216, + 1500833229340328329216, + 1512970950412615024640 + ] + }, + "Liquidator": { + "PercentWant": 100000000000000000 + }, + "Results": { + "PreMtM": -671041165721540886528, + "PreMM": -1105556759314385076224, + "PreBM": -1192459878032953835520, + "PostMtM": -596481036196925276160, + "PostMM": -982717119390564614144, + "PostBM": -1059964336029292560384, + "SMPayout": -89043982644377141248, + "PercentageReceived": 100000000000000000, + "PercentReceivedCurrent": 111111111111111120, + "LiqPrice": -801395843799394156544 + } + } + ] + }, + "test_Nov_05_Insolvent_two_liq_same_disc_diff_amount": { + "StartTime": 0, + "IsForce": false, + "InitialPortfolio": { + "OptionExpiries": [ + 500400, + 500400, + 500400, + 500400, + 7758000 + ], + "OptionStrikes": [ + 1500000000000000000000, + 2500000000000000000000, + 1500000000000000000000, + 2500000000000000000000, + 600000000000000000000 + ], + "OptionIsCall": [ + 1, + 1, + 0, + 0, + 1 + ], + "OptionAmounts": [ + 410000000000000000, + -410000000000000000, + -1000000000000000000, + 410000000000000000, + 410000000000000000 + ], + "OptionVols": [ + 1047884494084986240, + 1326538658030860032, + 1047884494084986240, + 1326538658030860032, + 1563882292297486080 + ], + "SVIparams": [ + 1, + 1.5, + -0.1, + -0.05, + 0.05 + ], + "OptionVolConfidences": [ + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000 + ], + "Cash": -3000000000000000000000, + "Perps": 0, + "Base": 1000000000000000000, + "SpotPrice": 1500000000000000000000, + "SpotConfidence": 1000000000000000000, + "PerpPrice": 1505000000000000000000, + "PerpConfidence": 1000000000000000000, + "FeedExpiries": [ + 500400, + 500400, + 500400, + 500400, + 7758000 + ], + "Forwards": [ + 1500833279310993817600, + 1500833279310993817600, + 1500833279310993817600, + 1500833279310993817600, + 1512971000787409567744 + ], + "ForwardConfidences": [ + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000 + ], + "Rates": [ + 0, + 0, + 0, + 0, + 0 + ], + "RateConfidences": [ + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000 + ], + "StablePrice": 1000000000000000000, + "UnrealisedPerpPNL": 0, + "UnrealisedFunding": 0, + "VolShockUp": [ + 1.7370684514926746, + 1.7370684514926746, + 1.7370684514926746, + 1.7370684514926746, + 1.3902272493224166 + ], + "VolShockDown": [ + 0.508621032338217, + 0.508621032338217, + 0.508621032338217, + 0.508621032338217, + 0.7398485004517223 + ], + "SettlementPrice": 1500833279310993817600, + "PercentFixed": 0, + "ForwardsFixed": [ + 0, + 0, + 0, + 0, + 0 + ], + "ForwardsVariable": [ + 1500833279310993817600, + 1500833279310993817600, + 1500833279310993817600, + 1500833279310993817600, + 1512971000787409567744 + ] + }, + "ActionCount": 2, + "LiquidationFee": 0, + "Actions": [ + { + "Time": 30, + "PortfolioAndFeeds": { + "OptionExpiries": [ + 500370, + 500370, + 500370, + 500370, + 7757970 + ], + "OptionStrikes": [ + 1500000000000000000000, + 2500000000000000000000, + 1500000000000000000000, + 2500000000000000000000, + 600000000000000000000 + ], + "OptionIsCall": [ + 1, + 1, + 0, + 0, + 1 + ], + "OptionAmounts": [ + 410000000000000000, + -410000000000000000, + -1000000000000000000, + 410000000000000000, + 410000000000000000 + ], + "OptionVols": [ + 1047884508458193792, + 1326538674898416384, + 1047884508458193792, + 1326538674898416384, + 1563882274759127552 + ], + "SVIparams": [ + 1, + 1.5, + -0.1, + -0.05, + 0.05 + ], + "OptionVolConfidences": [ + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000 + ], + "Cash": -3000000000000000000000, + "Perps": 0, + "Base": 1000000000000000000, + "SpotPrice": 1500000000000000000000, + "SpotConfidence": 1000000000000000000, + "PerpPrice": 1505000000000000000000, + "PerpConfidence": 1000000000000000000, + "FeedExpiries": [ + 500370, + 500370, + 500370, + 500370, + 7757970 + ], + "Forwards": [ + 1500833229340328329216, + 1500833229340328329216, + 1500833229340328329216, + 1500833229340328329216, + 1512970950412615024640 + ], + "ForwardConfidences": [ + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000 + ], + "Rates": [ + 0, + 0, + 0, + 0, + 0 + ], + "RateConfidences": [ + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000 + ], + "StablePrice": 1000000000000000000, + "UnrealisedPerpPNL": 0, + "UnrealisedFunding": 0, + "VolShockUp": [ + 1.737081708636119, + 1.737081708636119, + 1.737081708636119, + 1.737081708636119, + 1.3902274454927692 + ], + "VolShockDown": [ + 0.5086121942425874, + 0.5086121942425874, + 0.5086121942425874, + 0.5086121942425874, + 0.7398483696714871 + ], + "SettlementPrice": 1500833229340328329216, + "PercentFixed": 0, + "ForwardsFixed": [ + 0, + 0, + 0, + 0, + 0 + ], + "ForwardsVariable": [ + 1500833229340328329216, + 1500833229340328329216, + 1500833229340328329216, + 1500833229340328329216, + 1512970950412615024640 + ] + }, + "Liquidator": { + "PercentWant": 100000000000000000 + }, + "Results": { + "PreMtM": -745601295246156496896, + "PreMM": -1228396399238205669376, + "PreBM": -1324955420036615634944, + "PostMtM": -671041165721540886528, + "PostMM": -1105556759314385076224, + "PostBM": -1192459878032953835520, + "SMPayout": -89043982644377141248, + "PercentageReceived": 100000000000000000, + "PercentReceivedCurrent": 100000000000000000, + "LiqPrice": -890439826443771314176 + } + }, + { + "Time": 30, + "PortfolioAndFeeds": { + "OptionExpiries": [ + 500370, + 500370, + 500370, + 500370, + 7757970 + ], + "OptionStrikes": [ + 1500000000000000000000, + 2500000000000000000000, + 1500000000000000000000, + 2500000000000000000000, + 600000000000000000000 + ], + "OptionIsCall": [ + 1, + 1, + 0, + 0, + 1 + ], + "OptionAmounts": [ + 369000000000000000, + -369000000000000000, + -900000000000000000, + 369000000000000000, + 369000000000000000 + ], + "OptionVols": [ + 1047884508458193792, + 1326538674898416384, + 1047884508458193792, + 1326538674898416384, + 1563882274759127552 + ], + "SVIparams": [ + 1, + 1.5, + -0.1, + -0.05, + 0.05 + ], + "OptionVolConfidences": [ + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000 + ], + "Cash": -2700000000000000000000, + "Perps": 0, + "Base": 900000000000000000, + "SpotPrice": 1500000000000000000000, + "SpotConfidence": 1000000000000000000, + "PerpPrice": 1505000000000000000000, + "PerpConfidence": 1000000000000000000, + "FeedExpiries": [ + 500370, + 500370, + 500370, + 500370, + 7757970 + ], + "Forwards": [ + 1500833229340328329216, + 1500833229340328329216, + 1500833229340328329216, + 1500833229340328329216, + 1512970950412615024640 + ], + "ForwardConfidences": [ + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000 + ], + "Rates": [ + 0, + 0, + 0, + 0, + 0 + ], + "RateConfidences": [ + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000 + ], + "StablePrice": 1000000000000000000, + "UnrealisedPerpPNL": 0, + "UnrealisedFunding": 0, + "VolShockUp": [ + 1.737081708636119, + 1.737081708636119, + 1.737081708636119, + 1.737081708636119, + 1.3902274454927692 + ], + "VolShockDown": [ + 0.5086121942425874, + 0.5086121942425874, + 0.5086121942425874, + 0.5086121942425874, + 0.7398483696714871 + ], + "SettlementPrice": 1500833229340328329216, + "PercentFixed": 0, + "ForwardsFixed": [ + 0, + 0, + 0, + 0, + 0 + ], + "ForwardsVariable": [ + 1500833229340328329216, + 1500833229340328329216, + 1500833229340328329216, + 1500833229340328329216, + 1512970950412615024640 + ] + }, + "Liquidator": { + "PercentWant": 500000000000000000 + }, + "Results": { + "PreMtM": -671041165721540886528, + "PreMM": -1105556759314385076224, + "PreBM": -1192459878032953835520, + "PostMtM": -298240518098462638080, + "PostMM": -491358559695282307072, + "PostBM": -529982168014646280192, + "SMPayout": -445219913221885657088, + "PercentageReceived": 500000000000000000, + "PercentReceivedCurrent": 555555555555555584, + "LiqPrice": -801395843799394156544 + } + } + ] + }, + "test_Nov_06_Insolvent_General": { + "StartTime": 0, + "IsForce": false, + "InitialPortfolio": { + "OptionExpiries": [ + 500400, + 500400, + 500400, + 500400, + 7758000, + 2487600 + ], + "OptionStrikes": [ + 1500000000000000000000, + 2500000000000000000000, + 1500000000000000000000, + 2500000000000000000000, + 600000000000000000000, + 2300000000000000000000 + ], + "OptionIsCall": [ + 1, + 1, + 0, + 0, + 1, + 0 + ], + "OptionAmounts": [ + 410000000000000000, + -410000000000000000, + -1000000000000000000, + 210000000000000000, + 410000000000000000, + -610000000000000000 + ], + "OptionVols": [ + 1047884494084986240, + 1326538658030860032, + 1047884494084986240, + 1326538658030860032, + 1563882292297486080, + 1282482509289968384 + ], + "SVIparams": [ + 1, + 1.5, + -0.1, + -0.05, + 0.05 + ], + "OptionVolConfidences": [ + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000 + ], + "Cash": -3000000000000000000000, + "Perps": 0, + "Base": 2000000000000000000, + "SpotPrice": 1500000000000000000000, + "SpotConfidence": 1000000000000000000, + "PerpPrice": 1505000000000000000000, + "PerpConfidence": 1000000000000000000, + "FeedExpiries": [ + 500400, + 500400, + 500400, + 500400, + 7758000, + 2487600 + ], + "Forwards": [ + 1500833279310993817600, + 1500833279310993817600, + 1500833279310993817600, + 1500833279310993817600, + 1512971000787409567744, + 1504146989085687808000 + ], + "ForwardConfidences": [ + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000 + ], + "Rates": [ + 0, + 0, + 0, + 0, + 0, + 0 + ], + "RateConfidences": [ + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000 + ], + "StablePrice": 1000000000000000000, + "UnrealisedPerpPNL": 0, + "UnrealisedFunding": 0, + "VolShockUp": [ + 1.7370684514926746, + 1.7370684514926746, + 1.7370684514926746, + 1.7370684514926746, + 1.3902272493224166, + 1.4555844040146944 + ], + "VolShockDown": [ + 0.508621032338217, + 0.508621032338217, + 0.508621032338217, + 0.508621032338217, + 0.7398485004517223, + 0.6962770639902038 + ], + "SettlementPrice": 1500833279310993817600, + "PercentFixed": 0, + "ForwardsFixed": [ + 0, + 0, + 0, + 0, + 0, + 0 + ], + "ForwardsVariable": [ + 1500833279310993817600, + 1500833279310993817600, + 1500833279310993817600, + 1500833279310993817600, + 1512971000787409567744, + 1504146989085687808000 + ] + }, + "ActionCount": 3, + "LiquidationFee": 0, + "Actions": [ + { + "Time": 10, + "PortfolioAndFeeds": { + "OptionExpiries": [ + 500390, + 500390, + 500390, + 500390, + 7757990, + 2487590 + ], + "OptionStrikes": [ + 1500000000000000000000, + 2500000000000000000000, + 1500000000000000000000, + 2500000000000000000000, + 600000000000000000000, + 2300000000000000000000 + ], + "OptionIsCall": [ + 1, + 1, + 0, + 0, + 1, + 0 + ], + "OptionAmounts": [ + 410000000000000000, + -410000000000000000, + -1000000000000000000, + 210000000000000000, + 410000000000000000, + -610000000000000000 + ], + "OptionVols": [ + 1050875589263863680, + 1329923196477253120, + 1050875589263863680, + 1329923196477253120, + 1560354910244486656, + 1285977096978142208 + ], + "SVIparams": [ + 1, + 1.5, + -0.1, + -0.05, + 0.05 + ], + "OptionVolConfidences": [ + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000 + ], + "Cash": -3000000000000000000000, + "Perps": 0, + "Base": 2000000000000000000, + "SpotPrice": 1490000000000000000000, + "SpotConfidence": 1000000000000000000, + "PerpPrice": 1495000000000000000000, + "PerpConfidence": 1000000000000000000, + "FeedExpiries": [ + 500390, + 500390, + 500390, + 500390, + 7757990, + 2487590 + ], + "Forwards": [ + 1490827707569744642048, + 1490827707569744642048, + 1490827707569744642048, + 1490827707569744642048, + 1502884510769172447232, + 1494119325909408546816 + ], + "ForwardConfidences": [ + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000 + ], + "Rates": [ + 0, + 0, + 0, + 0, + 0, + 0 + ], + "RateConfidences": [ + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000 + ], + "StablePrice": 1000000000000000000, + "UnrealisedPerpPNL": 0, + "UnrealisedFunding": 0, + "VolShockUp": [ + 1.7370728704256835, + 1.7370728704256835, + 1.7370728704256835, + 1.7370728704256835, + 1.3902273147124389, + 1.4555849534425698 + ], + "VolShockDown": [ + 0.5086180863828778, + 0.5086180863828778, + 0.5086180863828778, + 0.5086180863828778, + 0.7398484568583741, + 0.6962766977049535 + ], + "SettlementPrice": 1490827707569744642048, + "PercentFixed": 0, + "ForwardsFixed": [ + 0, + 0, + 0, + 0, + 0, + 0 + ], + "ForwardsVariable": [ + 1490827707569744642048, + 1490827707569744642048, + 1490827707569744642048, + 1490827707569744642048, + 1502884510769172447232, + 1494119325909408546816 + ] + }, + "Liquidator": { + "PercentWant": 102400000000000000 + }, + "Results": { + "PreMtM": 11030253455229741056, + "PreMM": -901650726031643901952, + "PreBM": -1084186921929018572800, + "PostMtM": 9900755501414551552, + "PostMM": -809321691686003277824, + "PostBM": -973166181123486777344, + "SMPayout": -8216355276130061312, + "PercentageReceived": 102400000000000000, + "PercentReceivedCurrent": 102400000000000000, + "LiqPrice": -80237844493457637376 + } + }, + { + "Time": 40, + "PortfolioAndFeeds": { + "OptionExpiries": [ + 500360, + 500360, + 500360, + 500360, + 7757960, + 2487560 + ], + "OptionStrikes": [ + 1500000000000000000000, + 2500000000000000000000, + 1500000000000000000000, + 2500000000000000000000, + 600000000000000000000, + 2300000000000000000000 + ], + "OptionIsCall": [ + 1, + 1, + 0, + 0, + 1, + 0 + ], + "OptionAmounts": [ + 368015999999999936, + -368015999999999936, + -897600000000000000, + 188496000000000000, + 368015999999999936, + -547535999999999936 + ], + "OptionVols": [ + 1040549346267743360, + 1316469972459492096, + 1040549346267743360, + 1316469972459492096, + 1574279125755956992, + 1272084265166939904 + ], + "SVIparams": [ + 1, + 1.5, + -0.1, + -0.05, + 0.05 + ], + "OptionVolConfidences": [ + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000 + ], + "Cash": -2692799999999999475712, + "Perps": 0, + "Base": 1795200000000000000, + "SpotPrice": 1530000000000000000000, + "SpotConfidence": 1000000000000000000, + "PerpPrice": 1535000000000000000000, + "PerpConfidence": 1000000000000000000, + "FeedExpiries": [ + 500360, + 500360, + 500360, + 500360, + 7757960, + 2487560 + ], + "Forwards": [ + 1530849876937108881408, + 1530849876937108881408, + 1530849876937108881408, + 1530849876937108881408, + 1543230352293437636608, + 1534229860757246836736 + ], + "ForwardConfidences": [ + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000 + ], + "Rates": [ + 0, + 0, + 0, + 0, + 0, + 0 + ], + "RateConfidences": [ + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000 + ], + "StablePrice": 1000000000000000000, + "UnrealisedPerpPNL": 0, + "UnrealisedFunding": 0, + "VolShockUp": [ + 1.737086127913556, + 1.737086127913556, + 1.737086127913556, + 1.737086127913556, + 1.3902275108830775, + 1.4555866017434245 + ], + "VolShockDown": [ + 0.5086092480576293, + 0.5086092480576293, + 0.5086092480576293, + 0.5086092480576293, + 0.7398483260779484, + 0.696275598837717 + ], + "SettlementPrice": 1530849876937108881408, + "PercentFixed": 0, + "ForwardsFixed": [ + 0, + 0, + 0, + 0, + 0, + 0 + ], + "ForwardsVariable": [ + 1530849876937108881408, + 1530849876937108881408, + 1530849876937108881408, + 1530849876937108881408, + 1543230352293437636608, + 1534229860757246836736 + ] + }, + "Liquidator": { + "PercentWant": 532000000000000000 + }, + "Results": { + "PreMtM": 132518228046353661952, + "PreMM": -704325410524874801152, + "PreBM": -871694138239120441344, + "PostMtM": 53975784507293835264, + "PostMM": -286877640472253005824, + "PostBM": -355048325468162359296, + "SMPayout": -119853641897612836864, + "PercentageReceived": 532000000000000000, + "PercentReceivedCurrent": 592691622103386880, + "LiqPrice": -202219227382137716736 + } + }, + { + "Time": 100, + "PortfolioAndFeeds": { + "OptionExpiries": [ + 500300, + 500300, + 500300, + 500300, + 7757900, + 2487500 + ], + "OptionStrikes": [ + 1500000000000000000000, + 2500000000000000000000, + 1500000000000000000000, + 2500000000000000000000, + 600000000000000000000, + 2300000000000000000000 + ], + "OptionIsCall": [ + 1, + 1, + 0, + 0, + 1, + 0 + ], + "OptionAmounts": [ + 149895999999999936, + -149895999999999936, + -365599999999999936, + 76775999999999984, + 149895999999999936, + -223015999999999936 + ], + "OptionVols": [ + 1037570785183593600, + 1309826485577657088, + 1037570785183593600, + 1309826485577657088, + 1581060913768519680, + 1265221632045370112 + ], + "SVIparams": [ + 1, + 1.5, + -0.1, + -0.05, + 0.05 + ], + "OptionVolConfidences": [ + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000 + ], + "Cash": -1096799999999999737856, + "Perps": 0, + "Base": 731199999999999872, + "SpotPrice": 1550000000000000000000, + "SpotConfidence": 1000000000000000000, + "PerpPrice": 1555000000000000000000, + "PerpConfidence": 1000000000000000000, + "FeedExpiries": [ + 500300, + 500300, + 500300, + 500300, + 7757900, + 2487500 + ], + "Forwards": [ + 1550860883166851760128, + 1550860883166851760128, + 1550860883166851760128, + 1550860883166851760128, + 1563403193967148269568, + 1554285049554006704128 + ], + "ForwardConfidences": [ + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000 + ], + "Rates": [ + 0, + 0, + 0, + 0, + 0, + 0 + ], + "RateConfidences": [ + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000 + ], + "StablePrice": 1000000000000000000, + "UnrealisedPerpPNL": 0, + "UnrealisedFunding": 0, + "VolShockUp": [ + 1.7371126459895851, + 1.7371126459895851, + 1.7371126459895851, + 1.7371126459895851, + 1.3902279032269262, + 1.4555898984226612 + ], + "VolShockDown": [ + 0.5085915693402766, + 0.5085915693402766, + 0.5085915693402766, + 0.5085915693402766, + 0.7398480645153824, + 0.6962734010515592 + ], + "SettlementPrice": 1550860883166851760128, + "PercentFixed": 0, + "ForwardsFixed": [ + 0, + 0, + 0, + 0, + 0, + 0 + ], + "ForwardsVariable": [ + 1550860883166851760128, + 1550860883166851760128, + 1550860883166851760128, + 1550860883166851760128, + 1563403193967148269568, + 1554285049554006704128 + ] + }, + "Liquidator": { + "PercentWant": 1000000000000000000 + }, + "Results": { + "PreMtM": 78620035270646890496, + "PreMM": -265651603747238150144, + "PreBM": -334505931550815158272, + "PostMtM": 0, + "PostMM": 0, + "PostBM": 0, + "SMPayout": -265651603747238150144, + "PercentageReceived": 365599999999999936, + "PercentReceivedCurrent": 1000000000000000000, + "LiqPrice": -265651603747238150144 + } + } + ] + } +} \ No newline at end of file diff --git a/test/integration-tests/liquidation/PMRM_solvent.json b/test/integration-tests/liquidation/PMRM_solvent.json index 6962169b..9d22f46d 100644 --- a/test/integration-tests/liquidation/PMRM_solvent.json +++ b/test/integration-tests/liquidation/PMRM_solvent.json @@ -1378,7 +1378,7 @@ } ] }, - "Long_Box_Short_Cash": { + "test_Nov_01_long_box_neg_cash": { "StartTime": 0, "IsForce": false, "InitialPortfolio": { @@ -1627,7 +1627,7 @@ } ] }, - "liqs_same_price_same_amount": { + "test_Nov_02_3_liqs_same_price_same_amount": { "StartTime": 0, "IsForce": false, "InitialPortfolio": { @@ -1956,7 +1956,7 @@ } ] }, - "perp": { + "test_Nov_03_perp": { "StartTime": 0, "IsForce": false, "InitialPortfolio": { @@ -2684,4 +2684,4 @@ } ] } -} \ No newline at end of file +} diff --git a/test/integration-tests/liquidation/PM_liquidationSimTests.t.sol b/test/integration-tests/liquidation/PM_liquidationSimTests.t.sol index 837354ac..d90b48a1 100644 --- a/test/integration-tests/liquidation/PM_liquidationSimTests.t.sol +++ b/test/integration-tests/liquidation/PM_liquidationSimTests.t.sol @@ -34,15 +34,39 @@ contract LiquidationSimTests_PM is LiquidationSimBase { } function testLiquidationSimLong_Box_Short_Cash() public { - runLiquidationSim("PMRM_solvent", "Long_Box_Short_Cash"); + runLiquidationSim("PMRM_solvent", "test_Nov_01_long_box_neg_cash"); } function testLiquidationSimSimple_Short_3_liquidators() public { - runLiquidationSim("PMRM_solvent", "liqs_same_price_same_amount"); + runLiquidationSim("PMRM_solvent", "test_Nov_02_3_liqs_same_price_same_amount"); } function testLiquidationSimPMRM_perp() public { - runLiquidationSim("PMRM_solvent", "perp"); + runLiquidationSim("PMRM_solvent", "test_Nov_03_perp"); + } + + function testLiquidationSim_insolvent_1() public { + runLiquidationSim("PMRM_insolvent", "test_Nov_01_Insolvent_basic"); + } + + function testLiquidationSim_insolvent_2() public { + runLiquidationSim("PMRM_insolvent", "test_Nov_02_Insolvent_basic_mtm_pos"); + } + + function testLiquidationSim_insolvent_3() public { + runLiquidationSim("PMRM_insolvent", "test_Nov_03_Insolvent_basic_at_end"); + } + + function testLiquidationSim_insolvent_4() public { + runLiquidationSim("PMRM_insolvent", "test_Nov_04_Insolvent_two_liq_same_disc_same_amount"); + } + + function testLiquidationSim_insolvent_5() public { + runLiquidationSim("PMRM_insolvent", "test_Nov_05_Insolvent_two_liq_same_disc_diff_amount"); + } + + function testLiquidationSim_insolvent_6() public { + runLiquidationSim("PMRM_insolvent", "test_Nov_06_Insolvent_General"); } // function testInsolventSim1() public { From 6890453f8bf10e450d3eb0995d3da058e960766f Mon Sep 17 00:00:00 2001 From: SeanDaws <68123079+SeanDaws@users.noreply.github.com> Date: Thu, 16 Nov 2023 09:13:04 -0500 Subject: [PATCH 05/14] added base asset test --- .../liquidation/PMRM_solvent.json | 628 +++++++++--------- .../liquidation/PM_liquidationSimTests.t.sol | 96 +-- 2 files changed, 373 insertions(+), 351 deletions(-) diff --git a/test/integration-tests/liquidation/PMRM_solvent.json b/test/integration-tests/liquidation/PMRM_solvent.json index 9d22f46d..5f716bae 100644 --- a/test/integration-tests/liquidation/PMRM_solvent.json +++ b/test/integration-tests/liquidation/PMRM_solvent.json @@ -702,20 +702,20 @@ ] }, "Liquidator": { - "PercentWant": 90000000000000000 + "PercentWant": 111111111111111120 }, "Results": { "PreMtM": 118425834278252019712, "PreMM": -81731093685347155968, "PreBM": -121762479278066974720, "PreFMax": 524290585958138816, - "ExpectedBidPrice": 9943188624571351040, - "FinalPercentageReceived": 99999999999999984, - "fLiquidatedOfOriginal": 90000000000000000, - "PostMtM": 117631238211061661696, - "PostMM": -62509996956177588224, - "PostBM": -98538243989625438208, - "PostFMax": 471433984397932032 + "ExpectedBidPrice": 11047987360634836992, + "FinalPercentageReceived": 111111111111111120, + "fLiquidatedOfOriginal": 111111111111111120, + "PostMtM": 117542949759151603712, + "PostMM": -60374319541825396736, + "PostBM": -95957773402020790272, + "PostFMax": 464826909202906112 } } ] @@ -789,7 +789,7 @@ 1500833279310993817600 ] }, - "ActionCount": 3, + "ActionCount": 2, "LiquidationFee": 1.322084630165343, "Actions": [ { @@ -878,10 +878,10 @@ } }, { - "Time": 30, + "Time": 600, "PortfolioAndFeeds": { "OptionExpiries": [ - 500370 + 499800 ], "OptionStrikes": [ 1500000000000000000000 @@ -893,7 +893,7 @@ -900000000000000000 ], "OptionVols": [ - 1047884508458193792 + 1047884781550182784 ], "SVIparams": [ 1, @@ -913,95 +913,10 @@ "PerpPrice": 1505000000000000000000, "PerpConfidence": 1000000000000000000, "FeedExpiries": [ - 500370 - ], - "Forwards": [ - 1500833229340328329216 - ], - "ForwardConfidences": [ - 1000000000000000000 - ], - "Rates": [ - 0 - ], - "RateConfidences": [ - 1000000000000000000 - ], - "StablePrice": 1000000000000000000, - "UnrealisedPerpPNL": 0, - "UnrealisedFunding": 0, - "VolShockUp": [ - 1.737081708636119 - ], - "VolShockDown": [ - 0.5086121942425874 - ], - "SettlementPrice": 1500833229340328329216, - "PercentFixed": 0, - "ForwardsFixed": [ - 0 - ], - "ForwardsVariable": [ - 1500833229340328329216 - ] - }, - "Liquidator": { - "PercentWant": 100000000000000000 - }, - "Results": { - "PreMtM": 118425834278252019712, - "PreMM": -81731093685347155968, - "PreBM": -121762479278066974720, - "PreFMax": 524290585958138816, - "ExpectedBidPrice": 11047987360634836992, - "FinalPercentageReceived": 111111111111111120, - "fLiquidatedOfOriginal": 100000000000000000, - "PostMtM": 117542949759151603712, - "PostMM": -60374319541825396736, - "PostBM": -95957773402020790272, - "PostFMax": 464826909202906112 - } - }, - { - "Time": 30, - "PortfolioAndFeeds": { - "OptionExpiries": [ - 500370 - ], - "OptionStrikes": [ - 1500000000000000000000 - ], - "OptionIsCall": [ - 1 - ], - "OptionAmounts": [ - -799999999999999872 - ], - "OptionVols": [ - 1047884508458193792 - ], - "SVIparams": [ - 1, - 1.5, - -0.1, - -0.05, - 0.05 - ], - "OptionVolConfidences": [ - 1000000000000000000 - ], - "Cash": 181038307017137389568, - "Perps": 0, - "Base": 0, - "SpotPrice": 1500000000000000000000, - "SpotConfidence": 1000000000000000000, - "PerpPrice": 1505000000000000000000, - "PerpConfidence": 1000000000000000000, - "FeedExpiries": [ - 500370 + 499800 ], "Forwards": [ - 1500833229340328329216 + 1500832279897993904128 ], "ForwardConfidences": [ 1000000000000000000 @@ -1016,35 +931,35 @@ "UnrealisedPerpPNL": 0, "UnrealisedFunding": 0, "VolShockUp": [ - 1.737081708636119 + 1.7373337908573938 ], "VolShockDown": [ - 0.5086121942425874 + 0.508444139428404 ], - "SettlementPrice": 1500833229340328329216, + "SettlementPrice": 1500832279897993904128, "PercentFixed": 0, "ForwardsFixed": [ 0 ], "ForwardsVariable": [ - 1500833229340328329216 + 1500832279897993904128 ] }, "Liquidator": { - "PercentWant": 100000000000000000 + "PercentWant": 555555555555555584 }, "Results": { - "PreMtM": 117542949759151603712, - "PreMM": -60374319541825396736, - "PreBM": -95957773402020790272, - "PreFMax": 464826909202906112, - "ExpectedBidPrice": 11047987360634834944, - "FinalPercentageReceived": 125000000000000000, - "fLiquidatedOfOriginal": 100000000000000000, - "PostMtM": 116660065240051187712, - "PostMM": -39017545398303694848, - "PostBM": -70153067525974679552, - "PostFMax": 388373610517607104 + "PreMtM": 118466691793233494016, + "PreMM": -81684028137284435968, + "PreBM": -121714172123388018688, + "PreFMax": 564240540466009600, + "ExpectedBidPrice": 46083950358429671424, + "FinalPercentageReceived": 555555555555555584, + "fLiquidatedOfOriginal": 555555555555555584, + "PostMtM": 104873584133552816128, + "PostMM": 15917708608878172160, + "PostBM": -1873466496056750080, + "PostFMax": 19541216048521428 } } ] @@ -1137,7 +1052,7 @@ -1000000000000000000 ], "OptionVols": [ - 1040549342988285696 + 1047884508458193792 ], "SVIparams": [ 1, @@ -1152,15 +1067,15 @@ "Cash": 198677915369834676224, "Perps": 0, "Base": 0, - "SpotPrice": 1530000000000000000000, + "SpotPrice": 1500000000000000000000, "SpotConfidence": 1000000000000000000, - "PerpPrice": 1535000000000000000000, + "PerpPrice": 1505000000000000000000, "PerpConfidence": 1000000000000000000, "FeedExpiries": [ 500370 ], "Forwards": [ - 1530849893927134953472 + 1500833229340328329216 ], "ForwardConfidences": [ 1000000000000000000 @@ -1180,37 +1095,37 @@ "VolShockDown": [ 0.5086121942425874 ], - "SettlementPrice": 1530849893927134953472, + "SettlementPrice": 1500833229340328329216, "PercentFixed": 0, "ForwardsFixed": [ 0 ], "ForwardsVariable": [ - 1530849893927134953472 + 1500833229340328329216 ] }, "Liquidator": { "PercentWant": 100000000000000000 }, "Results": { - "PreMtM": 103116914250414571520, - "PreMM": -129478717730831056896, - "PreBM": -175997844127080185856, - "PreFMax": 648280469348716416, - "ExpectedBidPrice": 9548626259588390912, + "PreMtM": 119308718797352435712, + "PreMM": -103087867828868841472, + "PreBM": -147567185154113110016, + "PreFMax": 571861527362324864, + "ExpectedBidPrice": 11047987360634836992, "FinalPercentageReceived": 100000000000000000, "fLiquidatedOfOriginal": 100000000000000000, - "PostMtM": 102353849084961488896, - "PostMM": -106982219698159517696, - "PostBM": -148849433454783692800, - "PostFMax": 609200521498573696 + "PostMtM": 118425834278252019712, + "PostMM": -81731093685347155968, + "PostBM": -121762479278066974720, + "PostFMax": 524290585958138816 } }, { - "Time": 600, + "Time": 30, "PortfolioAndFeeds": { "OptionExpiries": [ - 499800 + 500370 ], "OptionStrikes": [ 1500000000000000000000 @@ -1222,7 +1137,7 @@ -900000000000000000 ], "OptionVols": [ - 1068668852270611200 + 1047884508458193792 ], "SVIparams": [ 1, @@ -1234,18 +1149,18 @@ "OptionVolConfidences": [ 1000000000000000000 ], - "Cash": 188358750092439584768, + "Cash": 189858111193486032896, "Perps": 0, "Base": 0, - "SpotPrice": 1439000000000000000000, + "SpotPrice": 1500000000000000000000, "SpotConfidence": 1000000000000000000, - "PerpPrice": 1444000000000000000000, + "PerpPrice": 1505000000000000000000, "PerpConfidence": 1000000000000000000, "FeedExpiries": [ - 499800 + 500370 ], "Forwards": [ - 1439798433848808701952 + 1500833229340328329216 ], "ForwardConfidences": [ 1000000000000000000 @@ -1260,42 +1175,42 @@ "UnrealisedPerpPNL": 0, "UnrealisedFunding": 0, "VolShockUp": [ - 1.7373337908573938 + 1.737081708636119 ], "VolShockDown": [ - 0.508444139428404 + 0.5086121942425874 ], - "SettlementPrice": 1439798433848808701952, + "SettlementPrice": 1500833229340328329216, "PercentFixed": 0, "ForwardsFixed": [ 0 ], "ForwardsVariable": [ - 1439798433848808701952 + 1500833229340328329216 ] }, "Liquidator": { - "PercentWant": 200000000000000000 + "PercentWant": 148888888888888896 }, "Results": { - "PreMtM": 141241828744923119616, - "PreMM": -38371724770906210304, - "PreBM": -74294435474072059904, - "PreFMax": 400423865535404544, - "ExpectedBidPrice": 22599203883285839872, - "FinalPercentageReceived": 222222222222222240, - "fLiquidatedOfOriginal": 200000000000000000, - "PostMtM": 134575876520356806656, - "PostMM": -5123553991954907136, - "PostBM": -33063440094417244160, - "PostFMax": 229116398545520192 + "PreMtM": 118425834278252019712, + "PreMM": -81731093685347155968, + "PreBM": -121762479278066974720, + "PreFMax": 524290585958138816, + "ExpectedBidPrice": 14804303063250681856, + "FinalPercentageReceived": 148888888888888896, + "fLiquidatedOfOriginal": 148888888888888896, + "PostMtM": 117242769022657511424, + "PostMM": -53113016333027983360, + "PostBM": -87184173404165079040, + "PostFMax": 441072490029144640 } }, { - "Time": 9000, + "Time": 30, "PortfolioAndFeeds": { "OptionExpiries": [ - 491400 + 500370 ], "OptionStrikes": [ 1500000000000000000000 @@ -1304,10 +1219,10 @@ 1 ], "OptionAmounts": [ - -700000000000000128 + -766000000000000000 ], "OptionVols": [ - 1042220856498288000 + 1047884508458193792 ], "SVIparams": [ 1, @@ -1319,18 +1234,18 @@ "OptionVolConfidences": [ 1000000000000000000 ], - "Cash": 171222370901758509056, + "Cash": 178039573597178888192, "Perps": 0, "Base": 0, - "SpotPrice": 1522000000000000000000, + "SpotPrice": 1500000000000000000000, "SpotConfidence": 1000000000000000000, - "PerpPrice": 1527000000000000000000, + "PerpPrice": 1505000000000000000000, "PerpConfidence": 1000000000000000000, "FeedExpiries": [ - 491400 + 500370 ], "Forwards": [ - 1522830289745930354688 + 1500833229340328329216 ], "ForwardConfidences": [ 1000000000000000000 @@ -1345,35 +1260,35 @@ "UnrealisedPerpPNL": 0, "UnrealisedFunding": 0, "VolShockUp": [ - 1.7410925838661393 + 1.737081708636119 ], "VolShockDown": [ - 0.5059382774225738 + 0.5086121942425874 ], - "SettlementPrice": 1522830289745930354688, + "SettlementPrice": 1500833229340328329216, "PercentFixed": 0, "ForwardsFixed": [ 0 ], "ForwardsVariable": [ - 1522830289745930354688 + 1500833229340328329216 ] }, "Liquidator": { - "PercentWant": 300000000000000000 + "PercentWant": 1000000000000000000 }, "Results": { - "PreMtM": 107989712946571624448, - "PreMM": -52917319139126501376, - "PreBM": -85098725556266106880, - "PreFMax": 606027945856190080, - "ExpectedBidPrice": 9931675129055612928, - "FinalPercentageReceived": 428571428571428608, - "fLiquidatedOfOriginal": 300000000000000000, - "PostMtM": 85417724016899784704, - "PostMM": -6529151460641997824, - "PostBM": -24918526556150353920, - "PostFMax": 310548905248332864 + "PreMtM": 117242769022657511424, + "PreMM": -53113016333027983360, + "PreBM": -87184173404165079040, + "PreFMax": 441072490029144640, + "ExpectedBidPrice": 37326898839437451264, + "FinalPercentageReceived": 441072490029144640, + "fLiquidatedOfOriginal": 441072490029144640, + "PostMtM": 114259841901579370496, + "PostMM": 19043306983596552192, + "PostBM": -14210, + "PostFMax": 128 } } ] @@ -1853,7 +1768,7 @@ ] }, "Liquidator": { - "PercentWant": 190620509120774976 + "PercentWant": 235514380174996576 }, "Results": { "PreMtM": 117625759832094736384, @@ -1862,7 +1777,7 @@ "PreFMax": 471028760349993216, "ExpectedBidPrice": 21059729754440994816, "FinalPercentageReceived": 235514380174996576, - "fLiquidatedOfOriginal": 190620509120774976, + "fLiquidatedOfOriginal": 235514380174996576, "PostMtM": 115942800866837053440, "PostMM": -21667084620558540800, "PostBM": -49189061718037659648, @@ -1938,7 +1853,7 @@ ] }, "Liquidator": { - "PercentWant": 190620509120774976 + "PercentWant": 308069078171683136 }, "Results": { "PreMtM": 115942800866837053440, @@ -1947,7 +1862,7 @@ "PreFMax": 308069078171682880, "ExpectedBidPrice": 21059729754440986624, "FinalPercentageReceived": 308069078171682880, - "fLiquidatedOfOriginal": 190620509120774816, + "fLiquidatedOfOriginal": 308069078171682880, "PostMtM": 114259841901579370496, "PostMM": 19043306983596552192, "PostBM": -14210, @@ -1973,7 +1888,7 @@ 0.05 ], "OptionVolConfidences": [], - "Cash": 100000000000000000000, + "Cash": 40000000000000000000, "Perps": 1000000000000000000, "Base": 0, "SpotPrice": 1500000000000000000000, @@ -1986,7 +1901,7 @@ "Rates": [], "RateConfidences": [], "StablePrice": 1000000000000000000, - "UnrealisedPerpPNL": -50000000000000000000, + "UnrealisedPerpPNL": 0, "UnrealisedFunding": 0, "VolShockUp": [], "VolShockDown": [], @@ -1996,7 +1911,7 @@ "ForwardsVariable": [] }, "ActionCount": 1, - "LiquidationFee": 0.8370804822417725, + "LiquidationFee": 0.6957315086347344, "Actions": [ { "Time": 0, @@ -2014,7 +1929,7 @@ 0.05 ], "OptionVolConfidences": [], - "Cash": 99162919517758226432, + "Cash": 39304268491365261312, "Perps": 1000000000000000000, "Base": 0, "SpotPrice": 1500000000000000000000, @@ -2027,7 +1942,7 @@ "Rates": [], "RateConfidences": [], "StablePrice": 1000000000000000000, - "UnrealisedPerpPNL": -50000000000000000000, + "UnrealisedPerpPNL": 0, "UnrealisedFunding": 0, "VolShockUp": [], "VolShockDown": [], @@ -2040,17 +1955,17 @@ "PercentWant": 1000000000000000000 }, "Results": { - "PreMtM": 49162919517758226432, - "PreMM": -206587080482241773568, - "PreBM": -257737080482241773568, - "PreFMax": 842507275430904192, - "ExpectedBidPrice": 40591715027632594944, - "FinalPercentageReceived": 842507275430904192, - "fLiquidatedOfOriginal": 842507275430904192, - "PostMtM": 48334517170255519744, - "PostMM": 8055752861709265920, - "PostBM": 14210, - "PostFMax": -294 + "PreMtM": 39304268491365261312, + "PreMM": -216445731508634746880, + "PreBM": -267595731508634681344, + "PreFMax": 874170427149405568, + "ExpectedBidPrice": 33671456592373858304, + "FinalPercentageReceived": 874170427149405568, + "fLiquidatedOfOriginal": 874170427149405568, + "PostMtM": 38617095907847430144, + "PostMM": 6436182651307888640, + "PostBM": -21316, + "PostFMax": 553 } } ] @@ -2114,8 +2029,8 @@ 1000000000000000000, 1000000000000000000 ], - "Cash": -4200000000000000000000, - "Perps": 1000000000000000000, + "Cash": -5000000000000000000000, + "Perps": 0, "Base": 5000000000000000000, "SpotPrice": 1500000000000000000000, "SpotConfidence": 1000000000000000000, @@ -2162,7 +2077,7 @@ 1000000000000000000 ], "StablePrice": 1000000000000000000, - "UnrealisedPerpPNL": -63000000000000000000, + "UnrealisedPerpPNL": 0, "UnrealisedFunding": 0, "VolShockUp": [ 1.5681511166375728, @@ -2200,7 +2115,7 @@ ] }, "ActionCount": 3, - "LiquidationFee": 16.264543471042824, + "LiquidationFee": 8.723085851319075, "Actions": [ { "Time": 1, @@ -2238,12 +2153,12 @@ -1600000000000000000 ], "OptionVols": [ - 1077307287018514688, - 1143578187182830720, - 1171703284439064064, - 1173072277125157120, - 1059335143046964608, - 1266806217053655296 + 1081048412866353792, + 1138939398052892160, + 1175456213289622784, + 1168496419451440128, + 1062799244178520832, + 1262509092493988864 ], "SVIparams": [ 1, @@ -2260,12 +2175,12 @@ 1000000000000000000, 1000000000000000000 ], - "Cash": -4216264543471042822144, - "Perps": 1000000000000000000, + "Cash": -5008723085851319336960, + "Perps": 0, "Base": 5000000000000000000, - "SpotPrice": 1510000000000000000000, + "SpotPrice": 1500000000000000000000, "SpotConfidence": 1000000000000000000, - "PerpPrice": 1515000000000000000000, + "PerpPrice": 1505000000000000000000, "PerpConfidence": 1000000000000000000, "FeedExpiries": [ 1191599, @@ -2276,12 +2191,12 @@ 1191599 ], "Forwards": [ - 1511998277143696769024, - 1510838832829607444480, - 1523057472435638239232, - 1510838832829607444480, - 1514174633999096872960, - 1511998277143696769024 + 1501985043520228950016, + 1500833277645305413632, + 1512970999108249845760, + 1500833277645305413632, + 1504146987416321261568, + 1501985043520228950016 ], "ForwardConfidences": [ 1000000000000000000, @@ -2308,7 +2223,7 @@ 1000000000000000000 ], "StablePrice": 1000000000000000000, - "UnrealisedPerpPNL": -53000000000000000000, + "UnrealisedPerpPNL": 0, "UnrealisedFunding": 0, "VolShockUp": [ 1.5681512596767035, @@ -2326,7 +2241,7 @@ 0.6962770273617649, 0.6212324935488645 ], - "SettlementPrice": 1510838832829607444480, + "SettlementPrice": 1500833277645305413632, "PercentFixed": 0, "ForwardsFixed": [ 0, @@ -2337,29 +2252,29 @@ 0 ], "ForwardsVariable": [ - 1511998277143696769024, - 1510838832829607444480, - 1523057472435638239232, - 1510838832829607444480, - 1514174633999096872960, - 1511998277143696769024 + 1501985043520228950016, + 1500833277645305413632, + 1512970999108249845760, + 1500833277645305413632, + 1504146987416321261568, + 1501985043520228950016 ] }, "Liquidator": { "PercentWant": 212000000000000000 }, "Results": { - "PreMtM": 1267017661980376825856, - "PreMM": -1672178334671392735232, - "PreBM": -2260017534001746804736, - "PreFMax": 645827386460660352, - "ExpectedBidPrice": 262752095513231392768, + "PreMtM": 510089056180759166976, + "PreMM": -2203579942180327522304, + "PreBM": -2746313741852544598016, + "PreFMax": 846247881370359424, + "ExpectedBidPrice": 105781452328275935232, "FinalPercentageReceived": 212000000000000000, "fLiquidatedOfOriginal": 212000000000000000, - "PostMtM": 1261162013153768505344, - "PostMM": -1054924432207826386944, - "PostBM": -1518141721280145522688, - "PostFMax": 550542368604898816 + "PostMtM": 507731628598714433536, + "PostMM": -1630639542109820944384, + "PostBM": -2058313776251528019968, + "PostFMax": 804883098185735168 } }, { @@ -2398,12 +2313,12 @@ -1260800000000000256 ], "OptionVols": [ - 1073625031002286976, - 1148178475668307328, - 1167966725683237376, - 1177605942516402432, - 1055994002402481024, - 1271061686714528000 + 1081048600443659648, + 1138939166206683392, + 1175456400499937280, + 1168496190632824064, + 1062799419362179456, + 1262508877555349760 ], "SVIparams": [ 1, @@ -2420,12 +2335,12 @@ 1000000000000000000, 1000000000000000000 ], - "Cash": -3059664364741950701568, - "Perps": 788000000000000000, + "Cash": -3841092339322564116480, + "Perps": 0, "Base": 3940000000000000512, - "SpotPrice": 1520000000000000000000, + "SpotPrice": 1500000000000000000000, "SpotConfidence": 1000000000000000000, - "PerpPrice": 1525000000000000000000, + "PerpPrice": 1505000000000000000000, "PerpConfidence": 1000000000000000000, "FeedExpiries": [ 1191300, @@ -2436,12 +2351,12 @@ 1191300 ], "Forwards": [ - 1522011005698423914496, - 1520843883332469784576, - 1533143437000065679360, - 1520843883332469784576, - 1524201774786140176384, - 1522011005698423914496 + 1501984545097129132032, + 1500832779604410761216, + 1512970497039538585600, + 1500832779604410761216, + 1504146488275796230144, + 1501984545097129132032 ], "ForwardConfidences": [ 1000000000000000000, @@ -2468,7 +2383,7 @@ 1000000000000000000 ], "StablePrice": 1000000000000000000, - "UnrealisedPerpPNL": -33884000000000000000, + "UnrealisedPerpPNL": 0, "UnrealisedFunding": 0, "VolShockUp": [ 1.5681940353769965, @@ -2486,7 +2401,7 @@ 0.6962660745999473, 0.6212039764153356 ], - "SettlementPrice": 1520843883332469784576, + "SettlementPrice": 1500832779604410761216, "PercentFixed": 0, "ForwardsFixed": [ 0, @@ -2497,29 +2412,29 @@ 0 ], "ForwardsVariable": [ - 1522011005698423914496, - 1520843883332469784576, - 1533143437000065679360, - 1520843883332469784576, - 1524201774786140176384, - 1522011005698423914496 + 1501984545097129132032, + 1500832779604410761216, + 1512970497039538585600, + 1500832779604410761216, + 1504146488275796230144, + 1501984545097129132032 ] }, "Liquidator": { - "PercentWant": 140000000000000016 + "PercentWant": 177664974619289344 }, "Results": { - "PreMtM": 1282139939925138604032, - "PreMM": -1010205953757457809408, - "PreBM": -1468675132493976829952, - "PreFMax": 579219426304514560, - "ExpectedBidPrice": 142875284453671190528, + "PreMtM": 507870376293439242240, + "PreMM": -1630279398986097360896, + "PreBM": -2057909354042004865024, + "PreFMax": 829503039144855296, + "ExpectedBidPrice": 56355949015985954816, "FinalPercentageReceived": 177664974619289344, - "fLiquidatedOfOriginal": 140000000000000016, - "PostMtM": 1243905708874155950080, - "PostMM": -641170609788690366464, - "PostBM": -1018185873521259446272, - "PostFMax": 488310043098700096 + "fLiquidatedOfOriginal": 177664974619289344, + "PostMtM": 492789206838456287232, + "PostMM": -1265486242883802234880, + "PostBM": -1617141332828253847552, + "PostFMax": 792667275997139072 } }, { @@ -2558,12 +2473,12 @@ -1036800000000000128 ], "OptionVols": [ - 1092574198714486144, - 1124794262461757312, - 1186817279412732672, - 1154508913406808832, - 1073774576826392448, - 1249356163864710912 + 1081053431053289728, + 1138933195579575424, + 1175461221627552256, + 1168490297969628672, + 1062803930850502656, + 1262503342334851840 ], "SVIparams": [ 1, @@ -2580,12 +2495,12 @@ 1000000000000000000, 1000000000000000000 ], - "Cash": -2326512044202333569024, - "Perps": 648000000000000000, + "Cash": -3083515158287393226752, + "Perps": 0, "Base": 3240000000000000000, - "SpotPrice": 1470000000000000000000, + "SpotPrice": 1500000000000000000000, "SpotConfidence": 1000000000000000000, - "PerpPrice": 1475000000000000000000, + "PerpPrice": 1505000000000000000000, "PerpConfidence": 1000000000000000000, "FeedExpiries": [ 1183600, @@ -2596,12 +2511,12 @@ 1183600 ], "Forwards": [ - 1471932275318880206848, - 1470803554781864656896, - 1482698416216880447488, - 1470803554781864656896, - 1474050961528051204096, - 1471932275318880206848 + 1501971709509061050368, + 1500819953859045621760, + 1512957567568245424128, + 1500819953859045621760, + 1504133634212297179136, + 1501971709509061050368 ], "ForwardConfidences": [ 1000000000000000000, @@ -2628,7 +2543,7 @@ 1000000000000000000 ], "StablePrice": 1000000000000000000, - "UnrealisedPerpPNL": -60264000000000000000, + "UnrealisedPerpPNL": 0, "UnrealisedFunding": 0, "VolShockUp": [ 1.5693004485466155, @@ -2646,7 +2561,7 @@ 0.6959834225060578, 0.6204663676355897 ], - "SettlementPrice": 1470803554781864656896, + "SettlementPrice": 1500819953859045621760, "PercentFixed": 0, "ForwardsFixed": [ 0, @@ -2657,29 +2572,128 @@ 0 ], "ForwardsVariable": [ - 1471932275318880206848, - 1470803554781864656896, - 1482698416216880447488, - 1470803554781864656896, - 1474050961528051204096, - 1471932275318880206848 + 1501971709509061050368, + 1500819953859045621760, + 1512957567568245424128, + 1500819953859045621760, + 1504133634212297179136, + 1501971709509061050368 ] }, "Liquidator": { - "PercentWant": 923900000000000000 + "PercentWant": 1000000000000000000 + }, + "Results": { + "PreMtM": 495719167035687436288, + "PreMM": -1257829300755020906496, + "PreBM": -1608538994313162653696, + "PreFMax": 850567377484409856, + "ExpectedBidPrice": 102459416085279768576, + "FinalPercentageReceived": 850567377484409856, + "fLiquidatedOfOriginal": 850567377484409856, + "PostMtM": 314444815500192514048, + "PostMM": 52407469250032189440, + "PostBM": 113686, + "PostFMax": -402 + } + } + ] + }, + "test_Nov_05_borrow": { + "StartTime": 0, + "IsForce": false, + "InitialPortfolio": { + "OptionExpiries": [], + "OptionStrikes": [], + "OptionIsCall": [], + "OptionAmounts": [], + "OptionVols": [], + "SVIparams": [ + 1, + 1.5, + -0.1, + -0.05, + 0.05 + ], + "OptionVolConfidences": [], + "Cash": -1250000000000000000000, + "Perps": 0, + "Base": 1000000000000000000, + "SpotPrice": 1500000000000000000000, + "SpotConfidence": 1000000000000000000, + "PerpPrice": 1505000000000000000000, + "PerpConfidence": 1000000000000000000, + "FeedExpiries": [], + "Forwards": [], + "ForwardConfidences": [], + "Rates": [], + "RateConfidences": [], + "StablePrice": 1000000000000000000, + "UnrealisedPerpPNL": 0, + "UnrealisedFunding": 0, + "VolShockUp": [], + "VolShockDown": [], + "SettlementPrice": null, + "PercentFixed": null, + "ForwardsFixed": [], + "ForwardsVariable": [] + }, + "ActionCount": 1, + "LiquidationFee": 0.9150326797385621, + "Actions": [ + { + "Time": 1, + "PortfolioAndFeeds": { + "OptionExpiries": [], + "OptionStrikes": [], + "OptionIsCall": [], + "OptionAmounts": [], + "OptionVols": [], + "SVIparams": [ + 1, + 1.5, + -0.1, + -0.05, + 0.05 + ], + "OptionVolConfidences": [], + "Cash": -1250915032679738507264, + "Perps": 0, + "Base": 1000000000000000000, + "SpotPrice": 1500000000000000000000, + "SpotConfidence": 1000000000000000000, + "PerpPrice": 1505000000000000000000, + "PerpConfidence": 1000000000000000000, + "FeedExpiries": [], + "Forwards": [], + "ForwardConfidences": [], + "Rates": [], + "RateConfidences": [], + "StablePrice": 1000000000000000000, + "UnrealisedPerpPNL": 0, + "UnrealisedFunding": 0, + "VolShockUp": [], + "VolShockDown": [], + "SettlementPrice": null, + "PercentFixed": null, + "ForwardsFixed": [], + "ForwardsVariable": [] + }, + "Liquidator": { + "PercentWant": 1000000000000000000 }, "Results": { - "PreMtM": 1154588646360142053376, - "PreMM": -825252423175791443968, - "PreBM": -1221220637082977828864, - "PreFMax": 643660260808136960, - "ExpectedBidPrice": 174083218133451309056, - "FinalPercentageReceived": 643660260808136960, - "fLiquidatedOfOriginal": 417091849003672768, - "PostMtM": 846595260431728377856, - "PostMM": 141099210071954620416, - "PostBM": -113686, - "PostFMax": 168 + "PreMtM": 249084967320261525504, + "PreMM": -5915032679738487808, + "PreBM": -56915032679738490880, + "PreFMax": 189357030245066656, + "ExpectedBidPrice": 46137771115202289664, + "FinalPercentageReceived": 189357030245066656, + "fLiquidatedOfOriginal": 189357030245066656, + "PostMtM": 248056748745009725440, + "PostMM": 41342791457501675520, + "PostBM": 85265, + "PostFMax": -349 } } ] diff --git a/test/integration-tests/liquidation/PM_liquidationSimTests.t.sol b/test/integration-tests/liquidation/PM_liquidationSimTests.t.sol index d90b48a1..80f07648 100644 --- a/test/integration-tests/liquidation/PM_liquidationSimTests.t.sol +++ b/test/integration-tests/liquidation/PM_liquidationSimTests.t.sol @@ -9,65 +9,73 @@ import "./util/LiquidationSimBase.sol"; contract LiquidationSimTests_PM is LiquidationSimBase { using stdJson for string; - function testLiquidationSim1() public { - runLiquidationSim("PMRM_solvent", "Test1"); - } + // function testLiquidationSim1() public { + // runLiquidationSim("PMRM_solvent", "Test1"); + // } - function testLiquidationSim2() public { - runLiquidationSim("PMRM_solvent", "Test2"); - } + // function testLiquidationSim2() public { + // runLiquidationSim("PMRM_solvent", "Test2"); + // } - function testLiquidationSim3() public { - runLiquidationSim("PMRM_solvent", "Test3"); - } + // function testLiquidationSim3() public { + // runLiquidationSim("PMRM_solvent", "Test3"); + // } - function testLiquidationSim4() public { - runLiquidationSim("PMRM_solvent", "Test4"); - } + // function testLiquidationSim4() public { + // runLiquidationSim("PMRM_solvent", "Test4"); + // } - function testLiquidationSim5() public { - runLiquidationSim("PMRM_solvent", "Test5"); - } + // function testLiquidationSim5() public { + // runLiquidationSim("PMRM_solvent", "Test5"); + // } - function testLiquidationSim6() public { - runLiquidationSim("PMRM_solvent", "Test6"); - } + // function testLiquidationSim6() public { + // runLiquidationSim("PMRM_solvent", "Test6"); + // } - function testLiquidationSimLong_Box_Short_Cash() public { - runLiquidationSim("PMRM_solvent", "test_Nov_01_long_box_neg_cash"); - } + // function testLiquidationSimLong_Box_Short_Cash() public { + // runLiquidationSim("PMRM_solvent", "test_Nov_01_long_box_neg_cash"); + // } - function testLiquidationSimSimple_Short_3_liquidators() public { - runLiquidationSim("PMRM_solvent", "test_Nov_02_3_liqs_same_price_same_amount"); - } + // function testLiquidationSimSimple_Short_3_liquidators() public { + // runLiquidationSim("PMRM_solvent", "test_Nov_02_3_liqs_same_price_same_amount"); + // } - function testLiquidationSimPMRM_perp() public { - runLiquidationSim("PMRM_solvent", "test_Nov_03_perp"); - } + // function testLiquidationSimPMRM_perp() public { + // runLiquidationSim("PMRM_solvent", "test_Nov_03_perp"); + // } - function testLiquidationSim_insolvent_1() public { - runLiquidationSim("PMRM_insolvent", "test_Nov_01_Insolvent_basic"); - } + // function testLiquidationSimPMRM_General() public { + // runLiquidationSim("PMRM_solvent", "test_Nov_04_general"); + // } - function testLiquidationSim_insolvent_2() public { - runLiquidationSim("PMRM_insolvent", "test_Nov_02_Insolvent_basic_mtm_pos"); + function testLiquidationSimPMRM_Borrow() public { + runLiquidationSim("PMRM_solvent", "test_Nov_05_borrow"); } - function testLiquidationSim_insolvent_3() public { - runLiquidationSim("PMRM_insolvent", "test_Nov_03_Insolvent_basic_at_end"); - } + // function testLiquidationSim_insolvent_1() public { + // runLiquidationSim("PMRM_insolvent", "test_Nov_01_Insolvent_basic"); + // } - function testLiquidationSim_insolvent_4() public { - runLiquidationSim("PMRM_insolvent", "test_Nov_04_Insolvent_two_liq_same_disc_same_amount"); - } + // function testLiquidationSim_insolvent_2() public { + // runLiquidationSim("PMRM_insolvent", "test_Nov_02_Insolvent_basic_mtm_pos"); + // } - function testLiquidationSim_insolvent_5() public { - runLiquidationSim("PMRM_insolvent", "test_Nov_05_Insolvent_two_liq_same_disc_diff_amount"); - } + // function testLiquidationSim_insolvent_3() public { + // runLiquidationSim("PMRM_insolvent", "test_Nov_03_Insolvent_basic_at_end"); + // } - function testLiquidationSim_insolvent_6() public { - runLiquidationSim("PMRM_insolvent", "test_Nov_06_Insolvent_General"); - } + // function testLiquidationSim_insolvent_4() public { + // runLiquidationSim("PMRM_insolvent", "test_Nov_04_Insolvent_two_liq_same_disc_same_amount"); + // } + + // function testLiquidationSim_insolvent_5() public { + // runLiquidationSim("PMRM_insolvent", "test_Nov_05_Insolvent_two_liq_same_disc_diff_amount"); + // } + + // function testLiquidationSim_insolvent_6() public { + // runLiquidationSim("PMRM_insolvent", "test_Nov_06_Insolvent_General"); + // } // function testInsolventSim1() public { // runLiquidationSim("InsolventTest1"); From d2a7d142da47b34a8d0db44c679cef56e7fe5587 Mon Sep 17 00:00:00 2001 From: SeanDaws <68123079+SeanDaws@users.noreply.github.com> Date: Thu, 16 Nov 2023 15:24:30 -0500 Subject: [PATCH 06/14] sean tests --- .../liquidation/PMRM_solvent.json | 77 ++++++++++++++++--- .../liquidation/PM_liquidationSimTests.t.sol | 3 + .../liquidation/util/LiquidationSimBase.sol | 1 + 3 files changed, 70 insertions(+), 11 deletions(-) diff --git a/test/integration-tests/liquidation/PMRM_solvent.json b/test/integration-tests/liquidation/PMRM_solvent.json index 5f716bae..488efb52 100644 --- a/test/integration-tests/liquidation/PMRM_solvent.json +++ b/test/integration-tests/liquidation/PMRM_solvent.json @@ -2638,11 +2638,11 @@ "ForwardsFixed": [], "ForwardsVariable": [] }, - "ActionCount": 1, + "ActionCount": 2, "LiquidationFee": 0.9150326797385621, "Actions": [ { - "Time": 1, + "Time": 0, "PortfolioAndFeeds": { "OptionExpiries": [], "OptionStrikes": [], @@ -2680,20 +2680,75 @@ "ForwardsVariable": [] }, "Liquidator": { - "PercentWant": 1000000000000000000 + "PercentWant": 100000000000 }, "Results": { "PreMtM": 249084967320261525504, "PreMM": -5915032679738487808, "PreBM": -56915032679738490880, - "PreFMax": 189357030245066656, - "ExpectedBidPrice": 46137771115202289664, - "FinalPercentageReceived": 189357030245066656, - "fLiquidatedOfOriginal": 189357030245066656, - "PostMtM": 248056748745009725440, - "PostMM": 41342791457501675520, - "PostBM": 85265, - "PostFMax": -349 + "PreFMax": 189074991640574880, + "ExpectedBidPrice": 24410326797385, + "FinalPercentageReceived": 100000000000, + "fLiquidatedOfOriginal": 100000000000, + "PostMtM": 249084966822091685888, + "PostMM": -5915007677908306944, + "PostBM": -56915002577908293632, + "PostFMax": 189074910548065536 + } + }, + { + "Time": 0, + "PortfolioAndFeeds": { + "OptionExpiries": [], + "OptionStrikes": [], + "OptionIsCall": [], + "OptionAmounts": [], + "OptionVols": [], + "SVIparams": [ + 1, + 1.5, + -0.1, + -0.05, + 0.05 + ], + "OptionVolConfidences": [], + "Cash": -1250914883177908535296, + "Perps": 0, + "Base": 999999900000000000, + "SpotPrice": 1500000000000000000000, + "SpotConfidence": 1000000000000000000, + "PerpPrice": 1505000000000000000000, + "PerpConfidence": 1000000000000000000, + "FeedExpiries": [], + "Forwards": [], + "ForwardConfidences": [], + "Rates": [], + "RateConfidences": [], + "StablePrice": 1000000000000000000, + "UnrealisedPerpPNL": 0, + "UnrealisedFunding": 0, + "VolShockUp": [], + "VolShockDown": [], + "SettlementPrice": null, + "PercentFixed": null, + "ForwardsFixed": [], + "ForwardsVariable": [] + }, + "Liquidator": { + "PercentWant": 50000005000000496 + }, + "Results": { + "PreMtM": 249084966822091685888, + "PreMM": -5915007677908306944, + "PreBM": -56915002577908293632, + "PreFMax": 189074910548065536, + "ExpectedBidPrice": 12205163398692818944, + "FinalPercentageReceived": 50000005000000496, + "fLiquidatedOfOriginal": 50000005000000496, + "PostMtM": 248835881854771298304, + "PostMM": 6585907354771279872, + "PostBM": -41864087545228697600, + "PostFMax": 146394638189514496 } } ] diff --git a/test/integration-tests/liquidation/PM_liquidationSimTests.t.sol b/test/integration-tests/liquidation/PM_liquidationSimTests.t.sol index 80f07648..98bbaa75 100644 --- a/test/integration-tests/liquidation/PM_liquidationSimTests.t.sol +++ b/test/integration-tests/liquidation/PM_liquidationSimTests.t.sol @@ -88,6 +88,7 @@ contract LiquidationSimTests_PM is LiquidationSimBase { function runLiquidationSim(string memory fileName, string memory testName) internal { LiquidationSim memory data = LiquidationSimBase.getTestData(fileName, testName); setupTestScenario(data); + vm.warp(data.StartTime); startAuction(); @@ -148,6 +149,7 @@ contract LiquidationSimTests_PM is LiquidationSimBase { assertApproxEqRel(mtm, data.Actions[actionId].Results.PostMtM, 0.001e18, "post mtm"); assertApproxEqRel(mm, data.Actions[actionId].Results.PostMM, 0.001e18, "post mm"); + if (data.Actions[actionId].Results.PostBM == 0) { assertGt(bm, 0, "post bm"); } else { @@ -171,6 +173,7 @@ contract LiquidationSimTests_PM is LiquidationSimBase { worstScenario = i; } } + console2.log("worst scenario", worstScenario); } function updateToActionState(LiquidationSim memory data, uint actionId) internal { diff --git a/test/integration-tests/liquidation/util/LiquidationSimBase.sol b/test/integration-tests/liquidation/util/LiquidationSimBase.sol index 831369b6..be414a99 100644 --- a/test/integration-tests/liquidation/util/LiquidationSimBase.sol +++ b/test/integration-tests/liquidation/util/LiquidationSimBase.sol @@ -242,6 +242,7 @@ contract LiquidationSimBase is PMRMTestBase { subId: 0, balance: data.InitialPortfolio.BasePosition }); + } setBalances(aliceAcc, balances); From aa303333e1330b203701e4e6dff4505be02a02b9 Mon Sep 17 00:00:00 2001 From: SeanDaws <68123079+SeanDaws@users.noreply.github.com> Date: Thu, 16 Nov 2023 15:42:12 -0500 Subject: [PATCH 07/14] sean push --- .../liquidation/PMRM_insolvent.json | 8 ++-- .../liquidation/PMRM_solvent.json | 44 +++++++++---------- .../liquidation/PM_liquidationSimTests.t.sol | 14 +++--- 3 files changed, 33 insertions(+), 33 deletions(-) diff --git a/test/integration-tests/liquidation/PMRM_insolvent.json b/test/integration-tests/liquidation/PMRM_insolvent.json index 549389a6..486f049d 100644 --- a/test/integration-tests/liquidation/PMRM_insolvent.json +++ b/test/integration-tests/liquidation/PMRM_insolvent.json @@ -878,7 +878,7 @@ ] }, "Liquidator": { - "PercentWant": 100000000000000000 + "PercentWant": 111111111111111120 }, "Results": { "PreMtM": -671041165721540886528, @@ -1300,7 +1300,7 @@ ] }, "Liquidator": { - "PercentWant": 500000000000000000 + "PercentWant": 555555555555555584 }, "Results": { "PreMtM": -671041165721540886528, @@ -1767,7 +1767,7 @@ ] }, "Liquidator": { - "PercentWant": 532000000000000000 + "PercentWant": 592691622103386880 }, "Results": { "PreMtM": 132518228046353661952, @@ -1943,4 +1943,4 @@ } ] } -} \ No newline at end of file +} diff --git a/test/integration-tests/liquidation/PMRM_solvent.json b/test/integration-tests/liquidation/PMRM_solvent.json index 488efb52..3ef8c4b4 100644 --- a/test/integration-tests/liquidation/PMRM_solvent.json +++ b/test/integration-tests/liquidation/PMRM_solvent.json @@ -2680,20 +2680,20 @@ "ForwardsVariable": [] }, "Liquidator": { - "PercentWant": 100000000000 + "PercentWant": 100000000000000000 }, "Results": { "PreMtM": 249084967320261525504, "PreMM": -5915032679738487808, "PreBM": -56915032679738490880, "PreFMax": 189074991640574880, - "ExpectedBidPrice": 24410326797385, - "FinalPercentageReceived": 100000000000, - "fLiquidatedOfOriginal": 100000000000, - "PostMtM": 249084966822091685888, - "PostMM": -5915007677908306944, - "PostBM": -56915002577908293632, - "PostFMax": 189074910548065536 + "ExpectedBidPrice": 24410326797385629696, + "FinalPercentageReceived": 100000000000000000, + "fLiquidatedOfOriginal": 100000000000000000, + "PostMtM": 248586797385620914176, + "PostMM": 19086797385620910080, + "PostBM": -26813202614379065344, + "PostFMax": 98972212933972304 } }, { @@ -2712,9 +2712,9 @@ 0.05 ], "OptionVolConfidences": [], - "Cash": -1250914883177908535296, + "Cash": -1101413202614379085824, "Perps": 0, - "Base": 999999900000000000, + "Base": 900000000000000000, "SpotPrice": 1500000000000000000000, "SpotConfidence": 1000000000000000000, "PerpPrice": 1505000000000000000000, @@ -2735,20 +2735,20 @@ "ForwardsVariable": [] }, "Liquidator": { - "PercentWant": 50000005000000496 + "PercentWant": 111111111111111120 }, "Results": { - "PreMtM": 249084966822091685888, - "PreMM": -5915007677908306944, - "PreBM": -56915002577908293632, - "PreFMax": 189074910548065536, - "ExpectedBidPrice": 12205163398692818944, - "FinalPercentageReceived": 50000005000000496, - "fLiquidatedOfOriginal": 50000005000000496, - "PostMtM": 248835881854771298304, - "PostMM": 6585907354771279872, - "PostBM": -41864087545228697600, - "PostFMax": 146394638189514496 + "PreMtM": 248586797385620914176, + "PreMM": 19086797385620910080, + "PreBM": -26813202614379065344, + "PreFMax": 98972212933972304, + "ExpectedBidPrice": 21743496554208296960, + "FinalPercentageReceived": 98972212933972304, + "fLiquidatedOfOriginal": 98972212933972304, + "PostMtM": 248143052557984006144, + "PostMM": 41357175426330624000, + "PostBM": -28421, + "PostFMax": 116 } } ] diff --git a/test/integration-tests/liquidation/PM_liquidationSimTests.t.sol b/test/integration-tests/liquidation/PM_liquidationSimTests.t.sol index 98bbaa75..2e1076da 100644 --- a/test/integration-tests/liquidation/PM_liquidationSimTests.t.sol +++ b/test/integration-tests/liquidation/PM_liquidationSimTests.t.sol @@ -45,14 +45,14 @@ contract LiquidationSimTests_PM is LiquidationSimBase { // runLiquidationSim("PMRM_solvent", "test_Nov_03_perp"); // } - // function testLiquidationSimPMRM_General() public { - // runLiquidationSim("PMRM_solvent", "test_Nov_04_general"); - // } - - function testLiquidationSimPMRM_Borrow() public { - runLiquidationSim("PMRM_solvent", "test_Nov_05_borrow"); + function testLiquidationSimPMRM_General() public { + runLiquidationSim("PMRM_solvent", "test_Nov_04_general"); } + // function testLiquidationSimPMRM_Borrow() public { + // runLiquidationSim("PMRM_solvent", "test_Nov_05_borrow"); + // } + // function testLiquidationSim_insolvent_1() public { // runLiquidationSim("PMRM_insolvent", "test_Nov_01_Insolvent_basic"); // } @@ -165,7 +165,7 @@ contract LiquidationSimTests_PM is LiquidationSimBase { function getWorstScenario(uint account) internal view returns (uint worstScenario) { worstScenario = 0; - int worstMM = 0; + int worstMM = type(int).max; for (uint i = 0; i < pmrm.getScenarios().length; ++i) { (int mm_,,) = auction.getMarginAndMarkToMarket(account, i); if (mm_ < worstMM) { From 6386cab2d034b59e561bdce5819df154c241cbab Mon Sep 17 00:00:00 2001 From: SeanDaws <68123079+SeanDaws@users.noreply.github.com> Date: Thu, 16 Nov 2023 16:22:18 -0500 Subject: [PATCH 08/14] general test with spot changes --- .../liquidation/PMRM_solvent.json | 188 +++++++++--------- 1 file changed, 94 insertions(+), 94 deletions(-) diff --git a/test/integration-tests/liquidation/PMRM_solvent.json b/test/integration-tests/liquidation/PMRM_solvent.json index 3ef8c4b4..f36346dc 100644 --- a/test/integration-tests/liquidation/PMRM_solvent.json +++ b/test/integration-tests/liquidation/PMRM_solvent.json @@ -2153,12 +2153,12 @@ -1600000000000000000 ], "OptionVols": [ - 1081048412866353792, - 1138939398052892160, - 1175456213289622784, - 1168496419451440128, - 1062799244178520832, - 1262509092493988864 + 1078423755029964032, + 1142190546545185152, + 1172827463800546816, + 1171703938269880576, + 1060362341064233600, + 1265521462825042944 ], "SVIparams": [ 1, @@ -2178,9 +2178,9 @@ "Cash": -5008723085851319336960, "Perps": 0, "Base": 5000000000000000000, - "SpotPrice": 1500000000000000000000, + "SpotPrice": 1507000000000000000000, "SpotConfidence": 1000000000000000000, - "PerpPrice": 1505000000000000000000, + "PerpPrice": 1512000000000000000000, "PerpConfidence": 1000000000000000000, "FeedExpiries": [ 1191599, @@ -2191,12 +2191,12 @@ 1191599 ], "Forwards": [ - 1501985043520228950016, - 1500833277645305413632, - 1512970999108249845760, - 1500833277645305413632, - 1504146987416321261568, - 1501985043520228950016 + 1508994307056656449536, + 1507837166274316599296, + 1520031530437421563904, + 1507837166274316599296, + 1511166340024264294400, + 1508994307056656449536 ], "ForwardConfidences": [ 1000000000000000000, @@ -2241,7 +2241,7 @@ 0.6962770273617649, 0.6212324935488645 ], - "SettlementPrice": 1500833277645305413632, + "SettlementPrice": 1507837166274316599296, "PercentFixed": 0, "ForwardsFixed": [ 0, @@ -2252,29 +2252,29 @@ 0 ], "ForwardsVariable": [ - 1501985043520228950016, - 1500833277645305413632, - 1512970999108249845760, - 1500833277645305413632, - 1504146987416321261568, - 1501985043520228950016 + 1508994307056656449536, + 1507837166274316599296, + 1520031530437421563904, + 1507837166274316599296, + 1511166340024264294400, + 1508994307056656449536 ] }, "Liquidator": { "PercentWant": 212000000000000000 }, "Results": { - "PreMtM": 510089056180759166976, - "PreMM": -2203579942180327522304, - "PreBM": -2746313741852544598016, - "PreFMax": 846247881370359424, - "ExpectedBidPrice": 105781452328275935232, + "PreMtM": 522426271073480146944, + "PreMM": -2168856402462630215680, + "PreBM": -2707112937169852301312, + "PreFMax": 841201520047924992, + "ExpectedBidPrice": 108339924213184593920, "FinalPercentageReceived": 212000000000000000, "fLiquidatedOfOriginal": 212000000000000000, - "PostMtM": 507731628598714433536, - "PostMM": -1630639542109820944384, - "PostBM": -2058313776251528019968, - "PostFMax": 804883098185735168 + "PostMtM": 520011825819087798272, + "PostMM": -1600718920927366610944, + "PostBM": -2024865070276657283072, + "PostFMax": 798479086355234560 } }, { @@ -2313,12 +2313,12 @@ -1260800000000000256 ], "OptionVols": [ - 1081048600443659648, - 1138939166206683392, - 1175456400499937280, - 1168496190632824064, - 1062799419362179456, - 1262508877555349760 + 1084842456681448704, + 1134262687039083264, + 1179225523223866624, + 1163878129543114240, + 1066368911453592320, + 1258169606786900736 ], "SVIparams": [ 1, @@ -2335,12 +2335,12 @@ 1000000000000000000, 1000000000000000000 ], - "Cash": -3841092339322564116480, + "Cash": -3838533867437655326720, "Perps": 0, "Base": 3940000000000000512, - "SpotPrice": 1500000000000000000000, + "SpotPrice": 1490000000000000000000, "SpotConfidence": 1000000000000000000, - "PerpPrice": 1505000000000000000000, + "PerpPrice": 1495000000000000000000, "PerpConfidence": 1000000000000000000, "FeedExpiries": [ 1191300, @@ -2351,12 +2351,12 @@ 1191300 ], "Forwards": [ - 1501984545097129132032, - 1500832779604410761216, - 1512970497039538585600, - 1500832779604410761216, - 1504146488275796230144, - 1501984545097129132032 + 1491971314796481478656, + 1490827227740381380608, + 1502884027059275038720, + 1490827227740381380608, + 1494118845020624125952, + 1491971314796481478656 ], "ForwardConfidences": [ 1000000000000000000, @@ -2401,7 +2401,7 @@ 0.6962660745999473, 0.6212039764153356 ], - "SettlementPrice": 1500832779604410761216, + "SettlementPrice": 1490827227740381380608, "PercentFixed": 0, "ForwardsFixed": [ 0, @@ -2412,29 +2412,29 @@ 0 ], "ForwardsVariable": [ - 1501984545097129132032, - 1500832779604410761216, - 1512970497039538585600, - 1500832779604410761216, - 1504146488275796230144, - 1501984545097129132032 + 1491971314796481478656, + 1490827227740381380608, + 1502884027059275038720, + 1490827227740381380608, + 1494118845020624125952, + 1491971314796481478656 ] }, "Liquidator": { "PercentWant": 177664974619289344 }, "Results": { - "PreMtM": 507870376293439242240, - "PreMM": -1630279398986097360896, - "PreBM": -2057909354042004865024, - "PreFMax": 829503039144855296, - "ExpectedBidPrice": 56355949015985954816, + "PreMtM": 495836096830023073792, + "PreMM": -1667768991089948884992, + "PreBM": -2100490008673943027712, + "PreFMax": 835343872515414272, + "ExpectedBidPrice": 54310659275400101888, "FinalPercentageReceived": 177664974619289344, "fLiquidatedOfOriginal": 177664974619289344, - "PostMtM": 492789206838456287232, - "PostMM": -1265486242883802234880, - "PostBM": -1617141332828253847552, - "PostFMax": 792667275997139072 + "PostMtM": 481302258432380764160, + "PostMM": -1297905986456124129280, + "PostBM": -1653747635433825107968, + "PostFMax": 799770017811954432 } }, { @@ -2473,12 +2473,12 @@ -1036800000000000128 ], "OptionVols": [ - 1081053431053289728, - 1138933195579575424, - 1175461221627552256, - 1168490297969628672, - 1062803930850502656, - 1262503342334851840 + 1073629773311693312, + 1148172524809817600, + 1167971569048958720, + 1177600080291231744, + 1055998254219873152, + 1271056185355171840 ], "SVIparams": [ 1, @@ -2495,12 +2495,12 @@ 1000000000000000000, 1000000000000000000 ], - "Cash": -3083515158287393226752, + "Cash": -3083001976143070363648, "Perps": 0, "Base": 3240000000000000000, - "SpotPrice": 1500000000000000000000, + "SpotPrice": 1520000000000000000000, "SpotConfidence": 1000000000000000000, - "PerpPrice": 1505000000000000000000, + "PerpPrice": 1525000000000000000000, "PerpConfidence": 1000000000000000000, "FeedExpiries": [ 1183600, @@ -2511,12 +2511,12 @@ 1183600 ], "Forwards": [ - 1501971709509061050368, - 1500819953859045621760, - 1512957567568245424128, - 1500819953859045621760, - 1504133634212297179136, - 1501971709509061050368 + 1521997998969181962240, + 1520830886577166090240, + 1533130335135821987840, + 1520830886577166090240, + 1524188749335127916544, + 1521997998969181962240 ], "ForwardConfidences": [ 1000000000000000000, @@ -2561,7 +2561,7 @@ 0.6959834225060578, 0.6204663676355897 ], - "SettlementPrice": 1500819953859045621760, + "SettlementPrice": 1520830886577166090240, "PercentFixed": 0, "ForwardsFixed": [ 0, @@ -2572,29 +2572,29 @@ 0 ], "ForwardsVariable": [ - 1501971709509061050368, - 1500819953859045621760, - 1512957567568245424128, - 1500819953859045621760, - 1504133634212297179136, - 1501971709509061050368 + 1521997998969181962240, + 1520830886577166090240, + 1533130335135821987840, + 1520830886577166090240, + 1524188749335127916544, + 1521997998969181962240 ] }, "Liquidator": { "PercentWant": 1000000000000000000 }, "Results": { - "PreMtM": 495719167035687436288, - "PreMM": -1257829300755020906496, - "PreBM": -1608538994313162653696, - "PreFMax": 850567377484409856, - "ExpectedBidPrice": 102459416085279768576, - "FinalPercentageReceived": 850567377484409856, - "fLiquidatedOfOriginal": 850567377484409856, - "PostMtM": 314444815500192514048, - "PostMM": 52407469250032189440, - "PostBM": 113686, - "PostFMax": -402 + "PreMtM": 518023799241593192448, + "PreMM": -1194171051509298233344, + "PreBM": -1536610021659476492288, + "PreFMax": 840784952512938752, + "ExpectedBidPrice": 107897274452956332032, + "FinalPercentageReceived": 840784952512938752, + "fLiquidatedOfOriginal": 840784952512938752, + "PostMtM": 327128621363285983232, + "PostMM": 54521436893880885248, + "PostBM": -113686, + "PostFMax": 390 } } ] From 6ea0dc5ed8caeeec8d79f802d09a67114ced59c0 Mon Sep 17 00:00:00 2001 From: Dominic Romanowski Date: Fri, 17 Nov 2023 10:15:04 +1100 Subject: [PATCH 09/14] fixes/cleanup --- lib/lyra-utils | 2 +- .../liquidation/PM_liquidationSimTests.t.sol | 140 +++++++++--------- .../liquidation/util/LiquidationSimBase.sol | 20 ++- 3 files changed, 82 insertions(+), 80 deletions(-) diff --git a/lib/lyra-utils b/lib/lyra-utils index f64d5e3b..c81cdc39 160000 --- a/lib/lyra-utils +++ b/lib/lyra-utils @@ -1 +1 @@ -Subproject commit f64d5e3bab9da4807003d505fbd19b364ef64671 +Subproject commit c81cdc3905a83c42bc55741a0d57a51c9260be0b diff --git a/test/integration-tests/liquidation/PM_liquidationSimTests.t.sol b/test/integration-tests/liquidation/PM_liquidationSimTests.t.sol index 2e1076da..aee0e5e4 100644 --- a/test/integration-tests/liquidation/PM_liquidationSimTests.t.sol +++ b/test/integration-tests/liquidation/PM_liquidationSimTests.t.sol @@ -9,81 +9,81 @@ import "./util/LiquidationSimBase.sol"; contract LiquidationSimTests_PM is LiquidationSimBase { using stdJson for string; - // function testLiquidationSim1() public { - // runLiquidationSim("PMRM_solvent", "Test1"); - // } + function testLiquidationSim1() public { + runLiquidationSim("PMRM_solvent", "Test1"); + } - // function testLiquidationSim2() public { - // runLiquidationSim("PMRM_solvent", "Test2"); - // } + function testLiquidationSim2() public { + runLiquidationSim("PMRM_solvent", "Test2"); + } - // function testLiquidationSim3() public { - // runLiquidationSim("PMRM_solvent", "Test3"); - // } + function testLiquidationSim3() public { + runLiquidationSim("PMRM_solvent", "Test3"); + } - // function testLiquidationSim4() public { - // runLiquidationSim("PMRM_solvent", "Test4"); - // } + function testLiquidationSim4() public { + runLiquidationSim("PMRM_solvent", "Test4"); + } - // function testLiquidationSim5() public { - // runLiquidationSim("PMRM_solvent", "Test5"); - // } + function testLiquidationSim5() public { + runLiquidationSim("PMRM_solvent", "Test5"); + } - // function testLiquidationSim6() public { - // runLiquidationSim("PMRM_solvent", "Test6"); - // } + function testLiquidationSim6() public { + runLiquidationSim("PMRM_solvent", "Test6"); + } - // function testLiquidationSimLong_Box_Short_Cash() public { - // runLiquidationSim("PMRM_solvent", "test_Nov_01_long_box_neg_cash"); - // } + function testLiquidationSimLong_Box_Short_Cash() public { + runLiquidationSim("PMRM_solvent", "test_Nov_01_long_box_neg_cash"); + } - // function testLiquidationSimSimple_Short_3_liquidators() public { - // runLiquidationSim("PMRM_solvent", "test_Nov_02_3_liqs_same_price_same_amount"); - // } + function testLiquidationSimSimple_Short_3_liquidators() public { + runLiquidationSim("PMRM_solvent", "test_Nov_02_3_liqs_same_price_same_amount"); + } - // function testLiquidationSimPMRM_perp() public { - // runLiquidationSim("PMRM_solvent", "test_Nov_03_perp"); - // } + function testLiquidationSimPMRM_perp() public { + runLiquidationSim("PMRM_solvent", "test_Nov_03_perp"); + } function testLiquidationSimPMRM_General() public { runLiquidationSim("PMRM_solvent", "test_Nov_04_general"); } - // function testLiquidationSimPMRM_Borrow() public { - // runLiquidationSim("PMRM_solvent", "test_Nov_05_borrow"); - // } - - // function testLiquidationSim_insolvent_1() public { - // runLiquidationSim("PMRM_insolvent", "test_Nov_01_Insolvent_basic"); - // } - - // function testLiquidationSim_insolvent_2() public { - // runLiquidationSim("PMRM_insolvent", "test_Nov_02_Insolvent_basic_mtm_pos"); - // } - - // function testLiquidationSim_insolvent_3() public { - // runLiquidationSim("PMRM_insolvent", "test_Nov_03_Insolvent_basic_at_end"); - // } - - // function testLiquidationSim_insolvent_4() public { - // runLiquidationSim("PMRM_insolvent", "test_Nov_04_Insolvent_two_liq_same_disc_same_amount"); - // } - - // function testLiquidationSim_insolvent_5() public { - // runLiquidationSim("PMRM_insolvent", "test_Nov_05_Insolvent_two_liq_same_disc_diff_amount"); - // } - - // function testLiquidationSim_insolvent_6() public { - // runLiquidationSim("PMRM_insolvent", "test_Nov_06_Insolvent_General"); - // } - - // function testInsolventSim1() public { - // runLiquidationSim("InsolventTest1"); - // } - - // function testInsolventSim2() public { - // runLiquidationSim("InsolventTest2"); - // } + function testLiquidationSimPMRM_Borrow() public { + runLiquidationSim("PMRM_solvent", "test_Nov_05_borrow"); + } + + function testLiquidationSim_insolvent_1() public { + runLiquidationSim("PMRM_insolvent", "test_Nov_01_Insolvent_basic"); + } + + function testLiquidationSim_insolvent_2() public { + runLiquidationSim("PMRM_insolvent", "test_Nov_02_Insolvent_basic_mtm_pos"); + } + + function testLiquidationSim_insolvent_3() public { + runLiquidationSim("PMRM_insolvent", "test_Nov_03_Insolvent_basic_at_end"); + } + + function testLiquidationSim_insolvent_4() public { + runLiquidationSim("PMRM_insolvent", "test_Nov_04_Insolvent_two_liq_same_disc_same_amount"); + } + + function testLiquidationSim_insolvent_5() public { + runLiquidationSim("PMRM_insolvent", "test_Nov_05_Insolvent_two_liq_same_disc_diff_amount"); + } + + function testLiquidationSim_insolvent_6() public { + runLiquidationSim("PMRM_insolvent", "test_Nov_06_Insolvent_General"); + } +// +// function testInsolventSim1() public { +// runLiquidationSim("InsolventTest1"); +// } +// +// function testInsolventSim2() public { +// runLiquidationSim("InsolventTest2"); +// } function runLiquidationSim(string memory fileName, string memory testName) internal { LiquidationSim memory data = LiquidationSimBase.getTestData(fileName, testName); @@ -105,6 +105,7 @@ contract LiquidationSimTests_PM is LiquidationSimBase { function startAuction() internal { uint worstScenario = getWorstScenario(aliceAcc); auction.startAuction(aliceAcc, worstScenario); + } function doLiquidation(LiquidationSim memory data, uint actionId) internal { @@ -129,18 +130,17 @@ contract LiquidationSimTests_PM is LiquidationSimBase { uint worstScenario = getWorstScenario(aliceAcc); (int mm, int bm, int mtm) = auction.getMarginAndMarkToMarket(aliceAcc, worstScenario); IDutchAuction.Auction memory auctionDetails = auction.getAuction(aliceAcc); - uint fMax; if (auctionDetails.insolvent) { // todo: this needs to be changed to use MM as lower bound // assertApproxEqAbs(mm, data.Actions[actionId].Results.LowerBound, 1e6, "lowerbound"); } else { - fMax = auction.getMaxProportion(aliceAcc, worstScenario); + uint fMax = auction.getMaxProportion(aliceAcc, worstScenario); + assertApproxEqRel(fMax, data.Actions[actionId].Results.PreFMax, 0.001e18, "pre fmax"); } assertApproxEqRel(mtm, data.Actions[actionId].Results.PreMtM, 0.001e18, "pre mtm"); assertApproxEqRel(mm, data.Actions[actionId].Results.PreMM, 0.001e18, "pre mm"); assertApproxEqRel(bm, data.Actions[actionId].Results.PreBM, 0.001e18, "pre bm"); - assertApproxEqRel(fMax, data.Actions[actionId].Results.PreFMax, 0.001e18, "pre fmax"); } function checkPostLiquidation(LiquidationSim memory data, uint actionId) internal { @@ -150,8 +150,8 @@ contract LiquidationSimTests_PM is LiquidationSimBase { assertApproxEqRel(mtm, data.Actions[actionId].Results.PostMtM, 0.001e18, "post mtm"); assertApproxEqRel(mm, data.Actions[actionId].Results.PostMM, 0.001e18, "post mm"); - if (data.Actions[actionId].Results.PostBM == 0) { - assertGt(bm, 0, "post bm"); + if (SignedMath.abs(data.Actions[actionId].Results.PostBM) < 1e10) { + assertLt(SignedMath.abs(bm), 1e8, "post bm dust check"); } else { assertApproxEqRel(bm, data.Actions[actionId].Results.PostBM, 0.00001e18, "post bm"); } @@ -159,7 +159,11 @@ contract LiquidationSimTests_PM is LiquidationSimBase { IDutchAuction.Auction memory auctionDetails = auction.getAuction(aliceAcc); if (auctionDetails.insolvent) {} else { uint fMax = auction.getMaxProportion(aliceAcc, worstScenario); - assertApproxEqRel(fMax, data.Actions[actionId].Results.PostFMax, 0.001e18, "post fmax"); + if (data.Actions[actionId].Results.PostFMax < 1e10) { + assertLt(fMax, 1e8, "post fmax dust check"); + } else { + assertApproxEqRel(fMax, data.Actions[actionId].Results.PostFMax, 0.001e18, "post fmax"); + } } } diff --git a/test/integration-tests/liquidation/util/LiquidationSimBase.sol b/test/integration-tests/liquidation/util/LiquidationSimBase.sol index be414a99..0ba1e560 100644 --- a/test/integration-tests/liquidation/util/LiquidationSimBase.sol +++ b/test/integration-tests/liquidation/util/LiquidationSimBase.sol @@ -65,7 +65,7 @@ contract LiquidationSimBase is PMRMTestBase { int PreBM; uint PreFMax; int ExpectedBidPrice; - uint FinalPercentageReceived; +// uint FinalPercentageReceived; uint LiquidatedOfOriginal; int PostMtM; int PostMM; @@ -157,27 +157,25 @@ contract LiquidationSimBase is PMRMTestBase { action.Results.PreMtM = json.readInt(string.concat(baseActionIndex, ".Results.PreMtM")); action.Results.PreMM = json.readInt(string.concat(baseActionIndex, ".Results.PreMM")); action.Results.PreBM = json.readInt(string.concat(baseActionIndex, ".Results.PreBM")); - action.Results.PreFMax = json.readUint(string.concat(baseActionIndex, ".Results.PreFMax")); - action.Results.ExpectedBidPrice = json.readInt(string.concat(baseActionIndex, ".Results.ExpectedBidPrice")); - action.Results.FinalPercentageReceived = - json.readUint(string.concat(baseActionIndex, ".Results.FinalPercentageReceived")); - action.Results.LiquidatedOfOriginal = - json.readUint(string.concat(baseActionIndex, ".Results.fLiquidatedOfOriginal")); action.Results.PostMtM = json.readInt(string.concat(baseActionIndex, ".Results.PostMtM")); action.Results.PostMM = json.readInt(string.concat(baseActionIndex, ".Results.PostMM")); action.Results.PostBM = json.readInt(string.concat(baseActionIndex, ".Results.PostBM")); - action.Results.PostFMax = json.readUint(string.concat(baseActionIndex, ".Results.PostFMax")); - action.Results.SMPayout = getSMPayout(json, string.concat(baseActionIndex, ".Results.SMPayout")); + // Ignored for insolvent so we just set to 0 + action.Results.PreFMax = uint(tryGetWithDefault(json, string.concat(baseActionIndex, ".Results.PreFMax"), 0)); + action.Results.ExpectedBidPrice = tryGetWithDefault(json, string.concat(baseActionIndex, ".Results.ExpectedBidPrice"), 0); + action.Results.LiquidatedOfOriginal = uint(tryGetWithDefault(json, string.concat(baseActionIndex, ".Results.fLiquidatedOfOriginal"), 0)); + action.Results.PostFMax = uint(tryGetWithDefault(json, string.concat(baseActionIndex, ".Results.PostFMax"), 0)); + action.Results.SMPayout = tryGetWithDefault(json, string.concat(baseActionIndex, ".Results.SMPayout"), 0); return action; } - function getSMPayout(string memory json, string memory location) internal view returns (int) { + function tryGetWithDefault(string memory json, string memory location, int defaultVal) internal view returns (int) { try t.readInt(json, location) returns (int payout) { return payout; } catch { - return 0; + return defaultVal; } } From 0e51caabd2e38dd36b29ff02dc28b7d971ee48a5 Mon Sep 17 00:00:00 2001 From: SeanDaws <68123079+SeanDaws@users.noreply.github.com> Date: Thu, 16 Nov 2023 21:07:27 -0500 Subject: [PATCH 10/14] weird error --- lib/lyra-utils | 2 +- .../liquidation/PMRM_solvent.json | 188 +++++++++--------- .../liquidation/PM_liquidationSimTests.t.sol | 92 ++++----- 3 files changed, 141 insertions(+), 141 deletions(-) diff --git a/lib/lyra-utils b/lib/lyra-utils index c81cdc39..f64d5e3b 160000 --- a/lib/lyra-utils +++ b/lib/lyra-utils @@ -1 +1 @@ -Subproject commit c81cdc3905a83c42bc55741a0d57a51c9260be0b +Subproject commit f64d5e3bab9da4807003d505fbd19b364ef64671 diff --git a/test/integration-tests/liquidation/PMRM_solvent.json b/test/integration-tests/liquidation/PMRM_solvent.json index f36346dc..3ef8c4b4 100644 --- a/test/integration-tests/liquidation/PMRM_solvent.json +++ b/test/integration-tests/liquidation/PMRM_solvent.json @@ -2153,12 +2153,12 @@ -1600000000000000000 ], "OptionVols": [ - 1078423755029964032, - 1142190546545185152, - 1172827463800546816, - 1171703938269880576, - 1060362341064233600, - 1265521462825042944 + 1081048412866353792, + 1138939398052892160, + 1175456213289622784, + 1168496419451440128, + 1062799244178520832, + 1262509092493988864 ], "SVIparams": [ 1, @@ -2178,9 +2178,9 @@ "Cash": -5008723085851319336960, "Perps": 0, "Base": 5000000000000000000, - "SpotPrice": 1507000000000000000000, + "SpotPrice": 1500000000000000000000, "SpotConfidence": 1000000000000000000, - "PerpPrice": 1512000000000000000000, + "PerpPrice": 1505000000000000000000, "PerpConfidence": 1000000000000000000, "FeedExpiries": [ 1191599, @@ -2191,12 +2191,12 @@ 1191599 ], "Forwards": [ - 1508994307056656449536, - 1507837166274316599296, - 1520031530437421563904, - 1507837166274316599296, - 1511166340024264294400, - 1508994307056656449536 + 1501985043520228950016, + 1500833277645305413632, + 1512970999108249845760, + 1500833277645305413632, + 1504146987416321261568, + 1501985043520228950016 ], "ForwardConfidences": [ 1000000000000000000, @@ -2241,7 +2241,7 @@ 0.6962770273617649, 0.6212324935488645 ], - "SettlementPrice": 1507837166274316599296, + "SettlementPrice": 1500833277645305413632, "PercentFixed": 0, "ForwardsFixed": [ 0, @@ -2252,29 +2252,29 @@ 0 ], "ForwardsVariable": [ - 1508994307056656449536, - 1507837166274316599296, - 1520031530437421563904, - 1507837166274316599296, - 1511166340024264294400, - 1508994307056656449536 + 1501985043520228950016, + 1500833277645305413632, + 1512970999108249845760, + 1500833277645305413632, + 1504146987416321261568, + 1501985043520228950016 ] }, "Liquidator": { "PercentWant": 212000000000000000 }, "Results": { - "PreMtM": 522426271073480146944, - "PreMM": -2168856402462630215680, - "PreBM": -2707112937169852301312, - "PreFMax": 841201520047924992, - "ExpectedBidPrice": 108339924213184593920, + "PreMtM": 510089056180759166976, + "PreMM": -2203579942180327522304, + "PreBM": -2746313741852544598016, + "PreFMax": 846247881370359424, + "ExpectedBidPrice": 105781452328275935232, "FinalPercentageReceived": 212000000000000000, "fLiquidatedOfOriginal": 212000000000000000, - "PostMtM": 520011825819087798272, - "PostMM": -1600718920927366610944, - "PostBM": -2024865070276657283072, - "PostFMax": 798479086355234560 + "PostMtM": 507731628598714433536, + "PostMM": -1630639542109820944384, + "PostBM": -2058313776251528019968, + "PostFMax": 804883098185735168 } }, { @@ -2313,12 +2313,12 @@ -1260800000000000256 ], "OptionVols": [ - 1084842456681448704, - 1134262687039083264, - 1179225523223866624, - 1163878129543114240, - 1066368911453592320, - 1258169606786900736 + 1081048600443659648, + 1138939166206683392, + 1175456400499937280, + 1168496190632824064, + 1062799419362179456, + 1262508877555349760 ], "SVIparams": [ 1, @@ -2335,12 +2335,12 @@ 1000000000000000000, 1000000000000000000 ], - "Cash": -3838533867437655326720, + "Cash": -3841092339322564116480, "Perps": 0, "Base": 3940000000000000512, - "SpotPrice": 1490000000000000000000, + "SpotPrice": 1500000000000000000000, "SpotConfidence": 1000000000000000000, - "PerpPrice": 1495000000000000000000, + "PerpPrice": 1505000000000000000000, "PerpConfidence": 1000000000000000000, "FeedExpiries": [ 1191300, @@ -2351,12 +2351,12 @@ 1191300 ], "Forwards": [ - 1491971314796481478656, - 1490827227740381380608, - 1502884027059275038720, - 1490827227740381380608, - 1494118845020624125952, - 1491971314796481478656 + 1501984545097129132032, + 1500832779604410761216, + 1512970497039538585600, + 1500832779604410761216, + 1504146488275796230144, + 1501984545097129132032 ], "ForwardConfidences": [ 1000000000000000000, @@ -2401,7 +2401,7 @@ 0.6962660745999473, 0.6212039764153356 ], - "SettlementPrice": 1490827227740381380608, + "SettlementPrice": 1500832779604410761216, "PercentFixed": 0, "ForwardsFixed": [ 0, @@ -2412,29 +2412,29 @@ 0 ], "ForwardsVariable": [ - 1491971314796481478656, - 1490827227740381380608, - 1502884027059275038720, - 1490827227740381380608, - 1494118845020624125952, - 1491971314796481478656 + 1501984545097129132032, + 1500832779604410761216, + 1512970497039538585600, + 1500832779604410761216, + 1504146488275796230144, + 1501984545097129132032 ] }, "Liquidator": { "PercentWant": 177664974619289344 }, "Results": { - "PreMtM": 495836096830023073792, - "PreMM": -1667768991089948884992, - "PreBM": -2100490008673943027712, - "PreFMax": 835343872515414272, - "ExpectedBidPrice": 54310659275400101888, + "PreMtM": 507870376293439242240, + "PreMM": -1630279398986097360896, + "PreBM": -2057909354042004865024, + "PreFMax": 829503039144855296, + "ExpectedBidPrice": 56355949015985954816, "FinalPercentageReceived": 177664974619289344, "fLiquidatedOfOriginal": 177664974619289344, - "PostMtM": 481302258432380764160, - "PostMM": -1297905986456124129280, - "PostBM": -1653747635433825107968, - "PostFMax": 799770017811954432 + "PostMtM": 492789206838456287232, + "PostMM": -1265486242883802234880, + "PostBM": -1617141332828253847552, + "PostFMax": 792667275997139072 } }, { @@ -2473,12 +2473,12 @@ -1036800000000000128 ], "OptionVols": [ - 1073629773311693312, - 1148172524809817600, - 1167971569048958720, - 1177600080291231744, - 1055998254219873152, - 1271056185355171840 + 1081053431053289728, + 1138933195579575424, + 1175461221627552256, + 1168490297969628672, + 1062803930850502656, + 1262503342334851840 ], "SVIparams": [ 1, @@ -2495,12 +2495,12 @@ 1000000000000000000, 1000000000000000000 ], - "Cash": -3083001976143070363648, + "Cash": -3083515158287393226752, "Perps": 0, "Base": 3240000000000000000, - "SpotPrice": 1520000000000000000000, + "SpotPrice": 1500000000000000000000, "SpotConfidence": 1000000000000000000, - "PerpPrice": 1525000000000000000000, + "PerpPrice": 1505000000000000000000, "PerpConfidence": 1000000000000000000, "FeedExpiries": [ 1183600, @@ -2511,12 +2511,12 @@ 1183600 ], "Forwards": [ - 1521997998969181962240, - 1520830886577166090240, - 1533130335135821987840, - 1520830886577166090240, - 1524188749335127916544, - 1521997998969181962240 + 1501971709509061050368, + 1500819953859045621760, + 1512957567568245424128, + 1500819953859045621760, + 1504133634212297179136, + 1501971709509061050368 ], "ForwardConfidences": [ 1000000000000000000, @@ -2561,7 +2561,7 @@ 0.6959834225060578, 0.6204663676355897 ], - "SettlementPrice": 1520830886577166090240, + "SettlementPrice": 1500819953859045621760, "PercentFixed": 0, "ForwardsFixed": [ 0, @@ -2572,29 +2572,29 @@ 0 ], "ForwardsVariable": [ - 1521997998969181962240, - 1520830886577166090240, - 1533130335135821987840, - 1520830886577166090240, - 1524188749335127916544, - 1521997998969181962240 + 1501971709509061050368, + 1500819953859045621760, + 1512957567568245424128, + 1500819953859045621760, + 1504133634212297179136, + 1501971709509061050368 ] }, "Liquidator": { "PercentWant": 1000000000000000000 }, "Results": { - "PreMtM": 518023799241593192448, - "PreMM": -1194171051509298233344, - "PreBM": -1536610021659476492288, - "PreFMax": 840784952512938752, - "ExpectedBidPrice": 107897274452956332032, - "FinalPercentageReceived": 840784952512938752, - "fLiquidatedOfOriginal": 840784952512938752, - "PostMtM": 327128621363285983232, - "PostMM": 54521436893880885248, - "PostBM": -113686, - "PostFMax": 390 + "PreMtM": 495719167035687436288, + "PreMM": -1257829300755020906496, + "PreBM": -1608538994313162653696, + "PreFMax": 850567377484409856, + "ExpectedBidPrice": 102459416085279768576, + "FinalPercentageReceived": 850567377484409856, + "fLiquidatedOfOriginal": 850567377484409856, + "PostMtM": 314444815500192514048, + "PostMM": 52407469250032189440, + "PostBM": 113686, + "PostFMax": -402 } } ] diff --git a/test/integration-tests/liquidation/PM_liquidationSimTests.t.sol b/test/integration-tests/liquidation/PM_liquidationSimTests.t.sol index aee0e5e4..e602711c 100644 --- a/test/integration-tests/liquidation/PM_liquidationSimTests.t.sol +++ b/test/integration-tests/liquidation/PM_liquidationSimTests.t.sol @@ -13,69 +13,69 @@ contract LiquidationSimTests_PM is LiquidationSimBase { runLiquidationSim("PMRM_solvent", "Test1"); } - function testLiquidationSim2() public { - runLiquidationSim("PMRM_solvent", "Test2"); - } + // function testLiquidationSim2() public { + // runLiquidationSim("PMRM_solvent", "Test2"); + // } - function testLiquidationSim3() public { - runLiquidationSim("PMRM_solvent", "Test3"); - } + // function testLiquidationSim3() public { + // runLiquidationSim("PMRM_solvent", "Test3"); + // } - function testLiquidationSim4() public { - runLiquidationSim("PMRM_solvent", "Test4"); - } + // function testLiquidationSim4() public { + // runLiquidationSim("PMRM_solvent", "Test4"); + // } - function testLiquidationSim5() public { - runLiquidationSim("PMRM_solvent", "Test5"); - } + // function testLiquidationSim5() public { + // runLiquidationSim("PMRM_solvent", "Test5"); + // } - function testLiquidationSim6() public { - runLiquidationSim("PMRM_solvent", "Test6"); - } + // function testLiquidationSim6() public { + // runLiquidationSim("PMRM_solvent", "Test6"); + // } - function testLiquidationSimLong_Box_Short_Cash() public { - runLiquidationSim("PMRM_solvent", "test_Nov_01_long_box_neg_cash"); - } + // function testLiquidationSimLong_Box_Short_Cash() public { + // runLiquidationSim("PMRM_solvent", "test_Nov_01_long_box_neg_cash"); + // } - function testLiquidationSimSimple_Short_3_liquidators() public { - runLiquidationSim("PMRM_solvent", "test_Nov_02_3_liqs_same_price_same_amount"); - } + // function testLiquidationSimSimple_Short_3_liquidators() public { + // runLiquidationSim("PMRM_solvent", "test_Nov_02_3_liqs_same_price_same_amount"); + // } - function testLiquidationSimPMRM_perp() public { - runLiquidationSim("PMRM_solvent", "test_Nov_03_perp"); - } + // function testLiquidationSimPMRM_perp() public { + // runLiquidationSim("PMRM_solvent", "test_Nov_03_perp"); + // } function testLiquidationSimPMRM_General() public { runLiquidationSim("PMRM_solvent", "test_Nov_04_general"); } - function testLiquidationSimPMRM_Borrow() public { - runLiquidationSim("PMRM_solvent", "test_Nov_05_borrow"); - } + // function testLiquidationSimPMRM_Borrow() public { + // runLiquidationSim("PMRM_solvent", "test_Nov_05_borrow"); + // } - function testLiquidationSim_insolvent_1() public { - runLiquidationSim("PMRM_insolvent", "test_Nov_01_Insolvent_basic"); - } + // function testLiquidationSim_insolvent_1() public { + // runLiquidationSim("PMRM_insolvent", "test_Nov_01_Insolvent_basic"); + // } - function testLiquidationSim_insolvent_2() public { - runLiquidationSim("PMRM_insolvent", "test_Nov_02_Insolvent_basic_mtm_pos"); - } + // function testLiquidationSim_insolvent_2() public { + // runLiquidationSim("PMRM_insolvent", "test_Nov_02_Insolvent_basic_mtm_pos"); + // } - function testLiquidationSim_insolvent_3() public { - runLiquidationSim("PMRM_insolvent", "test_Nov_03_Insolvent_basic_at_end"); - } + // function testLiquidationSim_insolvent_3() public { + // runLiquidationSim("PMRM_insolvent", "test_Nov_03_Insolvent_basic_at_end"); + // } - function testLiquidationSim_insolvent_4() public { - runLiquidationSim("PMRM_insolvent", "test_Nov_04_Insolvent_two_liq_same_disc_same_amount"); - } + // function testLiquidationSim_insolvent_4() public { + // runLiquidationSim("PMRM_insolvent", "test_Nov_04_Insolvent_two_liq_same_disc_same_amount"); + // } - function testLiquidationSim_insolvent_5() public { - runLiquidationSim("PMRM_insolvent", "test_Nov_05_Insolvent_two_liq_same_disc_diff_amount"); - } + // function testLiquidationSim_insolvent_5() public { + // runLiquidationSim("PMRM_insolvent", "test_Nov_05_Insolvent_two_liq_same_disc_diff_amount"); + // } - function testLiquidationSim_insolvent_6() public { - runLiquidationSim("PMRM_insolvent", "test_Nov_06_Insolvent_General"); - } + // function testLiquidationSim_insolvent_6() public { + // runLiquidationSim("PMRM_insolvent", "test_Nov_06_Insolvent_General"); + // } // // function testInsolventSim1() public { // runLiquidationSim("InsolventTest1"); @@ -177,7 +177,7 @@ contract LiquidationSimTests_PM is LiquidationSimBase { worstScenario = i; } } - console2.log("worst scenario", worstScenario); + //console2.log("worst scenario", worstScenario); } function updateToActionState(LiquidationSim memory data, uint actionId) internal { From f5d78a13c7f884d684f96cd41b5223346cf1ebc4 Mon Sep 17 00:00:00 2001 From: SeanDaws <68123079+SeanDaws@users.noreply.github.com> Date: Thu, 16 Nov 2023 21:34:07 -0500 Subject: [PATCH 11/14] for om --- .../liquidation/PMRM_insolvent.json | 30 +++++++ .../liquidation/PMRM_solvent.json | 80 ++++++++++++++----- 2 files changed, 90 insertions(+), 20 deletions(-) diff --git a/test/integration-tests/liquidation/PMRM_insolvent.json b/test/integration-tests/liquidation/PMRM_insolvent.json index 486f049d..63b04dde 100644 --- a/test/integration-tests/liquidation/PMRM_insolvent.json +++ b/test/integration-tests/liquidation/PMRM_insolvent.json @@ -150,6 +150,9 @@ "PostMM": 0, "PostBM": 0, "SMPayout": -29371585189059944448, + "ExpectedBidPrice": -29371585189059944448, + "fLiquidatedOfOriginal": 0, + "PostFMax": 0, "PercentageReceived": 1000000000000000000, "PercentReceivedCurrent": 1000000000000000000, "LiqPrice": -29371585189059944448 @@ -308,6 +311,9 @@ "PostMM": 0, "PostBM": 0, "SMPayout": 0, + "ExpectedBidPrice": 0, + "fLiquidatedOfOriginal": 0, + "PostFMax": 0, "PercentageReceived": 1000000000000000000, "PercentReceivedCurrent": 1000000000000000000, "LiqPrice": 0 @@ -466,6 +472,9 @@ "PostMM": 0, "PostBM": 0, "SMPayout": -211759362378998743040, + "ExpectedBidPrice": -211759362378998743040, + "fLiquidatedOfOriginal": 0, + "PostFMax": 0, "PercentageReceived": 1000000000000000000, "PercentReceivedCurrent": 1000000000000000000, "LiqPrice": -211759362378998743040 @@ -744,6 +753,9 @@ "PostMM": -1105556759314385076224, "PostBM": -1192459878032953835520, "SMPayout": -89043982644377141248, + "ExpectedBidPrice": -890439826443771314176, + "fLiquidatedOfOriginal": 0, + "PostFMax": 0, "PercentageReceived": 100000000000000000, "PercentReceivedCurrent": 100000000000000000, "LiqPrice": -890439826443771314176 @@ -888,6 +900,9 @@ "PostMM": -982717119390564614144, "PostBM": -1059964336029292560384, "SMPayout": -89043982644377141248, + "ExpectedBidPrice": -801395843799394156544, + "fLiquidatedOfOriginal": 0, + "PostFMax": 0, "PercentageReceived": 100000000000000000, "PercentReceivedCurrent": 111111111111111120, "LiqPrice": -801395843799394156544 @@ -1166,6 +1181,9 @@ "PostMM": -1105556759314385076224, "PostBM": -1192459878032953835520, "SMPayout": -89043982644377141248, + "ExpectedBidPrice": -890439826443771314176, + "fLiquidatedOfOriginal": 0, + "PostFMax": 0, "PercentageReceived": 100000000000000000, "PercentReceivedCurrent": 100000000000000000, "LiqPrice": -890439826443771314176 @@ -1310,6 +1328,9 @@ "PostMM": -491358559695282307072, "PostBM": -529982168014646280192, "SMPayout": -445219913221885657088, + "ExpectedBidPrice": -801395843799394156544, + "fLiquidatedOfOriginal": 0, + "PostFMax": 0, "PercentageReceived": 500000000000000000, "PercentReceivedCurrent": 555555555555555584, "LiqPrice": -801395843799394156544 @@ -1618,6 +1639,9 @@ "PostMM": -809321691686003277824, "PostBM": -973166181123486777344, "SMPayout": -8216355276130061312, + "ExpectedBidPrice": -80237844493457637376, + "fLiquidatedOfOriginal": 0, + "PostFMax": 0, "PercentageReceived": 102400000000000000, "PercentReceivedCurrent": 102400000000000000, "LiqPrice": -80237844493457637376 @@ -1777,6 +1801,9 @@ "PostMM": -286877640472253005824, "PostBM": -355048325468162359296, "SMPayout": -119853641897612836864, + "ExpectedBidPrice": -202219227382137716736, + "fLiquidatedOfOriginal": 0, + "PostFMax": 0, "PercentageReceived": 532000000000000000, "PercentReceivedCurrent": 592691622103386880, "LiqPrice": -202219227382137716736 @@ -1936,6 +1963,9 @@ "PostMM": 0, "PostBM": 0, "SMPayout": -265651603747238150144, + "ExpectedBidPrice": -265651603747238150144, + "fLiquidatedOfOriginal": 0, + "PostFMax": 0, "PercentageReceived": 365599999999999936, "PercentReceivedCurrent": 1000000000000000000, "LiqPrice": -265651603747238150144 diff --git a/test/integration-tests/liquidation/PMRM_solvent.json b/test/integration-tests/liquidation/PMRM_solvent.json index 3ef8c4b4..3cfb840d 100644 --- a/test/integration-tests/liquidation/PMRM_solvent.json +++ b/test/integration-tests/liquidation/PMRM_solvent.json @@ -153,7 +153,9 @@ "PostMtM": 117975011636365344768, "PostMM": 19662501939394220032, "PostBM": 0, - "PostFMax": 0 + "PostFMax": 0, + "PercentLiquidated": 557941285425569408, + "SMPayout": 0 } } ] @@ -312,7 +314,9 @@ "PostMtM": 119187023850593943552, "PostMM": -92090078337145208832, "PostBM": -134345498774693052416, - "PostFMax": 534675037290073152 + "PostFMax": 534675037290073152, + "PercentLiquidated": 50000000000000000, + "SMPayout": 0 } } ] @@ -471,7 +475,9 @@ "PostMtM": 117984392018701828096, "PostMM": -71052706613586223104, "PostBM": -108860126340043833344, - "PostFMax": 496307679249793920 + "PostFMax": 496307679249793920, + "PercentLiquidated": 150000000000000000, + "SMPayout": 0 } } ] @@ -630,7 +636,9 @@ "PostMtM": 118425834278252019712, "PostMM": -81731093685347155968, "PostBM": -121762479278066974720, - "PostFMax": 524290585958138816 + "PostFMax": 524290585958138816, + "PercentLiquidated": 100000000000000000, + "SMPayout": 0 } }, { @@ -715,7 +723,9 @@ "PostMtM": 117542949759151603712, "PostMM": -60374319541825396736, "PostBM": -95957773402020790272, - "PostFMax": 464826909202906112 + "PostFMax": 464826909202906112, + "PercentLiquidated": 100000000000000000, + "SMPayout": 0 } } ] @@ -874,7 +884,9 @@ "PostMtM": 118425834278252019712, "PostMM": -81731093685347155968, "PostBM": -121762479278066974720, - "PostFMax": 524290585958138816 + "PostFMax": 524290585958138816, + "PercentLiquidated": 100000000000000000, + "SMPayout": 0 } }, { @@ -959,7 +971,9 @@ "PostMtM": 104873584133552816128, "PostMM": 15917708608878172160, "PostBM": -1873466496056750080, - "PostFMax": 19541216048521428 + "PostFMax": 19541216048521428, + "PercentLiquidated": 500000000000000000, + "SMPayout": 0 } } ] @@ -1118,7 +1132,9 @@ "PostMtM": 118425834278252019712, "PostMM": -81731093685347155968, "PostBM": -121762479278066974720, - "PostFMax": 524290585958138816 + "PostFMax": 524290585958138816, + "PercentLiquidated": 100000000000000000, + "SMPayout": 0 } }, { @@ -1203,7 +1219,9 @@ "PostMtM": 117242769022657511424, "PostMM": -53113016333027983360, "PostBM": -87184173404165079040, - "PostFMax": 441072490029144640 + "PostFMax": 441072490029144640, + "PercentLiquidated": 134000000000000000, + "SMPayout": 0 } }, { @@ -1288,7 +1306,9 @@ "PostMtM": 114259841901579370496, "PostMM": 19043306983596552192, "PostBM": -14210, - "PostFMax": 128 + "PostFMax": 128, + "PercentLiquidated": 337861527362324800, + "SMPayout": 0 } } ] @@ -1537,7 +1557,9 @@ "PostMtM": 48406961864176648192, "PostMM": 8067826977362642944, "PostBM": -156319, - "PostFMax": 3398 + "PostFMax": 3398, + "PercentLiquidated": 345288467178951872, + "SMPayout": 0 } } ] @@ -1696,7 +1718,9 @@ "PostMtM": 117625759832094736384, "PostMM": -62377476224713719808, "PostBM": -98378123436075417600, - "PostFMax": 471028760349993216 + "PostFMax": 471028760349993216, + "PercentLiquidated": 190620509120774976, + "SMPayout": 0 } }, { @@ -1781,7 +1805,9 @@ "PostMtM": 115942800866837053440, "PostMM": -21667084620558540800, "PostBM": -49189061718037659648, - "PostFMax": 308069078171682880 + "PostFMax": 308069078171682880, + "PercentLiquidated": 190620509120774976, + "SMPayout": 0 } }, { @@ -1866,7 +1892,9 @@ "PostMtM": 114259841901579370496, "PostMM": 19043306983596552192, "PostBM": -14210, - "PostFMax": 128 + "PostFMax": 128, + "PercentLiquidated": 190620509120774816, + "SMPayout": 0 } } ] @@ -1965,7 +1993,9 @@ "PostMtM": 38617095907847430144, "PostMM": 6436182651307888640, "PostBM": -21316, - "PostFMax": 553 + "PostFMax": 553, + "PercentLiquidated": 874170427149405568, + "SMPayout": 0 } } ] @@ -2274,7 +2304,9 @@ "PostMtM": 507731628598714433536, "PostMM": -1630639542109820944384, "PostBM": -2058313776251528019968, - "PostFMax": 804883098185735168 + "PostFMax": 804883098185735168, + "PercentLiquidated": 212000000000000000, + "SMPayout": 0 } }, { @@ -2434,7 +2466,9 @@ "PostMtM": 492789206838456287232, "PostMM": -1265486242883802234880, "PostBM": -1617141332828253847552, - "PostFMax": 792667275997139072 + "PostFMax": 792667275997139072, + "PercentLiquidated": 140000000000000016, + "SMPayout": 0 } }, { @@ -2594,7 +2628,9 @@ "PostMtM": 314444815500192514048, "PostMM": 52407469250032189440, "PostBM": 113686, - "PostFMax": -402 + "PostFMax": -402, + "PercentLiquidated": 551167660609897664, + "SMPayout": 0 } } ] @@ -2693,7 +2729,9 @@ "PostMtM": 248586797385620914176, "PostMM": 19086797385620910080, "PostBM": -26813202614379065344, - "PostFMax": 98972212933972304 + "PostFMax": 98972212933972304, + "PercentLiquidated": 100000000000000000, + "SMPayout": 0 } }, { @@ -2748,7 +2786,9 @@ "PostMtM": 248143052557984006144, "PostMM": 41357175426330624000, "PostBM": -28421, - "PostFMax": 116 + "PostFMax": 116, + "PercentLiquidated": 89074991640575072, + "SMPayout": 0 } } ] From 4126385acbf3c310ebe74ea3b339df9f4eeef93f Mon Sep 17 00:00:00 2001 From: Dominic Romanowski Date: Fri, 17 Nov 2023 13:39:23 +1100 Subject: [PATCH 12/14] . --- lib/lyra-utils | 2 +- .../liquidation/PMRM_solvent.json | 2 +- .../liquidation/PM_liquidationSimTests.t.sol | 126 +++++++++--------- .../liquidation/util/LiquidationSimBase.sol | 11 +- 4 files changed, 70 insertions(+), 71 deletions(-) diff --git a/lib/lyra-utils b/lib/lyra-utils index f64d5e3b..c81cdc39 160000 --- a/lib/lyra-utils +++ b/lib/lyra-utils @@ -1 +1 @@ -Subproject commit f64d5e3bab9da4807003d505fbd19b364ef64671 +Subproject commit c81cdc3905a83c42bc55741a0d57a51c9260be0b diff --git a/test/integration-tests/liquidation/PMRM_solvent.json b/test/integration-tests/liquidation/PMRM_solvent.json index 3cfb840d..b6930124 100644 --- a/test/integration-tests/liquidation/PMRM_solvent.json +++ b/test/integration-tests/liquidation/PMRM_solvent.json @@ -2628,7 +2628,7 @@ "PostMtM": 314444815500192514048, "PostMM": 52407469250032189440, "PostBM": 113686, - "PostFMax": -402, + "PostFMax": 0, "PercentLiquidated": 551167660609897664, "SMPayout": 0 } diff --git a/test/integration-tests/liquidation/PM_liquidationSimTests.t.sol b/test/integration-tests/liquidation/PM_liquidationSimTests.t.sol index e602711c..e1e2c180 100644 --- a/test/integration-tests/liquidation/PM_liquidationSimTests.t.sol +++ b/test/integration-tests/liquidation/PM_liquidationSimTests.t.sol @@ -13,77 +13,70 @@ contract LiquidationSimTests_PM is LiquidationSimBase { runLiquidationSim("PMRM_solvent", "Test1"); } - // function testLiquidationSim2() public { - // runLiquidationSim("PMRM_solvent", "Test2"); - // } + function testLiquidationSim2() public { + runLiquidationSim("PMRM_solvent", "Test2"); + } - // function testLiquidationSim3() public { - // runLiquidationSim("PMRM_solvent", "Test3"); - // } + function testLiquidationSim3() public { + runLiquidationSim("PMRM_solvent", "Test3"); + } - // function testLiquidationSim4() public { - // runLiquidationSim("PMRM_solvent", "Test4"); - // } + function testLiquidationSim4() public { + runLiquidationSim("PMRM_solvent", "Test4"); + } - // function testLiquidationSim5() public { - // runLiquidationSim("PMRM_solvent", "Test5"); - // } + function testLiquidationSim5() public { + runLiquidationSim("PMRM_solvent", "Test5"); + } - // function testLiquidationSim6() public { - // runLiquidationSim("PMRM_solvent", "Test6"); - // } + function testLiquidationSim6() public { + runLiquidationSim("PMRM_solvent", "Test6"); + } - // function testLiquidationSimLong_Box_Short_Cash() public { - // runLiquidationSim("PMRM_solvent", "test_Nov_01_long_box_neg_cash"); - // } + function testLiquidationSimLong_Box_Short_Cash() public { + runLiquidationSim("PMRM_solvent", "test_Nov_01_long_box_neg_cash"); + } - // function testLiquidationSimSimple_Short_3_liquidators() public { - // runLiquidationSim("PMRM_solvent", "test_Nov_02_3_liqs_same_price_same_amount"); - // } + function testLiquidationSimSimple_Short_3_liquidators() public { + runLiquidationSim("PMRM_solvent", "test_Nov_02_3_liqs_same_price_same_amount"); + } - // function testLiquidationSimPMRM_perp() public { - // runLiquidationSim("PMRM_solvent", "test_Nov_03_perp"); - // } + function testLiquidationSimPMRM_perp() public { + runLiquidationSim("PMRM_solvent", "test_Nov_03_perp"); + } function testLiquidationSimPMRM_General() public { runLiquidationSim("PMRM_solvent", "test_Nov_04_general"); } - // function testLiquidationSimPMRM_Borrow() public { - // runLiquidationSim("PMRM_solvent", "test_Nov_05_borrow"); - // } - - // function testLiquidationSim_insolvent_1() public { - // runLiquidationSim("PMRM_insolvent", "test_Nov_01_Insolvent_basic"); - // } - - // function testLiquidationSim_insolvent_2() public { - // runLiquidationSim("PMRM_insolvent", "test_Nov_02_Insolvent_basic_mtm_pos"); - // } - - // function testLiquidationSim_insolvent_3() public { - // runLiquidationSim("PMRM_insolvent", "test_Nov_03_Insolvent_basic_at_end"); - // } - - // function testLiquidationSim_insolvent_4() public { - // runLiquidationSim("PMRM_insolvent", "test_Nov_04_Insolvent_two_liq_same_disc_same_amount"); - // } - - // function testLiquidationSim_insolvent_5() public { - // runLiquidationSim("PMRM_insolvent", "test_Nov_05_Insolvent_two_liq_same_disc_diff_amount"); - // } - - // function testLiquidationSim_insolvent_6() public { - // runLiquidationSim("PMRM_insolvent", "test_Nov_06_Insolvent_General"); - // } -// -// function testInsolventSim1() public { -// runLiquidationSim("InsolventTest1"); -// } -// -// function testInsolventSim2() public { -// runLiquidationSim("InsolventTest2"); -// } + function testLiquidationSimPMRM_Borrow() public { + runLiquidationSim("PMRM_solvent", "test_Nov_05_borrow"); + } + + function testLiquidationSim_insolvent_1() public { + runLiquidationSim("PMRM_insolvent", "test_Nov_01_Insolvent_basic"); + } + + function testLiquidationSim_insolvent_2() public { + runLiquidationSim("PMRM_insolvent", "test_Nov_02_Insolvent_basic_mtm_pos"); + } + + function testLiquidationSim_insolvent_3() public { + runLiquidationSim("PMRM_insolvent", "test_Nov_03_Insolvent_basic_at_end"); + } + + function testLiquidationSim_insolvent_4() public { + runLiquidationSim("PMRM_insolvent", "test_Nov_04_Insolvent_two_liq_same_disc_same_amount"); + } + + function testLiquidationSim_insolvent_5() public { + runLiquidationSim("PMRM_insolvent", "test_Nov_05_Insolvent_two_liq_same_disc_diff_amount"); + } + + function testLiquidationSim_insolvent_6() public { + runLiquidationSim("PMRM_insolvent", "test_Nov_06_Insolvent_General"); + } + function runLiquidationSim(string memory fileName, string memory testName) internal { LiquidationSim memory data = LiquidationSimBase.getTestData(fileName, testName); @@ -94,10 +87,13 @@ contract LiquidationSimTests_PM is LiquidationSimBase { startAuction(); for (uint i = 0; i < data.Actions.length; ++i) { - // console2.log("\n=== STEP:", i); + console2.log("\n=== STEP:", i); updateToActionState(data, i); + console2.log("Pre:", i); checkPreLiquidation(data, i); + console2.log("Liq:", i); doLiquidation(data, i); + console2.log("Post:", i); checkPostLiquidation(data, i); } } @@ -150,8 +146,9 @@ contract LiquidationSimTests_PM is LiquidationSimBase { assertApproxEqRel(mtm, data.Actions[actionId].Results.PostMtM, 0.001e18, "post mtm"); assertApproxEqRel(mm, data.Actions[actionId].Results.PostMM, 0.001e18, "post mm"); - if (SignedMath.abs(data.Actions[actionId].Results.PostBM) < 1e10) { - assertLt(SignedMath.abs(bm), 1e8, "post bm dust check"); + if (SignedMath.abs(data.Actions[actionId].Results.PostBM) < 1e10 || SignedMath.abs(bm) < 1e10) { + assertApproxEqAbs(SignedMath.abs(bm), 0, 1e8, "post bm dust check"); + assertApproxEqAbs(SignedMath.abs(data.Actions[actionId].Results.PostBM), 0, 1e8, "post bm dust check"); } else { assertApproxEqRel(bm, data.Actions[actionId].Results.PostBM, 0.00001e18, "post bm"); } @@ -159,8 +156,9 @@ contract LiquidationSimTests_PM is LiquidationSimBase { IDutchAuction.Auction memory auctionDetails = auction.getAuction(aliceAcc); if (auctionDetails.insolvent) {} else { uint fMax = auction.getMaxProportion(aliceAcc, worstScenario); - if (data.Actions[actionId].Results.PostFMax < 1e10) { - assertLt(fMax, 1e8, "post fmax dust check"); + if (data.Actions[actionId].Results.PostFMax < 1e10 || fMax < 1e10) { + assertApproxEqAbs(fMax, 0, 1e8, "post fmax dust check"); + assertApproxEqAbs(data.Actions[actionId].Results.PostFMax, 0, 1e8, "post fmax dust check"); } else { assertApproxEqRel(fMax, data.Actions[actionId].Results.PostFMax, 0.001e18, "post fmax"); } diff --git a/test/integration-tests/liquidation/util/LiquidationSimBase.sol b/test/integration-tests/liquidation/util/LiquidationSimBase.sol index 0ba1e560..40b21fac 100644 --- a/test/integration-tests/liquidation/util/LiquidationSimBase.sol +++ b/test/integration-tests/liquidation/util/LiquidationSimBase.sol @@ -162,11 +162,12 @@ contract LiquidationSimBase is PMRMTestBase { action.Results.PostBM = json.readInt(string.concat(baseActionIndex, ".Results.PostBM")); // Ignored for insolvent so we just set to 0 - action.Results.PreFMax = uint(tryGetWithDefault(json, string.concat(baseActionIndex, ".Results.PreFMax"), 0)); - action.Results.ExpectedBidPrice = tryGetWithDefault(json, string.concat(baseActionIndex, ".Results.ExpectedBidPrice"), 0); - action.Results.LiquidatedOfOriginal = uint(tryGetWithDefault(json, string.concat(baseActionIndex, ".Results.fLiquidatedOfOriginal"), 0)); - action.Results.PostFMax = uint(tryGetWithDefault(json, string.concat(baseActionIndex, ".Results.PostFMax"), 0)); - action.Results.SMPayout = tryGetWithDefault(json, string.concat(baseActionIndex, ".Results.SMPayout"), 0); + action.Results.PreFMax = json.readUint(string.concat(baseActionIndex, ".Results.PreFMax")); + action.Results.ExpectedBidPrice = json.readInt(string.concat(baseActionIndex, ".Results.ExpectedBidPrice")); + action.Results.LiquidatedOfOriginal = json.readUint(string.concat(baseActionIndex, ".Results.fLiquidatedOfOriginal")); + action.Results.PostFMax = json.readUint(string.concat(baseActionIndex, ".Results.PostFMax")); + console2.log("res", action.Results.PostFMax); + action.Results.SMPayout = json.readInt(string.concat(baseActionIndex, ".Results.SMPayout")); return action; } From 9893d68d98ebcb4f5b0338c93490eea75154e1e3 Mon Sep 17 00:00:00 2001 From: Dominic Romanowski Date: Fri, 17 Nov 2023 14:30:42 +1100 Subject: [PATCH 13/14] . --- src/risk-managers/PMRM.sol | 2 + .../liquidation/PMRM_solvent.json | 507 ++++++++++++------ .../liquidation/PM_liquidationSimTests.t.sol | 106 ++-- .../liquidation/util/LiquidationSimBase.sol | 5 + 4 files changed, 395 insertions(+), 225 deletions(-) diff --git a/src/risk-managers/PMRM.sol b/src/risk-managers/PMRM.sol index 2d57ea60..96574506 100644 --- a/src/risk-managers/PMRM.sol +++ b/src/risk-managers/PMRM.sol @@ -28,6 +28,8 @@ import {IBasePortfolioViewer} from "../interfaces/IBasePortfolioViewer.sol"; import {BaseManager} from "./BaseManager.sol"; +import "forge-std/console2.sol"; + /** * @title PMRM * @author Lyra diff --git a/test/integration-tests/liquidation/PMRM_solvent.json b/test/integration-tests/liquidation/PMRM_solvent.json index b6930124..d0c8e3ac 100644 --- a/test/integration-tests/liquidation/PMRM_solvent.json +++ b/test/integration-tests/liquidation/PMRM_solvent.json @@ -36,7 +36,7 @@ "PerpPrice": 1505000000000000000000, "PerpConfidence": 1000000000000000000, "FeedExpiries": [ - 500400 + 1670400000 ], "Forwards": [ 1500833279310993817600 @@ -107,7 +107,7 @@ "PerpPrice": 1505000000000000000000, "PerpConfidence": 1000000000000000000, "FeedExpiries": [ - 500400 + 1670400000 ], "Forwards": [ 1500833279310993817600 @@ -197,7 +197,7 @@ "PerpPrice": 1505000000000000000000, "PerpConfidence": 1000000000000000000, "FeedExpiries": [ - 500400 + 1670400000 ], "Forwards": [ 1500833279310993817600 @@ -268,7 +268,7 @@ "PerpPrice": 1505000000000000000000, "PerpConfidence": 1000000000000000000, "FeedExpiries": [ - 500400 + 1670400000 ], "Forwards": [ 1500833279310993817600 @@ -358,7 +358,7 @@ "PerpPrice": 1505000000000000000000, "PerpConfidence": 1000000000000000000, "FeedExpiries": [ - 500400 + 1670400000 ], "Forwards": [ 1500833279310993817600 @@ -429,7 +429,7 @@ "PerpPrice": 1505000000000000000000, "PerpConfidence": 1000000000000000000, "FeedExpiries": [ - 500370 + 1670400000 ], "Forwards": [ 1500833229340328329216 @@ -519,7 +519,7 @@ "PerpPrice": 1505000000000000000000, "PerpConfidence": 1000000000000000000, "FeedExpiries": [ - 500400 + 1670400000 ], "Forwards": [ 1500833279310993817600 @@ -590,7 +590,7 @@ "PerpPrice": 1505000000000000000000, "PerpConfidence": 1000000000000000000, "FeedExpiries": [ - 500370 + 1670400000 ], "Forwards": [ 1500833229340328329216 @@ -677,7 +677,7 @@ "PerpPrice": 1505000000000000000000, "PerpConfidence": 1000000000000000000, "FeedExpiries": [ - 500370 + 1670400000 ], "Forwards": [ 1500833229340328329216 @@ -767,7 +767,7 @@ "PerpPrice": 1505000000000000000000, "PerpConfidence": 1000000000000000000, "FeedExpiries": [ - 500400 + 1670400000 ], "Forwards": [ 1500833279310993817600 @@ -838,7 +838,7 @@ "PerpPrice": 1505000000000000000000, "PerpConfidence": 1000000000000000000, "FeedExpiries": [ - 500370 + 1670400000 ], "Forwards": [ 1500833229340328329216 @@ -925,7 +925,7 @@ "PerpPrice": 1505000000000000000000, "PerpConfidence": 1000000000000000000, "FeedExpiries": [ - 499800 + 1670400000 ], "Forwards": [ 1500832279897993904128 @@ -1015,7 +1015,7 @@ "PerpPrice": 1505000000000000000000, "PerpConfidence": 1000000000000000000, "FeedExpiries": [ - 500400 + 1670400000 ], "Forwards": [ 1500833279310993817600 @@ -1086,7 +1086,7 @@ "PerpPrice": 1505000000000000000000, "PerpConfidence": 1000000000000000000, "FeedExpiries": [ - 500370 + 1670400000 ], "Forwards": [ 1500833229340328329216 @@ -1173,7 +1173,7 @@ "PerpPrice": 1505000000000000000000, "PerpConfidence": 1000000000000000000, "FeedExpiries": [ - 500370 + 1670400000 ], "Forwards": [ 1500833229340328329216 @@ -1260,7 +1260,7 @@ "PerpPrice": 1505000000000000000000, "PerpConfidence": 1000000000000000000, "FeedExpiries": [ - 500370 + 1670400000 ], "Forwards": [ 1500833229340328329216 @@ -1368,10 +1368,10 @@ "PerpPrice": 1505000000000000000000, "PerpConfidence": 1000000000000000000, "FeedExpiries": [ - 7758000, - 7758000, - 7758000, - 7758000 + 1677657600, + 1677657600, + 1677657600, + 1677657600 ], "Forwards": [ 1512971000787409567744, @@ -1484,10 +1484,10 @@ "PerpPrice": 1505000000000000000000, "PerpConfidence": 1000000000000000000, "FeedExpiries": [ - 7757970, - 7757970, - 7757970, - 7757970 + 1677657600, + 1677657600, + 1677657600, + 1677657600 ], "Forwards": [ 1512970950412615024640, @@ -1601,7 +1601,7 @@ "PerpPrice": 1505000000000000000000, "PerpConfidence": 1000000000000000000, "FeedExpiries": [ - 500400 + 1670400000 ], "Forwards": [ 1500833279310993817600 @@ -1672,7 +1672,7 @@ "PerpPrice": 1505000000000000000000, "PerpConfidence": 1000000000000000000, "FeedExpiries": [ - 500370 + 1670400000 ], "Forwards": [ 1500833229340328329216 @@ -1759,7 +1759,7 @@ "PerpPrice": 1505000000000000000000, "PerpConfidence": 1000000000000000000, "FeedExpiries": [ - 500370 + 1670400000 ], "Forwards": [ 1500833229340328329216 @@ -1846,7 +1846,7 @@ "PerpPrice": 1505000000000000000000, "PerpConfidence": 1000000000000000000, "FeedExpiries": [ - 500370 + 1670400000 ], "Forwards": [ 1500833229340328329216 @@ -2067,12 +2067,12 @@ "PerpPrice": 1505000000000000000000, "PerpConfidence": 1000000000000000000, "FeedExpiries": [ - 1191600, - 500400, - 7758000, - 500400, - 2487600, - 1191600 + 1671091200, + 1670400000, + 1677657600, + 1670400000, + 1672387200, + 1671091200 ], "Forwards": [ 1501985045187195830272, @@ -2183,12 +2183,12 @@ -1600000000000000000 ], "OptionVols": [ - 1081048412866353792, - 1138939398052892160, - 1175456213289622784, - 1168496419451440128, - 1062799244178520832, - 1262509092493988864 + 1047554809890547840, + 1183586609116811264, + 1138661228182543872, + 1212411005988884480, + 1037397363758752128, + 1303695811129270528 ], "SVIparams": [ 1, @@ -2208,25 +2208,25 @@ "Cash": -5008723085851319336960, "Perps": 0, "Base": 5000000000000000000, - "SpotPrice": 1500000000000000000000, + "SpotPrice": 1600000000000000000000, "SpotConfidence": 1000000000000000000, - "PerpPrice": 1505000000000000000000, + "PerpPrice": 1605000000000000000000, "PerpConfidence": 1000000000000000000, "FeedExpiries": [ - 1191599, - 500399, - 7757999, - 500399, - 2487599, - 1191599 + 1671091200, + 1670400000, + 1677657600, + 1670400000, + 1672387200, + 1671091200 ], "Forwards": [ - 1501985043520228950016, - 1500833277645305413632, - 1512970999108249845760, - 1500833277645305413632, - 1504146987416321261568, - 1501985043520228950016 + 1602117379754910547968, + 1600888829488325722112, + 1613835732382132994048, + 1600888829488325722112, + 1604423453244076326912, + 1602117379754910547968 ], "ForwardConfidences": [ 1000000000000000000, @@ -2271,7 +2271,7 @@ 0.6962770273617649, 0.6212324935488645 ], - "SettlementPrice": 1500833277645305413632, + "SettlementPrice": 1600888829488325722112, "PercentFixed": 0, "ForwardsFixed": [ 0, @@ -2282,29 +2282,29 @@ 0 ], "ForwardsVariable": [ - 1501985043520228950016, - 1500833277645305413632, - 1512970999108249845760, - 1500833277645305413632, - 1504146987416321261568, - 1501985043520228950016 + 1602117379754910547968, + 1600888829488325722112, + 1613835732382132994048, + 1600888829488325722112, + 1604423453244076326912, + 1602117379754910547968 ] }, "Liquidator": { "PercentWant": 212000000000000000 }, "Results": { - "PreMtM": 510089056180759166976, - "PreMM": -2203579942180327522304, - "PreBM": -2746313741852544598016, - "PreFMax": 846247881370359424, - "ExpectedBidPrice": 105781452328275935232, + "PreMtM": 642400350514621054976, + "PreMM": -1771031720645170823168, + "PreBM": -2253718134877129277440, + "PreFMax": 781966990730214272, + "ExpectedBidPrice": 133219956849161289728, "FinalPercentageReceived": 212000000000000000, "fLiquidatedOfOriginal": 212000000000000000, - "PostMtM": 507731628598714433536, - "PostMM": -1630639542109820944384, - "PostBM": -2058313776251528019968, - "PostFMax": 804883098185735168, + "PostMtM": 639431433054684053504, + "PostMM": -1262353039019232722944, + "PostBM": -1642709933434015842304, + "PostFMax": 723308363870829824, "PercentLiquidated": 212000000000000000, "SMPayout": 0 } @@ -2345,12 +2345,12 @@ -1260800000000000256 ], "OptionVols": [ - 1081048600443659648, - 1138939166206683392, - 1175456400499937280, - 1168496190632824064, - 1062799419362179456, - 1262508877555349760 + 1124897328781591040, + 1085836000502368896, + 1217822136291152896, + 1115411294310137344, + 1105698526538111872, + 1212296181135196928 ], "SVIparams": [ 1, @@ -2367,28 +2367,28 @@ 1000000000000000000, 1000000000000000000 ], - "Cash": -3841092339322564116480, + "Cash": -3813653834801678385152, "Perps": 0, "Base": 3940000000000000512, - "SpotPrice": 1500000000000000000000, + "SpotPrice": 1390000000000000000000, "SpotConfidence": 1000000000000000000, - "PerpPrice": 1505000000000000000000, + "PerpPrice": 1395000000000000000000, "PerpConfidence": 1000000000000000000, "FeedExpiries": [ - 1191300, - 500100, - 7757700, - 500100, - 2487300, - 1191300 + 1671091200, + 1670400000, + 1677657600, + 1670400000, + 1672387200, + 1671091200 ], "Forwards": [ - 1501984545097129132032, - 1500832779604410761216, - 1512970497039538585600, - 1500832779604410761216, - 1504146488275796230144, - 1501984545097129132032 + 1391839011790006255616, + 1390771709100087312384, + 1402019327256639045632, + 1390771709100087312384, + 1393842412468904394752, + 1391839011790006255616 ], "ForwardConfidences": [ 1000000000000000000, @@ -2433,7 +2433,7 @@ 0.6962660745999473, 0.6212039764153356 ], - "SettlementPrice": 1500832779604410761216, + "SettlementPrice": 1390771709100087312384, "PercentFixed": 0, "ForwardsFixed": [ 0, @@ -2444,29 +2444,29 @@ 0 ], "ForwardsVariable": [ - 1501984545097129132032, - 1500832779604410761216, - 1512970497039538585600, - 1500832779604410761216, - 1504146488275796230144, - 1501984545097129132032 + 1391839011790006255616, + 1390771709100087312384, + 1402019327256639045632, + 1390771709100087312384, + 1393842412468904394752, + 1391839011790006255616 ] }, "Liquidator": { "PercentWant": 177664974619289344 }, "Results": { - "PreMtM": 507870376293439242240, - "PreMM": -1630279398986097360896, - "PreBM": -2057909354042004865024, - "PreFMax": 829503039144855296, - "ExpectedBidPrice": 56355949015985954816, + "PreMtM": 318804576311993499648, + "PreMM": -2110882991457339703296, + "PreBM": -2596820505011206225920, + "PreFMax": 902787818447649664, + "ExpectedBidPrice": 26011155068535709696, "FinalPercentageReceived": 177664974619289344, "fLiquidatedOfOriginal": 177664974619289344, - "PostMtM": 492789206838456287232, - "PostMM": -1265486242883802234880, - "PostBM": -1617141332828253847552, - "PostFMax": 792667275997139072, + "PostMtM": 311843844673934655488, + "PostMM": -1686173343034857750528, + "PostBM": -2085776780576616087552, + "PostFMax": 881785186630783744, "PercentLiquidated": 140000000000000016, "SMPayout": 0 } @@ -2507,12 +2507,12 @@ -1036800000000000128 ], "OptionVols": [ - 1081053431053289728, - 1138933195579575424, - 1175461221627552256, - 1168490297969628672, - 1062803930850502656, - 1262503342334851840 + 1056408066959279488, + 1170592799128591872, + 1149531706780766208, + 1199652232702845440, + 1042062949539862784, + 1291736833438787840 ], "SVIparams": [ 1, @@ -2529,28 +2529,28 @@ 1000000000000000000, 1000000000000000000 ], - "Cash": -3083515158287393226752, + "Cash": -3086421447713958133760, "Perps": 0, "Base": 3240000000000000000, - "SpotPrice": 1500000000000000000000, + "SpotPrice": 1570000000000000000000, "SpotConfidence": 1000000000000000000, - "PerpPrice": 1505000000000000000000, + "PerpPrice": 1575000000000000000000, "PerpConfidence": 1000000000000000000, "FeedExpiries": [ - 1183600, - 492400, - 7750000, - 492400, - 2479600, - 1183600 + 1671091200, + 1670400000, + 1677657600, + 1670400000, + 1672387200, + 1671091200 ], "Forwards": [ - 1501971709509061050368, - 1500819953859045621760, - 1512957567568245424128, - 1500819953859045621760, - 1504133634212297179136, - 1501971709509061050368 + 1572063722619483979776, + 1570858218372467785728, + 1583562254054763266048, + 1570858218372467785728, + 1574326537142204366848, + 1572063722619483979776 ], "ForwardConfidences": [ 1000000000000000000, @@ -2595,7 +2595,7 @@ 0.6959834225060578, 0.6204663676355897 ], - "SettlementPrice": 1500819953859045621760, + "SettlementPrice": 1570858218372467785728, "PercentFixed": 0, "ForwardsFixed": [ 0, @@ -2606,30 +2606,30 @@ 0 ], "ForwardsVariable": [ - 1501971709509061050368, - 1500819953859045621760, - 1512957567568245424128, - 1500819953859045621760, - 1504133634212297179136, - 1501971709509061050368 + 1572063722619483979776, + 1570858218372467785728, + 1583562254054763266048, + 1570858218372467785728, + 1574326537142204366848, + 1572063722619483979776 ] }, "Liquidator": { "PercentWant": 1000000000000000000 }, "Results": { - "PreMtM": 495719167035687436288, - "PreMM": -1257829300755020906496, - "PreBM": -1608538994313162653696, - "PreFMax": 850567377484409856, - "ExpectedBidPrice": 102459416085279768576, - "FinalPercentageReceived": 850567377484409856, - "fLiquidatedOfOriginal": 850567377484409856, - "PostMtM": 314444815500192514048, - "PostMM": 52407469250032189440, - "PostBM": 113686, - "PostFMax": 0, - "PercentLiquidated": 551167660609897664, + "PreMtM": 558350023025698209792, + "PreMM": -1055309310999661641728, + "PreBM": -1378041177804733415424, + "PreFMax": 819580323180499968, + "ExpectedBidPrice": 118123057777596776448, + "FinalPercentageReceived": 819580323180499968, + "fLiquidatedOfOriginal": 819580323180499968, + "PostMtM": 349363074649949995008, + "PostMM": 58227179108324892672, + "PostBM": -113686, + "PostFMax": 374, + "PercentLiquidated": 531088049420963968, "SMPayout": 0 } } @@ -2696,9 +2696,9 @@ "Cash": -1250915032679738507264, "Perps": 0, "Base": 1000000000000000000, - "SpotPrice": 1500000000000000000000, + "SpotPrice": 1520000000000000000000, "SpotConfidence": 1000000000000000000, - "PerpPrice": 1505000000000000000000, + "PerpPrice": 1525000000000000000000, "PerpConfidence": 1000000000000000000, "FeedExpiries": [], "Forwards": [], @@ -2719,17 +2719,17 @@ "PercentWant": 100000000000000000 }, "Results": { - "PreMtM": 249084967320261525504, - "PreMM": -5915032679738487808, - "PreBM": -56915032679738490880, - "PreFMax": 189074991640574880, - "ExpectedBidPrice": 24410326797385629696, + "PreMtM": 269084967320261525504, + "PreMM": 10684967320261421056, + "PreBM": -40995032679738589184, + "PreFMax": 134543030242708784, + "ExpectedBidPrice": 26370326797385625600, "FinalPercentageReceived": 100000000000000000, "fLiquidatedOfOriginal": 100000000000000000, - "PostMtM": 248586797385620914176, - "PostMM": 19086797385620910080, - "PostBM": -26813202614379065344, - "PostFMax": 98972212933972304, + "PostMtM": 268546797385620946944, + "PostMM": 35986797385621004288, + "PostBM": -10525202614378997760, + "PostFMax": 38381144714120520, "PercentLiquidated": 100000000000000000, "SMPayout": 0 } @@ -2750,12 +2750,12 @@ 0.05 ], "OptionVolConfidences": [], - "Cash": -1101413202614379085824, + "Cash": -1099453202614379085824, "Perps": 0, "Base": 900000000000000000, - "SpotPrice": 1500000000000000000000, + "SpotPrice": 1490000000000000000000, "SpotConfidence": 1000000000000000000, - "PerpPrice": 1505000000000000000000, + "PerpPrice": 1495000000000000000000, "PerpConfidence": 1000000000000000000, "FeedExpiries": [], "Forwards": [], @@ -2776,18 +2776,179 @@ "PercentWant": 111111111111111120 }, "Results": { - "PreMtM": 248586797385620914176, - "PreMM": 19086797385620910080, - "PreBM": -26813202614379065344, - "PreFMax": 98972212933972304, - "ExpectedBidPrice": 21743496554208296960, - "FinalPercentageReceived": 98972212933972304, - "fLiquidatedOfOriginal": 98972212933972304, - "PostMtM": 248143052557984006144, - "PostMM": 41357175426330624000, - "PostBM": -28421, - "PostFMax": 116, - "PercentLiquidated": 89074991640575072, + "PreMtM": 241546797385620946944, + "PreMM": 13576797385621147648, + "PreBM": -32017202614378790912, + "PreFMax": 118907920440133632, + "ExpectedBidPrice": 23430326797385629696, + "FinalPercentageReceived": 111111111111111120, + "fLiquidatedOfOriginal": 111111111111111120, + "PostMtM": 241068627450980433920, + "PostMM": 38428627450980343808, + "PostBM": -2099372549019676672, + "PostFMax": 8771410495151708, + "PercentLiquidated": 100000000000000000, + "SMPayout": 0 + } + } + ] + }, + "test_DOMSEAN": { + "StartTime": 0, + "IsForce": false, + "InitialPortfolio": { + "OptionExpiries": [ + 1191600 + ], + "OptionStrikes": [ + 1600000000000000000000 + ], + "OptionIsCall": [ + 1 + ], + "OptionAmounts": [ + -1000000000000000000 + ], + "OptionVols": [ + 1081048412239005184 + ], + "SVIparams": [ + 1, + 1.5, + -0.1, + -0.05, + 0.05 + ], + "OptionVolConfidences": [ + 1000000000000000000 + ], + "Cash": 200000000000000000000, + "Perps": 0, + "Base": 0, + "SpotPrice": 1500000000000000000000, + "SpotConfidence": 1000000000000000000, + "PerpPrice": 1505000000000000000000, + "PerpConfidence": 1000000000000000000, + "FeedExpiries": [ + 1671091200 + ], + "Forwards": [ + 1501985045187195830272 + ], + "ForwardConfidences": [ + 1000000000000000000 + ], + "Rates": [ + 0 + ], + "RateConfidences": [ + 1000000000000000000 + ], + "StablePrice": 1000000000000000000, + "UnrealisedPerpPNL": 0, + "UnrealisedFunding": 0, + "VolShockUp": [ + 1.5681511166375728 + ], + "VolShockDown": [ + 0.6212325889082848 + ], + "SettlementPrice": 1501985045187195830272, + "PercentFixed": 0, + "ForwardsFixed": [ + 0 + ], + "ForwardsVariable": [ + 1501985045187195830272 + ] + }, + "ActionCount": 1, + "LiquidationFee": 1.2738185008613723, + "Actions": [ + { + "Time": 1, + "PortfolioAndFeeds": { + "OptionExpiries": [ + 1191599 + ], + "OptionStrikes": [ + 1600000000000000000000 + ], + "OptionIsCall": [ + 1 + ], + "OptionAmounts": [ + -1000000000000000000 + ], + "OptionVols": [ + 1047554809890547840 + ], + "SVIparams": [ + 1, + 1.5, + -0.1, + -0.05, + 0.05 + ], + "OptionVolConfidences": [ + 1000000000000000000 + ], + "Cash": 198726181499138605056, + "Perps": 0, + "Base": 0, + "SpotPrice": 1600000000000000000000, + "SpotConfidence": 1000000000000000000, + "PerpPrice": 1605000000000000000000, + "PerpConfidence": 1000000000000000000, + "FeedExpiries": [ + 1671091200 + ], + "Forwards": [ + 1602117379754910547968 + ], + "ForwardConfidences": [ + 1000000000000000000 + ], + "Rates": [ + 0 + ], + "RateConfidences": [ + 1000000000000000000 + ], + "StablePrice": 1000000000000000000, + "UnrealisedPerpPNL": 0, + "UnrealisedFunding": 0, + "VolShockUp": [ + 1.5681512596767035 + ], + "VolShockDown": [ + 0.6212324935488645 + ], + "SettlementPrice": 1602117379754910547968, + "PercentFixed": 0, + "ForwardsFixed": [ + 0 + ], + "ForwardsVariable": [ + 1602117379754910547968 + ] + }, + "Liquidator": { + "PercentWant": 1000000000000000000 + }, + "Results": { + "PreMtM": 67825504170939867136, + "PreMM": -177580319470280769536, + "PreBM": -226661484198524911616, + "PreFMax": 773566526059432448, + "ExpectedBidPrice": 51323747275597086720, + "FinalPercentageReceived": 773566526059432448, + "fLiquidatedOfOriginal": 773566526059432448, + "PostMtM": 66681711806793457664, + "PostMM": 11113618634465595392, + "PostBM": 28421, + "PostFMax": 0, + "PercentLiquidated": 773566526059432448, "SMPayout": 0 } } diff --git a/test/integration-tests/liquidation/PM_liquidationSimTests.t.sol b/test/integration-tests/liquidation/PM_liquidationSimTests.t.sol index e1e2c180..75412564 100644 --- a/test/integration-tests/liquidation/PM_liquidationSimTests.t.sol +++ b/test/integration-tests/liquidation/PM_liquidationSimTests.t.sol @@ -9,79 +9,79 @@ import "./util/LiquidationSimBase.sol"; contract LiquidationSimTests_PM is LiquidationSimBase { using stdJson for string; - function testLiquidationSim1() public { - runLiquidationSim("PMRM_solvent", "Test1"); - } + function testLiquidationSim1() public { + runLiquidationSim("PMRM_solvent", "Test1"); + } - function testLiquidationSim2() public { - runLiquidationSim("PMRM_solvent", "Test2"); - } + function testLiquidationSim2() public { + runLiquidationSim("PMRM_solvent", "Test2"); + } - function testLiquidationSim3() public { - runLiquidationSim("PMRM_solvent", "Test3"); - } + function testLiquidationSim3() public { + runLiquidationSim("PMRM_solvent", "Test3"); + } - function testLiquidationSim4() public { - runLiquidationSim("PMRM_solvent", "Test4"); - } + function testLiquidationSim4() public { + runLiquidationSim("PMRM_solvent", "Test4"); + } - function testLiquidationSim5() public { - runLiquidationSim("PMRM_solvent", "Test5"); - } + function testLiquidationSim5() public { + runLiquidationSim("PMRM_solvent", "Test5"); + } - function testLiquidationSim6() public { - runLiquidationSim("PMRM_solvent", "Test6"); - } + function testLiquidationSim6() public { + runLiquidationSim("PMRM_solvent", "Test6"); + } - function testLiquidationSimLong_Box_Short_Cash() public { - runLiquidationSim("PMRM_solvent", "test_Nov_01_long_box_neg_cash"); - } + function testLiquidationSimLong_Box_Short_Cash() public { + runLiquidationSim("PMRM_solvent", "test_Nov_01_long_box_neg_cash"); + } - function testLiquidationSimSimple_Short_3_liquidators() public { - runLiquidationSim("PMRM_solvent", "test_Nov_02_3_liqs_same_price_same_amount"); - } + function testLiquidationSimSimple_Short_3_liquidators() public { + runLiquidationSim("PMRM_solvent", "test_Nov_02_3_liqs_same_price_same_amount"); + } - function testLiquidationSimPMRM_perp() public { - runLiquidationSim("PMRM_solvent", "test_Nov_03_perp"); - } + function testLiquidationSimPMRM_perp() public { + runLiquidationSim("PMRM_solvent", "test_Nov_03_perp"); + } function testLiquidationSimPMRM_General() public { runLiquidationSim("PMRM_solvent", "test_Nov_04_general"); } - function testLiquidationSimPMRM_Borrow() public { - runLiquidationSim("PMRM_solvent", "test_Nov_05_borrow"); - } + function testLiquidationSimPMRM_Borrow() public { + runLiquidationSim("PMRM_solvent", "test_Nov_05_borrow"); + } - function testLiquidationSim_insolvent_1() public { - runLiquidationSim("PMRM_insolvent", "test_Nov_01_Insolvent_basic"); - } + function testLiquidationSim_insolvent_1() public { + runLiquidationSim("PMRM_insolvent", "test_Nov_01_Insolvent_basic"); + } - function testLiquidationSim_insolvent_2() public { - runLiquidationSim("PMRM_insolvent", "test_Nov_02_Insolvent_basic_mtm_pos"); - } + function testLiquidationSim_insolvent_2() public { + runLiquidationSim("PMRM_insolvent", "test_Nov_02_Insolvent_basic_mtm_pos"); + } - function testLiquidationSim_insolvent_3() public { - runLiquidationSim("PMRM_insolvent", "test_Nov_03_Insolvent_basic_at_end"); - } + function testLiquidationSim_insolvent_3() public { + runLiquidationSim("PMRM_insolvent", "test_Nov_03_Insolvent_basic_at_end"); + } - function testLiquidationSim_insolvent_4() public { - runLiquidationSim("PMRM_insolvent", "test_Nov_04_Insolvent_two_liq_same_disc_same_amount"); - } + function testLiquidationSim_insolvent_4() public { + runLiquidationSim("PMRM_insolvent", "test_Nov_04_Insolvent_two_liq_same_disc_same_amount"); + } - function testLiquidationSim_insolvent_5() public { - runLiquidationSim("PMRM_insolvent", "test_Nov_05_Insolvent_two_liq_same_disc_diff_amount"); - } + function testLiquidationSim_insolvent_5() public { + runLiquidationSim("PMRM_insolvent", "test_Nov_05_Insolvent_two_liq_same_disc_diff_amount"); + } - function testLiquidationSim_insolvent_6() public { - runLiquidationSim("PMRM_insolvent", "test_Nov_06_Insolvent_General"); - } + function testLiquidationSim_insolvent_6() public { + runLiquidationSim("PMRM_insolvent", "test_Nov_06_Insolvent_General"); + } function runLiquidationSim(string memory fileName, string memory testName) internal { LiquidationSim memory data = LiquidationSimBase.getTestData(fileName, testName); setupTestScenario(data); - + vm.warp(data.StartTime); startAuction(); @@ -109,11 +109,11 @@ contract LiquidationSimTests_PM is LiquidationSimBase { _depositCash(liqAcc, 1000000000e18); (uint finalPercentage, uint cashFromBidder, uint cashToBidder) = - auction.bid(aliceAcc, liqAcc, data.Actions[actionId].Liquidator.PercentLiquidated, 0, 0); + auction.bid(aliceAcc, liqAcc, data.Actions[actionId].Liquidator.PercentLiquidated, 0, 0); IDutchAuction.Auction memory auctionDetails = auction.getAuction(aliceAcc); if (auctionDetails.insolvent) { - assertApproxEqRel(int(cashToBidder), -data.Actions[actionId].Results.SMPayout, 0.001e18, "bid price insolvent"); + assertApproxEqRel(int(cashToBidder), - data.Actions[actionId].Results.SMPayout, 0.001e18, "bid price insolvent"); } else { assertApproxEqRel(int(cashFromBidder), data.Actions[actionId].Results.ExpectedBidPrice, 0.001e18, "bid price solvent"); assertApproxEqRel( @@ -134,6 +134,8 @@ contract LiquidationSimTests_PM is LiquidationSimBase { assertApproxEqRel(fMax, data.Actions[actionId].Results.PreFMax, 0.001e18, "pre fmax"); } + console2.log("MTM", mtm); + assertApproxEqRel(mtm, data.Actions[actionId].Results.PreMtM, 0.001e18, "pre mtm"); assertApproxEqRel(mm, data.Actions[actionId].Results.PreMM, 0.001e18, "pre mm"); assertApproxEqRel(bm, data.Actions[actionId].Results.PreBM, 0.001e18, "pre bm"); @@ -175,7 +177,7 @@ contract LiquidationSimTests_PM is LiquidationSimBase { worstScenario = i; } } - //console2.log("worst scenario", worstScenario); + //console2.log("worst scenario", worstScenario); } function updateToActionState(LiquidationSim memory data, uint actionId) internal { diff --git a/test/integration-tests/liquidation/util/LiquidationSimBase.sol b/test/integration-tests/liquidation/util/LiquidationSimBase.sol index 40b21fac..1cf46752 100644 --- a/test/integration-tests/liquidation/util/LiquidationSimBase.sol +++ b/test/integration-tests/liquidation/util/LiquidationSimBase.sol @@ -5,6 +5,8 @@ import "test/shared/utils/JsonMechIO.sol"; import "test/risk-managers/unit-tests/PMRM/utils/PMRMTestBase.sol"; import "lyra-utils/encoding/OptionEncoding.sol"; +import "forge-std/console2.sol"; + contract TempReader { function readInt(string memory json, string memory location) external pure returns (int) { @@ -252,7 +254,10 @@ contract LiquidationSimBase is PMRMTestBase { stableFeed.setSpot(feedData.StablePrice, feedData.StableConfidence); feed.setSpot(feedData.SpotPrice, feedData.SpotConfidence); + console.log("AAAAAAA", feedData.FeedExpiries.length); for (uint i = 0; i < feedData.FeedExpiries.length; i++) { + console2.log("Setting expiry:", feedData.FeedExpiries[i]); + console2.log("fwd", feedData.Forwards[i]); feed.setForwardPrice(feedData.FeedExpiries[i], feedData.Forwards[i], feedData.ForwardConfidences[i]); feed.setInterestRate(feedData.FeedExpiries[i], int64(feedData.Rates[i]), uint64(feedData.RateConfidences[i])); } From 39025450c7b07d1808f8eae6e405fb59b56cdb11 Mon Sep 17 00:00:00 2001 From: Dominic Romanowski Date: Mon, 20 Nov 2023 10:19:53 +1100 Subject: [PATCH 14/14] try add srm, tests seem more broken though --- .../liquidation/PM_liquidationSimTests.t.sol | 6 +- .../liquidation/SRM_liquidation.json | 2957 +++++++++++++++++ .../liquidation/SRM_liquidationSim.t.sol | 133 + ...SimBase.sol => PMRMLiquidationSimBase.sol} | 19 +- .../util/SRMLiquidationSimBase.sol | 255 ++ .../StandardManager/StandardManagerPublic.sol | 14 + .../TestStandardManagerBase.t.sol | 21 +- 7 files changed, 3383 insertions(+), 22 deletions(-) create mode 100644 test/integration-tests/liquidation/SRM_liquidation.json create mode 100644 test/integration-tests/liquidation/SRM_liquidationSim.t.sol rename test/integration-tests/liquidation/util/{LiquidationSimBase.sol => PMRMLiquidationSimBase.sol} (95%) create mode 100644 test/integration-tests/liquidation/util/SRMLiquidationSimBase.sol diff --git a/test/integration-tests/liquidation/PM_liquidationSimTests.t.sol b/test/integration-tests/liquidation/PM_liquidationSimTests.t.sol index d4207e00..89f11981 100644 --- a/test/integration-tests/liquidation/PM_liquidationSimTests.t.sol +++ b/test/integration-tests/liquidation/PM_liquidationSimTests.t.sol @@ -4,9 +4,9 @@ pragma solidity ^0.8.18; import "forge-std/Test.sol"; import "forge-std/console2.sol"; import "test/shared/utils/JsonMechIO.sol"; -import "./util/LiquidationSimBase.sol"; +import "./util/PMRMLiquidationSimBase.sol"; -contract LiquidationSimTests_PM is LiquidationSimBase { +contract LiquidationSimTests_PM is PMRMLiquidationSimBase { using stdJson for string; function testLiquidationSim1() public { @@ -79,7 +79,7 @@ contract LiquidationSimTests_PM is LiquidationSimBase { function runLiquidationSim(string memory fileName, string memory testName) internal { - LiquidationSim memory data = LiquidationSimBase.getTestData(fileName, testName); + LiquidationSim memory data = PMRMLiquidationSimBase.getTestData(fileName, testName); setupTestScenario(data); diff --git a/test/integration-tests/liquidation/SRM_liquidation.json b/test/integration-tests/liquidation/SRM_liquidation.json new file mode 100644 index 00000000..d0c8e3ac --- /dev/null +++ b/test/integration-tests/liquidation/SRM_liquidation.json @@ -0,0 +1,2957 @@ +{ + "Test1": { + "StartTime": 0, + "IsForce": false, + "InitialPortfolio": { + "OptionExpiries": [ + 500400 + ], + "OptionStrikes": [ + 1500000000000000000000 + ], + "OptionIsCall": [ + 1 + ], + "OptionAmounts": [ + -1000000000000000000 + ], + "OptionVols": [ + 1047884494084986240 + ], + "SVIparams": [ + 1, + 1.5, + -0.1, + -0.05, + 0.05 + ], + "OptionVolConfidences": [ + 1000000000000000000 + ], + "Cash": 200000000000000000000, + "Perps": 0, + "Base": 0, + "SpotPrice": 1500000000000000000000, + "SpotConfidence": 1000000000000000000, + "PerpPrice": 1505000000000000000000, + "PerpConfidence": 1000000000000000000, + "FeedExpiries": [ + 1670400000 + ], + "Forwards": [ + 1500833279310993817600 + ], + "ForwardConfidences": [ + 1000000000000000000 + ], + "Rates": [ + 0 + ], + "RateConfidences": [ + 1000000000000000000 + ], + "StablePrice": 1000000000000000000, + "UnrealisedPerpPNL": 0, + "UnrealisedFunding": 0, + "VolShockUp": [ + 1.7370684514926746 + ], + "VolShockDown": [ + 0.508621032338217 + ], + "SettlementPrice": 1500833279310993817600, + "PercentFixed": 0, + "ForwardsFixed": [ + 0 + ], + "ForwardsVariable": [ + 1500833279310993817600 + ] + }, + "ActionCount": 1, + "LiquidationFee": 1.322084630165343, + "Actions": [ + { + "Time": 0, + "PortfolioAndFeeds": { + "OptionExpiries": [ + 500400 + ], + "OptionStrikes": [ + 1500000000000000000000 + ], + "OptionIsCall": [ + 1 + ], + "OptionAmounts": [ + -1000000000000000000 + ], + "OptionVols": [ + 1047884494084986240 + ], + "SVIparams": [ + 1, + 1.5, + -0.1, + -0.05, + 0.05 + ], + "OptionVolConfidences": [ + 1000000000000000000 + ], + "Cash": 198677915369834676224, + "Perps": 0, + "Base": 0, + "SpotPrice": 1500000000000000000000, + "SpotConfidence": 1000000000000000000, + "PerpPrice": 1505000000000000000000, + "PerpConfidence": 1000000000000000000, + "FeedExpiries": [ + 1670400000 + ], + "Forwards": [ + 1500833279310993817600 + ], + "ForwardConfidences": [ + 1000000000000000000 + ], + "Rates": [ + 0 + ], + "RateConfidences": [ + 1000000000000000000 + ], + "StablePrice": 1000000000000000000, + "UnrealisedPerpPNL": 0, + "UnrealisedFunding": 0, + "VolShockUp": [ + 1.7370684514926746 + ], + "VolShockDown": [ + 0.508621032338217 + ], + "SettlementPrice": 1500833279310993817600, + "PercentFixed": 0, + "ForwardsFixed": [ + 0 + ], + "ForwardsVariable": [ + 1500833279310993817600 + ] + }, + "Liquidator": { + "PercentWant": 1000000000000000000 + }, + "Results": { + "PreMtM": 119306330180774723584, + "PreMM": -103090619490529640448, + "PreBM": -147570009424790470656, + "PreFMax": 557941285425569408, + "ExpectedBidPrice": 65234608676059463680, + "FinalPercentageReceived": 557941285425569408, + "fLiquidatedOfOriginal": 557941285425569408, + "PostMtM": 117975011636365344768, + "PostMM": 19662501939394220032, + "PostBM": 0, + "PostFMax": 0, + "PercentLiquidated": 557941285425569408, + "SMPayout": 0 + } + } + ] + }, + "Test2": { + "StartTime": 0, + "IsForce": false, + "InitialPortfolio": { + "OptionExpiries": [ + 500400 + ], + "OptionStrikes": [ + 1500000000000000000000 + ], + "OptionIsCall": [ + 1 + ], + "OptionAmounts": [ + -1000000000000000000 + ], + "OptionVols": [ + 1047884494084986240 + ], + "SVIparams": [ + 1, + 1.5, + -0.1, + -0.05, + 0.05 + ], + "OptionVolConfidences": [ + 1000000000000000000 + ], + "Cash": 200000000000000000000, + "Perps": 0, + "Base": 0, + "SpotPrice": 1500000000000000000000, + "SpotConfidence": 1000000000000000000, + "PerpPrice": 1505000000000000000000, + "PerpConfidence": 1000000000000000000, + "FeedExpiries": [ + 1670400000 + ], + "Forwards": [ + 1500833279310993817600 + ], + "ForwardConfidences": [ + 1000000000000000000 + ], + "Rates": [ + 0 + ], + "RateConfidences": [ + 1000000000000000000 + ], + "StablePrice": 1000000000000000000, + "UnrealisedPerpPNL": 0, + "UnrealisedFunding": 0, + "VolShockUp": [ + 1.7370684514926746 + ], + "VolShockDown": [ + 0.508621032338217 + ], + "SettlementPrice": 1500833279310993817600, + "PercentFixed": 0, + "ForwardsFixed": [ + 0 + ], + "ForwardsVariable": [ + 1500833279310993817600 + ] + }, + "ActionCount": 1, + "LiquidationFee": 1.322084630165343, + "Actions": [ + { + "Time": 0, + "PortfolioAndFeeds": { + "OptionExpiries": [ + 500400 + ], + "OptionStrikes": [ + 1500000000000000000000 + ], + "OptionIsCall": [ + 1 + ], + "OptionAmounts": [ + -1000000000000000000 + ], + "OptionVols": [ + 1047884494084986240 + ], + "SVIparams": [ + 1, + 1.5, + -0.1, + -0.05, + 0.05 + ], + "OptionVolConfidences": [ + 1000000000000000000 + ], + "Cash": 198677915369834676224, + "Perps": 0, + "Base": 0, + "SpotPrice": 1500000000000000000000, + "SpotConfidence": 1000000000000000000, + "PerpPrice": 1505000000000000000000, + "PerpConfidence": 1000000000000000000, + "FeedExpiries": [ + 1670400000 + ], + "Forwards": [ + 1500833279310993817600 + ], + "ForwardConfidences": [ + 1000000000000000000 + ], + "Rates": [ + 0 + ], + "RateConfidences": [ + 1000000000000000000 + ], + "StablePrice": 1000000000000000000, + "UnrealisedPerpPNL": 0, + "UnrealisedFunding": 0, + "VolShockUp": [ + 1.7370684514926746 + ], + "VolShockDown": [ + 0.508621032338217 + ], + "SettlementPrice": 1500833279310993817600, + "PercentFixed": 0, + "ForwardsFixed": [ + 0 + ], + "ForwardsVariable": [ + 1500833279310993817600 + ] + }, + "Liquidator": { + "PercentWant": 50000000000000000 + }, + "Results": { + "PreMtM": 119306330180774723584, + "PreMM": -103090619490529640448, + "PreBM": -147570009424790470656, + "PreFMax": 557941285425569408, + "ExpectedBidPrice": 5846010178857961472, + "FinalPercentageReceived": 50000000000000000, + "fLiquidatedOfOriginal": 50000000000000000, + "PostMtM": 119187023850593943552, + "PostMM": -92090078337145208832, + "PostBM": -134345498774693052416, + "PostFMax": 534675037290073152, + "PercentLiquidated": 50000000000000000, + "SMPayout": 0 + } + } + ] + }, + "Test3": { + "StartTime": 0, + "IsForce": false, + "InitialPortfolio": { + "OptionExpiries": [ + 500400 + ], + "OptionStrikes": [ + 1500000000000000000000 + ], + "OptionIsCall": [ + 1 + ], + "OptionAmounts": [ + -1000000000000000000 + ], + "OptionVols": [ + 1047884494084986240 + ], + "SVIparams": [ + 1, + 1.5, + -0.1, + -0.05, + 0.05 + ], + "OptionVolConfidences": [ + 1000000000000000000 + ], + "Cash": 200000000000000000000, + "Perps": 0, + "Base": 0, + "SpotPrice": 1500000000000000000000, + "SpotConfidence": 1000000000000000000, + "PerpPrice": 1505000000000000000000, + "PerpConfidence": 1000000000000000000, + "FeedExpiries": [ + 1670400000 + ], + "Forwards": [ + 1500833279310993817600 + ], + "ForwardConfidences": [ + 1000000000000000000 + ], + "Rates": [ + 0 + ], + "RateConfidences": [ + 1000000000000000000 + ], + "StablePrice": 1000000000000000000, + "UnrealisedPerpPNL": 0, + "UnrealisedFunding": 0, + "VolShockUp": [ + 1.7370684514926746 + ], + "VolShockDown": [ + 0.508621032338217 + ], + "SettlementPrice": 1500833279310993817600, + "PercentFixed": 0, + "ForwardsFixed": [ + 0 + ], + "ForwardsVariable": [ + 1500833279310993817600 + ] + }, + "ActionCount": 1, + "LiquidationFee": 1.322084630165343, + "Actions": [ + { + "Time": 30, + "PortfolioAndFeeds": { + "OptionExpiries": [ + 500370 + ], + "OptionStrikes": [ + 1500000000000000000000 + ], + "OptionIsCall": [ + 1 + ], + "OptionAmounts": [ + -1000000000000000000 + ], + "OptionVols": [ + 1047884508458193792 + ], + "SVIparams": [ + 1, + 1.5, + -0.1, + -0.05, + 0.05 + ], + "OptionVolConfidences": [ + 1000000000000000000 + ], + "Cash": 198677915369834676224, + "Perps": 0, + "Base": 0, + "SpotPrice": 1500000000000000000000, + "SpotConfidence": 1000000000000000000, + "PerpPrice": 1505000000000000000000, + "PerpConfidence": 1000000000000000000, + "FeedExpiries": [ + 1670400000 + ], + "Forwards": [ + 1500833229340328329216 + ], + "ForwardConfidences": [ + 1000000000000000000 + ], + "Rates": [ + 0 + ], + "RateConfidences": [ + 1000000000000000000 + ], + "StablePrice": 1000000000000000000, + "UnrealisedPerpPNL": 0, + "UnrealisedFunding": 0, + "VolShockUp": [ + 1.737081708636119 + ], + "VolShockDown": [ + 0.5086121942425874 + ], + "SettlementPrice": 1500833229340328329216, + "PercentFixed": 0, + "ForwardsFixed": [ + 0 + ], + "ForwardsVariable": [ + 1500833229340328329216 + ] + }, + "Liquidator": { + "PercentWant": 150000000000000000 + }, + "Results": { + "PreMtM": 119308718797352435712, + "PreMM": -103087867828868841472, + "PreBM": -147567185154113110016, + "PreFMax": 571861527362324864, + "ExpectedBidPrice": 16571981040952252416, + "FinalPercentageReceived": 150000000000000000, + "fLiquidatedOfOriginal": 150000000000000000, + "PostMtM": 117984392018701828096, + "PostMM": -71052706613586223104, + "PostBM": -108860126340043833344, + "PostFMax": 496307679249793920, + "PercentLiquidated": 150000000000000000, + "SMPayout": 0 + } + } + ] + }, + "Test4": { + "StartTime": 0, + "IsForce": false, + "InitialPortfolio": { + "OptionExpiries": [ + 500400 + ], + "OptionStrikes": [ + 1500000000000000000000 + ], + "OptionIsCall": [ + 1 + ], + "OptionAmounts": [ + -1000000000000000000 + ], + "OptionVols": [ + 1047884494084986240 + ], + "SVIparams": [ + 1, + 1.5, + -0.1, + -0.05, + 0.05 + ], + "OptionVolConfidences": [ + 1000000000000000000 + ], + "Cash": 200000000000000000000, + "Perps": 0, + "Base": 0, + "SpotPrice": 1500000000000000000000, + "SpotConfidence": 1000000000000000000, + "PerpPrice": 1505000000000000000000, + "PerpConfidence": 1000000000000000000, + "FeedExpiries": [ + 1670400000 + ], + "Forwards": [ + 1500833279310993817600 + ], + "ForwardConfidences": [ + 1000000000000000000 + ], + "Rates": [ + 0 + ], + "RateConfidences": [ + 1000000000000000000 + ], + "StablePrice": 1000000000000000000, + "UnrealisedPerpPNL": 0, + "UnrealisedFunding": 0, + "VolShockUp": [ + 1.7370684514926746 + ], + "VolShockDown": [ + 0.508621032338217 + ], + "SettlementPrice": 1500833279310993817600, + "PercentFixed": 0, + "ForwardsFixed": [ + 0 + ], + "ForwardsVariable": [ + 1500833279310993817600 + ] + }, + "ActionCount": 2, + "LiquidationFee": 1.322084630165343, + "Actions": [ + { + "Time": 30, + "PortfolioAndFeeds": { + "OptionExpiries": [ + 500370 + ], + "OptionStrikes": [ + 1500000000000000000000 + ], + "OptionIsCall": [ + 1 + ], + "OptionAmounts": [ + -1000000000000000000 + ], + "OptionVols": [ + 1047884508458193792 + ], + "SVIparams": [ + 1, + 1.5, + -0.1, + -0.05, + 0.05 + ], + "OptionVolConfidences": [ + 1000000000000000000 + ], + "Cash": 198677915369834676224, + "Perps": 0, + "Base": 0, + "SpotPrice": 1500000000000000000000, + "SpotConfidence": 1000000000000000000, + "PerpPrice": 1505000000000000000000, + "PerpConfidence": 1000000000000000000, + "FeedExpiries": [ + 1670400000 + ], + "Forwards": [ + 1500833229340328329216 + ], + "ForwardConfidences": [ + 1000000000000000000 + ], + "Rates": [ + 0 + ], + "RateConfidences": [ + 1000000000000000000 + ], + "StablePrice": 1000000000000000000, + "UnrealisedPerpPNL": 0, + "UnrealisedFunding": 0, + "VolShockUp": [ + 1.737081708636119 + ], + "VolShockDown": [ + 0.5086121942425874 + ], + "SettlementPrice": 1500833229340328329216, + "PercentFixed": 0, + "ForwardsFixed": [ + 0 + ], + "ForwardsVariable": [ + 1500833229340328329216 + ] + }, + "Liquidator": { + "PercentWant": 100000000000000000 + }, + "Results": { + "PreMtM": 119308718797352435712, + "PreMM": -103087867828868841472, + "PreBM": -147567185154113110016, + "PreFMax": 571861527362324864, + "ExpectedBidPrice": 11047987360634836992, + "FinalPercentageReceived": 100000000000000000, + "fLiquidatedOfOriginal": 100000000000000000, + "PostMtM": 118425834278252019712, + "PostMM": -81731093685347155968, + "PostBM": -121762479278066974720, + "PostFMax": 524290585958138816, + "PercentLiquidated": 100000000000000000, + "SMPayout": 0 + } + }, + { + "Time": 30, + "PortfolioAndFeeds": { + "OptionExpiries": [ + 500370 + ], + "OptionStrikes": [ + 1500000000000000000000 + ], + "OptionIsCall": [ + 1 + ], + "OptionAmounts": [ + -900000000000000000 + ], + "OptionVols": [ + 1047884508458193792 + ], + "SVIparams": [ + 1, + 1.5, + -0.1, + -0.05, + 0.05 + ], + "OptionVolConfidences": [ + 1000000000000000000 + ], + "Cash": 189858111193486032896, + "Perps": 0, + "Base": 0, + "SpotPrice": 1500000000000000000000, + "SpotConfidence": 1000000000000000000, + "PerpPrice": 1505000000000000000000, + "PerpConfidence": 1000000000000000000, + "FeedExpiries": [ + 1670400000 + ], + "Forwards": [ + 1500833229340328329216 + ], + "ForwardConfidences": [ + 1000000000000000000 + ], + "Rates": [ + 0 + ], + "RateConfidences": [ + 1000000000000000000 + ], + "StablePrice": 1000000000000000000, + "UnrealisedPerpPNL": 0, + "UnrealisedFunding": 0, + "VolShockUp": [ + 1.737081708636119 + ], + "VolShockDown": [ + 0.5086121942425874 + ], + "SettlementPrice": 1500833229340328329216, + "PercentFixed": 0, + "ForwardsFixed": [ + 0 + ], + "ForwardsVariable": [ + 1500833229340328329216 + ] + }, + "Liquidator": { + "PercentWant": 111111111111111120 + }, + "Results": { + "PreMtM": 118425834278252019712, + "PreMM": -81731093685347155968, + "PreBM": -121762479278066974720, + "PreFMax": 524290585958138816, + "ExpectedBidPrice": 11047987360634836992, + "FinalPercentageReceived": 111111111111111120, + "fLiquidatedOfOriginal": 111111111111111120, + "PostMtM": 117542949759151603712, + "PostMM": -60374319541825396736, + "PostBM": -95957773402020790272, + "PostFMax": 464826909202906112, + "PercentLiquidated": 100000000000000000, + "SMPayout": 0 + } + } + ] + }, + "Test5": { + "StartTime": 0, + "IsForce": false, + "InitialPortfolio": { + "OptionExpiries": [ + 500400 + ], + "OptionStrikes": [ + 1500000000000000000000 + ], + "OptionIsCall": [ + 1 + ], + "OptionAmounts": [ + -1000000000000000000 + ], + "OptionVols": [ + 1047884494084986240 + ], + "SVIparams": [ + 1, + 1.5, + -0.1, + -0.05, + 0.05 + ], + "OptionVolConfidences": [ + 1000000000000000000 + ], + "Cash": 200000000000000000000, + "Perps": 0, + "Base": 0, + "SpotPrice": 1500000000000000000000, + "SpotConfidence": 1000000000000000000, + "PerpPrice": 1505000000000000000000, + "PerpConfidence": 1000000000000000000, + "FeedExpiries": [ + 1670400000 + ], + "Forwards": [ + 1500833279310993817600 + ], + "ForwardConfidences": [ + 1000000000000000000 + ], + "Rates": [ + 0 + ], + "RateConfidences": [ + 1000000000000000000 + ], + "StablePrice": 1000000000000000000, + "UnrealisedPerpPNL": 0, + "UnrealisedFunding": 0, + "VolShockUp": [ + 1.7370684514926746 + ], + "VolShockDown": [ + 0.508621032338217 + ], + "SettlementPrice": 1500833279310993817600, + "PercentFixed": 0, + "ForwardsFixed": [ + 0 + ], + "ForwardsVariable": [ + 1500833279310993817600 + ] + }, + "ActionCount": 2, + "LiquidationFee": 1.322084630165343, + "Actions": [ + { + "Time": 30, + "PortfolioAndFeeds": { + "OptionExpiries": [ + 500370 + ], + "OptionStrikes": [ + 1500000000000000000000 + ], + "OptionIsCall": [ + 1 + ], + "OptionAmounts": [ + -1000000000000000000 + ], + "OptionVols": [ + 1047884508458193792 + ], + "SVIparams": [ + 1, + 1.5, + -0.1, + -0.05, + 0.05 + ], + "OptionVolConfidences": [ + 1000000000000000000 + ], + "Cash": 198677915369834676224, + "Perps": 0, + "Base": 0, + "SpotPrice": 1500000000000000000000, + "SpotConfidence": 1000000000000000000, + "PerpPrice": 1505000000000000000000, + "PerpConfidence": 1000000000000000000, + "FeedExpiries": [ + 1670400000 + ], + "Forwards": [ + 1500833229340328329216 + ], + "ForwardConfidences": [ + 1000000000000000000 + ], + "Rates": [ + 0 + ], + "RateConfidences": [ + 1000000000000000000 + ], + "StablePrice": 1000000000000000000, + "UnrealisedPerpPNL": 0, + "UnrealisedFunding": 0, + "VolShockUp": [ + 1.737081708636119 + ], + "VolShockDown": [ + 0.5086121942425874 + ], + "SettlementPrice": 1500833229340328329216, + "PercentFixed": 0, + "ForwardsFixed": [ + 0 + ], + "ForwardsVariable": [ + 1500833229340328329216 + ] + }, + "Liquidator": { + "PercentWant": 100000000000000000 + }, + "Results": { + "PreMtM": 119308718797352435712, + "PreMM": -103087867828868841472, + "PreBM": -147567185154113110016, + "PreFMax": 571861527362324864, + "ExpectedBidPrice": 11047987360634836992, + "FinalPercentageReceived": 100000000000000000, + "fLiquidatedOfOriginal": 100000000000000000, + "PostMtM": 118425834278252019712, + "PostMM": -81731093685347155968, + "PostBM": -121762479278066974720, + "PostFMax": 524290585958138816, + "PercentLiquidated": 100000000000000000, + "SMPayout": 0 + } + }, + { + "Time": 600, + "PortfolioAndFeeds": { + "OptionExpiries": [ + 499800 + ], + "OptionStrikes": [ + 1500000000000000000000 + ], + "OptionIsCall": [ + 1 + ], + "OptionAmounts": [ + -900000000000000000 + ], + "OptionVols": [ + 1047884781550182784 + ], + "SVIparams": [ + 1, + 1.5, + -0.1, + -0.05, + 0.05 + ], + "OptionVolConfidences": [ + 1000000000000000000 + ], + "Cash": 189858111193486032896, + "Perps": 0, + "Base": 0, + "SpotPrice": 1500000000000000000000, + "SpotConfidence": 1000000000000000000, + "PerpPrice": 1505000000000000000000, + "PerpConfidence": 1000000000000000000, + "FeedExpiries": [ + 1670400000 + ], + "Forwards": [ + 1500832279897993904128 + ], + "ForwardConfidences": [ + 1000000000000000000 + ], + "Rates": [ + 0 + ], + "RateConfidences": [ + 1000000000000000000 + ], + "StablePrice": 1000000000000000000, + "UnrealisedPerpPNL": 0, + "UnrealisedFunding": 0, + "VolShockUp": [ + 1.7373337908573938 + ], + "VolShockDown": [ + 0.508444139428404 + ], + "SettlementPrice": 1500832279897993904128, + "PercentFixed": 0, + "ForwardsFixed": [ + 0 + ], + "ForwardsVariable": [ + 1500832279897993904128 + ] + }, + "Liquidator": { + "PercentWant": 555555555555555584 + }, + "Results": { + "PreMtM": 118466691793233494016, + "PreMM": -81684028137284435968, + "PreBM": -121714172123388018688, + "PreFMax": 564240540466009600, + "ExpectedBidPrice": 46083950358429671424, + "FinalPercentageReceived": 555555555555555584, + "fLiquidatedOfOriginal": 555555555555555584, + "PostMtM": 104873584133552816128, + "PostMM": 15917708608878172160, + "PostBM": -1873466496056750080, + "PostFMax": 19541216048521428, + "PercentLiquidated": 500000000000000000, + "SMPayout": 0 + } + } + ] + }, + "Test6": { + "StartTime": 0, + "IsForce": false, + "InitialPortfolio": { + "OptionExpiries": [ + 500400 + ], + "OptionStrikes": [ + 1500000000000000000000 + ], + "OptionIsCall": [ + 1 + ], + "OptionAmounts": [ + -1000000000000000000 + ], + "OptionVols": [ + 1047884494084986240 + ], + "SVIparams": [ + 1, + 1.5, + -0.1, + -0.05, + 0.05 + ], + "OptionVolConfidences": [ + 1000000000000000000 + ], + "Cash": 200000000000000000000, + "Perps": 0, + "Base": 0, + "SpotPrice": 1500000000000000000000, + "SpotConfidence": 1000000000000000000, + "PerpPrice": 1505000000000000000000, + "PerpConfidence": 1000000000000000000, + "FeedExpiries": [ + 1670400000 + ], + "Forwards": [ + 1500833279310993817600 + ], + "ForwardConfidences": [ + 1000000000000000000 + ], + "Rates": [ + 0 + ], + "RateConfidences": [ + 1000000000000000000 + ], + "StablePrice": 1000000000000000000, + "UnrealisedPerpPNL": 0, + "UnrealisedFunding": 0, + "VolShockUp": [ + 1.7370684514926746 + ], + "VolShockDown": [ + 0.508621032338217 + ], + "SettlementPrice": 1500833279310993817600, + "PercentFixed": 0, + "ForwardsFixed": [ + 0 + ], + "ForwardsVariable": [ + 1500833279310993817600 + ] + }, + "ActionCount": 3, + "LiquidationFee": 1.322084630165343, + "Actions": [ + { + "Time": 30, + "PortfolioAndFeeds": { + "OptionExpiries": [ + 500370 + ], + "OptionStrikes": [ + 1500000000000000000000 + ], + "OptionIsCall": [ + 1 + ], + "OptionAmounts": [ + -1000000000000000000 + ], + "OptionVols": [ + 1047884508458193792 + ], + "SVIparams": [ + 1, + 1.5, + -0.1, + -0.05, + 0.05 + ], + "OptionVolConfidences": [ + 1000000000000000000 + ], + "Cash": 198677915369834676224, + "Perps": 0, + "Base": 0, + "SpotPrice": 1500000000000000000000, + "SpotConfidence": 1000000000000000000, + "PerpPrice": 1505000000000000000000, + "PerpConfidence": 1000000000000000000, + "FeedExpiries": [ + 1670400000 + ], + "Forwards": [ + 1500833229340328329216 + ], + "ForwardConfidences": [ + 1000000000000000000 + ], + "Rates": [ + 0 + ], + "RateConfidences": [ + 1000000000000000000 + ], + "StablePrice": 1000000000000000000, + "UnrealisedPerpPNL": 0, + "UnrealisedFunding": 0, + "VolShockUp": [ + 1.737081708636119 + ], + "VolShockDown": [ + 0.5086121942425874 + ], + "SettlementPrice": 1500833229340328329216, + "PercentFixed": 0, + "ForwardsFixed": [ + 0 + ], + "ForwardsVariable": [ + 1500833229340328329216 + ] + }, + "Liquidator": { + "PercentWant": 100000000000000000 + }, + "Results": { + "PreMtM": 119308718797352435712, + "PreMM": -103087867828868841472, + "PreBM": -147567185154113110016, + "PreFMax": 571861527362324864, + "ExpectedBidPrice": 11047987360634836992, + "FinalPercentageReceived": 100000000000000000, + "fLiquidatedOfOriginal": 100000000000000000, + "PostMtM": 118425834278252019712, + "PostMM": -81731093685347155968, + "PostBM": -121762479278066974720, + "PostFMax": 524290585958138816, + "PercentLiquidated": 100000000000000000, + "SMPayout": 0 + } + }, + { + "Time": 30, + "PortfolioAndFeeds": { + "OptionExpiries": [ + 500370 + ], + "OptionStrikes": [ + 1500000000000000000000 + ], + "OptionIsCall": [ + 1 + ], + "OptionAmounts": [ + -900000000000000000 + ], + "OptionVols": [ + 1047884508458193792 + ], + "SVIparams": [ + 1, + 1.5, + -0.1, + -0.05, + 0.05 + ], + "OptionVolConfidences": [ + 1000000000000000000 + ], + "Cash": 189858111193486032896, + "Perps": 0, + "Base": 0, + "SpotPrice": 1500000000000000000000, + "SpotConfidence": 1000000000000000000, + "PerpPrice": 1505000000000000000000, + "PerpConfidence": 1000000000000000000, + "FeedExpiries": [ + 1670400000 + ], + "Forwards": [ + 1500833229340328329216 + ], + "ForwardConfidences": [ + 1000000000000000000 + ], + "Rates": [ + 0 + ], + "RateConfidences": [ + 1000000000000000000 + ], + "StablePrice": 1000000000000000000, + "UnrealisedPerpPNL": 0, + "UnrealisedFunding": 0, + "VolShockUp": [ + 1.737081708636119 + ], + "VolShockDown": [ + 0.5086121942425874 + ], + "SettlementPrice": 1500833229340328329216, + "PercentFixed": 0, + "ForwardsFixed": [ + 0 + ], + "ForwardsVariable": [ + 1500833229340328329216 + ] + }, + "Liquidator": { + "PercentWant": 148888888888888896 + }, + "Results": { + "PreMtM": 118425834278252019712, + "PreMM": -81731093685347155968, + "PreBM": -121762479278066974720, + "PreFMax": 524290585958138816, + "ExpectedBidPrice": 14804303063250681856, + "FinalPercentageReceived": 148888888888888896, + "fLiquidatedOfOriginal": 148888888888888896, + "PostMtM": 117242769022657511424, + "PostMM": -53113016333027983360, + "PostBM": -87184173404165079040, + "PostFMax": 441072490029144640, + "PercentLiquidated": 134000000000000000, + "SMPayout": 0 + } + }, + { + "Time": 30, + "PortfolioAndFeeds": { + "OptionExpiries": [ + 500370 + ], + "OptionStrikes": [ + 1500000000000000000000 + ], + "OptionIsCall": [ + 1 + ], + "OptionAmounts": [ + -766000000000000000 + ], + "OptionVols": [ + 1047884508458193792 + ], + "SVIparams": [ + 1, + 1.5, + -0.1, + -0.05, + 0.05 + ], + "OptionVolConfidences": [ + 1000000000000000000 + ], + "Cash": 178039573597178888192, + "Perps": 0, + "Base": 0, + "SpotPrice": 1500000000000000000000, + "SpotConfidence": 1000000000000000000, + "PerpPrice": 1505000000000000000000, + "PerpConfidence": 1000000000000000000, + "FeedExpiries": [ + 1670400000 + ], + "Forwards": [ + 1500833229340328329216 + ], + "ForwardConfidences": [ + 1000000000000000000 + ], + "Rates": [ + 0 + ], + "RateConfidences": [ + 1000000000000000000 + ], + "StablePrice": 1000000000000000000, + "UnrealisedPerpPNL": 0, + "UnrealisedFunding": 0, + "VolShockUp": [ + 1.737081708636119 + ], + "VolShockDown": [ + 0.5086121942425874 + ], + "SettlementPrice": 1500833229340328329216, + "PercentFixed": 0, + "ForwardsFixed": [ + 0 + ], + "ForwardsVariable": [ + 1500833229340328329216 + ] + }, + "Liquidator": { + "PercentWant": 1000000000000000000 + }, + "Results": { + "PreMtM": 117242769022657511424, + "PreMM": -53113016333027983360, + "PreBM": -87184173404165079040, + "PreFMax": 441072490029144640, + "ExpectedBidPrice": 37326898839437451264, + "FinalPercentageReceived": 441072490029144640, + "fLiquidatedOfOriginal": 441072490029144640, + "PostMtM": 114259841901579370496, + "PostMM": 19043306983596552192, + "PostBM": -14210, + "PostFMax": 128, + "PercentLiquidated": 337861527362324800, + "SMPayout": 0 + } + } + ] + }, + "test_Nov_01_long_box_neg_cash": { + "StartTime": 0, + "IsForce": false, + "InitialPortfolio": { + "OptionExpiries": [ + 7758000, + 7758000, + 7758000, + 7758000 + ], + "OptionStrikes": [ + 1500000000000000000000, + 2500000000000000000000, + 1500000000000000000000, + 2500000000000000000000 + ], + "OptionIsCall": [ + 1, + 1, + 0, + 0 + ], + "OptionAmounts": [ + 1000000000000000000, + -1000000000000000000, + -1000000000000000000, + 1000000000000000000 + ], + "OptionVols": [ + 1044583332004474880, + 1322452025352536064, + 1044583332004474880, + 1322452025352536064 + ], + "SVIparams": [ + 1, + 1.5, + -0.1, + -0.05, + 0.05 + ], + "OptionVolConfidences": [ + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000 + ], + "Cash": -950000000000000000000, + "Perps": 0, + "Base": 0, + "SpotPrice": 1500000000000000000000, + "SpotConfidence": 1000000000000000000, + "PerpPrice": 1505000000000000000000, + "PerpConfidence": 1000000000000000000, + "FeedExpiries": [ + 1677657600, + 1677657600, + 1677657600, + 1677657600 + ], + "Forwards": [ + 1512971000787409567744, + 1512971000787409567744, + 1512971000787409567744, + 1512971000787409567744 + ], + "ForwardConfidences": [ + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000 + ], + "Rates": [ + 0, + 0, + 0, + 0 + ], + "RateConfidences": [ + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000 + ], + "StablePrice": 1000000000000000000, + "UnrealisedPerpPNL": 0, + "UnrealisedFunding": 0, + "VolShockUp": [ + 1.3902272493224166, + 1.3902272493224166, + 1.3902272493224166, + 1.3902272493224166 + ], + "VolShockDown": [ + 0.7398485004517223, + 0.7398485004517223, + 0.7398485004517223, + 0.7398485004517223 + ], + "SettlementPrice": 1512971000787409567744, + "PercentFixed": 0, + "ForwardsFixed": [ + 0, + 0, + 0, + 0 + ], + "ForwardsVariable": [ + 1512971000787409567744, + 1512971000787409567744, + 1512971000787409567744, + 1512971000787409567744 + ] + }, + "ActionCount": 1, + "LiquidationFee": 0.3237428736252539, + "Actions": [ + { + "Time": 30, + "PortfolioAndFeeds": { + "OptionExpiries": [ + 7757970, + 7757970, + 7757970, + 7757970 + ], + "OptionStrikes": [ + 1500000000000000000000, + 2500000000000000000000, + 1500000000000000000000, + 2500000000000000000000 + ], + "OptionIsCall": [ + 1, + 1, + 0, + 0 + ], + "OptionAmounts": [ + 1000000000000000000, + -1000000000000000000, + -1000000000000000000, + 1000000000000000000 + ], + "OptionVols": [ + 1044583344857694720, + 1322452042270033152, + 1044583344857694720, + 1322452042270033152 + ], + "SVIparams": [ + 1, + 1.5, + -0.1, + -0.05, + 0.05 + ], + "OptionVolConfidences": [ + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000 + ], + "Cash": -950323742873625296896, + "Perps": 0, + "Base": 0, + "SpotPrice": 1500000000000000000000, + "SpotConfidence": 1000000000000000000, + "PerpPrice": 1505000000000000000000, + "PerpConfidence": 1000000000000000000, + "FeedExpiries": [ + 1677657600, + 1677657600, + 1677657600, + 1677657600 + ], + "Forwards": [ + 1512970950412615024640, + 1512970950412615024640, + 1512970950412615024640, + 1512970950412615024640 + ], + "ForwardConfidences": [ + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000 + ], + "Rates": [ + 0, + 0, + 0, + 0 + ], + "RateConfidences": [ + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000 + ], + "StablePrice": 1000000000000000000, + "UnrealisedPerpPNL": 0, + "UnrealisedFunding": 0, + "VolShockUp": [ + 1.3902274454927692, + 1.3902274454927692, + 1.3902274454927692, + 1.3902274454927692 + ], + "VolShockDown": [ + 0.7398483696714871, + 0.7398483696714871, + 0.7398483696714871, + 0.7398483696714871 + ], + "SettlementPrice": 1512970950412615024640, + "PercentFixed": 0, + "ForwardsFixed": [ + 0, + 0, + 0, + 0 + ], + "ForwardsVariable": [ + 1512970950412615024640, + 1512970950412615024640, + 1512970950412615024640, + 1512970950412615024640 + ] + }, + "Liquidator": { + "PercentWant": 1000000000000000000 + }, + "Results": { + "PreMtM": 49676257126374711296, + "PreMM": -11937343466544234496, + "PreBM": -24260063585128022016, + "PreFMax": 345288467178951872, + "ExpectedBidPrice": 15883343416155256832, + "FinalPercentageReceived": 345288467178951872, + "fLiquidatedOfOriginal": 345288467178951872, + "PostMtM": 48406961864176648192, + "PostMM": 8067826977362642944, + "PostBM": -156319, + "PostFMax": 3398, + "PercentLiquidated": 345288467178951872, + "SMPayout": 0 + } + } + ] + }, + "test_Nov_02_3_liqs_same_price_same_amount": { + "StartTime": 0, + "IsForce": false, + "InitialPortfolio": { + "OptionExpiries": [ + 500400 + ], + "OptionStrikes": [ + 1500000000000000000000 + ], + "OptionIsCall": [ + 1 + ], + "OptionAmounts": [ + -1000000000000000000 + ], + "OptionVols": [ + 1047884494084986240 + ], + "SVIparams": [ + 1, + 1.5, + -0.1, + -0.05, + 0.05 + ], + "OptionVolConfidences": [ + 1000000000000000000 + ], + "Cash": 200000000000000000000, + "Perps": 0, + "Base": 0, + "SpotPrice": 1500000000000000000000, + "SpotConfidence": 1000000000000000000, + "PerpPrice": 1505000000000000000000, + "PerpConfidence": 1000000000000000000, + "FeedExpiries": [ + 1670400000 + ], + "Forwards": [ + 1500833279310993817600 + ], + "ForwardConfidences": [ + 1000000000000000000 + ], + "Rates": [ + 0 + ], + "RateConfidences": [ + 1000000000000000000 + ], + "StablePrice": 1000000000000000000, + "UnrealisedPerpPNL": 0, + "UnrealisedFunding": 0, + "VolShockUp": [ + 1.7370684514926746 + ], + "VolShockDown": [ + 0.508621032338217 + ], + "SettlementPrice": 1500833279310993817600, + "PercentFixed": 0, + "ForwardsFixed": [ + 0 + ], + "ForwardsVariable": [ + 1500833279310993817600 + ] + }, + "ActionCount": 3, + "LiquidationFee": 1.322084630165343, + "Actions": [ + { + "Time": 30, + "PortfolioAndFeeds": { + "OptionExpiries": [ + 500370 + ], + "OptionStrikes": [ + 1500000000000000000000 + ], + "OptionIsCall": [ + 1 + ], + "OptionAmounts": [ + -1000000000000000000 + ], + "OptionVols": [ + 1047884508458193792 + ], + "SVIparams": [ + 1, + 1.5, + -0.1, + -0.05, + 0.05 + ], + "OptionVolConfidences": [ + 1000000000000000000 + ], + "Cash": 198677915369834676224, + "Perps": 0, + "Base": 0, + "SpotPrice": 1500000000000000000000, + "SpotConfidence": 1000000000000000000, + "PerpPrice": 1505000000000000000000, + "PerpConfidence": 1000000000000000000, + "FeedExpiries": [ + 1670400000 + ], + "Forwards": [ + 1500833229340328329216 + ], + "ForwardConfidences": [ + 1000000000000000000 + ], + "Rates": [ + 0 + ], + "RateConfidences": [ + 1000000000000000000 + ], + "StablePrice": 1000000000000000000, + "UnrealisedPerpPNL": 0, + "UnrealisedFunding": 0, + "VolShockUp": [ + 1.737081708636119 + ], + "VolShockDown": [ + 0.5086121942425874 + ], + "SettlementPrice": 1500833229340328329216, + "PercentFixed": 0, + "ForwardsFixed": [ + 0 + ], + "ForwardsVariable": [ + 1500833229340328329216 + ] + }, + "Liquidator": { + "PercentWant": 190620509120774976 + }, + "Results": { + "PreMtM": 119308718797352435712, + "PreMM": -103087867828868841472, + "PreBM": -147567185154113110016, + "PreFMax": 571861527362324864, + "ExpectedBidPrice": 21059729754440994816, + "FinalPercentageReceived": 190620509120774976, + "fLiquidatedOfOriginal": 190620509120774976, + "PostMtM": 117625759832094736384, + "PostMM": -62377476224713719808, + "PostBM": -98378123436075417600, + "PostFMax": 471028760349993216, + "PercentLiquidated": 190620509120774976, + "SMPayout": 0 + } + }, + { + "Time": 30, + "PortfolioAndFeeds": { + "OptionExpiries": [ + 500370 + ], + "OptionStrikes": [ + 1500000000000000000000 + ], + "OptionIsCall": [ + 1 + ], + "OptionAmounts": [ + -809379490879224960 + ], + "OptionVols": [ + 1047884508458193792 + ], + "SVIparams": [ + 1, + 1.5, + -0.1, + -0.05, + 0.05 + ], + "OptionVolConfidences": [ + 1000000000000000000 + ], + "Cash": 181865559745423540224, + "Perps": 0, + "Base": 0, + "SpotPrice": 1500000000000000000000, + "SpotConfidence": 1000000000000000000, + "PerpPrice": 1505000000000000000000, + "PerpConfidence": 1000000000000000000, + "FeedExpiries": [ + 1670400000 + ], + "Forwards": [ + 1500833229340328329216 + ], + "ForwardConfidences": [ + 1000000000000000000 + ], + "Rates": [ + 0 + ], + "RateConfidences": [ + 1000000000000000000 + ], + "StablePrice": 1000000000000000000, + "UnrealisedPerpPNL": 0, + "UnrealisedFunding": 0, + "VolShockUp": [ + 1.737081708636119 + ], + "VolShockDown": [ + 0.5086121942425874 + ], + "SettlementPrice": 1500833229340328329216, + "PercentFixed": 0, + "ForwardsFixed": [ + 0 + ], + "ForwardsVariable": [ + 1500833229340328329216 + ] + }, + "Liquidator": { + "PercentWant": 235514380174996576 + }, + "Results": { + "PreMtM": 117625759832094736384, + "PreMM": -62377476224713719808, + "PreBM": -98378123436075417600, + "PreFMax": 471028760349993216, + "ExpectedBidPrice": 21059729754440994816, + "FinalPercentageReceived": 235514380174996576, + "fLiquidatedOfOriginal": 235514380174996576, + "PostMtM": 115942800866837053440, + "PostMM": -21667084620558540800, + "PostBM": -49189061718037659648, + "PostFMax": 308069078171682880, + "PercentLiquidated": 190620509120774976, + "SMPayout": 0 + } + }, + { + "Time": 30, + "PortfolioAndFeeds": { + "OptionExpiries": [ + 500370 + ], + "OptionStrikes": [ + 1500000000000000000000 + ], + "OptionIsCall": [ + 1 + ], + "OptionAmounts": [ + -618758981758450048 + ], + "OptionVols": [ + 1047884508458193792 + ], + "SVIparams": [ + 1, + 1.5, + -0.1, + -0.05, + 0.05 + ], + "OptionVolConfidences": [ + 1000000000000000000 + ], + "Cash": 165053204121012404224, + "Perps": 0, + "Base": 0, + "SpotPrice": 1500000000000000000000, + "SpotConfidence": 1000000000000000000, + "PerpPrice": 1505000000000000000000, + "PerpConfidence": 1000000000000000000, + "FeedExpiries": [ + 1670400000 + ], + "Forwards": [ + 1500833229340328329216 + ], + "ForwardConfidences": [ + 1000000000000000000 + ], + "Rates": [ + 0 + ], + "RateConfidences": [ + 1000000000000000000 + ], + "StablePrice": 1000000000000000000, + "UnrealisedPerpPNL": 0, + "UnrealisedFunding": 0, + "VolShockUp": [ + 1.737081708636119 + ], + "VolShockDown": [ + 0.5086121942425874 + ], + "SettlementPrice": 1500833229340328329216, + "PercentFixed": 0, + "ForwardsFixed": [ + 0 + ], + "ForwardsVariable": [ + 1500833229340328329216 + ] + }, + "Liquidator": { + "PercentWant": 308069078171683136 + }, + "Results": { + "PreMtM": 115942800866837053440, + "PreMM": -21667084620558540800, + "PreBM": -49189061718037659648, + "PreFMax": 308069078171682880, + "ExpectedBidPrice": 21059729754440986624, + "FinalPercentageReceived": 308069078171682880, + "fLiquidatedOfOriginal": 308069078171682880, + "PostMtM": 114259841901579370496, + "PostMM": 19043306983596552192, + "PostBM": -14210, + "PostFMax": 128, + "PercentLiquidated": 190620509120774816, + "SMPayout": 0 + } + } + ] + }, + "test_Nov_03_perp": { + "StartTime": 0, + "IsForce": false, + "InitialPortfolio": { + "OptionExpiries": [], + "OptionStrikes": [], + "OptionIsCall": [], + "OptionAmounts": [], + "OptionVols": [], + "SVIparams": [ + 1, + 1.5, + -0.1, + -0.05, + 0.05 + ], + "OptionVolConfidences": [], + "Cash": 40000000000000000000, + "Perps": 1000000000000000000, + "Base": 0, + "SpotPrice": 1500000000000000000000, + "SpotConfidence": 1000000000000000000, + "PerpPrice": 1505000000000000000000, + "PerpConfidence": 1000000000000000000, + "FeedExpiries": [], + "Forwards": [], + "ForwardConfidences": [], + "Rates": [], + "RateConfidences": [], + "StablePrice": 1000000000000000000, + "UnrealisedPerpPNL": 0, + "UnrealisedFunding": 0, + "VolShockUp": [], + "VolShockDown": [], + "SettlementPrice": null, + "PercentFixed": null, + "ForwardsFixed": [], + "ForwardsVariable": [] + }, + "ActionCount": 1, + "LiquidationFee": 0.6957315086347344, + "Actions": [ + { + "Time": 0, + "PortfolioAndFeeds": { + "OptionExpiries": [], + "OptionStrikes": [], + "OptionIsCall": [], + "OptionAmounts": [], + "OptionVols": [], + "SVIparams": [ + 1, + 1.5, + -0.1, + -0.05, + 0.05 + ], + "OptionVolConfidences": [], + "Cash": 39304268491365261312, + "Perps": 1000000000000000000, + "Base": 0, + "SpotPrice": 1500000000000000000000, + "SpotConfidence": 1000000000000000000, + "PerpPrice": 1505000000000000000000, + "PerpConfidence": 1000000000000000000, + "FeedExpiries": [], + "Forwards": [], + "ForwardConfidences": [], + "Rates": [], + "RateConfidences": [], + "StablePrice": 1000000000000000000, + "UnrealisedPerpPNL": 0, + "UnrealisedFunding": 0, + "VolShockUp": [], + "VolShockDown": [], + "SettlementPrice": null, + "PercentFixed": null, + "ForwardsFixed": [], + "ForwardsVariable": [] + }, + "Liquidator": { + "PercentWant": 1000000000000000000 + }, + "Results": { + "PreMtM": 39304268491365261312, + "PreMM": -216445731508634746880, + "PreBM": -267595731508634681344, + "PreFMax": 874170427149405568, + "ExpectedBidPrice": 33671456592373858304, + "FinalPercentageReceived": 874170427149405568, + "fLiquidatedOfOriginal": 874170427149405568, + "PostMtM": 38617095907847430144, + "PostMM": 6436182651307888640, + "PostBM": -21316, + "PostFMax": 553, + "PercentLiquidated": 874170427149405568, + "SMPayout": 0 + } + } + ] + }, + "test_Nov_04_general": { + "StartTime": 0, + "IsForce": false, + "InitialPortfolio": { + "OptionExpiries": [ + 1191600, + 500400, + 7758000, + 500400, + 2487600, + 1191600 + ], + "OptionStrikes": [ + 1600000000000000000000, + 1200000000000000000000, + 1900000000000000000000, + 1150000000000000000000, + 1550000000000000000000, + 1000000000000000000000 + ], + "OptionIsCall": [ + 1, + 0, + 1, + 0, + 1, + 1 + ], + "OptionAmounts": [ + -1000000000000000000, + -21000000000000000000, + -3000000000000000000, + 7000000000000000000, + -2000000000000000000, + -1600000000000000000 + ], + "OptionVols": [ + 1081048412239005184, + 1138939398828297472, + 1175456212663501056, + 1168496420216719616, + 1062799243592622592, + 1262509093212846848 + ], + "SVIparams": [ + 1, + 1.5, + -0.1, + -0.05, + 0.05 + ], + "OptionVolConfidences": [ + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000 + ], + "Cash": -5000000000000000000000, + "Perps": 0, + "Base": 5000000000000000000, + "SpotPrice": 1500000000000000000000, + "SpotConfidence": 1000000000000000000, + "PerpPrice": 1505000000000000000000, + "PerpConfidence": 1000000000000000000, + "FeedExpiries": [ + 1671091200, + 1670400000, + 1677657600, + 1670400000, + 1672387200, + 1671091200 + ], + "Forwards": [ + 1501985045187195830272, + 1500833279310993817600, + 1512971000787409567744, + 1500833279310993817600, + 1504146989085687808000, + 1501985045187195830272 + ], + "ForwardConfidences": [ + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000 + ], + "Rates": [ + 0, + 0, + 0, + 0, + 0, + 0 + ], + "RateConfidences": [ + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000 + ], + "StablePrice": 1000000000000000000, + "UnrealisedPerpPNL": 0, + "UnrealisedFunding": 0, + "VolShockUp": [ + 1.5681511166375728, + 1.7370684514926746, + 1.3902272493224166, + 1.7370684514926746, + 1.4555844040146944, + 1.5681511166375728 + ], + "VolShockDown": [ + 0.6212325889082848, + 0.508621032338217, + 0.7398485004517223, + 0.508621032338217, + 0.6962770639902038, + 0.6212325889082848 + ], + "SettlementPrice": 1500833279310993817600, + "PercentFixed": 0, + "ForwardsFixed": [ + 0, + 0, + 0, + 0, + 0, + 0 + ], + "ForwardsVariable": [ + 1501985045187195830272, + 1500833279310993817600, + 1512971000787409567744, + 1500833279310993817600, + 1504146989085687808000, + 1501985045187195830272 + ] + }, + "ActionCount": 3, + "LiquidationFee": 8.723085851319075, + "Actions": [ + { + "Time": 1, + "PortfolioAndFeeds": { + "OptionExpiries": [ + 1191599, + 500399, + 7757999, + 500399, + 2487599, + 1191599 + ], + "OptionStrikes": [ + 1600000000000000000000, + 1200000000000000000000, + 1900000000000000000000, + 1150000000000000000000, + 1550000000000000000000, + 1000000000000000000000 + ], + "OptionIsCall": [ + 1, + 0, + 1, + 0, + 1, + 1 + ], + "OptionAmounts": [ + -1000000000000000000, + -21000000000000000000, + -3000000000000000000, + 7000000000000000000, + -2000000000000000000, + -1600000000000000000 + ], + "OptionVols": [ + 1047554809890547840, + 1183586609116811264, + 1138661228182543872, + 1212411005988884480, + 1037397363758752128, + 1303695811129270528 + ], + "SVIparams": [ + 1, + 1.5, + -0.1, + -0.05, + 0.05 + ], + "OptionVolConfidences": [ + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000 + ], + "Cash": -5008723085851319336960, + "Perps": 0, + "Base": 5000000000000000000, + "SpotPrice": 1600000000000000000000, + "SpotConfidence": 1000000000000000000, + "PerpPrice": 1605000000000000000000, + "PerpConfidence": 1000000000000000000, + "FeedExpiries": [ + 1671091200, + 1670400000, + 1677657600, + 1670400000, + 1672387200, + 1671091200 + ], + "Forwards": [ + 1602117379754910547968, + 1600888829488325722112, + 1613835732382132994048, + 1600888829488325722112, + 1604423453244076326912, + 1602117379754910547968 + ], + "ForwardConfidences": [ + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000 + ], + "Rates": [ + 0, + 0, + 0, + 0, + 0, + 0 + ], + "RateConfidences": [ + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000 + ], + "StablePrice": 1000000000000000000, + "UnrealisedPerpPNL": 0, + "UnrealisedFunding": 0, + "VolShockUp": [ + 1.5681512596767035, + 1.7370688933808094, + 1.3902272558614146, + 1.7370688933808094, + 1.4555844589573526, + 1.5681512596767035 + ], + "VolShockDown": [ + 0.6212324935488645, + 0.5086207377461271, + 0.7398484960923903, + 0.5086207377461271, + 0.6962770273617649, + 0.6212324935488645 + ], + "SettlementPrice": 1600888829488325722112, + "PercentFixed": 0, + "ForwardsFixed": [ + 0, + 0, + 0, + 0, + 0, + 0 + ], + "ForwardsVariable": [ + 1602117379754910547968, + 1600888829488325722112, + 1613835732382132994048, + 1600888829488325722112, + 1604423453244076326912, + 1602117379754910547968 + ] + }, + "Liquidator": { + "PercentWant": 212000000000000000 + }, + "Results": { + "PreMtM": 642400350514621054976, + "PreMM": -1771031720645170823168, + "PreBM": -2253718134877129277440, + "PreFMax": 781966990730214272, + "ExpectedBidPrice": 133219956849161289728, + "FinalPercentageReceived": 212000000000000000, + "fLiquidatedOfOriginal": 212000000000000000, + "PostMtM": 639431433054684053504, + "PostMM": -1262353039019232722944, + "PostBM": -1642709933434015842304, + "PostFMax": 723308363870829824, + "PercentLiquidated": 212000000000000000, + "SMPayout": 0 + } + }, + { + "Time": 300, + "PortfolioAndFeeds": { + "OptionExpiries": [ + 1191300, + 500100, + 7757700, + 500100, + 2487300, + 1191300 + ], + "OptionStrikes": [ + 1600000000000000000000, + 1200000000000000000000, + 1900000000000000000000, + 1150000000000000000000, + 1550000000000000000000, + 1000000000000000000000 + ], + "OptionIsCall": [ + 1, + 0, + 1, + 0, + 1, + 1 + ], + "OptionAmounts": [ + -788000000000000000, + -16548000000000002048, + -2364000000000000000, + 5516000000000000000, + -1576000000000000000, + -1260800000000000256 + ], + "OptionVols": [ + 1124897328781591040, + 1085836000502368896, + 1217822136291152896, + 1115411294310137344, + 1105698526538111872, + 1212296181135196928 + ], + "SVIparams": [ + 1, + 1.5, + -0.1, + -0.05, + 0.05 + ], + "OptionVolConfidences": [ + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000 + ], + "Cash": -3813653834801678385152, + "Perps": 0, + "Base": 3940000000000000512, + "SpotPrice": 1390000000000000000000, + "SpotConfidence": 1000000000000000000, + "PerpPrice": 1395000000000000000000, + "PerpConfidence": 1000000000000000000, + "FeedExpiries": [ + 1671091200, + 1670400000, + 1677657600, + 1670400000, + 1672387200, + 1671091200 + ], + "Forwards": [ + 1391839011790006255616, + 1390771709100087312384, + 1402019327256639045632, + 1390771709100087312384, + 1393842412468904394752, + 1391839011790006255616 + ], + "ForwardConfidences": [ + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000 + ], + "Rates": [ + 0, + 0, + 0, + 0, + 0, + 0 + ], + "RateConfidences": [ + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000 + ], + "StablePrice": 1000000000000000000, + "UnrealisedPerpPNL": 0, + "UnrealisedFunding": 0, + "VolShockUp": [ + 1.5681940353769965, + 1.7372010694442017, + 1.3902292110645202, + 1.7372010694442017, + 1.455600888100079, + 1.5681940353769965 + ], + "VolShockDown": [ + 0.6212039764153356, + 0.5085326203705323, + 0.7398471926236532, + 0.5085326203705323, + 0.6962660745999473, + 0.6212039764153356 + ], + "SettlementPrice": 1390771709100087312384, + "PercentFixed": 0, + "ForwardsFixed": [ + 0, + 0, + 0, + 0, + 0, + 0 + ], + "ForwardsVariable": [ + 1391839011790006255616, + 1390771709100087312384, + 1402019327256639045632, + 1390771709100087312384, + 1393842412468904394752, + 1391839011790006255616 + ] + }, + "Liquidator": { + "PercentWant": 177664974619289344 + }, + "Results": { + "PreMtM": 318804576311993499648, + "PreMM": -2110882991457339703296, + "PreBM": -2596820505011206225920, + "PreFMax": 902787818447649664, + "ExpectedBidPrice": 26011155068535709696, + "FinalPercentageReceived": 177664974619289344, + "fLiquidatedOfOriginal": 177664974619289344, + "PostMtM": 311843844673934655488, + "PostMM": -1686173343034857750528, + "PostBM": -2085776780576616087552, + "PostFMax": 881785186630783744, + "PercentLiquidated": 140000000000000016, + "SMPayout": 0 + } + }, + { + "Time": 8000, + "PortfolioAndFeeds": { + "OptionExpiries": [ + 1183600, + 492400, + 7750000, + 492400, + 2479600, + 1183600 + ], + "OptionStrikes": [ + 1600000000000000000000, + 1200000000000000000000, + 1900000000000000000000, + 1150000000000000000000, + 1550000000000000000000, + 1000000000000000000000 + ], + "OptionIsCall": [ + 1, + 0, + 1, + 0, + 1, + 1 + ], + "OptionAmounts": [ + -648000000000000000, + -13608000000000002048, + -1944000000000000000, + 4536000000000000512, + -1296000000000000000, + -1036800000000000128 + ], + "OptionVols": [ + 1056408066959279488, + 1170592799128591872, + 1149531706780766208, + 1199652232702845440, + 1042062949539862784, + 1291736833438787840 + ], + "SVIparams": [ + 1, + 1.5, + -0.1, + -0.05, + 0.05 + ], + "OptionVolConfidences": [ + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000 + ], + "Cash": -3086421447713958133760, + "Perps": 0, + "Base": 3240000000000000000, + "SpotPrice": 1570000000000000000000, + "SpotConfidence": 1000000000000000000, + "PerpPrice": 1575000000000000000000, + "PerpConfidence": 1000000000000000000, + "FeedExpiries": [ + 1671091200, + 1670400000, + 1677657600, + 1670400000, + 1672387200, + 1671091200 + ], + "Forwards": [ + 1572063722619483979776, + 1570858218372467785728, + 1583562254054763266048, + 1570858218372467785728, + 1574326537142204366848, + 1572063722619483979776 + ], + "ForwardConfidences": [ + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000 + ], + "Rates": [ + 0, + 0, + 0, + 0, + 0, + 0 + ], + "RateConfidences": [ + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000, + 1000000000000000000 + ], + "StablePrice": 1000000000000000000, + "UnrealisedPerpPNL": 0, + "UnrealisedFunding": 0, + "VolShockUp": [ + 1.5693004485466155, + 1.7406407439213831, + 1.390279591802785, + 1.7406407439213831, + 1.4560248662409134, + 1.5693004485466155 + ], + "VolShockDown": [ + 0.6204663676355897, + 0.5062395040524114, + 0.7398136054648099, + 0.5062395040524114, + 0.6959834225060578, + 0.6204663676355897 + ], + "SettlementPrice": 1570858218372467785728, + "PercentFixed": 0, + "ForwardsFixed": [ + 0, + 0, + 0, + 0, + 0, + 0 + ], + "ForwardsVariable": [ + 1572063722619483979776, + 1570858218372467785728, + 1583562254054763266048, + 1570858218372467785728, + 1574326537142204366848, + 1572063722619483979776 + ] + }, + "Liquidator": { + "PercentWant": 1000000000000000000 + }, + "Results": { + "PreMtM": 558350023025698209792, + "PreMM": -1055309310999661641728, + "PreBM": -1378041177804733415424, + "PreFMax": 819580323180499968, + "ExpectedBidPrice": 118123057777596776448, + "FinalPercentageReceived": 819580323180499968, + "fLiquidatedOfOriginal": 819580323180499968, + "PostMtM": 349363074649949995008, + "PostMM": 58227179108324892672, + "PostBM": -113686, + "PostFMax": 374, + "PercentLiquidated": 531088049420963968, + "SMPayout": 0 + } + } + ] + }, + "test_Nov_05_borrow": { + "StartTime": 0, + "IsForce": false, + "InitialPortfolio": { + "OptionExpiries": [], + "OptionStrikes": [], + "OptionIsCall": [], + "OptionAmounts": [], + "OptionVols": [], + "SVIparams": [ + 1, + 1.5, + -0.1, + -0.05, + 0.05 + ], + "OptionVolConfidences": [], + "Cash": -1250000000000000000000, + "Perps": 0, + "Base": 1000000000000000000, + "SpotPrice": 1500000000000000000000, + "SpotConfidence": 1000000000000000000, + "PerpPrice": 1505000000000000000000, + "PerpConfidence": 1000000000000000000, + "FeedExpiries": [], + "Forwards": [], + "ForwardConfidences": [], + "Rates": [], + "RateConfidences": [], + "StablePrice": 1000000000000000000, + "UnrealisedPerpPNL": 0, + "UnrealisedFunding": 0, + "VolShockUp": [], + "VolShockDown": [], + "SettlementPrice": null, + "PercentFixed": null, + "ForwardsFixed": [], + "ForwardsVariable": [] + }, + "ActionCount": 2, + "LiquidationFee": 0.9150326797385621, + "Actions": [ + { + "Time": 0, + "PortfolioAndFeeds": { + "OptionExpiries": [], + "OptionStrikes": [], + "OptionIsCall": [], + "OptionAmounts": [], + "OptionVols": [], + "SVIparams": [ + 1, + 1.5, + -0.1, + -0.05, + 0.05 + ], + "OptionVolConfidences": [], + "Cash": -1250915032679738507264, + "Perps": 0, + "Base": 1000000000000000000, + "SpotPrice": 1520000000000000000000, + "SpotConfidence": 1000000000000000000, + "PerpPrice": 1525000000000000000000, + "PerpConfidence": 1000000000000000000, + "FeedExpiries": [], + "Forwards": [], + "ForwardConfidences": [], + "Rates": [], + "RateConfidences": [], + "StablePrice": 1000000000000000000, + "UnrealisedPerpPNL": 0, + "UnrealisedFunding": 0, + "VolShockUp": [], + "VolShockDown": [], + "SettlementPrice": null, + "PercentFixed": null, + "ForwardsFixed": [], + "ForwardsVariable": [] + }, + "Liquidator": { + "PercentWant": 100000000000000000 + }, + "Results": { + "PreMtM": 269084967320261525504, + "PreMM": 10684967320261421056, + "PreBM": -40995032679738589184, + "PreFMax": 134543030242708784, + "ExpectedBidPrice": 26370326797385625600, + "FinalPercentageReceived": 100000000000000000, + "fLiquidatedOfOriginal": 100000000000000000, + "PostMtM": 268546797385620946944, + "PostMM": 35986797385621004288, + "PostBM": -10525202614378997760, + "PostFMax": 38381144714120520, + "PercentLiquidated": 100000000000000000, + "SMPayout": 0 + } + }, + { + "Time": 0, + "PortfolioAndFeeds": { + "OptionExpiries": [], + "OptionStrikes": [], + "OptionIsCall": [], + "OptionAmounts": [], + "OptionVols": [], + "SVIparams": [ + 1, + 1.5, + -0.1, + -0.05, + 0.05 + ], + "OptionVolConfidences": [], + "Cash": -1099453202614379085824, + "Perps": 0, + "Base": 900000000000000000, + "SpotPrice": 1490000000000000000000, + "SpotConfidence": 1000000000000000000, + "PerpPrice": 1495000000000000000000, + "PerpConfidence": 1000000000000000000, + "FeedExpiries": [], + "Forwards": [], + "ForwardConfidences": [], + "Rates": [], + "RateConfidences": [], + "StablePrice": 1000000000000000000, + "UnrealisedPerpPNL": 0, + "UnrealisedFunding": 0, + "VolShockUp": [], + "VolShockDown": [], + "SettlementPrice": null, + "PercentFixed": null, + "ForwardsFixed": [], + "ForwardsVariable": [] + }, + "Liquidator": { + "PercentWant": 111111111111111120 + }, + "Results": { + "PreMtM": 241546797385620946944, + "PreMM": 13576797385621147648, + "PreBM": -32017202614378790912, + "PreFMax": 118907920440133632, + "ExpectedBidPrice": 23430326797385629696, + "FinalPercentageReceived": 111111111111111120, + "fLiquidatedOfOriginal": 111111111111111120, + "PostMtM": 241068627450980433920, + "PostMM": 38428627450980343808, + "PostBM": -2099372549019676672, + "PostFMax": 8771410495151708, + "PercentLiquidated": 100000000000000000, + "SMPayout": 0 + } + } + ] + }, + "test_DOMSEAN": { + "StartTime": 0, + "IsForce": false, + "InitialPortfolio": { + "OptionExpiries": [ + 1191600 + ], + "OptionStrikes": [ + 1600000000000000000000 + ], + "OptionIsCall": [ + 1 + ], + "OptionAmounts": [ + -1000000000000000000 + ], + "OptionVols": [ + 1081048412239005184 + ], + "SVIparams": [ + 1, + 1.5, + -0.1, + -0.05, + 0.05 + ], + "OptionVolConfidences": [ + 1000000000000000000 + ], + "Cash": 200000000000000000000, + "Perps": 0, + "Base": 0, + "SpotPrice": 1500000000000000000000, + "SpotConfidence": 1000000000000000000, + "PerpPrice": 1505000000000000000000, + "PerpConfidence": 1000000000000000000, + "FeedExpiries": [ + 1671091200 + ], + "Forwards": [ + 1501985045187195830272 + ], + "ForwardConfidences": [ + 1000000000000000000 + ], + "Rates": [ + 0 + ], + "RateConfidences": [ + 1000000000000000000 + ], + "StablePrice": 1000000000000000000, + "UnrealisedPerpPNL": 0, + "UnrealisedFunding": 0, + "VolShockUp": [ + 1.5681511166375728 + ], + "VolShockDown": [ + 0.6212325889082848 + ], + "SettlementPrice": 1501985045187195830272, + "PercentFixed": 0, + "ForwardsFixed": [ + 0 + ], + "ForwardsVariable": [ + 1501985045187195830272 + ] + }, + "ActionCount": 1, + "LiquidationFee": 1.2738185008613723, + "Actions": [ + { + "Time": 1, + "PortfolioAndFeeds": { + "OptionExpiries": [ + 1191599 + ], + "OptionStrikes": [ + 1600000000000000000000 + ], + "OptionIsCall": [ + 1 + ], + "OptionAmounts": [ + -1000000000000000000 + ], + "OptionVols": [ + 1047554809890547840 + ], + "SVIparams": [ + 1, + 1.5, + -0.1, + -0.05, + 0.05 + ], + "OptionVolConfidences": [ + 1000000000000000000 + ], + "Cash": 198726181499138605056, + "Perps": 0, + "Base": 0, + "SpotPrice": 1600000000000000000000, + "SpotConfidence": 1000000000000000000, + "PerpPrice": 1605000000000000000000, + "PerpConfidence": 1000000000000000000, + "FeedExpiries": [ + 1671091200 + ], + "Forwards": [ + 1602117379754910547968 + ], + "ForwardConfidences": [ + 1000000000000000000 + ], + "Rates": [ + 0 + ], + "RateConfidences": [ + 1000000000000000000 + ], + "StablePrice": 1000000000000000000, + "UnrealisedPerpPNL": 0, + "UnrealisedFunding": 0, + "VolShockUp": [ + 1.5681512596767035 + ], + "VolShockDown": [ + 0.6212324935488645 + ], + "SettlementPrice": 1602117379754910547968, + "PercentFixed": 0, + "ForwardsFixed": [ + 0 + ], + "ForwardsVariable": [ + 1602117379754910547968 + ] + }, + "Liquidator": { + "PercentWant": 1000000000000000000 + }, + "Results": { + "PreMtM": 67825504170939867136, + "PreMM": -177580319470280769536, + "PreBM": -226661484198524911616, + "PreFMax": 773566526059432448, + "ExpectedBidPrice": 51323747275597086720, + "FinalPercentageReceived": 773566526059432448, + "fLiquidatedOfOriginal": 773566526059432448, + "PostMtM": 66681711806793457664, + "PostMM": 11113618634465595392, + "PostBM": 28421, + "PostFMax": 0, + "PercentLiquidated": 773566526059432448, + "SMPayout": 0 + } + } + ] + } +} diff --git a/test/integration-tests/liquidation/SRM_liquidationSim.t.sol b/test/integration-tests/liquidation/SRM_liquidationSim.t.sol new file mode 100644 index 00000000..0313cf1f --- /dev/null +++ b/test/integration-tests/liquidation/SRM_liquidationSim.t.sol @@ -0,0 +1,133 @@ +// SPDX-License-Identifier: BUSL-1.1 +pragma solidity ^0.8.18; + +import "forge-std/Test.sol"; +import "lyra-utils/encoding/OptionEncoding.sol"; + +import "../shared/IntegrationTestBase.t.sol"; + +import {getDefaultAuctionParam} from "../../../scripts/config-local.sol"; +import "./util/SRMLiquidationSimBase.sol"; +/** + * @dev testing liquidation process + */ + +contract SRMLiqudationSimulationTests is SRMLiquidationSimBase { + using stdJson for string; + + function testSRMLiquidationSim1() public { + runLiquidationSim("SRM_liquidation", "Test1"); + } +// +// function testLiquidationSim2() public { +// runLiquidationSim("PMRM_solvent", "Test2"); +// } +// +// function testLiquidationSim3() public { +// runLiquidationSim("PMRM_solvent", "Test3"); +// } +// +// function testLiquidationSim4() public { +// runLiquidationSim("PMRM_solvent", "Test4"); +// } +// +// function testLiquidationSim5() public { +// runLiquidationSim("PMRM_solvent", "Test5"); +// } +// +// function testLiquidationSim6() public { +// runLiquidationSim("PMRM_solvent", "Test6"); +// } + + + function runLiquidationSim(string memory fileName, string memory testName) internal { + LiquidationSim memory data = SRMLiquidationSimBase.getTestData(fileName, testName); + setupTestScenario(data); + + + vm.warp(data.StartTime); + startAuction(); + + for (uint i = 0; i < data.Actions.length; ++i) { + console2.log("\n=== STEP:", i); + updateToActionState(data, i); + console2.log("Pre:", i); + checkPreLiquidation(data, i); + console2.log("Liq:", i); + doLiquidation(data, i); + console2.log("Post:", i); + checkPostLiquidation(data, i); + } + } + + function startAuction() internal { + auction.startAuction(aliceAcc, 0); + + } + + function doLiquidation(LiquidationSim memory data, uint actionId) internal { + uint liqAcc = subAccounts.createAccount(address(this), IManager(address(manager))); + _depositCash(liqAcc, 1000000000e18); + + (uint finalPercentage, uint cashFromBidder, uint cashToBidder) = + auction.bid(aliceAcc, liqAcc, data.Actions[actionId].Liquidator.PercentLiquidated, 0, 0); + + IDutchAuction.Auction memory auctionDetails = auction.getAuction(aliceAcc); + if (auctionDetails.insolvent) { + assertApproxEqRel(int(cashToBidder), - data.Actions[actionId].Results.SMPayout, 0.001e18, "bid price insolvent"); + } else { + assertApproxEqRel(int(cashFromBidder), data.Actions[actionId].Results.ExpectedBidPrice, 0.001e18, "bid price solvent"); + assertApproxEqRel( + finalPercentage, data.Actions[actionId].Results.LiquidatedOfOriginal, 0.001e18, "liquidated of original" + ); + } + } + + function checkPreLiquidation(LiquidationSim memory data, uint actionId) internal { + (int mm, int bm, int mtm) = auction.getMarginAndMarkToMarket(aliceAcc, 0); + IDutchAuction.Auction memory auctionDetails = auction.getAuction(aliceAcc); + if (auctionDetails.insolvent) { + // todo: this needs to be changed to use MM as lower bound + // assertApproxEqAbs(mm, data.Actions[actionId].Results.LowerBound, 1e6, "lowerbound"); + } else { + uint fMax = auction.getMaxProportion(aliceAcc, 0); + assertApproxEqRel(fMax, data.Actions[actionId].Results.PreFMax, 0.001e18, "pre fmax"); + } + + console2.log("MTM", mtm); + + assertApproxEqRel(mtm, data.Actions[actionId].Results.PreMtM, 0.001e18, "pre mtm"); + assertApproxEqRel(mm, data.Actions[actionId].Results.PreMM, 0.001e18, "pre mm"); + assertApproxEqRel(bm, data.Actions[actionId].Results.PreBM, 0.001e18, "pre bm"); + } + + function checkPostLiquidation(LiquidationSim memory data, uint actionId) internal { + (int mm, int bm, int mtm) = auction.getMarginAndMarkToMarket(aliceAcc, 0); + + assertApproxEqRel(mtm, data.Actions[actionId].Results.PostMtM, 0.001e18, "post mtm"); + assertApproxEqRel(mm, data.Actions[actionId].Results.PostMM, 0.001e18, "post mm"); + + if (SignedMath.abs(data.Actions[actionId].Results.PostBM) < 1e10 || SignedMath.abs(bm) < 1e10) { + assertApproxEqAbs(SignedMath.abs(bm), 0, 1e8, "post bm dust check"); + assertApproxEqAbs(SignedMath.abs(data.Actions[actionId].Results.PostBM), 0, 1e8, "post bm dust check"); + } else { + assertApproxEqRel(bm, data.Actions[actionId].Results.PostBM, 0.00001e18, "post bm"); + } + + IDutchAuction.Auction memory auctionDetails = auction.getAuction(aliceAcc); + if (auctionDetails.insolvent) {} else { + uint fMax = auction.getMaxProportion(aliceAcc, 0); + if (data.Actions[actionId].Results.PostFMax < 1e10 || fMax < 1e10) { + assertApproxEqAbs(fMax, 0, 1e8, "post fmax dust check"); + assertApproxEqAbs(data.Actions[actionId].Results.PostFMax, 0, 1e8, "post fmax dust check"); + } else { + assertApproxEqRel(fMax, data.Actions[actionId].Results.PostFMax, 0.001e18, "post fmax"); + } + } + } + + function updateToActionState(LiquidationSim memory data, uint actionId) internal { + vm.warp(data.Actions[actionId].Time); + updateFeeds(data.Actions[actionId].Feeds); + } +} diff --git a/test/integration-tests/liquidation/util/LiquidationSimBase.sol b/test/integration-tests/liquidation/util/PMRMLiquidationSimBase.sol similarity index 95% rename from test/integration-tests/liquidation/util/LiquidationSimBase.sol rename to test/integration-tests/liquidation/util/PMRMLiquidationSimBase.sol index 8a996fb4..336fedae 100644 --- a/test/integration-tests/liquidation/util/LiquidationSimBase.sol +++ b/test/integration-tests/liquidation/util/PMRMLiquidationSimBase.sol @@ -8,13 +8,7 @@ import "lyra-utils/encoding/OptionEncoding.sol"; import "forge-std/console2.sol"; -contract TempReader { - function readInt(string memory json, string memory location) external pure returns (int) { - return stdJson.readInt(json, location); - } -} - -contract LiquidationSimBase is PMRMTestBase { +contract PMRMLiquidationSimBase is PMRMTestBase { using stdJson for string; struct LiquidationSim { @@ -76,10 +70,7 @@ contract LiquidationSimBase is PMRMTestBase { int SMPayout; } - TempReader t; - constructor() { - t = new TempReader(); } function getTestData(string memory fileName, string memory testName) internal view returns (LiquidationSim memory sim) { @@ -174,14 +165,6 @@ contract LiquidationSimBase is PMRMTestBase { return action; } - function tryGetWithDefault(string memory json, string memory location, int defaultVal) internal view returns (int) { - try t.readInt(json, location) returns (int payout) { - return payout; - } catch { - return defaultVal; - } - } - function lookupNum(uint num) internal pure returns (string memory) { // return the string version of num if (num == 0) { diff --git a/test/integration-tests/liquidation/util/SRMLiquidationSimBase.sol b/test/integration-tests/liquidation/util/SRMLiquidationSimBase.sol new file mode 100644 index 00000000..71106ad5 --- /dev/null +++ b/test/integration-tests/liquidation/util/SRMLiquidationSimBase.sol @@ -0,0 +1,255 @@ +// SPDX-License-Identifier: BUSL-1.1 +pragma solidity ^0.8.18; + +import "test/shared/utils/JsonMechIO.sol"; +import "test/risk-managers/unit-tests/StandardManager/TestStandardManagerBase.t.sol"; + +import "lyra-utils/encoding/OptionEncoding.sol"; +import "forge-std/console2.sol"; + + +contract SRMLiquidationSimBase is TestStandardManagerBase, JsonMechIO { + using stdJson for string; + + struct LiquidationSim { + uint StartTime; + bool IsForce; + Portfolio InitialPortfolio; + LiquidationAction[] Actions; + } + + struct Portfolio { + int Cash; + int PerpPosition; + int BasePosition; + uint[] OptionStrikes; + uint[] OptionExpiries; + uint[] OptionIsCall; + int[] OptionAmounts; + Feeds initialFeeds; + } + + struct LiquidationAction { + uint Time; + Feeds Feeds; + Liquidator Liquidator; + Results Results; + } + + struct Feeds { + uint StablePrice; + uint StableConfidence; + uint SpotPrice; + uint SpotConfidence; + uint[] FeedExpiries; + uint[] Forwards; + uint[] ForwardConfidences; + int[] Rates; + uint[] RateConfidences; + uint[] VolFeedStrikes; + uint[] VolFeedExpiries; + uint[] VolFeedVols; + } + + struct Liquidator { + uint PercentLiquidated; + } + + struct Results { + int PreMtM; + int PreMM; + int PreBM; + uint PreFMax; + int ExpectedBidPrice; +// uint FinalPercentageReceived; + uint LiquidatedOfOriginal; + int PostMtM; + int PostMM; + int PostBM; + uint PostFMax; + int SMPayout; + } + + constructor() { + } + + function getTestData(string memory fileName, string memory testName) internal view returns (LiquidationSim memory sim) { + testName = string.concat(".", testName); + string memory json = JsonMechIO.jsonFromRelPath(string.concat("/test/integration-tests/liquidation/", fileName, ".json")); + sim.StartTime = json.readUint(string.concat(testName, ".StartTime")); + sim.IsForce = json.readBool(string.concat(testName, ".IsForce")); + sim.InitialPortfolio.Cash = json.readInt(string.concat(testName, ".InitialPortfolio.Cash")); + sim.InitialPortfolio.PerpPosition = json.readInt(string.concat(testName, ".InitialPortfolio.Perps")); + sim.InitialPortfolio.BasePosition = json.readInt(string.concat(testName, ".InitialPortfolio.Base")); + sim.InitialPortfolio.OptionStrikes = json.readUintArray(string.concat(testName, ".InitialPortfolio.OptionStrikes")); + sim.InitialPortfolio.OptionExpiries = + json.readUintArray(string.concat(testName, ".InitialPortfolio.OptionExpiries")); + sim.InitialPortfolio.OptionIsCall = json.readUintArray(string.concat(testName, ".InitialPortfolio.OptionIsCall")); + sim.InitialPortfolio.OptionAmounts = json.readIntArray(string.concat(testName, ".InitialPortfolio.OptionAmounts")); + + sim.InitialPortfolio.initialFeeds.StablePrice = + json.readUint(string.concat(testName, ".InitialPortfolio.StablePrice")); + // TODO: no stable confidence + sim.InitialPortfolio.initialFeeds.StableConfidence = 1e18; + sim.InitialPortfolio.initialFeeds.SpotPrice = json.readUint(string.concat(testName, ".InitialPortfolio.SpotPrice")); + sim.InitialPortfolio.initialFeeds.SpotConfidence = + json.readUint(string.concat(testName, ".InitialPortfolio.SpotConfidence")); + sim.InitialPortfolio.initialFeeds.FeedExpiries = + json.readUintArray(string.concat(testName, ".InitialPortfolio.FeedExpiries")); + sim.InitialPortfolio.initialFeeds.Forwards = + json.readUintArray(string.concat(testName, ".InitialPortfolio.Forwards")); + sim.InitialPortfolio.initialFeeds.ForwardConfidences = + json.readUintArray(string.concat(testName, ".InitialPortfolio.ForwardConfidences")); + sim.InitialPortfolio.initialFeeds.Rates = json.readIntArray(string.concat(testName, ".InitialPortfolio.Rates")); + sim.InitialPortfolio.initialFeeds.RateConfidences = + json.readUintArray(string.concat(testName, ".InitialPortfolio.RateConfidences")); + sim.InitialPortfolio.initialFeeds.VolFeedStrikes = + json.readUintArray(string.concat(testName, ".InitialPortfolio.OptionStrikes")); + sim.InitialPortfolio.initialFeeds.VolFeedExpiries = + json.readUintArray(string.concat(testName, ".InitialPortfolio.OptionExpiries")); + sim.InitialPortfolio.initialFeeds.VolFeedVols = + json.readUintArray(string.concat(testName, ".InitialPortfolio.OptionVols")); + + // add actions + uint actionCount = json.readUint(string.concat(testName, ".ActionCount")); + sim.Actions = new LiquidationAction[](actionCount); + for (uint i = 0; i < actionCount; i++) { + sim.Actions[i] = getActionData(json, testName, i); + } + return sim; + } + + function getActionData(string memory json, string memory testName, uint actionNum) + internal + view + returns (LiquidationAction memory action) + { + // E.g. Test1.Actions[0] + string memory baseActionIndex = + string.concat(string.concat(string.concat(testName, ".Actions["), lookupNum(actionNum)), "]"); + + action.Time = json.readUint(string.concat(baseActionIndex, ".Time")); + action.Feeds.StablePrice = json.readUint(string.concat(baseActionIndex, ".PortfolioAndFeeds.StablePrice")); + // TODO: no stable confidence + action.Feeds.StableConfidence = 1e18; + action.Feeds.SpotPrice = json.readUint(string.concat(baseActionIndex, ".PortfolioAndFeeds.SpotPrice")); + action.Feeds.SpotConfidence = json.readUint(string.concat(baseActionIndex, ".PortfolioAndFeeds.SpotConfidence")); + action.Feeds.FeedExpiries = json.readUintArray(string.concat(baseActionIndex, ".PortfolioAndFeeds.FeedExpiries")); + action.Feeds.Forwards = json.readUintArray(string.concat(baseActionIndex, ".PortfolioAndFeeds.Forwards")); + action.Feeds.ForwardConfidences = + json.readUintArray(string.concat(baseActionIndex, ".PortfolioAndFeeds.ForwardConfidences")); + action.Feeds.Rates = json.readIntArray(string.concat(baseActionIndex, ".PortfolioAndFeeds.Rates")); + action.Feeds.RateConfidences = + json.readUintArray(string.concat(baseActionIndex, ".PortfolioAndFeeds.RateConfidences")); + action.Feeds.VolFeedStrikes = json.readUintArray(string.concat(baseActionIndex, ".PortfolioAndFeeds.OptionStrikes")); + action.Feeds.VolFeedExpiries = + json.readUintArray(string.concat(baseActionIndex, ".PortfolioAndFeeds.OptionExpiries")); + action.Feeds.VolFeedVols = json.readUintArray(string.concat(baseActionIndex, ".PortfolioAndFeeds.OptionVols")); + + action.Liquidator.PercentLiquidated = json.readUint(string.concat(baseActionIndex, ".Liquidator.PercentWant")); + action.Results.PreMtM = json.readInt(string.concat(baseActionIndex, ".Results.PreMtM")); + action.Results.PreMM = json.readInt(string.concat(baseActionIndex, ".Results.PreMM")); + action.Results.PreBM = json.readInt(string.concat(baseActionIndex, ".Results.PreBM")); + action.Results.PostMtM = json.readInt(string.concat(baseActionIndex, ".Results.PostMtM")); + action.Results.PostMM = json.readInt(string.concat(baseActionIndex, ".Results.PostMM")); + action.Results.PostBM = json.readInt(string.concat(baseActionIndex, ".Results.PostBM")); + + // Ignored for insolvent so we just set to 0 + action.Results.PreFMax = json.readUint(string.concat(baseActionIndex, ".Results.PreFMax")); + action.Results.ExpectedBidPrice = json.readInt(string.concat(baseActionIndex, ".Results.ExpectedBidPrice")); + action.Results.LiquidatedOfOriginal = json.readUint(string.concat(baseActionIndex, ".Results.fLiquidatedOfOriginal")); + action.Results.PostFMax = json.readUint(string.concat(baseActionIndex, ".Results.PostFMax")); + console2.log("res", action.Results.PostFMax); + action.Results.SMPayout = json.readInt(string.concat(baseActionIndex, ".Results.SMPayout")); + + return action; + } + + + function lookupNum(uint num) internal pure returns (string memory) { + // return the string version of num + if (num == 0) { + return "0"; + } else if (num == 1) { + return "1"; + } else if (num == 2) { + return "2"; + } else if (num == 3) { + return "3"; + } else if (num == 4) { + return "4"; + } else if (num == 5) { + return "5"; + } else if (num == 6) { + return "6"; + } + revert("out of lookupNums"); + } + + function setupTestScenario(LiquidationSim memory data) internal { + vm.warp(data.StartTime); + + uint totalAssets = data.InitialPortfolio.OptionStrikes.length; + + totalAssets += data.InitialPortfolio.Cash != 0 ? 1 : 0; + totalAssets += data.InitialPortfolio.PerpPosition != 0 ? 1 : 0; + totalAssets += data.InitialPortfolio.BasePosition != 0 ? 1 : 0; + + ISubAccounts.AssetBalance[] memory balances = new ISubAccounts.AssetBalance[](totalAssets); + + uint i = 0; + for (; i < data.InitialPortfolio.OptionStrikes.length; ++i) { + balances[i] = ISubAccounts.AssetBalance({ + asset: IAsset(ethOption), + subId: OptionEncoding.toSubId( + data.InitialPortfolio.OptionExpiries[i], + data.InitialPortfolio.OptionStrikes[i], + data.InitialPortfolio.OptionIsCall[i] == 1 + ), + balance: data.InitialPortfolio.OptionAmounts[i] + }); + } + + if (data.InitialPortfolio.Cash != 0) { + balances[i++] = + ISubAccounts.AssetBalance({asset: IAsset(address(cash)), subId: 0, balance: data.InitialPortfolio.Cash}); + } + if (data.InitialPortfolio.PerpPosition != 0) { + balances[i++] = ISubAccounts.AssetBalance({ + asset: IAsset(address(ethPerp)), + subId: 0, + balance: data.InitialPortfolio.PerpPosition + }); + } + if (data.InitialPortfolio.BasePosition != 0) { + balances[i++] = ISubAccounts.AssetBalance({ + asset: IAsset(address(wethAsset)), + subId: 0, + balance: data.InitialPortfolio.BasePosition + }); + + } + + setBalances(aliceAcc, balances); + updateFeeds(data.InitialPortfolio.initialFeeds); + } + + function updateFeeds(Feeds memory feedData) internal { + stableFeed.setSpot(feedData.StablePrice, feedData.StableConfidence); + ethFeed.setSpot(feedData.SpotPrice, feedData.SpotConfidence); + + console.log("AAAAAAA", feedData.FeedExpiries.length); + for (uint i = 0; i < feedData.FeedExpiries.length; i++) { + console2.log("Setting expiry:", feedData.FeedExpiries[i]); + console2.log("fwd", feedData.Forwards[i]); + ethFeed.setForwardPrice(feedData.FeedExpiries[i], feedData.Forwards[i], feedData.ForwardConfidences[i]); + ethFeed.setInterestRate(feedData.FeedExpiries[i], int64(feedData.Rates[i]), uint64(feedData.RateConfidences[i])); + } + + for (uint i = 0; i < feedData.VolFeedStrikes.length; ++i) { + ethFeed.setVol( + uint64(feedData.VolFeedExpiries[i]), uint128(feedData.VolFeedStrikes[i]), feedData.VolFeedVols[i], 1e18 + ); + } + } +} diff --git a/test/risk-managers/unit-tests/StandardManager/StandardManagerPublic.sol b/test/risk-managers/unit-tests/StandardManager/StandardManagerPublic.sol index 25871812..fa1efa3b 100644 --- a/test/risk-managers/unit-tests/StandardManager/StandardManagerPublic.sol +++ b/test/risk-managers/unit-tests/StandardManager/StandardManagerPublic.sol @@ -20,4 +20,18 @@ contract StandardManagerPublic is StandardManager { (im, mtm) = _getMarginAndMarkToMarket(accountId, portfolio, true); (mm,) = _getMarginAndMarkToMarket(accountId, portfolio, false); } + + function setBalances(uint accountId, ISubAccounts.AssetBalance[] memory assets) external { + for (uint i = 0; i < assets.length; ++i) { + subAccounts.managerAdjustment( + ISubAccounts.AssetAdjustment({ + acc: accountId, + asset: assets[i].asset, + subId: assets[i].subId, + amount: assets[i].balance, + assetData: bytes32(0) + }) + ); + } + } } diff --git a/test/risk-managers/unit-tests/StandardManager/TestStandardManagerBase.t.sol b/test/risk-managers/unit-tests/StandardManager/TestStandardManagerBase.t.sol index 70ae8d57..7713e777 100644 --- a/test/risk-managers/unit-tests/StandardManager/TestStandardManagerBase.t.sol +++ b/test/risk-managers/unit-tests/StandardManager/TestStandardManagerBase.t.sol @@ -19,6 +19,8 @@ import "../../../shared/mocks/MockCash.sol"; import "../../../../scripts/config-local.sol"; import "../../mocks/MockDutchAuction.sol"; import "../../../../src/assets/WrappedERC20Asset.sol"; +import "../../../../src/liquidation/DutchAuction.sol"; +import "../../../../src/SecurityModule.sol"; /** * @dev shard contract setting up environment for testing StandardManager @@ -41,6 +43,8 @@ contract TestStandardManagerBase is Test { SRMPortfolioViewer portfolioViewer; + DutchAuction auction; + uint ethSpot = 1500e18; uint btcSpot = 20000e18; @@ -62,6 +66,8 @@ contract TestStandardManagerBase is Test { uint bobAcc; uint charlieAcc; + SecurityModule sm; + struct Trade { IAsset asset; int amount; @@ -89,10 +95,13 @@ contract TestStandardManagerBase is Test { portfolioViewer = new SRMPortfolioViewer(subAccounts, cash); + sm = new SecurityModule(subAccounts, cash, IManager(manager)); + auction = new DutchAuction(subAccounts, sm, cash); + manager = new StandardManagerPublic( subAccounts, ICashAsset(address(cash)), - IDutchAuction(new MockDutchAuction()), + IDutchAuction(auction), portfolioViewer ); @@ -186,4 +195,14 @@ contract TestStandardManagerBase is Test { function _getPerpBalance(IPerpAsset perp, uint acc) public view returns (int) { return subAccounts.getBalance(acc, perp, 0); } + + function _depositCash(uint acc, uint amount) internal { + usdc.mint(address(this), amount); + usdc.approve(address(cash), amount); + cash.deposit(acc, amount); + } + + function setBalances(uint acc, ISubAccounts.AssetBalance[] memory balances) internal { + manager.setBalances(acc, balances); + } }