/AevoOTCAnalysis

Altcoin Option Protocol Aevo OTC Trades Analysis

Primary LanguageJupyter Notebook

AevoOTC

Introduction

Analysis of Aevo alt option OTC trades PNL.

Usage

  1. Create a .env file with API_KEY=xxx where xxx is your alchemy api key
  2. (Optional) Go to alchemy playground and put the response to data/tokenMintEvents.json This is because there's a limit for the maximum block range we can query(2k).
  3. npm install .
    chmod +x lfg.sh
    ./lfg.sh
    

Methodology

To get All OTC transactions, we only pay attention to the following event:

Address
0xfed805e631ab9ed2b94f91255dd2714157fa759d
Name
ShortOtokenMinted (index_topic_1 address otoken, index_topic_2 address AccountOwner, index_topic_3 address to, uint256 vaultId, uint256 amount)View Source

Topics
0 0x4d7f96086c92b2f9a254ad21548b1c1f2d99502c7949508866349b96bb1a8d8a

We first get all events emitted by address 0xfed805e631ab9ed2b94f91255dd2714157fa759d

{
  "jsonrpc": "2.0",
  "id": 0,
  "method": "eth_getLogs",
  "params": [
    {
      "fromBlock": "0x0",
      "toBlock": "0x10B5E39",
      "address": "0xFED805e631aB9Ed2b94F91255DD2714157fA759d",
      "topics": [
        "0x4d7f96086c92b2f9a254ad21548b1c1f2d99502c7949508866349b96bb1a8d8a"
      ]
    }
  ]
}

Then in extract_tx.js, we do:

  1. get the timestamp of the tx from transaction hash => block number => block timestamp
  2. get the premium of each option, this is done through checking eth_getTransactionReceipt
  3. get the minted option token, then aggregate all fields replated to that token, which looks like:
  {
    decimals: 8,
    logo: null,
    name: 'BNBUSDC 30-June-2023 230Put USDC Collateral',
    symbol: 'oBNBUSDC/USDC-30JUN23-230P',
    tokenHash: '0xe5b284a2b69c08f5f879640d85d3d69fa723f551',
    transactionHash: '0x1886e90924c7eaa411cd76925ae93f2a66fb66b1569abc25cf53d078bafef316',
    optionBuyerAddr: '0x7ca28c291c806c955f48cdd7445e65fd702acec6',
    transactionTimeStamp: 1687443407
  }

With these, we are ready to fetch the settlement price (if expired) for each option. We use the Binance endpoint can be queried like https://data.binance.vision/data/spot/daily/klines/{ticker}USDT/{granularity}/{ticker}USDT-{granularity}-{date}.zip

We download the market data with a granularity up to 1h and get the spot price at time UTC 08:00. All data are downloaded at data directory. The final aggregated PNL csv file is located in result/TokenInfo_processed.csv.

Here is the result up to June 30.

PNL Analysis up to June 30

Vol Smile Visualization

Head to scripts/smiles.ipynb. Remember to replace aevo_api_url with the actual endpoint.

Vol Smile

Contact

Twitter @0xJChen