checkpoint() :
This function updates the global point and emits an event to indicate that a global checkpoint has been reached. The _updateGlobalPoint() function is used to update the global point, which is a value that is used to track the progress of the system. The epoch value is also passed to the event, which is used to indicate the current state of the system. (autogenerated documentation)
depositFor(address,uint128) :
This function allows a user to deposit additional tokens to an existing lock. It requires that the existing lock has not expired, and that the cooldown period (if applicable) has not been initiated. It then calls the _depositFor() function to update the locked balance for the specified address. (autogenerated documentation)
createLock(uint128,uint256,bool) :
This function allows a user to lock a certain amount of tokens for a specified amount of time. The user must specify the amount of tokens to be locked, the unlock time, and whether or not the lock should have an auto cooldown. The function checks that the amount of tokens is greater than 0, that the user has not already locked tokens, that the unlock time is in the future, and that the unlock time is not more than 4 years in the future. If all of these conditions are met, the function deposits the tokens for the user and sets the lock. (autogenerated documentation)
increaseAmount(uint128) :
This function allows a user to increase the amount of tokens they have locked in the contract. It requires that the user has an existing lock, that the amount of tokens they are trying to increase by is greater than 0, that the lock has not expired, and that the cooldown period has not been initiated (if the lock is not set to auto cooldown). If all of these conditions are met, the function calls the _depositFor() function with the ActionType.INCREASE_AMOUNT parameter to increase the amount of tokens locked in the contract. (autogenerated documentation)
increaseUnlockTime(uint256) :
This function allows a user to increase the duration of their locked balance. It requires that the user has an existing lock, that the lock has not expired, and that the new unlock time is greater than the existing unlock time. The new unlock time must also be within the maximum allowed time of 4 years. The function then updates the user's locked balance with the new unlock time. (autogenerated documentation)
initiateCooldown() :
This function allows a user to initiate a cooldown period for their locked balance. It requires that the user has an existing lock, that the cooldown has not already been initiated, and that the current block timestamp is greater than the existing lock's end time minus the minimum time. The function then calculates the rounded unlock time by taking the current block timestamp plus the minimum time and dividing it by the week, then multiplying it by the week. Finally, it calls the _depositFor function to initiate the cooldown period. (autogenerated documentation)
withdraw() :
This function allows a user to withdraw their locked tokens from the contract. It first checks that the user has an existing lock, that the cooldown period has been initiated, and that the lock has expired. It then sets the user's locked balance to 0, subtracts the withdrawn amount from the total token locked, and sends the tokens to the user. Finally, it emits two events - Withdraw and Supply - to track the withdrawal and the new total token locked. (autogenerated documentation)
totalSupplyAt(uint256) :
This function calculates the total supply of the token at a given block number. It does this by first finding the epoch associated with the given block number, then calculating the time difference between the given block number and the epoch. It then uses the supplyAt() function to calculate the total supply of the token at the given block number. (autogenerated documentation)
getLastUserSlope(address) :
This function retrieves the last slope value associated with a given user address. It does this by first checking the userPointEpoch mapping to get the epoch associated with the user address. If the epoch is 0, then the function returns 0. Otherwise, it retrieves the slope value from the userPointHistory mapping using the user address and epoch as the key. (autogenerated documentation)
getUserPointHistoryTS(address,uint256) :
This function retrieves the timestamp associated with a particular user point history index for a given address. The function is marked as external, view, and override, meaning that it can be called from outside the contract, it does not modify the state of the contract, and it can be overridden by derived contracts. The function takes an address and an index as parameters, and returns a uint256 timestamp. The timestamp is retrieved from the userPointHistory mapping, which is a mapping of addresses to an array of user point history entries. (autogenerated documentation)
lockedEnd(address) :
This function returns the end time of a locked balance for a given address. It works by accessing the lockedBalances mapping, which stores the start and end times for each address, and returning the end time associated with the given address. (autogenerated documentation)
estimateDeposit(bool,uint128,uint256) :
This function estimates the deposit amount for a given value, expected unlock time, and whether or not auto cooldown is enabled. It calculates the slope, bias, and residue of the deposit, as well as the actual unlock time, provided unlock time, and residue period start. The slope is calculated by dividing the value by one year (in seconds). The bias is calculated by multiplying the slope by the difference between the actual unlock time and the current block timestamp. The residue is calculated by multiplying the value by one minute and then dividing it by one year. The residue period start is calculated by subtracting one week from the actual unlock time. The initial VeToken balance is calculated by adding the bias and residue together. (autogenerated documentation)
balanceOf(address,uint256) :
This function calculates the balance of a given address at a given timestamp. It does this by first finding the timestamp epoch associated with the address and timestamp provided. If the epoch is 0, the balance is returned as 0. Otherwise, the last point in the user's point history is retrieved and the bias is adjusted by subtracting the slope multiplied by the difference between the given timestamp and the timestamp of the last point. The bias is then adjusted by adding the residue and the adjusted bias is returned as the balance. (autogenerated documentation)
balanceOf(address) :
This function returns the balance of a given address at a given timestamp. It works by taking in an address as an argument and then using the balanceOf() function to retrieve the balance of that address at the current block timestamp. The balance is then returned as a uint256. (autogenerated documentation)
balanceOfAt(address,uint256) :
This function is used to calculate the balance of a given address at a given block number. It first finds the user's point epoch by performing a binary search on the userPointHistory array. It then finds the block epoch by calling the _findBlockEpoch() function. It then calculates the block time by using the pointHistory array and the block number. Finally, it calculates the balance by subtracting the slope and the residue from the bias. (autogenerated documentation)
totalSupply() :
This function is an override of the totalSupply() function in the ERC20 standard. It returns the total supply of tokens at a given block timestamp. It works by taking the block timestamp as an argument and using it to calculate the total supply of tokens. (autogenerated documentation)
totalSupply(uint256) :
This function calculates the total supply of a token at a given timestamp. It does this by first finding the epoch associated with the given timestamp, then retrieving the Point associated with that epoch from the pointHistory mapping. Finally, it uses the supplyAt() function to calculate the total supply at the given timestamp using the retrieved Point and the given timestamp. (autogenerated documentation)
_checkpoint(address) :
This function is used to update the global point and user point history for a given address. It takes in an address, an old deposit, and a new deposit, and updates the global point and user point history accordingly. It does this by calculating the slope and bias of the old and new deposits, and then updating the global point and user point history with the difference between the old and new deposits. It also updates the slope changes for the old and new deposits, if applicable. (autogenerated documentation)
_depositFor(address,bool,bool,uint128,uint256) :
This function is used to deposit tokens into a locked balance for a given address. It takes in the address, whether auto cooldown is enabled, whether cooldown is enabled, the value of the deposit, the unlock time, the old deposit, and the action type as parameters. It then updates the total token locked, adds the value to the new deposit, sets the auto cooldown, cooldown initiated, and end values, and stores the new deposit in the locked balances mapping. It then emits a UserCheckpoint event and a Supply event. (autogenerated documentation)
supplyAt(uint256) :
This function calculates the supply of a token at a given timestamp. It does this by taking in a Point memory point, which contains the slope, bias, residue, and timestamp of the token, and a timestamp (ts). It then iterates through the slopeChanges array, subtracting the slope from the bias and adding the slope change to the slope for each week until the timestamp is reached. Finally, it adds the residue to the bias and returns the result as a uint256. (autogenerated documentation)
_findBlockEpoch(uint256,uint256) :
This function is used to find the epoch associated with a given block number. It uses a binary search algorithm to search through the pointHistory array, which stores the block numbers associated with each epoch. The function takes in the block number and the maximum epoch as parameters, and returns the epoch associated with the given block number. The binary search algorithm starts by setting the minimum and maximum epochs to 0 and maxEpoch respectively. It then iterates through the array, setting the midpoint to the average of the min and max epochs. If the block number associated with the midpoint is less than or equal to the given block number, the min is set to the midpoint. Otherwise, the max is set to the midpoint minus (autogenerated documentation)
_findUserTimestampEpoch(address,uint256) :
This function is an internal view function that finds the timestamp epoch for a given user address and timestamp. It uses a binary search algorithm to find the timestamp epoch by comparing the given timestamp to the timestamps stored in the userPointHistory mapping. The function starts by setting the min and max values to 0 and the userPointEpoch value for the given address, respectively. It then iterates through the mapping 128 times, setting the mid value to the average of the min and max values, and comparing the given timestamp to the timestamp stored in the mapping at the mid index. If the given timestamp is less than or equal to the timestamp stored in the mapping, the min value is set to the mid value. Otherwise, the max value (autogenerated documentation)
_findGlobalTimestampEpoch(uint256) :
This function is used to find the global timestamp epoch for a given timestamp. It works by using a binary search algorithm to search through the pointHistory array. The function takes in a uint256 timestamp as an argument and returns the corresponding global timestamp epoch. The binary search algorithm starts by setting the min and max values to 0 and epoch respectively. It then iterates through the array, setting the mid value to the average of min and max, and comparing the mid value to the given timestamp. If the mid value is less than or equal to the given timestamp, the min value is set to the mid value. Otherwise, the max value is set to the mid value minus one. This process is repeated until the min value is greater than or (autogenerated documentation)
_updateGlobalPoint() :
This function updates the global point of the contract. It takes the current block timestamp and block number and uses them to calculate the slope and bias of the global point. It also takes into account any changes in the slope that have been made since the last checkpoint. The function then stores the new global point in the pointHistory array and updates the epoch variable. (autogenerated documentation)