@ref-finance/ref-sdk 1.4.7 → 1.4.8

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