UniswapV3
You can import the UniswapV3 environment by running:
from dojo.environments import UniswapV3Env
from dojo.market_agents.uniswapV3 import HistoricReplayAgent
It is recommended to read the UniswapV3 docs if the concept of an automated market maker or concentrated liquidity is unclear.
Supported Pools
At the moment, we natively have data for the following pools:
Chains | Backend Types | Pools | Start Date |
---|---|---|---|
Ethereum Mainnet - ethereum | forked , local | DAI/FRAX-0.05 | 2021-04-24 01:40:00 UTC |
DAI/USDC-0.01 | 2021-11-13 02:50:00 UTC | ||
DAI/USDC-0.05 | 2021-05-04 20:00:00 UTC | ||
DAI/WETH-0.3 | 2021-05-04 20:20:00 UTC | ||
DUSK/USDT-0.3 | 2021-05-06 10:30:00 UTC | ||
FRAX/USDC-0.05 | 2021-04-24 01:40:00 UTC | ||
LDO/WETH-0.3 | 2021-04-24 01:40:00 UTC | ||
LDO/WETH-1 | 2021-04-24 01:40:00 UTC | ||
MATIC/WETH-0.3 | 2021-05-05 20:40:00 UTC | ||
PEPE/USDC-1 | 2021-04-24 01:40:00 UTC | ||
PEPE/WETH-1 | 2021-04-24 01:40:00 UTC | ||
PRO/WETH-0.01 | 2021-08-15 20:20:00 UTC | ||
SHIB/WETH-0.3 | 2021-04-24 01:40:00 UTC | ||
SAFE/WETH-0.1 | 2022-09-28 11:58:00 UTC | ||
SHIB/WETH-1 | 2021-04-24 01:40:00 UTC | ||
SKL/WETH-0.01 | 2021-11-17 14:00:00 UTC | ||
UNI/WETH-0.3 | 2021-05-04 20:00:00 UTC | ||
USDC/USDT-0.01 | 2021-11-13 17:50:00 UTC | ||
USDC/USDT-0.05 | 2021-05-04 20:20:00 UTC | ||
USDC/WETH-0.05 | 2021-05-05 21:50:00 UTC | ||
USDC/WETH-0.3 | 2021-05-04 23:10:00 UTC | ||
WBTC/USDC-0.3 | 2021-05-05 19:20:00 UTC | ||
WBTC/WETH-0.01 | 2021-05-04 20:00:00 UTC | ||
WBTC/WETH-0.05 | 2021-05-05 20:30:00 UTC | ||
WBTC/WETH-0.3 | 2021-05-04 20:10:00 UTC | ||
WETH/USDT-0.3 | 2021-05-05 16:40:00 UTC | ||
1INCH/UNI-1.0 | 2024-08-02 08:05:00 UTC | ||
UNI/AAVE-0.3 | 2021-05-25 14:15:00 UTC | ||
UNI/ETH-0.05 | 2021-05-05 19:35:00 UTC | ||
UNI/ETH-1.0 | 2021-05-05 20:05:00 UTC | ||
UNI/LINK-0.3 | 2021-05-06 05:20:00 UTC | ||
UNI/USDC-0.03 | 2021-05-06 03:55:00 UTC | ||
UNI/USDT-0.3 | 2021-05-06 05:20:00 UTC | ||
UNI/USDT-1.0 | 2023-03-27 08:50:00 UTC | ||
UNI/WBTC-0.3 | 2021-05-07 10:15:00 UTC | ||
Arbitrum L2 - arbitrum | forked , local | ARB-USDC-0.05 | 2023-03-20 19:40:12 UTC |
ARB/WETH-0.05 | 2023-03-17 01:50:00 UTC | ||
ARB/WETH-0.3 | 2023-03-17 01:50:00 UTC | ||
CRYPTO/WETH-1.0 | 2022-09-10 06:00:15 UTC | ||
GMX/WETH-0.3 | 2021-09-15 02:57:00 UTC | ||
GMX/WETH-1.0 | 2021-08-31 12:07:19 UTC | ||
PENDLE/WETH-0.3 | 2023-03-08 09:20:00 UTC | ||
USDC/ARB-0.05 | 2023-03-20 19:40:12 UTC | ||
USDC/WETH-0.05 | 2023-06-08 21:28:30 UTC | ||
USDC/WETH-0.3 | 2021-06-17 17:19:10 UTC | ||
USDT/DAI-0.01 | 2023-02-27 20:16:00 UTC | ||
USDT/WETH-0.05 | 2021-09-07 01:05:00 UTC | ||
WBTC/WETH-0.05 | 2021-09-12 11:51:00 UTC | ||
WBTC/WETH-0.3 | 2021-06-23 22:03:00 UTC | ||
DAI/UNI-0.05 | 2021-10-03 03:10:00 UTC | ||
DAI/UNI-0.3 | 2022-09-24 22:00:00 UTC | ||
ETH/UNI-0.01 | 2023-07-29 10:55:00 UTC | ||
ETH/UNI-0.05 | 2021-09-12 11:45:00 UTC | ||
ETH/UNI-0.3 | 2021-08-31 22:50:00 UTC | ||
ETH/UNI-1.0 | 2021-09-11 11:55:00 UTC | ||
UNI/USDC.e-0.3 | 2021-09-07 18:10:00 UTC | ||
UNI/USDT-0.05 | 2022-05-08 07:40:00 UTC | ||
UNI/USDT-0.3 | 2021-09-20 23:10:00 UTC | ||
UNI/USDT-1.0 | 2021-09-11 08:05:00 UTC | ||
Gnosis Chain - gnosis | forked , local | WETH/WXDAI-0.05 | 2024-09-06 15:35:20 UTC |
WETH/USDC-0.05 | 2024-09-06 15:41:45 UTC | ||
USDT/USDC-0.01 | 2024-09-06 15:39:50 UTC | ||
USDC/WXDAI-0.01 | 2024-09-06 15:38:00 UTC | ||
WETH/SDAI-0.05 | 2024-05-21 17:16:30 UTC | ||
USDC/WXDAI-0.3 | 2024-08-30 20:45:25 UTC |
If you want to do a simulation on a pool that is not included here, please contact us. We can add other pools fairly quickly.
Observations
An observation refers to the information that the agent receives from the environment at every block. Think of the current price, or the liquidity in the pool.
The methods within UniswapV3Observation
can be found here.
Actions
Actions are the means through which the agent interacts with the environment to achieve goals.
In general, there are 5 actions you can perform on the Uniswap V3 environment:
- TRADE: trading one token for another token, without changing your invested liquidity.
- QUOTE: either providing or taking liquidity out of the pool.
- COLLECT: collect LP fees from an LP position.
- BURN: close an empty LP position.
- SET FEE PROTOCOL: set the protocol fee of a pool.
Please refer to the code reference for more details.
Example
"""Execute an action on Uniswap."""
import os
import sys
from decimal import Decimal
from agents.uniswapV3_pool_wealth import UniswapV3PoolWealthAgent
from dojo.actions.uniswapV3 import UniswapV3Trade
from dojo.common import time_to_block
from dojo.common.constants import Chain
from dojo.environments.uniswapV3 import UniswapV3Env
current = os.path.dirname(os.path.realpath(__file__))
parent = os.path.dirname(current)
sys.path.append(parent)
pools = ["USDC/WETH-0.3"]
sim_start = "2021-06-21 00:00:00"
sim_end = "2021-06-21 00:10:00"
agent = UniswapV3PoolWealthAgent(initial_portfolio={"USDC": Decimal(10_000)})
chain = Chain.ETHEREUM
env = UniswapV3Env(
agents=[agent], # Of course, you'd want an agent here to actually do things
chain=chain,
block_range=(
time_to_block(sim_start, chain),
time_to_block(sim_end, chain),
),
pools=pools,
backend_type="forked",
)
action = UniswapV3Trade(
agent=agent,
pool=env.obs.pools[0],
quantities=(Decimal("0.1"), Decimal("0")),
)
env.step(actions=[action])