@ref-finance/ref-sdk 1.3.11 → 1.3.12
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/dist/constant.d.ts +1 -0
- package/dist/ref-sdk.cjs.development.js +78 -14
- 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 +77 -15
- package/dist/ref-sdk.esm.js.map +1 -1
- package/dist/ref-sdk.umd.development.js +81 -18
- 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/ref.d.ts +1 -0
- package/package.json +1 -1
package/dist/ref-sdk.esm.js
CHANGED
|
@@ -5,6 +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
9
|
import React, { useState, useEffect, useMemo, useCallback, createContext, useContext, useRef } from 'react';
|
|
9
10
|
import { FiChevronDown } from '@react-icons/all-files/fi/FiChevronDown';
|
|
10
11
|
import { FiChevronLeft } from '@react-icons/all-files/fi/FiChevronLeft';
|
|
@@ -26,6 +27,8 @@ var FEE_DIVISOR = 10000;
|
|
|
26
27
|
var STABLE_LP_TOKEN_DECIMALS = 18;
|
|
27
28
|
var RATED_POOL_LP_TOKEN_DECIMALS = 24;
|
|
28
29
|
var STORAGE_TO_REGISTER_WITH_MFT = '0.1';
|
|
30
|
+
//0.0125 NEAR
|
|
31
|
+
var FT_MINIMUM_STORAGE_BALANCE_LARGE = "12500000000000000000000";
|
|
29
32
|
var ONE_YOCTO_NEAR = '0.000000000000000000000001';
|
|
30
33
|
var ENV = '';
|
|
31
34
|
var INDEXER_URL = '';
|
|
@@ -4272,6 +4275,51 @@ var DCLSwapGetStorageBalance = function DCLSwapGetStorageBalance(tokenId, Accoun
|
|
|
4272
4275
|
}
|
|
4273
4276
|
});
|
|
4274
4277
|
};
|
|
4278
|
+
var getMinStorageBalance = /*#__PURE__*/function () {
|
|
4279
|
+
var _ref14 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(nep141Address) {
|
|
4280
|
+
var provider, result, balance;
|
|
4281
|
+
return _regeneratorRuntime().wrap(function _callee11$(_context11) {
|
|
4282
|
+
while (1) {
|
|
4283
|
+
switch (_context11.prev = _context11.next) {
|
|
4284
|
+
case 0:
|
|
4285
|
+
_context11.prev = 0;
|
|
4286
|
+
provider = new providers.JsonRpcProvider({
|
|
4287
|
+
url: getConfig().nodeUrl
|
|
4288
|
+
});
|
|
4289
|
+
_context11.next = 4;
|
|
4290
|
+
return provider.query({
|
|
4291
|
+
request_type: 'call_function',
|
|
4292
|
+
account_id: nep141Address,
|
|
4293
|
+
method_name: 'storage_balance_bounds',
|
|
4294
|
+
args_base64: '',
|
|
4295
|
+
finality: 'optimistic'
|
|
4296
|
+
});
|
|
4297
|
+
case 4:
|
|
4298
|
+
result = _context11.sent;
|
|
4299
|
+
balance = JSON.parse(Buffer.from(result.result).toString());
|
|
4300
|
+
if (!(!balance || !balance.min)) {
|
|
4301
|
+
_context11.next = 8;
|
|
4302
|
+
break;
|
|
4303
|
+
}
|
|
4304
|
+
return _context11.abrupt("return", FT_MINIMUM_STORAGE_BALANCE_LARGE);
|
|
4305
|
+
case 8:
|
|
4306
|
+
return _context11.abrupt("return", balance.min);
|
|
4307
|
+
case 11:
|
|
4308
|
+
_context11.prev = 11;
|
|
4309
|
+
_context11.t0 = _context11["catch"](0);
|
|
4310
|
+
console.error(_context11.t0, nep141Address);
|
|
4311
|
+
return _context11.abrupt("return", FT_MINIMUM_STORAGE_BALANCE_LARGE);
|
|
4312
|
+
case 15:
|
|
4313
|
+
case "end":
|
|
4314
|
+
return _context11.stop();
|
|
4315
|
+
}
|
|
4316
|
+
}
|
|
4317
|
+
}, _callee11, null, [[0, 11]]);
|
|
4318
|
+
}));
|
|
4319
|
+
return function getMinStorageBalance(_x13) {
|
|
4320
|
+
return _ref14.apply(this, arguments);
|
|
4321
|
+
};
|
|
4322
|
+
}();
|
|
4275
4323
|
|
|
4276
4324
|
var DCL_POOL_FEE_LIST = [100, 400, 2000, 10000];
|
|
4277
4325
|
var getDCLPoolId = function getDCLPoolId(tokenA, tokenB, fee) {
|
|
@@ -4372,21 +4420,35 @@ var instantSwap = /*#__PURE__*/function () {
|
|
|
4372
4420
|
});
|
|
4373
4421
|
case 2:
|
|
4374
4422
|
tokenRegistered = _context.sent;
|
|
4375
|
-
if (tokenRegistered === null) {
|
|
4376
|
-
|
|
4377
|
-
|
|
4378
|
-
functionCalls: [{
|
|
4379
|
-
methodName: 'storage_deposit',
|
|
4380
|
-
args: {
|
|
4381
|
-
registration_only: true,
|
|
4382
|
-
account_id: AccountId
|
|
4383
|
-
},
|
|
4384
|
-
gas: '30000000000000',
|
|
4385
|
-
amount: STORAGE_TO_REGISTER_WITH_MFT
|
|
4386
|
-
}]
|
|
4387
|
-
});
|
|
4423
|
+
if (!(tokenRegistered === null)) {
|
|
4424
|
+
_context.next = 16;
|
|
4425
|
+
break;
|
|
4388
4426
|
}
|
|
4389
|
-
|
|
4427
|
+
_context.t0 = transactions;
|
|
4428
|
+
_context.t1 = token.id;
|
|
4429
|
+
_context.t2 = {
|
|
4430
|
+
registration_only: true,
|
|
4431
|
+
account_id: AccountId
|
|
4432
|
+
};
|
|
4433
|
+
_context.t3 = formatNearAmount;
|
|
4434
|
+
_context.next = 10;
|
|
4435
|
+
return getMinStorageBalance(token.id);
|
|
4436
|
+
case 10:
|
|
4437
|
+
_context.t4 = _context.sent;
|
|
4438
|
+
_context.t5 = (0, _context.t3)(_context.t4, 24);
|
|
4439
|
+
_context.t6 = {
|
|
4440
|
+
methodName: 'storage_deposit',
|
|
4441
|
+
args: _context.t2,
|
|
4442
|
+
gas: '30000000000000',
|
|
4443
|
+
amount: _context.t5
|
|
4444
|
+
};
|
|
4445
|
+
_context.t7 = [_context.t6];
|
|
4446
|
+
_context.t8 = {
|
|
4447
|
+
receiverId: _context.t1,
|
|
4448
|
+
functionCalls: _context.t7
|
|
4449
|
+
};
|
|
4450
|
+
_context.t0.push.call(_context.t0, _context.t8);
|
|
4451
|
+
case 16:
|
|
4390
4452
|
case "end":
|
|
4391
4453
|
return _context.stop();
|
|
4392
4454
|
}
|
|
@@ -8232,5 +8294,5 @@ var get_pointorder_range = function get_pointorder_range(_ref5) {
|
|
|
8232
8294
|
});
|
|
8233
8295
|
};
|
|
8234
8296
|
|
|
8235
|
-
export { AccountIdMisMatch, CONSTANT_D, DCLInValid, DCLSwap, DCLSwapByInputOnBestPool, DCLSwapGetStorageBalance, DCL_POOL_FEE_LIST, DCL_POOL_SPLITER, DefaultMainnetTokenList, DefaultTestnetTokenList, FEE_DIVISOR, 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, 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 };
|
|
8297
|
+
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 };
|
|
8236
8298
|
//# sourceMappingURL=ref-sdk.esm.js.map
|