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

Commit

Permalink
PT V5 Optimism Support
Browse files Browse the repository at this point in the history
  • Loading branch information
Ncookiez committed Oct 22, 2023
1 parent d76b559 commit cc618ad
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 0 deletions.
Binary file added src/apps/pool-together-v5/assets/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import { Erc20, Erc4626 } from '~contract/contracts';
import { AppTokenTemplatePositionFetcher } from '~position/template/app-token.template.position-fetcher';
import { GetDataPropsParams, GetDisplayPropsParams, GetPricePerShareParams, GetUnderlyingTokensParams } from '~position/template/app-token.template.types';
import { PRIZE_VAULT_ADDRESSES } from './pool-together.v5.constants';

export abstract class PoolTogetherV5PrizeVaultTokenFetcher extends AppTokenTemplatePositionFetcher<Erc20> {
groupLabel: string;

getContract(address: string): Erc4626 {
return this.appToolkit.globalContracts.erc4626({ address, network: this.network });
}

async getAddresses(): Promise<string[]> {
return PRIZE_VAULT_ADDRESSES[this.network] ?? [];
}

async getUnderlyingTokenDefinitions({ contract }: GetUnderlyingTokensParams<Erc4626>) {
const underlyingToken = await contract.asset();
return [{ address: underlyingToken, network: this.network }];
}

async getPricePerShare({ contract, appToken }: GetPricePerShareParams<Erc4626>) {
const oneShare = BigInt(10 ** appToken.tokens[0].decimals);
const exchangeRate = (await contract.convertToAssets(oneShare)).toBigInt();
const pricePerShare = Number(exchangeRate / oneShare);
return [pricePerShare];
}

async getLiquidity({ contract, appToken }: GetDataPropsParams<Erc4626>) {
const reserveRaw = await contract.totalAssets();
const reserve = Number(reserveRaw) / 10 ** appToken.tokens[0].decimals;
const liquidity = reserve * appToken.tokens[0].price;
return liquidity;
}

async getReserves({ contract, appToken }: GetDataPropsParams<Erc4626>) {
const reserveRaw = await contract.totalAssets();
const reserve = Number(reserveRaw) / 10 ** appToken.tokens[0].decimals;
return [reserve];
}

async getLabel({ contract }: GetDisplayPropsParams<Erc4626>) {
return contract.name();
}

async getLabelDetailed({ appToken }: GetDisplayPropsParams<Erc4626>) {
return appToken.symbol;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { Network } from "~types"

export const PRIZE_VAULT_ADDRESSES: Partial<Record<Network, `0x${string}`[]>> = {
[Network.OPTIMISM_MAINNET]: [
'0xE3B3a464ee575E8E25D2508918383b89c832f275', // Prize USDC.e - Aave
'0x29Cb69D4780B53c1e5CD4D2B817142D2e9890715', // Prize WETH - Aave
'0xCe8293f586091d48A0cE761bBf85D5bCAa1B8d2b' // Prize DAI - Aave
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { PositionTemplate } from '~app-toolkit/decorators/position-template.decorator';
import { PoolTogetherV5PrizeVaultTokenFetcher } from '../common/pool-together-v5.prize-vault.token-fetcher';

@PositionTemplate()
export class OptimismPoolTogetherV5PrizeVaultTokenFetcher extends PoolTogetherV5PrizeVaultTokenFetcher {
groupLabel: 'Prize Vaults';
}
11 changes: 11 additions & 0 deletions src/apps/pool-together-v5/pool-together-v5.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { Module } from '@nestjs/common';

import { AbstractApp } from '~app/app.dynamic-module';
import { OptimismPoolTogetherV5PrizeVaultTokenFetcher } from './optimism/pool-together-v5.prize-vault.token-fetcher';

@Module({
providers: [
OptimismPoolTogetherV5PrizeVaultTokenFetcher
],
})
export class PoolTogetherV5AppModule extends AbstractApp() {}

0 comments on commit cc618ad

Please sign in to comment.