@ref-finance/ref-sdk 1.3.0 → 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.
@@ -7531,12 +7531,12 @@ function getDefaultTokenList() {
7531
7531
  var DCL_POOL_SPLITER = '|';
7532
7532
  var DCLSwap = /*#__PURE__*/function () {
7533
7533
  var _ref2 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(_ref) {
7534
- 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;
7535
7535
  return _regeneratorRuntime().wrap(function _callee$(_context) {
7536
7536
  while (1) {
7537
7537
  switch (_context.prev = _context.next) {
7538
7538
  case 0:
7539
- 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;
7540
7540
  transactions = [];
7541
7541
  tokenA = swapInfo.tokenA, tokenB = swapInfo.tokenB, amountA = swapInfo.amountA;
7542
7542
  if (!Swap) {
@@ -7579,7 +7579,7 @@ var DCLSwap = /*#__PURE__*/function () {
7579
7579
  amount: ONE_YOCTO_NEAR
7580
7580
  }]
7581
7581
  });
7582
- _context.next = 43;
7582
+ _context.next = 52;
7583
7583
  break;
7584
7584
  case 15:
7585
7585
  if (!SwapByOutput) {
@@ -7622,11 +7622,11 @@ var DCLSwap = /*#__PURE__*/function () {
7622
7622
  amount: ONE_YOCTO_NEAR
7623
7623
  }]
7624
7624
  });
7625
- _context.next = 43;
7625
+ _context.next = 52;
7626
7626
  break;
7627
7627
  case 27:
7628
7628
  if (!LimitOrderWithSwap) {
7629
- _context.next = 43;
7629
+ _context.next = 45;
7630
7630
  break;
7631
7631
  }
7632
7632
  pool_id = LimitOrderWithSwap.pool_id;
@@ -7693,14 +7693,49 @@ var DCLSwap = /*#__PURE__*/function () {
7693
7693
  amount: ONE_YOCTO_NEAR
7694
7694
  }]
7695
7695
  });
7696
- 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:
7697
7732
  if (!(tokenA.id === WRAP_NEAR_CONTRACT_ID)) {
7698
- _context.next = 48;
7733
+ _context.next = 57;
7699
7734
  break;
7700
7735
  }
7701
- _context.next = 46;
7736
+ _context.next = 55;
7702
7737
  return ftGetStorageBalance(WRAP_NEAR_CONTRACT_ID, AccountId);
7703
- case 46:
7738
+ case 55:
7704
7739
  registered = _context.sent;
7705
7740
  if (registered === null) {
7706
7741
  transactions.unshift({
@@ -7708,9 +7743,9 @@ var DCLSwap = /*#__PURE__*/function () {
7708
7743
  functionCalls: [registerAccountOnToken(AccountId)]
7709
7744
  });
7710
7745
  }
7711
- case 48:
7746
+ case 57:
7712
7747
  return _context.abrupt("return", transactions);
7713
- case 49:
7748
+ case 58:
7714
7749
  case "end":
7715
7750
  return _context.stop();
7716
7751
  }