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

Commit

Permalink
feat(pirex): To template (#2087)
Browse files Browse the repository at this point in the history
  • Loading branch information
immasandwich authored Jan 10, 2023
1 parent 5ca8aed commit 1c46899
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 44 deletions.
49 changes: 8 additions & 41 deletions src/apps/pirex/ethereum/pirex.vault.token-fetcher.ts
Original file line number Diff line number Diff line change
@@ -1,42 +1,9 @@
import { Inject } from '@nestjs/common';

import { IAppToolkit, APP_TOOLKIT } from '~app-toolkit/app-toolkit.interface';
import { Register } from '~app-toolkit/decorators';
import { PositionFetcher } from '~position/position-fetcher.interface';
import { AppTokenPosition } from '~position/position.interface';
import { Network } from '~types/network.interface';

import { PirexContractFactory } from '../contracts';
import { PirexPxCvx } from '../contracts/ethers';
import { PIREX_DEFINITION } from '../pirex.definition';

const appId = PIREX_DEFINITION.id;
const groupId = PIREX_DEFINITION.groups.vault.id;
const network = Network.ETHEREUM_MAINNET;

@Register.TokenPositionFetcher({ appId, groupId, network })
export class EthereumPirexVaultTokenFetcher implements PositionFetcher<AppTokenPosition> {
constructor(
@Inject(APP_TOOLKIT) private readonly appToolkit: IAppToolkit,
@Inject(PirexContractFactory) private readonly pirexContractFactory: PirexContractFactory,
) {}

async getPositions() {
return await this.appToolkit.helpers.vaultTokenHelper.getTokens<PirexPxCvx>({
appId,
groupId,
network,
resolveContract: ({ address, network }) => this.pirexContractFactory.pirexPxCvx({ address, network }),
resolveVaultAddresses: async () => [
'0xbce0cf87f513102f22232436cca2ca49e815c3ac', // pxCVX
],
resolveUnderlyingTokenAddress: () => '0x4e3fbd56cd56c3e72c1403e103b45db9da5b9d2b',
resolvePricePerShare: async () => 1,
resolveReserve: async ({ multicall, underlyingToken, address }) =>
multicall
.wrap(this.pirexContractFactory.erc20(underlyingToken))
.balanceOf(address)
.then(v => Number(v) / 10 ** underlyingToken.decimals),
});
}
import { PositionTemplate } from '~app-toolkit/decorators/position-template.decorator';
import { WrapperTemplateTokenFetcher } from '~position/template/wrapper.template.token-fetcher';

@PositionTemplate()
export class EthereumPirexVaultTokenFetcher extends WrapperTemplateTokenFetcher {
groupLabel = 'Vaults';
vaultAddress = '0xbce0cf87f513102f22232436cca2ca49e815c3ac';
underlyingTokenAddress = '0x4e3fbd56cd56c3e72c1403e103b45db9da5b9d2b';
}
3 changes: 0 additions & 3 deletions src/apps/pirex/index.ts

This file was deleted.

0 comments on commit 1c46899

Please sign in to comment.