From 94ca07e5f0904f8d56c8e40629b79b0411817070 Mon Sep 17 00:00:00 2001 From: Deepcryptodive <61325205+Deepcryptodive@users.noreply.github.com> Date: Tue, 14 Nov 2023 12:27:37 +0000 Subject: [PATCH 1/7] Update package.json to point to https://aave-nexus.pages.dev/ Creating new API service - focused on Aave only --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index b9d3a98..89a23a8 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,7 @@ "start:prod": "node dist/app/app.js", "start:wrangler": "yarn wrangler pages dev ./", "build": "tsc", - "deploy": "yarn wrangler pages deploy ./ --project-name spark-api --env production", + "deploy": "yarn wrangler pages deploy ./ --project-name aave-nexus --env production", "prepare": "husky install" }, "devDependencies": { From 5e0cc68f7726ec2fd6c93c01d2f288c9de420044 Mon Sep 17 00:00:00 2001 From: Deepcryptodive <61325205+Deepcryptodive@users.noreply.github.com> Date: Tue, 14 Nov 2023 13:12:07 +0000 Subject: [PATCH 2/7] Update to latest address package --- package.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 89a23a8..e9e2ff1 100644 --- a/package.json +++ b/package.json @@ -27,9 +27,9 @@ "wrangler": "^3.0.1" }, "dependencies": { - "@aave/contract-helpers": "^1.17.6", - "@aave/math-utils": "^1.17.6", - "@bgd-labs/aave-address-book": "^1.24.0", + "@aave/contract-helpers": "^1.21.0", + "@aave/math-utils": "^1.21.0", + "@bgd-labs/aave-address-book": "^2.11.0", "@cloudflare/workers-types": "^4.20230518.0", "@koa/cors": "^4.0.0", "bignumber.js": "^9.1.1", From 7575a950c9d1486c39d96e7bedf01765df364d5c Mon Sep 17 00:00:00 2001 From: Deepcryptodive <61325205+Deepcryptodive@users.noreply.github.com> Date: Tue, 14 Nov 2023 13:51:30 +0000 Subject: [PATCH 3/7] Add support for additional chains in helper.ts Arbitrum, Mainnet, Gnosis, Base, Optimism, Polygon, Metis --- utils/helper.ts | 88 ++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 79 insertions(+), 9 deletions(-) diff --git a/utils/helper.ts b/utils/helper.ts index 02e46f3..c59b927 100644 --- a/utils/helper.ts +++ b/utils/helper.ts @@ -9,27 +9,97 @@ export const chainConfig: { walletBalanceProvider: string; }; } = { + //Aave v3 on Arbitrum + [ChainId.arbitrum_one]: { + providerRPC: "https://arbitrum.llamarpc.com", + uiPoolDataProviderAddress: markets.AaveV3Arbitrum.UI_POOL_DATA_PROVIDER, + lendingPoolAddressProvider: markets.AaveV3Arbitrum.POOL_ADDRESSES_PROVIDER, + walletBalanceProvider: markets.AaveV3Arbitrum.WALLET_BALANCE_PROVIDER, + }, + //Aave v3 on Mainnet + [ChainId.mainnet]: { + providerRPC: "https://eth.llamarpc.com", + uiPoolDataProviderAddress: markets.AaveV3Ethereum.UI_POOL_DATA_PROVIDER, + lendingPoolAddressProvider: markets.AaveV3Ethereum.POOL_ADDRESSES_PROVIDER, + walletBalanceProvider: markets.AaveV3Ethereum.WALLET_BALANCE_PROVIDER, + }, + //Aave v3 on Gnosis - hardcoded chanId since it's not yet update in helper npm package + [100]: { + providerRPC: "https://gnosis.publicnode.com", + uiPoolDataProviderAddress: markets.AaveV3Gnosis.UI_POOL_DATA_PROVIDER, + lendingPoolAddressProvider: markets.AaveV3Gnosis.POOL_ADDRESSES_PROVIDER, + walletBalanceProvider: markets.AaveV3Gnosis.WALLET_BALANCE_PROVIDER, + }, + //Aave v3 on Base + [ChainId.base]: { + providerRPC: "https://base.llamarpc.com", + uiPoolDataProviderAddress: markets.AaveV3Base.UI_POOL_DATA_PROVIDER, + lendingPoolAddressProvider: markets.AaveV3Base.POOL_ADDRESSES_PROVIDER, + walletBalanceProvider: markets.AaveV3Base.WALLET_BALANCE_PROVIDER, + }, + //Aave v3 on Optimism + [ChainId.optimism]: { + providerRPC: "https://optimism.llamarpc.com", + uiPoolDataProviderAddress: markets.AaveV3Optimism.UI_POOL_DATA_PROVIDER, + lendingPoolAddressProvider: markets.AaveV3Optimism.POOL_ADDRESSES_PROVIDER, + walletBalanceProvider: markets.AaveV3Optimism.WALLET_BALANCE_PROVIDER, + }, + //Aave v3 on Polygon + [ChainId.polygon]: { + providerRPC: "https://polygon.llamarpc.com", + uiPoolDataProviderAddress: markets.AaveV3Polygon.UI_POOL_DATA_PROVIDER, + lendingPoolAddressProvider: markets.AaveV3Polygon.POOL_ADDRESSES_PROVIDER, + walletBalanceProvider: markets.AaveV3Polygon.WALLET_BALANCE_PROVIDER, + }, + + // Unused Aave markets (for now) + + //Aave v3 on Metis (1088) + [1088]: { + providerRPC: "https://metis-pokt.nodies.app", + uiPoolDataProviderAddress: markets.AaveV3Metis.UI_POOL_DATA_PROVIDER, + lendingPoolAddressProvider: markets.AaveV3Metis.POOL_ADDRESSES_PROVIDER, + walletBalanceProvider: markets.AaveV3Metis.WALLET_BALANCE_PROVIDER, + }, + + //Aave v3 on Fantom (250) - deprecated + /* + [ChainId.fantom]: { + providerRPC: "https://1rpc.io/ftm ", + uiPoolDataProviderAddress: markets.AaveV3Fantom.UI_POOL_DATA_PROVIDER, + lendingPoolAddressProvider: markets.AaveV3Fantom.POOL_ADDRESSES_PROVIDER, + walletBalanceProvider: markets.AaveV3Fantom.WALLET_BALANCE_PROVIDER, + }, + */ + + //Aave v3 on Harmony (1666600000) - deprecated + /* + [ChainId.harmony]: { + providerRPC: "https://1rpc.io/ftm ", + uiPoolDataProviderAddress: markets.AaveV3Harmony.UI_POOL_DATA_PROVIDER, + lendingPoolAddressProvider: markets.AaveV3Harmony.POOL_ADDRESSES_PROVIDER, + walletBalanceProvider: markets.AaveV3Harmony.WALLET_BALANCE_PROVIDER, + }, + */ + //Hardcoded the addresses of Spark protocol deployments //No Github 'address book' for Spark Protocol available + /* [ChainId.mainnet]: { - providerRPC: "https://eth-pokt.nodies.app", + providerRPC: "https://eth.llamarpc.com", uiPoolDataProviderAddress: "0xF028c2F4b19898718fD0F77b9b881CbfdAa5e8Bb", lendingPoolAddressProvider: "0x02C3eA4e34C0cBd694D2adFa2c690EECbC1793eE", walletBalanceProvider: "0xd2AeF86F51F92E8e49F42454c287AE4879D1BeDc", }, [100]: { - providerRPC: "https://gnosis-pokt.nodies.app", + providerRPC: "https://gnosis.publicnode.com", uiPoolDataProviderAddress: "0xF028c2F4b19898718fD0F77b9b881CbfdAa5e8Bb", lendingPoolAddressProvider: "0xA98DaCB3fC964A6A0d2ce3B77294241585EAbA6d", walletBalanceProvider: "0xd2AeF86F51F92E8e49F42454c287AE4879D1BeDc", }, - //Keep for debugging purposes - This relates to Aave v3 on Polygon - [ChainId.polygon]: { - providerRPC: "https://rpc.ankr.com/polygon", - uiPoolDataProviderAddress: markets.AaveV3Polygon.UI_POOL_DATA_PROVIDER, - lendingPoolAddressProvider: markets.AaveV3Polygon.POOL_ADDRESSES_PROVIDER, - walletBalanceProvider: markets.AaveV3Polygon.WALLET_BALANCE_PROVIDER, - }, + */ + + }; export function getTimestamp() { From 5b67681a755ddfaa6d5e253d3508842cdc2db43c Mon Sep 17 00:00:00 2001 From: Deepcryptodive <61325205+Deepcryptodive@users.noreply.github.com> Date: Tue, 14 Nov 2023 13:58:34 +0000 Subject: [PATCH 4/7] Update README.md --- README.md | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 71648d8..877d263 100644 --- a/README.md +++ b/README.md @@ -1,20 +1,20 @@ -# Data Service for Spark Protocol BOS Component +# Data Service for Aave v3 Protocol BOS Component -This service aggregates data from Spark Protocol across multiple chains, providing a crucial link between Spark Lend and applications that wish to utilize its data. [Spark Lend](https://github.com/marsfoundation/sparklend) is a lending market based on the Aave v3 codebase, that is currently live on Gnosis and Ethereum. +This service aggregates data from the Aave v3 Protocol across multiple chains, providing a crucial link between the [Aave lending market](https://github.com/aave) and applications that wish to utilize its data. -This Data Service was initially developed to be used in conjugation with [Spark Nexus](https://github.com/Deepcryptodive/spark-nexus), but it can also be run stand-alone. +This Data Service was initially developed to be used in conjugation with [Spark Nexus](https://github.com/Deepcryptodive/spark-nexus), but it can also be run stand-alone. Note that in the current `aave-nexus` branch, Spark Protocol is not supported - only Aave v3. ## Features -- Aggregates and serves market data from Spark Lend. +- Aggregates and serves market data from Aave v3 - Provides user-specific deposit, debt, and health factor information. -- Supports multiple blockchains (i.e. where Spark Protocol is deployed) +- Supports multiple blockchains (i.e. where Aave v3 is deployed) - Is accesible as public API ## Getting Started You can deploy this locally, or have it run on Cloudflare. -We have deployed it at `https://spark-api.pages.dev/` +We have deployed it at `https://aave-nexus.pages.dev/` ### Prerequisites @@ -35,13 +35,19 @@ Before running the service locally, ensure you have the following installed: Deploy the service to Cloudflare Pages with the `yarn deploy` command. Ensure you have the correct permissions and environmental variables set up. -i.e. in the [Cloudflare Dashboard]([url](https://dash.cloudflare.com/)), under `Workers & Pages` create a Page with name `spark-api` (or which name you defined in `package.json`). You **do not** need to link it to the Github repo. +i.e. in the [Cloudflare Dashboard]([url](https://dash.cloudflare.com/)), under `Workers & Pages` create a Page with name `aave-nexus` (or which name you defined in `package.json`). You **do not** need to link it to the Github repo. ## Support Chains (chainID) + - Ethereum Mainnet (1) +- Optimism (10) - Gnosis (100) -- _For debuggin purposes only:_ Polygon Mainnet (137) (fetching data from Aave v3 on Polygon) +- Polygon (137) +- Metis (1088) +- Base (8453) +- Arbitrum (42161) + ## API endpoints @@ -51,7 +57,7 @@ i.e. in the [Cloudflare Dashboard]([url](https://dash.cloudflare.com/)), under ` - Get all available Spark Lend markets - `chainId`: Spark Lend supported chain ID - Example query: https://spark-api.pages.dev/100/markets + Example query: https://aave-nexus.pages.dev/100/markets Example local query: http://localhost:8080/100/markets @@ -62,7 +68,7 @@ i.e. in the [Cloudflare Dashboard]([url](https://dash.cloudflare.com/)), under ` - `chainId`: Spark Lend supported chain ID - `user`: user address - Example query: https://spark-api.pages.dev/100/deposits/0xca4aD39F872E89Ef23eABd5716363Fc22513E147 + Example query: https://aave-nexus.pages.dev/100/deposits/0xca4aD39F872E89Ef23eABd5716363Fc22513E147 Example local query: http://localhost:8080/100/deposits/0xca4aD39F872E89Ef23eABd5716363Fc22513E147 @@ -73,7 +79,7 @@ i.e. in the [Cloudflare Dashboard]([url](https://dash.cloudflare.com/)), under ` - `chainId`: Spark Lend supported chain ID - `user`: user address - Example query: https://spark-api.pages.dev/100/debts/0xca4aD39F872E89Ef23eABd5716363Fc22513E147 + Example query: https://aave-nexus.pages.dev/100/debts/0xca4aD39F872E89Ef23eABd5716363Fc22513E147 Example local query: http://localhost:8080/100/debts/0xca4aD39F872E89Ef23eABd5716363Fc22513E147 @@ -87,7 +93,7 @@ i.e. in the [Cloudflare Dashboard]([url](https://dash.cloudflare.com/)), under ` - `amount`: token USD value - `asset`: token address - Example query: https://spark-api.pages.dev/100/health/0xca4aD39F872E89Ef23eABd5716363Fc22513E147?action=deposit&amount=10&asset=0xe91d153e0b41518a2ce8dd3d7944fa863463a97d + Example query: https://aave-nexus.pages.dev/100/health/0xca4aD39F872E89Ef23eABd5716363Fc22513E147?action=deposit&amount=10&asset=0xe91d153e0b41518a2ce8dd3d7944fa863463a97d Example local query: http://localhost:8080/100/health/0xca4aD39F872E89Ef23eABd5716363Fc22513E147?action=deposit&amount=10&asset=0xe91d153e0b41518a2ce8dd3d7944fa863463a97d From 5dc6dc3e79ab531ae9755692551e4ca4db480c97 Mon Sep 17 00:00:00 2001 From: Deepcryptodive <61325205+Deepcryptodive@users.noreply.github.com> Date: Tue, 14 Nov 2023 14:10:09 +0000 Subject: [PATCH 5/7] Update permit_config.ts to include new chains --- utils/permit_config.ts | 63 +++++++++++++++++++++++++++++++++--------- 1 file changed, 50 insertions(+), 13 deletions(-) diff --git a/utils/permit_config.ts b/utils/permit_config.ts index 1c94ef5..478d749 100644 --- a/utils/permit_config.ts +++ b/utils/permit_config.ts @@ -3,24 +3,61 @@ import { ChainId } from "@aave/contract-helpers"; export const permitByChainAndToken: { [chainId: number]: Record; } = { + [ChainId.arbitrum_one]: { + "0xf97f4df75117a78c1a5a0dbb814af92458539fb4": true, + "0xff970a61a04b1ca14834a43f5de4533ebddb5cc8": true, + "0x2f2a2543b76a4166549f7aab2e75bef0aefc5b0f": true, + "0x82af49447d8a07e3bd95bd0d56f35241523fbab1": true, + "0xfd086bc7cd5c481dcc9c85ebe478a1c0b69fcbb9": true, + "0xba5ddd1f9d7f570dc94a51479a000e3bce967196": true, + "0xd22a58f79e9481d1a88e00c343885a588b34b68b": false, // eurs + }, + [ChainId.mainnet]: { - "0x6b175474e89094c44da98b954eedeac495271d0f": false, - "0x83f20f44975d03b1b09e64809b757c47f942beea": false, - "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48": false, - "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2": false, - "0x7f39c581f595b53c5cb19bd0b3f8da6c935e2ca0": false, - "0x6810e776880c02933d47db1b9fc05908e5386b96": false, - "0xae78736cd615f374d3085123a210448e74fc6393": false, - "0xdac17f958d2ee523a2206206994597c13d831ec7": false, - }, - //Keep for debugging purposes - This relates to Aave v3 on Polygon - [ChainId.polygon]: { - "0x4e3decbb3645551b8a19f0ea1678079fcb33fb4c": true, + "0x2260fac5e5542a773aa44fbcfedf7c193bc2c599": false, + "0x514910771af9ca656af840dff83e8264ecf986ca": false, + "0x7fc66500c84a76ad7e9c93437bfc5ac33e2ddae9": true, + "0xbe9895146f7af43049ca1c1ae358b0541ea49704": false, + "0x5f98805a4e8be255a32880fdec7f6728c6568ba0": false, + "0xd533a949740bb3306d119cc777fa900ba034cd52": false, + "0x9f8f72aa9304c8b593d555f12ef6589cc3a579a2": false, + "0xc011a73ee8576fb46f5e1c5751ca3b9fe0af2a6f": false, + "0xba100000625a3754423978a60c9317c58a424e3d": false, + "0x1f9840a85d5af5bf1d1762f925bdaddc4201f984": false, + "0x5a98fcbea516cf06857215779fd812ca3bef1b32": false, + "0xc18360217d8f7ab5e7c516566761ea12ce7f9d72": false, + "0x111111111117dc0aa78b770fa6a738034120c302": false, + "0x853d955acef822db058eb8505911ed77f175b99e": false, + "0x40d16fc0246ad3160ccc09b8d0d3a2cd28ae6c2f": false, + "0xd33526068d116ce69f19a9ee46f0bd304f21a51f": false, + "0xaf5191b0de278c7286d6c7cc6ab6bb8a73ba2cd6": false, + "0xdefa4e8a7bcba345f687a2f1456f5edd9ce97202": false, }, + [100]: { - "0xe91d153e0b41518a2ce8dd3d7944fa863463a97d": false, "0x6a023ccd1ff6f2045c3309768ead9e68f978f6e1": false, "0x6c76971f98945ae98dd7d4dfca8711ebea946ea6": false, "0x9c58bacc331c9aa871afd802db6379a98e80cedb": false, + "0xddafbb505ad214d7b80b1f830fccc89b60fb7a83": false, + "0xe91d153e0b41518a2ce8dd3d7944fa863463a97d": false, + "0xcb444e90d8198415266c6a2724b7900fb12fc56e": false, + "0xaf204776c7245bf4147c2612bf6e5972ee483701": false, + }, + + [ChainId.base]: { + }, + + [ChainId.optimism]: { + }, + + [ChainId.polygon]: { + "0x4e3decbb3645551b8a19f0ea1678079fcb33fb4c": true, }, + + [1088]: { + }, + + [ChainId.avalanche]: { + }, + }; From 1d94f7e30ebd2f6dd9ba093559aa071dc5417d92 Mon Sep 17 00:00:00 2001 From: Deepcryptodive <61325205+Deepcryptodive@users.noreply.github.com> Date: Tue, 14 Nov 2023 14:10:43 +0000 Subject: [PATCH 6/7] Add Avalanche support --- utils/helper.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/utils/helper.ts b/utils/helper.ts index c59b927..66aa549 100644 --- a/utils/helper.ts +++ b/utils/helper.ts @@ -62,6 +62,14 @@ export const chainConfig: { walletBalanceProvider: markets.AaveV3Metis.WALLET_BALANCE_PROVIDER, }, + //Aave v3 on Avalanche (43114) + [ChainId.avalanche]: { + providerRPC: "https://avax-pokt.nodies.app/ext/bc/C/rpc", + uiPoolDataProviderAddress: markets.AaveV3Avalanche.UI_POOL_DATA_PROVIDER, + lendingPoolAddressProvider: markets.AaveV3Avalanche.POOL_ADDRESSES_PROVIDER, + walletBalanceProvider: markets.AaveV3Avalanche.WALLET_BALANCE_PROVIDER, + }, + //Aave v3 on Fantom (250) - deprecated /* [ChainId.fantom]: { From 10acc90a8295be11445755d712ccf3c3b511b243 Mon Sep 17 00:00:00 2001 From: Deepcryptodive <61325205+Deepcryptodive@users.noreply.github.com> Date: Tue, 14 Nov 2023 14:12:36 +0000 Subject: [PATCH 7/7] Update README.md --- README.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 877d263..dccaa7c 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Data Service for Aave v3 Protocol BOS Component +# Data Service for Aave v3 Protocol BOS Components This service aggregates data from the Aave v3 Protocol across multiple chains, providing a crucial link between the [Aave lending market](https://github.com/aave) and applications that wish to utilize its data. @@ -39,7 +39,6 @@ i.e. in the [Cloudflare Dashboard]([url](https://dash.cloudflare.com/)), under ` ## Support Chains (chainID) - - Ethereum Mainnet (1) - Optimism (10) - Gnosis (100) @@ -47,7 +46,7 @@ i.e. in the [Cloudflare Dashboard]([url](https://dash.cloudflare.com/)), under ` - Metis (1088) - Base (8453) - Arbitrum (42161) - +- Avalanche (43114) ## API endpoints