agentwallet-sdk 5.0.2 → 5.0.4

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 (258) hide show
  1. package/README.md +15 -0
  2. package/dist/index.d.ts +213 -284
  3. package/dist/index.d.ts.map +1 -1
  4. package/dist/index.js +1 -1
  5. package/dist/index.js.map +1 -1
  6. package/package.json +3 -3
  7. package/dist/ap2/index.d.ts +0 -185
  8. package/dist/ap2/index.d.ts.map +0 -1
  9. package/dist/ap2/index.js +0 -255
  10. package/dist/ap2/index.js.map +0 -1
  11. package/dist/bridge/unified.d.ts +0 -101
  12. package/dist/bridge/unified.d.ts.map +0 -1
  13. package/dist/bridge/unified.js +0 -284
  14. package/dist/bridge/unified.js.map +0 -1
  15. package/dist/chains.d.ts +0 -62
  16. package/dist/chains.d.ts.map +0 -1
  17. package/dist/chains.js +0 -108
  18. package/dist/chains.js.map +0 -1
  19. package/dist/fiat/index.d.ts +0 -10
  20. package/dist/fiat/index.d.ts.map +0 -1
  21. package/dist/fiat/index.js +0 -9
  22. package/dist/fiat/index.js.map +0 -1
  23. package/dist/fiat/onramp.d.ts +0 -101
  24. package/dist/fiat/onramp.d.ts.map +0 -1
  25. package/dist/fiat/onramp.js +0 -155
  26. package/dist/fiat/onramp.js.map +0 -1
  27. package/dist/fiat/providers/index.d.ts +0 -16
  28. package/dist/fiat/providers/index.d.ts.map +0 -1
  29. package/dist/fiat/providers/index.js +0 -30
  30. package/dist/fiat/providers/index.js.map +0 -1
  31. package/dist/fiat/providers/moonpay.d.ts +0 -22
  32. package/dist/fiat/providers/moonpay.d.ts.map +0 -1
  33. package/dist/fiat/providers/moonpay.js +0 -107
  34. package/dist/fiat/providers/moonpay.js.map +0 -1
  35. package/dist/fiat/providers/stripe.d.ts +0 -26
  36. package/dist/fiat/providers/stripe.d.ts.map +0 -1
  37. package/dist/fiat/providers/stripe.js +0 -135
  38. package/dist/fiat/providers/stripe.js.map +0 -1
  39. package/dist/fiat/providers/transak.d.ts +0 -26
  40. package/dist/fiat/providers/transak.d.ts.map +0 -1
  41. package/dist/fiat/providers/transak.js +0 -119
  42. package/dist/fiat/providers/transak.js.map +0 -1
  43. package/dist/fiat/types.d.ts +0 -106
  44. package/dist/fiat/types.d.ts.map +0 -1
  45. package/dist/fiat/types.js +0 -13
  46. package/dist/fiat/types.js.map +0 -1
  47. package/dist/flash/executor.d.ts +0 -119
  48. package/dist/flash/executor.d.ts.map +0 -1
  49. package/dist/flash/executor.js +0 -195
  50. package/dist/flash/executor.js.map +0 -1
  51. package/dist/flash/index.d.ts +0 -28
  52. package/dist/flash/index.d.ts.map +0 -1
  53. package/dist/flash/index.js +0 -29
  54. package/dist/flash/index.js.map +0 -1
  55. package/dist/flash/scanner.d.ts +0 -133
  56. package/dist/flash/scanner.d.ts.map +0 -1
  57. package/dist/flash/scanner.js +0 -212
  58. package/dist/flash/scanner.js.map +0 -1
  59. package/dist/flash/types.d.ts +0 -136
  60. package/dist/flash/types.d.ts.map +0 -1
  61. package/dist/flash/types.js +0 -23
  62. package/dist/flash/types.js.map +0 -1
  63. package/dist/gas/index.d.ts +0 -4
  64. package/dist/gas/index.d.ts.map +0 -1
  65. package/dist/gas/index.js +0 -3
  66. package/dist/gas/index.js.map +0 -1
  67. package/dist/gas/sponsor.d.ts +0 -70
  68. package/dist/gas/sponsor.d.ts.map +0 -1
  69. package/dist/gas/sponsor.js +0 -193
  70. package/dist/gas/sponsor.js.map +0 -1
  71. package/dist/gas/types.d.ts +0 -76
  72. package/dist/gas/types.d.ts.map +0 -1
  73. package/dist/gas/types.js +0 -21
  74. package/dist/gas/types.js.map +0 -1
  75. package/dist/identity/agent-identity.d.ts +0 -276
  76. package/dist/identity/agent-identity.d.ts.map +0 -1
  77. package/dist/identity/agent-identity.js +0 -300
  78. package/dist/identity/agent-identity.js.map +0 -1
  79. package/dist/identity/erc6551.d.ts +0 -441
  80. package/dist/identity/erc6551.d.ts.map +0 -1
  81. package/dist/identity/erc6551.js +0 -517
  82. package/dist/identity/erc6551.js.map +0 -1
  83. package/dist/mev/index.d.ts +0 -4
  84. package/dist/mev/index.d.ts.map +0 -1
  85. package/dist/mev/index.js +0 -8
  86. package/dist/mev/index.js.map +0 -1
  87. package/dist/mev/protection.d.ts +0 -54
  88. package/dist/mev/protection.d.ts.map +0 -1
  89. package/dist/mev/protection.js +0 -185
  90. package/dist/mev/protection.js.map +0 -1
  91. package/dist/mev/risk.d.ts +0 -19
  92. package/dist/mev/risk.d.ts.map +0 -1
  93. package/dist/mev/risk.js +0 -95
  94. package/dist/mev/risk.js.map +0 -1
  95. package/dist/mev/types.d.ts +0 -49
  96. package/dist/mev/types.d.ts.map +0 -1
  97. package/dist/mev/types.js +0 -2
  98. package/dist/mev/types.js.map +0 -1
  99. package/dist/settlement/index.d.ts +0 -4
  100. package/dist/settlement/index.d.ts.map +0 -1
  101. package/dist/settlement/index.js +0 -3
  102. package/dist/settlement/index.js.map +0 -1
  103. package/dist/settlement/types.d.ts +0 -66
  104. package/dist/settlement/types.d.ts.map +0 -1
  105. package/dist/settlement/types.js +0 -37
  106. package/dist/settlement/types.js.map +0 -1
  107. package/dist/settlement/verifier.d.ts +0 -75
  108. package/dist/settlement/verifier.d.ts.map +0 -1
  109. package/dist/settlement/verifier.js +0 -354
  110. package/dist/settlement/verifier.js.map +0 -1
  111. package/dist/solana/bridge.d.ts +0 -144
  112. package/dist/solana/bridge.d.ts.map +0 -1
  113. package/dist/solana/bridge.js +0 -352
  114. package/dist/solana/bridge.js.map +0 -1
  115. package/dist/solana/index.d.ts +0 -8
  116. package/dist/solana/index.d.ts.map +0 -1
  117. package/dist/solana/index.js +0 -6
  118. package/dist/solana/index.js.map +0 -1
  119. package/dist/solana/swap.d.ts +0 -85
  120. package/dist/solana/swap.d.ts.map +0 -1
  121. package/dist/solana/swap.js +0 -173
  122. package/dist/solana/swap.js.map +0 -1
  123. package/dist/solana/types.d.ts +0 -126
  124. package/dist/solana/types.d.ts.map +0 -1
  125. package/dist/solana/types.js +0 -10
  126. package/dist/solana/types.js.map +0 -1
  127. package/dist/solana/wallet.d.ts +0 -83
  128. package/dist/solana/wallet.d.ts.map +0 -1
  129. package/dist/solana/wallet.js +0 -164
  130. package/dist/solana/wallet.js.map +0 -1
  131. package/dist/solana/x402.d.ts +0 -69
  132. package/dist/solana/x402.d.ts.map +0 -1
  133. package/dist/solana/x402.js +0 -154
  134. package/dist/solana/x402.js.map +0 -1
  135. package/dist/solver/adapter.d.ts +0 -47
  136. package/dist/solver/adapter.d.ts.map +0 -1
  137. package/dist/solver/adapter.js +0 -146
  138. package/dist/solver/adapter.js.map +0 -1
  139. package/dist/solver/analyzer.d.ts +0 -48
  140. package/dist/solver/analyzer.d.ts.map +0 -1
  141. package/dist/solver/analyzer.js +0 -171
  142. package/dist/solver/analyzer.js.map +0 -1
  143. package/dist/solver/builder.d.ts +0 -31
  144. package/dist/solver/builder.d.ts.map +0 -1
  145. package/dist/solver/builder.js +0 -60
  146. package/dist/solver/builder.js.map +0 -1
  147. package/dist/solver/index.d.ts +0 -22
  148. package/dist/solver/index.d.ts.map +0 -1
  149. package/dist/solver/index.js +0 -25
  150. package/dist/solver/index.js.map +0 -1
  151. package/dist/solver/types.d.ts +0 -115
  152. package/dist/solver/types.d.ts.map +0 -1
  153. package/dist/solver/types.js +0 -10
  154. package/dist/solver/types.js.map +0 -1
  155. package/dist/spend-guard/index.d.ts +0 -125
  156. package/dist/spend-guard/index.d.ts.map +0 -1
  157. package/dist/spend-guard/index.js +0 -150
  158. package/dist/spend-guard/index.js.map +0 -1
  159. package/dist/swap/router/cache.d.ts +0 -13
  160. package/dist/swap/router/cache.d.ts.map +0 -1
  161. package/dist/swap/router/cache.js +0 -30
  162. package/dist/swap/router/cache.js.map +0 -1
  163. package/dist/swap/router/flashbots.d.ts +0 -10
  164. package/dist/swap/router/flashbots.d.ts.map +0 -1
  165. package/dist/swap/router/flashbots.js +0 -43
  166. package/dist/swap/router/flashbots.js.map +0 -1
  167. package/dist/swap/router/health.d.ts +0 -17
  168. package/dist/swap/router/health.d.ts.map +0 -1
  169. package/dist/swap/router/health.js +0 -38
  170. package/dist/swap/router/health.js.map +0 -1
  171. package/dist/swap/router/index.d.ts +0 -10
  172. package/dist/swap/router/index.d.ts.map +0 -1
  173. package/dist/swap/router/index.js +0 -10
  174. package/dist/swap/router/index.js.map +0 -1
  175. package/dist/swap/router/providers/cowswap.d.ts +0 -11
  176. package/dist/swap/router/providers/cowswap.d.ts.map +0 -1
  177. package/dist/swap/router/providers/cowswap.js +0 -79
  178. package/dist/swap/router/providers/cowswap.js.map +0 -1
  179. package/dist/swap/router/providers/index.d.ts +0 -20
  180. package/dist/swap/router/providers/index.d.ts.map +0 -1
  181. package/dist/swap/router/providers/index.js +0 -32
  182. package/dist/swap/router/providers/index.js.map +0 -1
  183. package/dist/swap/router/providers/jupiter.d.ts +0 -12
  184. package/dist/swap/router/providers/jupiter.d.ts.map +0 -1
  185. package/dist/swap/router/providers/jupiter.js +0 -73
  186. package/dist/swap/router/providers/jupiter.js.map +0 -1
  187. package/dist/swap/router/providers/lifi.d.ts +0 -11
  188. package/dist/swap/router/providers/lifi.d.ts.map +0 -1
  189. package/dist/swap/router/providers/lifi.js +0 -123
  190. package/dist/swap/router/providers/lifi.js.map +0 -1
  191. package/dist/swap/router/providers/oneinch.d.ts +0 -13
  192. package/dist/swap/router/providers/oneinch.d.ts.map +0 -1
  193. package/dist/swap/router/providers/oneinch.js +0 -71
  194. package/dist/swap/router/providers/oneinch.js.map +0 -1
  195. package/dist/swap/router/providers/paraswap.d.ts +0 -11
  196. package/dist/swap/router/providers/paraswap.d.ts.map +0 -1
  197. package/dist/swap/router/providers/paraswap.js +0 -73
  198. package/dist/swap/router/providers/paraswap.js.map +0 -1
  199. package/dist/swap/router/providers/uniswap.d.ts +0 -31
  200. package/dist/swap/router/providers/uniswap.d.ts.map +0 -1
  201. package/dist/swap/router/providers/uniswap.js +0 -237
  202. package/dist/swap/router/providers/uniswap.js.map +0 -1
  203. package/dist/swap/router/providers/zerox.d.ts +0 -13
  204. package/dist/swap/router/providers/zerox.d.ts.map +0 -1
  205. package/dist/swap/router/providers/zerox.js +0 -94
  206. package/dist/swap/router/providers/zerox.js.map +0 -1
  207. package/dist/swap/router/router.d.ts +0 -86
  208. package/dist/swap/router/router.d.ts.map +0 -1
  209. package/dist/swap/router/router.js +0 -224
  210. package/dist/swap/router/router.js.map +0 -1
  211. package/dist/swap/router/rsi/engine.d.ts +0 -60
  212. package/dist/swap/router/rsi/engine.d.ts.map +0 -1
  213. package/dist/swap/router/rsi/engine.js +0 -483
  214. package/dist/swap/router/rsi/engine.js.map +0 -1
  215. package/dist/swap/router/rsi/index.d.ts +0 -3
  216. package/dist/swap/router/rsi/index.d.ts.map +0 -1
  217. package/dist/swap/router/rsi/index.js +0 -3
  218. package/dist/swap/router/rsi/index.js.map +0 -1
  219. package/dist/swap/router/rsi/types.d.ts +0 -106
  220. package/dist/swap/router/rsi/types.d.ts.map +0 -1
  221. package/dist/swap/router/rsi/types.js +0 -3
  222. package/dist/swap/router/rsi/types.js.map +0 -1
  223. package/dist/swap/router/types.d.ts +0 -120
  224. package/dist/swap/router/types.d.ts.map +0 -1
  225. package/dist/swap/router/types.js +0 -16
  226. package/dist/swap/router/types.js.map +0 -1
  227. package/dist/tax/engine.d.ts +0 -131
  228. package/dist/tax/engine.d.ts.map +0 -1
  229. package/dist/tax/engine.js +0 -307
  230. package/dist/tax/engine.js.map +0 -1
  231. package/dist/tax/index.d.ts +0 -9
  232. package/dist/tax/index.d.ts.map +0 -1
  233. package/dist/tax/index.js +0 -12
  234. package/dist/tax/index.js.map +0 -1
  235. package/dist/tax/lots.d.ts +0 -60
  236. package/dist/tax/lots.d.ts.map +0 -1
  237. package/dist/tax/lots.js +0 -129
  238. package/dist/tax/lots.js.map +0 -1
  239. package/dist/tax/types.d.ts +0 -113
  240. package/dist/tax/types.d.ts.map +0 -1
  241. package/dist/tax/types.js +0 -18
  242. package/dist/tax/types.js.map +0 -1
  243. package/dist/yield/index.d.ts +0 -26
  244. package/dist/yield/index.d.ts.map +0 -1
  245. package/dist/yield/index.js +0 -29
  246. package/dist/yield/index.js.map +0 -1
  247. package/dist/yield/rates.d.ts +0 -114
  248. package/dist/yield/rates.d.ts.map +0 -1
  249. package/dist/yield/rates.js +0 -351
  250. package/dist/yield/rates.js.map +0 -1
  251. package/dist/yield/types.d.ts +0 -134
  252. package/dist/yield/types.d.ts.map +0 -1
  253. package/dist/yield/types.js +0 -24
  254. package/dist/yield/types.js.map +0 -1
  255. package/dist/yield/vault.d.ts +0 -112
  256. package/dist/yield/vault.d.ts.map +0 -1
  257. package/dist/yield/vault.js +0 -264
  258. package/dist/yield/vault.js.map +0 -1
@@ -1,212 +0,0 @@
1
- /**
2
- * Flash Loan Opportunity Scanner
3
- *
4
- * Scans for profitable flash loan opportunities across DEXs and lending protocols.
5
- *
6
- * ⚠️ PRODUCTION NOTICE:
7
- * Real arbitrage scanning requires live DEX price quotes (SmartSwapRouter integration)
8
- * and Aave borrower tracking (subgraph or event indexing). The methods below implement
9
- * the full interface and calculation logic — wire in the SmartSwapRouter for live quotes.
10
- */
11
- /** Aave V3 flash loan fee in basis points (0.09%) */
12
- const AAVE_FLASH_FEE_BPS = 9;
13
- /** Default estimated gas cost as a percentage of trade size (bps) */
14
- const DEFAULT_GAS_ESTIMATE_BPS = 10;
15
- /** Default minimum net profit threshold (bps) */
16
- const DEFAULT_MIN_NET_PROFIT_BPS = 5;
17
- /** Default trade size in USD for scanning */
18
- const DEFAULT_SCAN_AMOUNT_USD = 10000;
19
- /** Default minimum liquidation profit in USD */
20
- const DEFAULT_MIN_LIQUIDATION_PROFIT_USD = 50;
21
- /**
22
- * Aave V3 Pool Data Provider addresses by chain.
23
- * Used to query borrower health factors on-chain.
24
- */
25
- const AAVE_DATA_PROVIDER = {
26
- ethereum: '0x7B4EB56E7CD4b454BA8ff71E4518426369a138a3',
27
- base: '0x2d8A3C5677189723C4cB8873CfC9C8976ddf54D8',
28
- arbitrum: '0x69FA688f1Dc47d4B5d8029D5a35FB7a548310654',
29
- optimism: '0x69FA688f1Dc47d4B5d8029D5a35FB7a548310654',
30
- };
31
- /**
32
- * Minimal ABI for Aave V3 Pool getUserAccountData.
33
- * Returns (totalCollateralBase, totalDebtBase, availableBorrowsBase,
34
- * currentLiquidationThreshold, ltv, healthFactor)
35
- */
36
- const AAVE_POOL_DATA_ABI = [
37
- 'function getUserAccountData(address user) view returns (uint256 totalCollateralBase, uint256 totalDebtBase, uint256 availableBorrowsBase, uint256 currentLiquidationThreshold, uint256 ltv, uint256 healthFactor)',
38
- ];
39
- /**
40
- * Scans for flash loan opportunities: DEX arbitrage and protocol liquidations.
41
- *
42
- * **DEX Arbitrage**: Compares buy/sell prices across DEX aggregators.
43
- * A spread exceeding the Aave flash loan fee (0.09%) + gas becomes a
44
- * profitable arbitrage opportunity.
45
- *
46
- * **Liquidations**: Checks known borrowers' health factors on Aave V3.
47
- * Positions with healthFactor < 1.0 are liquidatable; the liquidator
48
- * receives a bonus (typically 5–10%) on the seized collateral.
49
- *
50
- * ⚠️ PRODUCTION NOTICE:
51
- * Requires a deployed `FlashLoanExecutor.sol` to actually execute opportunities.
52
- * See `src/flash/contracts/FlashLoanExecutor.sol`.
53
- */
54
- export class FlashOpportunityScanner {
55
- /**
56
- * Scan for DEX arbitrage opportunities across a token list.
57
- *
58
- * Algorithm:
59
- * 1. For each token, simulate buying $amountUsd on each available DEX aggregator
60
- * 2. Simulate selling the same amount on each DEX aggregator
61
- * 3. Compute the spread: (bestSell - bestBuy) / bestBuy * 10000 (bps)
62
- * 4. Subtract Aave flash loan fee (9 bps) and estimated gas cost
63
- * 5. Return opportunities where netProfitBps > minNetProfitBps, sorted desc
64
- *
65
- * In production, wire `SmartSwapRouter.getQuote()` to fetch real DEX prices.
66
- * Without live quotes, returns an empty array (no false positives).
67
- *
68
- * @param params - Scan configuration
69
- * @returns Viable arbitrage opportunities sorted by netProfitBps descending
70
- */
71
- async scanArbitrage(params) {
72
- const { tokens, chain, amountUsd = DEFAULT_SCAN_AMOUNT_USD, minNetProfitBps = DEFAULT_MIN_NET_PROFIT_BPS, } = params;
73
- if (!tokens || tokens.length === 0) {
74
- return [];
75
- }
76
- // In production: for each token, call SmartSwapRouter.getQuote() against
77
- // multiple DEX providers, compare best buy vs best sell price.
78
- // Without wired providers, we return an empty array to avoid false signals.
79
- //
80
- // Example production flow:
81
- // const router = new SmartSwapRouter(routerConfig);
82
- // for (const token of tokens) {
83
- // const quotes = await router.getQuotesFromAllProviders({ token, amountUsd, chain });
84
- // const bestBuy = quotes.reduce((min, q) => q.price < min.price ? q : min);
85
- // const bestSell = quotes.reduce((max, q) => q.price > max.price ? q : max);
86
- // const grossBps = Number((bestSell.price - bestBuy.price) * 10000n / bestBuy.price);
87
- // const netBps = grossBps - AAVE_FLASH_FEE_BPS - DEFAULT_GAS_ESTIMATE_BPS;
88
- // if (netBps > minNetProfitBps) opportunities.push({ ... });
89
- // }
90
- // Suppress unused-var warnings in strict mode
91
- void amountUsd;
92
- const opportunities = [];
93
- // Filter to only viable, sorted descending by netProfitBps
94
- return opportunities
95
- .filter((o) => o.netProfitBps > minNetProfitBps)
96
- .sort((a, b) => b.netProfitBps - a.netProfitBps);
97
- }
98
- /**
99
- * Check for liquidation opportunities on Aave V3.
100
- *
101
- * Algorithm:
102
- * 1. For each known borrower address, call getUserAccountData() on Aave Pool
103
- * 2. If healthFactor < 1e18 (i.e., < 1.0 in 18-decimal representation) → liquidatable
104
- * 3. Estimate profit: debtToRepay × liquidationBonus%
105
- * 4. Return opportunities where estimatedProfitUsd > minProfitUsd
106
- *
107
- * ⚠️ PRODUCTION NOTICE:
108
- * This requires tracking active Aave borrowers via:
109
- * - Aave subgraph (https://thegraph.com/explorer/subgraphs/...)
110
- * - Indexing Borrow events from the Aave Pool contract
111
- * Without a borrower list, returns empty array.
112
- *
113
- * @param params - Scan configuration
114
- * @returns Liquidatable positions sorted by estimatedProfitUsd descending
115
- */
116
- async scanLiquidations(params) {
117
- const { borrowers = [], minProfitUsd = DEFAULT_MIN_LIQUIDATION_PROFIT_USD, } = params;
118
- if (borrowers.length === 0) {
119
- // No borrower list — cannot scan without on-chain tracking infrastructure
120
- return [];
121
- }
122
- const opportunities = [];
123
- for (const borrower of borrowers) {
124
- // In production with a provider wired in:
125
- // const pool = new ethers.Contract(AAVE_POOL_ADDRESS, AAVE_POOL_DATA_ABI, provider);
126
- // const [,,,,, healthFactorRaw] = await pool.getUserAccountData(borrower);
127
- // const healthFactor = Number(healthFactorRaw) / 1e18;
128
- // if (healthFactor >= 1.0) continue;
129
- // // Fetch collateral + debt positions, compute bonus, push to opportunities
130
- void borrower;
131
- }
132
- return opportunities
133
- .filter((o) => o.estimatedProfitUsd > minProfitUsd)
134
- .sort((a, b) => b.estimatedProfitUsd - a.estimatedProfitUsd);
135
- }
136
- /**
137
- * Run a full scan: both DEX arbitrage and liquidations.
138
- * Returns a FlashScanResult with the best opportunity highlighted.
139
- */
140
- async scan(arbitrageParams, liquidationParams) {
141
- const start = Date.now();
142
- const [arbOpps, liqOpps] = await Promise.all([
143
- this.scanArbitrage(arbitrageParams),
144
- liquidationParams ? this.scanLiquidations(liquidationParams) : Promise.resolve([]),
145
- ]);
146
- const opportunities = [...arbOpps, ...liqOpps];
147
- // Find the best opportunity by estimated profit
148
- let bestOpportunity = null;
149
- for (const opp of opportunities) {
150
- if (!opp.viable)
151
- continue;
152
- if (bestOpportunity === null) {
153
- bestOpportunity = opp;
154
- continue;
155
- }
156
- const currentProfit = opp.type === 'dex-arbitrage' ? opp.estimatedNetProfitUsd : opp.estimatedProfitUsd;
157
- const bestProfit = bestOpportunity.type === 'dex-arbitrage'
158
- ? bestOpportunity.estimatedNetProfitUsd
159
- : bestOpportunity.estimatedProfitUsd;
160
- if (currentProfit > bestProfit)
161
- bestOpportunity = opp;
162
- }
163
- return {
164
- scannedAt: Date.now(),
165
- chain: arbitrageParams.chain,
166
- opportunities,
167
- bestOpportunity,
168
- scanDurationMs: Date.now() - start,
169
- };
170
- }
171
- /**
172
- * Calculate net profit in basis points for an arbitrage opportunity.
173
- * Public helper used by tests and external callers.
174
- *
175
- * @param grossProfitBps - Raw spread between buy and sell price
176
- * @param flashLoanFeeBps - Flash loan fee (default: 9 for Aave V3)
177
- * @param gasBps - Estimated gas as % of trade size (default: 10 bps)
178
- */
179
- static calcNetProfitBps(grossProfitBps, flashLoanFeeBps = AAVE_FLASH_FEE_BPS, gasBps = DEFAULT_GAS_ESTIMATE_BPS) {
180
- return grossProfitBps - flashLoanFeeBps - gasBps;
181
- }
182
- /**
183
- * Build an ArbitrageOpportunity object from raw price data.
184
- * Useful for testing the scanner logic without live DEX quotes.
185
- */
186
- static buildArbitrageOpportunity(params) {
187
- const { token, tokenAddress, amount, buyDex, buyPrice, sellDex, sellPrice, chain, amountUsd = 0, gasBps = DEFAULT_GAS_ESTIMATE_BPS, } = params;
188
- const grossProfitBps = buyPrice > 0n
189
- ? Number(((sellPrice - buyPrice) * 10000n) / buyPrice)
190
- : 0;
191
- const netProfitBps = grossProfitBps - AAVE_FLASH_FEE_BPS - gasBps;
192
- // estimatedNetProfitUsd = amountUsd * (netProfitBps / 10000)
193
- const estimatedNetProfitUsd = amountUsd * (netProfitBps / 10000);
194
- return {
195
- type: 'dex-arbitrage',
196
- token,
197
- tokenAddress,
198
- amount,
199
- buyDex,
200
- buyPrice,
201
- sellDex,
202
- sellPrice,
203
- grossProfitBps,
204
- flashLoanFeeBps: AAVE_FLASH_FEE_BPS,
205
- netProfitBps,
206
- estimatedNetProfitUsd,
207
- chain,
208
- viable: netProfitBps > 0,
209
- };
210
- }
211
- }
212
- //# sourceMappingURL=scanner.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"scanner.js","sourceRoot":"","sources":["../../src/flash/scanner.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AASH,qDAAqD;AACrD,MAAM,kBAAkB,GAAG,CAAC,CAAC;AAE7B,qEAAqE;AACrE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,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,GAAG,QAAQ,CAAC,GAAG,MAAM,CAAC,GAAG,QAAQ,CAAC;YACtD,CAAC,CAAC,CAAC,CAAC;QAER,MAAM,YAAY,GAAG,cAAc,GAAG,kBAAkB,GAAG,MAAM,CAAC;QAElE,6DAA6D;QAC7D,MAAM,qBAAqB,GAAG,SAAS,GAAG,CAAC,YAAY,GAAG,KAAM,CAAC,CAAC;QAElE,OAAO;YACL,IAAI,EAAE,eAAe;YACrB,KAAK;YACL,YAAY;YACZ,MAAM;YACN,MAAM;YACN,QAAQ;YACR,OAAO;YACP,SAAS;YACT,cAAc;YACd,eAAe,EAAE,kBAAkB;YACnC,YAAY;YACZ,qBAAqB;YACrB,KAAK;YACL,MAAM,EAAE,YAAY,GAAG,CAAC;SACzB,CAAC;IACJ,CAAC;CACF"}
@@ -1,136 +0,0 @@
1
- /**
2
- * Flash Loan Module — Types
3
- *
4
- * ⚠️ PRODUCTION NOTICE:
5
- * Executing flash loans requires a deployed `FlashLoanExecutor.sol` contract on-chain.
6
- * The contract receives funds from Aave, performs arbitrage/liquidation, then repays.
7
- * See `src/flash/contracts/FlashLoanExecutor.sol` for the Solidity scaffold.
8
- *
9
- * This SDK module generates the calldata for flash loan transactions.
10
- * The agent signs and sends the transaction — no private keys are held server-side.
11
- *
12
- * Supported use cases (atomic, same-block execution only):
13
- * 1. DEX Arbitrage — exploit price differences across DEXs in a single tx
14
- * 2. Liquidation — liquidate underwater borrowers, collect bonus collateral
15
- * 3. Collateral Swap — swap collateral token without closing position
16
- * 4. Self-Liquidation — repay your own loan to avoid protocol penalty
17
- *
18
- * NOT supported (wrong time scale):
19
- * - Yield arbitrage between lending protocols (APY differences take days/weeks to profit)
20
- * - Any strategy that requires holding funds between blocks
21
- */
22
- /** Supported flash loan providers */
23
- export type FlashLoanProvider = 'aave-v3' | 'balancer' | 'uniswap-v3';
24
- /** Configuration for the flash loan module */
25
- export interface FlashLoanConfig {
26
- /** Primary flash loan provider (default: 'aave-v3') */
27
- provider?: FlashLoanProvider;
28
- /**
29
- * Aave V3 Pool address override.
30
- * If not set, the executor uses the canonical address for the given chain.
31
- */
32
- aavePoolAddress?: string;
33
- /** Chain to operate on (e.g. 'ethereum', 'base', 'arbitrum') */
34
- chain: string;
35
- /** RPC URL for on-chain queries */
36
- rpcUrl?: string;
37
- }
38
- /**
39
- * Opportunity types that flash loans can profitably exploit.
40
- * All strategies must be atomic (open and close in the same transaction).
41
- */
42
- export type FlashOpportunityType = 'dex-arbitrage' | 'liquidation' | 'collateral-swap' | 'self-liquidation';
43
- /** A DEX arbitrage opportunity identified by the scanner */
44
- export interface ArbitrageOpportunity {
45
- type: 'dex-arbitrage';
46
- /** Token symbol (e.g. 'WETH') */
47
- token: string;
48
- /** Token contract address */
49
- tokenAddress: string;
50
- /** Flash loan amount (in token's native decimals) */
51
- amount: bigint;
52
- /** DEX with the lower (buy) price */
53
- buyDex: string;
54
- /** Price on the buy DEX (in quote token units, 18-decimal normalized) */
55
- buyPrice: bigint;
56
- /** DEX with the higher (sell) price */
57
- sellDex: string;
58
- /** Price on the sell DEX (in quote token units, 18-decimal normalized) */
59
- sellPrice: bigint;
60
- /** Gross profit in basis points: (sellPrice - buyPrice) / buyPrice * 10000 */
61
- grossProfitBps: number;
62
- /** Flash loan fee in bps (Aave V3 = 9 bps = 0.09%) */
63
- flashLoanFeeBps: number;
64
- /** Net profit after flash loan fee and estimated gas: grossProfitBps - flashLoanFeeBps - gasBps */
65
- netProfitBps: number;
66
- /** Estimated net profit in USD */
67
- estimatedNetProfitUsd: number;
68
- /** Chain this opportunity exists on */
69
- chain: string;
70
- /** true if netProfitBps > 0 (viable to execute) */
71
- viable: boolean;
72
- }
73
- /** A liquidation opportunity on a lending protocol */
74
- export interface LiquidationOpportunity {
75
- type: 'liquidation';
76
- /** Address of the underwater borrower */
77
- borrower: string;
78
- /** Symbol of the collateral token to receive */
79
- collateralToken: string;
80
- /** Address of the collateral token */
81
- collateralAddress: string;
82
- /** Symbol of the debt token to repay */
83
- debtToken: string;
84
- /** Address of the debt token */
85
- debtAddress: string;
86
- /** Amount of debt to repay (used as flash loan amount) */
87
- debtAmount: bigint;
88
- /**
89
- * Liquidation bonus as a percentage (e.g. 5 = 5%).
90
- * Aave V3 typically offers 5–10% bonus on collateral seized.
91
- */
92
- collateralBonus: number;
93
- /** Estimated profit in USD after repaying debt + flash loan fee */
94
- estimatedProfitUsd: number;
95
- /**
96
- * Borrower's current health factor.
97
- * Values < 1.0 indicate the position is liquidatable.
98
- */
99
- healthFactor: number;
100
- /** Lending protocol holding this position */
101
- protocol: 'aave-v3' | 'compound-v3' | 'morpho';
102
- /** true if the liquidation is profitable after fees */
103
- viable: boolean;
104
- }
105
- /** Union type for all flash loan opportunity types */
106
- export type FlashOpportunity = ArbitrageOpportunity | LiquidationOpportunity;
107
- /** Result of a flash loan execution attempt */
108
- export interface FlashLoanResult {
109
- success: boolean;
110
- txHash?: string;
111
- opportunityType: FlashOpportunityType;
112
- /** Amount borrowed in the flash loan */
113
- loanAmount: bigint;
114
- /** Address of the borrowed token */
115
- loanToken: string;
116
- /** Flash loan fee paid (e.g. 0.09% of loanAmount for Aave V3) */
117
- feePaid: bigint;
118
- /** Net profit in USD after fee and gas costs */
119
- netProfitUsd: number;
120
- gasUsed?: bigint;
121
- blockNumber?: number;
122
- error?: string;
123
- }
124
- /** Result of an opportunity scan */
125
- export interface FlashScanResult {
126
- /** Unix timestamp (ms) when the scan ran */
127
- scannedAt: number;
128
- chain: string;
129
- /** All opportunities found (viable and non-viable) */
130
- opportunities: FlashOpportunity[];
131
- /** Highest-profit viable opportunity, or null if none found */
132
- bestOpportunity: FlashOpportunity | null;
133
- /** How long the scan took in milliseconds */
134
- scanDurationMs: number;
135
- }
136
- //# sourceMappingURL=types.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/flash/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;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AAc,EAAE,MAAM,CAAC;CACxB"}
@@ -1,23 +0,0 @@
1
- /**
2
- * Flash Loan Module — Types
3
- *
4
- * ⚠️ PRODUCTION NOTICE:
5
- * Executing flash loans requires a deployed `FlashLoanExecutor.sol` contract on-chain.
6
- * The contract receives funds from Aave, performs arbitrage/liquidation, then repays.
7
- * See `src/flash/contracts/FlashLoanExecutor.sol` for the Solidity scaffold.
8
- *
9
- * This SDK module generates the calldata for flash loan transactions.
10
- * The agent signs and sends the transaction — no private keys are held server-side.
11
- *
12
- * Supported use cases (atomic, same-block execution only):
13
- * 1. DEX Arbitrage — exploit price differences across DEXs in a single tx
14
- * 2. Liquidation — liquidate underwater borrowers, collect bonus collateral
15
- * 3. Collateral Swap — swap collateral token without closing position
16
- * 4. Self-Liquidation — repay your own loan to avoid protocol penalty
17
- *
18
- * NOT supported (wrong time scale):
19
- * - Yield arbitrage between lending protocols (APY differences take days/weeks to profit)
20
- * - Any strategy that requires holding funds between blocks
21
- */
22
- export {};
23
- //# sourceMappingURL=types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/flash/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG"}
@@ -1,4 +0,0 @@
1
- export { GasSponsor } from './sponsor.js';
2
- export type { GasSponsorConfig, GasSupportedChain, UserOperation, SponsoredTx, SponsorTxParams, SponsorBridgeParams, } from './types.js';
3
- export { ALCHEMY_NETWORK_SLUGS } from './types.js';
4
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/gas/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,YAAY,EACV,gBAAgB,EAChB,iBAAiB,EACjB,aAAa,EACb,WAAW,EACX,eAAe,EACf,mBAAmB,GACpB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC"}
package/dist/gas/index.js DELETED
@@ -1,3 +0,0 @@
1
- export { GasSponsor } from './sponsor.js';
2
- export { ALCHEMY_NETWORK_SLUGS } from './types.js';
3
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/gas/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAS1C,OAAO,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC"}
@@ -1,70 +0,0 @@
1
- import type { GasSponsorConfig, GasSupportedChain, SponsoredTx, SponsorTxParams, SponsorBridgeParams } from './types.js';
2
- /**
3
- * GasSponsor — wraps transactions as ERC-4337 UserOperations with Alchemy paymaster data.
4
- *
5
- * Agents don't need to hold ETH/MATIC/etc. to pay gas. The Alchemy Gas Manager
6
- * sponsors gas on their behalf, billed to your Alchemy account.
7
- *
8
- * Requires:
9
- * - An Alchemy API key with Gas Manager enabled
10
- * - A Gas Manager policy ID (create at https://dashboard.alchemy.com/gas-manager)
11
- * - A smart account (ERC-4337 compatible) for the agent
12
- *
13
- * @example
14
- * const sponsor = new GasSponsor({ alchemyApiKey: 'your-key', policyId: 'your-policy-id' });
15
- * const sponsored = await sponsor.sponsorTransaction({
16
- * chain: 'base',
17
- * from: agentSmartAccountAddress,
18
- * to: usdcContract,
19
- * data: transferCalldata,
20
- * });
21
- * // Now submit sponsored.userOperation to an ERC-4337 bundler
22
- */
23
- export declare class GasSponsor {
24
- private readonly config;
25
- constructor(config: GasSponsorConfig);
26
- /** Get the Solana gas policy ID */
27
- getSolanaPolicyId(): string;
28
- /** Get the EVM gas policy ID */
29
- getEvmPolicyId(): string;
30
- /**
31
- * Check if gas sponsorship is available for a given chain.
32
- */
33
- isSupported(chain: string): chain is GasSupportedChain;
34
- /**
35
- * Returns the list of chains where Alchemy Gas Manager is available.
36
- * Of the SDK's 17 CCTP chains, 6 are supported by Alchemy's Gas Manager.
37
- */
38
- getSupportedChains(): GasSupportedChain[];
39
- /**
40
- * Get the Alchemy RPC URL for a given chain.
41
- */
42
- getAlchemyRpcUrl(chain: GasSupportedChain): string;
43
- /**
44
- * Sponsor a transaction — wraps it as a UserOperation with Alchemy paymaster data.
45
- *
46
- * The resulting UserOperation must be submitted to an ERC-4337 bundler
47
- * (e.g. Alchemy's bundler via `eth_sendUserOperation`).
48
- *
49
- * Note: `from` must be an ERC-4337 smart account, not a plain EOA.
50
- * Plain EOA transactions cannot be sponsored via ERC-4337 paymasters.
51
- */
52
- sponsorTransaction(params: SponsorTxParams): Promise<SponsoredTx>;
53
- /**
54
- * Sponsor a bridge transaction (e.g., from BridgeModule or UnifiedBridge).
55
- *
56
- * Bridge transactions tend to require significant gas on some chains.
57
- * Sponsoring allows agents to bridge USDC without holding native gas tokens.
58
- */
59
- sponsorBridge(params: SponsorBridgeParams): Promise<SponsoredTx>;
60
- /**
61
- * Encode the `execute(address,uint256,bytes)` call for ERC-4337 account contracts.
62
- * This is the standard call format used by SimpleAccount and many ERC-4337 wallets.
63
- *
64
- * Selector: keccak256("execute(address,uint256,bytes)")[0:4] = 0xb61d27f6
65
- */
66
- private _encodeExecuteCall;
67
- /** Make a JSON-RPC request to Alchemy */
68
- private _alchemyRpc;
69
- }
70
- //# sourceMappingURL=sponsor.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"sponsor.d.ts","sourceRoot":"","sources":["../../src/gas/sponsor.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EACV,gBAAgB,EAChB,iBAAiB,EAEjB,WAAW,EACX,eAAe,EACf,mBAAmB,EACpB,MAAM,YAAY,CAAC;AAMpB;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,qBAAa,UAAU;IACrB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAA6B;gBAExC,MAAM,EAAE,gBAAgB;IASpC,mCAAmC;IACnC,iBAAiB,IAAI,MAAM;IAI3B,gCAAgC;IAChC,cAAc,IAAI,MAAM;IAIxB;;OAEG;IACH,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,KAAK,IAAI,iBAAiB;IAItD;;;OAGG;IACH,kBAAkB,IAAI,iBAAiB,EAAE;IAIzC;;OAEG;IACH,gBAAgB,CAAC,KAAK,EAAE,iBAAiB,GAAG,MAAM;IAKlD;;;;;;;;OAQG;IACG,kBAAkB,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,WAAW,CAAC;IAyEvE;;;;;OAKG;IACG,aAAa,CAAC,MAAM,EAAE,mBAAmB,GAAG,OAAO,CAAC,WAAW,CAAC;IAUtE;;;;;OAKG;IACH,OAAO,CAAC,kBAAkB;IAqB1B,yCAAyC;YAC3B,WAAW;CAiC1B"}