feat: SDK gap-fill — mirror of TS PR #21 (order history + USD valuation + combined transfers + get_deployment filters + error preservation)#9
Open
hsyndeniz wants to merge 11 commits into
Conversation
…_call Backend reason codes (FQ-, P-, T-, RF-) now surface in Result.fail messages instead of being swallowed as generic HTTP status errors. Mirrors TypeScript SDK commit bbabf19. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
…ilters Backward-compatible. No-args call still resolves with defaults. Cache key includes filter params so variants don't collide. Mirrors TypeScript SDK commit 14265ad. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Returns token-symbol → USD-price map from the public /info/usd-prices
endpoint. Cached at Semi-Static tier (15m). No auth required.
The backend currently emits a flat ``dict[str, str]`` map (string prices,
including scientific notation for very small values); the SDK coerces to
``float`` and silently drops entries it cannot interpret. An array-of-
objects fallback (``[{"symbol", "price"}, ...]``) is also accepted in
case the backend shape ever changes. Cache key is namespaced by ``env``
so testnet and mainnet clients in the same process never collide.
The ``env`` query parameter is forwarded for parity with the TypeScript
SDK; the backend determines the network from the API host today and
ignores it, but the SDK is forward-compatible.
Also fixes a latent cache-instance-identity bug in ``_configure_caches``:
the function was reassigning the module-level cache globals when a
custom TTL was supplied, but subscriber modules (``transfer.py`` /
``swap.py`` / ``clob.py``) capture those globals by reference at module
load time. Reassigning would leave the cache the decorator writes to
disconnected from the cache test fixtures clear, producing
order-dependent test failures. ``_configure_caches`` now mutates the
existing ``MemoryCache.ttl`` in place.
Mirrors TypeScript SDK commit ea9f4a4.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
get_token_price_history and get_token_hourly_price_history return
ascending-time-ordered ``list[PricePoint]`` from the public
``/api/info/token-usd-price-history`` and
``/api/info/token-usd-price-history-hourly`` endpoints. Static-tier
cached (1 h TTL) with path-namespaced keys so daily and hourly never
collide; past prices don't change.
Both methods delegate to a shared ``_fetch_price_history`` helper that
normalizes the raw ``{date: ISO-8601-string, price: stringified-decimal}``
rows (descending by date on the wire) into ascending unix-seconds +
numeric ``PricePoint`` list, tolerates ``ts``/``timestamp``/``time``
numeric aliases (values ``>= 1e12`` treated as milliseconds), and
silently drops malformed rows. Optional ``from_ts``/``to_ts`` window
is forwarded to the backend (ignored today, forward-compat) and
additionally applied client-side so the caller's range contract holds.
The Python signature uses keyword-only ``from_ts``/``to_ts`` instead
of the TypeScript ``opts: {from, to}`` shape to avoid the ``from``
keyword conflict in Python.
New ``PricePoint`` frozen dataclass exported from
``dexalot_sdk.core.transfer`` (kept in the module that produces it,
matching the existing ``ResolvedChain`` convention in ``base.py``).
Mirrors TypeScript SDK commit 63b2e61.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Signed GET returning canonical ``list[Transfer]`` (snake_case fields,
status/action_type/bridge lifted from numeric enums) with
kind/from_ts/to_ts/limit/offset filters from the signed REST endpoint
``/api/trading/signed/transferscombined`` (NOT under ``/privapi/`` —
empirically confirmed via OPTIONS preflight: 404 vs 204). Balance-tier
cached (10 s TTL) per ``(address, kind, from_ts, to_ts, limit, offset)``.
Backend pagination uses ``itemsperpage`` / ``pageno``; the SDK exposes
the more conventional ``limit`` / ``offset`` signature and translates
internally (``pageno = (offset // limit) + 1``). ``kind`` is forwarded
to the backend as ``symbol``; ``from_ts`` / ``to_ts`` as
``periodfrom`` / ``periodto``. Response shape is ``{count, rows}``
with a bare-list fallback for forward-compat.
``quantity`` / ``fee`` arrive as already-display-decimal numeric strings
from the backend (the official frontend reads them straight through
Big.js — no decimals divide); the SDK coerces to ``float`` via the
shared ``_coerce_usd_price`` helper. Unknown ``action_type`` / ``status``
enums and rows missing required fields are silently dropped so a
single bad row does not poison the page. Unknown ``bridge`` enum falls
back to ``"NATIVE"`` to match the frontend's display-only treatment.
To support a signed call outside the CLOB surface, ``_get_auth_headers``
is lifted from ``CLOBClient`` to ``DexalotBaseClient``. The CLOB call
sites are unchanged; the duplicate body is removed and a pointer
comment kept. The lift also matches the TypeScript SDK structure where
``_getAuthHeaders`` lives on a shared base.
New ``Transfer`` / ``TransferStatus`` / ``TransferActionType`` /
``TransferBridge`` types exported from ``dexalot_sdk.core.transfer``.
Mirrors TypeScript SDK commit f7a9945.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Signed GET; returns canonical Order list (same shape as get_open_orders). Accepts pair/status/limit/offset filters and optional explicit account argument. Balance-tier cached (10s). Reuses _transform_order_from_api and _get_auth_headers. Mirrors TypeScript SDK commit ece5dcd. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
… preservation Adds new methods to Cached Methods lists, type-normalization entries for PricePoint + Transfer, an Error Handling note on preserved backend reason codes, and a get_order_history usage snippet. Mirrors TypeScript SDK commit fa4959c. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Six new features in this PR (order history, USD valuation x3, combined transfers, get_deployment filters) plus reason_code/reason error preservation. Local was at 0.5.14; PyPI has 0.5.15 already, so skip to 0.5.16 to avoid version collision. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Resolve conflicts: - VERSION / pyproject.toml / src/dexalot_sdk/__init__.py: keep 0.5.16 (main released 0.5.15; this PR ships 0.5.16) - src/dexalot_sdk/core/clob.py: keep both sides — main added 'import logging' + 'import time' for its display-decimals helpers, this branch's get_order_history is preserved as auto-merged - uv.lock: regenerated via 'uv lock' against the merged pyproject Also drop a now-unused [no-untyped-def] ignore that mypy flagged post-merge (BrokenAccount.address gets an explicit return type). Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
CI's `ruff format --check` caught formatting drift in:
- src/dexalot_sdk/core/transfer.py
- tests/unit/core/{test_base,test_clob,test_transfer}.py
My local Makefile target `make lint` only runs `ruff check` (lint),
not `ruff format --check`. The CI runs both. Auto-applied with
`ruff format .`.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Python parity port of dexalot-sdk-typescript#21. 7 commits, 954 unit tests pass, 100% coverage, mypy strict + ruff clean.