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

Commit

Permalink
fix(notional-finance-v3): Cleanup (#3013)
Browse files Browse the repository at this point in the history
  • Loading branch information
wpoulin authored Nov 6, 2023
1 parent 315595a commit dad27d3
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 55 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export type NotionalBorrowingDataProps = {
};

@PositionTemplate()
export class EthereumNotionalFinanceV3BorrowContractPositionFetcher extends ContractPositionTemplatePositionFetcher<
export class ArbitrumNotionalFinanceV3BorrowContractPositionFetcher extends ContractPositionTemplatePositionFetcher<
NotionalView,
NotionalBorrowingDataProps,
NotionalBorrowingDefinition
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { APP_TOOLKIT, IAppToolkit } from '~app-toolkit/app-toolkit.interface';
import { PositionTemplate } from '~app-toolkit/decorators/position-template.decorator';
import { AppTokenTemplatePositionFetcher } from '~position/template/app-token.template.position-fetcher';
import {
DefaultAppTokenDataProps,
DefaultAppTokenDefinition,
GetAddressesParams,
GetDefinitionsParams,
Expand All @@ -17,17 +16,8 @@ import {

import { NotionalFinanceV3ContractFactory, NotionalPCash } from '../contracts';

export type NotionalFinanceV3PCashTokenDefinition = {
address: string;
currencyId: number;
};

@PositionTemplate()
export class ArbitrumNotionalFinanceV3NTokenTokenFetcher extends AppTokenTemplatePositionFetcher<
NotionalPCash,
DefaultAppTokenDataProps,
NotionalFinanceV3PCashTokenDefinition
> {
export class ArbitrumNotionalFinanceV3NTokenTokenFetcher extends AppTokenTemplatePositionFetcher<NotionalPCash> {
groupLabel = 'nTokens';
notionalViewContractAddress = '0x1344a36a1b56144c3bc62e7757377d288fde0369';

Expand All @@ -42,7 +32,7 @@ export class ArbitrumNotionalFinanceV3NTokenTokenFetcher extends AppTokenTemplat
return this.contractFactory.notionalPCash({ network: this.network, address });
}

async getDefinitions({ multicall }: GetDefinitionsParams): Promise<NotionalFinanceV3PCashTokenDefinition[]> {
async getDefinitions({ multicall }: GetDefinitionsParams): Promise<DefaultAppTokenDefinition[]> {
const notionalViewContract = this.contractFactory.notionalView({
address: this.notionalViewContractAddress,
network: this.network,
Expand All @@ -60,7 +50,6 @@ export class ArbitrumNotionalFinanceV3NTokenTokenFetcher extends AppTokenTemplat

return {
address,
currencyId,
};
}),
);
Expand All @@ -78,10 +67,7 @@ export class ArbitrumNotionalFinanceV3NTokenTokenFetcher extends AppTokenTemplat
return [{ address: await contract.asset(), network: this.network }];
}

async getPricePerShare({
appToken,
contract,
}: GetPricePerShareParams<NotionalPCash, DefaultAppTokenDataProps, NotionalFinanceV3PCashTokenDefinition>) {
async getPricePerShare({ appToken, contract }: GetPricePerShareParams<NotionalPCash>) {
let pricePerShareRaw: BigNumber;
try {
pricePerShareRaw = await contract.exchangeRate();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { APP_TOOLKIT, IAppToolkit } from '~app-toolkit/app-toolkit.interface';
import { PositionTemplate } from '~app-toolkit/decorators/position-template.decorator';
import { AppTokenTemplatePositionFetcher } from '~position/template/app-token.template.position-fetcher';
import {
DefaultAppTokenDataProps,
DefaultAppTokenDefinition,
GetAddressesParams,
GetDefinitionsParams,
Expand All @@ -16,17 +15,8 @@ import {

import { NotionalFinanceV3ContractFactory, NotionalPCash } from '../contracts';

export type NotionalFinanceV3PCashTokenDefinition = {
address: string;
currencyId: number;
};

@PositionTemplate()
export class ArbitrumNotionalFinanceV3PCashTokenFetcher extends AppTokenTemplatePositionFetcher<
NotionalPCash,
DefaultAppTokenDataProps,
NotionalFinanceV3PCashTokenDefinition
> {
export class ArbitrumNotionalFinanceV3PCashTokenFetcher extends AppTokenTemplatePositionFetcher<NotionalPCash> {
groupLabel = 'Supply';
notionalViewContractAddress = '0x1344a36a1b56144c3bc62e7757377d288fde0369';

Expand All @@ -41,7 +31,7 @@ export class ArbitrumNotionalFinanceV3PCashTokenFetcher extends AppTokenTemplate
return this.contractFactory.notionalPCash({ network: this.network, address });
}

async getDefinitions({ multicall }: GetDefinitionsParams): Promise<NotionalFinanceV3PCashTokenDefinition[]> {
async getDefinitions({ multicall }: GetDefinitionsParams): Promise<DefaultAppTokenDefinition[]> {
const notionalViewContract = this.contractFactory.notionalView({
address: this.notionalViewContractAddress,
network: this.network,
Expand All @@ -54,7 +44,6 @@ export class ArbitrumNotionalFinanceV3PCashTokenFetcher extends AppTokenTemplate

return {
address,
currencyId,
};
}),
);
Expand All @@ -70,10 +59,7 @@ export class ArbitrumNotionalFinanceV3PCashTokenFetcher extends AppTokenTemplate
return [{ address: await contract.asset(), network: this.network }];
}

async getPricePerShare({
appToken,
contract,
}: GetPricePerShareParams<NotionalPCash, DefaultAppTokenDataProps, NotionalFinanceV3PCashTokenDefinition>) {
async getPricePerShare({ appToken, contract }: GetPricePerShareParams<NotionalPCash>) {
const pricePerShareRaw = await contract.exchangeRate();
const pricePerShare = Number(pricePerShareRaw) / 10 ** 10 + appToken.tokens[0].decimals;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { APP_TOOLKIT, IAppToolkit } from '~app-toolkit/app-toolkit.interface';
import { PositionTemplate } from '~app-toolkit/decorators/position-template.decorator';
import { AppTokenTemplatePositionFetcher } from '~position/template/app-token.template.position-fetcher';
import {
DefaultAppTokenDataProps,
DefaultAppTokenDefinition,
GetAddressesParams,
GetDefinitionsParams,
Expand All @@ -17,17 +16,8 @@ import {

import { NotionalFinanceV3ContractFactory, NotionalPCash } from '../contracts';

export type NotionalFinanceV3PDebtTokenDefinition = {
address: string;
currencyId: number;
};

@PositionTemplate()
export class ArbitrumNotionalFinanceV3PDebtTokenFetcher extends AppTokenTemplatePositionFetcher<
NotionalPCash,
DefaultAppTokenDataProps,
NotionalFinanceV3PDebtTokenDefinition
> {
export class ArbitrumNotionalFinanceV3PDebtTokenFetcher extends AppTokenTemplatePositionFetcher<NotionalPCash> {
groupLabel = 'Borrow';
isDebt = true;

Expand All @@ -44,7 +34,7 @@ export class ArbitrumNotionalFinanceV3PDebtTokenFetcher extends AppTokenTemplate
return this.contractFactory.notionalPCash({ network: this.network, address });
}

async getDefinitions({ multicall }: GetDefinitionsParams): Promise<NotionalFinanceV3PDebtTokenDefinition[]> {
async getDefinitions({ multicall }: GetDefinitionsParams): Promise<DefaultAppTokenDefinition[]> {
const notionalViewContract = this.contractFactory.notionalView({
address: this.notionalViewContractAddress,
network: this.network,
Expand All @@ -57,7 +47,6 @@ export class ArbitrumNotionalFinanceV3PDebtTokenFetcher extends AppTokenTemplate

return {
address,
currencyId,
};
}),
);
Expand All @@ -73,10 +62,7 @@ export class ArbitrumNotionalFinanceV3PDebtTokenFetcher extends AppTokenTemplate
return [{ address: await contract.asset(), network: this.network }];
}

async getPricePerShare({
appToken,
contract,
}: GetPricePerShareParams<NotionalPCash, DefaultAppTokenDataProps, NotionalFinanceV3PDebtTokenDefinition>) {
async getPricePerShare({ appToken, contract }: GetPricePerShareParams<NotionalPCash>) {
let pricePerShareRaw: BigNumber;
try {
pricePerShareRaw = await contract.exchangeRate();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ export type NotionalFinanceLendingDataProps = {
currencyId: number;
tokenId: string;
maturity: number;
type: string;
positionKey: string;
type: string;
};

@PositionTemplate()
Expand Down
4 changes: 2 additions & 2 deletions src/apps/notional-finance-v3/notional-finance-v3.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Module } from '@nestjs/common';

import { AbstractApp } from '~app/app.dynamic-module';

import { EthereumNotionalFinanceV3BorrowContractPositionFetcher } from './arbitrum/notional-finance-v3.borrow.contract-position-fetcher';
import { ArbitrumNotionalFinanceV3BorrowContractPositionFetcher } from './arbitrum/notional-finance-v3.borrow.contract-position-fetcher';
import { ArbitrumNotionalFinanceV3FCashTokenFetcher } from './arbitrum/notional-finance-v3.f-cash.token-fetcher';
import { ArbitrumNotionalFinanceV3NTokenTokenFetcher } from './arbitrum/notional-finance-v3.n-token.token-fetcher';
import { ArbitrumNotionalFinanceV3PCashTokenFetcher } from './arbitrum/notional-finance-v3.p-cash.token-fetcher';
Expand All @@ -19,7 +19,7 @@ import { NotionalFinanceV3ContractFactory } from './contracts';
ArbitrumNotionalFinanceV3NTokenTokenFetcher,
ArbitrumNotionalFinanceV3FCashTokenFetcher,
ArbitrumNotionalFinanceV3SupplyContractPositionFetcher,
EthereumNotionalFinanceV3BorrowContractPositionFetcher,
ArbitrumNotionalFinanceV3BorrowContractPositionFetcher,
],
})
export class NotionalFinanceV3AppModule extends AbstractApp() {}

0 comments on commit dad27d3

Please sign in to comment.