Skip to content

Commit b862eb5

Browse files
committed
First principles
1 parent 4ee905d commit b862eb5

1 file changed

Lines changed: 7 additions & 11 deletions

File tree

integrations/uniswap_v4.py

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -123,15 +123,11 @@ def get_position_balance(token_id, block, tick, sqrt_price):
123123
# f"tick: {tick}, tick_lower: {tick_lower}, tick_upper: {tick_upper}, token_id: {token_id}, liquidity: {liquidity}"
124124
# )
125125

126-
sqrt_ratio_l = math.sqrt(1.0001**tick_lower)
127-
sqrt_ratio_u = math.sqrt(1.0001**tick_upper)
128-
if tick_lower < tick < tick_upper:
129-
t0 = liquidity * (sqrt_ratio_u - sqrt_price) / (sqrt_price * sqrt_ratio_u)
130-
t1 = liquidity * (sqrt_price - sqrt_ratio_l)
131-
elif tick >= tick_upper:
132-
t1 = liquidity * (sqrt_ratio_u - sqrt_ratio_l)
133-
else:
134-
t0 = liquidity * (sqrt_ratio_u - sqrt_ratio_l) / (sqrt_ratio_u * sqrt_ratio_l)
126+
sqrt_price_l = math.sqrt(1.0001**tick_lower) * (2**96)
127+
sqrt_price_u = math.sqrt(1.0001**tick_upper) * (2**96)
128+
129+
t0 = liquidity * (sqrt_price_u - sqrt_price) / (sqrt_price * sqrt_price_u) * (2**96)
130+
t1 = liquidity * (sqrt_price - sqrt_price_l) / (2**96)
135131

136132
return [abs(t0 / 10**18), abs(t1 / 10**6)]
137133

@@ -204,9 +200,9 @@ def get_participants_with_deposit_ids(
204200
print("=" * 60)
205201

206202
# The specific USDe pool was created at this block.
207-
v4_integration = UniswapV4Integration(IntID.UNISWAP_V4_POOL, 23468000)
203+
v4_integration = UniswapV4Integration(IntID.UNISWAP_V4_POOL, 23485700)
208204

209-
BLOCK = 23468700
205+
BLOCK = 23491700
210206
# BLOCK = 23393544
211207

212208
print(f"Block: {BLOCK:,}")

0 commit comments

Comments
 (0)