2

I am studying the Voting Escrow contract and im looking to incorporate it in a project im building. In the _checkpoint function , there is this for loop:

    t_i: uint256 = (last_checkpoint / WEEK) * WEEK
    for i in range(255):
        # Hopefully it won't happen that this won't get used in 5 years!
        # If it does, users will be able to withdraw but vote weight will be broken
        t_i += WEEK
        d_slope: int128 = 0
        if t_i > block.timestamp:
            t_i = block.timestamp
        else:
            d_slope = self.slope_changes[t_i]
        last_point.bias -= last_point.slope * convert(t_i - last_checkpoint, int128)
        last_point.slope += d_slope
        if last_point.bias < 0:  # This can happen
            last_point.bias = 0
        if last_point.slope < 0:  # This cannot happen - just in case
            last_point.slope = 0
        last_checkpoint = t_i
        last_point.ts = t_i
        last_point.blk = initial_last_point.blk + block_slope * (t_i - initial_last_point.ts) / MULTIPLIER
        _epoch += 1
        if t_i == block.timestamp:
            last_point.blk = block.number
            break
        else:
            self.point_history[_epoch] = last_point

It seems like in 255 weeks(4,8 years) the contract wont be able to calculate the current point. What happens then?Do they migrate to an other voting escrow contract? In my implementation I'm trying to use 12h epochs. Do you think that the the gas to calculate in 12h epochs instead of weeks is going to become too big?

1 Answer 1

1

Each time _checkpoint() is called (for example during deposits or withdrawals), the 255-week period is reset. For the vote weight to get broken, 255 weeks have to go by without anyone interacting with the contract. And even if that happens, users will be able to withdraw their deposits, as mentioned in this comment in _checkpoint():

# Hopefully it won't happen that this won't get used in 5 years!
# If it does, users will be able to withdraw but vote weight will be broken

Regarding using 12 hours epochs instead of 1 week, that could work or not depending on your use case requirements and assumptions. It's hard to tell without more information.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.