Closed wwklsq closed 1 year ago
New version released, some more changes include:
Still looking into the final edge case, will update with progress :)
Hi @09tangriro,
Testing with latest version of dojo, I had follow-up questions:
local
backend mode only or also for anvil
mode? I´m testing the edge case with different result between chain data and dojo from previous commit, weird though, previously I can run this position with anvil
backend, now it yields STF
error, probably because it has more data now it leads to overflow in whale account?live
backend type for? Should we switch to that to get new data, or it´s more likely for live trading purpose.So we really only recommend using the forked backend for testing your code for bugs, the local backend should guarantee zero STF errors. If you want to continue using the forked backed, you can try to fund the market agent even more but you'll need to find the relevant whale accounts for that time period: env.agents[0].fund_erc20("USDC", your_whale_account, Decimal(large_number))
, you'll likely need to write your own loop though as well:
agent = YourAgent()
policy = YourPolicy(agent)
env = UniV3Env(...)
obs = env.reset()
for block in env.iter_block():
agent_actions = policy.predict(obs)
market_actions = env.market_actions(agents_actions=agent_actions)
actions = agent_actions + market_actions
_, rewards, _, _ = env.step(actions)
live
backend isn't quite an execution envrionment, for now it just allows you to query the observation signals in real time, for example to see what actions your policy will generate to new data.We've also found a speed improvement 🎉 The first edge case (STF) in the list now runs successfully for me in 282s (not yet in release).
Hi @09tangriro,
Thanks for the quick update, I switch now to local
backend type.
dashboard_port
and auto_close
, as both would lead to a crashdown of my working container. Reasons for that are still unclear, as monitoring memory usage and logging didn´t allude any useful information. Presumably working in container is not default/recommended set-up for dojo. I´m working with a handcrafted port-closing function & mem cleaning procedure.[{'start_time': Timestamp('2023-08-17 07:43:00+0000', tz='UTC'),
'end_time': Timestamp('2023-08-18 10:34:00+0000', tz='UTC'),
'deposit_token0': 574.861008,
'deposit_token1': 574.861008,
'lower_price': 0.0005261,
'upper_price': 0.00058962,
'token0': 'USDC',
'token1': 'WETH',
'fee_tier': 3000,
'dojo_fees_collected_token0': '2.804471',
'real_fees_collected_token0': 0.581423,
'dojo_fees_collected_token1': '0.001909294938952954',
'real_fees_collected_token1': 0.0013293,
'pool_desc': 'USDC/WETH-0.3',
'position_nft': 'https://revert.finance/#/uniswap-position/mainnet/551745'},
{'start_time': Timestamp('2023-04-02 20:13:00+0000', tz='UTC'),
'end_time': Timestamp('2023-04-04 12:13:00+0000', tz='UTC'),
'deposit_token0': 39539.1375,
'deposit_token1': 39539.1375,
'lower_price': 0.00053565,
'upper_price': 0.00058962,
'token0': 'USDC',
'token1': 'WETH',
'fee_tier': 3000,
'dojo_fees_collected_token0': '304.511513',
'real_fees_collected_token0': 152.703298,
'dojo_fees_collected_token1': '0.104557025810633318',
'real_fees_collected_token1': 0.05234959,
'pool_desc': 'USDC/WETH-0.3',
'position_nft': 'https://revert.finance/#/uniswap-position/mainnet/481049'},
{'start_time': Timestamp('2023-09-15 00:26:00+0000', tz='UTC'),
'end_time': Timestamp('2023-09-16 01:34:00+0000', tz='UTC'),
'deposit_token0': 71236.007076,
'deposit_token1': 71236.007076,
'lower_price': 0.00061491,
'upper_price': 0.00062608,
'token0': 'USDC',
'token1': 'WETH',
'fee_tier': 500,
'dojo_fees_collected_token0': '180.910437',
'real_fees_collected_token0': 97.614772,
'dojo_fees_collected_token1': '0.116631441591324158',
'real_fees_collected_token1': 0.05905205,
'pool_desc': 'USDC/WETH-0.05',
'position_nft': 'https://revert.finance/#/uniswap-position/mainnet/564394'},
{'start_time': Timestamp('2023-09-18 13:20:00+0000', tz='UTC'),
'end_time': Timestamp('2023-09-19 15:02:00+0000', tz='UTC'),
'deposit_token0': 2653.713952,
'deposit_token1': 2653.713952,
'lower_price': 0.00057506,
'upper_price': 0.00060576,
'token0': 'USDC',
'token1': 'WETH',
'fee_tier': 500,
'dojo_fees_collected_token0': '16.987608',
'real_fees_collected_token0': 7.21048,
'dojo_fees_collected_token1': '0.010694034637289168',
'real_fees_collected_token1': 0.00515498,
'pool_desc': 'USDC/WETH-0.05',
'position_nft': 'https://revert.finance/#/uniswap-position/mainnet/565818'},
{'start_time': Timestamp('2023-09-14 23:57:00+0000', tz='UTC'),
'end_time': Timestamp('2023-09-16 06:53:00+0000', tz='UTC'),
'deposit_token0': 21032.118402,
'deposit_token1': 21032.118402,
'lower_price': 0.00060274,
'upper_price': 0.00061491,
'token0': 'USDC',
'token1': 'WETH',
'fee_tier': 500,
'dojo_fees_collected_token0': '941.429875',
'real_fees_collected_token0': 4282.51329,
'dojo_fees_collected_token1': '0.584749281867812615',
'real_fees_collected_token1': 2.44181838,
'pool_desc': 'USDC/WETH-0.05',
'position_nft': '[https://revert.finance/#/unis](https://revert.finance/#/uniswap-position/mainnet/564389)
{'start_time': Timestamp('2023-09-11 12:17:00+0000', tz='UTC'),
'end_time': Timestamp('2023-09-12 21:49:00+0000', tz='UTC'),
'deposit_token0': 10153.796168,
'deposit_token1': 10153.796168,
'lower_price': 0.00062859,
'upper_price': 0.00072958,
'token0': 'USDC',
'token1': 'WETH',
'fee_tier': 500,
'dojo_fees_collected_token0': '1.013681',
'real_fees_collected_token0': 20.268507,
'dojo_fees_collected_token1': '0.000594838674044158',
'real_fees_collected_token1': 0.01295848,
'pool_desc': 'USDC/WETH-0.05',
'position_nft': 'https://revert.finance/#/uniswap-position/mainnet/562977'},
{'start_time': Timestamp('2023-09-27 11:37:00+0000', tz='UTC'),
'end_time': Timestamp('2023-09-28 21:40:00+0000', tz='UTC'),
'deposit_token0': 9266.97624,
'deposit_token1': 9266.97624,
'lower_price': 0.00061001,
'upper_price': 0.00062047,
'token0': 'USDC',
'token1': 'WETH',
'fee_tier': 500,
'dojo_fees_collected_token0': '83.143482',
'real_fees_collected_token0': 53.968819,
'dojo_fees_collected_token1': '0.050544862935275553',
'real_fees_collected_token1': 0.03040056,
'pool_desc': 'USDC/WETH-0.05',
'position_nft': 'https://revert.finance/#/uniswap-position/mainnet/570290'},
{'start_time': Timestamp('2023-09-06 06:10:00+0000', tz='UTC'),
'end_time': Timestamp('2023-09-07 18:05:00+0000', tz='UTC'),
'deposit_token0': 45300.0,
'deposit_token1': 45300.0,
'lower_price': 0.00058844,
'upper_price': 0.00061491,
'token0': 'USDC',
'token1': 'WETH',
'fee_tier': 500,
'dojo_fees_collected_token0': '1012.024289',
'real_fees_collected_token0': 2575.259249,
'dojo_fees_collected_token1': '0.633466098131261847',
'real_fees_collected_token1': 1.4826215,
'pool_desc': 'USDC/WETH-0.05',
'position_nft': 'https://revert.finance/#/uniswap-position/mainnet/560570'},
{'start_time': Timestamp('2023-09-10 18:06:00+0000', tz='UTC'),
'end_time': Timestamp('2023-09-12 09:49:00+0000', tz='UTC'),
'deposit_token0': 2040.61717,
'deposit_token1': 2040.61717,
'lower_price': 0.00061062,
'upper_price': 0.00062922,
'token0': 'USDC',
'token1': 'WETH',
'fee_tier': 500,
'dojo_fees_collected_token0': '24.323339',
'real_fees_collected_token0': 7.348751,
'dojo_fees_collected_token1': '0.014223481288578276',
'real_fees_collected_token1': 0.00521725,
'pool_desc': 'USDC/WETH-0.05',
'position_nft': 'https://revert.finance/#/uniswap-position/mainnet/562571'}]
Cool, we'll have a look :)
Interesting, so the forked backend recovers the true result:
https://revert.finance/#/uniswap-position/mainnet/551745
But the local backend gives incorrect fees as you mention. I'll continue debugging it but in the meantime, for these smaller simulation lengths, the forked backend should suffice.
Just noticed, the deposit_token1
is identical to deposit_token0
in my previous commit. It´s a typo. U can probably find the information in the link though.
Yeah nw, I've been using the link like you said :)
So quick update, I've identified why the local backend was diverging and think I've implemented a fix, am testing now but will update here when I have it working
Ok so I think that's a confirmed fix now 🎉, will release a new version soon. This will have quite a few changes actually, the interface you will use has also changes so you use UniV3Trade
, UniV3Quote
etc. rather than UniV3Action
, which I hope is a bit more intuitive. I'll do the release soon but updating the docs at dojo.compasslabs.ai might take a bit longer.
Ok so I think that's a confirmed fix now 🎉, will release a new version soon. This will have quite a few changes actually, the interface you will use has also changes so you use
UniV3Trade
,UniV3Quote
etc. rather thanUniV3Action
, which I hope is a bit more intuitive. I'll do the release soon but updating the docs at dojo.compasslabs.ai might take a bit longer.
Hi @09tangriro , thanks for the quick fix. Can I assume that dojo has now fixed all the problematic positions that I listed above, so the result from dojo in local
mode now matches exactly with the groundtruth from revert?
I believe so, just did a release now, you'll need to edit your code slightly to use the new format for actions though (https://readthedocs.compasslabs.ai/dojo.actions.html#dojo.actions.uniswapV3.UniV3Quote)
Thanks for giving dojo a try, closing the issue now :)
Hi Team dojo,
I am a beginner with dojo package and struggled a little bit with creating an example script using dojo to provide liquidity and inspect the fees earned in a backtesting manner. So far, I have set up the environment and successfully executed
run.py
both in notebook as well as in script. Here are the problems I faced today:Documentation link is broken on tutorial page under
code refererence
, I believe the link is outdated, this link might be the official docs for dojo.Failed to use USDC/ETH 0.05% pool (stated here to be supported) to create trade simulation, got key Error from error message.
The minimal viable strategy I wanted to create(cloned and modified from PassiveLP) is to use pool e.g. USDC/WETH 0.3% to mint a position and we should be able to check the uncollected fees in nft position at the end of simulation. Following code snippet explains my idea also the puzzling parts in comment after inspection of docs.
Last but not least, in which unit is
rewards
defined? I assume, it´s in USDC forrun.py
case. Do we have a lookup table of definition for other cases? Btw, When I ran therun.py
in notebook and plotted the reward results, there´s a big plummet in one block, which looks not close to the result from homepage. Although the time span was different, it also didn´t match any pattern from chart below.Thanks for the great work in general, I hope I can get supports for questions above and more examples from compass labs side regarding this project.
Best regards, Wwk