@sun-protocol/sun-sdk-chains 0.1.0-beta.0

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 ADDED
@@ -0,0 +1,31 @@
1
+ # @sun-protocol/sun-sdk-chains
2
+
3
+ Network configuration, service endpoints, and known SUN protocol contract addresses for TRON Mainnet and Nile.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ npm install @sun-protocol/sun-sdk-chains
9
+ ```
10
+
11
+ ## Example
12
+
13
+ ```ts
14
+ import {
15
+ getChainConfig,
16
+ getContractAddress,
17
+ getNetworkEndpoints,
18
+ } from '@sun-protocol/sun-sdk-chains'
19
+
20
+ const chain = getChainConfig('mainnet')
21
+ const router = getContractAddress('mainnet', 'sunswapV2Router')
22
+ const endpoints = getNetworkEndpoints('mainnet')
23
+ ```
24
+
25
+ Primary exports include chain and endpoint lookup functions, `CHAIN_CONFIGS`, `NETWORK_ENDPOINTS`, wrapped-native helpers, and network types.
26
+
27
+ This is a data-only package. It does not create HTTP clients, TronWeb instances, wallets, or runtimes, and top-level imports do not perform network requests.
28
+
29
+ Requires Node.js 20 or a compatible JavaScript runtime.
30
+
31
+ [Full API documentation](https://github.com/sun-protocol/sun-sdk/blob/main/docs/sdk/api/chains.md)
package/dist/index.cjs ADDED
@@ -0,0 +1,182 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/index.ts
21
+ var index_exports = {};
22
+ __export(index_exports, {
23
+ CHAIN_CONFIGS: () => CHAIN_CONFIGS,
24
+ NETWORK_ENDPOINTS: () => NETWORK_ENDPOINTS,
25
+ getChainConfig: () => getChainConfig,
26
+ getContractAddress: () => getContractAddress,
27
+ getNativeCurrency: () => getNativeCurrency,
28
+ getNetworkEndpoints: () => getNetworkEndpoints,
29
+ getWrappedNative: () => getWrappedNative,
30
+ getWrappedNativeAddress: () => getWrappedNativeAddress,
31
+ isSupportedNetwork: () => isSupportedNetwork,
32
+ listNetworks: () => listNetworks
33
+ });
34
+ module.exports = __toCommonJS(index_exports);
35
+
36
+ // src/endpoints.ts
37
+ var import_sun_sdk_core = require("@sun-protocol/sun-sdk-core");
38
+ var NETWORK_ENDPOINTS = {
39
+ mainnet: {
40
+ rpc: "https://api.trongrid.io",
41
+ router: "https://open.sun.io/apiv2/quote/swap",
42
+ time: "https://open.sun.io/apiv2/chain/block",
43
+ tronScan: "https://apilist.tronscanapi.com",
44
+ sunPump: "https://api-v2.sunpump.meme/pump-api"
45
+ },
46
+ nile: {
47
+ rpc: "https://api.nileex.io",
48
+ router: null,
49
+ time: "https://open.sun.io/apiv2/chain/block",
50
+ tronScan: "https://nileapi.tronscan.org",
51
+ sunPump: null
52
+ }
53
+ };
54
+ function getNetworkEndpoints(network) {
55
+ const endpoints = NETWORK_ENDPOINTS[network];
56
+ if (!endpoints) {
57
+ throw new import_sun_sdk_core.SDKError("SDK_UNSUPPORTED_NETWORK", `Unsupported network: ${String(network)}`, { network });
58
+ }
59
+ return endpoints;
60
+ }
61
+
62
+ // src/networks.ts
63
+ var import_sun_sdk_core2 = require("@sun-protocol/sun-sdk-core");
64
+ var MAINNET_UNISWAP_CHAIN_ID = 728126428;
65
+ var NILE_UNISWAP_CHAIN_ID = 3448148188;
66
+ function addr(value) {
67
+ return (0, import_sun_sdk_core2.assertTronAddress)(value);
68
+ }
69
+ function wrappedNative(chainId) {
70
+ const token = import_sun_sdk_core2.WETH9[chainId];
71
+ if (!token) {
72
+ throw new import_sun_sdk_core2.SDKError("SDK_UNSUPPORTED_NETWORK", `Missing wrapped native token for chain: ${chainId}`, { chainId });
73
+ }
74
+ return token;
75
+ }
76
+ var CHAIN_CONFIGS = {
77
+ mainnet: {
78
+ network: "mainnet",
79
+ uniswapChainId: MAINNET_UNISWAP_CHAIN_ID,
80
+ displayName: "TRON Mainnet",
81
+ nativeCurrency: import_sun_sdk_core2.Ether.onChain(MAINNET_UNISWAP_CHAIN_ID),
82
+ wrappedNative: wrappedNative(MAINNET_UNISWAP_CHAIN_ID),
83
+ wrappedNativeAddress: addr("TNUC9Qb1rRpS5CbWLmNMxXBjyFoydXjWFR"),
84
+ contracts: {
85
+ trx: addr("T9yD14Nj9j7xAB4dbGeiX9h8unkKHxuWwb"),
86
+ wtrx: addr("TNUC9Qb1rRpS5CbWLmNMxXBjyFoydXjWFR"),
87
+ usdt: addr("TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t"),
88
+ // gray test usdt for v3 usdt pool fix
89
+ // usdt: addr('TZCYYShNNo1WHHBDcTsztHVw2V5MHpJmy7'),
90
+ universalRouter: addr("TQqgNg13s2DjvXhW1ky4v6TsR8wZGvb7Y4"),
91
+ permit2: addr("TTJxU3P8rHycAyFY4kVtGNfmnMH4ezcuM9"),
92
+ permit2Helper: addr("TBc4z7389sAtM2nZRgWwHSJnHrWeUrZ3rL"),
93
+ multicall: addr("TBoFgjwfvu5SvT3KMCQYXHQ97bnHAjrDq3"),
94
+ sunswapV2Factory: addr("TKWJdrQkqHisa1X8HUdHEfREvTzw4pMAaY"),
95
+ sunswapV2Poly: addr("THAALWtwcxUxuSJ8h4ZSZGzzTaYhVQaNPf"),
96
+ sunswapV2Router: addr("TNJVzGqKBWkJxJB5XYSqGAwUTV15U24pPq"),
97
+ sunswapV3Factory: addr("TThJt8zaJzJMhCEScH7zWKnp5buVZqys9x"),
98
+ sunswapV3PositionManager: addr("TLSWrv7eC1AZCXkRjpqMZUmvgd99cj7pPF"),
99
+ sunswapV4PoolManager: addr("TVjuTE3V5bMVdpfNhid8kD2v35T2k1u1Br"),
100
+ sunswapV4PositionManager: addr("TC8xQzPHfn5KceZV6s6GmZkBCFWWUoPXs1"),
101
+ sunswapV4LpFeeHelper: addr("TN673trKGEALTAYB6n17SBGpzPwXrDqUKp"),
102
+ launchpad: addr("TTfvyrAz86hbZk5iDpKD78pqLGgi8C7AAw"),
103
+ psmUsdt: addr("TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t"),
104
+ psmUsdd: addr("TXDk8mbtRbXeYuMNS83CfKPaYYT8XWv9Hz"),
105
+ psm: addr("TBXW4hS5KYjjbJXDpnrPf4zhkLwrpUjbyz"),
106
+ psmGemJoin: addr("TSUYvQ5tdd3DijCD1uGunGLpftHuSZ12sQ"),
107
+ psmInfoReader: addr("TDQ9W8Snm59TSRh6DvvMVcoabpdJwAeghA")
108
+ }
109
+ },
110
+ nile: {
111
+ network: "nile",
112
+ uniswapChainId: NILE_UNISWAP_CHAIN_ID,
113
+ displayName: "TRON Nile",
114
+ nativeCurrency: import_sun_sdk_core2.Ether.onChain(NILE_UNISWAP_CHAIN_ID),
115
+ wrappedNative: wrappedNative(NILE_UNISWAP_CHAIN_ID),
116
+ wrappedNativeAddress: addr("TYsbWxNnyTgsZaTFaue9hqpxkU3Fkco94a"),
117
+ contracts: {
118
+ trx: addr("T9yD14Nj9j7xAB4dbGeiX9h8unkKHxuWwb"),
119
+ wtrx: addr("TYsbWxNnyTgsZaTFaue9hqpxkU3Fkco94a"),
120
+ usdt: addr("TXYZopYRdj2D9XRtbG411XZZ3kM5VkAeBf"),
121
+ // test usdt for v3 test
122
+ // usdt: addr('TNPzUytcAm9vtW1PDRVNsdppawBdbEVTDB'),
123
+ universalRouter: addr("TEgq4237arNE7jX74KCDkc1MXdZeWNkGVj"),
124
+ permit2: addr("TYQuuhGbEMxF7nZxUHV3uHJxAVVAegNU9h"),
125
+ permit2Helper: addr("TJcVB8vQVpAoGwp9owx1Ct91D4QpKVd78h"),
126
+ multicall: addr("TPX1jdAu3qdGCZCWX1m75RtB2wgtKotuDC"),
127
+ sunswapV2Factory: addr("THomLGMLhAjMecQf9FQjbZ8a1RtwsZLrGE"),
128
+ sunswapV2Poly: addr("THKx73oAnA6kejnEBzgFkNH2mD93neqmu8"),
129
+ sunswapV2Router: addr("TMn1qrmYUMSTXo9babrJLzepKZoPC7M6Sy"),
130
+ sunswapV3Factory: addr("TUTGcsGDRScK1gsDPMELV2QZxeESWb1Gac"),
131
+ sunswapV3PositionManager: addr("TPQzqHbCzQfoVdAV6bLwGDos8Lk2UjXz2R"),
132
+ sunswapV4PoolManager: addr("TVivLPeq7FMmTG8Z7HaiBgHTsMwCEcipKT"),
133
+ sunswapV4PositionManager: addr("TMTQ1BYo15aGgZXHcsBWXyae8bVaAdgfLP"),
134
+ sunswapV4LpFeeHelper: addr("TYKPrQ45J7w9E73JaTe9VWR7yAut8nkbgf"),
135
+ launchpad: addr("TLtTyEwqacNKc5CHLunKvxmqLB336R4Lrm"),
136
+ psmUsdt: addr("TZDnq7egPqzi7H4SXy1ABvwaVRvRTaVfJW"),
137
+ psmUsdd: addr("TZ78R2E6ejfFhxq8hxrmuqT6hGBxjHQbo4"),
138
+ psm: addr("TPj6Z88798iDSCuFe5gFcivJCSMsfmHKfr"),
139
+ psmGemJoin: addr("TSX7g6WiZaKPkVvrPaDHpRgoVsSvbPfrBv"),
140
+ psmInfoReader: addr("TSJFS9k3wkD6eTAtzqXvnCnS5tsvzbYKns")
141
+ }
142
+ }
143
+ };
144
+ function listNetworks() {
145
+ return ["mainnet", "nile"];
146
+ }
147
+ function isSupportedNetwork(network) {
148
+ return network === "mainnet" || network === "nile";
149
+ }
150
+ function getChainConfig(network) {
151
+ const config = CHAIN_CONFIGS[network];
152
+ if (!config) {
153
+ throw new import_sun_sdk_core2.SDKError("SDK_UNSUPPORTED_NETWORK", `Unsupported network: ${String(network)}`, { network });
154
+ }
155
+ return config;
156
+ }
157
+ function getContractAddress(network, key) {
158
+ return getChainConfig(network).contracts[key];
159
+ }
160
+ function getNativeCurrency(network) {
161
+ return getChainConfig(network).nativeCurrency;
162
+ }
163
+ function getWrappedNative(network) {
164
+ return getChainConfig(network).wrappedNative;
165
+ }
166
+ function getWrappedNativeAddress(network) {
167
+ return getChainConfig(network).wrappedNativeAddress;
168
+ }
169
+ // Annotate the CommonJS export names for ESM import in node:
170
+ 0 && (module.exports = {
171
+ CHAIN_CONFIGS,
172
+ NETWORK_ENDPOINTS,
173
+ getChainConfig,
174
+ getContractAddress,
175
+ getNativeCurrency,
176
+ getNetworkEndpoints,
177
+ getWrappedNative,
178
+ getWrappedNativeAddress,
179
+ isSupportedNetwork,
180
+ listNetworks
181
+ });
182
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts","../src/endpoints.ts","../src/networks.ts"],"sourcesContent":["export * from './endpoints.js'\nexport * from './networks.js'\n","import { SDKError, type Network } from '@sun-protocol/sun-sdk-core'\n\nexport interface NetworkEndpoints {\n readonly rpc: string\n readonly router: string | null\n readonly time: string\n readonly tronScan: string\n readonly sunPump: string | null\n}\n\nexport const NETWORK_ENDPOINTS: Record<Network, NetworkEndpoints> = {\n mainnet: {\n rpc: 'https://api.trongrid.io',\n router: 'https://open.sun.io/apiv2/quote/swap',\n time: 'https://open.sun.io/apiv2/chain/block',\n tronScan: 'https://apilist.tronscanapi.com',\n sunPump: 'https://api-v2.sunpump.meme/pump-api',\n },\n nile: {\n rpc: 'https://api.nileex.io',\n router: null,\n time: 'https://open.sun.io/apiv2/chain/block',\n tronScan: 'https://nileapi.tronscan.org',\n sunPump: null,\n },\n}\n\nexport function getNetworkEndpoints(network: Network): NetworkEndpoints {\n const endpoints = NETWORK_ENDPOINTS[network]\n if (!endpoints) {\n throw new SDKError('SDK_UNSUPPORTED_NETWORK', `Unsupported network: ${String(network)}`, { network })\n }\n return endpoints\n}\n","import {\n Ether,\n SDKError,\n WETH9,\n assertTronAddress,\n type NativeCurrency,\n type Network,\n type Token,\n type TronAddress,\n} from '@sun-protocol/sun-sdk-core'\n\nexport interface ChainContracts {\n readonly trx: TronAddress\n readonly wtrx: TronAddress\n readonly usdt: TronAddress\n readonly universalRouter: TronAddress\n readonly permit2: TronAddress\n readonly permit2Helper: TronAddress\n readonly multicall: TronAddress\n readonly sunswapV2Factory: TronAddress\n readonly sunswapV2Poly: TronAddress\n readonly sunswapV2Router: TronAddress\n readonly sunswapV3Factory: TronAddress\n readonly sunswapV3PositionManager: TronAddress\n readonly sunswapV4PoolManager: TronAddress\n readonly sunswapV4PositionManager: TronAddress\n readonly sunswapV4LpFeeHelper: TronAddress\n readonly launchpad: TronAddress\n readonly psmUsdt: TronAddress\n readonly psmUsdd: TronAddress\n readonly psm: TronAddress\n readonly psmGemJoin: TronAddress\n readonly psmInfoReader: TronAddress\n}\n\nexport interface ChainConfig {\n readonly network: Network\n readonly uniswapChainId: number\n readonly displayName: string\n readonly nativeCurrency: NativeCurrency\n readonly wrappedNative: Token\n readonly wrappedNativeAddress: TronAddress\n readonly contracts: ChainContracts\n}\n\nconst MAINNET_UNISWAP_CHAIN_ID = 728126428\nconst NILE_UNISWAP_CHAIN_ID = 3448148188\n\nfunction addr(value: string): TronAddress {\n return assertTronAddress(value)\n}\n\nfunction wrappedNative(chainId: number): Token {\n const token = WETH9[chainId]\n if (!token) {\n throw new SDKError('SDK_UNSUPPORTED_NETWORK', `Missing wrapped native token for chain: ${chainId}`, { chainId })\n }\n return token\n}\n\nexport const CHAIN_CONFIGS: Record<Network, ChainConfig> = {\n mainnet: {\n network: 'mainnet',\n uniswapChainId: MAINNET_UNISWAP_CHAIN_ID,\n displayName: 'TRON Mainnet',\n nativeCurrency: Ether.onChain(MAINNET_UNISWAP_CHAIN_ID),\n wrappedNative: wrappedNative(MAINNET_UNISWAP_CHAIN_ID),\n wrappedNativeAddress: addr('TNUC9Qb1rRpS5CbWLmNMxXBjyFoydXjWFR'),\n contracts: {\n trx: addr('T9yD14Nj9j7xAB4dbGeiX9h8unkKHxuWwb'),\n wtrx: addr('TNUC9Qb1rRpS5CbWLmNMxXBjyFoydXjWFR'),\n usdt: addr('TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t'),\n // gray test usdt for v3 usdt pool fix\n // usdt: addr('TZCYYShNNo1WHHBDcTsztHVw2V5MHpJmy7'),\n universalRouter: addr('TQqgNg13s2DjvXhW1ky4v6TsR8wZGvb7Y4'),\n permit2: addr('TTJxU3P8rHycAyFY4kVtGNfmnMH4ezcuM9'),\n permit2Helper: addr('TBc4z7389sAtM2nZRgWwHSJnHrWeUrZ3rL'),\n multicall: addr('TBoFgjwfvu5SvT3KMCQYXHQ97bnHAjrDq3'),\n sunswapV2Factory: addr('TKWJdrQkqHisa1X8HUdHEfREvTzw4pMAaY'),\n sunswapV2Poly: addr('THAALWtwcxUxuSJ8h4ZSZGzzTaYhVQaNPf'),\n sunswapV2Router: addr('TNJVzGqKBWkJxJB5XYSqGAwUTV15U24pPq'),\n sunswapV3Factory: addr('TThJt8zaJzJMhCEScH7zWKnp5buVZqys9x'),\n sunswapV3PositionManager: addr('TLSWrv7eC1AZCXkRjpqMZUmvgd99cj7pPF'),\n sunswapV4PoolManager: addr('TVjuTE3V5bMVdpfNhid8kD2v35T2k1u1Br'),\n sunswapV4PositionManager: addr('TC8xQzPHfn5KceZV6s6GmZkBCFWWUoPXs1'),\n sunswapV4LpFeeHelper: addr('TN673trKGEALTAYB6n17SBGpzPwXrDqUKp'),\n launchpad: addr('TTfvyrAz86hbZk5iDpKD78pqLGgi8C7AAw'),\n psmUsdt: addr('TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t'),\n psmUsdd: addr('TXDk8mbtRbXeYuMNS83CfKPaYYT8XWv9Hz'),\n psm: addr('TBXW4hS5KYjjbJXDpnrPf4zhkLwrpUjbyz'),\n psmGemJoin: addr('TSUYvQ5tdd3DijCD1uGunGLpftHuSZ12sQ'),\n psmInfoReader: addr('TDQ9W8Snm59TSRh6DvvMVcoabpdJwAeghA'),\n },\n },\n nile: {\n network: 'nile',\n uniswapChainId: NILE_UNISWAP_CHAIN_ID,\n displayName: 'TRON Nile',\n nativeCurrency: Ether.onChain(NILE_UNISWAP_CHAIN_ID),\n wrappedNative: wrappedNative(NILE_UNISWAP_CHAIN_ID),\n wrappedNativeAddress: addr('TYsbWxNnyTgsZaTFaue9hqpxkU3Fkco94a'),\n contracts: {\n trx: addr('T9yD14Nj9j7xAB4dbGeiX9h8unkKHxuWwb'),\n wtrx: addr('TYsbWxNnyTgsZaTFaue9hqpxkU3Fkco94a'),\n usdt: addr('TXYZopYRdj2D9XRtbG411XZZ3kM5VkAeBf'),\n // test usdt for v3 test\n // usdt: addr('TNPzUytcAm9vtW1PDRVNsdppawBdbEVTDB'),\n universalRouter: addr('TEgq4237arNE7jX74KCDkc1MXdZeWNkGVj'),\n permit2: addr('TYQuuhGbEMxF7nZxUHV3uHJxAVVAegNU9h'),\n permit2Helper: addr('TJcVB8vQVpAoGwp9owx1Ct91D4QpKVd78h'),\n multicall: addr('TPX1jdAu3qdGCZCWX1m75RtB2wgtKotuDC'),\n sunswapV2Factory: addr('THomLGMLhAjMecQf9FQjbZ8a1RtwsZLrGE'),\n sunswapV2Poly: addr('THKx73oAnA6kejnEBzgFkNH2mD93neqmu8'),\n sunswapV2Router: addr('TMn1qrmYUMSTXo9babrJLzepKZoPC7M6Sy'),\n sunswapV3Factory: addr('TUTGcsGDRScK1gsDPMELV2QZxeESWb1Gac'),\n sunswapV3PositionManager: addr('TPQzqHbCzQfoVdAV6bLwGDos8Lk2UjXz2R'),\n sunswapV4PoolManager: addr('TVivLPeq7FMmTG8Z7HaiBgHTsMwCEcipKT'),\n sunswapV4PositionManager: addr('TMTQ1BYo15aGgZXHcsBWXyae8bVaAdgfLP'),\n sunswapV4LpFeeHelper: addr('TYKPrQ45J7w9E73JaTe9VWR7yAut8nkbgf'),\n launchpad: addr('TLtTyEwqacNKc5CHLunKvxmqLB336R4Lrm'),\n psmUsdt: addr('TZDnq7egPqzi7H4SXy1ABvwaVRvRTaVfJW'),\n psmUsdd: addr('TZ78R2E6ejfFhxq8hxrmuqT6hGBxjHQbo4'),\n psm: addr('TPj6Z88798iDSCuFe5gFcivJCSMsfmHKfr'),\n psmGemJoin: addr('TSX7g6WiZaKPkVvrPaDHpRgoVsSvbPfrBv'),\n psmInfoReader: addr('TSJFS9k3wkD6eTAtzqXvnCnS5tsvzbYKns'),\n },\n },\n}\n\nexport function listNetworks(): Network[] {\n return ['mainnet', 'nile']\n}\n\nexport function isSupportedNetwork(network: string): network is Network {\n return network === 'mainnet' || network === 'nile'\n}\n\nexport function getChainConfig(network: Network): ChainConfig {\n const config = CHAIN_CONFIGS[network]\n if (!config) {\n throw new SDKError('SDK_UNSUPPORTED_NETWORK', `Unsupported network: ${String(network)}`, { network })\n }\n return config\n}\n\nexport function getContractAddress(network: Network, key: keyof ChainContracts): TronAddress {\n return getChainConfig(network).contracts[key]\n}\n\nexport function getNativeCurrency(network: Network): NativeCurrency {\n return getChainConfig(network).nativeCurrency\n}\n\nexport function getWrappedNative(network: Network): Token {\n return getChainConfig(network).wrappedNative\n}\n\nexport function getWrappedNativeAddress(network: Network): TronAddress {\n return getChainConfig(network).wrappedNativeAddress\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,0BAAuC;AAUhC,IAAM,oBAAuD;AAAA,EAClE,SAAS;AAAA,IACP,KAAK;AAAA,IACL,QAAQ;AAAA,IACR,MAAM;AAAA,IACN,UAAU;AAAA,IACV,SAAS;AAAA,EACX;AAAA,EACA,MAAM;AAAA,IACJ,K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ACrD,eAAe,KAAK,oCAAoC;AAAA,IAC1D;AAAA,EACF;AACF;AAEO,SAAS,eAA0B;AACxC,SAAO,CAAC,WAAW,MAAM;AAC3B;AAEO,SAAS,mBAAmB,SAAqC;AACtE,SAAO,YAAY,aAAa,YAAY;AAC9C;AAEO,SAAS,eAAe,SAA+B;AAC5D,QAAM,SAAS,cAAc,OAAO;AACpC,MAAI,CAAC,QAAQ;AACX,UAAM,IAAI,8BAAS,2BAA2B,wBAAwB,OAAO,OAAO,CAAC,IAAI,EAAE,QAAQ,CAAC;AAAA,EACtG;AACA,SAAO;AACT;AAEO,SAAS,mBAAmB,SAAkB,KAAwC;AAC3F,SAAO,eAAe,OAAO,EAAE,UAAU,GAAG;AAC9C;AAEO,SAAS,kBAAkB,SAAkC;AAClE,SAAO,eAAe,OAAO,EAAE;AACjC;AAEO,SAAS,iBAAiB,SAAyB;AACxD,SAAO,eAAe,OAAO,EAAE;AACjC;AAEO,SAAS,wBAAwB,SAA+B;AACrE,SAAO,eAAe,OAAO,EAAE;AACjC;","names":["import_sun_sdk_core"]}
@@ -0,0 +1,54 @@
1
+ import { Network, NativeCurrency, Token, TronAddress } from '@sun-protocol/sun-sdk-core';
2
+
3
+ interface NetworkEndpoints {
4
+ readonly rpc: string;
5
+ readonly router: string | null;
6
+ readonly time: string;
7
+ readonly tronScan: string;
8
+ readonly sunPump: string | null;
9
+ }
10
+ declare const NETWORK_ENDPOINTS: Record<Network, NetworkEndpoints>;
11
+ declare function getNetworkEndpoints(network: Network): NetworkEndpoints;
12
+
13
+ interface ChainContracts {
14
+ readonly trx: TronAddress;
15
+ readonly wtrx: TronAddress;
16
+ readonly usdt: TronAddress;
17
+ readonly universalRouter: TronAddress;
18
+ readonly permit2: TronAddress;
19
+ readonly permit2Helper: TronAddress;
20
+ readonly multicall: TronAddress;
21
+ readonly sunswapV2Factory: TronAddress;
22
+ readonly sunswapV2Poly: TronAddress;
23
+ readonly sunswapV2Router: TronAddress;
24
+ readonly sunswapV3Factory: TronAddress;
25
+ readonly sunswapV3PositionManager: TronAddress;
26
+ readonly sunswapV4PoolManager: TronAddress;
27
+ readonly sunswapV4PositionManager: TronAddress;
28
+ readonly sunswapV4LpFeeHelper: TronAddress;
29
+ readonly launchpad: TronAddress;
30
+ readonly psmUsdt: TronAddress;
31
+ readonly psmUsdd: TronAddress;
32
+ readonly psm: TronAddress;
33
+ readonly psmGemJoin: TronAddress;
34
+ readonly psmInfoReader: TronAddress;
35
+ }
36
+ interface ChainConfig {
37
+ readonly network: Network;
38
+ readonly uniswapChainId: number;
39
+ readonly displayName: string;
40
+ readonly nativeCurrency: NativeCurrency;
41
+ readonly wrappedNative: Token;
42
+ readonly wrappedNativeAddress: TronAddress;
43
+ readonly contracts: ChainContracts;
44
+ }
45
+ declare const CHAIN_CONFIGS: Record<Network, ChainConfig>;
46
+ declare function listNetworks(): Network[];
47
+ declare function isSupportedNetwork(network: string): network is Network;
48
+ declare function getChainConfig(network: Network): ChainConfig;
49
+ declare function getContractAddress(network: Network, key: keyof ChainContracts): TronAddress;
50
+ declare function getNativeCurrency(network: Network): NativeCurrency;
51
+ declare function getWrappedNative(network: Network): Token;
52
+ declare function getWrappedNativeAddress(network: Network): TronAddress;
53
+
54
+ export { CHAIN_CONFIGS, type ChainConfig, type ChainContracts, NETWORK_ENDPOINTS, type NetworkEndpoints, getChainConfig, getContractAddress, getNativeCurrency, getNetworkEndpoints, getWrappedNative, getWrappedNativeAddress, isSupportedNetwork, listNetworks };
@@ -0,0 +1,54 @@
1
+ import { Network, NativeCurrency, Token, TronAddress } from '@sun-protocol/sun-sdk-core';
2
+
3
+ interface NetworkEndpoints {
4
+ readonly rpc: string;
5
+ readonly router: string | null;
6
+ readonly time: string;
7
+ readonly tronScan: string;
8
+ readonly sunPump: string | null;
9
+ }
10
+ declare const NETWORK_ENDPOINTS: Record<Network, NetworkEndpoints>;
11
+ declare function getNetworkEndpoints(network: Network): NetworkEndpoints;
12
+
13
+ interface ChainContracts {
14
+ readonly trx: TronAddress;
15
+ readonly wtrx: TronAddress;
16
+ readonly usdt: TronAddress;
17
+ readonly universalRouter: TronAddress;
18
+ readonly permit2: TronAddress;
19
+ readonly permit2Helper: TronAddress;
20
+ readonly multicall: TronAddress;
21
+ readonly sunswapV2Factory: TronAddress;
22
+ readonly sunswapV2Poly: TronAddress;
23
+ readonly sunswapV2Router: TronAddress;
24
+ readonly sunswapV3Factory: TronAddress;
25
+ readonly sunswapV3PositionManager: TronAddress;
26
+ readonly sunswapV4PoolManager: TronAddress;
27
+ readonly sunswapV4PositionManager: TronAddress;
28
+ readonly sunswapV4LpFeeHelper: TronAddress;
29
+ readonly launchpad: TronAddress;
30
+ readonly psmUsdt: TronAddress;
31
+ readonly psmUsdd: TronAddress;
32
+ readonly psm: TronAddress;
33
+ readonly psmGemJoin: TronAddress;
34
+ readonly psmInfoReader: TronAddress;
35
+ }
36
+ interface ChainConfig {
37
+ readonly network: Network;
38
+ readonly uniswapChainId: number;
39
+ readonly displayName: string;
40
+ readonly nativeCurrency: NativeCurrency;
41
+ readonly wrappedNative: Token;
42
+ readonly wrappedNativeAddress: TronAddress;
43
+ readonly contracts: ChainContracts;
44
+ }
45
+ declare const CHAIN_CONFIGS: Record<Network, ChainConfig>;
46
+ declare function listNetworks(): Network[];
47
+ declare function isSupportedNetwork(network: string): network is Network;
48
+ declare function getChainConfig(network: Network): ChainConfig;
49
+ declare function getContractAddress(network: Network, key: keyof ChainContracts): TronAddress;
50
+ declare function getNativeCurrency(network: Network): NativeCurrency;
51
+ declare function getWrappedNative(network: Network): Token;
52
+ declare function getWrappedNativeAddress(network: Network): TronAddress;
53
+
54
+ export { CHAIN_CONFIGS, type ChainConfig, type ChainContracts, NETWORK_ENDPOINTS, type NetworkEndpoints, getChainConfig, getContractAddress, getNativeCurrency, getNetworkEndpoints, getWrappedNative, getWrappedNativeAddress, isSupportedNetwork, listNetworks };
package/dist/index.js ADDED
@@ -0,0 +1,151 @@
1
+ // src/endpoints.ts
2
+ import { SDKError } from "@sun-protocol/sun-sdk-core";
3
+ var NETWORK_ENDPOINTS = {
4
+ mainnet: {
5
+ rpc: "https://api.trongrid.io",
6
+ router: "https://open.sun.io/apiv2/quote/swap",
7
+ time: "https://open.sun.io/apiv2/chain/block",
8
+ tronScan: "https://apilist.tronscanapi.com",
9
+ sunPump: "https://api-v2.sunpump.meme/pump-api"
10
+ },
11
+ nile: {
12
+ rpc: "https://api.nileex.io",
13
+ router: null,
14
+ time: "https://open.sun.io/apiv2/chain/block",
15
+ tronScan: "https://nileapi.tronscan.org",
16
+ sunPump: null
17
+ }
18
+ };
19
+ function getNetworkEndpoints(network) {
20
+ const endpoints = NETWORK_ENDPOINTS[network];
21
+ if (!endpoints) {
22
+ throw new SDKError("SDK_UNSUPPORTED_NETWORK", `Unsupported network: ${String(network)}`, { network });
23
+ }
24
+ return endpoints;
25
+ }
26
+
27
+ // src/networks.ts
28
+ import {
29
+ Ether,
30
+ SDKError as SDKError2,
31
+ WETH9,
32
+ assertTronAddress
33
+ } from "@sun-protocol/sun-sdk-core";
34
+ var MAINNET_UNISWAP_CHAIN_ID = 728126428;
35
+ var NILE_UNISWAP_CHAIN_ID = 3448148188;
36
+ function addr(value) {
37
+ return assertTronAddress(value);
38
+ }
39
+ function wrappedNative(chainId) {
40
+ const token = WETH9[chainId];
41
+ if (!token) {
42
+ throw new SDKError2("SDK_UNSUPPORTED_NETWORK", `Missing wrapped native token for chain: ${chainId}`, { chainId });
43
+ }
44
+ return token;
45
+ }
46
+ var CHAIN_CONFIGS = {
47
+ mainnet: {
48
+ network: "mainnet",
49
+ uniswapChainId: MAINNET_UNISWAP_CHAIN_ID,
50
+ displayName: "TRON Mainnet",
51
+ nativeCurrency: Ether.onChain(MAINNET_UNISWAP_CHAIN_ID),
52
+ wrappedNative: wrappedNative(MAINNET_UNISWAP_CHAIN_ID),
53
+ wrappedNativeAddress: addr("TNUC9Qb1rRpS5CbWLmNMxXBjyFoydXjWFR"),
54
+ contracts: {
55
+ trx: addr("T9yD14Nj9j7xAB4dbGeiX9h8unkKHxuWwb"),
56
+ wtrx: addr("TNUC9Qb1rRpS5CbWLmNMxXBjyFoydXjWFR"),
57
+ usdt: addr("TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t"),
58
+ // gray test usdt for v3 usdt pool fix
59
+ // usdt: addr('TZCYYShNNo1WHHBDcTsztHVw2V5MHpJmy7'),
60
+ universalRouter: addr("TQqgNg13s2DjvXhW1ky4v6TsR8wZGvb7Y4"),
61
+ permit2: addr("TTJxU3P8rHycAyFY4kVtGNfmnMH4ezcuM9"),
62
+ permit2Helper: addr("TBc4z7389sAtM2nZRgWwHSJnHrWeUrZ3rL"),
63
+ multicall: addr("TBoFgjwfvu5SvT3KMCQYXHQ97bnHAjrDq3"),
64
+ sunswapV2Factory: addr("TKWJdrQkqHisa1X8HUdHEfREvTzw4pMAaY"),
65
+ sunswapV2Poly: addr("THAALWtwcxUxuSJ8h4ZSZGzzTaYhVQaNPf"),
66
+ sunswapV2Router: addr("TNJVzGqKBWkJxJB5XYSqGAwUTV15U24pPq"),
67
+ sunswapV3Factory: addr("TThJt8zaJzJMhCEScH7zWKnp5buVZqys9x"),
68
+ sunswapV3PositionManager: addr("TLSWrv7eC1AZCXkRjpqMZUmvgd99cj7pPF"),
69
+ sunswapV4PoolManager: addr("TVjuTE3V5bMVdpfNhid8kD2v35T2k1u1Br"),
70
+ sunswapV4PositionManager: addr("TC8xQzPHfn5KceZV6s6GmZkBCFWWUoPXs1"),
71
+ sunswapV4LpFeeHelper: addr("TN673trKGEALTAYB6n17SBGpzPwXrDqUKp"),
72
+ launchpad: addr("TTfvyrAz86hbZk5iDpKD78pqLGgi8C7AAw"),
73
+ psmUsdt: addr("TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t"),
74
+ psmUsdd: addr("TXDk8mbtRbXeYuMNS83CfKPaYYT8XWv9Hz"),
75
+ psm: addr("TBXW4hS5KYjjbJXDpnrPf4zhkLwrpUjbyz"),
76
+ psmGemJoin: addr("TSUYvQ5tdd3DijCD1uGunGLpftHuSZ12sQ"),
77
+ psmInfoReader: addr("TDQ9W8Snm59TSRh6DvvMVcoabpdJwAeghA")
78
+ }
79
+ },
80
+ nile: {
81
+ network: "nile",
82
+ uniswapChainId: NILE_UNISWAP_CHAIN_ID,
83
+ displayName: "TRON Nile",
84
+ nativeCurrency: Ether.onChain(NILE_UNISWAP_CHAIN_ID),
85
+ wrappedNative: wrappedNative(NILE_UNISWAP_CHAIN_ID),
86
+ wrappedNativeAddress: addr("TYsbWxNnyTgsZaTFaue9hqpxkU3Fkco94a"),
87
+ contracts: {
88
+ trx: addr("T9yD14Nj9j7xAB4dbGeiX9h8unkKHxuWwb"),
89
+ wtrx: addr("TYsbWxNnyTgsZaTFaue9hqpxkU3Fkco94a"),
90
+ usdt: addr("TXYZopYRdj2D9XRtbG411XZZ3kM5VkAeBf"),
91
+ // test usdt for v3 test
92
+ // usdt: addr('TNPzUytcAm9vtW1PDRVNsdppawBdbEVTDB'),
93
+ universalRouter: addr("TEgq4237arNE7jX74KCDkc1MXdZeWNkGVj"),
94
+ permit2: addr("TYQuuhGbEMxF7nZxUHV3uHJxAVVAegNU9h"),
95
+ permit2Helper: addr("TJcVB8vQVpAoGwp9owx1Ct91D4QpKVd78h"),
96
+ multicall: addr("TPX1jdAu3qdGCZCWX1m75RtB2wgtKotuDC"),
97
+ sunswapV2Factory: addr("THomLGMLhAjMecQf9FQjbZ8a1RtwsZLrGE"),
98
+ sunswapV2Poly: addr("THKx73oAnA6kejnEBzgFkNH2mD93neqmu8"),
99
+ sunswapV2Router: addr("TMn1qrmYUMSTXo9babrJLzepKZoPC7M6Sy"),
100
+ sunswapV3Factory: addr("TUTGcsGDRScK1gsDPMELV2QZxeESWb1Gac"),
101
+ sunswapV3PositionManager: addr("TPQzqHbCzQfoVdAV6bLwGDos8Lk2UjXz2R"),
102
+ sunswapV4PoolManager: addr("TVivLPeq7FMmTG8Z7HaiBgHTsMwCEcipKT"),
103
+ sunswapV4PositionManager: addr("TMTQ1BYo15aGgZXHcsBWXyae8bVaAdgfLP"),
104
+ sunswapV4LpFeeHelper: addr("TYKPrQ45J7w9E73JaTe9VWR7yAut8nkbgf"),
105
+ launchpad: addr("TLtTyEwqacNKc5CHLunKvxmqLB336R4Lrm"),
106
+ psmUsdt: addr("TZDnq7egPqzi7H4SXy1ABvwaVRvRTaVfJW"),
107
+ psmUsdd: addr("TZ78R2E6ejfFhxq8hxrmuqT6hGBxjHQbo4"),
108
+ psm: addr("TPj6Z88798iDSCuFe5gFcivJCSMsfmHKfr"),
109
+ psmGemJoin: addr("TSX7g6WiZaKPkVvrPaDHpRgoVsSvbPfrBv"),
110
+ psmInfoReader: addr("TSJFS9k3wkD6eTAtzqXvnCnS5tsvzbYKns")
111
+ }
112
+ }
113
+ };
114
+ function listNetworks() {
115
+ return ["mainnet", "nile"];
116
+ }
117
+ function isSupportedNetwork(network) {
118
+ return network === "mainnet" || network === "nile";
119
+ }
120
+ function getChainConfig(network) {
121
+ const config = CHAIN_CONFIGS[network];
122
+ if (!config) {
123
+ throw new SDKError2("SDK_UNSUPPORTED_NETWORK", `Unsupported network: ${String(network)}`, { network });
124
+ }
125
+ return config;
126
+ }
127
+ function getContractAddress(network, key) {
128
+ return getChainConfig(network).contracts[key];
129
+ }
130
+ function getNativeCurrency(network) {
131
+ return getChainConfig(network).nativeCurrency;
132
+ }
133
+ function getWrappedNative(network) {
134
+ return getChainConfig(network).wrappedNative;
135
+ }
136
+ function getWrappedNativeAddress(network) {
137
+ return getChainConfig(network).wrappedNativeAddress;
138
+ }
139
+ export {
140
+ CHAIN_CONFIGS,
141
+ NETWORK_ENDPOINTS,
142
+ getChainConfig,
143
+ getContractAddress,
144
+ getNativeCurrency,
145
+ getNetworkEndpoints,
146
+ getWrappedNative,
147
+ getWrappedNativeAddress,
148
+ isSupportedNetwork,
149
+ listNetworks
150
+ };
151
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/endpoints.ts","../src/networks.ts"],"sourcesContent":["import { SDKError, type Network } from '@sun-protocol/sun-sdk-core'\n\nexport interface NetworkEndpoints {\n readonly rpc: string\n readonly router: string | null\n readonly time: string\n readonly tronScan: string\n readonly sunPump: string | null\n}\n\nexport const NETWORK_ENDPOINTS: Record<Network, NetworkEndpoints> = {\n mainnet: {\n rpc: 'https://api.trongrid.io',\n router: 'https://open.sun.io/apiv2/quote/swap',\n time: 'https://open.sun.io/apiv2/chain/block',\n tronScan: 'https://apilist.tronscanapi.com',\n sunPump: 'https://api-v2.sunpump.meme/pump-api',\n },\n nile: {\n rpc: 'https://api.nileex.io',\n router: null,\n time: 'https://open.sun.io/apiv2/chain/block',\n tronScan: 'https://nileapi.tronscan.org',\n sunPump: null,\n },\n}\n\nexport function getNetworkEndpoints(network: Network): NetworkEndpoints {\n const endpoints = NETWORK_ENDPOINTS[network]\n if (!endpoints) {\n throw new SDKError('SDK_UNSUPPORTED_NETWORK', `Unsupported network: ${String(network)}`, { network })\n }\n return endpoints\n}\n","import {\n Ether,\n SDKError,\n WETH9,\n assertTronAddress,\n type NativeCurrency,\n type Network,\n type Token,\n type TronAddress,\n} from '@sun-protocol/sun-sdk-core'\n\nexport interface ChainContracts {\n readonly trx: TronAddress\n readonly wtrx: TronAddress\n readonly usdt: TronAddress\n readonly universalRouter: TronAddress\n readonly permit2: TronAddress\n readonly permit2Helper: TronAddress\n readonly multicall: TronAddress\n readonly sunswapV2Factory: TronAddress\n readonly sunswapV2Poly: TronAddress\n readonly sunswapV2Router: TronAddress\n readonly sunswapV3Factory: TronAddress\n readonly sunswapV3PositionManager: TronAddress\n readonly sunswapV4PoolManager: TronAddress\n readonly sunswapV4PositionManager: TronAddress\n readonly sunswapV4LpFeeHelper: TronAddress\n readonly launchpad: TronAddress\n readonly psmUsdt: TronAddress\n readonly psmUsdd: TronAddress\n readonly psm: TronAddress\n readonly psmGemJoin: TronAddress\n readonly psmInfoReader: TronAddress\n}\n\nexport interface ChainConfig {\n readonly network: Network\n readonly uniswapChainId: number\n readonly displayName: string\n readonly nativeCurrency: NativeCurrency\n readonly wrappedNative: Token\n readonly wrappedNativeAddress: TronAddress\n readonly contracts: ChainContracts\n}\n\nconst MAINNET_UNISWAP_CHAIN_ID = 728126428\nconst NILE_UNISWAP_CHAIN_ID = 3448148188\n\nfunction addr(value: string): TronAddress {\n return assertTronAddress(value)\n}\n\nfunction wrappedNative(chainId: number): Token {\n const token = WETH9[chainId]\n if (!token) {\n throw new SDKError('SDK_UNSUPPORTED_NETWORK', `Missing wrapped native token for chain: ${chainId}`, { chainId })\n }\n return token\n}\n\nexport const CHAIN_CONFIGS: Record<Network, ChainConfig> = {\n mainnet: {\n network: 'mainnet',\n uniswapChainId: MAINNET_UNISWAP_CHAIN_ID,\n displayName: 'TRON Mainnet',\n nativeCurrency: Ether.onChain(MAINNET_UNISWAP_CHAIN_ID),\n wrappedNative: wrappedNative(MAINNET_UNISWAP_CHAIN_ID),\n wrappedNativeAddress: addr('TNUC9Qb1rRpS5CbWLmNMxXBjyFoydXjWFR'),\n contracts: {\n trx: addr('T9yD14Nj9j7xAB4dbGeiX9h8unkKHxuWwb'),\n wtrx: addr('TNUC9Qb1rRpS5CbWLmNMxXBjyFoydXjWFR'),\n usdt: addr('TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t'),\n // gray test usdt for v3 usdt pool fix\n // usdt: addr('TZCYYShNNo1WHHBDcTsztHVw2V5MHpJmy7'),\n universalRouter: addr('TQqgNg13s2DjvXhW1ky4v6TsR8wZGvb7Y4'),\n permit2: addr('TTJxU3P8rHycAyFY4kVtGNfmnMH4ezcuM9'),\n permit2Helper: addr('TBc4z7389sAtM2nZRgWwHSJnHrWeUrZ3rL'),\n multicall: addr('TBoFgjwfvu5SvT3KMCQYXHQ97bnHAjrDq3'),\n sunswapV2Factory: addr('TKWJdrQkqHisa1X8HUdHEfREvTzw4pMAaY'),\n sunswapV2Poly: addr('THAALWtwcxUxuSJ8h4ZSZGzzTaYhVQaNPf'),\n sunswapV2Router: addr('TNJVzGqKBWkJxJB5XYSqGAwUTV15U24pPq'),\n sunswapV3Factory: addr('TThJt8zaJzJMhCEScH7zWKnp5buVZqys9x'),\n sunswapV3PositionManager: addr('TLSWrv7eC1AZCXkRjpqMZUmvgd99cj7pPF'),\n sunswapV4PoolManager: addr('TVjuTE3V5bMVdpfNhid8kD2v35T2k1u1Br'),\n sunswapV4PositionManager: addr('TC8xQzPHfn5KceZV6s6GmZkBCFWWUoPXs1'),\n sunswapV4LpFeeHelper: addr('TN673trKGEALTAYB6n17SBGpzPwXrDqUKp'),\n launchpad: addr('TTfvyrAz86hbZk5iDpKD78pqLGgi8C7AAw'),\n psmUsdt: addr('TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t'),\n psmUsdd: addr('TXDk8mbtRbXeYuMNS83CfKPaYYT8XWv9Hz'),\n psm: addr('TBXW4hS5KYjjbJXDpnrPf4zhkLwrpUjbyz'),\n psmGemJoin: addr('TSUYvQ5tdd3DijCD1uGunGLpftHuSZ12sQ'),\n psmInfoReader: addr('TDQ9W8Snm59TSRh6DvvMVcoabpdJwAeghA'),\n },\n },\n nile: {\n network: 'nile',\n uniswapChainId: NILE_UNISWAP_CHAIN_ID,\n displayName: 'TRON Nile',\n nativeCurrency: Ether.onChain(NILE_UNISWAP_CHAIN_ID),\n wrappedNative: wrappedNative(NILE_UNISWAP_CHAIN_ID),\n wrappedNativeAddress: addr('TYsbWxNnyTgsZaTFaue9hqpxkU3Fkco94a'),\n contracts: {\n trx: addr('T9yD14Nj9j7xAB4dbGeiX9h8unkKHxuWwb'),\n wtrx: addr('TYsbWxNnyTgsZaTFaue9hqpxkU3Fkco94a'),\n usdt: addr('TXYZopYRdj2D9XRtbG411XZZ3kM5VkAeBf'),\n // test usdt for v3 test\n // usdt: addr('TNPzUytcAm9vtW1PDRVNsdppawBdbEVTDB'),\n universalRouter: addr('TEgq4237arNE7jX74KCDkc1MXdZeWNkGVj'),\n permit2: addr('TYQuuhGbEMxF7nZxUHV3uHJxAVVAegNU9h'),\n permit2Helper: addr('TJcVB8vQVpAoGwp9owx1Ct91D4QpKVd78h'),\n multicall: addr('TPX1jdAu3qdGCZCWX1m75RtB2wgtKotuDC'),\n sunswapV2Factory: addr('THomLGMLhAjMecQf9FQjbZ8a1RtwsZLrGE'),\n sunswapV2Poly: addr('THKx73oAnA6kejnEBzgFkNH2mD93neqmu8'),\n sunswapV2Router: addr('TMn1qrmYUMSTXo9babrJLzepKZoPC7M6Sy'),\n sunswapV3Factory: addr('TUTGcsGDRScK1gsDPMELV2QZxeESWb1Gac'),\n sunswapV3PositionManager: addr('TPQzqHbCzQfoVdAV6bLwGDos8Lk2UjXz2R'),\n sunswapV4PoolManager: addr('TVivLPeq7FMmTG8Z7HaiBgHTsMwCEcipKT'),\n sunswapV4PositionManager: addr('TMTQ1BYo15aGgZXHcsBWXyae8bVaAdgfLP'),\n sunswapV4LpFeeHelper: addr('TYKPrQ45J7w9E73JaTe9VWR7yAut8nkbgf'),\n launchpad: addr('TLtTyEwqacNKc5CHLunKvxmqLB336R4Lrm'),\n psmUsdt: addr('TZDnq7egPqzi7H4SXy1ABvwaVRvRTaVfJW'),\n psmUsdd: addr('TZ78R2E6ejfFhxq8hxrmuqT6hGBxjHQbo4'),\n psm: addr('TPj6Z88798iDSCuFe5gFcivJCSMsfmHKfr'),\n psmGemJoin: addr('TSX7g6WiZaKPkVvrPaDHpRgoVsSvbPfrBv'),\n psmInfoReader: addr('TSJFS9k3wkD6eTAtzqXvnCnS5tsvzbYKns'),\n },\n },\n}\n\nexport function listNetworks(): Network[] {\n return ['mainnet', 'nile']\n}\n\nexport function isSupportedNetwork(network: string): network is Network {\n return network === 'mainnet' || network === 'nile'\n}\n\nexport function getChainConfig(network: Network): ChainConfig {\n const config = CHAIN_CONFIGS[network]\n if (!config) {\n throw new SDKError('SDK_UNSUPPORTED_NETWORK', `Unsupported network: ${String(network)}`, { network })\n }\n return config\n}\n\nexport function getContractAddress(network: Network, key: keyof ChainContracts): TronAddress {\n return getChainConfig(network).contracts[key]\n}\n\nexport function getNativeCurrency(network: Network): NativeCurrency {\n return getChainConfig(network).nativeCurrency\n}\n\nexport function getWrappedNative(network: Network): Token {\n return getChainConfig(network).wrappedNative\n}\n\nexport function getWrappedNativeAddress(network: Network): TronAddress {\n return getChainConfig(network).wrappedNativeAddress\n}\n"],"mappings":";AAAA,SAAS,gBAA8B;AAUhC,IAAM,oBAAuD;AAAA,EAClE,SAAS;AAAA,IACP,KAAK;AAAA,IACL,QAAQ;AAAA,IACR,MAAM;AAAA,IACN,UAAU;AAAA,IACV,SAAS;AAAA,EACX;AAAA,EACA,MAAM;AAAA,IACJ,KAAK;AAAA,IACL,QAAQ;AAAA,IACR,MAAM;AAAA,IACN,UAAU;AAAA,IACV,SAAS;AAAA,EACX;AACF;AAEO,SAAS,oBAAoB,SAAoC;AACtE,QAAM,YAAY,kBAAkB,OAAO;AAC3C,MAAI,CAAC,WAAW;AACd,UAAM,IAAI,SAAS,2BAA2B,wBAAwB,OAAO,OAAO,CAAC,IAAI,EAAE,QAAQ,CAAC;AAAA,EACtG;AACA,SAAO;AACT;;;ACjCA;AAAA,EACE;AAAA,EACA,YAAAA;AAAA,EACA;AAAA,EACA;AAAA,OAKK;AAoCP,IAAM,2BAA2B;AACjC,IAAM,wBAAwB;AAE9B,SAAS,KAAK,OAA4B;AACxC,SAAO,kBAAkB,KAAK;AAChC;AAEA,SAAS,cAAc,SAAwB;AAC7C,QAAM,QAAQ,MAAM,OAAO;AAC3B,MAAI,CAAC,OAAO;AACV,UAAM,IAAIA,UAAS,2BAA2B,2CAA2C,OAAO,IAAI,EAAE,QAAQ,CAAC;AAAA,EACjH;AACA,SAAO;AACT;AAEO,IAAM,gBAA8C;AAAA,EACzD,SAAS;AAAA,IACP,SAAS;AAAA,IACT,gBAAgB;AAAA,IAChB,aAAa;AAAA,IACb,gBAAgB,MAAM,QAAQ,wBAAwB;AAAA,IACtD,eAA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0-beta.0",
4
+ "description": "TRON network configuration, service endpoints, and SUN protocol contract addresses.",
5
+ "keywords": [
6
+ "sun",
7
+ "tron",
8
+ "defi",
9
+ "chains",
10
+ "typescript"
11
+ ],
12
+ "homepage": "https://github.com/sun-protocol/sun-sdk#readme",
13
+ "repository": {
14
+ "type": "git",
15
+ "url": "git+https://github.com/sun-protocol/sun-sdk.git",
16
+ "directory": "packages/chains"
17
+ },
18
+ "private": false,
19
+ "type": "module",
20
+ "engines": {
21
+ "node": ">=20"
22
+ },
23
+ "main": "./dist/index.cjs",
24
+ "module": "./dist/index.js",
25
+ "types": "./dist/index.d.ts",
26
+ "sideEffects": false,
27
+ "files": [
28
+ "dist"
29
+ ],
30
+ "exports": {
31
+ ".": {
32
+ "types": "./dist/index.d.ts",
33
+ "import": "./dist/index.js",
34
+ "require": "./dist/index.cjs"
35
+ }
36
+ },
37
+ "dependencies": {
38
+ "@sun-protocol/sun-sdk-core": "0.1.0-beta.0"
39
+ },
40
+ "scripts": {
41
+ "build": "tsup src/index.ts --format esm,cjs --dts --sourcemap --clean --tsconfig ../../tsconfig.base.json",
42
+ "typecheck": "tsc -p tsconfig.json --noEmit",
43
+ "test": "vitest run"
44
+ }
45
+ }