@emberai/onchain-actions-registry 1.0.0 → 1.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,275 @@
1
+ # @emberai/onchain-actions-registry
2
+
3
+ [![npm version](https://img.shields.io/npm/v/@emberai/onchain-actions-registry.svg)](https://www.npmjs.com/package/@emberai/onchain-actions-registry)
4
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://github.com/EmberAGI/arbitrum-vibekit/blob/main/LICENSE)
5
+
6
+ A modular plugin architecture for integrating DeFi protocols into the Ember ecosystem. Build custom protocol plugins with TypeScript support and comprehensive type safety.
7
+
8
+ ## Features
9
+
10
+ - **Modular Plugin System**: Extensible architecture for DeFi protocol integrations.
11
+ - **Multi-Protocol Support**: Lending, liquidity, swap, perpetuals protocol.
12
+ - **Type Safety**: Full TypeScript support with Zod validation schemas
13
+ - **Multi-Chain**: Support for multiple blockchain networks.
14
+ - **Action-Based**: Define actions for supply, borrow, swap, and more.
15
+ - **Plugin for AAVE V3**: Complete lending protocol with supply, borrow, repay, withdraw.
16
+
17
+ ## Installation
18
+
19
+ ```bash
20
+ npm install @emberai/onchain-actions-registry
21
+ ```
22
+
23
+ ```bash
24
+ pnpm add @emberai/onchain-actions-registry
25
+ ```
26
+
27
+ ```bash
28
+ yarn add @emberai/onchain-actions-registry
29
+ ```
30
+
31
+ ## Quickstart
32
+
33
+ ```typescript
34
+ import { initializePublicRegistry, type ChainConfig } from '@emberai/onchain-actions-registry';
35
+
36
+ // 1. Define your chain configuration
37
+ const chainConfigs: ChainConfig[] = [
38
+ {
39
+ chainId: 42161,
40
+ rpcUrl: 'https://arb1.arbitrum.io/rpc',
41
+ wrappedNativeToken: '0x82aF49447D8a07e3bd95BD0d56f35241523fBab1',
42
+ },
43
+ ];
44
+
45
+ // 2. Initialize the registry with your chains
46
+ const registry = initializePublicRegistry(chainConfigs);
47
+
48
+ // 3. Iterate through available plugins
49
+ for await (const plugin of registry.getPlugins()) {
50
+ console.log(`Loaded plugin: ${plugin.name} (${plugin.type})`);
51
+ }
52
+ ```
53
+
54
+ ## Plugin Types
55
+
56
+ The registry supports four main plugin types:
57
+
58
+ ### Lending Plugins
59
+
60
+ Supply, borrow, repay, and withdraw operations across lending protocols.
61
+
62
+ ```typescript
63
+ import type { EmberPlugin } from '@emberai/onchain-actions-registry';
64
+
65
+ const lendingPlugin: EmberPlugin<'lending'> = {
66
+ type: 'lending',
67
+ name: 'AAVE V3',
68
+ actions: [
69
+ // lending-supply, lending-borrow, lending-repay, lending-withdraw
70
+ ],
71
+ queries: {
72
+ getPositions: async params => {
73
+ /* Get user positions */
74
+ },
75
+ },
76
+ };
77
+ ```
78
+
79
+ ### Liquidity Plugins
80
+
81
+ Add and remove liquidity from DEX pools and AMMs.
82
+
83
+ ```typescript
84
+ const liquidityPlugin: EmberPlugin<'liquidity'> = {
85
+ type: 'liquidity',
86
+ name: 'Camelot DEX',
87
+ actions: [
88
+ // liquidity-supply, liquidity-withdraw
89
+ ],
90
+ queries: {
91
+ getWalletPositions: async params => {
92
+ /* Get LP positions */
93
+ },
94
+ getPools: async () => {
95
+ /* Get available pools */
96
+ },
97
+ },
98
+ };
99
+ ```
100
+
101
+ ### Swap Plugins
102
+
103
+ Token exchange operations with slippage protection.
104
+
105
+ ```typescript
106
+ const swapPlugin: EmberPlugin<'swap'> = {
107
+ type: 'swap',
108
+ name: 'DEX Aggregator',
109
+ actions: [
110
+ // swap
111
+ ],
112
+ queries: {}, // Stateless operations
113
+ };
114
+ ```
115
+
116
+ ### Perpetuals Plugins
117
+
118
+ Long, short, and close perpetual positions with leverage.
119
+
120
+ ```typescript
121
+ const perpetualsPlugin: EmberPlugin<'perpetuals'> = {
122
+ type: 'perpetuals',
123
+ name: 'GMX V2',
124
+ actions: [
125
+ // perpetuals-long, perpetuals-short, perpetuals-close
126
+ ],
127
+ queries: {
128
+ getMarkets: async params => {
129
+ /* Get available markets */
130
+ },
131
+ getPositions: async params => {
132
+ /* Get open positions */
133
+ },
134
+ getOrders: async params => {
135
+ /* Get pending orders */
136
+ },
137
+ },
138
+ };
139
+ ```
140
+
141
+ ## Building Custom Plugins
142
+
143
+ For a comprehensive guide on building custom plugins, checkout the [GitHub repository](https://github.com/EmberAGI/arbitrum-vibekit/tree/main/typescript/onchain-actions-plugins/).
144
+
145
+ ### 1. Define Your Plugin
146
+
147
+ ```typescript
148
+ import type {
149
+ ActionDefinition,
150
+ EmberPlugin,
151
+ LendingActions,
152
+ } from '@emberai/onchain-actions-registry';
153
+
154
+ export async function getMyProtocolPlugin(params: {
155
+ chainId: number;
156
+ rpcUrl: string;
157
+ }): Promise<EmberPlugin<'lending'>> {
158
+ return {
159
+ type: 'lending',
160
+ name: 'My Protocol',
161
+ description: 'Custom lending protocol integration',
162
+ website: 'https://myprotocol.com',
163
+ actions: await getMyProtocolActions(params),
164
+ queries: {
165
+ getPositions: async params => {
166
+ // Implement position querying logic
167
+ return { positions: [] };
168
+ },
169
+ },
170
+ };
171
+ }
172
+ ```
173
+
174
+ ### 2. Implement Actions
175
+
176
+ ```typescript
177
+ async function getMyProtocolActions(params: any): Promise<ActionDefinition<LendingActions>[]> {
178
+ return [
179
+ {
180
+ type: 'lending-supply',
181
+ name: 'Supply to My Protocol',
182
+ inputTokens: async () => [
183
+ {
184
+ chainId: params.chainId.toString(),
185
+ tokens: ['0x...'], // Supported input tokens
186
+ },
187
+ ],
188
+ outputTokens: async () => [
189
+ {
190
+ chainId: params.chainId.toString(),
191
+ tokens: ['0x...'], // Yield tokens received
192
+ },
193
+ ],
194
+ callback: async request => {
195
+ // Implement supply transaction logic
196
+ return { transactions: [] };
197
+ },
198
+ },
199
+ ];
200
+ }
201
+ ```
202
+
203
+ ### 3. Register Your Plugin
204
+
205
+ ```typescript
206
+ import { PublicEmberPluginRegistry } from '@emberai/onchain-actions-registry';
207
+
208
+ const registry = new PublicEmberPluginRegistry();
209
+
210
+ // For async plugins (recommended)
211
+ registry.registerDeferredPlugin(
212
+ getMyProtocolPlugin({
213
+ chainId: 42161,
214
+ rpcUrl: 'https://arb1.arbitrum.io/rpc',
215
+ })
216
+ );
217
+
218
+ // For synchronous plugins
219
+ registry.registerPlugin(myInstantPlugin);
220
+ ```
221
+
222
+ ## PLugin Interfaces
223
+
224
+ ### Core Types
225
+
226
+ ```typescript
227
+ interface EmberPlugin<Type extends PluginType> {
228
+ id?: string;
229
+ type: Type;
230
+ name: string;
231
+ description?: string;
232
+ website?: string;
233
+ x?: string;
234
+ actions: ActionDefinition<AvailableActions[Type]>[];
235
+ queries: AvailableQueries[Type];
236
+ }
237
+
238
+ interface ActionDefinition<T extends Action> {
239
+ name: string;
240
+ type: T;
241
+ callback: ActionCallback<T>;
242
+ inputTokens: () => Promise<TokenSet[]>;
243
+ outputTokens?: () => Promise<TokenSet[]>;
244
+ }
245
+
246
+ interface TokenSet {
247
+ chainId: string;
248
+ tokens: string[];
249
+ }
250
+ ```
251
+
252
+ ### Registry Methods
253
+
254
+ ```typescript
255
+ class PublicEmberPluginRegistry {
256
+ registerPlugin(plugin: EmberPlugin<PluginType>): void;
257
+ registerDeferredPlugin(pluginPromise: Promise<EmberPlugin<PluginType>>): void;
258
+ getPlugins(): AsyncIterable<EmberPlugin<PluginType>>;
259
+ }
260
+ ```
261
+
262
+ ## Contributing
263
+
264
+ We welcome contributions! Please see our [Contributing Guide](https://github.com/EmberAGI/arbitrum-vibekit/blob/main/CONTRIBUTIONS.md) for details.
265
+
266
+ ## License
267
+
268
+ MIT © [EmberAGI](https://github.com/EmberAGI/arbitrum-vibekit/blob/main/LICENSE)
269
+
270
+ ## Links
271
+
272
+ - [NPM Package](https://www.npmjs.com/package/@emberai/onchain-actions-registry)
273
+ - [GitHub Repository](https://github.com/EmberAGI/arbitrum-vibekit/tree/main/typescript/onchain-actions-plugins/)
274
+ - [Ember Website](https://www.emberai.xyz/)
275
+ - [Ember X](https://x.com/EmberAGI)
package/dist/index.cjs CHANGED
@@ -1005,6 +1005,7 @@ var SwapTokensResponseSchema = import_zod6.z.object({
1005
1005
  });
1006
1006
 
1007
1007
  // src/aave-lending-plugin/adapter.ts
1008
+ var import_locales = require("zod/v4/locales");
1008
1009
  var AAVE_ETH_PLACEHOLDER = "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE";
1009
1010
  var AAVEAdapter = class {
1010
1011
  chain;
@@ -1178,7 +1179,7 @@ var AAVEAdapter = class {
1178
1179
  variableBorrowsUSD,
1179
1180
  totalBorrows,
1180
1181
  totalBorrowsUSD: totalBorrowsUSD2
1181
- } of userReservesData) {
1182
+ } of userReservesData.filter((ur2) => ur2.underlyingBalanceUSD !== "0")) {
1182
1183
  const tokenData = await this.getTokenData(reserve.underlyingAsset);
1183
1184
  userReservesFormatted.push({
1184
1185
  token: {
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/registry.ts","../src/aave-lending-plugin/chain.ts","../src/aave-lending-plugin/market.ts","../src/aave-lending-plugin/userSummary.ts","../src/aave-lending-plugin/populateTransaction.ts","../src/aave-lending-plugin/errors.ts","../src/aave-lending-plugin/dataProvider.ts","../src/aave-lending-plugin/adapter.ts","../src/core/schemas/core.ts","../src/core/schemas/enums.ts","../src/core/schemas/lending.ts","../src/core/schemas/liquidity.ts","../src/core/schemas/perpetuals.ts","../src/core/schemas/swap.ts","../src/aave-lending-plugin/index.ts"],"sourcesContent":["import type { ChainConfig } from './chainConfig.js';\nimport { PublicEmberPluginRegistry } from './registry.js';\nimport { registerAave } from './aave-lending-plugin/index.js';\n\n/**\n * Initialize the public Ember plugin registry.\n * @returns The initialized public Ember plugin registry with registered plugins.\n */\nexport function initializePublicRegistry(chainConfigs: ChainConfig[]) {\n const registry = new PublicEmberPluginRegistry();\n\n // Register any plugin in here\n for (const chainConfig of chainConfigs) {\n // Create aave plugins for each chain config\n registerAave(chainConfig, registry);\n }\n\n return registry;\n}\n\nexport { type ChainConfig, PublicEmberPluginRegistry };\nexport * from './core/index.js';\n","import type { EmberPlugin, PluginType } from './core/index.js';\n\n/**\n * Registry for public Ember plugins.\n */\nexport class PublicEmberPluginRegistry {\n private plugins: EmberPlugin<PluginType>[] = [];\n private deferredPlugins: Promise<EmberPlugin<PluginType>>[] = [];\n\n /**\n * Register a new Ember plugin.\n * @param plugin The plugin to register.\n */\n public registerPlugin(plugin: EmberPlugin<PluginType>) {\n this.plugins.push(plugin);\n }\n\n /**\n * Register a new deferred Ember plugin.\n * @param pluginPromise The promise resolving to the plugin to register.\n */\n public registerDeferredPlugin(pluginPromise: Promise<EmberPlugin<PluginType>>) {\n this.deferredPlugins.push(pluginPromise);\n }\n\n /**\n * Iterator for the registered Ember plugins.\n */\n public async *getPlugins(): AsyncIterable<EmberPlugin<PluginType>> {\n yield* this.plugins;\n\n for (const pluginPromise of this.deferredPlugins) {\n const plugin = await pluginPromise;\n\n // Register the plugin now that it is resolved\n this.registerPlugin(plugin);\n\n yield plugin;\n }\n\n this.deferredPlugins = [];\n }\n\n public get emberPlugins(): EmberPlugin<PluginType>[] {\n return this.plugins;\n }\n}\n","import { ethers } from 'ethers';\n\n/**\n * Represents a blockchain network configuration used to create JSON-RPC providers and\n * hold basic chain-specific metadata.\n *\n * The Chain class encapsulates:\n * - a numeric chain identifier (id),\n * - an RPC URL to connect to the chain (rpcUrl),\n * - an optional wrapped native token address (wrappedNativeTokenAddress).\n *\n * @param id - The numeric identifier for the chain (e.g., 1 for Ethereum mainnet).\n * @param rpcUrl - The JSON-RPC endpoint URL used to create providers for this chain.\n * @param wrappedNativeTokenAddress - Optional address of the chain's wrapped native token (if applicable).\n */\nexport class Chain {\n constructor(\n public id: number,\n public rpcUrl: string,\n public wrappedNativeTokenAddress?: string\n ) {}\n\n /**\n * Create and return an ethers.js JsonRpcProvider configured with this chain's RPC URL.\n *\n * This method constructs a new ethers.providers.JsonRpcProvider each time it is called.\n * Consumers may cache the provider if they intend to reuse it to avoid allocating multiple instances.\n *\n * @returns An instance of ethers.providers.JsonRpcProvider configured with the chain's rpcUrl.\n */\n public getProvider(): ethers.providers.JsonRpcProvider {\n return new ethers.providers.JsonRpcProvider(this.rpcUrl);\n }\n}\n","import * as markets from '@bgd-labs/aave-address-book';\n\n// AAVE market selection provided by aave-address-book is not very typescript-friendly:\n// we have to trust that the structure of their modules is the same, which\n// seems to be the case.\n\n// An interface that only contains fields of market definitions that we actually use\nexport type AAVEMarket = {\n AAVE_PROTOCOL_DATA_PROVIDER: string;\n POOL: string;\n POOL_ADDRESSES_PROVIDER: string;\n UI_INCENTIVE_DATA_PROVIDER: string;\n UI_POOL_DATA_PROVIDER: string;\n WALLET_BALANCE_PROVIDER: string;\n WETH_GATEWAY: string;\n};\n\nconst marketMap: Record<number, keyof typeof markets> = {\n 1: 'AaveV3Ethereum',\n 11155111: 'AaveV3Sepolia',\n 42161: 'AaveV3Arbitrum',\n 421614: 'AaveV3ArbitrumSepolia',\n 8453: 'AaveV3Base',\n 137: 'AaveV3Polygon',\n 10: 'AaveV3Optimism',\n};\n\nexport const getMarket = (chainId: number): AAVEMarket => {\n const marketKey = marketMap[chainId];\n if (!marketKey) {\n throw new Error(\n `AAVE: no market found for chain ID ${chainId}: modify providers/aave/market.ts`\n );\n }\n\n const market = markets[marketKey] as unknown as AAVEMarket;\n if (!market) {\n throw new Error(`No such market: ${marketKey}`);\n }\n\n return market;\n};\n","import type { ReservesDataHumanized, UserReserveDataHumanized } from '@aave/contract-helpers';\nimport {\n formatReserves,\n formatUserSummary,\n type FormatUserSummaryResponse,\n type FormatReserveUSDResponse,\n} from '@aave/math-utils';\n\nfunction formatNumeric(value: string): string {\n const num = parseFloat(value);\n if (Number.isInteger(num)) return num.toString();\n return parseFloat(num.toFixed(2)).toString();\n}\n\nexport class UserSummary {\n public reserves: FormatUserSummaryResponse<FormatReserveUSDResponse>;\n\n /**\n * @param userReservesResponse - The response from getUserReservesHumanized.\n * @param reservesResponse - The response from getReservesHumanized.\n */\n constructor(\n userReservesResponse: {\n userReserves: UserReserveDataHumanized[];\n userEmodeCategoryId: number;\n },\n reservesResponse: ReservesDataHumanized\n ) {\n const currentTimestamp = Date.now() / 1000;\n\n const formattedReserves = formatReserves({\n reserves: reservesResponse.reservesData,\n currentTimestamp,\n marketReferenceCurrencyDecimals:\n reservesResponse.baseCurrencyData.marketReferenceCurrencyDecimals,\n marketReferencePriceInUsd:\n reservesResponse.baseCurrencyData.marketReferenceCurrencyPriceInUsd,\n });\n\n this.reserves = formatUserSummary({\n currentTimestamp,\n marketReferencePriceInUsd:\n reservesResponse.baseCurrencyData.marketReferenceCurrencyPriceInUsd,\n marketReferenceCurrencyDecimals:\n reservesResponse.baseCurrencyData.marketReferenceCurrencyDecimals,\n userReserves: userReservesResponse.userReserves,\n formattedReserves,\n userEmodeCategoryId: userReservesResponse.userEmodeCategoryId,\n });\n }\n\n public toHumanReadable(): string {\n let output = 'User Positions:\\n';\n output += `Total Liquidity (USD): ${formatNumeric(this.reserves.totalLiquidityUSD)}\\n`;\n output += `Total Collateral (USD): ${formatNumeric(this.reserves.totalCollateralUSD)}\\n`;\n output += `Total Borrows (USD): ${formatNumeric(this.reserves.totalBorrowsUSD)}\\n`;\n output += `Net Worth (USD): ${formatNumeric(this.reserves.netWorthUSD)}\\n`;\n output += `Health Factor: ${formatNumeric(this.reserves.healthFactor)}\\n\\n`;\n output += 'Deposits:\\n';\n for (const entry of this.reserves.userReservesData) {\n if (parseFloat(entry.scaledATokenBalance) > 0) {\n const underlying = entry.underlyingBalance;\n const underlyingUSD = entry.underlyingBalanceUSD\n ? formatNumeric(entry.underlyingBalanceUSD)\n : 'N/A';\n output += `- ${entry.reserve.symbol}: ${underlying} (USD: ${underlyingUSD})\\n`;\n }\n }\n output += '\\nLoans:\\n';\n for (const entry of this.reserves.userReservesData) {\n const borrow = entry.totalBorrows || '0';\n if (parseFloat(borrow) > 0) {\n const totalBorrows = entry.totalBorrows;\n const totalBorrowsUSD = entry.totalBorrowsUSD\n ? formatNumeric(entry.totalBorrowsUSD)\n : 'N/A';\n output += `- ${entry.reserve.symbol}: ${totalBorrows} (USD: ${totalBorrowsUSD})\\n`;\n }\n }\n return output;\n }\n}\n","import type { EthereumTransactionTypeExtended } from '@aave/contract-helpers';\nimport { type PopulatedTransaction, ethers } from 'ethers';\nimport { getAaveError } from './errors.js';\n\nexport async function populateTransaction(\n tx: EthereumTransactionTypeExtended\n): Promise<PopulatedTransaction> {\n let txData = null;\n try {\n txData = await tx.tx();\n /* eslint-disable @typescript-eslint/no-explicit-any */\n } catch (e: any) {\n /* eslint-enable @typescript-eslint/no-explicit-any */\n\n // error reason looks like 'execution reverted: revert: 32', with the aave\n // domain error code at the very end\n const errorCode = (e.reason || '').split(' ').pop();\n // If we end up passing garbage to getAaveError, it does not matter - it will return null\n const aaveError = getAaveError(errorCode);\n if (aaveError !== null) {\n throw aaveError;\n } else {\n // we can hope that the LLM will provide an analysis of the error on the fly\n throw e;\n }\n }\n return {\n value: ethers.BigNumber.from(txData.value || 0),\n from: txData.from,\n to: txData.to,\n data: txData.data,\n };\n}\n","// based on https://github.com/aave-dao/aave-v3-origin/blob/083bd38a137b42b5df04e22ad4c9e72454365d0d/src/contracts/protocol/libraries/helpers/Errors.sol\n\nclass AaveError extends Error {\n public description: string;\n public override message: string;\n\n constructor(code: string, name: string, description: string) {\n const message = name + ` (${code}): ` + description;\n super(message);\n this.name = 'AaveError';\n this.description = description;\n this.message = message;\n\n // Ensures proper prototype chain in transpiled JavaScript\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\ntype AaveErrorData = {\n name: string;\n description: string;\n};\n\nexport const AAVE_ERROR_CODES: Record<string, AaveErrorData> = {\n '1': {\n name: 'CALLER_NOT_POOL_ADMIN',\n description: 'The caller of the function is not a pool admin',\n },\n '2': {\n name: 'CALLER_NOT_EMERGENCY_ADMIN',\n description: 'The caller of the function is not an emergency admin',\n },\n '3': {\n name: 'CALLER_NOT_POOL_OR_EMERGENCY_ADMIN',\n description: 'The caller of the function is not a pool or emergency admin',\n },\n '4': {\n name: 'CALLER_NOT_RISK_OR_POOL_ADMIN',\n description: 'The caller of the function is not a risk or pool admin',\n },\n '5': {\n name: 'CALLER_NOT_ASSET_LISTING_OR_POOL_ADMIN',\n description: 'The caller of the function is not an asset listing or pool admin',\n },\n '6': {\n name: 'CALLER_NOT_BRIDGE',\n description: 'The caller of the function is not a bridge',\n },\n '7': {\n name: 'ADDRESSES_PROVIDER_NOT_REGISTERED',\n description: 'Pool addresses provider is not registered',\n },\n '8': {\n name: 'INVALID_ADDRESSES_PROVIDER_ID',\n description: 'Invalid id for the pool addresses provider',\n },\n '9': { name: 'NOT_CONTRACT', description: 'Address is not a contract' },\n '10': {\n name: 'CALLER_NOT_POOL_CONFIGURATOR',\n description: 'The caller of the function is not the pool configurator',\n },\n '11': {\n name: 'CALLER_NOT_ATOKEN',\n description: 'The caller of the function is not an AToken',\n },\n '12': {\n name: 'INVALID_ADDRESSES_PROVIDER',\n description: 'The address of the pool addresses provider is invalid',\n },\n '13': {\n name: 'INVALID_FLASHLOAN_EXECUTOR_RETURN',\n description: 'Invalid return value of the flashloan executor function',\n },\n '14': {\n name: 'RESERVE_ALREADY_ADDED',\n description: 'Reserve has already been added to reserve list',\n },\n '15': {\n name: 'NO_MORE_RESERVES_ALLOWED',\n description: 'Maximum amount of reserves in the pool reached',\n },\n '16': {\n name: 'EMODE_CATEGORY_RESERVED',\n description: 'Zero eMode category is reserved for volatile heterogeneous assets',\n },\n '17': {\n name: 'INVALID_EMODE_CATEGORY_ASSIGNMENT',\n description: 'Invalid eMode category assignment to asset',\n },\n '18': {\n name: 'RESERVE_LIQUIDITY_NOT_ZERO',\n description: 'The liquidity of the reserve needs to be 0',\n },\n '19': {\n name: 'FLASHLOAN_PREMIUM_INVALID',\n description: 'Invalid flashloan premium',\n },\n '20': {\n name: 'INVALID_RESERVE_PARAMS',\n description: 'Invalid risk parameters for the reserve',\n },\n '21': {\n name: 'INVALID_EMODE_CATEGORY_PARAMS',\n description: 'Invalid risk parameters for the eMode category',\n },\n '22': {\n name: 'BRIDGE_PROTOCOL_FEE_INVALID',\n description: 'Invalid bridge protocol fee',\n },\n '23': {\n name: 'CALLER_MUST_BE_POOL',\n description: 'The caller of this function must be a pool',\n },\n '24': { name: 'INVALID_MINT_AMOUNT', description: 'Invalid amount to mint' },\n '25': { name: 'INVALID_BURN_AMOUNT', description: 'Invalid amount to burn' },\n '26': {\n name: 'INVALID_AMOUNT',\n description: 'Amount must be greater than 0',\n },\n '27': {\n name: 'RESERVE_INACTIVE',\n description: 'Action requires an active reserve',\n },\n '28': {\n name: 'RESERVE_FROZEN',\n description: 'Action cannot be performed because the reserve is frozen',\n },\n '29': {\n name: 'RESERVE_PAUSED',\n description: 'Action cannot be performed because the reserve is paused',\n },\n '30': {\n name: 'BORROWING_NOT_ENABLED',\n description: 'Borrowing is not enabled',\n },\n '32': {\n name: 'NOT_ENOUGH_AVAILABLE_USER_BALANCE',\n description: 'User cannot withdraw more than the available balance',\n },\n '33': {\n name: 'INVALID_INTEREST_RATE_MODE_SELECTED',\n description: 'Invalid interest rate mode selected',\n },\n '34': {\n name: 'COLLATERAL_BALANCE_IS_ZERO',\n description: 'The collateral balance is 0',\n },\n '35': {\n name: 'HEALTH_FACTOR_LOWER_THAN_LIQUIDATION_THRESHOLD',\n description: 'Health factor is lesser than the liquidation threshold',\n },\n '36': {\n name: 'COLLATERAL_CANNOT_COVER_NEW_BORROW',\n description: 'There is not enough collateral to cover a new borrow',\n },\n '37': {\n name: 'COLLATERAL_SAME_AS_BORROWING_CURRENCY',\n description: 'Collateral is (mostly) the same currency that is being borrowed',\n },\n '39': {\n name: 'NO_DEBT_OF_SELECTED_TYPE',\n description: 'For repayment of a specific type of debt, the user needs to have debt that type',\n },\n '40': {\n name: 'NO_EXPLICIT_AMOUNT_TO_REPAY_ON_BEHALF',\n description: 'To repay on behalf of a user an explicit amount to repay is needed',\n },\n '42': {\n name: 'NO_OUTSTANDING_VARIABLE_DEBT',\n description: 'User does not have outstanding variable rate debt on this reserve',\n },\n '43': {\n name: 'UNDERLYING_BALANCE_ZERO',\n description: 'The underlying balance needs to be greater than 0',\n },\n '44': {\n name: 'INTEREST_RATE_REBALANCE_CONDITIONS_NOT_MET',\n description: 'Interest rate rebalance conditions were not met',\n },\n '45': {\n name: 'HEALTH_FACTOR_NOT_BELOW_THRESHOLD',\n description: 'Health factor is not below the threshold',\n },\n '46': {\n name: 'COLLATERAL_CANNOT_BE_LIQUIDATED',\n description: 'The collateral chosen cannot be liquidated',\n },\n '47': {\n name: 'SPECIFIED_CURRENCY_NOT_BORROWED_BY_USER',\n description: 'User did not borrow the specified currency',\n },\n '49': {\n name: 'INCONSISTENT_FLASHLOAN_PARAMS',\n description: 'Inconsistent flashloan parameters',\n },\n '50': { name: 'BORROW_CAP_EXCEEDED', description: 'Borrow cap is exceeded' },\n '51': { name: 'SUPPLY_CAP_EXCEEDED', description: 'Supply cap is exceeded' },\n '52': {\n name: 'UNBACKED_MINT_CAP_EXCEEDED',\n description: 'Unbacked mint cap is exceeded',\n },\n '53': {\n name: 'DEBT_CEILING_EXCEEDED',\n description: 'Debt ceiling is exceeded',\n },\n '54': {\n name: 'UNDERLYING_CLAIMABLE_RIGHTS_NOT_ZERO',\n description: 'Claimable rights over underlying not zero (aToken supply or accruedToTreasury)',\n },\n '56': {\n name: 'VARIABLE_DEBT_SUPPLY_NOT_ZERO',\n description: 'Variable debt supply is not zero',\n },\n '57': { name: 'LTV_VALIDATION_FAILED', description: 'Ltv validation failed' },\n '58': {\n name: 'INCONSISTENT_EMODE_CATEGORY',\n description: 'Inconsistent eMode category',\n },\n '59': {\n name: 'PRICE_ORACLE_SENTINEL_CHECK_FAILED',\n description: 'Price oracle sentinel validation failed',\n },\n '60': {\n name: 'ASSET_NOT_BORROWABLE_IN_ISOLATION',\n description: 'Asset is not borrowable in isolation mode',\n },\n '61': {\n name: 'RESERVE_ALREADY_INITIALIZED',\n description: 'Reserve has already been initialized',\n },\n '62': {\n name: 'USER_IN_ISOLATION_MODE_OR_LTV_ZERO',\n description: 'User is in isolation mode or ltv is zero',\n },\n '63': {\n name: 'INVALID_LTV',\n description: 'Invalid ltv parameter for the reserve',\n },\n '64': {\n name: 'INVALID_LIQ_THRESHOLD',\n description: 'Invalid liquidity threshold parameter for the reserve',\n },\n '65': {\n name: 'INVALID_LIQ_BONUS',\n description: 'Invalid liquidity bonus parameter for the reserve',\n },\n '66': {\n name: 'INVALID_DECIMALS',\n description: 'Invalid decimals parameter of the underlying asset of the reserve',\n },\n '67': {\n name: 'INVALID_RESERVE_FACTOR',\n description: 'Invalid reserve factor parameter for the reserve',\n },\n '68': {\n name: 'INVALID_BORROW_CAP',\n description: 'Invalid borrow cap for the reserve',\n },\n '69': {\n name: 'INVALID_SUPPLY_CAP',\n description: 'Invalid supply cap for the reserve',\n },\n '70': {\n name: 'INVALID_LIQUIDATION_PROTOCOL_FEE',\n description: 'Invalid liquidation protocol fee for the reserve',\n },\n '71': {\n name: 'INVALID_EMODE_CATEGORY',\n description: 'Invalid eMode category for the reserve',\n },\n '72': {\n name: 'INVALID_UNBACKED_MINT_CAP',\n description: 'Invalid unbacked mint cap for the reserve',\n },\n '73': {\n name: 'INVALID_DEBT_CEILING',\n description: 'Invalid debt ceiling for the reserve',\n },\n '74': { name: 'INVALID_RESERVE_INDEX', description: 'Invalid reserve index' },\n '75': {\n name: 'ACL_ADMIN_CANNOT_BE_ZERO',\n description: 'ACL admin cannot be set to the zero address',\n },\n '76': {\n name: 'INCONSISTENT_PARAMS_LENGTH',\n description: 'Array parameters that should be equal length are not',\n },\n '77': {\n name: 'ZERO_ADDRESS_NOT_VALID',\n description: 'Zero address not valid',\n },\n '78': { name: 'INVALID_EXPIRATION', description: 'Invalid expiration' },\n '79': { name: 'INVALID_SIGNATURE', description: 'Invalid signature' },\n '80': {\n name: 'OPERATION_NOT_SUPPORTED',\n description: 'Operation not supported',\n },\n '81': {\n name: 'DEBT_CEILING_NOT_ZERO',\n description: 'Debt ceiling is not zero',\n },\n '82': { name: 'ASSET_NOT_LISTED', description: 'Asset is not listed' },\n '83': {\n name: 'INVALID_OPTIMAL_USAGE_RATIO',\n description: 'Invalid optimal usage ratio',\n },\n '85': {\n name: 'UNDERLYING_CANNOT_BE_RESCUED',\n description: 'The underlying asset cannot be rescued',\n },\n '86': {\n name: 'ADDRESSES_PROVIDER_ALREADY_ADDED',\n description: 'Reserve has already been added to reserve list',\n },\n '87': {\n name: 'POOL_ADDRESSES_DO_NOT_MATCH',\n description:\n 'The token implementation pool address and the pool address provided by the initializing pool do not match',\n },\n '89': {\n name: 'SILOED_BORROWING_VIOLATION',\n description: 'User is trying to borrow multiple assets including a siloed one',\n },\n '90': {\n name: 'RESERVE_DEBT_NOT_ZERO',\n description: 'The total debt of the reserve needs to be 0',\n },\n '91': {\n name: 'FLASHLOAN_DISABLED',\n description: 'FlashLoaning for this asset is disabled',\n },\n '92': {\n name: 'INVALID_MAX_RATE',\n description: 'The expect maximum borrow rate is invalid',\n },\n '93': {\n name: 'WITHDRAW_TO_ATOKEN',\n description: 'Withdrawing to the aToken is not allowed',\n },\n '94': {\n name: 'SUPPLY_TO_ATOKEN',\n description: 'Supplying to the aToken is not allowed',\n },\n '95': {\n name: 'SLOPE_2_MUST_BE_GTE_SLOPE_1',\n description: 'Variable interest rate slope 2 can not be lower than slope 1',\n },\n '96': {\n name: 'CALLER_NOT_RISK_OR_POOL_OR_EMERGENCY_ADMIN',\n description: 'The caller of the function is not a risk, pool or emergency admin',\n },\n '97': {\n name: 'LIQUIDATION_GRACE_SENTINEL_CHECK_FAILED',\n description: 'Liquidation grace sentinel validation failed',\n },\n '98': {\n name: 'INVALID_GRACE_PERIOD',\n description: 'Grace period above a valid range',\n },\n '99': {\n name: 'INVALID_FREEZE_STATE',\n description: 'Reserve is already in the passed freeze state',\n },\n '100': {\n name: 'NOT_BORROWABLE_IN_EMODE',\n description: 'Asset not borrowable in eMode',\n },\n};\n\nexport function getAaveError(code: string): AaveError | null {\n const err = AAVE_ERROR_CODES[code];\n if (err) {\n return new AaveError(code, err.name, err.description);\n }\n return null;\n}\n","import { ethers } from 'ethers';\nimport {\n LegacyUiPoolDataProvider,\n UiPoolDataProvider,\n type ReservesDataHumanized,\n type ReservesHelperInput,\n type UserReservesHelperInput,\n type EModeData,\n type EmodeDataHumanized,\n type UserReserveDataHumanized,\n} from '@aave/contract-helpers';\n\n// @aave/contract-helpers provides two periphery contracts for fetching data from the blockchain:\n// `LegacyUiPoolDataProvider` and `UiPoolDataProvider`. Which one should be used is determined by the version that is actually deployed on a given chain.\n// Fortunately, for our use case we don't care about this complexity,\n// because their interfaces share just enough similarities for us to proceed.\n// `IUiPoolDataProvider` is an intersection of two interfaces.\n\n// Common functions between `LegacyUiPoolDataProvider` and `UiPoolDataProvider`\nexport interface IUiPoolDataProvider {\n getReservesHumanized: (args: ReservesHelperInput) => Promise<ReservesDataHumanized>;\n getUserReservesHumanized: (args: UserReservesHelperInput) => Promise<{\n userReserves: UserReserveDataHumanized[];\n userEmodeCategoryId: number;\n }>;\n getEModes: (args: ReservesHelperInput) => Promise<EModeData[]>;\n getEModesHumanized: (args: ReservesHelperInput) => Promise<EmodeDataHumanized[]>;\n}\n\nexport type IUiPoolDataProviderConstructor = new ({\n uiPoolDataProviderAddress,\n provider,\n chainId,\n}: {\n uiPoolDataProviderAddress: string;\n provider: ethers.providers.JsonRpcProvider;\n chainId: number;\n}) => IUiPoolDataProvider;\n\n// which class to use: LegacyUiPoolDataProvider or UiPoolDataProvider\n// When adding new chains, either compare the interfaces or bruteforce the correct option.\nexport const UI_POOL_DATA_PROVIDER_INTERFACE_PER_CHAIN: Record<\n number,\n IUiPoolDataProviderConstructor\n> = {\n 11155111: LegacyUiPoolDataProvider as IUiPoolDataProviderConstructor,\n 42161: UiPoolDataProvider as IUiPoolDataProviderConstructor,\n 1: UiPoolDataProvider as IUiPoolDataProviderConstructor,\n};\n\n// Use this function to get the correct pool data provider implementation.\nexport const getUiPoolDataProviderImpl = (chainId: number): IUiPoolDataProviderConstructor => {\n const res = UI_POOL_DATA_PROVIDER_INTERFACE_PER_CHAIN[chainId];\n if (!res) {\n throw new Error(\n 'UI_POOL_DATA_PROVIDER_INTERFACE_PER_CHAIN does not contain this chain ID. Edit providers/aave/dataProvider.ts.'\n );\n }\n return res;\n};\n","import { Chain } from './chain.js';\nimport { type AAVEMarket, getMarket } from './market.js';\nimport { UserSummary } from './userSummary.js';\nimport { populateTransaction } from './populateTransaction.js';\nimport { getUiPoolDataProviderImpl, type IUiPoolDataProvider } from './dataProvider.js';\nimport { ethers, type PopulatedTransaction, utils } from 'ethers';\nimport {\n Pool,\n PoolBundle,\n InterestRate,\n type ReservesDataHumanized,\n type ReserveDataHumanized,\n} from '@aave/contract-helpers';\nimport {\n type TransactionPlan,\n type BorrowTokensRequest,\n type BorrowTokensResponse,\n type RepayTokensRequest,\n type RepayTokensResponse,\n type SupplyTokensRequest,\n type SupplyTokensResponse,\n type WithdrawTokensRequest,\n type WithdrawTokensResponse,\n type GetWalletLendingPositionsResponse,\n TransactionTypes,\n type GetWalletLendingPositionsRequest,\n type Token,\n} from '../core/index.js';\n\nexport type EModeCategory = 'default' | 'stablecoins';\n\nexport interface PoolData {\n tokenAddress: string;\n poolAddress: string;\n variableBorrowRate: string;\n variableSupplyRate: string;\n ltv: string;\n availableLiquidity: string;\n reserveSize: string;\n}\n\nexport type AAVEAction = PopulatedTransaction[];\n\nexport interface AAVEAdapterParams {\n chainId: number;\n rpcUrl: string;\n wrappedNativeToken?: string; // e.g. WETH address for ETH\n}\n\n// AAVE's ETH placeholder address used for native ETH operations\nconst AAVE_ETH_PLACEHOLDER = '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE';\n\n/**\n * AAVEAdapter is the primary class wrapping Aave V3 interactions.\n */\nexport class AAVEAdapter {\n public chain: Chain;\n public market: AAVEMarket;\n\n constructor(params: AAVEAdapterParams) {\n this.chain = new Chain(params.chainId, params.rpcUrl);\n this.market = getMarket(this.chain.id);\n }\n\n /**\n * If the token is native, return AAVE's placeholder address instead of the ember address.\n * @param token - The token to normalize.\n * @returns The normalized token address.\n */\n public normalizeTokenAddress(token: Token): string {\n return token.isNative ? AAVE_ETH_PLACEHOLDER : token.tokenUid.address;\n }\n\n public async createSupplyTransaction(params: SupplyTokensRequest): Promise<SupplyTokensResponse> {\n const { supplyToken: token, amount, walletAddress } = params;\n const txs = await this.supply(\n this.normalizeTokenAddress(token),\n amount.toString(),\n walletAddress\n );\n return {\n transactions: txs.map(t => transactionPlanFromEthers(this.chain.id.toString(), t)),\n };\n }\n\n public async createWithdrawTransaction(\n params: WithdrawTokensRequest\n ): Promise<WithdrawTokensResponse> {\n const { tokenToWithdraw, amount, walletAddress } = params;\n\n // Find aToken he wants to withdraw from\n const alphaTokenAddress = (await this.getReserves()).reservesData.find(\n reserve => reserve.underlyingAsset === tokenToWithdraw.tokenUid.address\n )?.aTokenAddress;\n if (!alphaTokenAddress) {\n throw new Error('No position can generate the token to withdraw');\n }\n\n const txs = await this.withdraw(alphaTokenAddress, amount, walletAddress, walletAddress);\n return {\n transactions: txs.map(t => transactionPlanFromEthers(this.chain.id.toString(), t)),\n };\n }\n\n public async createBorrowTransaction(params: BorrowTokensRequest): Promise<BorrowTokensResponse> {\n const { borrowToken, amount, walletAddress } = params;\n const normalizedTokenAddress = this.normalizeTokenAddress(borrowToken);\n\n // Get pool data to fetch APR\n const poolData = await this.getPool(normalizedTokenAddress);\n const reservesResponse = await this.getReserves();\n\n let reserveLiquidationThreshold: string | null = null;\n for (const reserve of reservesResponse.reservesData) {\n const token = ethers.utils.getAddress(reserve.underlyingAsset);\n if (token === normalizedTokenAddress) {\n reserveLiquidationThreshold = reserve.reserveLiquidationThreshold;\n }\n }\n\n if (reserveLiquidationThreshold == null) {\n throw new Error('Reserve not found in AAVE pool for a given token');\n }\n\n // Create borrow transaction\n const txs = await this.borrow(normalizedTokenAddress, amount.toString(), walletAddress);\n\n return {\n liquidationThreshold: reserveLiquidationThreshold,\n currentBorrowApy: poolData.variableBorrowRate,\n transactions: txs.map(t => transactionPlanFromEthers(this.chain.id.toString(), t)),\n };\n }\n\n public async createRepayTransaction(params: RepayTokensRequest): Promise<RepayTokensResponse> {\n const { repayToken, amount, walletAddress: from } = params;\n\n const normalizedAsset = this.normalizeTokenAddress(repayToken);\n\n // Choose repayment method based on useATokens flag\n const txs = await this.repay(normalizedAsset, amount.toString(), from);\n\n return {\n transactions: txs.map(t => transactionPlanFromEthers(this.chain.id.toString(), t)),\n };\n }\n\n public async createRepayTransactionWithATokens(\n params: RepayTokensRequest\n ): Promise<RepayTokensResponse> {\n const { repayToken, amount, walletAddress: from } = params;\n\n const normalizedAsset = this.normalizeTokenAddress(repayToken);\n\n // Choose repayment method based on useATokens flag\n const txs = await this.repayWithATokens(normalizedAsset, amount.toString(), from);\n\n return {\n transactions: txs.map(t => transactionPlanFromEthers(this.chain.id.toString(), t)),\n };\n }\n\n // Private Methods\n private getProvider() {\n return this.chain.getProvider();\n }\n\n private getPoolBundle() {\n const provider = this.getProvider();\n return new PoolBundle(provider, {\n POOL: this.market.POOL,\n WETH_GATEWAY: this.market.WETH_GATEWAY,\n });\n }\n\n private async getTokenData(address: string) {\n let targetAddress = address;\n\n // If address is AAVE's native token placeholder, find the corresponding wrapped native token address\n if (address === AAVE_ETH_PLACEHOLDER) {\n const poolData = await this.getPool(address);\n targetAddress = poolData.tokenAddress; // This will be the wrapped native token address\n }\n\n return await this.getPoolBundle().erc20Service.getTokenData(targetAddress);\n }\n\n private getPoolDataProvider(): IUiPoolDataProvider {\n const provider = this.getProvider();\n const DataProviderImpl = getUiPoolDataProviderImpl(this.chain.id);\n return new DataProviderImpl({\n uiPoolDataProviderAddress: this.market.UI_POOL_DATA_PROVIDER,\n provider,\n chainId: this.chain.id,\n });\n }\n\n private getPoolContract() {\n const provider = this.getProvider();\n return new Pool(provider, {\n POOL: this.market.POOL,\n WETH_GATEWAY: this.market.WETH_GATEWAY,\n });\n }\n\n private async getPool(asset: string): Promise<PoolData> {\n const reservesResponse = await this.getReserves();\n\n let targetAsset = asset;\n\n // If asset is AAVE's native token placeholder, find the corresponding wrapped native token reserve\n if (asset === AAVE_ETH_PLACEHOLDER) {\n const configuredWrappedNativeToken = this.chain.wrappedNativeTokenAddress;\n\n if (!configuredWrappedNativeToken) {\n throw new Error(`No wrapped native token configured for chain ${this.chain.id}`);\n }\n\n const wrappedNativeTokenReserve = reservesResponse.reservesData.find(\n (r: ReserveDataHumanized) =>\n ethers.utils.getAddress(r.underlyingAsset) === configuredWrappedNativeToken\n );\n\n if (!wrappedNativeTokenReserve) {\n throw new Error(`Wrapped native token reserve not found for native token operations`);\n }\n\n targetAsset = wrappedNativeTokenReserve.underlyingAsset;\n }\n\n const reserve = reservesResponse.reservesData.find(\n (r: ReserveDataHumanized) =>\n ethers.utils.getAddress(r.underlyingAsset) === ethers.utils.getAddress(targetAsset)\n );\n\n if (!reserve) {\n throw new Error(`Asset ${asset} not found in reserves`);\n }\n\n return {\n tokenAddress: reserve.underlyingAsset,\n poolAddress: this.market.POOL,\n variableBorrowRate: reserve.variableBorrowRate,\n variableSupplyRate: reserve.liquidityRate,\n ltv: reserve.baseLTVasCollateral,\n availableLiquidity: reserve.availableLiquidity,\n reserveSize: reserve.availableLiquidity,\n };\n }\n\n public async getReserves(): Promise<ReservesDataHumanized> {\n const reserves = this.getPoolDataProvider().getReservesHumanized({\n lendingPoolAddressProvider: this.market.POOL_ADDRESSES_PROVIDER,\n });\n return reserves;\n }\n\n public async getUserSummary(\n params: GetWalletLendingPositionsRequest\n ): Promise<GetWalletLendingPositionsResponse> {\n const userSummaryResponse = await this._getUserSummary(params.walletAddress);\n const {\n totalLiquidityUSD,\n totalCollateralUSD,\n totalBorrowsUSD,\n netWorthUSD,\n availableBorrowsUSD,\n currentLoanToValue,\n currentLiquidationThreshold,\n healthFactor,\n userReservesData,\n } = userSummaryResponse.reserves;\n\n const userReservesFormatted = [];\n for (const {\n reserve,\n underlyingBalance,\n underlyingBalanceUSD,\n variableBorrows,\n variableBorrowsUSD,\n totalBorrows,\n totalBorrowsUSD,\n } of userReservesData) {\n const tokenData = await this.getTokenData(reserve.underlyingAsset);\n userReservesFormatted.push({\n token: {\n // TODO: ideally we should populate this object somewhere else,\n // returning only tokenUid in this adapter\n tokenUid: {\n address: reserve.underlyingAsset,\n chainId: this.chain.id.toString(),\n },\n isNative: false,\n name: tokenData.name,\n symbol: tokenData.symbol,\n decimals: tokenData.decimals,\n isVetted: true, // assuming aave only lets really good assets in\n },\n underlyingBalance,\n underlyingBalanceUsd: underlyingBalanceUSD,\n variableBorrows,\n variableBorrowsUsd: variableBorrowsUSD,\n totalBorrows,\n totalBorrowsUsd: totalBorrowsUSD,\n });\n }\n\n return {\n userReserves: userReservesFormatted,\n totalLiquidityUsd: totalLiquidityUSD,\n totalCollateralUsd: totalCollateralUSD,\n totalBorrowsUsd: totalBorrowsUSD,\n netWorthUsd: netWorthUSD,\n availableBorrowsUsd: availableBorrowsUSD,\n currentLoanToValue,\n currentLiquidationThreshold,\n healthFactor,\n };\n }\n\n private async _getUserSummary(userAddress: string): Promise<UserSummary> {\n const validatedUser = ethers.utils.getAddress(userAddress);\n const poolDataProvider = this.getPoolDataProvider();\n\n const reservesResponse = await this.getReserves();\n\n const userReservesResponse = await poolDataProvider.getUserReservesHumanized({\n lendingPoolAddressProvider: this.market.POOL_ADDRESSES_PROVIDER,\n user: validatedUser,\n });\n\n return new UserSummary(userReservesResponse, reservesResponse);\n }\n\n private async borrow(asset: string, amount: string, from: string): Promise<AAVEAction> {\n // validate\n ethers.utils.getAddress(asset);\n ethers.utils.getAddress(from);\n\n const bundle: PoolBundle = this.getPoolBundle();\n\n const tx = bundle.borrowTxBuilder.generateTxData({\n user: from,\n reserve: asset,\n amount,\n interestRateMode: InterestRate.Variable,\n });\n\n return [tx];\n }\n\n private async createApproval({\n asset,\n amount_raw,\n user,\n spender,\n }: {\n spender: string;\n user: string;\n asset: string;\n amount_raw: string;\n }): Promise<PopulatedTransaction | null> {\n const bundle = this.getPoolBundle();\n let approvalTx = null;\n const isApprovedEnough = await bundle.erc20Service.isApproved({\n user: user,\n token: asset,\n spender,\n amount: amount_raw,\n nativeDecimals: true,\n });\n\n if (!isApprovedEnough) {\n approvalTx = bundle.erc20Service.approveTxData({\n user,\n token: asset,\n spender,\n amount: amount_raw,\n });\n }\n\n return approvalTx;\n }\n\n private async supply(asset: string, amount: string, from: string): Promise<AAVEAction> {\n // validate\n ethers.utils.getAddress(asset);\n ethers.utils.getAddress(from);\n\n const bundle = this.getPoolBundle();\n\n const approvalTx = await this.createApproval({\n asset,\n amount_raw: amount,\n user: from,\n spender: bundle.poolAddress,\n });\n\n const tx = bundle.supplyTxBuilder.generateTxData({\n user: from,\n reserve: asset,\n amount,\n onBehalfOf: from,\n });\n\n return (approvalTx ? [approvalTx] : []).concat([tx]);\n }\n\n private async repay(asset: string, amount_formatted: string, from: string): Promise<AAVEAction> {\n // validate\n ethers.utils.getAddress(asset);\n ethers.utils.getAddress(from);\n\n const bundle: PoolBundle = this.getPoolBundle();\n\n const amount = utils\n .parseUnits(amount_formatted, (await this.getTokenData(asset)).decimals)\n .toString();\n\n const tx = bundle.repayTxBuilder.generateTxData({\n user: from,\n reserve: asset,\n amount: amount,\n interestRateMode: InterestRate.Variable,\n onBehalfOf: from,\n });\n\n const approvalTx = await this.createApproval({\n asset,\n amount_raw: amount,\n user: from,\n spender: bundle.poolAddress,\n });\n\n return (approvalTx ? [approvalTx] : []).concat([tx]);\n }\n\n private async repayWithATokens(\n asset: string,\n amount_formatted: string,\n from: string\n ): Promise<AAVEAction> {\n ethers.utils.getAddress(asset);\n ethers.utils.getAddress(from);\n const bundle = this.getPoolBundle();\n const tokenData = await this.getTokenData(asset);\n const amount = utils.parseUnits(amount_formatted, tokenData.decimals).toString();\n const tx = bundle.repayWithATokensTxBuilder.generateTxData({\n user: from,\n reserve: asset,\n amount,\n rateMode: InterestRate.Variable,\n });\n return [tx];\n }\n\n private async withdraw(\n asset: string,\n amount: bigint,\n to: string,\n from: string\n ): Promise<AAVEAction> {\n ethers.utils.getAddress(asset);\n ethers.utils.getAddress(to);\n ethers.utils.getAddress(from);\n\n const pool = this.getPoolContract();\n const txs = await pool.withdraw({\n user: from,\n reserve: asset,\n amount: amount.toString(),\n });\n\n if (txs.length !== 1) {\n throw new Error('AAVEInstance.withdraw: impossible happened');\n }\n\n // Null coercion is safe here because we checked txs.length above\n return [await populateTransaction(txs[0]!)];\n }\n}\n\nconst transactionPlanFromEthers = (\n chainId: string,\n tx: ethers.PopulatedTransaction\n): TransactionPlan => {\n return {\n type: TransactionTypes.EVM_TX,\n to: tx.to!,\n value: tx.value?.toString() || '0',\n data: tx.data!,\n chainId,\n };\n};\n","import { z } from 'zod';\nimport { ChainTypeSchema, TransactionTypeSchema } from './enums.js';\n\nexport const TokenIdentifierSchema = z.object({\n chainId: z.string(),\n address: z.string(),\n});\nexport type TokenIdentifier = z.infer<typeof TokenIdentifierSchema>;\n\nexport const TokenSchema = z.object({\n tokenUid: TokenIdentifierSchema,\n name: z.string(),\n symbol: z.string(),\n isNative: z.boolean(),\n decimals: z.number().int(),\n iconUri: z.string().nullish(),\n isVetted: z.boolean(),\n});\nexport type Token = z.infer<typeof TokenSchema>;\n\nexport const ChainSchema = z.object({\n chainId: z.string(),\n type: ChainTypeSchema,\n iconUri: z.string(),\n nativeToken: TokenSchema,\n httpRpcUrl: z.string(),\n name: z.string(),\n blockExplorerUrls: z.array(z.string()),\n});\nexport type Chain = z.infer<typeof ChainSchema>;\n\nexport const FeeBreakdownSchema = z.object({\n serviceFee: z.string(),\n slippageCost: z.string(),\n total: z.string(),\n feeDenomination: z.string(),\n});\nexport type FeeBreakdown = z.infer<typeof FeeBreakdownSchema>;\n\nexport const TransactionPlanSchema = z.object({\n type: TransactionTypeSchema,\n to: z.string(),\n data: z.string(),\n value: z.string(),\n chainId: z.string(),\n});\nexport type TransactionPlan = z.infer<typeof TransactionPlanSchema>;\n\nexport const TransactionPlanErrorSchema = z.object({\n code: z.string(),\n message: z.string(),\n details: z.record(z.string()),\n});\nexport type TransactionPlanError = z.infer<typeof TransactionPlanErrorSchema>;\n\nexport const ProviderTrackingInfoSchema = z.object({\n requestId: z.string(),\n providerName: z.string(),\n explorerUrl: z.string(),\n});\nexport type ProviderTrackingInfo = z.infer<typeof ProviderTrackingInfoSchema>;\n\nexport const SwapEstimationSchema = z.object({\n effectivePrice: z.string(),\n timeEstimate: z.string(),\n expiration: z.string(),\n});\nexport type SwapEstimation = z.infer<typeof SwapEstimationSchema>;\n\nexport const ProviderTrackingStatusSchema = z.object({\n requestId: z.string(),\n transactionId: z.string(),\n providerName: z.string(),\n explorerUrl: z.string(),\n status: z.string(),\n});\nexport type ProviderTrackingStatus = z.infer<typeof ProviderTrackingStatusSchema>;\n","import { z } from 'zod';\n\nexport const ChainTypeSchema = z.enum(['UNSPECIFIED', 'EVM', 'SOLANA', 'COSMOS']);\nexport type ChainType = z.infer<typeof ChainTypeSchema>;\n\n// TransactionType\nexport const TransactionTypes = {\n TRANSACTION_TYPE_UNSPECIFIED: 'TRANSACTION_TYPE_UNSPECIFIED' as const,\n EVM_TX: 'EVM_TX' as const,\n SOLANA_TX: 'SOLANA_TX' as const,\n} as const;\n\nexport const TransactionTypeSchema = z.enum(\n Object.values(TransactionTypes) as [string, ...string[]]\n);\nexport type TransactionType = keyof typeof TransactionTypes;\n","import { z } from 'zod';\nimport { FeeBreakdownSchema, TransactionPlanSchema, TokenSchema } from './core.js';\n\nexport const BorrowTokensRequestSchema = z.object({\n borrowToken: TokenSchema,\n amount: z.bigint(),\n walletAddress: z.string(),\n});\nexport type BorrowTokensRequest = z.infer<typeof BorrowTokensRequestSchema>;\n\nexport const BorrowTokensResponseSchema = z.object({\n currentBorrowApy: z.string(),\n liquidationThreshold: z.string(),\n feeBreakdown: FeeBreakdownSchema.optional(),\n transactions: z.array(TransactionPlanSchema),\n});\nexport type BorrowTokensResponse = z.infer<typeof BorrowTokensResponseSchema>;\n\nexport const RepayTokensRequestSchema = z.object({\n repayToken: TokenSchema,\n amount: z.bigint(),\n walletAddress: z.string(),\n});\nexport type RepayTokensRequest = z.infer<typeof RepayTokensRequestSchema>;\n\nexport const RepayTokensResponseSchema = z.object({\n feeBreakdown: FeeBreakdownSchema.optional(),\n transactions: z.array(TransactionPlanSchema),\n});\nexport type RepayTokensResponse = z.infer<typeof RepayTokensResponseSchema>;\n\nexport const SupplyTokensRequestSchema = z.object({\n supplyToken: TokenSchema,\n amount: z.bigint(),\n walletAddress: z.string(),\n});\nexport type SupplyTokensRequest = z.infer<typeof SupplyTokensRequestSchema>;\n\nexport const SupplyTokensResponseSchema = z.object({\n feeBreakdown: FeeBreakdownSchema.optional(),\n transactions: z.array(TransactionPlanSchema),\n});\nexport type SupplyTokensResponse = z.infer<typeof SupplyTokensResponseSchema>;\n\nexport const WithdrawTokensRequestSchema = z.object({\n tokenToWithdraw: TokenSchema,\n amount: z.bigint(),\n walletAddress: z.string(),\n});\nexport type WithdrawTokensRequest = z.infer<typeof WithdrawTokensRequestSchema>;\n\nexport const WithdrawTokensResponseSchema = z.object({\n feeBreakdown: FeeBreakdownSchema.optional(),\n transactions: z.array(TransactionPlanSchema),\n});\nexport type WithdrawTokensResponse = z.infer<typeof WithdrawTokensResponseSchema>;\n\nexport const TokenPositionSchema = z.object({\n underlyingToken: TokenSchema,\n borrowRate: z.string(),\n supplyBalance: z.string(),\n borrowBalance: z.string(),\n valueUsd: z.string(),\n});\nexport type TokenPosition = z.infer<typeof TokenPositionSchema>;\n\nexport const GetWalletLendingPositionsRequestSchema = z.object({\n walletAddress: z.string(),\n});\nexport type GetWalletLendingPositionsRequest = z.infer<\n typeof GetWalletLendingPositionsRequestSchema\n>;\n\nexport const LendTokenDetailSchema = z.object({\n token: TokenSchema,\n underlyingBalance: z.string(),\n underlyingBalanceUsd: z.string(),\n variableBorrows: z.string(),\n variableBorrowsUsd: z.string(),\n totalBorrows: z.string(),\n totalBorrowsUsd: z.string(),\n});\nexport type LendTokenDetail = z.infer<typeof LendTokenDetailSchema>;\n\nexport const GetWalletLendingPositionsResponseSchema = z.object({\n userReserves: z.array(LendTokenDetailSchema),\n totalLiquidityUsd: z.string(),\n totalCollateralUsd: z.string(),\n totalBorrowsUsd: z.string(),\n netWorthUsd: z.string(),\n availableBorrowsUsd: z.string(),\n currentLoanToValue: z.string(),\n currentLiquidationThreshold: z.string(),\n healthFactor: z.string(),\n});\nexport type GetWalletLendingPositionsResponse = z.infer<\n typeof GetWalletLendingPositionsResponseSchema\n>;\n","import { z } from 'zod';\nimport { TokenIdentifierSchema, TransactionPlanSchema } from './core.js';\n\nexport const LimitedLiquidityProvisionRangeSchema = z.object({\n minPrice: z.string(),\n maxPrice: z.string(),\n});\nexport type LimitedLiquidityProvisionRange = z.infer<typeof LimitedLiquidityProvisionRangeSchema>;\n\nexport const LiquidityProvisionRangeSchema = z.discriminatedUnion('type', [\n z.object({\n type: z.literal('full'),\n }),\n z.object({\n type: z.literal('limited'),\n minPrice: z.string(),\n maxPrice: z.string(),\n }),\n]);\nexport type LiquidityProvisionRange = z.infer<typeof LiquidityProvisionRangeSchema>;\n\nexport const LiquidityPositionRangeSchema = z.object({\n fromPrice: z.string(),\n toPrice: z.string(),\n});\nexport type LiquidityPositionRange = z.infer<typeof LiquidityPositionRangeSchema>;\n\nexport const LiquidityPositionSchema = z.object({\n tokenId: z.string(),\n poolAddress: z.string(),\n operator: z.string(),\n token0: TokenIdentifierSchema,\n token1: TokenIdentifierSchema,\n tokensOwed0: z.string(),\n tokensOwed1: z.string(),\n amount0: z.string(),\n amount1: z.string(),\n symbol0: z.string(),\n symbol1: z.string(),\n price: z.string(),\n providerId: z.string(),\n positionRange: LiquidityPositionRangeSchema.optional(),\n});\nexport type LiquidityPosition = z.infer<typeof LiquidityPositionSchema>;\n\nexport const LiquidityPoolSchema = z.object({\n token0: TokenIdentifierSchema,\n token1: TokenIdentifierSchema,\n symbol0: z.string(),\n symbol1: z.string(),\n price: z.string(),\n providerId: z.string(),\n});\nexport type LiquidityPool = z.infer<typeof LiquidityPoolSchema>;\n\nexport const SupplyLiquidityRequestSchema = z.object({\n token0: TokenIdentifierSchema,\n token1: TokenIdentifierSchema,\n amount0: z.bigint(),\n amount1: z.bigint(),\n range: LiquidityProvisionRangeSchema,\n walletAddress: z.string(),\n});\nexport type SupplyLiquidityRequest = z.infer<typeof SupplyLiquidityRequestSchema>;\n\nexport const SupplyLiquidityResponseSchema = z.object({\n transactions: z.array(TransactionPlanSchema),\n chainId: z.string(),\n});\nexport type SupplyLiquidityResponse = z.infer<typeof SupplyLiquidityResponseSchema>;\n\nexport const WithdrawLiquidityRequestSchema = z.object({\n tokenId: z.string(),\n walletAddress: z.string(),\n});\nexport type WithdrawLiquidityRequest = z.infer<typeof WithdrawLiquidityRequestSchema>;\n\nexport const WithdrawLiquidityResponseSchema = z.object({\n transactions: z.array(TransactionPlanSchema),\n chainId: z.string(),\n});\nexport type WithdrawLiquidityResponse = z.infer<typeof WithdrawLiquidityResponseSchema>;\n\nexport const GetWalletLiquidityPositionsRequestSchema = z.object({\n walletAddress: z.string(),\n});\nexport type GetWalletLiquidityPositionsRequest = z.infer<\n typeof GetWalletLiquidityPositionsRequestSchema\n>;\n\nexport const GetWalletLiquidityPositionsResponseSchema = z.object({\n positions: z.array(LiquidityPositionSchema),\n});\nexport type GetWalletLiquidityPositionsResponse = z.infer<\n typeof GetWalletLiquidityPositionsResponseSchema\n>;\n\nexport const GetLiquidityPoolsResponseSchema = z.object({\n liquidityPools: z.array(LiquidityPoolSchema),\n});\nexport type GetLiquidityPoolsResponse = z.infer<typeof GetLiquidityPoolsResponseSchema>;\n","import { z } from 'zod';\nimport { TransactionPlanSchema, TokenIdentifierSchema } from './core.js';\nimport { DecreasePositionSwapType, OrderType } from '@gmx-io/sdk/types/orders';\n\n// Enums\nexport const DecreasePositionSwapTypeSchema = z.nativeEnum(DecreasePositionSwapType);\n\nexport const PositionSideSchema = z.union([z.literal('long'), z.literal('short')]);\n\nexport type PositionSide = z.infer<typeof PositionSideSchema>;\n\n// API Schemas and types\nexport const PositionSchema = z.object({\n chainId: z.string(),\n key: z.string(),\n contractKey: z.string(),\n account: z.string(),\n marketAddress: z.string(),\n collateralTokenAddress: z.string(),\n sizeInUsd: z.string(),\n sizeInTokens: z.string(),\n collateralAmount: z.string(),\n pendingBorrowingFeesUsd: z.string(),\n increasedAtTime: z.string(),\n decreasedAtTime: z.string(),\n positionSide: PositionSideSchema,\n isLong: z.boolean(),\n fundingFeeAmount: z.string(),\n claimableLongTokenAmount: z.string(),\n claimableShortTokenAmount: z.string(),\n isOpening: z.boolean().optional(),\n pnl: z.string(),\n positionFeeAmount: z.string(),\n traderDiscountAmount: z.string(),\n uiFeeAmount: z.string(),\n data: z.string().optional(),\n});\n\nexport type PerpetualsPosition = z.infer<typeof PositionSchema>;\n\nexport const PositionsDataSchema = z.array(PositionSchema);\n\n// Order Schema\nexport const OrderSchema = z.object({\n chainId: z.string(),\n key: z.string(),\n account: z.string(),\n callbackContract: z.string(),\n initialCollateralTokenAddress: z.string(),\n marketAddress: z.string(),\n decreasePositionSwapType: DecreasePositionSwapTypeSchema,\n receiver: z.string(),\n swapPath: z.array(z.string()),\n contractAcceptablePrice: z.string(),\n contractTriggerPrice: z.string(),\n callbackGasLimit: z.string(),\n executionFee: z.string(),\n initialCollateralDeltaAmount: z.string(),\n minOutputAmount: z.string(),\n sizeDeltaUsd: z.string(),\n updatedAtTime: z.string(),\n isFrozen: z.boolean(),\n positionSide: PositionSideSchema,\n orderType: z.nativeEnum(OrderType),\n shouldUnwrapNativeToken: z.boolean(),\n autoCancel: z.boolean(),\n data: z.string().optional(),\n uiFeeReceiver: z.string(),\n validFromTime: z.string(),\n title: z.string().optional(),\n});\n\nexport type PerpetualsOrder = z.infer<typeof OrderSchema>;\n\nexport const OrdersDataSchema = z.array(OrderSchema);\n\n// Definition for plugin with mapped entities already in place\nexport const CreatePerpetualsPositionRequestSchema = z.object({\n amount: z.bigint(),\n walletAddress: z.string(),\n chainId: z.string(),\n marketAddress: z.string(),\n payTokenAddress: z.string(),\n collateralTokenAddress: z.string(),\n referralCode: z.string().optional(),\n limitPrice: z.string().optional(),\n leverage: z.string(),\n});\n\nexport type CreatePerpetualsPositionRequest = z.infer<typeof CreatePerpetualsPositionRequestSchema>;\n\nexport const CreatePerpetualsPositionResponseSchema = z.object({\n transactions: z.array(TransactionPlanSchema),\n});\nexport type CreatePerpetualsPositionResponse = z.infer<\n typeof CreatePerpetualsPositionResponseSchema\n>;\n\nexport const GetPerpetualsMarketsPositionsRequestSchema = z.object({\n walletAddress: z.string().describe(\"User's wallet address\"),\n});\n\nexport type GetPerpetualsMarketsPositionsRequest = z.infer<\n typeof GetPerpetualsMarketsPositionsRequestSchema\n>;\n\nexport const GetPerpetualsMarketsPositionsResponseSchema = z.object({\n positions: PositionsDataSchema,\n});\n\nexport type GetPerpetualsMarketsPositionsResponse = z.infer<\n typeof GetPerpetualsMarketsPositionsResponseSchema\n>;\n\nexport const GetPerpetualsMarketsOrdersRequestSchema = z.object({\n walletAddress: z.string().describe(\"User's wallet address\"),\n});\n\nexport type GetPerpetualsMarketsOrdersRequest = z.infer<\n typeof GetPerpetualsMarketsOrdersRequestSchema\n>;\n\nexport const GetPerpetualsMarketsOrdersResponseSchema = z.object({\n orders: OrdersDataSchema,\n});\n\nexport type GetPerpetualsMarketsOrdersResponse = z.infer<\n typeof GetPerpetualsMarketsOrdersResponseSchema\n>;\n\nexport const ClosePerpetualsOrdersRequestSchema = z.object({\n walletAddress: z.string().describe(\"User's wallet address\"),\n key: z.string(),\n});\n\nexport type ClosePerpetualsOrdersRequest = z.infer<typeof ClosePerpetualsOrdersRequestSchema>;\n\nexport const ClosePerpetualsOrdersResponseSchema = z.object({\n transactions: z.array(TransactionPlanSchema),\n});\n\nexport type ClosePerpetualsOrdersResponse = z.infer<typeof ClosePerpetualsOrdersResponseSchema>;\n\nexport const GetPerpetualsMarketsRequestSchema = z.object({\n chainIds: z.array(z.string()),\n});\n\nexport type GetPerpetualsMarketsRequest = z.infer<typeof GetPerpetualsMarketsRequestSchema>;\n\nexport const PerpetualMarketSchema = z.object({\n marketToken: TokenIdentifierSchema,\n indexToken: TokenIdentifierSchema,\n longToken: TokenIdentifierSchema,\n shortToken: TokenIdentifierSchema,\n longFundingFee: z.string(),\n shortFundingFee: z.string(),\n longBorrowingFee: z.string(),\n shortBorrowingFee: z.string(),\n chainId: z.string(),\n name: z.string(),\n});\n\nexport type PerpetualMarket = z.infer<typeof PerpetualMarketSchema>;\n\nexport const GetPerpetualsMarketsResponseSchema = z.object({\n markets: z.array(PerpetualMarketSchema),\n});\n\nexport type GetPerpetualsMarketsResponse = z.infer<typeof GetPerpetualsMarketsResponseSchema>;\n","import { z } from 'zod';\nimport {\n FeeBreakdownSchema,\n TransactionPlanSchema,\n SwapEstimationSchema,\n ProviderTrackingInfoSchema,\n TokenSchema,\n} from './core.js';\n\nexport const SwapTokensRequestSchema = z.object({\n fromToken: TokenSchema,\n toToken: TokenSchema,\n amount: z.bigint(),\n limitPrice: z.string().optional(),\n slippageTolerance: z.string().optional(),\n expiration: z.string().optional(),\n recipient: z.string(),\n});\nexport type SwapTokensRequest = z.infer<typeof SwapTokensRequestSchema>;\n\nexport const SwapTokensResponseSchema = z.object({\n fromToken: TokenSchema,\n toToken: TokenSchema,\n exactFromAmount: z.string(),\n displayFromAmount: z.string(),\n exactToAmount: z.string(),\n displayToAmount: z.string(),\n transactions: z.array(TransactionPlanSchema),\n feeBreakdown: FeeBreakdownSchema.optional(),\n estimation: SwapEstimationSchema.optional(),\n providerTracking: ProviderTrackingInfoSchema.optional(),\n});\nexport type SwapTokensResponse = z.infer<typeof SwapTokensResponseSchema>;\n","import type { ActionDefinition, EmberPlugin, LendingActions } from '../core/index.js';\nimport { AAVEAdapter, type AAVEAdapterParams } from './adapter.js';\nimport type { ChainConfig } from '../chainConfig.js';\nimport type { PublicEmberPluginRegistry } from '../registry.js';\n\n/**\n * Get the AAVE Ember plugin.\n * @param params - Configuration parameters for the AAVEAdapter, including chainId and rpcUrl.\n * @returns The AAVE Ember plugin.\n */\nexport async function getAaveEmberPlugin(\n params: AAVEAdapterParams\n): Promise<EmberPlugin<'lending'>> {\n const adapter = new AAVEAdapter(params);\n\n return {\n id: `AAVE_CHAIN_${params.chainId}`,\n type: 'lending',\n name: `AAVE lending for ${params.chainId}`,\n description: 'Aave V3 lending protocol',\n website: 'https://aave.com',\n x: 'https://x.com/aave',\n actions: await getAaveActions(adapter),\n queries: {\n getPositions: adapter.getUserSummary.bind(adapter),\n },\n };\n}\n\n/**\n * Get the AAVE actions for the lending protocol.\n * @param adapter - An instance of AAVEAdapter to interact with the AAVE protocol.\n * @returns An array of action definitions for the AAVE lending protocol.\n */\nexport async function getAaveActions(\n adapter: AAVEAdapter\n): Promise<ActionDefinition<LendingActions>[]> {\n const reservesResponse = await adapter.getReserves();\n\n const underlyingAssets: string[] = reservesResponse.reservesData.map(\n reserve => reserve.underlyingAsset\n );\n const aTokens: string[] = reservesResponse.reservesData.map(reserve => reserve.aTokenAddress);\n const borrowableAssets = reservesResponse.reservesData\n .filter(reserve => reserve.borrowingEnabled)\n .map(reserve => reserve.underlyingAsset);\n\n return [\n // Supply any of the underlying assets to get aTokens\n {\n type: 'lending-supply',\n name: `AAVE lending pools in chain ${adapter.chain.id}`,\n inputTokens: async () =>\n Promise.resolve([\n {\n chainId: adapter.chain.id.toString(),\n tokens: underlyingAssets,\n },\n ]),\n outputTokens: async () =>\n Promise.resolve([\n {\n chainId: adapter.chain.id.toString(),\n tokens: aTokens,\n },\n ]),\n callback: adapter.createSupplyTransaction.bind(adapter),\n },\n\n // Borrow any of the borrowable assets if you have some alpha tokens as collateral\n {\n type: 'lending-borrow',\n name: `AAVE borrow in chain ${adapter.chain.id}`,\n inputTokens: async () =>\n Promise.resolve([\n {\n chainId: adapter.chain.id.toString(),\n tokens: aTokens,\n },\n ]),\n outputTokens: async () =>\n Promise.resolve([\n {\n chainId: adapter.chain.id.toString(),\n tokens: borrowableAssets,\n },\n ]),\n callback: adapter.createBorrowTransaction.bind(adapter),\n },\n\n // Repay your borrow with the underlying asset\n {\n type: 'lending-repay',\n name: `AAVE repay in chain ${adapter.chain.id}`,\n inputTokens: async () =>\n Promise.resolve([\n {\n chainId: adapter.chain.id.toString(),\n tokens: borrowableAssets,\n },\n ]),\n // Empty output tokens as this doesn't generate any token\n outputTokens: async () => Promise.resolve([]),\n callback: adapter.createRepayTransaction.bind(adapter),\n },\n\n // Repay your borrow with aTokens\n {\n type: 'lending-repay',\n name: `AAVE repay with aTokens in chain ${adapter.chain.id}`,\n inputTokens: async () =>\n Promise.resolve([\n {\n chainId: adapter.chain.id.toString(),\n tokens: aTokens,\n },\n ]),\n // Empty output tokens as this doesn't generate any token\n outputTokens: async () => Promise.resolve([]),\n callback: adapter.createRepayTransactionWithATokens.bind(adapter),\n },\n\n // Withdraw from your aTokens to get the underlying asset back\n {\n type: 'lending-withdraw',\n name: `AAVE withdraw in chain ${adapter.chain.id}`,\n inputTokens: async () =>\n Promise.resolve([\n {\n chainId: adapter.chain.id.toString(),\n tokens: aTokens,\n },\n ]),\n outputTokens: async () =>\n Promise.resolve([\n {\n chainId: adapter.chain.id.toString(),\n tokens: underlyingAssets,\n },\n ]),\n callback: adapter.createWithdrawTransaction.bind(adapter),\n },\n ];\n}\n\n/**\n * Register the AAVE plugin for the specified chain configuration.\n * @param chainConfig - The chain configuration to check for AAVE support.\n * @param registry - The public Ember plugin registry to register the plugin with.\n * @returns A promise that resolves when the plugin is registered.\n */\nexport function registerAave(chainConfig: ChainConfig, registry: PublicEmberPluginRegistry) {\n const supportedChains = [42161];\n if (!supportedChains.includes(chainConfig.chainId)) {\n return;\n }\n\n registry.registerDeferredPlugin(\n getAaveEmberPlugin({\n chainId: chainConfig.chainId,\n rpcUrl: chainConfig.rpcUrl,\n wrappedNativeToken: chainConfig.wrappedNativeToken,\n })\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;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AM,GAAG,SAAS;AAAA,UACnC,QAAQ;AAAA,QACV;AAAA,MACF,CAAC;AAAA,MACH,UAAU,QAAQ,0BAA0B,KAAK,OAAO;AAAA,IAC1D;AAAA,EACF;AACF;AAQO,SAAS,aAAa,aAA0B,UAAqC;AAC1F,QAAM,kBAAkB,CAAC,KAAK;AAC9B,MAAI,CAAC,gBAAgB,SAAS,YAAY,OAAO,GAAG;AAClD;AAAA,EACF;AAEA,WAAS;AAAA,IACP,mBAAmB;AAAA,MACjB,SAAS,YAAY;AAAA,MACrB,QAAQ,YAAY;AAAA,MACpB,oBAAoB,YAAY;AAAA,IAClC,CAAC;AAAA,EACH;AACF;;;Af5JO,SAAS,yBAAyB,cAA6B;AACpE,QAAM,WAAW,IAAI,0BAA0B;AAG/C,aAAW,eAAe,cAAc;AAEtC,iBAAa,aAAa,QAAQ;AAAA,EACpC;AAEA,SAAO;AACT;","names":["import_ethers","import_ethers","import_ethers","import_contract_helpers","import_zod","import_zod","import_zod","import_zod","import_zod","totalBorrowsUSD"]}
1
+ {"version":3,"sources":["../src/index.ts","../src/registry.ts","../src/aave-lending-plugin/chain.ts","../src/aave-lending-plugin/market.ts","../src/aave-lending-plugin/userSummary.ts","../src/aave-lending-plugin/populateTransaction.ts","../src/aave-lending-plugin/errors.ts","../src/aave-lending-plugin/dataProvider.ts","../src/aave-lending-plugin/adapter.ts","../src/core/schemas/core.ts","../src/core/schemas/enums.ts","../src/core/schemas/lending.ts","../src/core/schemas/liquidity.ts","../src/core/schemas/perpetuals.ts","../src/core/schemas/swap.ts","../src/aave-lending-plugin/index.ts"],"sourcesContent":["import type { ChainConfig } from './chainConfig.js';\nimport { PublicEmberPluginRegistry } from './registry.js';\nimport { registerAave } from './aave-lending-plugin/index.js';\n\n/**\n * Initialize the public Ember plugin registry.\n * @returns The initialized public Ember plugin registry with registered plugins.\n */\nexport function initializePublicRegistry(chainConfigs: ChainConfig[]) {\n const registry = new PublicEmberPluginRegistry();\n\n // Register any plugin in here\n for (const chainConfig of chainConfigs) {\n // Create aave plugins for each chain config\n registerAave(chainConfig, registry);\n }\n\n return registry;\n}\n\nexport { type ChainConfig, PublicEmberPluginRegistry };\nexport * from './core/index.js';\n","import type { EmberPlugin, PluginType } from './core/index.js';\n\n/**\n * Registry for public Ember plugins.\n */\nexport class PublicEmberPluginRegistry {\n private plugins: EmberPlugin<PluginType>[] = [];\n private deferredPlugins: Promise<EmberPlugin<PluginType>>[] = [];\n\n /**\n * Register a new Ember plugin.\n * @param plugin The plugin to register.\n */\n public registerPlugin(plugin: EmberPlugin<PluginType>) {\n this.plugins.push(plugin);\n }\n\n /**\n * Register a new deferred Ember plugin.\n * @param pluginPromise The promise resolving to the plugin to register.\n */\n public registerDeferredPlugin(pluginPromise: Promise<EmberPlugin<PluginType>>) {\n this.deferredPlugins.push(pluginPromise);\n }\n\n /**\n * Iterator for the registered Ember plugins.\n */\n public async *getPlugins(): AsyncIterable<EmberPlugin<PluginType>> {\n yield* this.plugins;\n\n for (const pluginPromise of this.deferredPlugins) {\n const plugin = await pluginPromise;\n\n // Register the plugin now that it is resolved\n this.registerPlugin(plugin);\n\n yield plugin;\n }\n\n this.deferredPlugins = [];\n }\n\n public get emberPlugins(): EmberPlugin<PluginType>[] {\n return this.plugins;\n }\n}\n","import { ethers } from 'ethers';\n\n/**\n * Represents a blockchain network configuration used to create JSON-RPC providers and\n * hold basic chain-specific metadata.\n *\n * The Chain class encapsulates:\n * - a numeric chain identifier (id),\n * - an RPC URL to connect to the chain (rpcUrl),\n * - an optional wrapped native token address (wrappedNativeTokenAddress).\n *\n * @param id - The numeric identifier for the chain (e.g., 1 for Ethereum mainnet).\n * @param rpcUrl - The JSON-RPC endpoint URL used to create providers for this chain.\n * @param wrappedNativeTokenAddress - Optional address of the chain's wrapped native token (if applicable).\n */\nexport class Chain {\n constructor(\n public id: number,\n public rpcUrl: string,\n public wrappedNativeTokenAddress?: string\n ) {}\n\n /**\n * Create and return an ethers.js JsonRpcProvider configured with this chain's RPC URL.\n *\n * This method constructs a new ethers.providers.JsonRpcProvider each time it is called.\n * Consumers may cache the provider if they intend to reuse it to avoid allocating multiple instances.\n *\n * @returns An instance of ethers.providers.JsonRpcProvider configured with the chain's rpcUrl.\n */\n public getProvider(): ethers.providers.JsonRpcProvider {\n return new ethers.providers.JsonRpcProvider(this.rpcUrl);\n }\n}\n","import * as markets from '@bgd-labs/aave-address-book';\n\n// AAVE market selection provided by aave-address-book is not very typescript-friendly:\n// we have to trust that the structure of their modules is the same, which\n// seems to be the case.\n\n// An interface that only contains fields of market definitions that we actually use\nexport type AAVEMarket = {\n AAVE_PROTOCOL_DATA_PROVIDER: string;\n POOL: string;\n POOL_ADDRESSES_PROVIDER: string;\n UI_INCENTIVE_DATA_PROVIDER: string;\n UI_POOL_DATA_PROVIDER: string;\n WALLET_BALANCE_PROVIDER: string;\n WETH_GATEWAY: string;\n};\n\nconst marketMap: Record<number, keyof typeof markets> = {\n 1: 'AaveV3Ethereum',\n 11155111: 'AaveV3Sepolia',\n 42161: 'AaveV3Arbitrum',\n 421614: 'AaveV3ArbitrumSepolia',\n 8453: 'AaveV3Base',\n 137: 'AaveV3Polygon',\n 10: 'AaveV3Optimism',\n};\n\nexport const getMarket = (chainId: number): AAVEMarket => {\n const marketKey = marketMap[chainId];\n if (!marketKey) {\n throw new Error(\n `AAVE: no market found for chain ID ${chainId}: modify providers/aave/market.ts`\n );\n }\n\n const market = markets[marketKey] as unknown as AAVEMarket;\n if (!market) {\n throw new Error(`No such market: ${marketKey}`);\n }\n\n return market;\n};\n","import type { ReservesDataHumanized, UserReserveDataHumanized } from '@aave/contract-helpers';\nimport {\n formatReserves,\n formatUserSummary,\n type FormatUserSummaryResponse,\n type FormatReserveUSDResponse,\n} from '@aave/math-utils';\n\nfunction formatNumeric(value: string): string {\n const num = parseFloat(value);\n if (Number.isInteger(num)) return num.toString();\n return parseFloat(num.toFixed(2)).toString();\n}\n\nexport class UserSummary {\n public reserves: FormatUserSummaryResponse<FormatReserveUSDResponse>;\n\n /**\n * @param userReservesResponse - The response from getUserReservesHumanized.\n * @param reservesResponse - The response from getReservesHumanized.\n */\n constructor(\n userReservesResponse: {\n userReserves: UserReserveDataHumanized[];\n userEmodeCategoryId: number;\n },\n reservesResponse: ReservesDataHumanized\n ) {\n const currentTimestamp = Date.now() / 1000;\n\n const formattedReserves = formatReserves({\n reserves: reservesResponse.reservesData,\n currentTimestamp,\n marketReferenceCurrencyDecimals:\n reservesResponse.baseCurrencyData.marketReferenceCurrencyDecimals,\n marketReferencePriceInUsd:\n reservesResponse.baseCurrencyData.marketReferenceCurrencyPriceInUsd,\n });\n\n this.reserves = formatUserSummary({\n currentTimestamp,\n marketReferencePriceInUsd:\n reservesResponse.baseCurrencyData.marketReferenceCurrencyPriceInUsd,\n marketReferenceCurrencyDecimals:\n reservesResponse.baseCurrencyData.marketReferenceCurrencyDecimals,\n userReserves: userReservesResponse.userReserves,\n formattedReserves,\n userEmodeCategoryId: userReservesResponse.userEmodeCategoryId,\n });\n }\n\n public toHumanReadable(): string {\n let output = 'User Positions:\\n';\n output += `Total Liquidity (USD): ${formatNumeric(this.reserves.totalLiquidityUSD)}\\n`;\n output += `Total Collateral (USD): ${formatNumeric(this.reserves.totalCollateralUSD)}\\n`;\n output += `Total Borrows (USD): ${formatNumeric(this.reserves.totalBorrowsUSD)}\\n`;\n output += `Net Worth (USD): ${formatNumeric(this.reserves.netWorthUSD)}\\n`;\n output += `Health Factor: ${formatNumeric(this.reserves.healthFactor)}\\n\\n`;\n output += 'Deposits:\\n';\n for (const entry of this.reserves.userReservesData) {\n if (parseFloat(entry.scaledATokenBalance) > 0) {\n const underlying = entry.underlyingBalance;\n const underlyingUSD = entry.underlyingBalanceUSD\n ? formatNumeric(entry.underlyingBalanceUSD)\n : 'N/A';\n output += `- ${entry.reserve.symbol}: ${underlying} (USD: ${underlyingUSD})\\n`;\n }\n }\n output += '\\nLoans:\\n';\n for (const entry of this.reserves.userReservesData) {\n const borrow = entry.totalBorrows || '0';\n if (parseFloat(borrow) > 0) {\n const totalBorrows = entry.totalBorrows;\n const totalBorrowsUSD = entry.totalBorrowsUSD\n ? formatNumeric(entry.totalBorrowsUSD)\n : 'N/A';\n output += `- ${entry.reserve.symbol}: ${totalBorrows} (USD: ${totalBorrowsUSD})\\n`;\n }\n }\n return output;\n }\n}\n","import type { EthereumTransactionTypeExtended } from '@aave/contract-helpers';\nimport { type PopulatedTransaction, ethers } from 'ethers';\nimport { getAaveError } from './errors.js';\n\nexport async function populateTransaction(\n tx: EthereumTransactionTypeExtended\n): Promise<PopulatedTransaction> {\n let txData = null;\n try {\n txData = await tx.tx();\n /* eslint-disable @typescript-eslint/no-explicit-any */\n } catch (e: any) {\n /* eslint-enable @typescript-eslint/no-explicit-any */\n\n // error reason looks like 'execution reverted: revert: 32', with the aave\n // domain error code at the very end\n const errorCode = (e.reason || '').split(' ').pop();\n // If we end up passing garbage to getAaveError, it does not matter - it will return null\n const aaveError = getAaveError(errorCode);\n if (aaveError !== null) {\n throw aaveError;\n } else {\n // we can hope that the LLM will provide an analysis of the error on the fly\n throw e;\n }\n }\n return {\n value: ethers.BigNumber.from(txData.value || 0),\n from: txData.from,\n to: txData.to,\n data: txData.data,\n };\n}\n","// based on https://github.com/aave-dao/aave-v3-origin/blob/083bd38a137b42b5df04e22ad4c9e72454365d0d/src/contracts/protocol/libraries/helpers/Errors.sol\n\nclass AaveError extends Error {\n public description: string;\n public override message: string;\n\n constructor(code: string, name: string, description: string) {\n const message = name + ` (${code}): ` + description;\n super(message);\n this.name = 'AaveError';\n this.description = description;\n this.message = message;\n\n // Ensures proper prototype chain in transpiled JavaScript\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\ntype AaveErrorData = {\n name: string;\n description: string;\n};\n\nexport const AAVE_ERROR_CODES: Record<string, AaveErrorData> = {\n '1': {\n name: 'CALLER_NOT_POOL_ADMIN',\n description: 'The caller of the function is not a pool admin',\n },\n '2': {\n name: 'CALLER_NOT_EMERGENCY_ADMIN',\n description: 'The caller of the function is not an emergency admin',\n },\n '3': {\n name: 'CALLER_NOT_POOL_OR_EMERGENCY_ADMIN',\n description: 'The caller of the function is not a pool or emergency admin',\n },\n '4': {\n name: 'CALLER_NOT_RISK_OR_POOL_ADMIN',\n description: 'The caller of the function is not a risk or pool admin',\n },\n '5': {\n name: 'CALLER_NOT_ASSET_LISTING_OR_POOL_ADMIN',\n description: 'The caller of the function is not an asset listing or pool admin',\n },\n '6': {\n name: 'CALLER_NOT_BRIDGE',\n description: 'The caller of the function is not a bridge',\n },\n '7': {\n name: 'ADDRESSES_PROVIDER_NOT_REGISTERED',\n description: 'Pool addresses provider is not registered',\n },\n '8': {\n name: 'INVALID_ADDRESSES_PROVIDER_ID',\n description: 'Invalid id for the pool addresses provider',\n },\n '9': { name: 'NOT_CONTRACT', description: 'Address is not a contract' },\n '10': {\n name: 'CALLER_NOT_POOL_CONFIGURATOR',\n description: 'The caller of the function is not the pool configurator',\n },\n '11': {\n name: 'CALLER_NOT_ATOKEN',\n description: 'The caller of the function is not an AToken',\n },\n '12': {\n name: 'INVALID_ADDRESSES_PROVIDER',\n description: 'The address of the pool addresses provider is invalid',\n },\n '13': {\n name: 'INVALID_FLASHLOAN_EXECUTOR_RETURN',\n description: 'Invalid return value of the flashloan executor function',\n },\n '14': {\n name: 'RESERVE_ALREADY_ADDED',\n description: 'Reserve has already been added to reserve list',\n },\n '15': {\n name: 'NO_MORE_RESERVES_ALLOWED',\n description: 'Maximum amount of reserves in the pool reached',\n },\n '16': {\n name: 'EMODE_CATEGORY_RESERVED',\n description: 'Zero eMode category is reserved for volatile heterogeneous assets',\n },\n '17': {\n name: 'INVALID_EMODE_CATEGORY_ASSIGNMENT',\n description: 'Invalid eMode category assignment to asset',\n },\n '18': {\n name: 'RESERVE_LIQUIDITY_NOT_ZERO',\n description: 'The liquidity of the reserve needs to be 0',\n },\n '19': {\n name: 'FLASHLOAN_PREMIUM_INVALID',\n description: 'Invalid flashloan premium',\n },\n '20': {\n name: 'INVALID_RESERVE_PARAMS',\n description: 'Invalid risk parameters for the reserve',\n },\n '21': {\n name: 'INVALID_EMODE_CATEGORY_PARAMS',\n description: 'Invalid risk parameters for the eMode category',\n },\n '22': {\n name: 'BRIDGE_PROTOCOL_FEE_INVALID',\n description: 'Invalid bridge protocol fee',\n },\n '23': {\n name: 'CALLER_MUST_BE_POOL',\n description: 'The caller of this function must be a pool',\n },\n '24': { name: 'INVALID_MINT_AMOUNT', description: 'Invalid amount to mint' },\n '25': { name: 'INVALID_BURN_AMOUNT', description: 'Invalid amount to burn' },\n '26': {\n name: 'INVALID_AMOUNT',\n description: 'Amount must be greater than 0',\n },\n '27': {\n name: 'RESERVE_INACTIVE',\n description: 'Action requires an active reserve',\n },\n '28': {\n name: 'RESERVE_FROZEN',\n description: 'Action cannot be performed because the reserve is frozen',\n },\n '29': {\n name: 'RESERVE_PAUSED',\n description: 'Action cannot be performed because the reserve is paused',\n },\n '30': {\n name: 'BORROWING_NOT_ENABLED',\n description: 'Borrowing is not enabled',\n },\n '32': {\n name: 'NOT_ENOUGH_AVAILABLE_USER_BALANCE',\n description: 'User cannot withdraw more than the available balance',\n },\n '33': {\n name: 'INVALID_INTEREST_RATE_MODE_SELECTED',\n description: 'Invalid interest rate mode selected',\n },\n '34': {\n name: 'COLLATERAL_BALANCE_IS_ZERO',\n description: 'The collateral balance is 0',\n },\n '35': {\n name: 'HEALTH_FACTOR_LOWER_THAN_LIQUIDATION_THRESHOLD',\n description: 'Health factor is lesser than the liquidation threshold',\n },\n '36': {\n name: 'COLLATERAL_CANNOT_COVER_NEW_BORROW',\n description: 'There is not enough collateral to cover a new borrow',\n },\n '37': {\n name: 'COLLATERAL_SAME_AS_BORROWING_CURRENCY',\n description: 'Collateral is (mostly) the same currency that is being borrowed',\n },\n '39': {\n name: 'NO_DEBT_OF_SELECTED_TYPE',\n description: 'For repayment of a specific type of debt, the user needs to have debt that type',\n },\n '40': {\n name: 'NO_EXPLICIT_AMOUNT_TO_REPAY_ON_BEHALF',\n description: 'To repay on behalf of a user an explicit amount to repay is needed',\n },\n '42': {\n name: 'NO_OUTSTANDING_VARIABLE_DEBT',\n description: 'User does not have outstanding variable rate debt on this reserve',\n },\n '43': {\n name: 'UNDERLYING_BALANCE_ZERO',\n description: 'The underlying balance needs to be greater than 0',\n },\n '44': {\n name: 'INTEREST_RATE_REBALANCE_CONDITIONS_NOT_MET',\n description: 'Interest rate rebalance conditions were not met',\n },\n '45': {\n name: 'HEALTH_FACTOR_NOT_BELOW_THRESHOLD',\n description: 'Health factor is not below the threshold',\n },\n '46': {\n name: 'COLLATERAL_CANNOT_BE_LIQUIDATED',\n description: 'The collateral chosen cannot be liquidated',\n },\n '47': {\n name: 'SPECIFIED_CURRENCY_NOT_BORROWED_BY_USER',\n description: 'User did not borrow the specified currency',\n },\n '49': {\n name: 'INCONSISTENT_FLASHLOAN_PARAMS',\n description: 'Inconsistent flashloan parameters',\n },\n '50': { name: 'BORROW_CAP_EXCEEDED', description: 'Borrow cap is exceeded' },\n '51': { name: 'SUPPLY_CAP_EXCEEDED', description: 'Supply cap is exceeded' },\n '52': {\n name: 'UNBACKED_MINT_CAP_EXCEEDED',\n description: 'Unbacked mint cap is exceeded',\n },\n '53': {\n name: 'DEBT_CEILING_EXCEEDED',\n description: 'Debt ceiling is exceeded',\n },\n '54': {\n name: 'UNDERLYING_CLAIMABLE_RIGHTS_NOT_ZERO',\n description: 'Claimable rights over underlying not zero (aToken supply or accruedToTreasury)',\n },\n '56': {\n name: 'VARIABLE_DEBT_SUPPLY_NOT_ZERO',\n description: 'Variable debt supply is not zero',\n },\n '57': { name: 'LTV_VALIDATION_FAILED', description: 'Ltv validation failed' },\n '58': {\n name: 'INCONSISTENT_EMODE_CATEGORY',\n description: 'Inconsistent eMode category',\n },\n '59': {\n name: 'PRICE_ORACLE_SENTINEL_CHECK_FAILED',\n description: 'Price oracle sentinel validation failed',\n },\n '60': {\n name: 'ASSET_NOT_BORROWABLE_IN_ISOLATION',\n description: 'Asset is not borrowable in isolation mode',\n },\n '61': {\n name: 'RESERVE_ALREADY_INITIALIZED',\n description: 'Reserve has already been initialized',\n },\n '62': {\n name: 'USER_IN_ISOLATION_MODE_OR_LTV_ZERO',\n description: 'User is in isolation mode or ltv is zero',\n },\n '63': {\n name: 'INVALID_LTV',\n description: 'Invalid ltv parameter for the reserve',\n },\n '64': {\n name: 'INVALID_LIQ_THRESHOLD',\n description: 'Invalid liquidity threshold parameter for the reserve',\n },\n '65': {\n name: 'INVALID_LIQ_BONUS',\n description: 'Invalid liquidity bonus parameter for the reserve',\n },\n '66': {\n name: 'INVALID_DECIMALS',\n description: 'Invalid decimals parameter of the underlying asset of the reserve',\n },\n '67': {\n name: 'INVALID_RESERVE_FACTOR',\n description: 'Invalid reserve factor parameter for the reserve',\n },\n '68': {\n name: 'INVALID_BORROW_CAP',\n description: 'Invalid borrow cap for the reserve',\n },\n '69': {\n name: 'INVALID_SUPPLY_CAP',\n description: 'Invalid supply cap for the reserve',\n },\n '70': {\n name: 'INVALID_LIQUIDATION_PROTOCOL_FEE',\n description: 'Invalid liquidation protocol fee for the reserve',\n },\n '71': {\n name: 'INVALID_EMODE_CATEGORY',\n description: 'Invalid eMode category for the reserve',\n },\n '72': {\n name: 'INVALID_UNBACKED_MINT_CAP',\n description: 'Invalid unbacked mint cap for the reserve',\n },\n '73': {\n name: 'INVALID_DEBT_CEILING',\n description: 'Invalid debt ceiling for the reserve',\n },\n '74': { name: 'INVALID_RESERVE_INDEX', description: 'Invalid reserve index' },\n '75': {\n name: 'ACL_ADMIN_CANNOT_BE_ZERO',\n description: 'ACL admin cannot be set to the zero address',\n },\n '76': {\n name: 'INCONSISTENT_PARAMS_LENGTH',\n description: 'Array parameters that should be equal length are not',\n },\n '77': {\n name: 'ZERO_ADDRESS_NOT_VALID',\n description: 'Zero address not valid',\n },\n '78': { name: 'INVALID_EXPIRATION', description: 'Invalid expiration' },\n '79': { name: 'INVALID_SIGNATURE', description: 'Invalid signature' },\n '80': {\n name: 'OPERATION_NOT_SUPPORTED',\n description: 'Operation not supported',\n },\n '81': {\n name: 'DEBT_CEILING_NOT_ZERO',\n description: 'Debt ceiling is not zero',\n },\n '82': { name: 'ASSET_NOT_LISTED', description: 'Asset is not listed' },\n '83': {\n name: 'INVALID_OPTIMAL_USAGE_RATIO',\n description: 'Invalid optimal usage ratio',\n },\n '85': {\n name: 'UNDERLYING_CANNOT_BE_RESCUED',\n description: 'The underlying asset cannot be rescued',\n },\n '86': {\n name: 'ADDRESSES_PROVIDER_ALREADY_ADDED',\n description: 'Reserve has already been added to reserve list',\n },\n '87': {\n name: 'POOL_ADDRESSES_DO_NOT_MATCH',\n description:\n 'The token implementation pool address and the pool address provided by the initializing pool do not match',\n },\n '89': {\n name: 'SILOED_BORROWING_VIOLATION',\n description: 'User is trying to borrow multiple assets including a siloed one',\n },\n '90': {\n name: 'RESERVE_DEBT_NOT_ZERO',\n description: 'The total debt of the reserve needs to be 0',\n },\n '91': {\n name: 'FLASHLOAN_DISABLED',\n description: 'FlashLoaning for this asset is disabled',\n },\n '92': {\n name: 'INVALID_MAX_RATE',\n description: 'The expect maximum borrow rate is invalid',\n },\n '93': {\n name: 'WITHDRAW_TO_ATOKEN',\n description: 'Withdrawing to the aToken is not allowed',\n },\n '94': {\n name: 'SUPPLY_TO_ATOKEN',\n description: 'Supplying to the aToken is not allowed',\n },\n '95': {\n name: 'SLOPE_2_MUST_BE_GTE_SLOPE_1',\n description: 'Variable interest rate slope 2 can not be lower than slope 1',\n },\n '96': {\n name: 'CALLER_NOT_RISK_OR_POOL_OR_EMERGENCY_ADMIN',\n description: 'The caller of the function is not a risk, pool or emergency admin',\n },\n '97': {\n name: 'LIQUIDATION_GRACE_SENTINEL_CHECK_FAILED',\n description: 'Liquidation grace sentinel validation failed',\n },\n '98': {\n name: 'INVALID_GRACE_PERIOD',\n description: 'Grace period above a valid range',\n },\n '99': {\n name: 'INVALID_FREEZE_STATE',\n description: 'Reserve is already in the passed freeze state',\n },\n '100': {\n name: 'NOT_BORROWABLE_IN_EMODE',\n description: 'Asset not borrowable in eMode',\n },\n};\n\nexport function getAaveError(code: string): AaveError | null {\n const err = AAVE_ERROR_CODES[code];\n if (err) {\n return new AaveError(code, err.name, err.description);\n }\n return null;\n}\n","import { ethers } from 'ethers';\nimport {\n LegacyUiPoolDataProvider,\n UiPoolDataProvider,\n type ReservesDataHumanized,\n type ReservesHelperInput,\n type UserReservesHelperInput,\n type EModeData,\n type EmodeDataHumanized,\n type UserReserveDataHumanized,\n} from '@aave/contract-helpers';\n\n// @aave/contract-helpers provides two periphery contracts for fetching data from the blockchain:\n// `LegacyUiPoolDataProvider` and `UiPoolDataProvider`. Which one should be used is determined by the version that is actually deployed on a given chain.\n// Fortunately, for our use case we don't care about this complexity,\n// because their interfaces share just enough similarities for us to proceed.\n// `IUiPoolDataProvider` is an intersection of two interfaces.\n\n// Common functions between `LegacyUiPoolDataProvider` and `UiPoolDataProvider`\nexport interface IUiPoolDataProvider {\n getReservesHumanized: (args: ReservesHelperInput) => Promise<ReservesDataHumanized>;\n getUserReservesHumanized: (args: UserReservesHelperInput) => Promise<{\n userReserves: UserReserveDataHumanized[];\n userEmodeCategoryId: number;\n }>;\n getEModes: (args: ReservesHelperInput) => Promise<EModeData[]>;\n getEModesHumanized: (args: ReservesHelperInput) => Promise<EmodeDataHumanized[]>;\n}\n\nexport type IUiPoolDataProviderConstructor = new ({\n uiPoolDataProviderAddress,\n provider,\n chainId,\n}: {\n uiPoolDataProviderAddress: string;\n provider: ethers.providers.JsonRpcProvider;\n chainId: number;\n}) => IUiPoolDataProvider;\n\n// which class to use: LegacyUiPoolDataProvider or UiPoolDataProvider\n// When adding new chains, either compare the interfaces or bruteforce the correct option.\nexport const UI_POOL_DATA_PROVIDER_INTERFACE_PER_CHAIN: Record<\n number,\n IUiPoolDataProviderConstructor\n> = {\n 11155111: LegacyUiPoolDataProvider as IUiPoolDataProviderConstructor,\n 42161: UiPoolDataProvider as IUiPoolDataProviderConstructor,\n 1: UiPoolDataProvider as IUiPoolDataProviderConstructor,\n};\n\n// Use this function to get the correct pool data provider implementation.\nexport const getUiPoolDataProviderImpl = (chainId: number): IUiPoolDataProviderConstructor => {\n const res = UI_POOL_DATA_PROVIDER_INTERFACE_PER_CHAIN[chainId];\n if (!res) {\n throw new Error(\n 'UI_POOL_DATA_PROVIDER_INTERFACE_PER_CHAIN does not contain this chain ID. Edit providers/aave/dataProvider.ts.'\n );\n }\n return res;\n};\n","import { Chain } from './chain.js';\nimport { type AAVEMarket, getMarket } from './market.js';\nimport { UserSummary } from './userSummary.js';\nimport { populateTransaction } from './populateTransaction.js';\nimport { getUiPoolDataProviderImpl, type IUiPoolDataProvider } from './dataProvider.js';\nimport { ethers, type PopulatedTransaction, utils } from 'ethers';\nimport {\n Pool,\n PoolBundle,\n InterestRate,\n type ReservesDataHumanized,\n type ReserveDataHumanized,\n} from '@aave/contract-helpers';\nimport {\n type TransactionPlan,\n type BorrowTokensRequest,\n type BorrowTokensResponse,\n type RepayTokensRequest,\n type RepayTokensResponse,\n type SupplyTokensRequest,\n type SupplyTokensResponse,\n type WithdrawTokensRequest,\n type WithdrawTokensResponse,\n type GetWalletLendingPositionsResponse,\n TransactionTypes,\n type GetWalletLendingPositionsRequest,\n type Token,\n} from '../core/index.js';\nimport { ur } from 'zod/v4/locales';\n\nexport type EModeCategory = 'default' | 'stablecoins';\n\nexport interface PoolData {\n tokenAddress: string;\n poolAddress: string;\n variableBorrowRate: string;\n variableSupplyRate: string;\n ltv: string;\n availableLiquidity: string;\n reserveSize: string;\n}\n\nexport type AAVEAction = PopulatedTransaction[];\n\nexport interface AAVEAdapterParams {\n chainId: number;\n rpcUrl: string;\n wrappedNativeToken?: string; // e.g. WETH address for ETH\n}\n\n// AAVE's ETH placeholder address used for native ETH operations\nconst AAVE_ETH_PLACEHOLDER = '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE';\n\n/**\n * AAVEAdapter is the primary class wrapping Aave V3 interactions.\n */\nexport class AAVEAdapter {\n public chain: Chain;\n public market: AAVEMarket;\n\n constructor(params: AAVEAdapterParams) {\n this.chain = new Chain(params.chainId, params.rpcUrl);\n this.market = getMarket(this.chain.id);\n }\n\n /**\n * If the token is native, return AAVE's placeholder address instead of the ember address.\n * @param token - The token to normalize.\n * @returns The normalized token address.\n */\n public normalizeTokenAddress(token: Token): string {\n return token.isNative ? AAVE_ETH_PLACEHOLDER : token.tokenUid.address;\n }\n\n public async createSupplyTransaction(params: SupplyTokensRequest): Promise<SupplyTokensResponse> {\n const { supplyToken: token, amount, walletAddress } = params;\n const txs = await this.supply(\n this.normalizeTokenAddress(token),\n amount.toString(),\n walletAddress\n );\n return {\n transactions: txs.map(t => transactionPlanFromEthers(this.chain.id.toString(), t)),\n };\n }\n\n public async createWithdrawTransaction(\n params: WithdrawTokensRequest\n ): Promise<WithdrawTokensResponse> {\n const { tokenToWithdraw, amount, walletAddress } = params;\n\n // Find aToken he wants to withdraw from\n const alphaTokenAddress = (await this.getReserves()).reservesData.find(\n reserve => reserve.underlyingAsset === tokenToWithdraw.tokenUid.address\n )?.aTokenAddress;\n if (!alphaTokenAddress) {\n throw new Error('No position can generate the token to withdraw');\n }\n\n const txs = await this.withdraw(alphaTokenAddress, amount, walletAddress, walletAddress);\n return {\n transactions: txs.map(t => transactionPlanFromEthers(this.chain.id.toString(), t)),\n };\n }\n\n public async createBorrowTransaction(params: BorrowTokensRequest): Promise<BorrowTokensResponse> {\n const { borrowToken, amount, walletAddress } = params;\n const normalizedTokenAddress = this.normalizeTokenAddress(borrowToken);\n\n // Get pool data to fetch APR\n const poolData = await this.getPool(normalizedTokenAddress);\n const reservesResponse = await this.getReserves();\n\n let reserveLiquidationThreshold: string | null = null;\n for (const reserve of reservesResponse.reservesData) {\n const token = ethers.utils.getAddress(reserve.underlyingAsset);\n if (token === normalizedTokenAddress) {\n reserveLiquidationThreshold = reserve.reserveLiquidationThreshold;\n }\n }\n\n if (reserveLiquidationThreshold == null) {\n throw new Error('Reserve not found in AAVE pool for a given token');\n }\n\n // Create borrow transaction\n const txs = await this.borrow(normalizedTokenAddress, amount.toString(), walletAddress);\n\n return {\n liquidationThreshold: reserveLiquidationThreshold,\n currentBorrowApy: poolData.variableBorrowRate,\n transactions: txs.map(t => transactionPlanFromEthers(this.chain.id.toString(), t)),\n };\n }\n\n public async createRepayTransaction(params: RepayTokensRequest): Promise<RepayTokensResponse> {\n const { repayToken, amount, walletAddress: from } = params;\n\n const normalizedAsset = this.normalizeTokenAddress(repayToken);\n\n // Choose repayment method based on useATokens flag\n const txs = await this.repay(normalizedAsset, amount.toString(), from);\n\n return {\n transactions: txs.map(t => transactionPlanFromEthers(this.chain.id.toString(), t)),\n };\n }\n\n public async createRepayTransactionWithATokens(\n params: RepayTokensRequest\n ): Promise<RepayTokensResponse> {\n const { repayToken, amount, walletAddress: from } = params;\n\n const normalizedAsset = this.normalizeTokenAddress(repayToken);\n\n // Choose repayment method based on useATokens flag\n const txs = await this.repayWithATokens(normalizedAsset, amount.toString(), from);\n\n return {\n transactions: txs.map(t => transactionPlanFromEthers(this.chain.id.toString(), t)),\n };\n }\n\n // Private Methods\n private getProvider() {\n return this.chain.getProvider();\n }\n\n private getPoolBundle() {\n const provider = this.getProvider();\n return new PoolBundle(provider, {\n POOL: this.market.POOL,\n WETH_GATEWAY: this.market.WETH_GATEWAY,\n });\n }\n\n private async getTokenData(address: string) {\n let targetAddress = address;\n\n // If address is AAVE's native token placeholder, find the corresponding wrapped native token address\n if (address === AAVE_ETH_PLACEHOLDER) {\n const poolData = await this.getPool(address);\n targetAddress = poolData.tokenAddress; // This will be the wrapped native token address\n }\n\n return await this.getPoolBundle().erc20Service.getTokenData(targetAddress);\n }\n\n private getPoolDataProvider(): IUiPoolDataProvider {\n const provider = this.getProvider();\n const DataProviderImpl = getUiPoolDataProviderImpl(this.chain.id);\n return new DataProviderImpl({\n uiPoolDataProviderAddress: this.market.UI_POOL_DATA_PROVIDER,\n provider,\n chainId: this.chain.id,\n });\n }\n\n private getPoolContract() {\n const provider = this.getProvider();\n return new Pool(provider, {\n POOL: this.market.POOL,\n WETH_GATEWAY: this.market.WETH_GATEWAY,\n });\n }\n\n private async getPool(asset: string): Promise<PoolData> {\n const reservesResponse = await this.getReserves();\n\n let targetAsset = asset;\n\n // If asset is AAVE's native token placeholder, find the corresponding wrapped native token reserve\n if (asset === AAVE_ETH_PLACEHOLDER) {\n const configuredWrappedNativeToken = this.chain.wrappedNativeTokenAddress;\n\n if (!configuredWrappedNativeToken) {\n throw new Error(`No wrapped native token configured for chain ${this.chain.id}`);\n }\n\n const wrappedNativeTokenReserve = reservesResponse.reservesData.find(\n (r: ReserveDataHumanized) =>\n ethers.utils.getAddress(r.underlyingAsset) === configuredWrappedNativeToken\n );\n\n if (!wrappedNativeTokenReserve) {\n throw new Error(`Wrapped native token reserve not found for native token operations`);\n }\n\n targetAsset = wrappedNativeTokenReserve.underlyingAsset;\n }\n\n const reserve = reservesResponse.reservesData.find(\n (r: ReserveDataHumanized) =>\n ethers.utils.getAddress(r.underlyingAsset) === ethers.utils.getAddress(targetAsset)\n );\n\n if (!reserve) {\n throw new Error(`Asset ${asset} not found in reserves`);\n }\n\n return {\n tokenAddress: reserve.underlyingAsset,\n poolAddress: this.market.POOL,\n variableBorrowRate: reserve.variableBorrowRate,\n variableSupplyRate: reserve.liquidityRate,\n ltv: reserve.baseLTVasCollateral,\n availableLiquidity: reserve.availableLiquidity,\n reserveSize: reserve.availableLiquidity,\n };\n }\n\n public async getReserves(): Promise<ReservesDataHumanized> {\n const reserves = this.getPoolDataProvider().getReservesHumanized({\n lendingPoolAddressProvider: this.market.POOL_ADDRESSES_PROVIDER,\n });\n return reserves;\n }\n\n public async getUserSummary(\n params: GetWalletLendingPositionsRequest\n ): Promise<GetWalletLendingPositionsResponse> {\n const userSummaryResponse = await this._getUserSummary(params.walletAddress);\n const {\n totalLiquidityUSD,\n totalCollateralUSD,\n totalBorrowsUSD,\n netWorthUSD,\n availableBorrowsUSD,\n currentLoanToValue,\n currentLiquidationThreshold,\n healthFactor,\n userReservesData,\n } = userSummaryResponse.reserves;\n\n const userReservesFormatted = [];\n for (const {\n reserve,\n underlyingBalance,\n underlyingBalanceUSD,\n variableBorrows,\n variableBorrowsUSD,\n totalBorrows,\n totalBorrowsUSD,\n } of userReservesData.filter(ur => ur.underlyingBalanceUSD !== '0')) {\n const tokenData = await this.getTokenData(reserve.underlyingAsset);\n userReservesFormatted.push({\n token: {\n // TODO: ideally we should populate this object somewhere else,\n // returning only tokenUid in this adapter\n tokenUid: {\n address: reserve.underlyingAsset,\n chainId: this.chain.id.toString(),\n },\n isNative: false,\n name: tokenData.name,\n symbol: tokenData.symbol,\n decimals: tokenData.decimals,\n isVetted: true, // assuming aave only lets really good assets in\n },\n underlyingBalance,\n underlyingBalanceUsd: underlyingBalanceUSD,\n variableBorrows,\n variableBorrowsUsd: variableBorrowsUSD,\n totalBorrows,\n totalBorrowsUsd: totalBorrowsUSD,\n });\n }\n\n return {\n userReserves: userReservesFormatted,\n totalLiquidityUsd: totalLiquidityUSD,\n totalCollateralUsd: totalCollateralUSD,\n totalBorrowsUsd: totalBorrowsUSD,\n netWorthUsd: netWorthUSD,\n availableBorrowsUsd: availableBorrowsUSD,\n currentLoanToValue,\n currentLiquidationThreshold,\n healthFactor,\n };\n }\n\n private async _getUserSummary(userAddress: string): Promise<UserSummary> {\n const validatedUser = ethers.utils.getAddress(userAddress);\n const poolDataProvider = this.getPoolDataProvider();\n\n const reservesResponse = await this.getReserves();\n\n const userReservesResponse = await poolDataProvider.getUserReservesHumanized({\n lendingPoolAddressProvider: this.market.POOL_ADDRESSES_PROVIDER,\n user: validatedUser,\n });\n\n return new UserSummary(userReservesResponse, reservesResponse);\n }\n\n private async borrow(asset: string, amount: string, from: string): Promise<AAVEAction> {\n // validate\n ethers.utils.getAddress(asset);\n ethers.utils.getAddress(from);\n\n const bundle: PoolBundle = this.getPoolBundle();\n\n const tx = bundle.borrowTxBuilder.generateTxData({\n user: from,\n reserve: asset,\n amount,\n interestRateMode: InterestRate.Variable,\n });\n\n return [tx];\n }\n\n private async createApproval({\n asset,\n amount_raw,\n user,\n spender,\n }: {\n spender: string;\n user: string;\n asset: string;\n amount_raw: string;\n }): Promise<PopulatedTransaction | null> {\n const bundle = this.getPoolBundle();\n let approvalTx = null;\n const isApprovedEnough = await bundle.erc20Service.isApproved({\n user: user,\n token: asset,\n spender,\n amount: amount_raw,\n nativeDecimals: true,\n });\n\n if (!isApprovedEnough) {\n approvalTx = bundle.erc20Service.approveTxData({\n user,\n token: asset,\n spender,\n amount: amount_raw,\n });\n }\n\n return approvalTx;\n }\n\n private async supply(asset: string, amount: string, from: string): Promise<AAVEAction> {\n // validate\n ethers.utils.getAddress(asset);\n ethers.utils.getAddress(from);\n\n const bundle = this.getPoolBundle();\n\n const approvalTx = await this.createApproval({\n asset,\n amount_raw: amount,\n user: from,\n spender: bundle.poolAddress,\n });\n\n const tx = bundle.supplyTxBuilder.generateTxData({\n user: from,\n reserve: asset,\n amount,\n onBehalfOf: from,\n });\n\n return (approvalTx ? [approvalTx] : []).concat([tx]);\n }\n\n private async repay(asset: string, amount_formatted: string, from: string): Promise<AAVEAction> {\n // validate\n ethers.utils.getAddress(asset);\n ethers.utils.getAddress(from);\n\n const bundle: PoolBundle = this.getPoolBundle();\n\n const amount = utils\n .parseUnits(amount_formatted, (await this.getTokenData(asset)).decimals)\n .toString();\n\n const tx = bundle.repayTxBuilder.generateTxData({\n user: from,\n reserve: asset,\n amount: amount,\n interestRateMode: InterestRate.Variable,\n onBehalfOf: from,\n });\n\n const approvalTx = await this.createApproval({\n asset,\n amount_raw: amount,\n user: from,\n spender: bundle.poolAddress,\n });\n\n return (approvalTx ? [approvalTx] : []).concat([tx]);\n }\n\n private async repayWithATokens(\n asset: string,\n amount_formatted: string,\n from: string\n ): Promise<AAVEAction> {\n ethers.utils.getAddress(asset);\n ethers.utils.getAddress(from);\n const bundle = this.getPoolBundle();\n const tokenData = await this.getTokenData(asset);\n const amount = utils.parseUnits(amount_formatted, tokenData.decimals).toString();\n const tx = bundle.repayWithATokensTxBuilder.generateTxData({\n user: from,\n reserve: asset,\n amount,\n rateMode: InterestRate.Variable,\n });\n return [tx];\n }\n\n private async withdraw(\n asset: string,\n amount: bigint,\n to: string,\n from: string\n ): Promise<AAVEAction> {\n ethers.utils.getAddress(asset);\n ethers.utils.getAddress(to);\n ethers.utils.getAddress(from);\n\n const pool = this.getPoolContract();\n const txs = await pool.withdraw({\n user: from,\n reserve: asset,\n amount: amount.toString(),\n });\n\n if (txs.length !== 1) {\n throw new Error('AAVEInstance.withdraw: impossible happened');\n }\n\n // Null coercion is safe here because we checked txs.length above\n return [await populateTransaction(txs[0]!)];\n }\n}\n\nconst transactionPlanFromEthers = (\n chainId: string,\n tx: ethers.PopulatedTransaction\n): TransactionPlan => {\n return {\n type: TransactionTypes.EVM_TX,\n to: tx.to!,\n value: tx.value?.toString() || '0',\n data: tx.data!,\n chainId,\n };\n};\n","import { z } from 'zod';\nimport { ChainTypeSchema, TransactionTypeSchema } from './enums.js';\n\nexport const TokenIdentifierSchema = z.object({\n chainId: z.string(),\n address: z.string(),\n});\nexport type TokenIdentifier = z.infer<typeof TokenIdentifierSchema>;\n\nexport const TokenSchema = z.object({\n tokenUid: TokenIdentifierSchema,\n name: z.string(),\n symbol: z.string(),\n isNative: z.boolean(),\n decimals: z.number().int(),\n iconUri: z.string().nullish(),\n isVetted: z.boolean(),\n});\nexport type Token = z.infer<typeof TokenSchema>;\n\nexport const ChainSchema = z.object({\n chainId: z.string(),\n type: ChainTypeSchema,\n iconUri: z.string(),\n nativeToken: TokenSchema,\n httpRpcUrl: z.string(),\n name: z.string(),\n blockExplorerUrls: z.array(z.string()),\n});\nexport type Chain = z.infer<typeof ChainSchema>;\n\nexport const FeeBreakdownSchema = z.object({\n serviceFee: z.string(),\n slippageCost: z.string(),\n total: z.string(),\n feeDenomination: z.string(),\n});\nexport type FeeBreakdown = z.infer<typeof FeeBreakdownSchema>;\n\nexport const TransactionPlanSchema = z.object({\n type: TransactionTypeSchema,\n to: z.string(),\n data: z.string(),\n value: z.string(),\n chainId: z.string(),\n});\nexport type TransactionPlan = z.infer<typeof TransactionPlanSchema>;\n\nexport const TransactionPlanErrorSchema = z.object({\n code: z.string(),\n message: z.string(),\n details: z.record(z.string()),\n});\nexport type TransactionPlanError = z.infer<typeof TransactionPlanErrorSchema>;\n\nexport const ProviderTrackingInfoSchema = z.object({\n requestId: z.string(),\n providerName: z.string(),\n explorerUrl: z.string(),\n});\nexport type ProviderTrackingInfo = z.infer<typeof ProviderTrackingInfoSchema>;\n\nexport const SwapEstimationSchema = z.object({\n effectivePrice: z.string(),\n timeEstimate: z.string(),\n expiration: z.string(),\n});\nexport type SwapEstimation = z.infer<typeof SwapEstimationSchema>;\n\nexport const ProviderTrackingStatusSchema = z.object({\n requestId: z.string(),\n transactionId: z.string(),\n providerName: z.string(),\n explorerUrl: z.string(),\n status: z.string(),\n});\nexport type ProviderTrackingStatus = z.infer<typeof ProviderTrackingStatusSchema>;\n","import { z } from 'zod';\n\nexport const ChainTypeSchema = z.enum(['UNSPECIFIED', 'EVM', 'SOLANA', 'COSMOS']);\nexport type ChainType = z.infer<typeof ChainTypeSchema>;\n\n// TransactionType\nexport const TransactionTypes = {\n TRANSACTION_TYPE_UNSPECIFIED: 'TRANSACTION_TYPE_UNSPECIFIED' as const,\n EVM_TX: 'EVM_TX' as const,\n SOLANA_TX: 'SOLANA_TX' as const,\n} as const;\n\nexport const TransactionTypeSchema = z.enum(\n Object.values(TransactionTypes) as [string, ...string[]]\n);\nexport type TransactionType = keyof typeof TransactionTypes;\n","import { z } from 'zod';\nimport { FeeBreakdownSchema, TransactionPlanSchema, TokenSchema } from './core.js';\n\nexport const BorrowTokensRequestSchema = z.object({\n borrowToken: TokenSchema,\n amount: z.bigint(),\n walletAddress: z.string(),\n});\nexport type BorrowTokensRequest = z.infer<typeof BorrowTokensRequestSchema>;\n\nexport const BorrowTokensResponseSchema = z.object({\n currentBorrowApy: z.string(),\n liquidationThreshold: z.string(),\n feeBreakdown: FeeBreakdownSchema.optional(),\n transactions: z.array(TransactionPlanSchema),\n});\nexport type BorrowTokensResponse = z.infer<typeof BorrowTokensResponseSchema>;\n\nexport const RepayTokensRequestSchema = z.object({\n repayToken: TokenSchema,\n amount: z.bigint(),\n walletAddress: z.string(),\n});\nexport type RepayTokensRequest = z.infer<typeof RepayTokensRequestSchema>;\n\nexport const RepayTokensResponseSchema = z.object({\n feeBreakdown: FeeBreakdownSchema.optional(),\n transactions: z.array(TransactionPlanSchema),\n});\nexport type RepayTokensResponse = z.infer<typeof RepayTokensResponseSchema>;\n\nexport const SupplyTokensRequestSchema = z.object({\n supplyToken: TokenSchema,\n amount: z.bigint(),\n walletAddress: z.string(),\n});\nexport type SupplyTokensRequest = z.infer<typeof SupplyTokensRequestSchema>;\n\nexport const SupplyTokensResponseSchema = z.object({\n feeBreakdown: FeeBreakdownSchema.optional(),\n transactions: z.array(TransactionPlanSchema),\n});\nexport type SupplyTokensResponse = z.infer<typeof SupplyTokensResponseSchema>;\n\nexport const WithdrawTokensRequestSchema = z.object({\n tokenToWithdraw: TokenSchema,\n amount: z.bigint(),\n walletAddress: z.string(),\n});\nexport type WithdrawTokensRequest = z.infer<typeof WithdrawTokensRequestSchema>;\n\nexport const WithdrawTokensResponseSchema = z.object({\n feeBreakdown: FeeBreakdownSchema.optional(),\n transactions: z.array(TransactionPlanSchema),\n});\nexport type WithdrawTokensResponse = z.infer<typeof WithdrawTokensResponseSchema>;\n\nexport const TokenPositionSchema = z.object({\n underlyingToken: TokenSchema,\n borrowRate: z.string(),\n supplyBalance: z.string(),\n borrowBalance: z.string(),\n valueUsd: z.string(),\n});\nexport type TokenPosition = z.infer<typeof TokenPositionSchema>;\n\nexport const GetWalletLendingPositionsRequestSchema = z.object({\n walletAddress: z.string(),\n});\nexport type GetWalletLendingPositionsRequest = z.infer<\n typeof GetWalletLendingPositionsRequestSchema\n>;\n\nexport const LendTokenDetailSchema = z.object({\n token: TokenSchema,\n underlyingBalance: z.string(),\n underlyingBalanceUsd: z.string(),\n variableBorrows: z.string(),\n variableBorrowsUsd: z.string(),\n totalBorrows: z.string(),\n totalBorrowsUsd: z.string(),\n});\nexport type LendTokenDetail = z.infer<typeof LendTokenDetailSchema>;\n\nexport const GetWalletLendingPositionsResponseSchema = z.object({\n userReserves: z.array(LendTokenDetailSchema),\n totalLiquidityUsd: z.string(),\n totalCollateralUsd: z.string(),\n totalBorrowsUsd: z.string(),\n netWorthUsd: z.string(),\n availableBorrowsUsd: z.string(),\n currentLoanToValue: z.string(),\n currentLiquidationThreshold: z.string(),\n healthFactor: z.string(),\n});\nexport type GetWalletLendingPositionsResponse = z.infer<\n typeof GetWalletLendingPositionsResponseSchema\n>;\n","import { z } from 'zod';\nimport { TokenIdentifierSchema, TransactionPlanSchema } from './core.js';\n\nexport const LimitedLiquidityProvisionRangeSchema = z.object({\n minPrice: z.string(),\n maxPrice: z.string(),\n});\nexport type LimitedLiquidityProvisionRange = z.infer<typeof LimitedLiquidityProvisionRangeSchema>;\n\nexport const LiquidityProvisionRangeSchema = z.discriminatedUnion('type', [\n z.object({\n type: z.literal('full'),\n }),\n z.object({\n type: z.literal('limited'),\n minPrice: z.string(),\n maxPrice: z.string(),\n }),\n]);\nexport type LiquidityProvisionRange = z.infer<typeof LiquidityProvisionRangeSchema>;\n\nexport const LiquidityPositionRangeSchema = z.object({\n fromPrice: z.string(),\n toPrice: z.string(),\n});\nexport type LiquidityPositionRange = z.infer<typeof LiquidityPositionRangeSchema>;\n\nexport const LiquidityPositionSchema = z.object({\n tokenId: z.string(),\n poolAddress: z.string(),\n operator: z.string(),\n token0: TokenIdentifierSchema,\n token1: TokenIdentifierSchema,\n tokensOwed0: z.string(),\n tokensOwed1: z.string(),\n amount0: z.string(),\n amount1: z.string(),\n symbol0: z.string(),\n symbol1: z.string(),\n price: z.string(),\n providerId: z.string(),\n positionRange: LiquidityPositionRangeSchema.optional(),\n});\nexport type LiquidityPosition = z.infer<typeof LiquidityPositionSchema>;\n\nexport const LiquidityPoolSchema = z.object({\n token0: TokenIdentifierSchema,\n token1: TokenIdentifierSchema,\n symbol0: z.string(),\n symbol1: z.string(),\n price: z.string(),\n providerId: z.string(),\n});\nexport type LiquidityPool = z.infer<typeof LiquidityPoolSchema>;\n\nexport const SupplyLiquidityRequestSchema = z.object({\n token0: TokenIdentifierSchema,\n token1: TokenIdentifierSchema,\n amount0: z.bigint(),\n amount1: z.bigint(),\n range: LiquidityProvisionRangeSchema,\n walletAddress: z.string(),\n});\nexport type SupplyLiquidityRequest = z.infer<typeof SupplyLiquidityRequestSchema>;\n\nexport const SupplyLiquidityResponseSchema = z.object({\n transactions: z.array(TransactionPlanSchema),\n chainId: z.string(),\n});\nexport type SupplyLiquidityResponse = z.infer<typeof SupplyLiquidityResponseSchema>;\n\nexport const WithdrawLiquidityRequestSchema = z.object({\n tokenId: z.string(),\n walletAddress: z.string(),\n});\nexport type WithdrawLiquidityRequest = z.infer<typeof WithdrawLiquidityRequestSchema>;\n\nexport const WithdrawLiquidityResponseSchema = z.object({\n transactions: z.array(TransactionPlanSchema),\n chainId: z.string(),\n});\nexport type WithdrawLiquidityResponse = z.infer<typeof WithdrawLiquidityResponseSchema>;\n\nexport const GetWalletLiquidityPositionsRequestSchema = z.object({\n walletAddress: z.string(),\n});\nexport type GetWalletLiquidityPositionsRequest = z.infer<\n typeof GetWalletLiquidityPositionsRequestSchema\n>;\n\nexport const GetWalletLiquidityPositionsResponseSchema = z.object({\n positions: z.array(LiquidityPositionSchema),\n});\nexport type GetWalletLiquidityPositionsResponse = z.infer<\n typeof GetWalletLiquidityPositionsResponseSchema\n>;\n\nexport const GetLiquidityPoolsResponseSchema = z.object({\n liquidityPools: z.array(LiquidityPoolSchema),\n});\nexport type GetLiquidityPoolsResponse = z.infer<typeof GetLiquidityPoolsResponseSchema>;\n","import { z } from 'zod';\nimport { TransactionPlanSchema, TokenIdentifierSchema } from './core.js';\nimport { DecreasePositionSwapType, OrderType } from '@gmx-io/sdk/types/orders';\n\n// Enums\nexport const DecreasePositionSwapTypeSchema = z.nativeEnum(DecreasePositionSwapType);\n\nexport const PositionSideSchema = z.union([z.literal('long'), z.literal('short')]);\n\nexport type PositionSide = z.infer<typeof PositionSideSchema>;\n\n// API Schemas and types\nexport const PositionSchema = z.object({\n chainId: z.string(),\n key: z.string(),\n contractKey: z.string(),\n account: z.string(),\n marketAddress: z.string(),\n collateralTokenAddress: z.string(),\n sizeInUsd: z.string(),\n sizeInTokens: z.string(),\n collateralAmount: z.string(),\n pendingBorrowingFeesUsd: z.string(),\n increasedAtTime: z.string(),\n decreasedAtTime: z.string(),\n positionSide: PositionSideSchema,\n isLong: z.boolean(),\n fundingFeeAmount: z.string(),\n claimableLongTokenAmount: z.string(),\n claimableShortTokenAmount: z.string(),\n isOpening: z.boolean().optional(),\n pnl: z.string(),\n positionFeeAmount: z.string(),\n traderDiscountAmount: z.string(),\n uiFeeAmount: z.string(),\n data: z.string().optional(),\n});\n\nexport type PerpetualsPosition = z.infer<typeof PositionSchema>;\n\nexport const PositionsDataSchema = z.array(PositionSchema);\n\n// Order Schema\nexport const OrderSchema = z.object({\n chainId: z.string(),\n key: z.string(),\n account: z.string(),\n callbackContract: z.string(),\n initialCollateralTokenAddress: z.string(),\n marketAddress: z.string(),\n decreasePositionSwapType: DecreasePositionSwapTypeSchema,\n receiver: z.string(),\n swapPath: z.array(z.string()),\n contractAcceptablePrice: z.string(),\n contractTriggerPrice: z.string(),\n callbackGasLimit: z.string(),\n executionFee: z.string(),\n initialCollateralDeltaAmount: z.string(),\n minOutputAmount: z.string(),\n sizeDeltaUsd: z.string(),\n updatedAtTime: z.string(),\n isFrozen: z.boolean(),\n positionSide: PositionSideSchema,\n orderType: z.nativeEnum(OrderType),\n shouldUnwrapNativeToken: z.boolean(),\n autoCancel: z.boolean(),\n data: z.string().optional(),\n uiFeeReceiver: z.string(),\n validFromTime: z.string(),\n title: z.string().optional(),\n});\n\nexport type PerpetualsOrder = z.infer<typeof OrderSchema>;\n\nexport const OrdersDataSchema = z.array(OrderSchema);\n\n// Definition for plugin with mapped entities already in place\nexport const CreatePerpetualsPositionRequestSchema = z.object({\n amount: z.bigint(),\n walletAddress: z.string(),\n chainId: z.string(),\n marketAddress: z.string(),\n payTokenAddress: z.string(),\n collateralTokenAddress: z.string(),\n referralCode: z.string().optional(),\n limitPrice: z.string().optional(),\n leverage: z.string(),\n});\n\nexport type CreatePerpetualsPositionRequest = z.infer<typeof CreatePerpetualsPositionRequestSchema>;\n\nexport const CreatePerpetualsPositionResponseSchema = z.object({\n transactions: z.array(TransactionPlanSchema),\n});\nexport type CreatePerpetualsPositionResponse = z.infer<\n typeof CreatePerpetualsPositionResponseSchema\n>;\n\nexport const GetPerpetualsMarketsPositionsRequestSchema = z.object({\n walletAddress: z.string().describe(\"User's wallet address\"),\n});\n\nexport type GetPerpetualsMarketsPositionsRequest = z.infer<\n typeof GetPerpetualsMarketsPositionsRequestSchema\n>;\n\nexport const GetPerpetualsMarketsPositionsResponseSchema = z.object({\n positions: PositionsDataSchema,\n});\n\nexport type GetPerpetualsMarketsPositionsResponse = z.infer<\n typeof GetPerpetualsMarketsPositionsResponseSchema\n>;\n\nexport const GetPerpetualsMarketsOrdersRequestSchema = z.object({\n walletAddress: z.string().describe(\"User's wallet address\"),\n});\n\nexport type GetPerpetualsMarketsOrdersRequest = z.infer<\n typeof GetPerpetualsMarketsOrdersRequestSchema\n>;\n\nexport const GetPerpetualsMarketsOrdersResponseSchema = z.object({\n orders: OrdersDataSchema,\n});\n\nexport type GetPerpetualsMarketsOrdersResponse = z.infer<\n typeof GetPerpetualsMarketsOrdersResponseSchema\n>;\n\nexport const ClosePerpetualsOrdersRequestSchema = z.object({\n walletAddress: z.string().describe(\"User's wallet address\"),\n key: z.string(),\n});\n\nexport type ClosePerpetualsOrdersRequest = z.infer<typeof ClosePerpetualsOrdersRequestSchema>;\n\nexport const ClosePerpetualsOrdersResponseSchema = z.object({\n transactions: z.array(TransactionPlanSchema),\n});\n\nexport type ClosePerpetualsOrdersResponse = z.infer<typeof ClosePerpetualsOrdersResponseSchema>;\n\nexport const GetPerpetualsMarketsRequestSchema = z.object({\n chainIds: z.array(z.string()),\n});\n\nexport type GetPerpetualsMarketsRequest = z.infer<typeof GetPerpetualsMarketsRequestSchema>;\n\nexport const PerpetualMarketSchema = z.object({\n marketToken: TokenIdentifierSchema,\n indexToken: TokenIdentifierSchema,\n longToken: TokenIdentifierSchema,\n shortToken: TokenIdentifierSchema,\n longFundingFee: z.string(),\n shortFundingFee: z.string(),\n longBorrowingFee: z.string(),\n shortBorrowingFee: z.string(),\n chainId: z.string(),\n name: z.string(),\n});\n\nexport type PerpetualMarket = z.infer<typeof PerpetualMarketSchema>;\n\nexport const GetPerpetualsMarketsResponseSchema = z.object({\n markets: z.array(PerpetualMarketSchema),\n});\n\nexport type GetPerpetualsMarketsResponse = z.infer<typeof GetPerpetualsMarketsResponseSchema>;\n","import { z } from 'zod';\nimport {\n FeeBreakdownSchema,\n TransactionPlanSchema,\n SwapEstimationSchema,\n ProviderTrackingInfoSchema,\n TokenSchema,\n} from './core.js';\n\nexport const SwapTokensRequestSchema = z.object({\n fromToken: TokenSchema,\n toToken: TokenSchema,\n amount: z.bigint(),\n limitPrice: z.string().optional(),\n slippageTolerance: z.string().optional(),\n expiration: z.string().optional(),\n recipient: z.string(),\n});\nexport type SwapTokensRequest = z.infer<typeof SwapTokensRequestSchema>;\n\nexport const SwapTokensResponseSchema = z.object({\n fromToken: TokenSchema,\n toToken: TokenSchema,\n exactFromAmount: z.string(),\n displayFromAmount: z.string(),\n exactToAmount: z.string(),\n displayToAmount: z.string(),\n transactions: z.array(TransactionPlanSchema),\n feeBreakdown: FeeBreakdownSchema.optional(),\n estimation: SwapEstimationSchema.optional(),\n providerTracking: ProviderTrackingInfoSchema.optional(),\n});\nexport type SwapTokensResponse = z.infer<typeof SwapTokensResponseSchema>;\n","import type { ActionDefinition, EmberPlugin, LendingActions } from '../core/index.js';\nimport { AAVEAdapter, type AAVEAdapterParams } from './adapter.js';\nimport type { ChainConfig } from '../chainConfig.js';\nimport type { PublicEmberPluginRegistry } from '../registry.js';\n\n/**\n * Get the AAVE Ember plugin.\n * @param params - Configuration parameters for the AAVEAdapter, including chainId and rpcUrl.\n * @returns The AAVE Ember plugin.\n */\nexport async function getAaveEmberPlugin(\n params: AAVEAdapterParams\n): Promise<EmberPlugin<'lending'>> {\n const adapter = new AAVEAdapter(params);\n\n return {\n id: `AAVE_CHAIN_${params.chainId}`,\n type: 'lending',\n name: `AAVE lending for ${params.chainId}`,\n description: 'Aave V3 lending protocol',\n website: 'https://aave.com',\n x: 'https://x.com/aave',\n actions: await getAaveActions(adapter),\n queries: {\n getPositions: adapter.getUserSummary.bind(adapter),\n },\n };\n}\n\n/**\n * Get the AAVE actions for the lending protocol.\n * @param adapter - An instance of AAVEAdapter to interact with the AAVE protocol.\n * @returns An array of action definitions for the AAVE lending protocol.\n */\nexport async function getAaveActions(\n adapter: AAVEAdapter\n): Promise<ActionDefinition<LendingActions>[]> {\n const reservesResponse = await adapter.getReserves();\n\n const underlyingAssets: string[] = reservesResponse.reservesData.map(\n reserve => reserve.underlyingAsset\n );\n const aTokens: string[] = reservesResponse.reservesData.map(reserve => reserve.aTokenAddress);\n const borrowableAssets = reservesResponse.reservesData\n .filter(reserve => reserve.borrowingEnabled)\n .map(reserve => reserve.underlyingAsset);\n\n return [\n // Supply any of the underlying assets to get aTokens\n {\n type: 'lending-supply',\n name: `AAVE lending pools in chain ${adapter.chain.id}`,\n inputTokens: async () =>\n Promise.resolve([\n {\n chainId: adapter.chain.id.toString(),\n tokens: underlyingAssets,\n },\n ]),\n outputTokens: async () =>\n Promise.resolve([\n {\n chainId: adapter.chain.id.toString(),\n tokens: aTokens,\n },\n ]),\n callback: adapter.createSupplyTransaction.bind(adapter),\n },\n\n // Borrow any of the borrowable assets if you have some alpha tokens as collateral\n {\n type: 'lending-borrow',\n name: `AAVE borrow in chain ${adapter.chain.id}`,\n inputTokens: async () =>\n Promise.resolve([\n {\n chainId: adapter.chain.id.toString(),\n tokens: aTokens,\n },\n ]),\n outputTokens: async () =>\n Promise.resolve([\n {\n chainId: adapter.chain.id.toString(),\n tokens: borrowableAssets,\n },\n ]),\n callback: adapter.createBorrowTransaction.bind(adapter),\n },\n\n // Repay your borrow with the underlying asset\n {\n type: 'lending-repay',\n name: `AAVE repay in chain ${adapter.chain.id}`,\n inputTokens: async () =>\n Promise.resolve([\n {\n chainId: adapter.chain.id.toString(),\n tokens: borrowableAssets,\n },\n ]),\n // Empty output tokens as this doesn't generate any token\n outputTokens: async () => Promise.resolve([]),\n callback: adapter.createRepayTransaction.bind(adapter),\n },\n\n // Repay your borrow with aTokens\n {\n type: 'lending-repay',\n name: `AAVE repay with aTokens in chain ${adapter.chain.id}`,\n inputTokens: async () =>\n Promise.resolve([\n {\n chainId: adapter.chain.id.toString(),\n tokens: aTokens,\n },\n ]),\n // Empty output tokens as this doesn't generate any token\n outputTokens: async () => Promise.resolve([]),\n callback: adapter.createRepayTransactionWithATokens.bind(adapter),\n },\n\n // Withdraw from your aTokens to get the underlying asset back\n {\n type: 'lending-withdraw',\n name: `AAVE withdraw in chain ${adapter.chain.id}`,\n inputTokens: async () =>\n Promise.resolve([\n {\n chainId: adapter.chain.id.toString(),\n tokens: aTokens,\n },\n ]),\n outputTokens: async () =>\n Promise.resolve([\n {\n chainId: adapter.chain.id.toString(),\n tokens: underlyingAssets,\n },\n ]),\n callback: adapter.createWithdrawTransaction.bind(adapter),\n },\n ];\n}\n\n/**\n * Register the AAVE plugin for the specified chain configuration.\n * @param chainConfig - The chain configuration to check for AAVE support.\n * @param registry - The public Ember plugin registry to register the plugin with.\n * @returns A promise that resolves when the plugin is registered.\n */\nexport function registerAave(chainConfig: ChainConfig, registry: PublicEmberPluginRegistry) {\n const supportedChains = [42161];\n if (!supportedChains.includes(chainConfig.chainId)) {\n return;\n }\n\n registry.register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,MAAM,EAAE;AAAA,MAChD,aAAa,YACX,QAAQ,QAAQ;AAAA,QACd;AAAA,UACE,SAAS,QAAQ,MAAM,GAAG,SAAS;AAAA,UACnC,QAAQ;AAAA,QACV;AAAA,MACF,CAAC;AAAA,MACH,cAAc,YACZ,QAAQ,QAAQ;AAAA,QACd;AAAA,UACE,SAAS,QAAQ,MAAM,GAAG,SAAS;AAAA,UACnC,QAAQ;AAAA,QACV;AAAA,MACF,CAAC;AAAA,MACH,UAAU,QAAQ,0BAA0B,KAAK,OAAO;AAAA,IAC1D;AAAA,EACF;AACF;AAQO,SAAS,aAAa,aAA0B,UAAqC;AAC1F,QAAM,kBAAkB,CAAC,KAAK;AAC9B,MAAI,CAAC,gBAAgB,SAAS,YAAY,OAAO,GAAG;AAClD;AAAA,EACF;AAEA,WAAS;AAAA,IACP,mBAAmB;AAAA,MACjB,SAAS,YAAY;AAAA,MACrB,QAAQ,YAAY;AAAA,MACpB,oBAAoB,YAAY;AAAA,IAClC,CAAC;AAAA,EACH;AACF;;;Af5JO,SAAS,yBAAyB,cAA6B;AACpE,QAAM,WAAW,IAAI,0BAA0B;AAG/C,aAAW,eAAe,cAAc;AAEtC,iBAAa,aAAa,QAAQ;AAAA,EACpC;AAEA,SAAO;AACT;","names":["import_ethers","import_ethers","import_ethers","import_contract_helpers","import_zod","import_zod","import_zod","import_zod","import_zod","totalBorrowsUSD","ur"]}
package/dist/index.js CHANGED
@@ -923,6 +923,7 @@ var SwapTokensResponseSchema = z6.object({
923
923
  });
924
924
 
925
925
  // src/aave-lending-plugin/adapter.ts
926
+ import "zod/v4/locales";
926
927
  var AAVE_ETH_PLACEHOLDER = "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE";
927
928
  var AAVEAdapter = class {
928
929
  chain;
@@ -1096,7 +1097,7 @@ var AAVEAdapter = class {
1096
1097
  variableBorrowsUSD,
1097
1098
  totalBorrows,
1098
1099
  totalBorrowsUSD: totalBorrowsUSD2
1099
- } of userReservesData) {
1100
+ } of userReservesData.filter((ur2) => ur2.underlyingBalanceUSD !== "0")) {
1100
1101
  const tokenData = await this.getTokenData(reserve.underlyingAsset);
1101
1102
  userReservesFormatted.push({
1102
1103
  token: {
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/registry.ts","../src/aave-lending-plugin/chain.ts","../src/aave-lending-plugin/market.ts","../src/aave-lending-plugin/userSummary.ts","../src/aave-lending-plugin/populateTransaction.ts","../src/aave-lending-plugin/errors.ts","../src/aave-lending-plugin/dataProvider.ts","../src/aave-lending-plugin/adapter.ts","../src/core/schemas/core.ts","../src/core/schemas/enums.ts","../src/core/schemas/lending.ts","../src/core/schemas/liquidity.ts","../src/core/schemas/perpetuals.ts","../src/core/schemas/swap.ts","../src/aave-lending-plugin/index.ts","../src/index.ts"],"sourcesContent":["import type { EmberPlugin, PluginType } from './core/index.js';\n\n/**\n * Registry for public Ember plugins.\n */\nexport class PublicEmberPluginRegistry {\n private plugins: EmberPlugin<PluginType>[] = [];\n private deferredPlugins: Promise<EmberPlugin<PluginType>>[] = [];\n\n /**\n * Register a new Ember plugin.\n * @param plugin The plugin to register.\n */\n public registerPlugin(plugin: EmberPlugin<PluginType>) {\n this.plugins.push(plugin);\n }\n\n /**\n * Register a new deferred Ember plugin.\n * @param pluginPromise The promise resolving to the plugin to register.\n */\n public registerDeferredPlugin(pluginPromise: Promise<EmberPlugin<PluginType>>) {\n this.deferredPlugins.push(pluginPromise);\n }\n\n /**\n * Iterator for the registered Ember plugins.\n */\n public async *getPlugins(): AsyncIterable<EmberPlugin<PluginType>> {\n yield* this.plugins;\n\n for (const pluginPromise of this.deferredPlugins) {\n const plugin = await pluginPromise;\n\n // Register the plugin now that it is resolved\n this.registerPlugin(plugin);\n\n yield plugin;\n }\n\n this.deferredPlugins = [];\n }\n\n public get emberPlugins(): EmberPlugin<PluginType>[] {\n return this.plugins;\n }\n}\n","import { ethers } from 'ethers';\n\n/**\n * Represents a blockchain network configuration used to create JSON-RPC providers and\n * hold basic chain-specific metadata.\n *\n * The Chain class encapsulates:\n * - a numeric chain identifier (id),\n * - an RPC URL to connect to the chain (rpcUrl),\n * - an optional wrapped native token address (wrappedNativeTokenAddress).\n *\n * @param id - The numeric identifier for the chain (e.g., 1 for Ethereum mainnet).\n * @param rpcUrl - The JSON-RPC endpoint URL used to create providers for this chain.\n * @param wrappedNativeTokenAddress - Optional address of the chain's wrapped native token (if applicable).\n */\nexport class Chain {\n constructor(\n public id: number,\n public rpcUrl: string,\n public wrappedNativeTokenAddress?: string\n ) {}\n\n /**\n * Create and return an ethers.js JsonRpcProvider configured with this chain's RPC URL.\n *\n * This method constructs a new ethers.providers.JsonRpcProvider each time it is called.\n * Consumers may cache the provider if they intend to reuse it to avoid allocating multiple instances.\n *\n * @returns An instance of ethers.providers.JsonRpcProvider configured with the chain's rpcUrl.\n */\n public getProvider(): ethers.providers.JsonRpcProvider {\n return new ethers.providers.JsonRpcProvider(this.rpcUrl);\n }\n}\n","import * as markets from '@bgd-labs/aave-address-book';\n\n// AAVE market selection provided by aave-address-book is not very typescript-friendly:\n// we have to trust that the structure of their modules is the same, which\n// seems to be the case.\n\n// An interface that only contains fields of market definitions that we actually use\nexport type AAVEMarket = {\n AAVE_PROTOCOL_DATA_PROVIDER: string;\n POOL: string;\n POOL_ADDRESSES_PROVIDER: string;\n UI_INCENTIVE_DATA_PROVIDER: string;\n UI_POOL_DATA_PROVIDER: string;\n WALLET_BALANCE_PROVIDER: string;\n WETH_GATEWAY: string;\n};\n\nconst marketMap: Record<number, keyof typeof markets> = {\n 1: 'AaveV3Ethereum',\n 11155111: 'AaveV3Sepolia',\n 42161: 'AaveV3Arbitrum',\n 421614: 'AaveV3ArbitrumSepolia',\n 8453: 'AaveV3Base',\n 137: 'AaveV3Polygon',\n 10: 'AaveV3Optimism',\n};\n\nexport const getMarket = (chainId: number): AAVEMarket => {\n const marketKey = marketMap[chainId];\n if (!marketKey) {\n throw new Error(\n `AAVE: no market found for chain ID ${chainId}: modify providers/aave/market.ts`\n );\n }\n\n const market = markets[marketKey] as unknown as AAVEMarket;\n if (!market) {\n throw new Error(`No such market: ${marketKey}`);\n }\n\n return market;\n};\n","import type { ReservesDataHumanized, UserReserveDataHumanized } from '@aave/contract-helpers';\nimport {\n formatReserves,\n formatUserSummary,\n type FormatUserSummaryResponse,\n type FormatReserveUSDResponse,\n} from '@aave/math-utils';\n\nfunction formatNumeric(value: string): string {\n const num = parseFloat(value);\n if (Number.isInteger(num)) return num.toString();\n return parseFloat(num.toFixed(2)).toString();\n}\n\nexport class UserSummary {\n public reserves: FormatUserSummaryResponse<FormatReserveUSDResponse>;\n\n /**\n * @param userReservesResponse - The response from getUserReservesHumanized.\n * @param reservesResponse - The response from getReservesHumanized.\n */\n constructor(\n userReservesResponse: {\n userReserves: UserReserveDataHumanized[];\n userEmodeCategoryId: number;\n },\n reservesResponse: ReservesDataHumanized\n ) {\n const currentTimestamp = Date.now() / 1000;\n\n const formattedReserves = formatReserves({\n reserves: reservesResponse.reservesData,\n currentTimestamp,\n marketReferenceCurrencyDecimals:\n reservesResponse.baseCurrencyData.marketReferenceCurrencyDecimals,\n marketReferencePriceInUsd:\n reservesResponse.baseCurrencyData.marketReferenceCurrencyPriceInUsd,\n });\n\n this.reserves = formatUserSummary({\n currentTimestamp,\n marketReferencePriceInUsd:\n reservesResponse.baseCurrencyData.marketReferenceCurrencyPriceInUsd,\n marketReferenceCurrencyDecimals:\n reservesResponse.baseCurrencyData.marketReferenceCurrencyDecimals,\n userReserves: userReservesResponse.userReserves,\n formattedReserves,\n userEmodeCategoryId: userReservesResponse.userEmodeCategoryId,\n });\n }\n\n public toHumanReadable(): string {\n let output = 'User Positions:\\n';\n output += `Total Liquidity (USD): ${formatNumeric(this.reserves.totalLiquidityUSD)}\\n`;\n output += `Total Collateral (USD): ${formatNumeric(this.reserves.totalCollateralUSD)}\\n`;\n output += `Total Borrows (USD): ${formatNumeric(this.reserves.totalBorrowsUSD)}\\n`;\n output += `Net Worth (USD): ${formatNumeric(this.reserves.netWorthUSD)}\\n`;\n output += `Health Factor: ${formatNumeric(this.reserves.healthFactor)}\\n\\n`;\n output += 'Deposits:\\n';\n for (const entry of this.reserves.userReservesData) {\n if (parseFloat(entry.scaledATokenBalance) > 0) {\n const underlying = entry.underlyingBalance;\n const underlyingUSD = entry.underlyingBalanceUSD\n ? formatNumeric(entry.underlyingBalanceUSD)\n : 'N/A';\n output += `- ${entry.reserve.symbol}: ${underlying} (USD: ${underlyingUSD})\\n`;\n }\n }\n output += '\\nLoans:\\n';\n for (const entry of this.reserves.userReservesData) {\n const borrow = entry.totalBorrows || '0';\n if (parseFloat(borrow) > 0) {\n const totalBorrows = entry.totalBorrows;\n const totalBorrowsUSD = entry.totalBorrowsUSD\n ? formatNumeric(entry.totalBorrowsUSD)\n : 'N/A';\n output += `- ${entry.reserve.symbol}: ${totalBorrows} (USD: ${totalBorrowsUSD})\\n`;\n }\n }\n return output;\n }\n}\n","import type { EthereumTransactionTypeExtended } from '@aave/contract-helpers';\nimport { type PopulatedTransaction, ethers } from 'ethers';\nimport { getAaveError } from './errors.js';\n\nexport async function populateTransaction(\n tx: EthereumTransactionTypeExtended\n): Promise<PopulatedTransaction> {\n let txData = null;\n try {\n txData = await tx.tx();\n /* eslint-disable @typescript-eslint/no-explicit-any */\n } catch (e: any) {\n /* eslint-enable @typescript-eslint/no-explicit-any */\n\n // error reason looks like 'execution reverted: revert: 32', with the aave\n // domain error code at the very end\n const errorCode = (e.reason || '').split(' ').pop();\n // If we end up passing garbage to getAaveError, it does not matter - it will return null\n const aaveError = getAaveError(errorCode);\n if (aaveError !== null) {\n throw aaveError;\n } else {\n // we can hope that the LLM will provide an analysis of the error on the fly\n throw e;\n }\n }\n return {\n value: ethers.BigNumber.from(txData.value || 0),\n from: txData.from,\n to: txData.to,\n data: txData.data,\n };\n}\n","// based on https://github.com/aave-dao/aave-v3-origin/blob/083bd38a137b42b5df04e22ad4c9e72454365d0d/src/contracts/protocol/libraries/helpers/Errors.sol\n\nclass AaveError extends Error {\n public description: string;\n public override message: string;\n\n constructor(code: string, name: string, description: string) {\n const message = name + ` (${code}): ` + description;\n super(message);\n this.name = 'AaveError';\n this.description = description;\n this.message = message;\n\n // Ensures proper prototype chain in transpiled JavaScript\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\ntype AaveErrorData = {\n name: string;\n description: string;\n};\n\nexport const AAVE_ERROR_CODES: Record<string, AaveErrorData> = {\n '1': {\n name: 'CALLER_NOT_POOL_ADMIN',\n description: 'The caller of the function is not a pool admin',\n },\n '2': {\n name: 'CALLER_NOT_EMERGENCY_ADMIN',\n description: 'The caller of the function is not an emergency admin',\n },\n '3': {\n name: 'CALLER_NOT_POOL_OR_EMERGENCY_ADMIN',\n description: 'The caller of the function is not a pool or emergency admin',\n },\n '4': {\n name: 'CALLER_NOT_RISK_OR_POOL_ADMIN',\n description: 'The caller of the function is not a risk or pool admin',\n },\n '5': {\n name: 'CALLER_NOT_ASSET_LISTING_OR_POOL_ADMIN',\n description: 'The caller of the function is not an asset listing or pool admin',\n },\n '6': {\n name: 'CALLER_NOT_BRIDGE',\n description: 'The caller of the function is not a bridge',\n },\n '7': {\n name: 'ADDRESSES_PROVIDER_NOT_REGISTERED',\n description: 'Pool addresses provider is not registered',\n },\n '8': {\n name: 'INVALID_ADDRESSES_PROVIDER_ID',\n description: 'Invalid id for the pool addresses provider',\n },\n '9': { name: 'NOT_CONTRACT', description: 'Address is not a contract' },\n '10': {\n name: 'CALLER_NOT_POOL_CONFIGURATOR',\n description: 'The caller of the function is not the pool configurator',\n },\n '11': {\n name: 'CALLER_NOT_ATOKEN',\n description: 'The caller of the function is not an AToken',\n },\n '12': {\n name: 'INVALID_ADDRESSES_PROVIDER',\n description: 'The address of the pool addresses provider is invalid',\n },\n '13': {\n name: 'INVALID_FLASHLOAN_EXECUTOR_RETURN',\n description: 'Invalid return value of the flashloan executor function',\n },\n '14': {\n name: 'RESERVE_ALREADY_ADDED',\n description: 'Reserve has already been added to reserve list',\n },\n '15': {\n name: 'NO_MORE_RESERVES_ALLOWED',\n description: 'Maximum amount of reserves in the pool reached',\n },\n '16': {\n name: 'EMODE_CATEGORY_RESERVED',\n description: 'Zero eMode category is reserved for volatile heterogeneous assets',\n },\n '17': {\n name: 'INVALID_EMODE_CATEGORY_ASSIGNMENT',\n description: 'Invalid eMode category assignment to asset',\n },\n '18': {\n name: 'RESERVE_LIQUIDITY_NOT_ZERO',\n description: 'The liquidity of the reserve needs to be 0',\n },\n '19': {\n name: 'FLASHLOAN_PREMIUM_INVALID',\n description: 'Invalid flashloan premium',\n },\n '20': {\n name: 'INVALID_RESERVE_PARAMS',\n description: 'Invalid risk parameters for the reserve',\n },\n '21': {\n name: 'INVALID_EMODE_CATEGORY_PARAMS',\n description: 'Invalid risk parameters for the eMode category',\n },\n '22': {\n name: 'BRIDGE_PROTOCOL_FEE_INVALID',\n description: 'Invalid bridge protocol fee',\n },\n '23': {\n name: 'CALLER_MUST_BE_POOL',\n description: 'The caller of this function must be a pool',\n },\n '24': { name: 'INVALID_MINT_AMOUNT', description: 'Invalid amount to mint' },\n '25': { name: 'INVALID_BURN_AMOUNT', description: 'Invalid amount to burn' },\n '26': {\n name: 'INVALID_AMOUNT',\n description: 'Amount must be greater than 0',\n },\n '27': {\n name: 'RESERVE_INACTIVE',\n description: 'Action requires an active reserve',\n },\n '28': {\n name: 'RESERVE_FROZEN',\n description: 'Action cannot be performed because the reserve is frozen',\n },\n '29': {\n name: 'RESERVE_PAUSED',\n description: 'Action cannot be performed because the reserve is paused',\n },\n '30': {\n name: 'BORROWING_NOT_ENABLED',\n description: 'Borrowing is not enabled',\n },\n '32': {\n name: 'NOT_ENOUGH_AVAILABLE_USER_BALANCE',\n description: 'User cannot withdraw more than the available balance',\n },\n '33': {\n name: 'INVALID_INTEREST_RATE_MODE_SELECTED',\n description: 'Invalid interest rate mode selected',\n },\n '34': {\n name: 'COLLATERAL_BALANCE_IS_ZERO',\n description: 'The collateral balance is 0',\n },\n '35': {\n name: 'HEALTH_FACTOR_LOWER_THAN_LIQUIDATION_THRESHOLD',\n description: 'Health factor is lesser than the liquidation threshold',\n },\n '36': {\n name: 'COLLATERAL_CANNOT_COVER_NEW_BORROW',\n description: 'There is not enough collateral to cover a new borrow',\n },\n '37': {\n name: 'COLLATERAL_SAME_AS_BORROWING_CURRENCY',\n description: 'Collateral is (mostly) the same currency that is being borrowed',\n },\n '39': {\n name: 'NO_DEBT_OF_SELECTED_TYPE',\n description: 'For repayment of a specific type of debt, the user needs to have debt that type',\n },\n '40': {\n name: 'NO_EXPLICIT_AMOUNT_TO_REPAY_ON_BEHALF',\n description: 'To repay on behalf of a user an explicit amount to repay is needed',\n },\n '42': {\n name: 'NO_OUTSTANDING_VARIABLE_DEBT',\n description: 'User does not have outstanding variable rate debt on this reserve',\n },\n '43': {\n name: 'UNDERLYING_BALANCE_ZERO',\n description: 'The underlying balance needs to be greater than 0',\n },\n '44': {\n name: 'INTEREST_RATE_REBALANCE_CONDITIONS_NOT_MET',\n description: 'Interest rate rebalance conditions were not met',\n },\n '45': {\n name: 'HEALTH_FACTOR_NOT_BELOW_THRESHOLD',\n description: 'Health factor is not below the threshold',\n },\n '46': {\n name: 'COLLATERAL_CANNOT_BE_LIQUIDATED',\n description: 'The collateral chosen cannot be liquidated',\n },\n '47': {\n name: 'SPECIFIED_CURRENCY_NOT_BORROWED_BY_USER',\n description: 'User did not borrow the specified currency',\n },\n '49': {\n name: 'INCONSISTENT_FLASHLOAN_PARAMS',\n description: 'Inconsistent flashloan parameters',\n },\n '50': { name: 'BORROW_CAP_EXCEEDED', description: 'Borrow cap is exceeded' },\n '51': { name: 'SUPPLY_CAP_EXCEEDED', description: 'Supply cap is exceeded' },\n '52': {\n name: 'UNBACKED_MINT_CAP_EXCEEDED',\n description: 'Unbacked mint cap is exceeded',\n },\n '53': {\n name: 'DEBT_CEILING_EXCEEDED',\n description: 'Debt ceiling is exceeded',\n },\n '54': {\n name: 'UNDERLYING_CLAIMABLE_RIGHTS_NOT_ZERO',\n description: 'Claimable rights over underlying not zero (aToken supply or accruedToTreasury)',\n },\n '56': {\n name: 'VARIABLE_DEBT_SUPPLY_NOT_ZERO',\n description: 'Variable debt supply is not zero',\n },\n '57': { name: 'LTV_VALIDATION_FAILED', description: 'Ltv validation failed' },\n '58': {\n name: 'INCONSISTENT_EMODE_CATEGORY',\n description: 'Inconsistent eMode category',\n },\n '59': {\n name: 'PRICE_ORACLE_SENTINEL_CHECK_FAILED',\n description: 'Price oracle sentinel validation failed',\n },\n '60': {\n name: 'ASSET_NOT_BORROWABLE_IN_ISOLATION',\n description: 'Asset is not borrowable in isolation mode',\n },\n '61': {\n name: 'RESERVE_ALREADY_INITIALIZED',\n description: 'Reserve has already been initialized',\n },\n '62': {\n name: 'USER_IN_ISOLATION_MODE_OR_LTV_ZERO',\n description: 'User is in isolation mode or ltv is zero',\n },\n '63': {\n name: 'INVALID_LTV',\n description: 'Invalid ltv parameter for the reserve',\n },\n '64': {\n name: 'INVALID_LIQ_THRESHOLD',\n description: 'Invalid liquidity threshold parameter for the reserve',\n },\n '65': {\n name: 'INVALID_LIQ_BONUS',\n description: 'Invalid liquidity bonus parameter for the reserve',\n },\n '66': {\n name: 'INVALID_DECIMALS',\n description: 'Invalid decimals parameter of the underlying asset of the reserve',\n },\n '67': {\n name: 'INVALID_RESERVE_FACTOR',\n description: 'Invalid reserve factor parameter for the reserve',\n },\n '68': {\n name: 'INVALID_BORROW_CAP',\n description: 'Invalid borrow cap for the reserve',\n },\n '69': {\n name: 'INVALID_SUPPLY_CAP',\n description: 'Invalid supply cap for the reserve',\n },\n '70': {\n name: 'INVALID_LIQUIDATION_PROTOCOL_FEE',\n description: 'Invalid liquidation protocol fee for the reserve',\n },\n '71': {\n name: 'INVALID_EMODE_CATEGORY',\n description: 'Invalid eMode category for the reserve',\n },\n '72': {\n name: 'INVALID_UNBACKED_MINT_CAP',\n description: 'Invalid unbacked mint cap for the reserve',\n },\n '73': {\n name: 'INVALID_DEBT_CEILING',\n description: 'Invalid debt ceiling for the reserve',\n },\n '74': { name: 'INVALID_RESERVE_INDEX', description: 'Invalid reserve index' },\n '75': {\n name: 'ACL_ADMIN_CANNOT_BE_ZERO',\n description: 'ACL admin cannot be set to the zero address',\n },\n '76': {\n name: 'INCONSISTENT_PARAMS_LENGTH',\n description: 'Array parameters that should be equal length are not',\n },\n '77': {\n name: 'ZERO_ADDRESS_NOT_VALID',\n description: 'Zero address not valid',\n },\n '78': { name: 'INVALID_EXPIRATION', description: 'Invalid expiration' },\n '79': { name: 'INVALID_SIGNATURE', description: 'Invalid signature' },\n '80': {\n name: 'OPERATION_NOT_SUPPORTED',\n description: 'Operation not supported',\n },\n '81': {\n name: 'DEBT_CEILING_NOT_ZERO',\n description: 'Debt ceiling is not zero',\n },\n '82': { name: 'ASSET_NOT_LISTED', description: 'Asset is not listed' },\n '83': {\n name: 'INVALID_OPTIMAL_USAGE_RATIO',\n description: 'Invalid optimal usage ratio',\n },\n '85': {\n name: 'UNDERLYING_CANNOT_BE_RESCUED',\n description: 'The underlying asset cannot be rescued',\n },\n '86': {\n name: 'ADDRESSES_PROVIDER_ALREADY_ADDED',\n description: 'Reserve has already been added to reserve list',\n },\n '87': {\n name: 'POOL_ADDRESSES_DO_NOT_MATCH',\n description:\n 'The token implementation pool address and the pool address provided by the initializing pool do not match',\n },\n '89': {\n name: 'SILOED_BORROWING_VIOLATION',\n description: 'User is trying to borrow multiple assets including a siloed one',\n },\n '90': {\n name: 'RESERVE_DEBT_NOT_ZERO',\n description: 'The total debt of the reserve needs to be 0',\n },\n '91': {\n name: 'FLASHLOAN_DISABLED',\n description: 'FlashLoaning for this asset is disabled',\n },\n '92': {\n name: 'INVALID_MAX_RATE',\n description: 'The expect maximum borrow rate is invalid',\n },\n '93': {\n name: 'WITHDRAW_TO_ATOKEN',\n description: 'Withdrawing to the aToken is not allowed',\n },\n '94': {\n name: 'SUPPLY_TO_ATOKEN',\n description: 'Supplying to the aToken is not allowed',\n },\n '95': {\n name: 'SLOPE_2_MUST_BE_GTE_SLOPE_1',\n description: 'Variable interest rate slope 2 can not be lower than slope 1',\n },\n '96': {\n name: 'CALLER_NOT_RISK_OR_POOL_OR_EMERGENCY_ADMIN',\n description: 'The caller of the function is not a risk, pool or emergency admin',\n },\n '97': {\n name: 'LIQUIDATION_GRACE_SENTINEL_CHECK_FAILED',\n description: 'Liquidation grace sentinel validation failed',\n },\n '98': {\n name: 'INVALID_GRACE_PERIOD',\n description: 'Grace period above a valid range',\n },\n '99': {\n name: 'INVALID_FREEZE_STATE',\n description: 'Reserve is already in the passed freeze state',\n },\n '100': {\n name: 'NOT_BORROWABLE_IN_EMODE',\n description: 'Asset not borrowable in eMode',\n },\n};\n\nexport function getAaveError(code: string): AaveError | null {\n const err = AAVE_ERROR_CODES[code];\n if (err) {\n return new AaveError(code, err.name, err.description);\n }\n return null;\n}\n","import { ethers } from 'ethers';\nimport {\n LegacyUiPoolDataProvider,\n UiPoolDataProvider,\n type ReservesDataHumanized,\n type ReservesHelperInput,\n type UserReservesHelperInput,\n type EModeData,\n type EmodeDataHumanized,\n type UserReserveDataHumanized,\n} from '@aave/contract-helpers';\n\n// @aave/contract-helpers provides two periphery contracts for fetching data from the blockchain:\n// `LegacyUiPoolDataProvider` and `UiPoolDataProvider`. Which one should be used is determined by the version that is actually deployed on a given chain.\n// Fortunately, for our use case we don't care about this complexity,\n// because their interfaces share just enough similarities for us to proceed.\n// `IUiPoolDataProvider` is an intersection of two interfaces.\n\n// Common functions between `LegacyUiPoolDataProvider` and `UiPoolDataProvider`\nexport interface IUiPoolDataProvider {\n getReservesHumanized: (args: ReservesHelperInput) => Promise<ReservesDataHumanized>;\n getUserReservesHumanized: (args: UserReservesHelperInput) => Promise<{\n userReserves: UserReserveDataHumanized[];\n userEmodeCategoryId: number;\n }>;\n getEModes: (args: ReservesHelperInput) => Promise<EModeData[]>;\n getEModesHumanized: (args: ReservesHelperInput) => Promise<EmodeDataHumanized[]>;\n}\n\nexport type IUiPoolDataProviderConstructor = new ({\n uiPoolDataProviderAddress,\n provider,\n chainId,\n}: {\n uiPoolDataProviderAddress: string;\n provider: ethers.providers.JsonRpcProvider;\n chainId: number;\n}) => IUiPoolDataProvider;\n\n// which class to use: LegacyUiPoolDataProvider or UiPoolDataProvider\n// When adding new chains, either compare the interfaces or bruteforce the correct option.\nexport const UI_POOL_DATA_PROVIDER_INTERFACE_PER_CHAIN: Record<\n number,\n IUiPoolDataProviderConstructor\n> = {\n 11155111: LegacyUiPoolDataProvider as IUiPoolDataProviderConstructor,\n 42161: UiPoolDataProvider as IUiPoolDataProviderConstructor,\n 1: UiPoolDataProvider as IUiPoolDataProviderConstructor,\n};\n\n// Use this function to get the correct pool data provider implementation.\nexport const getUiPoolDataProviderImpl = (chainId: number): IUiPoolDataProviderConstructor => {\n const res = UI_POOL_DATA_PROVIDER_INTERFACE_PER_CHAIN[chainId];\n if (!res) {\n throw new Error(\n 'UI_POOL_DATA_PROVIDER_INTERFACE_PER_CHAIN does not contain this chain ID. Edit providers/aave/dataProvider.ts.'\n );\n }\n return res;\n};\n","import { Chain } from './chain.js';\nimport { type AAVEMarket, getMarket } from './market.js';\nimport { UserSummary } from './userSummary.js';\nimport { populateTransaction } from './populateTransaction.js';\nimport { getUiPoolDataProviderImpl, type IUiPoolDataProvider } from './dataProvider.js';\nimport { ethers, type PopulatedTransaction, utils } from 'ethers';\nimport {\n Pool,\n PoolBundle,\n InterestRate,\n type ReservesDataHumanized,\n type ReserveDataHumanized,\n} from '@aave/contract-helpers';\nimport {\n type TransactionPlan,\n type BorrowTokensRequest,\n type BorrowTokensResponse,\n type RepayTokensRequest,\n type RepayTokensResponse,\n type SupplyTokensRequest,\n type SupplyTokensResponse,\n type WithdrawTokensRequest,\n type WithdrawTokensResponse,\n type GetWalletLendingPositionsResponse,\n TransactionTypes,\n type GetWalletLendingPositionsRequest,\n type Token,\n} from '../core/index.js';\n\nexport type EModeCategory = 'default' | 'stablecoins';\n\nexport interface PoolData {\n tokenAddress: string;\n poolAddress: string;\n variableBorrowRate: string;\n variableSupplyRate: string;\n ltv: string;\n availableLiquidity: string;\n reserveSize: string;\n}\n\nexport type AAVEAction = PopulatedTransaction[];\n\nexport interface AAVEAdapterParams {\n chainId: number;\n rpcUrl: string;\n wrappedNativeToken?: string; // e.g. WETH address for ETH\n}\n\n// AAVE's ETH placeholder address used for native ETH operations\nconst AAVE_ETH_PLACEHOLDER = '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE';\n\n/**\n * AAVEAdapter is the primary class wrapping Aave V3 interactions.\n */\nexport class AAVEAdapter {\n public chain: Chain;\n public market: AAVEMarket;\n\n constructor(params: AAVEAdapterParams) {\n this.chain = new Chain(params.chainId, params.rpcUrl);\n this.market = getMarket(this.chain.id);\n }\n\n /**\n * If the token is native, return AAVE's placeholder address instead of the ember address.\n * @param token - The token to normalize.\n * @returns The normalized token address.\n */\n public normalizeTokenAddress(token: Token): string {\n return token.isNative ? AAVE_ETH_PLACEHOLDER : token.tokenUid.address;\n }\n\n public async createSupplyTransaction(params: SupplyTokensRequest): Promise<SupplyTokensResponse> {\n const { supplyToken: token, amount, walletAddress } = params;\n const txs = await this.supply(\n this.normalizeTokenAddress(token),\n amount.toString(),\n walletAddress\n );\n return {\n transactions: txs.map(t => transactionPlanFromEthers(this.chain.id.toString(), t)),\n };\n }\n\n public async createWithdrawTransaction(\n params: WithdrawTokensRequest\n ): Promise<WithdrawTokensResponse> {\n const { tokenToWithdraw, amount, walletAddress } = params;\n\n // Find aToken he wants to withdraw from\n const alphaTokenAddress = (await this.getReserves()).reservesData.find(\n reserve => reserve.underlyingAsset === tokenToWithdraw.tokenUid.address\n )?.aTokenAddress;\n if (!alphaTokenAddress) {\n throw new Error('No position can generate the token to withdraw');\n }\n\n const txs = await this.withdraw(alphaTokenAddress, amount, walletAddress, walletAddress);\n return {\n transactions: txs.map(t => transactionPlanFromEthers(this.chain.id.toString(), t)),\n };\n }\n\n public async createBorrowTransaction(params: BorrowTokensRequest): Promise<BorrowTokensResponse> {\n const { borrowToken, amount, walletAddress } = params;\n const normalizedTokenAddress = this.normalizeTokenAddress(borrowToken);\n\n // Get pool data to fetch APR\n const poolData = await this.getPool(normalizedTokenAddress);\n const reservesResponse = await this.getReserves();\n\n let reserveLiquidationThreshold: string | null = null;\n for (const reserve of reservesResponse.reservesData) {\n const token = ethers.utils.getAddress(reserve.underlyingAsset);\n if (token === normalizedTokenAddress) {\n reserveLiquidationThreshold = reserve.reserveLiquidationThreshold;\n }\n }\n\n if (reserveLiquidationThreshold == null) {\n throw new Error('Reserve not found in AAVE pool for a given token');\n }\n\n // Create borrow transaction\n const txs = await this.borrow(normalizedTokenAddress, amount.toString(), walletAddress);\n\n return {\n liquidationThreshold: reserveLiquidationThreshold,\n currentBorrowApy: poolData.variableBorrowRate,\n transactions: txs.map(t => transactionPlanFromEthers(this.chain.id.toString(), t)),\n };\n }\n\n public async createRepayTransaction(params: RepayTokensRequest): Promise<RepayTokensResponse> {\n const { repayToken, amount, walletAddress: from } = params;\n\n const normalizedAsset = this.normalizeTokenAddress(repayToken);\n\n // Choose repayment method based on useATokens flag\n const txs = await this.repay(normalizedAsset, amount.toString(), from);\n\n return {\n transactions: txs.map(t => transactionPlanFromEthers(this.chain.id.toString(), t)),\n };\n }\n\n public async createRepayTransactionWithATokens(\n params: RepayTokensRequest\n ): Promise<RepayTokensResponse> {\n const { repayToken, amount, walletAddress: from } = params;\n\n const normalizedAsset = this.normalizeTokenAddress(repayToken);\n\n // Choose repayment method based on useATokens flag\n const txs = await this.repayWithATokens(normalizedAsset, amount.toString(), from);\n\n return {\n transactions: txs.map(t => transactionPlanFromEthers(this.chain.id.toString(), t)),\n };\n }\n\n // Private Methods\n private getProvider() {\n return this.chain.getProvider();\n }\n\n private getPoolBundle() {\n const provider = this.getProvider();\n return new PoolBundle(provider, {\n POOL: this.market.POOL,\n WETH_GATEWAY: this.market.WETH_GATEWAY,\n });\n }\n\n private async getTokenData(address: string) {\n let targetAddress = address;\n\n // If address is AAVE's native token placeholder, find the corresponding wrapped native token address\n if (address === AAVE_ETH_PLACEHOLDER) {\n const poolData = await this.getPool(address);\n targetAddress = poolData.tokenAddress; // This will be the wrapped native token address\n }\n\n return await this.getPoolBundle().erc20Service.getTokenData(targetAddress);\n }\n\n private getPoolDataProvider(): IUiPoolDataProvider {\n const provider = this.getProvider();\n const DataProviderImpl = getUiPoolDataProviderImpl(this.chain.id);\n return new DataProviderImpl({\n uiPoolDataProviderAddress: this.market.UI_POOL_DATA_PROVIDER,\n provider,\n chainId: this.chain.id,\n });\n }\n\n private getPoolContract() {\n const provider = this.getProvider();\n return new Pool(provider, {\n POOL: this.market.POOL,\n WETH_GATEWAY: this.market.WETH_GATEWAY,\n });\n }\n\n private async getPool(asset: string): Promise<PoolData> {\n const reservesResponse = await this.getReserves();\n\n let targetAsset = asset;\n\n // If asset is AAVE's native token placeholder, find the corresponding wrapped native token reserve\n if (asset === AAVE_ETH_PLACEHOLDER) {\n const configuredWrappedNativeToken = this.chain.wrappedNativeTokenAddress;\n\n if (!configuredWrappedNativeToken) {\n throw new Error(`No wrapped native token configured for chain ${this.chain.id}`);\n }\n\n const wrappedNativeTokenReserve = reservesResponse.reservesData.find(\n (r: ReserveDataHumanized) =>\n ethers.utils.getAddress(r.underlyingAsset) === configuredWrappedNativeToken\n );\n\n if (!wrappedNativeTokenReserve) {\n throw new Error(`Wrapped native token reserve not found for native token operations`);\n }\n\n targetAsset = wrappedNativeTokenReserve.underlyingAsset;\n }\n\n const reserve = reservesResponse.reservesData.find(\n (r: ReserveDataHumanized) =>\n ethers.utils.getAddress(r.underlyingAsset) === ethers.utils.getAddress(targetAsset)\n );\n\n if (!reserve) {\n throw new Error(`Asset ${asset} not found in reserves`);\n }\n\n return {\n tokenAddress: reserve.underlyingAsset,\n poolAddress: this.market.POOL,\n variableBorrowRate: reserve.variableBorrowRate,\n variableSupplyRate: reserve.liquidityRate,\n ltv: reserve.baseLTVasCollateral,\n availableLiquidity: reserve.availableLiquidity,\n reserveSize: reserve.availableLiquidity,\n };\n }\n\n public async getReserves(): Promise<ReservesDataHumanized> {\n const reserves = this.getPoolDataProvider().getReservesHumanized({\n lendingPoolAddressProvider: this.market.POOL_ADDRESSES_PROVIDER,\n });\n return reserves;\n }\n\n public async getUserSummary(\n params: GetWalletLendingPositionsRequest\n ): Promise<GetWalletLendingPositionsResponse> {\n const userSummaryResponse = await this._getUserSummary(params.walletAddress);\n const {\n totalLiquidityUSD,\n totalCollateralUSD,\n totalBorrowsUSD,\n netWorthUSD,\n availableBorrowsUSD,\n currentLoanToValue,\n currentLiquidationThreshold,\n healthFactor,\n userReservesData,\n } = userSummaryResponse.reserves;\n\n const userReservesFormatted = [];\n for (const {\n reserve,\n underlyingBalance,\n underlyingBalanceUSD,\n variableBorrows,\n variableBorrowsUSD,\n totalBorrows,\n totalBorrowsUSD,\n } of userReservesData) {\n const tokenData = await this.getTokenData(reserve.underlyingAsset);\n userReservesFormatted.push({\n token: {\n // TODO: ideally we should populate this object somewhere else,\n // returning only tokenUid in this adapter\n tokenUid: {\n address: reserve.underlyingAsset,\n chainId: this.chain.id.toString(),\n },\n isNative: false,\n name: tokenData.name,\n symbol: tokenData.symbol,\n decimals: tokenData.decimals,\n isVetted: true, // assuming aave only lets really good assets in\n },\n underlyingBalance,\n underlyingBalanceUsd: underlyingBalanceUSD,\n variableBorrows,\n variableBorrowsUsd: variableBorrowsUSD,\n totalBorrows,\n totalBorrowsUsd: totalBorrowsUSD,\n });\n }\n\n return {\n userReserves: userReservesFormatted,\n totalLiquidityUsd: totalLiquidityUSD,\n totalCollateralUsd: totalCollateralUSD,\n totalBorrowsUsd: totalBorrowsUSD,\n netWorthUsd: netWorthUSD,\n availableBorrowsUsd: availableBorrowsUSD,\n currentLoanToValue,\n currentLiquidationThreshold,\n healthFactor,\n };\n }\n\n private async _getUserSummary(userAddress: string): Promise<UserSummary> {\n const validatedUser = ethers.utils.getAddress(userAddress);\n const poolDataProvider = this.getPoolDataProvider();\n\n const reservesResponse = await this.getReserves();\n\n const userReservesResponse = await poolDataProvider.getUserReservesHumanized({\n lendingPoolAddressProvider: this.market.POOL_ADDRESSES_PROVIDER,\n user: validatedUser,\n });\n\n return new UserSummary(userReservesResponse, reservesResponse);\n }\n\n private async borrow(asset: string, amount: string, from: string): Promise<AAVEAction> {\n // validate\n ethers.utils.getAddress(asset);\n ethers.utils.getAddress(from);\n\n const bundle: PoolBundle = this.getPoolBundle();\n\n const tx = bundle.borrowTxBuilder.generateTxData({\n user: from,\n reserve: asset,\n amount,\n interestRateMode: InterestRate.Variable,\n });\n\n return [tx];\n }\n\n private async createApproval({\n asset,\n amount_raw,\n user,\n spender,\n }: {\n spender: string;\n user: string;\n asset: string;\n amount_raw: string;\n }): Promise<PopulatedTransaction | null> {\n const bundle = this.getPoolBundle();\n let approvalTx = null;\n const isApprovedEnough = await bundle.erc20Service.isApproved({\n user: user,\n token: asset,\n spender,\n amount: amount_raw,\n nativeDecimals: true,\n });\n\n if (!isApprovedEnough) {\n approvalTx = bundle.erc20Service.approveTxData({\n user,\n token: asset,\n spender,\n amount: amount_raw,\n });\n }\n\n return approvalTx;\n }\n\n private async supply(asset: string, amount: string, from: string): Promise<AAVEAction> {\n // validate\n ethers.utils.getAddress(asset);\n ethers.utils.getAddress(from);\n\n const bundle = this.getPoolBundle();\n\n const approvalTx = await this.createApproval({\n asset,\n amount_raw: amount,\n user: from,\n spender: bundle.poolAddress,\n });\n\n const tx = bundle.supplyTxBuilder.generateTxData({\n user: from,\n reserve: asset,\n amount,\n onBehalfOf: from,\n });\n\n return (approvalTx ? [approvalTx] : []).concat([tx]);\n }\n\n private async repay(asset: string, amount_formatted: string, from: string): Promise<AAVEAction> {\n // validate\n ethers.utils.getAddress(asset);\n ethers.utils.getAddress(from);\n\n const bundle: PoolBundle = this.getPoolBundle();\n\n const amount = utils\n .parseUnits(amount_formatted, (await this.getTokenData(asset)).decimals)\n .toString();\n\n const tx = bundle.repayTxBuilder.generateTxData({\n user: from,\n reserve: asset,\n amount: amount,\n interestRateMode: InterestRate.Variable,\n onBehalfOf: from,\n });\n\n const approvalTx = await this.createApproval({\n asset,\n amount_raw: amount,\n user: from,\n spender: bundle.poolAddress,\n });\n\n return (approvalTx ? [approvalTx] : []).concat([tx]);\n }\n\n private async repayWithATokens(\n asset: string,\n amount_formatted: string,\n from: string\n ): Promise<AAVEAction> {\n ethers.utils.getAddress(asset);\n ethers.utils.getAddress(from);\n const bundle = this.getPoolBundle();\n const tokenData = await this.getTokenData(asset);\n const amount = utils.parseUnits(amount_formatted, tokenData.decimals).toString();\n const tx = bundle.repayWithATokensTxBuilder.generateTxData({\n user: from,\n reserve: asset,\n amount,\n rateMode: InterestRate.Variable,\n });\n return [tx];\n }\n\n private async withdraw(\n asset: string,\n amount: bigint,\n to: string,\n from: string\n ): Promise<AAVEAction> {\n ethers.utils.getAddress(asset);\n ethers.utils.getAddress(to);\n ethers.utils.getAddress(from);\n\n const pool = this.getPoolContract();\n const txs = await pool.withdraw({\n user: from,\n reserve: asset,\n amount: amount.toString(),\n });\n\n if (txs.length !== 1) {\n throw new Error('AAVEInstance.withdraw: impossible happened');\n }\n\n // Null coercion is safe here because we checked txs.length above\n return [await populateTransaction(txs[0]!)];\n }\n}\n\nconst transactionPlanFromEthers = (\n chainId: string,\n tx: ethers.PopulatedTransaction\n): TransactionPlan => {\n return {\n type: TransactionTypes.EVM_TX,\n to: tx.to!,\n value: tx.value?.toString() || '0',\n data: tx.data!,\n chainId,\n };\n};\n","import { z } from 'zod';\nimport { ChainTypeSchema, TransactionTypeSchema } from './enums.js';\n\nexport const TokenIdentifierSchema = z.object({\n chainId: z.string(),\n address: z.string(),\n});\nexport type TokenIdentifier = z.infer<typeof TokenIdentifierSchema>;\n\nexport const TokenSchema = z.object({\n tokenUid: TokenIdentifierSchema,\n name: z.string(),\n symbol: z.string(),\n isNative: z.boolean(),\n decimals: z.number().int(),\n iconUri: z.string().nullish(),\n isVetted: z.boolean(),\n});\nexport type Token = z.infer<typeof TokenSchema>;\n\nexport const ChainSchema = z.object({\n chainId: z.string(),\n type: ChainTypeSchema,\n iconUri: z.string(),\n nativeToken: TokenSchema,\n httpRpcUrl: z.string(),\n name: z.string(),\n blockExplorerUrls: z.array(z.string()),\n});\nexport type Chain = z.infer<typeof ChainSchema>;\n\nexport const FeeBreakdownSchema = z.object({\n serviceFee: z.string(),\n slippageCost: z.string(),\n total: z.string(),\n feeDenomination: z.string(),\n});\nexport type FeeBreakdown = z.infer<typeof FeeBreakdownSchema>;\n\nexport const TransactionPlanSchema = z.object({\n type: TransactionTypeSchema,\n to: z.string(),\n data: z.string(),\n value: z.string(),\n chainId: z.string(),\n});\nexport type TransactionPlan = z.infer<typeof TransactionPlanSchema>;\n\nexport const TransactionPlanErrorSchema = z.object({\n code: z.string(),\n message: z.string(),\n details: z.record(z.string()),\n});\nexport type TransactionPlanError = z.infer<typeof TransactionPlanErrorSchema>;\n\nexport const ProviderTrackingInfoSchema = z.object({\n requestId: z.string(),\n providerName: z.string(),\n explorerUrl: z.string(),\n});\nexport type ProviderTrackingInfo = z.infer<typeof ProviderTrackingInfoSchema>;\n\nexport const SwapEstimationSchema = z.object({\n effectivePrice: z.string(),\n timeEstimate: z.string(),\n expiration: z.string(),\n});\nexport type SwapEstimation = z.infer<typeof SwapEstimationSchema>;\n\nexport const ProviderTrackingStatusSchema = z.object({\n requestId: z.string(),\n transactionId: z.string(),\n providerName: z.string(),\n explorerUrl: z.string(),\n status: z.string(),\n});\nexport type ProviderTrackingStatus = z.infer<typeof ProviderTrackingStatusSchema>;\n","import { z } from 'zod';\n\nexport const ChainTypeSchema = z.enum(['UNSPECIFIED', 'EVM', 'SOLANA', 'COSMOS']);\nexport type ChainType = z.infer<typeof ChainTypeSchema>;\n\n// TransactionType\nexport const TransactionTypes = {\n TRANSACTION_TYPE_UNSPECIFIED: 'TRANSACTION_TYPE_UNSPECIFIED' as const,\n EVM_TX: 'EVM_TX' as const,\n SOLANA_TX: 'SOLANA_TX' as const,\n} as const;\n\nexport const TransactionTypeSchema = z.enum(\n Object.values(TransactionTypes) as [string, ...string[]]\n);\nexport type TransactionType = keyof typeof TransactionTypes;\n","import { z } from 'zod';\nimport { FeeBreakdownSchema, TransactionPlanSchema, TokenSchema } from './core.js';\n\nexport const BorrowTokensRequestSchema = z.object({\n borrowToken: TokenSchema,\n amount: z.bigint(),\n walletAddress: z.string(),\n});\nexport type BorrowTokensRequest = z.infer<typeof BorrowTokensRequestSchema>;\n\nexport const BorrowTokensResponseSchema = z.object({\n currentBorrowApy: z.string(),\n liquidationThreshold: z.string(),\n feeBreakdown: FeeBreakdownSchema.optional(),\n transactions: z.array(TransactionPlanSchema),\n});\nexport type BorrowTokensResponse = z.infer<typeof BorrowTokensResponseSchema>;\n\nexport const RepayTokensRequestSchema = z.object({\n repayToken: TokenSchema,\n amount: z.bigint(),\n walletAddress: z.string(),\n});\nexport type RepayTokensRequest = z.infer<typeof RepayTokensRequestSchema>;\n\nexport const RepayTokensResponseSchema = z.object({\n feeBreakdown: FeeBreakdownSchema.optional(),\n transactions: z.array(TransactionPlanSchema),\n});\nexport type RepayTokensResponse = z.infer<typeof RepayTokensResponseSchema>;\n\nexport const SupplyTokensRequestSchema = z.object({\n supplyToken: TokenSchema,\n amount: z.bigint(),\n walletAddress: z.string(),\n});\nexport type SupplyTokensRequest = z.infer<typeof SupplyTokensRequestSchema>;\n\nexport const SupplyTokensResponseSchema = z.object({\n feeBreakdown: FeeBreakdownSchema.optional(),\n transactions: z.array(TransactionPlanSchema),\n});\nexport type SupplyTokensResponse = z.infer<typeof SupplyTokensResponseSchema>;\n\nexport const WithdrawTokensRequestSchema = z.object({\n tokenToWithdraw: TokenSchema,\n amount: z.bigint(),\n walletAddress: z.string(),\n});\nexport type WithdrawTokensRequest = z.infer<typeof WithdrawTokensRequestSchema>;\n\nexport const WithdrawTokensResponseSchema = z.object({\n feeBreakdown: FeeBreakdownSchema.optional(),\n transactions: z.array(TransactionPlanSchema),\n});\nexport type WithdrawTokensResponse = z.infer<typeof WithdrawTokensResponseSchema>;\n\nexport const TokenPositionSchema = z.object({\n underlyingToken: TokenSchema,\n borrowRate: z.string(),\n supplyBalance: z.string(),\n borrowBalance: z.string(),\n valueUsd: z.string(),\n});\nexport type TokenPosition = z.infer<typeof TokenPositionSchema>;\n\nexport const GetWalletLendingPositionsRequestSchema = z.object({\n walletAddress: z.string(),\n});\nexport type GetWalletLendingPositionsRequest = z.infer<\n typeof GetWalletLendingPositionsRequestSchema\n>;\n\nexport const LendTokenDetailSchema = z.object({\n token: TokenSchema,\n underlyingBalance: z.string(),\n underlyingBalanceUsd: z.string(),\n variableBorrows: z.string(),\n variableBorrowsUsd: z.string(),\n totalBorrows: z.string(),\n totalBorrowsUsd: z.string(),\n});\nexport type LendTokenDetail = z.infer<typeof LendTokenDetailSchema>;\n\nexport const GetWalletLendingPositionsResponseSchema = z.object({\n userReserves: z.array(LendTokenDetailSchema),\n totalLiquidityUsd: z.string(),\n totalCollateralUsd: z.string(),\n totalBorrowsUsd: z.string(),\n netWorthUsd: z.string(),\n availableBorrowsUsd: z.string(),\n currentLoanToValue: z.string(),\n currentLiquidationThreshold: z.string(),\n healthFactor: z.string(),\n});\nexport type GetWalletLendingPositionsResponse = z.infer<\n typeof GetWalletLendingPositionsResponseSchema\n>;\n","import { z } from 'zod';\nimport { TokenIdentifierSchema, TransactionPlanSchema } from './core.js';\n\nexport const LimitedLiquidityProvisionRangeSchema = z.object({\n minPrice: z.string(),\n maxPrice: z.string(),\n});\nexport type LimitedLiquidityProvisionRange = z.infer<typeof LimitedLiquidityProvisionRangeSchema>;\n\nexport const LiquidityProvisionRangeSchema = z.discriminatedUnion('type', [\n z.object({\n type: z.literal('full'),\n }),\n z.object({\n type: z.literal('limited'),\n minPrice: z.string(),\n maxPrice: z.string(),\n }),\n]);\nexport type LiquidityProvisionRange = z.infer<typeof LiquidityProvisionRangeSchema>;\n\nexport const LiquidityPositionRangeSchema = z.object({\n fromPrice: z.string(),\n toPrice: z.string(),\n});\nexport type LiquidityPositionRange = z.infer<typeof LiquidityPositionRangeSchema>;\n\nexport const LiquidityPositionSchema = z.object({\n tokenId: z.string(),\n poolAddress: z.string(),\n operator: z.string(),\n token0: TokenIdentifierSchema,\n token1: TokenIdentifierSchema,\n tokensOwed0: z.string(),\n tokensOwed1: z.string(),\n amount0: z.string(),\n amount1: z.string(),\n symbol0: z.string(),\n symbol1: z.string(),\n price: z.string(),\n providerId: z.string(),\n positionRange: LiquidityPositionRangeSchema.optional(),\n});\nexport type LiquidityPosition = z.infer<typeof LiquidityPositionSchema>;\n\nexport const LiquidityPoolSchema = z.object({\n token0: TokenIdentifierSchema,\n token1: TokenIdentifierSchema,\n symbol0: z.string(),\n symbol1: z.string(),\n price: z.string(),\n providerId: z.string(),\n});\nexport type LiquidityPool = z.infer<typeof LiquidityPoolSchema>;\n\nexport const SupplyLiquidityRequestSchema = z.object({\n token0: TokenIdentifierSchema,\n token1: TokenIdentifierSchema,\n amount0: z.bigint(),\n amount1: z.bigint(),\n range: LiquidityProvisionRangeSchema,\n walletAddress: z.string(),\n});\nexport type SupplyLiquidityRequest = z.infer<typeof SupplyLiquidityRequestSchema>;\n\nexport const SupplyLiquidityResponseSchema = z.object({\n transactions: z.array(TransactionPlanSchema),\n chainId: z.string(),\n});\nexport type SupplyLiquidityResponse = z.infer<typeof SupplyLiquidityResponseSchema>;\n\nexport const WithdrawLiquidityRequestSchema = z.object({\n tokenId: z.string(),\n walletAddress: z.string(),\n});\nexport type WithdrawLiquidityRequest = z.infer<typeof WithdrawLiquidityRequestSchema>;\n\nexport const WithdrawLiquidityResponseSchema = z.object({\n transactions: z.array(TransactionPlanSchema),\n chainId: z.string(),\n});\nexport type WithdrawLiquidityResponse = z.infer<typeof WithdrawLiquidityResponseSchema>;\n\nexport const GetWalletLiquidityPositionsRequestSchema = z.object({\n walletAddress: z.string(),\n});\nexport type GetWalletLiquidityPositionsRequest = z.infer<\n typeof GetWalletLiquidityPositionsRequestSchema\n>;\n\nexport const GetWalletLiquidityPositionsResponseSchema = z.object({\n positions: z.array(LiquidityPositionSchema),\n});\nexport type GetWalletLiquidityPositionsResponse = z.infer<\n typeof GetWalletLiquidityPositionsResponseSchema\n>;\n\nexport const GetLiquidityPoolsResponseSchema = z.object({\n liquidityPools: z.array(LiquidityPoolSchema),\n});\nexport type GetLiquidityPoolsResponse = z.infer<typeof GetLiquidityPoolsResponseSchema>;\n","import { z } from 'zod';\nimport { TransactionPlanSchema, TokenIdentifierSchema } from './core.js';\nimport { DecreasePositionSwapType, OrderType } from '@gmx-io/sdk/types/orders';\n\n// Enums\nexport const DecreasePositionSwapTypeSchema = z.nativeEnum(DecreasePositionSwapType);\n\nexport const PositionSideSchema = z.union([z.literal('long'), z.literal('short')]);\n\nexport type PositionSide = z.infer<typeof PositionSideSchema>;\n\n// API Schemas and types\nexport const PositionSchema = z.object({\n chainId: z.string(),\n key: z.string(),\n contractKey: z.string(),\n account: z.string(),\n marketAddress: z.string(),\n collateralTokenAddress: z.string(),\n sizeInUsd: z.string(),\n sizeInTokens: z.string(),\n collateralAmount: z.string(),\n pendingBorrowingFeesUsd: z.string(),\n increasedAtTime: z.string(),\n decreasedAtTime: z.string(),\n positionSide: PositionSideSchema,\n isLong: z.boolean(),\n fundingFeeAmount: z.string(),\n claimableLongTokenAmount: z.string(),\n claimableShortTokenAmount: z.string(),\n isOpening: z.boolean().optional(),\n pnl: z.string(),\n positionFeeAmount: z.string(),\n traderDiscountAmount: z.string(),\n uiFeeAmount: z.string(),\n data: z.string().optional(),\n});\n\nexport type PerpetualsPosition = z.infer<typeof PositionSchema>;\n\nexport const PositionsDataSchema = z.array(PositionSchema);\n\n// Order Schema\nexport const OrderSchema = z.object({\n chainId: z.string(),\n key: z.string(),\n account: z.string(),\n callbackContract: z.string(),\n initialCollateralTokenAddress: z.string(),\n marketAddress: z.string(),\n decreasePositionSwapType: DecreasePositionSwapTypeSchema,\n receiver: z.string(),\n swapPath: z.array(z.string()),\n contractAcceptablePrice: z.string(),\n contractTriggerPrice: z.string(),\n callbackGasLimit: z.string(),\n executionFee: z.string(),\n initialCollateralDeltaAmount: z.string(),\n minOutputAmount: z.string(),\n sizeDeltaUsd: z.string(),\n updatedAtTime: z.string(),\n isFrozen: z.boolean(),\n positionSide: PositionSideSchema,\n orderType: z.nativeEnum(OrderType),\n shouldUnwrapNativeToken: z.boolean(),\n autoCancel: z.boolean(),\n data: z.string().optional(),\n uiFeeReceiver: z.string(),\n validFromTime: z.string(),\n title: z.string().optional(),\n});\n\nexport type PerpetualsOrder = z.infer<typeof OrderSchema>;\n\nexport const OrdersDataSchema = z.array(OrderSchema);\n\n// Definition for plugin with mapped entities already in place\nexport const CreatePerpetualsPositionRequestSchema = z.object({\n amount: z.bigint(),\n walletAddress: z.string(),\n chainId: z.string(),\n marketAddress: z.string(),\n payTokenAddress: z.string(),\n collateralTokenAddress: z.string(),\n referralCode: z.string().optional(),\n limitPrice: z.string().optional(),\n leverage: z.string(),\n});\n\nexport type CreatePerpetualsPositionRequest = z.infer<typeof CreatePerpetualsPositionRequestSchema>;\n\nexport const CreatePerpetualsPositionResponseSchema = z.object({\n transactions: z.array(TransactionPlanSchema),\n});\nexport type CreatePerpetualsPositionResponse = z.infer<\n typeof CreatePerpetualsPositionResponseSchema\n>;\n\nexport const GetPerpetualsMarketsPositionsRequestSchema = z.object({\n walletAddress: z.string().describe(\"User's wallet address\"),\n});\n\nexport type GetPerpetualsMarketsPositionsRequest = z.infer<\n typeof GetPerpetualsMarketsPositionsRequestSchema\n>;\n\nexport const GetPerpetualsMarketsPositionsResponseSchema = z.object({\n positions: PositionsDataSchema,\n});\n\nexport type GetPerpetualsMarketsPositionsResponse = z.infer<\n typeof GetPerpetualsMarketsPositionsResponseSchema\n>;\n\nexport const GetPerpetualsMarketsOrdersRequestSchema = z.object({\n walletAddress: z.string().describe(\"User's wallet address\"),\n});\n\nexport type GetPerpetualsMarketsOrdersRequest = z.infer<\n typeof GetPerpetualsMarketsOrdersRequestSchema\n>;\n\nexport const GetPerpetualsMarketsOrdersResponseSchema = z.object({\n orders: OrdersDataSchema,\n});\n\nexport type GetPerpetualsMarketsOrdersResponse = z.infer<\n typeof GetPerpetualsMarketsOrdersResponseSchema\n>;\n\nexport const ClosePerpetualsOrdersRequestSchema = z.object({\n walletAddress: z.string().describe(\"User's wallet address\"),\n key: z.string(),\n});\n\nexport type ClosePerpetualsOrdersRequest = z.infer<typeof ClosePerpetualsOrdersRequestSchema>;\n\nexport const ClosePerpetualsOrdersResponseSchema = z.object({\n transactions: z.array(TransactionPlanSchema),\n});\n\nexport type ClosePerpetualsOrdersResponse = z.infer<typeof ClosePerpetualsOrdersResponseSchema>;\n\nexport const GetPerpetualsMarketsRequestSchema = z.object({\n chainIds: z.array(z.string()),\n});\n\nexport type GetPerpetualsMarketsRequest = z.infer<typeof GetPerpetualsMarketsRequestSchema>;\n\nexport const PerpetualMarketSchema = z.object({\n marketToken: TokenIdentifierSchema,\n indexToken: TokenIdentifierSchema,\n longToken: TokenIdentifierSchema,\n shortToken: TokenIdentifierSchema,\n longFundingFee: z.string(),\n shortFundingFee: z.string(),\n longBorrowingFee: z.string(),\n shortBorrowingFee: z.string(),\n chainId: z.string(),\n name: z.string(),\n});\n\nexport type PerpetualMarket = z.infer<typeof PerpetualMarketSchema>;\n\nexport const GetPerpetualsMarketsResponseSchema = z.object({\n markets: z.array(PerpetualMarketSchema),\n});\n\nexport type GetPerpetualsMarketsResponse = z.infer<typeof GetPerpetualsMarketsResponseSchema>;\n","import { z } from 'zod';\nimport {\n FeeBreakdownSchema,\n TransactionPlanSchema,\n SwapEstimationSchema,\n ProviderTrackingInfoSchema,\n TokenSchema,\n} from './core.js';\n\nexport const SwapTokensRequestSchema = z.object({\n fromToken: TokenSchema,\n toToken: TokenSchema,\n amount: z.bigint(),\n limitPrice: z.string().optional(),\n slippageTolerance: z.string().optional(),\n expiration: z.string().optional(),\n recipient: z.string(),\n});\nexport type SwapTokensRequest = z.infer<typeof SwapTokensRequestSchema>;\n\nexport const SwapTokensResponseSchema = z.object({\n fromToken: TokenSchema,\n toToken: TokenSchema,\n exactFromAmount: z.string(),\n displayFromAmount: z.string(),\n exactToAmount: z.string(),\n displayToAmount: z.string(),\n transactions: z.array(TransactionPlanSchema),\n feeBreakdown: FeeBreakdownSchema.optional(),\n estimation: SwapEstimationSchema.optional(),\n providerTracking: ProviderTrackingInfoSchema.optional(),\n});\nexport type SwapTokensResponse = z.infer<typeof SwapTokensResponseSchema>;\n","import type { ActionDefinition, EmberPlugin, LendingActions } from '../core/index.js';\nimport { AAVEAdapter, type AAVEAdapterParams } from './adapter.js';\nimport type { ChainConfig } from '../chainConfig.js';\nimport type { PublicEmberPluginRegistry } from '../registry.js';\n\n/**\n * Get the AAVE Ember plugin.\n * @param params - Configuration parameters for the AAVEAdapter, including chainId and rpcUrl.\n * @returns The AAVE Ember plugin.\n */\nexport async function getAaveEmberPlugin(\n params: AAVEAdapterParams\n): Promise<EmberPlugin<'lending'>> {\n const adapter = new AAVEAdapter(params);\n\n return {\n id: `AAVE_CHAIN_${params.chainId}`,\n type: 'lending',\n name: `AAVE lending for ${params.chainId}`,\n description: 'Aave V3 lending protocol',\n website: 'https://aave.com',\n x: 'https://x.com/aave',\n actions: await getAaveActions(adapter),\n queries: {\n getPositions: adapter.getUserSummary.bind(adapter),\n },\n };\n}\n\n/**\n * Get the AAVE actions for the lending protocol.\n * @param adapter - An instance of AAVEAdapter to interact with the AAVE protocol.\n * @returns An array of action definitions for the AAVE lending protocol.\n */\nexport async function getAaveActions(\n adapter: AAVEAdapter\n): Promise<ActionDefinition<LendingActions>[]> {\n const reservesResponse = await adapter.getReserves();\n\n const underlyingAssets: string[] = reservesResponse.reservesData.map(\n reserve => reserve.underlyingAsset\n );\n const aTokens: string[] = reservesResponse.reservesData.map(reserve => reserve.aTokenAddress);\n const borrowableAssets = reservesResponse.reservesData\n .filter(reserve => reserve.borrowingEnabled)\n .map(reserve => reserve.underlyingAsset);\n\n return [\n // Supply any of the underlying assets to get aTokens\n {\n type: 'lending-supply',\n name: `AAVE lending pools in chain ${adapter.chain.id}`,\n inputTokens: async () =>\n Promise.resolve([\n {\n chainId: adapter.chain.id.toString(),\n tokens: underlyingAssets,\n },\n ]),\n outputTokens: async () =>\n Promise.resolve([\n {\n chainId: adapter.chain.id.toString(),\n tokens: aTokens,\n },\n ]),\n callback: adapter.createSupplyTransaction.bind(adapter),\n },\n\n // Borrow any of the borrowable assets if you have some alpha tokens as collateral\n {\n type: 'lending-borrow',\n name: `AAVE borrow in chain ${adapter.chain.id}`,\n inputTokens: async () =>\n Promise.resolve([\n {\n chainId: adapter.chain.id.toString(),\n tokens: aTokens,\n },\n ]),\n outputTokens: async () =>\n Promise.resolve([\n {\n chainId: adapter.chain.id.toString(),\n tokens: borrowableAssets,\n },\n ]),\n callback: adapter.createBorrowTransaction.bind(adapter),\n },\n\n // Repay your borrow with the underlying asset\n {\n type: 'lending-repay',\n name: `AAVE repay in chain ${adapter.chain.id}`,\n inputTokens: async () =>\n Promise.resolve([\n {\n chainId: adapter.chain.id.toString(),\n tokens: borrowableAssets,\n },\n ]),\n // Empty output tokens as this doesn't generate any token\n outputTokens: async () => Promise.resolve([]),\n callback: adapter.createRepayTransaction.bind(adapter),\n },\n\n // Repay your borrow with aTokens\n {\n type: 'lending-repay',\n name: `AAVE repay with aTokens in chain ${adapter.chain.id}`,\n inputTokens: async () =>\n Promise.resolve([\n {\n chainId: adapter.chain.id.toString(),\n tokens: aTokens,\n },\n ]),\n // Empty output tokens as this doesn't generate any token\n outputTokens: async () => Promise.resolve([]),\n callback: adapter.createRepayTransactionWithATokens.bind(adapter),\n },\n\n // Withdraw from your aTokens to get the underlying asset back\n {\n type: 'lending-withdraw',\n name: `AAVE withdraw in chain ${adapter.chain.id}`,\n inputTokens: async () =>\n Promise.resolve([\n {\n chainId: adapter.chain.id.toString(),\n tokens: aTokens,\n },\n ]),\n outputTokens: async () =>\n Promise.resolve([\n {\n chainId: adapter.chain.id.toString(),\n tokens: underlyingAssets,\n },\n ]),\n callback: adapter.createWithdrawTransaction.bind(adapter),\n },\n ];\n}\n\n/**\n * Register the AAVE plugin for the specified chain configuration.\n * @param chainConfig - The chain configuration to check for AAVE support.\n * @param registry - The public Ember plugin registry to register the plugin with.\n * @returns A promise that resolves when the plugin is registered.\n */\nexport function registerAave(chainConfig: ChainConfig, registry: PublicEmberPluginRegistry) {\n const supportedChains = [42161];\n if (!supportedChains.includes(chainConfig.chainId)) {\n return;\n }\n\n registry.registerDeferredPlugin(\n getAaveEmberPlugin({\n chainId: chainConfig.chainId,\n rpcUrl: chainConfig.rpcUrl,\n wrappedNativeToken: chainConfig.wrappedNativeToken,\n })\n );\n}\n","import type { ChainConfig } from './chainConfig.js';\nimport { PublicEmberPluginRegistry } from './registry.js';\nimport { registerAave } from './aave-lending-plugin/index.js';\n\n/**\n * Initialize the public Ember plugin registry.\n * @returns The initialized public Ember plugin registry with registered plugins.\n */\nexport function initializePublicRegistry(chainConfigs: ChainConfig[]) {\n const registry = new PublicEmberPluginRegistry();\n\n // Register any plugin in here\n for (const chainConfig of chainConfigs) {\n // Create aave plugins for each chain config\n registerAave(chainConfig, registry);\n }\n\n return registry;\n}\n\nexport { type ChainConfig, PublicEmberPluginRegistry };\nexport * from './core/index.js';\n"],"mappings":";AAKO,IAAM,4BAAN,MAAgC;AAAA,EAC7B,UAAqC,CAAC;AAAA,EACtC,kBAAsD,CAAC;AAAA;AAAA;AAAA;AAAA;AAAA,EAMxD,eAAe,QAAiC;AACrD,SAAK,QAAQ,KAAK,MAAM;AAAA,EAC1B;AAAA;AAAA;AAAA;AAAA;AAAA,EAMO,uBAAuB,eAAiD;AAC7E,SAAK,gBAAgB,KAAK,aAAa;AAAA,EACzC;AAAA;AAAA;AAAA;AAAA,EAKA,OAAc,aAAqD;AACjE,WAAO,KAAK;AAEZ,eAAW,iBAAiB,KAAK,iBAAiB;AAChD,YAAM,SAAS,MAA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AAY;AAAA,MACrB,QAAQ,YAAY;AAAA,MACpB,oBAAoB,YAAY;AAAA,IAClC,CAAC;AAAA,EACH;AACF;;;AC5JO,SAAS,yBAAyB,cAA6B;AACpE,QAAM,WAAW,IAAI,0BAA0B;AAG/C,aAAW,eAAe,cAAc;AAEtC,iBAAa,aAAa,QAAQ;AAAA,EACpC;AAEA,SAAO;AACT;","names":["ethers","ethers","ethers","z","z","z","z","z","z","z","z","z","z","ethers","totalBorrowsUSD"]}
1
+ {"version":3,"sources":["../src/registry.ts","../src/aave-lending-plugin/chain.ts","../src/aave-lending-plugin/market.ts","../src/aave-lending-plugin/userSummary.ts","../src/aave-lending-plugin/populateTransaction.ts","../src/aave-lending-plugin/errors.ts","../src/aave-lending-plugin/dataProvider.ts","../src/aave-lending-plugin/adapter.ts","../src/core/schemas/core.ts","../src/core/schemas/enums.ts","../src/core/schemas/lending.ts","../src/core/schemas/liquidity.ts","../src/core/schemas/perpetuals.ts","../src/core/schemas/swap.ts","../src/aave-lending-plugin/index.ts","../src/index.ts"],"sourcesContent":["import type { EmberPlugin, PluginType } from './core/index.js';\n\n/**\n * Registry for public Ember plugins.\n */\nexport class PublicEmberPluginRegistry {\n private plugins: EmberPlugin<PluginType>[] = [];\n private deferredPlugins: Promise<EmberPlugin<PluginType>>[] = [];\n\n /**\n * Register a new Ember plugin.\n * @param plugin The plugin to register.\n */\n public registerPlugin(plugin: EmberPlugin<PluginType>) {\n this.plugins.push(plugin);\n }\n\n /**\n * Register a new deferred Ember plugin.\n * @param pluginPromise The promise resolving to the plugin to register.\n */\n public registerDeferredPlugin(pluginPromise: Promise<EmberPlugin<PluginType>>) {\n this.deferredPlugins.push(pluginPromise);\n }\n\n /**\n * Iterator for the registered Ember plugins.\n */\n public async *getPlugins(): AsyncIterable<EmberPlugin<PluginType>> {\n yield* this.plugins;\n\n for (const pluginPromise of this.deferredPlugins) {\n const plugin = await pluginPromise;\n\n // Register the plugin now that it is resolved\n this.registerPlugin(plugin);\n\n yield plugin;\n }\n\n this.deferredPlugins = [];\n }\n\n public get emberPlugins(): EmberPlugin<PluginType>[] {\n return this.plugins;\n }\n}\n","import { ethers } from 'ethers';\n\n/**\n * Represents a blockchain network configuration used to create JSON-RPC providers and\n * hold basic chain-specific metadata.\n *\n * The Chain class encapsulates:\n * - a numeric chain identifier (id),\n * - an RPC URL to connect to the chain (rpcUrl),\n * - an optional wrapped native token address (wrappedNativeTokenAddress).\n *\n * @param id - The numeric identifier for the chain (e.g., 1 for Ethereum mainnet).\n * @param rpcUrl - The JSON-RPC endpoint URL used to create providers for this chain.\n * @param wrappedNativeTokenAddress - Optional address of the chain's wrapped native token (if applicable).\n */\nexport class Chain {\n constructor(\n public id: number,\n public rpcUrl: string,\n public wrappedNativeTokenAddress?: string\n ) {}\n\n /**\n * Create and return an ethers.js JsonRpcProvider configured with this chain's RPC URL.\n *\n * This method constructs a new ethers.providers.JsonRpcProvider each time it is called.\n * Consumers may cache the provider if they intend to reuse it to avoid allocating multiple instances.\n *\n * @returns An instance of ethers.providers.JsonRpcProvider configured with the chain's rpcUrl.\n */\n public getProvider(): ethers.providers.JsonRpcProvider {\n return new ethers.providers.JsonRpcProvider(this.rpcUrl);\n }\n}\n","import * as markets from '@bgd-labs/aave-address-book';\n\n// AAVE market selection provided by aave-address-book is not very typescript-friendly:\n// we have to trust that the structure of their modules is the same, which\n// seems to be the case.\n\n// An interface that only contains fields of market definitions that we actually use\nexport type AAVEMarket = {\n AAVE_PROTOCOL_DATA_PROVIDER: string;\n POOL: string;\n POOL_ADDRESSES_PROVIDER: string;\n UI_INCENTIVE_DATA_PROVIDER: string;\n UI_POOL_DATA_PROVIDER: string;\n WALLET_BALANCE_PROVIDER: string;\n WETH_GATEWAY: string;\n};\n\nconst marketMap: Record<number, keyof typeof markets> = {\n 1: 'AaveV3Ethereum',\n 11155111: 'AaveV3Sepolia',\n 42161: 'AaveV3Arbitrum',\n 421614: 'AaveV3ArbitrumSepolia',\n 8453: 'AaveV3Base',\n 137: 'AaveV3Polygon',\n 10: 'AaveV3Optimism',\n};\n\nexport const getMarket = (chainId: number): AAVEMarket => {\n const marketKey = marketMap[chainId];\n if (!marketKey) {\n throw new Error(\n `AAVE: no market found for chain ID ${chainId}: modify providers/aave/market.ts`\n );\n }\n\n const market = markets[marketKey] as unknown as AAVEMarket;\n if (!market) {\n throw new Error(`No such market: ${marketKey}`);\n }\n\n return market;\n};\n","import type { ReservesDataHumanized, UserReserveDataHumanized } from '@aave/contract-helpers';\nimport {\n formatReserves,\n formatUserSummary,\n type FormatUserSummaryResponse,\n type FormatReserveUSDResponse,\n} from '@aave/math-utils';\n\nfunction formatNumeric(value: string): string {\n const num = parseFloat(value);\n if (Number.isInteger(num)) return num.toString();\n return parseFloat(num.toFixed(2)).toString();\n}\n\nexport class UserSummary {\n public reserves: FormatUserSummaryResponse<FormatReserveUSDResponse>;\n\n /**\n * @param userReservesResponse - The response from getUserReservesHumanized.\n * @param reservesResponse - The response from getReservesHumanized.\n */\n constructor(\n userReservesResponse: {\n userReserves: UserReserveDataHumanized[];\n userEmodeCategoryId: number;\n },\n reservesResponse: ReservesDataHumanized\n ) {\n const currentTimestamp = Date.now() / 1000;\n\n const formattedReserves = formatReserves({\n reserves: reservesResponse.reservesData,\n currentTimestamp,\n marketReferenceCurrencyDecimals:\n reservesResponse.baseCurrencyData.marketReferenceCurrencyDecimals,\n marketReferencePriceInUsd:\n reservesResponse.baseCurrencyData.marketReferenceCurrencyPriceInUsd,\n });\n\n this.reserves = formatUserSummary({\n currentTimestamp,\n marketReferencePriceInUsd:\n reservesResponse.baseCurrencyData.marketReferenceCurrencyPriceInUsd,\n marketReferenceCurrencyDecimals:\n reservesResponse.baseCurrencyData.marketReferenceCurrencyDecimals,\n userReserves: userReservesResponse.userReserves,\n formattedReserves,\n userEmodeCategoryId: userReservesResponse.userEmodeCategoryId,\n });\n }\n\n public toHumanReadable(): string {\n let output = 'User Positions:\\n';\n output += `Total Liquidity (USD): ${formatNumeric(this.reserves.totalLiquidityUSD)}\\n`;\n output += `Total Collateral (USD): ${formatNumeric(this.reserves.totalCollateralUSD)}\\n`;\n output += `Total Borrows (USD): ${formatNumeric(this.reserves.totalBorrowsUSD)}\\n`;\n output += `Net Worth (USD): ${formatNumeric(this.reserves.netWorthUSD)}\\n`;\n output += `Health Factor: ${formatNumeric(this.reserves.healthFactor)}\\n\\n`;\n output += 'Deposits:\\n';\n for (const entry of this.reserves.userReservesData) {\n if (parseFloat(entry.scaledATokenBalance) > 0) {\n const underlying = entry.underlyingBalance;\n const underlyingUSD = entry.underlyingBalanceUSD\n ? formatNumeric(entry.underlyingBalanceUSD)\n : 'N/A';\n output += `- ${entry.reserve.symbol}: ${underlying} (USD: ${underlyingUSD})\\n`;\n }\n }\n output += '\\nLoans:\\n';\n for (const entry of this.reserves.userReservesData) {\n const borrow = entry.totalBorrows || '0';\n if (parseFloat(borrow) > 0) {\n const totalBorrows = entry.totalBorrows;\n const totalBorrowsUSD = entry.totalBorrowsUSD\n ? formatNumeric(entry.totalBorrowsUSD)\n : 'N/A';\n output += `- ${entry.reserve.symbol}: ${totalBorrows} (USD: ${totalBorrowsUSD})\\n`;\n }\n }\n return output;\n }\n}\n","import type { EthereumTransactionTypeExtended } from '@aave/contract-helpers';\nimport { type PopulatedTransaction, ethers } from 'ethers';\nimport { getAaveError } from './errors.js';\n\nexport async function populateTransaction(\n tx: EthereumTransactionTypeExtended\n): Promise<PopulatedTransaction> {\n let txData = null;\n try {\n txData = await tx.tx();\n /* eslint-disable @typescript-eslint/no-explicit-any */\n } catch (e: any) {\n /* eslint-enable @typescript-eslint/no-explicit-any */\n\n // error reason looks like 'execution reverted: revert: 32', with the aave\n // domain error code at the very end\n const errorCode = (e.reason || '').split(' ').pop();\n // If we end up passing garbage to getAaveError, it does not matter - it will return null\n const aaveError = getAaveError(errorCode);\n if (aaveError !== null) {\n throw aaveError;\n } else {\n // we can hope that the LLM will provide an analysis of the error on the fly\n throw e;\n }\n }\n return {\n value: ethers.BigNumber.from(txData.value || 0),\n from: txData.from,\n to: txData.to,\n data: txData.data,\n };\n}\n","// based on https://github.com/aave-dao/aave-v3-origin/blob/083bd38a137b42b5df04e22ad4c9e72454365d0d/src/contracts/protocol/libraries/helpers/Errors.sol\n\nclass AaveError extends Error {\n public description: string;\n public override message: string;\n\n constructor(code: string, name: string, description: string) {\n const message = name + ` (${code}): ` + description;\n super(message);\n this.name = 'AaveError';\n this.description = description;\n this.message = message;\n\n // Ensures proper prototype chain in transpiled JavaScript\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\ntype AaveErrorData = {\n name: string;\n description: string;\n};\n\nexport const AAVE_ERROR_CODES: Record<string, AaveErrorData> = {\n '1': {\n name: 'CALLER_NOT_POOL_ADMIN',\n description: 'The caller of the function is not a pool admin',\n },\n '2': {\n name: 'CALLER_NOT_EMERGENCY_ADMIN',\n description: 'The caller of the function is not an emergency admin',\n },\n '3': {\n name: 'CALLER_NOT_POOL_OR_EMERGENCY_ADMIN',\n description: 'The caller of the function is not a pool or emergency admin',\n },\n '4': {\n name: 'CALLER_NOT_RISK_OR_POOL_ADMIN',\n description: 'The caller of the function is not a risk or pool admin',\n },\n '5': {\n name: 'CALLER_NOT_ASSET_LISTING_OR_POOL_ADMIN',\n description: 'The caller of the function is not an asset listing or pool admin',\n },\n '6': {\n name: 'CALLER_NOT_BRIDGE',\n description: 'The caller of the function is not a bridge',\n },\n '7': {\n name: 'ADDRESSES_PROVIDER_NOT_REGISTERED',\n description: 'Pool addresses provider is not registered',\n },\n '8': {\n name: 'INVALID_ADDRESSES_PROVIDER_ID',\n description: 'Invalid id for the pool addresses provider',\n },\n '9': { name: 'NOT_CONTRACT', description: 'Address is not a contract' },\n '10': {\n name: 'CALLER_NOT_POOL_CONFIGURATOR',\n description: 'The caller of the function is not the pool configurator',\n },\n '11': {\n name: 'CALLER_NOT_ATOKEN',\n description: 'The caller of the function is not an AToken',\n },\n '12': {\n name: 'INVALID_ADDRESSES_PROVIDER',\n description: 'The address of the pool addresses provider is invalid',\n },\n '13': {\n name: 'INVALID_FLASHLOAN_EXECUTOR_RETURN',\n description: 'Invalid return value of the flashloan executor function',\n },\n '14': {\n name: 'RESERVE_ALREADY_ADDED',\n description: 'Reserve has already been added to reserve list',\n },\n '15': {\n name: 'NO_MORE_RESERVES_ALLOWED',\n description: 'Maximum amount of reserves in the pool reached',\n },\n '16': {\n name: 'EMODE_CATEGORY_RESERVED',\n description: 'Zero eMode category is reserved for volatile heterogeneous assets',\n },\n '17': {\n name: 'INVALID_EMODE_CATEGORY_ASSIGNMENT',\n description: 'Invalid eMode category assignment to asset',\n },\n '18': {\n name: 'RESERVE_LIQUIDITY_NOT_ZERO',\n description: 'The liquidity of the reserve needs to be 0',\n },\n '19': {\n name: 'FLASHLOAN_PREMIUM_INVALID',\n description: 'Invalid flashloan premium',\n },\n '20': {\n name: 'INVALID_RESERVE_PARAMS',\n description: 'Invalid risk parameters for the reserve',\n },\n '21': {\n name: 'INVALID_EMODE_CATEGORY_PARAMS',\n description: 'Invalid risk parameters for the eMode category',\n },\n '22': {\n name: 'BRIDGE_PROTOCOL_FEE_INVALID',\n description: 'Invalid bridge protocol fee',\n },\n '23': {\n name: 'CALLER_MUST_BE_POOL',\n description: 'The caller of this function must be a pool',\n },\n '24': { name: 'INVALID_MINT_AMOUNT', description: 'Invalid amount to mint' },\n '25': { name: 'INVALID_BURN_AMOUNT', description: 'Invalid amount to burn' },\n '26': {\n name: 'INVALID_AMOUNT',\n description: 'Amount must be greater than 0',\n },\n '27': {\n name: 'RESERVE_INACTIVE',\n description: 'Action requires an active reserve',\n },\n '28': {\n name: 'RESERVE_FROZEN',\n description: 'Action cannot be performed because the reserve is frozen',\n },\n '29': {\n name: 'RESERVE_PAUSED',\n description: 'Action cannot be performed because the reserve is paused',\n },\n '30': {\n name: 'BORROWING_NOT_ENABLED',\n description: 'Borrowing is not enabled',\n },\n '32': {\n name: 'NOT_ENOUGH_AVAILABLE_USER_BALANCE',\n description: 'User cannot withdraw more than the available balance',\n },\n '33': {\n name: 'INVALID_INTEREST_RATE_MODE_SELECTED',\n description: 'Invalid interest rate mode selected',\n },\n '34': {\n name: 'COLLATERAL_BALANCE_IS_ZERO',\n description: 'The collateral balance is 0',\n },\n '35': {\n name: 'HEALTH_FACTOR_LOWER_THAN_LIQUIDATION_THRESHOLD',\n description: 'Health factor is lesser than the liquidation threshold',\n },\n '36': {\n name: 'COLLATERAL_CANNOT_COVER_NEW_BORROW',\n description: 'There is not enough collateral to cover a new borrow',\n },\n '37': {\n name: 'COLLATERAL_SAME_AS_BORROWING_CURRENCY',\n description: 'Collateral is (mostly) the same currency that is being borrowed',\n },\n '39': {\n name: 'NO_DEBT_OF_SELECTED_TYPE',\n description: 'For repayment of a specific type of debt, the user needs to have debt that type',\n },\n '40': {\n name: 'NO_EXPLICIT_AMOUNT_TO_REPAY_ON_BEHALF',\n description: 'To repay on behalf of a user an explicit amount to repay is needed',\n },\n '42': {\n name: 'NO_OUTSTANDING_VARIABLE_DEBT',\n description: 'User does not have outstanding variable rate debt on this reserve',\n },\n '43': {\n name: 'UNDERLYING_BALANCE_ZERO',\n description: 'The underlying balance needs to be greater than 0',\n },\n '44': {\n name: 'INTEREST_RATE_REBALANCE_CONDITIONS_NOT_MET',\n description: 'Interest rate rebalance conditions were not met',\n },\n '45': {\n name: 'HEALTH_FACTOR_NOT_BELOW_THRESHOLD',\n description: 'Health factor is not below the threshold',\n },\n '46': {\n name: 'COLLATERAL_CANNOT_BE_LIQUIDATED',\n description: 'The collateral chosen cannot be liquidated',\n },\n '47': {\n name: 'SPECIFIED_CURRENCY_NOT_BORROWED_BY_USER',\n description: 'User did not borrow the specified currency',\n },\n '49': {\n name: 'INCONSISTENT_FLASHLOAN_PARAMS',\n description: 'Inconsistent flashloan parameters',\n },\n '50': { name: 'BORROW_CAP_EXCEEDED', description: 'Borrow cap is exceeded' },\n '51': { name: 'SUPPLY_CAP_EXCEEDED', description: 'Supply cap is exceeded' },\n '52': {\n name: 'UNBACKED_MINT_CAP_EXCEEDED',\n description: 'Unbacked mint cap is exceeded',\n },\n '53': {\n name: 'DEBT_CEILING_EXCEEDED',\n description: 'Debt ceiling is exceeded',\n },\n '54': {\n name: 'UNDERLYING_CLAIMABLE_RIGHTS_NOT_ZERO',\n description: 'Claimable rights over underlying not zero (aToken supply or accruedToTreasury)',\n },\n '56': {\n name: 'VARIABLE_DEBT_SUPPLY_NOT_ZERO',\n description: 'Variable debt supply is not zero',\n },\n '57': { name: 'LTV_VALIDATION_FAILED', description: 'Ltv validation failed' },\n '58': {\n name: 'INCONSISTENT_EMODE_CATEGORY',\n description: 'Inconsistent eMode category',\n },\n '59': {\n name: 'PRICE_ORACLE_SENTINEL_CHECK_FAILED',\n description: 'Price oracle sentinel validation failed',\n },\n '60': {\n name: 'ASSET_NOT_BORROWABLE_IN_ISOLATION',\n description: 'Asset is not borrowable in isolation mode',\n },\n '61': {\n name: 'RESERVE_ALREADY_INITIALIZED',\n description: 'Reserve has already been initialized',\n },\n '62': {\n name: 'USER_IN_ISOLATION_MODE_OR_LTV_ZERO',\n description: 'User is in isolation mode or ltv is zero',\n },\n '63': {\n name: 'INVALID_LTV',\n description: 'Invalid ltv parameter for the reserve',\n },\n '64': {\n name: 'INVALID_LIQ_THRESHOLD',\n description: 'Invalid liquidity threshold parameter for the reserve',\n },\n '65': {\n name: 'INVALID_LIQ_BONUS',\n description: 'Invalid liquidity bonus parameter for the reserve',\n },\n '66': {\n name: 'INVALID_DECIMALS',\n description: 'Invalid decimals parameter of the underlying asset of the reserve',\n },\n '67': {\n name: 'INVALID_RESERVE_FACTOR',\n description: 'Invalid reserve factor parameter for the reserve',\n },\n '68': {\n name: 'INVALID_BORROW_CAP',\n description: 'Invalid borrow cap for the reserve',\n },\n '69': {\n name: 'INVALID_SUPPLY_CAP',\n description: 'Invalid supply cap for the reserve',\n },\n '70': {\n name: 'INVALID_LIQUIDATION_PROTOCOL_FEE',\n description: 'Invalid liquidation protocol fee for the reserve',\n },\n '71': {\n name: 'INVALID_EMODE_CATEGORY',\n description: 'Invalid eMode category for the reserve',\n },\n '72': {\n name: 'INVALID_UNBACKED_MINT_CAP',\n description: 'Invalid unbacked mint cap for the reserve',\n },\n '73': {\n name: 'INVALID_DEBT_CEILING',\n description: 'Invalid debt ceiling for the reserve',\n },\n '74': { name: 'INVALID_RESERVE_INDEX', description: 'Invalid reserve index' },\n '75': {\n name: 'ACL_ADMIN_CANNOT_BE_ZERO',\n description: 'ACL admin cannot be set to the zero address',\n },\n '76': {\n name: 'INCONSISTENT_PARAMS_LENGTH',\n description: 'Array parameters that should be equal length are not',\n },\n '77': {\n name: 'ZERO_ADDRESS_NOT_VALID',\n description: 'Zero address not valid',\n },\n '78': { name: 'INVALID_EXPIRATION', description: 'Invalid expiration' },\n '79': { name: 'INVALID_SIGNATURE', description: 'Invalid signature' },\n '80': {\n name: 'OPERATION_NOT_SUPPORTED',\n description: 'Operation not supported',\n },\n '81': {\n name: 'DEBT_CEILING_NOT_ZERO',\n description: 'Debt ceiling is not zero',\n },\n '82': { name: 'ASSET_NOT_LISTED', description: 'Asset is not listed' },\n '83': {\n name: 'INVALID_OPTIMAL_USAGE_RATIO',\n description: 'Invalid optimal usage ratio',\n },\n '85': {\n name: 'UNDERLYING_CANNOT_BE_RESCUED',\n description: 'The underlying asset cannot be rescued',\n },\n '86': {\n name: 'ADDRESSES_PROVIDER_ALREADY_ADDED',\n description: 'Reserve has already been added to reserve list',\n },\n '87': {\n name: 'POOL_ADDRESSES_DO_NOT_MATCH',\n description:\n 'The token implementation pool address and the pool address provided by the initializing pool do not match',\n },\n '89': {\n name: 'SILOED_BORROWING_VIOLATION',\n description: 'User is trying to borrow multiple assets including a siloed one',\n },\n '90': {\n name: 'RESERVE_DEBT_NOT_ZERO',\n description: 'The total debt of the reserve needs to be 0',\n },\n '91': {\n name: 'FLASHLOAN_DISABLED',\n description: 'FlashLoaning for this asset is disabled',\n },\n '92': {\n name: 'INVALID_MAX_RATE',\n description: 'The expect maximum borrow rate is invalid',\n },\n '93': {\n name: 'WITHDRAW_TO_ATOKEN',\n description: 'Withdrawing to the aToken is not allowed',\n },\n '94': {\n name: 'SUPPLY_TO_ATOKEN',\n description: 'Supplying to the aToken is not allowed',\n },\n '95': {\n name: 'SLOPE_2_MUST_BE_GTE_SLOPE_1',\n description: 'Variable interest rate slope 2 can not be lower than slope 1',\n },\n '96': {\n name: 'CALLER_NOT_RISK_OR_POOL_OR_EMERGENCY_ADMIN',\n description: 'The caller of the function is not a risk, pool or emergency admin',\n },\n '97': {\n name: 'LIQUIDATION_GRACE_SENTINEL_CHECK_FAILED',\n description: 'Liquidation grace sentinel validation failed',\n },\n '98': {\n name: 'INVALID_GRACE_PERIOD',\n description: 'Grace period above a valid range',\n },\n '99': {\n name: 'INVALID_FREEZE_STATE',\n description: 'Reserve is already in the passed freeze state',\n },\n '100': {\n name: 'NOT_BORROWABLE_IN_EMODE',\n description: 'Asset not borrowable in eMode',\n },\n};\n\nexport function getAaveError(code: string): AaveError | null {\n const err = AAVE_ERROR_CODES[code];\n if (err) {\n return new AaveError(code, err.name, err.description);\n }\n return null;\n}\n","import { ethers } from 'ethers';\nimport {\n LegacyUiPoolDataProvider,\n UiPoolDataProvider,\n type ReservesDataHumanized,\n type ReservesHelperInput,\n type UserReservesHelperInput,\n type EModeData,\n type EmodeDataHumanized,\n type UserReserveDataHumanized,\n} from '@aave/contract-helpers';\n\n// @aave/contract-helpers provides two periphery contracts for fetching data from the blockchain:\n// `LegacyUiPoolDataProvider` and `UiPoolDataProvider`. Which one should be used is determined by the version that is actually deployed on a given chain.\n// Fortunately, for our use case we don't care about this complexity,\n// because their interfaces share just enough similarities for us to proceed.\n// `IUiPoolDataProvider` is an intersection of two interfaces.\n\n// Common functions between `LegacyUiPoolDataProvider` and `UiPoolDataProvider`\nexport interface IUiPoolDataProvider {\n getReservesHumanized: (args: ReservesHelperInput) => Promise<ReservesDataHumanized>;\n getUserReservesHumanized: (args: UserReservesHelperInput) => Promise<{\n userReserves: UserReserveDataHumanized[];\n userEmodeCategoryId: number;\n }>;\n getEModes: (args: ReservesHelperInput) => Promise<EModeData[]>;\n getEModesHumanized: (args: ReservesHelperInput) => Promise<EmodeDataHumanized[]>;\n}\n\nexport type IUiPoolDataProviderConstructor = new ({\n uiPoolDataProviderAddress,\n provider,\n chainId,\n}: {\n uiPoolDataProviderAddress: string;\n provider: ethers.providers.JsonRpcProvider;\n chainId: number;\n}) => IUiPoolDataProvider;\n\n// which class to use: LegacyUiPoolDataProvider or UiPoolDataProvider\n// When adding new chains, either compare the interfaces or bruteforce the correct option.\nexport const UI_POOL_DATA_PROVIDER_INTERFACE_PER_CHAIN: Record<\n number,\n IUiPoolDataProviderConstructor\n> = {\n 11155111: LegacyUiPoolDataProvider as IUiPoolDataProviderConstructor,\n 42161: UiPoolDataProvider as IUiPoolDataProviderConstructor,\n 1: UiPoolDataProvider as IUiPoolDataProviderConstructor,\n};\n\n// Use this function to get the correct pool data provider implementation.\nexport const getUiPoolDataProviderImpl = (chainId: number): IUiPoolDataProviderConstructor => {\n const res = UI_POOL_DATA_PROVIDER_INTERFACE_PER_CHAIN[chainId];\n if (!res) {\n throw new Error(\n 'UI_POOL_DATA_PROVIDER_INTERFACE_PER_CHAIN does not contain this chain ID. Edit providers/aave/dataProvider.ts.'\n );\n }\n return res;\n};\n","import { Chain } from './chain.js';\nimport { type AAVEMarket, getMarket } from './market.js';\nimport { UserSummary } from './userSummary.js';\nimport { populateTransaction } from './populateTransaction.js';\nimport { getUiPoolDataProviderImpl, type IUiPoolDataProvider } from './dataProvider.js';\nimport { ethers, type PopulatedTransaction, utils } from 'ethers';\nimport {\n Pool,\n PoolBundle,\n InterestRate,\n type ReservesDataHumanized,\n type ReserveDataHumanized,\n} from '@aave/contract-helpers';\nimport {\n type TransactionPlan,\n type BorrowTokensRequest,\n type BorrowTokensResponse,\n type RepayTokensRequest,\n type RepayTokensResponse,\n type SupplyTokensRequest,\n type SupplyTokensResponse,\n type WithdrawTokensRequest,\n type WithdrawTokensResponse,\n type GetWalletLendingPositionsResponse,\n TransactionTypes,\n type GetWalletLendingPositionsRequest,\n type Token,\n} from '../core/index.js';\nimport { ur } from 'zod/v4/locales';\n\nexport type EModeCategory = 'default' | 'stablecoins';\n\nexport interface PoolData {\n tokenAddress: string;\n poolAddress: string;\n variableBorrowRate: string;\n variableSupplyRate: string;\n ltv: string;\n availableLiquidity: string;\n reserveSize: string;\n}\n\nexport type AAVEAction = PopulatedTransaction[];\n\nexport interface AAVEAdapterParams {\n chainId: number;\n rpcUrl: string;\n wrappedNativeToken?: string; // e.g. WETH address for ETH\n}\n\n// AAVE's ETH placeholder address used for native ETH operations\nconst AAVE_ETH_PLACEHOLDER = '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE';\n\n/**\n * AAVEAdapter is the primary class wrapping Aave V3 interactions.\n */\nexport class AAVEAdapter {\n public chain: Chain;\n public market: AAVEMarket;\n\n constructor(params: AAVEAdapterParams) {\n this.chain = new Chain(params.chainId, params.rpcUrl);\n this.market = getMarket(this.chain.id);\n }\n\n /**\n * If the token is native, return AAVE's placeholder address instead of the ember address.\n * @param token - The token to normalize.\n * @returns The normalized token address.\n */\n public normalizeTokenAddress(token: Token): string {\n return token.isNative ? AAVE_ETH_PLACEHOLDER : token.tokenUid.address;\n }\n\n public async createSupplyTransaction(params: SupplyTokensRequest): Promise<SupplyTokensResponse> {\n const { supplyToken: token, amount, walletAddress } = params;\n const txs = await this.supply(\n this.normalizeTokenAddress(token),\n amount.toString(),\n walletAddress\n );\n return {\n transactions: txs.map(t => transactionPlanFromEthers(this.chain.id.toString(), t)),\n };\n }\n\n public async createWithdrawTransaction(\n params: WithdrawTokensRequest\n ): Promise<WithdrawTokensResponse> {\n const { tokenToWithdraw, amount, walletAddress } = params;\n\n // Find aToken he wants to withdraw from\n const alphaTokenAddress = (await this.getReserves()).reservesData.find(\n reserve => reserve.underlyingAsset === tokenToWithdraw.tokenUid.address\n )?.aTokenAddress;\n if (!alphaTokenAddress) {\n throw new Error('No position can generate the token to withdraw');\n }\n\n const txs = await this.withdraw(alphaTokenAddress, amount, walletAddress, walletAddress);\n return {\n transactions: txs.map(t => transactionPlanFromEthers(this.chain.id.toString(), t)),\n };\n }\n\n public async createBorrowTransaction(params: BorrowTokensRequest): Promise<BorrowTokensResponse> {\n const { borrowToken, amount, walletAddress } = params;\n const normalizedTokenAddress = this.normalizeTokenAddress(borrowToken);\n\n // Get pool data to fetch APR\n const poolData = await this.getPool(normalizedTokenAddress);\n const reservesResponse = await this.getReserves();\n\n let reserveLiquidationThreshold: string | null = null;\n for (const reserve of reservesResponse.reservesData) {\n const token = ethers.utils.getAddress(reserve.underlyingAsset);\n if (token === normalizedTokenAddress) {\n reserveLiquidationThreshold = reserve.reserveLiquidationThreshold;\n }\n }\n\n if (reserveLiquidationThreshold == null) {\n throw new Error('Reserve not found in AAVE pool for a given token');\n }\n\n // Create borrow transaction\n const txs = await this.borrow(normalizedTokenAddress, amount.toString(), walletAddress);\n\n return {\n liquidationThreshold: reserveLiquidationThreshold,\n currentBorrowApy: poolData.variableBorrowRate,\n transactions: txs.map(t => transactionPlanFromEthers(this.chain.id.toString(), t)),\n };\n }\n\n public async createRepayTransaction(params: RepayTokensRequest): Promise<RepayTokensResponse> {\n const { repayToken, amount, walletAddress: from } = params;\n\n const normalizedAsset = this.normalizeTokenAddress(repayToken);\n\n // Choose repayment method based on useATokens flag\n const txs = await this.repay(normalizedAsset, amount.toString(), from);\n\n return {\n transactions: txs.map(t => transactionPlanFromEthers(this.chain.id.toString(), t)),\n };\n }\n\n public async createRepayTransactionWithATokens(\n params: RepayTokensRequest\n ): Promise<RepayTokensResponse> {\n const { repayToken, amount, walletAddress: from } = params;\n\n const normalizedAsset = this.normalizeTokenAddress(repayToken);\n\n // Choose repayment method based on useATokens flag\n const txs = await this.repayWithATokens(normalizedAsset, amount.toString(), from);\n\n return {\n transactions: txs.map(t => transactionPlanFromEthers(this.chain.id.toString(), t)),\n };\n }\n\n // Private Methods\n private getProvider() {\n return this.chain.getProvider();\n }\n\n private getPoolBundle() {\n const provider = this.getProvider();\n return new PoolBundle(provider, {\n POOL: this.market.POOL,\n WETH_GATEWAY: this.market.WETH_GATEWAY,\n });\n }\n\n private async getTokenData(address: string) {\n let targetAddress = address;\n\n // If address is AAVE's native token placeholder, find the corresponding wrapped native token address\n if (address === AAVE_ETH_PLACEHOLDER) {\n const poolData = await this.getPool(address);\n targetAddress = poolData.tokenAddress; // This will be the wrapped native token address\n }\n\n return await this.getPoolBundle().erc20Service.getTokenData(targetAddress);\n }\n\n private getPoolDataProvider(): IUiPoolDataProvider {\n const provider = this.getProvider();\n const DataProviderImpl = getUiPoolDataProviderImpl(this.chain.id);\n return new DataProviderImpl({\n uiPoolDataProviderAddress: this.market.UI_POOL_DATA_PROVIDER,\n provider,\n chainId: this.chain.id,\n });\n }\n\n private getPoolContract() {\n const provider = this.getProvider();\n return new Pool(provider, {\n POOL: this.market.POOL,\n WETH_GATEWAY: this.market.WETH_GATEWAY,\n });\n }\n\n private async getPool(asset: string): Promise<PoolData> {\n const reservesResponse = await this.getReserves();\n\n let targetAsset = asset;\n\n // If asset is AAVE's native token placeholder, find the corresponding wrapped native token reserve\n if (asset === AAVE_ETH_PLACEHOLDER) {\n const configuredWrappedNativeToken = this.chain.wrappedNativeTokenAddress;\n\n if (!configuredWrappedNativeToken) {\n throw new Error(`No wrapped native token configured for chain ${this.chain.id}`);\n }\n\n const wrappedNativeTokenReserve = reservesResponse.reservesData.find(\n (r: ReserveDataHumanized) =>\n ethers.utils.getAddress(r.underlyingAsset) === configuredWrappedNativeToken\n );\n\n if (!wrappedNativeTokenReserve) {\n throw new Error(`Wrapped native token reserve not found for native token operations`);\n }\n\n targetAsset = wrappedNativeTokenReserve.underlyingAsset;\n }\n\n const reserve = reservesResponse.reservesData.find(\n (r: ReserveDataHumanized) =>\n ethers.utils.getAddress(r.underlyingAsset) === ethers.utils.getAddress(targetAsset)\n );\n\n if (!reserve) {\n throw new Error(`Asset ${asset} not found in reserves`);\n }\n\n return {\n tokenAddress: reserve.underlyingAsset,\n poolAddress: this.market.POOL,\n variableBorrowRate: reserve.variableBorrowRate,\n variableSupplyRate: reserve.liquidityRate,\n ltv: reserve.baseLTVasCollateral,\n availableLiquidity: reserve.availableLiquidity,\n reserveSize: reserve.availableLiquidity,\n };\n }\n\n public async getReserves(): Promise<ReservesDataHumanized> {\n const reserves = this.getPoolDataProvider().getReservesHumanized({\n lendingPoolAddressProvider: this.market.POOL_ADDRESSES_PROVIDER,\n });\n return reserves;\n }\n\n public async getUserSummary(\n params: GetWalletLendingPositionsRequest\n ): Promise<GetWalletLendingPositionsResponse> {\n const userSummaryResponse = await this._getUserSummary(params.walletAddress);\n const {\n totalLiquidityUSD,\n totalCollateralUSD,\n totalBorrowsUSD,\n netWorthUSD,\n availableBorrowsUSD,\n currentLoanToValue,\n currentLiquidationThreshold,\n healthFactor,\n userReservesData,\n } = userSummaryResponse.reserves;\n\n const userReservesFormatted = [];\n for (const {\n reserve,\n underlyingBalance,\n underlyingBalanceUSD,\n variableBorrows,\n variableBorrowsUSD,\n totalBorrows,\n totalBorrowsUSD,\n } of userReservesData.filter(ur => ur.underlyingBalanceUSD !== '0')) {\n const tokenData = await this.getTokenData(reserve.underlyingAsset);\n userReservesFormatted.push({\n token: {\n // TODO: ideally we should populate this object somewhere else,\n // returning only tokenUid in this adapter\n tokenUid: {\n address: reserve.underlyingAsset,\n chainId: this.chain.id.toString(),\n },\n isNative: false,\n name: tokenData.name,\n symbol: tokenData.symbol,\n decimals: tokenData.decimals,\n isVetted: true, // assuming aave only lets really good assets in\n },\n underlyingBalance,\n underlyingBalanceUsd: underlyingBalanceUSD,\n variableBorrows,\n variableBorrowsUsd: variableBorrowsUSD,\n totalBorrows,\n totalBorrowsUsd: totalBorrowsUSD,\n });\n }\n\n return {\n userReserves: userReservesFormatted,\n totalLiquidityUsd: totalLiquidityUSD,\n totalCollateralUsd: totalCollateralUSD,\n totalBorrowsUsd: totalBorrowsUSD,\n netWorthUsd: netWorthUSD,\n availableBorrowsUsd: availableBorrowsUSD,\n currentLoanToValue,\n currentLiquidationThreshold,\n healthFactor,\n };\n }\n\n private async _getUserSummary(userAddress: string): Promise<UserSummary> {\n const validatedUser = ethers.utils.getAddress(userAddress);\n const poolDataProvider = this.getPoolDataProvider();\n\n const reservesResponse = await this.getReserves();\n\n const userReservesResponse = await poolDataProvider.getUserReservesHumanized({\n lendingPoolAddressProvider: this.market.POOL_ADDRESSES_PROVIDER,\n user: validatedUser,\n });\n\n return new UserSummary(userReservesResponse, reservesResponse);\n }\n\n private async borrow(asset: string, amount: string, from: string): Promise<AAVEAction> {\n // validate\n ethers.utils.getAddress(asset);\n ethers.utils.getAddress(from);\n\n const bundle: PoolBundle = this.getPoolBundle();\n\n const tx = bundle.borrowTxBuilder.generateTxData({\n user: from,\n reserve: asset,\n amount,\n interestRateMode: InterestRate.Variable,\n });\n\n return [tx];\n }\n\n private async createApproval({\n asset,\n amount_raw,\n user,\n spender,\n }: {\n spender: string;\n user: string;\n asset: string;\n amount_raw: string;\n }): Promise<PopulatedTransaction | null> {\n const bundle = this.getPoolBundle();\n let approvalTx = null;\n const isApprovedEnough = await bundle.erc20Service.isApproved({\n user: user,\n token: asset,\n spender,\n amount: amount_raw,\n nativeDecimals: true,\n });\n\n if (!isApprovedEnough) {\n approvalTx = bundle.erc20Service.approveTxData({\n user,\n token: asset,\n spender,\n amount: amount_raw,\n });\n }\n\n return approvalTx;\n }\n\n private async supply(asset: string, amount: string, from: string): Promise<AAVEAction> {\n // validate\n ethers.utils.getAddress(asset);\n ethers.utils.getAddress(from);\n\n const bundle = this.getPoolBundle();\n\n const approvalTx = await this.createApproval({\n asset,\n amount_raw: amount,\n user: from,\n spender: bundle.poolAddress,\n });\n\n const tx = bundle.supplyTxBuilder.generateTxData({\n user: from,\n reserve: asset,\n amount,\n onBehalfOf: from,\n });\n\n return (approvalTx ? [approvalTx] : []).concat([tx]);\n }\n\n private async repay(asset: string, amount_formatted: string, from: string): Promise<AAVEAction> {\n // validate\n ethers.utils.getAddress(asset);\n ethers.utils.getAddress(from);\n\n const bundle: PoolBundle = this.getPoolBundle();\n\n const amount = utils\n .parseUnits(amount_formatted, (await this.getTokenData(asset)).decimals)\n .toString();\n\n const tx = bundle.repayTxBuilder.generateTxData({\n user: from,\n reserve: asset,\n amount: amount,\n interestRateMode: InterestRate.Variable,\n onBehalfOf: from,\n });\n\n const approvalTx = await this.createApproval({\n asset,\n amount_raw: amount,\n user: from,\n spender: bundle.poolAddress,\n });\n\n return (approvalTx ? [approvalTx] : []).concat([tx]);\n }\n\n private async repayWithATokens(\n asset: string,\n amount_formatted: string,\n from: string\n ): Promise<AAVEAction> {\n ethers.utils.getAddress(asset);\n ethers.utils.getAddress(from);\n const bundle = this.getPoolBundle();\n const tokenData = await this.getTokenData(asset);\n const amount = utils.parseUnits(amount_formatted, tokenData.decimals).toString();\n const tx = bundle.repayWithATokensTxBuilder.generateTxData({\n user: from,\n reserve: asset,\n amount,\n rateMode: InterestRate.Variable,\n });\n return [tx];\n }\n\n private async withdraw(\n asset: string,\n amount: bigint,\n to: string,\n from: string\n ): Promise<AAVEAction> {\n ethers.utils.getAddress(asset);\n ethers.utils.getAddress(to);\n ethers.utils.getAddress(from);\n\n const pool = this.getPoolContract();\n const txs = await pool.withdraw({\n user: from,\n reserve: asset,\n amount: amount.toString(),\n });\n\n if (txs.length !== 1) {\n throw new Error('AAVEInstance.withdraw: impossible happened');\n }\n\n // Null coercion is safe here because we checked txs.length above\n return [await populateTransaction(txs[0]!)];\n }\n}\n\nconst transactionPlanFromEthers = (\n chainId: string,\n tx: ethers.PopulatedTransaction\n): TransactionPlan => {\n return {\n type: TransactionTypes.EVM_TX,\n to: tx.to!,\n value: tx.value?.toString() || '0',\n data: tx.data!,\n chainId,\n };\n};\n","import { z } from 'zod';\nimport { ChainTypeSchema, TransactionTypeSchema } from './enums.js';\n\nexport const TokenIdentifierSchema = z.object({\n chainId: z.string(),\n address: z.string(),\n});\nexport type TokenIdentifier = z.infer<typeof TokenIdentifierSchema>;\n\nexport const TokenSchema = z.object({\n tokenUid: TokenIdentifierSchema,\n name: z.string(),\n symbol: z.string(),\n isNative: z.boolean(),\n decimals: z.number().int(),\n iconUri: z.string().nullish(),\n isVetted: z.boolean(),\n});\nexport type Token = z.infer<typeof TokenSchema>;\n\nexport const ChainSchema = z.object({\n chainId: z.string(),\n type: ChainTypeSchema,\n iconUri: z.string(),\n nativeToken: TokenSchema,\n httpRpcUrl: z.string(),\n name: z.string(),\n blockExplorerUrls: z.array(z.string()),\n});\nexport type Chain = z.infer<typeof ChainSchema>;\n\nexport const FeeBreakdownSchema = z.object({\n serviceFee: z.string(),\n slippageCost: z.string(),\n total: z.string(),\n feeDenomination: z.string(),\n});\nexport type FeeBreakdown = z.infer<typeof FeeBreakdownSchema>;\n\nexport const TransactionPlanSchema = z.object({\n type: TransactionTypeSchema,\n to: z.string(),\n data: z.string(),\n value: z.string(),\n chainId: z.string(),\n});\nexport type TransactionPlan = z.infer<typeof TransactionPlanSchema>;\n\nexport const TransactionPlanErrorSchema = z.object({\n code: z.string(),\n message: z.string(),\n details: z.record(z.string()),\n});\nexport type TransactionPlanError = z.infer<typeof TransactionPlanErrorSchema>;\n\nexport const ProviderTrackingInfoSchema = z.object({\n requestId: z.string(),\n providerName: z.string(),\n explorerUrl: z.string(),\n});\nexport type ProviderTrackingInfo = z.infer<typeof ProviderTrackingInfoSchema>;\n\nexport const SwapEstimationSchema = z.object({\n effectivePrice: z.string(),\n timeEstimate: z.string(),\n expiration: z.string(),\n});\nexport type SwapEstimation = z.infer<typeof SwapEstimationSchema>;\n\nexport const ProviderTrackingStatusSchema = z.object({\n requestId: z.string(),\n transactionId: z.string(),\n providerName: z.string(),\n explorerUrl: z.string(),\n status: z.string(),\n});\nexport type ProviderTrackingStatus = z.infer<typeof ProviderTrackingStatusSchema>;\n","import { z } from 'zod';\n\nexport const ChainTypeSchema = z.enum(['UNSPECIFIED', 'EVM', 'SOLANA', 'COSMOS']);\nexport type ChainType = z.infer<typeof ChainTypeSchema>;\n\n// TransactionType\nexport const TransactionTypes = {\n TRANSACTION_TYPE_UNSPECIFIED: 'TRANSACTION_TYPE_UNSPECIFIED' as const,\n EVM_TX: 'EVM_TX' as const,\n SOLANA_TX: 'SOLANA_TX' as const,\n} as const;\n\nexport const TransactionTypeSchema = z.enum(\n Object.values(TransactionTypes) as [string, ...string[]]\n);\nexport type TransactionType = keyof typeof TransactionTypes;\n","import { z } from 'zod';\nimport { FeeBreakdownSchema, TransactionPlanSchema, TokenSchema } from './core.js';\n\nexport const BorrowTokensRequestSchema = z.object({\n borrowToken: TokenSchema,\n amount: z.bigint(),\n walletAddress: z.string(),\n});\nexport type BorrowTokensRequest = z.infer<typeof BorrowTokensRequestSchema>;\n\nexport const BorrowTokensResponseSchema = z.object({\n currentBorrowApy: z.string(),\n liquidationThreshold: z.string(),\n feeBreakdown: FeeBreakdownSchema.optional(),\n transactions: z.array(TransactionPlanSchema),\n});\nexport type BorrowTokensResponse = z.infer<typeof BorrowTokensResponseSchema>;\n\nexport const RepayTokensRequestSchema = z.object({\n repayToken: TokenSchema,\n amount: z.bigint(),\n walletAddress: z.string(),\n});\nexport type RepayTokensRequest = z.infer<typeof RepayTokensRequestSchema>;\n\nexport const RepayTokensResponseSchema = z.object({\n feeBreakdown: FeeBreakdownSchema.optional(),\n transactions: z.array(TransactionPlanSchema),\n});\nexport type RepayTokensResponse = z.infer<typeof RepayTokensResponseSchema>;\n\nexport const SupplyTokensRequestSchema = z.object({\n supplyToken: TokenSchema,\n amount: z.bigint(),\n walletAddress: z.string(),\n});\nexport type SupplyTokensRequest = z.infer<typeof SupplyTokensRequestSchema>;\n\nexport const SupplyTokensResponseSchema = z.object({\n feeBreakdown: FeeBreakdownSchema.optional(),\n transactions: z.array(TransactionPlanSchema),\n});\nexport type SupplyTokensResponse = z.infer<typeof SupplyTokensResponseSchema>;\n\nexport const WithdrawTokensRequestSchema = z.object({\n tokenToWithdraw: TokenSchema,\n amount: z.bigint(),\n walletAddress: z.string(),\n});\nexport type WithdrawTokensRequest = z.infer<typeof WithdrawTokensRequestSchema>;\n\nexport const WithdrawTokensResponseSchema = z.object({\n feeBreakdown: FeeBreakdownSchema.optional(),\n transactions: z.array(TransactionPlanSchema),\n});\nexport type WithdrawTokensResponse = z.infer<typeof WithdrawTokensResponseSchema>;\n\nexport const TokenPositionSchema = z.object({\n underlyingToken: TokenSchema,\n borrowRate: z.string(),\n supplyBalance: z.string(),\n borrowBalance: z.string(),\n valueUsd: z.string(),\n});\nexport type TokenPosition = z.infer<typeof TokenPositionSchema>;\n\nexport const GetWalletLendingPositionsRequestSchema = z.object({\n walletAddress: z.string(),\n});\nexport type GetWalletLendingPositionsRequest = z.infer<\n typeof GetWalletLendingPositionsRequestSchema\n>;\n\nexport const LendTokenDetailSchema = z.object({\n token: TokenSchema,\n underlyingBalance: z.string(),\n underlyingBalanceUsd: z.string(),\n variableBorrows: z.string(),\n variableBorrowsUsd: z.string(),\n totalBorrows: z.string(),\n totalBorrowsUsd: z.string(),\n});\nexport type LendTokenDetail = z.infer<typeof LendTokenDetailSchema>;\n\nexport const GetWalletLendingPositionsResponseSchema = z.object({\n userReserves: z.array(LendTokenDetailSchema),\n totalLiquidityUsd: z.string(),\n totalCollateralUsd: z.string(),\n totalBorrowsUsd: z.string(),\n netWorthUsd: z.string(),\n availableBorrowsUsd: z.string(),\n currentLoanToValue: z.string(),\n currentLiquidationThreshold: z.string(),\n healthFactor: z.string(),\n});\nexport type GetWalletLendingPositionsResponse = z.infer<\n typeof GetWalletLendingPositionsResponseSchema\n>;\n","import { z } from 'zod';\nimport { TokenIdentifierSchema, TransactionPlanSchema } from './core.js';\n\nexport const LimitedLiquidityProvisionRangeSchema = z.object({\n minPrice: z.string(),\n maxPrice: z.string(),\n});\nexport type LimitedLiquidityProvisionRange = z.infer<typeof LimitedLiquidityProvisionRangeSchema>;\n\nexport const LiquidityProvisionRangeSchema = z.discriminatedUnion('type', [\n z.object({\n type: z.literal('full'),\n }),\n z.object({\n type: z.literal('limited'),\n minPrice: z.string(),\n maxPrice: z.string(),\n }),\n]);\nexport type LiquidityProvisionRange = z.infer<typeof LiquidityProvisionRangeSchema>;\n\nexport const LiquidityPositionRangeSchema = z.object({\n fromPrice: z.string(),\n toPrice: z.string(),\n});\nexport type LiquidityPositionRange = z.infer<typeof LiquidityPositionRangeSchema>;\n\nexport const LiquidityPositionSchema = z.object({\n tokenId: z.string(),\n poolAddress: z.string(),\n operator: z.string(),\n token0: TokenIdentifierSchema,\n token1: TokenIdentifierSchema,\n tokensOwed0: z.string(),\n tokensOwed1: z.string(),\n amount0: z.string(),\n amount1: z.string(),\n symbol0: z.string(),\n symbol1: z.string(),\n price: z.string(),\n providerId: z.string(),\n positionRange: LiquidityPositionRangeSchema.optional(),\n});\nexport type LiquidityPosition = z.infer<typeof LiquidityPositionSchema>;\n\nexport const LiquidityPoolSchema = z.object({\n token0: TokenIdentifierSchema,\n token1: TokenIdentifierSchema,\n symbol0: z.string(),\n symbol1: z.string(),\n price: z.string(),\n providerId: z.string(),\n});\nexport type LiquidityPool = z.infer<typeof LiquidityPoolSchema>;\n\nexport const SupplyLiquidityRequestSchema = z.object({\n token0: TokenIdentifierSchema,\n token1: TokenIdentifierSchema,\n amount0: z.bigint(),\n amount1: z.bigint(),\n range: LiquidityProvisionRangeSchema,\n walletAddress: z.string(),\n});\nexport type SupplyLiquidityRequest = z.infer<typeof SupplyLiquidityRequestSchema>;\n\nexport const SupplyLiquidityResponseSchema = z.object({\n transactions: z.array(TransactionPlanSchema),\n chainId: z.string(),\n});\nexport type SupplyLiquidityResponse = z.infer<typeof SupplyLiquidityResponseSchema>;\n\nexport const WithdrawLiquidityRequestSchema = z.object({\n tokenId: z.string(),\n walletAddress: z.string(),\n});\nexport type WithdrawLiquidityRequest = z.infer<typeof WithdrawLiquidityRequestSchema>;\n\nexport const WithdrawLiquidityResponseSchema = z.object({\n transactions: z.array(TransactionPlanSchema),\n chainId: z.string(),\n});\nexport type WithdrawLiquidityResponse = z.infer<typeof WithdrawLiquidityResponseSchema>;\n\nexport const GetWalletLiquidityPositionsRequestSchema = z.object({\n walletAddress: z.string(),\n});\nexport type GetWalletLiquidityPositionsRequest = z.infer<\n typeof GetWalletLiquidityPositionsRequestSchema\n>;\n\nexport const GetWalletLiquidityPositionsResponseSchema = z.object({\n positions: z.array(LiquidityPositionSchema),\n});\nexport type GetWalletLiquidityPositionsResponse = z.infer<\n typeof GetWalletLiquidityPositionsResponseSchema\n>;\n\nexport const GetLiquidityPoolsResponseSchema = z.object({\n liquidityPools: z.array(LiquidityPoolSchema),\n});\nexport type GetLiquidityPoolsResponse = z.infer<typeof GetLiquidityPoolsResponseSchema>;\n","import { z } from 'zod';\nimport { TransactionPlanSchema, TokenIdentifierSchema } from './core.js';\nimport { DecreasePositionSwapType, OrderType } from '@gmx-io/sdk/types/orders';\n\n// Enums\nexport const DecreasePositionSwapTypeSchema = z.nativeEnum(DecreasePositionSwapType);\n\nexport const PositionSideSchema = z.union([z.literal('long'), z.literal('short')]);\n\nexport type PositionSide = z.infer<typeof PositionSideSchema>;\n\n// API Schemas and types\nexport const PositionSchema = z.object({\n chainId: z.string(),\n key: z.string(),\n contractKey: z.string(),\n account: z.string(),\n marketAddress: z.string(),\n collateralTokenAddress: z.string(),\n sizeInUsd: z.string(),\n sizeInTokens: z.string(),\n collateralAmount: z.string(),\n pendingBorrowingFeesUsd: z.string(),\n increasedAtTime: z.string(),\n decreasedAtTime: z.string(),\n positionSide: PositionSideSchema,\n isLong: z.boolean(),\n fundingFeeAmount: z.string(),\n claimableLongTokenAmount: z.string(),\n claimableShortTokenAmount: z.string(),\n isOpening: z.boolean().optional(),\n pnl: z.string(),\n positionFeeAmount: z.string(),\n traderDiscountAmount: z.string(),\n uiFeeAmount: z.string(),\n data: z.string().optional(),\n});\n\nexport type PerpetualsPosition = z.infer<typeof PositionSchema>;\n\nexport const PositionsDataSchema = z.array(PositionSchema);\n\n// Order Schema\nexport const OrderSchema = z.object({\n chainId: z.string(),\n key: z.string(),\n account: z.string(),\n callbackContract: z.string(),\n initialCollateralTokenAddress: z.string(),\n marketAddress: z.string(),\n decreasePositionSwapType: DecreasePositionSwapTypeSchema,\n receiver: z.string(),\n swapPath: z.array(z.string()),\n contractAcceptablePrice: z.string(),\n contractTriggerPrice: z.string(),\n callbackGasLimit: z.string(),\n executionFee: z.string(),\n initialCollateralDeltaAmount: z.string(),\n minOutputAmount: z.string(),\n sizeDeltaUsd: z.string(),\n updatedAtTime: z.string(),\n isFrozen: z.boolean(),\n positionSide: PositionSideSchema,\n orderType: z.nativeEnum(OrderType),\n shouldUnwrapNativeToken: z.boolean(),\n autoCancel: z.boolean(),\n data: z.string().optional(),\n uiFeeReceiver: z.string(),\n validFromTime: z.string(),\n title: z.string().optional(),\n});\n\nexport type PerpetualsOrder = z.infer<typeof OrderSchema>;\n\nexport const OrdersDataSchema = z.array(OrderSchema);\n\n// Definition for plugin with mapped entities already in place\nexport const CreatePerpetualsPositionRequestSchema = z.object({\n amount: z.bigint(),\n walletAddress: z.string(),\n chainId: z.string(),\n marketAddress: z.string(),\n payTokenAddress: z.string(),\n collateralTokenAddress: z.string(),\n referralCode: z.string().optional(),\n limitPrice: z.string().optional(),\n leverage: z.string(),\n});\n\nexport type CreatePerpetualsPositionRequest = z.infer<typeof CreatePerpetualsPositionRequestSchema>;\n\nexport const CreatePerpetualsPositionResponseSchema = z.object({\n transactions: z.array(TransactionPlanSchema),\n});\nexport type CreatePerpetualsPositionResponse = z.infer<\n typeof CreatePerpetualsPositionResponseSchema\n>;\n\nexport const GetPerpetualsMarketsPositionsRequestSchema = z.object({\n walletAddress: z.string().describe(\"User's wallet address\"),\n});\n\nexport type GetPerpetualsMarketsPositionsRequest = z.infer<\n typeof GetPerpetualsMarketsPositionsRequestSchema\n>;\n\nexport const GetPerpetualsMarketsPositionsResponseSchema = z.object({\n positions: PositionsDataSchema,\n});\n\nexport type GetPerpetualsMarketsPositionsResponse = z.infer<\n typeof GetPerpetualsMarketsPositionsResponseSchema\n>;\n\nexport const GetPerpetualsMarketsOrdersRequestSchema = z.object({\n walletAddress: z.string().describe(\"User's wallet address\"),\n});\n\nexport type GetPerpetualsMarketsOrdersRequest = z.infer<\n typeof GetPerpetualsMarketsOrdersRequestSchema\n>;\n\nexport const GetPerpetualsMarketsOrdersResponseSchema = z.object({\n orders: OrdersDataSchema,\n});\n\nexport type GetPerpetualsMarketsOrdersResponse = z.infer<\n typeof GetPerpetualsMarketsOrdersResponseSchema\n>;\n\nexport const ClosePerpetualsOrdersRequestSchema = z.object({\n walletAddress: z.string().describe(\"User's wallet address\"),\n key: z.string(),\n});\n\nexport type ClosePerpetualsOrdersRequest = z.infer<typeof ClosePerpetualsOrdersRequestSchema>;\n\nexport const ClosePerpetualsOrdersResponseSchema = z.object({\n transactions: z.array(TransactionPlanSchema),\n});\n\nexport type ClosePerpetualsOrdersResponse = z.infer<typeof ClosePerpetualsOrdersResponseSchema>;\n\nexport const GetPerpetualsMarketsRequestSchema = z.object({\n chainIds: z.array(z.string()),\n});\n\nexport type GetPerpetualsMarketsRequest = z.infer<typeof GetPerpetualsMarketsRequestSchema>;\n\nexport const PerpetualMarketSchema = z.object({\n marketToken: TokenIdentifierSchema,\n indexToken: TokenIdentifierSchema,\n longToken: TokenIdentifierSchema,\n shortToken: TokenIdentifierSchema,\n longFundingFee: z.string(),\n shortFundingFee: z.string(),\n longBorrowingFee: z.string(),\n shortBorrowingFee: z.string(),\n chainId: z.string(),\n name: z.string(),\n});\n\nexport type PerpetualMarket = z.infer<typeof PerpetualMarketSchema>;\n\nexport const GetPerpetualsMarketsResponseSchema = z.object({\n markets: z.array(PerpetualMarketSchema),\n});\n\nexport type GetPerpetualsMarketsResponse = z.infer<typeof GetPerpetualsMarketsResponseSchema>;\n","import { z } from 'zod';\nimport {\n FeeBreakdownSchema,\n TransactionPlanSchema,\n SwapEstimationSchema,\n ProviderTrackingInfoSchema,\n TokenSchema,\n} from './core.js';\n\nexport const SwapTokensRequestSchema = z.object({\n fromToken: TokenSchema,\n toToken: TokenSchema,\n amount: z.bigint(),\n limitPrice: z.string().optional(),\n slippageTolerance: z.string().optional(),\n expiration: z.string().optional(),\n recipient: z.string(),\n});\nexport type SwapTokensRequest = z.infer<typeof SwapTokensRequestSchema>;\n\nexport const SwapTokensResponseSchema = z.object({\n fromToken: TokenSchema,\n toToken: TokenSchema,\n exactFromAmount: z.string(),\n displayFromAmount: z.string(),\n exactToAmount: z.string(),\n displayToAmount: z.string(),\n transactions: z.array(TransactionPlanSchema),\n feeBreakdown: FeeBreakdownSchema.optional(),\n estimation: SwapEstimationSchema.optional(),\n providerTracking: ProviderTrackingInfoSchema.optional(),\n});\nexport type SwapTokensResponse = z.infer<typeof SwapTokensResponseSchema>;\n","import type { ActionDefinition, EmberPlugin, LendingActions } from '../core/index.js';\nimport { AAVEAdapter, type AAVEAdapterParams } from './adapter.js';\nimport type { ChainConfig } from '../chainConfig.js';\nimport type { PublicEmberPluginRegistry } from '../registry.js';\n\n/**\n * Get the AAVE Ember plugin.\n * @param params - Configuration parameters for the AAVEAdapter, including chainId and rpcUrl.\n * @returns The AAVE Ember plugin.\n */\nexport async function getAaveEmberPlugin(\n params: AAVEAdapterParams\n): Promise<EmberPlugin<'lending'>> {\n const adapter = new AAVEAdapter(params);\n\n return {\n id: `AAVE_CHAIN_${params.chainId}`,\n type: 'lending',\n name: `AAVE lending for ${params.chainId}`,\n description: 'Aave V3 lending protocol',\n website: 'https://aave.com',\n x: 'https://x.com/aave',\n actions: await getAaveActions(adapter),\n queries: {\n getPositions: adapter.getUserSummary.bind(adapter),\n },\n };\n}\n\n/**\n * Get the AAVE actions for the lending protocol.\n * @param adapter - An instance of AAVEAdapter to interact with the AAVE protocol.\n * @returns An array of action definitions for the AAVE lending protocol.\n */\nexport async function getAaveActions(\n adapter: AAVEAdapter\n): Promise<ActionDefinition<LendingActions>[]> {\n const reservesResponse = await adapter.getReserves();\n\n const underlyingAssets: string[] = reservesResponse.reservesData.map(\n reserve => reserve.underlyingAsset\n );\n const aTokens: string[] = reservesResponse.reservesData.map(reserve => reserve.aTokenAddress);\n const borrowableAssets = reservesResponse.reservesData\n .filter(reserve => reserve.borrowingEnabled)\n .map(reserve => reserve.underlyingAsset);\n\n return [\n // Supply any of the underlying assets to get aTokens\n {\n type: 'lending-supply',\n name: `AAVE lending pools in chain ${adapter.chain.id}`,\n inputTokens: async () =>\n Promise.resolve([\n {\n chainId: adapter.chain.id.toString(),\n tokens: underlyingAssets,\n },\n ]),\n outputTokens: async () =>\n Promise.resolve([\n {\n chainId: adapter.chain.id.toString(),\n tokens: aTokens,\n },\n ]),\n callback: adapter.createSupplyTransaction.bind(adapter),\n },\n\n // Borrow any of the borrowable assets if you have some alpha tokens as collateral\n {\n type: 'lending-borrow',\n name: `AAVE borrow in chain ${adapter.chain.id}`,\n inputTokens: async () =>\n Promise.resolve([\n {\n chainId: adapter.chain.id.toString(),\n tokens: aTokens,\n },\n ]),\n outputTokens: async () =>\n Promise.resolve([\n {\n chainId: adapter.chain.id.toString(),\n tokens: borrowableAssets,\n },\n ]),\n callback: adapter.createBorrowTransaction.bind(adapter),\n },\n\n // Repay your borrow with the underlying asset\n {\n type: 'lending-repay',\n name: `AAVE repay in chain ${adapter.chain.id}`,\n inputTokens: async () =>\n Promise.resolve([\n {\n chainId: adapter.chain.id.toString(),\n tokens: borrowableAssets,\n },\n ]),\n // Empty output tokens as this doesn't generate any token\n outputTokens: async () => Promise.resolve([]),\n callback: adapter.createRepayTransaction.bind(adapter),\n },\n\n // Repay your borrow with aTokens\n {\n type: 'lending-repay',\n name: `AAVE repay with aTokens in chain ${adapter.chain.id}`,\n inputTokens: async () =>\n Promise.resolve([\n {\n chainId: adapter.chain.id.toString(),\n tokens: aTokens,\n },\n ]),\n // Empty output tokens as this doesn't generate any token\n outputTokens: async () => Promise.resolve([]),\n callback: adapter.createRepayTransactionWithATokens.bind(adapter),\n },\n\n // Withdraw from your aTokens to get the underlying asset back\n {\n type: 'lending-withdraw',\n name: `AAVE withdraw in chain ${adapter.chain.id}`,\n inputTokens: async () =>\n Promise.resolve([\n {\n chainId: adapter.chain.id.toString(),\n tokens: aTokens,\n },\n ]),\n outputTokens: async () =>\n Promise.resolve([\n {\n chainId: adapter.chain.id.toString(),\n tokens: underlyingAssets,\n },\n ]),\n callback: adapter.createWithdrawTransaction.bind(adapter),\n },\n ];\n}\n\n/**\n * Register the AAVE plugin for the specified chain configuration.\n * @param chainConfig - The chain configuration to check for AAVE support.\n * @param registry - The public Ember plugin registry to register the plugin with.\n * @returns A promise that resolves when the plugin is registered.\n */\nexport function registerAave(chainConfig: ChainConfig, registry: PublicEmberPluginRegistry) {\n const supportedChains = [42161];\n if (!supportedChains.includes(chainConfig.chainId)) {\n return;\n }\n\n registry.registerDeferredPlugin(\n getAaveEmberPlugin({\n chainId: chainConfig.chainId,\n rpcUrl: chainConfig.rpcUrl,\n wrappedNativeToken: chainConfig.wrappedNativeToken,\n })\n );\n}\n","import type { ChainConfig } from './chainConfig.js';\nimport { PublicEmberPluginRegistry } from './registry.js';\nimport { registerAave } from './aave-lending-plugin/index.js';\n\n/**\n * Initialize the public Ember plugin registry.\n * @returns The initialized public Ember plugin registry with registered plugins.\n */\nexport function initializePublicRegistry(chainConfigs: ChainConfig[]) {\n const registry = new PublicEmberPluginRegistry();\n\n // Register any plugin in here\n for (const chainConfig of chainConfigs) {\n // Create aave plugins for each chain config\n registerAave(chainConfig, registry);\n }\n\n return registry;\n}\n\nexport { type ChainConfig, PublicEmberPluginRegistry };\nexport * from './core/index.js';\n"],"mappings":";AAKO,IAAM,4BAAN,MAAgC;AAAA,EAC7B,UAAqC,CAAC;AAAA,EACtC,kBAAsD,CAAC;AAAA;AAAA;AAAA;AAAA;AAAA,EAMxD,eAAe,QAAiC;AACrD,SAAK,QAAQ,KAAK,MAAM;AAAA,EAC1B;AAAA;AAAA;AAAA;AAAA;AAAA,EAMO,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,QAAQ,0BAA0B,KAAK,OAAO;AAAA,IAC1D;AAAA,EACF;AACF;AAQO,SAAS,aAAa,aAA0B,UAAqC;AAC1F,QAAM,kBAAkB,CAAC,KAAK;AAC9B,MAAI,CAAC,gBAAgB,SAAS,YAAY,OAAO,GAAG;AAClD;AAAA,EACF;AAEA,WAAS;AAAA,IACP,mBAAmB;AAAA,MACjB,SAAS,YAAY;AAAA,MACrB,QAAQ,YAAY;AAAA,MACpB,oBAAoB,YAAY;AAAA,IAClC,CAAC;AAAA,EACH;AACF;;;AC5JO,SAAS,yBAAyB,cAA6B;AACpE,QAAM,WAAW,IAAI,0BAA0B;AAG/C,aAAW,eAAe,cAAc;AAEtC,iBAAa,aAAa,QAAQ;AAAA,EACpC;AAEA,SAAO;AACT;","names":["ethers","ethers","ethers","z","z","z","z","z","z","z","z","z","z","ethers","totalBorrowsUSD","ur"]}
package/package.json CHANGED
@@ -1,13 +1,14 @@
1
1
  {
2
2
  "name": "@emberai/onchain-actions-registry",
3
- "version": "1.0.0",
3
+ "version": "1.1.1",
4
4
  "description": "Registry for plugins compatible with Ember to execute DeFi actions.",
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs",
7
7
  "module": "dist/index.js",
8
8
  "types": "dist/index.d.ts",
9
9
  "files": [
10
- "dist"
10
+ "dist",
11
+ "README.md"
11
12
  ],
12
13
  "sideEffects": false,
13
14
  "scripts": {