Skip to content

Commit

Permalink
reduce one redundant for-loop
Browse files Browse the repository at this point in the history
  • Loading branch information
bout3fiddy committed Sep 14, 2023
1 parent 1bc9337 commit de23ace
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions contracts/main/CurveTricryptoOptimizedWETH.vy
Original file line number Diff line number Diff line change
Expand Up @@ -474,16 +474,16 @@ def add_liquidity(

xp[0] *= PRECISIONS[0]
xp_old[0] *= PRECISIONS[0]
for i in range(1, N_COINS):
xp[i] = unsafe_div(xp[i] * price_scale[i-1] * PRECISIONS[i], PRECISION)
xp_old[i] = unsafe_div(
xp_old[i] * unsafe_mul(price_scale[i-1], PRECISIONS[i]),
PRECISION
)

# recalc amountsp:
for i in range(N_COINS):
if amounts[i] > 0:

if i >= 1:
xp[i] = unsafe_div(xp[i] * price_scale[i-1] * PRECISIONS[i], PRECISION)
xp_old[i] = unsafe_div(
xp_old[i] * unsafe_mul(price_scale[i-1], PRECISIONS[i]),
PRECISION
)

if amounts_received[i] > 0:
amountsp[i] = xp[i] - xp_old[i]

# -------------------- Calculate LP tokens to mint -----------------------
Expand Down

0 comments on commit de23ace

Please sign in to comment.