Skip to content

xenophonlabs/dydx-trader-rewards

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

dydx-trader-rewards

Reward Optimization Code for dYdX

This repository contains all the code used for our review of the dYdX trading rewards mechanism. All plots are generated by running the analysis.py file, and are saved in the images directory. All notebooks provide examples of how to use utils.py. Historical data is gathered in historical_data.ipynb. Below is a description of how to use the code provided in utils.py.

Most functions in utils.py have two versions, one which acounts to stakedDYDX and one that does not.

Newton's Method

To simulate a trading rewards epoch use the find_equilibrium(...) function with appropriate parameters. This function uses Newton's method to update a fees vector F until it converges to a Nash equilibrium. A brief description of parameters follows:

  • D is the total average open interest at the end of the epoch.
  • n is the total number of traders eligible for rewards.
  • R is the total rewards to be disbursed at the end of the epoch.
  • p is the price of DYDX token at the end of the epoch.
  • alpha is the learning rate which must be sufficiently small to ensure convergence.
  • num_whales is the number of market whales to generate.
  • whale_alpha is the weight for each whale in the Dirichlet probability density function.

To simulate the Nash equilibrium fee vector for epoch 3, for example, we would run the following.

find_equilibrium(
    D=1000000000,
    R=3835616,
    n=8502,
    p=5.50, 
    alpha=0.01, 
    num_whales=10,
    whale_alpha=200
)

For users to optimize their own trading rewards, they can use the run.py script as follows (for mac/linux).

$ bash build.sh
$ source venv/bin/activate
$ python3 trading_mechanisms/run.py -D 1000000000 -p 5.5 -n 100 -d 100_000

Users can change the parameters to reflect their own account open interest through the -d argument.

About

Reward Optimization Code for dYdX

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published