wayfinder-paths 0.1.8__py3-none-any.whl → 0.1.9__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of wayfinder-paths might be problematic. Click here for more details.

Files changed (47) hide show
  1. wayfinder_paths/CONFIG_GUIDE.md +5 -14
  2. wayfinder_paths/adapters/brap_adapter/README.md +1 -1
  3. wayfinder_paths/adapters/brap_adapter/adapter.py +0 -51
  4. wayfinder_paths/adapters/hyperlend_adapter/adapter.py +0 -7
  5. wayfinder_paths/adapters/hyperliquid_adapter/adapter.py +0 -54
  6. wayfinder_paths/adapters/hyperliquid_adapter/test_adapter_live.py +1 -1
  7. wayfinder_paths/adapters/ledger_adapter/README.md +1 -1
  8. wayfinder_paths/adapters/pool_adapter/README.md +1 -77
  9. wayfinder_paths/adapters/pool_adapter/adapter.py +0 -122
  10. wayfinder_paths/adapters/pool_adapter/examples.json +0 -57
  11. wayfinder_paths/adapters/pool_adapter/test_adapter.py +0 -86
  12. wayfinder_paths/adapters/token_adapter/README.md +1 -1
  13. wayfinder_paths/core/clients/AuthClient.py +0 -3
  14. wayfinder_paths/core/clients/ClientManager.py +1 -22
  15. wayfinder_paths/core/clients/WalletClient.py +0 -8
  16. wayfinder_paths/core/clients/WayfinderClient.py +9 -14
  17. wayfinder_paths/core/clients/__init__.py +0 -8
  18. wayfinder_paths/core/clients/protocols.py +0 -60
  19. wayfinder_paths/core/config.py +5 -45
  20. wayfinder_paths/core/engine/StrategyJob.py +0 -3
  21. wayfinder_paths/core/services/base.py +0 -49
  22. wayfinder_paths/core/services/local_evm_txn.py +3 -82
  23. wayfinder_paths/core/services/local_token_txn.py +61 -70
  24. wayfinder_paths/core/services/web3_service.py +0 -2
  25. wayfinder_paths/core/settings.py +8 -8
  26. wayfinder_paths/core/strategies/Strategy.py +1 -5
  27. wayfinder_paths/core/utils/evm_helpers.py +7 -12
  28. wayfinder_paths/core/wallets/README.md +3 -6
  29. wayfinder_paths/run_strategy.py +29 -32
  30. wayfinder_paths/scripts/make_wallets.py +1 -25
  31. wayfinder_paths/scripts/run_strategy.py +0 -2
  32. wayfinder_paths/strategies/basis_trading_strategy/snapshot_mixin.py +1 -3
  33. wayfinder_paths/strategies/basis_trading_strategy/strategy.py +86 -137
  34. wayfinder_paths/strategies/basis_trading_strategy/test_strategy.py +96 -58
  35. wayfinder_paths/strategies/hyperlend_stable_yield_strategy/README.md +2 -2
  36. wayfinder_paths/strategies/hyperlend_stable_yield_strategy/examples.json +4 -1
  37. wayfinder_paths/strategies/hyperlend_stable_yield_strategy/strategy.py +106 -28
  38. wayfinder_paths/strategies/hyperlend_stable_yield_strategy/test_strategy.py +53 -14
  39. wayfinder_paths/strategies/stablecoin_yield_strategy/strategy.py +1 -6
  40. wayfinder_paths/strategies/stablecoin_yield_strategy/test_strategy.py +0 -4
  41. wayfinder_paths/templates/strategy/test_strategy.py +0 -4
  42. {wayfinder_paths-0.1.8.dist-info → wayfinder_paths-0.1.9.dist-info}/METADATA +5 -15
  43. {wayfinder_paths-0.1.8.dist-info → wayfinder_paths-0.1.9.dist-info}/RECORD +45 -47
  44. wayfinder_paths/core/clients/SimulationClient.py +0 -192
  45. wayfinder_paths/core/clients/TransactionClient.py +0 -63
  46. {wayfinder_paths-0.1.8.dist-info → wayfinder_paths-0.1.9.dist-info}/LICENSE +0 -0
  47. {wayfinder_paths-0.1.8.dist-info → wayfinder_paths-0.1.9.dist-info}/WHEEL +0 -0
@@ -52,7 +52,6 @@ cp wayfinder_paths/config.example.json config.json
52
52
  **Option 1: Service Account (API Key) - Recommended for Production**
53
53
  - `user.api_key` - Your Wayfinder API key for service account authentication (loaded directly by clients from config.json)
54
54
  - OR `system.api_key` - System-level API key (alternative location, loaded directly by clients)
55
- - OR set `WAYFINDER_API_KEY` environment variable
56
55
  - OR pass `api_key` parameter to strategy constructor
57
56
 
58
57
  **Note:** API keys in `config.json` are loaded directly by `WayfinderClient` via `_load_config_credentials()`, not through the `UserConfig` or `SystemConfig` dataclasses. This is intentional to allow flexible credential loading.
@@ -229,7 +228,6 @@ The strategy system supports multiple wallet types through a wallet abstraction
229
228
 
230
229
  By default, adapters use `LocalWalletProvider` which resolves private keys from:
231
230
  - `wallets.json` (matched by address)
232
- - Environment variables (`PRIVATE_KEY`, `PRIVATE_KEY_STRATEGY`)
233
231
  - Wallet config in `config.json`
234
232
 
235
233
  No code changes are required - existing strategies continue to work.
@@ -270,7 +268,7 @@ Wayfinder Paths supports **dual authentication** for different use cases:
270
268
 
271
269
  **Best for:** Backend services, automated systems, and production deployments with higher rate limits.
272
270
 
273
- API keys provide service account authentication and are automatically discovered by all clients. You can provide an API key in three ways:
271
+ API keys provide service account authentication and are automatically discovered by all clients. You can provide an API key in two ways:
274
272
 
275
273
  #### Option A: Strategy Constructor (Programmatic)
276
274
  ```python
@@ -278,16 +276,11 @@ from wayfinder_paths.strategies.stablecoin_yield_strategy.strategy import Stable
278
276
 
279
277
  strategy = StablecoinYieldStrategy(
280
278
  config={...},
281
- api_key="sk_live_abc123..." # Sets WAYFINDER_API_KEY env var automatically
279
+ api_key="sk_live_abc123..." # API key is auto-discovered by all clients
282
280
  )
283
281
  ```
284
282
 
285
- #### Option B: Environment Variable
286
- ```bash
287
- export WAYFINDER_API_KEY="sk_live_abc123..."
288
- ```
289
-
290
- #### Option C: config.json
283
+ #### Option B: config.json
291
284
  ```json
292
285
  {
293
286
  "user": {
@@ -299,14 +292,12 @@ export WAYFINDER_API_KEY="sk_live_abc123..."
299
292
  }
300
293
  ```
301
294
 
302
- **Priority Order:** Constructor parameter > `config.json` (user.api_key or system.api_key) > `WAYFINDER_API_KEY` environment variable
295
+ **Priority Order:** Constructor parameter > `config.json` (user.api_key or system.api_key)
303
296
 
304
297
  **How It Works:**
305
- - When a strategy receives an `api_key`, it sets `os.environ["WAYFINDER_API_KEY"]`
306
298
  - All clients created by adapters automatically discover the API key from:
307
299
  - Constructor parameter (if passed)
308
300
  - `config.json` (via `WayfinderClient._load_config_credentials()` which reads `user.api_key` or `system.api_key`)
309
- - `WAYFINDER_API_KEY` environment variable
310
301
  - API keys are included in **all** API requests (including public endpoints) for rate limiting
311
302
  - No need to pass API keys explicitly to adapters or clients—they auto-discover it
312
303
  - **Note:** API keys in `config.json` are loaded directly by clients, not stored in the `UserConfig` or `SystemConfig` dataclasses
@@ -379,7 +370,7 @@ To use custom RPC endpoints, update the `strategy.rpc_urls` section in `config.j
379
370
  **Issue:** "Authentication failed"
380
371
  - **If using API key:**
381
372
  - Verify API key is correct and not expired
382
- - Check that API key is set in one of: constructor parameter, `config.json` (user.api_key or system.api_key), or `WAYFINDER_API_KEY` env var
373
+ - Check that API key is set in one of: constructor parameter or `config.json` (user.api_key or system.api_key)
383
374
  - Ensure API key has proper permissions for the operations you're performing
384
375
  - **If using OAuth:**
385
376
  - Check that `username` and `password` are correct in `config.json`
@@ -17,7 +17,7 @@ The adapter uses the BRAPClient which automatically handles authentication and A
17
17
 
18
18
  The BRAPClient will automatically:
19
19
  - Use the WAYFINDER_API_URL from settings
20
- - Handle authentication via environment variables or config.json
20
+ - Handle authentication via config.json
21
21
  - Manage token refresh and retry logic
22
22
 
23
23
  ## Usage
@@ -10,10 +10,6 @@ from wayfinder_paths.core.adapters.BaseAdapter import BaseAdapter
10
10
  from wayfinder_paths.core.adapters.models import SWAP
11
11
  from wayfinder_paths.core.clients.BRAPClient import BRAPClient, BRAPQuote
12
12
  from wayfinder_paths.core.clients.LedgerClient import TransactionRecord
13
- from wayfinder_paths.core.clients.SimulationClient import (
14
- SimulationClient,
15
- SimulationResult,
16
- )
17
13
  from wayfinder_paths.core.clients.TokenClient import TokenClient
18
14
  from wayfinder_paths.core.constants import DEFAULT_SLIPPAGE
19
15
  from wayfinder_paths.core.constants.base import DEFAULT_TRANSACTION_TIMEOUT
@@ -45,7 +41,6 @@ class BRAPAdapter(BaseAdapter):
45
41
  config: dict[str, Any] | None = None,
46
42
  *,
47
43
  web3_service: Web3Service,
48
- simulation: bool = False,
49
44
  ):
50
45
  super().__init__("brap_adapter", config)
51
46
  self.brap_client = BRAPClient()
@@ -55,8 +50,6 @@ class BRAPAdapter(BaseAdapter):
55
50
  self.web3_service = web3_service
56
51
  self.wallet_provider = web3_service.evm_transactions
57
52
  self.token_transactions = web3_service.token_transactions
58
- self.simulation = simulation
59
- self.simulation_client = SimulationClient() if simulation else None
60
53
 
61
54
  async def get_swap_quote(
62
55
  self,
@@ -367,12 +360,6 @@ class BRAPAdapter(BaseAdapter):
367
360
  if not approve_success:
368
361
  return (False, approve_response)
369
362
 
370
- if self.simulation:
371
- simulation = await self._simulate_swap(
372
- from_token, to_token, from_address, chain_id, quote
373
- )
374
- return (True, {"quote": quote, "simulation": simulation})
375
-
376
363
  broadcast_success, broadcast_response = await self._broadcast_transaction(
377
364
  transaction
378
365
  )
@@ -677,44 +664,6 @@ class BRAPAdapter(BaseAdapter):
677
664
  / 10 ** int(decimals)
678
665
  )
679
666
 
680
- async def _simulate_swap(
681
- self,
682
- from_token: dict[str, Any],
683
- to_token: dict[str, Any],
684
- from_address: str,
685
- chain_id: int,
686
- quote: dict[str, Any],
687
- ) -> SimulationResult:
688
- client = await self._get_simulation_client()
689
- initial_balances = {"native": "5000000000000000000"}
690
- if from_token.get("address"):
691
- initial_balances[from_token.get("address")] = "1000000000000000000000000"
692
-
693
- slippage = quote.get("slippage") or quote.get("slippage_percent")
694
- if isinstance(slippage, str):
695
- try:
696
- slippage = float(slippage)
697
- except ValueError:
698
- slippage = DEFAULT_SLIPPAGE
699
- slippage = slippage or DEFAULT_SLIPPAGE
700
-
701
- amount = quote.get("input_amount") or quote.get("inputAmount") or "0"
702
- return await client.simulate_swap(
703
- from_token_address=from_token.get("address"),
704
- to_token_address=to_token.get("address"),
705
- from_chain_id=chain_id,
706
- to_chain_id=chain_id,
707
- amount=str(amount),
708
- from_address=from_address,
709
- slippage=float(slippage),
710
- initial_balances=initial_balances,
711
- )
712
-
713
- async def _get_simulation_client(self) -> SimulationClient:
714
- if not self.simulation_client:
715
- self.simulation_client = SimulationClient()
716
- return self.simulation_client
717
-
718
667
  def _chain_id(self, chain: Any) -> int:
719
668
  if isinstance(chain, dict):
720
669
  chain_id = chain.get("id") or chain.get("chain_id")
@@ -12,7 +12,6 @@ from wayfinder_paths.core.clients.HyperlendClient import (
12
12
  MarketEntry,
13
13
  StableMarket,
14
14
  )
15
- from wayfinder_paths.core.clients.SimulationClient import SimulationClient
16
15
  from wayfinder_paths.core.constants.base import DEFAULT_TRANSACTION_TIMEOUT
17
16
  from wayfinder_paths.core.constants.hyperlend_abi import (
18
17
  POOL_ABI,
@@ -37,16 +36,12 @@ class HyperlendAdapter(BaseAdapter):
37
36
  self,
38
37
  config: dict[str, Any],
39
38
  web3_service: Web3Service,
40
- simulation: bool = False,
41
39
  ) -> None:
42
40
  super().__init__("hyperlend_adapter", config)
43
41
  cfg = config or {}
44
42
  adapter_cfg = cfg.get("hyperlend_adapter") or {}
45
43
 
46
44
  self.hyperlend_client = HyperlendClient()
47
- self.simulation = simulation
48
- self.simulation_client = SimulationClient() if simulation else None
49
-
50
45
  self.web3 = web3_service
51
46
  self.token_txn_service = web3_service.token_transactions
52
47
 
@@ -237,8 +232,6 @@ class HyperlendAdapter(BaseAdapter):
237
232
  return await self._broadcast_transaction(approve_tx)
238
233
 
239
234
  async def _execute(self, tx: dict[str, Any]) -> tuple[bool, Any]:
240
- if self.simulation:
241
- return True, {"simulation": tx}
242
235
  return await self.web3.broadcast_transaction(
243
236
  tx, wait_for_receipt=True, timeout=DEFAULT_TRANSACTION_TIMEOUT
244
237
  )
@@ -74,7 +74,6 @@ class HyperliquidAdapter(BaseAdapter):
74
74
  self,
75
75
  config: dict[str, Any] | None = None,
76
76
  *,
77
- simulation: bool = False,
78
77
  executor: HyperliquidExecutor | None = None,
79
78
  ) -> None:
80
79
  super().__init__("hyperliquid_adapter", config)
@@ -85,7 +84,6 @@ class HyperliquidAdapter(BaseAdapter):
85
84
  "Install with: poetry add hyperliquid"
86
85
  )
87
86
 
88
- self.simulation = simulation
89
87
  self._cache = SimpleCache()
90
88
  self._executor = executor
91
89
 
@@ -481,13 +479,6 @@ class HyperliquidAdapter(BaseAdapter):
481
479
  Returns:
482
480
  (success, response_data or error_message)
483
481
  """
484
- if self.simulation:
485
- self.logger.info(
486
- f"[SIMULATION] place_market_order: asset={asset_id}, "
487
- f"is_buy={is_buy}, size={size}, address={address}"
488
- )
489
- return True, {"simulation": True, "status": "ok"}
490
-
491
482
  if not self._executor:
492
483
  raise NotImplementedError(
493
484
  "No Hyperliquid executor configured. "
@@ -525,12 +516,6 @@ class HyperliquidAdapter(BaseAdapter):
525
516
  Returns:
526
517
  (success, response_data or error_message)
527
518
  """
528
- if self.simulation:
529
- self.logger.info(
530
- f"[SIMULATION] cancel_order: asset={asset_id}, oid={order_id}"
531
- )
532
- return True, {"simulation": True, "status": "ok"}
533
-
534
519
  if not self._executor:
535
520
  raise NotImplementedError(
536
521
  "No Hyperliquid executor configured. "
@@ -565,12 +550,6 @@ class HyperliquidAdapter(BaseAdapter):
565
550
  Returns:
566
551
  (success, response_data or error_message)
567
552
  """
568
- if self.simulation:
569
- self.logger.info(
570
- f"[SIMULATION] update_leverage: asset={asset_id}, leverage={leverage}"
571
- )
572
- return True, {"simulation": True, "status": "ok"}
573
-
574
553
  if not self._executor:
575
554
  raise NotImplementedError("No Hyperliquid executor configured.")
576
555
 
@@ -590,10 +569,6 @@ class HyperliquidAdapter(BaseAdapter):
590
569
  address: str,
591
570
  ) -> tuple[bool, dict[str, Any]]:
592
571
  """Transfer USDC from spot to perp balance."""
593
- if self.simulation:
594
- self.logger.info(f"[SIMULATION] transfer_spot_to_perp: {amount} USDC")
595
- return True, {"simulation": True, "status": "ok"}
596
-
597
572
  if not self._executor:
598
573
  raise NotImplementedError("No Hyperliquid executor configured.")
599
574
 
@@ -611,10 +586,6 @@ class HyperliquidAdapter(BaseAdapter):
611
586
  address: str,
612
587
  ) -> tuple[bool, dict[str, Any]]:
613
588
  """Transfer USDC from perp to spot balance."""
614
- if self.simulation:
615
- self.logger.info(f"[SIMULATION] transfer_perp_to_spot: {amount} USDC")
616
- return True, {"simulation": True, "status": "ok"}
617
-
618
589
  if not self._executor:
619
590
  raise NotImplementedError("No Hyperliquid executor configured.")
620
591
 
@@ -647,13 +618,6 @@ class HyperliquidAdapter(BaseAdapter):
647
618
  Returns:
648
619
  (success, response_data or error_message)
649
620
  """
650
- if self.simulation:
651
- self.logger.info(
652
- f"[SIMULATION] place_stop_loss: asset={asset_id}, "
653
- f"trigger={trigger_price}, size={size}"
654
- )
655
- return True, {"simulation": True, "status": "ok"}
656
-
657
621
  if not self._executor:
658
622
  raise NotImplementedError("No Hyperliquid executor configured.")
659
623
 
@@ -758,10 +722,6 @@ class HyperliquidAdapter(BaseAdapter):
758
722
 
759
723
  Note: This is an L1 withdrawal handled by the Hyperliquid executor (signing required).
760
724
  """
761
- if self.simulation:
762
- self.logger.info(f"[SIMULATION] withdraw: {amount} USDC")
763
- return True, {"simulation": True, "status": "ok"}
764
-
765
725
  if not self._executor:
766
726
  raise NotImplementedError("No Hyperliquid executor configured.")
767
727
 
@@ -856,13 +816,6 @@ class HyperliquidAdapter(BaseAdapter):
856
816
  Returns:
857
817
  (success, response_data or error_message)
858
818
  """
859
- if self.simulation:
860
- self.logger.info(
861
- f"[SIMULATION] approve_builder_fee: builder={builder}, "
862
- f"rate={max_fee_rate}, address={address}"
863
- )
864
- return True, {"simulation": True, "status": "ok"}
865
-
866
819
  if not self._executor:
867
820
  raise NotImplementedError("No Hyperliquid executor configured.")
868
821
 
@@ -903,13 +856,6 @@ class HyperliquidAdapter(BaseAdapter):
903
856
  Returns:
904
857
  (success, response_data or error_message)
905
858
  """
906
- if self.simulation:
907
- self.logger.info(
908
- f"[SIMULATION] place_limit_order: asset={asset_id}, "
909
- f"is_buy={is_buy}, price={price}, size={size}"
910
- )
911
- return True, {"simulation": True, "status": "ok"}
912
-
913
859
  if not self._executor:
914
860
  raise NotImplementedError("No Hyperliquid executor configured.")
915
861
 
@@ -17,7 +17,7 @@ from wayfinder_paths.adapters.hyperliquid_adapter.adapter import HyperliquidAdap
17
17
  @pytest.fixture
18
18
  def live_adapter():
19
19
  """Create adapter connected to real Hyperliquid API."""
20
- return HyperliquidAdapter(config={}, simulation=True)
20
+ return HyperliquidAdapter(config={})
21
21
 
22
22
 
23
23
  class TestSpotAssetIDs:
@@ -17,7 +17,7 @@ The adapter uses the LedgerClient which automatically handles authentication and
17
17
 
18
18
  The LedgerClient will automatically:
19
19
  - Use the WAYFINDER_API_URL from settings
20
- - Handle authentication via environment variables or config.json
20
+ - Handle authentication via config.json
21
21
  - Manage token refresh and retry logic
22
22
 
23
23
  ## Usage
@@ -17,7 +17,7 @@ The adapter uses the PoolClient which automatically handles authentication and A
17
17
  The PoolClient will automatically:
18
18
 
19
19
  - Use the WAYFINDER_API_URL from settings
20
- - Handle authentication via environment variables or config.json
20
+ - Handle authentication via config.json
21
21
  - Manage token refresh and retry logic
22
22
 
23
23
  ## Usage
@@ -45,41 +45,6 @@ else:
45
45
  print(f"Error: {data}")
46
46
  ```
47
47
 
48
- ### Find High Yield Pools
49
-
50
- ```python
51
- success, data = await adapter.find_high_yield_pools(
52
- min_apy=0.03, # 3% minimum APY
53
- min_tvl=500000, # $500k minimum TVL
54
- stablecoin_only=True,
55
- network_codes=["base", "ethereum"]
56
- )
57
- if success:
58
- pools = data.get("pools", [])
59
- print(f"Found {len(pools)} high-yield pools")
60
- for pool in pools:
61
- print(f"Pool: {pool.get('id')} - APY: {pool.get('llama_apy_pct')}%")
62
- else:
63
- print(f"Error: {data}")
64
- ```
65
-
66
- ### Get Pool Analytics
67
-
68
- ```python
69
- success, data = await adapter.get_pool_analytics(
70
- pool_ids=["pool-123", "pool-456"]
71
- )
72
- if success:
73
- analytics = data.get("analytics", [])
74
- for pool_analytics in analytics:
75
- pool = pool_analytics.get("pool", {})
76
- combined_apy = pool_analytics.get("combined_apy", 0)
77
- tvl_usd = pool_analytics.get("tvl_usd", 0)
78
- print(f"Pool: {pool.get('name')} - APY: {combined_apy:.2%} - TVL: ${tvl_usd:,.0f}")
79
- else:
80
- print(f"Error: {data}")
81
- ```
82
-
83
48
  ### Get Llama Matches
84
49
 
85
50
  ```python
@@ -110,47 +75,6 @@ else:
110
75
 
111
76
  ## Advanced Usage
112
77
 
113
- ### Filtering High Yield Pools
114
-
115
- The `find_high_yield_pools` method provides powerful filtering capabilities:
116
-
117
- ```python
118
- # Find stablecoin pools with high yield on specific networks
119
- success, data = await adapter.find_high_yield_pools(
120
- min_apy=0.05, # 5% minimum APY
121
- min_tvl=1000000, # $1M minimum TVL
122
- stablecoin_only=True, # Only stablecoin pools
123
- network_codes=["base", "arbitrum"] # Specific networks
124
- )
125
-
126
- if success:
127
- pools = data.get("pools", [])
128
- # Pools are automatically sorted by APY (highest first)
129
- best_pool = pools[0] if pools else None
130
- if best_pool:
131
- print(f"Best pool: {best_pool.get('id')} - APY: {best_pool.get('llama_apy_pct')}%")
132
- ```
133
-
134
- ### Comprehensive Pool Analysis
135
-
136
- ```python
137
- # Get detailed analytics for specific pools
138
- success, data = await adapter.get_pool_analytics(["pool-123"])
139
-
140
- if success:
141
- analytics = data.get("analytics", [])
142
- for pool_analytics in analytics:
143
- pool = pool_analytics.get("pool", {})
144
- llama_data = pool_analytics.get("llama_data", {})
145
-
146
- print(f"Pool: {pool.get('name')}")
147
- print(f" Combined APY: {pool_analytics.get('combined_apy', 0):.2%}")
148
- print(f" TVL: ${pool_analytics.get('tvl_usd', 0):,.0f}")
149
- print(f" Llama APY: {llama_data.get('llama_apy_pct', 0)}%")
150
- print(f" Stablecoin: {llama_data.get('llama_stablecoin', False)}")
151
- print(f" IL Risk: {llama_data.get('llama_il_risk', 'unknown')}")
152
- ```
153
-
154
78
  ## API Endpoints
155
79
 
156
80
  The adapter uses the following Wayfinder API endpoints:
@@ -86,125 +86,3 @@ class PoolAdapter(BaseAdapter):
86
86
  except Exception as e:
87
87
  self.logger.error(f"Error fetching Llama reports: {e}")
88
88
  return (False, str(e))
89
-
90
- async def find_high_yield_pools(
91
- self,
92
- min_apy: float = 0.01,
93
- min_tvl: float = 1000000,
94
- stablecoin_only: bool = True,
95
- network_codes: list[str] | None = None,
96
- ) -> tuple[bool, Any]:
97
- """
98
- Find high-yield pools based on criteria.
99
-
100
- Args:
101
- min_apy: Minimum APY threshold (as decimal, e.g., 0.01 for 1%)
102
- min_tvl: Minimum TVL threshold in USD
103
- stablecoin_only: Whether to filter for stablecoin pools only
104
- network_codes: List of network codes to filter by
105
-
106
- Returns:
107
- Tuple of (success, data) where data is filtered pools or error message
108
- """
109
- try:
110
- # Get Llama matches for yield data
111
- success, llama_data = await self.get_llama_matches()
112
- if not success:
113
- return (False, f"Failed to fetch Llama data: {llama_data}")
114
-
115
- matches = llama_data.get("matches", [])
116
- filtered_pools = []
117
-
118
- for pool in matches:
119
- # Apply filters
120
- if stablecoin_only and not pool.get("llama_stablecoin", False):
121
- continue
122
-
123
- if pool.get("llama_tvl_usd", 0) < min_tvl:
124
- continue
125
-
126
- if (
127
- pool.get("llama_apy_pct", 0) < min_apy * 100
128
- ): # Convert to percentage
129
- continue
130
-
131
- if network_codes and pool.get("network", "").lower() not in [
132
- nc.lower() for nc in network_codes
133
- ]:
134
- continue
135
-
136
- filtered_pools.append(pool)
137
-
138
- # Sort by APY descending
139
- filtered_pools.sort(key=lambda x: x.get("llama_apy_pct", 0), reverse=True)
140
-
141
- return (
142
- True,
143
- {
144
- "pools": filtered_pools,
145
- "total_found": len(filtered_pools),
146
- "filters_applied": {
147
- "min_apy": min_apy,
148
- "min_tvl": min_tvl,
149
- "stablecoin_only": stablecoin_only,
150
- "network_codes": network_codes,
151
- },
152
- },
153
- )
154
- except Exception as e:
155
- self.logger.error(f"Error finding high yield pools: {e}")
156
- return (False, str(e))
157
-
158
- async def get_pool_analytics(self, pool_ids: list[str]) -> tuple[bool, Any]:
159
- """
160
- Get comprehensive analytics for specific pools.
161
-
162
- Args:
163
- pool_ids: List of pool identifiers
164
-
165
- Returns:
166
- Tuple of (success, data) where data is pool analytics or error message
167
- """
168
- try:
169
- # Get pool data
170
- success, pool_data = await self.get_pools_by_ids(pool_ids)
171
- if not success:
172
- return (False, f"Failed to fetch pool data: {pool_data}")
173
-
174
- # Get Llama reports
175
- success, llama_data = await self.get_llama_reports(pool_ids)
176
- if not success:
177
- self.logger.warning(f"Failed to fetch Llama data: {llama_data}")
178
- llama_data = {}
179
-
180
- pools = pool_data.get("pools", [])
181
- llama_reports = llama_data
182
-
183
- # Combine data
184
- analytics = []
185
- for pool in pools:
186
- pool_id = pool.get("id")
187
- llama_report = llama_reports.get(pool_id.lower()) if pool_id else None
188
-
189
- analytics.append(
190
- {
191
- "pool": pool,
192
- "llama_data": llama_report,
193
- "combined_apy": (
194
- llama_report.get("llama_combined_apy_pct", 0) / 100
195
- if llama_report
196
- and llama_report.get("llama_combined_apy_pct") is not None
197
- else pool.get("apy", 0)
198
- ),
199
- "tvl_usd": (
200
- llama_report.get("llama_tvl_usd", 0)
201
- if llama_report and llama_report.get("llama_tvl_usd")
202
- else pool.get("tvl", 0)
203
- ),
204
- }
205
- )
206
-
207
- return (True, {"analytics": analytics, "total_pools": len(analytics)})
208
- except Exception as e:
209
- self.logger.error(f"Error getting pool analytics: {e}")
210
- return (False, str(e))
@@ -39,62 +39,5 @@
39
39
  ]
40
40
  }
41
41
  }
42
- },
43
- "find_high_yield_pools": {
44
- "description": "Find high-yield pools based on criteria",
45
- "input": {
46
- "min_apy": 0.03,
47
- "min_tvl": 500000,
48
- "stablecoin_only": true,
49
- "network_codes": ["base", "ethereum"]
50
- },
51
- "output": {
52
- "success": true,
53
- "data": {
54
- "pools": [
55
- {
56
- "id": "pool-123",
57
- "llama_apy_pct": 5.2,
58
- "llama_tvl_usd": 1000000,
59
- "llama_stablecoin": true,
60
- "network": "base"
61
- }
62
- ],
63
- "total_found": 1,
64
- "filters_applied": {
65
- "min_apy": 0.03,
66
- "min_tvl": 500000,
67
- "stablecoin_only": true,
68
- "network_codes": ["base", "ethereum"]
69
- }
70
- }
71
- }
72
- },
73
- "get_pool_analytics": {
74
- "description": "Get comprehensive analytics for specific pools",
75
- "input": {
76
- "pool_ids": ["pool-123"]
77
- },
78
- "output": {
79
- "success": true,
80
- "data": {
81
- "analytics": [
82
- {
83
- "pool": {
84
- "id": "pool-123",
85
- "name": "USDC/USDT Pool",
86
- "symbol": "USDC-USDT"
87
- },
88
- "llama_data": {
89
- "llama_apy_pct": 5.2,
90
- "llama_tvl_usd": 1000000
91
- },
92
- "combined_apy": 0.052,
93
- "tvl_usd": 1000000
94
- }
95
- ],
96
- "total_pools": 1
97
- }
98
- }
99
42
  }
100
43
  }