@ref-finance/ref-sdk 1.3.11 → 1.4.0
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 +93 -23
- 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 +92 -24
- package/dist/ref-sdk.esm.js.map +1 -1
- package/dist/ref-sdk.umd.development.js +96 -27
- 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
|
}
|
|
@@ -4688,24 +4750,30 @@ var fetchAllPools = /*#__PURE__*/function () {
|
|
|
4688
4750
|
});
|
|
4689
4751
|
case 3:
|
|
4690
4752
|
_pools = _context7.sent;
|
|
4753
|
+
if (!(_pools.code !== 0 || !_pools.simplePools)) {
|
|
4754
|
+
_context7.next = 6;
|
|
4755
|
+
break;
|
|
4756
|
+
}
|
|
4757
|
+
throw Error();
|
|
4758
|
+
case 6:
|
|
4691
4759
|
return _context7.abrupt("return", _pools);
|
|
4692
|
-
case 7:
|
|
4693
|
-
_context7.prev = 7;
|
|
4694
|
-
_context7.t0 = _context7["catch"](0);
|
|
4695
4760
|
case 9:
|
|
4761
|
+
_context7.prev = 9;
|
|
4762
|
+
_context7.t0 = _context7["catch"](0);
|
|
4763
|
+
case 11:
|
|
4696
4764
|
if (perPage) {
|
|
4697
4765
|
DEFAULT_PAGE_LIMIT = Math.min(perPage, 500);
|
|
4698
4766
|
}
|
|
4699
|
-
_context7.next =
|
|
4767
|
+
_context7.next = 14;
|
|
4700
4768
|
return getTotalPools();
|
|
4701
|
-
case
|
|
4769
|
+
case 14:
|
|
4702
4770
|
totalPools = _context7.sent;
|
|
4703
4771
|
pages = Math.ceil(totalPools / DEFAULT_PAGE_LIMIT);
|
|
4704
|
-
_context7.next =
|
|
4772
|
+
_context7.next = 18;
|
|
4705
4773
|
return Promise.all([].concat(Array(pages)).fill(0).map(function (_, i) {
|
|
4706
4774
|
return getRefPools(i + 1);
|
|
4707
4775
|
}));
|
|
4708
|
-
case
|
|
4776
|
+
case 18:
|
|
4709
4777
|
pools = _context7.sent.flat();
|
|
4710
4778
|
return _context7.abrupt("return", {
|
|
4711
4779
|
simplePools: pools.filter(function (p) {
|
|
@@ -4718,12 +4786,12 @@ var fetchAllPools = /*#__PURE__*/function () {
|
|
|
4718
4786
|
return p.pool_kind && p.pool_kind === 'RATED_SWAP';
|
|
4719
4787
|
})
|
|
4720
4788
|
});
|
|
4721
|
-
case
|
|
4789
|
+
case 20:
|
|
4722
4790
|
case "end":
|
|
4723
4791
|
return _context7.stop();
|
|
4724
4792
|
}
|
|
4725
4793
|
}
|
|
4726
|
-
}, _callee7, null, [[0,
|
|
4794
|
+
}, _callee7, null, [[0, 9]]);
|
|
4727
4795
|
}));
|
|
4728
4796
|
return function fetchAllPools(_x8) {
|
|
4729
4797
|
return _ref9.apply(this, arguments);
|
|
@@ -8232,5 +8300,5 @@ var get_pointorder_range = function get_pointorder_range(_ref5) {
|
|
|
8232
8300
|
});
|
|
8233
8301
|
};
|
|
8234
8302
|
|
|
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 };
|
|
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 };
|
|
8236
8304
|
//# sourceMappingURL=ref-sdk.esm.js.map
|