Skip to content

Commit bf03f94

Browse files
authored
Merge pull request #101 from Uniswap/match-with-deployed
fix: update main with current version at ianlapham/uniswap-v3-subgraph
2 parents 1393818 + c63cb39 commit bf03f94

File tree

5 files changed

+18
-41
lines changed

5 files changed

+18
-41
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"build": "graph build",
99
"create-local": "graph create ianlapham/uniswap-v3 --node http://127.0.0.1:8020",
1010
"deploy-local": "graph deploy ianlapham/uniswap-v3 --debug --ipfs http://localhost:5001 --node http://127.0.0.1:8020",
11-
"deploy": "graph deploy uniswap/uniswap-v3 --ipfs https://api.thegraph.com/ipfs/ --node https://api.thegraph.com/deploy/ --debug",
11+
"deploy": "graph deploy ianlapham/uniswap-v3-subgraph --ipfs https://api.thegraph.com/ipfs/ --node https://api.thegraph.com/deploy/ --debug",
1212
"deploy-dev": "graph deploy sommelier/uniswap-v3 --ipfs http://35.197.14.14:5000/ --node http://35.197.14.14:8020/ --debug",
1313
"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/",
1414
"watch-local": "graph deploy ianlapham/uniswap-v3 --watch --debug --node http://127.0.0.1:8020/ --ipfs http://localhost:5001"

schema.graphql

-6
Original file line numberDiff line numberDiff line change
@@ -219,12 +219,6 @@ type Position @entity {
219219
collectedFeesToken0: BigDecimal!
220220
# all time collected fees in token1
221221
collectedFeesToken1: BigDecimal!
222-
# Total amount deposited in terms of USD
223-
amountDepositedUSD: BigDecimal!
224-
# Total amount withdrawn in terms of USD
225-
amountWithdrawnUSD: BigDecimal!
226-
# Total amount collected in terms of USD
227-
amountCollectedUSD: BigDecimal!
228222
# tx in which the position was initialized
229223
transaction: Transaction!
230224
# vars needed for fee computation

src/mappings/position-manager.ts

+12-31
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,6 @@ function getPosition(event: ethereum.Event, tokenId: BigInt): Position | null {
4343
position.transaction = loadTransaction(event).id
4444
position.feeGrowthInside0LastX128 = positionResult.value8
4545
position.feeGrowthInside1LastX128 = positionResult.value9
46-
47-
position.amountDepositedUSD = ZERO_BD
48-
position.amountWithdrawnUSD = ZERO_BD
49-
position.amountCollectedUSD = ZERO_BD
5046
}
5147
}
5248

@@ -84,6 +80,11 @@ function savePositionSnapshot(position: Position, event: ethereum.Event): void {
8480
}
8581

8682
export function handleIncreaseLiquidity(event: IncreaseLiquidity): void {
83+
// temp fix
84+
if (event.block.number.equals(BigInt.fromI32(14317993))) {
85+
return
86+
}
87+
8788
let position = getPosition(event, event.params.tokenId)
8889

8990
// position was not able to be fetched
@@ -95,7 +96,6 @@ export function handleIncreaseLiquidity(event: IncreaseLiquidity): void {
9596
if (Address.fromString(position.pool).equals(Address.fromHexString('0x8fe8d9bb8eeba3ed688069c3d6b556c9ca258248'))) {
9697
return
9798
}
98-
let bundle = Bundle.load('1')
9999

100100
let token0 = Token.load(position.token0)
101101
let token1 = Token.load(position.token1)
@@ -107,11 +107,6 @@ export function handleIncreaseLiquidity(event: IncreaseLiquidity): void {
107107
position.depositedToken0 = position.depositedToken0.plus(amount0)
108108
position.depositedToken1 = position.depositedToken1.plus(amount1)
109109

110-
let newDepositUSD = amount0
111-
.times(token0.derivedETH.times(bundle.ethPriceUSD))
112-
.plus(amount1.times(token1.derivedETH.times(bundle.ethPriceUSD)))
113-
position.amountDepositedUSD = position.amountDepositedUSD.plus(newDepositUSD)
114-
115110
updateFeeVars(position!, event, event.params.tokenId)
116111

117112
position.save()
@@ -120,6 +115,11 @@ export function handleIncreaseLiquidity(event: IncreaseLiquidity): void {
120115
}
121116

122117
export function handleDecreaseLiquidity(event: DecreaseLiquidity): void {
118+
// temp fix
119+
if (event.block.number == BigInt.fromI32(14317993)) {
120+
return
121+
}
122+
123123
let position = getPosition(event, event.params.tokenId)
124124

125125
// position was not able to be fetched
@@ -132,7 +132,6 @@ export function handleDecreaseLiquidity(event: DecreaseLiquidity): void {
132132
return
133133
}
134134

135-
let bundle = Bundle.load('1')
136135
let token0 = Token.load(position.token0)
137136
let token1 = Token.load(position.token1)
138137
let amount0 = convertTokenToDecimal(event.params.amount0, token0.decimals)
@@ -142,11 +141,6 @@ export function handleDecreaseLiquidity(event: DecreaseLiquidity): void {
142141
position.withdrawnToken0 = position.withdrawnToken0.plus(amount0)
143142
position.withdrawnToken1 = position.withdrawnToken1.plus(amount1)
144143

145-
let newWithdrawUSD = amount0
146-
.times(token0.derivedETH.times(bundle.ethPriceUSD))
147-
.plus(amount1.times(token1.derivedETH.times(bundle.ethPriceUSD)))
148-
position.amountWithdrawnUSD = position.amountWithdrawnUSD.plus(newWithdrawUSD)
149-
150144
position = updateFeeVars(position!, event, event.params.tokenId)
151145
position.save()
152146
savePositionSnapshot(position!, event)
@@ -162,23 +156,10 @@ export function handleCollect(event: Collect): void {
162156
return
163157
}
164158

165-
166-
let bundle = Bundle.load('1')
167159
let token0 = Token.load(position.token0)
168-
let token1 = Token.load(position.token1)
169160
let amount0 = convertTokenToDecimal(event.params.amount0, token0.decimals)
170-
let amount1 = convertTokenToDecimal(event.params.amount1, token1.decimals)
171-
position.collectedToken0 = position.collectedToken0.plus(amount0)
172-
position.collectedToken1 = position.collectedToken1.plus(amount1)
173-
174-
position.collectedFeesToken0 = position.collectedToken0.minus(position.withdrawnToken0)
175-
position.collectedFeesToken1 = position.collectedToken1.minus(position.withdrawnToken1)
176-
177-
let newCollectUSD = amount0
178-
.times(token0.derivedETH.times(bundle.ethPriceUSD))
179-
.plus(amount1.times(token1.derivedETH.times(bundle.ethPriceUSD)))
180-
position.amountCollectedUSD = position.amountCollectedUSD.plus(newCollectUSD)
181-
161+
position.collectedFeesToken0 = position.collectedFeesToken0.plus(amount0)
162+
position.collectedFeesToken1 = position.collectedFeesToken1.plus(amount0)
182163

183164
position = updateFeeVars(position!, event, event.params.tokenId)
184165
position.save()

src/utils/pricing.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ let STABLE_COINS: string[] = [
4242
'0x4dd28568d05f09b02220b09c2cb307bfd837cb95'
4343
]
4444

45-
let MINIMUM_ETH_LOCKED = BigDecimal.fromString('52')
45+
let MINIMUM_ETH_LOCKED = BigDecimal.fromString('60')
4646

4747
let Q192 = 2 ** 192
4848
export function sqrtPriceX96ToTokenPrices(sqrtPriceX96: BigInt, token0: Token, token1: Token): BigDecimal[] {

subgraph.yaml

+4-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@ repository: https://github.com/Uniswap/uniswap-v3-subgraph
44
schema:
55
file: ./schema.graphql
66
graft:
7-
base: QmZeCuoZeadgHkGwLwMeguyqUKz1WPWQYKcKyMCeQqGhsF
8-
block: 12673736
7+
base: QmPrb5mvZj3ycUugZgwLWCvK93jfXfhvfjRXrFk4tRmyCX
8+
block: 14292820
9+
features:
10+
- nonFatalErrors
911
dataSources:
1012
- kind: ethereum/contract
1113
name: Factory

0 commit comments

Comments
 (0)