@ref-finance/ref-sdk 1.3.0 → 1.3.2

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.
@@ -3878,11 +3878,7 @@ var refFiViewFunction = /*#__PURE__*/function () {
3878
3878
  return near.account(REF_FI_CONTRACT_ID);
3879
3879
  case 3:
3880
3880
  nearConnection = _context.sent;
3881
- return _context.abrupt("return", nearConnection.viewFunction({
3882
- contractId: REF_FI_CONTRACT_ID,
3883
- methodName: methodName,
3884
- args: args
3885
- }));
3881
+ return _context.abrupt("return", nearConnection.viewFunction(REF_FI_CONTRACT_ID, methodName, args));
3886
3882
  case 5:
3887
3883
  case "end":
3888
3884
  return _context.stop();
@@ -3906,11 +3902,7 @@ var ftViewFunction = /*#__PURE__*/function () {
3906
3902
  return near.account(REF_FI_CONTRACT_ID);
3907
3903
  case 3:
3908
3904
  nearConnection = _context2.sent;
3909
- return _context2.abrupt("return", nearConnection.viewFunction({
3910
- contractId: tokenId,
3911
- methodName: methodName,
3912
- args: args
3913
- }));
3905
+ return _context2.abrupt("return", nearConnection.viewFunction(tokenId, methodName, args));
3914
3906
  case 5:
3915
3907
  case "end":
3916
3908
  return _context2.stop();
@@ -4202,11 +4194,7 @@ var refDCLSwapViewFunction = /*#__PURE__*/function () {
4202
4194
  }
4203
4195
  throw DCLInValid;
4204
4196
  case 6:
4205
- return _context10.abrupt("return", nearConnection.viewFunction({
4206
- contractId: config.REF_DCL_SWAP_CONTRACT_ID,
4207
- methodName: methodName,
4208
- args: args
4209
- }));
4197
+ return _context10.abrupt("return", nearConnection.viewFunction(config.REF_DCL_SWAP_CONTRACT_ID, methodName, args));
4210
4198
  case 7:
4211
4199
  case "end":
4212
4200
  return _context10.stop();
@@ -7531,12 +7519,12 @@ function getDefaultTokenList() {
7531
7519
  var DCL_POOL_SPLITER = '|';
7532
7520
  var DCLSwap = /*#__PURE__*/function () {
7533
7521
  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;
7522
+ 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
7523
  return _regeneratorRuntime().wrap(function _callee$(_context) {
7536
7524
  while (1) {
7537
7525
  switch (_context.prev = _context.next) {
7538
7526
  case 0:
7539
- Swap = _ref.Swap, SwapByOutput = _ref.SwapByOutput, LimitOrderWithSwap = _ref.LimitOrderWithSwap, AccountId = _ref.AccountId, swapInfo = _ref.swapInfo;
7527
+ Swap = _ref.Swap, SwapByOutput = _ref.SwapByOutput, LimitOrderWithSwap = _ref.LimitOrderWithSwap, SwapByStopPoint = _ref.SwapByStopPoint, AccountId = _ref.AccountId, swapInfo = _ref.swapInfo;
7540
7528
  transactions = [];
7541
7529
  tokenA = swapInfo.tokenA, tokenB = swapInfo.tokenB, amountA = swapInfo.amountA;
7542
7530
  if (!Swap) {
@@ -7579,7 +7567,7 @@ var DCLSwap = /*#__PURE__*/function () {
7579
7567
  amount: ONE_YOCTO_NEAR
7580
7568
  }]
7581
7569
  });
7582
- _context.next = 43;
7570
+ _context.next = 52;
7583
7571
  break;
7584
7572
  case 15:
7585
7573
  if (!SwapByOutput) {
@@ -7622,11 +7610,11 @@ var DCLSwap = /*#__PURE__*/function () {
7622
7610
  amount: ONE_YOCTO_NEAR
7623
7611
  }]
7624
7612
  });
7625
- _context.next = 43;
7613
+ _context.next = 52;
7626
7614
  break;
7627
7615
  case 27:
7628
7616
  if (!LimitOrderWithSwap) {
7629
- _context.next = 43;
7617
+ _context.next = 45;
7630
7618
  break;
7631
7619
  }
7632
7620
  pool_id = LimitOrderWithSwap.pool_id;
@@ -7693,14 +7681,49 @@ var DCLSwap = /*#__PURE__*/function () {
7693
7681
  amount: ONE_YOCTO_NEAR
7694
7682
  }]
7695
7683
  });
7696
- case 43:
7684
+ _context.next = 52;
7685
+ break;
7686
+ case 45:
7687
+ if (!SwapByStopPoint) {
7688
+ _context.next = 52;
7689
+ break;
7690
+ }
7691
+ _context.next = 48;
7692
+ return ftGetStorageBalance(tokenB.id, AccountId)["catch"](function () {
7693
+ throw new Error(tokenB.id + " doesn't exist.");
7694
+ });
7695
+ case 48:
7696
+ _tokenRegistered3 = _context.sent;
7697
+ if (_tokenRegistered3 === null) {
7698
+ transactions.push({
7699
+ receiverId: tokenB.id,
7700
+ functionCalls: [registerAccountOnToken(AccountId)]
7701
+ });
7702
+ }
7703
+ _msg3 = JSON.stringify({
7704
+ SwapByStopPoint: SwapByStopPoint
7705
+ });
7706
+ transactions.push({
7707
+ receiverId: tokenA.id,
7708
+ functionCalls: [{
7709
+ methodName: 'ft_transfer_call',
7710
+ args: {
7711
+ receiver_id: config.REF_DCL_SWAP_CONTRACT_ID,
7712
+ amount: toNonDivisibleNumber(tokenA.decimals, amountA),
7713
+ msg: _msg3
7714
+ },
7715
+ gas: '180000000000000',
7716
+ amount: ONE_YOCTO_NEAR
7717
+ }]
7718
+ });
7719
+ case 52:
7697
7720
  if (!(tokenA.id === WRAP_NEAR_CONTRACT_ID)) {
7698
- _context.next = 48;
7721
+ _context.next = 57;
7699
7722
  break;
7700
7723
  }
7701
- _context.next = 46;
7724
+ _context.next = 55;
7702
7725
  return ftGetStorageBalance(WRAP_NEAR_CONTRACT_ID, AccountId);
7703
- case 46:
7726
+ case 55:
7704
7727
  registered = _context.sent;
7705
7728
  if (registered === null) {
7706
7729
  transactions.unshift({
@@ -7708,9 +7731,9 @@ var DCLSwap = /*#__PURE__*/function () {
7708
7731
  functionCalls: [registerAccountOnToken(AccountId)]
7709
7732
  });
7710
7733
  }
7711
- case 48:
7734
+ case 57:
7712
7735
  return _context.abrupt("return", transactions);
7713
- case 49:
7736
+ case 58:
7714
7737
  case "end":
7715
7738
  return _context.stop();
7716
7739
  }