Skip to content

Add two Aave endpoints to get reserve data and reserve token addresses#4112

Merged
kajoseph merged 3 commits intobitpay:masterfrom
tmcollins4:addGetAaveTokenAddressesAndReserveData
Mar 11, 2026
Merged

Add two Aave endpoints to get reserve data and reserve token addresses#4112
kajoseph merged 3 commits intobitpay:masterfrom
tmcollins4:addGetAaveTokenAddressesAndReserveData

Conversation

@tmcollins4
Copy link
Copy Markdown
Contributor

Description

Added two new endpoints to get reserve data and reserve token addresses from Aave.

Changelog

  • Added AaveReserveData and AaveReserveTokensAddresses interfaces in packages/bitcore-node/src/providers/chain-state/evm/api/aave.ts.
  • Added /api/:chain/:network/aave/reserve/:asset endpoint; returns currentVariableBorrowRate.
  • Added /api/:chain/:network/aave/reserve-tokens/:asset endpoint; returns variableDebtTokenAddress.
  • Added CSP methods getAaveReserveData and getAaveReserveTokensAddresses.
  • Added unit tests for both methods covering v2 and v3.
  • Added integration tests for both endpoints covering v2 (mainnet RPC), v3 (sepolia), and 400 error cases.

Testing Notes

I made a script to call both endpoints across multiple chains/versions with USDC addresses.


Checklist

  • I have read CONTRIBUTING.md and verified that this PR follows the guidelines and requirements outlined in it.
  • I have added the appropriate package tag(s) (e.g. BWC if modifying the bitcore-wallet-client package, CLI if modifying the bitcore-cli package, etc.)
  • I have verified that this is not an existing PR (open or closed)

Comment on lines +129 to +141
const requestedVersion = String(req.query.version || 'v3').toLowerCase();
if (!isAaveVersion(requestedVersion)) {
res.status(400).send('Unsupported Aave version');
return;
}
if (!getAavePoolAddress(this.chain, network, requestedVersion)) {
res.status(400).send('Unsupported chain or network for Aave');
return;
}
if (!Web3.utils.isAddress(asset)) {
res.status(400).send('Invalid address');
return;
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is essentially repeated across here, getAaveReserveTokensAddresses and getAaveUserAccountData. code can be DRY'd up with a helper function like validateAaveRequest

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a centralized helper function to validate the request.

Copy link
Copy Markdown
Contributor

@leolambo leolambo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tACK

Copy link
Copy Markdown
Collaborator

@kajoseph kajoseph left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are a few linting errors here. TBH, I'm not sure how you were able to bypass the precommit lint check. npm run lint from the bitcore-node module should show you what needs to be fixed - mostly string double quotes in aavePool.ts and aavePoolV2.ts. Otherwise, I'm good to approve.

Copy link
Copy Markdown
Collaborator

@kajoseph kajoseph left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work!

@kajoseph kajoseph merged commit 2f45b33 into bitpay:master Mar 11, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants