@ref-finance/ref-sdk 1.2.0 → 1.2.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.
@@ -75,7 +75,7 @@ function getConfig(env) {
75
75
  REF_TOKEN_ID: 'token.v2.ref-finance.near',
76
76
  indexerUrl: 'https://indexer.ref.finance',
77
77
  explorerUrl: 'https://nearblocks.io',
78
- REF_DCL_SWAP_CONTRACT_ID: 'dcl.ref-labs.near'
78
+ REF_DCL_SWAP_CONTRACT_ID: 'dclv2.ref-labs.near'
79
79
  };
80
80
  }
81
81
  }
@@ -186,6 +186,9 @@ function _regeneratorRuntime() {
186
186
  var exports = {},
187
187
  Op = Object.prototype,
188
188
  hasOwn = Op.hasOwnProperty,
189
+ defineProperty = Object.defineProperty || function (obj, key, desc) {
190
+ obj[key] = desc.value;
191
+ },
189
192
  $Symbol = "function" == typeof Symbol ? Symbol : {},
190
193
  iteratorSymbol = $Symbol.iterator || "@@iterator",
191
194
  asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator",
@@ -209,40 +212,9 @@ function _regeneratorRuntime() {
209
212
  var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator,
210
213
  generator = Object.create(protoGenerator.prototype),
211
214
  context = new Context(tryLocsList || []);
212
- return generator._invoke = function (innerFn, self, context) {
213
- var state = "suspendedStart";
214
- return function (method, arg) {
215
- if ("executing" === state) throw new Error("Generator is already running");
216
- if ("completed" === state) {
217
- if ("throw" === method) throw arg;
218
- return doneResult();
219
- }
220
- for (context.method = method, context.arg = arg;;) {
221
- var delegate = context.delegate;
222
- if (delegate) {
223
- var delegateResult = maybeInvokeDelegate(delegate, context);
224
- if (delegateResult) {
225
- if (delegateResult === ContinueSentinel) continue;
226
- return delegateResult;
227
- }
228
- }
229
- if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) {
230
- if ("suspendedStart" === state) throw state = "completed", context.arg;
231
- context.dispatchException(context.arg);
232
- } else "return" === context.method && context.abrupt("return", context.arg);
233
- state = "executing";
234
- var record = tryCatch(innerFn, self, context);
235
- if ("normal" === record.type) {
236
- if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue;
237
- return {
238
- value: record.arg,
239
- done: context.done
240
- };
241
- }
242
- "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg);
243
- }
244
- };
245
- }(innerFn, self, context), generator;
215
+ return defineProperty(generator, "_invoke", {
216
+ value: makeInvokeMethod(innerFn, self, context)
217
+ }), generator;
246
218
  }
247
219
  function tryCatch(fn, obj, arg) {
248
220
  try {
@@ -296,13 +268,49 @@ function _regeneratorRuntime() {
296
268
  reject(record.arg);
297
269
  }
298
270
  var previousPromise;
299
- this._invoke = function (method, arg) {
300
- function callInvokeWithMethodAndArg() {
301
- return new PromiseImpl(function (resolve, reject) {
302
- invoke(method, arg, resolve, reject);
303
- });
271
+ defineProperty(this, "_invoke", {
272
+ value: function (method, arg) {
273
+ function callInvokeWithMethodAndArg() {
274
+ return new PromiseImpl(function (resolve, reject) {
275
+ invoke(method, arg, resolve, reject);
276
+ });
277
+ }
278
+ return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
279
+ }
280
+ });
281
+ }
282
+ function makeInvokeMethod(innerFn, self, context) {
283
+ var state = "suspendedStart";
284
+ return function (method, arg) {
285
+ if ("executing" === state) throw new Error("Generator is already running");
286
+ if ("completed" === state) {
287
+ if ("throw" === method) throw arg;
288
+ return doneResult();
289
+ }
290
+ for (context.method = method, context.arg = arg;;) {
291
+ var delegate = context.delegate;
292
+ if (delegate) {
293
+ var delegateResult = maybeInvokeDelegate(delegate, context);
294
+ if (delegateResult) {
295
+ if (delegateResult === ContinueSentinel) continue;
296
+ return delegateResult;
297
+ }
298
+ }
299
+ if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) {
300
+ if ("suspendedStart" === state) throw state = "completed", context.arg;
301
+ context.dispatchException(context.arg);
302
+ } else "return" === context.method && context.abrupt("return", context.arg);
303
+ state = "executing";
304
+ var record = tryCatch(innerFn, self, context);
305
+ if ("normal" === record.type) {
306
+ if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue;
307
+ return {
308
+ value: record.arg,
309
+ done: context.done
310
+ };
311
+ }
312
+ "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg);
304
313
  }
305
- return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
306
314
  };
307
315
  }
308
316
  function maybeInvokeDelegate(delegate, context) {
@@ -358,7 +366,13 @@ function _regeneratorRuntime() {
358
366
  done: !0
359
367
  };
360
368
  }
361
- return GeneratorFunction.prototype = GeneratorFunctionPrototype, define(Gp, "constructor", GeneratorFunctionPrototype), define(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) {
369
+ return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", {
370
+ value: GeneratorFunctionPrototype,
371
+ configurable: !0
372
+ }), defineProperty(GeneratorFunctionPrototype, "constructor", {
373
+ value: GeneratorFunction,
374
+ configurable: !0
375
+ }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) {
362
376
  var ctor = "function" == typeof genFun && genFun.constructor;
363
377
  return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name));
364
378
  }, exports.mark = function (genFun) {
@@ -379,8 +393,9 @@ function _regeneratorRuntime() {
379
393
  return this;
380
394
  }), define(Gp, "toString", function () {
381
395
  return "[object Generator]";
382
- }), exports.keys = function (object) {
383
- var keys = [];
396
+ }), exports.keys = function (val) {
397
+ var object = Object(val),
398
+ keys = [];
384
399
  for (var key in object) keys.push(key);
385
400
  return keys.reverse(), function next() {
386
401
  for (; keys.length;) {
@@ -869,7 +884,7 @@ function checkIntegerSumOfAllocations(allocations, totalInput) {
869
884
  return newAllocations;
870
885
  }
871
886
 
872
- var _marked5 = /*#__PURE__*/_regeneratorRuntime().mark(yenFromPy);
887
+ var _marked3 = /*#__PURE__*/_regeneratorRuntime().mark(yenFromPy);
873
888
  Big.RM = 0;
874
889
  Big.DP = 40;
875
890
  Big.NE = -40;
@@ -1291,8 +1306,8 @@ function getBestOptimalAllocationsAndOutputs(_x, _x2, _x3, _x4, _x5, _x6) {
1291
1306
  return _getBestOptimalAllocationsAndOutputs.apply(this, arguments);
1292
1307
  }
1293
1308
  function _getBestOptimalAllocationsAndOutputs() {
1294
- _getBestOptimalAllocationsAndOutputs = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(pools, inputToken, outputToken, totalInput, maxPathLength, threshold) {
1295
- return _regeneratorRuntime().wrap(function _callee2$(_context7) {
1309
+ _getBestOptimalAllocationsAndOutputs = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(pools, inputToken, outputToken, totalInput, maxPathLength, threshold) {
1310
+ return _regeneratorRuntime().wrap(function _callee4$(_context7) {
1296
1311
  while (1) {
1297
1312
  switch (_context7.prev = _context7.next) {
1298
1313
  case 0:
@@ -1303,9 +1318,9 @@ function _getBestOptimalAllocationsAndOutputs() {
1303
1318
  threshold = 0.001;
1304
1319
  }
1305
1320
  return _context7.abrupt("return", function () {
1306
- var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(totalInput) {
1321
+ var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(totalInput) {
1307
1322
  var paths, poolChains, routes, nodeRoutes, inputOutput, allocations, outputs;
1308
- return _regeneratorRuntime().wrap(function _callee$(_context6) {
1323
+ return _regeneratorRuntime().wrap(function _callee3$(_context6) {
1309
1324
  while (1) {
1310
1325
  switch (_context6.prev = _context6.next) {
1311
1326
  case 0:
@@ -1354,7 +1369,7 @@ function _getBestOptimalAllocationsAndOutputs() {
1354
1369
  return _context6.stop();
1355
1370
  }
1356
1371
  }
1357
- }, _callee);
1372
+ }, _callee3);
1358
1373
  }));
1359
1374
  return function (_x33) {
1360
1375
  return _ref.apply(this, arguments);
@@ -1365,7 +1380,7 @@ function _getBestOptimalAllocationsAndOutputs() {
1365
1380
  return _context7.stop();
1366
1381
  }
1367
1382
  }
1368
- }, _callee2);
1383
+ }, _callee4);
1369
1384
  }));
1370
1385
  return _getBestOptimalAllocationsAndOutputs.apply(this, arguments);
1371
1386
  }
@@ -1475,8 +1490,8 @@ function getSmartRouteSwapActions(_x7, _x8, _x9, _x10, _x11, _x12, _x13, _x14, _
1475
1490
  return _getSmartRouteSwapActions.apply(this, arguments);
1476
1491
  }
1477
1492
  function _getSmartRouteSwapActions() {
1478
- _getSmartRouteSwapActions = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(pools, inputToken, outputToken, totalInput, allTokens, maxPathLength, threshold, numberOfRoutesLimit, MAX_NUMBER_PARALLEL_POOLS, decimalsCulledPoolIds) {
1479
- return _regeneratorRuntime().wrap(function _callee5$(_context10) {
1493
+ _getSmartRouteSwapActions = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(pools, inputToken, outputToken, totalInput, allTokens, maxPathLength, threshold, numberOfRoutesLimit, MAX_NUMBER_PARALLEL_POOLS, decimalsCulledPoolIds) {
1494
+ return _regeneratorRuntime().wrap(function _callee7$(_context10) {
1480
1495
  while (1) {
1481
1496
  switch (_context10.prev = _context10.next) {
1482
1497
  case 0:
@@ -1496,9 +1511,9 @@ function _getSmartRouteSwapActions() {
1496
1511
  decimalsCulledPoolIds = [];
1497
1512
  }
1498
1513
  return _context10.abrupt("return", function () {
1499
- var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(totalInput) {
1514
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(totalInput) {
1500
1515
  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;
1501
- return _regeneratorRuntime().wrap(function _callee4$(_context9) {
1516
+ return _regeneratorRuntime().wrap(function _callee6$(_context9) {
1502
1517
  while (1) {
1503
1518
  switch (_context9.prev = _context9.next) {
1504
1519
  case 0:
@@ -1893,8 +1908,8 @@ function _getSmartRouteSwapActions() {
1893
1908
  }
1894
1909
  _context9.next = 143;
1895
1910
  return Promise.all(hops[i].nodeRoute.map( /*#__PURE__*/function () {
1896
- var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(t) {
1897
- return _regeneratorRuntime().wrap(function _callee3$(_context8) {
1911
+ var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(t) {
1912
+ return _regeneratorRuntime().wrap(function _callee5$(_context8) {
1898
1913
  while (1) {
1899
1914
  switch (_context8.prev = _context8.next) {
1900
1915
  case 0:
@@ -1917,7 +1932,7 @@ function _getSmartRouteSwapActions() {
1917
1932
  return _context8.stop();
1918
1933
  }
1919
1934
  }
1920
- }, _callee3);
1935
+ }, _callee5);
1921
1936
  }));
1922
1937
  return function (_x35) {
1923
1938
  return _ref3.apply(this, arguments);
@@ -1978,7 +1993,7 @@ function _getSmartRouteSwapActions() {
1978
1993
  return _context9.stop();
1979
1994
  }
1980
1995
  }
1981
- }, _callee4);
1996
+ }, _callee6);
1982
1997
  }));
1983
1998
  return function (_x34) {
1984
1999
  return _ref2.apply(this, arguments);
@@ -1989,7 +2004,7 @@ function _getSmartRouteSwapActions() {
1989
2004
  return _context10.stop();
1990
2005
  }
1991
2006
  }
1992
- }, _callee5);
2007
+ }, _callee7);
1993
2008
  }));
1994
2009
  return _getSmartRouteSwapActions.apply(this, arguments);
1995
2010
  }
@@ -1997,9 +2012,9 @@ function calculateSmartRouteV2PriceImpact(_x17, _x18) {
1997
2012
  return _calculateSmartRouteV2PriceImpact.apply(this, arguments);
1998
2013
  }
1999
2014
  function _calculateSmartRouteV2PriceImpact() {
2000
- _calculateSmartRouteV2PriceImpact = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(actions, allTokens) {
2015
+ _calculateSmartRouteV2PriceImpact = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(actions, allTokens) {
2001
2016
  var deltaY, inputTokenMeta, deltaX, R, P, routes, nodeRoutes, allocations, totalAllocations, weights, i, route, nodeRoute, tokens, weight, num, denom, routeMarketPrice, num1, denom1, num2, denom2, priceImpact;
2002
- return _regeneratorRuntime().wrap(function _callee7$(_context12) {
2017
+ return _regeneratorRuntime().wrap(function _callee9$(_context12) {
2003
2018
  while (1) {
2004
2019
  switch (_context12.prev = _context12.next) {
2005
2020
  case 0:
@@ -2045,8 +2060,8 @@ function _calculateSmartRouteV2PriceImpact() {
2045
2060
  nodeRoute = nodeRoutes[i];
2046
2061
  _context12.next = 17;
2047
2062
  return Promise.all(nodeRoute.map( /*#__PURE__*/function () {
2048
- var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(t) {
2049
- return _regeneratorRuntime().wrap(function _callee6$(_context11) {
2063
+ var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(t) {
2064
+ return _regeneratorRuntime().wrap(function _callee8$(_context11) {
2050
2065
  while (1) {
2051
2066
  switch (_context11.prev = _context11.next) {
2052
2067
  case 0:
@@ -2069,7 +2084,7 @@ function _calculateSmartRouteV2PriceImpact() {
2069
2084
  return _context11.stop();
2070
2085
  }
2071
2086
  }
2072
- }, _callee6);
2087
+ }, _callee8);
2073
2088
  }));
2074
2089
  return function (_x36) {
2075
2090
  return _ref4.apply(this, arguments);
@@ -2100,7 +2115,7 @@ function _calculateSmartRouteV2PriceImpact() {
2100
2115
  return _context12.stop();
2101
2116
  }
2102
2117
  }
2103
- }, _callee7);
2118
+ }, _callee9);
2104
2119
  }));
2105
2120
  return _calculateSmartRouteV2PriceImpact.apply(this, arguments);
2106
2121
  }
@@ -2435,7 +2450,7 @@ function yenFromPy(g, source, target) {
2435
2450
  return _context5.stop();
2436
2451
  }
2437
2452
  }
2438
- }, _marked5, null, [[6, 14]]);
2453
+ }, _marked3, null, [[6, 14]]);
2439
2454
  }
2440
2455
  function getKShortestPaths(g, source, target, k, maxPathLength) {
2441
2456
  if (maxPathLength === void 0) {
@@ -2472,9 +2487,9 @@ function getPathsFromPools(_x19, _x20, _x21, _x22) {
2472
2487
  return _getPathsFromPools.apply(this, arguments);
2473
2488
  }
2474
2489
  function _getPathsFromPools() {
2475
- _getPathsFromPools = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(pools, inputToken, outputToken, maxPathLength) {
2490
+ _getPathsFromPools = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(pools, inputToken, outputToken, maxPathLength) {
2476
2491
  var graph;
2477
- return _regeneratorRuntime().wrap(function _callee8$(_context13) {
2492
+ return _regeneratorRuntime().wrap(function _callee10$(_context13) {
2478
2493
  while (1) {
2479
2494
  switch (_context13.prev = _context13.next) {
2480
2495
  case 0:
@@ -2488,7 +2503,7 @@ function _getPathsFromPools() {
2488
2503
  return _context13.stop();
2489
2504
  }
2490
2505
  }
2491
- }, _callee8);
2506
+ }, _callee10);
2492
2507
  }));
2493
2508
  return _getPathsFromPools.apply(this, arguments);
2494
2509
  }
@@ -2523,9 +2538,9 @@ function stableSmart(_x28, _x29, _x30, _x31, _x32) {
2523
2538
  return _stableSmart.apply(this, arguments);
2524
2539
  }
2525
2540
  function _stableSmart() {
2526
- _stableSmart = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(pools, inputToken, outputToken, totalInput, allTokens) {
2541
+ _stableSmart = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12(pools, inputToken, outputToken, totalInput, allTokens) {
2527
2542
  var smartRouteActions;
2528
- return _regeneratorRuntime().wrap(function _callee10$(_context15) {
2543
+ return _regeneratorRuntime().wrap(function _callee12$(_context15) {
2529
2544
  while (1) {
2530
2545
  switch (_context15.prev = _context15.next) {
2531
2546
  case 0:
@@ -2539,7 +2554,7 @@ function _stableSmart() {
2539
2554
  return _context15.stop();
2540
2555
  }
2541
2556
  }
2542
- }, _callee10);
2557
+ }, _callee12);
2543
2558
  }));
2544
2559
  return _stableSmart.apply(this, arguments);
2545
2560
  }
@@ -4433,6 +4448,7 @@ var instantSwap = /*#__PURE__*/function () {
4433
4448
  }();
4434
4449
 
4435
4450
  var DEFAULT_PAGE_LIMIT = 100;
4451
+ var BLACK_TOKEN_LIST = ['meta-token.near'];
4436
4452
  var getRatedPoolDetail = /*#__PURE__*/function () {
4437
4453
  var _ref2 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(_ref) {
4438
4454
  var id;
@@ -4604,6 +4620,11 @@ var getRefPools = /*#__PURE__*/function () {
4604
4620
  poolData = _context6.sent;
4605
4621
  return _context6.abrupt("return", poolData.map(function (rawPool, i) {
4606
4622
  return parsePool(rawPool, i + index);
4623
+ }).filter(function (p) {
4624
+ var _p$tokenIds;
4625
+ return !((_p$tokenIds = p.tokenIds) != null && _p$tokenIds.find(function (tokenId) {
4626
+ return BLACK_TOKEN_LIST.includes(tokenId);
4627
+ }));
4607
4628
  }));
4608
4629
  case 7:
4609
4630
  case "end":