From e5e8665c02409f071f3330f3cdac88cf403b7463 Mon Sep 17 00:00:00 2001 From: William Poulin Date: Wed, 6 Dec 2023 17:23:44 -0500 Subject: [PATCH] fix(spice-finance): Remove app integration in order to allow EIs (#3101) --- src/apps/spice-finance/assets/logo.png | Bin 8582 -> 0 bytes .../abis/spice-finance-nft-vault.json | 1679 ---------------- src/apps/spice-finance/contracts/index.ts | 4 - .../contracts/viem.contract-factory.ts | 17 - .../contracts/viem/SpiceFinanceNftVault.ts | 1693 ----------------- .../spice-finance/contracts/viem/index.ts | 7 - .../spice-finance.weth.token-fetcher.ts | 115 -- .../spice-finance/spice-finance.module.ts | 11 - 8 files changed, 3526 deletions(-) delete mode 100644 src/apps/spice-finance/assets/logo.png delete mode 100644 src/apps/spice-finance/contracts/abis/spice-finance-nft-vault.json delete mode 100644 src/apps/spice-finance/contracts/index.ts delete mode 100644 src/apps/spice-finance/contracts/viem.contract-factory.ts delete mode 100644 src/apps/spice-finance/contracts/viem/SpiceFinanceNftVault.ts delete mode 100644 src/apps/spice-finance/contracts/viem/index.ts delete mode 100644 src/apps/spice-finance/ethereum/spice-finance.weth.token-fetcher.ts delete mode 100644 src/apps/spice-finance/spice-finance.module.ts diff --git a/src/apps/spice-finance/assets/logo.png b/src/apps/spice-finance/assets/logo.png deleted file mode 100644 index b8fbe5416ef8b210e3b3c0f0493dd0722eac399e..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 8582 zcmeHL2Ut_twmu?=_P`owoE9=QGZzB3 zH7jd(S5-Ydt!<*O*rhH2oCyHhrD$_~)%maf?yy0-TLS=u862o!?TYmPc@>b?@%C_~ z@wY&JkF}kZ4ah$Lc}Xm2Ajr4S^u|@`Jpl@s-FJ$|Pm!$ERKJheP zgsknbPT&|vkpIca(G#>`v(Y?ZLpvi3LCUxJa|a9n4d65&1Y80<0eip^@BpMh>I}y0 z+j>Vg^>hFiP{$g)x&l4`7Syl>>_A;fQ0fV|189(52IXk*;|Pub+n3mXiK+Y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SXm#X3&;98*OQ@-i?~r!m2!sIiKtS|M?qZ87c3~PBzq%M5O`@1*BJ%C9TGf zLQ_JP-C@QF?|;bq&x7fmq$Dv1UC^-8#FHVaJrc6lj+Ey; - -export class SpiceFinanceNftVault__factory { - static connect(address: string, client: PublicClient) { - return getContract({ address, abi: spiceFinanceNftVaultAbi, publicClient: client }); - } -} diff --git a/src/apps/spice-finance/contracts/viem/index.ts b/src/apps/spice-finance/contracts/viem/index.ts deleted file mode 100644 index 716722288..000000000 --- a/src/apps/spice-finance/contracts/viem/index.ts +++ /dev/null @@ -1,7 +0,0 @@ -/* Autogenerated file. Do not edit manually. */ -/* tslint:disable */ -/* eslint-disable */ - -export type { SpiceFinanceNftVault } from './SpiceFinanceNftVault'; - -export { SpiceFinanceNftVault__factory } from './SpiceFinanceNftVault'; diff --git a/src/apps/spice-finance/ethereum/spice-finance.weth.token-fetcher.ts b/src/apps/spice-finance/ethereum/spice-finance.weth.token-fetcher.ts deleted file mode 100644 index 644001a74..000000000 --- a/src/apps/spice-finance/ethereum/spice-finance.weth.token-fetcher.ts +++ /dev/null @@ -1,115 +0,0 @@ -import { Inject } from '@nestjs/common'; -import { BigNumberish, constants } from 'ethers'; -import { range } from 'lodash'; - -import { APP_TOOLKIT, IAppToolkit } from '~app-toolkit/app-toolkit.interface'; -import { PositionTemplate } from '~app-toolkit/decorators/position-template.decorator'; -import { Erc721 } from '~contract/contracts/viem'; -import { ViemMulticallDataLoader } from '~multicall'; -import { AppTokenPosition } from '~position/position.interface'; -import { AppTokenTemplatePositionFetcher } from '~position/template/app-token.template.position-fetcher'; -import { - GetAddressesParams, - DefaultAppTokenDefinition, - GetUnderlyingTokensParams, - UnderlyingTokenDefinition, - GetDataPropsParams, - GetPricePerShareParams, - DefaultAppTokenDataProps, -} from '~position/template/app-token.template.types'; - -import { SpiceFinanceViemContractFactory } from '../contracts'; - -@PositionTemplate() -export class EthereumSpiceFinanceWethTokenFetcher extends AppTokenTemplatePositionFetcher { - groupLabel = 'WETH'; - - vaultAddress = '0x6110d61dd1133b0f845f1025d6678cd22a11a2fe'; - underlyingTokenAddress = '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2'; - - constructor( - @Inject(APP_TOOLKIT) public readonly appToolkit: IAppToolkit, - @Inject(SpiceFinanceViemContractFactory) - private readonly spiceFinanceContractFactory: SpiceFinanceViemContractFactory, - ) { - super(appToolkit); - } - - getContract(address: string) { - return this.appToolkit.globalViemContracts.erc721({ address, network: this.network }); - } - - async getAddresses(_params: GetAddressesParams): Promise { - return [this.vaultAddress]; - } - - async getUnderlyingTokenDefinitions( - _params: GetUnderlyingTokensParams, - ): Promise { - return [{ address: this.underlyingTokenAddress, network: this.network }]; - } - - async getPricePerShare( - _params: GetPricePerShareParams, - ): Promise { - return [1]; - } - - async getLiquidity({ appToken }: GetDataPropsParams) { - const vault = this.spiceFinanceContractFactory.spiceFinanceNftVault({ - address: this.vaultAddress, - network: this.network, - }); - const reserveRaw = await vault.read.totalAssets(); - const reserve = Number(reserveRaw) / 10 ** appToken.tokens[0].decimals; - const liquidity = reserve * appToken.tokens[0].price; - return liquidity; - } - - async getReserves({ appToken }: GetDataPropsParams) { - const vault = this.spiceFinanceContractFactory.spiceFinanceNftVault({ - address: this.vaultAddress, - network: this.network, - }); - const reserveRaw = await vault.read.totalAssets(); - const reserve = Number(reserveRaw) / 10 ** appToken.tokens[0].decimals; - return [reserve]; - } - - async getApy(_params: GetDataPropsParams) { - return 0; - } - - async getDecimals(_params: GetDataPropsParams): Promise { - return 0; - } - - async getBalancePerToken({ - address, - }: { - address: string; - appToken: AppTokenPosition; - multicall: ViemMulticallDataLoader; - }): Promise { - const vault = this.spiceFinanceContractFactory.spiceFinanceNftVault({ - address: this.vaultAddress, - network: this.network, - }); - - const balances = await Promise.all( - range(1, 555).map(async i => { - const owner = await vault.read.ownerOf([BigInt(i)]); - - if (owner.toLowerCase() === address.toLowerCase()) { - const shares = await vault.read.tokenShares([BigInt(i)]); - const assets = await vault.read.convertToAssets([shares]); - return assets; - } - - return 0; - }), - ); - - return balances.reduce((acc, curr) => acc.add(curr), constants.Zero); - } -} diff --git a/src/apps/spice-finance/spice-finance.module.ts b/src/apps/spice-finance/spice-finance.module.ts deleted file mode 100644 index 2fcf7d5a1..000000000 --- a/src/apps/spice-finance/spice-finance.module.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { Module } from '@nestjs/common'; - -import { AbstractApp } from '~app/app.dynamic-module'; - -import { SpiceFinanceViemContractFactory } from './contracts'; -import { EthereumSpiceFinanceWethTokenFetcher } from './ethereum/spice-finance.weth.token-fetcher'; - -@Module({ - providers: [EthereumSpiceFinanceWethTokenFetcher, SpiceFinanceViemContractFactory], -}) -export class SpiceFinanceAppModule extends AbstractApp() {}