From 1fde9afe467fb13e22c633a27983c31c0d34a7cd Mon Sep 17 00:00:00 2001 From: Justin D'Errico Date: Wed, 8 Jun 2022 11:50:12 -0400 Subject: [PATCH] feat(exchangeable-tokens): Compound and Olympus tokens as exchangeable (#601) --- src/app-toolkit/helpers/position/vault.token-helper.ts | 7 +++++-- .../compound/ethereum/compound.supply.token-fetcher.ts | 1 + src/apps/compound/helper/compound.supply.token-helper.ts | 7 +++++-- src/apps/olympus/ethereum/olympus.g-ohm.token-fetcher.ts | 1 + .../olympus/ethereum/olympus.s-ohm-v1.token-fetcher.ts | 1 + src/apps/olympus/ethereum/olympus.s-ohm.token-fetcher.ts | 1 + 6 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/app-toolkit/helpers/position/vault.token-helper.ts b/src/app-toolkit/helpers/position/vault.token-helper.ts index d8f42b8f2..d1851bb7e 100644 --- a/src/app-toolkit/helpers/position/vault.token-helper.ts +++ b/src/app-toolkit/helpers/position/vault.token-helper.ts @@ -13,11 +13,11 @@ import { getImagesFromToken } from '~app-toolkit/helpers/presentation/image.pres import { EthersMulticall } from '~multicall'; import { ContractType } from '~position/contract.interface'; import { StatsItem } from '~position/display.interface'; -import { AppTokenPosition, Token } from '~position/position.interface'; +import { AppTokenPosition, ExchangeableAppTokenDataProps, Token } from '~position/position.interface'; import { AppGroupsDefinition } from '~position/position.service'; import { Network } from '~types/network.interface'; -export type VaultTokenDataProps = { +export type VaultTokenDataProps = ExchangeableAppTokenDataProps & { liquidity: number; reserve: number; }; @@ -27,6 +27,7 @@ export type VaultTokenHelperParams = { appId: string; groupId: string; dependencies?: AppGroupsDefinition[]; + exchangeable?: boolean; resolveContract: (opts: { address: string; network: Network }) => T; resolveVaultAddresses: (opts: { multicall: EthersMulticall; network: Network }) => string[] | Promise; resolveUnderlyingTokenAddress: (opts: { multicall: EthersMulticall; contract: T }) => string | Promise; @@ -58,6 +59,7 @@ export class VaultTokenHelper { appId, groupId, dependencies = [], + exchangeable = false, resolveVaultAddresses, resolveContract, resolveUnderlyingTokenAddress, @@ -131,6 +133,7 @@ export class VaultTokenHelper { dataProps: { liquidity, reserve, + exchangeable, }, displayProps: { diff --git a/src/apps/compound/ethereum/compound.supply.token-fetcher.ts b/src/apps/compound/ethereum/compound.supply.token-fetcher.ts index 33aafc6a7..22e22c7fa 100644 --- a/src/apps/compound/ethereum/compound.supply.token-fetcher.ts +++ b/src/apps/compound/ethereum/compound.supply.token-fetcher.ts @@ -25,6 +25,7 @@ export class EthereumCompoundSupplyTokenFetcher implements PositionFetcher this.compoundContractFactory.compoundComptroller({ address, network }), diff --git a/src/apps/compound/helper/compound.supply.token-helper.ts b/src/apps/compound/helper/compound.supply.token-helper.ts index 3bc2f5c61..97f93406f 100644 --- a/src/apps/compound/helper/compound.supply.token-helper.ts +++ b/src/apps/compound/helper/compound.supply.token-helper.ts @@ -13,14 +13,14 @@ import { getTokenImg } from '~app-toolkit/helpers/presentation/image.present'; import { EthersMulticall as Multicall } from '~multicall/multicall.ethers'; import { ContractType } from '~position/contract.interface'; import { BalanceDisplayMode } from '~position/display.interface'; -import { AppTokenPosition, Token } from '~position/position.interface'; +import { AppTokenPosition, ExchangeableAppTokenDataProps, Token } from '~position/position.interface'; import { AppGroupsDefinition } from '~position/position.service'; import { BaseToken } from '~position/token.interface'; import { Network } from '~types/network.interface'; import { CompoundComptroller, CompoundContractFactory, CompoundCToken } from '../contracts'; -export type CompoundSupplyTokenDataProps = { +export type CompoundSupplyTokenDataProps = ExchangeableAppTokenDataProps & { supplyApy: number; borrowApy: number; liquidity: number; @@ -46,6 +46,7 @@ type CompoundSupplyTokenHelperParams number; getDisplayLabel?: (opts: { contract: V; multicall: Multicall; underlyingToken: Token }) => Promise; getDenormalizedRate?: (opts: { rate: BigNumberish; blocksPerDay: number; decimals: number }) => number; + exchangeable?: boolean; }; @Injectable() @@ -61,6 +62,7 @@ export class CompoundSupplyTokenHelper { network, appId, groupId, + exchangeable = false, dependencies = [], allTokens = [], getComptrollerContract, @@ -161,6 +163,7 @@ export class CompoundSupplyTokenHelper { borrowApy, liquidity, comptrollerAddress, + exchangeable, }, displayProps: { diff --git a/src/apps/olympus/ethereum/olympus.g-ohm.token-fetcher.ts b/src/apps/olympus/ethereum/olympus.g-ohm.token-fetcher.ts index 367a574f2..cad8dfa90 100644 --- a/src/apps/olympus/ethereum/olympus.g-ohm.token-fetcher.ts +++ b/src/apps/olympus/ethereum/olympus.g-ohm.token-fetcher.ts @@ -31,6 +31,7 @@ export class EthereumOlympusGOhmTokenFetcher implements PositionFetcher ['0x0ab87046fbb341d058f17cbc4c1133f25a20a52f'], // gOHM resolveContract: ({ address, network }) => this.contractFactory.olympusGOhmToken({ address, network }), diff --git a/src/apps/olympus/ethereum/olympus.s-ohm-v1.token-fetcher.ts b/src/apps/olympus/ethereum/olympus.s-ohm-v1.token-fetcher.ts index c332e7e40..0a46304c7 100644 --- a/src/apps/olympus/ethereum/olympus.s-ohm-v1.token-fetcher.ts +++ b/src/apps/olympus/ethereum/olympus.s-ohm-v1.token-fetcher.ts @@ -30,6 +30,7 @@ export class EthereumOlympusSOhmV1TokenFetcher implements PositionFetcher this.contractFactory.olympusSOhmV1Token({ address, network }), resolveVaultAddresses: () => ['0x04f2694c8fcee23e8fd0dfea1d4f5bb8c352111f'], // sOHMv1 resolveUnderlyingTokenAddress: () => '0x383518188c0c6d7730d91b2c03a03c837814a899', // OHMv1 diff --git a/src/apps/olympus/ethereum/olympus.s-ohm.token-fetcher.ts b/src/apps/olympus/ethereum/olympus.s-ohm.token-fetcher.ts index 51d105554..c0ef6e4d5 100644 --- a/src/apps/olympus/ethereum/olympus.s-ohm.token-fetcher.ts +++ b/src/apps/olympus/ethereum/olympus.s-ohm.token-fetcher.ts @@ -30,6 +30,7 @@ export class EthereumOlympusSOhmTokenFetcher implements PositionFetcher this.contractFactory.olympusSOhmToken({ address, network }), resolveVaultAddresses: () => ['0x04906695d6d12cf5459975d7c3c03356e4ccd460'], // sOHM resolveUnderlyingTokenAddress: () => '0x64aa3364f17a4d01c6f1751fd97c2bd3d7e7f1d5', // OHM