Skip to content

Commit

Permalink
Lp extension (#192)
Browse files Browse the repository at this point in the history
* initial changes

* WIP, reimplementing multiple LP positions in same asset to use agent.nfts

* WIP, reimplementing multiple LP positions in same asset to use agent.nfts

* Fixed dca_with_lping strategy to take advantage of new LPing features

* Fixed test_compare_several_lp_adds_to_single

* Fixed remove_liquidity handling of removing all liquidity when quantity is not specified

* Extended simulate_remove_liquidity
Added basic test for remove_liquidity at exact added price

* Extended exact test for remove liquidity

* Added test to compare basic case with case where shares are in holdings

* Added test to compare basic usage when quantity is unspecified

* Added test to compare base case to case where both quantity and nft_id are unspecified

* Removed outdated test

* reverted change

* Added logic to pull tkn_remove from nft in remove_liquidity if necessary

* Fixed some tests

* removed commented out test

* Removed commented out function

* Removed commented out function

* Removed old test

* Formatting

* Optimized cash_out

* Added test_cash_out_omnipool_exact

* add test_cash_out_multiple_positions

* Allowing LRNA price in cash_out_omnipool. Fixed test_cash_out_multiple_positions

* fixed liquidation test

* fixed stableswap test

* Removed unused function

* Fixed calculate_remove_liquidity so it always returns nft_ids

---------

Co-authored-by: jepidoptera <jepidoptera@live.com>
  • Loading branch information
poliwop and jepidoptera authored Sep 23, 2024
1 parent 2aa38ac commit da94618
Show file tree
Hide file tree
Showing 8 changed files with 780 additions and 176 deletions.
7 changes: 5 additions & 2 deletions hydradx/model/amm/agents.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ def __init__(self,
share_prices: dict[str: float] = None,
delta_r: dict[str: float] = None,
trade_strategy: any = None,
unique_id: str = 'agent'
unique_id: str = 'agent',
nfts: dict[str: any] = None,
):
"""
holdings should be in the form of:
Expand All @@ -29,6 +30,7 @@ def __init__(self,
self.trade_strategy = trade_strategy
self.asset_list = list(self.holdings.keys())
self.unique_id = unique_id
self.nfts = nfts or {}

def __repr__(self):
precision = 10
Expand All @@ -52,7 +54,8 @@ def copy(self):
share_prices={k: v for k, v in self.share_prices.items()},
delta_r={k: v for k, v in self.delta_r.items()},
trade_strategy=self.trade_strategy,
unique_id=self.unique_id
unique_id=self.unique_id,
nfts={id: copy.deepcopy(nft) for id, nft in self.nfts.items()}
)
copy_self.initial_holdings = {k: v for k, v in self.initial_holdings.items()}
copy_self.asset_list = [tkn for tkn in self.asset_list]
Expand Down
Loading

0 comments on commit da94618

Please sign in to comment.