Granting too much fees when opening up multiple high liquidity positions
mbartn opened this issue · comments
The function demeter.uniswap.market.UniLpMarket.__update_fee
updates LP fees for each position opened.
However, if position_liquidity > pool_liquidity
, the position's share is 1
so it receives all the fees generated by the pool in the current timestamp_index
. This leads to a bug where for n
positions opened, broker earns n * all_fees_generated_in_current_timestamp_index
I think when calculating share, liquidity of all brokker's positions should be considered as well
demeter/demeter/uniswap/core.py
Lines 92 to 96 in b91c228
I think it is caused by its assumption. During backtesting, your liquidity will not add to the market's total liquidity. "If" of Share calculation is defensive code.
We will take your case into consideration, and maybe fix it in the next version. Or, you can help us fix it, and make a PR.
This bug has fixed and will be available in next release.