Order Books
Get Security Status
Read on-chain registration, the EIP-712 domain, and a wallet’s tradable balances
GET
/
orderbooks
/
external-securities
/
api
/
order-books
/
{orderBookId}
/
security
curl "https://api.trusset.org/orderbooks/external-securities/api/order-books/clx_ob_extsec_001/security?userAddress=0xabc7f1093d5e26b804a1c3f78de025916b47c0d3" \
-H "X-API-Key: trusset_your_key_here"
const res = await fetch(
`https://api.trusset.org/orderbooks/external-securities/api/order-books/${orderBookId}/security?userAddress=${address}`,
{ headers: { 'X-API-Key': 'trusset_your_key_here' } }
);
const { data } = await res.json();
const signature = await signer._signTypedData(data.eip712.domain, data.eip712.types, order);
{
"success": true,
"data": {
"orderBookId": "clx_ob_extsec_001",
"custodyContract": "0x489aee4ae9546081d55848f157e03192e826988c",
"tokenAddress": "0x51f2b9d0e77c4a1b83ce6d4a9271e5f3a0c8b912",
"quoteTokenAddress": "0x98ad0ca091552e23c564b41c74282e5343d03e8a",
"underlyingIdentifier": "CH0012032048",
"baseDecimals": 18,
"quoteDecimals": 6,
"settlementOperator": "0x5ad87a0621175206b72d10e4b8577b192e7f40ab",
"security": {
"admin": "0x7712db30a7b4ffd9c445793089118b60e56d752a",
"isin": "CH0012032048",
"isinRaw": "0x4348303031323033323034380000000000000000000000000000000000000000",
"baseUnit": "1000000000000000000",
"registered": true,
"active": true
},
"eip712": {
"domain": {
"name": "TRexCustody",
"version": "1",
"chainId": 11155111,
"verifyingContract": "0x489AeE4ae9546081d55848F157E03192e826988c"
},
"types": {
"Order": [
{ "name": "trader", "type": "address" },
{ "name": "token", "type": "address" },
{ "name": "quote", "type": "address" },
{ "name": "isBuy", "type": "bool" },
{ "name": "quantity", "type": "uint256" },
{ "name": "price", "type": "uint256" },
{ "name": "expiry", "type": "uint64" },
{ "name": "nonce", "type": "uint64" },
{ "name": "salt", "type": "bytes32" }
]
}
},
"balances": {
"base": {
"total": "500000000000000000000",
"locked": "0",
"onChainAvailable": "500000000000000000000",
"reserved": "20000000000000000000",
"available": "480000000000000000000"
},
"quote": {
"total": "100000000000",
"locked": "0",
"onChainAvailable": "50000000000",
"reserved": "0",
"available": "50000000000"
}
},
"quoteAllowance": "50000000000"
}
}
Returns everything a client needs to build and sign an order for this book: the security’s live registration state, the exact EIP-712 domain and type definitions the custody contract expects, and, when you name a wallet, that wallet’s tradable balances and its settlement asset allowance.
Use it before Prepare Order if you want to build the typed data yourself, and to show a trader what they can actually trade.
Path Parameters
Query Parameters
Response Fields
Show child attributes
Show child attributes
Live state read from the custody contract.
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Present only when
userAddress was supplied. What the wallet has approved the custody contract to spend of the settlement asset, in base units.Reading the balances
onChainAvailable is what the contract reports. reserved is what this venue has committed to the wallet’s own resting orders. available is the difference, and is the number an order is checked against.
For the settlement asset, the contract’s available figure is already the lesser of balance and allowance, so a wallet with plenty of tokens but no approval reads as zero. Raise it with Approve Settlement Asset.
The same holds for the security under TRANSFER delivery: the available figure is the lesser of the unfrozen balance and securityAllowance. Raise it with Approve Security.
A balance read that fails answers with zeros rather than an error. Treat an unexpected zero as suspect if the wallet is known to be funded, and check Get Trade Readiness, which does surface a chain failure explicitly.
curl "https://api.trusset.org/orderbooks/external-securities/api/order-books/clx_ob_extsec_001/security?userAddress=0xabc7f1093d5e26b804a1c3f78de025916b47c0d3" \
-H "X-API-Key: trusset_your_key_here"
const res = await fetch(
`https://api.trusset.org/orderbooks/external-securities/api/order-books/${orderBookId}/security?userAddress=${address}`,
{ headers: { 'X-API-Key': 'trusset_your_key_here' } }
);
const { data } = await res.json();
const signature = await signer._signTypedData(data.eip712.domain, data.eip712.types, order);
{
"success": true,
"data": {
"orderBookId": "clx_ob_extsec_001",
"custodyContract": "0x489aee4ae9546081d55848f157e03192e826988c",
"tokenAddress": "0x51f2b9d0e77c4a1b83ce6d4a9271e5f3a0c8b912",
"quoteTokenAddress": "0x98ad0ca091552e23c564b41c74282e5343d03e8a",
"underlyingIdentifier": "CH0012032048",
"baseDecimals": 18,
"quoteDecimals": 6,
"settlementOperator": "0x5ad87a0621175206b72d10e4b8577b192e7f40ab",
"security": {
"admin": "0x7712db30a7b4ffd9c445793089118b60e56d752a",
"isin": "CH0012032048",
"isinRaw": "0x4348303031323033323034380000000000000000000000000000000000000000",
"baseUnit": "1000000000000000000",
"registered": true,
"active": true
},
"eip712": {
"domain": {
"name": "TRexCustody",
"version": "1",
"chainId": 11155111,
"verifyingContract": "0x489AeE4ae9546081d55848F157E03192e826988c"
},
"types": {
"Order": [
{ "name": "trader", "type": "address" },
{ "name": "token", "type": "address" },
{ "name": "quote", "type": "address" },
{ "name": "isBuy", "type": "bool" },
{ "name": "quantity", "type": "uint256" },
{ "name": "price", "type": "uint256" },
{ "name": "expiry", "type": "uint64" },
{ "name": "nonce", "type": "uint64" },
{ "name": "salt", "type": "bytes32" }
]
}
},
"balances": {
"base": {
"total": "500000000000000000000",
"locked": "0",
"onChainAvailable": "500000000000000000000",
"reserved": "20000000000000000000",
"available": "480000000000000000000"
},
"quote": {
"total": "100000000000",
"locked": "0",
"onChainAvailable": "50000000000",
"reserved": "0",
"available": "50000000000"
}
},
"quoteAllowance": "50000000000"
}
}
Error Codes
| Code | HTTP | Cause |
|---|---|---|
VALIDATION_ERROR | 400 | userAddress is not a valid address |
ORDER_BOOK_NOT_FOUND | 404 | No such external securities book on this instance, and not imported |
CHAIN_UNAVAILABLE | 503 | The custody contract could not be read |
SERVICE_NOT_ENABLED | 403 | The Trading service is not enabled on this instance |
⌘I
curl "https://api.trusset.org/orderbooks/external-securities/api/order-books/clx_ob_extsec_001/security?userAddress=0xabc7f1093d5e26b804a1c3f78de025916b47c0d3" \
-H "X-API-Key: trusset_your_key_here"
const res = await fetch(
`https://api.trusset.org/orderbooks/external-securities/api/order-books/${orderBookId}/security?userAddress=${address}`,
{ headers: { 'X-API-Key': 'trusset_your_key_here' } }
);
const { data } = await res.json();
const signature = await signer._signTypedData(data.eip712.domain, data.eip712.types, order);
{
"success": true,
"data": {
"orderBookId": "clx_ob_extsec_001",
"custodyContract": "0x489aee4ae9546081d55848f157e03192e826988c",
"tokenAddress": "0x51f2b9d0e77c4a1b83ce6d4a9271e5f3a0c8b912",
"quoteTokenAddress": "0x98ad0ca091552e23c564b41c74282e5343d03e8a",
"underlyingIdentifier": "CH0012032048",
"baseDecimals": 18,
"quoteDecimals": 6,
"settlementOperator": "0x5ad87a0621175206b72d10e4b8577b192e7f40ab",
"security": {
"admin": "0x7712db30a7b4ffd9c445793089118b60e56d752a",
"isin": "CH0012032048",
"isinRaw": "0x4348303031323033323034380000000000000000000000000000000000000000",
"baseUnit": "1000000000000000000",
"registered": true,
"active": true
},
"eip712": {
"domain": {
"name": "TRexCustody",
"version": "1",
"chainId": 11155111,
"verifyingContract": "0x489AeE4ae9546081d55848F157E03192e826988c"
},
"types": {
"Order": [
{ "name": "trader", "type": "address" },
{ "name": "token", "type": "address" },
{ "name": "quote", "type": "address" },
{ "name": "isBuy", "type": "bool" },
{ "name": "quantity", "type": "uint256" },
{ "name": "price", "type": "uint256" },
{ "name": "expiry", "type": "uint64" },
{ "name": "nonce", "type": "uint64" },
{ "name": "salt", "type": "bytes32" }
]
}
},
"balances": {
"base": {
"total": "500000000000000000000",
"locked": "0",
"onChainAvailable": "500000000000000000000",
"reserved": "20000000000000000000",
"available": "480000000000000000000"
},
"quote": {
"total": "100000000000",
"locked": "0",
"onChainAvailable": "50000000000",
"reserved": "0",
"available": "50000000000"
}
},
"quoteAllowance": "50000000000"
}
}
