This repository has been archived by the owner on Jan 24, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 380
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
77 additions
and
0 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
50 changes: 50 additions & 0 deletions
50
src/apps/pool-together-v5/common/pool-together-v5.prize-vault.token-fetcher.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
|
||
} |
9 changes: 9 additions & 0 deletions
9
src/apps/pool-together-v5/common/pool-together.v5.constants.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
] | ||
} |
7 changes: 7 additions & 0 deletions
7
src/apps/pool-together-v5/optimism/pool-together-v5.prize-vault.token-fetcher.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() {} |