Skip to content

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

Open
tmcollins4 wants to merge 2 commits intobitpay:masterfrom
tmcollins4:addGetAaveTokenAddressesAndReserveData
Open

Add two Aave endpoints to get reserve data and reserve token addresses#4112
tmcollins4 wants to merge 2 commits intobitpay:masterfrom
tmcollins4:addGetAaveTokenAddressesAndReserveData

Conversation

@tmcollins4
Copy link
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
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
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
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

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.

2 participants