def set_position(self, user, i_l, i_l_l, i_u, i_u_l, Delta_L):
    assert (i_l_l <= i_l)
    if (i_l not in self.ticks):
        self.initialize_tick(i_l, i_l_l)
    assert (i_u_l <= i_u)
    if (i_u not in self.ticks):
        self.initialize_tick(i_u, i_u_l)
    position_key = (user, i_l, i_u)
    fees = self.collect_fees(user, i_l, i_u)
    self.positions[position_key].L += Delta_L
    assert (self.positions[position_key].L >= 0)
    Delta = XY()
    if (self.i_a < i_l):
        Delta.x = (Delta_L * ((1 / self.srp(i_l)) - (1 / self.srp(i_u))))
        Delta.y = 0
    elif (i_l <= self.i_a < i_u):
        if (i_l > self.i_l):
            self.i_l = i_l
        Delta.x = (Delta_L * ((1 / self.srP) - (1 / self.srp(i_u))))
        Delta.y = (Delta_L * (self.srP - self.srp(i_l)))
        self.L += Delta_L
    else:
        Delta.x = 0
        Delta.y = (Delta_L * (self.srp(i_u) - self.srp(i_l)))
    Delta -= fees
    self.ticks[i_l].Delta_L += Delta_L
    self.ticks[i_u].Delta_L -= Delta_L
    self.balance += Delta
    return (- Delta)
def set_position(self, user, i_l, i_l_l, i_u, i_u_l, Delta_L):
    assert (i_l_l <= i_l)
    if (i_l not in self.ticks):
        self.initialize_tick(i_l, i_l_l)
    assert (i_u_l <= i_u)
    if (i_u not in self.ticks):
        self.initialize_tick(i_u, i_u_l)
    position_key = (user, i_l, i_u)
    fees = self.collect_fees(user, i_l, i_u)
    self.positions[position_key].L += Delta_L
    assert (self.positions[position_key].L >= 0)
    Delta = XY()
    if (self.i_a < i_l):
        Delta.x = (Delta_L * ((1 / self.srp(i_l)) - (1 / self.srp(i_u))))
        Delta.y = 0
    elif (i_l <= self.i_a < i_u):
        if (i_l > self.i_l):
            self.i_l = i_l
        Delta.x = (Delta_L * ((1 / self.srP) - (1 / self.srp(i_u))))
        Delta.y = (Delta_L * (self.srP - self.srp(i_l)))
        self.L += Delta_L
    else:
        Delta.x = 0
        Delta.y = (Delta_L * (self.srp(i_u) - self.srp(i_l)))
    Delta -= fees
    self.ticks[i_l].Delta_L += Delta_L
    self.ticks[i_u].Delta_L -= Delta_L
    self.balance += Delta
    return (- Delta)