Skip to content

lumoswiz/DopexSsovBacktesting

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SSOV V3 Backtesting

Dopex SSOV backtesting built with Foundry for Arbitrum fork testing of SSOV V3 contracts.

Setup

Running backtests

  • Navigate to StrategyTest.t.sol. User input is required in the setUp() function.

  • Variables:

    • ssov: contract address of the SSOV V3 to run backtests against. NOTE: I have only currently run backtests against DPX WEEKLY CALLS SSOV V3.

    • epoch: the expired epoch to run backtests against.

    • Deposit parameters (depositBlockNumbers, depositStrikeIndexes and depositAmounts):

      • Contracts require the block number, strike index and amount to deposit. To deposit 1 DPX (1e18 precision) at strike index 2 and block number 22962396 then the deposit parameter arrays will look like:
      depositBlockNumbers = [22962396];
      depositStrikeIndexes = [2];
      depositAmounts = [1e18];
    • Purchase parameters (purchaseBlockNumbers, purchaseStrikeIndexes and purchaseAmounts):

      • Same rules apply as for deposit parameters. If you want to simulate two purchases, with: Purchase 1: 10 option tokens at strike index 1 at block number 23165341 & Purchase 2: 2 option tokens at strike index 0 at block number 23402497 the purchase parameters will look as follows:
      purchaseBlockNumbers = [23165341, 23402497];
      purchaseStrikeIndexes = [1, 0];
      purchaseAmounts = [10e18, 2e18];
      • NOTE: if the desired purchase amount/s exceed the available collateral for the given parameters, the purchase amount will be adjusted to the available collateral and a log will be emitted to indicate this.
  • If the user wants to run only deposits or purchases, comment out the lines containing the arrays of the other type. Example: only deposits to be backtested, then the purchase array lines will look like:

// purchaseBlockNumbers = [];
// purchaseStrikeIndexes = [];
// purchaseAmounts = [];
  • Testing:

    • When parameters are input, in the command line run:
    forge test --match-test testStrategy -vvv
    • When the test has completed running, logs will be emitted for the corresponding deposits and/or purchases.
      • For deposits: collateralTokenWithdrawAmount, reward token amounts and the net DPX return (in units) are summarised.
      • For purchases: the dpx net pnl (in units) is summarised, accounting for purchase fees, premium and settlement fees.

Backtests vs. actual performance

  • Tested actual deposits and purchases duing epoch 1 for DPX WEEKLY CALLS SSOV V3. Near 100% accuracy (simulation/real) achieved for collateralTokenWithdrawAmount, rewardTokenAmounts (both DPX and JONES) and net pnl. Inputs tested summarised below:
ssov = 0x10FD85ec522C245a63239b9FC64434F58520bd1f;

epoch = 1;

depositBlockNumbers = [22962396, 23020472, 23244639];
depositStrikeIndexes = [3, 2, 1];
depositAmounts = [7.782e18, 11.427e18, 0.15e18];

purchaseBlockNumbers = [23165341, 23377592, 23402497];
purchaseStrikeIndexes = [0, 0, 0];
purchaseAmounts = [1e18, 6e18, 6e18];

Bugs/Help

  • For any help, feedback, or questions please feel free to reach out to me on Twitter.
  • So far I have only tested DPX weekly (V3 contracts) for epoch 1. I hope to test more SSOV/epoch combinations soon, so stay tuned.

Acknowledgements

  • Thanks to Dopex for inspiring this personal project. Reading through your contracts has helped me improve my comfortability with Solidity and pushed me to improve my working knowledge of Foundry (such as fork testing and using the StdStorage library).
  • Foundry. Refer to the book.

About

Backtesting Dopex Single Staking Option Vaults (V3 contracts).

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published