From 1784daf79f1f4af5a63f4aaf12001baeab58b2ee Mon Sep 17 00:00:00 2001 From: William Poulin Date: Wed, 11 Oct 2023 16:08:07 -0400 Subject: [PATCH] fix(granary-finance): Add variable debt on Base --- .../granary-finance.position-presenter.ts | 22 ++++++++++++++ ...anary-finance.stable-debt.token-fetcher.ts | 28 ------------------ .../granary-finance.position-presenter.ts | 29 +++++++++++++++++++ ...ry-finance.variable-debt.token-fetcher.ts} | 10 +++---- .../granary-finance.position-presenter.ts | 22 ++++++++++++++ ...anary-finance.stable-debt.token-fetcher.ts | 28 ------------------ .../granary-finance.position-presenter.ts | 22 ++++++++++++++ .../granary-finance/granary-finance.module.ts | 13 ++++----- .../granary-finance.position-presenter.ts | 22 ++++++++++++++ ...anary-finance.stable-debt.token-fetcher.ts | 28 ------------------ 10 files changed, 127 insertions(+), 97 deletions(-) delete mode 100644 src/apps/granary-finance/arbitrum/granary-finance.stable-debt.token-fetcher.ts create mode 100644 src/apps/granary-finance/base/granary-finance.position-presenter.ts rename src/apps/granary-finance/{fantom/granary-finance.stable-debt.token-fetcher.ts => base/granary-finance.variable-debt.token-fetcher.ts} (72%) delete mode 100644 src/apps/granary-finance/ethereum/granary-finance.stable-debt.token-fetcher.ts delete mode 100644 src/apps/granary-finance/optimism/granary-finance.stable-debt.token-fetcher.ts diff --git a/src/apps/granary-finance/arbitrum/granary-finance.position-presenter.ts b/src/apps/granary-finance/arbitrum/granary-finance.position-presenter.ts index d330ad310..ba7941cc0 100644 --- a/src/apps/granary-finance/arbitrum/granary-finance.position-presenter.ts +++ b/src/apps/granary-finance/arbitrum/granary-finance.position-presenter.ts @@ -1,7 +1,29 @@ import { PresenterTemplate } from '~app-toolkit/decorators/presenter-template.decorator'; +import { PresentationConfig } from '~app/app.interface'; import { AaveV2PositionPresenter } from '~apps/aave-v2/common/aave-v2.position-presenter'; @PresenterTemplate() export class ArbitrumGranaryFinancePositionPresenter extends AaveV2PositionPresenter { lendingPoolAddress = '0x102442a3ba1e441043154bc0b8a2e2fb5e0f94a7'; + + explorePresentationConfig?: PresentationConfig = { + tabs: [ + { + label: 'Lending', + viewType: 'split', + views: [ + { + viewType: 'list', + label: 'Supply', + groupIds: ['supply'], + }, + { + viewType: 'list', + label: 'Borrow', + groupIds: ['variable-debt'], + }, + ], + }, + ], + }; } diff --git a/src/apps/granary-finance/arbitrum/granary-finance.stable-debt.token-fetcher.ts b/src/apps/granary-finance/arbitrum/granary-finance.stable-debt.token-fetcher.ts deleted file mode 100644 index d59ebbde9..000000000 --- a/src/apps/granary-finance/arbitrum/granary-finance.stable-debt.token-fetcher.ts +++ /dev/null @@ -1,28 +0,0 @@ -import { PositionTemplate } from '~app-toolkit/decorators/position-template.decorator'; -import { - AaveV2LendingTokenFetcher, - AaveV2LendingTokenDataProps, - AaveV2ReserveApyData, - AaveV2ReserveTokenAddressesData, -} from '~apps/aave-v2/common/aave-v2.lending.token-fetcher'; -import { AaveV2AToken } from '~apps/aave-v2/contracts'; -import { GetDisplayPropsParams } from '~position/template/app-token.template.types'; - -@PositionTemplate() -export class ArbitrumGranaryFinanceStableDebtTokenFetcher extends AaveV2LendingTokenFetcher { - groupLabel = 'Lending'; - providerAddress = '0x96bcfb86f1bff315c13e00d850e2faea93ccd3e7'; - isDebt = true; - - getTokenAddress(reserveTokenAddressesData: AaveV2ReserveTokenAddressesData): string { - return reserveTokenAddressesData.stableDebtTokenAddress; - } - - getApyFromReserveData(reserveApyData: AaveV2ReserveApyData): number { - return reserveApyData.stableBorrowApy; - } - - async getTertiaryLabel({ appToken }: GetDisplayPropsParams) { - return `${appToken.dataProps.apy.toFixed(3)}% APR (stable)`; - } -} diff --git a/src/apps/granary-finance/base/granary-finance.position-presenter.ts b/src/apps/granary-finance/base/granary-finance.position-presenter.ts new file mode 100644 index 000000000..aa2a353ae --- /dev/null +++ b/src/apps/granary-finance/base/granary-finance.position-presenter.ts @@ -0,0 +1,29 @@ +import { PresenterTemplate } from '~app-toolkit/decorators/presenter-template.decorator'; +import { PresentationConfig } from '~app/app.interface'; +import { AaveV2PositionPresenter } from '~apps/aave-v2/common/aave-v2.position-presenter'; + +@PresenterTemplate() +export class BaseGranaryFinancePositionPresenter extends AaveV2PositionPresenter { + lendingPoolAddress = '0xb702ce183b4e1faa574834715e5d4a6378d0eed3'; + + explorePresentationConfig?: PresentationConfig = { + tabs: [ + { + label: 'Lending', + viewType: 'split', + views: [ + { + viewType: 'list', + label: 'Supply', + groupIds: ['supply'], + }, + { + viewType: 'list', + label: 'Borrow', + groupIds: ['variable-debt'], + }, + ], + }, + ], + }; +} diff --git a/src/apps/granary-finance/fantom/granary-finance.stable-debt.token-fetcher.ts b/src/apps/granary-finance/base/granary-finance.variable-debt.token-fetcher.ts similarity index 72% rename from src/apps/granary-finance/fantom/granary-finance.stable-debt.token-fetcher.ts rename to src/apps/granary-finance/base/granary-finance.variable-debt.token-fetcher.ts index 4fa6fcd42..ce7decffe 100644 --- a/src/apps/granary-finance/fantom/granary-finance.stable-debt.token-fetcher.ts +++ b/src/apps/granary-finance/base/granary-finance.variable-debt.token-fetcher.ts @@ -9,20 +9,20 @@ import { AaveV2AToken } from '~apps/aave-v2/contracts'; import { GetDisplayPropsParams } from '~position/template/app-token.template.types'; @PositionTemplate() -export class FantomGranaryFinanceStableDebtTokenFetcher extends AaveV2LendingTokenFetcher { +export class BaseGranaryFinanceVariableDebtTokenFetcher extends AaveV2LendingTokenFetcher { groupLabel = 'Lending'; - providerAddress = '0x3132870d08f736505ff13b19199be17629085072'; + providerAddress = '0xed984a0e9c12ee27602314191fc4487a702bb83f'; isDebt = true; getTokenAddress(reserveTokenAddressesData: AaveV2ReserveTokenAddressesData): string { - return reserveTokenAddressesData.stableDebtTokenAddress; + return reserveTokenAddressesData.variableDebtTokenAddress; } getApyFromReserveData(reserveApyData: AaveV2ReserveApyData): number { - return reserveApyData.stableBorrowApy; + return reserveApyData.variableBorrowApy; } async getTertiaryLabel({ appToken }: GetDisplayPropsParams) { - return `${appToken.dataProps.apy.toFixed(3)}% APR (stable)`; + return `${appToken.dataProps.apy.toFixed(3)}% APR (variable)`; } } diff --git a/src/apps/granary-finance/ethereum/granary-finance.position-presenter.ts b/src/apps/granary-finance/ethereum/granary-finance.position-presenter.ts index 98d3c06df..3723f5ee0 100644 --- a/src/apps/granary-finance/ethereum/granary-finance.position-presenter.ts +++ b/src/apps/granary-finance/ethereum/granary-finance.position-presenter.ts @@ -1,7 +1,29 @@ import { PresenterTemplate } from '~app-toolkit/decorators/presenter-template.decorator'; +import { PresentationConfig } from '~app/app.interface'; import { AaveV2PositionPresenter } from '~apps/aave-v2/common/aave-v2.position-presenter'; @PresenterTemplate() export class EthereumGranaryFinancePositionPresenter extends AaveV2PositionPresenter { lendingPoolAddress = '0xb702ce183b4e1faa574834715e5d4a6378d0eed3'; + + explorePresentationConfig?: PresentationConfig = { + tabs: [ + { + label: 'Lending', + viewType: 'split', + views: [ + { + viewType: 'list', + label: 'Supply', + groupIds: ['supply'], + }, + { + viewType: 'list', + label: 'Borrow', + groupIds: ['variable-debt'], + }, + ], + }, + ], + }; } diff --git a/src/apps/granary-finance/ethereum/granary-finance.stable-debt.token-fetcher.ts b/src/apps/granary-finance/ethereum/granary-finance.stable-debt.token-fetcher.ts deleted file mode 100644 index 110ff95c7..000000000 --- a/src/apps/granary-finance/ethereum/granary-finance.stable-debt.token-fetcher.ts +++ /dev/null @@ -1,28 +0,0 @@ -import { PositionTemplate } from '~app-toolkit/decorators/position-template.decorator'; -import { - AaveV2LendingTokenFetcher, - AaveV2LendingTokenDataProps, - AaveV2ReserveApyData, - AaveV2ReserveTokenAddressesData, -} from '~apps/aave-v2/common/aave-v2.lending.token-fetcher'; -import { AaveV2AToken } from '~apps/aave-v2/contracts'; -import { GetDisplayPropsParams } from '~position/template/app-token.template.types'; - -@PositionTemplate() -export class EthereumGranaryFinanceStableDebtTokenFetcher extends AaveV2LendingTokenFetcher { - groupLabel = 'Lending'; - providerAddress = '0x33c62bc416309f010c4941163abea3725e4645bf'; - isDebt = true; - - getTokenAddress(reserveTokenAddressesData: AaveV2ReserveTokenAddressesData): string { - return reserveTokenAddressesData.stableDebtTokenAddress; - } - - getApyFromReserveData(reserveApyData: AaveV2ReserveApyData): number { - return reserveApyData.stableBorrowApy; - } - - async getTertiaryLabel({ appToken }: GetDisplayPropsParams) { - return `${appToken.dataProps.apy.toFixed(3)}% APR (stable)`; - } -} diff --git a/src/apps/granary-finance/fantom/granary-finance.position-presenter.ts b/src/apps/granary-finance/fantom/granary-finance.position-presenter.ts index 173729a1f..5efb8531a 100644 --- a/src/apps/granary-finance/fantom/granary-finance.position-presenter.ts +++ b/src/apps/granary-finance/fantom/granary-finance.position-presenter.ts @@ -1,7 +1,29 @@ import { PresenterTemplate } from '~app-toolkit/decorators/presenter-template.decorator'; +import { PresentationConfig } from '~app/app.interface'; import { AaveV2PositionPresenter } from '~apps/aave-v2/common/aave-v2.position-presenter'; @PresenterTemplate() export class FantomGranaryFinancePositionPresenter extends AaveV2PositionPresenter { lendingPoolAddress = '0x7220ffd5dc173ba3717e47033a01d870f06e5284'; + + explorePresentationConfig?: PresentationConfig = { + tabs: [ + { + label: 'Lending', + viewType: 'split', + views: [ + { + viewType: 'list', + label: 'Supply', + groupIds: ['supply'], + }, + { + viewType: 'list', + label: 'Borrow', + groupIds: ['variable-debt'], + }, + ], + }, + ], + }; } diff --git a/src/apps/granary-finance/granary-finance.module.ts b/src/apps/granary-finance/granary-finance.module.ts index 10bd5262f..2e6e91389 100644 --- a/src/apps/granary-finance/granary-finance.module.ts +++ b/src/apps/granary-finance/granary-finance.module.ts @@ -4,20 +4,18 @@ import { AbstractApp } from '~app/app.dynamic-module'; import { AaveV2ContractFactory } from '~apps/aave-v2/contracts'; import { ArbitrumGranaryFinancePositionPresenter } from './arbitrum/granary-finance.position-presenter'; -import { ArbitrumGranaryFinanceStableDebtTokenFetcher } from './arbitrum/granary-finance.stable-debt.token-fetcher'; import { ArbitrumGranaryFinanceSupplyTokenFetcher } from './arbitrum/granary-finance.supply.token-fetcher'; import { ArbitrumGranaryFinanceVariableDebtTokenFetcher } from './arbitrum/granary-finance.variable-debt.token-fetcher'; +import { BaseGranaryFinancePositionPresenter } from './base/granary-finance.position-presenter'; +import { BaseGranaryFinanceVariableDebtTokenFetcher } from './base/granary-finance.variable-debt.token-fetcher'; import { GranaryFinanceContractFactory } from './contracts'; import { EthereumGranaryFinancePositionPresenter } from './ethereum/granary-finance.position-presenter'; -import { EthereumGranaryFinanceStableDebtTokenFetcher } from './ethereum/granary-finance.stable-debt.token-fetcher'; import { EthereumGranaryFinanceSupplyTokenFetcher } from './ethereum/granary-finance.supply.token-fetcher'; import { EthereumGranaryFinanceVariableDebtTokenFetcher } from './ethereum/granary-finance.variable-debt.token-fetcher'; import { FantomGranaryFinancePositionPresenter } from './fantom/granary-finance.position-presenter'; -import { FantomGranaryFinanceStableDebtTokenFetcher } from './fantom/granary-finance.stable-debt.token-fetcher'; import { FantomGranaryFinanceSupplyTokenFetcher } from './fantom/granary-finance.supply.token-fetcher'; import { FantomGranaryFinanceVariableDebtTokenFetcher } from './fantom/granary-finance.variable-debt.token-fetcher'; import { OptimismGranaryFinancePositionPresenter } from './optimism/granary-finance.position-presenter'; -import { OptimismGranaryFinanceStableDebtTokenFetcher } from './optimism/granary-finance.stable-debt.token-fetcher'; import { OptimismGranaryFinanceSupplyTokenFetcher } from './optimism/granary-finance.supply.token-fetcher'; import { OptimismGranaryFinanceVariableDebtTokenFetcher } from './optimism/granary-finance.variable-debt.token-fetcher'; @@ -27,22 +25,21 @@ import { OptimismGranaryFinanceVariableDebtTokenFetcher } from './optimism/grana AaveV2ContractFactory, // Arbitrum ArbitrumGranaryFinancePositionPresenter, - ArbitrumGranaryFinanceStableDebtTokenFetcher, ArbitrumGranaryFinanceSupplyTokenFetcher, ArbitrumGranaryFinanceVariableDebtTokenFetcher, + // Base + BaseGranaryFinancePositionPresenter, + BaseGranaryFinanceVariableDebtTokenFetcher, // Ethereum EthereumGranaryFinancePositionPresenter, - EthereumGranaryFinanceStableDebtTokenFetcher, EthereumGranaryFinanceSupplyTokenFetcher, EthereumGranaryFinanceVariableDebtTokenFetcher, // Fantom FantomGranaryFinancePositionPresenter, - FantomGranaryFinanceStableDebtTokenFetcher, FantomGranaryFinanceSupplyTokenFetcher, FantomGranaryFinanceVariableDebtTokenFetcher, // Optimism OptimismGranaryFinancePositionPresenter, - OptimismGranaryFinanceStableDebtTokenFetcher, OptimismGranaryFinanceSupplyTokenFetcher, OptimismGranaryFinanceVariableDebtTokenFetcher, ], diff --git a/src/apps/granary-finance/optimism/granary-finance.position-presenter.ts b/src/apps/granary-finance/optimism/granary-finance.position-presenter.ts index b416cf2da..25b85d158 100644 --- a/src/apps/granary-finance/optimism/granary-finance.position-presenter.ts +++ b/src/apps/granary-finance/optimism/granary-finance.position-presenter.ts @@ -1,7 +1,29 @@ import { PresenterTemplate } from '~app-toolkit/decorators/presenter-template.decorator'; +import { PresentationConfig } from '~app/app.interface'; import { AaveV2PositionPresenter } from '~apps/aave-v2/common/aave-v2.position-presenter'; @PresenterTemplate() export class OptimismGranaryFinancePositionPresenter extends AaveV2PositionPresenter { lendingPoolAddress = '0x8fd4af47e4e63d1d2d45582c3286b4bd9bb95dfe'; + + explorePresentationConfig?: PresentationConfig = { + tabs: [ + { + label: 'Lending', + viewType: 'split', + views: [ + { + viewType: 'list', + label: 'Supply', + groupIds: ['supply'], + }, + { + viewType: 'list', + label: 'Borrow', + groupIds: ['variable-debt'], + }, + ], + }, + ], + }; } diff --git a/src/apps/granary-finance/optimism/granary-finance.stable-debt.token-fetcher.ts b/src/apps/granary-finance/optimism/granary-finance.stable-debt.token-fetcher.ts deleted file mode 100644 index 034b81ae7..000000000 --- a/src/apps/granary-finance/optimism/granary-finance.stable-debt.token-fetcher.ts +++ /dev/null @@ -1,28 +0,0 @@ -import { PositionTemplate } from '~app-toolkit/decorators/position-template.decorator'; -import { - AaveV2LendingTokenFetcher, - AaveV2LendingTokenDataProps, - AaveV2ReserveApyData, - AaveV2ReserveTokenAddressesData, -} from '~apps/aave-v2/common/aave-v2.lending.token-fetcher'; -import { AaveV2AToken } from '~apps/aave-v2/contracts'; -import { GetDisplayPropsParams } from '~position/template/app-token.template.types'; - -@PositionTemplate() -export class OptimismGranaryFinanceStableDebtTokenFetcher extends AaveV2LendingTokenFetcher { - groupLabel = 'Lending'; - providerAddress = '0x9546f673ef71ff666ae66d01fd6e7c6dae5a9995'; - isDebt = true; - - getTokenAddress(reserveTokenAddressesData: AaveV2ReserveTokenAddressesData): string { - return reserveTokenAddressesData.stableDebtTokenAddress; - } - - getApyFromReserveData(reserveApyData: AaveV2ReserveApyData): number { - return reserveApyData.stableBorrowApy; - } - - async getTertiaryLabel({ appToken }: GetDisplayPropsParams) { - return `${appToken.dataProps.apy.toFixed(3)}% APR (stable)`; - } -}