@rabby-wallet/rabby-swap 0.0.80-alpha.1 → 0.0.80-alpha.2
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/tokenPools.d.ts +3 -4
- package/dist/tokenPools.js +6 -14
- package/package.json +1 -1
package/dist/tokenPools.d.ts
CHANGED
|
@@ -13,10 +13,9 @@ export declare const STABLE_TOKEN_POOL: readonly TokenPoolToken[];
|
|
|
13
13
|
export declare const NATIVE_AND_DERIVATIVE_TOKEN_POOL: readonly TokenPoolToken[];
|
|
14
14
|
/**
|
|
15
15
|
* Returns true when both tokens form a same-type pair in the same pool:
|
|
16
|
-
* either two stablecoins, or
|
|
17
|
-
* native-equivalent/derivative pair.
|
|
16
|
+
* either two stablecoins, or two native/derivative tokens.
|
|
18
17
|
*
|
|
19
|
-
* Lookup is O(1) after module initialization. Tokens from different pools
|
|
20
|
-
*
|
|
18
|
+
* Lookup is O(1) after module initialization. Tokens from different pools do
|
|
19
|
+
* not match.
|
|
21
20
|
*/
|
|
22
21
|
export declare const isSameTypeTokenPair: (tokenA: TokenPoolLookupToken | null | undefined, tokenB: TokenPoolLookupToken | null | undefined) => boolean;
|
package/dist/tokenPools.js
CHANGED
|
@@ -115,10 +115,9 @@ export const STABLE_TOKEN_POOL = [
|
|
|
115
115
|
{ chain: "xlayer", id: "0x5d3a1Ff2b6BAb83b63cd9AD0787074081a52ef34" }, // USDe
|
|
116
116
|
];
|
|
117
117
|
/**
|
|
118
|
-
* Native-equivalent and derivative
|
|
118
|
+
* Native-equivalent and derivative tokens.
|
|
119
119
|
*
|
|
120
|
-
*
|
|
121
|
-
* ETH <-> stETH and WETH <-> stETH while rejecting stETH <-> cbETH.
|
|
120
|
+
* Any two tokens in this pool form a same-type pair on the same chain.
|
|
122
121
|
*/
|
|
123
122
|
const ETH_NATIVE_TOKEN = { chain: "eth", id: "eth" }; // ETH
|
|
124
123
|
const ETH_WRAPPED_NATIVE_TOKEN = {
|
|
@@ -148,14 +147,12 @@ const isTokenPoolLookupToken = (token) => !!token &&
|
|
|
148
147
|
const getTokenKey = (token) => `${token.chain.toLowerCase()}${TOKEN_KEY_SEPARATOR}${token.id.toLowerCase()}`;
|
|
149
148
|
const stableTokenKeySet = new Set(STABLE_TOKEN_POOL.map(getTokenKey));
|
|
150
149
|
const nativeAndDerivativeTokenKeySet = new Set(NATIVE_AND_DERIVATIVE_TOKEN_POOL.map(getTokenKey));
|
|
151
|
-
const nativeEquivalentTokenKeySet = new Set([ETH_NATIVE_TOKEN, ETH_WRAPPED_NATIVE_TOKEN].map(getTokenKey));
|
|
152
150
|
/**
|
|
153
151
|
* Returns true when both tokens form a same-type pair in the same pool:
|
|
154
|
-
* either two stablecoins, or
|
|
155
|
-
* native-equivalent/derivative pair.
|
|
152
|
+
* either two stablecoins, or two native/derivative tokens.
|
|
156
153
|
*
|
|
157
|
-
* Lookup is O(1) after module initialization. Tokens from different pools
|
|
158
|
-
*
|
|
154
|
+
* Lookup is O(1) after module initialization. Tokens from different pools do
|
|
155
|
+
* not match.
|
|
159
156
|
*/
|
|
160
157
|
export const isSameTypeTokenPair = (tokenA, tokenB) => {
|
|
161
158
|
if (!isTokenPoolLookupToken(tokenA) || !isTokenPoolLookupToken(tokenB)) {
|
|
@@ -170,11 +167,6 @@ export const isSameTypeTokenPair = (tokenA, tokenB) => {
|
|
|
170
167
|
stableTokenKeySet.has(tokenBKey)) {
|
|
171
168
|
return true;
|
|
172
169
|
}
|
|
173
|
-
if (tokenAKey === tokenBKey) {
|
|
174
|
-
return false;
|
|
175
|
-
}
|
|
176
170
|
return (nativeAndDerivativeTokenKeySet.has(tokenAKey) &&
|
|
177
|
-
nativeAndDerivativeTokenKeySet.has(tokenBKey)
|
|
178
|
-
(nativeEquivalentTokenKeySet.has(tokenAKey) ||
|
|
179
|
-
nativeEquivalentTokenKeySet.has(tokenBKey)));
|
|
171
|
+
nativeAndDerivativeTokenKeySet.has(tokenBKey));
|
|
180
172
|
};
|