@uniswap/sdk-core 4.1.4 → 4.2.1-beta.1
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 +0 -2
- package/dist/chains.d.ts +4 -3
- package/dist/sdk-core.cjs.development.js +102 -216
- package/dist/sdk-core.cjs.development.js.map +1 -1
- package/dist/sdk-core.cjs.production.min.js +1 -1
- package/dist/sdk-core.cjs.production.min.js.map +1 -1
- package/dist/sdk-core.esm.js +102 -219
- package/dist/sdk-core.esm.js.map +1 -1
- package/package.json +51 -14
package/dist/sdk-core.esm.js
CHANGED
|
@@ -6,48 +6,65 @@ import toFormat from 'toformat';
|
|
|
6
6
|
import { BigNumber } from '@ethersproject/bignumber';
|
|
7
7
|
import { getAddress } from '@ethersproject/address';
|
|
8
8
|
|
|
9
|
+
function _toPrimitive(t, r) {
|
|
10
|
+
if ("object" != typeof t || !t) return t;
|
|
11
|
+
var e = t[Symbol.toPrimitive];
|
|
12
|
+
if (void 0 !== e) {
|
|
13
|
+
var i = e.call(t, r || "default");
|
|
14
|
+
if ("object" != typeof i) return i;
|
|
15
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
16
|
+
}
|
|
17
|
+
return ("string" === r ? String : Number)(t);
|
|
18
|
+
}
|
|
19
|
+
function _toPropertyKey(t) {
|
|
20
|
+
var i = _toPrimitive(t, "string");
|
|
21
|
+
return "symbol" == typeof i ? i : String(i);
|
|
22
|
+
}
|
|
9
23
|
function _defineProperties(target, props) {
|
|
10
24
|
for (var i = 0; i < props.length; i++) {
|
|
11
25
|
var descriptor = props[i];
|
|
12
26
|
descriptor.enumerable = descriptor.enumerable || false;
|
|
13
27
|
descriptor.configurable = true;
|
|
14
28
|
if ("value" in descriptor) descriptor.writable = true;
|
|
15
|
-
Object.defineProperty(target, descriptor.key, descriptor);
|
|
29
|
+
Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor);
|
|
16
30
|
}
|
|
17
31
|
}
|
|
18
|
-
|
|
19
32
|
function _createClass(Constructor, protoProps, staticProps) {
|
|
20
33
|
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
21
34
|
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
35
|
+
Object.defineProperty(Constructor, "prototype", {
|
|
36
|
+
writable: false
|
|
37
|
+
});
|
|
22
38
|
return Constructor;
|
|
23
39
|
}
|
|
24
|
-
|
|
25
40
|
function _extends() {
|
|
26
|
-
_extends = Object.assign
|
|
41
|
+
_extends = Object.assign ? Object.assign.bind() : function (target) {
|
|
27
42
|
for (var i = 1; i < arguments.length; i++) {
|
|
28
43
|
var source = arguments[i];
|
|
29
|
-
|
|
30
44
|
for (var key in source) {
|
|
31
45
|
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
32
46
|
target[key] = source[key];
|
|
33
47
|
}
|
|
34
48
|
}
|
|
35
49
|
}
|
|
36
|
-
|
|
37
50
|
return target;
|
|
38
51
|
};
|
|
39
|
-
|
|
40
52
|
return _extends.apply(this, arguments);
|
|
41
53
|
}
|
|
42
|
-
|
|
43
54
|
function _inheritsLoose(subClass, superClass) {
|
|
44
55
|
subClass.prototype = Object.create(superClass.prototype);
|
|
45
56
|
subClass.prototype.constructor = subClass;
|
|
46
|
-
subClass
|
|
57
|
+
_setPrototypeOf(subClass, superClass);
|
|
58
|
+
}
|
|
59
|
+
function _setPrototypeOf(o, p) {
|
|
60
|
+
_setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
|
|
61
|
+
o.__proto__ = p;
|
|
62
|
+
return o;
|
|
63
|
+
};
|
|
64
|
+
return _setPrototypeOf(o, p);
|
|
47
65
|
}
|
|
48
66
|
|
|
49
67
|
var ChainId;
|
|
50
|
-
|
|
51
68
|
(function (ChainId) {
|
|
52
69
|
ChainId[ChainId["MAINNET"] = 1] = "MAINNET";
|
|
53
70
|
ChainId[ChainId["GOERLI"] = 5] = "GOERLI";
|
|
@@ -71,11 +88,10 @@ var ChainId;
|
|
|
71
88
|
ChainId[ChainId["ZORA"] = 7777777] = "ZORA";
|
|
72
89
|
ChainId[ChainId["ZORA_SEPOLIA"] = 999999999] = "ZORA_SEPOLIA";
|
|
73
90
|
ChainId[ChainId["ROOTSTOCK"] = 30] = "ROOTSTOCK";
|
|
91
|
+
ChainId[ChainId["BLAST"] = 81457] = "BLAST";
|
|
74
92
|
})(ChainId || (ChainId = {}));
|
|
75
|
-
|
|
76
|
-
var SUPPORTED_CHAINS = [ChainId.MAINNET, ChainId.OPTIMISM, ChainId.OPTIMISM_GOERLI, ChainId.OPTIMISM_SEPOLIA, ChainId.ARBITRUM_ONE, ChainId.ARBITRUM_GOERLI, ChainId.ARBITRUM_SEPOLIA, ChainId.POLYGON, ChainId.POLYGON_MUMBAI, ChainId.GOERLI, ChainId.SEPOLIA, ChainId.CELO_ALFAJORES, ChainId.CELO, ChainId.BNB, ChainId.AVALANCHE, ChainId.BASE, ChainId.BASE_GOERLI, ChainId.ZORA, ChainId.ZORA_SEPOLIA, ChainId.ROOTSTOCK];
|
|
93
|
+
var SUPPORTED_CHAINS = [ChainId.MAINNET, ChainId.OPTIMISM, ChainId.OPTIMISM_GOERLI, ChainId.OPTIMISM_SEPOLIA, ChainId.ARBITRUM_ONE, ChainId.ARBITRUM_GOERLI, ChainId.ARBITRUM_SEPOLIA, ChainId.POLYGON, ChainId.POLYGON_MUMBAI, ChainId.GOERLI, ChainId.SEPOLIA, ChainId.CELO_ALFAJORES, ChainId.CELO, ChainId.BNB, ChainId.AVALANCHE, ChainId.BASE, ChainId.BASE_GOERLI, ChainId.ZORA, ChainId.ZORA_SEPOLIA, ChainId.ROOTSTOCK, ChainId.BLAST];
|
|
77
94
|
var NativeCurrencyName;
|
|
78
|
-
|
|
79
95
|
(function (NativeCurrencyName) {
|
|
80
96
|
// Strings match input for CLI
|
|
81
97
|
NativeCurrencyName["ETHER"] = "ETH";
|
|
@@ -90,33 +106,28 @@ var NativeCurrencyName;
|
|
|
90
106
|
|
|
91
107
|
var _V2_FACTORY_ADDRESSES, _V2_ROUTER_ADDRESSES, _CHAIN_TO_ADDRESSES_M, _GOVERNANCE_ALPHA_V1_, _GOVERNANCE_BRAVO_ADD, _MERKLE_DISTRIBUTOR_A, _ARGENT_WALLET_DETECT, _SOCKS_CONTROLLER_ADD;
|
|
92
108
|
var DEFAULT_NETWORKS = [ChainId.MAINNET, ChainId.GOERLI, ChainId.SEPOLIA];
|
|
93
|
-
|
|
94
109
|
function constructSameAddressMap(address, additionalNetworks) {
|
|
95
110
|
if (additionalNetworks === void 0) {
|
|
96
111
|
additionalNetworks = [];
|
|
97
112
|
}
|
|
98
|
-
|
|
99
113
|
return DEFAULT_NETWORKS.concat(additionalNetworks).reduce(function (memo, chainId) {
|
|
100
114
|
memo[chainId] = address;
|
|
101
115
|
return memo;
|
|
102
116
|
}, {});
|
|
103
117
|
}
|
|
104
|
-
|
|
105
118
|
var UNI_ADDRESSES = /*#__PURE__*/constructSameAddressMap('0x1f9840a85d5aF5bf1D1762F925BDADdC4201F984', [ChainId.OPTIMISM, ChainId.ARBITRUM_ONE, ChainId.POLYGON, ChainId.POLYGON_MUMBAI, ChainId.SEPOLIA]);
|
|
106
119
|
var UNISWAP_NFT_AIRDROP_CLAIM_ADDRESS = '0x8B799381ac40b838BBA4131ffB26197C432AFe78';
|
|
107
120
|
/**
|
|
108
121
|
* @deprecated use V2_FACTORY_ADDRESSES instead
|
|
109
122
|
*/
|
|
110
|
-
|
|
111
123
|
var V2_FACTORY_ADDRESS = '0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f';
|
|
112
|
-
var V2_FACTORY_ADDRESSES = (_V2_FACTORY_ADDRESSES = {}, _V2_FACTORY_ADDRESSES[ChainId.MAINNET] = '0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f', _V2_FACTORY_ADDRESSES[ChainId.GOERLI] = '0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f', _V2_FACTORY_ADDRESSES[ChainId.SEPOLIA] = '
|
|
124
|
+
var V2_FACTORY_ADDRESSES = (_V2_FACTORY_ADDRESSES = {}, _V2_FACTORY_ADDRESSES[ChainId.MAINNET] = '0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f', _V2_FACTORY_ADDRESSES[ChainId.GOERLI] = '0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f', _V2_FACTORY_ADDRESSES[ChainId.SEPOLIA] = '0xB7f907f7A9eBC822a80BD25E224be42Ce0A698A0', _V2_FACTORY_ADDRESSES[ChainId.OPTIMISM] = '0x0c3c1c532F1e39EdF36BE9Fe0bE1410313E074Bf', _V2_FACTORY_ADDRESSES[ChainId.ARBITRUM_ONE] = '0xf1D7CC64Fb4452F05c498126312eBE29f30Fbcf9', _V2_FACTORY_ADDRESSES[ChainId.AVALANCHE] = '0x9e5A52f57b3038F1B8EeE45F28b3C1967e22799C', _V2_FACTORY_ADDRESSES[ChainId.BASE] = '0x8909dc15e40173ff4699343b6eb8132c65e18ec6', _V2_FACTORY_ADDRESSES[ChainId.BNB] = '0x8909Dc15e40173Ff4699343b6eB8132c65e18eC6', _V2_FACTORY_ADDRESSES[ChainId.POLYGON] = '0x9e5A52f57b3038F1B8EeE45F28b3C1967e22799C', _V2_FACTORY_ADDRESSES[ChainId.CELO] = '0x79a530c8e2fA8748B7B40dd3629C0520c2cCf03f', _V2_FACTORY_ADDRESSES[ChainId.BLAST] = '0x5C346464d33F90bABaf70dB6388507CC889C1070', _V2_FACTORY_ADDRESSES);
|
|
113
125
|
/**
|
|
114
126
|
* @deprecated use V2_ROUTER_ADDRESSES instead
|
|
115
127
|
*/
|
|
116
|
-
|
|
117
128
|
var V2_ROUTER_ADDRESS = '0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D';
|
|
118
|
-
var V2_ROUTER_ADDRESSES = (_V2_ROUTER_ADDRESSES = {}, _V2_ROUTER_ADDRESSES[ChainId.MAINNET] = '0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D', _V2_ROUTER_ADDRESSES[ChainId.GOERLI] = '0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D', _V2_ROUTER_ADDRESSES[ChainId.
|
|
119
|
-
|
|
129
|
+
var V2_ROUTER_ADDRESSES = (_V2_ROUTER_ADDRESSES = {}, _V2_ROUTER_ADDRESSES[ChainId.MAINNET] = '0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D', _V2_ROUTER_ADDRESSES[ChainId.GOERLI] = '0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D', _V2_ROUTER_ADDRESSES[ChainId.ARBITRUM_ONE] = '0x4752ba5dbc23f44d87826276bf6fd6b1c372ad24', _V2_ROUTER_ADDRESSES[ChainId.OPTIMISM] = '0x4a7b5da61326a6379179b40d00f57e5bbdc962c2', _V2_ROUTER_ADDRESSES[ChainId.BASE] = '0x4752ba5dbc23f44d87826276bf6fd6b1c372ad24', _V2_ROUTER_ADDRESSES[ChainId.AVALANCHE] = '0x4752ba5dbc23f44d87826276bf6fd6b1c372ad24', _V2_ROUTER_ADDRESSES[ChainId.BNB] = '0x4752ba5dbc23f44d87826276bf6fd6b1c372ad24', _V2_ROUTER_ADDRESSES[ChainId.POLYGON] = '0xedf6066a2b290c185783862c7f4776a2c8077ad1', _V2_ROUTER_ADDRESSES[ChainId.BLAST] = '0xBB66Eb1c5e875933D44DAe661dbD80e5D9B03035', _V2_ROUTER_ADDRESSES);
|
|
130
|
+
// Networks that share most of the same addresses i.e. Mainnet, Goerli, Optimism, Arbitrum, Polygon
|
|
120
131
|
var DEFAULT_ADDRESSES = {
|
|
121
132
|
v3CoreFactoryAddress: '0x1F98431c8aD98523631AE4a59f267346ea31F984',
|
|
122
133
|
multicallAddress: '0x1F98415757620B543A52E61c46B32eB19261F984',
|
|
@@ -124,24 +135,19 @@ var DEFAULT_ADDRESSES = {
|
|
|
124
135
|
v3MigratorAddress: '0xA5644E29708357803b5A882D272c41cC0dF92B34',
|
|
125
136
|
nonfungiblePositionManagerAddress: '0xC36442b4a4522E871399CD717aBDD847Ab11FE88'
|
|
126
137
|
};
|
|
127
|
-
|
|
128
138
|
var MAINNET_ADDRESSES = /*#__PURE__*/_extends({}, DEFAULT_ADDRESSES, {
|
|
129
139
|
v1MixedRouteQuoterAddress: '0x84E44095eeBfEC7793Cd7d5b57B7e401D7f1cA2E'
|
|
130
140
|
});
|
|
131
|
-
|
|
132
141
|
var GOERLI_ADDRESSES = /*#__PURE__*/_extends({}, DEFAULT_ADDRESSES, {
|
|
133
142
|
v1MixedRouteQuoterAddress: '0xBa60b6e6fF25488308789E6e0A65D838be34194e'
|
|
134
143
|
});
|
|
135
|
-
|
|
136
144
|
var OPTIMISM_ADDRESSES = DEFAULT_ADDRESSES;
|
|
137
|
-
|
|
138
145
|
var ARBITRUM_ONE_ADDRESSES = /*#__PURE__*/_extends({}, DEFAULT_ADDRESSES, {
|
|
139
146
|
multicallAddress: '0xadF885960B47eA2CD9B55E6DAc6B42b7Cb2806dB',
|
|
140
147
|
tickLensAddress: '0xbfd8137f7d1516D3ea5cA83523914859ec47F573'
|
|
141
148
|
});
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
149
|
+
var POLYGON_ADDRESSES = DEFAULT_ADDRESSES;
|
|
150
|
+
// celo v3 addresses
|
|
145
151
|
var CELO_ADDRESSES = {
|
|
146
152
|
v3CoreFactoryAddress: '0xAfE208a311B21f13EF87E33A90049fC17A7acDEc',
|
|
147
153
|
multicallAddress: '0x633987602DE5C4F337e3DbF265303A1080324204',
|
|
@@ -149,8 +155,8 @@ var CELO_ADDRESSES = {
|
|
|
149
155
|
v3MigratorAddress: '0x3cFd4d48EDfDCC53D3f173F596f621064614C582',
|
|
150
156
|
nonfungiblePositionManagerAddress: '0x3d79EdAaBC0EaB6F08ED885C05Fc0B014290D95A',
|
|
151
157
|
tickLensAddress: '0x5f115D9113F88e0a0Db1b5033D90D4a9690AcD3D'
|
|
152
|
-
};
|
|
153
|
-
|
|
158
|
+
};
|
|
159
|
+
// BNB v3 addresses
|
|
154
160
|
var BNB_ADDRESSES = {
|
|
155
161
|
v3CoreFactoryAddress: '0xdB1d10011AD0Ff90774D0C6Bb92e5C5c8b4461F7',
|
|
156
162
|
multicallAddress: '0x963Df249eD09c358A4819E39d9Cd5736c3087184',
|
|
@@ -159,8 +165,8 @@ var BNB_ADDRESSES = {
|
|
|
159
165
|
nonfungiblePositionManagerAddress: '0x7b8A01B39D58278b5DE7e48c8449c9f4F5170613',
|
|
160
166
|
tickLensAddress: '0xD9270014D396281579760619CCf4c3af0501A47C',
|
|
161
167
|
swapRouter02Address: '0xB971eF87ede563556b2ED4b1C0b0019111Dd85d2'
|
|
162
|
-
};
|
|
163
|
-
|
|
168
|
+
};
|
|
169
|
+
// optimism goerli addresses
|
|
164
170
|
var OPTIMISM_GOERLI_ADDRESSES = {
|
|
165
171
|
v3CoreFactoryAddress: '0xB656dA17129e7EB733A557f4EBc57B76CFbB5d10',
|
|
166
172
|
multicallAddress: '0x07F2D8a2a02251B62af965f22fC4744A5f96BCCd',
|
|
@@ -168,8 +174,8 @@ var OPTIMISM_GOERLI_ADDRESSES = {
|
|
|
168
174
|
v3MigratorAddress: '0xf6c55fBe84B1C8c3283533c53F51bC32F5C7Aba8',
|
|
169
175
|
nonfungiblePositionManagerAddress: '0x39Ca85Af2F383190cBf7d7c41ED9202D27426EF6',
|
|
170
176
|
tickLensAddress: '0xe6140Bd164b63E8BfCfc40D5dF952f83e171758e'
|
|
171
|
-
};
|
|
172
|
-
|
|
177
|
+
};
|
|
178
|
+
// optimism sepolia addresses
|
|
173
179
|
var OPTIMISM_SEPOLIA_ADDRESSES = {
|
|
174
180
|
v3CoreFactoryAddress: '0x8CE191193D15ea94e11d327b4c7ad8bbE520f6aF',
|
|
175
181
|
multicallAddress: '0x80e4e06841bb76AA9735E0448cB8d003C0EF009a',
|
|
@@ -178,8 +184,8 @@ var OPTIMISM_SEPOLIA_ADDRESSES = {
|
|
|
178
184
|
nonfungiblePositionManagerAddress: '0xdA75cEf1C93078e8b736FCA5D5a30adb97C8957d',
|
|
179
185
|
tickLensAddress: '0xCb7f54747F58F8944973cea5b8f4ac2209BadDC5',
|
|
180
186
|
swapRouter02Address: '0x94cC0AaC535CCDB3C01d6787D6413C739ae12bc4'
|
|
181
|
-
};
|
|
182
|
-
|
|
187
|
+
};
|
|
188
|
+
// arbitrum goerli v3 addresses
|
|
183
189
|
var ARBITRUM_GOERLI_ADDRESSES = {
|
|
184
190
|
v3CoreFactoryAddress: '0x4893376342d5D7b3e31d4184c08b265e5aB2A3f6',
|
|
185
191
|
multicallAddress: '0x8260CB40247290317a4c062F3542622367F206Ee',
|
|
@@ -187,8 +193,8 @@ var ARBITRUM_GOERLI_ADDRESSES = {
|
|
|
187
193
|
v3MigratorAddress: '0xA815919D2584Ac3F76ea9CB62E6Fd40a43BCe0C3',
|
|
188
194
|
nonfungiblePositionManagerAddress: '0x622e4726a167799826d1E1D150b076A7725f5D81',
|
|
189
195
|
tickLensAddress: '0xb52429333da969a0C79a60930a4Bf0020E5D1DE8'
|
|
190
|
-
};
|
|
191
|
-
|
|
196
|
+
};
|
|
197
|
+
// arbitrum sepolia v3 addresses
|
|
192
198
|
var ARBITRUM_SEPOLIA_ADDRESSES = {
|
|
193
199
|
v3CoreFactoryAddress: '0x248AB79Bbb9bC29bB72f7Cd42F17e054Fc40188e',
|
|
194
200
|
multicallAddress: '0x2B718b475e385eD29F56775a66aAB1F5cC6B2A0A',
|
|
@@ -197,8 +203,8 @@ var ARBITRUM_SEPOLIA_ADDRESSES = {
|
|
|
197
203
|
nonfungiblePositionManagerAddress: '0x6b2937Bde17889EDCf8fbD8dE31C3C2a70Bc4d65',
|
|
198
204
|
tickLensAddress: '0x0fd18587734e5C2dcE2dccDcC7DD1EC89ba557d9',
|
|
199
205
|
swapRouter02Address: '0x101F443B4d1b059569D643917553c771E1b9663E'
|
|
200
|
-
};
|
|
201
|
-
|
|
206
|
+
};
|
|
207
|
+
// sepolia v3 addresses
|
|
202
208
|
var SEPOLIA_ADDRESSES = {
|
|
203
209
|
v3CoreFactoryAddress: '0x0227628f3F023bb0B980b67D528571c95c6DaC1c',
|
|
204
210
|
multicallAddress: '0xD7F33bCdb21b359c8ee6F0251d30E94832baAd07',
|
|
@@ -207,8 +213,8 @@ var SEPOLIA_ADDRESSES = {
|
|
|
207
213
|
nonfungiblePositionManagerAddress: '0x1238536071E1c677A632429e3655c799b22cDA52',
|
|
208
214
|
tickLensAddress: '0xd7f33bcdb21b359c8ee6f0251d30e94832baad07',
|
|
209
215
|
swapRouter02Address: '0x3bFA4769FB09eefC5a80d6E87c3B9C650f7Ae48E'
|
|
210
|
-
};
|
|
211
|
-
|
|
216
|
+
};
|
|
217
|
+
// Avalanche v3 addresses
|
|
212
218
|
var AVALANCHE_ADDRESSES = {
|
|
213
219
|
v3CoreFactoryAddress: '0x740b1c1de25031C31FF4fC9A62f554A55cdC1baD',
|
|
214
220
|
multicallAddress: '0x0139141Cd4Ee88dF3Cdb65881D411bAE271Ef0C2',
|
|
@@ -226,8 +232,8 @@ var BASE_ADDRESSES = {
|
|
|
226
232
|
nonfungiblePositionManagerAddress: '0x03a520b32C04BF3bEEf7BEb72E919cf822Ed34f1',
|
|
227
233
|
tickLensAddress: '0x0CdeE061c75D43c82520eD998C23ac2991c9ac6d',
|
|
228
234
|
swapRouter02Address: '0x2626664c2603336E57B271c5C0b26F421741e481'
|
|
229
|
-
};
|
|
230
|
-
|
|
235
|
+
};
|
|
236
|
+
// Base Goerli v3 addresses
|
|
231
237
|
var BASE_GOERLI_ADDRESSES = {
|
|
232
238
|
v3CoreFactoryAddress: '0x9323c1d6D800ed51Bd7C6B216cfBec678B7d0BC2',
|
|
233
239
|
multicallAddress: '0xB206027a9E0E13F05eBEFa5D2402Bab3eA716439',
|
|
@@ -263,20 +269,26 @@ var ROOTSTOCK_ADDRESSES = {
|
|
|
263
269
|
tickLensAddress: '0x55B9dF5bF68ADe972191a91980459f48ecA16afC',
|
|
264
270
|
swapRouter02Address: '0x0B14ff67f0014046b4b99057Aec4509640b3947A'
|
|
265
271
|
};
|
|
266
|
-
var
|
|
272
|
+
var BLAST_ADDRESSES = {
|
|
273
|
+
v3CoreFactoryAddress: '0x792edAdE80af5fC680d96a2eD80A44247D2Cf6Fd',
|
|
274
|
+
multicallAddress: '0xdC7f370de7631cE9e2c2e1DCDA6B3B5744Cf4705',
|
|
275
|
+
quoterAddress: '0x6Cdcd65e03c1CEc3730AeeCd45bc140D57A25C77',
|
|
276
|
+
v3MigratorAddress: '0x15CA7043CD84C5D21Ae76Ba0A1A967d42c40ecE0',
|
|
277
|
+
nonfungiblePositionManagerAddress: '0xB218e4f7cF0533d4696fDfC419A0023D33345F28',
|
|
278
|
+
tickLensAddress: '0x2E95185bCdD928a3e984B7e2D6560Ab1b17d7274',
|
|
279
|
+
swapRouter02Address: '0x549FEB8c9bd4c12Ad2AB27022dA12492aC452B66'
|
|
280
|
+
};
|
|
281
|
+
var CHAIN_TO_ADDRESSES_MAP = (_CHAIN_TO_ADDRESSES_M = {}, _CHAIN_TO_ADDRESSES_M[ChainId.MAINNET] = MAINNET_ADDRESSES, _CHAIN_TO_ADDRESSES_M[ChainId.OPTIMISM] = OPTIMISM_ADDRESSES, _CHAIN_TO_ADDRESSES_M[ChainId.ARBITRUM_ONE] = ARBITRUM_ONE_ADDRESSES, _CHAIN_TO_ADDRESSES_M[ChainId.POLYGON] = POLYGON_ADDRESSES, _CHAIN_TO_ADDRESSES_M[ChainId.POLYGON_MUMBAI] = POLYGON_ADDRESSES, _CHAIN_TO_ADDRESSES_M[ChainId.GOERLI] = GOERLI_ADDRESSES, _CHAIN_TO_ADDRESSES_M[ChainId.CELO] = CELO_ADDRESSES, _CHAIN_TO_ADDRESSES_M[ChainId.CELO_ALFAJORES] = CELO_ADDRESSES, _CHAIN_TO_ADDRESSES_M[ChainId.BNB] = BNB_ADDRESSES, _CHAIN_TO_ADDRESSES_M[ChainId.OPTIMISM_GOERLI] = OPTIMISM_GOERLI_ADDRESSES, _CHAIN_TO_ADDRESSES_M[ChainId.OPTIMISM_SEPOLIA] = OPTIMISM_SEPOLIA_ADDRESSES, _CHAIN_TO_ADDRESSES_M[ChainId.ARBITRUM_GOERLI] = ARBITRUM_GOERLI_ADDRESSES, _CHAIN_TO_ADDRESSES_M[ChainId.ARBITRUM_SEPOLIA] = ARBITRUM_SEPOLIA_ADDRESSES, _CHAIN_TO_ADDRESSES_M[ChainId.SEPOLIA] = SEPOLIA_ADDRESSES, _CHAIN_TO_ADDRESSES_M[ChainId.AVALANCHE] = AVALANCHE_ADDRESSES, _CHAIN_TO_ADDRESSES_M[ChainId.BASE] = BASE_ADDRESSES, _CHAIN_TO_ADDRESSES_M[ChainId.BASE_GOERLI] = BASE_GOERLI_ADDRESSES, _CHAIN_TO_ADDRESSES_M[ChainId.ZORA] = ZORA_ADDRESSES, _CHAIN_TO_ADDRESSES_M[ChainId.ZORA_SEPOLIA] = ZORA_SEPOLIA_ADDRESSES, _CHAIN_TO_ADDRESSES_M[ChainId.ROOTSTOCK] = ROOTSTOCK_ADDRESSES, _CHAIN_TO_ADDRESSES_M[ChainId.BLAST] = BLAST_ADDRESSES, _CHAIN_TO_ADDRESSES_M);
|
|
267
282
|
/* V3 Contract Addresses */
|
|
268
|
-
|
|
269
283
|
var V3_CORE_FACTORY_ADDRESSES = /*#__PURE__*/_extends({}, /*#__PURE__*/SUPPORTED_CHAINS.reduce(function (memo, chainId) {
|
|
270
284
|
memo[chainId] = CHAIN_TO_ADDRESSES_MAP[chainId].v3CoreFactoryAddress;
|
|
271
285
|
return memo;
|
|
272
286
|
}, {}));
|
|
273
287
|
var V3_MIGRATOR_ADDRESSES = /*#__PURE__*/_extends({}, /*#__PURE__*/SUPPORTED_CHAINS.reduce(function (memo, chainId) {
|
|
274
288
|
var v3MigratorAddress = CHAIN_TO_ADDRESSES_MAP[chainId].v3MigratorAddress;
|
|
275
|
-
|
|
276
289
|
if (v3MigratorAddress) {
|
|
277
290
|
memo[chainId] = v3MigratorAddress;
|
|
278
291
|
}
|
|
279
|
-
|
|
280
292
|
return memo;
|
|
281
293
|
}, {}));
|
|
282
294
|
var MULTICALL_ADDRESSES = /*#__PURE__*/_extends({}, /*#__PURE__*/SUPPORTED_CHAINS.reduce(function (memo, chainId) {
|
|
@@ -286,17 +298,14 @@ var MULTICALL_ADDRESSES = /*#__PURE__*/_extends({}, /*#__PURE__*/SUPPORTED_CHAIN
|
|
|
286
298
|
/**
|
|
287
299
|
* The oldest V0 governance address
|
|
288
300
|
*/
|
|
289
|
-
|
|
290
301
|
var GOVERNANCE_ALPHA_V0_ADDRESSES = /*#__PURE__*/constructSameAddressMap('0x5e4be8Bc9637f0EAA1A755019e06A68ce081D58F');
|
|
291
302
|
/**
|
|
292
303
|
* The older V1 governance address
|
|
293
304
|
*/
|
|
294
|
-
|
|
295
305
|
var GOVERNANCE_ALPHA_V1_ADDRESSES = (_GOVERNANCE_ALPHA_V1_ = {}, _GOVERNANCE_ALPHA_V1_[ChainId.MAINNET] = '0xC4e172459f1E7939D522503B81AFAaC1014CE6F6', _GOVERNANCE_ALPHA_V1_);
|
|
296
306
|
/**
|
|
297
307
|
* The latest governor bravo that is currently admin of timelock
|
|
298
308
|
*/
|
|
299
|
-
|
|
300
309
|
var GOVERNANCE_BRAVO_ADDRESSES = (_GOVERNANCE_BRAVO_ADD = {}, _GOVERNANCE_BRAVO_ADD[ChainId.MAINNET] = '0x408ED6354d4973f66138C91495F2f2FCbd8724C3', _GOVERNANCE_BRAVO_ADD);
|
|
301
310
|
var TIMELOCK_ADDRESSES = /*#__PURE__*/constructSameAddressMap('0x1a9C8182C09F50C8318d769245beA52c32BE35BC');
|
|
302
311
|
var MERKLE_DISTRIBUTOR_ADDRESS = (_MERKLE_DISTRIBUTOR_A = {}, _MERKLE_DISTRIBUTOR_A[ChainId.MAINNET] = '0x090D4613473dEE047c3f2706764f49E0821D256e', _MERKLE_DISTRIBUTOR_A);
|
|
@@ -307,59 +316,47 @@ var QUOTER_ADDRESSES = /*#__PURE__*/_extends({}, /*#__PURE__*/SUPPORTED_CHAINS.r
|
|
|
307
316
|
}, {}));
|
|
308
317
|
var NONFUNGIBLE_POSITION_MANAGER_ADDRESSES = /*#__PURE__*/_extends({}, /*#__PURE__*/SUPPORTED_CHAINS.reduce(function (memo, chainId) {
|
|
309
318
|
var nonfungiblePositionManagerAddress = CHAIN_TO_ADDRESSES_MAP[chainId].nonfungiblePositionManagerAddress;
|
|
310
|
-
|
|
311
319
|
if (nonfungiblePositionManagerAddress) {
|
|
312
320
|
memo[chainId] = nonfungiblePositionManagerAddress;
|
|
313
321
|
}
|
|
314
|
-
|
|
315
322
|
return memo;
|
|
316
323
|
}, {}));
|
|
317
324
|
var ENS_REGISTRAR_ADDRESSES = /*#__PURE__*/_extends({}, /*#__PURE__*/constructSameAddressMap('0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e'));
|
|
318
325
|
var SOCKS_CONTROLLER_ADDRESSES = (_SOCKS_CONTROLLER_ADD = {}, _SOCKS_CONTROLLER_ADD[ChainId.MAINNET] = '0x65770b5283117639760beA3F867b69b3697a91dd', _SOCKS_CONTROLLER_ADD);
|
|
319
326
|
var TICK_LENS_ADDRESSES = /*#__PURE__*/_extends({}, /*#__PURE__*/SUPPORTED_CHAINS.reduce(function (memo, chainId) {
|
|
320
327
|
var tickLensAddress = CHAIN_TO_ADDRESSES_MAP[chainId].tickLensAddress;
|
|
321
|
-
|
|
322
328
|
if (tickLensAddress) {
|
|
323
329
|
memo[chainId] = tickLensAddress;
|
|
324
330
|
}
|
|
325
|
-
|
|
326
331
|
return memo;
|
|
327
332
|
}, {}));
|
|
328
333
|
var MIXED_ROUTE_QUOTER_V1_ADDRESSES = /*#__PURE__*/SUPPORTED_CHAINS.reduce(function (memo, chainId) {
|
|
329
334
|
var v1MixedRouteQuoterAddress = CHAIN_TO_ADDRESSES_MAP[chainId].v1MixedRouteQuoterAddress;
|
|
330
|
-
|
|
331
335
|
if (v1MixedRouteQuoterAddress) {
|
|
332
336
|
memo[chainId] = v1MixedRouteQuoterAddress;
|
|
333
337
|
}
|
|
334
|
-
|
|
335
338
|
return memo;
|
|
336
339
|
}, {});
|
|
337
340
|
var SWAP_ROUTER_02_ADDRESSES = function SWAP_ROUTER_02_ADDRESSES(chainId) {
|
|
338
341
|
if (SUPPORTED_CHAINS.includes(chainId)) {
|
|
339
342
|
var _CHAIN_TO_ADDRESSES_M2;
|
|
340
|
-
|
|
341
343
|
var id = chainId;
|
|
342
344
|
return (_CHAIN_TO_ADDRESSES_M2 = CHAIN_TO_ADDRESSES_MAP[id].swapRouter02Address) != null ? _CHAIN_TO_ADDRESSES_M2 : '0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45';
|
|
343
345
|
}
|
|
344
|
-
|
|
345
346
|
return '';
|
|
346
347
|
};
|
|
347
348
|
|
|
348
349
|
var TradeType;
|
|
349
|
-
|
|
350
350
|
(function (TradeType) {
|
|
351
351
|
TradeType[TradeType["EXACT_INPUT"] = 0] = "EXACT_INPUT";
|
|
352
352
|
TradeType[TradeType["EXACT_OUTPUT"] = 1] = "EXACT_OUTPUT";
|
|
353
353
|
})(TradeType || (TradeType = {}));
|
|
354
|
-
|
|
355
354
|
var Rounding;
|
|
356
|
-
|
|
357
355
|
(function (Rounding) {
|
|
358
356
|
Rounding[Rounding["ROUND_DOWN"] = 0] = "ROUND_DOWN";
|
|
359
357
|
Rounding[Rounding["ROUND_HALF_UP"] = 1] = "ROUND_HALF_UP";
|
|
360
358
|
Rounding[Rounding["ROUND_UP"] = 2] = "ROUND_UP";
|
|
361
359
|
})(Rounding || (Rounding = {}));
|
|
362
|
-
|
|
363
360
|
var MaxUint256 = /*#__PURE__*/JSBI.BigInt('0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff');
|
|
364
361
|
|
|
365
362
|
var _toSignificantRoundin, _toFixedRounding;
|
|
@@ -372,80 +369,63 @@ var Fraction = /*#__PURE__*/function () {
|
|
|
372
369
|
if (denominator === void 0) {
|
|
373
370
|
denominator = JSBI.BigInt(1);
|
|
374
371
|
}
|
|
375
|
-
|
|
376
372
|
this.numerator = JSBI.BigInt(numerator);
|
|
377
373
|
this.denominator = JSBI.BigInt(denominator);
|
|
378
374
|
}
|
|
379
|
-
|
|
380
375
|
Fraction.tryParseFraction = function tryParseFraction(fractionish) {
|
|
381
376
|
if (fractionish instanceof JSBI || typeof fractionish === 'number' || typeof fractionish === 'string') return new Fraction(fractionish);
|
|
382
377
|
if ('numerator' in fractionish && 'denominator' in fractionish) return fractionish;
|
|
383
378
|
throw new Error('Could not parse fraction');
|
|
384
|
-
}
|
|
379
|
+
}
|
|
380
|
+
// performs floor division
|
|
385
381
|
;
|
|
386
|
-
|
|
387
382
|
var _proto = Fraction.prototype;
|
|
388
|
-
|
|
389
383
|
_proto.invert = function invert() {
|
|
390
384
|
return new Fraction(this.denominator, this.numerator);
|
|
391
385
|
};
|
|
392
|
-
|
|
393
386
|
_proto.add = function add(other) {
|
|
394
387
|
var otherParsed = Fraction.tryParseFraction(other);
|
|
395
|
-
|
|
396
388
|
if (JSBI.equal(this.denominator, otherParsed.denominator)) {
|
|
397
389
|
return new Fraction(JSBI.add(this.numerator, otherParsed.numerator), this.denominator);
|
|
398
390
|
}
|
|
399
|
-
|
|
400
391
|
return new Fraction(JSBI.add(JSBI.multiply(this.numerator, otherParsed.denominator), JSBI.multiply(otherParsed.numerator, this.denominator)), JSBI.multiply(this.denominator, otherParsed.denominator));
|
|
401
392
|
};
|
|
402
|
-
|
|
403
393
|
_proto.subtract = function subtract(other) {
|
|
404
394
|
var otherParsed = Fraction.tryParseFraction(other);
|
|
405
|
-
|
|
406
395
|
if (JSBI.equal(this.denominator, otherParsed.denominator)) {
|
|
407
396
|
return new Fraction(JSBI.subtract(this.numerator, otherParsed.numerator), this.denominator);
|
|
408
397
|
}
|
|
409
|
-
|
|
410
398
|
return new Fraction(JSBI.subtract(JSBI.multiply(this.numerator, otherParsed.denominator), JSBI.multiply(otherParsed.numerator, this.denominator)), JSBI.multiply(this.denominator, otherParsed.denominator));
|
|
411
399
|
};
|
|
412
|
-
|
|
413
400
|
_proto.lessThan = function lessThan(other) {
|
|
414
401
|
var otherParsed = Fraction.tryParseFraction(other);
|
|
415
402
|
return JSBI.lessThan(JSBI.multiply(this.numerator, otherParsed.denominator), JSBI.multiply(otherParsed.numerator, this.denominator));
|
|
416
403
|
};
|
|
417
|
-
|
|
418
404
|
_proto.equalTo = function equalTo(other) {
|
|
419
405
|
var otherParsed = Fraction.tryParseFraction(other);
|
|
420
406
|
return JSBI.equal(JSBI.multiply(this.numerator, otherParsed.denominator), JSBI.multiply(otherParsed.numerator, this.denominator));
|
|
421
407
|
};
|
|
422
|
-
|
|
423
408
|
_proto.greaterThan = function greaterThan(other) {
|
|
424
409
|
var otherParsed = Fraction.tryParseFraction(other);
|
|
425
410
|
return JSBI.greaterThan(JSBI.multiply(this.numerator, otherParsed.denominator), JSBI.multiply(otherParsed.numerator, this.denominator));
|
|
426
411
|
};
|
|
427
|
-
|
|
428
412
|
_proto.multiply = function multiply(other) {
|
|
429
413
|
var otherParsed = Fraction.tryParseFraction(other);
|
|
430
414
|
return new Fraction(JSBI.multiply(this.numerator, otherParsed.numerator), JSBI.multiply(this.denominator, otherParsed.denominator));
|
|
431
415
|
};
|
|
432
|
-
|
|
433
416
|
_proto.divide = function divide(other) {
|
|
434
417
|
var otherParsed = Fraction.tryParseFraction(other);
|
|
435
418
|
return new Fraction(JSBI.multiply(this.numerator, otherParsed.denominator), JSBI.multiply(this.denominator, otherParsed.numerator));
|
|
436
419
|
};
|
|
437
|
-
|
|
438
420
|
_proto.toSignificant = function toSignificant(significantDigits, format, rounding) {
|
|
439
421
|
if (format === void 0) {
|
|
440
422
|
format = {
|
|
441
423
|
groupSeparator: ''
|
|
442
424
|
};
|
|
443
425
|
}
|
|
444
|
-
|
|
445
426
|
if (rounding === void 0) {
|
|
446
427
|
rounding = Rounding.ROUND_HALF_UP;
|
|
447
428
|
}
|
|
448
|
-
|
|
449
429
|
!Number.isInteger(significantDigits) ? process.env.NODE_ENV !== "production" ? invariant(false, significantDigits + " is not an integer.") : invariant(false) : void 0;
|
|
450
430
|
!(significantDigits > 0) ? process.env.NODE_ENV !== "production" ? invariant(false, significantDigits + " is not positive.") : invariant(false) : void 0;
|
|
451
431
|
Decimal.set({
|
|
@@ -455,18 +435,15 @@ var Fraction = /*#__PURE__*/function () {
|
|
|
455
435
|
var quotient = new Decimal(this.numerator.toString()).div(this.denominator.toString()).toSignificantDigits(significantDigits);
|
|
456
436
|
return quotient.toFormat(quotient.decimalPlaces(), format);
|
|
457
437
|
};
|
|
458
|
-
|
|
459
438
|
_proto.toFixed = function toFixed(decimalPlaces, format, rounding) {
|
|
460
439
|
if (format === void 0) {
|
|
461
440
|
format = {
|
|
462
441
|
groupSeparator: ''
|
|
463
442
|
};
|
|
464
443
|
}
|
|
465
|
-
|
|
466
444
|
if (rounding === void 0) {
|
|
467
445
|
rounding = Rounding.ROUND_HALF_UP;
|
|
468
446
|
}
|
|
469
|
-
|
|
470
447
|
!Number.isInteger(decimalPlaces) ? process.env.NODE_ENV !== "production" ? invariant(false, decimalPlaces + " is not an integer.") : invariant(false) : void 0;
|
|
471
448
|
!(decimalPlaces >= 0) ? process.env.NODE_ENV !== "production" ? invariant(false, decimalPlaces + " is negative.") : invariant(false) : void 0;
|
|
472
449
|
Big.DP = decimalPlaces;
|
|
@@ -475,15 +452,13 @@ var Fraction = /*#__PURE__*/function () {
|
|
|
475
452
|
}
|
|
476
453
|
/**
|
|
477
454
|
* Helper method for converting any super class back to a fraction
|
|
478
|
-
|
|
479
|
-
;
|
|
480
|
-
|
|
455
|
+
*/;
|
|
481
456
|
_createClass(Fraction, [{
|
|
482
457
|
key: "quotient",
|
|
483
458
|
get: function get() {
|
|
484
459
|
return JSBI.divide(this.numerator, this.denominator);
|
|
485
|
-
}
|
|
486
|
-
|
|
460
|
+
}
|
|
461
|
+
// remainder after floor division
|
|
487
462
|
}, {
|
|
488
463
|
key: "remainder",
|
|
489
464
|
get: function get() {
|
|
@@ -495,17 +470,14 @@ var Fraction = /*#__PURE__*/function () {
|
|
|
495
470
|
return new Fraction(this.numerator, this.denominator);
|
|
496
471
|
}
|
|
497
472
|
}]);
|
|
498
|
-
|
|
499
473
|
return Fraction;
|
|
500
474
|
}();
|
|
501
475
|
|
|
502
476
|
var Big$1 = /*#__PURE__*/toFormat(_Big);
|
|
503
477
|
var CurrencyAmount = /*#__PURE__*/function (_Fraction) {
|
|
504
478
|
_inheritsLoose(CurrencyAmount, _Fraction);
|
|
505
|
-
|
|
506
479
|
function CurrencyAmount(currency, numerator, denominator) {
|
|
507
480
|
var _this;
|
|
508
|
-
|
|
509
481
|
_this = _Fraction.call(this, numerator, denominator) || this;
|
|
510
482
|
!JSBI.lessThanOrEqual(_this.quotient, MaxUint256) ? process.env.NODE_ENV !== "production" ? invariant(false, 'AMOUNT') : invariant(false) : void 0;
|
|
511
483
|
_this.currency = currency;
|
|
@@ -517,8 +489,6 @@ var CurrencyAmount = /*#__PURE__*/function (_Fraction) {
|
|
|
517
489
|
* @param currency the currency in the amount
|
|
518
490
|
* @param rawAmount the raw token or ether amount
|
|
519
491
|
*/
|
|
520
|
-
|
|
521
|
-
|
|
522
492
|
CurrencyAmount.fromRawAmount = function fromRawAmount(currency, rawAmount) {
|
|
523
493
|
return new CurrencyAmount(currency, rawAmount);
|
|
524
494
|
}
|
|
@@ -527,79 +497,57 @@ var CurrencyAmount = /*#__PURE__*/function (_Fraction) {
|
|
|
527
497
|
* @param currency the currency
|
|
528
498
|
* @param numerator the numerator of the fractional token amount
|
|
529
499
|
* @param denominator the denominator of the fractional token amount
|
|
530
|
-
|
|
531
|
-
;
|
|
532
|
-
|
|
500
|
+
*/;
|
|
533
501
|
CurrencyAmount.fromFractionalAmount = function fromFractionalAmount(currency, numerator, denominator) {
|
|
534
502
|
return new CurrencyAmount(currency, numerator, denominator);
|
|
535
503
|
};
|
|
536
|
-
|
|
537
504
|
var _proto = CurrencyAmount.prototype;
|
|
538
|
-
|
|
539
505
|
_proto.add = function add(other) {
|
|
540
506
|
!this.currency.equals(other.currency) ? process.env.NODE_ENV !== "production" ? invariant(false, 'CURRENCY') : invariant(false) : void 0;
|
|
541
|
-
|
|
542
507
|
var added = _Fraction.prototype.add.call(this, other);
|
|
543
|
-
|
|
544
508
|
return CurrencyAmount.fromFractionalAmount(this.currency, added.numerator, added.denominator);
|
|
545
509
|
};
|
|
546
|
-
|
|
547
510
|
_proto.subtract = function subtract(other) {
|
|
548
511
|
!this.currency.equals(other.currency) ? process.env.NODE_ENV !== "production" ? invariant(false, 'CURRENCY') : invariant(false) : void 0;
|
|
549
|
-
|
|
550
512
|
var subtracted = _Fraction.prototype.subtract.call(this, other);
|
|
551
|
-
|
|
552
513
|
return CurrencyAmount.fromFractionalAmount(this.currency, subtracted.numerator, subtracted.denominator);
|
|
553
514
|
};
|
|
554
|
-
|
|
555
515
|
_proto.multiply = function multiply(other) {
|
|
556
516
|
var multiplied = _Fraction.prototype.multiply.call(this, other);
|
|
557
|
-
|
|
558
517
|
return CurrencyAmount.fromFractionalAmount(this.currency, multiplied.numerator, multiplied.denominator);
|
|
559
518
|
};
|
|
560
|
-
|
|
561
519
|
_proto.divide = function divide(other) {
|
|
562
520
|
var divided = _Fraction.prototype.divide.call(this, other);
|
|
563
|
-
|
|
564
521
|
return CurrencyAmount.fromFractionalAmount(this.currency, divided.numerator, divided.denominator);
|
|
565
522
|
};
|
|
566
|
-
|
|
567
523
|
_proto.toSignificant = function toSignificant(significantDigits, format, rounding) {
|
|
568
524
|
if (significantDigits === void 0) {
|
|
569
525
|
significantDigits = 6;
|
|
570
526
|
}
|
|
571
|
-
|
|
572
527
|
if (rounding === void 0) {
|
|
573
528
|
rounding = Rounding.ROUND_DOWN;
|
|
574
529
|
}
|
|
575
|
-
|
|
576
530
|
return _Fraction.prototype.divide.call(this, this.decimalScale).toSignificant(significantDigits, format, rounding);
|
|
577
531
|
};
|
|
578
|
-
|
|
579
532
|
_proto.toFixed = function toFixed(decimalPlaces, format, rounding) {
|
|
580
533
|
if (decimalPlaces === void 0) {
|
|
581
534
|
decimalPlaces = this.currency.decimals;
|
|
582
535
|
}
|
|
583
|
-
|
|
584
536
|
if (rounding === void 0) {
|
|
585
537
|
rounding = Rounding.ROUND_DOWN;
|
|
586
538
|
}
|
|
587
|
-
|
|
588
539
|
!(decimalPlaces <= this.currency.decimals) ? process.env.NODE_ENV !== "production" ? invariant(false, 'DECIMALS') : invariant(false) : void 0;
|
|
589
540
|
return _Fraction.prototype.divide.call(this, this.decimalScale).toFixed(decimalPlaces, format, rounding);
|
|
590
541
|
};
|
|
591
|
-
|
|
592
542
|
_proto.toExact = function toExact(format) {
|
|
593
543
|
if (format === void 0) {
|
|
594
544
|
format = {
|
|
595
545
|
groupSeparator: ''
|
|
596
546
|
};
|
|
597
547
|
}
|
|
598
|
-
|
|
599
548
|
Big$1.DP = this.currency.decimals;
|
|
600
549
|
return new Big$1(this.quotient.toString()).div(this.decimalScale.toString()).toFormat(format);
|
|
601
550
|
};
|
|
602
|
-
|
|
603
551
|
_createClass(CurrencyAmount, [{
|
|
604
552
|
key: "wrapped",
|
|
605
553
|
get: function get() {
|
|
@@ -607,7 +555,6 @@ var CurrencyAmount = /*#__PURE__*/function (_Fraction) {
|
|
|
607
555
|
return CurrencyAmount.fromFractionalAmount(this.currency.wrapped, this.numerator, this.denominator);
|
|
608
556
|
}
|
|
609
557
|
}]);
|
|
610
|
-
|
|
611
558
|
return CurrencyAmount;
|
|
612
559
|
}(Fraction);
|
|
613
560
|
|
|
@@ -616,79 +563,60 @@ var ONE_HUNDRED = /*#__PURE__*/new Fraction( /*#__PURE__*/JSBI.BigInt(100));
|
|
|
616
563
|
* Converts a fraction to a percent
|
|
617
564
|
* @param fraction the fraction to convert
|
|
618
565
|
*/
|
|
619
|
-
|
|
620
566
|
function toPercent(fraction) {
|
|
621
567
|
return new Percent(fraction.numerator, fraction.denominator);
|
|
622
568
|
}
|
|
623
|
-
|
|
624
569
|
var Percent = /*#__PURE__*/function (_Fraction) {
|
|
625
570
|
_inheritsLoose(Percent, _Fraction);
|
|
626
|
-
|
|
627
571
|
function Percent() {
|
|
628
572
|
var _this;
|
|
629
|
-
|
|
630
573
|
_this = _Fraction.apply(this, arguments) || this;
|
|
631
574
|
/**
|
|
632
575
|
* This boolean prevents a fraction from being interpreted as a Percent
|
|
633
576
|
*/
|
|
634
|
-
|
|
635
577
|
_this.isPercent = true;
|
|
636
578
|
return _this;
|
|
637
579
|
}
|
|
638
|
-
|
|
639
580
|
var _proto = Percent.prototype;
|
|
640
|
-
|
|
641
581
|
_proto.add = function add(other) {
|
|
642
582
|
return toPercent(_Fraction.prototype.add.call(this, other));
|
|
643
583
|
};
|
|
644
|
-
|
|
645
584
|
_proto.subtract = function subtract(other) {
|
|
646
585
|
return toPercent(_Fraction.prototype.subtract.call(this, other));
|
|
647
586
|
};
|
|
648
|
-
|
|
649
587
|
_proto.multiply = function multiply(other) {
|
|
650
588
|
return toPercent(_Fraction.prototype.multiply.call(this, other));
|
|
651
589
|
};
|
|
652
|
-
|
|
653
590
|
_proto.divide = function divide(other) {
|
|
654
591
|
return toPercent(_Fraction.prototype.divide.call(this, other));
|
|
655
592
|
};
|
|
656
|
-
|
|
657
593
|
_proto.toSignificant = function toSignificant(significantDigits, format, rounding) {
|
|
658
594
|
if (significantDigits === void 0) {
|
|
659
595
|
significantDigits = 5;
|
|
660
596
|
}
|
|
661
|
-
|
|
662
597
|
return _Fraction.prototype.multiply.call(this, ONE_HUNDRED).toSignificant(significantDigits, format, rounding);
|
|
663
598
|
};
|
|
664
|
-
|
|
665
599
|
_proto.toFixed = function toFixed(decimalPlaces, format, rounding) {
|
|
666
600
|
if (decimalPlaces === void 0) {
|
|
667
601
|
decimalPlaces = 2;
|
|
668
602
|
}
|
|
669
|
-
|
|
670
603
|
return _Fraction.prototype.multiply.call(this, ONE_HUNDRED).toFixed(decimalPlaces, format, rounding);
|
|
671
604
|
};
|
|
672
|
-
|
|
673
605
|
return Percent;
|
|
674
606
|
}(Fraction);
|
|
675
607
|
|
|
676
608
|
var Price = /*#__PURE__*/function (_Fraction) {
|
|
677
609
|
_inheritsLoose(Price, _Fraction);
|
|
678
|
-
|
|
679
610
|
/**
|
|
680
611
|
* Construct a price, either with the base and quote currency amount, or the
|
|
681
612
|
* @param args
|
|
682
613
|
*/
|
|
683
614
|
function Price() {
|
|
684
615
|
var _this;
|
|
685
|
-
|
|
686
616
|
var baseCurrency, quoteCurrency, denominator, numerator;
|
|
687
|
-
|
|
688
617
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
689
618
|
args[_key] = arguments[_key];
|
|
690
619
|
}
|
|
691
|
-
|
|
692
620
|
if (args.length === 4) {
|
|
693
621
|
baseCurrency = args[0];
|
|
694
622
|
quoteCurrency = args[1];
|
|
@@ -702,7 +630,6 @@ var Price = /*#__PURE__*/function (_Fraction) {
|
|
|
702
630
|
denominator = _ref[2];
|
|
703
631
|
numerator = _ref[3];
|
|
704
632
|
}
|
|
705
|
-
|
|
706
633
|
_this = _Fraction.call(this, numerator, denominator) || this;
|
|
707
634
|
_this.baseCurrency = baseCurrency;
|
|
708
635
|
_this.quoteCurrency = quoteCurrency;
|
|
@@ -712,75 +639,56 @@ var Price = /*#__PURE__*/function (_Fraction) {
|
|
|
712
639
|
/**
|
|
713
640
|
* Flip the price, switching the base and quote currency
|
|
714
641
|
*/
|
|
715
|
-
|
|
716
|
-
|
|
717
642
|
var _proto = Price.prototype;
|
|
718
|
-
|
|
719
643
|
_proto.invert = function invert() {
|
|
720
644
|
return new Price(this.quoteCurrency, this.baseCurrency, this.numerator, this.denominator);
|
|
721
645
|
}
|
|
722
646
|
/**
|
|
723
647
|
* Multiply the price by another price, returning a new price. The other price must have the same base currency as this price's quote currency
|
|
724
648
|
* @param other the other price
|
|
725
|
-
|
|
726
|
-
;
|
|
727
|
-
|
|
649
|
+
*/;
|
|
728
650
|
_proto.multiply = function multiply(other) {
|
|
729
651
|
!this.quoteCurrency.equals(other.baseCurrency) ? process.env.NODE_ENV !== "production" ? invariant(false, 'TOKEN') : invariant(false) : void 0;
|
|
730
|
-
|
|
731
652
|
var fraction = _Fraction.prototype.multiply.call(this, other);
|
|
732
|
-
|
|
733
653
|
return new Price(this.baseCurrency, other.quoteCurrency, fraction.denominator, fraction.numerator);
|
|
734
654
|
}
|
|
735
655
|
/**
|
|
736
656
|
* Return the amount of quote currency corresponding to a given amount of the base currency
|
|
737
657
|
* @param currencyAmount the amount of base currency to quote against the price
|
|
738
|
-
|
|
739
|
-
;
|
|
740
|
-
|
|
658
|
+
*/;
|
|
741
659
|
_proto.quote = function quote(currencyAmount) {
|
|
742
660
|
!currencyAmount.currency.equals(this.baseCurrency) ? process.env.NODE_ENV !== "production" ? invariant(false, 'TOKEN') : invariant(false) : void 0;
|
|
743
|
-
|
|
744
661
|
var result = _Fraction.prototype.multiply.call(this, currencyAmount);
|
|
745
|
-
|
|
746
662
|
return CurrencyAmount.fromFractionalAmount(this.quoteCurrency, result.numerator, result.denominator);
|
|
747
663
|
}
|
|
748
664
|
/**
|
|
749
665
|
* Get the value scaled by decimals for formatting
|
|
750
666
|
* @private
|
|
751
|
-
|
|
752
|
-
;
|
|
753
|
-
|
|
667
|
+
*/;
|
|
754
668
|
_proto.toSignificant = function toSignificant(significantDigits, format, rounding) {
|
|
755
669
|
if (significantDigits === void 0) {
|
|
756
670
|
significantDigits = 6;
|
|
757
671
|
}
|
|
758
|
-
|
|
759
672
|
return this.adjustedForDecimals.toSignificant(significantDigits, format, rounding);
|
|
760
673
|
};
|
|
761
|
-
|
|
762
674
|
_proto.toFixed = function toFixed(decimalPlaces, format, rounding) {
|
|
763
675
|
if (decimalPlaces === void 0) {
|
|
764
676
|
decimalPlaces = 4;
|
|
765
677
|
}
|
|
766
|
-
|
|
767
678
|
return this.adjustedForDecimals.toFixed(decimalPlaces, format, rounding);
|
|
768
679
|
};
|
|
769
|
-
|
|
770
680
|
_createClass(Price, [{
|
|
771
681
|
key: "adjustedForDecimals",
|
|
772
682
|
get: function get() {
|
|
773
683
|
return _Fraction.prototype.multiply.call(this, this.scalar);
|
|
774
684
|
}
|
|
775
685
|
}]);
|
|
776
|
-
|
|
777
686
|
return Price;
|
|
778
687
|
}(Fraction);
|
|
779
688
|
|
|
780
689
|
/**
|
|
781
690
|
* A currency is any fungible financial instrument, including Ether, all ERC20 tokens, and other chain-native currencies
|
|
782
691
|
*/
|
|
783
|
-
|
|
784
692
|
var BaseCurrency =
|
|
785
693
|
/**
|
|
786
694
|
* Constructs an instance of the base class `BaseCurrency`.
|
|
@@ -801,19 +709,15 @@ function BaseCurrency(chainId, decimals, symbol, name) {
|
|
|
801
709
|
/**
|
|
802
710
|
* Represents the native currency of the chain on which it resides, e.g.
|
|
803
711
|
*/
|
|
804
|
-
|
|
805
712
|
var NativeCurrency = /*#__PURE__*/function (_BaseCurrency) {
|
|
806
713
|
_inheritsLoose(NativeCurrency, _BaseCurrency);
|
|
807
|
-
|
|
808
714
|
function NativeCurrency() {
|
|
809
715
|
var _this;
|
|
810
|
-
|
|
811
716
|
_this = _BaseCurrency.apply(this, arguments) || this;
|
|
812
717
|
_this.isNative = true;
|
|
813
718
|
_this.isToken = false;
|
|
814
719
|
return _this;
|
|
815
720
|
}
|
|
816
|
-
|
|
817
721
|
return NativeCurrency;
|
|
818
722
|
}(BaseCurrency);
|
|
819
723
|
|
|
@@ -821,36 +725,31 @@ var NativeCurrency = /*#__PURE__*/function (_BaseCurrency) {
|
|
|
821
725
|
* Validates an address and returns the parsed (checksummed) version of that address
|
|
822
726
|
* @param address the unchecksummed hex address
|
|
823
727
|
*/
|
|
824
|
-
|
|
825
728
|
function validateAndParseAddress(address) {
|
|
826
729
|
try {
|
|
827
730
|
return getAddress(address);
|
|
828
731
|
} catch (error) {
|
|
829
732
|
throw new Error(address + " is not a valid address.");
|
|
830
733
|
}
|
|
831
|
-
}
|
|
832
|
-
|
|
734
|
+
}
|
|
735
|
+
// Checks a string starts with 0x, is 42 characters long and contains only hex characters after 0x
|
|
833
736
|
var startsWith0xLen42HexRegex = /^0x[0-9a-fA-F]{40}$/;
|
|
834
737
|
/**
|
|
835
738
|
* Checks if an address is valid by checking 0x prefix, length === 42 and hex encoding.
|
|
836
739
|
* @param address the unchecksummed hex address
|
|
837
740
|
*/
|
|
838
|
-
|
|
839
741
|
function checkValidAddress(address) {
|
|
840
742
|
if (startsWith0xLen42HexRegex.test(address)) {
|
|
841
743
|
return address;
|
|
842
744
|
}
|
|
843
|
-
|
|
844
745
|
throw new Error(address + " is not a valid address.");
|
|
845
746
|
}
|
|
846
747
|
|
|
847
748
|
/**
|
|
848
749
|
* Represents an ERC20 token with a unique address and some metadata.
|
|
849
750
|
*/
|
|
850
|
-
|
|
851
751
|
var Token = /*#__PURE__*/function (_BaseCurrency) {
|
|
852
752
|
_inheritsLoose(Token, _BaseCurrency);
|
|
853
|
-
|
|
854
753
|
/**
|
|
855
754
|
*
|
|
856
755
|
* @param chainId {@link BaseCurrency#chainId}
|
|
@@ -864,25 +763,20 @@ var Token = /*#__PURE__*/function (_BaseCurrency) {
|
|
|
864
763
|
*/
|
|
865
764
|
function Token(chainId, address, decimals, symbol, name, bypassChecksum, buyFeeBps, sellFeeBps) {
|
|
866
765
|
var _this;
|
|
867
|
-
|
|
868
766
|
_this = _BaseCurrency.call(this, chainId, decimals, symbol, name) || this;
|
|
869
767
|
_this.isNative = false;
|
|
870
768
|
_this.isToken = true;
|
|
871
|
-
|
|
872
769
|
if (bypassChecksum) {
|
|
873
770
|
_this.address = checkValidAddress(address);
|
|
874
771
|
} else {
|
|
875
772
|
_this.address = validateAndParseAddress(address);
|
|
876
773
|
}
|
|
877
|
-
|
|
878
774
|
if (buyFeeBps) {
|
|
879
775
|
!buyFeeBps.gte(BigNumber.from(0)) ? process.env.NODE_ENV !== "production" ? invariant(false, 'NON-NEGATIVE FOT FEES') : invariant(false) : void 0;
|
|
880
776
|
}
|
|
881
|
-
|
|
882
777
|
if (sellFeeBps) {
|
|
883
778
|
!sellFeeBps.gte(BigNumber.from(0)) ? process.env.NODE_ENV !== "production" ? invariant(false, 'NON-NEGATIVE FOT FEES') : invariant(false) : void 0;
|
|
884
779
|
}
|
|
885
|
-
|
|
886
780
|
_this.buyFeeBps = buyFeeBps;
|
|
887
781
|
_this.sellFeeBps = sellFeeBps;
|
|
888
782
|
return _this;
|
|
@@ -891,10 +785,7 @@ var Token = /*#__PURE__*/function (_BaseCurrency) {
|
|
|
891
785
|
* Returns true if the two tokens are equivalent, i.e. have the same chainId and address.
|
|
892
786
|
* @param other other token to compare
|
|
893
787
|
*/
|
|
894
|
-
|
|
895
|
-
|
|
896
788
|
var _proto = Token.prototype;
|
|
897
|
-
|
|
898
789
|
_proto.equals = function equals(other) {
|
|
899
790
|
return other.isToken && this.chainId === other.chainId && this.address.toLowerCase() === other.address.toLowerCase();
|
|
900
791
|
}
|
|
@@ -903,9 +794,7 @@ var Token = /*#__PURE__*/function (_BaseCurrency) {
|
|
|
903
794
|
* @param other other token to compare
|
|
904
795
|
* @throws if the tokens have the same address
|
|
905
796
|
* @throws if the tokens are on different chains
|
|
906
|
-
|
|
907
|
-
;
|
|
908
|
-
|
|
797
|
+
*/;
|
|
909
798
|
_proto.sortsBefore = function sortsBefore(other) {
|
|
910
799
|
!(this.chainId === other.chainId) ? process.env.NODE_ENV !== "production" ? invariant(false, 'CHAIN_IDS') : invariant(false) : void 0;
|
|
911
800
|
!(this.address.toLowerCase() !== other.address.toLowerCase()) ? process.env.NODE_ENV !== "production" ? invariant(false, 'ADDRESSES') : invariant(false) : void 0;
|
|
@@ -913,49 +802,53 @@ var Token = /*#__PURE__*/function (_BaseCurrency) {
|
|
|
913
802
|
}
|
|
914
803
|
/**
|
|
915
804
|
* Return this token, which does not need to be wrapped
|
|
916
|
-
|
|
917
|
-
;
|
|
918
|
-
|
|
805
|
+
*/;
|
|
919
806
|
_createClass(Token, [{
|
|
920
807
|
key: "wrapped",
|
|
921
808
|
get: function get() {
|
|
922
809
|
return this;
|
|
923
810
|
}
|
|
924
811
|
}]);
|
|
925
|
-
|
|
926
812
|
return Token;
|
|
927
813
|
}(BaseCurrency);
|
|
928
814
|
|
|
929
|
-
var _WETH;
|
|
930
815
|
/**
|
|
931
816
|
* Known WETH9 implementation addresses, used in our implementation of Ether#wrapped
|
|
932
817
|
*/
|
|
933
|
-
|
|
934
|
-
|
|
818
|
+
var WETH9 = {
|
|
819
|
+
1: /*#__PURE__*/new Token(1, '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2', 18, 'WETH', 'Wrapped Ether'),
|
|
820
|
+
3: /*#__PURE__*/new Token(3, '0xc778417E063141139Fce010982780140Aa0cD5Ab', 18, 'WETH', 'Wrapped Ether'),
|
|
821
|
+
4: /*#__PURE__*/new Token(4, '0xc778417E063141139Fce010982780140Aa0cD5Ab', 18, 'WETH', 'Wrapped Ether'),
|
|
822
|
+
5: /*#__PURE__*/new Token(5, '0xB4FBF271143F4FBf7B91A5ded31805e42b2208d6', 18, 'WETH', 'Wrapped Ether'),
|
|
823
|
+
42: /*#__PURE__*/new Token(42, '0xd0A1E359811322d97991E03f863a0C30C2cF029C', 18, 'WETH', 'Wrapped Ether'),
|
|
824
|
+
10: /*#__PURE__*/new Token(10, '0x4200000000000000000000000000000000000006', 18, 'WETH', 'Wrapped Ether'),
|
|
825
|
+
69: /*#__PURE__*/new Token(69, '0x4200000000000000000000000000000000000006', 18, 'WETH', 'Wrapped Ether'),
|
|
826
|
+
11155420: /*#__PURE__*/new Token(11155420, '0x4200000000000000000000000000000000000006', 18, 'WETH', 'Wrapped Ether'),
|
|
827
|
+
42161: /*#__PURE__*/new Token(42161, '0x82aF49447D8a07e3bd95BD0d56f35241523fBab1', 18, 'WETH', 'Wrapped Ether'),
|
|
828
|
+
421611: /*#__PURE__*/new Token(421611, '0xB47e6A5f8b33b3F17603C83a0535A9dcD7E32681', 18, 'WETH', 'Wrapped Ether'),
|
|
829
|
+
421614: /*#__PURE__*/new Token(421614, '0x980B62Da83eFf3D4576C647993b0c1D7faf17c73', 18, 'WETH', 'Wrapped Ether'),
|
|
830
|
+
8453: /*#__PURE__*/new Token(8453, '0x4200000000000000000000000000000000000006', 18, 'WETH', 'Wrapped Ether'),
|
|
831
|
+
56: /*#__PURE__*/new Token(56, '0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c', 18, 'WBNB', 'Wrapped BNB'),
|
|
832
|
+
137: /*#__PURE__*/new Token(137, '0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270', 18, 'WMATIC', 'Wrapped MATIC'),
|
|
833
|
+
43114: /*#__PURE__*/new Token(43114, '0xB31f66AA3C1e785363F0875A1B74E27b85FD66c7', 18, 'WAVAX', 'Wrapped AVAX')
|
|
834
|
+
};
|
|
935
835
|
|
|
936
836
|
/**
|
|
937
837
|
* Ether is the main usage of a 'native' currency, i.e. for Ethereum mainnet and all testnets
|
|
938
838
|
*/
|
|
939
|
-
|
|
940
839
|
var Ether = /*#__PURE__*/function (_NativeCurrency) {
|
|
941
840
|
_inheritsLoose(Ether, _NativeCurrency);
|
|
942
|
-
|
|
943
841
|
function Ether(chainId) {
|
|
944
842
|
return _NativeCurrency.call(this, chainId, 18, 'ETH', 'Ether') || this;
|
|
945
843
|
}
|
|
946
|
-
|
|
947
844
|
Ether.onChain = function onChain(chainId) {
|
|
948
845
|
var _this$_etherCache$cha;
|
|
949
|
-
|
|
950
846
|
return (_this$_etherCache$cha = this._etherCache[chainId]) != null ? _this$_etherCache$cha : this._etherCache[chainId] = new Ether(chainId);
|
|
951
847
|
};
|
|
952
|
-
|
|
953
848
|
var _proto = Ether.prototype;
|
|
954
|
-
|
|
955
849
|
_proto.equals = function equals(other) {
|
|
956
850
|
return other.isNative && other.chainId === this.chainId;
|
|
957
851
|
};
|
|
958
|
-
|
|
959
852
|
_createClass(Ether, [{
|
|
960
853
|
key: "wrapped",
|
|
961
854
|
get: function get() {
|
|
@@ -964,7 +857,6 @@ var Ether = /*#__PURE__*/function (_NativeCurrency) {
|
|
|
964
857
|
return weth9;
|
|
965
858
|
}
|
|
966
859
|
}]);
|
|
967
|
-
|
|
968
860
|
return Ether;
|
|
969
861
|
}(NativeCurrency);
|
|
970
862
|
Ether._etherCache = {};
|
|
@@ -975,44 +867,39 @@ Ether._etherCache = {};
|
|
|
975
867
|
* @param inputAmount the input amount of the trade
|
|
976
868
|
* @param outputAmount the output amount of the trade
|
|
977
869
|
*/
|
|
978
|
-
|
|
979
870
|
function computePriceImpact(midPrice, inputAmount, outputAmount) {
|
|
980
|
-
var quotedOutputAmount = midPrice.quote(inputAmount);
|
|
981
|
-
|
|
871
|
+
var quotedOutputAmount = midPrice.quote(inputAmount);
|
|
872
|
+
// calculate price impact := (exactQuote - outputAmount) / exactQuote
|
|
982
873
|
var priceImpact = quotedOutputAmount.subtract(outputAmount).divide(quotedOutputAmount);
|
|
983
874
|
return new Percent(priceImpact.numerator, priceImpact.denominator);
|
|
984
875
|
}
|
|
985
876
|
|
|
877
|
+
// given an array of items sorted by `comparator`, insert an item into its sort index and constrain the size to
|
|
986
878
|
// `maxSize` by removing the last item
|
|
987
|
-
|
|
988
879
|
function sortedInsert(items, add, maxSize, comparator) {
|
|
989
|
-
!(maxSize > 0) ? process.env.NODE_ENV !== "production" ? invariant(false, 'MAX_SIZE_ZERO') : invariant(false) : void 0;
|
|
990
|
-
|
|
991
|
-
!(items.length <= maxSize) ? process.env.NODE_ENV !== "production" ? invariant(false, 'ITEMS_SIZE') : invariant(false) : void 0;
|
|
992
|
-
|
|
880
|
+
!(maxSize > 0) ? process.env.NODE_ENV !== "production" ? invariant(false, 'MAX_SIZE_ZERO') : invariant(false) : void 0;
|
|
881
|
+
// this is an invariant because the interface cannot return multiple removed items if items.length exceeds maxSize
|
|
882
|
+
!(items.length <= maxSize) ? process.env.NODE_ENV !== "production" ? invariant(false, 'ITEMS_SIZE') : invariant(false) : void 0;
|
|
883
|
+
// short circuit first item add
|
|
993
884
|
if (items.length === 0) {
|
|
994
885
|
items.push(add);
|
|
995
886
|
return null;
|
|
996
887
|
} else {
|
|
997
|
-
var isFull = items.length === maxSize;
|
|
998
|
-
|
|
888
|
+
var isFull = items.length === maxSize;
|
|
889
|
+
// short circuit if full and the additional item does not come before the last item
|
|
999
890
|
if (isFull && comparator(items[items.length - 1], add) <= 0) {
|
|
1000
891
|
return add;
|
|
1001
892
|
}
|
|
1002
|
-
|
|
1003
893
|
var lo = 0,
|
|
1004
|
-
|
|
1005
|
-
|
|
894
|
+
hi = items.length;
|
|
1006
895
|
while (lo < hi) {
|
|
1007
896
|
var mid = lo + hi >>> 1;
|
|
1008
|
-
|
|
1009
897
|
if (comparator(items[mid], add) <= 0) {
|
|
1010
898
|
lo = mid + 1;
|
|
1011
899
|
} else {
|
|
1012
900
|
hi = mid;
|
|
1013
901
|
}
|
|
1014
902
|
}
|
|
1015
|
-
|
|
1016
903
|
items.splice(lo, 0, add);
|
|
1017
904
|
return isFull ? items.pop() : null;
|
|
1018
905
|
}
|
|
@@ -1026,24 +913,20 @@ var TWO = /*#__PURE__*/JSBI.BigInt(2);
|
|
|
1026
913
|
* Computes floor(sqrt(value))
|
|
1027
914
|
* @param value the value for which to compute the square root, rounded down
|
|
1028
915
|
*/
|
|
1029
|
-
|
|
1030
916
|
function sqrt(value) {
|
|
1031
|
-
!JSBI.greaterThanOrEqual(value, ZERO) ? process.env.NODE_ENV !== "production" ? invariant(false, 'NEGATIVE') : invariant(false) : void 0;
|
|
1032
|
-
|
|
917
|
+
!JSBI.greaterThanOrEqual(value, ZERO) ? process.env.NODE_ENV !== "production" ? invariant(false, 'NEGATIVE') : invariant(false) : void 0;
|
|
918
|
+
// rely on built in sqrt if possible
|
|
1033
919
|
if (JSBI.lessThan(value, MAX_SAFE_INTEGER)) {
|
|
1034
920
|
return JSBI.BigInt(Math.floor(Math.sqrt(JSBI.toNumber(value))));
|
|
1035
921
|
}
|
|
1036
|
-
|
|
1037
922
|
var z;
|
|
1038
923
|
var x;
|
|
1039
924
|
z = value;
|
|
1040
925
|
x = JSBI.add(JSBI.divide(value, TWO), ONE);
|
|
1041
|
-
|
|
1042
926
|
while (JSBI.lessThan(x, z)) {
|
|
1043
927
|
z = x;
|
|
1044
928
|
x = JSBI.divide(JSBI.add(JSBI.divide(value, x), x), TWO);
|
|
1045
929
|
}
|
|
1046
|
-
|
|
1047
930
|
return z;
|
|
1048
931
|
}
|
|
1049
932
|
|