@anywalletkit/protocol-swap2-wrap 0.0.0-stage → 0.1.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/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
package/README.md CHANGED
@@ -1,3 +1,26 @@
1
- # Temporary Holding Version
1
+ # @anywalletkit/protocol-swap2-wrap
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Wrap / unwrap the native coin as a swap2 module: WETH9 `deposit()` and
4
+ `withdraw(uint256)` on the wrapper in `WRAPPED_NATIVE` for each chain (WETH,
5
+ WBNB, WPOL, WAVAX, …), verified on-chain before use. Standalone through
6
+ `WrapSwap2Protocol`, or as one provider of the router.
7
+
8
+ ## Activity
9
+
10
+ `describeActivity(tx, ctx)` recognizes calls to the chain's wrapper (the
11
+ table, or the `wrapped` override you passed):
12
+
13
+ | Selector | Kind | Title |
14
+ | --- | --- | --- |
15
+ | `deposit()` `0xd0e30db0` | `wrap` | "Wrapped ETH" (the chain's native symbol) |
16
+ | `withdraw(uint256)` `0x2e1a7d4d` | `unwrap` | "Unwrapped WETH" (the wrapper's symbol) |
17
+
18
+ Assets are the owner's net transfers (native out + WETH mint in, or WETH burn
19
+ out + native in), subtitle = the wrapper symbol, counterparty = the wrapper.
20
+ A swap that unwraps inside a DEX router is that router's activity, not this
21
+ module's.
22
+
23
+ Fixtures (`fixtures/activity/`, public Ethereum WETH9 transactions,
24
+ 2026-10-14 — the test wallet's wrap runs were quote-only on the matrix): two
25
+ `deposit()`, two `withdraw()`; negatives: a Uniswap `multicall` ending in
26
+ `unwrapWETH9`, a Balancer Vault swap.
@@ -0,0 +1,98 @@
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/activity.ts
21
+ var activity_exports = {};
22
+ __export(activity_exports, {
23
+ WETH_DEPOSIT: () => WETH_DEPOSIT,
24
+ WETH_WITHDRAW: () => WETH_WITHDRAW,
25
+ WRAP_MODULE: () => WRAP_MODULE,
26
+ describeWrapActivity: () => describeWrapActivity
27
+ });
28
+ module.exports = __toCommonJS(activity_exports);
29
+ var import_activity = require("@anywalletkit/protocol-swap2-core/activity");
30
+ var import_util2 = require("@anywalletkit/protocol-swap2-core/util");
31
+
32
+ // src/provider.ts
33
+ var import_viem = require("viem");
34
+ var import_swap2_assets = require("@anywalletkit/swap2-assets");
35
+ var import_util = require("@anywalletkit/protocol-swap2-core/util");
36
+ var WRAPPED_NATIVE = Object.freeze({
37
+ 1: { address: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2", symbol: "WETH" },
38
+ 10: { address: "0x4200000000000000000000000000000000000006", symbol: "WETH" },
39
+ 56: { address: "0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c", symbol: "WBNB" },
40
+ 100: { address: "0xe91D153E0b41518A2Ce8Dd3D7944Fa863463a97d", symbol: "WXDAI" },
41
+ 130: { address: "0x4200000000000000000000000000000000000006", symbol: "WETH" },
42
+ 137: { address: "0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270", symbol: "WPOL" },
43
+ 143: { address: "0x3bd359C1119dA7Da1D913D1C4D2B7c461115433A", symbol: "WMON" },
44
+ 999: { address: "0x5555555555555555555555555555555555555555", symbol: "WHYPE" },
45
+ 324: { address: "0x5AEa5775959fBC2557Cc8789bC1bf90A239D9a91", symbol: "WETH" },
46
+ 4326: { address: "0x4200000000000000000000000000000000000006", symbol: "WETH" },
47
+ 9745: { address: "0x6100E367285b01F48D07953803A2d8dCA5D19873", symbol: "WXPL" },
48
+ 146: { address: "0x039e2fB66102314Ce7b64Ce5Ce3E5183bc94aD38", symbol: "wS" },
49
+ 59144: { address: "0xe5D7C2a44FfDDf6b295A15c148167daaAf5Cf34f", symbol: "WETH" },
50
+ 8453: { address: "0x4200000000000000000000000000000000000006", symbol: "WETH" },
51
+ 42161: { address: "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1", symbol: "WETH" },
52
+ 43114: { address: "0xB31f66AA3C1e785363F0875A1B74E27b85FD66c7", symbol: "WAVAX" },
53
+ 80094: { address: "0x6969696969696969696969696969696969696969", symbol: "WBERA" },
54
+ 534352: { address: "0x5300000000000000000000000000000000000004", symbol: "WETH" },
55
+ // 2026-10-13: World Chain, Sei, Ink, Plume, X Layer — verified on-chain (symbol, decimals, supply, deposit()).
56
+ 480: { address: "0x4200000000000000000000000000000000000006", symbol: "WETH" },
57
+ 1329: { address: "0xE30feDd158A2e3b13e9badaeABaFc5516e95e8C7", symbol: "WSEI" },
58
+ 57073: { address: "0x4200000000000000000000000000000000000006", symbol: "WETH" },
59
+ 98866: { address: "0xEa237441c92CAe6FC17Caaf9a7acB3f953be4bd1", symbol: "WPLUME" },
60
+ 196: { address: "0xe538905cf8410324e03A5A23C1c177a474D59b2b", symbol: "WOKB" },
61
+ // 2026-10-14: Mantle, Katana, Morph, Flare — symbol, 18 decimals, supply, deposit()/withdraw() selectors in the
62
+ // bytecode and eth_estimateGas of deposit() with value from a funded sender, all checked on-chain. Katana's WETH9 is
63
+ // Vault Bridge's vbETH (the on-chain symbol the verify step compares against; the catalog shows it as WETH).
64
+ // Arc has no wrapper by design: its native USDC already exposes an ERC-20 interface (docs.arc.network).
65
+ 5e3: { address: "0x78c1b0C915c4FAA5FffA6CAbf0219DA63d7f4cb8", symbol: "WMNT" },
66
+ 747474: { address: "0xEE7D8BCFb72bC1880D0Cf19822eB0A2e6577aB62", symbol: "vbETH" },
67
+ 2818: { address: "0x5300000000000000000000000000000000000011", symbol: "WETH" },
68
+ 14: { address: "0x1D80c49BbBCd1C0911346656B529DF9E5c2F783d", symbol: "WFLR" }
69
+ });
70
+ var WETH_ABI = (0, import_viem.parseAbi)([
71
+ "function deposit() payable",
72
+ "function withdraw(uint256 wad)",
73
+ "function symbol() view returns (string)",
74
+ "function decimals() view returns (uint8)"
75
+ ]);
76
+
77
+ // src/activity.ts
78
+ var WRAP_MODULE = "@anywalletkit/protocol-swap2-wrap";
79
+ var WETH_DEPOSIT = "0xd0e30db0";
80
+ var WETH_WITHDRAW = "0x2e1a7d4d";
81
+ function describeWrapActivity(tx, ctx, wrapped = WRAPPED_NATIVE) {
82
+ if (!(0, import_util2.isEvm)(tx.chain)) return null;
83
+ const w = wrapped[(0, import_util2.evmRef)(tx.chain)];
84
+ if (!w) return null;
85
+ const isDeposit = (0, import_activity.matchesCall)(tx, [w.address], [WETH_DEPOSIT]);
86
+ const isWithdraw = !isDeposit && (0, import_activity.matchesCall)(tx, [w.address], [WETH_WITHDRAW]);
87
+ if (!isDeposit && !isWithdraw) return null;
88
+ const { assetsIn, assetsOut } = (0, import_activity.ownerAssets)(tx, ctx);
89
+ const native = [...assetsIn, ...assetsOut].find((a) => a.token === null);
90
+ const nativeLabel = native ? (0, import_activity.assetLabel)(tx, native) : w.symbol.replace(/^[Ww]/, "");
91
+ return (0, import_activity.describeSwapLike)(tx, ctx, {
92
+ protocol: WRAP_MODULE,
93
+ subtitle: w.symbol,
94
+ kind: isDeposit ? "wrap" : "unwrap",
95
+ title: isDeposit ? `Wrapped ${nativeLabel}` : `Unwrapped ${w.symbol}`
96
+ });
97
+ }
98
+ //# sourceMappingURL=activity.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/activity.ts","../src/provider.ts"],"sourcesContent":["/**\n * Activity recognition for the Wrap module: WETH9 `deposit()` → `wrap`\n * (\"Wrapped ETH\"), `withdraw(uint256)` → `unwrap` (\"Unwrapped WETH\"), on the\n * wrapper the table (or the caller's override) names for the chain.\n */\nimport type {ActivityItem, ChainTx, DescribeActivityContext} from \"@anywalletkit/core\";\nimport {assetLabel, describeSwapLike, matchesCall, ownerAssets} from \"@anywalletkit/protocol-swap2-core/activity\";\nimport {evmRef, isEvm} from \"@anywalletkit/protocol-swap2-core/util\";\nimport {WRAPPED_NATIVE} from \"./provider.js\";\n\nexport const WRAP_MODULE = \"@anywalletkit/protocol-swap2-wrap\";\n\n/** deposit() */\nexport const WETH_DEPOSIT = \"0xd0e30db0\";\n/** withdraw(uint256 wad) */\nexport const WETH_WITHDRAW = \"0x2e1a7d4d\";\n\nexport function describeWrapActivity(\n tx: ChainTx,\n ctx: DescribeActivityContext,\n wrapped: Readonly<Record<number, {address: `0x${string}`; symbol: string}>> = WRAPPED_NATIVE,\n): ActivityItem | null {\n if (!isEvm(tx.chain)) return null;\n const w = wrapped[evmRef(tx.chain)];\n if (!w) return null;\n const isDeposit = matchesCall(tx, [w.address], [WETH_DEPOSIT]);\n const isWithdraw = !isDeposit && matchesCall(tx, [w.address], [WETH_WITHDRAW]);\n if (!isDeposit && !isWithdraw) return null;\n const {assetsIn, assetsOut} = ownerAssets(tx, ctx);\n const native = [...assetsIn, ...assetsOut].find((a) => a.token === null);\n const nativeLabel = native ? assetLabel(tx, native) : w.symbol.replace(/^[Ww]/, \"\");\n return describeSwapLike(tx, ctx, {\n protocol: WRAP_MODULE,\n subtitle: w.symbol,\n kind: isDeposit ? \"wrap\" : \"unwrap\",\n title: isDeposit ? `Wrapped ${nativeLabel}` : `Unwrapped ${w.symbol}`,\n });\n}\n","import {decodeFunctionResult, encodeFunctionData, getAddress, parseAbi, type Hex} from \"viem\";\nimport {describeWrapActivity} from \"./activity.js\";\nimport {ccAsset} from \"@anywalletkit/swap2-assets\";\nimport {evmRef, isEvm, timeoutSignal} from \"@anywalletkit/protocol-swap2-core/util\";\nimport type {Asset, CrossChainProvider, IntentRef, IntentStatus, Quote, QuoteParams, UnsignedTx} from \"@anywalletkit/protocol-swap2-core/types\";\n\n/**\n * The chain's canonical wrapped native token (WETH9-style `deposit()` /\n * `withdraw(uint256)`). Every entry was checked on-chain 2026-10-12: symbol,\n * 18 decimals, non-zero supply, and `deposit()` succeeding for a funded sender.\n * The provider re-checks symbol + decimals once per chain before quoting.\n */\nexport const WRAPPED_NATIVE: Readonly<Record<number, {address: `0x${string}`; symbol: string}>> = Object.freeze({\n 1: {address: \"0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2\", symbol: \"WETH\"},\n 10: {address: \"0x4200000000000000000000000000000000000006\", symbol: \"WETH\"},\n 56: {address: \"0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c\", symbol: \"WBNB\"},\n 100: {address: \"0xe91D153E0b41518A2Ce8Dd3D7944Fa863463a97d\", symbol: \"WXDAI\"},\n 130: {address: \"0x4200000000000000000000000000000000000006\", symbol: \"WETH\"},\n 137: {address: \"0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270\", symbol: \"WPOL\"},\n 143: {address: \"0x3bd359C1119dA7Da1D913D1C4D2B7c461115433A\", symbol: \"WMON\"},\n 999: {address: \"0x5555555555555555555555555555555555555555\", symbol: \"WHYPE\"},\n 324: {address: \"0x5AEa5775959fBC2557Cc8789bC1bf90A239D9a91\", symbol: \"WETH\"},\n 4326: {address: \"0x4200000000000000000000000000000000000006\", symbol: \"WETH\"},\n 9745: {address: \"0x6100E367285b01F48D07953803A2d8dCA5D19873\", symbol: \"WXPL\"},\n 146: {address: \"0x039e2fB66102314Ce7b64Ce5Ce3E5183bc94aD38\", symbol: \"wS\"},\n 59144: {address: \"0xe5D7C2a44FfDDf6b295A15c148167daaAf5Cf34f\", symbol: \"WETH\"},\n 8453: {address: \"0x4200000000000000000000000000000000000006\", symbol: \"WETH\"},\n 42161: {address: \"0x82aF49447D8a07e3bd95BD0d56f35241523fBab1\", symbol: \"WETH\"},\n 43114: {address: \"0xB31f66AA3C1e785363F0875A1B74E27b85FD66c7\", symbol: \"WAVAX\"},\n 80094: {address: \"0x6969696969696969696969696969696969696969\", symbol: \"WBERA\"},\n 534352: {address: \"0x5300000000000000000000000000000000000004\", symbol: \"WETH\"},\n // 2026-10-13: World Chain, Sei, Ink, Plume, X Layer — verified on-chain (symbol, decimals, supply, deposit()).\n 480: {address: \"0x4200000000000000000000000000000000000006\", symbol: \"WETH\"},\n 1329: {address: \"0xE30feDd158A2e3b13e9badaeABaFc5516e95e8C7\", symbol: \"WSEI\"},\n 57073: {address: \"0x4200000000000000000000000000000000000006\", symbol: \"WETH\"},\n 98866: {address: \"0xEa237441c92CAe6FC17Caaf9a7acB3f953be4bd1\", symbol: \"WPLUME\"},\n 196: {address: \"0xe538905cf8410324e03A5A23C1c177a474D59b2b\", symbol: \"WOKB\"},\n // 2026-10-14: Mantle, Katana, Morph, Flare — symbol, 18 decimals, supply, deposit()/withdraw() selectors in the\n // bytecode and eth_estimateGas of deposit() with value from a funded sender, all checked on-chain. Katana's WETH9 is\n // Vault Bridge's vbETH (the on-chain symbol the verify step compares against; the catalog shows it as WETH).\n // Arc has no wrapper by design: its native USDC already exposes an ERC-20 interface (docs.arc.network).\n 5000: {address: \"0x78c1b0C915c4FAA5FffA6CAbf0219DA63d7f4cb8\", symbol: \"WMNT\"},\n 747474: {address: \"0xEE7D8BCFb72bC1880D0Cf19822eB0A2e6577aB62\", symbol: \"vbETH\"},\n 2818: {address: \"0x5300000000000000000000000000000000000011\", symbol: \"WETH\"},\n 14: {address: \"0x1D80c49BbBCd1C0911346656B529DF9E5c2F783d\", symbol: \"WFLR\"},\n});\n\nconst WETH_ABI = parseAbi([\n \"function deposit() payable\",\n \"function withdraw(uint256 wad)\",\n \"function symbol() view returns (string)\",\n \"function decimals() view returns (uint8)\",\n]);\n/** deposit/withdraw on WETH9 cost ~30-45k; a generous cap, the account still estimates. */\nconst GAS_LIMIT = \"90000\";\n\nexport interface WrapProviderConfig {\n enabled?: boolean;\n /** JSON-RPC endpoints per EVM chain id (on-chain token check + receipt tracking). */\n rpcUrls: Readonly<Record<number, readonly string[]>>;\n /** Override the wrapped tokens (tests, new chains). Still verified on-chain before use. */\n wrapped?: Readonly<Record<number, {address: `0x${string}`; symbol: string}>>;\n}\n\n/**\n * Native ↔ wrapped native as a swap2 venue: `deposit()` with value to wrap,\n * `withdraw(amount)` to unwrap. 1:1, no pool, no slippage, no approval. WETH9\n * credits and pays `msg.sender`, so the recipient must be the sender — a wrap\n * \"to someone else\" is refused rather than silently paid to the wrong place.\n */\nexport function wrapProvider(config: WrapProviderConfig): CrossChainProvider {\n const wrapped = config.wrapped ?? WRAPPED_NATIVE;\n const verified = new Map<number, Promise<void>>();\n\n const chainIdOf = (caip2: string): number | null => {\n if (!isEvm(caip2)) return null;\n const id = evmRef(caip2);\n return wrapped[id] && config.rpcUrls[id]?.length ? id : null;\n };\n\n async function rpc(chainId: number, method: string, params: unknown[]): Promise<unknown> {\n let lastErr: unknown;\n for (const url of config.rpcUrls[chainId] ?? []) {\n try {\n const res = await fetch(url, {\n method: \"POST\",\n headers: {\"content-type\": \"application/json\"},\n body: JSON.stringify({jsonrpc: \"2.0\", id: 1, method, params}),\n signal: timeoutSignal(10_000),\n });\n if (!res.ok) throw new Error(`HTTP ${res.status}`);\n const body = (await res.json()) as {result?: unknown; error?: {message?: string}};\n if (body.error) throw new Error(body.error.message ?? \"rpc error\");\n return body.result ?? null;\n } catch (e) {\n lastErr = e;\n }\n }\n throw new Error(`wrap: no RPC answered on chain ${chainId} (${lastErr instanceof Error ? lastErr.message : String(lastErr)})`);\n }\n\n function verify(chainId: number): Promise<void> {\n let p = verified.get(chainId);\n if (!p) {\n const w = wrapped[chainId]!;\n p = (async () => {\n const read = async (fn: \"symbol\" | \"decimals\") =>\n decodeFunctionResult({abi: WETH_ABI, functionName: fn, data: (await rpc(chainId, \"eth_call\", [{to: w.address, data: encodeFunctionData({abi: WETH_ABI, functionName: fn})}, \"latest\"])) as Hex});\n const [symbol, decimals] = await Promise.all([read(\"symbol\"), read(\"decimals\")]);\n if (symbol !== w.symbol || Number(decimals) !== 18) throw new Error(`wrap: ${w.address} on chain ${chainId} is not ${w.symbol} — refusing`);\n })();\n p.catch(() => verified.delete(chainId));\n verified.set(chainId, p);\n }\n return p;\n }\n\n return {\n name: \"wrap\",\n describeActivity: (tx, ctx) => describeWrapActivity(tx, ctx, wrapped),\n supportsSameChain: true,\n enabled: () => config.enabled ?? true,\n supportsChain: (caip2: string) => chainIdOf(caip2) !== null,\n supportsChainPair: (from: string, to: string) => from === to && chainIdOf(from) !== null,\n supportsRoute(from: Asset, to: Asset): boolean {\n return from.chain === to.chain && chainIdOf(from.chain) !== null;\n },\n\n async getQuote(params: QuoteParams): Promise<Quote | null> {\n const refuse = (why: string): null => {\n params.onRefusal?.(`wrap: ${why}`);\n return null;\n };\n if (params.flex) return refuse(\"amount-flexible deposits are not supported\");\n if (params.sourceChain !== params.destChain) return refuse(\"same-chain only\");\n const chainId = chainIdOf(params.sourceChain);\n if (chainId === null) return refuse(`no wrapped native token or RPC for ${params.sourceChain}`);\n const w = wrapped[chainId]!;\n const src = ccAsset(params.sourceChain, params.sourceToken);\n if (!src) return refuse(`unknown source token ${params.sourceToken}`);\n const nativeIn = !src.contract;\n const srcIsWrapped = !!src.contract && /^0x[0-9a-fA-F]{40}$/.test(src.contract) && getAddress(src.contract) === getAddress(w.address);\n const nativeOut = /^0x0+$/.test(params.destToken);\n const destIsWrapped = /^0x[0-9a-fA-F]{40}$/.test(params.destToken) && !nativeOut && getAddress(params.destToken) === getAddress(w.address);\n const wrap = nativeIn && destIsWrapped;\n const unwrap = srcIsWrapped && nativeOut;\n if (!wrap && !unwrap) return refuse(`only ${w.symbol.slice(1)} ↔ ${w.symbol}`);\n // WETH9 credits / pays msg.sender: the recipient can only be the sender.\n if (params.refundAddress && /^0x[0-9a-fA-F]{40}$/.test(params.refundAddress) && getAddress(params.refundAddress) !== getAddress(params.destAddress)) {\n return refuse(\"wrapping pays the sender's own address — send the result separately\");\n }\n let amount: bigint;\n try {\n amount = BigInt(params.amountIn);\n } catch {\n return refuse(\"amount is not an integer\");\n }\n if (amount <= 0n) return refuse(\"amount must be positive\");\n if (params.minAmountOut !== undefined && amount < BigInt(params.minAmountOut)) return refuse(`floor breach (min=${amount} < floor=${params.minAmountOut})`);\n try {\n await verify(chainId);\n } catch (e) {\n return refuse(e instanceof Error ? e.message.replace(/^wrap: /, \"\") : String(e));\n }\n const data = wrap ? encodeFunctionData({abi: WETH_ABI, functionName: \"deposit\"}) : encodeFunctionData({abi: WETH_ABI, functionName: \"withdraw\", args: [amount]});\n return {\n provider: \"wrap\",\n intentId: `wrap:${chainId}`,\n depositAddress: \"\",\n depositMemo: null,\n txRequest: {to: w.address, data, value: wrap ? amount.toString() : \"0\", chainId, gasLimit: GAS_LIMIT},\n sourceAmount: amount.toString(),\n destAmount: amount.toString(),\n minDestAmount: amount.toString(),\n feeUsd: 0,\n etaSeconds: 15,\n reliability: 0.995,\n validUntilMs: Date.now() + 5 * 60_000,\n providerData: {action: wrap ? \"wrap\" : \"unwrap\", token: w.address},\n };\n },\n\n async buildDeposit(quote: Quote): Promise<UnsignedTx> {\n const tx = quote.txRequest;\n if (!tx?.to || !tx.data) throw new Error(\"swap2: wrap quote has no transaction request\");\n return {chain: \"\", to: tx.to, value: tx.value ?? \"0\", data: tx.data, ...(tx.chainId !== undefined ? {chainId: tx.chainId} : {}), ...(tx.gasLimit ? {gasLimit: tx.gasLimit} : {})};\n },\n\n async trackIntent(ref: IntentRef): Promise<IntentStatus> {\n if (!ref.sourceTxHash) return {state: \"pending\"};\n const chainId = Number(ref.intentId.split(\":\")[1]);\n if (!wrapped[chainId] || !config.rpcUrls[chainId]?.length) return {state: \"pending\"};\n try {\n const receipt = (await rpc(chainId, \"eth_getTransactionReceipt\", [ref.sourceTxHash])) as {status?: string} | null;\n if (!receipt) return {state: \"pending\"};\n return receipt.status === \"0x1\" ? {state: \"completed\", destTxHash: ref.sourceTxHash} : {state: \"failed\"};\n } catch {\n return {state: \"pending\"};\n }\n },\n };\n}\n"],"mappings":"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","names":["import_util"]}
@@ -0,0 +1,19 @@
1
+ import { ChainTx, DescribeActivityContext, ActivityItem } from '@anywalletkit/core';
2
+
3
+ /**
4
+ * Activity recognition for the Wrap module: WETH9 `deposit()` → `wrap`
5
+ * ("Wrapped ETH"), `withdraw(uint256)` → `unwrap` ("Unwrapped WETH"), on the
6
+ * wrapper the table (or the caller's override) names for the chain.
7
+ */
8
+
9
+ declare const WRAP_MODULE = "@anywalletkit/protocol-swap2-wrap";
10
+ /** deposit() */
11
+ declare const WETH_DEPOSIT = "0xd0e30db0";
12
+ /** withdraw(uint256 wad) */
13
+ declare const WETH_WITHDRAW = "0x2e1a7d4d";
14
+ declare function describeWrapActivity(tx: ChainTx, ctx: DescribeActivityContext, wrapped?: Readonly<Record<number, {
15
+ address: `0x${string}`;
16
+ symbol: string;
17
+ }>>): ActivityItem | null;
18
+
19
+ export { WETH_DEPOSIT, WETH_WITHDRAW, WRAP_MODULE, describeWrapActivity };
@@ -0,0 +1,19 @@
1
+ import { ChainTx, DescribeActivityContext, ActivityItem } from '@anywalletkit/core';
2
+
3
+ /**
4
+ * Activity recognition for the Wrap module: WETH9 `deposit()` → `wrap`
5
+ * ("Wrapped ETH"), `withdraw(uint256)` → `unwrap` ("Unwrapped WETH"), on the
6
+ * wrapper the table (or the caller's override) names for the chain.
7
+ */
8
+
9
+ declare const WRAP_MODULE = "@anywalletkit/protocol-swap2-wrap";
10
+ /** deposit() */
11
+ declare const WETH_DEPOSIT = "0xd0e30db0";
12
+ /** withdraw(uint256 wad) */
13
+ declare const WETH_WITHDRAW = "0x2e1a7d4d";
14
+ declare function describeWrapActivity(tx: ChainTx, ctx: DescribeActivityContext, wrapped?: Readonly<Record<number, {
15
+ address: `0x${string}`;
16
+ symbol: string;
17
+ }>>): ActivityItem | null;
18
+
19
+ export { WETH_DEPOSIT, WETH_WITHDRAW, WRAP_MODULE, describeWrapActivity };
@@ -0,0 +1,13 @@
1
+ import {
2
+ WETH_DEPOSIT,
3
+ WETH_WITHDRAW,
4
+ WRAP_MODULE,
5
+ describeWrapActivity
6
+ } from "./chunk-AVEVP6OU.js";
7
+ export {
8
+ WETH_DEPOSIT,
9
+ WETH_WITHDRAW,
10
+ WRAP_MODULE,
11
+ describeWrapActivity
12
+ };
13
+ //# sourceMappingURL=activity.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,30 @@
1
+ import {
2
+ WRAPPED_NATIVE,
3
+ wrapProvider
4
+ } from "./chunk-AVEVP6OU.js";
5
+
6
+ // src/protocol.ts
7
+ import { SingleProviderSwap2 } from "@anywalletkit/protocol-swap2-core/swap2/single";
8
+ import { evmRef, isEvm } from "@anywalletkit/protocol-swap2-core/util";
9
+ var WrapSwap2Protocol = class extends SingleProviderSwap2 {
10
+ provider;
11
+ _rpcUrls;
12
+ _wrapped;
13
+ constructor(account, config) {
14
+ super(account, config);
15
+ this.provider = wrapProvider(config);
16
+ this._rpcUrls = config.rpcUrls ?? {};
17
+ this._wrapped = config.wrapped ?? WRAPPED_NATIVE;
18
+ }
19
+ chainSupported(caip2) {
20
+ return isEvm(caip2) && !!this._wrapped[evmRef(caip2)] && !!this._rpcUrls[evmRef(caip2)]?.length;
21
+ }
22
+ pairSupported(fromChain, toChain) {
23
+ return fromChain === toChain && this.chainSupported(fromChain);
24
+ }
25
+ };
26
+
27
+ export {
28
+ WrapSwap2Protocol
29
+ };
30
+ //# sourceMappingURL=chunk-ATKZPIBU.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/protocol.ts"],"sourcesContent":["import {SingleProviderSwap2} from \"@anywalletkit/protocol-swap2-core/swap2/single\";\nimport type {Swap2Account, Swap2EngineConfig} from \"@anywalletkit/protocol-swap2-core/swap2/base\";\nimport {evmRef, isEvm} from \"@anywalletkit/protocol-swap2-core/util\";\nimport {WRAPPED_NATIVE, wrapProvider, type WrapProviderConfig} from \"./provider.js\";\n\nexport interface WrapSwap2Config extends Swap2EngineConfig, WrapProviderConfig {}\n\n/** Wrap / unwrap the native coin on one account (ETH ↔ WETH and friends). */\nexport class WrapSwap2Protocol extends SingleProviderSwap2 {\n protected readonly provider;\n private readonly _rpcUrls: WrapProviderConfig[\"rpcUrls\"];\n private readonly _wrapped: NonNullable<WrapProviderConfig[\"wrapped\"]>;\n constructor(account: Swap2Account | undefined, config: WrapSwap2Config) {\n super(account, config);\n this.provider = wrapProvider(config);\n this._rpcUrls = config.rpcUrls ?? {};\n this._wrapped = config.wrapped ?? WRAPPED_NATIVE;\n }\n protected override chainSupported(caip2: string): boolean {\n return isEvm(caip2) && !!this._wrapped[evmRef(caip2)] && !!this._rpcUrls[evmRef(caip2)]?.length;\n }\n protected override pairSupported(fromChain: string, toChain: string): boolean {\n return fromChain === toChain && this.chainSupported(fromChain);\n }\n}\n"],"mappings":";;;;;;AAAA,SAAQ,2BAA0B;AAElC,SAAQ,QAAQ,aAAY;AAMrB,IAAM,oBAAN,cAAgC,oBAAoB;AAAA,EACtC;AAAA,EACF;AAAA,EACA;AAAA,EACjB,YAAY,SAAmC,QAAyB;AACtE,UAAM,SAAS,MAAM;AACrB,SAAK,WAAW,aAAa,MAAM;AACnC,SAAK,WAAW,OAAO,WAAW,CAAC;AACnC,SAAK,WAAW,OAAO,WAAW;AAAA,EACpC;AAAA,EACmB,eAAe,OAAwB;AACxD,WAAO,MAAM,KAAK,KAAK,CAAC,CAAC,KAAK,SAAS,OAAO,KAAK,CAAC,KAAK,CAAC,CAAC,KAAK,SAAS,OAAO,KAAK,CAAC,GAAG;AAAA,EAC3F;AAAA,EACmB,cAAc,WAAmB,SAA0B;AAC5E,WAAO,cAAc,WAAW,KAAK,eAAe,SAAS;AAAA,EAC/D;AACF;","names":[]}