@ref-finance/ref-sdk 1.4.4-beta.1-development → 1.4.6-beta.0-development
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 +4 -0
- package/dist/constant.d.ts +1 -1
- package/dist/ref-sdk.cjs.development.js +35 -20
- 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 +35 -20
- package/dist/ref-sdk.esm.js.map +1 -1
- package/dist/ref-sdk.umd.development.js +35 -20
- 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 -1
- package/dist/types.d.ts +1 -0
- package/dist/utils.d.ts +1 -1
- package/dist/v1-swap/pool.d.ts +1 -1
- package/dist/v1-swap/swap.d.ts +8 -2
- package/package.json +1 -1
|
@@ -11,29 +11,32 @@
|
|
|
11
11
|
var React__default = 'default' in React ? React['default'] : React;
|
|
12
12
|
|
|
13
13
|
var FEE_DIVISOR = 10000;
|
|
14
|
-
var DEFAULT_SLIPPAGE_TOLERANCE =
|
|
14
|
+
var DEFAULT_SLIPPAGE_TOLERANCE = '0.5';
|
|
15
15
|
var STABLE_LP_TOKEN_DECIMALS = 18;
|
|
16
16
|
var RATED_POOL_LP_TOKEN_DECIMALS = 24;
|
|
17
17
|
var STORAGE_TO_REGISTER_WITH_MFT = '0.1';
|
|
18
18
|
//0.0125 NEAR
|
|
19
|
-
var FT_MINIMUM_STORAGE_BALANCE_LARGE =
|
|
19
|
+
var FT_MINIMUM_STORAGE_BALANCE_LARGE = '12500000000000000000000';
|
|
20
20
|
var ONE_YOCTO_NEAR = '0.000000000000000000000001';
|
|
21
21
|
var ENV = '';
|
|
22
22
|
var INDEXER_URL = '';
|
|
23
|
-
function getConfig(env, indexerUrl) {
|
|
23
|
+
function getConfig(env, indexerUrl, nodeUrl) {
|
|
24
24
|
if (env === void 0) {
|
|
25
25
|
env = ENV || process.env.NEAR_ENV || process.env.REACT_APP_REF_SDK_ENV;
|
|
26
26
|
}
|
|
27
27
|
if (indexerUrl === void 0) {
|
|
28
28
|
indexerUrl = INDEXER_URL;
|
|
29
29
|
}
|
|
30
|
+
if (nodeUrl === void 0) {
|
|
31
|
+
nodeUrl = '';
|
|
32
|
+
}
|
|
30
33
|
ENV = env;
|
|
31
34
|
INDEXER_URL = indexerUrl;
|
|
32
35
|
switch (env) {
|
|
33
36
|
case 'mainnet':
|
|
34
37
|
return {
|
|
35
38
|
networkId: 'mainnet',
|
|
36
|
-
nodeUrl: 'https://rpc.mainnet.near.org',
|
|
39
|
+
nodeUrl: nodeUrl || 'https://rpc.mainnet.near.org',
|
|
37
40
|
walletUrl: 'https://wallet.near.org',
|
|
38
41
|
WRAP_NEAR_CONTRACT_ID: 'wrap.near',
|
|
39
42
|
REF_FI_CONTRACT_ID: 'v2.ref-finance.near',
|
|
@@ -45,7 +48,7 @@
|
|
|
45
48
|
case 'testnet':
|
|
46
49
|
return {
|
|
47
50
|
networkId: 'testnet',
|
|
48
|
-
nodeUrl: 'https://rpc.testnet.near.org',
|
|
51
|
+
nodeUrl: nodeUrl || 'https://rpc.testnet.near.org',
|
|
49
52
|
walletUrl: 'https://wallet.testnet.near.org',
|
|
50
53
|
indexerUrl: indexerUrl || 'https://testnet-indexer.ref-finance.com',
|
|
51
54
|
WRAP_NEAR_CONTRACT_ID: 'wrap.testnet',
|
|
@@ -57,7 +60,7 @@
|
|
|
57
60
|
case 'dev':
|
|
58
61
|
return {
|
|
59
62
|
networkId: 'testnet',
|
|
60
|
-
nodeUrl: 'https://rpc.testnet.near.org',
|
|
63
|
+
nodeUrl: nodeUrl || 'https://rpc.testnet.near.org',
|
|
61
64
|
walletUrl: 'https://wallet.testnet.near.org',
|
|
62
65
|
indexerUrl: indexerUrl || 'https://dev-indexer.ref-finance.com',
|
|
63
66
|
WRAP_NEAR_CONTRACT_ID: 'wrap.testnet',
|
|
@@ -69,7 +72,7 @@
|
|
|
69
72
|
default:
|
|
70
73
|
return {
|
|
71
74
|
networkId: 'mainnet',
|
|
72
|
-
nodeUrl: 'https://rpc.mainnet.near.org',
|
|
75
|
+
nodeUrl: nodeUrl || 'https://rpc.mainnet.near.org',
|
|
73
76
|
walletUrl: 'https://wallet.near.org',
|
|
74
77
|
REF_FI_CONTRACT_ID: 'v2.ref-finance.near',
|
|
75
78
|
WRAP_NEAR_CONTRACT_ID: 'wrap.near',
|
|
@@ -612,7 +615,9 @@
|
|
|
612
615
|
var out_token_idx = stablePool.token_account_ids.findIndex(function (id) {
|
|
613
616
|
return id === tokenOutId;
|
|
614
617
|
});
|
|
615
|
-
var rates = stablePool.
|
|
618
|
+
var rates = stablePool != null && stablePool.degens ? stablePool.degens.map(function (r) {
|
|
619
|
+
return toReadableNumber(STABLE_LP_TOKEN_DECIMALS, r);
|
|
620
|
+
}) : stablePool.rates.map(function (r) {
|
|
616
621
|
return toReadableNumber(STABLE_LP_TOKEN_DECIMALS, r);
|
|
617
622
|
});
|
|
618
623
|
var base_old_c_amounts = stablePool.c_amounts.map(function (amount) {
|
|
@@ -2940,7 +2945,7 @@
|
|
|
2940
2945
|
var tmpPool1 = poolPair[0],
|
|
2941
2946
|
tmpPool2 = poolPair[1];
|
|
2942
2947
|
var tokenMidId = poolPair[0].tokenIds.find(function (t) {
|
|
2943
|
-
return poolPair[1].tokenIds.includes(t);
|
|
2948
|
+
return poolPair[1].tokenIds.includes(t) && t !== tokenIn.id && t !== tokenOut.id;
|
|
2944
2949
|
});
|
|
2945
2950
|
var tokenMidMeta = tokensMedata[tokenMidId];
|
|
2946
2951
|
var estimate1 = _extends({}, isStablePool(stablePoolsDetail, tmpPool1.id) ? getStablePoolEstimate({
|
|
@@ -3014,7 +3019,7 @@
|
|
|
3014
3019
|
pool1 = BestPoolPair[0];
|
|
3015
3020
|
pool2 = BestPoolPair[1];
|
|
3016
3021
|
tokenMidId = BestPoolPair[0].tokenIds.find(function (t) {
|
|
3017
|
-
return BestPoolPair[1].tokenIds.includes(t);
|
|
3022
|
+
return BestPoolPair[1].tokenIds.includes(t) && t !== tokenIn.id && t !== tokenOut.id;
|
|
3018
3023
|
});
|
|
3019
3024
|
_context3.t0 = allTokens[tokenMidId];
|
|
3020
3025
|
if (_context3.t0) {
|
|
@@ -3230,7 +3235,7 @@
|
|
|
3230
3235
|
}).includes(poolId.toString());
|
|
3231
3236
|
};
|
|
3232
3237
|
var getStablePoolDecimal = function getStablePoolDecimal(stablePool) {
|
|
3233
|
-
return stablePool.pool_kind === 'RATED_SWAP' ? RATED_POOL_LP_TOKEN_DECIMALS : STABLE_LP_TOKEN_DECIMALS;
|
|
3238
|
+
return stablePool.pool_kind === 'RATED_SWAP' || stablePool.pool_kind === 'DEGEN_SWAP' ? RATED_POOL_LP_TOKEN_DECIMALS : STABLE_LP_TOKEN_DECIMALS;
|
|
3234
3239
|
};
|
|
3235
3240
|
var round = function round(decimals, minAmountOut) {
|
|
3236
3241
|
return Number.isInteger(Number(minAmountOut)) ? minAmountOut : Math.ceil(Math.round(Number(minAmountOut) * Math.pow(10, decimals)) / Math.pow(10, decimals)).toString();
|
|
@@ -3910,11 +3915,11 @@
|
|
|
3910
3915
|
keyStore: /*#__PURE__*/getKeyStore(),
|
|
3911
3916
|
headers: {}
|
|
3912
3917
|
}, /*#__PURE__*/getConfig()));
|
|
3913
|
-
var init_env = function init_env(env, indexerUrl) {
|
|
3918
|
+
var init_env = function init_env(env, indexerUrl, nodeUrl) {
|
|
3914
3919
|
near = new nearApiJs.Near(_extends({
|
|
3915
3920
|
keyStore: getKeyStore(),
|
|
3916
3921
|
headers: {}
|
|
3917
|
-
}, getConfig(env, indexerUrl)));
|
|
3922
|
+
}, getConfig(env, indexerUrl, nodeUrl)));
|
|
3918
3923
|
return switchEnv();
|
|
3919
3924
|
};
|
|
3920
3925
|
var refFiViewFunction = /*#__PURE__*/function () {
|
|
@@ -4541,7 +4546,7 @@
|
|
|
4541
4546
|
id: Number(id),
|
|
4542
4547
|
pool_kind: 'RATED_SWAP'
|
|
4543
4548
|
});
|
|
4544
|
-
}));
|
|
4549
|
+
})["catch"](function () {}));
|
|
4545
4550
|
case 2:
|
|
4546
4551
|
case "end":
|
|
4547
4552
|
return _context.stop();
|
|
@@ -4574,7 +4579,7 @@
|
|
|
4574
4579
|
return toNonDivisibleNumber(STABLE_LP_TOKEN_DECIMALS, '1');
|
|
4575
4580
|
})
|
|
4576
4581
|
});
|
|
4577
|
-
}));
|
|
4582
|
+
})["catch"](function () {}));
|
|
4578
4583
|
case 2:
|
|
4579
4584
|
case "end":
|
|
4580
4585
|
return _context2.stop();
|
|
@@ -4607,7 +4612,7 @@
|
|
|
4607
4612
|
return toNonDivisibleNumber(STABLE_LP_TOKEN_DECIMALS, '1');
|
|
4608
4613
|
})
|
|
4609
4614
|
});
|
|
4610
|
-
}));
|
|
4615
|
+
})["catch"](function () {}));
|
|
4611
4616
|
case 2:
|
|
4612
4617
|
case "end":
|
|
4613
4618
|
return _context3.stop();
|
|
@@ -4621,11 +4626,13 @@
|
|
|
4621
4626
|
}();
|
|
4622
4627
|
var getStablePools = /*#__PURE__*/function () {
|
|
4623
4628
|
var _ref7 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(stablePools) {
|
|
4629
|
+
var res;
|
|
4624
4630
|
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
4625
4631
|
while (1) {
|
|
4626
4632
|
switch (_context4.prev = _context4.next) {
|
|
4627
4633
|
case 0:
|
|
4628
|
-
|
|
4634
|
+
_context4.next = 2;
|
|
4635
|
+
return Promise.allSettled(stablePools.map(function (pool) {
|
|
4629
4636
|
return pool.pool_kind === 'RATED_SWAP' ? getRatedPoolDetail({
|
|
4630
4637
|
id: pool.id
|
|
4631
4638
|
}) : pool.pool_kind === 'DEGEN_SWAP' ? getDegenPoolDetail({
|
|
@@ -4633,8 +4640,16 @@
|
|
|
4633
4640
|
}) : pool.pool_kind === 'STABLE_SWAP' ? getUnRatedPoolDetail({
|
|
4634
4641
|
id: pool.id
|
|
4635
4642
|
}) : getPool(pool.id);
|
|
4636
|
-
}))
|
|
4637
|
-
case
|
|
4643
|
+
}));
|
|
4644
|
+
case 2:
|
|
4645
|
+
res = _context4.sent;
|
|
4646
|
+
return _context4.abrupt("return", res.reduce(function (acc, cur) {
|
|
4647
|
+
if (cur.status === 'fulfilled' && cur.value) {
|
|
4648
|
+
return [].concat(acc || [], [cur.value]);
|
|
4649
|
+
}
|
|
4650
|
+
return acc;
|
|
4651
|
+
}, []));
|
|
4652
|
+
case 4:
|
|
4638
4653
|
case "end":
|
|
4639
4654
|
return _context4.stop();
|
|
4640
4655
|
}
|
|
@@ -4659,7 +4674,7 @@
|
|
|
4659
4674
|
}
|
|
4660
4675
|
}).then(function (pool) {
|
|
4661
4676
|
return parsePool(pool, id);
|
|
4662
|
-
});
|
|
4677
|
+
})["catch"]();
|
|
4663
4678
|
case 2:
|
|
4664
4679
|
return _context5.abrupt("return", _context5.sent);
|
|
4665
4680
|
case 3:
|