diff --git a/src/feeds/LyraSpotDiffFeed.sol b/src/feeds/LyraSpotDiffFeed.sol index 6fc8f910..45e22f93 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/src/risk-managers/PMRM.sol b/src/risk-managers/PMRM.sol index fc94b3ba..992f1791 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_insolvent.json b/test/integration-tests/liquidation/PMRM_insolvent.json new file mode 100644 index 00000000..63b04dde --- /dev/null +++ b/test/integration-tests/liquidation/PMRM_insolvent.json @@ -0,0 +1,1976 @@ +{ + "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, + "ExpectedBidPrice": -29371585189059944448, + "fLiquidatedOfOriginal": 0, + "PostFMax": 0, + "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, + "ExpectedBidPrice": 0, + "fLiquidatedOfOriginal": 0, + "PostFMax": 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, + "ExpectedBidPrice": -211759362378998743040, + "fLiquidatedOfOriginal": 0, + "PostFMax": 0, + "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, + "ExpectedBidPrice": -890439826443771314176, + "fLiquidatedOfOriginal": 0, + "PostFMax": 0, + "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": 111111111111111120 + }, + "Results": { + "PreMtM": -671041165721540886528, + "PreMM": -1105556759314385076224, + "PreBM": -1192459878032953835520, + "PostMtM": -596481036196925276160, + "PostMM": -982717119390564614144, + "PostBM": -1059964336029292560384, + "SMPayout": -89043982644377141248, + "ExpectedBidPrice": -801395843799394156544, + "fLiquidatedOfOriginal": 0, + "PostFMax": 0, + "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, + "ExpectedBidPrice": -890439826443771314176, + "fLiquidatedOfOriginal": 0, + "PostFMax": 0, + "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": 555555555555555584 + }, + "Results": { + "PreMtM": -671041165721540886528, + "PreMM": -1105556759314385076224, + "PreBM": -1192459878032953835520, + "PostMtM": -298240518098462638080, + "PostMM": -491358559695282307072, + "PostBM": -529982168014646280192, + "SMPayout": -445219913221885657088, + "ExpectedBidPrice": -801395843799394156544, + "fLiquidatedOfOriginal": 0, + "PostFMax": 0, + "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, + "ExpectedBidPrice": -80237844493457637376, + "fLiquidatedOfOriginal": 0, + "PostFMax": 0, + "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": 592691622103386880 + }, + "Results": { + "PreMtM": 132518228046353661952, + "PreMM": -704325410524874801152, + "PreBM": -871694138239120441344, + "PostMtM": 53975784507293835264, + "PostMM": -286877640472253005824, + "PostBM": -355048325468162359296, + "SMPayout": -119853641897612836864, + "ExpectedBidPrice": -202219227382137716736, + "fLiquidatedOfOriginal": 0, + "PostFMax": 0, + "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, + "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 new file mode 100644 index 00000000..d0c8e3ac --- /dev/null +++ b/test/integration-tests/liquidation/PMRM_solvent.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/PM_liquidationSimTests.t.sol b/test/integration-tests/liquidation/PM_liquidationSimTests.t.sol index 8c9b6ce0..89f11981 100644 --- a/test/integration-tests/liquidation/PM_liquidationSimTests.t.sol +++ b/test/integration-tests/liquidation/PM_liquidationSimTests.t.sol @@ -4,55 +4,96 @@ 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 { - 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 testInsolventSim1() public { - // runLiquidationSim("InsolventTest1"); - // } + 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 testLiquidationSimPMRM_perp() public { + runLiquidationSim("PMRM_solvent", "test_Nov_03_perp"); + } + + function testLiquidationSimPMRM_General() public { + runLiquidationSim("PMRM_solvent", "test_Nov_04_general"); + } - // function testInsolventSim2() public { - // runLiquidationSim("InsolventTest2"); - // } + function testLiquidationSimPMRM_Borrow() public { + runLiquidationSim("PMRM_solvent", "test_Nov_05_borrow"); + } - function runLiquidationSim(string memory testName) internal { - LiquidationSim memory data = LiquidationSimBase.getTestData(testName); + 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 = PMRMLiquidationSimBase.getTestData(fileName, testName); setupTestScenario(data); + vm.warp(data.StartTime); 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); } } @@ -60,6 +101,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 { @@ -67,15 +109,15 @@ 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) { - 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" ); } } @@ -84,38 +126,50 @@ 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"); } - 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("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 { 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"); + + 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, worstScenario); - assertApproxEqAbs(fMax, data.Actions[actionId].Results.PostFMax, 1e6, "post fmax"); + 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 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) { @@ -123,6 +177,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/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/liquidationTests.json b/test/integration-tests/liquidation/liquidationTests.json index 3e1551bd..c6c1b2fd 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], - "StableConfidence": 0, + "FeedExpiries": [ + 500400 + ], + "Forwards": [ + 1500833279310993817600 + ], + "ForwardConfidences": [ + 1000000000000000000 + ], + "Rates": [ + 0 + ], + "RateConfidences": [ + 1000000000000000000 + ], "StablePrice": 1000000000000000000, - "UnrealisedPerpPNL": 0, - "UnrealisedFunding": 0, - "VolShockUp": [1.7370684514926746], - "VolShockDown": [0.508621032338217], + "StableConfidence": 1000000000000000000, + "UnrealizedPerpPNL": 0, + "UnrealizedFunding": 0, + "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], - "StableConfidence": 0, + "FeedExpiries": [ + 500400 + ], + "Forwards": [ + 1500833279310993817600 + ], + "ForwardConfidences": [ + 1000000000000000000 + ], + "Rates": [ + 40000000000000000 + ], + "RateConfidences": [ + 1000000000000000000 + ], "StablePrice": 1000000000000000000, - "UnrealisedPerpPNL": 0, - "UnrealisedFunding": 0, - "VolShockUp": [1.7370684514926746], - "VolShockDown": [0.508621032338217], + "StableConfidence": 1000000000000000000, + "UnrealizedPerpPNL": 0, + "UnrealizedFunding": 0, + "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], - "StableConfidence": 0, + "FeedExpiries": [ + 500400 + ], + "Forwards": [ + 1500833279310993817600 + ], + "ForwardConfidences": [ + 1000000000000000000 + ], + "Rates": [ + 0 + ], + "RateConfidences": [ + 1000000000000000000 + ], "StablePrice": 1000000000000000000, - "UnrealisedPerpPNL": 0, - "UnrealisedFunding": 0, - "VolShockUp": [1.7370684514926746], - "VolShockDown": [0.508621032338217], + "StableConfidence": 1000000000000000000, + "UnrealizedPerpPNL": 0, + "UnrealizedFunding": 0, + "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], - "StableConfidence": 0, + "FeedExpiries": [ + 500400 + ], + "Forwards": [ + 1500833279310993817600 + ], + "ForwardConfidences": [ + 1000000000000000000 + ], + "Rates": [ + 40000000000000000 + ], + "RateConfidences": [ + 1000000000000000000 + ], "StablePrice": 1000000000000000000, - "UnrealisedPerpPNL": 0, - "UnrealisedFunding": 0, - "VolShockUp": [1.7370684514926746], - "VolShockDown": [0.508621032338217], + "StableConfidence": 1000000000000000000, + "UnrealizedPerpPNL": 0, + "UnrealizedFunding": 0, + "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], - "StableConfidence": 0, + "FeedExpiries": [ + 500400 + ], + "Forwards": [ + 1500833279310993817600 + ], + "ForwardConfidences": [ + 1000000000000000000 + ], + "Rates": [ + 0 + ], + "RateConfidences": [ + 1000000000000000000 + ], "StablePrice": 1000000000000000000, - "UnrealisedPerpPNL": 0, - "UnrealisedFunding": 0, - "VolShockUp": [1.7370684514926746], - "VolShockDown": [0.508621032338217], + "StableConfidence": 1000000000000000000, + "UnrealizedPerpPNL": 0, + "UnrealizedFunding": 0, + "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": [ + 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, @@ -235,21 +433,39 @@ "SpotConfidence": 1000000000000000000, "PerpPrice": 0, "PerpConfidence": 1000000000000000000, - "FeedExpiries": [500400], - "Forwards": [1500833229340328329216], - "ForwardConfidences": [1000000000000000000], - "Rates": [40000000000000000], - "RateConfidences": [1000000000000000000], - "StableConfidence": 0, + "FeedExpiries": [ + 500370 + ], + "Forwards": [ + 1500833229340328329216 + ], + "ForwardConfidences": [ + 1000000000000000000 + ], + "Rates": [ + 40000000000000000 + ], + "RateConfidences": [ + 1000000000000000000 + ], "StablePrice": 1000000000000000000, - "UnrealisedPerpPNL": 0, - "UnrealisedFunding": 0, - "VolShockUp": [1.737081708636119], - "VolShockDown": [0.5086121942425874], + "StableConfidence": 1000000000000000000, + "UnrealizedPerpPNL": 0, + "UnrealizedFunding": 0, + "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], - "StableConfidence": 0, + "FeedExpiries": [ + 500400 + ], + "Forwards": [ + 1500833279310993817600 + ], + "ForwardConfidences": [ + 1000000000000000000 + ], + "Rates": [ + 0 + ], + "RateConfidences": [ + 1000000000000000000 + ], "StablePrice": 1000000000000000000, - "UnrealisedPerpPNL": 0, - "UnrealisedFunding": 0, - "VolShockUp": [1.7370684514926746], - "VolShockDown": [0.508621032338217], + "StableConfidence": 1000000000000000000, + "UnrealizedPerpPNL": 0, + "UnrealizedFunding": 0, + "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": [ + 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, @@ -326,21 +596,39 @@ "SpotConfidence": 1000000000000000000, "PerpPrice": 0, "PerpConfidence": 1000000000000000000, - "FeedExpiries": [500400], - "Forwards": [1500833229340328329216], - "ForwardConfidences": [1000000000000000000], - "Rates": [40000000000000000], - "RateConfidences": [1000000000000000000], - "StableConfidence": 0, + "FeedExpiries": [ + 500370 + ], + "Forwards": [ + 1500833229340328329216 + ], + "ForwardConfidences": [ + 1000000000000000000 + ], + "Rates": [ + 40000000000000000 + ], + "RateConfidences": [ + 1000000000000000000 + ], "StablePrice": 1000000000000000000, - "UnrealisedPerpPNL": 0, - "UnrealisedFunding": 0, - "VolShockUp": [1.737081708636119], - "VolShockDown": [0.5086121942425874], + "StableConfidence": 1000000000000000000, + "UnrealizedPerpPNL": 0, + "UnrealizedFunding": 0, + "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": [ + 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, @@ -378,24 +684,42 @@ "SpotConfidence": 1000000000000000000, "PerpPrice": 0, "PerpConfidence": 1000000000000000000, - "FeedExpiries": [500400], - "Forwards": [1500833229340328329216], - "ForwardConfidences": [1000000000000000000], - "Rates": [40000000000000000], - "RateConfidences": [1000000000000000000], - "StableConfidence": 0, + "FeedExpiries": [ + 500370 + ], + "Forwards": [ + 1500833229340328329216 + ], + "ForwardConfidences": [ + 1000000000000000000 + ], + "Rates": [ + 40000000000000000 + ], + "RateConfidences": [ + 1000000000000000000 + ], "StablePrice": 1000000000000000000, - "UnrealisedPerpPNL": 0, - "UnrealisedFunding": 0, - "VolShockUp": [1.737081708636119], - "VolShockDown": [0.5086121942425874], + "StableConfidence": 1000000000000000000, + "UnrealizedPerpPNL": 0, + "UnrealizedFunding": 0, + "VolShockUp": [ + 1.737081708636119 + ], + "VolShockDown": [ + 0.5086121942425874 + ], "SettlementPrice": 1500833229340328329216, "PercentFixed": 0, - "ForwardsFixed": [0], - "ForwardsVariable": [1500833229340328329216] + "ForwardsFixed": [ + 0 + ], + "ForwardsVariable": [ + 1500833229340328329216 + ] }, "Liquidator": { - "PercentWant": 111111111111111111 + "PercentWant": 100000000000000000 }, "Results": { "PreMtM": 118425834278252019712, @@ -404,7 +728,7 @@ "PreFMax": 524290585958138816, "ExpectedBidPrice": 11047987360634836992, "FinalPercentageReceived": 111111111111111120, - "fLiquidatedOfOriginal": 111111111111111111, + "fLiquidatedOfOriginal": 100000000000000000, "PostMtM": 117542949759151603712, "PostMM": -60374319541825396736, "PostBM": -95957773402020790272, @@ -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,125 +775,303 @@ "SpotConfidence": 1000000000000000000, "PerpPrice": 1505000000000000000000, "PerpConfidence": 1000000000000000000, - "FeedExpiries": [500400], - "Forwards": [1500833279310993817600], - "ForwardConfidences": [1000000000000000000], - "Rates": [0], - "RateConfidences": [1000000000000000000], - "StableConfidence": 0, + "FeedExpiries": [ + 500400 + ], + "Forwards": [ + 1500833279310993817600 + ], + "ForwardConfidences": [ + 1000000000000000000 + ], + "Rates": [ + 0 + ], + "RateConfidences": [ + 1000000000000000000 + ], "StablePrice": 1000000000000000000, - "UnrealisedPerpPNL": 0, - "UnrealisedFunding": 0, - "VolShockUp": [1.7370684514926746], - "VolShockDown": [0.508621032338217], + "StableConfidence": 1000000000000000000, + "UnrealizedPerpPNL": 0, + "UnrealizedFunding": 0, + "VolShockUp": [ + 1.7370684514926746 + ], + "VolShockDown": [ + 0.508621032338217 + ], "SettlementPrice": 1500833279310993817600, "PercentFixed": 0, - "ForwardsFixed": [0], - "ForwardsVariable": [1500833279310993817600] + "ForwardsFixed": [ + 0 + ], + "ForwardsVariable": [ + 1500833279310993817600 + ] }, - "ActionCount": 2, + "ActionCount": 3, "LiquidationFee": 1.322084630165343, "Actions": [ { "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": [ + 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": 1530000000000000000000, + "SpotPrice": 1500000000000000000000, "SpotConfidence": 1000000000000000000, "PerpPrice": 0, "PerpConfidence": 1000000000000000000, - "FeedExpiries": [500400], - "Forwards": [1530849893927134953472], - "ForwardConfidences": [1000000000000000000], - "Rates": [40000000000000000], - "RateConfidences": [1000000000000000000], - "StableConfidence": 0, + "FeedExpiries": [ + 500370 + ], + "Forwards": [ + 1500833229340328329216 + ], + "ForwardConfidences": [ + 1000000000000000000 + ], + "Rates": [ + 40000000000000000 + ], + "RateConfidences": [ + 1000000000000000000 + ], "StablePrice": 1000000000000000000, - "UnrealisedPerpPNL": 0, - "UnrealisedFunding": 0, - "VolShockUp": [1.737081708636119], - "VolShockDown": [0.5086121942425874], - "SettlementPrice": 1530849893927134953472, + "StableConfidence": 1000000000000000000, + "UnrealizedPerpPNL": 0, + "UnrealizedFunding": 0, + "VolShockUp": [ + 1.737081708636119 + ], + "VolShockDown": [ + 0.5086121942425874 + ], + "SettlementPrice": 1500833229340328329216, "PercentFixed": 0, - "ForwardsFixed": [0], - "ForwardsVariable": [1530849893927134953472] + "ForwardsFixed": [ + 0 + ], + "ForwardsVariable": [ + 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], - "OptionStrikes": [1500000000000000000000], - "OptionIsCall": [1], - "OptionAmounts": [-900000000000000000], - "OptionVols": [1064560547131661312], - "SVIparams": [1, 1.5, -0.1, -0.05, 0.05], - "OptionVolConfidences": [1000000000000000000], - "Cash": 188358750092439584768, + "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": 1450000000000000000000, + "SpotPrice": 1500000000000000000000, "SpotConfidence": 1000000000000000000, "PerpPrice": 0, "PerpConfidence": 1000000000000000000, - "FeedExpiries": [500400], - "Forwards": [1450804537234727370752], - "ForwardConfidences": [1000000000000000000], - "Rates": [40000000000000000], - "RateConfidences": [1000000000000000000], - "StableConfidence": 0, + "FeedExpiries": [ + 500370 + ], + "Forwards": [ + 1500833229340328329216 + ], + "ForwardConfidences": [ + 1000000000000000000 + ], + "Rates": [ + 40000000000000000 + ], + "RateConfidences": [ + 1000000000000000000 + ], "StablePrice": 1000000000000000000, - "UnrealisedPerpPNL": 0, - "UnrealisedFunding": 0, - "VolShockUp": [1.7373337908573938], - "VolShockDown": [0.508444139428404], - "SettlementPrice": 1450804537234727370752, + "StableConfidence": 1000000000000000000, + "UnrealizedPerpPNL": 0, + "UnrealizedFunding": 0, + "VolShockUp": [ + 1.737081708636119 + ], + "VolShockDown": [ + 0.5086121942425874 + ], + "SettlementPrice": 1500833229340328329216, "PercentFixed": 0, - "ForwardsFixed": [0], - "ForwardsVariable": [1450804537234727370752] + "ForwardsFixed": [ + 0 + ], + "ForwardsVariable": [ + 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 } @@ -562,13 +1082,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 +1114,39 @@ "SpotConfidence": 1000000000000000000, "PerpPrice": 1505000000000000000000, "PerpConfidence": 1000000000000000000, - "FeedExpiries": [500400], - "Forwards": [1500833279310993817600], - "ForwardConfidences": [1000000000000000000], - "Rates": [0], - "RateConfidences": [1000000000000000000], - "StableConfidence": 0, + "FeedExpiries": [ + 500400 + ], + "Forwards": [ + 1500833279310993817600 + ], + "ForwardConfidences": [ + 1000000000000000000 + ], + "Rates": [ + 0 + ], + "RateConfidences": [ + 1000000000000000000 + ], "StablePrice": 1000000000000000000, - "UnrealisedPerpPNL": 0, - "UnrealisedFunding": 0, - "VolShockUp": [1.7370684514926746], - "VolShockDown": [0.508621032338217], + "StableConfidence": 1000000000000000000, + "UnrealizedPerpPNL": 0, + "UnrealizedFunding": 0, + "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 +1154,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": [ + 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, @@ -612,21 +1186,39 @@ "SpotConfidence": 1000000000000000000, "PerpPrice": 0, "PerpConfidence": 1000000000000000000, - "FeedExpiries": [500400], - "Forwards": [1530849893927134953472], - "ForwardConfidences": [1000000000000000000], - "Rates": [40000000000000000], - "RateConfidences": [1000000000000000000], - "StableConfidence": 0, + "FeedExpiries": [ + 500370 + ], + "Forwards": [ + 1530849893927134953472 + ], + "ForwardConfidences": [ + 1000000000000000000 + ], + "Rates": [ + 40000000000000000 + ], + "RateConfidences": [ + 1000000000000000000 + ], "StablePrice": 1000000000000000000, - "UnrealisedPerpPNL": 0, - "UnrealisedFunding": 0, - "VolShockUp": [1.737081708636119], - "VolShockDown": [0.5086121942425874], + "StableConfidence": 1000000000000000000, + "UnrealizedPerpPNL": 0, + "UnrealizedFunding": 0, + "VolShockUp": [ + 1.737081708636119 + ], + "VolShockDown": [ + 0.5086121942425874 + ], "SettlementPrice": 1530849893927134953472, "PercentFixed": 0, - "ForwardsFixed": [0], - "ForwardsVariable": [1530849893927134953472] + "ForwardsFixed": [ + 0 + ], + "ForwardsVariable": [ + 1530849893927134953472 + ] }, "Liquidator": { "PercentWant": 100000000000000000 @@ -650,13 +1242,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": [ + 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, @@ -664,24 +1274,42 @@ "SpotConfidence": 1000000000000000000, "PerpPrice": 0, "PerpConfidence": 1000000000000000000, - "FeedExpiries": [500400], - "Forwards": [1439798433848808701952], - "ForwardConfidences": [1000000000000000000], - "Rates": [40000000000000000], - "RateConfidences": [1000000000000000000], - "StableConfidence": 0, + "FeedExpiries": [ + 499800 + ], + "Forwards": [ + 1439798433848808701952 + ], + "ForwardConfidences": [ + 1000000000000000000 + ], + "Rates": [ + 40000000000000000 + ], + "RateConfidences": [ + 1000000000000000000 + ], "StablePrice": 1000000000000000000, - "UnrealisedPerpPNL": 0, - "UnrealisedFunding": 0, - "VolShockUp": [1.7373337908573938], - "VolShockDown": [0.508444139428404], + "StableConfidence": 1000000000000000000, + "UnrealizedPerpPNL": 0, + "UnrealizedFunding": 0, + "VolShockUp": [ + 1.7373337908573938 + ], + "VolShockDown": [ + 0.508444139428404 + ], "SettlementPrice": 1439798433848808701952, "PercentFixed": 0, - "ForwardsFixed": [0], - "ForwardsVariable": [1439798433848808701952] + "ForwardsFixed": [ + 0 + ], + "ForwardsVariable": [ + 1439798433848808701952 + ] }, "Liquidator": { - "PercentWant": 222222222222222222 + "PercentWant": 200000000000000000 }, "Results": { "PreMtM": 141241828744923119616, @@ -689,8 +1317,8 @@ "PreBM": -74294435474072059904, "PreFMax": 400423865535404544, "ExpectedBidPrice": 22599203883285839872, - "FinalPercentageReceived": 200000000000000000, - "fLiquidatedOfOriginal": 222222222222222240, + "FinalPercentageReceived": 222222222222222240, + "fLiquidatedOfOriginal": 200000000000000000, "PostMtM": 134575876520356806656, "PostMM": -5123553991954907136, "PostBM": -33063440094417244160, @@ -702,13 +1330,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": [ + 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, @@ -716,24 +1362,42 @@ "SpotConfidence": 1000000000000000000, "PerpPrice": 0, "PerpConfidence": 1000000000000000000, - "FeedExpiries": [500400], - "Forwards": [1522830289745930354688], - "ForwardConfidences": [1000000000000000000], - "Rates": [40000000000000000], - "RateConfidences": [1000000000000000000], - "StableConfidence": 0, + "FeedExpiries": [ + 491400 + ], + "Forwards": [ + 1522830289745930354688 + ], + "ForwardConfidences": [ + 1000000000000000000 + ], + "Rates": [ + 40000000000000000 + ], + "RateConfidences": [ + 1000000000000000000 + ], "StablePrice": 1000000000000000000, - "UnrealisedPerpPNL": 0, - "UnrealisedFunding": 0, - "VolShockUp": [1.7410925838661393], - "VolShockDown": [0.5059382774225738], + "StableConfidence": 1000000000000000000, + "UnrealizedPerpPNL": 0, + "UnrealizedFunding": 0, + "VolShockUp": [ + 1.7410925838661393 + ], + "VolShockDown": [ + 0.5059382774225738 + ], "SettlementPrice": 1522830289745930354688, "PercentFixed": 0, - "ForwardsFixed": [0], - "ForwardsVariable": [1522830289745930354688] + "ForwardsFixed": [ + 0 + ], + "ForwardsVariable": [ + 1522830289745930354688 + ] }, "Liquidator": { - "PercentWant": 428571428571428608 + "PercentWant": 300000000000000000 }, "Results": { "PreMtM": 107989712946571624448, @@ -741,8 +1405,8 @@ "PreBM": -85098725556266106880, "PreFMax": 606027945856190080, "ExpectedBidPrice": 9931675129055612928, - "FinalPercentageReceived": 300000000000000000, - "fLiquidatedOfOriginal": 428571428571428608, + "FinalPercentageReceived": 428571428571428608, + "fLiquidatedOfOriginal": 300000000000000000, "PostMtM": 85417724016899784704, "PostMM": -6529151460641997824, "PostBM": -24918526556150353920, @@ -757,13 +1421,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 +1453,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 +1493,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 +1525,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 +1581,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 +1613,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 +1672,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 +1704,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 +1744,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 +1776,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 @@ -986,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 + } + } + ] } } diff --git a/test/integration-tests/liquidation/util/LiquidationSimBase.sol b/test/integration-tests/liquidation/util/PMRMLiquidationSimBase.sol similarity index 90% rename from test/integration-tests/liquidation/util/LiquidationSimBase.sol rename to test/integration-tests/liquidation/util/PMRMLiquidationSimBase.sol index ab83f5a3..336fedae 100644 --- a/test/integration-tests/liquidation/util/LiquidationSimBase.sol +++ b/test/integration-tests/liquidation/util/PMRMLiquidationSimBase.sol @@ -5,8 +5,10 @@ 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 LiquidationSimBase is PMRMTestBase { + +contract PMRMLiquidationSimBase is PMRMTestBase { using stdJson for string; struct LiquidationSim { @@ -59,20 +61,21 @@ contract LiquidationSimBase is PMRMTestBase { int PreBM; uint PreFMax; int ExpectedBidPrice; - uint FinalPercentageReceived; +// uint FinalPercentageReceived; uint LiquidatedOfOriginal; int PostMtM; int PostMM; int PostBM; uint PostFMax; int SMPayout; - int LowerBound; } - // uint PostFMax; - function getTestData(string memory testName) internal view returns (LiquidationSim memory sim) { + constructor() { + } + + 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 +89,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 +121,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 +130,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")); @@ -146,17 +150,16 @@ 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")); + + // 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")); - action.Results.LowerBound = json.readInt(string.concat(baseActionIndex, ".Results.Lowerbound")); + console2.log("res", action.Results.PostFMax); action.Results.SMPayout = json.readInt(string.concat(baseActionIndex, ".Results.SMPayout")); return action; @@ -223,6 +226,7 @@ contract LiquidationSimBase is PMRMTestBase { subId: 0, balance: data.InitialPortfolio.BasePosition }); + } setBalances(aliceAcc, balances); @@ -233,7 +237,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])); } 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); + } }