wayfinder-paths 0.1.27__py3-none-any.whl → 0.1.28__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.

@@ -1,9 +1,7 @@
1
- import json
2
1
  from decimal import Decimal
3
2
  from typing import Any, Literal
4
3
 
5
4
  from eth_account.messages import encode_typed_data
6
- from eth_utils import keccak
7
5
  from hyperliquid.api import API
8
6
  from hyperliquid.exchange import get_timestamp_ms
9
7
  from hyperliquid.info import Info
@@ -204,7 +202,7 @@ class Exchange:
204
202
  "time": nonce,
205
203
  "type": "withdraw3",
206
204
  }
207
- payload = self._get_hypecore_user_signature_payload(
205
+ payload = user_signed_payload(
208
206
  "HyperliquidTransaction:Withdraw", WITHDRAW_SIGN_TYPES, action
209
207
  )
210
208
  if not (sig := await self.sign(payload, action, address)):
@@ -230,7 +228,7 @@ class Exchange:
230
228
  "amount": amount,
231
229
  "time": nonce,
232
230
  }
233
- payload = self._get_hypecore_user_signature_payload(
231
+ payload = user_signed_payload(
234
232
  "HyperliquidTransaction:SpotSend", SPOT_TRANSFER_SIGN_TYPES, action
235
233
  )
236
234
  if not (sig := await self.sign(payload, action, address)):
@@ -248,7 +246,7 @@ class Exchange:
248
246
  "nonce": nonce,
249
247
  "type": "usdClassTransfer",
250
248
  }
251
- payload = self._get_hypecore_user_signature_payload(
249
+ payload = user_signed_payload(
252
250
  "HyperliquidTransaction:UsdClassTransfer",
253
251
  USD_CLASS_TRANSFER_SIGN_TYPES,
254
252
  action,
@@ -268,7 +266,7 @@ class Exchange:
268
266
  "nonce": nonce,
269
267
  "type": "userDexAbstraction",
270
268
  }
271
- payload = self._get_hypecore_user_signature_payload(
269
+ payload = user_signed_payload(
272
270
  "HyperliquidTransaction:UserDexAbstraction",
273
271
  USER_DEX_ABSTRACTION_SIGN_TYPES,
274
272
  action,
@@ -288,56 +286,26 @@ class Exchange:
288
286
  "nonce": nonce,
289
287
  "type": "approveBuilderFee",
290
288
  }
291
- payload = self._get_hypecore_user_signature_payload(
289
+ payload = user_signed_payload(
292
290
  "HyperliquidTransaction:ApproveBuilderFee", BUILDER_FEE_SIGN_TYPES, action
293
291
  )
294
292
  if not (sig := await self.sign(payload, action, address)):
295
293
  return USER_DECLINED_ERROR
296
294
  return self._broadcast_hypecore(action, nonce, sig)
297
295
 
298
- def build_sign(self, raw_payload: dict) -> str:
299
- """Build and format the signing payload based on signing_type."""
300
- if self.signing_type == "eip712":
301
- # Remote signing: Return JSON string of typed data
302
- return json.dumps(
303
- raw_payload,
304
- default=lambda o: (
305
- "0x" + o.hex() if isinstance(o, (bytes, bytearray)) else o
306
- ),
307
- separators=(",", ":"),
308
- )
309
- # Local signing: Return keccak hash
310
- encoded = encode_typed_data(full_message=raw_payload)
311
- full_msg = b"\x19" + encoded.version + encoded.header + encoded.body
312
- return f"0x{keccak(full_msg).hex()}"
313
-
314
296
  async def sign(
315
297
  self, payload: str, action: dict, address: str
316
298
  ) -> dict[str, Any] | None:
317
299
  """Sign the payload and return Hyperliquid-format signature."""
318
300
  if self.signing_type == "eip712":
319
- # For EIP-712: parse JSON, call callback with typed data dict, convert hex to {r,s,v}
320
- typed_data = json.loads(payload)
321
- sig_hex = await self.sign_callback(typed_data)
301
+ sig_hex = await self.sign_callback(payload)
322
302
  if not sig_hex:
323
303
  return None
324
304
  return self.util._sig_hex_to_hl_signature(sig_hex)
325
305
 
326
- # Local signing: payload is hash string, callback returns {r,s,v} directly
306
+ payload = encode_typed_data(full_message=payload)
327
307
  return await self.sign_callback(action, payload, address)
328
308
 
329
- def _get_hypecore_l1_payload(
330
- self, action, nonce, expires_after=None, is_mainnet=True
331
- ):
332
- """Build L1 action payload (orders, leverage, cancels)."""
333
- payload = get_l1_action_payload(action, None, nonce, expires_after, is_mainnet)
334
- return self.build_sign(payload)
335
-
336
- def _get_hypecore_user_signature_payload(self, primary_type, payload_types, action):
337
- """Build user signed action payload (withdrawals, transfers, etc.)."""
338
- payload = user_signed_payload(primary_type, payload_types, action)
339
- return self.build_sign(payload)
340
-
341
309
  def _broadcast_hypecore(self, action, nonce, signature):
342
310
  """Broadcast a signed action to the Hyperliquid exchange."""
343
311
  payload = {
@@ -351,7 +319,7 @@ class Exchange:
351
319
  async def sign_and_broadcast_hypecore(self, action, address):
352
320
  """Sign and broadcast an L1 action (orders, leverage, cancels)."""
353
321
  nonce = get_timestamp_ms()
354
- payload = self._get_hypecore_l1_payload(action, nonce)
322
+ payload = payload = get_l1_action_payload(action, None, nonce, None, True)
355
323
  if not (sig := await self.sign(payload, action, address)):
356
324
  return USER_DECLINED_ERROR
357
325
  return self._broadcast_hypecore(action, nonce, sig)
@@ -52,7 +52,7 @@ def create_local_signer(config: dict[str, Any]) -> HyperliquidSignCallback:
52
52
 
53
53
  # Create account
54
54
  pk = private_key if private_key.startswith("0x") else "0x" + private_key
55
- account = Account.from_key(pk)
55
+ account: Account = Account.from_key(pk)
56
56
 
57
57
  async def sign(
58
58
  action: dict[str, Any], payload: str, address: str
@@ -76,7 +76,7 @@ def create_local_signer(config: dict[str, Any]) -> HyperliquidSignCallback:
76
76
  return None
77
77
 
78
78
  # Sign the hash
79
- signed = account.signHash(payload)
79
+ signed = account.sign_message(payload)
80
80
  return {"r": hex(signed.r), "s": hex(signed.s), "v": signed.v}
81
81
 
82
82
  return sign
@@ -1,12 +1,13 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.3
2
2
  Name: wayfinder-paths
3
- Version: 0.1.27
3
+ Version: 0.1.28
4
4
  Summary: Wayfinder Path: strategies and adapters
5
5
  Author: Wayfinder
6
6
  Author-email: dev@wayfinder.ai
7
7
  Requires-Python: >=3.12,<4.0
8
8
  Classifier: Programming Language :: Python :: 3
9
9
  Classifier: Programming Language :: Python :: 3.12
10
+ Classifier: Programming Language :: Python :: 3.13
10
11
  Requires-Dist: aiocache (>=0.12.3,<0.13.0)
11
12
  Requires-Dist: aiohttp (>=3.13.0,<4.0.0)
12
13
  Requires-Dist: eth-account (>=0.13.7,<0.14.0)
@@ -26,9 +26,9 @@ wayfinder_paths/adapters/hyperlend_adapter/manifest.yaml,sha256=M0xfk0KPpILSo-Xt
26
26
  wayfinder_paths/adapters/hyperlend_adapter/test_adapter.py,sha256=QYpXpxSw-aG20DXPbNowPZs8Z9BnACa-OO8mc0EaR9I,13677
27
27
  wayfinder_paths/adapters/hyperliquid_adapter/__init__.py,sha256=8kOiGrmGvk8BR16wHxVo1qaWwAQSTQbkcJg0cW46RCE,288
28
28
  wayfinder_paths/adapters/hyperliquid_adapter/adapter.py,sha256=dmd6vpkSC5aOSrIx9T3EWutNklDyLm45K2djXjV92oE,46146
29
- wayfinder_paths/adapters/hyperliquid_adapter/exchange.py,sha256=WV5PujGggl8y96A2QkkktdsxdoUtfvZG7YbUc50lWlw,14146
29
+ wayfinder_paths/adapters/hyperliquid_adapter/exchange.py,sha256=VSSCmsSTnQ3qDjPRLZLA60mwHoBkn5l_f-h0H0g7yBw,12551
30
30
  wayfinder_paths/adapters/hyperliquid_adapter/executor.py,sha256=PDF8oM99m7EVgij8scLYkdpvFsq_lrhTVeLYrP_5vfY,18372
31
- wayfinder_paths/adapters/hyperliquid_adapter/local_signer.py,sha256=QrAOoUtFjNvT_san5DIuZzDK-EQAek7GnOTTD2ZSM0s,2738
31
+ wayfinder_paths/adapters/hyperliquid_adapter/local_signer.py,sha256=56RVsFy63pxXYzAxIyVbyn3NRBt1lQ6dCAvtBH7M9SU,2751
32
32
  wayfinder_paths/adapters/hyperliquid_adapter/manifest.yaml,sha256=lwADwkooWOivqIUEAxiVTdHBYuchHyuQR8y40K_AUgw,315
33
33
  wayfinder_paths/adapters/hyperliquid_adapter/paired_filler.py,sha256=V_cIiNJYER6E3r8hYLTy1zR2YuO_GBKhn9rP5dkPaVs,35156
34
34
  wayfinder_paths/adapters/hyperliquid_adapter/test_adapter.py,sha256=1oMMoHG6hNeq08Tcwtt4XYjEdGaO5Jc0daCPuKvMWPM,3784
@@ -184,7 +184,7 @@ wayfinder_paths/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3h
184
184
  wayfinder_paths/tests/test_mcp_quote_swap.py,sha256=In4SxTkjfy7f2dqr8z6g1onHk8N2hQRc7a5_zQwcpXI,5473
185
185
  wayfinder_paths/tests/test_test_coverage.py,sha256=ZU0zhlm1PllvQkrnESPtEVdr-VcFDT6EtPiPRreLukk,7118
186
186
  wayfinder_paths/tests/test_utils.py,sha256=VzweYVaO20deZOwR8RKGYFrDnKTW0gZLm3dBwZiMK28,1015
187
- wayfinder_paths-0.1.27.dist-info/LICENSE,sha256=dYKnlkC_xosBAEQNUvB6cHMuhFgcUtN0oBR7E8_aR2Y,1066
188
- wayfinder_paths-0.1.27.dist-info/METADATA,sha256=WNeDzpbrIXWTklz_ps0086oPvLE9WyqdIbekvYNHfxA,14422
189
- wayfinder_paths-0.1.27.dist-info/WHEEL,sha256=FMvqSimYX_P7y0a7UY-_Mc83r5zkBZsCYPm7Lr0Bsq4,88
190
- wayfinder_paths-0.1.27.dist-info/RECORD,,
187
+ wayfinder_paths-0.1.28.dist-info/LICENSE,sha256=dYKnlkC_xosBAEQNUvB6cHMuhFgcUtN0oBR7E8_aR2Y,1066
188
+ wayfinder_paths-0.1.28.dist-info/METADATA,sha256=jugtcgnX8bNTAwoQXaUx6-ejV-oTl661XzuCEqcFzjo,14473
189
+ wayfinder_paths-0.1.28.dist-info/WHEEL,sha256=XbeZDeTWKc1w7CSIyre5aMDU_-PohRwTQceYnisIYYY,88
190
+ wayfinder_paths-0.1.28.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: poetry-core 1.8.1
2
+ Generator: poetry-core 2.1.1
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any