Repository navigation
Conversation
add funding rate config
aster spot doc
futures v3
v3 change url to prod
use apiwallet
add api guide
…pprove-agent-api docs: add registerAndApproveAgent API documentation
- Add POST/GET /fapi/v3/stpMode (Change/Get STP Mode) to EN and CN futures docs (v3 + testnet) - Add stpMode TOC entries and ENUM definitions in all four files - Add optional stpMode parameter to POST /fapi/v3/order parameter table - Auth params use nonce/signer/signature consistent with v3 auth - Update CHANGELOG.md Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
docs: add fapi/v3/stpMode endpoints and stpMode order parameter
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
strategy_api
Add full REST and WebSocket API reference for the prediction market testnet (https://papi.asterdex-testnet.com), covering market data, trading, prediction market mint/burn/positions, account, and WebSocket streams. Update CHANGELOG for 2026-05-26. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
docs: add Prediction API testnet documentation (EN & CN)
prediction_twap
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
add deposit withdraw
prediction_prod
announcement
- aster-code.py, sol_agent.py: migrate encode_structured_data to encode_typed_data (removed in eth-account >= 0.13; the demos failed to import on a fresh install). Output is byte-identical, cross-checked against ethers signTypedData. - nonce: use microsecond time.time_ns()//1000, locked and strictly monotonic, so concurrent workers or a restart never reuse a nonce. The previous int(time.time()) gave 1-second resolution and could collide (server returns -4225 Nonce Expired). - sol_agent.py: print the nonce actually sent instead of calling get_nonce() a second time. - consolidation.js: fix `if (x = 'SUCCESS')` (assignment, not comparison) and guard error returns so a failed transfer or withdraw no longer reports success. - add requirements.txt and package.json to pin runnable dependencies.
224 |
Summary
The
demo/scripts are what integrators copy to build bots that hold API-wallet keys and move funds, so a small defect here propagates widely. This PR fixes three issues that bite on a fresh setup and pins runnable dependencies.All changes are client-side only and do not alter any byte the server verifies. EIP-712 / HMAC signatures are byte-identical before and after — cross-checked against
ethers.signTypedData(see Verification).Fixes
1. Demos fail to import on a current
eth-accountaster-code.pyandsol_agent.pyimportencode_structured_data, which was removed ineth-account >= 0.13(replaced byencode_typed_data). A freshpip install eth-accountmakes the demos crash withImportErrorbefore anything is sent. Both are migrated toencode_typed_data(full_message=...).2. Nonce can collide and get rejected as
-4225 Nonce Expiredget_nonce()usedint(time.time()) * 1_000_000, i.e. 1-second resolution (the docs state microsecond precision). Two workers — or one process restarted — sharing a single API wallet emit the same nonce within the same second, and the server rejects the duplicate (-4225 Nonce Expired).aster-code.pyalso had no lock. Now uses microsecondtime.time_ns() // 1000, mutex-guarded and strictly monotonic, so a nonce is never reused within a process. (Across multiple processes, still use one nonce source per key.)3.
consolidation.jsreports success on failureif (sendToMainAddressRes['status'] = 'SUCCESS')is an assignment, not a comparison, so the consolidation step always logs success — even when the transfer failed. The withdraw checkspotWithdraw['hash'] != ''also dereferences an error return (''). Fixed to===and added guards so a failed transfer or withdraw is reported as a failure.4. Minor
sol_agent.py: print the nonce that was actually sent, instead of callingget_nonce()a second time (which produced a different value than the one signed).demo/requirements.txtanddemo/package.jsonpinning runnable dependency versions.Verification
python -m py_compileandnode --checkpass on all demo files.encode_typed_data) and withethers.signTypedDataproduces identical signatures for both theMessage{msg}scheme and the dynamic action struct — so the migration stays wire-compatible with the live API.Intentionally not changed (needs server-side coordination)
These are genuine hardening opportunities, but changing them client-side would break verification against the current backend, so they are left for a coordinated follow-up rather than silently altered here:
sign_v3_eip712: the field type depends on the literal (canWithdraw=Falsevs0sign to different digests). A fixed per-action schema would be more robust.chainIdhardcoded to56on the main-account path, withverifyingContract = 0x0— the EIP-712 domain does not bind the operating chain.personal_sign("You are signing into Astherus {nonce}")authorizes API-key creation and is byte-identical to the login message. EIP-712 typed data would let wallets show users what they are actually authorizing.