@pioneer-platform/osmosis-client 0.0.1 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.d.ts +2 -1
- package/lib/index.js +13 -2
- package/package.json +4 -2
package/lib/index.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ declare const log: any;
|
|
|
3
3
|
declare let shortListSymbolToCaip: any;
|
|
4
4
|
declare let networkOsmo: any;
|
|
5
5
|
declare let networkAtom: any;
|
|
6
|
+
declare const uuid: any;
|
|
6
7
|
declare let networkSupport: any[];
|
|
7
8
|
interface QuoteResult {
|
|
8
9
|
amountOut: string;
|
|
@@ -68,4 +69,4 @@ declare const build_ibc_tx: (from: string, to: string, amount: string) => Promis
|
|
|
68
69
|
signatures: never[];
|
|
69
70
|
sequence: any;
|
|
70
71
|
} | undefined>;
|
|
71
|
-
declare const get_quote: (quote: any) => Promise<
|
|
72
|
+
declare const get_quote: (quote: any) => Promise<any>;
|
package/lib/index.js
CHANGED
|
@@ -45,6 +45,7 @@ var log = require('@pioneer-platform/loggerdog')();
|
|
|
45
45
|
var shortListSymbolToCaip = require("@pioneer-platform/pioneer-caip").shortListSymbolToCaip;
|
|
46
46
|
var networkOsmo = require("@pioneer-platform/osmosis-network");
|
|
47
47
|
var networkAtom = require("@pioneer-platform/cosmos-network");
|
|
48
|
+
var uuid = require('uuidv4').uuid;
|
|
48
49
|
var networkSupport = [
|
|
49
50
|
shortListSymbolToCaip["OSMO"],
|
|
50
51
|
shortListSymbolToCaip["GAIA"],
|
|
@@ -216,7 +217,7 @@ var build_ibc_tx = function (from, to, amount) {
|
|
|
216
217
|
};
|
|
217
218
|
var get_quote = function (quote) {
|
|
218
219
|
return __awaiter(this, void 0, void 0, function () {
|
|
219
|
-
var tag, output, pools, amountAtom, amountOsmo, rate, result, tx1, tx2, tx2, tx1, e_3;
|
|
220
|
+
var tag, output, pools, amountAtom, amountOsmo, rate, invocationId, result, tx1, tx2, tx2, tx1, e_3;
|
|
220
221
|
return __generator(this, function (_a) {
|
|
221
222
|
switch (_a.label) {
|
|
222
223
|
case 0:
|
|
@@ -244,10 +245,17 @@ var get_quote = function (quote) {
|
|
|
244
245
|
amountAtom = pools.pools[0].pool_assets[0].token.amount;
|
|
245
246
|
amountOsmo = pools.pools[0].pool_assets[1].token.amount;
|
|
246
247
|
rate = amountOsmo / amountAtom;
|
|
248
|
+
output.rate = rate;
|
|
247
249
|
log.info(tag, "rate: ", rate);
|
|
250
|
+
invocationId = uuid();
|
|
251
|
+
output.invocationId = invocationId;
|
|
252
|
+
// get amountOut
|
|
253
|
+
//2 steps
|
|
254
|
+
output.steps = 2;
|
|
248
255
|
result = void 0;
|
|
249
256
|
if (!(quote.sellAsset === shortListSymbolToCaip["OSMO"])) return [3 /*break*/, 5];
|
|
250
257
|
result = quoteFromPool(quote.sellAmount, amountAtom, amountOsmo);
|
|
258
|
+
output.result = result;
|
|
251
259
|
return [4 /*yield*/, build_swap_tx(quote.senderAddress, quote.sellAsset, quote.buyAsset, quote.sellAmount, result.amountOut)];
|
|
252
260
|
case 3:
|
|
253
261
|
tx1 = _a.sent();
|
|
@@ -256,10 +264,12 @@ var get_quote = function (quote) {
|
|
|
256
264
|
case 4:
|
|
257
265
|
tx2 = _a.sent();
|
|
258
266
|
log.info(tag, "tx2: ", tx2);
|
|
267
|
+
output.txs = [tx1, tx2];
|
|
259
268
|
return [3 /*break*/, 9];
|
|
260
269
|
case 5:
|
|
261
270
|
if (!(quote.sellAsset === shortListSymbolToCaip["ATOM"])) return [3 /*break*/, 8];
|
|
262
271
|
result = quoteFromPool(quote.sellAmount, amountAtom, amountOsmo);
|
|
272
|
+
output.result = result;
|
|
263
273
|
return [4 /*yield*/, build_ibc_tx(quote.recipientAddress, quote.senderAddress, result.amountOut)];
|
|
264
274
|
case 6:
|
|
265
275
|
tx2 = _a.sent();
|
|
@@ -268,9 +278,10 @@ var get_quote = function (quote) {
|
|
|
268
278
|
case 7:
|
|
269
279
|
tx1 = _a.sent();
|
|
270
280
|
log.info(tag, "tx1: ", tx1);
|
|
281
|
+
output.txs = [tx1, tx2];
|
|
271
282
|
return [3 /*break*/, 9];
|
|
272
283
|
case 8: throw Error("Asset not supported! asset:" + quote.sellAsset);
|
|
273
|
-
case 9: return [2 /*return*/,
|
|
284
|
+
case 9: return [2 /*return*/, output];
|
|
274
285
|
case 10:
|
|
275
286
|
e_3 = _a.sent();
|
|
276
287
|
console.error(tag, "e: ", e_3);
|
package/package.json
CHANGED
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pioneer-platform/osmosis-client",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.3",
|
|
4
4
|
"main": "./lib/index.js",
|
|
5
5
|
"types": "./lib/index.d.ts",
|
|
6
6
|
"dependencies": {
|
|
7
7
|
"@pioneer-platform/cosmos-network": "^8.3.1",
|
|
8
8
|
"@pioneer-platform/loggerdog": "^8.3.1",
|
|
9
|
+
"@pioneer-platform/osmosis-network": "^8.3.7",
|
|
9
10
|
"@pioneer-platform/pioneer-coins": "^9.2.3",
|
|
10
11
|
"axios": "^1.3.4",
|
|
11
12
|
"dotenv": "^8.2.0",
|
|
12
|
-
"rango-sdk": "^0.1.45"
|
|
13
|
+
"rango-sdk": "^0.1.45",
|
|
14
|
+
"uuidv4": "^6.2.13"
|
|
13
15
|
},
|
|
14
16
|
"scripts": {
|
|
15
17
|
"npm": "npm i",
|