From 954d23c6eb76c0f6a7db7de0244b882381c589d8 Mon Sep 17 00:00:00 2001 From: William Poulin Date: Mon, 11 Dec 2023 15:38:55 -0500 Subject: [PATCH] fix(uniswap-v3): Cleanup and update subgraph url (#3128) --- ...-v3.liquidity.contract-position-fetcher.ts | 61 ++----------------- ...-v3.liquidity.contract-position-builder.ts | 12 ---- 2 files changed, 4 insertions(+), 69 deletions(-) diff --git a/src/apps/uniswap-v3/base/uniswap-v3.liquidity.contract-position-fetcher.ts b/src/apps/uniswap-v3/base/uniswap-v3.liquidity.contract-position-fetcher.ts index e8ccfe917..20f41c701 100644 --- a/src/apps/uniswap-v3/base/uniswap-v3.liquidity.contract-position-fetcher.ts +++ b/src/apps/uniswap-v3/base/uniswap-v3.liquidity.contract-position-fetcher.ts @@ -1,9 +1,9 @@ -import { Inject, NotImplementedException } from '@nestjs/common'; -import { compact, range } from 'lodash'; +import { Inject } from '@nestjs/common'; import { APP_TOOLKIT, IAppToolkit } from '~app-toolkit/app-toolkit.interface'; import { PositionTemplate } from '~app-toolkit/decorators/position-template.decorator'; +import { UniswapV3LiquidityContractPositionBuilder } from '../common/uniswap-v3.liquidity.contract-position-builder'; import { UniswapV3LiquidityContractPositionFetcher } from '../common/uniswap-v3.liquidity.contract-position-fetcher'; import { UniswapV3ViemContractFactory } from '../contracts'; @@ -13,7 +13,7 @@ import { BaseUniswapV3LiquidityContractPositionBuilder } from './uniswap-v3.liqu export class BaseUniswapV3LiquidityContractPositionFetcher extends UniswapV3LiquidityContractPositionFetcher { groupLabel = 'Pools'; - subgraphUrl = ''; + subgraphUrl = 'https://api.studio.thegraph.com/query/48211/uniswap-v3-base/v0.0.1'; positionManagerAddress = '0x03a520b32c04bf3beef7beb72e919cf822ed34f1'; factoryAddress = '0x33128a8fc17869897dce68ed026d694621f6fdfd'; @@ -21,61 +21,8 @@ export class BaseUniswapV3LiquidityContractPositionFetcher extends UniswapV3Liqu @Inject(APP_TOOLKIT) protected readonly appToolkit: IAppToolkit, @Inject(UniswapV3ViemContractFactory) protected readonly contractFactory: UniswapV3ViemContractFactory, @Inject(BaseUniswapV3LiquidityContractPositionBuilder) - protected readonly uniswapV3LiquidityContractPositionBuilder: BaseUniswapV3LiquidityContractPositionBuilder, + protected readonly uniswapV3LiquidityContractPositionBuilder: UniswapV3LiquidityContractPositionBuilder, ) { super(appToolkit, contractFactory, uniswapV3LiquidityContractPositionBuilder); } - - getContract(address: string) { - return this.contractFactory.uniswapV3PositionManager({ address, network: this.network }); - } - - async getDefinitions() { - return []; - } - - async getTokenDefinitions() { - return []; - } - - // @ts-ignore - async getDataProps() { - return {}; - } - - async getLabel() { - return ''; - } - - // @ts-ignore - async getTokenBalancesPerPosition() { - throw new NotImplementedException(); - } - - async getBalances(address: string) { - // @TODO: Rely on contract positions when we can correctly index all pools - const multicall = this.appToolkit.getViemMulticall(this.network); - const tokenLoader = this.appToolkit.getTokenDependencySelector({ - tags: { network: this.network, context: `${this.appId}__template_balances` }, - }); - - const positionManager = this.contractFactory.uniswapV3PositionManager({ - address: this.positionManagerAddress, - network: this.network, - }); - - const numPositionsRaw = await positionManager.read.balanceOf([address]); - const balances = await Promise.all( - range(0, Number(numPositionsRaw)).map(async index => - this.uniswapV3LiquidityContractPositionBuilder.buildPosition({ - positionId: await multicall.wrap(positionManager).read.tokenOfOwnerByIndex([address, BigInt(index)]), - network: this.network, - multicall, - tokenLoader, - }), - ), - ); - - return compact(balances); - } } diff --git a/src/apps/uniswap-v3/common/uniswap-v3.liquidity.contract-position-builder.ts b/src/apps/uniswap-v3/common/uniswap-v3.liquidity.contract-position-builder.ts index 67b516b4f..f77d6fc93 100644 --- a/src/apps/uniswap-v3/common/uniswap-v3.liquidity.contract-position-builder.ts +++ b/src/apps/uniswap-v3/common/uniswap-v3.liquidity.contract-position-builder.ts @@ -1,19 +1,7 @@ import { Inject } from '@nestjs/common'; import { Token as TokenWrapper } from '@uniswap/sdk-core'; import { Pool, Position, TickMath } from '@uniswap/v3-sdk'; -import { AbiEvent } from 'abitype'; import { BigNumberish, BigNumber as EtherBigNumber } from 'ethers'; -import { - RpcLog, - EstimateGasParameters, - GetEnsAddressReturnType, - GetFilterChangesParameters, - GetTransactionParameters, - MulticallReturnType, - WaitForTransactionReceiptParameters, - WatchEventParameters, -} from 'viem'; -import { VerifyTypedDataParameters } from 'viem/_types/actions/public/verifyTypedData'; import { APP_TOOLKIT, IAppToolkit } from '~app-toolkit/app-toolkit.interface'; import { Token } from '~position/position.interface';