Add TS-SDK feature parity: readers, write methods, and utilities#18
Open
gregnazario wants to merge 3 commits into
Open
Add TS-SDK feature parity: readers, write methods, and utilities#18gregnazario wants to merge 3 commits into
gregnazario wants to merge 3 commits into
Conversation
Closes gaps relative to @decibeltrade/sdk (TypeScript reference). Write client (DecibelWriteDex + Sync): - update_order, withdraw_non_collateral, admin_create_subaccount, claim_campaign_reward (+ campaign_package added to Deployment/configs) Read client (DecibelReadDex): - On-chain view helpers: global_perp_engine_state, collateral_balance_decimals, usdc_decimals, usdc_balance, token_balance, account_balance, position_size, get_crossed_position - 9 new read namespaces: campaigns, points_leaderboard, streaks, trading_amps, tier, global_points_stats, referrals, user_fees, withdraw_queue (withdraw_queue includes WS subscribe, on-chain pending view, and merge helpers) Utilities: - calculate_liquidation_price (concentrated margin buffer strategy) - EIP-55 checksums (zero-dep keccak-256) + derivable-account address derivation Includes tests (96% total coverage) and examples for each new reader.
☂️ Python Coverage
Overall Coverage
New Files
Modified Files
|
…ties Update the README API reference with the new read namespaces, on-chain view helpers, write methods, and a Utilities section (liquidation price, EIP-55, derivable accounts). Add a CHANGELOG Unreleased entry.
…e methods Document every new reader class/method (porting the reference JSDoc where it existed), the read-client on-chain view helpers, and the four new write methods so generated API docs (Sphinx/pdoc) surface them.
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.
Context
Brings the Python SDK to feature parity with the reference TypeScript SDK (
@decibeltrade/sdk), which had moved ahead. Gaps were confirmed by diffing the reference API surface (write.ts,read/index.ts,read/*/*.reader.ts,index.ts) againstsrc/decibel/.Changes
Phase 1a — Write-client parity (
DecibelWriteDex+DecibelWriteDexSync)update_order(update_order_to_subaccount) +UpdateOrderArgswithdraw_non_collateral(withdraw_from_non_collateral)admin_create_subaccount(admin_create_new_subaccount)claim_campaign_reward(campaign_manager::claim_by_id) — adds acampaign_packagefield toDeployment+get_campaign_package()helper, populated for mainnet/testnetPhase 1b — Read-client on-chain view helpers (
DecibelReadDex)global_perp_engine_state,collateral_balance_decimals,usdc_decimals(cached),usdc_balance,token_balance,account_balance,position_size,get_crossed_positionPhase 2 — 9 new read namespaces
campaigns,points_leaderboard,streaks,trading_amps,tier,global_points_stats,referrals,user_fees,withdraw_queue. Each has pydantic models, registration onDecibelReadDex, tests, and an example.withdraw_queuealso ports the WSsubscribe_by_addr, the on-chainget_pending_withdrawalsfallback, and themerge_withdraw_queue_entries/is_known_cancel_reasonhelpers.Phase 3 — Utility modules
calculate_liquidation_price— concentrated margin buffer strategy (all 10 golden values from the reference test suite match)to_checksum_address— EIP-55 with a zero-dependency Keccak-256 (verified against spec vectors)derive_aptos_from_eth/derive_aptos_from_solana— derivable-account derivation (scheme byte 0x05)Out of scope (deferred)
The 4 testnet-only USDC mint view helpers and the ~7 expanded admin methods (chainlink-blended oracle, allowlist/mode-guardian, open-interest getters/setters).
Testing
ruff check,ruff format --check,pyright(0 errors) all passpytest -k "not testnet": 1087 passed