@ref-finance/ref-sdk 1.4.1 → 1.4.3
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.
- package/README.md +6 -3
- package/dist/constant.d.ts +1 -0
- package/dist/ref-sdk.cjs.development.css +2 -2
- package/dist/ref-sdk.cjs.development.js +161 -163
- package/dist/ref-sdk.cjs.development.js.map +1 -1
- package/dist/ref-sdk.cjs.production.min.js +1 -1
- package/dist/ref-sdk.cjs.production.min.js.map +1 -1
- package/dist/ref-sdk.esm.js +162 -166
- package/dist/ref-sdk.esm.js.map +1 -1
- package/dist/ref-sdk.umd.development.js +162 -164
- package/dist/ref-sdk.umd.development.js.map +1 -1
- package/dist/ref-sdk.umd.production.min.js +1 -1
- package/dist/ref-sdk.umd.production.min.js.map +1 -1
- package/dist/swap-widget/components.d.ts +10 -11
- package/dist/swap-widget/types.d.ts +5 -3
- package/dist/utils.d.ts +2 -1
- package/package.json +1 -1
package/dist/ref-sdk.esm.js
CHANGED
|
@@ -5,7 +5,7 @@ import _, { sortBy } from 'lodash-es';
|
|
|
5
5
|
import * as math from 'mathjs';
|
|
6
6
|
import { divide as divide$1, evaluate, format, floor, bignumber, sum, round as round$1 } from 'mathjs';
|
|
7
7
|
import Big from 'big.js';
|
|
8
|
-
import { formatNearAmount } from 'near-api-js/lib/utils/format';
|
|
8
|
+
import { formatNearAmount, parseNearAmount } from 'near-api-js/lib/utils/format';
|
|
9
9
|
import React, { useState, useEffect, useMemo, useCallback, createContext, useContext, useRef } from 'react';
|
|
10
10
|
import { FiChevronDown } from '@react-icons/all-files/fi/FiChevronDown';
|
|
11
11
|
import { FiChevronLeft } from '@react-icons/all-files/fi/FiChevronLeft';
|
|
@@ -24,6 +24,7 @@ import { TiWarning } from '@react-icons/all-files/ti/TiWarning';
|
|
|
24
24
|
import { CgArrowsExchangeAltV } from '@react-icons/all-files/cg/CgArrowsExchangeAltV';
|
|
25
25
|
|
|
26
26
|
var FEE_DIVISOR = 10000;
|
|
27
|
+
var DEFAULT_SLIPPAGE_TOLERANCE = "0.5";
|
|
27
28
|
var STABLE_LP_TOKEN_DECIMALS = 18;
|
|
28
29
|
var RATED_POOL_LP_TOKEN_DECIMALS = 24;
|
|
29
30
|
var STORAGE_TO_REGISTER_WITH_MFT = '0.1';
|
|
@@ -3642,8 +3643,11 @@ function divide(numerator, denominator) {
|
|
|
3642
3643
|
notation: 'fixed'
|
|
3643
3644
|
});
|
|
3644
3645
|
}
|
|
3645
|
-
var getMax = function getMax(id, amount) {
|
|
3646
|
-
return id !== WRAP_NEAR_CONTRACT_ID ? amount : Number(amount) <=
|
|
3646
|
+
var getMax = function getMax(id, amount, minNearAmountLeftForGasFees) {
|
|
3647
|
+
return id !== WRAP_NEAR_CONTRACT_ID ? amount : Number(amount) <= minNearAmountLeftForGasFees ? '0' : String(Number(amount) - minNearAmountLeftForGasFees);
|
|
3648
|
+
};
|
|
3649
|
+
var isValidSlippageTolerance = function isValidSlippageTolerance(value) {
|
|
3650
|
+
return value > 0 && value < 100;
|
|
3647
3651
|
};
|
|
3648
3652
|
function getPointByPrice(pointDelta, price, decimalRate, noNeedSlot) {
|
|
3649
3653
|
var point = Math.log(+price * decimalRate) / Math.log(CONSTANT_D);
|
|
@@ -4394,7 +4398,7 @@ var OrderNoRemainedAmount = /*#__PURE__*/formatError('No remained amount on this
|
|
|
4394
4398
|
var instantSwap = /*#__PURE__*/function () {
|
|
4395
4399
|
var _ref2 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(_ref) {
|
|
4396
4400
|
var _swapTodos;
|
|
4397
|
-
var tokenIn, tokenOut, amountIn, slippageTolerance, swapTodos, AccountId, referralId, transactions, registerToken,
|
|
4401
|
+
var tokenIn, tokenOut, amountIn, slippageTolerance, swapTodos, AccountId, referralId, transactions, registerToken, actionsList, allSwapsTokens, i, swapTokens;
|
|
4398
4402
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
4399
4403
|
while (1) {
|
|
4400
4404
|
switch (_context2.prev = _context2.next) {
|
|
@@ -4459,24 +4463,9 @@ var instantSwap = /*#__PURE__*/function () {
|
|
|
4459
4463
|
return _ref3.apply(this, arguments);
|
|
4460
4464
|
};
|
|
4461
4465
|
}();
|
|
4462
|
-
|
|
4463
|
-
_context2.next = 12;
|
|
4464
|
-
break;
|
|
4465
|
-
}
|
|
4466
|
-
_context2.next = 8;
|
|
4467
|
-
return ftGetStorageBalance(config.WRAP_NEAR_CONTRACT_ID, AccountId);
|
|
4468
|
-
case 8:
|
|
4469
|
-
registered = _context2.sent;
|
|
4470
|
-
if (!(registered === null)) {
|
|
4471
|
-
_context2.next = 12;
|
|
4472
|
-
break;
|
|
4473
|
-
}
|
|
4474
|
-
_context2.next = 12;
|
|
4475
|
-
return registerToken(tokenIn);
|
|
4476
|
-
case 12:
|
|
4477
|
-
_context2.next = 14;
|
|
4466
|
+
_context2.next = 7;
|
|
4478
4467
|
return registerToken(tokenOut);
|
|
4479
|
-
case
|
|
4468
|
+
case 7:
|
|
4480
4469
|
actionsList = [];
|
|
4481
4470
|
allSwapsTokens = swapTodos.map(function (s) {
|
|
4482
4471
|
return [s.inputToken, s.outputToken];
|
|
@@ -4534,7 +4523,7 @@ var instantSwap = /*#__PURE__*/function () {
|
|
|
4534
4523
|
}]
|
|
4535
4524
|
});
|
|
4536
4525
|
return _context2.abrupt("return", transactions);
|
|
4537
|
-
case
|
|
4526
|
+
case 12:
|
|
4538
4527
|
case "end":
|
|
4539
4528
|
return _context2.stop();
|
|
4540
4529
|
}
|
|
@@ -4750,7 +4739,7 @@ var fetchAllPools = /*#__PURE__*/function () {
|
|
|
4750
4739
|
});
|
|
4751
4740
|
case 3:
|
|
4752
4741
|
_pools = _context7.sent;
|
|
4753
|
-
if (
|
|
4742
|
+
if (_pools.simplePools) {
|
|
4754
4743
|
_context7.next = 6;
|
|
4755
4744
|
break;
|
|
4756
4745
|
}
|
|
@@ -5012,12 +5001,12 @@ var useSwap = function useSwap(params) {
|
|
|
5012
5001
|
var rate = calculateExchangeRate(ONLY_ZEROS.test(params.amountIn) ? '1' : params.amountIn, amountOut || '1');
|
|
5013
5002
|
var makeSwap = /*#__PURE__*/function () {
|
|
5014
5003
|
var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
|
|
5015
|
-
var transactionsRef, outEstimate, routes, bigEstimate, _minAmountOut;
|
|
5004
|
+
var transactionsRef, tokenRegistered, nearDepositAmount, minStorageBalance, outEstimate, routes, bigEstimate, _minAmountOut;
|
|
5016
5005
|
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
5017
5006
|
while (1) {
|
|
5018
5007
|
switch (_context3.prev = _context3.next) {
|
|
5019
5008
|
case 0:
|
|
5020
|
-
if (!(!params.tokenIn || !params.tokenOut)) {
|
|
5009
|
+
if (!(!params.tokenIn || !params.tokenOut || !AccountId)) {
|
|
5021
5010
|
_context3.next = 2;
|
|
5022
5011
|
break;
|
|
5023
5012
|
}
|
|
@@ -5030,14 +5019,32 @@ var useSwap = function useSwap(params) {
|
|
|
5030
5019
|
amountIn: params.amountIn,
|
|
5031
5020
|
swapTodos: estimates,
|
|
5032
5021
|
slippageTolerance: slippageTolerance,
|
|
5033
|
-
AccountId: AccountId
|
|
5022
|
+
AccountId: AccountId,
|
|
5034
5023
|
referralId: referralId
|
|
5035
5024
|
});
|
|
5036
5025
|
case 4:
|
|
5037
5026
|
transactionsRef = _context3.sent;
|
|
5038
|
-
if (tokenIn && tokenIn.id === WRAP_NEAR_CONTRACT_ID) {
|
|
5039
|
-
|
|
5027
|
+
if (!(tokenIn && tokenIn.id === WRAP_NEAR_CONTRACT_ID)) {
|
|
5028
|
+
_context3.next = 16;
|
|
5029
|
+
break;
|
|
5040
5030
|
}
|
|
5031
|
+
_context3.next = 8;
|
|
5032
|
+
return ftGetStorageBalance(tokenIn.id, AccountId);
|
|
5033
|
+
case 8:
|
|
5034
|
+
tokenRegistered = _context3.sent;
|
|
5035
|
+
nearDepositAmount = amountIn;
|
|
5036
|
+
if (!(tokenRegistered === null)) {
|
|
5037
|
+
_context3.next = 15;
|
|
5038
|
+
break;
|
|
5039
|
+
}
|
|
5040
|
+
_context3.next = 13;
|
|
5041
|
+
return getMinStorageBalance(tokenIn.id);
|
|
5042
|
+
case 13:
|
|
5043
|
+
minStorageBalance = _context3.sent;
|
|
5044
|
+
nearDepositAmount = formatNearAmount(String(BigInt(parseNearAmount(nearDepositAmount)) + BigInt(minStorageBalance)));
|
|
5045
|
+
case 15:
|
|
5046
|
+
transactionsRef.splice(-1, 0, nearDepositTransaction(nearDepositAmount));
|
|
5047
|
+
case 16:
|
|
5041
5048
|
if (tokenOut && tokenOut.id === WRAP_NEAR_CONTRACT_ID) {
|
|
5042
5049
|
outEstimate = new Big(0);
|
|
5043
5050
|
routes = separateRoutes(estimates, tokenOut.id);
|
|
@@ -5048,16 +5055,16 @@ var useSwap = function useSwap(params) {
|
|
|
5048
5055
|
_minAmountOut = percentLess(slippageTolerance, scientificNotationToString(bigEstimate.toString()));
|
|
5049
5056
|
transactionsRef.push(nearWithdrawTransaction(_minAmountOut));
|
|
5050
5057
|
}
|
|
5051
|
-
_context3.next =
|
|
5058
|
+
_context3.next = 19;
|
|
5052
5059
|
return onSwap(transactionsRef);
|
|
5053
|
-
case
|
|
5060
|
+
case 19:
|
|
5054
5061
|
setTimeout(function () {
|
|
5055
5062
|
var tokensToUpdate = [];
|
|
5056
5063
|
if (tokenIn) tokensToUpdate.push(tokenIn.id);
|
|
5057
5064
|
if (tokenOut) tokensToUpdate.push(tokenOut.id);
|
|
5058
5065
|
if (tokensToUpdate.length > 0 && AccountId) updateTokenBalance(tokensToUpdate, AccountId);
|
|
5059
5066
|
}, 3000);
|
|
5060
|
-
case
|
|
5067
|
+
case 20:
|
|
5061
5068
|
case "end":
|
|
5062
5069
|
return _context3.stop();
|
|
5063
5070
|
}
|
|
@@ -5280,7 +5287,7 @@ function styleInject(css, ref) {
|
|
|
5280
5287
|
}
|
|
5281
5288
|
}
|
|
5282
5289
|
|
|
5283
|
-
var css_248z = ".__ref-swap-widget-container {\n border-radius: 16px;\n padding: 28px;\n padding-bottom: 16px;\n position: relative;\n max-width: 90%;\n}\n\n.__ref-swap-widget-row-flex-center {\n display: flex;\n align-items: center;\n}\n\n.__ref-swap-widget-col-flex-start {\n display: flex;\n flex-direction: column;\n align-items: flex-start;\n}\n\n.__ref-swap-widget-header {\n justify-content: space-between;\n margin-bottom: 25px;\n}\n\n.__ref-swap-widget-header-title {\n font-weight: 700;\n font-size: 20px;\n}\n.__ref-swap-widget-header-button-account {\n font-size: 14px;\n margin-right: 8px;\n padding: 4px 13px;\n border-radius: 25px;\n min-width: 120px;\n justify-content: center;\n}\n\n.__ref-swap-widget-header-button-account:hover {\n background: rgba(255, 104, 158, 0.2) !important;\n}\n\n.__ref-swap-widget_slippage_selector {\n box-shadow: 0px 0px 12px rgba(0, 0, 0, 0.25);\n border-radius: 12px;\n position: absolute;\n top: 30px;\n right: 0px;\n padding: 16px;\n padding-right: 20px;\n padding-left: 20px;\n z-index:
|
|
5290
|
+
var css_248z = ".__ref-swap-widget-container {\n border-radius: 16px;\n padding: 28px;\n padding-bottom: 16px;\n position: relative;\n max-width: 90%;\n}\n\n.__ref-swap-widget-row-flex-center {\n display: flex;\n align-items: center;\n}\n\n.__ref-swap-widget-col-flex-start {\n display: flex;\n flex-direction: column;\n align-items: flex-start;\n}\n\n.__ref-swap-widget-header {\n justify-content: space-between;\n margin-bottom: 25px;\n}\n\n.__ref-swap-widget-header-title {\n font-weight: 700;\n font-size: 20px;\n}\n.__ref-swap-widget-header-button-account {\n font-size: 14px;\n margin-right: 8px;\n padding: 4px 13px;\n border-radius: 25px;\n min-width: 120px;\n justify-content: center;\n}\n\n.__ref-swap-widget-header-button-account:hover {\n background: rgba(255, 104, 158, 0.2) !important;\n}\n\n.__ref-swap-widget_slippage_selector {\n box-shadow: 0px 0px 12px rgba(0, 0, 0, 0.25);\n border-radius: 12px;\n position: absolute;\n top: 30px;\n right: 0px;\n padding: 16px;\n padding-right: 20px;\n padding-left: 20px;\n z-index: 5;\n width: 230px;\n font-size: 14px;\n}\n\n.__ref-swap-widget_slippage_selector_input_container {\n width: 100%;\n height: 26px;\n margin-right: 4px;\n padding: 2px 10px;\n}\n.__ref-swap-widget_slippage_selector_button {\n font-size: 14px;\n display: flex;\n align-items: center;\n justify-content: center;\n padding: 6px 16px;\n}\n\n.__ref-swap-widget-opacity-hover:hover {\n opacity: 0.5;\n}\n\n.__ref-swap-widget-opacity-active:active {\n opacity: 0.5;\n}\n\n.__ref-swap-widger-token-amount {\n padding: 14px;\n padding-bottom: 8px;\n border-radius: 8px;\n display: flex;\n align-items: flex-start;\n}\n\n.__ref-swap-widger-token-amount_input {\n width: 100%;\n display: flex;\n flex-direction: column;\n align-items: flex-end;\n}\n\n.__ref-swap-widget-token-amount_quick_selector {\n}\n\n.__ref-swap-widger-token-amount_balance {\n margin-top: 7px;\n justify-content: space-between;\n}\n\n.__ref-swap-widget-token-amount_quick_selector_item {\n font-size: 12px;\n padding: 6px;\n padding-top: 3px;\n padding-bottom: 3px;\n cursor: pointer;\n}\n.__ref-swap-widget-select-token_input {\n padding: 14px;\n border-radius: 8px;\n}\n\n.__ref-swap-widget_star_token {\n padding: 8px 10px 8px 8px;\n margin: 0px 6px 10px 0px;\n position: relative;\n cursor: pointer;\n border-radius: 8px;\n}\n\n.__ref-swap-widget_token_icon {\n border-radius: 100%;\n flex-shrink: 0;\n}\n\n.__ref-swap-widget_token_list_table {\n table-layout: auto;\n width: 100%;\n font-size: 14px;\n}\n\n.__ref-swap-widget_token_list_table_header {\n display: flex;\n align-items: center;\n justify-content: space-between;\n padding: 6px 12px;\n margin: 0px 6px;\n}\n\n.__ref-swap-widget_token-selector-star-tokens {\n margin-top: 20px;\n flex-wrap: wrap;\n}\n.__ref-swap-widget_token_list_table_content {\n display: flex;\n flex-direction: column;\n max-height: 50vh;\n min-height: 30vh;\n overflow-y: auto;\n}\n\n.__ref-swap-widget_token-selector-token-list-item {\n justify-content: space-between;\n padding: 9px 20px;\n}\n.__ref-swap-widget-token-amount_token-select-button {\n font-size: 16px;\n border-radius: 18px;\n padding: 6px 8px;\n cursor: pointer;\n}\n\n.__ref-swap-widget-exchange-button {\n width: 100%;\n justify-content: center;\n padding: 20px 0;\n}\n\n.__ref-swap-widget-submit-button {\n width: 100%;\n display: flex;\n align-items: center;\n justify-content: center;\n font-size: 18px;\n font-weight: 700;\n border-radius: 8px;\n padding: 14px 0 14px 0;\n margin-top: 14px;\n cursor: pointer;\n}\n\n.__ref-swap-widget-submit-button-loader {\n width: 20px;\n height: 20px;\n border: 2px solid #fff;\n border-bottom-color: rgb(255, 255, 255);\n border-bottom-color: transparent;\n border-radius: 50%;\n display: inline-block;\n box-sizing: border-box;\n animation: rotation 1s linear infinite;\n}\n\n@keyframes rotation {\n 0% {\n transform: rotate(0deg);\n }\n 100% {\n transform: rotate(360deg);\n }\n}\n\n.__ref-widget-swap-detail-view {\n justify-content: space-between;\n width: 100%;\n font-size: 14px;\n margin-top: 16px;\n}\n\n.__ref-swap-widget-swap-detail-view-item {\n justify-content: space-between;\n margin-bottom: 12px;\n width: 100%;\n}\n\n.__ref-swap-widget-loading {\n animation: spin 2s linear infinite;\n}\n\n.__ref-swap-widget-notification {\n position: absolute;\n top: 50%;\n left: 50%;\n width: 50%;\n transform: translate(-50%, -50%);\n background: rgba(0, 0, 0, 0.5);\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n z-index: 5;\n box-shadow: 0px 0px 12px rgba(0, 0, 0, 0.25);\n border-radius: 12px;\n padding: 32px 20px;\n}\n\n.__ref-swap-widget-notification__button {\n border-radius: 8px;\n padding: 8px 20px;\n margin-top: 14px;\n}\n@keyframes spin {\n from {\n transform: rotate(0deg);\n }\n to {\n transform: rotate(360deg);\n }\n}\n\ninput.__ref-swap-widget-input-class {\n margin: 0;\n background-color: transparent;\n display: block;\n width: 100%;\n padding: 0;\n border-width: 0;\n}\n\ninput.__ref-swap-widget-input-class:focus {\n outline: none;\n border-width: 0;\n}\n\ninput.__ref-swap-widget-input-class::-webkit-outer-spin-button,\ninput.__ref-swap-widget-input-class::-webkit-inner-spin-button {\n -webkit-appearance: none;\n margin: 0;\n}\n\ninput.__ref-swap-widget-input-class[type='number'] {\n -moz-appearance: textfield; /* Firefox */\n}\n\nbutton.__ref-swap-widget-button {\n border: none;\n}\n\n.__ref-swap-widget-submit-button:hover {\n opacity: 0.5;\n}\n\n.__ref-swap-widget-active:active {\n color: #00c6a2;\n}\n\n.__ref-swap-widget-hover:hover {\n color: #00c6a2;\n}\n\n.__ref-swap-widget_token_list_table_content::-webkit-scrollbar {\n width: 4px;\n height: 4px;\n border-radius: 3px;\n}\n\n.__ref-swap-widget_token_list_table_content::-webkit-scrollbar-track {\n box-shadow: inset 0 0 6px rgba(0, 0, 0, 0);\n}\n.__ref-swap-widget_token_list_table_content::-webkit-scrollbar-thumb {\n background: #00c6a2;\n border-radius: 8px;\n}\n\n.__ref-swap-widget-swap_routes {\n border-radius: 12px;\n padding: 8px 12px 8px 12px;\n width: 100%;\n}\n\n.__ref-swap-widget-valueStyle {\n background-image: -webkit-linear-gradient(left, #00ffd1, #00ffd1, #8c78ff);\n -webkit-background-clip: text;\n -webkit-text-fill-color: transparent;\n}\n\n.__ref-swap-widget-swap_route_row {\n justify-content: space-between;\n margin-bottom: 4px;\n}\n";
|
|
5284
5291
|
styleInject(css_248z);
|
|
5285
5292
|
|
|
5286
5293
|
var _ALLOWED_KEYS;
|
|
@@ -5631,7 +5638,8 @@ var TokenAmount = function TokenAmount(props) {
|
|
|
5631
5638
|
onChangeAmount = props.onChangeAmount,
|
|
5632
5639
|
price = props.price,
|
|
5633
5640
|
onForceUpdate = props.onForceUpdate,
|
|
5634
|
-
poolFetchingState = props.poolFetchingState
|
|
5641
|
+
poolFetchingState = props.poolFetchingState,
|
|
5642
|
+
minNearAmountLeftForGasFees = props.minNearAmountLeftForGasFees;
|
|
5635
5643
|
var theme = useContext(ThemeContext);
|
|
5636
5644
|
var primary = theme.primary,
|
|
5637
5645
|
secondary = theme.secondary,
|
|
@@ -5651,14 +5659,14 @@ var TokenAmount = function TokenAmount(props) {
|
|
|
5651
5659
|
}
|
|
5652
5660
|
};
|
|
5653
5661
|
useEffect(function () {
|
|
5654
|
-
if (ref.current && onChangeAmount && token && balance && token.id === WRAP_NEAR_CONTRACT_ID && Number(balance) - Number(ref.current.value) <
|
|
5655
|
-
ref.current.setCustomValidity(
|
|
5662
|
+
if (ref.current && onChangeAmount && token && balance && token.id === WRAP_NEAR_CONTRACT_ID && Number(balance) - Number(ref.current.value) < minNearAmountLeftForGasFees) {
|
|
5663
|
+
ref.current.setCustomValidity("Must have " + minNearAmountLeftForGasFees + "N or more left in wallet for gas fee.");
|
|
5656
5664
|
} else {
|
|
5657
5665
|
var _ref$current;
|
|
5658
5666
|
(_ref$current = ref.current) == null ? void 0 : _ref$current.setCustomValidity('');
|
|
5659
5667
|
}
|
|
5660
5668
|
}, [ref, balance, ref.current, (_ref$current2 = ref.current) == null ? void 0 : _ref$current2.value, token, amount]);
|
|
5661
|
-
var curMax = token ? getMax(token.id, balance || '0') : '0';
|
|
5669
|
+
var curMax = token ? getMax(token.id, balance || '0', minNearAmountLeftForGasFees) : '0';
|
|
5662
5670
|
return React.createElement(React.Fragment, null, React.createElement("div", {
|
|
5663
5671
|
className: "__ref-swap-widger-token-amount ",
|
|
5664
5672
|
style: {
|
|
@@ -5760,7 +5768,7 @@ var TokenAmount = function TokenAmount(props) {
|
|
|
5760
5768
|
}
|
|
5761
5769
|
}, React.createElement("span", null, "Balance:\xA0", toPrecision(balance, 2)), token && React.createElement(HalfAndMaxAmount, {
|
|
5762
5770
|
token: token,
|
|
5763
|
-
max: getMax(token.id, balance),
|
|
5771
|
+
max: getMax(token.id, balance, minNearAmountLeftForGasFees),
|
|
5764
5772
|
onChangeAmount: handleChange,
|
|
5765
5773
|
amount: amount
|
|
5766
5774
|
})));
|
|
@@ -5768,7 +5776,6 @@ var TokenAmount = function TokenAmount(props) {
|
|
|
5768
5776
|
var SlippageSelector = function SlippageSelector(_ref8) {
|
|
5769
5777
|
var slippageTolerance = _ref8.slippageTolerance,
|
|
5770
5778
|
onChangeSlippageTolerance = _ref8.onChangeSlippageTolerance,
|
|
5771
|
-
showSlip = _ref8.showSlip,
|
|
5772
5779
|
setShowSlip = _ref8.setShowSlip;
|
|
5773
5780
|
var _useState6 = useState(false),
|
|
5774
5781
|
invalid = _useState6[0],
|
|
@@ -5779,30 +5786,26 @@ var SlippageSelector = function SlippageSelector(_ref8) {
|
|
|
5779
5786
|
primary = theme.primary,
|
|
5780
5787
|
borderRadius = theme.borderRadius,
|
|
5781
5788
|
borderColor = theme.borderColor;
|
|
5782
|
-
var ref = useRef(null);
|
|
5783
5789
|
var handleChange = function handleChange(amount) {
|
|
5784
|
-
onChangeSlippageTolerance(
|
|
5785
|
-
|
|
5786
|
-
setInValid(false);
|
|
5787
|
-
} else {
|
|
5788
|
-
setInValid(true);
|
|
5789
|
-
}
|
|
5790
|
-
if (ref.current) {
|
|
5791
|
-
ref.current.value = amount;
|
|
5792
|
-
}
|
|
5790
|
+
onChangeSlippageTolerance(amount);
|
|
5791
|
+
setInValid(!isValidSlippageTolerance(Number(amount)));
|
|
5793
5792
|
};
|
|
5794
5793
|
useEffect(function () {
|
|
5795
|
-
|
|
5796
|
-
|
|
5797
|
-
|
|
5794
|
+
var onClick = function onClick(event) {
|
|
5795
|
+
if (!event.target) return;
|
|
5796
|
+
if (event.target.closest('#__ref-slippage-container') === null) {
|
|
5797
|
+
setShowSlip(false);
|
|
5798
|
+
if (invalid) onChangeSlippageTolerance(DEFAULT_SLIPPAGE_TOLERANCE);
|
|
5799
|
+
}
|
|
5798
5800
|
};
|
|
5801
|
+
document.addEventListener('click', onClick);
|
|
5799
5802
|
return function () {
|
|
5800
|
-
document.
|
|
5803
|
+
document.removeEventListener('click', onClick);
|
|
5801
5804
|
};
|
|
5802
|
-
}, [
|
|
5803
|
-
if (!showSlip) return null;
|
|
5805
|
+
}, [invalid]);
|
|
5804
5806
|
return React.createElement("div", {
|
|
5805
5807
|
className: "__ref-swap-widget_slippage_selector __ref-swap-widget-col-flex-start",
|
|
5808
|
+
id: "__ref-slippage-container",
|
|
5806
5809
|
onClick: function onClick(e) {
|
|
5807
5810
|
return e.stopPropagation();
|
|
5808
5811
|
},
|
|
@@ -5821,33 +5824,21 @@ var SlippageSelector = function SlippageSelector(_ref8) {
|
|
|
5821
5824
|
className: "__ref-swap-widget-row-flex-center\n __ref-swap-widget_slippage_selector_input_container",
|
|
5822
5825
|
style: {
|
|
5823
5826
|
border: "1px solid " + (invalid ? '#FF7575' : borderColor),
|
|
5824
|
-
borderRadius: borderRadius
|
|
5827
|
+
borderRadius: borderRadius,
|
|
5828
|
+
color: invalid ? '#FF7575' : primary
|
|
5825
5829
|
}
|
|
5826
5830
|
}, React.createElement("input", {
|
|
5827
|
-
ref: ref,
|
|
5828
|
-
max: 99.99999,
|
|
5829
|
-
min: 0.000001,
|
|
5830
|
-
defaultValue: slippageTolerance ? slippageTolerance : 0.5,
|
|
5831
|
-
onWheel: function onWheel() {
|
|
5832
|
-
if (ref.current) {
|
|
5833
|
-
ref.current.blur();
|
|
5834
|
-
}
|
|
5835
|
-
},
|
|
5836
5831
|
value: slippageTolerance,
|
|
5837
|
-
|
|
5838
|
-
type: "number",
|
|
5832
|
+
type: "text",
|
|
5839
5833
|
required: true,
|
|
5840
5834
|
placeholder: "",
|
|
5841
|
-
onChange: function onChange(
|
|
5842
|
-
|
|
5843
|
-
|
|
5844
|
-
|
|
5845
|
-
onKeyDown: function onKeyDown(e) {
|
|
5846
|
-
return symbolsArr.includes(e.key) && e.preventDefault();
|
|
5835
|
+
onChange: function onChange(event) {
|
|
5836
|
+
if (isValidInput(event.target.value)) {
|
|
5837
|
+
handleChange(event.target.value);
|
|
5838
|
+
}
|
|
5847
5839
|
},
|
|
5848
5840
|
style: {
|
|
5849
|
-
width: '100%'
|
|
5850
|
-
color: invalid ? '#FF7575' : primary
|
|
5841
|
+
width: '100%'
|
|
5851
5842
|
},
|
|
5852
5843
|
className: "__ref-swap-widget-input-class"
|
|
5853
5844
|
}), React.createElement("span", {
|
|
@@ -5862,7 +5853,7 @@ var SlippageSelector = function SlippageSelector(_ref8) {
|
|
|
5862
5853
|
onClick: function onClick(e) {
|
|
5863
5854
|
e.stopPropagation();
|
|
5864
5855
|
e.preventDefault();
|
|
5865
|
-
onChangeSlippageTolerance(
|
|
5856
|
+
onChangeSlippageTolerance(DEFAULT_SLIPPAGE_TOLERANCE);
|
|
5866
5857
|
setInValid(false);
|
|
5867
5858
|
}
|
|
5868
5859
|
}, "Auto")), invalid && React.createElement("div", {
|
|
@@ -5870,7 +5861,7 @@ var SlippageSelector = function SlippageSelector(_ref8) {
|
|
|
5870
5861
|
style: {
|
|
5871
5862
|
color: '#FF7575',
|
|
5872
5863
|
fontSize: '12px',
|
|
5873
|
-
padding: '10px 0px',
|
|
5864
|
+
padding: '10px 0px 0px 0px',
|
|
5874
5865
|
alignItems: 'start'
|
|
5875
5866
|
}
|
|
5876
5867
|
}, React.createElement(IoWarning, {
|
|
@@ -5881,11 +5872,11 @@ var SlippageSelector = function SlippageSelector(_ref8) {
|
|
|
5881
5872
|
size: 20
|
|
5882
5873
|
}), React.createElement("div", null, 'The slippage tolerance is invalid.')));
|
|
5883
5874
|
};
|
|
5884
|
-
var StarToken = function StarToken(
|
|
5885
|
-
var price =
|
|
5886
|
-
token =
|
|
5887
|
-
onDelete =
|
|
5888
|
-
_onClick =
|
|
5875
|
+
var StarToken = function StarToken(_ref9) {
|
|
5876
|
+
var price = _ref9.price,
|
|
5877
|
+
token = _ref9.token,
|
|
5878
|
+
onDelete = _ref9.onDelete,
|
|
5879
|
+
_onClick = _ref9.onClick;
|
|
5889
5880
|
var theme = useContext(ThemeContext);
|
|
5890
5881
|
var primary = theme.primary,
|
|
5891
5882
|
secondary = theme.secondary,
|
|
@@ -5962,16 +5953,16 @@ var StarToken = function StarToken(_ref10) {
|
|
|
5962
5953
|
}
|
|
5963
5954
|
}, !price ? '$-' : '$' + toInternationalCurrencySystemLongString(price, 2))));
|
|
5964
5955
|
};
|
|
5965
|
-
var Token = function Token(
|
|
5966
|
-
var token =
|
|
5967
|
-
_onClick2 =
|
|
5968
|
-
price =
|
|
5969
|
-
balance =
|
|
5970
|
-
isSticky =
|
|
5971
|
-
onClickPin =
|
|
5972
|
-
index =
|
|
5973
|
-
setHoverIndex =
|
|
5974
|
-
hoverIndex =
|
|
5956
|
+
var Token = function Token(_ref10) {
|
|
5957
|
+
var token = _ref10.token,
|
|
5958
|
+
_onClick2 = _ref10.onClick,
|
|
5959
|
+
price = _ref10.price,
|
|
5960
|
+
balance = _ref10.balance,
|
|
5961
|
+
isSticky = _ref10.isSticky,
|
|
5962
|
+
onClickPin = _ref10.onClickPin,
|
|
5963
|
+
index = _ref10.index,
|
|
5964
|
+
setHoverIndex = _ref10.setHoverIndex,
|
|
5965
|
+
hoverIndex = _ref10.hoverIndex;
|
|
5975
5966
|
var theme = useContext(ThemeContext);
|
|
5976
5967
|
var primary = theme.primary,
|
|
5977
5968
|
secondary = theme.secondary,
|
|
@@ -6087,14 +6078,14 @@ var Token = function Token(_ref11) {
|
|
|
6087
6078
|
}
|
|
6088
6079
|
})));
|
|
6089
6080
|
};
|
|
6090
|
-
var TokenListTable = function TokenListTable(
|
|
6091
|
-
var tokens =
|
|
6092
|
-
onClick =
|
|
6093
|
-
balances =
|
|
6094
|
-
tokenPriceList =
|
|
6095
|
-
starList =
|
|
6096
|
-
setStarList =
|
|
6097
|
-
onDelete =
|
|
6081
|
+
var TokenListTable = function TokenListTable(_ref11) {
|
|
6082
|
+
var tokens = _ref11.tokens,
|
|
6083
|
+
onClick = _ref11.onClick,
|
|
6084
|
+
balances = _ref11.balances,
|
|
6085
|
+
tokenPriceList = _ref11.tokenPriceList,
|
|
6086
|
+
starList = _ref11.starList,
|
|
6087
|
+
setStarList = _ref11.setStarList,
|
|
6088
|
+
onDelete = _ref11.onDelete;
|
|
6098
6089
|
var _useState11 = useState('down'),
|
|
6099
6090
|
currentSort = _useState11[0],
|
|
6100
6091
|
setCurrentSort = _useState11[1];
|
|
@@ -6157,13 +6148,13 @@ var TokenListTable = function TokenListTable(_ref12) {
|
|
|
6157
6148
|
});
|
|
6158
6149
|
})));
|
|
6159
6150
|
};
|
|
6160
|
-
var TokenSelector = function TokenSelector(
|
|
6161
|
-
var onSelect =
|
|
6162
|
-
width =
|
|
6163
|
-
tokens =
|
|
6164
|
-
onClose =
|
|
6165
|
-
balances =
|
|
6166
|
-
className =
|
|
6151
|
+
var TokenSelector = function TokenSelector(_ref12) {
|
|
6152
|
+
var onSelect = _ref12.onSelect,
|
|
6153
|
+
width = _ref12.width,
|
|
6154
|
+
tokens = _ref12.tokens,
|
|
6155
|
+
onClose = _ref12.onClose,
|
|
6156
|
+
balances = _ref12.balances,
|
|
6157
|
+
className = _ref12.className;
|
|
6167
6158
|
var theme = useContext(ThemeContext);
|
|
6168
6159
|
var container = theme.container,
|
|
6169
6160
|
buttonBg = theme.buttonBg,
|
|
@@ -6265,9 +6256,9 @@ var TokenSelector = function TokenSelector(_ref13) {
|
|
|
6265
6256
|
onDelete: onDelete
|
|
6266
6257
|
}));
|
|
6267
6258
|
};
|
|
6268
|
-
var Slider = function Slider(
|
|
6269
|
-
var showSlip =
|
|
6270
|
-
setShowSlip =
|
|
6259
|
+
var Slider = function Slider(_ref13) {
|
|
6260
|
+
var showSlip = _ref13.showSlip,
|
|
6261
|
+
setShowSlip = _ref13.setShowSlip;
|
|
6271
6262
|
var _useState15 = useState(false),
|
|
6272
6263
|
hover = _useState15[0],
|
|
6273
6264
|
setHover = _useState15[1];
|
|
@@ -6285,7 +6276,8 @@ var Slider = function Slider(_ref14) {
|
|
|
6285
6276
|
},
|
|
6286
6277
|
onClick: function onClick() {
|
|
6287
6278
|
return setShowSlip(true);
|
|
6288
|
-
}
|
|
6279
|
+
},
|
|
6280
|
+
className: "cursor-pointer"
|
|
6289
6281
|
}, React.createElement("path", {
|
|
6290
6282
|
fillRule: "evenodd",
|
|
6291
6283
|
clipRule: "evenodd",
|
|
@@ -6440,18 +6432,23 @@ var RouterIcon = function RouterIcon() {
|
|
|
6440
6432
|
stopColor: "#8C78FF"
|
|
6441
6433
|
}))));
|
|
6442
6434
|
};
|
|
6443
|
-
var Notification = function Notification(
|
|
6444
|
-
var state =
|
|
6445
|
-
tx =
|
|
6446
|
-
detail =
|
|
6447
|
-
|
|
6448
|
-
setOpen = _ref15.setOpen,
|
|
6449
|
-
setState = _ref15.setState;
|
|
6435
|
+
var Notification = function Notification(_ref14) {
|
|
6436
|
+
var state = _ref14.state,
|
|
6437
|
+
tx = _ref14.tx,
|
|
6438
|
+
detail = _ref14.detail,
|
|
6439
|
+
setSwapState = _ref14.setSwapState;
|
|
6450
6440
|
var theme = useContext(ThemeContext);
|
|
6451
6441
|
var container = theme.container,
|
|
6452
6442
|
buttonBg = theme.buttonBg,
|
|
6453
6443
|
primary = theme.primary;
|
|
6454
|
-
|
|
6444
|
+
var notificationStatus = useMemo(function () {
|
|
6445
|
+
return {
|
|
6446
|
+
isClosed: false,
|
|
6447
|
+
isWaitingForConfirmation: state === 'waitingForConfirmation',
|
|
6448
|
+
isFailure: state === 'fail',
|
|
6449
|
+
isSuccess: state === 'success'
|
|
6450
|
+
};
|
|
6451
|
+
}, [state]);
|
|
6455
6452
|
return React.createElement("div", {
|
|
6456
6453
|
className: "__ref-swap-widget-notification",
|
|
6457
6454
|
style: {
|
|
@@ -6460,18 +6457,18 @@ var Notification = function Notification(_ref15) {
|
|
|
6460
6457
|
}
|
|
6461
6458
|
}, React.createElement("div", {
|
|
6462
6459
|
className: "__ref-swap-widget-notification__icon"
|
|
6463
|
-
},
|
|
6460
|
+
}, notificationStatus.isWaitingForConfirmation && React.createElement(Loading, null), notificationStatus.isFailure && React.createElement(Warning, null), notificationStatus.isSuccess && React.createElement(Success, null)), React.createElement("div", {
|
|
6464
6461
|
style: {
|
|
6465
6462
|
fontSize: '16px',
|
|
6466
6463
|
marginTop: '10px',
|
|
6467
6464
|
marginBottom: '6px'
|
|
6468
6465
|
}
|
|
6469
|
-
},
|
|
6470
|
-
className: "
|
|
6466
|
+
}, notificationStatus.isSuccess && React.createElement("p", null, "Success!"), notificationStatus.isFailure && React.createElement("p", null, "Swap Failed!")), React.createElement("div", {
|
|
6467
|
+
className: "text-center",
|
|
6471
6468
|
style: {
|
|
6472
6469
|
color: primary
|
|
6473
6470
|
}
|
|
6474
|
-
},
|
|
6471
|
+
}, notificationStatus.isWaitingForConfirmation && React.createElement("p", null, "Waiting for confirmation"), notificationStatus.isSuccess && tx && React.createElement("a", {
|
|
6475
6472
|
className: "text-primary font-semibold",
|
|
6476
6473
|
href: config.explorerUrl + "/txns/" + tx,
|
|
6477
6474
|
target: "_blank",
|
|
@@ -6481,7 +6478,7 @@ var Notification = function Notification(_ref15) {
|
|
|
6481
6478
|
color: primary
|
|
6482
6479
|
},
|
|
6483
6480
|
rel: "noreferrer"
|
|
6484
|
-
}, "Click to view."),
|
|
6481
|
+
}, "Click to view."), notificationStatus.isSuccess && detail), state !== null && React.createElement("button", {
|
|
6485
6482
|
className: "__ref-swap-widget-notification__button __ref-swap-widget-button",
|
|
6486
6483
|
style: {
|
|
6487
6484
|
background: buttonBg,
|
|
@@ -6491,8 +6488,7 @@ var Notification = function Notification(_ref15) {
|
|
|
6491
6488
|
onClick: function onClick(e) {
|
|
6492
6489
|
e.preventDefault();
|
|
6493
6490
|
e.stopPropagation();
|
|
6494
|
-
|
|
6495
|
-
setState && setState(null);
|
|
6491
|
+
setSwapState(null);
|
|
6496
6492
|
}
|
|
6497
6493
|
}, "Close"));
|
|
6498
6494
|
};
|
|
@@ -6510,9 +6506,9 @@ var ArrowRight = function ArrowRight() {
|
|
|
6510
6506
|
fill: "#7E8A93"
|
|
6511
6507
|
})));
|
|
6512
6508
|
};
|
|
6513
|
-
var AccountButton = function AccountButton(
|
|
6514
|
-
var AccountId =
|
|
6515
|
-
onDisConnect =
|
|
6509
|
+
var AccountButton = function AccountButton(_ref15) {
|
|
6510
|
+
var AccountId = _ref15.AccountId,
|
|
6511
|
+
onDisConnect = _ref15.onDisConnect;
|
|
6516
6512
|
var _useState16 = useState(false),
|
|
6517
6513
|
hoverAccount = _useState16[0],
|
|
6518
6514
|
setHoverAccount = _useState16[1];
|
|
@@ -6558,7 +6554,9 @@ var SwapWidget = function SwapWidget(props) {
|
|
|
6558
6554
|
defaultTokenOut = props.defaultTokenOut,
|
|
6559
6555
|
onDisConnect = props.onDisConnect,
|
|
6560
6556
|
darkMode = props.darkMode,
|
|
6561
|
-
referralId = props.referralId
|
|
6557
|
+
referralId = props.referralId,
|
|
6558
|
+
_props$minNearAmountL = props.minNearAmountLeftForGasFees,
|
|
6559
|
+
minNearAmountLeftForGasFees = _props$minNearAmountL === void 0 ? 0.5 : _props$minNearAmountL;
|
|
6562
6560
|
var curTheme = theme || (darkMode ? defaultDarkModeTheme : defaultTheme);
|
|
6563
6561
|
var STORAGED_TOKEN_IN = localStorage.getItem(REF_WIDGET_SWAP_IN_KEY);
|
|
6564
6562
|
var STORAGED_TOKEN_OUT = localStorage.getItem(REF_WIDGET_SWAP_OUT_KEY);
|
|
@@ -6586,28 +6584,27 @@ var SwapWidget = function SwapWidget(props) {
|
|
|
6586
6584
|
var _useState2 = useState(),
|
|
6587
6585
|
tokenOut = _useState2[0],
|
|
6588
6586
|
setTokenOut = _useState2[1];
|
|
6589
|
-
var _useState3 = useState(
|
|
6590
|
-
|
|
6591
|
-
|
|
6592
|
-
|
|
6593
|
-
|
|
6594
|
-
|
|
6595
|
-
|
|
6587
|
+
var _useState3 = useState('swap'),
|
|
6588
|
+
widgetRoute = _useState3[0],
|
|
6589
|
+
setWidgetRoute = _useState3[1];
|
|
6590
|
+
var _useState4 = useState('1'),
|
|
6591
|
+
amountIn = _useState4[0],
|
|
6592
|
+
setAmountIn = _useState4[1];
|
|
6593
|
+
var _useState5 = useState(false),
|
|
6594
|
+
showSlip = _useState5[0],
|
|
6595
|
+
setShowSlip = _useState5[1];
|
|
6596
|
+
var _useState6 = useState(DEFAULT_SLIPPAGE_TOLERANCE),
|
|
6597
|
+
slippageTolerance = _useState6[0],
|
|
6598
|
+
setSlippageTolerance = _useState6[1];
|
|
6599
|
+
var formattedSlippageTolerance = useMemo(function () {
|
|
6600
|
+
try {
|
|
6601
|
+
var formatted = Number(slippageTolerance);
|
|
6602
|
+
if (Number.isNaN(formatted) || !isValidSlippageTolerance(formatted)) return +DEFAULT_SLIPPAGE_TOLERANCE;
|
|
6603
|
+
return formatted;
|
|
6604
|
+
} catch (_unused) {
|
|
6605
|
+
return +DEFAULT_SLIPPAGE_TOLERANCE;
|
|
6596
6606
|
}
|
|
6597
|
-
|
|
6598
|
-
}, [transactionState]);
|
|
6599
|
-
var _useState4 = useState('swap'),
|
|
6600
|
-
widgetRoute = _useState4[0],
|
|
6601
|
-
setWidgetRoute = _useState4[1];
|
|
6602
|
-
var _useState5 = useState('1'),
|
|
6603
|
-
amountIn = _useState5[0],
|
|
6604
|
-
setAmountIn = _useState5[1];
|
|
6605
|
-
var _useState6 = useState(false),
|
|
6606
|
-
showSlip = _useState6[0],
|
|
6607
|
-
setShowSlip = _useState6[1];
|
|
6608
|
-
var _useState7 = useState(0.5),
|
|
6609
|
-
slippageTolerance = _useState7[0],
|
|
6610
|
-
setSlippageTolerance = _useState7[1];
|
|
6607
|
+
}, [slippageTolerance]);
|
|
6611
6608
|
var _useTokensIndexer = useTokensIndexer({
|
|
6612
6609
|
defaultTokenList: defaultTokenList,
|
|
6613
6610
|
AccountId: AccountId
|
|
@@ -6618,9 +6615,9 @@ var SwapWidget = function SwapWidget(props) {
|
|
|
6618
6615
|
useAllTokens({
|
|
6619
6616
|
reload: true
|
|
6620
6617
|
});
|
|
6621
|
-
var
|
|
6622
|
-
refreshTrigger =
|
|
6623
|
-
setRreshTrigger =
|
|
6618
|
+
var _useState7 = useState(false),
|
|
6619
|
+
refreshTrigger = _useState7[0],
|
|
6620
|
+
setRreshTrigger = _useState7[1];
|
|
6624
6621
|
var tokenPriceList = useTokenPriceList();
|
|
6625
6622
|
var _useRefPools = useRefPools(refreshTrigger),
|
|
6626
6623
|
allPools = _useRefPools.allPools,
|
|
@@ -6678,7 +6675,7 @@ var SwapWidget = function SwapWidget(props) {
|
|
|
6678
6675
|
return Number(p.shares_total_supply) > 0;
|
|
6679
6676
|
})
|
|
6680
6677
|
},
|
|
6681
|
-
slippageTolerance:
|
|
6678
|
+
slippageTolerance: formattedSlippageTolerance,
|
|
6682
6679
|
onSwap: onSwap,
|
|
6683
6680
|
AccountId: AccountId,
|
|
6684
6681
|
refreshTrigger: refreshTrigger,
|
|
@@ -6711,10 +6708,10 @@ var SwapWidget = function SwapWidget(props) {
|
|
|
6711
6708
|
}, [estimates, tokenIn, tokenOut, amountIn, amountOut, allStablePools]);
|
|
6712
6709
|
var handleSubmit = function handleSubmit(e) {
|
|
6713
6710
|
e.preventDefault();
|
|
6714
|
-
|
|
6711
|
+
transactionState.setState('waitingForConfirmation');
|
|
6715
6712
|
makeSwap();
|
|
6716
6713
|
};
|
|
6717
|
-
var canSubmit = tokenIn && tokenOut && canSwap && !swapError && isSignedIn && new Big(tokenInBalance || '0').gte(amountIn || '0') &&
|
|
6714
|
+
var canSubmit = tokenIn && tokenOut && canSwap && !swapError && isSignedIn && new Big(tokenInBalance || '0').gte(amountIn || '0') && isValidSlippageTolerance(formattedSlippageTolerance) && !ONLY_ZEROS.test(tokenInBalance);
|
|
6718
6715
|
var tokensLoaded = useMemo(function () {
|
|
6719
6716
|
return tokens.length > 0;
|
|
6720
6717
|
}, [tokens]);
|
|
@@ -6747,10 +6744,9 @@ var SwapWidget = function SwapWidget(props) {
|
|
|
6747
6744
|
}), React.createElement(Slider, {
|
|
6748
6745
|
showSlip: showSlip,
|
|
6749
6746
|
setShowSlip: setShowSlip
|
|
6750
|
-
}), React.createElement(SlippageSelector, {
|
|
6747
|
+
}), showSlip && React.createElement(SlippageSelector, {
|
|
6751
6748
|
slippageTolerance: slippageTolerance,
|
|
6752
6749
|
onChangeSlippageTolerance: setSlippageTolerance,
|
|
6753
|
-
showSlip: showSlip,
|
|
6754
6750
|
setShowSlip: setShowSlip
|
|
6755
6751
|
}))), React.createElement(TokenAmount, {
|
|
6756
6752
|
amount: amountIn,
|
|
@@ -6761,7 +6757,8 @@ var SwapWidget = function SwapWidget(props) {
|
|
|
6761
6757
|
onSelectToken: function onSelectToken() {
|
|
6762
6758
|
if (!tokensLoaded) return;
|
|
6763
6759
|
setWidgetRoute('token-selector-in');
|
|
6764
|
-
}
|
|
6760
|
+
},
|
|
6761
|
+
minNearAmountLeftForGasFees: minNearAmountLeftForGasFees
|
|
6765
6762
|
}), React.createElement("div", {
|
|
6766
6763
|
className: "__ref-swap-widget-exchange-button __ref-swap-widget-row-flex-center ",
|
|
6767
6764
|
style: {
|
|
@@ -6791,7 +6788,8 @@ var SwapWidget = function SwapWidget(props) {
|
|
|
6791
6788
|
onForceUpdate: function onForceUpdate() {
|
|
6792
6789
|
setRreshTrigger(!refreshTrigger);
|
|
6793
6790
|
},
|
|
6794
|
-
poolFetchingState: poolFetchingState
|
|
6791
|
+
poolFetchingState: poolFetchingState,
|
|
6792
|
+
minNearAmountLeftForGasFees: minNearAmountLeftForGasFees
|
|
6795
6793
|
}), !swapError && amountIn && amountOut && React.createElement(DetailView, {
|
|
6796
6794
|
fee: fee,
|
|
6797
6795
|
rate: rate,
|
|
@@ -6854,11 +6852,9 @@ var SwapWidget = function SwapWidget(props) {
|
|
|
6854
6852
|
style: {
|
|
6855
6853
|
color: refIcon || 'black'
|
|
6856
6854
|
}
|
|
6857
|
-
}), "\xA0 Powered by Ref.finance")), React.createElement(Notification, {
|
|
6858
|
-
state: transactionState
|
|
6859
|
-
|
|
6860
|
-
open: notOpen,
|
|
6861
|
-
setOpen: setNotOpen,
|
|
6855
|
+
}), "\xA0 Powered by Ref.finance")), transactionState.state !== null && React.createElement(Notification, {
|
|
6856
|
+
state: transactionState.state,
|
|
6857
|
+
setSwapState: transactionState.setState,
|
|
6862
6858
|
tx: transactionState == null ? void 0 : transactionState.tx,
|
|
6863
6859
|
detail: transactionState == null ? void 0 : transactionState.detail
|
|
6864
6860
|
})), widgetRoute === 'token-selector-in' && React.createElement(TokenSelector, {
|
|
@@ -8300,5 +8296,5 @@ var get_pointorder_range = function get_pointorder_range(_ref5) {
|
|
|
8300
8296
|
});
|
|
8301
8297
|
};
|
|
8302
8298
|
|
|
8303
|
-
export { AccountIdMisMatch, CONSTANT_D, DCLInValid, DCLSwap, DCLSwapByInputOnBestPool, DCLSwapGetStorageBalance, DCL_POOL_FEE_LIST, DCL_POOL_SPLITER, 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, 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, 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 };
|
|
8299
|
+
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, 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 };
|
|
8304
8300
|
//# sourceMappingURL=ref-sdk.esm.js.map
|