dev
dart 52 lines 1.74 KB
Raw
1 import 'package:cw_core/erc20_token.dart';
2
3 /// USDT0 (Omnichain USDT) config.
4 /// Addresses and EIDs from https://docs.usdt0.to/technical-documentation/deployments
5 class USDT0Config {
6 USDT0Config._();
7
8 static const String ethereumOftAdapter = '0x6C96dE32CEa08842dcc4058c14d3aaAD7Fa41dee';
9
10 static const String ethereumNativeUsdt = '0xdac17f958d2ee523a2206206994597c13d831ec7';
11
12 static const Map<int, String> usdt0TokenAddressByChainId = {
13 1: ethereumNativeUsdt,
14 137: '0xc2132D05D31c914a87C6611C10748AEb04B58e8F',
15 42161: '0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9',
16 };
17
18 static const Map<int, String> oftContractAddressByChainId = {
19 1: ethereumOftAdapter,
20 137: '0x6BA10300f0DC58B7a1e4c0e41f5daBb7D7829e13',
21 42161: '0x14E4A1B13bf7F943c8ff7C51fb60FA964A298D92',
22 };
23
24 static const Map<int, int> endpointIdByChainId = {
25 1: 30101,
26 137: 30109,
27 42161: 30110,
28 };
29
30 static const int ethereumChainId = 1;
31
32 static List<int> get supportedChainIds => usdt0TokenAddressByChainId.keys.toList(growable: false);
33
34 static String? getOftAdapterAddress(int chainId) {
35 if (chainId == ethereumChainId) return ethereumOftAdapter;
36 return null;
37 }
38
39 static String? getUsdt0TokenAddress(int chainId) => usdt0TokenAddressByChainId[chainId];
40
41 static String? getOftContractAddress(int chainId) => oftContractAddressByChainId[chainId];
42
43 static int? getEndpointId(int chainId) => endpointIdByChainId[chainId];
44
45 static bool isChainSupported(int chainId) => usdt0TokenAddressByChainId.containsKey(chainId);
46
47 static bool isUSDT0Token(Erc20Token token, int chainId) {
48 final address = getUsdt0TokenAddress(chainId);
49 if (address == null) return false;
50 return token.contractAddress.toLowerCase() == address.toLowerCase();
51 }
52 }