Skip to content

Commit

Permalink
Fixed bug in Omnipool arbitrager (#145)
Browse files Browse the repository at this point in the history
* Fixed bug in Omnipool arbitrager

* Removed upper bound that does not exist in implementation
  • Loading branch information
poliwop committed Jul 14, 2023
1 parent acbd1dc commit f81aa59
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 5 deletions.
4 changes: 0 additions & 4 deletions hydradx/model/amm/omnipool_amm.py
Original file line number Diff line number Diff line change
Expand Up @@ -923,10 +923,6 @@ def execute_add_liquidity(
if (state.total_value_locked + quantity * usd_price(state, tkn_add)) > state.tvl_cap:
return state.fail_transaction('Transaction rejected because it would exceed the TVL cap.', agent)

if (state.liquidity[tkn_add] + quantity) > 10 ** 12:
# TODO: this may not actually exist as part of the protocol
return state.fail_transaction('Asset liquidity cannot exceed 10 ^ 12.', agent)

# assert quantity > 0, f"delta_R must be positive: {quantity}"
if tkn_add not in state.asset_list:
for sub_pool in state.sub_pools.values():
Expand Down
3 changes: 2 additions & 1 deletion hydradx/model/amm/trade_strategies.py
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,8 @@ def strategy(state: GlobalState, agent_id: str) -> GlobalState:
if delta_Qi > 0:
dr[i] = r[asset] * delta_Qi / (q[asset] + delta_Qi) * (1 - asset_fees[i])
else:
dr[i] = r[asset] * delta_Qi / (q[asset] + delta_Qi) / (1 - lrna_fees[i])
delta_Qi_fee_adj = delta_Qi / (1 - lrna_fees[i])
dr[i] = r[asset] * delta_Qi_fee_adj / (q[asset] + delta_Qi_fee_adj)
profit = sum([dr[i] * prices[i] for i in range(len(prices))])
if profit < 0:
if j > 0:
Expand Down

0 comments on commit f81aa59

Please sign in to comment.