@heyanon/sdk 2.3.1 → 2.3.3

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.
Files changed (30) hide show
  1. package/dist/adapter/misc.d.ts +35 -0
  2. package/dist/adapter/transformers/toResult.d.ts +24 -0
  3. package/dist/adapter/types.d.ts +123 -7
  4. package/dist/blockchain/constants/chains.d.ts +96 -2
  5. package/dist/blockchain/constants/types.d.ts +33 -0
  6. package/dist/blockchain/evm/constants/chains.d.ts +57 -0
  7. package/dist/blockchain/evm/constants/misc.d.ts +69 -0
  8. package/dist/blockchain/evm/constants/weth9.d.ts +77 -1
  9. package/dist/blockchain/evm/types.d.ts +273 -0
  10. package/dist/blockchain/evm/utils/checkToApprove.d.ts +86 -0
  11. package/dist/blockchain/evm/utils/getChainFromName.d.ts +81 -0
  12. package/dist/blockchain/evm/utils/getChainName.d.ts +114 -0
  13. package/dist/blockchain/evm/utils/getUnwrapData.d.ts +114 -0
  14. package/dist/blockchain/evm/utils/getWrapAddress.d.ts +147 -0
  15. package/dist/blockchain/evm/utils/getWrapData.d.ts +189 -0
  16. package/dist/blockchain/evm/utils/getWrappedNative.d.ts +198 -0
  17. package/dist/blockchain/evm/utils/isEvmChain.d.ts +183 -0
  18. package/dist/blockchain/evm/utils/isNativeAddress.d.ts +221 -0
  19. package/dist/blockchain/evm/utils/isNativeAddress.test.d.ts +1 -0
  20. package/dist/blockchain/solana/types.d.ts +291 -0
  21. package/dist/blockchain/solana/utils/buildV0Transaction.d.ts +184 -0
  22. package/dist/blockchain/solana/utils/toPublicKey.d.ts +194 -0
  23. package/dist/blockchain/ton/types.d.ts +410 -0
  24. package/dist/index.js +37 -2
  25. package/dist/index.mjs +37 -2
  26. package/dist/utils/retry.d.ts +218 -0
  27. package/dist/utils/sleep.d.ts +239 -0
  28. package/dist/utils/stringify.d.ts +235 -0
  29. package/dist/utils/stringify.spec.d.ts +1 -0
  30. package/package.json +1 -1
@@ -1,3 +1,117 @@
1
1
  import { EvmChain } from '../../constants';
2
2
  import { TransactionParams } from '../types';
3
+ /**
4
+ * Generates transaction data for unwrapping tokens (converting wrapped tokens back to native currency)
5
+ * @param chain - The EVM chain where the unwrap operation will occur
6
+ * @param amount - The amount of wrapped tokens to unwrap (in wei/smallest unit)
7
+ * @returns Transaction parameters for the unwrap operation
8
+ * @example
9
+ * ```typescript
10
+ * import { parseEther } from 'viem';
11
+ *
12
+ * // Basic unwrap operation
13
+ * const unwrapTxData = getUnwrapData(Chain.ETHEREUM, parseEther('1')); // Unwrap 1 WETH to ETH
14
+ * // Returns: { target: '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2', data: '0x...' }
15
+ *
16
+ * // Different chains with their wrapped tokens
17
+ * const unwrapWBNB = getUnwrapData(Chain.BSC, parseEther('0.5')); // WBNB → BNB
18
+ * const unwrapWMATIC = getUnwrapData(Chain.POLYGON, parseEther('100')); // WPOL → POL
19
+ * const unwrapWAVAX = getUnwrapData(Chain.AVALANCHE, parseEther('10')); // WAVAX → AVAX
20
+ *
21
+ * // Use in adapter function
22
+ * async function unwrapTokens(chain: EvmChain, amount: string) {
23
+ * const amountBigInt = parseEther(amount);
24
+ * const unwrapData = getUnwrapData(chain, amountBigInt);
25
+ *
26
+ * return await options.evm.sendTransactions({
27
+ * transactions: [unwrapData]
28
+ * });
29
+ * }
30
+ *
31
+ * // Complete unwrap workflow with balance check
32
+ * async function safeUnwrapTokens(chain: EvmChain, amount: bigint) {
33
+ * const userAddress = await options.evm.getAddress();
34
+ * const wrappedTokenAddress = getWrapAddress(chain);
35
+ * const provider = options.evm.getProvider(getChainFromName(chain));
36
+ *
37
+ * // Check user's wrapped token balance
38
+ * const balance = await provider.readContract({
39
+ * address: wrappedTokenAddress,
40
+ * abi: WETH9Abi,
41
+ * functionName: 'balanceOf',
42
+ * args: [userAddress]
43
+ * });
44
+ *
45
+ * if (balance < amount) {
46
+ * throw new Error(`Insufficient wrapped token balance. Have: ${balance}, Need: ${amount}`);
47
+ * }
48
+ *
49
+ * // Generate unwrap transaction
50
+ * const unwrapData = getUnwrapData(chain, amount);
51
+ *
52
+ * return await options.evm.sendTransactions({
53
+ * transactions: [unwrapData]
54
+ * });
55
+ * }
56
+ *
57
+ * // Batch unwrap on multiple chains
58
+ * async function batchUnwrapAcrossChains(
59
+ * operations: Array<{ chain: EvmChain; amount: bigint }>
60
+ * ) {
61
+ * const results = await Promise.allSettled(
62
+ * operations.map(async ({ chain, amount }) => {
63
+ * const unwrapData = getUnwrapData(chain, amount);
64
+ *
65
+ * return {
66
+ * chain,
67
+ * amount,
68
+ * transaction: await options.evm.sendTransactions({
69
+ * transactions: [unwrapData]
70
+ * })
71
+ * };
72
+ * })
73
+ * );
74
+ *
75
+ * return results.map((result, index) => ({
76
+ * ...operations[index],
77
+ * success: result.status === 'fulfilled',
78
+ * result: result.status === 'fulfilled' ? result.value : result.reason
79
+ * }));
80
+ * }
81
+ *
82
+ * // Use in DeFi yield withdrawal
83
+ * async function withdrawYieldAndUnwrap(chain: EvmChain, poolAddress: string) {
84
+ * const transactions: TransactionParams[] = [];
85
+ *
86
+ * // First, withdraw from yield farming pool (gets wrapped tokens)
87
+ * transactions.push({
88
+ * target: poolAddress,
89
+ * data: encodeFunctionData({
90
+ * abi: yieldPoolAbi,
91
+ * functionName: 'withdraw',
92
+ * args: [userStakedAmount]
93
+ * })
94
+ * });
95
+ *
96
+ * // Then unwrap the received tokens to native currency
97
+ * const unwrapData = getUnwrapData(chain, expectedWrappedAmount);
98
+ * transactions.push(unwrapData);
99
+ *
100
+ * return await options.evm.sendTransactions({ transactions });
101
+ * }
102
+ *
103
+ * // Gas estimation for unwrap operation
104
+ * async function estimateUnwrapGas(chain: EvmChain, amount: bigint) {
105
+ * const unwrapData = getUnwrapData(chain, amount);
106
+ * const provider = options.evm.getProvider(getChainFromName(chain));
107
+ * const userAddress = await options.evm.getAddress();
108
+ *
109
+ * return await provider.estimateGas({
110
+ * account: userAddress,
111
+ * to: unwrapData.target,
112
+ * data: unwrapData.data
113
+ * });
114
+ * }
115
+ * ```
116
+ */
3
117
  export declare function getUnwrapData(chain: EvmChain, amount: bigint): TransactionParams;
@@ -1,3 +1,150 @@
1
1
  import { EvmChain } from '../../constants';
2
2
  import { Address } from 'viem';
3
+ /**
4
+ * Retrieves the wrapped native token contract address for a specific EVM chain
5
+ * @param chain - The EVM chain to get the wrapped token address for
6
+ * @returns The contract address of the wrapped native token (WETH9-compatible)
7
+ * @throws {Error} When the chain doesn't have a configured wrapped token address
8
+ * @example
9
+ * ```typescript
10
+ * // Get wrapped token addresses for different chains
11
+ * const wethAddress = getWrapAddress(Chain.ETHEREUM); // '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'
12
+ * const wbnbAddress = getWrapAddress(Chain.BSC); // '0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c'
13
+ * const wpolAddress = getWrapAddress(Chain.POLYGON); // '0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270'
14
+ *
15
+ * // Use in token operations
16
+ * async function getWrappedTokenBalance(chain: EvmChain, userAddress: Address) {
17
+ * const wrapAddress = getWrapAddress(chain);
18
+ * const provider = options.evm.getProvider(getChainFromName(chain));
19
+ *
20
+ * return await provider.readContract({
21
+ * address: wrapAddress,
22
+ * abi: erc20Abi,
23
+ * functionName: 'balanceOf',
24
+ * args: [userAddress]
25
+ * });
26
+ * }
27
+ *
28
+ * // Check if token address is a wrapped native token
29
+ * function isWrappedNativeToken(chain: EvmChain, tokenAddress: Address): boolean {
30
+ * try {
31
+ * const wrapAddress = getWrapAddress(chain);
32
+ * return wrapAddress.toLowerCase() === tokenAddress.toLowerCase();
33
+ * } catch (error) {
34
+ * return false;
35
+ * }
36
+ * }
37
+ *
38
+ * // Use in DEX trading setup
39
+ * async function setupTokenSwap(
40
+ * chain: EvmChain,
41
+ * tokenIn: Address,
42
+ * tokenOut: Address,
43
+ * amountIn: bigint
44
+ * ) {
45
+ * const transactions: TransactionParams[] = [];
46
+ * const wrapAddress = getWrapAddress(chain);
47
+ *
48
+ * // If input is native token, wrap it first
49
+ * if (tokenIn === NATIVE_ADDRESS) {
50
+ * const wrapData = getWrapData(chain, amountIn);
51
+ * transactions.push(wrapData);
52
+ * tokenIn = wrapAddress; // Update tokenIn to wrapped version
53
+ * }
54
+ *
55
+ * // Add swap transaction
56
+ * transactions.push(buildSwapTransaction(tokenIn, tokenOut, amountIn));
57
+ *
58
+ * // If output should be native, add unwrap transaction
59
+ * if (tokenOut === NATIVE_ADDRESS) {
60
+ * const unwrapData = getUnwrapData(chain, expectedAmountOut);
61
+ * transactions.push(unwrapData);
62
+ * }
63
+ *
64
+ * return transactions;
65
+ * }
66
+ *
67
+ * // Get wrapped token info for UI display
68
+ * function getWrappedTokenInfo(chain: EvmChain) {
69
+ * const address = getWrapAddress(chain);
70
+ * const token = WETH9[chain];
71
+ *
72
+ * return {
73
+ * address,
74
+ * name: token.name,
75
+ * symbol: token.symbol,
76
+ * decimals: token.decimals,
77
+ * chainId: token.chainId
78
+ * };
79
+ * }
80
+ *
81
+ * // Approve wrapped token for spending
82
+ * async function approveWrappedToken(
83
+ * chain: EvmChain,
84
+ * spender: Address,
85
+ * amount: bigint
86
+ * ) {
87
+ * const wrapAddress = getWrapAddress(chain);
88
+ * const transactions: TransactionParams[] = [];
89
+ *
90
+ * await checkToApprove({
91
+ * args: {
92
+ * account: await options.evm.getAddress(),
93
+ * target: wrapAddress,
94
+ * spender,
95
+ * amount
96
+ * },
97
+ * provider: options.evm.getProvider(getChainFromName(chain)),
98
+ * transactions
99
+ * });
100
+ *
101
+ * return transactions;
102
+ * }
103
+ *
104
+ * // Multi-chain wrapped token portfolio
105
+ * async function getWrappedTokenPortfolio(
106
+ * chains: EvmChain[],
107
+ * userAddress: Address
108
+ * ) {
109
+ * const portfolio = await Promise.allSettled(
110
+ * chains.map(async (chain) => {
111
+ * try {
112
+ * const wrapAddress = getWrapAddress(chain);
113
+ * const provider = options.evm.getProvider(getChainFromName(chain));
114
+ *
115
+ * const balance = await provider.readContract({
116
+ * address: wrapAddress,
117
+ * abi: erc20Abi,
118
+ * functionName: 'balanceOf',
119
+ * args: [userAddress]
120
+ * });
121
+ *
122
+ * return {
123
+ * chain,
124
+ * address: wrapAddress,
125
+ * balance,
126
+ * token: WETH9[chain]
127
+ * };
128
+ * } catch (error) {
129
+ * throw new Error(`Failed to get wrapped token for ${chain}: ${error.message}`);
130
+ * }
131
+ * })
132
+ * );
133
+ *
134
+ * return portfolio
135
+ * .filter((result): result is PromiseFulfilledResult<any> => result.status === 'fulfilled')
136
+ * .map(result => result.value)
137
+ * .filter(item => item.balance > 0n);
138
+ * }
139
+ *
140
+ * // Safe version that returns null instead of throwing
141
+ * function safeGetWrapAddress(chain: EvmChain): Address | null {
142
+ * try {
143
+ * return getWrapAddress(chain);
144
+ * } catch (error) {
145
+ * return null;
146
+ * }
147
+ * }
148
+ * ```
149
+ */
3
150
  export declare function getWrapAddress(chain: EvmChain): Address;
@@ -1,3 +1,192 @@
1
1
  import { TransactionParams } from '../types';
2
2
  import { EvmChain } from '../../constants';
3
+ /**
4
+ * Generates transaction data for wrapping native currency into wrapped tokens (e.g., ETH → WETH)
5
+ * @param chain - The EVM chain where the wrap operation will occur
6
+ * @param amount - The amount of native currency to wrap (in wei/smallest unit)
7
+ * @returns Transaction parameters for the wrap operation including target, data, and value
8
+ * @example
9
+ * ```typescript
10
+ * import { parseEther } from 'viem';
11
+ *
12
+ * // Basic wrap operation
13
+ * const wrapTxData = getWrapData(Chain.ETHEREUM, parseEther('1')); // Wrap 1 ETH to WETH
14
+ * // Returns: {
15
+ * // target: '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2',
16
+ * // data: '0xd0e30db0',
17
+ * // value: 1000000000000000000n
18
+ * // }
19
+ *
20
+ * // Different chains with their native currencies
21
+ * const wrapBNB = getWrapData(Chain.BSC, parseEther('0.5')); // BNB → WBNB
22
+ * const wrapMATIC = getWrapData(Chain.POLYGON, parseEther('100')); // POL → WPOL
23
+ * const wrapAVAX = getWrapData(Chain.AVALANCHE, parseEther('10')); // AVAX → WAVAX
24
+ *
25
+ * // Use in adapter function
26
+ * async function wrapNativeTokens(chain: EvmChain, amount: string) {
27
+ * const amountBigInt = parseEther(amount);
28
+ * const wrapData = getWrapData(chain, amountBigInt);
29
+ *
30
+ * return await options.evm.sendTransactions({
31
+ * transactions: [wrapData]
32
+ * });
33
+ * }
34
+ *
35
+ * // Complete wrap workflow with balance check
36
+ * async function safeWrapTokens(chain: EvmChain, amount: bigint) {
37
+ * const userAddress = await options.evm.getAddress();
38
+ * const provider = options.evm.getProvider(getChainFromName(chain));
39
+ *
40
+ * // Check user's native token balance
41
+ * const balance = await provider.getBalance({ address: userAddress });
42
+ *
43
+ * if (balance < amount) {
44
+ * throw new Error(`Insufficient native token balance. Have: ${balance}, Need: ${amount}`);
45
+ * }
46
+ *
47
+ * // Generate wrap transaction
48
+ * const wrapData = getWrapData(chain, amount);
49
+ *
50
+ * return await options.evm.sendTransactions({
51
+ * transactions: [wrapData]
52
+ * });
53
+ * }
54
+ *
55
+ * // Use in DEX operations that require wrapped tokens
56
+ * async function wrapAndSwap(
57
+ * chain: EvmChain,
58
+ * amountIn: bigint,
59
+ * tokenOut: Address,
60
+ * minAmountOut: bigint
61
+ * ) {
62
+ * const transactions: TransactionParams[] = [];
63
+ *
64
+ * // First, wrap native currency
65
+ * const wrapData = getWrapData(chain, amountIn);
66
+ * transactions.push(wrapData);
67
+ *
68
+ * // Then approve wrapped token for DEX
69
+ * const wrapAddress = getWrapAddress(chain);
70
+ * await checkToApprove({
71
+ * args: {
72
+ * account: await options.evm.getAddress(),
73
+ * target: wrapAddress,
74
+ * spender: DEX_ROUTER_ADDRESS,
75
+ * amount: amountIn
76
+ * },
77
+ * provider: options.evm.getProvider(getChainFromName(chain)),
78
+ * transactions
79
+ * });
80
+ *
81
+ * // Finally, execute swap
82
+ * transactions.push({
83
+ * target: DEX_ROUTER_ADDRESS,
84
+ * data: encodeFunctionData({
85
+ * abi: dexRouterAbi,
86
+ * functionName: 'swapExactTokensForTokens',
87
+ * args: [amountIn, minAmountOut, [wrapAddress, tokenOut], userAddress, deadline]
88
+ * })
89
+ * });
90
+ *
91
+ * return await options.evm.sendTransactions({ transactions });
92
+ * }
93
+ *
94
+ * // Batch wrap operations across multiple chains
95
+ * async function batchWrapAcrossChains(
96
+ * operations: Array<{ chain: EvmChain; amount: bigint }>
97
+ * ) {
98
+ * const results = await Promise.allSettled(
99
+ * operations.map(async ({ chain, amount }) => {
100
+ * const wrapData = getWrapData(chain, amount);
101
+ *
102
+ * return {
103
+ * chain,
104
+ * amount,
105
+ * transaction: await options.evm.sendTransactions({
106
+ * transactions: [wrapData]
107
+ * })
108
+ * };
109
+ * })
110
+ * );
111
+ *
112
+ * return results.map((result, index) => ({
113
+ * ...operations[index],
114
+ * success: result.status === 'fulfilled',
115
+ * result: result.status === 'fulfilled' ? result.value : result.reason
116
+ * }));
117
+ * }
118
+ *
119
+ * // Use in yield farming setup
120
+ * async function wrapAndStake(
121
+ * chain: EvmChain,
122
+ * stakingPoolAddress: Address,
123
+ * amount: bigint
124
+ * ) {
125
+ * const transactions: TransactionParams[] = [];
126
+ * const wrapAddress = getWrapAddress(chain);
127
+ *
128
+ * // Wrap native currency
129
+ * const wrapData = getWrapData(chain, amount);
130
+ * transactions.push(wrapData);
131
+ *
132
+ * // Approve wrapped token for staking pool
133
+ * await checkToApprove({
134
+ * args: {
135
+ * account: await options.evm.getAddress(),
136
+ * target: wrapAddress,
137
+ * spender: stakingPoolAddress,
138
+ * amount
139
+ * },
140
+ * provider: options.evm.getProvider(getChainFromName(chain)),
141
+ * transactions
142
+ * });
143
+ *
144
+ * // Stake wrapped tokens
145
+ * transactions.push({
146
+ * target: stakingPoolAddress,
147
+ * data: encodeFunctionData({
148
+ * abi: stakingPoolAbi,
149
+ * functionName: 'stake',
150
+ * args: [amount]
151
+ * })
152
+ * });
153
+ *
154
+ * return await options.evm.sendTransactions({ transactions });
155
+ * }
156
+ *
157
+ * // Gas estimation for wrap operation
158
+ * async function estimateWrapGas(chain: EvmChain, amount: bigint) {
159
+ * const wrapData = getWrapData(chain, amount);
160
+ * const provider = options.evm.getProvider(getChainFromName(chain));
161
+ * const userAddress = await options.evm.getAddress();
162
+ *
163
+ * return await provider.estimateGas({
164
+ * account: userAddress,
165
+ * to: wrapData.target,
166
+ * data: wrapData.data,
167
+ * value: wrapData.value
168
+ * });
169
+ * }
170
+ *
171
+ * // Progressive wrap for large amounts
172
+ * async function progressiveWrap(
173
+ * chain: EvmChain,
174
+ * totalAmount: bigint,
175
+ * batchSize: bigint = parseEther('10')
176
+ * ) {
177
+ * const transactions: TransactionParams[] = [];
178
+ * let remainingAmount = totalAmount;
179
+ *
180
+ * while (remainingAmount > 0n) {
181
+ * const currentBatch = remainingAmount > batchSize ? batchSize : remainingAmount;
182
+ * const wrapData = getWrapData(chain, currentBatch);
183
+ * transactions.push(wrapData);
184
+ *
185
+ * remainingAmount -= currentBatch;
186
+ * }
187
+ *
188
+ * return await options.evm.sendTransactions({ transactions });
189
+ * }
190
+ * ```
191
+ */
3
192
  export declare function getWrapData(chain: EvmChain, amount: bigint): TransactionParams;
@@ -1,3 +1,201 @@
1
1
  import { Token } from '@real-wagmi/sdk';
2
2
  import { EvmChain } from '../../constants/chains';
3
+ /**
4
+ * Retrieves the wrapped native token object for a specific EVM chain
5
+ * @param chain - The EVM chain to get the wrapped native token for
6
+ * @returns Complete Token object with address, decimals, symbol, name, and chainId
7
+ * @throws {Error} When the chain doesn't have a configured wrapped native token
8
+ * @example
9
+ * ```typescript
10
+ * // Get wrapped native tokens for different chains
11
+ * const weth = getWrappedNative(Chain.ETHEREUM);
12
+ * console.log(weth);
13
+ * // Output: {
14
+ * // chainId: 1,
15
+ * // address: '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2',
16
+ * // decimals: 18,
17
+ * // symbol: 'WETH',
18
+ * // name: 'Wrapped Ether'
19
+ * // }
20
+ *
21
+ * const wbnb = getWrappedNative(Chain.BSC); // WBNB on BSC
22
+ * const wpol = getWrappedNative(Chain.POLYGON); // WPOL on Polygon
23
+ * const wavax = getWrappedNative(Chain.AVALANCHE); // WAVAX on Avalanche
24
+ *
25
+ * // Use token properties in DeFi operations
26
+ * function formatTokenAmount(chain: EvmChain, amount: bigint): string {
27
+ * const token = getWrappedNative(chain);
28
+ * const formatted = formatUnits(amount, token.decimals);
29
+ * return `${formatted} ${token.symbol}`;
30
+ * }
31
+ *
32
+ * // Create token pair for DEX operations
33
+ * function createTokenPair(chainA: EvmChain, chainB: EvmChain) {
34
+ * const tokenA = getWrappedNative(chainA);
35
+ * const tokenB = getWrappedNative(chainB);
36
+ *
37
+ * return {
38
+ * tokenA,
39
+ * tokenB,
40
+ * isValid: tokenA.chainId !== tokenB.chainId
41
+ * };
42
+ * }
43
+ *
44
+ * // Use in liquidity pool operations
45
+ * async function addLiquidityWithWrappedNative(
46
+ * chain: EvmChain,
47
+ * otherToken: Token,
48
+ * amountNative: bigint,
49
+ * amountOther: bigint
50
+ * ) {
51
+ * const wrappedNative = getWrappedNative(chain);
52
+ *
53
+ * // First wrap native currency
54
+ * const wrapData = getWrapData(chain, amountNative);
55
+ *
56
+ * // Then add liquidity
57
+ * const addLiquidityData = {
58
+ * target: LP_ROUTER_ADDRESS,
59
+ * data: encodeFunctionData({
60
+ * abi: lpRouterAbi,
61
+ * functionName: 'addLiquidity',
62
+ * args: [
63
+ * wrappedNative.address,
64
+ * otherToken.address,
65
+ * amountNative,
66
+ * amountOther,
67
+ * 0n, // min amounts (should be calculated properly)
68
+ * 0n,
69
+ * await options.evm.getAddress(),
70
+ * Math.floor(Date.now() / 1000) + 3600 // deadline
71
+ * ]
72
+ * })
73
+ * };
74
+ *
75
+ * return await options.evm.sendTransactions({
76
+ * transactions: [wrapData, addLiquidityData]
77
+ * });
78
+ * }
79
+ *
80
+ * // Token validation and comparison
81
+ * function isWrappedNativeToken(chain: EvmChain, tokenAddress: string): boolean {
82
+ * try {
83
+ * const wrappedNative = getWrappedNative(chain);
84
+ * return wrappedNative.address.toLowerCase() === tokenAddress.toLowerCase();
85
+ * } catch (error) {
86
+ * return false;
87
+ * }
88
+ * }
89
+ *
90
+ * // Generate token list for UI
91
+ * function generateWrappedNativeTokenList(chains: EvmChain[]) {
92
+ * return chains.map(chain => {
93
+ * try {
94
+ * const token = getWrappedNative(chain);
95
+ * return {
96
+ * ...token,
97
+ * chainName: chain,
98
+ * logoURI: `https://tokens.app/tokens/${token.chainId}/${token.address}.png`,
99
+ * tags: ['wrapped', 'native']
100
+ * };
101
+ * } catch (error) {
102
+ * return null;
103
+ * }
104
+ * }).filter(Boolean);
105
+ * }
106
+ *
107
+ * // Cross-chain token bridge preparation
108
+ * async function prepareBridgeTransaction(
109
+ * sourceChain: EvmChain,
110
+ * targetChain: EvmChain,
111
+ * amount: bigint
112
+ * ) {
113
+ * const sourceToken = getWrappedNative(sourceChain);
114
+ * const targetToken = getWrappedNative(targetChain);
115
+ *
116
+ * return {
117
+ * source: {
118
+ * chain: sourceChain,
119
+ * token: sourceToken,
120
+ * amount
121
+ * },
122
+ * target: {
123
+ * chain: targetChain,
124
+ * token: targetToken,
125
+ * expectedAmount: amount // Simplified - should include bridge fees
126
+ * },
127
+ * bridgeConfig: {
128
+ * sourceChainId: sourceToken.chainId,
129
+ * targetChainId: targetToken.chainId,
130
+ * tokenAddress: sourceToken.address
131
+ * }
132
+ * };
133
+ * }
134
+ *
135
+ * // Portfolio tracking with wrapped natives
136
+ * async function getWrappedNativePortfolio(
137
+ * chains: EvmChain[],
138
+ * userAddress: Address
139
+ * ) {
140
+ * const portfolio = await Promise.allSettled(
141
+ * chains.map(async (chain) => {
142
+ * const token = getWrappedNative(chain);
143
+ * const provider = options.evm.getProvider(token.chainId);
144
+ *
145
+ * const balance = await provider.readContract({
146
+ * address: token.address,
147
+ * abi: erc20Abi,
148
+ * functionName: 'balanceOf',
149
+ * args: [userAddress]
150
+ * });
151
+ *
152
+ * return {
153
+ * chain,
154
+ * token,
155
+ * balance,
156
+ * formattedBalance: formatUnits(balance, token.decimals),
157
+ * usdValue: await getTokenUSDValue(token, balance) // External price service
158
+ * };
159
+ * })
160
+ * );
161
+ *
162
+ * return portfolio
163
+ * .filter((result): result is PromiseFulfilledResult<any> => result.status === 'fulfilled')
164
+ * .map(result => result.value)
165
+ * .filter(item => item.balance > 0n);
166
+ * }
167
+ *
168
+ * // DEX price comparison across chains
169
+ * async function compareWrappedNativePrices(chains: EvmChain[]) {
170
+ * const priceData = await Promise.allSettled(
171
+ * chains.map(async (chain) => {
172
+ * const token = getWrappedNative(chain);
173
+ * const price = await getDEXPrice(token); // External price fetching
174
+ *
175
+ * return {
176
+ * chain,
177
+ * token: token.symbol,
178
+ * address: token.address,
179
+ * priceUSD: price,
180
+ * chainId: token.chainId
181
+ * };
182
+ * })
183
+ * );
184
+ *
185
+ * return priceData
186
+ * .filter((result): result is PromiseFulfilledResult<any> => result.status === 'fulfilled')
187
+ * .map(result => result.value)
188
+ * .sort((a, b) => b.priceUSD - a.priceUSD);
189
+ * }
190
+ *
191
+ * // Safe version that returns null instead of throwing
192
+ * function safeGetWrappedNative(chain: EvmChain): Token | null {
193
+ * try {
194
+ * return getWrappedNative(chain);
195
+ * } catch (error) {
196
+ * return null;
197
+ * }
198
+ * }
199
+ * ```
200
+ */
3
201
  export declare function getWrappedNative(chain: EvmChain): Token;