Skip to navigation

Users & Assets

Users & Assets: Agent Java SDK v0.3.0 integration, examples, parameters and response semantics.

View as Markdown

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.

import com.sixmm.agent.*;
import com.sixmm.agent.model.*;
import java.util.*;

User ID Rules

platformUserId is the 6MM external user ID. It is currently a 10-digit numeric string, for example:

1188041528

Rules:

  • Store it as a string, not as an integer.
  • Do not generate, decode, or infer meaning from it.
  • Use your own partner-side user ID as agentUserId.
  • Persist the relationship among agentUserId, platformUserId, and agentOrderNo.

Bind User

Bind creates or fetches the relationship between a partner user and a 6MM platform user. Call it when a user first enters the trading flow or before the first transfer into 6MM.

import com.sixmm.agent.model.BindRequest;
import com.sixmm.agent.model.BindResponse;
BindResponse resp = client.bind(
BindRequest.of("agent-user-001")
.withUsername("alice")
.withExt("{\"source\":\"web\"}"));
System.out.println(resp.platformUserId);
System.out.println(resp.bindStatus);
System.out.println(resp.isSimulatedUser);

Request fields:

FieldTypeRequiredDescription
agentUserIdstringYesUnique partner-side user ID
usernamestringNoPartner-side display name used as the platform user’s nickname
extstringNoExtension field. JSON string is recommended

Response fields:

FieldTypeDescription
platformUserIdstring6MM external user ID
bindStatusstringUsually BOUND
isSimulatedUserbooleanWhether this is a simulated user

Query Partner Account

import com.sixmm.agent.model.QueryAccountRequest;
import com.sixmm.agent.model.QueryAccountResponse;
QueryAccountResponse resp = client.queryAccount(QueryAccountRequest.of("USDT"));
System.out.println(resp.agentCode);
System.out.println(resp.agentStatus);
resp.assets.forEach(asset -> {
System.out.println(asset.currency);
System.out.println(asset.depositBalance);
});

When currency is absent, the SDK uses defaultCurrency.

Query User Assets

import com.sixmm.agent.model.QueryUserAssetsRequest;
import com.sixmm.agent.model.QueryUserAssetsResponse;
QueryUserAssetsResponse resp = client.queryUserAssets(
QueryUserAssetsRequest.of("1188041528"));
System.out.println(resp.walletBalance);
System.out.println(resp.availableBalance);
System.out.println(resp.version);

Fields:

FieldTypeDescription
walletBalancestringWallet balance
frozenMarginstringFrozen margin
usedMarginstringUsed margin
availableBalancestringAvailable balance
isolatedMarginstringIsolated margin
versionint64Asset version
isSimulatedUserbooleanWhether this is a simulated user

Distinguish the three wallets

walletBalance sourceuse
Merchant’s own user walletMerchant’s own accounting systemThe user’s available balance on the merchant side
Platform FundingqueryUserAssets of fundingSeconds trading funds and Funding/Contract mutual transfer
Platform ContractThe contract asset field of queryUserAssetsPerpetual contract margin and transferable balance

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:

QueryUserAssetsResponse assets = client.queryUserAssets(
QueryUserAssetsRequest.of(platformUserId)
.withFunding()
.withEnvironment(ExecutionEnvironment.SIMULATED));

Interface: POST /v1/agent/query-user-assets. Funding is requested only when includeFunding=true; the original contract asset query semantics are used by default.

response fieldsmeaning
walletBalance, availableBalance, frozenMargin, usedMargin, isolatedMarginContract wallet related amounts
funding.assetCodeCurrently USDT
funding.availableAmount, heldAmount, totalAmountFunding available, occupied and total amount
funding.materializedWhether the Funding account has been materialized?
environmentThis field is echoed when the environment is passed explicitly; old requests that omit the environment do not return this field.
isSimulatedUserAccount classification; cannot replace trading environment selection

Amounts are handled as strings or BigDecimal, not float/double.