@ref-finance/ref-sdk 1.4.7 → 1.4.9

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.
@@ -5,9 +5,10 @@ Object.defineProperty(exports, '__esModule', { value: true });
5
5
  function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
6
6
 
7
7
  var nearApiJs = require('near-api-js');
8
+ var BN = _interopDefault(require('bn.js'));
9
+ var fs = _interopDefault(require('fs'));
8
10
  var _ = require('lodash');
9
11
  var ___default = _interopDefault(_);
10
- var BN = _interopDefault(require('bn.js'));
11
12
  var math = require('mathjs');
12
13
  var Big = _interopDefault(require('big.js'));
13
14
  var format = require('near-api-js/lib/utils/format');
@@ -569,55 +570,129 @@ function _createForOfIteratorHelperLoose(o, allowArrayLike) {
569
570
  throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
570
571
  }
571
572
 
572
- var getKeyStore = function getKeyStore() {
573
- return typeof window === 'undefined' ? new nearApiJs.keyStores.InMemoryKeyStore() : new nearApiJs.keyStores.BrowserLocalStorageKeyStore();
573
+ var tradeFee = function tradeFee(amount, trade_fee) {
574
+ return amount * trade_fee / FEE_DIVISOR;
575
+ };
576
+ var calc_d = function calc_d(amp, c_amounts) {
577
+ var token_num = c_amounts.length;
578
+ var sum_amounts = ___default.sum(c_amounts);
579
+ var d_prev = 0;
580
+ var d = sum_amounts;
581
+ for (var i = 0; i < 256; i++) {
582
+ var d_prod = d;
583
+ for (var _iterator = _createForOfIteratorHelperLoose(c_amounts), _step; !(_step = _iterator()).done;) {
584
+ var c_amount = _step.value;
585
+ d_prod = d_prod * d / (c_amount * token_num);
586
+ }
587
+ d_prev = d;
588
+ var ann = amp * Math.pow(token_num, token_num);
589
+ var numerator = d_prev * (d_prod * token_num + ann * sum_amounts);
590
+ var denominator = d_prev * (ann - 1) + d_prod * (token_num + 1);
591
+ d = numerator / denominator;
592
+ if (Math.abs(d - d_prev) <= 1) break;
593
+ }
594
+ return d;
595
+ };
596
+ var calc_y = function calc_y(amp, x_c_amount, current_c_amounts, index_x, index_y) {
597
+ var token_num = current_c_amounts.length;
598
+ var ann = amp * Math.pow(token_num, token_num);
599
+ var d = calc_d(amp, current_c_amounts);
600
+ var s = x_c_amount;
601
+ var c = d * d / x_c_amount;
602
+ for (var i = 0; i < token_num; i++) {
603
+ if (i !== index_x && i !== index_y) {
604
+ s += current_c_amounts[i];
605
+ c = c * d / current_c_amounts[i];
606
+ }
607
+ }
608
+ c = c * d / (ann * Math.pow(token_num, token_num));
609
+ var b = d / ann + s;
610
+ var y_prev = 0;
611
+ var y = d;
612
+ for (var _i = 0; _i < 256; _i++) {
613
+ y_prev = y;
614
+ var y_numerator = Math.pow(y, 2) + c;
615
+ var y_denominator = 2 * y + b - d;
616
+ y = y_numerator / y_denominator;
617
+ if (Math.abs(y - y_prev) <= 1) break;
618
+ }
619
+ return y;
620
+ };
621
+ var calc_swap = function calc_swap(amp, in_token_idx, in_c_amount, out_token_idx, old_c_amounts, trade_fee) {
622
+ var y = calc_y(amp, in_c_amount + old_c_amounts[in_token_idx], old_c_amounts, in_token_idx, out_token_idx);
623
+ var dy = old_c_amounts[out_token_idx] - y;
624
+ var fee = tradeFee(dy, trade_fee);
625
+ var amount_swapped = dy - fee;
626
+ return [amount_swapped, fee, dy];
627
+ };
628
+ var getSwappedAmount = function getSwappedAmount(tokenInId, tokenOutId, amountIn, stablePool, STABLE_LP_TOKEN_DECIMALS) {
629
+ var amp = stablePool.amp;
630
+ var trade_fee = stablePool.total_fee;
631
+ // depended on pools
632
+ var in_token_idx = stablePool.token_account_ids.findIndex(function (id) {
633
+ return id === tokenInId;
634
+ });
635
+ var out_token_idx = stablePool.token_account_ids.findIndex(function (id) {
636
+ return id === tokenOutId;
637
+ });
638
+ var rates = stablePool != null && stablePool.degens ? stablePool.degens.map(function (r) {
639
+ return toReadableNumber(STABLE_LP_TOKEN_DECIMALS, r);
640
+ }) : stablePool.rates.map(function (r) {
641
+ return toReadableNumber(STABLE_LP_TOKEN_DECIMALS, r);
642
+ });
643
+ var base_old_c_amounts = stablePool.c_amounts.map(function (amount) {
644
+ return toReadableNumber(STABLE_LP_TOKEN_DECIMALS, amount);
645
+ });
646
+ var old_c_amounts = base_old_c_amounts.map(function (amount, i) {
647
+ return toNonDivisibleNumber(STABLE_LP_TOKEN_DECIMALS, scientificNotationToString(new Big(amount || 0).times(new Big(rates[i])).toString()));
648
+ }).map(function (amount) {
649
+ return Number(amount);
650
+ });
651
+ var in_c_amount = Number(toNonDivisibleNumber(STABLE_LP_TOKEN_DECIMALS, scientificNotationToString(new Big(amountIn).times(new Big(rates[in_token_idx])).toString())));
652
+ var _calc_swap = calc_swap(amp, in_token_idx, in_c_amount, out_token_idx, old_c_amounts, trade_fee),
653
+ amount_swapped = _calc_swap[0],
654
+ fee = _calc_swap[1],
655
+ dy = _calc_swap[2];
656
+ return [amount_swapped / Number(rates[out_token_idx]), fee, dy / Number(rates[out_token_idx])];
657
+ };
658
+
659
+ var REF_WIDGET_STAR_TOKEN_LIST_KEY = 'REF_WIDGET_STAR_TOKEN_LIST_VALUE';
660
+ var REF_WIDGET_ALL_TOKENS_LIST_KEY = 'REF_WIDGET_ALL_TOKENS_LIST_VALUE';
661
+ var REF_WIDGET_ALL_LIGHT_TOKENS_LIST_KEY = 'REF_WIDGET_ALL_LIGHT_TOKENS_LIST_VALUE';
662
+ var REF_WIDGET_SWAP_IN_KEY = 'REF_WIDGET_SWAP_IN_VALUE';
663
+ var REF_WIDGET_SWAP_OUT_KEY = 'REF_WIDGET_SWAP_OUT_VALUE';
664
+ var REF_WIDGET_SWAP_DETAIL_KEY = 'REF_WIDGET_SWAP_DETAIL_VALUE';
665
+ var DEFAULT_START_TOKEN_LIST_TESTNET = ['wrap.testnet', 'usdtt.fakes.testnet', 'usdt.fakes.testnet', 'ref.fakes.testnet', 'usdn.testnet', 'eth.fakes.testnet'];
666
+ var DEFAULT_START_TOKEN_LIST_MAINNET = ['wrap.near', 'usdt.tether-token.near', 'dac17f958d2ee523a2206206994597c13d831ec7.factory.bridge.near', 'token.v2.ref-finance.near', 'usn', 'aurora', 'token.sweat'];
667
+ var defaultTheme = {
668
+ container: '#FFFFFF',
669
+ buttonBg: '#00C6A2',
670
+ primary: '#000000',
671
+ secondary: '#7E8A93',
672
+ borderRadius: '4px',
673
+ fontFamily: 'sans-serif',
674
+ hover: 'rgba(126, 138, 147, 0.2)',
675
+ active: 'rgba(126, 138, 147, 0.2)',
676
+ secondaryBg: '#F7F7F7',
677
+ borderColor: 'rgba(126, 138, 147, 0.2)',
678
+ iconDefault: 'rgba(126, 138, 147, 1)',
679
+ iconHover: 'rgba(62, 62, 62, 1)'
680
+ };
681
+ var defaultDarkModeTheme = {
682
+ container: '#26343E',
683
+ buttonBg: '#00C6A2',
684
+ primary: '#FFFFFF',
685
+ secondary: '#7E8A93',
686
+ borderRadius: '4px',
687
+ fontFamily: 'sans-serif',
688
+ hover: 'rgba(126, 138, 147, 0.2)',
689
+ active: 'rgba(126, 138, 147, 0.2)',
690
+ secondaryBg: 'rgba(0, 0, 0, 0.2)',
691
+ borderColor: 'rgba(126, 138, 147, 0.2)',
692
+ iconDefault: 'rgba(126, 138, 147, 1)',
693
+ iconHover: 'rgba(183, 201, 214, 1)',
694
+ refIcon: 'white'
574
695
  };
575
- var provider = /*#__PURE__*/new nearApiJs.providers.JsonRpcProvider({
576
- url: /*#__PURE__*/getConfig().nodeUrl
577
- });
578
- var sendTransactionsByMemoryKey = /*#__PURE__*/function () {
579
- var _ref2 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(_ref) {
580
- var signedTransactions, results, i;
581
- return _regeneratorRuntime().wrap(function _callee$(_context) {
582
- while (1) {
583
- switch (_context.prev = _context.next) {
584
- case 0:
585
- signedTransactions = _ref.signedTransactions;
586
- _context.prev = 1;
587
- results = [];
588
- i = 0;
589
- case 4:
590
- if (!(i < signedTransactions.length)) {
591
- _context.next = 13;
592
- break;
593
- }
594
- _context.t0 = results;
595
- _context.next = 8;
596
- return provider.sendTransaction(signedTransactions[i]);
597
- case 8:
598
- _context.t1 = _context.sent;
599
- _context.t0.push.call(_context.t0, _context.t1);
600
- case 10:
601
- i += 1;
602
- _context.next = 4;
603
- break;
604
- case 13:
605
- return _context.abrupt("return", results);
606
- case 16:
607
- _context.prev = 16;
608
- _context.t2 = _context["catch"](1);
609
- throw _context.t2;
610
- case 19:
611
- case "end":
612
- return _context.stop();
613
- }
614
- }
615
- }, _callee, null, [[1, 16]]);
616
- }));
617
- return function sendTransactionsByMemoryKey(_x) {
618
- return _ref2.apply(this, arguments);
619
- };
620
- }();
621
696
 
622
697
  var icons = {
623
698
  '4691937a7508860f876c9c0a2a617e7d9e945d4b.factory.bridge.near': 'https://assets.ref.finance/images/woo-wtrue.png',
@@ -651,822 +726,217 @@ var icons = {
651
726
  'd9c2d319cd7e6177336b0a9c93c21cb48d84fb54.factory.bridge.near': 'https://assets.ref.finance/images/HAPI.png'
652
727
  };
653
728
 
654
- var BANANA_ID = 'berryclub.ek.near';
655
- var CHEDDAR_ID = 'token.cheddar.near';
656
- var CUCUMBER_ID = 'farm.berryclub.ek.near';
657
- var HAPI_ID = 'd9c2d319cd7e6177336b0a9c93c21cb48d84fb54.factory.bridge.near';
658
- var WOO_ID = '4691937a7508860f876c9c0a2a617e7d9e945d4b.factory.bridge.near';
659
- var REPLACE_TOKENS = [BANANA_ID, CHEDDAR_ID, CUCUMBER_ID, HAPI_ID, WOO_ID];
660
- var near = /*#__PURE__*/new nearApiJs.Near( /*#__PURE__*/_extends({
661
- keyStore: /*#__PURE__*/getKeyStore(),
662
- headers: {}
663
- }, /*#__PURE__*/getConfig()));
664
- var init_env = function init_env(env, indexerUrl, nodeUrl) {
665
- near = new nearApiJs.Near(_extends({
666
- keyStore: getKeyStore(),
667
- headers: {}
668
- }, getConfig(env, indexerUrl, nodeUrl)));
669
- return switchEnv();
670
- };
671
- var refFiViewFunction = /*#__PURE__*/function () {
672
- var _ref2 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(_ref) {
673
- var methodName, args, nearConnection;
729
+ var getTokenPriceList = /*#__PURE__*/function () {
730
+ var _ref = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
674
731
  return _regeneratorRuntime().wrap(function _callee$(_context) {
675
732
  while (1) {
676
733
  switch (_context.prev = _context.next) {
677
734
  case 0:
678
- methodName = _ref.methodName, args = _ref.args;
679
- _context.next = 3;
680
- return near.account(exports.REF_FI_CONTRACT_ID);
735
+ _context.next = 2;
736
+ return fetch(exports.config.indexerUrl + '/list-token-price', {
737
+ method: 'GET',
738
+ headers: {
739
+ 'Content-type': 'application/json; charset=UTF-8'
740
+ }
741
+ }).then(function (res) {
742
+ return res.json();
743
+ }).then(function (list) {
744
+ return list;
745
+ });
746
+ case 2:
747
+ return _context.abrupt("return", _context.sent);
681
748
  case 3:
682
- nearConnection = _context.sent;
683
- return _context.abrupt("return", nearConnection.viewFunction(exports.REF_FI_CONTRACT_ID, methodName, args));
684
- case 5:
685
749
  case "end":
686
750
  return _context.stop();
687
751
  }
688
752
  }
689
753
  }, _callee);
690
754
  }));
691
- return function refFiViewFunction(_x) {
692
- return _ref2.apply(this, arguments);
755
+ return function getTokenPriceList() {
756
+ return _ref.apply(this, arguments);
693
757
  };
694
758
  }();
695
- var ftViewFunction = /*#__PURE__*/function () {
696
- var _ref4 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(tokenId, _ref3) {
697
- var methodName, args, nearConnection;
759
+ var getTokens = /*#__PURE__*/function () {
760
+ var _ref2 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(reload) {
761
+ var storagedTokens;
698
762
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
699
763
  while (1) {
700
764
  switch (_context2.prev = _context2.next) {
701
765
  case 0:
702
- methodName = _ref3.methodName, args = _ref3.args;
703
- _context2.next = 3;
704
- return near.account(exports.REF_FI_CONTRACT_ID);
705
- case 3:
706
- nearConnection = _context2.sent;
707
- return _context2.abrupt("return", nearConnection.viewFunction(tokenId, methodName, args));
766
+ storagedTokens = typeof window !== 'undefined' && !reload ? localStorage.getItem(REF_WIDGET_ALL_TOKENS_LIST_KEY) : null;
767
+ if (!storagedTokens) {
768
+ _context2.next = 5;
769
+ break;
770
+ }
771
+ _context2.t0 = JSON.parse(storagedTokens);
772
+ _context2.next = 8;
773
+ break;
708
774
  case 5:
775
+ _context2.next = 7;
776
+ return fetch(exports.config.indexerUrl + '/list-token', {
777
+ method: 'GET',
778
+ headers: {
779
+ 'Content-type': 'application/json; charset=UTF-8'
780
+ }
781
+ }).then(function (res) {
782
+ return res.json();
783
+ }).then(function (tokens) {
784
+ var newTokens = Object.values(tokens).reduce(function (acc, cur, i) {
785
+ var _extends2;
786
+ var id = Object.keys(tokens)[i];
787
+ return _extends({}, acc, (_extends2 = {}, _extends2[id] = _extends({}, cur, {
788
+ id: id,
789
+ icon: !cur.icon || REPLACE_TOKENS.includes(id) ? icons[id] : cur.icon
790
+ }), _extends2));
791
+ }, {});
792
+ return newTokens;
793
+ }).then(function (res) {
794
+ typeof window !== 'undefined' && !reload && localStorage.setItem(REF_WIDGET_ALL_TOKENS_LIST_KEY, JSON.stringify(res));
795
+ return res;
796
+ });
797
+ case 7:
798
+ _context2.t0 = _context2.sent;
799
+ case 8:
800
+ return _context2.abrupt("return", _context2.t0);
801
+ case 9:
709
802
  case "end":
710
803
  return _context2.stop();
711
804
  }
712
805
  }
713
806
  }, _callee2);
714
807
  }));
715
- return function ftViewFunction(_x2, _x3) {
716
- return _ref4.apply(this, arguments);
808
+ return function getTokens(_x) {
809
+ return _ref2.apply(this, arguments);
717
810
  };
718
811
  }();
719
- var ftGetStorageBalance = function ftGetStorageBalance(tokenId, AccountId) {
720
- if (!AccountId) throw NoAccountIdFound;
721
- return ftViewFunction(tokenId, {
722
- methodName: 'storage_balance_of',
723
- args: {
724
- account_id: AccountId
725
- }
726
- });
727
- };
728
- var ftGetBalance = /*#__PURE__*/function () {
729
- var _ref5 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(tokenId, AccountId) {
812
+ var getTokensTiny = /*#__PURE__*/function () {
813
+ var _ref3 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(reload) {
814
+ var storagedTokens;
730
815
  return _regeneratorRuntime().wrap(function _callee3$(_context3) {
731
816
  while (1) {
732
817
  switch (_context3.prev = _context3.next) {
733
818
  case 0:
734
- if (AccountId) {
735
- _context3.next = 2;
736
- break;
737
- }
738
- return _context3.abrupt("return", '0');
739
- case 2:
740
- if (!(tokenId === 'NEAR')) {
741
- _context3.next = 4;
819
+ storagedTokens = typeof window !== 'undefined' && !reload ? localStorage.getItem(REF_WIDGET_ALL_LIGHT_TOKENS_LIST_KEY) : null;
820
+ if (!storagedTokens) {
821
+ _context3.next = 5;
742
822
  break;
743
823
  }
744
- return _context3.abrupt("return", getAccountNearBalance(AccountId)["catch"](function () {
745
- return '0';
746
- }));
747
- case 4:
748
- return _context3.abrupt("return", ftViewFunction(tokenId, {
749
- methodName: 'ft_balance_of',
750
- args: {
751
- account_id: AccountId
824
+ _context3.t0 = JSON.parse(storagedTokens);
825
+ _context3.next = 8;
826
+ break;
827
+ case 5:
828
+ _context3.next = 7;
829
+ return fetch(exports.config.indexerUrl + '/list-token-v2', {
830
+ method: 'GET',
831
+ headers: {
832
+ 'Content-type': 'application/json; charset=UTF-8'
752
833
  }
753
834
  }).then(function (res) {
835
+ return res.json();
836
+ }).then(function (tokens) {
837
+ var newTokens = Object.values(tokens).reduce(function (acc, cur, i) {
838
+ var _extends3;
839
+ var id = Object.keys(tokens)[i];
840
+ return _extends({}, acc, (_extends3 = {}, _extends3[id] = _extends({}, cur, {
841
+ id: id
842
+ }), _extends3));
843
+ }, {});
844
+ return newTokens;
845
+ }).then(function (res) {
846
+ typeof window !== 'undefined' && !reload && localStorage.setItem(REF_WIDGET_ALL_LIGHT_TOKENS_LIST_KEY, JSON.stringify(res));
754
847
  return res;
755
- })["catch"](function () {
756
- return '0';
757
- }));
758
- case 5:
848
+ });
849
+ case 7:
850
+ _context3.t0 = _context3.sent;
851
+ case 8:
852
+ return _context3.abrupt("return", _context3.t0);
853
+ case 9:
759
854
  case "end":
760
855
  return _context3.stop();
761
856
  }
762
857
  }
763
858
  }, _callee3);
764
859
  }));
765
- return function ftGetBalance(_x4, _x5) {
766
- return _ref5.apply(this, arguments);
860
+ return function getTokensTiny(_x2) {
861
+ return _ref3.apply(this, arguments);
767
862
  };
768
863
  }();
769
- var getTotalPools = /*#__PURE__*/function () {
770
- var _ref6 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
864
+ var getWhiteListTokensIndexer = /*#__PURE__*/function () {
865
+ var _ref4 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(whiteListIds) {
771
866
  return _regeneratorRuntime().wrap(function _callee4$(_context4) {
772
867
  while (1) {
773
868
  switch (_context4.prev = _context4.next) {
774
869
  case 0:
775
- return _context4.abrupt("return", refFiViewFunction({
776
- methodName: 'get_number_of_pools'
777
- }));
778
- case 1:
779
- case "end":
780
- return _context4.stop();
781
- }
782
- }
783
- }, _callee4);
784
- }));
785
- return function getTotalPools() {
786
- return _ref6.apply(this, arguments);
787
- };
788
- }();
789
- var ftGetTokenMetadata = /*#__PURE__*/function () {
790
- var _ref7 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(id, tag) {
791
- var metadata;
792
- return _regeneratorRuntime().wrap(function _callee5$(_context5) {
793
- while (1) {
794
- switch (_context5.prev = _context5.next) {
795
- case 0:
796
- if (!(id === exports.REF_TOKEN_ID)) {
797
- _context5.next = 2;
798
- break;
799
- }
800
- return _context5.abrupt("return", exports.REF_META_DATA);
801
- case 2:
802
- _context5.next = 4;
803
- return ftViewFunction(id, {
804
- methodName: 'ft_metadata'
805
- })["catch"](function () {
806
- throw TokenNotExistError(id);
807
- });
808
- case 4:
809
- metadata = _context5.sent;
810
- if (!(!metadata.icon || id === BANANA_ID || id === CHEDDAR_ID || id === CUCUMBER_ID || id === HAPI_ID || id === WOO_ID || id === exports.WRAP_NEAR_CONTRACT_ID)) {
811
- _context5.next = 7;
812
- break;
813
- }
814
- return _context5.abrupt("return", _extends({}, metadata, {
815
- icon: icons[id],
816
- id: id
817
- }));
818
- case 7:
819
- return _context5.abrupt("return", _extends({}, metadata, {
820
- id: id
821
- }));
822
- case 8:
823
- case "end":
824
- return _context5.stop();
825
- }
826
- }
827
- }, _callee5);
828
- }));
829
- return function ftGetTokenMetadata(_x6, _x7) {
830
- return _ref7.apply(this, arguments);
831
- };
832
- }();
833
- var ftGetTokensMetadata = /*#__PURE__*/function () {
834
- var _ref8 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(tokenIds, allTokens) {
835
- var ids, tokensMetadata;
836
- return _regeneratorRuntime().wrap(function _callee6$(_context6) {
837
- while (1) {
838
- switch (_context6.prev = _context6.next) {
839
- case 0:
840
- _context6.t0 = tokenIds;
841
- if (_context6.t0) {
842
- _context6.next = 5;
843
- break;
844
- }
845
- _context6.next = 4;
846
- return getGlobalWhitelist();
847
- case 4:
848
- _context6.t0 = _context6.sent;
849
- case 5:
850
- ids = _context6.t0;
851
- _context6.next = 8;
852
- return Promise.all(ids.map(function (id) {
853
- return (allTokens == null ? void 0 : allTokens[id]) || ftGetTokenMetadata(id)["catch"](function () {
854
- return null;
855
- });
856
- }));
857
- case 8:
858
- tokensMetadata = _context6.sent;
859
- return _context6.abrupt("return", tokensMetadata.reduce(function (pre, cur, i) {
860
- var _extends2;
861
- return _extends({}, pre, (_extends2 = {}, _extends2[ids[i]] = cur, _extends2));
862
- }, {}));
863
- case 10:
864
- case "end":
865
- return _context6.stop();
866
- }
867
- }
868
- }, _callee6);
869
- }));
870
- return function ftGetTokensMetadata(_x8, _x9) {
871
- return _ref8.apply(this, arguments);
872
- };
873
- }();
874
- var getGlobalWhitelist = /*#__PURE__*/function () {
875
- var _ref9 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
876
- var globalWhitelist;
877
- return _regeneratorRuntime().wrap(function _callee7$(_context7) {
878
- while (1) {
879
- switch (_context7.prev = _context7.next) {
880
- case 0:
881
- _context7.next = 2;
882
- return refFiViewFunction({
883
- methodName: 'get_whitelisted_tokens'
870
+ _context4.next = 2;
871
+ return fetch(exports.config.indexerUrl + '/list-token', {
872
+ method: 'GET',
873
+ headers: {
874
+ 'Content-type': 'application/json; charset=UTF-8'
875
+ }
876
+ }).then(function (res) {
877
+ return res.json();
878
+ }).then(function (res) {
879
+ return whiteListIds.reduce(function (acc, cur, i) {
880
+ var _extends4;
881
+ if (!res[cur] || !Object.values(res[cur]) || Object.values(res[cur]).length === 0) return acc;
882
+ return _extends({}, acc, (_extends4 = {}, _extends4[cur] = _extends({}, res[cur], {
883
+ id: cur
884
+ }), _extends4));
885
+ }, {});
886
+ }).then(function (res) {
887
+ return Object.values(res);
884
888
  });
885
889
  case 2:
886
- globalWhitelist = _context7.sent;
887
- return _context7.abrupt("return", Array.from(new Set(globalWhitelist)));
888
- case 4:
889
- case "end":
890
- return _context7.stop();
891
- }
892
- }
893
- }, _callee7);
894
- }));
895
- return function getGlobalWhitelist() {
896
- return _ref9.apply(this, arguments);
897
- };
898
- }();
899
- var getUserRegisteredTokens = /*#__PURE__*/function () {
900
- var _ref10 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(AccountId) {
901
- return _regeneratorRuntime().wrap(function _callee8$(_context8) {
902
- while (1) {
903
- switch (_context8.prev = _context8.next) {
904
- case 0:
905
- if (AccountId) {
906
- _context8.next = 2;
907
- break;
908
- }
909
- return _context8.abrupt("return", []);
910
- case 2:
911
- return _context8.abrupt("return", refFiViewFunction({
912
- methodName: 'get_user_whitelisted_tokens',
913
- args: {
914
- account_id: AccountId
915
- }
916
- }));
890
+ return _context4.abrupt("return", _context4.sent);
917
891
  case 3:
918
892
  case "end":
919
- return _context8.stop();
893
+ return _context4.stop();
920
894
  }
921
895
  }
922
- }, _callee8);
896
+ }, _callee4);
923
897
  }));
924
- return function getUserRegisteredTokens(_x10) {
925
- return _ref10.apply(this, arguments);
926
- };
927
- }();
928
- var getAccountNearBalance = /*#__PURE__*/function () {
929
- var _ref11 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(accountId) {
930
- var provider;
931
- return _regeneratorRuntime().wrap(function _callee9$(_context9) {
932
- while (1) {
933
- switch (_context9.prev = _context9.next) {
934
- case 0:
935
- provider = new nearApiJs.providers.JsonRpcProvider({
936
- url: getConfig().nodeUrl
937
- });
938
- return _context9.abrupt("return", provider.query({
939
- request_type: 'view_account',
940
- finality: 'final',
941
- account_id: accountId
942
- }).then(function (data) {
943
- return data.amount;
944
- }));
945
- case 2:
946
- case "end":
947
- return _context9.stop();
948
- }
949
- }
950
- }, _callee9);
951
- }));
952
- return function getAccountNearBalance(_x11) {
953
- return _ref11.apply(this, arguments);
954
- };
955
- }();
956
- var nearDepositTransaction = function nearDepositTransaction(amount) {
957
- var transaction = {
958
- receiverId: exports.WRAP_NEAR_CONTRACT_ID,
959
- functionCalls: [{
960
- methodName: 'near_deposit',
961
- args: {},
962
- gas: '50000000000000',
963
- amount: amount
964
- }]
965
- };
966
- return transaction;
967
- };
968
- var nearWithdrawTransaction = function nearWithdrawTransaction(amount) {
969
- var transaction = {
970
- receiverId: exports.WRAP_NEAR_CONTRACT_ID,
971
- functionCalls: [{
972
- methodName: 'near_withdraw',
973
- args: {
974
- amount: nearApiJs.utils.format.parseNearAmount(amount)
975
- },
976
- amount: ONE_YOCTO_NEAR
977
- }]
978
- };
979
- return transaction;
980
- };
981
- var refDCLSwapViewFunction = /*#__PURE__*/function () {
982
- var _ref13 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(_ref12) {
983
- var methodName, args, nearConnection;
984
- return _regeneratorRuntime().wrap(function _callee10$(_context10) {
985
- while (1) {
986
- switch (_context10.prev = _context10.next) {
987
- case 0:
988
- methodName = _ref12.methodName, args = _ref12.args;
989
- _context10.next = 3;
990
- return near.account(exports.REF_FI_CONTRACT_ID);
991
- case 3:
992
- nearConnection = _context10.sent;
993
- if (exports.config.REF_DCL_SWAP_CONTRACT_ID) {
994
- _context10.next = 6;
995
- break;
996
- }
997
- throw DCLInValid;
998
- case 6:
999
- return _context10.abrupt("return", nearConnection.viewFunction(exports.config.REF_DCL_SWAP_CONTRACT_ID, methodName, args));
1000
- case 7:
1001
- case "end":
1002
- return _context10.stop();
1003
- }
1004
- }
1005
- }, _callee10);
1006
- }));
1007
- return function refDCLSwapViewFunction(_x12) {
1008
- return _ref13.apply(this, arguments);
1009
- };
1010
- }();
1011
- var DCLSwapGetStorageBalance = function DCLSwapGetStorageBalance(tokenId, AccountId) {
1012
- return refDCLSwapViewFunction({
1013
- methodName: 'storage_balance_of',
1014
- args: {
1015
- account_id: AccountId
1016
- }
1017
- });
1018
- };
1019
- var getMinStorageBalance = /*#__PURE__*/function () {
1020
- var _ref14 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(nep141Address) {
1021
- var provider, result, balance;
1022
- return _regeneratorRuntime().wrap(function _callee11$(_context11) {
1023
- while (1) {
1024
- switch (_context11.prev = _context11.next) {
1025
- case 0:
1026
- _context11.prev = 0;
1027
- provider = new nearApiJs.providers.JsonRpcProvider({
1028
- url: getConfig().nodeUrl
1029
- });
1030
- _context11.next = 4;
1031
- return provider.query({
1032
- request_type: 'call_function',
1033
- account_id: nep141Address,
1034
- method_name: 'storage_balance_bounds',
1035
- args_base64: '',
1036
- finality: 'optimistic'
1037
- });
1038
- case 4:
1039
- result = _context11.sent;
1040
- balance = JSON.parse(Buffer.from(result.result).toString());
1041
- if (!(!balance || !balance.min)) {
1042
- _context11.next = 8;
1043
- break;
1044
- }
1045
- return _context11.abrupt("return", FT_MINIMUM_STORAGE_BALANCE_LARGE);
1046
- case 8:
1047
- return _context11.abrupt("return", balance.min);
1048
- case 11:
1049
- _context11.prev = 11;
1050
- _context11.t0 = _context11["catch"](0);
1051
- console.error(_context11.t0, nep141Address);
1052
- return _context11.abrupt("return", FT_MINIMUM_STORAGE_BALANCE_LARGE);
1053
- case 15:
1054
- case "end":
1055
- return _context11.stop();
1056
- }
1057
- }
1058
- }, _callee11, null, [[0, 11]]);
1059
- }));
1060
- return function getMinStorageBalance(_x13) {
1061
- return _ref14.apply(this, arguments);
898
+ return function getWhiteListTokensIndexer(_x3) {
899
+ return _ref4.apply(this, arguments);
1062
900
  };
1063
901
  }();
1064
902
 
1065
- var DCL_POOL_FEE_LIST = [100, 400, 2000, 10000];
1066
- var getDCLPoolId = function getDCLPoolId(tokenA, tokenB, fee) {
1067
- if (DCL_POOL_FEE_LIST.indexOf(fee) === -1) throw NoFeeToPool(fee);
1068
- var tokenSeq = [tokenA, tokenB].sort().join('|');
1069
- return tokenSeq + "|" + fee;
1070
- };
1071
- var listDCLPools = function listDCLPools() {
1072
- return refDCLSwapViewFunction({
1073
- methodName: 'list_pools'
903
+ //@ts-nocheck
904
+ Big.RM = 0;
905
+ Big.DP = 40;
906
+ Big.NE = -40;
907
+ Big.PE = 40;
908
+ function checkIntegerSumOfAllocations(allocations, totalInput) {
909
+ var totalInput = new Big(totalInput);
910
+ var allocations = allocations.map(function (item) {
911
+ return new Big(item).round();
1074
912
  });
1075
- };
1076
- var getDCLPool = /*#__PURE__*/function () {
1077
- var _ref = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(pool_id) {
1078
- var _pool_id$split, token_x, token_y, fee, token_seq, new_pool_id;
1079
- return _regeneratorRuntime().wrap(function _callee$(_context) {
1080
- while (1) {
1081
- switch (_context.prev = _context.next) {
1082
- case 0:
1083
- _pool_id$split = pool_id.split('|'), token_x = _pool_id$split[0], token_y = _pool_id$split[1], fee = _pool_id$split[2];
1084
- token_seq = [token_x, token_y].sort().join('|');
1085
- new_pool_id = token_seq + "|" + fee;
1086
- return _context.abrupt("return", refDCLSwapViewFunction({
1087
- methodName: 'get_pool',
1088
- args: {
1089
- pool_id: new_pool_id
1090
- }
1091
- }));
1092
- case 4:
1093
- case "end":
1094
- return _context.stop();
1095
- }
1096
- }
1097
- }, _callee);
1098
- }));
1099
- return function getDCLPool(_x) {
1100
- return _ref.apply(this, arguments);
1101
- };
1102
- }();
1103
-
1104
- var formatError = function formatError(msg) {
1105
- return new Error(msg);
1106
- };
1107
- var unNamedError = /*#__PURE__*/formatError('Something wrong happened');
1108
- var SameInputTokenError = /*#__PURE__*/formatError('Input token should be different with output token');
1109
- var ZeroInputError = /*#__PURE__*/formatError('Input amount should be greater than 0');
1110
- var NoPoolError = /*#__PURE__*/formatError('No pool found for the input tokens');
1111
- var NotLoginError = /*#__PURE__*/formatError('Please login in first');
1112
- var SwapRouteError = /*#__PURE__*/formatError("Something wrong happened, we don't get correct routes corrreponding to current input");
1113
- var TokenNotExistError = function TokenNotExistError(id) {
1114
- return formatError(id + " doesn't exist in " + getConfig().networkId);
1115
- };
1116
- var NoPuiblicKeyError = /*#__PURE__*/formatError('No public key found');
1117
- var NoLocalSignerError = /*#__PURE__*/formatError('No local signer found');
1118
- var InValidAccessKeyError = /*#__PURE__*/formatError('Invalid access key');
1119
- var AccountIdMisMatch = /*#__PURE__*/formatError("Your input account id doesn't match the account id in the credential");
1120
- var NoCredential = /*#__PURE__*/formatError('No Credential to such path');
1121
- var NoAccountIdFound = /*#__PURE__*/formatError('No account id found');
1122
- var NoFeeToPool = function NoFeeToPool(fee) {
1123
- return formatError("InValid fee " + fee + " to DCL pool, the valid fee should be one of " + DCL_POOL_FEE_LIST);
1124
- };
1125
- var DCLInValid = /*#__PURE__*/formatError("DCL contract currently in Valid on " + exports.config.networkId);
1126
- var NoPoolOnThisPair = function NoPoolOnThisPair(tokenA, tokenB) {
1127
- return formatError("No pools on pair " + tokenA + " <> " + tokenB);
1128
- };
1129
- var SlippageError = /*#__PURE__*/formatError('slippage tolerance should be in range (0, 100)');
1130
- var NoOrderFound = function NoOrderFound(order_id) {
1131
- return formatError("No order " + (order_id || '') + " found");
1132
- };
1133
- var OrderNoRemainedAmount = /*#__PURE__*/formatError('No remained amount on this order');
1134
-
1135
- var tradeFee = function tradeFee(amount, trade_fee) {
1136
- return amount * trade_fee / FEE_DIVISOR;
1137
- };
1138
- var calc_d = function calc_d(amp, c_amounts) {
1139
- var token_num = c_amounts.length;
1140
- var sum_amounts = ___default.sum(c_amounts);
1141
- var d_prev = 0;
1142
- var d = sum_amounts;
1143
- for (var i = 0; i < 256; i++) {
1144
- var d_prod = d;
1145
- for (var _iterator = _createForOfIteratorHelperLoose(c_amounts), _step; !(_step = _iterator()).done;) {
1146
- var c_amount = _step.value;
1147
- d_prod = d_prod * d / (c_amount * token_num);
913
+ var alloSum = allocations.map(function (item) {
914
+ return new Big(item);
915
+ }).reduce(function (a, b) {
916
+ return a.plus(b);
917
+ }, new Big(0));
918
+ var offset = totalInput.minus(alloSum);
919
+ //get largest allocation.
920
+ var currMax = new Big(0);
921
+ var currMaxInd = 0;
922
+ for (var i = 0; i < allocations.length; i++) {
923
+ if (allocations[i].gt(currMax)) {
924
+ currMaxInd = i;
925
+ currMax = allocations[i];
1148
926
  }
1149
- d_prev = d;
1150
- var ann = amp * Math.pow(token_num, token_num);
1151
- var numerator = d_prev * (d_prod * token_num + ann * sum_amounts);
1152
- var denominator = d_prev * (ann - 1) + d_prod * (token_num + 1);
1153
- d = numerator / denominator;
1154
- if (Math.abs(d - d_prev) <= 1) break;
1155
927
  }
1156
- return d;
1157
- };
1158
- var calc_y = function calc_y(amp, x_c_amount, current_c_amounts, index_x, index_y) {
1159
- var token_num = current_c_amounts.length;
1160
- var ann = amp * Math.pow(token_num, token_num);
1161
- var d = calc_d(amp, current_c_amounts);
1162
- var s = x_c_amount;
1163
- var c = d * d / x_c_amount;
1164
- for (var i = 0; i < token_num; i++) {
1165
- if (i !== index_x && i !== index_y) {
1166
- s += current_c_amounts[i];
1167
- c = c * d / current_c_amounts[i];
928
+ var newAllocations = [];
929
+ for (var j = 0; j < allocations.length; j++) {
930
+ if (j === currMaxInd) {
931
+ newAllocations.push(allocations[j].plus(offset).toString());
932
+ } else {
933
+ newAllocations.push(allocations[j].toString());
1168
934
  }
1169
935
  }
1170
- c = c * d / (ann * Math.pow(token_num, token_num));
1171
- var b = d / ann + s;
1172
- var y_prev = 0;
1173
- var y = d;
1174
- for (var _i = 0; _i < 256; _i++) {
1175
- y_prev = y;
1176
- var y_numerator = Math.pow(y, 2) + c;
1177
- var y_denominator = 2 * y + b - d;
1178
- y = y_numerator / y_denominator;
1179
- if (Math.abs(y - y_prev) <= 1) break;
1180
- }
1181
- return y;
1182
- };
1183
- var calc_swap = function calc_swap(amp, in_token_idx, in_c_amount, out_token_idx, old_c_amounts, trade_fee) {
1184
- var y = calc_y(amp, in_c_amount + old_c_amounts[in_token_idx], old_c_amounts, in_token_idx, out_token_idx);
1185
- var dy = old_c_amounts[out_token_idx] - y;
1186
- var fee = tradeFee(dy, trade_fee);
1187
- var amount_swapped = dy - fee;
1188
- return [amount_swapped, fee, dy];
1189
- };
1190
- var getSwappedAmount = function getSwappedAmount(tokenInId, tokenOutId, amountIn, stablePool, STABLE_LP_TOKEN_DECIMALS) {
1191
- var amp = stablePool.amp;
1192
- var trade_fee = stablePool.total_fee;
1193
- // depended on pools
1194
- var in_token_idx = stablePool.token_account_ids.findIndex(function (id) {
1195
- return id === tokenInId;
1196
- });
1197
- var out_token_idx = stablePool.token_account_ids.findIndex(function (id) {
1198
- return id === tokenOutId;
1199
- });
1200
- var rates = stablePool != null && stablePool.degens ? stablePool.degens.map(function (r) {
1201
- return toReadableNumber(STABLE_LP_TOKEN_DECIMALS, r);
1202
- }) : stablePool.rates.map(function (r) {
1203
- return toReadableNumber(STABLE_LP_TOKEN_DECIMALS, r);
1204
- });
1205
- var base_old_c_amounts = stablePool.c_amounts.map(function (amount) {
1206
- return toReadableNumber(STABLE_LP_TOKEN_DECIMALS, amount);
1207
- });
1208
- var old_c_amounts = base_old_c_amounts.map(function (amount, i) {
1209
- return toNonDivisibleNumber(STABLE_LP_TOKEN_DECIMALS, scientificNotationToString(new Big(amount || 0).times(new Big(rates[i])).toString()));
1210
- }).map(function (amount) {
1211
- return Number(amount);
1212
- });
1213
- var in_c_amount = Number(toNonDivisibleNumber(STABLE_LP_TOKEN_DECIMALS, scientificNotationToString(new Big(amountIn).times(new Big(rates[in_token_idx])).toString())));
1214
- var _calc_swap = calc_swap(amp, in_token_idx, in_c_amount, out_token_idx, old_c_amounts, trade_fee),
1215
- amount_swapped = _calc_swap[0],
1216
- fee = _calc_swap[1],
1217
- dy = _calc_swap[2];
1218
- return [amount_swapped / Number(rates[out_token_idx]), fee, dy / Number(rates[out_token_idx])];
1219
- };
1220
-
1221
- var REF_WIDGET_STAR_TOKEN_LIST_KEY = 'REF_WIDGET_STAR_TOKEN_LIST_VALUE';
1222
- var REF_WIDGET_ALL_TOKENS_LIST_KEY = 'REF_WIDGET_ALL_TOKENS_LIST_VALUE';
1223
- var REF_WIDGET_ALL_LIGHT_TOKENS_LIST_KEY = 'REF_WIDGET_ALL_LIGHT_TOKENS_LIST_VALUE';
1224
- var REF_WIDGET_SWAP_IN_KEY = 'REF_WIDGET_SWAP_IN_VALUE';
1225
- var REF_WIDGET_SWAP_OUT_KEY = 'REF_WIDGET_SWAP_OUT_VALUE';
1226
- var REF_WIDGET_SWAP_DETAIL_KEY = 'REF_WIDGET_SWAP_DETAIL_VALUE';
1227
- var DEFAULT_START_TOKEN_LIST_TESTNET = ['wrap.testnet', 'usdtt.fakes.testnet', 'usdt.fakes.testnet', 'ref.fakes.testnet', 'usdn.testnet', 'eth.fakes.testnet'];
1228
- var DEFAULT_START_TOKEN_LIST_MAINNET = ['wrap.near', 'usdt.tether-token.near', 'dac17f958d2ee523a2206206994597c13d831ec7.factory.bridge.near', 'token.v2.ref-finance.near', 'usn', 'aurora', 'token.sweat'];
1229
- var defaultTheme = {
1230
- container: '#FFFFFF',
1231
- buttonBg: '#00C6A2',
1232
- primary: '#000000',
1233
- secondary: '#7E8A93',
1234
- borderRadius: '4px',
1235
- fontFamily: 'sans-serif',
1236
- hover: 'rgba(126, 138, 147, 0.2)',
1237
- active: 'rgba(126, 138, 147, 0.2)',
1238
- secondaryBg: '#F7F7F7',
1239
- borderColor: 'rgba(126, 138, 147, 0.2)',
1240
- iconDefault: 'rgba(126, 138, 147, 1)',
1241
- iconHover: 'rgba(62, 62, 62, 1)'
1242
- };
1243
- var defaultDarkModeTheme = {
1244
- container: '#26343E',
1245
- buttonBg: '#00C6A2',
1246
- primary: '#FFFFFF',
1247
- secondary: '#7E8A93',
1248
- borderRadius: '4px',
1249
- fontFamily: 'sans-serif',
1250
- hover: 'rgba(126, 138, 147, 0.2)',
1251
- active: 'rgba(126, 138, 147, 0.2)',
1252
- secondaryBg: 'rgba(0, 0, 0, 0.2)',
1253
- borderColor: 'rgba(126, 138, 147, 0.2)',
1254
- iconDefault: 'rgba(126, 138, 147, 1)',
1255
- iconHover: 'rgba(183, 201, 214, 1)',
1256
- refIcon: 'white'
1257
- };
1258
-
1259
- var getTokenPriceList = /*#__PURE__*/function () {
1260
- var _ref = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
1261
- return _regeneratorRuntime().wrap(function _callee$(_context) {
1262
- while (1) {
1263
- switch (_context.prev = _context.next) {
1264
- case 0:
1265
- _context.next = 2;
1266
- return fetch(exports.config.indexerUrl + '/list-token-price', {
1267
- method: 'GET',
1268
- headers: {
1269
- 'Content-type': 'application/json; charset=UTF-8'
1270
- }
1271
- }).then(function (res) {
1272
- return res.json();
1273
- }).then(function (list) {
1274
- return list;
1275
- });
1276
- case 2:
1277
- return _context.abrupt("return", _context.sent);
1278
- case 3:
1279
- case "end":
1280
- return _context.stop();
1281
- }
1282
- }
1283
- }, _callee);
1284
- }));
1285
- return function getTokenPriceList() {
1286
- return _ref.apply(this, arguments);
1287
- };
1288
- }();
1289
- var getTokens = /*#__PURE__*/function () {
1290
- var _ref2 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(reload) {
1291
- var storagedTokens;
1292
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
1293
- while (1) {
1294
- switch (_context2.prev = _context2.next) {
1295
- case 0:
1296
- storagedTokens = typeof window !== 'undefined' && !reload ? localStorage.getItem(REF_WIDGET_ALL_TOKENS_LIST_KEY) : null;
1297
- if (!storagedTokens) {
1298
- _context2.next = 5;
1299
- break;
1300
- }
1301
- _context2.t0 = JSON.parse(storagedTokens);
1302
- _context2.next = 8;
1303
- break;
1304
- case 5:
1305
- _context2.next = 7;
1306
- return fetch(exports.config.indexerUrl + '/list-token', {
1307
- method: 'GET',
1308
- headers: {
1309
- 'Content-type': 'application/json; charset=UTF-8'
1310
- }
1311
- }).then(function (res) {
1312
- return res.json();
1313
- }).then(function (tokens) {
1314
- var newTokens = Object.values(tokens).reduce(function (acc, cur, i) {
1315
- var _extends2;
1316
- var id = Object.keys(tokens)[i];
1317
- return _extends({}, acc, (_extends2 = {}, _extends2[id] = _extends({}, cur, {
1318
- id: id,
1319
- icon: !cur.icon || REPLACE_TOKENS.includes(id) ? icons[id] : cur.icon
1320
- }), _extends2));
1321
- }, {});
1322
- return newTokens;
1323
- }).then(function (res) {
1324
- typeof window !== 'undefined' && !reload && localStorage.setItem(REF_WIDGET_ALL_TOKENS_LIST_KEY, JSON.stringify(res));
1325
- return res;
1326
- });
1327
- case 7:
1328
- _context2.t0 = _context2.sent;
1329
- case 8:
1330
- return _context2.abrupt("return", _context2.t0);
1331
- case 9:
1332
- case "end":
1333
- return _context2.stop();
1334
- }
1335
- }
1336
- }, _callee2);
1337
- }));
1338
- return function getTokens(_x) {
1339
- return _ref2.apply(this, arguments);
1340
- };
1341
- }();
1342
- var getTokensTiny = /*#__PURE__*/function () {
1343
- var _ref3 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(reload) {
1344
- var storagedTokens;
1345
- return _regeneratorRuntime().wrap(function _callee3$(_context3) {
1346
- while (1) {
1347
- switch (_context3.prev = _context3.next) {
1348
- case 0:
1349
- storagedTokens = typeof window !== 'undefined' && !reload ? localStorage.getItem(REF_WIDGET_ALL_LIGHT_TOKENS_LIST_KEY) : null;
1350
- if (!storagedTokens) {
1351
- _context3.next = 5;
1352
- break;
1353
- }
1354
- _context3.t0 = JSON.parse(storagedTokens);
1355
- _context3.next = 8;
1356
- break;
1357
- case 5:
1358
- _context3.next = 7;
1359
- return fetch(exports.config.indexerUrl + '/list-token-v2', {
1360
- method: 'GET',
1361
- headers: {
1362
- 'Content-type': 'application/json; charset=UTF-8'
1363
- }
1364
- }).then(function (res) {
1365
- return res.json();
1366
- }).then(function (tokens) {
1367
- var newTokens = Object.values(tokens).reduce(function (acc, cur, i) {
1368
- var _extends3;
1369
- var id = Object.keys(tokens)[i];
1370
- return _extends({}, acc, (_extends3 = {}, _extends3[id] = _extends({}, cur, {
1371
- id: id
1372
- }), _extends3));
1373
- }, {});
1374
- return newTokens;
1375
- }).then(function (res) {
1376
- typeof window !== 'undefined' && !reload && localStorage.setItem(REF_WIDGET_ALL_LIGHT_TOKENS_LIST_KEY, JSON.stringify(res));
1377
- return res;
1378
- });
1379
- case 7:
1380
- _context3.t0 = _context3.sent;
1381
- case 8:
1382
- return _context3.abrupt("return", _context3.t0);
1383
- case 9:
1384
- case "end":
1385
- return _context3.stop();
1386
- }
1387
- }
1388
- }, _callee3);
1389
- }));
1390
- return function getTokensTiny(_x2) {
1391
- return _ref3.apply(this, arguments);
1392
- };
1393
- }();
1394
- var getWhiteListTokensIndexer = /*#__PURE__*/function () {
1395
- var _ref4 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(whiteListIds) {
1396
- return _regeneratorRuntime().wrap(function _callee4$(_context4) {
1397
- while (1) {
1398
- switch (_context4.prev = _context4.next) {
1399
- case 0:
1400
- _context4.next = 2;
1401
- return fetch(exports.config.indexerUrl + '/list-token', {
1402
- method: 'GET',
1403
- headers: {
1404
- 'Content-type': 'application/json; charset=UTF-8'
1405
- }
1406
- }).then(function (res) {
1407
- return res.json();
1408
- }).then(function (res) {
1409
- return whiteListIds.reduce(function (acc, cur, i) {
1410
- var _extends4;
1411
- if (!res[cur] || !Object.values(res[cur]) || Object.values(res[cur]).length === 0) return acc;
1412
- return _extends({}, acc, (_extends4 = {}, _extends4[cur] = _extends({}, res[cur], {
1413
- id: cur
1414
- }), _extends4));
1415
- }, {});
1416
- }).then(function (res) {
1417
- return Object.values(res);
1418
- });
1419
- case 2:
1420
- return _context4.abrupt("return", _context4.sent);
1421
- case 3:
1422
- case "end":
1423
- return _context4.stop();
1424
- }
1425
- }
1426
- }, _callee4);
1427
- }));
1428
- return function getWhiteListTokensIndexer(_x3) {
1429
- return _ref4.apply(this, arguments);
1430
- };
1431
- }();
936
+ return newAllocations;
937
+ }
1432
938
 
1433
- //@ts-nocheck
1434
- Big.RM = 0;
1435
- Big.DP = 40;
1436
- Big.NE = -40;
1437
- Big.PE = 40;
1438
- function checkIntegerSumOfAllocations(allocations, totalInput) {
1439
- var totalInput = new Big(totalInput);
1440
- var allocations = allocations.map(function (item) {
1441
- return new Big(item).round();
1442
- });
1443
- var alloSum = allocations.map(function (item) {
1444
- return new Big(item);
1445
- }).reduce(function (a, b) {
1446
- return a.plus(b);
1447
- }, new Big(0));
1448
- var offset = totalInput.minus(alloSum);
1449
- //get largest allocation.
1450
- var currMax = new Big(0);
1451
- var currMaxInd = 0;
1452
- for (var i = 0; i < allocations.length; i++) {
1453
- if (allocations[i].gt(currMax)) {
1454
- currMaxInd = i;
1455
- currMax = allocations[i];
1456
- }
1457
- }
1458
- var newAllocations = [];
1459
- for (var j = 0; j < allocations.length; j++) {
1460
- if (j === currMaxInd) {
1461
- newAllocations.push(allocations[j].plus(offset).toString());
1462
- } else {
1463
- newAllocations.push(allocations[j].toString());
1464
- }
1465
- }
1466
- return newAllocations;
1467
- }
1468
-
1469
- var _marked5 = /*#__PURE__*/_regeneratorRuntime().mark(yenFromPy);
939
+ var _marked5 = /*#__PURE__*/_regeneratorRuntime().mark(yenFromPy);
1470
940
  Big.RM = 0;
1471
941
  Big.DP = 40;
1472
942
  Big.NE = -40;
@@ -4134,123 +3604,800 @@ var getPriceImpact = function getPriceImpact(_ref) {
4134
3604
  return '0';
4135
3605
  }
4136
3606
  };
4137
- var subtraction = function subtraction(initialValue, toBeSubtract) {
4138
- return math.format(math.evaluate(initialValue + " - " + toBeSubtract), {
4139
- notation: 'fixed'
4140
- });
3607
+ var subtraction = function subtraction(initialValue, toBeSubtract) {
3608
+ return math.format(math.evaluate(initialValue + " - " + toBeSubtract), {
3609
+ notation: 'fixed'
3610
+ });
3611
+ };
3612
+ function getPoolAllocationPercents(pools) {
3613
+ if (pools.length === 1) return ['100'];
3614
+ if (pools) {
3615
+ var partialAmounts = pools.map(function (pool) {
3616
+ return math.bignumber(pool.partialAmountIn);
3617
+ });
3618
+ var ps = new Array(partialAmounts.length).fill('0');
3619
+ var sum = partialAmounts.length === 1 ? partialAmounts[0] : math.sum.apply(math, partialAmounts);
3620
+ var sortedAmount = _.sortBy(partialAmounts, function (p) {
3621
+ return Number(p);
3622
+ });
3623
+ var minIndexes = [];
3624
+ for (var k = 0; k < sortedAmount.length - 1; k++) {
3625
+ var minIndex = -1;
3626
+ for (var j = 0; j < partialAmounts.length; j++) {
3627
+ if (partialAmounts[j].eq(sortedAmount[k]) && !minIndexes.includes(j)) {
3628
+ minIndex = j;
3629
+ minIndexes.push(j);
3630
+ break;
3631
+ }
3632
+ }
3633
+ var res = math.round(percent(partialAmounts[minIndex].toString(), sum)).toString();
3634
+ if (Number(res) === 0) {
3635
+ ps[minIndex] = '1';
3636
+ } else {
3637
+ ps[minIndex] = res;
3638
+ }
3639
+ }
3640
+ var finalPIndex = ps.indexOf('0');
3641
+ ps[finalPIndex] = subtraction('100', ps.length === 1 ? Number(ps[0]) : math.sum.apply(math, ps.map(function (p) {
3642
+ return Number(p);
3643
+ }))).toString();
3644
+ return ps;
3645
+ } else {
3646
+ return [];
3647
+ }
3648
+ }
3649
+ var isMobile = function isMobile() {
3650
+ return window.screen.width <= 600;
3651
+ };
3652
+ function divide(numerator, denominator) {
3653
+ return math.format(math.evaluate(numerator + " / " + denominator), {
3654
+ notation: 'fixed'
3655
+ });
3656
+ }
3657
+ var getMax = function getMax(id, amount, minNearAmountLeftForGasFees) {
3658
+ return id !== exports.WRAP_NEAR_CONTRACT_ID ? amount : Number(amount) <= minNearAmountLeftForGasFees ? '0' : String(Number(amount) - minNearAmountLeftForGasFees);
3659
+ };
3660
+ var isValidSlippageTolerance = function isValidSlippageTolerance(value) {
3661
+ return value > 0 && value < 100;
3662
+ };
3663
+ function getPointByPrice(pointDelta, price, decimalRate, noNeedSlot) {
3664
+ var point = Math.log(+price * decimalRate) / Math.log(CONSTANT_D);
3665
+ var point_int = Math.round(point);
3666
+ var point_int_slot = point_int;
3667
+ if (!noNeedSlot) {
3668
+ point_int_slot = Math.floor(point_int / pointDelta) * pointDelta;
3669
+ }
3670
+ if (point_int_slot < POINTLEFTRANGE) {
3671
+ return POINTLEFTRANGE;
3672
+ } else if (point_int_slot > POINTRIGHTRANGE) {
3673
+ return 800000;
3674
+ }
3675
+ return point_int_slot;
3676
+ }
3677
+ var feeToPointDelta = function feeToPointDelta(fee) {
3678
+ switch (fee) {
3679
+ case 100:
3680
+ return 1;
3681
+ case 400:
3682
+ return 8;
3683
+ case 2000:
3684
+ return 40;
3685
+ case 10000:
3686
+ return 200;
3687
+ default:
3688
+ throw NoFeeToPool(fee);
3689
+ }
3690
+ };
3691
+ var priceToPoint = function priceToPoint(_ref2) {
3692
+ var tokenA = _ref2.tokenA,
3693
+ tokenB = _ref2.tokenB,
3694
+ amountA = _ref2.amountA,
3695
+ amountB = _ref2.amountB,
3696
+ fee = _ref2.fee;
3697
+ if (DCL_POOL_FEE_LIST.indexOf(fee) === -1) throw NoFeeToPool(fee);
3698
+ var decimal_price_A_by_B = new Big(amountB).div(amountA);
3699
+ var undecimal_price_A_by_B = decimal_price_A_by_B.times(new Big(10).pow(tokenB.decimals)).div(new Big(10).pow(tokenA.decimals));
3700
+ var pointDelta = feeToPointDelta(fee);
3701
+ var price = decimal_price_A_by_B;
3702
+ var decimalRate = new Big(10).pow(tokenB.decimals).div(new Big(10).pow(tokenA.decimals)).toNumber();
3703
+ return getPointByPrice(pointDelta, scientificNotationToString(price.toString()), decimalRate);
3704
+ };
3705
+ var pointToPrice = function pointToPrice(_ref3) {
3706
+ var tokenA = _ref3.tokenA,
3707
+ tokenB = _ref3.tokenB,
3708
+ point = _ref3.point;
3709
+ var undecimal_price = Math.pow(CONSTANT_D, point);
3710
+ var decimal_price_A_by_B = new Big(undecimal_price).times(new Big(10).pow(tokenA.decimals)).div(new Big(10).pow(tokenB.decimals));
3711
+ return scientificNotationToString(decimal_price_A_by_B.toString());
3712
+ };
3713
+ var registerAccountOnToken = function registerAccountOnToken(AccountId) {
3714
+ return {
3715
+ methodName: 'storage_deposit',
3716
+ args: {
3717
+ registration_only: true,
3718
+ account_id: AccountId
3719
+ },
3720
+ gas: '30000000000000',
3721
+ amount: STORAGE_TO_REGISTER_WITH_MFT
3722
+ };
3723
+ };
3724
+
3725
+ var getKeyStore = function getKeyStore() {
3726
+ return typeof window === 'undefined' ? new nearApiJs.keyStores.InMemoryKeyStore() : new nearApiJs.keyStores.BrowserLocalStorageKeyStore();
3727
+ };
3728
+ var provider = /*#__PURE__*/new nearApiJs.providers.JsonRpcProvider({
3729
+ url: /*#__PURE__*/getConfig().nodeUrl
3730
+ });
3731
+ var getMemorySigner = /*#__PURE__*/function () {
3732
+ var _ref2 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(_ref) {
3733
+ var AccountId, keyPath, credentials, credentialAccountId, myKeyStore, signer;
3734
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
3735
+ while (1) {
3736
+ switch (_context.prev = _context.next) {
3737
+ case 0:
3738
+ AccountId = _ref.AccountId, keyPath = _ref.keyPath;
3739
+ _context.prev = 1;
3740
+ // const homedir = os.homedir();
3741
+ credentials = JSON.parse(fs.readFileSync(keyPath).toString());
3742
+ credentialAccountId = credentials == null ? void 0 : credentials.account_id;
3743
+ if (credentialAccountId) {
3744
+ _context.next = 6;
3745
+ break;
3746
+ }
3747
+ throw NoCredential;
3748
+ case 6:
3749
+ if (!(credentialAccountId !== AccountId)) {
3750
+ _context.next = 8;
3751
+ break;
3752
+ }
3753
+ throw AccountIdMisMatch;
3754
+ case 8:
3755
+ myKeyStore = new nearApiJs.keyStores.InMemoryKeyStore();
3756
+ myKeyStore.setKey(getConfig().networkId, AccountId, nearApiJs.KeyPair.fromString(credentials.private_key));
3757
+ signer = new nearApiJs.InMemorySigner(myKeyStore);
3758
+ return _context.abrupt("return", signer);
3759
+ case 14:
3760
+ _context.prev = 14;
3761
+ _context.t0 = _context["catch"](1);
3762
+ throw _context.t0;
3763
+ case 17:
3764
+ case "end":
3765
+ return _context.stop();
3766
+ }
3767
+ }
3768
+ }, _callee, null, [[1, 14]]);
3769
+ }));
3770
+ return function getMemorySigner(_x) {
3771
+ return _ref2.apply(this, arguments);
3772
+ };
3773
+ }();
3774
+ var validateAccessKey = function validateAccessKey(transaction, accessKey) {
3775
+ if (accessKey.permission === 'FullAccess') {
3776
+ return accessKey;
3777
+ }
3778
+ // eslint-disable-next-line @typescript-eslint/naming-convention
3779
+ var _accessKey$permission = accessKey.permission.FunctionCall,
3780
+ receiver_id = _accessKey$permission.receiver_id,
3781
+ method_names = _accessKey$permission.method_names;
3782
+ if (transaction.receiverId !== receiver_id) {
3783
+ return null;
3784
+ }
3785
+ return transaction.actions.every(function (action) {
3786
+ if (action.type !== 'FunctionCall') {
3787
+ return false;
3788
+ }
3789
+ var _action$params = action.params,
3790
+ methodName = _action$params.methodName,
3791
+ deposit = _action$params.deposit;
3792
+ if (method_names.length && method_names.includes(methodName)) {
3793
+ return false;
3794
+ }
3795
+ return parseFloat(deposit) <= 0;
3796
+ });
3797
+ };
3798
+ var getSignedTransactionsByMemoryKey = /*#__PURE__*/function () {
3799
+ var _ref4 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(_ref3) {
3800
+ var transactionsRef, AccountId, keyPath, transactions, block, signedTransactions, signer, i, transaction, publicKey, accessKey, tx, _yield$nearTransactio, signedTx;
3801
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
3802
+ while (1) {
3803
+ switch (_context2.prev = _context2.next) {
3804
+ case 0:
3805
+ transactionsRef = _ref3.transactionsRef, AccountId = _ref3.AccountId, keyPath = _ref3.keyPath;
3806
+ transactions = transformTransactions(transactionsRef, AccountId);
3807
+ _context2.next = 4;
3808
+ return provider.block({
3809
+ finality: 'final'
3810
+ });
3811
+ case 4:
3812
+ block = _context2.sent;
3813
+ signedTransactions = [];
3814
+ _context2.next = 8;
3815
+ return getMemorySigner({
3816
+ AccountId: AccountId,
3817
+ keyPath: keyPath
3818
+ });
3819
+ case 8:
3820
+ signer = _context2.sent;
3821
+ i = 0;
3822
+ case 10:
3823
+ if (!(i < transactions.length)) {
3824
+ _context2.next = 31;
3825
+ break;
3826
+ }
3827
+ transaction = transactions[i];
3828
+ _context2.next = 14;
3829
+ return signer.getPublicKey(AccountId, getConfig().networkId);
3830
+ case 14:
3831
+ publicKey = _context2.sent;
3832
+ if (publicKey) {
3833
+ _context2.next = 17;
3834
+ break;
3835
+ }
3836
+ throw NoPuiblicKeyError;
3837
+ case 17:
3838
+ _context2.next = 19;
3839
+ return provider.query({
3840
+ request_type: 'view_access_key',
3841
+ finality: 'final',
3842
+ account_id: AccountId,
3843
+ public_key: publicKey.toString()
3844
+ });
3845
+ case 19:
3846
+ accessKey = _context2.sent;
3847
+ if (validateAccessKey(transaction, accessKey)) {
3848
+ _context2.next = 22;
3849
+ break;
3850
+ }
3851
+ throw InValidAccessKeyError;
3852
+ case 22:
3853
+ tx = nearApiJs.transactions.createTransaction(AccountId, nearApiJs.utils.PublicKey.from(publicKey.toString()), transactions[i].receiverId, accessKey.nonce + i + 1, transaction.actions.map(function (action) {
3854
+ var _action$params2 = action.params,
3855
+ methodName = _action$params2.methodName,
3856
+ args = _action$params2.args,
3857
+ gas = _action$params2.gas,
3858
+ deposit = _action$params2.deposit;
3859
+ return nearApiJs.transactions.functionCall(methodName, args, new BN(gas), new BN(deposit));
3860
+ }), nearApiJs.utils.serialize.base_decode(block.header.hash));
3861
+ _context2.next = 25;
3862
+ return nearApiJs.transactions.signTransaction(tx, signer, transactions[i].signerId, getConfig().networkId);
3863
+ case 25:
3864
+ _yield$nearTransactio = _context2.sent;
3865
+ signedTx = _yield$nearTransactio[1];
3866
+ signedTransactions.push(signedTx);
3867
+ case 28:
3868
+ i += 1;
3869
+ _context2.next = 10;
3870
+ break;
3871
+ case 31:
3872
+ return _context2.abrupt("return", signedTransactions);
3873
+ case 32:
3874
+ case "end":
3875
+ return _context2.stop();
3876
+ }
3877
+ }
3878
+ }, _callee2);
3879
+ }));
3880
+ return function getSignedTransactionsByMemoryKey(_x2) {
3881
+ return _ref4.apply(this, arguments);
3882
+ };
3883
+ }();
3884
+ var sendTransactionsByMemoryKey = /*#__PURE__*/function () {
3885
+ var _ref6 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(_ref5) {
3886
+ var signedTransactions, results, i;
3887
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
3888
+ while (1) {
3889
+ switch (_context3.prev = _context3.next) {
3890
+ case 0:
3891
+ signedTransactions = _ref5.signedTransactions;
3892
+ _context3.prev = 1;
3893
+ results = [];
3894
+ i = 0;
3895
+ case 4:
3896
+ if (!(i < signedTransactions.length)) {
3897
+ _context3.next = 13;
3898
+ break;
3899
+ }
3900
+ _context3.t0 = results;
3901
+ _context3.next = 8;
3902
+ return provider.sendTransaction(signedTransactions[i]);
3903
+ case 8:
3904
+ _context3.t1 = _context3.sent;
3905
+ _context3.t0.push.call(_context3.t0, _context3.t1);
3906
+ case 10:
3907
+ i += 1;
3908
+ _context3.next = 4;
3909
+ break;
3910
+ case 13:
3911
+ return _context3.abrupt("return", results);
3912
+ case 16:
3913
+ _context3.prev = 16;
3914
+ _context3.t2 = _context3["catch"](1);
3915
+ throw _context3.t2;
3916
+ case 19:
3917
+ case "end":
3918
+ return _context3.stop();
3919
+ }
3920
+ }
3921
+ }, _callee3, null, [[1, 16]]);
3922
+ }));
3923
+ return function sendTransactionsByMemoryKey(_x3) {
3924
+ return _ref6.apply(this, arguments);
3925
+ };
3926
+ }();
3927
+
3928
+ var BANANA_ID = 'berryclub.ek.near';
3929
+ var CHEDDAR_ID = 'token.cheddar.near';
3930
+ var CUCUMBER_ID = 'farm.berryclub.ek.near';
3931
+ var HAPI_ID = 'd9c2d319cd7e6177336b0a9c93c21cb48d84fb54.factory.bridge.near';
3932
+ var WOO_ID = '4691937a7508860f876c9c0a2a617e7d9e945d4b.factory.bridge.near';
3933
+ var REPLACE_TOKENS = [BANANA_ID, CHEDDAR_ID, CUCUMBER_ID, HAPI_ID, WOO_ID];
3934
+ var near = /*#__PURE__*/new nearApiJs.Near( /*#__PURE__*/_extends({
3935
+ keyStore: /*#__PURE__*/getKeyStore(),
3936
+ headers: {}
3937
+ }, /*#__PURE__*/getConfig()));
3938
+ var init_env = function init_env(env, indexerUrl, nodeUrl) {
3939
+ near = new nearApiJs.Near(_extends({
3940
+ keyStore: getKeyStore(),
3941
+ headers: {}
3942
+ }, getConfig(env, indexerUrl, nodeUrl)));
3943
+ return switchEnv();
3944
+ };
3945
+ var refFiViewFunction = /*#__PURE__*/function () {
3946
+ var _ref2 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(_ref) {
3947
+ var methodName, args, nearConnection;
3948
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
3949
+ while (1) {
3950
+ switch (_context.prev = _context.next) {
3951
+ case 0:
3952
+ methodName = _ref.methodName, args = _ref.args;
3953
+ _context.next = 3;
3954
+ return near.account(exports.REF_FI_CONTRACT_ID);
3955
+ case 3:
3956
+ nearConnection = _context.sent;
3957
+ return _context.abrupt("return", nearConnection.viewFunction(exports.REF_FI_CONTRACT_ID, methodName, args));
3958
+ case 5:
3959
+ case "end":
3960
+ return _context.stop();
3961
+ }
3962
+ }
3963
+ }, _callee);
3964
+ }));
3965
+ return function refFiViewFunction(_x) {
3966
+ return _ref2.apply(this, arguments);
3967
+ };
3968
+ }();
3969
+ var ftViewFunction = /*#__PURE__*/function () {
3970
+ var _ref4 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(tokenId, _ref3) {
3971
+ var methodName, args, nearConnection;
3972
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
3973
+ while (1) {
3974
+ switch (_context2.prev = _context2.next) {
3975
+ case 0:
3976
+ methodName = _ref3.methodName, args = _ref3.args;
3977
+ _context2.next = 3;
3978
+ return near.account(exports.REF_FI_CONTRACT_ID);
3979
+ case 3:
3980
+ nearConnection = _context2.sent;
3981
+ return _context2.abrupt("return", nearConnection.viewFunction(tokenId, methodName, args));
3982
+ case 5:
3983
+ case "end":
3984
+ return _context2.stop();
3985
+ }
3986
+ }
3987
+ }, _callee2);
3988
+ }));
3989
+ return function ftViewFunction(_x2, _x3) {
3990
+ return _ref4.apply(this, arguments);
3991
+ };
3992
+ }();
3993
+ var ftGetStorageBalance = function ftGetStorageBalance(tokenId, AccountId) {
3994
+ if (!AccountId) throw NoAccountIdFound;
3995
+ return ftViewFunction(tokenId, {
3996
+ methodName: 'storage_balance_of',
3997
+ args: {
3998
+ account_id: AccountId
3999
+ }
4000
+ });
4001
+ };
4002
+ var ftGetBalance = /*#__PURE__*/function () {
4003
+ var _ref5 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(tokenId, AccountId) {
4004
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
4005
+ while (1) {
4006
+ switch (_context3.prev = _context3.next) {
4007
+ case 0:
4008
+ if (AccountId) {
4009
+ _context3.next = 2;
4010
+ break;
4011
+ }
4012
+ return _context3.abrupt("return", '0');
4013
+ case 2:
4014
+ if (!(tokenId === 'NEAR')) {
4015
+ _context3.next = 4;
4016
+ break;
4017
+ }
4018
+ return _context3.abrupt("return", getAccountNearBalance(AccountId)["catch"](function () {
4019
+ return '0';
4020
+ }));
4021
+ case 4:
4022
+ return _context3.abrupt("return", ftViewFunction(tokenId, {
4023
+ methodName: 'ft_balance_of',
4024
+ args: {
4025
+ account_id: AccountId
4026
+ }
4027
+ }).then(function (res) {
4028
+ return res;
4029
+ })["catch"](function () {
4030
+ return '0';
4031
+ }));
4032
+ case 5:
4033
+ case "end":
4034
+ return _context3.stop();
4035
+ }
4036
+ }
4037
+ }, _callee3);
4038
+ }));
4039
+ return function ftGetBalance(_x4, _x5) {
4040
+ return _ref5.apply(this, arguments);
4041
+ };
4042
+ }();
4043
+ var getTotalPools = /*#__PURE__*/function () {
4044
+ var _ref6 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
4045
+ return _regeneratorRuntime().wrap(function _callee4$(_context4) {
4046
+ while (1) {
4047
+ switch (_context4.prev = _context4.next) {
4048
+ case 0:
4049
+ return _context4.abrupt("return", refFiViewFunction({
4050
+ methodName: 'get_number_of_pools'
4051
+ }));
4052
+ case 1:
4053
+ case "end":
4054
+ return _context4.stop();
4055
+ }
4056
+ }
4057
+ }, _callee4);
4058
+ }));
4059
+ return function getTotalPools() {
4060
+ return _ref6.apply(this, arguments);
4061
+ };
4062
+ }();
4063
+ var ftGetTokenMetadata = /*#__PURE__*/function () {
4064
+ var _ref7 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(id, tag) {
4065
+ var metadata;
4066
+ return _regeneratorRuntime().wrap(function _callee5$(_context5) {
4067
+ while (1) {
4068
+ switch (_context5.prev = _context5.next) {
4069
+ case 0:
4070
+ if (!(id === exports.REF_TOKEN_ID)) {
4071
+ _context5.next = 2;
4072
+ break;
4073
+ }
4074
+ return _context5.abrupt("return", exports.REF_META_DATA);
4075
+ case 2:
4076
+ _context5.next = 4;
4077
+ return ftViewFunction(id, {
4078
+ methodName: 'ft_metadata'
4079
+ })["catch"](function () {
4080
+ throw TokenNotExistError(id);
4081
+ });
4082
+ case 4:
4083
+ metadata = _context5.sent;
4084
+ if (!(!metadata.icon || id === BANANA_ID || id === CHEDDAR_ID || id === CUCUMBER_ID || id === HAPI_ID || id === WOO_ID || id === exports.WRAP_NEAR_CONTRACT_ID)) {
4085
+ _context5.next = 7;
4086
+ break;
4087
+ }
4088
+ return _context5.abrupt("return", _extends({}, metadata, {
4089
+ icon: icons[id],
4090
+ id: id
4091
+ }));
4092
+ case 7:
4093
+ return _context5.abrupt("return", _extends({}, metadata, {
4094
+ id: id
4095
+ }));
4096
+ case 8:
4097
+ case "end":
4098
+ return _context5.stop();
4099
+ }
4100
+ }
4101
+ }, _callee5);
4102
+ }));
4103
+ return function ftGetTokenMetadata(_x6, _x7) {
4104
+ return _ref7.apply(this, arguments);
4105
+ };
4106
+ }();
4107
+ var ftGetTokensMetadata = /*#__PURE__*/function () {
4108
+ var _ref8 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(tokenIds, allTokens) {
4109
+ var ids, tokensMetadata;
4110
+ return _regeneratorRuntime().wrap(function _callee6$(_context6) {
4111
+ while (1) {
4112
+ switch (_context6.prev = _context6.next) {
4113
+ case 0:
4114
+ _context6.t0 = tokenIds;
4115
+ if (_context6.t0) {
4116
+ _context6.next = 5;
4117
+ break;
4118
+ }
4119
+ _context6.next = 4;
4120
+ return getGlobalWhitelist();
4121
+ case 4:
4122
+ _context6.t0 = _context6.sent;
4123
+ case 5:
4124
+ ids = _context6.t0;
4125
+ _context6.next = 8;
4126
+ return Promise.all(ids.map(function (id) {
4127
+ return (allTokens == null ? void 0 : allTokens[id]) || ftGetTokenMetadata(id)["catch"](function () {
4128
+ return null;
4129
+ });
4130
+ }));
4131
+ case 8:
4132
+ tokensMetadata = _context6.sent;
4133
+ return _context6.abrupt("return", tokensMetadata.reduce(function (pre, cur, i) {
4134
+ var _extends2;
4135
+ return _extends({}, pre, (_extends2 = {}, _extends2[ids[i]] = cur, _extends2));
4136
+ }, {}));
4137
+ case 10:
4138
+ case "end":
4139
+ return _context6.stop();
4140
+ }
4141
+ }
4142
+ }, _callee6);
4143
+ }));
4144
+ return function ftGetTokensMetadata(_x8, _x9) {
4145
+ return _ref8.apply(this, arguments);
4146
+ };
4147
+ }();
4148
+ var getGlobalWhitelist = /*#__PURE__*/function () {
4149
+ var _ref9 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
4150
+ var globalWhitelist;
4151
+ return _regeneratorRuntime().wrap(function _callee7$(_context7) {
4152
+ while (1) {
4153
+ switch (_context7.prev = _context7.next) {
4154
+ case 0:
4155
+ _context7.next = 2;
4156
+ return refFiViewFunction({
4157
+ methodName: 'get_whitelisted_tokens'
4158
+ });
4159
+ case 2:
4160
+ globalWhitelist = _context7.sent;
4161
+ return _context7.abrupt("return", Array.from(new Set(globalWhitelist)));
4162
+ case 4:
4163
+ case "end":
4164
+ return _context7.stop();
4165
+ }
4166
+ }
4167
+ }, _callee7);
4168
+ }));
4169
+ return function getGlobalWhitelist() {
4170
+ return _ref9.apply(this, arguments);
4171
+ };
4172
+ }();
4173
+ var getUserRegisteredTokens = /*#__PURE__*/function () {
4174
+ var _ref10 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(AccountId) {
4175
+ return _regeneratorRuntime().wrap(function _callee8$(_context8) {
4176
+ while (1) {
4177
+ switch (_context8.prev = _context8.next) {
4178
+ case 0:
4179
+ if (AccountId) {
4180
+ _context8.next = 2;
4181
+ break;
4182
+ }
4183
+ return _context8.abrupt("return", []);
4184
+ case 2:
4185
+ return _context8.abrupt("return", refFiViewFunction({
4186
+ methodName: 'get_user_whitelisted_tokens',
4187
+ args: {
4188
+ account_id: AccountId
4189
+ }
4190
+ }));
4191
+ case 3:
4192
+ case "end":
4193
+ return _context8.stop();
4194
+ }
4195
+ }
4196
+ }, _callee8);
4197
+ }));
4198
+ return function getUserRegisteredTokens(_x10) {
4199
+ return _ref10.apply(this, arguments);
4200
+ };
4201
+ }();
4202
+ var getAccountNearBalance = /*#__PURE__*/function () {
4203
+ var _ref11 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(accountId) {
4204
+ return _regeneratorRuntime().wrap(function _callee9$(_context9) {
4205
+ while (1) {
4206
+ switch (_context9.prev = _context9.next) {
4207
+ case 0:
4208
+ return _context9.abrupt("return", near.connection.provider.query({
4209
+ request_type: 'view_account',
4210
+ finality: 'final',
4211
+ account_id: accountId
4212
+ }).then(function (data) {
4213
+ return data.amount;
4214
+ }));
4215
+ case 1:
4216
+ case "end":
4217
+ return _context9.stop();
4218
+ }
4219
+ }
4220
+ }, _callee9);
4221
+ }));
4222
+ return function getAccountNearBalance(_x11) {
4223
+ return _ref11.apply(this, arguments);
4224
+ };
4225
+ }();
4226
+ var nearDepositTransaction = function nearDepositTransaction(amount) {
4227
+ var transaction = {
4228
+ receiverId: exports.WRAP_NEAR_CONTRACT_ID,
4229
+ functionCalls: [{
4230
+ methodName: 'near_deposit',
4231
+ args: {},
4232
+ gas: '50000000000000',
4233
+ amount: amount
4234
+ }]
4235
+ };
4236
+ return transaction;
4237
+ };
4238
+ var nearWithdrawTransaction = function nearWithdrawTransaction(amount) {
4239
+ var transaction = {
4240
+ receiverId: exports.WRAP_NEAR_CONTRACT_ID,
4241
+ functionCalls: [{
4242
+ methodName: 'near_withdraw',
4243
+ args: {
4244
+ amount: nearApiJs.utils.format.parseNearAmount(amount)
4245
+ },
4246
+ amount: ONE_YOCTO_NEAR
4247
+ }]
4248
+ };
4249
+ return transaction;
4141
4250
  };
4142
- function getPoolAllocationPercents(pools) {
4143
- if (pools.length === 1) return ['100'];
4144
- if (pools) {
4145
- var partialAmounts = pools.map(function (pool) {
4146
- return math.bignumber(pool.partialAmountIn);
4147
- });
4148
- var ps = new Array(partialAmounts.length).fill('0');
4149
- var sum = partialAmounts.length === 1 ? partialAmounts[0] : math.sum.apply(math, partialAmounts);
4150
- var sortedAmount = _.sortBy(partialAmounts, function (p) {
4151
- return Number(p);
4152
- });
4153
- var minIndexes = [];
4154
- for (var k = 0; k < sortedAmount.length - 1; k++) {
4155
- var minIndex = -1;
4156
- for (var j = 0; j < partialAmounts.length; j++) {
4157
- if (partialAmounts[j].eq(sortedAmount[k]) && !minIndexes.includes(j)) {
4158
- minIndex = j;
4159
- minIndexes.push(j);
4160
- break;
4251
+ var refDCLSwapViewFunction = /*#__PURE__*/function () {
4252
+ var _ref13 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(_ref12) {
4253
+ var methodName, args, nearConnection;
4254
+ return _regeneratorRuntime().wrap(function _callee10$(_context10) {
4255
+ while (1) {
4256
+ switch (_context10.prev = _context10.next) {
4257
+ case 0:
4258
+ methodName = _ref12.methodName, args = _ref12.args;
4259
+ _context10.next = 3;
4260
+ return near.account(exports.REF_FI_CONTRACT_ID);
4261
+ case 3:
4262
+ nearConnection = _context10.sent;
4263
+ if (exports.config.REF_DCL_SWAP_CONTRACT_ID) {
4264
+ _context10.next = 6;
4265
+ break;
4266
+ }
4267
+ throw DCLInValid;
4268
+ case 6:
4269
+ return _context10.abrupt("return", nearConnection.viewFunction(exports.config.REF_DCL_SWAP_CONTRACT_ID, methodName, args));
4270
+ case 7:
4271
+ case "end":
4272
+ return _context10.stop();
4161
4273
  }
4162
4274
  }
4163
- var res = math.round(percent(partialAmounts[minIndex].toString(), sum)).toString();
4164
- if (Number(res) === 0) {
4165
- ps[minIndex] = '1';
4166
- } else {
4167
- ps[minIndex] = res;
4168
- }
4275
+ }, _callee10);
4276
+ }));
4277
+ return function refDCLSwapViewFunction(_x12) {
4278
+ return _ref13.apply(this, arguments);
4279
+ };
4280
+ }();
4281
+ var DCLSwapGetStorageBalance = function DCLSwapGetStorageBalance(tokenId, AccountId) {
4282
+ return refDCLSwapViewFunction({
4283
+ methodName: 'storage_balance_of',
4284
+ args: {
4285
+ account_id: AccountId
4169
4286
  }
4170
- var finalPIndex = ps.indexOf('0');
4171
- ps[finalPIndex] = subtraction('100', ps.length === 1 ? Number(ps[0]) : math.sum.apply(math, ps.map(function (p) {
4172
- return Number(p);
4173
- }))).toString();
4174
- return ps;
4175
- } else {
4176
- return [];
4177
- }
4178
- }
4179
- var isMobile = function isMobile() {
4180
- return window.screen.width <= 600;
4287
+ });
4181
4288
  };
4182
- function divide(numerator, denominator) {
4183
- return math.format(math.evaluate(numerator + " / " + denominator), {
4184
- notation: 'fixed'
4289
+ var getMinStorageBalance = /*#__PURE__*/function () {
4290
+ var _ref14 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(nep141Address) {
4291
+ var result, balance;
4292
+ return _regeneratorRuntime().wrap(function _callee11$(_context11) {
4293
+ while (1) {
4294
+ switch (_context11.prev = _context11.next) {
4295
+ case 0:
4296
+ _context11.prev = 0;
4297
+ _context11.next = 3;
4298
+ return near.connection.provider.query({
4299
+ request_type: 'call_function',
4300
+ account_id: nep141Address,
4301
+ method_name: 'storage_balance_bounds',
4302
+ args_base64: '',
4303
+ finality: 'optimistic'
4304
+ });
4305
+ case 3:
4306
+ result = _context11.sent;
4307
+ balance = JSON.parse(Buffer.from(result.result).toString());
4308
+ if (!(!balance || !balance.min)) {
4309
+ _context11.next = 7;
4310
+ break;
4311
+ }
4312
+ return _context11.abrupt("return", FT_MINIMUM_STORAGE_BALANCE_LARGE);
4313
+ case 7:
4314
+ return _context11.abrupt("return", balance.min);
4315
+ case 10:
4316
+ _context11.prev = 10;
4317
+ _context11.t0 = _context11["catch"](0);
4318
+ console.error(_context11.t0, nep141Address);
4319
+ return _context11.abrupt("return", FT_MINIMUM_STORAGE_BALANCE_LARGE);
4320
+ case 14:
4321
+ case "end":
4322
+ return _context11.stop();
4323
+ }
4324
+ }
4325
+ }, _callee11, null, [[0, 10]]);
4326
+ }));
4327
+ return function getMinStorageBalance(_x13) {
4328
+ return _ref14.apply(this, arguments);
4329
+ };
4330
+ }();
4331
+
4332
+ var DCL_POOL_FEE_LIST = [100, 400, 2000, 10000];
4333
+ var getDCLPoolId = function getDCLPoolId(tokenA, tokenB, fee) {
4334
+ if (DCL_POOL_FEE_LIST.indexOf(fee) === -1) throw NoFeeToPool(fee);
4335
+ var tokenSeq = [tokenA, tokenB].sort().join('|');
4336
+ return tokenSeq + "|" + fee;
4337
+ };
4338
+ var listDCLPools = function listDCLPools() {
4339
+ return refDCLSwapViewFunction({
4340
+ methodName: 'list_pools'
4185
4341
  });
4186
- }
4187
- var getMax = function getMax(id, amount, minNearAmountLeftForGasFees) {
4188
- return id !== exports.WRAP_NEAR_CONTRACT_ID ? amount : Number(amount) <= minNearAmountLeftForGasFees ? '0' : String(Number(amount) - minNearAmountLeftForGasFees);
4189
4342
  };
4190
- var isValidSlippageTolerance = function isValidSlippageTolerance(value) {
4191
- return value > 0 && value < 100;
4343
+ var getDCLPool = /*#__PURE__*/function () {
4344
+ var _ref = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(pool_id) {
4345
+ var _pool_id$split, token_x, token_y, fee, token_seq, new_pool_id;
4346
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
4347
+ while (1) {
4348
+ switch (_context.prev = _context.next) {
4349
+ case 0:
4350
+ _pool_id$split = pool_id.split('|'), token_x = _pool_id$split[0], token_y = _pool_id$split[1], fee = _pool_id$split[2];
4351
+ token_seq = [token_x, token_y].sort().join('|');
4352
+ new_pool_id = token_seq + "|" + fee;
4353
+ return _context.abrupt("return", refDCLSwapViewFunction({
4354
+ methodName: 'get_pool',
4355
+ args: {
4356
+ pool_id: new_pool_id
4357
+ }
4358
+ }));
4359
+ case 4:
4360
+ case "end":
4361
+ return _context.stop();
4362
+ }
4363
+ }
4364
+ }, _callee);
4365
+ }));
4366
+ return function getDCLPool(_x) {
4367
+ return _ref.apply(this, arguments);
4368
+ };
4369
+ }();
4370
+
4371
+ var formatError = function formatError(msg) {
4372
+ return new Error(msg);
4192
4373
  };
4193
- function getPointByPrice(pointDelta, price, decimalRate, noNeedSlot) {
4194
- var point = Math.log(+price * decimalRate) / Math.log(CONSTANT_D);
4195
- var point_int = Math.round(point);
4196
- var point_int_slot = point_int;
4197
- if (!noNeedSlot) {
4198
- point_int_slot = Math.floor(point_int / pointDelta) * pointDelta;
4199
- }
4200
- if (point_int_slot < POINTLEFTRANGE) {
4201
- return POINTLEFTRANGE;
4202
- } else if (point_int_slot > POINTRIGHTRANGE) {
4203
- return 800000;
4204
- }
4205
- return point_int_slot;
4206
- }
4207
- var feeToPointDelta = function feeToPointDelta(fee) {
4208
- switch (fee) {
4209
- case 100:
4210
- return 1;
4211
- case 400:
4212
- return 8;
4213
- case 2000:
4214
- return 40;
4215
- case 10000:
4216
- return 200;
4217
- default:
4218
- throw NoFeeToPool(fee);
4219
- }
4374
+ var unNamedError = /*#__PURE__*/formatError('Something wrong happened');
4375
+ var SameInputTokenError = /*#__PURE__*/formatError('Input token should be different with output token');
4376
+ var ZeroInputError = /*#__PURE__*/formatError('Input amount should be greater than 0');
4377
+ var NoPoolError = /*#__PURE__*/formatError('No pool found for the input tokens');
4378
+ var NotLoginError = /*#__PURE__*/formatError('Please login in first');
4379
+ var SwapRouteError = /*#__PURE__*/formatError("Something wrong happened, we don't get correct routes corrreponding to current input");
4380
+ var TokenNotExistError = function TokenNotExistError(id) {
4381
+ return formatError(id + " doesn't exist in " + getConfig().networkId);
4220
4382
  };
4221
- var priceToPoint = function priceToPoint(_ref2) {
4222
- var tokenA = _ref2.tokenA,
4223
- tokenB = _ref2.tokenB,
4224
- amountA = _ref2.amountA,
4225
- amountB = _ref2.amountB,
4226
- fee = _ref2.fee;
4227
- if (DCL_POOL_FEE_LIST.indexOf(fee) === -1) throw NoFeeToPool(fee);
4228
- var decimal_price_A_by_B = new Big(amountB).div(amountA);
4229
- var undecimal_price_A_by_B = decimal_price_A_by_B.times(new Big(10).pow(tokenB.decimals)).div(new Big(10).pow(tokenA.decimals));
4230
- var pointDelta = feeToPointDelta(fee);
4231
- var price = decimal_price_A_by_B;
4232
- var decimalRate = new Big(10).pow(tokenB.decimals).div(new Big(10).pow(tokenA.decimals)).toNumber();
4233
- return getPointByPrice(pointDelta, scientificNotationToString(price.toString()), decimalRate);
4383
+ var NoPuiblicKeyError = /*#__PURE__*/formatError('No public key found');
4384
+ var NoLocalSignerError = /*#__PURE__*/formatError('No local signer found');
4385
+ var InValidAccessKeyError = /*#__PURE__*/formatError('Invalid access key');
4386
+ var AccountIdMisMatch = /*#__PURE__*/formatError("Your input account id doesn't match the account id in the credential");
4387
+ var NoCredential = /*#__PURE__*/formatError('No Credential to such path');
4388
+ var NoAccountIdFound = /*#__PURE__*/formatError('No account id found');
4389
+ var NoFeeToPool = function NoFeeToPool(fee) {
4390
+ return formatError("InValid fee " + fee + " to DCL pool, the valid fee should be one of " + DCL_POOL_FEE_LIST);
4234
4391
  };
4235
- var pointToPrice = function pointToPrice(_ref3) {
4236
- var tokenA = _ref3.tokenA,
4237
- tokenB = _ref3.tokenB,
4238
- point = _ref3.point;
4239
- var undecimal_price = Math.pow(CONSTANT_D, point);
4240
- var decimal_price_A_by_B = new Big(undecimal_price).times(new Big(10).pow(tokenA.decimals)).div(new Big(10).pow(tokenB.decimals));
4241
- return scientificNotationToString(decimal_price_A_by_B.toString());
4392
+ var DCLInValid = /*#__PURE__*/formatError("DCL contract currently in Valid on " + exports.config.networkId);
4393
+ var NoPoolOnThisPair = function NoPoolOnThisPair(tokenA, tokenB) {
4394
+ return formatError("No pools on pair " + tokenA + " <> " + tokenB);
4242
4395
  };
4243
- var registerAccountOnToken = function registerAccountOnToken(AccountId) {
4244
- return {
4245
- methodName: 'storage_deposit',
4246
- args: {
4247
- registration_only: true,
4248
- account_id: AccountId
4249
- },
4250
- gas: '30000000000000',
4251
- amount: STORAGE_TO_REGISTER_WITH_MFT
4252
- };
4396
+ var SlippageError = /*#__PURE__*/formatError('slippage tolerance should be in range (0, 100)');
4397
+ var NoOrderFound = function NoOrderFound(order_id) {
4398
+ return formatError("No order " + (order_id || '') + " found");
4253
4399
  };
4400
+ var OrderNoRemainedAmount = /*#__PURE__*/formatError('No remained amount on this order');
4254
4401
 
4255
4402
  var instantSwap = /*#__PURE__*/function () {
4256
4403
  var _ref2 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(_ref) {
@@ -8251,6 +8398,7 @@ exports.getGlobalWhitelist = getGlobalWhitelist;
8251
8398
  exports.getHybridStableSmart = getHybridStableSmart;
8252
8399
  exports.getKeyStore = getKeyStore;
8253
8400
  exports.getMax = getMax;
8401
+ exports.getMemorySigner = getMemorySigner;
8254
8402
  exports.getMinStorageBalance = getMinStorageBalance;
8255
8403
  exports.getPointByPrice = getPointByPrice;
8256
8404
  exports.getPool = getPool;
@@ -8261,6 +8409,7 @@ exports.getPoolsByTokens = getPoolsByTokens;
8261
8409
  exports.getPriceImpact = getPriceImpact;
8262
8410
  exports.getRatedPoolDetail = getRatedPoolDetail;
8263
8411
  exports.getRefPools = getRefPools;
8412
+ exports.getSignedTransactionsByMemoryKey = getSignedTransactionsByMemoryKey;
8264
8413
  exports.getSimplePoolEstimate = getSimplePoolEstimate;
8265
8414
  exports.getStablePoolDecimal = getStablePoolDecimal;
8266
8415
  exports.getStablePoolEstimate = getStablePoolEstimate;