Skip to content

Commit

Permalink
Aave GHO markets (#3969)
Browse files Browse the repository at this point in the history
  • Loading branch information
piekczyk committed Jun 26, 2024
1 parent a8628e5 commit b94a845
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 1 deletion.
16 changes: 16 additions & 0 deletions blockchain/aave-v3/aave-v3-pool-data-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,22 @@ export function getAaveV3ReserveData({
})
}

export function getAaveV3BorrowCap({
token,
networkId,
}: AaveV3ReserveDataParameters): Promise<BigNumber> {
const { contract, tokenMappings } = networkMappings[networkId]()
const tokenAddress = wethToEthAddress(tokenMappings, token)
warnIfAddressIsZero(tokenAddress, networkId, 'aaveV3PoolDataProvider', 'getReserveData')

return (
contract
.getReserveCaps(tokenAddress)
// doesn't require conversion from wei since value is already in correct format
.then((result) => new BigNumber(result.borrowCap.toString()))
)
}

export function getAaveV3ReserveConfigurationData({
networkId,
token,
Expand Down
6 changes: 6 additions & 0 deletions features/aave/strategies/ethereum-aave-v3-strategies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,12 @@ const availableTokenPairs: TokenPairConfig[] = [
strategyType: StrategyType.Long,
productTypes: borrowAndMultiply,
},
{
collateral: 'WEETH',
debt: 'GHO',
strategyType: StrategyType.Long,
productTypes: borrowAndMultiply,
},
{
collateral: 'ETH',
debt: 'USDT',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -896,6 +896,28 @@ export const aaveV3EthereumMainnetProductHubProducts: ProductHubItemWithoutAddre
network: NetworkNames.ethereumMainnet,
protocol: LendingProtocol.AaveV3,
},
{
product: [OmniProductType.Multiply],
primaryToken: 'WEETH',
primaryTokenGroup: getTokenGroup('WEETH'),
secondaryToken: 'GHO',
depositToken: 'WEETH',
label: 'WEETH/GHO',
multiplyStrategyType: 'long',
multiplyStrategy: 'Long ETH',
network: NetworkNames.ethereumMainnet,
protocol: LendingProtocol.AaveV3,
},
{
product: [OmniProductType.Borrow],
primaryToken: 'WEETH',
primaryTokenGroup: getTokenGroup('WEETH'),
secondaryToken: 'GHO',
depositToken: 'WEETH',
label: 'WEETH/GHO',
network: NetworkNames.ethereumMainnet,
protocol: LendingProtocol.AaveV3,
},
{
product: [OmniProductType.Multiply],
primaryToken: 'ETH',
Expand Down
22 changes: 21 additions & 1 deletion handlers/product-hub/update-handlers/aaveV3/aaveV3Handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import BigNumber from 'bignumber.js'
import type { AaveV3SupportedNetwork } from 'blockchain/aave-v3'
import {
aaveV3SupportedNetworkList,
getAaveV3BorrowCap,
getAaveV3EModeCategoryForAsset,
getAaveV3ReserveConfigurationData,
getAaveV3ReserveData,
Expand Down Expand Up @@ -39,6 +40,8 @@ const networkNameToIdMap = {
[NetworkNames.baseMainnet]: NetworkIds.BASEMAINNET,
}

const tokensWithoutAssociatedToken = ['GHO']

const getAaveV3TokensData = async (networkName: AaveV3Networks, tickers: Tickers) => {
const currentNetworkProducts = aaveV3ProductHubProducts.filter(
(product) => product.network === networkName,
Expand All @@ -62,13 +65,30 @@ const getAaveV3TokensData = async (networkName: AaveV3Networks, tickers: Tickers
const tokensReserveDataPromises = secondaryTokensList.map(async (token) => {
const reserveData = await getAaveV3ReserveData({ token, networkId })
const debtTokenPrice = new BigNumber(getTokenPrice(token, tickers, 'aaveV3Handler'))

const fee = aaveLikeAprToApy(reserveData.variableBorrowRate)

if (tokensWithoutAssociatedToken.includes(token.toUpperCase())) {
const borrowCap = await getAaveV3BorrowCap({ token, networkId })

return {
[token]: {
liquidity: borrowCap
.minus(reserveData.totalStableDebt)
.minus(reserveData.totalVariableDebt)
.times(debtTokenPrice),
fee,
},
}
}

return {
[token]: {
liquidity: reserveData.totalAToken
.minus(reserveData.totalStableDebt)
.minus(reserveData.totalVariableDebt)
.times(debtTokenPrice),
fee: aaveLikeAprToApy(reserveData.variableBorrowRate),
fee,
},
}
})
Expand Down

0 comments on commit b94a845

Please sign in to comment.