Skip to content
This repository has been archived by the owner on Jan 24, 2024. It is now read-only.

Commit

Permalink
feat(exchangeable-tokens): Compound and Olympus tokens as exchangeable (
Browse files Browse the repository at this point in the history
  • Loading branch information
JForsaken committed Jun 8, 2022
1 parent 913c112 commit 1fde9af
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 4 deletions.
7 changes: 5 additions & 2 deletions src/app-toolkit/helpers/position/vault.token-helper.ts
Expand Up @@ -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;
};
Expand All @@ -27,6 +27,7 @@ export type VaultTokenHelperParams<T> = {
appId: string;
groupId: string;
dependencies?: AppGroupsDefinition[];
exchangeable?: boolean;
resolveContract: (opts: { address: string; network: Network }) => T;
resolveVaultAddresses: (opts: { multicall: EthersMulticall; network: Network }) => string[] | Promise<string[]>;
resolveUnderlyingTokenAddress: (opts: { multicall: EthersMulticall; contract: T }) => string | Promise<string | null>;
Expand Down Expand Up @@ -58,6 +59,7 @@ export class VaultTokenHelper {
appId,
groupId,
dependencies = [],
exchangeable = false,
resolveVaultAddresses,
resolveContract,
resolveUnderlyingTokenAddress,
Expand Down Expand Up @@ -131,6 +133,7 @@ export class VaultTokenHelper {
dataProps: {
liquidity,
reserve,
exchangeable,
},

displayProps: {
Expand Down
Expand Up @@ -25,6 +25,7 @@ export class EthereumCompoundSupplyTokenFetcher implements PositionFetcher<AppTo
network,
appId,
groupId,
exchangeable: true,
comptrollerAddress: '0x3d9819210a31b4961b30ef54be2aed79b9c9cd3b',
getComptrollerContract: ({ address, network }) =>
this.compoundContractFactory.compoundComptroller({ address, network }),
Expand Down
7 changes: 5 additions & 2 deletions src/apps/compound/helper/compound.supply.token-helper.ts
Expand Up @@ -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;
Expand All @@ -46,6 +46,7 @@ type CompoundSupplyTokenHelperParams<T = CompoundComptroller, V = CompoundCToken
getExchangeRateMantissa: (opts: { tokenDecimals: number; underlyingTokenDecimals: number }) => number;
getDisplayLabel?: (opts: { contract: V; multicall: Multicall; underlyingToken: Token }) => Promise<string>;
getDenormalizedRate?: (opts: { rate: BigNumberish; blocksPerDay: number; decimals: number }) => number;
exchangeable?: boolean;
};

@Injectable()
Expand All @@ -61,6 +62,7 @@ export class CompoundSupplyTokenHelper {
network,
appId,
groupId,
exchangeable = false,
dependencies = [],
allTokens = [],
getComptrollerContract,
Expand Down Expand Up @@ -161,6 +163,7 @@ export class CompoundSupplyTokenHelper {
borrowApy,
liquidity,
comptrollerAddress,
exchangeable,
},

displayProps: {
Expand Down
1 change: 1 addition & 0 deletions src/apps/olympus/ethereum/olympus.g-ohm.token-fetcher.ts
Expand Up @@ -31,6 +31,7 @@ export class EthereumOlympusGOhmTokenFetcher implements PositionFetcher<AppToken
appId,
groupId,
network,
exchangeable: true,
dependencies: [{ appId, groupIds: [OLYMPUS_DEFINITION.groups.sOhm.id], network }],
resolveVaultAddresses: () => ['0x0ab87046fbb341d058f17cbc4c1133f25a20a52f'], // gOHM
resolveContract: ({ address, network }) => this.contractFactory.olympusGOhmToken({ address, network }),
Expand Down
Expand Up @@ -30,6 +30,7 @@ export class EthereumOlympusSOhmV1TokenFetcher implements PositionFetcher<AppTok
appId,
groupId,
network,
exchangeable: true,
resolveContract: ({ address, network }) => this.contractFactory.olympusSOhmV1Token({ address, network }),
resolveVaultAddresses: () => ['0x04f2694c8fcee23e8fd0dfea1d4f5bb8c352111f'], // sOHMv1
resolveUnderlyingTokenAddress: () => '0x383518188c0c6d7730d91b2c03a03c837814a899', // OHMv1
Expand Down
1 change: 1 addition & 0 deletions src/apps/olympus/ethereum/olympus.s-ohm.token-fetcher.ts
Expand Up @@ -30,6 +30,7 @@ export class EthereumOlympusSOhmTokenFetcher implements PositionFetcher<AppToken
appId,
groupId,
network,
exchangeable: true,
resolveContract: ({ address, network }) => this.contractFactory.olympusSOhmToken({ address, network }),
resolveVaultAddresses: () => ['0x04906695d6d12cf5459975d7c3c03356e4ccd460'], // sOHM
resolveUnderlyingTokenAddress: () => '0x64aa3364f17a4d01c6f1751fd97c2bd3d7e7f1d5', // OHM
Expand Down

0 comments on commit 1fde9af

Please sign in to comment.