@agenticvault/agentic-vault 0.1.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.
Files changed (201) hide show
  1. package/.claude-plugin/plugin.json +19 -0
  2. package/.env.example +16 -0
  3. package/.mcp.json.example +18 -0
  4. package/LICENSE +21 -0
  5. package/README.ja.md +163 -0
  6. package/README.ko.md +163 -0
  7. package/README.md +161 -0
  8. package/README.zh-CN.md +163 -0
  9. package/README.zh-TW.md +163 -0
  10. package/dist/agentic/audit/logger.d.ts +7 -0
  11. package/dist/agentic/audit/logger.js +19 -0
  12. package/dist/agentic/audit/logger.js.map +1 -0
  13. package/dist/agentic/audit/types.d.ts +11 -0
  14. package/dist/agentic/audit/types.js +2 -0
  15. package/dist/agentic/audit/types.js.map +1 -0
  16. package/dist/agentic/cli.d.ts +8 -0
  17. package/dist/agentic/cli.js +87 -0
  18. package/dist/agentic/cli.js.map +1 -0
  19. package/dist/agentic/index.d.ts +5 -0
  20. package/dist/agentic/index.js +7 -0
  21. package/dist/agentic/index.js.map +1 -0
  22. package/dist/agentic/mcp/server.d.ts +8 -0
  23. package/dist/agentic/mcp/server.js +25 -0
  24. package/dist/agentic/mcp/server.js.map +1 -0
  25. package/dist/agentic/mcp/tools/decoded-call-pipeline.d.ts +14 -0
  26. package/dist/agentic/mcp/tools/decoded-call-pipeline.js +18 -0
  27. package/dist/agentic/mcp/tools/decoded-call-pipeline.js.map +1 -0
  28. package/dist/agentic/mcp/tools/get-address.d.ts +3 -0
  29. package/dist/agentic/mcp/tools/get-address.js +25 -0
  30. package/dist/agentic/mcp/tools/get-address.js.map +1 -0
  31. package/dist/agentic/mcp/tools/health-check.d.ts +3 -0
  32. package/dist/agentic/mcp/tools/health-check.js +25 -0
  33. package/dist/agentic/mcp/tools/health-check.js.map +1 -0
  34. package/dist/agentic/mcp/tools/index.d.ts +7 -0
  35. package/dist/agentic/mcp/tools/index.js +21 -0
  36. package/dist/agentic/mcp/tools/index.js.map +1 -0
  37. package/dist/agentic/mcp/tools/result-adapter.d.ts +10 -0
  38. package/dist/agentic/mcp/tools/result-adapter.js +15 -0
  39. package/dist/agentic/mcp/tools/result-adapter.js.map +1 -0
  40. package/dist/agentic/mcp/tools/shared.d.ts +71 -0
  41. package/dist/agentic/mcp/tools/shared.js +12 -0
  42. package/dist/agentic/mcp/tools/shared.js.map +1 -0
  43. package/dist/agentic/mcp/tools/sign-defi-call.d.ts +3 -0
  44. package/dist/agentic/mcp/tools/sign-defi-call.js +23 -0
  45. package/dist/agentic/mcp/tools/sign-defi-call.js.map +1 -0
  46. package/dist/agentic/mcp/tools/sign-permit.d.ts +3 -0
  47. package/dist/agentic/mcp/tools/sign-permit.js +39 -0
  48. package/dist/agentic/mcp/tools/sign-permit.js.map +1 -0
  49. package/dist/agentic/mcp/tools/sign-swap.d.ts +3 -0
  50. package/dist/agentic/mcp/tools/sign-swap.js +23 -0
  51. package/dist/agentic/mcp/tools/sign-swap.js.map +1 -0
  52. package/dist/agentic/mcp/tools/sign-transaction.d.ts +3 -0
  53. package/dist/agentic/mcp/tools/sign-transaction.js +68 -0
  54. package/dist/agentic/mcp/tools/sign-transaction.js.map +1 -0
  55. package/dist/agentic/mcp/tools/sign-typed-data.d.ts +3 -0
  56. package/dist/agentic/mcp/tools/sign-typed-data.js +50 -0
  57. package/dist/agentic/mcp/tools/sign-typed-data.js.map +1 -0
  58. package/dist/agentic/policy/engine.d.ts +2 -0
  59. package/dist/agentic/policy/engine.js +3 -0
  60. package/dist/agentic/policy/engine.js.map +1 -0
  61. package/dist/agentic/policy/types.d.ts +2 -0
  62. package/dist/agentic/policy/types.js +2 -0
  63. package/dist/agentic/policy/types.js.map +1 -0
  64. package/dist/cli/commands/decode.d.ts +1 -0
  65. package/dist/cli/commands/decode.js +51 -0
  66. package/dist/cli/commands/decode.js.map +1 -0
  67. package/dist/cli/commands/dry-run.d.ts +2 -0
  68. package/dist/cli/commands/dry-run.js +56 -0
  69. package/dist/cli/commands/dry-run.js.map +1 -0
  70. package/dist/cli/commands/encode.d.ts +1 -0
  71. package/dist/cli/commands/encode.js +77 -0
  72. package/dist/cli/commands/encode.js.map +1 -0
  73. package/dist/cli/commands/get-address.d.ts +3 -0
  74. package/dist/cli/commands/get-address.js +26 -0
  75. package/dist/cli/commands/get-address.js.map +1 -0
  76. package/dist/cli/commands/health.d.ts +3 -0
  77. package/dist/cli/commands/health.js +26 -0
  78. package/dist/cli/commands/health.js.map +1 -0
  79. package/dist/cli/commands/mcp.d.ts +6 -0
  80. package/dist/cli/commands/mcp.js +40 -0
  81. package/dist/cli/commands/mcp.js.map +1 -0
  82. package/dist/cli/commands/sign-permit.d.ts +2 -0
  83. package/dist/cli/commands/sign-permit.js +110 -0
  84. package/dist/cli/commands/sign-permit.js.map +1 -0
  85. package/dist/cli/commands/sign.d.ts +2 -0
  86. package/dist/cli/commands/sign.js +82 -0
  87. package/dist/cli/commands/sign.js.map +1 -0
  88. package/dist/cli/context.d.ts +10 -0
  89. package/dist/cli/context.js +84 -0
  90. package/dist/cli/context.js.map +1 -0
  91. package/dist/cli/formatters.d.ts +18 -0
  92. package/dist/cli/formatters.js +74 -0
  93. package/dist/cli/formatters.js.map +1 -0
  94. package/dist/cli/index.d.ts +2 -0
  95. package/dist/cli/index.js +108 -0
  96. package/dist/cli/index.js.map +1 -0
  97. package/dist/core/evm-signer-adapter.d.ts +42 -0
  98. package/dist/core/evm-signer-adapter.js +92 -0
  99. package/dist/core/evm-signer-adapter.js.map +1 -0
  100. package/dist/core/signing-provider.d.ts +14 -0
  101. package/dist/core/signing-provider.js +2 -0
  102. package/dist/core/signing-provider.js.map +1 -0
  103. package/dist/crypto/evm-signer.util.d.ts +43 -0
  104. package/dist/crypto/evm-signer.util.js +151 -0
  105. package/dist/crypto/evm-signer.util.js.map +1 -0
  106. package/dist/evm-signer.util.d.ts +1 -0
  107. package/dist/evm-signer.util.js +4 -0
  108. package/dist/evm-signer.util.js.map +1 -0
  109. package/dist/index.d.ts +11 -0
  110. package/dist/index.js +9 -0
  111. package/dist/index.js.map +1 -0
  112. package/dist/kms-client.d.ts +1 -0
  113. package/dist/kms-client.js +4 -0
  114. package/dist/kms-client.js.map +1 -0
  115. package/dist/kms-signer.d.ts +1 -0
  116. package/dist/kms-signer.js +4 -0
  117. package/dist/kms-signer.js.map +1 -0
  118. package/dist/protocols/catalog.d.ts +310 -0
  119. package/dist/protocols/catalog.js +162 -0
  120. package/dist/protocols/catalog.js.map +1 -0
  121. package/dist/protocols/decoders/aave-v3.d.ts +2 -0
  122. package/dist/protocols/decoders/aave-v3.js +105 -0
  123. package/dist/protocols/decoders/aave-v3.js.map +1 -0
  124. package/dist/protocols/decoders/erc20.d.ts +2 -0
  125. package/dist/protocols/decoders/erc20.js +51 -0
  126. package/dist/protocols/decoders/erc20.js.map +1 -0
  127. package/dist/protocols/decoders/uniswap-v3.d.ts +2 -0
  128. package/dist/protocols/decoders/uniswap-v3.js +57 -0
  129. package/dist/protocols/decoders/uniswap-v3.js.map +1 -0
  130. package/dist/protocols/dispatcher.d.ts +8 -0
  131. package/dist/protocols/dispatcher.js +32 -0
  132. package/dist/protocols/dispatcher.js.map +1 -0
  133. package/dist/protocols/index.d.ts +16 -0
  134. package/dist/protocols/index.js +19 -0
  135. package/dist/protocols/index.js.map +1 -0
  136. package/dist/protocols/policy/engine.d.ts +11 -0
  137. package/dist/protocols/policy/engine.js +67 -0
  138. package/dist/protocols/policy/engine.js.map +1 -0
  139. package/dist/protocols/policy/evaluators/aave-v3.d.ts +2 -0
  140. package/dist/protocols/policy/evaluators/aave-v3.js +118 -0
  141. package/dist/protocols/policy/evaluators/aave-v3.js.map +1 -0
  142. package/dist/protocols/policy/evaluators/erc20.d.ts +2 -0
  143. package/dist/protocols/policy/evaluators/erc20.js +55 -0
  144. package/dist/protocols/policy/evaluators/erc20.js.map +1 -0
  145. package/dist/protocols/policy/evaluators/uniswap-v3.d.ts +2 -0
  146. package/dist/protocols/policy/evaluators/uniswap-v3.js +46 -0
  147. package/dist/protocols/policy/evaluators/uniswap-v3.js.map +1 -0
  148. package/dist/protocols/policy/loader.d.ts +11 -0
  149. package/dist/protocols/policy/loader.js +70 -0
  150. package/dist/protocols/policy/loader.js.map +1 -0
  151. package/dist/protocols/policy/types.d.ts +38 -0
  152. package/dist/protocols/policy/types.js +2 -0
  153. package/dist/protocols/policy/types.js.map +1 -0
  154. package/dist/protocols/registry.d.ts +21 -0
  155. package/dist/protocols/registry.js +52 -0
  156. package/dist/protocols/registry.js.map +1 -0
  157. package/dist/protocols/types.d.ts +90 -0
  158. package/dist/protocols/types.js +2 -0
  159. package/dist/protocols/types.js.map +1 -0
  160. package/dist/protocols/workflows/get-address.d.ts +2 -0
  161. package/dist/protocols/workflows/get-address.js +41 -0
  162. package/dist/protocols/workflows/get-address.js.map +1 -0
  163. package/dist/protocols/workflows/health-check.d.ts +2 -0
  164. package/dist/protocols/workflows/health-check.js +41 -0
  165. package/dist/protocols/workflows/health-check.js.map +1 -0
  166. package/dist/protocols/workflows/index.d.ts +5 -0
  167. package/dist/protocols/workflows/index.js +5 -0
  168. package/dist/protocols/workflows/index.js.map +1 -0
  169. package/dist/protocols/workflows/sign-defi-call.d.ts +14 -0
  170. package/dist/protocols/workflows/sign-defi-call.js +157 -0
  171. package/dist/protocols/workflows/sign-defi-call.js.map +1 -0
  172. package/dist/protocols/workflows/sign-permit.d.ts +21 -0
  173. package/dist/protocols/workflows/sign-permit.js +320 -0
  174. package/dist/protocols/workflows/sign-permit.js.map +1 -0
  175. package/dist/protocols/workflows/types.d.ts +79 -0
  176. package/dist/protocols/workflows/types.js +2 -0
  177. package/dist/protocols/workflows/types.js.map +1 -0
  178. package/dist/provider/factory.d.ts +12 -0
  179. package/dist/provider/factory.js +19 -0
  180. package/dist/provider/factory.js.map +1 -0
  181. package/dist/providers/aws-kms/aws-kms-client.d.ts +19 -0
  182. package/dist/providers/aws-kms/aws-kms-client.js +47 -0
  183. package/dist/providers/aws-kms/aws-kms-client.js.map +1 -0
  184. package/dist/providers/aws-kms/aws-kms-provider.d.ts +17 -0
  185. package/dist/providers/aws-kms/aws-kms-provider.js +40 -0
  186. package/dist/providers/aws-kms/aws-kms-provider.js.map +1 -0
  187. package/dist/providers/aws-kms/index.d.ts +3 -0
  188. package/dist/providers/aws-kms/index.js +4 -0
  189. package/dist/providers/aws-kms/index.js.map +1 -0
  190. package/dist/providers/aws-kms/kms-signer-adapter.d.ts +41 -0
  191. package/dist/providers/aws-kms/kms-signer-adapter.js +101 -0
  192. package/dist/providers/aws-kms/kms-signer-adapter.js.map +1 -0
  193. package/dist/types.d.ts +13 -0
  194. package/dist/types.js +2 -0
  195. package/dist/types.js.map +1 -0
  196. package/package.json +109 -0
  197. package/policy.example.json +43 -0
  198. package/skills/audit-log/SKILL.md +32 -0
  199. package/skills/check-wallet/SKILL.md +23 -0
  200. package/skills/sign-permit/SKILL.md +29 -0
  201. package/skills/sign-swap/SKILL.md +29 -0
@@ -0,0 +1,310 @@
1
+ import type { Hex } from 'viem';
2
+ /**
3
+ * Protocol Action Catalog — shared ABI metadata for encode/decode.
4
+ * Single source of truth: ABIs live here, decoders import from here.
5
+ */
6
+ export declare const erc20ApproveAbi: {
7
+ readonly name: "approve";
8
+ readonly type: "function";
9
+ readonly stateMutability: "nonpayable";
10
+ readonly inputs: readonly [{
11
+ readonly name: "spender";
12
+ readonly type: "address";
13
+ }, {
14
+ readonly name: "amount";
15
+ readonly type: "uint256";
16
+ }];
17
+ readonly outputs: readonly [{
18
+ readonly name: "";
19
+ readonly type: "bool";
20
+ }];
21
+ };
22
+ export declare const erc20TransferAbi: {
23
+ readonly name: "transfer";
24
+ readonly type: "function";
25
+ readonly stateMutability: "nonpayable";
26
+ readonly inputs: readonly [{
27
+ readonly name: "to";
28
+ readonly type: "address";
29
+ }, {
30
+ readonly name: "amount";
31
+ readonly type: "uint256";
32
+ }];
33
+ readonly outputs: readonly [{
34
+ readonly name: "";
35
+ readonly type: "bool";
36
+ }];
37
+ };
38
+ export declare const uniswapV3ExactInputSingleAbi: {
39
+ readonly name: "exactInputSingle";
40
+ readonly type: "function";
41
+ readonly stateMutability: "payable";
42
+ readonly inputs: readonly [{
43
+ readonly name: "params";
44
+ readonly type: "tuple";
45
+ readonly components: readonly [{
46
+ readonly name: "tokenIn";
47
+ readonly type: "address";
48
+ }, {
49
+ readonly name: "tokenOut";
50
+ readonly type: "address";
51
+ }, {
52
+ readonly name: "fee";
53
+ readonly type: "uint24";
54
+ }, {
55
+ readonly name: "recipient";
56
+ readonly type: "address";
57
+ }, {
58
+ readonly name: "amountIn";
59
+ readonly type: "uint256";
60
+ }, {
61
+ readonly name: "amountOutMinimum";
62
+ readonly type: "uint256";
63
+ }, {
64
+ readonly name: "sqrtPriceLimitX96";
65
+ readonly type: "uint160";
66
+ }];
67
+ }];
68
+ readonly outputs: readonly [{
69
+ readonly name: "amountOut";
70
+ readonly type: "uint256";
71
+ }];
72
+ };
73
+ export declare const erc20Abi: readonly [{
74
+ readonly name: "approve";
75
+ readonly type: "function";
76
+ readonly stateMutability: "nonpayable";
77
+ readonly inputs: readonly [{
78
+ readonly name: "spender";
79
+ readonly type: "address";
80
+ }, {
81
+ readonly name: "amount";
82
+ readonly type: "uint256";
83
+ }];
84
+ readonly outputs: readonly [{
85
+ readonly name: "";
86
+ readonly type: "bool";
87
+ }];
88
+ }, {
89
+ readonly name: "transfer";
90
+ readonly type: "function";
91
+ readonly stateMutability: "nonpayable";
92
+ readonly inputs: readonly [{
93
+ readonly name: "to";
94
+ readonly type: "address";
95
+ }, {
96
+ readonly name: "amount";
97
+ readonly type: "uint256";
98
+ }];
99
+ readonly outputs: readonly [{
100
+ readonly name: "";
101
+ readonly type: "bool";
102
+ }];
103
+ }];
104
+ export declare const uniswapV3SwapRouterAbi: readonly [{
105
+ readonly name: "exactInputSingle";
106
+ readonly type: "function";
107
+ readonly stateMutability: "payable";
108
+ readonly inputs: readonly [{
109
+ readonly name: "params";
110
+ readonly type: "tuple";
111
+ readonly components: readonly [{
112
+ readonly name: "tokenIn";
113
+ readonly type: "address";
114
+ }, {
115
+ readonly name: "tokenOut";
116
+ readonly type: "address";
117
+ }, {
118
+ readonly name: "fee";
119
+ readonly type: "uint24";
120
+ }, {
121
+ readonly name: "recipient";
122
+ readonly type: "address";
123
+ }, {
124
+ readonly name: "amountIn";
125
+ readonly type: "uint256";
126
+ }, {
127
+ readonly name: "amountOutMinimum";
128
+ readonly type: "uint256";
129
+ }, {
130
+ readonly name: "sqrtPriceLimitX96";
131
+ readonly type: "uint160";
132
+ }];
133
+ }];
134
+ readonly outputs: readonly [{
135
+ readonly name: "amountOut";
136
+ readonly type: "uint256";
137
+ }];
138
+ }];
139
+ export declare const aaveV3SupplyAbi: {
140
+ readonly name: "supply";
141
+ readonly type: "function";
142
+ readonly stateMutability: "nonpayable";
143
+ readonly inputs: readonly [{
144
+ readonly name: "asset";
145
+ readonly type: "address";
146
+ }, {
147
+ readonly name: "amount";
148
+ readonly type: "uint256";
149
+ }, {
150
+ readonly name: "onBehalfOf";
151
+ readonly type: "address";
152
+ }, {
153
+ readonly name: "referralCode";
154
+ readonly type: "uint16";
155
+ }];
156
+ readonly outputs: readonly [];
157
+ };
158
+ export declare const aaveV3BorrowAbi: {
159
+ readonly name: "borrow";
160
+ readonly type: "function";
161
+ readonly stateMutability: "nonpayable";
162
+ readonly inputs: readonly [{
163
+ readonly name: "asset";
164
+ readonly type: "address";
165
+ }, {
166
+ readonly name: "amount";
167
+ readonly type: "uint256";
168
+ }, {
169
+ readonly name: "interestRateMode";
170
+ readonly type: "uint256";
171
+ }, {
172
+ readonly name: "referralCode";
173
+ readonly type: "uint16";
174
+ }, {
175
+ readonly name: "onBehalfOf";
176
+ readonly type: "address";
177
+ }];
178
+ readonly outputs: readonly [];
179
+ };
180
+ export declare const aaveV3RepayAbi: {
181
+ readonly name: "repay";
182
+ readonly type: "function";
183
+ readonly stateMutability: "nonpayable";
184
+ readonly inputs: readonly [{
185
+ readonly name: "asset";
186
+ readonly type: "address";
187
+ }, {
188
+ readonly name: "amount";
189
+ readonly type: "uint256";
190
+ }, {
191
+ readonly name: "interestRateMode";
192
+ readonly type: "uint256";
193
+ }, {
194
+ readonly name: "onBehalfOf";
195
+ readonly type: "address";
196
+ }];
197
+ readonly outputs: readonly [{
198
+ readonly name: "";
199
+ readonly type: "uint256";
200
+ }];
201
+ };
202
+ export declare const aaveV3WithdrawAbi: {
203
+ readonly name: "withdraw";
204
+ readonly type: "function";
205
+ readonly stateMutability: "nonpayable";
206
+ readonly inputs: readonly [{
207
+ readonly name: "asset";
208
+ readonly type: "address";
209
+ }, {
210
+ readonly name: "amount";
211
+ readonly type: "uint256";
212
+ }, {
213
+ readonly name: "to";
214
+ readonly type: "address";
215
+ }];
216
+ readonly outputs: readonly [{
217
+ readonly name: "";
218
+ readonly type: "uint256";
219
+ }];
220
+ };
221
+ export declare const aaveV3PoolAbi: readonly [{
222
+ readonly name: "supply";
223
+ readonly type: "function";
224
+ readonly stateMutability: "nonpayable";
225
+ readonly inputs: readonly [{
226
+ readonly name: "asset";
227
+ readonly type: "address";
228
+ }, {
229
+ readonly name: "amount";
230
+ readonly type: "uint256";
231
+ }, {
232
+ readonly name: "onBehalfOf";
233
+ readonly type: "address";
234
+ }, {
235
+ readonly name: "referralCode";
236
+ readonly type: "uint16";
237
+ }];
238
+ readonly outputs: readonly [];
239
+ }, {
240
+ readonly name: "borrow";
241
+ readonly type: "function";
242
+ readonly stateMutability: "nonpayable";
243
+ readonly inputs: readonly [{
244
+ readonly name: "asset";
245
+ readonly type: "address";
246
+ }, {
247
+ readonly name: "amount";
248
+ readonly type: "uint256";
249
+ }, {
250
+ readonly name: "interestRateMode";
251
+ readonly type: "uint256";
252
+ }, {
253
+ readonly name: "referralCode";
254
+ readonly type: "uint16";
255
+ }, {
256
+ readonly name: "onBehalfOf";
257
+ readonly type: "address";
258
+ }];
259
+ readonly outputs: readonly [];
260
+ }, {
261
+ readonly name: "repay";
262
+ readonly type: "function";
263
+ readonly stateMutability: "nonpayable";
264
+ readonly inputs: readonly [{
265
+ readonly name: "asset";
266
+ readonly type: "address";
267
+ }, {
268
+ readonly name: "amount";
269
+ readonly type: "uint256";
270
+ }, {
271
+ readonly name: "interestRateMode";
272
+ readonly type: "uint256";
273
+ }, {
274
+ readonly name: "onBehalfOf";
275
+ readonly type: "address";
276
+ }];
277
+ readonly outputs: readonly [{
278
+ readonly name: "";
279
+ readonly type: "uint256";
280
+ }];
281
+ }, {
282
+ readonly name: "withdraw";
283
+ readonly type: "function";
284
+ readonly stateMutability: "nonpayable";
285
+ readonly inputs: readonly [{
286
+ readonly name: "asset";
287
+ readonly type: "address";
288
+ }, {
289
+ readonly name: "amount";
290
+ readonly type: "uint256";
291
+ }, {
292
+ readonly name: "to";
293
+ readonly type: "address";
294
+ }];
295
+ readonly outputs: readonly [{
296
+ readonly name: "";
297
+ readonly type: "uint256";
298
+ }];
299
+ }];
300
+ export interface ProtocolAction {
301
+ readonly protocol: string;
302
+ readonly action: string;
303
+ readonly selector: Hex;
304
+ readonly abi: readonly [typeof erc20ApproveAbi | typeof erc20TransferAbi | typeof uniswapV3ExactInputSingleAbi | typeof aaveV3SupplyAbi | typeof aaveV3BorrowAbi | typeof aaveV3RepayAbi | typeof aaveV3WithdrawAbi];
305
+ readonly paramNames: readonly string[];
306
+ readonly paramTypes: readonly string[];
307
+ }
308
+ export declare const ACTION_CATALOG: Readonly<Record<string, ProtocolAction>>;
309
+ /** List all available action keys for help/error messages */
310
+ export declare function listActions(): string[];
@@ -0,0 +1,162 @@
1
+ /**
2
+ * Protocol Action Catalog — shared ABI metadata for encode/decode.
3
+ * Single source of truth: ABIs live here, decoders import from here.
4
+ */
5
+ // -- ABI fragments (same as used by decoders, exported for encoder) --
6
+ export const erc20ApproveAbi = {
7
+ name: 'approve',
8
+ type: 'function',
9
+ stateMutability: 'nonpayable',
10
+ inputs: [
11
+ { name: 'spender', type: 'address' },
12
+ { name: 'amount', type: 'uint256' },
13
+ ],
14
+ outputs: [{ name: '', type: 'bool' }],
15
+ };
16
+ export const erc20TransferAbi = {
17
+ name: 'transfer',
18
+ type: 'function',
19
+ stateMutability: 'nonpayable',
20
+ inputs: [
21
+ { name: 'to', type: 'address' },
22
+ { name: 'amount', type: 'uint256' },
23
+ ],
24
+ outputs: [{ name: '', type: 'bool' }],
25
+ };
26
+ export const uniswapV3ExactInputSingleAbi = {
27
+ name: 'exactInputSingle',
28
+ type: 'function',
29
+ stateMutability: 'payable',
30
+ inputs: [
31
+ {
32
+ name: 'params',
33
+ type: 'tuple',
34
+ components: [
35
+ { name: 'tokenIn', type: 'address' },
36
+ { name: 'tokenOut', type: 'address' },
37
+ { name: 'fee', type: 'uint24' },
38
+ { name: 'recipient', type: 'address' },
39
+ { name: 'amountIn', type: 'uint256' },
40
+ { name: 'amountOutMinimum', type: 'uint256' },
41
+ { name: 'sqrtPriceLimitX96', type: 'uint160' },
42
+ ],
43
+ },
44
+ ],
45
+ outputs: [{ name: 'amountOut', type: 'uint256' }],
46
+ };
47
+ // -- Combined ABI arrays for decoders --
48
+ export const erc20Abi = [erc20ApproveAbi, erc20TransferAbi];
49
+ export const uniswapV3SwapRouterAbi = [uniswapV3ExactInputSingleAbi];
50
+ // -- Aave V3 Pool --
51
+ export const aaveV3SupplyAbi = {
52
+ name: 'supply',
53
+ type: 'function',
54
+ stateMutability: 'nonpayable',
55
+ inputs: [
56
+ { name: 'asset', type: 'address' },
57
+ { name: 'amount', type: 'uint256' },
58
+ { name: 'onBehalfOf', type: 'address' },
59
+ { name: 'referralCode', type: 'uint16' },
60
+ ],
61
+ outputs: [],
62
+ };
63
+ export const aaveV3BorrowAbi = {
64
+ name: 'borrow',
65
+ type: 'function',
66
+ stateMutability: 'nonpayable',
67
+ inputs: [
68
+ { name: 'asset', type: 'address' },
69
+ { name: 'amount', type: 'uint256' },
70
+ { name: 'interestRateMode', type: 'uint256' },
71
+ { name: 'referralCode', type: 'uint16' },
72
+ { name: 'onBehalfOf', type: 'address' },
73
+ ],
74
+ outputs: [],
75
+ };
76
+ export const aaveV3RepayAbi = {
77
+ name: 'repay',
78
+ type: 'function',
79
+ stateMutability: 'nonpayable',
80
+ inputs: [
81
+ { name: 'asset', type: 'address' },
82
+ { name: 'amount', type: 'uint256' },
83
+ { name: 'interestRateMode', type: 'uint256' },
84
+ { name: 'onBehalfOf', type: 'address' },
85
+ ],
86
+ outputs: [{ name: '', type: 'uint256' }],
87
+ };
88
+ export const aaveV3WithdrawAbi = {
89
+ name: 'withdraw',
90
+ type: 'function',
91
+ stateMutability: 'nonpayable',
92
+ inputs: [
93
+ { name: 'asset', type: 'address' },
94
+ { name: 'amount', type: 'uint256' },
95
+ { name: 'to', type: 'address' },
96
+ ],
97
+ outputs: [{ name: '', type: 'uint256' }],
98
+ };
99
+ export const aaveV3PoolAbi = [aaveV3SupplyAbi, aaveV3BorrowAbi, aaveV3RepayAbi, aaveV3WithdrawAbi];
100
+ export const ACTION_CATALOG = {
101
+ 'erc20:approve': {
102
+ protocol: 'erc20',
103
+ action: 'approve',
104
+ selector: '0x095ea7b3',
105
+ abi: [erc20ApproveAbi],
106
+ paramNames: ['spender', 'amount'],
107
+ paramTypes: ['address', 'uint256'],
108
+ },
109
+ 'erc20:transfer': {
110
+ protocol: 'erc20',
111
+ action: 'transfer',
112
+ selector: '0xa9059cbb',
113
+ abi: [erc20TransferAbi],
114
+ paramNames: ['to', 'amount'],
115
+ paramTypes: ['address', 'uint256'],
116
+ },
117
+ 'uniswap_v3:exactInputSingle': {
118
+ protocol: 'uniswap_v3',
119
+ action: 'exactInputSingle',
120
+ selector: '0x04e45aaf',
121
+ abi: [uniswapV3ExactInputSingleAbi],
122
+ paramNames: ['tokenIn', 'tokenOut', 'fee', 'recipient', 'amountIn', 'amountOutMinimum', 'sqrtPriceLimitX96'],
123
+ paramTypes: ['address', 'address', 'uint24', 'address', 'uint256', 'uint256', 'uint160'],
124
+ },
125
+ 'aave_v3:supply': {
126
+ protocol: 'aave_v3',
127
+ action: 'supply',
128
+ selector: '0x617ba037',
129
+ abi: [aaveV3SupplyAbi],
130
+ paramNames: ['asset', 'amount', 'onBehalfOf', 'referralCode'],
131
+ paramTypes: ['address', 'uint256', 'address', 'uint16'],
132
+ },
133
+ 'aave_v3:borrow': {
134
+ protocol: 'aave_v3',
135
+ action: 'borrow',
136
+ selector: '0xa415bcad',
137
+ abi: [aaveV3BorrowAbi],
138
+ paramNames: ['asset', 'amount', 'interestRateMode', 'referralCode', 'onBehalfOf'],
139
+ paramTypes: ['address', 'uint256', 'uint256', 'uint16', 'address'],
140
+ },
141
+ 'aave_v3:repay': {
142
+ protocol: 'aave_v3',
143
+ action: 'repay',
144
+ selector: '0x573ade81',
145
+ abi: [aaveV3RepayAbi],
146
+ paramNames: ['asset', 'amount', 'interestRateMode', 'onBehalfOf'],
147
+ paramTypes: ['address', 'uint256', 'uint256', 'address'],
148
+ },
149
+ 'aave_v3:withdraw': {
150
+ protocol: 'aave_v3',
151
+ action: 'withdraw',
152
+ selector: '0x69328dec',
153
+ abi: [aaveV3WithdrawAbi],
154
+ paramNames: ['asset', 'amount', 'to'],
155
+ paramTypes: ['address', 'uint256', 'address'],
156
+ },
157
+ };
158
+ /** List all available action keys for help/error messages */
159
+ export function listActions() {
160
+ return Object.keys(ACTION_CATALOG);
161
+ }
162
+ //# sourceMappingURL=catalog.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"catalog.js","sourceRoot":"","sources":["../../src/protocols/catalog.ts"],"names":[],"mappings":"AAEA;;;GAGG;AAEH,uEAAuE;AAEvE,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,IAAI,EAAE,SAAS;IACf,IAAI,EAAE,UAAU;IAChB,eAAe,EAAE,YAAY;IAC7B,MAAM,EAAE;QACN,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,EAAE;QACpC,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE;KACpC;IACD,OAAO,EAAE,CAAC,EAAE,IAAI,E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S,EAAE,SAAS,CAAC;KACzD;IACD,kBAAkB,EAAE;QAClB,QAAQ,EAAE,SAAS;QACnB,MAAM,EAAE,UAAU;QAClB,QAAQ,EAAE,YAAY;QACtB,GAAG,EAAE,CAAC,iBAAiB,CAAC;QACxB,UAAU,EAAE,CAAC,OAAO,EAAE,QAAQ,EAAE,IAAI,CAAC;QACrC,UAAU,EAAE,CAAC,SAAS,EAAE,SAAS,EAAE,SAAS,CAAC;KAC9C;CACF,CAAC;AAEF,6DAA6D;AAC7D,MAAM,UAAU,WAAW;IACzB,OAAO,MAAM,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;AACrC,CAAC"}
@@ -0,0 +1,2 @@
1
+ import type { ProtocolDecoder } from '../types.js';
2
+ export declare const aaveV3Decoder: ProtocolDecoder;
@@ -0,0 +1,105 @@
1
+ import { decodeFunctionData } from 'viem';
2
+ import { aaveV3PoolAbi } from '../catalog.js';
3
+ // supply(address,uint256,address,uint16)
4
+ const SUPPLY_SELECTOR = '0x617ba037';
5
+ // borrow(address,uint256,uint256,uint16,address)
6
+ const BORROW_SELECTOR = '0xa415bcad';
7
+ // repay(address,uint256,uint256,address)
8
+ const REPAY_SELECTOR = '0x573ade81';
9
+ // withdraw(address,uint256,address)
10
+ const WITHDRAW_SELECTOR = '0x69328dec';
11
+ export const aaveV3Decoder = {
12
+ protocol: 'aave_v3',
13
+ supportedSelectors: [
14
+ SUPPLY_SELECTOR,
15
+ BORROW_SELECTOR,
16
+ REPAY_SELECTOR,
17
+ WITHDRAW_SELECTOR,
18
+ ],
19
+ decode(chainId, to, data) {
20
+ try {
21
+ const { functionName, args } = decodeFunctionData({
22
+ abi: aaveV3PoolAbi,
23
+ data,
24
+ });
25
+ const selector = data.slice(0, 10).toLowerCase();
26
+ switch (functionName) {
27
+ case 'supply':
28
+ return {
29
+ protocol: 'aave_v3',
30
+ action: 'supply',
31
+ chainId,
32
+ to,
33
+ selector,
34
+ args: {
35
+ asset: args[0],
36
+ amount: args[1],
37
+ onBehalfOf: args[2],
38
+ referralCode: Number(args[3]),
39
+ },
40
+ };
41
+ case 'borrow':
42
+ return {
43
+ protocol: 'aave_v3',
44
+ action: 'borrow',
45
+ chainId,
46
+ to,
47
+ selector,
48
+ args: {
49
+ asset: args[0],
50
+ amount: args[1],
51
+ interestRateMode: args[2],
52
+ referralCode: Number(args[3]),
53
+ onBehalfOf: args[4],
54
+ },
55
+ };
56
+ case 'repay':
57
+ return {
58
+ protocol: 'aave_v3',
59
+ action: 'repay',
60
+ chainId,
61
+ to,
62
+ selector,
63
+ args: {
64
+ asset: args[0],
65
+ amount: args[1],
66
+ interestRateMode: args[2],
67
+ onBehalfOf: args[3],
68
+ },
69
+ };
70
+ case 'withdraw':
71
+ return {
72
+ protocol: 'aave_v3',
73
+ action: 'withdraw',
74
+ chainId,
75
+ to,
76
+ selector,
77
+ args: {
78
+ asset: args[0],
79
+ amount: args[1],
80
+ to: args[2],
81
+ },
82
+ };
83
+ default:
84
+ return {
85
+ protocol: 'unknown',
86
+ chainId,
87
+ to,
88
+ selector,
89
+ rawData: data,
90
+ reason: `Unsupported Aave V3 function: ${functionName}`,
91
+ };
92
+ }
93
+ }
94
+ catch {
95
+ return {
96
+ protocol: 'unknown',
97
+ chainId,
98
+ to,
99
+ rawData: data,
100
+ reason: 'Failed to decode Aave V3 calldata',
101
+ };
102
+ }
103
+ },
104
+ };
105
+ //# sourceMappingURL=aave-v3.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"aave-v3.js","sourceRoot":"","sources":["../../../src/protocols/decoders/aave-v3.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAA0B,MAAM,MAAM,CAAC;AAElE,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAE9C,yCAAyC;AACzC,MAAM,eAAe,GAAG,YAAY,CAAC;AACrC,iDAAiD;AACjD,MAAM,eAAe,GAAG,YAAY,CAAC;AACrC,yCAAyC;AACzC,MAAM,cAAc,GAAG,YAAY,C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CAAC,CAAY;yBAC/B;qBACF,CAAC;gBACJ,KAAK,OAAO;oBACV,OAAO;wBACL,QAAQ,EAAE,SAAS;wBACnB,MAAM,EAAE,OAAO;wBACf,OAAO;wBACP,EAAE;wBACF,QAAQ;wBACR,IAAI,EAAE;4BACJ,KAAK,EAAE,IAAI,CAAC,CAAC,CAAY;4BACzB,MAAM,EAAE,IAAI,CAAC,CAAC,CAAC;4BACf,gBAAgB,EAAE,IAAI,CAAC,CAAC,CAAC;4BACzB,UAAU,EAAE,IAAI,CAAC,CAAC,CAAY;yBAC/B;qBACF,CAAC;gBACJ,KAAK,UAAU;oBACb,OAAO;wBACL,QAAQ,EAAE,SAAS;wBACnB,MAAM,EAAE,UAAU;wBAClB,OAAO;wBACP,EAAE;wBACF,QAAQ;wBACR,IAAI,EAAE;4BACJ,KAAK,EAAE,IAAI,CAAC,CAAC,CAAY;4BACzB,MAAM,EAAE,IAAI,CAAC,CAAC,CAAC;4BACf,EAAE,EAAE,IAAI,CAAC,CAAC,CAAY;yBACvB;qBACF,CAAC;gBACJ;oBACE,OAAO;wBACL,QAAQ,EAAE,SAAS;wBACnB,OAAO;wBACP,EAAE;wBACF,QAAQ;wBACR,OAAO,EAAE,IAAI;wBACb,MAAM,EAAE,iCAAiC,YAAY,EAAE;qBACxD,CAAC;YACN,CAAC;QACH,CAAC;QAAC,MAAM,CAAC;YACP,OAAO;gBACL,QAAQ,EAAE,SAAS;gBACnB,OAAO;gBACP,EAAE;gBACF,OAAO,EAAE,IAAI;gBACb,MAAM,EAAE,mCAAmC;aAC5C,CAAC;QACJ,CAAC;IACH,CAAC;CACF,CAAC"}
@@ -0,0 +1,2 @@
1
+ import type { ProtocolDecoder } from '../types.js';
2
+ export declare const erc20Decoder: ProtocolDecoder;
@@ -0,0 +1,51 @@
1
+ import { decodeFunctionData } from 'viem';
2
+ import { erc20Abi } from '../catalog.js';
3
+ export const erc20Decoder = {
4
+ protocol: 'erc20',
5
+ supportedSelectors: ['0x095ea7b3', '0xa9059cbb'], // approve, transfer
6
+ decode(chainId, to, data) {
7
+ try {
8
+ const { functionName, args } = decodeFunctionData({ abi: erc20Abi, data });
9
+ const selector = data.slice(0, 10).toLowerCase();
10
+ switch (functionName) {
11
+ case 'approve':
12
+ return {
13
+ protocol: 'erc20',
14
+ action: 'approve',
15
+ chainId,
16
+ to,
17
+ selector,
18
+ args: { spender: args[0], amount: args[1] },
19
+ };
20
+ case 'transfer':
21
+ return {
22
+ protocol: 'erc20',
23
+ action: 'transfer',
24
+ chainId,
25
+ to,
26
+ selector,
27
+ args: { to: args[0], amount: args[1] },
28
+ };
29
+ default:
30
+ return {
31
+ protocol: 'unknown',
32
+ chainId,
33
+ to,
34
+ selector,
35
+ rawData: data,
36
+ reason: `Unsupported ERC-20 function: ${functionName}`,
37
+ };
38
+ }
39
+ }
40
+ catch {
41
+ return {
42
+ protocol: 'unknown',
43
+ chainId,
44
+ to,
45
+ rawData: data,
46
+ reason: 'Failed to decode ERC-20 calldata',
47
+ };
48
+ }
49
+ },
50
+ };
51
+ //# sourceMappingURL=erc20.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"erc20.js","sourceRoot":"","sources":["../../../src/protocols/decoders/erc20.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAA0B,MAAM,MAAM,CAAC;AAElE,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEzC,MAAM,CAAC,MAAM,YAAY,GAAoB;IAC3C,QAAQ,EAAE,OAAO;IACjB,kBAAkB,EAAE,CAAC,YAAY,EAAE,YAAY,CAAC,EAAE,oBAAoB;IAEtE,MAAM,CAAC,OAAe,EAAE,EAAW,EAAE,IAAS;QAC5C,IAAI,CAAC;YACH,MAAM,EAAE,YAAY,EAAE,IAAI,EAAE,GAAG,kBAAkB,CAAC,EAAE,GAAG,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;YAC3E,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,C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