mirror of
https://github.com/orionprotocol/sdk.git
synced 2026-03-14 14:12:35 +03:00
Added new docs
This commit is contained in:
51
README.md
51
README.md
@@ -244,22 +244,21 @@ if (placeOrderFetchResult.isErr()) {
|
||||
Available subscriptions:
|
||||
|
||||
```ts
|
||||
ASSET_PAIRS_CONFIG_UPDATES_SUBSCRIBE = 'apcus',
|
||||
AGGREGATED_ORDER_BOOK_UPDATES_SUBSCRIBE = 'aobus',
|
||||
ADDRESS_UPDATES_SUBSCRIBE = 'aus', // Orders history, balances info
|
||||
BROKER_TRADABLE_ATOMIC_SWAP_ASSETS_BALANCE_UPDATES_SUBSCRIBE = 'btasabus',
|
||||
SWAP_SUBSCRIBE = 'ss', // Swap info updates
|
||||
AGGREGATED_ORDER_BOOK_UPDATES_SUBSCRIBE = 'aobus', // Bids and asks
|
||||
ASSET_PAIRS_CONFIG_UPDATES_SUBSCRIBE = 'apcus',
|
||||
BROKER_TRADABLE_ATOMIC_SWAP_ASSETS_BALANCE_UPDATES_SUBSCRIBE = 'btasabus', // Need for Orion Bridge
|
||||
```
|
||||
|
||||
Example:
|
||||
|
||||
```ts
|
||||
import { services } from "@orionprotocol/sdk";
|
||||
import { v4 as uuidv4 } from "uuid";
|
||||
|
||||
const swapRequestId = uuidv4();
|
||||
orionUnit.orionAggregator.ws.subscribe(
|
||||
services.orionAggregator.ws.SubscriptionType.SWAP_SUBSCRIBE,
|
||||
"ss", // SWAP_SUBSCRIBE
|
||||
{
|
||||
payload: {
|
||||
d: swapRequestId, // generated by client
|
||||
@@ -282,3 +281,45 @@ orionUnit.orionAggregator.ws.subscribe(
|
||||
}
|
||||
);
|
||||
```
|
||||
|
||||
### Balances and order history stream
|
||||
|
||||
```ts
|
||||
orionUnit.orionAggregator.ws.subscribe(
|
||||
"aus", // ADDRESS_UPDATES_SUBSCRIBE — orders, balances
|
||||
{
|
||||
payload: "0x0000000000000000000000000000000000000000", // Some wallet address
|
||||
callback: ({ fullOrders, orderUpdate, balances }) => {
|
||||
// Each field is optional
|
||||
if (fullOrders) console.log(fullOrders); // Completed orders
|
||||
|
||||
if (orderUpdate) {
|
||||
switch (orderUpdate.kind) {
|
||||
case "full":
|
||||
console.log("Order completed", orderUpdate);
|
||||
break;
|
||||
case "update":
|
||||
console.log("Order in the process of execution", orderUpdate);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (balances) console.log("Balance update", balances);
|
||||
},
|
||||
}
|
||||
);
|
||||
```
|
||||
|
||||
### Orderbook stream
|
||||
|
||||
```ts
|
||||
orionUnit.orionAggregator.ws.subscribe("aobus", {
|
||||
payload: "ORN-USDT", // Some trading pair
|
||||
callback: (asks, bids, pairName) => {
|
||||
console.log("Orderbook asks", asks);
|
||||
console.log("Orderbook bids", bids);
|
||||
},
|
||||
});
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user