@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
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('near-api-js'), require('bn.js'), require('fs'), require('lodash-es'), require('mathjs'), require('big.js'), require('react'), require('@react-icons/all-files/fi/FiChevronDown'), require('@react-icons/all-files/fi/FiChevronLeft'), require('@react-icons/all-files/fi/FiChevronUp'), require('@react-icons/all-files/fa/FaSearch'), require('@react-icons/all-files/ri/RiRefreshLine'), require('@react-icons/all-files/ti/TiArrowSortedUp'), require('@react-icons/all-files/ti/TiArrowSortedDown'), require('@react-icons/all-files/hi/HiOutlineExternalLink'), require('@react-icons/all-files/ai/AiFillPushpin'), require('@react-icons/all-files/ai/AiOutlinePushpin'), require('@react-icons/all-files/ri/RiExchangeFill'), require('@react-icons/all-files/io5/IoWarning'), require('@react-icons/all-files/io5/IoCloseOutline'), require('@react-icons/all-files/ti/TiWarning'), require('@react-icons/all-files/cg/CgArrowsExchangeAltV')) :
|
|
3
|
-
typeof define === 'function' && define.amd ? define(['exports', 'near-api-js', 'bn.js', 'fs', 'lodash-es', 'mathjs', 'big.js', 'react', '@react-icons/all-files/fi/FiChevronDown', '@react-icons/all-files/fi/FiChevronLeft', '@react-icons/all-files/fi/FiChevronUp', '@react-icons/all-files/fa/FaSearch', '@react-icons/all-files/ri/RiRefreshLine', '@react-icons/all-files/ti/TiArrowSortedUp', '@react-icons/all-files/ti/TiArrowSortedDown', '@react-icons/all-files/hi/HiOutlineExternalLink', '@react-icons/all-files/ai/AiFillPushpin', '@react-icons/all-files/ai/AiOutlinePushpin', '@react-icons/all-files/ri/RiExchangeFill', '@react-icons/all-files/io5/IoWarning', '@react-icons/all-files/io5/IoCloseOutline', '@react-icons/all-files/ti/TiWarning', '@react-icons/all-files/cg/CgArrowsExchangeAltV'], factory) :
|
|
4
|
-
(global = global || self, factory(global['@ref-finance/ref-sdk'] = {}, global.nearApiJs, global.BN, global.fs, global._, global.math, global.Big, global.React, global.FiChevronDown, global.FiChevronLeft, global.FiChevronUp, global.FaSearch, global.RiRefreshLine, global.TiArrowSortedUp, global.TiArrowSortedDown, global.HiOutlineExternalLink, global.AiFillPushpin, global.AiOutlinePushpin, global.RiExchangeFill, global.IoWarning, global.IoCloseOutline, global.TiWarning, global.CgArrowsExchangeAltV));
|
|
5
|
-
}(this, (function (exports, nearApiJs, BN, fs, _, math, Big, React, FiChevronDown, FiChevronLeft, FiChevronUp, FaSearch, RiRefreshLine, TiArrowSortedUp, TiArrowSortedDown, HiOutlineExternalLink, AiFillPushpin, AiOutlinePushpin, RiExchangeFill, IoWarning, IoCloseOutline, TiWarning, CgArrowsExchangeAltV) { 'use strict';
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('near-api-js'), require('bn.js'), require('fs'), require('lodash-es'), require('mathjs'), require('big.js'), require('near-api-js/lib/utils/format'), require('react'), require('@react-icons/all-files/fi/FiChevronDown'), require('@react-icons/all-files/fi/FiChevronLeft'), require('@react-icons/all-files/fi/FiChevronUp'), require('@react-icons/all-files/fa/FaSearch'), require('@react-icons/all-files/ri/RiRefreshLine'), require('@react-icons/all-files/ti/TiArrowSortedUp'), require('@react-icons/all-files/ti/TiArrowSortedDown'), require('@react-icons/all-files/hi/HiOutlineExternalLink'), require('@react-icons/all-files/ai/AiFillPushpin'), require('@react-icons/all-files/ai/AiOutlinePushpin'), require('@react-icons/all-files/ri/RiExchangeFill'), require('@react-icons/all-files/io5/IoWarning'), require('@react-icons/all-files/io5/IoCloseOutline'), require('@react-icons/all-files/ti/TiWarning'), require('@react-icons/all-files/cg/CgArrowsExchangeAltV')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(['exports', 'near-api-js', 'bn.js', 'fs', 'lodash-es', 'mathjs', 'big.js', 'near-api-js/lib/utils/format', 'react', '@react-icons/all-files/fi/FiChevronDown', '@react-icons/all-files/fi/FiChevronLeft', '@react-icons/all-files/fi/FiChevronUp', '@react-icons/all-files/fa/FaSearch', '@react-icons/all-files/ri/RiRefreshLine', '@react-icons/all-files/ti/TiArrowSortedUp', '@react-icons/all-files/ti/TiArrowSortedDown', '@react-icons/all-files/hi/HiOutlineExternalLink', '@react-icons/all-files/ai/AiFillPushpin', '@react-icons/all-files/ai/AiOutlinePushpin', '@react-icons/all-files/ri/RiExchangeFill', '@react-icons/all-files/io5/IoWarning', '@react-icons/all-files/io5/IoCloseOutline', '@react-icons/all-files/ti/TiWarning', '@react-icons/all-files/cg/CgArrowsExchangeAltV'], factory) :
|
|
4
|
+
(global = global || self, factory(global['@ref-finance/ref-sdk'] = {}, global.nearApiJs, global.BN, global.fs, global._, global.math, global.Big, global.format, global.React, global.FiChevronDown, global.FiChevronLeft, global.FiChevronUp, global.FaSearch, global.RiRefreshLine, global.TiArrowSortedUp, global.TiArrowSortedDown, global.HiOutlineExternalLink, global.AiFillPushpin, global.AiOutlinePushpin, global.RiExchangeFill, global.IoWarning, global.IoCloseOutline, global.TiWarning, global.CgArrowsExchangeAltV));
|
|
5
|
+
}(this, (function (exports, nearApiJs, BN, fs, _, math, Big, format, React, FiChevronDown, FiChevronLeft, FiChevronUp, FaSearch, RiRefreshLine, TiArrowSortedUp, TiArrowSortedDown, HiOutlineExternalLink, AiFillPushpin, AiOutlinePushpin, RiExchangeFill, IoWarning, IoCloseOutline, TiWarning, CgArrowsExchangeAltV) { 'use strict';
|
|
6
6
|
|
|
7
7
|
BN = BN && Object.prototype.hasOwnProperty.call(BN, 'default') ? BN['default'] : BN;
|
|
8
8
|
fs = fs && Object.prototype.hasOwnProperty.call(fs, 'default') ? fs['default'] : fs;
|
|
@@ -14,6 +14,8 @@
|
|
|
14
14
|
var STABLE_LP_TOKEN_DECIMALS = 18;
|
|
15
15
|
var RATED_POOL_LP_TOKEN_DECIMALS = 24;
|
|
16
16
|
var STORAGE_TO_REGISTER_WITH_MFT = '0.1';
|
|
17
|
+
//0.0125 NEAR
|
|
18
|
+
var FT_MINIMUM_STORAGE_BALANCE_LARGE = "12500000000000000000000";
|
|
17
19
|
var ONE_YOCTO_NEAR = '0.000000000000000000000001';
|
|
18
20
|
var ENV = '';
|
|
19
21
|
var INDEXER_URL = '';
|
|
@@ -4259,6 +4261,51 @@
|
|
|
4259
4261
|
}
|
|
4260
4262
|
});
|
|
4261
4263
|
};
|
|
4264
|
+
var getMinStorageBalance = /*#__PURE__*/function () {
|
|
4265
|
+
var _ref14 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(nep141Address) {
|
|
4266
|
+
var provider, result, balance;
|
|
4267
|
+
return _regeneratorRuntime().wrap(function _callee11$(_context11) {
|
|
4268
|
+
while (1) {
|
|
4269
|
+
switch (_context11.prev = _context11.next) {
|
|
4270
|
+
case 0:
|
|
4271
|
+
_context11.prev = 0;
|
|
4272
|
+
provider = new nearApiJs.providers.JsonRpcProvider({
|
|
4273
|
+
url: getConfig().nodeUrl
|
|
4274
|
+
});
|
|
4275
|
+
_context11.next = 4;
|
|
4276
|
+
return provider.query({
|
|
4277
|
+
request_type: 'call_function',
|
|
4278
|
+
account_id: nep141Address,
|
|
4279
|
+
method_name: 'storage_balance_bounds',
|
|
4280
|
+
args_base64: '',
|
|
4281
|
+
finality: 'optimistic'
|
|
4282
|
+
});
|
|
4283
|
+
case 4:
|
|
4284
|
+
result = _context11.sent;
|
|
4285
|
+
balance = JSON.parse(Buffer.from(result.result).toString());
|
|
4286
|
+
if (!(!balance || !balance.min)) {
|
|
4287
|
+
_context11.next = 8;
|
|
4288
|
+
break;
|
|
4289
|
+
}
|
|
4290
|
+
return _context11.abrupt("return", FT_MINIMUM_STORAGE_BALANCE_LARGE);
|
|
4291
|
+
case 8:
|
|
4292
|
+
return _context11.abrupt("return", balance.min);
|
|
4293
|
+
case 11:
|
|
4294
|
+
_context11.prev = 11;
|
|
4295
|
+
_context11.t0 = _context11["catch"](0);
|
|
4296
|
+
console.error(_context11.t0, nep141Address);
|
|
4297
|
+
return _context11.abrupt("return", FT_MINIMUM_STORAGE_BALANCE_LARGE);
|
|
4298
|
+
case 15:
|
|
4299
|
+
case "end":
|
|
4300
|
+
return _context11.stop();
|
|
4301
|
+
}
|
|
4302
|
+
}
|
|
4303
|
+
}, _callee11, null, [[0, 11]]);
|
|
4304
|
+
}));
|
|
4305
|
+
return function getMinStorageBalance(_x13) {
|
|
4306
|
+
return _ref14.apply(this, arguments);
|
|
4307
|
+
};
|
|
4308
|
+
}();
|
|
4262
4309
|
|
|
4263
4310
|
var DCL_POOL_FEE_LIST = [100, 400, 2000, 10000];
|
|
4264
4311
|
var getDCLPoolId = function getDCLPoolId(tokenA, tokenB, fee) {
|
|
@@ -4359,21 +4406,35 @@
|
|
|
4359
4406
|
});
|
|
4360
4407
|
case 2:
|
|
4361
4408
|
tokenRegistered = _context.sent;
|
|
4362
|
-
if (tokenRegistered === null) {
|
|
4363
|
-
|
|
4364
|
-
|
|
4365
|
-
functionCalls: [{
|
|
4366
|
-
methodName: 'storage_deposit',
|
|
4367
|
-
args: {
|
|
4368
|
-
registration_only: true,
|
|
4369
|
-
account_id: AccountId
|
|
4370
|
-
},
|
|
4371
|
-
gas: '30000000000000',
|
|
4372
|
-
amount: STORAGE_TO_REGISTER_WITH_MFT
|
|
4373
|
-
}]
|
|
4374
|
-
});
|
|
4409
|
+
if (!(tokenRegistered === null)) {
|
|
4410
|
+
_context.next = 16;
|
|
4411
|
+
break;
|
|
4375
4412
|
}
|
|
4376
|
-
|
|
4413
|
+
_context.t0 = transactions;
|
|
4414
|
+
_context.t1 = token.id;
|
|
4415
|
+
_context.t2 = {
|
|
4416
|
+
registration_only: true,
|
|
4417
|
+
account_id: AccountId
|
|
4418
|
+
};
|
|
4419
|
+
_context.t3 = format.formatNearAmount;
|
|
4420
|
+
_context.next = 10;
|
|
4421
|
+
return getMinStorageBalance(token.id);
|
|
4422
|
+
case 10:
|
|
4423
|
+
_context.t4 = _context.sent;
|
|
4424
|
+
_context.t5 = (0, _context.t3)(_context.t4, 24);
|
|
4425
|
+
_context.t6 = {
|
|
4426
|
+
methodName: 'storage_deposit',
|
|
4427
|
+
args: _context.t2,
|
|
4428
|
+
gas: '30000000000000',
|
|
4429
|
+
amount: _context.t5
|
|
4430
|
+
};
|
|
4431
|
+
_context.t7 = [_context.t6];
|
|
4432
|
+
_context.t8 = {
|
|
4433
|
+
receiverId: _context.t1,
|
|
4434
|
+
functionCalls: _context.t7
|
|
4435
|
+
};
|
|
4436
|
+
_context.t0.push.call(_context.t0, _context.t8);
|
|
4437
|
+
case 16:
|
|
4377
4438
|
case "end":
|
|
4378
4439
|
return _context.stop();
|
|
4379
4440
|
}
|
|
@@ -4675,24 +4736,30 @@
|
|
|
4675
4736
|
});
|
|
4676
4737
|
case 3:
|
|
4677
4738
|
_pools = _context7.sent;
|
|
4739
|
+
if (!(_pools.code !== 0 || !_pools.simplePools)) {
|
|
4740
|
+
_context7.next = 6;
|
|
4741
|
+
break;
|
|
4742
|
+
}
|
|
4743
|
+
throw Error();
|
|
4744
|
+
case 6:
|
|
4678
4745
|
return _context7.abrupt("return", _pools);
|
|
4679
|
-
case 7:
|
|
4680
|
-
_context7.prev = 7;
|
|
4681
|
-
_context7.t0 = _context7["catch"](0);
|
|
4682
4746
|
case 9:
|
|
4747
|
+
_context7.prev = 9;
|
|
4748
|
+
_context7.t0 = _context7["catch"](0);
|
|
4749
|
+
case 11:
|
|
4683
4750
|
if (perPage) {
|
|
4684
4751
|
DEFAULT_PAGE_LIMIT = Math.min(perPage, 500);
|
|
4685
4752
|
}
|
|
4686
|
-
_context7.next =
|
|
4753
|
+
_context7.next = 14;
|
|
4687
4754
|
return getTotalPools();
|
|
4688
|
-
case
|
|
4755
|
+
case 14:
|
|
4689
4756
|
totalPools = _context7.sent;
|
|
4690
4757
|
pages = Math.ceil(totalPools / DEFAULT_PAGE_LIMIT);
|
|
4691
|
-
_context7.next =
|
|
4758
|
+
_context7.next = 18;
|
|
4692
4759
|
return Promise.all([].concat(Array(pages)).fill(0).map(function (_, i) {
|
|
4693
4760
|
return getRefPools(i + 1);
|
|
4694
4761
|
}));
|
|
4695
|
-
case
|
|
4762
|
+
case 18:
|
|
4696
4763
|
pools = _context7.sent.flat();
|
|
4697
4764
|
return _context7.abrupt("return", {
|
|
4698
4765
|
simplePools: pools.filter(function (p) {
|
|
@@ -4705,12 +4772,12 @@
|
|
|
4705
4772
|
return p.pool_kind && p.pool_kind === 'RATED_SWAP';
|
|
4706
4773
|
})
|
|
4707
4774
|
});
|
|
4708
|
-
case
|
|
4775
|
+
case 20:
|
|
4709
4776
|
case "end":
|
|
4710
4777
|
return _context7.stop();
|
|
4711
4778
|
}
|
|
4712
4779
|
}
|
|
4713
|
-
}, _callee7, null, [[0,
|
|
4780
|
+
}, _callee7, null, [[0, 9]]);
|
|
4714
4781
|
}));
|
|
4715
4782
|
return function fetchAllPools(_x8) {
|
|
4716
4783
|
return _ref9.apply(this, arguments);
|
|
@@ -8230,6 +8297,7 @@
|
|
|
8230
8297
|
exports.DefaultMainnetTokenList = DefaultMainnetTokenList;
|
|
8231
8298
|
exports.DefaultTestnetTokenList = DefaultTestnetTokenList;
|
|
8232
8299
|
exports.FEE_DIVISOR = FEE_DIVISOR;
|
|
8300
|
+
exports.FT_MINIMUM_STORAGE_BALANCE_LARGE = FT_MINIMUM_STORAGE_BALANCE_LARGE;
|
|
8233
8301
|
exports.InValidAccessKeyError = InValidAccessKeyError;
|
|
8234
8302
|
exports.NEAR_META_DATA = NEAR_META_DATA;
|
|
8235
8303
|
exports.NoAccountIdFound = NoAccountIdFound;
|
|
@@ -8300,6 +8368,7 @@
|
|
|
8300
8368
|
exports.getKeyStore = getKeyStore;
|
|
8301
8369
|
exports.getMax = getMax;
|
|
8302
8370
|
exports.getMemorySigner = getMemorySigner;
|
|
8371
|
+
exports.getMinStorageBalance = getMinStorageBalance;
|
|
8303
8372
|
exports.getPointByPrice = getPointByPrice;
|
|
8304
8373
|
exports.getPool = getPool;
|
|
8305
8374
|
exports.getPoolAllocationPercents = getPoolAllocationPercents;
|