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

Commit

Permalink
feat(studio): Remove overrides on getBalancePerToken (#2987)
Browse files Browse the repository at this point in the history
  • Loading branch information
immasandwich committed Oct 18, 2023
1 parent 5c5ff57 commit 2d1609b
Show file tree
Hide file tree
Showing 5 changed files with 0 additions and 102 deletions.
20 changes: 0 additions & 20 deletions src/apps/exactly/common/exactly.borrow.token-fetcher.ts
@@ -1,5 +1,3 @@
import type { IMulticallWrapper } from '~multicall/multicall.interface';
import type { AppTokenPosition } from '~position/position.interface';
import type { GetDataPropsParams, GetTokenPropsParams } from '~position/template/app-token.template.types';

import type { ExactlyMarketDefinition } from '../common/exactly.definitions-resolver';
Expand All @@ -21,22 +19,4 @@ export abstract class ExactlyBorrowFetcher extends ExactlyTokenFetcher {
getApr({ definition }: GetDataPropsParams<Market, ExactlyMarketProps, ExactlyMarketDefinition>) {
return Number(definition.floatingBorrowRate) / 1e16;
}

async getBalancePerToken({
address,
appToken,
multicall,
}: {
address: string;
appToken: AppTokenPosition;
multicall: IMulticallWrapper;
}) {
const { floatingBorrowShares } = await this.definitionsResolver.getDefinition({
multicall,
network: this.network,
account: address,
market: appToken.address,
});
return floatingBorrowShares;
}
}
20 changes: 0 additions & 20 deletions src/apps/exactly/common/exactly.fixed-borrow.token-fetcher.ts
@@ -1,7 +1,5 @@
import { BigNumber, constants } from 'ethers';

import type { IMulticallWrapper } from '~multicall/multicall.interface';
import type { AppTokenPosition } from '~position/position.interface';
import type { GetDataPropsParams, GetTokenPropsParams } from '~position/template/app-token.template.types';

import type { ExactlyMarketDefinition } from '../common/exactly.definitions-resolver';
Expand All @@ -23,22 +21,4 @@ export abstract class ExactlyFixedBorrowFetcher extends ExactlyFixedPositionFetc
{ maturity: constants.Zero, rate: constants.MaxUint256 },
);
}

async getBalancePerToken({
address,
appToken,
multicall,
}: {
address: string;
appToken: AppTokenPosition;
multicall: IMulticallWrapper;
}) {
const { fixedBorrowPositions } = await this.definitionsResolver.getDefinition({
multicall,
network: this.network,
account: address,
market: appToken.address,
});
return fixedBorrowPositions.reduce((total, { previewValue }) => total.add(previewValue), constants.Zero);
}
}
20 changes: 0 additions & 20 deletions src/apps/exactly/common/exactly.fixed-deposit.token-fetcher.ts
@@ -1,7 +1,5 @@
import { BigNumber, constants } from 'ethers';

import type { IMulticallWrapper } from '~multicall/multicall.interface';
import type { AppTokenPosition } from '~position/position.interface';
import type { GetDataPropsParams, GetTokenPropsParams } from '~position/template/app-token.template.types';

import type { ExactlyMarketDefinition } from '../common/exactly.definitions-resolver';
Expand All @@ -22,22 +20,4 @@ export abstract class ExactlyFixedDepositFetcher extends ExactlyFixedPositionFet
{ maturity: constants.Zero, rate: constants.Zero },
);
}

async getBalancePerToken({
address,
appToken,
multicall,
}: {
address: string;
appToken: AppTokenPosition;
multicall: IMulticallWrapper;
}) {
const { fixedDepositPositions } = await this.definitionsResolver.getDefinition({
multicall,
network: this.network,
account: address,
market: appToken.address,
});
return fixedDepositPositions.reduce((total, { previewValue }) => total.add(previewValue), constants.Zero);
}
}
@@ -1,11 +1,8 @@
import { Inject } from '@nestjs/common';
import { BigNumberish, constants } from 'ethers';

import { APP_TOOLKIT, IAppToolkit } from '~app-toolkit/app-toolkit.interface';
import { PositionTemplate } from '~app-toolkit/decorators/position-template.decorator';
import { Erc721 } from '~contract/contracts';
import { IMulticallWrapper } from '~multicall';
import { AppTokenPosition } from '~position/position.interface';
import { AppTokenTemplatePositionFetcher } from '~position/template/app-token.template.position-fetcher';
import {
GetAddressesParams,
Expand Down Expand Up @@ -74,29 +71,6 @@ export class EthereumSpiceFinanceWethTokenFetcher extends AppTokenTemplatePositi
return [reserve];
}

async getBalancePerToken({
address,
}: {
address: string;
appToken: AppTokenPosition;
multicall: IMulticallWrapper;
}): Promise<BigNumberish> {
const vault = this.spiceFinanceContractFactory.spiceFinanceNftVault({
address: this.vaultAddress,
network: this.network,
});
let balance = constants.Zero;
for (let i = 1; i <= 555; ++i) {
const owner = await vault.ownerOf(i);
if (owner.toLowerCase() === address.toLowerCase()) {
const shares = await vault.tokenShares(i);
const assets = await vault.convertToAssets(shares);
balance = balance.add(assets);
}
}
return balance;
}

async getApy(_params: GetDataPropsParams<Erc721>) {
return 0;
}
Expand Down
16 changes: 0 additions & 16 deletions src/apps/synthetix/common/synthetix.snx.token-fetcher.ts
@@ -1,11 +1,7 @@
import { Inject } from '@nestjs/common';
import { BigNumberish } from 'ethers';

import { APP_TOOLKIT, IAppToolkit } from '~app-toolkit/app-toolkit.interface';
import { getTokenImg } from '~app-toolkit/helpers/presentation/image.present';
import { IMulticallWrapper } from '~multicall';
import { DefaultDataProps } from '~position/display.interface';
import { AppTokenPosition } from '~position/position.interface';
import { AppTokenTemplatePositionFetcher } from '~position/template/app-token.template.position-fetcher';
import { GetDataPropsParams, GetDisplayPropsParams, GetPriceParams } from '~position/template/app-token.template.types';

Expand Down Expand Up @@ -63,16 +59,4 @@ export abstract class SynthetixSnxTokenFetcher extends AppTokenTemplatePositionF
async getImages({ appToken }: GetDisplayPropsParams<SynthetixNetworkToken>) {
return [getTokenImg(appToken.address, this.network)];
}

async getBalancePerToken({
address,
appToken,
multicall,
}: {
address: string;
appToken: AppTokenPosition<DefaultDataProps>;
multicall: IMulticallWrapper;
}): Promise<BigNumberish> {
return multicall.wrap(this.getContract(appToken.address)).transferableSynthetix(address);
}
}

0 comments on commit 2d1609b

Please sign in to comment.