Skip to content

Commit

Permalink
removed copy operation from add_liquidity
Browse files Browse the repository at this point in the history
  • Loading branch information
jepidoptera committed Jul 3, 2023
1 parent fadb8ca commit a61002f
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions hydradx/model/amm/global_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ def swap(


def add_liquidity(
old_state: GlobalState,
state: GlobalState,
pool_id: str,
agent_id: str,
quantity: float,
Expand All @@ -363,20 +363,19 @@ def add_liquidity(
"""
copy state, execute add liquidity
"""
new_state = old_state.copy()
# add liquidity to sub_pools through main pool
if pool_id not in new_state.pools:
for pool in new_state.pools.values():
if pool_id not in state.pools:
for pool in state.pools.values():
if hasattr(pool, 'sub_pools') and pool_id in pool.sub_pools:
pool_id = pool.unique_id

new_state.pools[pool_id].execute_add_liquidity(
state=new_state.pools[pool_id],
agent=new_state.agents[agent_id],
state.pools[pool_id].execute_add_liquidity(
state=state.pools[pool_id],
agent=state.agents[agent_id],
quantity=quantity,
tkn_add=tkn_add
)
return new_state
return state


def remove_liquidity(
Expand Down

0 comments on commit a61002f

Please sign in to comment.