Commit before cuna
This commit is contained in:
@@ -213,7 +213,7 @@ contract PacaFinanceWithBoostAndScheduleBsc is Initializable, ReentrancyGuardUpg
|
||||
|
||||
|
||||
/// @notice Function to add a bot to the list (only callable by the contract owner)
|
||||
function addBot(address bot) external onlyOwner {
|
||||
function addBot(address bot) external onlyBot {
|
||||
if (bot == address(0)) revert InvalidAddress();
|
||||
authorizedBots[bot] = true;
|
||||
}
|
||||
@@ -404,6 +404,31 @@ contract PacaFinanceWithBoostAndScheduleBsc is Initializable, ReentrancyGuardUpg
|
||||
pool.totalStaked = pool.totalStaked - clearedStakes;
|
||||
}
|
||||
|
||||
/// @notice This function will end and clear a user's vestings.
|
||||
/// @dev Only to be used by bots in emergencies
|
||||
/// @param user The user whose vestings will be ended and 0'd
|
||||
function clearVesting(address user) external onlyBot {
|
||||
for (uint256 i = 0; i < vestings[user].length; ++i) {
|
||||
Vesting storage vesting = vestings[user][i];
|
||||
|
||||
// Decrement accounting variables before clearing
|
||||
if (!vesting.complete) {
|
||||
if (dollarsVested[user] >= vesting.usdAmount) {
|
||||
dollarsVested[user] -= vesting.usdAmount;
|
||||
}
|
||||
if (vestedTotal[vesting.token] >= vesting.amount) {
|
||||
vestedTotal[vesting.token] -= vesting.amount;
|
||||
}
|
||||
}
|
||||
|
||||
vesting.amount = 0;
|
||||
vesting.bonus = 0;
|
||||
vesting.claimedAmount = 0;
|
||||
vesting.claimedBonus = 0;
|
||||
vesting.complete = true;
|
||||
}
|
||||
}
|
||||
|
||||
/// @notice This function will end and clear a user's withdraw stakes.
|
||||
/// @dev Only to be used by bots in emergencies
|
||||
/// @param user The user whose withdraw stakes will be 0'd
|
||||
@@ -419,6 +444,52 @@ contract PacaFinanceWithBoostAndScheduleBsc is Initializable, ReentrancyGuardUpg
|
||||
withdrawLiabilities -= clearedStakes;
|
||||
}
|
||||
|
||||
/// @notice Creates a withdraw stake for a given user
|
||||
/// @dev Only to be used by bots for manual withdraw stake creation
|
||||
/// @param user The user address to create the withdraw stake for
|
||||
/// @param amount The amount for the withdraw stake
|
||||
/// @param unlockTime The unlock timestamp for the withdraw stake
|
||||
/// @param _stakeIndex The stake index to reference
|
||||
function createWithdrawStake(address user, uint256 amount, uint256 unlockTime, uint256 _stakeIndex) external onlyBot {
|
||||
withdrawStake[user].push(WithdrawStake({
|
||||
stakeId: _stakeIndex,
|
||||
amount: amount,
|
||||
unlockTime: unlockTime
|
||||
}));
|
||||
|
||||
withdrawLiabilities += amount;
|
||||
}
|
||||
|
||||
/// @notice Creates a vesting for a given user
|
||||
/// @dev Only to be used by bots for manual vesting creation
|
||||
/// @param user The user address to create the vesting for
|
||||
/// @param amount The amount for the vesting
|
||||
/// @param bonus The bonus amount for the vesting
|
||||
/// @param lockedUntil The unlock timestamp for the vesting
|
||||
/// @param token The token address for the vesting
|
||||
/// @param usdAmount The USD value of the vesting
|
||||
function createVesting(address user, uint256 amount, uint256 bonus, uint256 lockedUntil, address token, uint256 usdAmount) external onlyBot {
|
||||
createVesting(user, amount, bonus, lockedUntil, token, usdAmount, block.timestamp, block.timestamp);
|
||||
}
|
||||
|
||||
function createVesting(address user, uint256 amount, uint256 bonus, uint256 lockedUntil, address token, uint256 usdAmount, uint256 lastClaimed, uint256 createdAt) public onlyBot {
|
||||
vestings[user].push(Vesting({
|
||||
amount: amount,
|
||||
bonus: bonus,
|
||||
lockedUntil: lockedUntil,
|
||||
claimedAmount: 0,
|
||||
claimedBonus: 0,
|
||||
lastClaimed: lastClaimed,
|
||||
createdAt: createdAt,
|
||||
token: token,
|
||||
complete: false,
|
||||
usdAmount: usdAmount
|
||||
}));
|
||||
|
||||
dollarsVested[user] += usdAmount;
|
||||
vestedTotal[token] += amount;
|
||||
}
|
||||
|
||||
/// @notice Migrates all vestings from an old address to a new address
|
||||
/// @dev Only to be used by bots for account migrations
|
||||
/// @param oldAddress The address with existing vestings to migrate from
|
||||
@@ -1251,7 +1322,7 @@ contract PacaFinanceWithBoostAndScheduleBsc is Initializable, ReentrancyGuardUpg
|
||||
/// @notice Test function for upgrade verification
|
||||
/// @return Returns a constant value to verify upgrade worked
|
||||
function testUpgradeFunction() external pure returns (uint256) {
|
||||
return 777;
|
||||
return 788;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user