@volare.finance/volare.js
Version:
The SDK for Volare Protocol
50 lines • 1.93 kB
JavaScript
;
/**
* @file swap.ts
* @author astra <astra@volare.finance>
* @date 2022
*/
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
const utils_js_1 = require("@volare.finance/utils.js");
const axios_1 = tslib_1.__importDefault(require("axios"));
const dotenv_1 = require("dotenv");
const src_1 = require("../../src");
const swap_1 = require("../../src/apis/swap");
(0, dotenv_1.config)({
path: '.env',
encoding: 'utf8',
});
const URL = String(process.env.API_URL);
const ENDPOINT = String(process.env.ENDPOINT);
if (!utils_js_1.ERC20.IsInited()) {
utils_js_1.ERC20.Init(ENDPOINT);
}
(() => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
const instance = axios_1.default.create({
baseURL: URL,
headers: {
'Content-Type': 'application/json; charset=utf-8',
},
});
const swap = new swap_1.Swap(instance);
const products = yield swap.products();
console.log(JSON.stringify(products, undefined, 2));
const expires = yield swap.expires(products[0].symbol);
console.log(JSON.stringify(expires, undefined, 2));
const pairs = yield swap.pairs();
console.log(JSON.stringify(pairs, undefined, 2));
const pair = yield swap.pair(pairs[0].asset);
console.log(JSON.stringify(pair, undefined, 2));
const orderbook = yield swap.orderbook(pairs[0].asset, src_1.OrderSide.Ask);
console.log(JSON.stringify(orderbook, undefined, 2));
const trades = yield swap.trades(pairs[0].asset);
console.log(JSON.stringify(trades, undefined, 2));
const orders = yield swap.orders();
console.log(JSON.stringify(orders, undefined, 2));
const order = yield swap.order(orders[0].orderHash);
console.log(JSON.stringify(order, undefined, 2));
const history = yield swap.history();
console.log(JSON.stringify(history, undefined, 2));
}))();
//# sourceMappingURL=swap.js.map