@ref-finance/ref-sdk 1.2.2 → 1.3.0

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,9 +167,6 @@
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
- },
173
170
  $Symbol = "function" == typeof Symbol ? Symbol : {},
174
171
  iteratorSymbol = $Symbol.iterator || "@@iterator",
175
172
  asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator",
@@ -193,9 +190,40 @@
193
190
  var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator,
194
191
  generator = Object.create(protoGenerator.prototype),
195
192
  context = new Context(tryLocsList || []);
196
- return defineProperty(generator, "_invoke", {
197
- value: makeInvokeMethod(innerFn, self, context)
198
- }), generator;
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;
199
227
  }
200
228
  function tryCatch(fn, obj, arg) {
201
229
  try {
@@ -249,49 +277,13 @@
249
277
  reject(record.arg);
250
278
  }
251
279
  var previousPromise;
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);
280
+ this._invoke = function (method, arg) {
281
+ function callInvokeWithMethodAndArg() {
282
+ return new PromiseImpl(function (resolve, reject) {
283
+ invoke(method, arg, resolve, reject);
284
+ });
294
285
  }
286
+ return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
295
287
  };
296
288
  }
297
289
  function maybeInvokeDelegate(delegate, context) {
@@ -347,13 +339,7 @@
347
339
  done: !0
348
340
  };
349
341
  }
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) {
342
+ return GeneratorFunction.prototype = GeneratorFunctionPrototype, define(Gp, "constructor", GeneratorFunctionPrototype), define(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) {
357
343
  var ctor = "function" == typeof genFun && genFun.constructor;
358
344
  return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name));
359
345
  }, exports.mark = function (genFun) {
@@ -374,9 +360,8 @@
374
360
  return this;
375
361
  }), define(Gp, "toString", function () {
376
362
  return "[object Generator]";
377
- }), exports.keys = function (val) {
378
- var object = Object(val),
379
- keys = [];
363
+ }), exports.keys = function (object) {
364
+ var keys = [];
380
365
  for (var key in object) keys.push(key);
381
366
  return keys.reverse(), function next() {
382
367
  for (; keys.length;) {
@@ -865,7 +850,7 @@
865
850
  return newAllocations;
866
851
  }
867
852
 
868
- var _marked3 = /*#__PURE__*/_regeneratorRuntime().mark(yenFromPy);
853
+ var _marked5 = /*#__PURE__*/_regeneratorRuntime().mark(yenFromPy);
869
854
  Big.RM = 0;
870
855
  Big.DP = 40;
871
856
  Big.NE = -40;
@@ -1287,8 +1272,8 @@
1287
1272
  return _getBestOptimalAllocationsAndOutputs.apply(this, arguments);
1288
1273
  }
1289
1274
  function _getBestOptimalAllocationsAndOutputs() {
1290
- _getBestOptimalAllocationsAndOutputs = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(pools, inputToken, outputToken, totalInput, maxPathLength, threshold) {
1291
- return _regeneratorRuntime().wrap(function _callee4$(_context7) {
1275
+ _getBestOptimalAllocationsAndOutputs = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(pools, inputToken, outputToken, totalInput, maxPathLength, threshold) {
1276
+ return _regeneratorRuntime().wrap(function _callee2$(_context7) {
1292
1277
  while (1) {
1293
1278
  switch (_context7.prev = _context7.next) {
1294
1279
  case 0:
@@ -1299,9 +1284,9 @@
1299
1284
  threshold = 0.001;
1300
1285
  }
1301
1286
  return _context7.abrupt("return", function () {
1302
- var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(totalInput) {
1287
+ var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(totalInput) {
1303
1288
  var paths, poolChains, routes, nodeRoutes, inputOutput, allocations, outputs;
1304
- return _regeneratorRuntime().wrap(function _callee3$(_context6) {
1289
+ return _regeneratorRuntime().wrap(function _callee$(_context6) {
1305
1290
  while (1) {
1306
1291
  switch (_context6.prev = _context6.next) {
1307
1292
  case 0:
@@ -1350,7 +1335,7 @@
1350
1335
  return _context6.stop();
1351
1336
  }
1352
1337
  }
1353
- }, _callee3);
1338
+ }, _callee);
1354
1339
  }));
1355
1340
  return function (_x33) {
1356
1341
  return _ref.apply(this, arguments);
@@ -1361,7 +1346,7 @@
1361
1346
  return _context7.stop();
1362
1347
  }
1363
1348
  }
1364
- }, _callee4);
1349
+ }, _callee2);
1365
1350
  }));
1366
1351
  return _getBestOptimalAllocationsAndOutputs.apply(this, arguments);
1367
1352
  }
@@ -1471,8 +1456,8 @@
1471
1456
  return _getSmartRouteSwapActions.apply(this, arguments);
1472
1457
  }
1473
1458
  function _getSmartRouteSwapActions() {
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) {
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) {
1476
1461
  while (1) {
1477
1462
  switch (_context10.prev = _context10.next) {
1478
1463
  case 0:
@@ -1492,9 +1477,9 @@
1492
1477
  decimalsCulledPoolIds = [];
1493
1478
  }
1494
1479
  return _context10.abrupt("return", function () {
1495
- var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(totalInput) {
1480
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(totalInput) {
1496
1481
  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;
1497
- return _regeneratorRuntime().wrap(function _callee6$(_context9) {
1482
+ return _regeneratorRuntime().wrap(function _callee4$(_context9) {
1498
1483
  while (1) {
1499
1484
  switch (_context9.prev = _context9.next) {
1500
1485
  case 0:
@@ -1889,8 +1874,8 @@
1889
1874
  }
1890
1875
  _context9.next = 143;
1891
1876
  return Promise.all(hops[i].nodeRoute.map( /*#__PURE__*/function () {
1892
- var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(t) {
1893
- return _regeneratorRuntime().wrap(function _callee5$(_context8) {
1877
+ var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(t) {
1878
+ return _regeneratorRuntime().wrap(function _callee3$(_context8) {
1894
1879
  while (1) {
1895
1880
  switch (_context8.prev = _context8.next) {
1896
1881
  case 0:
@@ -1913,7 +1898,7 @@
1913
1898
  return _context8.stop();
1914
1899
  }
1915
1900
  }
1916
- }, _callee5);
1901
+ }, _callee3);
1917
1902
  }));
1918
1903
  return function (_x35) {
1919
1904
  return _ref3.apply(this, arguments);
@@ -1974,7 +1959,7 @@
1974
1959
  return _context9.stop();
1975
1960
  }
1976
1961
  }
1977
- }, _callee6);
1962
+ }, _callee4);
1978
1963
  }));
1979
1964
  return function (_x34) {
1980
1965
  return _ref2.apply(this, arguments);
@@ -1985,7 +1970,7 @@
1985
1970
  return _context10.stop();
1986
1971
  }
1987
1972
  }
1988
- }, _callee7);
1973
+ }, _callee5);
1989
1974
  }));
1990
1975
  return _getSmartRouteSwapActions.apply(this, arguments);
1991
1976
  }
@@ -1993,9 +1978,9 @@
1993
1978
  return _calculateSmartRouteV2PriceImpact.apply(this, arguments);
1994
1979
  }
1995
1980
  function _calculateSmartRouteV2PriceImpact() {
1996
- _calculateSmartRouteV2PriceImpact = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(actions, allTokens) {
1981
+ _calculateSmartRouteV2PriceImpact = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(actions, allTokens) {
1997
1982
  var deltaY, inputTokenMeta, deltaX, R, P, routes, nodeRoutes, allocations, totalAllocations, weights, i, route, nodeRoute, tokens, weight, num, denom, routeMarketPrice, num1, denom1, num2, denom2, priceImpact;
1998
- return _regeneratorRuntime().wrap(function _callee9$(_context12) {
1983
+ return _regeneratorRuntime().wrap(function _callee7$(_context12) {
1999
1984
  while (1) {
2000
1985
  switch (_context12.prev = _context12.next) {
2001
1986
  case 0:
@@ -2041,8 +2026,8 @@
2041
2026
  nodeRoute = nodeRoutes[i];
2042
2027
  _context12.next = 17;
2043
2028
  return Promise.all(nodeRoute.map( /*#__PURE__*/function () {
2044
- var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(t) {
2045
- return _regeneratorRuntime().wrap(function _callee8$(_context11) {
2029
+ var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(t) {
2030
+ return _regeneratorRuntime().wrap(function _callee6$(_context11) {
2046
2031
  while (1) {
2047
2032
  switch (_context11.prev = _context11.next) {
2048
2033
  case 0:
@@ -2065,7 +2050,7 @@
2065
2050
  return _context11.stop();
2066
2051
  }
2067
2052
  }
2068
- }, _callee8);
2053
+ }, _callee6);
2069
2054
  }));
2070
2055
  return function (_x36) {
2071
2056
  return _ref4.apply(this, arguments);
@@ -2096,7 +2081,7 @@
2096
2081
  return _context12.stop();
2097
2082
  }
2098
2083
  }
2099
- }, _callee9);
2084
+ }, _callee7);
2100
2085
  }));
2101
2086
  return _calculateSmartRouteV2PriceImpact.apply(this, arguments);
2102
2087
  }
@@ -2431,7 +2416,7 @@
2431
2416
  return _context5.stop();
2432
2417
  }
2433
2418
  }
2434
- }, _marked3, null, [[6, 14]]);
2419
+ }, _marked5, null, [[6, 14]]);
2435
2420
  }
2436
2421
  function getKShortestPaths(g, source, target, k, maxPathLength) {
2437
2422
  if (maxPathLength === void 0) {
@@ -2468,9 +2453,9 @@
2468
2453
  return _getPathsFromPools.apply(this, arguments);
2469
2454
  }
2470
2455
  function _getPathsFromPools() {
2471
- _getPathsFromPools = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(pools, inputToken, outputToken, maxPathLength) {
2456
+ _getPathsFromPools = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(pools, inputToken, outputToken, maxPathLength) {
2472
2457
  var graph;
2473
- return _regeneratorRuntime().wrap(function _callee10$(_context13) {
2458
+ return _regeneratorRuntime().wrap(function _callee8$(_context13) {
2474
2459
  while (1) {
2475
2460
  switch (_context13.prev = _context13.next) {
2476
2461
  case 0:
@@ -2484,7 +2469,7 @@
2484
2469
  return _context13.stop();
2485
2470
  }
2486
2471
  }
2487
- }, _callee10);
2472
+ }, _callee8);
2488
2473
  }));
2489
2474
  return _getPathsFromPools.apply(this, arguments);
2490
2475
  }
@@ -2519,9 +2504,9 @@
2519
2504
  return _stableSmart.apply(this, arguments);
2520
2505
  }
2521
2506
  function _stableSmart() {
2522
- _stableSmart = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12(pools, inputToken, outputToken, totalInput, allTokens) {
2507
+ _stableSmart = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(pools, inputToken, outputToken, totalInput, allTokens) {
2523
2508
  var smartRouteActions;
2524
- return _regeneratorRuntime().wrap(function _callee12$(_context15) {
2509
+ return _regeneratorRuntime().wrap(function _callee10$(_context15) {
2525
2510
  while (1) {
2526
2511
  switch (_context15.prev = _context15.next) {
2527
2512
  case 0:
@@ -2535,7 +2520,7 @@
2535
2520
  return _context15.stop();
2536
2521
  }
2537
2522
  }
2538
- }, _callee12);
2523
+ }, _callee10);
2539
2524
  }));
2540
2525
  return _stableSmart.apply(this, arguments);
2541
2526
  }
@@ -3880,7 +3865,11 @@
3880
3865
  return near.account(exports.REF_FI_CONTRACT_ID);
3881
3866
  case 3:
3882
3867
  nearConnection = _context.sent;
3883
- return _context.abrupt("return", nearConnection.viewFunction(exports.REF_FI_CONTRACT_ID, methodName, args));
3868
+ return _context.abrupt("return", nearConnection.viewFunction({
3869
+ contractId: exports.REF_FI_CONTRACT_ID,
3870
+ methodName: methodName,
3871
+ args: args
3872
+ }));
3884
3873
  case 5:
3885
3874
  case "end":
3886
3875
  return _context.stop();
@@ -3904,7 +3893,11 @@
3904
3893
  return near.account(exports.REF_FI_CONTRACT_ID);
3905
3894
  case 3:
3906
3895
  nearConnection = _context2.sent;
3907
- return _context2.abrupt("return", nearConnection.viewFunction(tokenId, methodName, args));
3896
+ return _context2.abrupt("return", nearConnection.viewFunction({
3897
+ contractId: tokenId,
3898
+ methodName: methodName,
3899
+ args: args
3900
+ }));
3908
3901
  case 5:
3909
3902
  case "end":
3910
3903
  return _context2.stop();
@@ -4196,7 +4189,11 @@
4196
4189
  }
4197
4190
  throw DCLInValid;
4198
4191
  case 6:
4199
- return _context10.abrupt("return", nearConnection.viewFunction(exports.config.REF_DCL_SWAP_CONTRACT_ID, methodName, args));
4192
+ return _context10.abrupt("return", nearConnection.viewFunction({
4193
+ contractId: exports.config.REF_DCL_SWAP_CONTRACT_ID,
4194
+ methodName: methodName,
4195
+ args: args
4196
+ }));
4200
4197
  case 7:
4201
4198
  case "end":
4202
4199
  return _context10.stop();