@ref-finance/ref-sdk 1.2.0 → 1.2.2

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.
@@ -179,6 +179,9 @@ function _regeneratorRuntime() {
179
179
  var exports = {},
180
180
  Op = Object.prototype,
181
181
  hasOwn = Op.hasOwnProperty,
182
+ defineProperty = Object.defineProperty || function (obj, key, desc) {
183
+ obj[key] = desc.value;
184
+ },
182
185
  $Symbol = "function" == typeof Symbol ? Symbol : {},
183
186
  iteratorSymbol = $Symbol.iterator || "@@iterator",
184
187
  asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator",
@@ -202,40 +205,9 @@ function _regeneratorRuntime() {
202
205
  var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator,
203
206
  generator = Object.create(protoGenerator.prototype),
204
207
  context = new Context(tryLocsList || []);
205
- return generator._invoke = function (innerFn, self, context) {
206
- var state = "suspendedStart";
207
- return function (method, arg) {
208
- if ("executing" === state) throw new Error("Generator is already running");
209
- if ("completed" === state) {
210
- if ("throw" === method) throw arg;
211
- return doneResult();
212
- }
213
- for (context.method = method, context.arg = arg;;) {
214
- var delegate = context.delegate;
215
- if (delegate) {
216
- var delegateResult = maybeInvokeDelegate(delegate, context);
217
- if (delegateResult) {
218
- if (delegateResult === ContinueSentinel) continue;
219
- return delegateResult;
220
- }
221
- }
222
- if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) {
223
- if ("suspendedStart" === state) throw state = "completed", context.arg;
224
- context.dispatchException(context.arg);
225
- } else "return" === context.method && context.abrupt("return", context.arg);
226
- state = "executing";
227
- var record = tryCatch(innerFn, self, context);
228
- if ("normal" === record.type) {
229
- if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue;
230
- return {
231
- value: record.arg,
232
- done: context.done
233
- };
234
- }
235
- "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg);
236
- }
237
- };
238
- }(innerFn, self, context), generator;
208
+ return defineProperty(generator, "_invoke", {
209
+ value: makeInvokeMethod(innerFn, self, context)
210
+ }), generator;
239
211
  }
240
212
  function tryCatch(fn, obj, arg) {
241
213
  try {
@@ -289,13 +261,49 @@ function _regeneratorRuntime() {
289
261
  reject(record.arg);
290
262
  }
291
263
  var previousPromise;
292
- this._invoke = function (method, arg) {
293
- function callInvokeWithMethodAndArg() {
294
- return new PromiseImpl(function (resolve, reject) {
295
- invoke(method, arg, resolve, reject);
296
- });
264
+ defineProperty(this, "_invoke", {
265
+ value: function (method, arg) {
266
+ function callInvokeWithMethodAndArg() {
267
+ return new PromiseImpl(function (resolve, reject) {
268
+ invoke(method, arg, resolve, reject);
269
+ });
270
+ }
271
+ return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
272
+ }
273
+ });
274
+ }
275
+ function makeInvokeMethod(innerFn, self, context) {
276
+ var state = "suspendedStart";
277
+ return function (method, arg) {
278
+ if ("executing" === state) throw new Error("Generator is already running");
279
+ if ("completed" === state) {
280
+ if ("throw" === method) throw arg;
281
+ return doneResult();
282
+ }
283
+ for (context.method = method, context.arg = arg;;) {
284
+ var delegate = context.delegate;
285
+ if (delegate) {
286
+ var delegateResult = maybeInvokeDelegate(delegate, context);
287
+ if (delegateResult) {
288
+ if (delegateResult === ContinueSentinel) continue;
289
+ return delegateResult;
290
+ }
291
+ }
292
+ if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) {
293
+ if ("suspendedStart" === state) throw state = "completed", context.arg;
294
+ context.dispatchException(context.arg);
295
+ } else "return" === context.method && context.abrupt("return", context.arg);
296
+ state = "executing";
297
+ var record = tryCatch(innerFn, self, context);
298
+ if ("normal" === record.type) {
299
+ if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue;
300
+ return {
301
+ value: record.arg,
302
+ done: context.done
303
+ };
304
+ }
305
+ "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg);
297
306
  }
298
- return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
299
307
  };
300
308
  }
301
309
  function maybeInvokeDelegate(delegate, context) {
@@ -351,7 +359,13 @@ function _regeneratorRuntime() {
351
359
  done: !0
352
360
  };
353
361
  }
354
- return GeneratorFunction.prototype = GeneratorFunctionPrototype, define(Gp, "constructor", GeneratorFunctionPrototype), define(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) {
362
+ return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", {
363
+ value: GeneratorFunctionPrototype,
364
+ configurable: !0
365
+ }), defineProperty(GeneratorFunctionPrototype, "constructor", {
366
+ value: GeneratorFunction,
367
+ configurable: !0
368
+ }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) {
355
369
  var ctor = "function" == typeof genFun && genFun.constructor;
356
370
  return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name));
357
371
  }, exports.mark = function (genFun) {
@@ -372,8 +386,9 @@ function _regeneratorRuntime() {
372
386
  return this;
373
387
  }), define(Gp, "toString", function () {
374
388
  return "[object Generator]";
375
- }), exports.keys = function (object) {
376
- var keys = [];
389
+ }), exports.keys = function (val) {
390
+ var object = Object(val),
391
+ keys = [];
377
392
  for (var key in object) keys.push(key);
378
393
  return keys.reverse(), function next() {
379
394
  for (; keys.length;) {
@@ -862,7 +877,7 @@ function checkIntegerSumOfAllocations(allocations, totalInput) {
862
877
  return newAllocations;
863
878
  }
864
879
 
865
- var _marked5 = /*#__PURE__*/_regeneratorRuntime().mark(yenFromPy);
880
+ var _marked3 = /*#__PURE__*/_regeneratorRuntime().mark(yenFromPy);
866
881
  Big.RM = 0;
867
882
  Big.DP = 40;
868
883
  Big.NE = -40;
@@ -1284,8 +1299,8 @@ function getBestOptimalAllocationsAndOutputs(_x, _x2, _x3, _x4, _x5, _x6) {
1284
1299
  return _getBestOptimalAllocationsAndOutputs.apply(this, arguments);
1285
1300
  }
1286
1301
  function _getBestOptimalAllocationsAndOutputs() {
1287
- _getBestOptimalAllocationsAndOutputs = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(pools, inputToken, outputToken, totalInput, maxPathLength, threshold) {
1288
- return _regeneratorRuntime().wrap(function _callee2$(_context7) {
1302
+ _getBestOptimalAllocationsAndOutputs = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(pools, inputToken, outputToken, totalInput, maxPathLength, threshold) {
1303
+ return _regeneratorRuntime().wrap(function _callee4$(_context7) {
1289
1304
  while (1) {
1290
1305
  switch (_context7.prev = _context7.next) {
1291
1306
  case 0:
@@ -1296,9 +1311,9 @@ function _getBestOptimalAllocationsAndOutputs() {
1296
1311
  threshold = 0.001;
1297
1312
  }
1298
1313
  return _context7.abrupt("return", function () {
1299
- var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(totalInput) {
1314
+ var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(totalInput) {
1300
1315
  var paths, poolChains, routes, nodeRoutes, inputOutput, allocations, outputs;
1301
- return _regeneratorRuntime().wrap(function _callee$(_context6) {
1316
+ return _regeneratorRuntime().wrap(function _callee3$(_context6) {
1302
1317
  while (1) {
1303
1318
  switch (_context6.prev = _context6.next) {
1304
1319
  case 0:
@@ -1347,7 +1362,7 @@ function _getBestOptimalAllocationsAndOutputs() {
1347
1362
  return _context6.stop();
1348
1363
  }
1349
1364
  }
1350
- }, _callee);
1365
+ }, _callee3);
1351
1366
  }));
1352
1367
  return function (_x33) {
1353
1368
  return _ref.apply(this, arguments);
@@ -1358,7 +1373,7 @@ function _getBestOptimalAllocationsAndOutputs() {
1358
1373
  return _context7.stop();
1359
1374
  }
1360
1375
  }
1361
- }, _callee2);
1376
+ }, _callee4);
1362
1377
  }));
1363
1378
  return _getBestOptimalAllocationsAndOutputs.apply(this, arguments);
1364
1379
  }
@@ -1468,8 +1483,8 @@ function getSmartRouteSwapActions(_x7, _x8, _x9, _x10, _x11, _x12, _x13, _x14, _
1468
1483
  return _getSmartRouteSwapActions.apply(this, arguments);
1469
1484
  }
1470
1485
  function _getSmartRouteSwapActions() {
1471
- _getSmartRouteSwapActions = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(pools, inputToken, outputToken, totalInput, allTokens, maxPathLength, threshold, numberOfRoutesLimit, MAX_NUMBER_PARALLEL_POOLS, decimalsCulledPoolIds) {
1472
- return _regeneratorRuntime().wrap(function _callee5$(_context10) {
1486
+ _getSmartRouteSwapActions = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(pools, inputToken, outputToken, totalInput, allTokens, maxPathLength, threshold, numberOfRoutesLimit, MAX_NUMBER_PARALLEL_POOLS, decimalsCulledPoolIds) {
1487
+ return _regeneratorRuntime().wrap(function _callee7$(_context10) {
1473
1488
  while (1) {
1474
1489
  switch (_context10.prev = _context10.next) {
1475
1490
  case 0:
@@ -1489,9 +1504,9 @@ function _getSmartRouteSwapActions() {
1489
1504
  decimalsCulledPoolIds = [];
1490
1505
  }
1491
1506
  return _context10.abrupt("return", function () {
1492
- var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(totalInput) {
1507
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(totalInput) {
1493
1508
  var resDict, allocations, routes, nodeRoutes, sortedIndexValues, topIndices, reducedRoutes, reducedNodeRoutes, _iterator3, _step3, ind, currentBestOutput, bestAllocations, bestNodeRoutes, bestRoutes, parallelNodeRoutes, parallelRoutes, n, currentNodeRoute, bestRoutesAreParallel, _filteredAllocationsAndOutputs, parallellAllocations, parallelOutputs, sortIndices, filteredParallelRoutes, filteredParallelNodeRoutes, i, parallelOutput, canHaveTwoRoutes, j, route1, route2, nodeRoute1, nodeRoute2, _route1PoolIds, route2PoolIds, sharePool, _iterator4, _step4, route1PoolId, currentRoutes, currentNodeRoutes, _filteredAllocationsAndOutputs2, _filteredAllocations, _filteredOutputs, totalOutput, _currentRoutes, _currentNodeRoutes, _filteredAllocationsAndOutputs3, _filteredAllocations2, _filteredOutputs2, _totalOutput, allSortedIndices, sortedIndices, filteredRoutes, filteredNodeRoutes, index, route1PoolIds, _route2PoolIds, sharedRoute, allFilteredRoutes, allFilteredNodeRoutes, firstRoute, firstRoutePoolIds, allFilteredRouteIds, secondRoute, filteredAllocationsAndOutputs, filteredAllocations, hops, actions, _supplies, hopInputTokenMeta, hopOutputTokenMeta, hopOutputTokenDecimals, expectedHopOutput, decimalEstimate, status, tokens, overallPriceImpact, action;
1494
- return _regeneratorRuntime().wrap(function _callee4$(_context9) {
1509
+ return _regeneratorRuntime().wrap(function _callee6$(_context9) {
1495
1510
  while (1) {
1496
1511
  switch (_context9.prev = _context9.next) {
1497
1512
  case 0:
@@ -1886,8 +1901,8 @@ function _getSmartRouteSwapActions() {
1886
1901
  }
1887
1902
  _context9.next = 143;
1888
1903
  return Promise.all(hops[i].nodeRoute.map( /*#__PURE__*/function () {
1889
- var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(t) {
1890
- return _regeneratorRuntime().wrap(function _callee3$(_context8) {
1904
+ var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(t) {
1905
+ return _regeneratorRuntime().wrap(function _callee5$(_context8) {
1891
1906
  while (1) {
1892
1907
  switch (_context8.prev = _context8.next) {
1893
1908
  case 0:
@@ -1910,7 +1925,7 @@ function _getSmartRouteSwapActions() {
1910
1925
  return _context8.stop();
1911
1926
  }
1912
1927
  }
1913
- }, _callee3);
1928
+ }, _callee5);
1914
1929
  }));
1915
1930
  return function (_x35) {
1916
1931
  return _ref3.apply(this, arguments);
@@ -1971,7 +1986,7 @@ function _getSmartRouteSwapActions() {
1971
1986
  return _context9.stop();
1972
1987
  }
1973
1988
  }
1974
- }, _callee4);
1989
+ }, _callee6);
1975
1990
  }));
1976
1991
  return function (_x34) {
1977
1992
  return _ref2.apply(this, arguments);
@@ -1982,7 +1997,7 @@ function _getSmartRouteSwapActions() {
1982
1997
  return _context10.stop();
1983
1998
  }
1984
1999
  }
1985
- }, _callee5);
2000
+ }, _callee7);
1986
2001
  }));
1987
2002
  return _getSmartRouteSwapActions.apply(this, arguments);
1988
2003
  }
@@ -1990,9 +2005,9 @@ function calculateSmartRouteV2PriceImpact(_x17, _x18) {
1990
2005
  return _calculateSmartRouteV2PriceImpact.apply(this, arguments);
1991
2006
  }
1992
2007
  function _calculateSmartRouteV2PriceImpact() {
1993
- _calculateSmartRouteV2PriceImpact = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(actions, allTokens) {
2008
+ _calculateSmartRouteV2PriceImpact = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(actions, allTokens) {
1994
2009
  var deltaY, inputTokenMeta, deltaX, R, P, routes, nodeRoutes, allocations, totalAllocations, weights, i, route, nodeRoute, tokens, weight, num, denom, routeMarketPrice, num1, denom1, num2, denom2, priceImpact;
1995
- return _regeneratorRuntime().wrap(function _callee7$(_context12) {
2010
+ return _regeneratorRuntime().wrap(function _callee9$(_context12) {
1996
2011
  while (1) {
1997
2012
  switch (_context12.prev = _context12.next) {
1998
2013
  case 0:
@@ -2038,8 +2053,8 @@ function _calculateSmartRouteV2PriceImpact() {
2038
2053
  nodeRoute = nodeRoutes[i];
2039
2054
  _context12.next = 17;
2040
2055
  return Promise.all(nodeRoute.map( /*#__PURE__*/function () {
2041
- var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(t) {
2042
- return _regeneratorRuntime().wrap(function _callee6$(_context11) {
2056
+ var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(t) {
2057
+ return _regeneratorRuntime().wrap(function _callee8$(_context11) {
2043
2058
  while (1) {
2044
2059
  switch (_context11.prev = _context11.next) {
2045
2060
  case 0:
@@ -2062,7 +2077,7 @@ function _calculateSmartRouteV2PriceImpact() {
2062
2077
  return _context11.stop();
2063
2078
  }
2064
2079
  }
2065
- }, _callee6);
2080
+ }, _callee8);
2066
2081
  }));
2067
2082
  return function (_x36) {
2068
2083
  return _ref4.apply(this, arguments);
@@ -2093,7 +2108,7 @@ function _calculateSmartRouteV2PriceImpact() {
2093
2108
  return _context12.stop();
2094
2109
  }
2095
2110
  }
2096
- }, _callee7);
2111
+ }, _callee9);
2097
2112
  }));
2098
2113
  return _calculateSmartRouteV2PriceImpact.apply(this, arguments);
2099
2114
  }
@@ -2428,7 +2443,7 @@ function yenFromPy(g, source, target) {
2428
2443
  return _context5.stop();
2429
2444
  }
2430
2445
  }
2431
- }, _marked5, null, [[6, 14]]);
2446
+ }, _marked3, null, [[6, 14]]);
2432
2447
  }
2433
2448
  function getKShortestPaths(g, source, target, k, maxPathLength) {
2434
2449
  if (maxPathLength === void 0) {
@@ -2465,9 +2480,9 @@ function getPathsFromPools(_x19, _x20, _x21, _x22) {
2465
2480
  return _getPathsFromPools.apply(this, arguments);
2466
2481
  }
2467
2482
  function _getPathsFromPools() {
2468
- _getPathsFromPools = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(pools, inputToken, outputToken, maxPathLength) {
2483
+ _getPathsFromPools = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(pools, inputToken, outputToken, maxPathLength) {
2469
2484
  var graph;
2470
- return _regeneratorRuntime().wrap(function _callee8$(_context13) {
2485
+ return _regeneratorRuntime().wrap(function _callee10$(_context13) {
2471
2486
  while (1) {
2472
2487
  switch (_context13.prev = _context13.next) {
2473
2488
  case 0:
@@ -2481,7 +2496,7 @@ function _getPathsFromPools() {
2481
2496
  return _context13.stop();
2482
2497
  }
2483
2498
  }
2484
- }, _callee8);
2499
+ }, _callee10);
2485
2500
  }));
2486
2501
  return _getPathsFromPools.apply(this, arguments);
2487
2502
  }
@@ -2516,9 +2531,9 @@ function stableSmart(_x28, _x29, _x30, _x31, _x32) {
2516
2531
  return _stableSmart.apply(this, arguments);
2517
2532
  }
2518
2533
  function _stableSmart() {
2519
- _stableSmart = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(pools, inputToken, outputToken, totalInput, allTokens) {
2534
+ _stableSmart = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12(pools, inputToken, outputToken, totalInput, allTokens) {
2520
2535
  var smartRouteActions;
2521
- return _regeneratorRuntime().wrap(function _callee10$(_context15) {
2536
+ return _regeneratorRuntime().wrap(function _callee12$(_context15) {
2522
2537
  while (1) {
2523
2538
  switch (_context15.prev = _context15.next) {
2524
2539
  case 0:
@@ -2532,7 +2547,7 @@ function _stableSmart() {
2532
2547
  return _context15.stop();
2533
2548
  }
2534
2549
  }
2535
- }, _callee10);
2550
+ }, _callee12);
2536
2551
  }));
2537
2552
  return _stableSmart.apply(this, arguments);
2538
2553
  }
@@ -4427,6 +4442,7 @@ var instantSwap = /*#__PURE__*/function () {
4427
4442
  }();
4428
4443
 
4429
4444
  var DEFAULT_PAGE_LIMIT = 100;
4445
+ var BLACK_TOKEN_LIST = ['meta-token.near'];
4430
4446
  var getRatedPoolDetail = /*#__PURE__*/function () {
4431
4447
  var _ref2 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(_ref) {
4432
4448
  var id;
@@ -4598,6 +4614,11 @@ var getRefPools = /*#__PURE__*/function () {
4598
4614
  poolData = _context6.sent;
4599
4615
  return _context6.abrupt("return", poolData.map(function (rawPool, i) {
4600
4616
  return parsePool(rawPool, i + index);
4617
+ }).filter(function (p) {
4618
+ var _p$tokenIds;
4619
+ return !((_p$tokenIds = p.tokenIds) != null && _p$tokenIds.find(function (tokenId) {
4620
+ return BLACK_TOKEN_LIST.includes(tokenId);
4621
+ }));
4601
4622
  }));
4602
4623
  case 7:
4603
4624
  case "end":