@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.
@@ -56,7 +56,7 @@
56
56
  REF_TOKEN_ID: 'token.v2.ref-finance.near',
57
57
  indexerUrl: 'https://indexer.ref.finance',
58
58
  explorerUrl: 'https://nearblocks.io',
59
- REF_DCL_SWAP_CONTRACT_ID: 'dcl.ref-labs.near'
59
+ REF_DCL_SWAP_CONTRACT_ID: 'dclv2.ref-labs.near'
60
60
  };
61
61
  }
62
62
  }
@@ -167,6 +167,9 @@
167
167
  var exports = {},
168
168
  Op = Object.prototype,
169
169
  hasOwn = Op.hasOwnProperty,
170
+ defineProperty = Object.defineProperty || function (obj, key, desc) {
171
+ obj[key] = desc.value;
172
+ },
170
173
  $Symbol = "function" == typeof Symbol ? Symbol : {},
171
174
  iteratorSymbol = $Symbol.iterator || "@@iterator",
172
175
  asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator",
@@ -190,40 +193,9 @@
190
193
  var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator,
191
194
  generator = Object.create(protoGenerator.prototype),
192
195
  context = new Context(tryLocsList || []);
193
- return generator._invoke = function (innerFn, self, context) {
194
- var state = "suspendedStart";
195
- return function (method, arg) {
196
- if ("executing" === state) throw new Error("Generator is already running");
197
- if ("completed" === state) {
198
- if ("throw" === method) throw arg;
199
- return doneResult();
200
- }
201
- for (context.method = method, context.arg = arg;;) {
202
- var delegate = context.delegate;
203
- if (delegate) {
204
- var delegateResult = maybeInvokeDelegate(delegate, context);
205
- if (delegateResult) {
206
- if (delegateResult === ContinueSentinel) continue;
207
- return delegateResult;
208
- }
209
- }
210
- if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) {
211
- if ("suspendedStart" === state) throw state = "completed", context.arg;
212
- context.dispatchException(context.arg);
213
- } else "return" === context.method && context.abrupt("return", context.arg);
214
- state = "executing";
215
- var record = tryCatch(innerFn, self, context);
216
- if ("normal" === record.type) {
217
- if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue;
218
- return {
219
- value: record.arg,
220
- done: context.done
221
- };
222
- }
223
- "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg);
224
- }
225
- };
226
- }(innerFn, self, context), generator;
196
+ return defineProperty(generator, "_invoke", {
197
+ value: makeInvokeMethod(innerFn, self, context)
198
+ }), generator;
227
199
  }
228
200
  function tryCatch(fn, obj, arg) {
229
201
  try {
@@ -277,13 +249,49 @@
277
249
  reject(record.arg);
278
250
  }
279
251
  var previousPromise;
280
- this._invoke = function (method, arg) {
281
- function callInvokeWithMethodAndArg() {
282
- return new PromiseImpl(function (resolve, reject) {
283
- invoke(method, arg, resolve, reject);
284
- });
252
+ defineProperty(this, "_invoke", {
253
+ value: function (method, arg) {
254
+ function callInvokeWithMethodAndArg() {
255
+ return new PromiseImpl(function (resolve, reject) {
256
+ invoke(method, arg, resolve, reject);
257
+ });
258
+ }
259
+ return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
260
+ }
261
+ });
262
+ }
263
+ function makeInvokeMethod(innerFn, self, context) {
264
+ var state = "suspendedStart";
265
+ return function (method, arg) {
266
+ if ("executing" === state) throw new Error("Generator is already running");
267
+ if ("completed" === state) {
268
+ if ("throw" === method) throw arg;
269
+ return doneResult();
270
+ }
271
+ for (context.method = method, context.arg = arg;;) {
272
+ var delegate = context.delegate;
273
+ if (delegate) {
274
+ var delegateResult = maybeInvokeDelegate(delegate, context);
275
+ if (delegateResult) {
276
+ if (delegateResult === ContinueSentinel) continue;
277
+ return delegateResult;
278
+ }
279
+ }
280
+ if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) {
281
+ if ("suspendedStart" === state) throw state = "completed", context.arg;
282
+ context.dispatchException(context.arg);
283
+ } else "return" === context.method && context.abrupt("return", context.arg);
284
+ state = "executing";
285
+ var record = tryCatch(innerFn, self, context);
286
+ if ("normal" === record.type) {
287
+ if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue;
288
+ return {
289
+ value: record.arg,
290
+ done: context.done
291
+ };
292
+ }
293
+ "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg);
285
294
  }
286
- return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
287
295
  };
288
296
  }
289
297
  function maybeInvokeDelegate(delegate, context) {
@@ -339,7 +347,13 @@
339
347
  done: !0
340
348
  };
341
349
  }
342
- return GeneratorFunction.prototype = GeneratorFunctionPrototype, define(Gp, "constructor", GeneratorFunctionPrototype), define(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) {
350
+ return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", {
351
+ value: GeneratorFunctionPrototype,
352
+ configurable: !0
353
+ }), defineProperty(GeneratorFunctionPrototype, "constructor", {
354
+ value: GeneratorFunction,
355
+ configurable: !0
356
+ }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) {
343
357
  var ctor = "function" == typeof genFun && genFun.constructor;
344
358
  return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name));
345
359
  }, exports.mark = function (genFun) {
@@ -360,8 +374,9 @@
360
374
  return this;
361
375
  }), define(Gp, "toString", function () {
362
376
  return "[object Generator]";
363
- }), exports.keys = function (object) {
364
- var keys = [];
377
+ }), exports.keys = function (val) {
378
+ var object = Object(val),
379
+ keys = [];
365
380
  for (var key in object) keys.push(key);
366
381
  return keys.reverse(), function next() {
367
382
  for (; keys.length;) {
@@ -850,7 +865,7 @@
850
865
  return newAllocations;
851
866
  }
852
867
 
853
- var _marked5 = /*#__PURE__*/_regeneratorRuntime().mark(yenFromPy);
868
+ var _marked3 = /*#__PURE__*/_regeneratorRuntime().mark(yenFromPy);
854
869
  Big.RM = 0;
855
870
  Big.DP = 40;
856
871
  Big.NE = -40;
@@ -1272,8 +1287,8 @@
1272
1287
  return _getBestOptimalAllocationsAndOutputs.apply(this, arguments);
1273
1288
  }
1274
1289
  function _getBestOptimalAllocationsAndOutputs() {
1275
- _getBestOptimalAllocationsAndOutputs = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(pools, inputToken, outputToken, totalInput, maxPathLength, threshold) {
1276
- return _regeneratorRuntime().wrap(function _callee2$(_context7) {
1290
+ _getBestOptimalAllocationsAndOutputs = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(pools, inputToken, outputToken, totalInput, maxPathLength, threshold) {
1291
+ return _regeneratorRuntime().wrap(function _callee4$(_context7) {
1277
1292
  while (1) {
1278
1293
  switch (_context7.prev = _context7.next) {
1279
1294
  case 0:
@@ -1284,9 +1299,9 @@
1284
1299
  threshold = 0.001;
1285
1300
  }
1286
1301
  return _context7.abrupt("return", function () {
1287
- var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(totalInput) {
1302
+ var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(totalInput) {
1288
1303
  var paths, poolChains, routes, nodeRoutes, inputOutput, allocations, outputs;
1289
- return _regeneratorRuntime().wrap(function _callee$(_context6) {
1304
+ return _regeneratorRuntime().wrap(function _callee3$(_context6) {
1290
1305
  while (1) {
1291
1306
  switch (_context6.prev = _context6.next) {
1292
1307
  case 0:
@@ -1335,7 +1350,7 @@
1335
1350
  return _context6.stop();
1336
1351
  }
1337
1352
  }
1338
- }, _callee);
1353
+ }, _callee3);
1339
1354
  }));
1340
1355
  return function (_x33) {
1341
1356
  return _ref.apply(this, arguments);
@@ -1346,7 +1361,7 @@
1346
1361
  return _context7.stop();
1347
1362
  }
1348
1363
  }
1349
- }, _callee2);
1364
+ }, _callee4);
1350
1365
  }));
1351
1366
  return _getBestOptimalAllocationsAndOutputs.apply(this, arguments);
1352
1367
  }
@@ -1456,8 +1471,8 @@
1456
1471
  return _getSmartRouteSwapActions.apply(this, arguments);
1457
1472
  }
1458
1473
  function _getSmartRouteSwapActions() {
1459
- _getSmartRouteSwapActions = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(pools, inputToken, outputToken, totalInput, allTokens, maxPathLength, threshold, numberOfRoutesLimit, MAX_NUMBER_PARALLEL_POOLS, decimalsCulledPoolIds) {
1460
- return _regeneratorRuntime().wrap(function _callee5$(_context10) {
1474
+ _getSmartRouteSwapActions = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(pools, inputToken, outputToken, totalInput, allTokens, maxPathLength, threshold, numberOfRoutesLimit, MAX_NUMBER_PARALLEL_POOLS, decimalsCulledPoolIds) {
1475
+ return _regeneratorRuntime().wrap(function _callee7$(_context10) {
1461
1476
  while (1) {
1462
1477
  switch (_context10.prev = _context10.next) {
1463
1478
  case 0:
@@ -1477,9 +1492,9 @@
1477
1492
  decimalsCulledPoolIds = [];
1478
1493
  }
1479
1494
  return _context10.abrupt("return", function () {
1480
- var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(totalInput) {
1495
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(totalInput) {
1481
1496
  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;
1482
- return _regeneratorRuntime().wrap(function _callee4$(_context9) {
1497
+ return _regeneratorRuntime().wrap(function _callee6$(_context9) {
1483
1498
  while (1) {
1484
1499
  switch (_context9.prev = _context9.next) {
1485
1500
  case 0:
@@ -1874,8 +1889,8 @@
1874
1889
  }
1875
1890
  _context9.next = 143;
1876
1891
  return Promise.all(hops[i].nodeRoute.map( /*#__PURE__*/function () {
1877
- var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(t) {
1878
- return _regeneratorRuntime().wrap(function _callee3$(_context8) {
1892
+ var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(t) {
1893
+ return _regeneratorRuntime().wrap(function _callee5$(_context8) {
1879
1894
  while (1) {
1880
1895
  switch (_context8.prev = _context8.next) {
1881
1896
  case 0:
@@ -1898,7 +1913,7 @@
1898
1913
  return _context8.stop();
1899
1914
  }
1900
1915
  }
1901
- }, _callee3);
1916
+ }, _callee5);
1902
1917
  }));
1903
1918
  return function (_x35) {
1904
1919
  return _ref3.apply(this, arguments);
@@ -1959,7 +1974,7 @@
1959
1974
  return _context9.stop();
1960
1975
  }
1961
1976
  }
1962
- }, _callee4);
1977
+ }, _callee6);
1963
1978
  }));
1964
1979
  return function (_x34) {
1965
1980
  return _ref2.apply(this, arguments);
@@ -1970,7 +1985,7 @@
1970
1985
  return _context10.stop();
1971
1986
  }
1972
1987
  }
1973
- }, _callee5);
1988
+ }, _callee7);
1974
1989
  }));
1975
1990
  return _getSmartRouteSwapActions.apply(this, arguments);
1976
1991
  }
@@ -1978,9 +1993,9 @@
1978
1993
  return _calculateSmartRouteV2PriceImpact.apply(this, arguments);
1979
1994
  }
1980
1995
  function _calculateSmartRouteV2PriceImpact() {
1981
- _calculateSmartRouteV2PriceImpact = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(actions, allTokens) {
1996
+ _calculateSmartRouteV2PriceImpact = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(actions, allTokens) {
1982
1997
  var deltaY, inputTokenMeta, deltaX, R, P, routes, nodeRoutes, allocations, totalAllocations, weights, i, route, nodeRoute, tokens, weight, num, denom, routeMarketPrice, num1, denom1, num2, denom2, priceImpact;
1983
- return _regeneratorRuntime().wrap(function _callee7$(_context12) {
1998
+ return _regeneratorRuntime().wrap(function _callee9$(_context12) {
1984
1999
  while (1) {
1985
2000
  switch (_context12.prev = _context12.next) {
1986
2001
  case 0:
@@ -2026,8 +2041,8 @@
2026
2041
  nodeRoute = nodeRoutes[i];
2027
2042
  _context12.next = 17;
2028
2043
  return Promise.all(nodeRoute.map( /*#__PURE__*/function () {
2029
- var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(t) {
2030
- return _regeneratorRuntime().wrap(function _callee6$(_context11) {
2044
+ var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(t) {
2045
+ return _regeneratorRuntime().wrap(function _callee8$(_context11) {
2031
2046
  while (1) {
2032
2047
  switch (_context11.prev = _context11.next) {
2033
2048
  case 0:
@@ -2050,7 +2065,7 @@
2050
2065
  return _context11.stop();
2051
2066
  }
2052
2067
  }
2053
- }, _callee6);
2068
+ }, _callee8);
2054
2069
  }));
2055
2070
  return function (_x36) {
2056
2071
  return _ref4.apply(this, arguments);
@@ -2081,7 +2096,7 @@
2081
2096
  return _context12.stop();
2082
2097
  }
2083
2098
  }
2084
- }, _callee7);
2099
+ }, _callee9);
2085
2100
  }));
2086
2101
  return _calculateSmartRouteV2PriceImpact.apply(this, arguments);
2087
2102
  }
@@ -2416,7 +2431,7 @@
2416
2431
  return _context5.stop();
2417
2432
  }
2418
2433
  }
2419
- }, _marked5, null, [[6, 14]]);
2434
+ }, _marked3, null, [[6, 14]]);
2420
2435
  }
2421
2436
  function getKShortestPaths(g, source, target, k, maxPathLength) {
2422
2437
  if (maxPathLength === void 0) {
@@ -2453,9 +2468,9 @@
2453
2468
  return _getPathsFromPools.apply(this, arguments);
2454
2469
  }
2455
2470
  function _getPathsFromPools() {
2456
- _getPathsFromPools = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(pools, inputToken, outputToken, maxPathLength) {
2471
+ _getPathsFromPools = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(pools, inputToken, outputToken, maxPathLength) {
2457
2472
  var graph;
2458
- return _regeneratorRuntime().wrap(function _callee8$(_context13) {
2473
+ return _regeneratorRuntime().wrap(function _callee10$(_context13) {
2459
2474
  while (1) {
2460
2475
  switch (_context13.prev = _context13.next) {
2461
2476
  case 0:
@@ -2469,7 +2484,7 @@
2469
2484
  return _context13.stop();
2470
2485
  }
2471
2486
  }
2472
- }, _callee8);
2487
+ }, _callee10);
2473
2488
  }));
2474
2489
  return _getPathsFromPools.apply(this, arguments);
2475
2490
  }
@@ -2504,9 +2519,9 @@
2504
2519
  return _stableSmart.apply(this, arguments);
2505
2520
  }
2506
2521
  function _stableSmart() {
2507
- _stableSmart = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(pools, inputToken, outputToken, totalInput, allTokens) {
2522
+ _stableSmart = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12(pools, inputToken, outputToken, totalInput, allTokens) {
2508
2523
  var smartRouteActions;
2509
- return _regeneratorRuntime().wrap(function _callee10$(_context15) {
2524
+ return _regeneratorRuntime().wrap(function _callee12$(_context15) {
2510
2525
  while (1) {
2511
2526
  switch (_context15.prev = _context15.next) {
2512
2527
  case 0:
@@ -2520,7 +2535,7 @@
2520
2535
  return _context15.stop();
2521
2536
  }
2522
2537
  }
2523
- }, _callee10);
2538
+ }, _callee12);
2524
2539
  }));
2525
2540
  return _stableSmart.apply(this, arguments);
2526
2541
  }
@@ -4414,6 +4429,7 @@
4414
4429
  }();
4415
4430
 
4416
4431
  var DEFAULT_PAGE_LIMIT = 100;
4432
+ var BLACK_TOKEN_LIST = ['meta-token.near'];
4417
4433
  var getRatedPoolDetail = /*#__PURE__*/function () {
4418
4434
  var _ref2 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(_ref) {
4419
4435
  var id;
@@ -4585,6 +4601,11 @@
4585
4601
  poolData = _context6.sent;
4586
4602
  return _context6.abrupt("return", poolData.map(function (rawPool, i) {
4587
4603
  return parsePool(rawPool, i + index);
4604
+ }).filter(function (p) {
4605
+ var _p$tokenIds;
4606
+ return !((_p$tokenIds = p.tokenIds) != null && _p$tokenIds.find(function (tokenId) {
4607
+ return BLACK_TOKEN_LIST.includes(tokenId);
4608
+ }));
4588
4609
  }));
4589
4610
  case 7:
4590
4611
  case "end":