@openocean.finance/openocean-sdk 1.2.7 → 1.2.9
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/lib/api/index.d.ts +3 -3
- package/lib/index.js +2 -50
- package/lib/index.js.LICENSE.txt +1 -25
- package/lib/swapSdk/Approve.d.ts +1 -1
- package/lib/swapSdk/RequestVo.d.ts +1 -1
- package/lib/v1/constants.d.ts +1 -1
- package/package.json +4 -4
- package/lib/api/index.js +0 -139
- package/lib/api/vo/RequestVo.js +0 -398
- package/lib/asset/abi/ERC20_abi.js +0 -119
- package/lib/asset/abi/aggregator.js +0 -391
- package/lib/config/index.js +0 -33
- package/lib/swapSdk/Approve.js +0 -342
- package/lib/swapSdk/NotoMobile.js +0 -141
- package/lib/swapSdk/RequestVo.js +0 -94
- package/lib/swapSdk/Swap.js +0 -1123
- package/lib/swapSdk/getAllowance.js +0 -97
- package/lib/swapSdk/getBalance.js +0 -280
- package/lib/swapSdk/index.js +0 -257
- package/lib/swapSdk/qrcode.js +0 -969
- package/lib/utils/ajx.js +0 -150
- package/lib/utils/index.js +0 -369
- package/lib/utils/web3.js +0 -9
- package/lib/v1/abis/ERC20.js +0 -22
- package/lib/v1/abis/IUniswapV2Pair.js +0 -1434
- package/lib/v1/constants.js +0 -71
- package/lib/v1/entities/currency.js +0 -39
- package/lib/v1/entities/fractions/currencyAmount.js +0 -83
- package/lib/v1/entities/fractions/fraction.js +0 -109
- package/lib/v1/entities/fractions/index.js +0 -21
- package/lib/v1/entities/fractions/percent.js +0 -37
- package/lib/v1/entities/fractions/price.js +0 -90
- package/lib/v1/entities/fractions/tokenAmount.js +0 -43
- package/lib/v1/entities/index.js +0 -22
- package/lib/v1/entities/pair.js +0 -210
- package/lib/v1/entities/route.js +0 -43
- package/lib/v1/entities/token.js +0 -87
- package/lib/v1/entities/trade.js +0 -336
- package/lib/v1/errors.js +0 -56
- package/lib/v1/fetcher.js +0 -140
- package/lib/v1/router.js +0 -97
- package/lib/v1/utils.js +0 -87
package/lib/v1/utils.js
DELETED
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.sortedInsert = exports.sqrt = exports.parseBigintIsh = exports.validateAndParseAddress = exports.validateSolidityTypeInstance = void 0;
|
|
7
|
-
var tiny_invariant_1 = __importDefault(require("tiny-invariant"));
|
|
8
|
-
var tiny_warning_1 = __importDefault(require("tiny-warning"));
|
|
9
|
-
var jsbi_1 = __importDefault(require("jsbi"));
|
|
10
|
-
var address_1 = require("@ethersproject/address");
|
|
11
|
-
var constants_1 = require("./constants");
|
|
12
|
-
function validateSolidityTypeInstance(value, solidityType) {
|
|
13
|
-
(0, tiny_invariant_1.default)(jsbi_1.default.greaterThanOrEqual(value, constants_1.ZERO), "".concat(value, " is not a ").concat(solidityType, "."));
|
|
14
|
-
(0, tiny_invariant_1.default)(jsbi_1.default.lessThanOrEqual(value, constants_1.SOLIDITY_TYPE_MAXIMA[solidityType]), "".concat(value, " is not a ").concat(solidityType, "."));
|
|
15
|
-
}
|
|
16
|
-
exports.validateSolidityTypeInstance = validateSolidityTypeInstance;
|
|
17
|
-
// warns if addresses are not checksummed
|
|
18
|
-
function validateAndParseAddress(address) {
|
|
19
|
-
try {
|
|
20
|
-
var checksummedAddress = (0, address_1.getAddress)(address);
|
|
21
|
-
(0, tiny_warning_1.default)(address === checksummedAddress, "".concat(address, " is not checksummed."));
|
|
22
|
-
return checksummedAddress;
|
|
23
|
-
}
|
|
24
|
-
catch (error) {
|
|
25
|
-
(0, tiny_invariant_1.default)(false, "".concat(address, " is not a valid address."));
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
exports.validateAndParseAddress = validateAndParseAddress;
|
|
29
|
-
function parseBigintIsh(bigintIsh) {
|
|
30
|
-
return bigintIsh instanceof jsbi_1.default
|
|
31
|
-
? bigintIsh
|
|
32
|
-
: typeof bigintIsh === 'bigint'
|
|
33
|
-
? jsbi_1.default.BigInt(bigintIsh.toString())
|
|
34
|
-
: jsbi_1.default.BigInt(bigintIsh);
|
|
35
|
-
}
|
|
36
|
-
exports.parseBigintIsh = parseBigintIsh;
|
|
37
|
-
// mock the on-chain sqrt function
|
|
38
|
-
function sqrt(y) {
|
|
39
|
-
validateSolidityTypeInstance(y, constants_1.SolidityType.uint256);
|
|
40
|
-
var z = constants_1.ZERO;
|
|
41
|
-
var x;
|
|
42
|
-
if (jsbi_1.default.greaterThan(y, constants_1.THREE)) {
|
|
43
|
-
z = y;
|
|
44
|
-
x = jsbi_1.default.add(jsbi_1.default.divide(y, constants_1.TWO), constants_1.ONE);
|
|
45
|
-
while (jsbi_1.default.lessThan(x, z)) {
|
|
46
|
-
z = x;
|
|
47
|
-
x = jsbi_1.default.divide(jsbi_1.default.add(jsbi_1.default.divide(y, x), x), constants_1.TWO);
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
else if (jsbi_1.default.notEqual(y, constants_1.ZERO)) {
|
|
51
|
-
z = constants_1.ONE;
|
|
52
|
-
}
|
|
53
|
-
return z;
|
|
54
|
-
}
|
|
55
|
-
exports.sqrt = sqrt;
|
|
56
|
-
// given an array of items sorted by `comparator`, insert an item into its sort index and constrain the size to
|
|
57
|
-
// `maxSize` by removing the last item
|
|
58
|
-
function sortedInsert(items, add, maxSize, comparator) {
|
|
59
|
-
(0, tiny_invariant_1.default)(maxSize > 0, 'MAX_SIZE_ZERO');
|
|
60
|
-
// this is an invariant because the interface cannot return multiple removed items if items.length exceeds maxSize
|
|
61
|
-
(0, tiny_invariant_1.default)(items.length <= maxSize, 'ITEMS_SIZE');
|
|
62
|
-
// short circuit first item add
|
|
63
|
-
if (items.length === 0) {
|
|
64
|
-
items.push(add);
|
|
65
|
-
return null;
|
|
66
|
-
}
|
|
67
|
-
else {
|
|
68
|
-
var isFull = items.length === maxSize;
|
|
69
|
-
// short circuit if full and the additional item does not come before the last item
|
|
70
|
-
if (isFull && comparator(items[items.length - 1], add) <= 0) {
|
|
71
|
-
return add;
|
|
72
|
-
}
|
|
73
|
-
var lo = 0, hi = items.length;
|
|
74
|
-
while (lo < hi) {
|
|
75
|
-
var mid = (lo + hi) >>> 1;
|
|
76
|
-
if (comparator(items[mid], add) <= 0) {
|
|
77
|
-
lo = mid + 1;
|
|
78
|
-
}
|
|
79
|
-
else {
|
|
80
|
-
hi = mid;
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
items.splice(lo, 0, add);
|
|
84
|
-
return isFull ? items.pop() : null;
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
exports.sortedInsert = sortedInsert;
|