This repository contains the paper and replication code for Funding Timing and No-Arbitrage Bounds in Decentralized Perpetual Markets.
The paper studies when no-arbitrage restrictions for decentralized perpetual futures have empirical content. The central mechanism is the timing of funding determination: Drift is the observable-funding case, where the next funding transfer is known at entry, while dYdX v4 is the forward-looking-funding case, where only an entry-time guaranteed cap or floor can enter the arbitrage bound.
defi-perps/
├── paper/
│ ├── main.tex # source of truth for the paper
│ └── figures/ # figures included by main.tex
├── drift/
│ ├── collection/ # Drift public archive fetchers
│ └── analysis/ # Drift notebooks, robustness scripts, outputs
├── dydx/
│ ├── collection/ # dYdX public indexer fetchers
│ └── analysis/ # dYdX notebook, cap robustness script, outputs
├── analysis/
│ └── verify_intro_stats.py # checks introduction volume statistics
├── notes/
│ └── table_figure_manifest.md # source map for tables and figures
├── Makefile
├── requirements.txt
└── README.md
Raw data files, LaTeX build artifacts, virtual environments, and local machine files are intentionally not tracked.
Install Python dependencies:
python3.11 -m venv venv
source venv/bin/activate
pip install -r requirements.txtCompile the paper from the project root:
make paperThis runs latexmk inside paper/ and builds paper/main.pdf.
The Drift analysis uses public Drift S3 archive records.
- Markets:
BTC-PERP,ETH-PERP,SOL-PERP - Sample window: 2023-01-01 through 2024-12-31
- Frequency: hourly funding records
- Main fields:
markPriceTwap,oraclePriceTwap,fundingRate,fundingRateLong,fundingRateShort, and timestamp
Fetch Drift funding records:
python drift/collection/fetch_funding_records.pyFetch Drift trade records used for cumulative volume checks:
python drift/collection/fetch_trade_volumes.pyThe dYdX analysis uses the public dYdX v4 indexer.
- Markets:
BTC-USD,ETH-USD,SOL-USD - Sample window: 2023-10-26 UTC through 2025-12-30
- Frequency: hourly funding updates
- Funding endpoint:
/v4/historicalFunding/{ticker} - Candle endpoint:
/v4/candles/perpetualMarkets/{ticker} - Market-parameter endpoint:
/v4/perpetualMarkets
Fetch dYdX funding, candle, and market-parameter data:
python dydx/collection/dydx_fetch_funding_records.py --out-dir ./data/raw/dydxRaw data are not redistributed with the repository because they are large and reconstructible from public protocol or indexer sources.
The deterministic theorem is implemented statistically using
high-probability empirical bands. The residual basis parameter
\hat{\Gamma} is calibrated as a 99th percentile on a training window
and then held fixed for out-of-sample evaluation.
| Protocol | Training window | Test window | Main empirical object |
|---|---|---|---|
| Drift | 2023 | 2024 | Out-of-band exits from high-probability empirical bands |
| dYdX | 2023-10-26 to 2024-12-31 | 2025 | Clamped-regime coverage and cap proximity |
For Drift, the empirical ratio is markPriceTwap / oraclePriceTwap.
The implementation sets the oracle TWAP ratio rho_k to 1 because the
public Drift archive used here does not expose a synchronous
instantaneous oracle price for each funding record.
For dYdX, the analysis treats historicalFunding records as hourly
funding updates. The protocol cap is specified as an 8-hour-normalized
quantity, with hourly cap eta_1h = eta_8h / 8.
Rebuild the Drift analysis:
jupyter nbconvert --execute drift/analysis/test1_bounds.ipynb --to notebook --inplace
python drift/analysis/robustness_checks.pyRebuild the dYdX analysis:
jupyter nbconvert --execute dydx/analysis/dydx_test1_bounds.ipynb --to notebook --inplace
python dydx/analysis/cap_robustness.pyThe table and figure source map is in
notes/table_figure_manifest.md. It lists the script, input data,
sample window, and output file for each empirical table and figure in
the paper.
Some small generated CSV tables are tracked because they are directly used for appendix robustness checks. Large raw datasets are ignored and should be regenerated from the public sources above.
The main Drift test window contains 8,774 BTC observations, 8,773 ETH
observations, and 8,773 SOL observations. With the baseline 99th
percentile \hat{\Gamma} calibration, the out-of-band rates are:
| Market | Out-of-band rate |
|---|---|
| BTC-PERP | 4.55% |
| ETH-PERP | 3.21% |
| SOL-PERP | 5.02% |
The dYdX sample contains 57,330 hourly funding records across the three markets. In the 2025 test window, the funding cap never binds. Maximum absolute hourly funding reaches 8.96% of cap for BTC-USD, 3.62% for ETH-USD, and 2.27% for SOL-USD. The cap-tightening robustness script shows that even a tenfold tightening leaves zero clamped observations in the test window.
The current paper source is paper/main.tex. Generated LaTeX files,
including paper/main.pdf, are build artifacts and are not tracked.
Use:
make paperto rebuild the PDF after editing the paper.
If you use this repository, please cite the working paper:
Erez, E. and Smirnov, M. Funding Timing and No-Arbitrage Bounds in
Decentralized Perpetual Markets.