diff --git a/package.json b/package.json index 9a7bdda5..6c30ecac 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,7 @@ "build": "graph build", "create-local": "graph create ianlapham/uniswap-v3 --node http://127.0.0.1:8020", "deploy-local": "graph deploy ianlapham/uniswap-v3 --debug --ipfs http://localhost:5001 --node http://127.0.0.1:8020", - "deploy": "graph deploy uniswap/uniswap-v3 --ipfs https://api.thegraph.com/ipfs/ --node https://api.thegraph.com/deploy/ --debug", + "deploy": "graph deploy ianlapham/uniswap-v3-subgraph --ipfs https://api.thegraph.com/ipfs/ --node https://api.thegraph.com/deploy/ --debug", "deploy-dev": "graph deploy sommelier/uniswap-v3 --ipfs http://35.197.14.14:5000/ --node http://35.197.14.14:8020/ --debug", "deploy-staging": "graph deploy $THE_GRAPH_GITHUB_USER/$THE_GRAPH_SUBGRAPH_NAME /Uniswap --ipfs https://api.staging.thegraph.com/ipfs/ --node https://api.staging.thegraph.com/deploy/", "watch-local": "graph deploy ianlapham/uniswap-v3 --watch --debug --node http://127.0.0.1:8020/ --ipfs http://localhost:5001" diff --git a/schema.graphql b/schema.graphql index a8f1d0a7..6b10e59b 100644 --- a/schema.graphql +++ b/schema.graphql @@ -219,12 +219,6 @@ type Position @entity { collectedFeesToken0: BigDecimal! # all time collected fees in token1 collectedFeesToken1: BigDecimal! - # Total amount deposited in terms of USD - amountDepositedUSD: BigDecimal! - # Total amount withdrawn in terms of USD - amountWithdrawnUSD: BigDecimal! - # Total amount collected in terms of USD - amountCollectedUSD: BigDecimal! # tx in which the position was initialized transaction: Transaction! # vars needed for fee computation diff --git a/src/mappings/position-manager.ts b/src/mappings/position-manager.ts index c619d646..5eaa1520 100644 --- a/src/mappings/position-manager.ts +++ b/src/mappings/position-manager.ts @@ -43,10 +43,6 @@ function getPosition(event: ethereum.Event, tokenId: BigInt): Position | null { position.transaction = loadTransaction(event).id position.feeGrowthInside0LastX128 = positionResult.value8 position.feeGrowthInside1LastX128 = positionResult.value9 - - position.amountDepositedUSD = ZERO_BD - position.amountWithdrawnUSD = ZERO_BD - position.amountCollectedUSD = ZERO_BD } } @@ -84,6 +80,11 @@ function savePositionSnapshot(position: Position, event: ethereum.Event): void { } export function handleIncreaseLiquidity(event: IncreaseLiquidity): void { + // temp fix + if (event.block.number.equals(BigInt.fromI32(14317993))) { + return + } + let position = getPosition(event, event.params.tokenId) // position was not able to be fetched @@ -95,7 +96,6 @@ export function handleIncreaseLiquidity(event: IncreaseLiquidity): void { if (Address.fromString(position.pool).equals(Address.fromHexString('0x8fe8d9bb8eeba3ed688069c3d6b556c9ca258248'))) { return } - let bundle = Bundle.load('1') let token0 = Token.load(position.token0) let token1 = Token.load(position.token1) @@ -107,11 +107,6 @@ export function handleIncreaseLiquidity(event: IncreaseLiquidity): void { position.depositedToken0 = position.depositedToken0.plus(amount0) position.depositedToken1 = position.depositedToken1.plus(amount1) - let newDepositUSD = amount0 - .times(token0.derivedETH.times(bundle.ethPriceUSD)) - .plus(amount1.times(token1.derivedETH.times(bundle.ethPriceUSD))) - position.amountDepositedUSD = position.amountDepositedUSD.plus(newDepositUSD) - updateFeeVars(position!, event, event.params.tokenId) position.save() @@ -120,6 +115,11 @@ export function handleIncreaseLiquidity(event: IncreaseLiquidity): void { } export function handleDecreaseLiquidity(event: DecreaseLiquidity): void { + // temp fix + if (event.block.number == BigInt.fromI32(14317993)) { + return + } + let position = getPosition(event, event.params.tokenId) // position was not able to be fetched @@ -132,7 +132,6 @@ export function handleDecreaseLiquidity(event: DecreaseLiquidity): void { return } - let bundle = Bundle.load('1') let token0 = Token.load(position.token0) let token1 = Token.load(position.token1) let amount0 = convertTokenToDecimal(event.params.amount0, token0.decimals) @@ -142,11 +141,6 @@ export function handleDecreaseLiquidity(event: DecreaseLiquidity): void { position.withdrawnToken0 = position.withdrawnToken0.plus(amount0) position.withdrawnToken1 = position.withdrawnToken1.plus(amount1) - let newWithdrawUSD = amount0 - .times(token0.derivedETH.times(bundle.ethPriceUSD)) - .plus(amount1.times(token1.derivedETH.times(bundle.ethPriceUSD))) - position.amountWithdrawnUSD = position.amountWithdrawnUSD.plus(newWithdrawUSD) - position = updateFeeVars(position!, event, event.params.tokenId) position.save() savePositionSnapshot(position!, event) @@ -162,23 +156,10 @@ export function handleCollect(event: Collect): void { return } - - let bundle = Bundle.load('1') let token0 = Token.load(position.token0) - let token1 = Token.load(position.token1) let amount0 = convertTokenToDecimal(event.params.amount0, token0.decimals) - let amount1 = convertTokenToDecimal(event.params.amount1, token1.decimals) - position.collectedToken0 = position.collectedToken0.plus(amount0) - position.collectedToken1 = position.collectedToken1.plus(amount1) - - position.collectedFeesToken0 = position.collectedToken0.minus(position.withdrawnToken0) - position.collectedFeesToken1 = position.collectedToken1.minus(position.withdrawnToken1) - - let newCollectUSD = amount0 - .times(token0.derivedETH.times(bundle.ethPriceUSD)) - .plus(amount1.times(token1.derivedETH.times(bundle.ethPriceUSD))) - position.amountCollectedUSD = position.amountCollectedUSD.plus(newCollectUSD) - + position.collectedFeesToken0 = position.collectedFeesToken0.plus(amount0) + position.collectedFeesToken1 = position.collectedFeesToken1.plus(amount0) position = updateFeeVars(position!, event, event.params.tokenId) position.save() diff --git a/src/utils/pricing.ts b/src/utils/pricing.ts index a4e0bca4..1a8a19cf 100644 --- a/src/utils/pricing.ts +++ b/src/utils/pricing.ts @@ -42,7 +42,7 @@ let STABLE_COINS: string[] = [ '0x4dd28568d05f09b02220b09c2cb307bfd837cb95' ] -let MINIMUM_ETH_LOCKED = BigDecimal.fromString('52') +let MINIMUM_ETH_LOCKED = BigDecimal.fromString('60') let Q192 = 2 ** 192 export function sqrtPriceX96ToTokenPrices(sqrtPriceX96: BigInt, token0: Token, token1: Token): BigDecimal[] { diff --git a/subgraph.yaml b/subgraph.yaml index 03459143..ee6d649e 100644 --- a/subgraph.yaml +++ b/subgraph.yaml @@ -4,8 +4,10 @@ repository: https://github.com/Uniswap/uniswap-v3-subgraph schema: file: ./schema.graphql graft: - base: QmZeCuoZeadgHkGwLwMeguyqUKz1WPWQYKcKyMCeQqGhsF - block: 12673736 + base: QmPrb5mvZj3ycUugZgwLWCvK93jfXfhvfjRXrFk4tRmyCX + block: 14292820 +features: + - nonFatalErrors dataSources: - kind: ethereum/contract name: Factory