mirror of
https://github.com/orionprotocol/sdk.git
synced 2026-03-14 06:02:36 +03:00
Docs improvements
This commit is contained in:
41
README.md
41
README.md
@@ -15,6 +15,8 @@ npm i @orionprotocol/sdk
|
|||||||
|
|
||||||
### Initialization
|
### Initialization
|
||||||
|
|
||||||
|
> :warning: **Ethers ^5.6.0 required**
|
||||||
|
|
||||||
```js
|
```js
|
||||||
// Node.js
|
// Node.js
|
||||||
import { OrionUnit } from "@orionprotocol/sdk";
|
import { OrionUnit } from "@orionprotocol/sdk";
|
||||||
@@ -121,10 +123,9 @@ import { simpleFetch } from "@orionprotocol/sdk";
|
|||||||
|
|
||||||
const candles = await simpleFetch(orionUnit.priceFeed.getCandles)(
|
const candles = await simpleFetch(orionUnit.priceFeed.getCandles)(
|
||||||
"ORN-USDT",
|
"ORN-USDT",
|
||||||
1650287678, // interval start
|
1650287678, // interval start, unix timestamp
|
||||||
1650374078, // interval end
|
1650374078, // interval end, unix timestamp
|
||||||
"5m", // interval
|
"5m" // '5m' or '30m' or '1h' or '1d',
|
||||||
"all" // exchange
|
|
||||||
);
|
);
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -158,6 +159,7 @@ const orionVoting = OrionVoting__factory.connect(
|
|||||||
```ts
|
```ts
|
||||||
import { simpleFetch } from "@orionprotocol/sdk";
|
import { simpleFetch } from "@orionprotocol/sdk";
|
||||||
const pairsList = await simpleFetch(orionUnit.orionAggregator.getPairsList)();
|
const pairsList = await simpleFetch(orionUnit.orionAggregator.getPairsList)();
|
||||||
|
console.log(pairsList); // ['ORN-USDT', 'BNB-ORN', 'FTM-ORN', 'ETH-ORN']
|
||||||
```
|
```
|
||||||
|
|
||||||
### Get swap info
|
### Get swap info
|
||||||
@@ -170,11 +172,40 @@ const swapInfo = await simpleFetch(orionUnit.orionAggregator.getSwapInfo)(
|
|||||||
"exactSpend", // type
|
"exactSpend", // type
|
||||||
"ORN", // asset in
|
"ORN", // asset in
|
||||||
"USDT", // asset out
|
"USDT", // asset out
|
||||||
6.23453457, // amount
|
25.23453457, // amount
|
||||||
["ORION_POOL"] // Exchanges. OPTIONAL! Specify ['ORION_POOL'] if you want "pool only" swap execution
|
["ORION_POOL"] // Exchanges. OPTIONAL! Specify ['ORION_POOL'] if you want "pool only" swap execution
|
||||||
);
|
);
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Swap info eesponse example:
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"id": "2275c9b1-5c42-40c4-805f-bb1e685029f9",
|
||||||
|
"assetIn": "ORN",
|
||||||
|
"amountIn": 25.23453457,
|
||||||
|
"assetOut": "USDT",
|
||||||
|
"amountOut": 37.11892965,
|
||||||
|
"price": 1.47095757,
|
||||||
|
"marketAmountOut": 37.11892965,
|
||||||
|
"marketAmountIn": null,
|
||||||
|
"marketPrice": 1.47095757,
|
||||||
|
"minAmountIn": 8.2,
|
||||||
|
"minAmountOut": 12,
|
||||||
|
"availableAmountIn": 25.2,
|
||||||
|
"availableAmountOut": null,
|
||||||
|
"path": ["ORN", "USDT"],
|
||||||
|
"isThroughPoolOptimal": true,
|
||||||
|
"orderInfo": {
|
||||||
|
"assetPair": "ORN-USDT",
|
||||||
|
"side": "SELL",
|
||||||
|
"amount": 25.2,
|
||||||
|
"safePrice": 1.468
|
||||||
|
},
|
||||||
|
"executionInfo": "ORION_POOL: ORN -> USDT (length = 1): 25.23453457 ORN -> 37.11892965 USDT, market amount out = 37.11892965 USDT, price = 1.47095757 USDT/ORN (order SELL 25.2 @ 1.47 (safe price 1.468) on ORN-USDT), available amount in = 25.2 ORN, steps: {[1]: 25.23453457 ORN -> 37.11892965 USDT, price = 1.47095757 USDT/ORN, passed amount in = 25.23453457 ORN, amount out = cost of SELL on ORN-USDT order by min price = 1.47095757 USDT/ORN (sell by amount), avgWeighedPrice = 1.47095757 USDT/ORN, cost by avgWeighedPrice = 37.11892965 USDT, executed sell amount = 25.23453457 ORN}"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
### Place order in Orion Aggregator
|
### Place order in Orion Aggregator
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ class PriceFeed {
|
|||||||
timeStart: number,
|
timeStart: number,
|
||||||
timeEnd: number,
|
timeEnd: number,
|
||||||
interval: '5m' | '30m' | '1h' | '1d',
|
interval: '5m' | '30m' | '1h' | '1d',
|
||||||
exchange: string,
|
exchange = 'all',
|
||||||
) => {
|
) => {
|
||||||
const url = new URL(this.candlesUrl);
|
const url = new URL(this.candlesUrl);
|
||||||
url.searchParams.append('symbol', symbol);
|
url.searchParams.append('symbol', symbol);
|
||||||
|
|||||||
Reference in New Issue
Block a user