@ref-finance/ref-sdk 1.2.3 → 1.3.1

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,9 +179,6 @@ 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
- },
185
182
  $Symbol = "function" == typeof Symbol ? Symbol : {},
186
183
  iteratorSymbol = $Symbol.iterator || "@@iterator",
187
184
  asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator",
@@ -205,9 +202,40 @@ function _regeneratorRuntime() {
205
202
  var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator,
206
203
  generator = Object.create(protoGenerator.prototype),
207
204
  context = new Context(tryLocsList || []);
208
- return defineProperty(generator, "_invoke", {
209
- value: makeInvokeMethod(innerFn, self, context)
210
- }), generator;
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;
211
239
  }
212
240
  function tryCatch(fn, obj, arg) {
213
241
  try {
@@ -261,49 +289,13 @@ function _regeneratorRuntime() {
261
289
  reject(record.arg);
262
290
  }
263
291
  var previousPromise;
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);
292
+ this._invoke = function (method, arg) {
293
+ function callInvokeWithMethodAndArg() {
294
+ return new PromiseImpl(function (resolve, reject) {
295
+ invoke(method, arg, resolve, reject);
296
+ });
306
297
  }
298
+ return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
307
299
  };
308
300
  }
309
301
  function maybeInvokeDelegate(delegate, context) {
@@ -359,13 +351,7 @@ function _regeneratorRuntime() {
359
351
  done: !0
360
352
  };
361
353
  }
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) {
354
+ return GeneratorFunction.prototype = GeneratorFunctionPrototype, define(Gp, "constructor", GeneratorFunctionPrototype), define(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) {
369
355
  var ctor = "function" == typeof genFun && genFun.constructor;
370
356
  return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name));
371
357
  }, exports.mark = function (genFun) {
@@ -386,9 +372,8 @@ function _regeneratorRuntime() {
386
372
  return this;
387
373
  }), define(Gp, "toString", function () {
388
374
  return "[object Generator]";
389
- }), exports.keys = function (val) {
390
- var object = Object(val),
391
- keys = [];
375
+ }), exports.keys = function (object) {
376
+ var keys = [];
392
377
  for (var key in object) keys.push(key);
393
378
  return keys.reverse(), function next() {
394
379
  for (; keys.length;) {
@@ -877,7 +862,7 @@ function checkIntegerSumOfAllocations(allocations, totalInput) {
877
862
  return newAllocations;
878
863
  }
879
864
 
880
- var _marked3 = /*#__PURE__*/_regeneratorRuntime().mark(yenFromPy);
865
+ var _marked5 = /*#__PURE__*/_regeneratorRuntime().mark(yenFromPy);
881
866
  Big.RM = 0;
882
867
  Big.DP = 40;
883
868
  Big.NE = -40;
@@ -1299,8 +1284,8 @@ function getBestOptimalAllocationsAndOutputs(_x, _x2, _x3, _x4, _x5, _x6) {
1299
1284
  return _getBestOptimalAllocationsAndOutputs.apply(this, arguments);
1300
1285
  }
1301
1286
  function _getBestOptimalAllocationsAndOutputs() {
1302
- _getBestOptimalAllocationsAndOutputs = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(pools, inputToken, outputToken, totalInput, maxPathLength, threshold) {
1303
- return _regeneratorRuntime().wrap(function _callee4$(_context7) {
1287
+ _getBestOptimalAllocationsAndOutputs = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(pools, inputToken, outputToken, totalInput, maxPathLength, threshold) {
1288
+ return _regeneratorRuntime().wrap(function _callee2$(_context7) {
1304
1289
  while (1) {
1305
1290
  switch (_context7.prev = _context7.next) {
1306
1291
  case 0:
@@ -1311,9 +1296,9 @@ function _getBestOptimalAllocationsAndOutputs() {
1311
1296
  threshold = 0.001;
1312
1297
  }
1313
1298
  return _context7.abrupt("return", function () {
1314
- var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(totalInput) {
1299
+ var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(totalInput) {
1315
1300
  var paths, poolChains, routes, nodeRoutes, inputOutput, allocations, outputs;
1316
- return _regeneratorRuntime().wrap(function _callee3$(_context6) {
1301
+ return _regeneratorRuntime().wrap(function _callee$(_context6) {
1317
1302
  while (1) {
1318
1303
  switch (_context6.prev = _context6.next) {
1319
1304
  case 0:
@@ -1362,7 +1347,7 @@ function _getBestOptimalAllocationsAndOutputs() {
1362
1347
  return _context6.stop();
1363
1348
  }
1364
1349
  }
1365
- }, _callee3);
1350
+ }, _callee);
1366
1351
  }));
1367
1352
  return function (_x33) {
1368
1353
  return _ref.apply(this, arguments);
@@ -1373,7 +1358,7 @@ function _getBestOptimalAllocationsAndOutputs() {
1373
1358
  return _context7.stop();
1374
1359
  }
1375
1360
  }
1376
- }, _callee4);
1361
+ }, _callee2);
1377
1362
  }));
1378
1363
  return _getBestOptimalAllocationsAndOutputs.apply(this, arguments);
1379
1364
  }
@@ -1483,8 +1468,8 @@ function getSmartRouteSwapActions(_x7, _x8, _x9, _x10, _x11, _x12, _x13, _x14, _
1483
1468
  return _getSmartRouteSwapActions.apply(this, arguments);
1484
1469
  }
1485
1470
  function _getSmartRouteSwapActions() {
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) {
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) {
1488
1473
  while (1) {
1489
1474
  switch (_context10.prev = _context10.next) {
1490
1475
  case 0:
@@ -1504,9 +1489,9 @@ function _getSmartRouteSwapActions() {
1504
1489
  decimalsCulledPoolIds = [];
1505
1490
  }
1506
1491
  return _context10.abrupt("return", function () {
1507
- var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(totalInput) {
1492
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(totalInput) {
1508
1493
  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;
1509
- return _regeneratorRuntime().wrap(function _callee6$(_context9) {
1494
+ return _regeneratorRuntime().wrap(function _callee4$(_context9) {
1510
1495
  while (1) {
1511
1496
  switch (_context9.prev = _context9.next) {
1512
1497
  case 0:
@@ -1901,8 +1886,8 @@ function _getSmartRouteSwapActions() {
1901
1886
  }
1902
1887
  _context9.next = 143;
1903
1888
  return Promise.all(hops[i].nodeRoute.map( /*#__PURE__*/function () {
1904
- var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(t) {
1905
- return _regeneratorRuntime().wrap(function _callee5$(_context8) {
1889
+ var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(t) {
1890
+ return _regeneratorRuntime().wrap(function _callee3$(_context8) {
1906
1891
  while (1) {
1907
1892
  switch (_context8.prev = _context8.next) {
1908
1893
  case 0:
@@ -1925,7 +1910,7 @@ function _getSmartRouteSwapActions() {
1925
1910
  return _context8.stop();
1926
1911
  }
1927
1912
  }
1928
- }, _callee5);
1913
+ }, _callee3);
1929
1914
  }));
1930
1915
  return function (_x35) {
1931
1916
  return _ref3.apply(this, arguments);
@@ -1986,7 +1971,7 @@ function _getSmartRouteSwapActions() {
1986
1971
  return _context9.stop();
1987
1972
  }
1988
1973
  }
1989
- }, _callee6);
1974
+ }, _callee4);
1990
1975
  }));
1991
1976
  return function (_x34) {
1992
1977
  return _ref2.apply(this, arguments);
@@ -1997,7 +1982,7 @@ function _getSmartRouteSwapActions() {
1997
1982
  return _context10.stop();
1998
1983
  }
1999
1984
  }
2000
- }, _callee7);
1985
+ }, _callee5);
2001
1986
  }));
2002
1987
  return _getSmartRouteSwapActions.apply(this, arguments);
2003
1988
  }
@@ -2005,9 +1990,9 @@ function calculateSmartRouteV2PriceImpact(_x17, _x18) {
2005
1990
  return _calculateSmartRouteV2PriceImpact.apply(this, arguments);
2006
1991
  }
2007
1992
  function _calculateSmartRouteV2PriceImpact() {
2008
- _calculateSmartRouteV2PriceImpact = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(actions, allTokens) {
1993
+ _calculateSmartRouteV2PriceImpact = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(actions, allTokens) {
2009
1994
  var deltaY, inputTokenMeta, deltaX, R, P, routes, nodeRoutes, allocations, totalAllocations, weights, i, route, nodeRoute, tokens, weight, num, denom, routeMarketPrice, num1, denom1, num2, denom2, priceImpact;
2010
- return _regeneratorRuntime().wrap(function _callee9$(_context12) {
1995
+ return _regeneratorRuntime().wrap(function _callee7$(_context12) {
2011
1996
  while (1) {
2012
1997
  switch (_context12.prev = _context12.next) {
2013
1998
  case 0:
@@ -2053,8 +2038,8 @@ function _calculateSmartRouteV2PriceImpact() {
2053
2038
  nodeRoute = nodeRoutes[i];
2054
2039
  _context12.next = 17;
2055
2040
  return Promise.all(nodeRoute.map( /*#__PURE__*/function () {
2056
- var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(t) {
2057
- return _regeneratorRuntime().wrap(function _callee8$(_context11) {
2041
+ var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(t) {
2042
+ return _regeneratorRuntime().wrap(function _callee6$(_context11) {
2058
2043
  while (1) {
2059
2044
  switch (_context11.prev = _context11.next) {
2060
2045
  case 0:
@@ -2077,7 +2062,7 @@ function _calculateSmartRouteV2PriceImpact() {
2077
2062
  return _context11.stop();
2078
2063
  }
2079
2064
  }
2080
- }, _callee8);
2065
+ }, _callee6);
2081
2066
  }));
2082
2067
  return function (_x36) {
2083
2068
  return _ref4.apply(this, arguments);
@@ -2108,7 +2093,7 @@ function _calculateSmartRouteV2PriceImpact() {
2108
2093
  return _context12.stop();
2109
2094
  }
2110
2095
  }
2111
- }, _callee9);
2096
+ }, _callee7);
2112
2097
  }));
2113
2098
  return _calculateSmartRouteV2PriceImpact.apply(this, arguments);
2114
2099
  }
@@ -2443,7 +2428,7 @@ function yenFromPy(g, source, target) {
2443
2428
  return _context5.stop();
2444
2429
  }
2445
2430
  }
2446
- }, _marked3, null, [[6, 14]]);
2431
+ }, _marked5, null, [[6, 14]]);
2447
2432
  }
2448
2433
  function getKShortestPaths(g, source, target, k, maxPathLength) {
2449
2434
  if (maxPathLength === void 0) {
@@ -2480,9 +2465,9 @@ function getPathsFromPools(_x19, _x20, _x21, _x22) {
2480
2465
  return _getPathsFromPools.apply(this, arguments);
2481
2466
  }
2482
2467
  function _getPathsFromPools() {
2483
- _getPathsFromPools = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(pools, inputToken, outputToken, maxPathLength) {
2468
+ _getPathsFromPools = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(pools, inputToken, outputToken, maxPathLength) {
2484
2469
  var graph;
2485
- return _regeneratorRuntime().wrap(function _callee10$(_context13) {
2470
+ return _regeneratorRuntime().wrap(function _callee8$(_context13) {
2486
2471
  while (1) {
2487
2472
  switch (_context13.prev = _context13.next) {
2488
2473
  case 0:
@@ -2496,7 +2481,7 @@ function _getPathsFromPools() {
2496
2481
  return _context13.stop();
2497
2482
  }
2498
2483
  }
2499
- }, _callee10);
2484
+ }, _callee8);
2500
2485
  }));
2501
2486
  return _getPathsFromPools.apply(this, arguments);
2502
2487
  }
@@ -2531,9 +2516,9 @@ function stableSmart(_x28, _x29, _x30, _x31, _x32) {
2531
2516
  return _stableSmart.apply(this, arguments);
2532
2517
  }
2533
2518
  function _stableSmart() {
2534
- _stableSmart = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12(pools, inputToken, outputToken, totalInput, allTokens) {
2519
+ _stableSmart = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(pools, inputToken, outputToken, totalInput, allTokens) {
2535
2520
  var smartRouteActions;
2536
- return _regeneratorRuntime().wrap(function _callee12$(_context15) {
2521
+ return _regeneratorRuntime().wrap(function _callee10$(_context15) {
2537
2522
  while (1) {
2538
2523
  switch (_context15.prev = _context15.next) {
2539
2524
  case 0:
@@ -2547,7 +2532,7 @@ function _stableSmart() {
2547
2532
  return _context15.stop();
2548
2533
  }
2549
2534
  }
2550
- }, _callee12);
2535
+ }, _callee10);
2551
2536
  }));
2552
2537
  return _stableSmart.apply(this, arguments);
2553
2538
  }
@@ -3893,7 +3878,11 @@ var refFiViewFunction = /*#__PURE__*/function () {
3893
3878
  return near.account(REF_FI_CONTRACT_ID);
3894
3879
  case 3:
3895
3880
  nearConnection = _context.sent;
3896
- return _context.abrupt("return", nearConnection.viewFunction(REF_FI_CONTRACT_ID, methodName, args));
3881
+ return _context.abrupt("return", nearConnection.viewFunction({
3882
+ contractId: REF_FI_CONTRACT_ID,
3883
+ methodName: methodName,
3884
+ args: args
3885
+ }));
3897
3886
  case 5:
3898
3887
  case "end":
3899
3888
  return _context.stop();
@@ -3917,7 +3906,11 @@ var ftViewFunction = /*#__PURE__*/function () {
3917
3906
  return near.account(REF_FI_CONTRACT_ID);
3918
3907
  case 3:
3919
3908
  nearConnection = _context2.sent;
3920
- return _context2.abrupt("return", nearConnection.viewFunction(tokenId, methodName, args));
3909
+ return _context2.abrupt("return", nearConnection.viewFunction({
3910
+ contractId: tokenId,
3911
+ methodName: methodName,
3912
+ args: args
3913
+ }));
3921
3914
  case 5:
3922
3915
  case "end":
3923
3916
  return _context2.stop();
@@ -4209,7 +4202,11 @@ var refDCLSwapViewFunction = /*#__PURE__*/function () {
4209
4202
  }
4210
4203
  throw DCLInValid;
4211
4204
  case 6:
4212
- return _context10.abrupt("return", nearConnection.viewFunction(config.REF_DCL_SWAP_CONTRACT_ID, methodName, args));
4205
+ return _context10.abrupt("return", nearConnection.viewFunction({
4206
+ contractId: config.REF_DCL_SWAP_CONTRACT_ID,
4207
+ methodName: methodName,
4208
+ args: args
4209
+ }));
4213
4210
  case 7:
4214
4211
  case "end":
4215
4212
  return _context10.stop();
@@ -7534,12 +7531,12 @@ function getDefaultTokenList() {
7534
7531
  var DCL_POOL_SPLITER = '|';
7535
7532
  var DCLSwap = /*#__PURE__*/function () {
7536
7533
  var _ref2 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(_ref) {
7537
- var Swap, SwapByOutput, LimitOrderWithSwap, AccountId, swapInfo, transactions, tokenA, tokenB, amountA, pool_ids, tokenRegistered, output_token, min_output_amount, msg, _pool_ids, _output_token, output_amount, _msg, _tokenRegistered, pool_id, fee, buy_token, point, _tokenRegistered2, DCLRegistered, new_point, _msg2, registered;
7534
+ var Swap, SwapByOutput, LimitOrderWithSwap, SwapByStopPoint, AccountId, swapInfo, transactions, tokenA, tokenB, amountA, pool_ids, tokenRegistered, output_token, min_output_amount, msg, _pool_ids, _output_token, output_amount, _msg, _tokenRegistered, pool_id, fee, buy_token, point, _tokenRegistered2, DCLRegistered, new_point, _msg2, _tokenRegistered3, _msg3, registered;
7538
7535
  return _regeneratorRuntime().wrap(function _callee$(_context) {
7539
7536
  while (1) {
7540
7537
  switch (_context.prev = _context.next) {
7541
7538
  case 0:
7542
- Swap = _ref.Swap, SwapByOutput = _ref.SwapByOutput, LimitOrderWithSwap = _ref.LimitOrderWithSwap, AccountId = _ref.AccountId, swapInfo = _ref.swapInfo;
7539
+ Swap = _ref.Swap, SwapByOutput = _ref.SwapByOutput, LimitOrderWithSwap = _ref.LimitOrderWithSwap, SwapByStopPoint = _ref.SwapByStopPoint, AccountId = _ref.AccountId, swapInfo = _ref.swapInfo;
7543
7540
  transactions = [];
7544
7541
  tokenA = swapInfo.tokenA, tokenB = swapInfo.tokenB, amountA = swapInfo.amountA;
7545
7542
  if (!Swap) {
@@ -7582,7 +7579,7 @@ var DCLSwap = /*#__PURE__*/function () {
7582
7579
  amount: ONE_YOCTO_NEAR
7583
7580
  }]
7584
7581
  });
7585
- _context.next = 43;
7582
+ _context.next = 52;
7586
7583
  break;
7587
7584
  case 15:
7588
7585
  if (!SwapByOutput) {
@@ -7625,11 +7622,11 @@ var DCLSwap = /*#__PURE__*/function () {
7625
7622
  amount: ONE_YOCTO_NEAR
7626
7623
  }]
7627
7624
  });
7628
- _context.next = 43;
7625
+ _context.next = 52;
7629
7626
  break;
7630
7627
  case 27:
7631
7628
  if (!LimitOrderWithSwap) {
7632
- _context.next = 43;
7629
+ _context.next = 45;
7633
7630
  break;
7634
7631
  }
7635
7632
  pool_id = LimitOrderWithSwap.pool_id;
@@ -7696,14 +7693,49 @@ var DCLSwap = /*#__PURE__*/function () {
7696
7693
  amount: ONE_YOCTO_NEAR
7697
7694
  }]
7698
7695
  });
7699
- case 43:
7696
+ _context.next = 52;
7697
+ break;
7698
+ case 45:
7699
+ if (!SwapByStopPoint) {
7700
+ _context.next = 52;
7701
+ break;
7702
+ }
7703
+ _context.next = 48;
7704
+ return ftGetStorageBalance(tokenB.id, AccountId)["catch"](function () {
7705
+ throw new Error(tokenB.id + " doesn't exist.");
7706
+ });
7707
+ case 48:
7708
+ _tokenRegistered3 = _context.sent;
7709
+ if (_tokenRegistered3 === null) {
7710
+ transactions.push({
7711
+ receiverId: tokenB.id,
7712
+ functionCalls: [registerAccountOnToken(AccountId)]
7713
+ });
7714
+ }
7715
+ _msg3 = JSON.stringify({
7716
+ SwapByStopPoint: SwapByStopPoint
7717
+ });
7718
+ transactions.push({
7719
+ receiverId: tokenA.id,
7720
+ functionCalls: [{
7721
+ methodName: 'ft_transfer_call',
7722
+ args: {
7723
+ receiver_id: config.REF_DCL_SWAP_CONTRACT_ID,
7724
+ amount: toNonDivisibleNumber(tokenA.decimals, amountA),
7725
+ msg: _msg3
7726
+ },
7727
+ gas: '180000000000000',
7728
+ amount: ONE_YOCTO_NEAR
7729
+ }]
7730
+ });
7731
+ case 52:
7700
7732
  if (!(tokenA.id === WRAP_NEAR_CONTRACT_ID)) {
7701
- _context.next = 48;
7733
+ _context.next = 57;
7702
7734
  break;
7703
7735
  }
7704
- _context.next = 46;
7736
+ _context.next = 55;
7705
7737
  return ftGetStorageBalance(WRAP_NEAR_CONTRACT_ID, AccountId);
7706
- case 46:
7738
+ case 55:
7707
7739
  registered = _context.sent;
7708
7740
  if (registered === null) {
7709
7741
  transactions.unshift({
@@ -7711,9 +7743,9 @@ var DCLSwap = /*#__PURE__*/function () {
7711
7743
  functionCalls: [registerAccountOnToken(AccountId)]
7712
7744
  });
7713
7745
  }
7714
- case 48:
7746
+ case 57:
7715
7747
  return _context.abrupt("return", transactions);
7716
- case 49:
7748
+ case 58:
7717
7749
  case "end":
7718
7750
  return _context.stop();
7719
7751
  }