forked from Uniswap/interface
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathtokens.ts
More file actions
376 lines (360 loc) · 9.32 KB
/
tokens.ts
File metadata and controls
376 lines (360 loc) · 9.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
import { Currency, Ether, NativeCurrency, Token, WETH9 } from '@uniswap/sdk-core'
import { KROM_TOKEN_ADDRESSES, UNI_ADDRESS } from './addresses'
import { SupportedChainId } from './chains'
export const AMPL = new Token(
SupportedChainId.MAINNET,
'0xD46bA6D942050d489DBd938a2C909A5d5039A161',
9,
'AMPL',
'Ampleforth'
)
export const DAI = new Token(
SupportedChainId.MAINNET,
'0x6B175474E89094C44Da98b954EedeAC495271d0F',
18,
'DAI',
'Dai Stablecoin'
)
export const DAI_ARBITRUM_ONE = new Token(
SupportedChainId.ARBITRUM_ONE,
'0xDA10009cBd5D07dd0CeCc66161FC93D7c9000da1',
18,
'DAI',
'Dai stable coin'
)
export const DAI_OPTIMISM = new Token(
SupportedChainId.OPTIMISM,
'0xDA10009cBd5D07dd0CeCc66161FC93D7c9000da1',
18,
'DAI',
'Dai stable coin'
)
export const USDC = new Token(
SupportedChainId.MAINNET,
'0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48',
6,
'USDC',
'USD//C'
)
export const USDC_ARBITRUM = new Token(
SupportedChainId.ARBITRUM_ONE,
'0xFF970A61A04b1cA14834A43f5dE4533eBDDB5CC8',
6,
'USDC',
'USD//C'
)
export const USDC_POLYGON = new Token(
SupportedChainId.POLYGON,
'0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174',
6,
'USDC',
'USD//C'
)
export const DAI_POLYGON = new Token(
SupportedChainId.POLYGON,
'0x8f3Cf7ad23Cd3CaDbD9735AFf958023239c6A063',
18,
'DAI',
'Dai Stablecoin'
)
export const USDT_POLYGON = new Token(
SupportedChainId.POLYGON,
'0xc2132d05d31c914a87c6611c10748aeb04b58e8f',
6,
'USDT',
'Tether USD'
)
export const WBTC_POLYGON = new Token(
SupportedChainId.POLYGON,
'0x1bfd67037b42cf73acf2047067bd4f2c47d9bfd6',
8,
'WBTC',
'Wrapped BTC'
)
export const USDC_OPTIMISM = new Token(
SupportedChainId.OPTIMISM,
'0x7F5c764cBc14f9669B88837ca1490cCa17c31607',
6,
'USDC',
'USD//C'
)
export const USDT = new Token(
SupportedChainId.MAINNET,
'0xdAC17F958D2ee523a2206206994597C13D831ec7',
6,
'USDT',
'Tether USD'
)
export const USDT_ARBITRUM_ONE = new Token(
SupportedChainId.ARBITRUM_ONE,
'0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9',
6,
'USDT',
'Tether USD'
)
export const USDT_OPTIMISM = new Token(
SupportedChainId.OPTIMISM,
'0x94b008aA00579c1307B0EF2c499aD98a8ce58e58',
6,
'USDT',
'Tether USD'
)
export const WBTC = new Token(
SupportedChainId.MAINNET,
'0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599',
8,
'WBTC',
'Wrapped BTC'
)
export const WBTC_ARBITRUM_ONE = new Token(
SupportedChainId.ARBITRUM_ONE,
'0x2f2a2543B76A4166549F7aaB2e75Bef0aefC5B0f',
8,
'WBTC',
'Wrapped BTC'
)
export const WBTC_OPTIMISM = new Token(
SupportedChainId.OPTIMISM,
'0x68f180fcCe6836688e9084f035309E29Bf0A2095',
8,
'WBTC',
'Wrapped BTC'
)
export const FEI = new Token(
SupportedChainId.MAINNET,
'0x956F47F50A910163D8BF957Cf5846D573E7f87CA',
18,
'FEI',
'Fei USD'
)
export const TRIBE = new Token(
SupportedChainId.MAINNET,
'0xc7283b66Eb1EB5FB86327f08e1B5816b0720212B',
18,
'TRIBE',
'Tribe'
)
export const FRAX = new Token(
SupportedChainId.MAINNET,
'0x853d955aCEf822Db058eb8505911ED77F175b99e',
18,
'FRAX',
'Frax'
)
export const FXS = new Token(
SupportedChainId.MAINNET,
'0x3432B6A60D23Ca0dFCa7761B7ab56459D9C964D0',
18,
'FXS',
'Frax Share'
)
export const renBTC = new Token(
SupportedChainId.MAINNET,
'0xEB4C2781e4ebA804CE9a9803C67d0893436bB27D',
8,
'renBTC',
'renBTC'
)
export const ETH2X_FLI = new Token(
SupportedChainId.MAINNET,
'0xAa6E8127831c9DE45ae56bB1b0d4D4Da6e5665BD',
18,
'ETH2x-FLI',
'ETH 2x Flexible Leverage Index'
)
export const KROM: { [chainId: number]: Token } = {
[SupportedChainId.KOVAN]: new Token(
SupportedChainId.KOVAN,
KROM_TOKEN_ADDRESSES[SupportedChainId.KOVAN],
18,
'KROM',
'Kromatika'
),
[SupportedChainId.OPTIMISTIC_KOVAN]: new Token(
SupportedChainId.OPTIMISTIC_KOVAN,
KROM_TOKEN_ADDRESSES[SupportedChainId.OPTIMISTIC_KOVAN],
18,
'KROM',
'Kromatika'
),
[SupportedChainId.OPTIMISM]: new Token(
SupportedChainId.OPTIMISM,
KROM_TOKEN_ADDRESSES[SupportedChainId.OPTIMISM],
18,
'KROM',
'Kromatika'
),
[SupportedChainId.ARBITRUM_RINKEBY]: new Token(
SupportedChainId.ARBITRUM_RINKEBY,
KROM_TOKEN_ADDRESSES[SupportedChainId.ARBITRUM_RINKEBY],
18,
'KROM',
'Kromatika'
),
[SupportedChainId.ARBITRUM_ONE]: new Token(
SupportedChainId.ARBITRUM_ONE,
KROM_TOKEN_ADDRESSES[SupportedChainId.ARBITRUM_ONE],
18,
'KROM',
'Kromatika'
),
[SupportedChainId.MAINNET]: new Token(
SupportedChainId.MAINNET,
KROM_TOKEN_ADDRESSES[SupportedChainId.MAINNET],
18,
'KROM',
'Kromatika'
),
[SupportedChainId.POLYGON]: new Token(
SupportedChainId.POLYGON,
KROM_TOKEN_ADDRESSES[SupportedChainId.POLYGON],
18,
'KROM',
'Kromatika'
),
[SupportedChainId.POLYGON_MUMBAI]: new Token(
SupportedChainId.POLYGON_MUMBAI,
KROM_TOKEN_ADDRESSES[SupportedChainId.POLYGON_MUMBAI],
18,
'KROM',
'Kromatika'
),
}
export const WETH: { [chainId: number]: Token } = {
[SupportedChainId.OPTIMISM]: new Token(
SupportedChainId.OPTIMISM,
'0x4200000000000000000000000000000000000006',
18,
'KROM',
'Kromatika'
),
[SupportedChainId.ARBITRUM_ONE]: new Token(
SupportedChainId.ARBITRUM_ONE,
'0x82aF49447D8a07e3bd95BD0d56f35241523fBab1',
18,
'WETH',
'Wrapped Ether'
),
[SupportedChainId.MAINNET]: new Token(
SupportedChainId.MAINNET,
'0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2',
18,
'WETH',
'Wrapped Ether'
),
[SupportedChainId.POLYGON]: new Token(
SupportedChainId.POLYGON,
'0x7ceb23fd6bc0add59e62ac25578270cff1b9f619',
18,
'WETH',
'Wrapped Ether'
),
}
export const CHAIN_NATIVE_TOKEN_SYMBOL: { [chainId: number]: string } = {
[SupportedChainId.OPTIMISM]: 'ETH',
[SupportedChainId.ARBITRUM_ONE]: 'ETH',
[SupportedChainId.MAINNET]: 'ETH',
[SupportedChainId.POLYGON]: 'MATIC',
}
export const NATIVE_TOKEN_ADDRESS = '0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee'
export const WETH_POLYGON_MUMBAI = new Token(
SupportedChainId.POLYGON_MUMBAI,
'0xa6fa4fb5f76172d178d61b04b0ecd319c5d1c0aa',
18,
'WETH',
'Wrapped Ether'
)
export const WETH_POLYGON = new Token(
SupportedChainId.POLYGON,
'0x7ceb23fd6bc0add59e62ac25578270cff1b9f619',
18,
'WETH',
'Wrapped Ether'
)
export const UNI: { [chainId: number]: Token } = {
[SupportedChainId.MAINNET]: new Token(SupportedChainId.MAINNET, UNI_ADDRESS[1], 18, 'UNI', 'Uniswap'),
[SupportedChainId.RINKEBY]: new Token(SupportedChainId.RINKEBY, UNI_ADDRESS[4], 18, 'UNI', 'Uniswap'),
[SupportedChainId.ROPSTEN]: new Token(SupportedChainId.ROPSTEN, UNI_ADDRESS[3], 18, 'UNI', 'Uniswap'),
[SupportedChainId.GOERLI]: new Token(SupportedChainId.GOERLI, UNI_ADDRESS[5], 18, 'UNI', 'Uniswap'),
[SupportedChainId.KOVAN]: new Token(SupportedChainId.KOVAN, UNI_ADDRESS[42], 18, 'UNI', 'Uniswap'),
}
export const WRAPPED_NATIVE_CURRENCY: { [chainId: number]: Token } = {
...WETH9,
[SupportedChainId.OPTIMISM]: new Token(
SupportedChainId.OPTIMISM,
'0x4200000000000000000000000000000000000006',
18,
'WETH',
'Wrapped Ether'
),
[SupportedChainId.OPTIMISTIC_KOVAN]: new Token(
SupportedChainId.OPTIMISTIC_KOVAN,
'0x4200000000000000000000000000000000000006',
18,
'WETH',
'Wrapped Ether'
),
[SupportedChainId.ARBITRUM_ONE]: new Token(
SupportedChainId.ARBITRUM_ONE,
'0x82aF49447D8a07e3bd95BD0d56f35241523fBab1',
18,
'WETH',
'Wrapped Ether'
),
[SupportedChainId.ARBITRUM_RINKEBY]: new Token(
SupportedChainId.ARBITRUM_RINKEBY,
'0xB47e6A5f8b33b3F17603C83a0535A9dcD7E32681',
18,
'WETH',
'Wrapped Ether'
),
[SupportedChainId.POLYGON]: new Token(
SupportedChainId.POLYGON,
'0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270',
18,
'WMATIC',
'Wrapped MATIC'
),
[SupportedChainId.POLYGON_MUMBAI]: new Token(
SupportedChainId.POLYGON_MUMBAI,
'0x9c3C9283D3e44854697Cd22D3Faa240Cfb032889',
18,
'WMATIC',
'Wrapped MATIC'
),
}
function isMatic(chainId: number): chainId is SupportedChainId.POLYGON | SupportedChainId.POLYGON_MUMBAI {
return chainId === SupportedChainId.POLYGON_MUMBAI || chainId === SupportedChainId.POLYGON
}
class MaticNativeCurrency extends NativeCurrency {
equals(other: Currency): boolean {
return other.isNative && other.chainId === this.chainId
}
get wrapped(): Token {
if (!isMatic(this.chainId)) throw new Error('Not matic')
return WRAPPED_NATIVE_CURRENCY[this.chainId]
}
public constructor(chainId: number) {
if (!isMatic(chainId)) throw new Error('Not matic')
super(chainId, 18, 'MATIC', 'Polygon Matic')
}
}
export class ExtendedEther extends Ether {
public get wrapped(): Token {
if (this.chainId in WRAPPED_NATIVE_CURRENCY) return WRAPPED_NATIVE_CURRENCY[this.chainId]
throw new Error('Unsupported chain ID')
}
private static _cachedExtendedEther: { [chainId: number]: NativeCurrency } = {}
public static onChain(chainId: number): ExtendedEther {
return this._cachedExtendedEther[chainId] ?? (this._cachedExtendedEther[chainId] = new ExtendedEther(chainId))
}
}
const cachedNativeCurrency: { [chainId: number]: NativeCurrency } = {}
export function nativeOnChain(chainId: number): NativeCurrency {
return (
cachedNativeCurrency[chainId] ??
(cachedNativeCurrency[chainId] = isMatic(chainId)
? new MaticNativeCurrency(chainId)
: ExtendedEther.onChain(chainId))
)
}