Funding Wallet
Funding Wallet: Agent Java SDK v0.3.0 integration, examples, parameters and response semantics.
This guide targets Agent Java SDK v0.3.0, Java 8+, and the tagged public contract. Examples run in a partner backend after initializing client in Quick Start.
Example prerequisites
The Java snippets share these imports. Initialize client using Quick Start and obtain platformUserId from the saved binding. Example user/order IDs must be replaced with your own persisted values.
Wallet queries and transfers
Distinguish the three wallets
queryAccount Query the merchant platform margin account, not the merchant user wallet. This interface does not have environment parameters and cannot be queried as a simulated user asset.
Query the two platform wallets of simulated users:
Interface: POST /v1/agent/query-user-assets. Funding is requested only when includeFunding=true; the original contract asset query semantics are used by default.
Amounts are handled as strings or BigDecimal, not float/double.
Funding transfer directions
Create: POST /v1/agent/wallet-transfer, SDK walletTransfer.
The current currency only supports USDT. The fixed amount must be a positive string with up to 8 decimal places and cannot use scientific notation. When transferAll=true, omit amount and record it as the final response amount; “all” only includes the withdrawable funds.
Example: Merchant transfers 10 USDT to simulated Funding. First save the business order and environment in the merchant system, and then send the request:
Funding Transfer all funds that can be transferred to the simulated Contract:
The same operation must continue to use the original agentOrderNo; different operations and different environments use different order numbers. Changing the amount, user, direction or environment with the same order number will be rejected. Funding/Contract transfers can only be performed within the same environment, and simulated funds cannot be transferred to real funds.
Result confirmation and unknown result recovery
Funding responses are represented by status, SUCCESS, PROCESSING, or FAILED, and are returned orderNo, direction, currency, amount, resultCode, etc. code=0 only means that the request is processed successfully and you need to continue to judge status.
Funding query uses the dedicated interface POST /v1/agent/wallet-transfer-status:
Use this dedicated endpoint to recover the original Funding operation; queryOrder cannot replace it. Save the original environment and pass it explicitly during recovery. If environment is omitted from wallet-transfer-status, the server uses the environment saved on the original order, including simulated orders. An explicitly conflicting environment returns 102002 (order environment mismatch). When the caller omits the environment, the response omits environment too; this does not mean the original order is a production order.
Merchants’ local deposits and withdrawals are idempotent; persistent orders and balances are reserved before initiation, and are reserved for confirmation when the result is unknown. Funding access uses a dedicated query to confirm the final status; do not assume that old contract transfer Webhook or reversal methods are automatically applicable to Funding.
Existing Contract transfer flow
The original transfer, transferAllOut, reverse, queryOrder, listOrders continue to process the original contract transfer process. queryOrder is querying fund transfer orders, listOrders is a transfer reconciliation list; instead, Perpetual queries are used for perpetual trading orders.
The original funding response uses orderStatus; the Funding response uses status, do not mix them. The original transfer Webhook is verified using X-Agent-Timestamp, X-Agent-Nonce, X-Agent-Signature, and the original signature text is timestamp + nonce + rawBody; the original request body is first verified, then deserialized and idempotent. Explicit simulated environment notifications contain environment=SIMULATED, production notifications remain compatible with old fields. The amount, order number, status and environment need to be checked with the local business order.