@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.
@@ -3865,11 +3865,7 @@
3865
3865
  return near.account(exports.REF_FI_CONTRACT_ID);
3866
3866
  case 3:
3867
3867
  nearConnection = _context.sent;
3868
- return _context.abrupt("return", nearConnection.viewFunction({
3869
- contractId: exports.REF_FI_CONTRACT_ID,
3870
- methodName: methodName,
3871
- args: args
3872
- }));
3868
+ return _context.abrupt("return", nearConnection.viewFunction(exports.REF_FI_CONTRACT_ID, methodName, args));
3873
3869
  case 5:
3874
3870
  case "end":
3875
3871
  return _context.stop();
@@ -3893,11 +3889,7 @@
3893
3889
  return near.account(exports.REF_FI_CONTRACT_ID);
3894
3890
  case 3:
3895
3891
  nearConnection = _context2.sent;
3896
- return _context2.abrupt("return", nearConnection.viewFunction({
3897
- contractId: tokenId,
3898
- methodName: methodName,
3899
- args: args
3900
- }));
3892
+ return _context2.abrupt("return", nearConnection.viewFunction(tokenId, methodName, args));
3901
3893
  case 5:
3902
3894
  case "end":
3903
3895
  return _context2.stop();
@@ -4189,11 +4181,7 @@
4189
4181
  }
4190
4182
  throw DCLInValid;
4191
4183
  case 6:
4192
- return _context10.abrupt("return", nearConnection.viewFunction({
4193
- contractId: exports.config.REF_DCL_SWAP_CONTRACT_ID,
4194
- methodName: methodName,
4195
- args: args
4196
- }));
4184
+ return _context10.abrupt("return", nearConnection.viewFunction(exports.config.REF_DCL_SWAP_CONTRACT_ID, methodName, args));
4197
4185
  case 7:
4198
4186
  case "end":
4199
4187
  return _context10.stop();
@@ -7518,12 +7506,12 @@
7518
7506
  var DCL_POOL_SPLITER = '|';
7519
7507
  var DCLSwap = /*#__PURE__*/function () {
7520
7508
  var _ref2 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(_ref) {
7521
- 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;
7509
+ 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;
7522
7510
  return _regeneratorRuntime().wrap(function _callee$(_context) {
7523
7511
  while (1) {
7524
7512
  switch (_context.prev = _context.next) {
7525
7513
  case 0:
7526
- Swap = _ref.Swap, SwapByOutput = _ref.SwapByOutput, LimitOrderWithSwap = _ref.LimitOrderWithSwap, AccountId = _ref.AccountId, swapInfo = _ref.swapInfo;
7514
+ Swap = _ref.Swap, SwapByOutput = _ref.SwapByOutput, LimitOrderWithSwap = _ref.LimitOrderWithSwap, SwapByStopPoint = _ref.SwapByStopPoint, AccountId = _ref.AccountId, swapInfo = _ref.swapInfo;
7527
7515
  transactions = [];
7528
7516
  tokenA = swapInfo.tokenA, tokenB = swapInfo.tokenB, amountA = swapInfo.amountA;
7529
7517
  if (!Swap) {
@@ -7566,7 +7554,7 @@
7566
7554
  amount: ONE_YOCTO_NEAR
7567
7555
  }]
7568
7556
  });
7569
- _context.next = 43;
7557
+ _context.next = 52;
7570
7558
  break;
7571
7559
  case 15:
7572
7560
  if (!SwapByOutput) {
@@ -7609,11 +7597,11 @@
7609
7597
  amount: ONE_YOCTO_NEAR
7610
7598
  }]
7611
7599
  });
7612
- _context.next = 43;
7600
+ _context.next = 52;
7613
7601
  break;
7614
7602
  case 27:
7615
7603
  if (!LimitOrderWithSwap) {
7616
- _context.next = 43;
7604
+ _context.next = 45;
7617
7605
  break;
7618
7606
  }
7619
7607
  pool_id = LimitOrderWithSwap.pool_id;
@@ -7680,14 +7668,49 @@
7680
7668
  amount: ONE_YOCTO_NEAR
7681
7669
  }]
7682
7670
  });
7683
- case 43:
7671
+ _context.next = 52;
7672
+ break;
7673
+ case 45:
7674
+ if (!SwapByStopPoint) {
7675
+ _context.next = 52;
7676
+ break;
7677
+ }
7678
+ _context.next = 48;
7679
+ return ftGetStorageBalance(tokenB.id, AccountId)["catch"](function () {
7680
+ throw new Error(tokenB.id + " doesn't exist.");
7681
+ });
7682
+ case 48:
7683
+ _tokenRegistered3 = _context.sent;
7684
+ if (_tokenRegistered3 === null) {
7685
+ transactions.push({
7686
+ receiverId: tokenB.id,
7687
+ functionCalls: [registerAccountOnToken(AccountId)]
7688
+ });
7689
+ }
7690
+ _msg3 = JSON.stringify({
7691
+ SwapByStopPoint: SwapByStopPoint
7692
+ });
7693
+ transactions.push({
7694
+ receiverId: tokenA.id,
7695
+ functionCalls: [{
7696
+ methodName: 'ft_transfer_call',
7697
+ args: {
7698
+ receiver_id: exports.config.REF_DCL_SWAP_CONTRACT_ID,
7699
+ amount: toNonDivisibleNumber(tokenA.decimals, amountA),
7700
+ msg: _msg3
7701
+ },
7702
+ gas: '180000000000000',
7703
+ amount: ONE_YOCTO_NEAR
7704
+ }]
7705
+ });
7706
+ case 52:
7684
7707
  if (!(tokenA.id === exports.WRAP_NEAR_CONTRACT_ID)) {
7685
- _context.next = 48;
7708
+ _context.next = 57;
7686
7709
  break;
7687
7710
  }
7688
- _context.next = 46;
7711
+ _context.next = 55;
7689
7712
  return ftGetStorageBalance(exports.WRAP_NEAR_CONTRACT_ID, AccountId);
7690
- case 46:
7713
+ case 55:
7691
7714
  registered = _context.sent;
7692
7715
  if (registered === null) {
7693
7716
  transactions.unshift({
@@ -7695,9 +7718,9 @@
7695
7718
  functionCalls: [registerAccountOnToken(AccountId)]
7696
7719
  });
7697
7720
  }
7698
- case 48:
7721
+ case 57:
7699
7722
  return _context.abrupt("return", transactions);
7700
- case 49:
7723
+ case 58:
7701
7724
  case "end":
7702
7725
  return _context.stop();
7703
7726
  }