@pioneer-platform/osmosis-client 0.0.2 → 0.0.4
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 +17 -2
- package/package.json +3 -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,21 @@ 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
|
+
output.meta = {
|
|
253
|
+
quoteMode: "OSMOSIS-IBC"
|
|
254
|
+
};
|
|
255
|
+
// get amountOut
|
|
256
|
+
//2 steps
|
|
257
|
+
output.steps = 2;
|
|
258
|
+
output.complete = true;
|
|
248
259
|
result = void 0;
|
|
249
260
|
if (!(quote.sellAsset === shortListSymbolToCaip["OSMO"])) return [3 /*break*/, 5];
|
|
250
261
|
result = quoteFromPool(quote.sellAmount, amountAtom, amountOsmo);
|
|
262
|
+
output.result = result;
|
|
251
263
|
return [4 /*yield*/, build_swap_tx(quote.senderAddress, quote.sellAsset, quote.buyAsset, quote.sellAmount, result.amountOut)];
|
|
252
264
|
case 3:
|
|
253
265
|
tx1 = _a.sent();
|
|
@@ -256,10 +268,12 @@ var get_quote = function (quote) {
|
|
|
256
268
|
case 4:
|
|
257
269
|
tx2 = _a.sent();
|
|
258
270
|
log.info(tag, "tx2: ", tx2);
|
|
271
|
+
output.txs = [tx1, tx2];
|
|
259
272
|
return [3 /*break*/, 9];
|
|
260
273
|
case 5:
|
|
261
274
|
if (!(quote.sellAsset === shortListSymbolToCaip["ATOM"])) return [3 /*break*/, 8];
|
|
262
275
|
result = quoteFromPool(quote.sellAmount, amountAtom, amountOsmo);
|
|
276
|
+
output.result = result;
|
|
263
277
|
return [4 /*yield*/, build_ibc_tx(quote.recipientAddress, quote.senderAddress, result.amountOut)];
|
|
264
278
|
case 6:
|
|
265
279
|
tx2 = _a.sent();
|
|
@@ -268,9 +282,10 @@ var get_quote = function (quote) {
|
|
|
268
282
|
case 7:
|
|
269
283
|
tx1 = _a.sent();
|
|
270
284
|
log.info(tag, "tx1: ", tx1);
|
|
285
|
+
output.txs = [tx1, tx2];
|
|
271
286
|
return [3 /*break*/, 9];
|
|
272
287
|
case 8: throw Error("Asset not supported! asset:" + quote.sellAsset);
|
|
273
|
-
case 9: return [2 /*return*/,
|
|
288
|
+
case 9: return [2 /*return*/, output];
|
|
274
289
|
case 10:
|
|
275
290
|
e_3 = _a.sent();
|
|
276
291
|
console.error(tag, "e: ", e_3);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pioneer-platform/osmosis-client",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.4",
|
|
4
4
|
"main": "./lib/index.js",
|
|
5
5
|
"types": "./lib/index.d.ts",
|
|
6
6
|
"dependencies": {
|
|
@@ -10,7 +10,8 @@
|
|
|
10
10
|
"@pioneer-platform/pioneer-coins": "^9.2.3",
|
|
11
11
|
"axios": "^1.3.4",
|
|
12
12
|
"dotenv": "^8.2.0",
|
|
13
|
-
"rango-sdk": "^0.1.45"
|
|
13
|
+
"rango-sdk": "^0.1.45",
|
|
14
|
+
"uuidv4": "^6.2.13"
|
|
14
15
|
},
|
|
15
16
|
"scripts": {
|
|
16
17
|
"npm": "npm i",
|