Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Go over weeks to fill history and calculate what the current point is | |
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: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
last_point: Point = Point({bias: 0, slope: 0, ts: block.timestamp, blk: block.number}) | |
if _epoch > 0: | |
last_point = self.point_history[_epoch] | |
// 중략 | |
if addr != ZERO_ADDRESS: | |
last_point.slope += (u_new.slope - u_old.slope) | |
last_point.bias += (u_new.bias - u_old.bias) | |
if last_point.slope < 0: | |
last_point.slope = 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
_epoch: uint256 = self.user_point_epoch[addr] | |
if _epoch == 0: | |
return 0 | |
else: | |
last_point: Point = self.user_point_history[addr][_epoch] | |
last_point.bias -= last_point.slope * convert(_t - last_point.ts, int128) | |
if last_point.bias < 0: | |
last_point.bias = 0 | |
return convert(last_point.bias, uint256) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if new_locked.end > block.timestamp and new_locked.amount > 0: | |
u_new.slope = new_locked.amount / MAXTIME | |
u_new.bias = u_new.slope * convert(new_locked.end - block.timestamp, int128) | |
// 중략 | |
self.user_point_epoch[addr] = user_epoch | |
u_new.ts = block.timestamp | |
u_new.blk = block.number | |
self.user_point_history[addr][user_epoch] = u_new |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if new_locked.end > block.timestamp and new_locked.amount > 0: | |
u_new.slope = new_locked.amount / MAXTIME | |
u_new.bias = u_new.slope * convert(new_locked.end - block.timestamp, int128) | |
// 중략 | |
self.user_point_epoch[addr] = user_epoch | |
u_new.ts = block.timestamp | |
u_new.blk = block.number | |
self.user_point_history[addr][user_epoch] = u_new |