This commit is contained in:
Aleksandr Kraiz
2022-06-04 18:17:16 +04:00
parent 201d41e94b
commit 40a39f7cd2
4 changed files with 80 additions and 69 deletions

View File

@@ -24,7 +24,6 @@ Orions SDK is free to use and does not require an API key or registration. Re
- [Remove all liquidity](#remove-all-liquidity)
- [Low level methods](#low-level-methods)
- [Get historical price](#get-historical-price)
- [Using contracts](#using-contracts)
- [Get tradable pairs](#get-tradable-pairs)
- [Get swap info](#get-swap-info)
- [Place order in Orion Aggregator](#place-order-in-orion-aggregator)
@@ -35,6 +34,7 @@ Orions SDK is free to use and does not require an API key or registration. Re
- [Orion Aggregator WS Stream Unsubscribing](#orion-aggregator-ws-stream-unsubscribing)
- [Price Feed Websocket Stream](#price-feed-websocket-stream)
- [About our fetching system](#about-our-fetching-system)
- [Using contracts](#using-contracts)
## Install
@@ -192,31 +192,6 @@ const candles = await simpleFetch(orionUnit.priceFeed.getCandles)(
);
```
### Using contracts
```ts
import {
Exchange__factory,
ERC20__factory,
OrionGovernance__factory,
OrionVoting__factory,
} from "@orionprotocol/contracts";
const exchangeContract = Exchange__factory.connect(
exchangeContractAddress,
orionUnit.provider
);
const erc20Contract = ERC20__factory.connect(tokenAddress, orionUnit.provider);
const governanceContract = OrionGovernance__factory.connect(
governanceAddress,
orionUnit.provider
);
const orionVoting = OrionVoting__factory.connect(
votingContractAddress,
orionUnit.provider
);
```
### Get tradable pairs
```ts
@@ -240,7 +215,7 @@ const swapInfo = await simpleFetch(orionUnit.orionAggregator.getSwapInfo)(
);
```
Swap info eesponse example:
Swap info response example:
```json
{
@@ -332,14 +307,11 @@ BROKER_TRADABLE_ATOMIC_SWAP_ASSETS_BALANCE_UPDATES_SUBSCRIBE = 'btasabus', // Ne
### Swap Info
```ts
import { v4 as uuidv4 } from "uuid";
const swapRequestId = uuidv4();
orionUnit.orionAggregator.ws.subscribe(
const swapRequestId = orionUnit.orionAggregator.ws.subscribe(
"ss", // SWAP_SUBSCRIBE
{
payload: {
d: swapRequestId, // generated by client
i: assetIn, // asset in
o: assetOut, // asset out
e: true, // true when type of swap is exactSpend, can be omitted (true by default)
@@ -359,6 +331,9 @@ orionUnit.orionAggregator.ws.subscribe(
},
}
);
orionAggregator.ws.unsubscribe(swapRequestId);
```
### Balances and order history stream
@@ -393,6 +368,10 @@ orionUnit.orionAggregator.ws.subscribe(
},
}
);
orionUnit.orionAggregator.ws.unsubscribe(
"0x0000000000000000000000000000000000000000"
);
```
### Orderbook stream
@@ -405,22 +384,13 @@ orionUnit.orionAggregator.ws.subscribe("aobus", {
console.log(`${pairName} orderbook bids`, bids);
},
});
orionUnit.orionAggregator.ws.unsubscribe("ORN-USDT");
```
### Orion Aggregator WS Stream Unsubscribing
```ts
// Swap request unsubscribe
orionAggregator.ws.unsubscribe(swapRequestId); // Pass here id that you generate when subscribe
// Address update (balances / order history) unsubscribe
orionUnit.orionAggregator.ws.unsubscribe(
"0x0000000000000000000000000000000000000000"
);
// Pair orderbook unsubscribe
orionUnit.orionAggregator.ws.unsubscribe("ORN-USDT");
// Asset pairs config updates unsubscribe
orionUnit.orionAggregator.ws.unsubscribe("apcu");
@@ -511,3 +481,7 @@ const { candles, timeStart, timeEnd } = await simpleFetch(
// Here we can handle response data
```
## Using contracts
Use package [@prionprotocol/contracts](https://github.com/orionprotocol/contracts)