Currently deployed, has vesting tracker
This commit is contained in:
@@ -36,7 +36,7 @@ error StakeNotInSellState();
|
||||
|
||||
// File: paca.sol
|
||||
|
||||
contract PacaFinanceWithBoostAndScheduleUSDC is Initializable, ReentrancyGuardUpgradeable {
|
||||
contract PacaFinanceWithBoostAndScheduleBase is Initializable, ReentrancyGuardUpgradeable {
|
||||
using SafeERC20 for IERC20;
|
||||
|
||||
|
||||
@@ -136,8 +136,6 @@ contract PacaFinanceWithBoostAndScheduleUSDC is Initializable, ReentrancyGuardUp
|
||||
uint256 public unlockDelay;
|
||||
uint256 public withdrawLiabilities;
|
||||
mapping(address => WithdrawStake[]) public withdrawStake;
|
||||
mapping(address => WithdrawVesting[]) public withdrawVesting;
|
||||
uint256 private withdrawVestingCounter;
|
||||
uint256 public restakeBonus;
|
||||
mapping(address => uint256) public addressFixedRate;
|
||||
mapping(address => mapping(uint256 => SellStake)) public sellStakes;
|
||||
@@ -146,6 +144,12 @@ contract PacaFinanceWithBoostAndScheduleUSDC is Initializable, ReentrancyGuardUp
|
||||
SellStakeKey[] public sellStakeKeys;
|
||||
mapping(address => mapping(uint256 => uint256)) private sellStakeKeyIndex;
|
||||
uint256 public sellMin;
|
||||
|
||||
mapping(address => WithdrawVesting[]) private withdrawVestingActual;
|
||||
uint256 private withdrawVestingCounterActual;
|
||||
|
||||
// Track total withdraw vesting liabilities by token address
|
||||
mapping(address => uint256) public withdrawVestingLiabilities;
|
||||
|
||||
// Events
|
||||
event Staked(address indexed user, uint256 amount);
|
||||
@@ -451,14 +455,14 @@ contract PacaFinanceWithBoostAndScheduleUSDC is Initializable, ReentrancyGuardUp
|
||||
dollarsVested[oldAddress] = 0;
|
||||
|
||||
// Migrate pending vesting withdrawals
|
||||
WithdrawVesting[] storage oldWithdrawVestings = withdrawVesting[oldAddress];
|
||||
WithdrawVesting[] storage oldWithdrawVestings = withdrawVestingActual[oldAddress];
|
||||
uint256 withdrawVestingCount = oldWithdrawVestings.length;
|
||||
if (withdrawVestingCount > 0) {
|
||||
WithdrawVesting[] storage newWithdrawVestings = withdrawVesting[newAddress];
|
||||
WithdrawVesting[] storage newWithdrawVestings = withdrawVestingActual[newAddress];
|
||||
for (uint256 i = 0; i < withdrawVestingCount; i++) {
|
||||
newWithdrawVestings.push(oldWithdrawVestings[i]);
|
||||
}
|
||||
delete withdrawVesting[oldAddress];
|
||||
delete withdrawVestingActual[oldAddress];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -824,7 +828,7 @@ function withdraw(uint256 _stakeIndex) external nonReentrant {
|
||||
* @param _vestingId The vesting ID to withdraw
|
||||
*/
|
||||
function withdrawVestingToken(uint256 _vestingId) external nonReentrant {
|
||||
WithdrawVesting[] storage userVestings = withdrawVesting[msg.sender];
|
||||
WithdrawVesting[] storage userVestings = withdrawVestingActual[msg.sender];
|
||||
if (userVestings.length == 0) revert NoStakesAvailable();
|
||||
|
||||
for (uint256 i = 0; i < userVestings.length; ++i) {
|
||||
@@ -842,6 +846,9 @@ function withdrawVestingToken(uint256 _vestingId) external nonReentrant {
|
||||
// Update state before external calls
|
||||
vestingWithdraw.amount = 0;
|
||||
|
||||
// Decrement withdraw vesting liabilities for this token
|
||||
withdrawVestingLiabilities[_token] -= _amount;
|
||||
|
||||
// Transfer tokens
|
||||
IERC20(_token).safeTransfer(msg.sender, _amount);
|
||||
emit StakeWithdrawn(msg.sender, _amount, _vestingId);
|
||||
@@ -849,7 +856,6 @@ function withdrawVestingToken(uint256 _vestingId) external nonReentrant {
|
||||
}
|
||||
}
|
||||
|
||||
// Revert if no matching vesting with non-zero amount was found
|
||||
revert StakeNotFound();
|
||||
}
|
||||
|
||||
@@ -1009,12 +1015,15 @@ function withdrawVestingToken(uint256 _vestingId) external nonReentrant {
|
||||
vestedTotal[vesting.token] -= amountToClaim;
|
||||
|
||||
// Add vesting claims to cooldown queue
|
||||
withdrawVesting[msg.sender].push(WithdrawVesting({
|
||||
vestingId: withdrawVestingCounter++,
|
||||
withdrawVestingActual[msg.sender].push(WithdrawVesting({
|
||||
vestingId: withdrawVestingCounterActual++,
|
||||
amount: amountToClaim,
|
||||
unlockTime: block.timestamp + unlockDelay,
|
||||
token: vesting.token
|
||||
}));
|
||||
|
||||
// Increment withdraw vesting liabilities for this token
|
||||
withdrawVestingLiabilities[vesting.token] += amountToClaim;
|
||||
|
||||
emit VestingClaimed(msg.sender, amountToClaim, 0);
|
||||
}
|
||||
@@ -1062,12 +1071,15 @@ function withdrawVestingToken(uint256 _vestingId) external nonReentrant {
|
||||
vestedTotal[_token] -= totalReward;
|
||||
|
||||
// Add vesting claims to cooldown queue
|
||||
withdrawVesting[msg.sender].push(WithdrawVesting({
|
||||
vestingId: withdrawVestingCounter++,
|
||||
withdrawVestingActual[msg.sender].push(WithdrawVesting({
|
||||
vestingId: withdrawVestingCounterActual++,
|
||||
amount: totalReward,
|
||||
unlockTime: block.timestamp + unlockDelay,
|
||||
token: _token
|
||||
}));
|
||||
|
||||
// Increment withdraw vesting liabilities for this token
|
||||
withdrawVestingLiabilities[_token] += totalReward;
|
||||
|
||||
emit RewardClaimed(msg.sender, totalReward);
|
||||
}
|
||||
@@ -1237,15 +1249,23 @@ function withdrawVestingToken(uint256 _vestingId) external nonReentrant {
|
||||
/// @param user The address to evaluate.
|
||||
/// @return An array of WithdrawVesting for the given user.
|
||||
function getAllWithdrawVestings(address user) external view returns (WithdrawVesting[] memory) {
|
||||
return withdrawVesting[user];
|
||||
return withdrawVestingActual[user];
|
||||
}
|
||||
|
||||
/// @notice Returns the current withdraw vesting counter value
|
||||
/// @return Current counter value for tracking unique withdrawal IDs
|
||||
function getWithdrawVestingCounter() external view returns (uint256) {
|
||||
return withdrawVestingCounter;
|
||||
return withdrawVestingCounterActual;
|
||||
}
|
||||
|
||||
/// @notice Test function for upgrade verification
|
||||
/// @return Returns a constant value to verify upgrade worked
|
||||
function testUpgradeFunction() external pure returns (uint256) {
|
||||
return 888;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// @notice Function to put a stake for sale.
|
||||
/// Sets the original stake amount to 0 to prevent any alterations while for sale.
|
||||
/// @param _stakeId The stake to sell.
|
||||
|
||||
@@ -36,7 +36,7 @@ error StakeNotInSellState();
|
||||
|
||||
// File: paca.sol
|
||||
|
||||
contract PacaFinanceWithBoostAndScheduleUSDT is Initializable, ReentrancyGuardUpgradeable {
|
||||
contract PacaFinanceWithBoostAndScheduleBsc is Initializable, ReentrancyGuardUpgradeable {
|
||||
using SafeERC20 for IERC20;
|
||||
|
||||
|
||||
@@ -136,8 +136,6 @@ contract PacaFinanceWithBoostAndScheduleUSDT is Initializable, ReentrancyGuardUp
|
||||
uint256 public unlockDelay;
|
||||
uint256 public withdrawLiabilities;
|
||||
mapping(address => WithdrawStake[]) public withdrawStake;
|
||||
mapping(address => WithdrawVesting[]) public withdrawVesting;
|
||||
uint256 private withdrawVestingCounter;
|
||||
uint256 public restakeBonus;
|
||||
mapping(address => uint256) public addressFixedRate;
|
||||
mapping(address => mapping(uint256 => SellStake)) public sellStakes;
|
||||
@@ -146,6 +144,12 @@ contract PacaFinanceWithBoostAndScheduleUSDT is Initializable, ReentrancyGuardUp
|
||||
SellStakeKey[] public sellStakeKeys;
|
||||
mapping(address => mapping(uint256 => uint256)) private sellStakeKeyIndex;
|
||||
uint256 public sellMin;
|
||||
|
||||
mapping(address => WithdrawVesting[]) private withdrawVestingActual;
|
||||
uint256 private withdrawVestingCounterActual;
|
||||
|
||||
// Track total withdraw vesting liabilities by token address
|
||||
mapping(address => uint256) public withdrawVestingLiabilities;
|
||||
|
||||
// Events
|
||||
event Staked(address indexed user, uint256 amount);
|
||||
@@ -207,6 +211,7 @@ contract PacaFinanceWithBoostAndScheduleUSDT is Initializable, ReentrancyGuardUp
|
||||
owners[_owner] = false;
|
||||
}
|
||||
|
||||
|
||||
/// @notice Function to add a bot to the list (only callable by the contract owner)
|
||||
function addBot(address bot) external onlyOwner {
|
||||
if (bot == address(0)) revert InvalidAddress();
|
||||
@@ -226,6 +231,7 @@ contract PacaFinanceWithBoostAndScheduleUSDT is Initializable, ReentrancyGuardUp
|
||||
emit PoolUpdated(_lockupPeriod, _dailyRewardRate);
|
||||
}
|
||||
|
||||
|
||||
function depositRewards(uint256 _amount) external onlyOwner {
|
||||
IERC20(pool.tokenAddress).safeTransferFrom(msg.sender, address(this), _amount);
|
||||
pool.totalRewards = pool.totalRewards + _amount;
|
||||
@@ -449,14 +455,14 @@ contract PacaFinanceWithBoostAndScheduleUSDT is Initializable, ReentrancyGuardUp
|
||||
dollarsVested[oldAddress] = 0;
|
||||
|
||||
// Migrate pending vesting withdrawals
|
||||
WithdrawVesting[] storage oldWithdrawVestings = withdrawVesting[oldAddress];
|
||||
WithdrawVesting[] storage oldWithdrawVestings = withdrawVestingActual[oldAddress];
|
||||
uint256 withdrawVestingCount = oldWithdrawVestings.length;
|
||||
if (withdrawVestingCount > 0) {
|
||||
WithdrawVesting[] storage newWithdrawVestings = withdrawVesting[newAddress];
|
||||
WithdrawVesting[] storage newWithdrawVestings = withdrawVestingActual[newAddress];
|
||||
for (uint256 i = 0; i < withdrawVestingCount; i++) {
|
||||
newWithdrawVestings.push(oldWithdrawVestings[i]);
|
||||
}
|
||||
delete withdrawVesting[oldAddress];
|
||||
delete withdrawVestingActual[oldAddress];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -812,7 +818,7 @@ contract PacaFinanceWithBoostAndScheduleUSDT is Initializable, ReentrancyGuardUp
|
||||
* @param _vestingId The vesting ID to withdraw
|
||||
*/
|
||||
function withdrawVestingToken(uint256 _vestingId) external nonReentrant {
|
||||
WithdrawVesting[] storage userVestings = withdrawVesting[msg.sender];
|
||||
WithdrawVesting[] storage userVestings = withdrawVestingActual[msg.sender];
|
||||
if (userVestings.length == 0) revert NoStakesAvailable();
|
||||
|
||||
for (uint256 i = 0; i < userVestings.length; ++i) {
|
||||
@@ -830,6 +836,9 @@ function withdrawVestingToken(uint256 _vestingId) external nonReentrant {
|
||||
// Update state before external calls
|
||||
vestingWithdraw.amount = 0;
|
||||
|
||||
// Decrement withdraw vesting liabilities for this token
|
||||
withdrawVestingLiabilities[_token] -= _amount;
|
||||
|
||||
// Transfer tokens
|
||||
IERC20(_token).safeTransfer(msg.sender, _amount);
|
||||
emit StakeWithdrawn(msg.sender, _amount, _vestingId);
|
||||
@@ -837,7 +846,6 @@ function withdrawVestingToken(uint256 _vestingId) external nonReentrant {
|
||||
}
|
||||
}
|
||||
|
||||
// Revert if no matching vesting with non-zero amount was found
|
||||
revert StakeNotFound();
|
||||
}
|
||||
|
||||
@@ -997,12 +1005,15 @@ function withdrawVestingToken(uint256 _vestingId) external nonReentrant {
|
||||
vestedTotal[vesting.token] -= amountToClaim;
|
||||
|
||||
// Add vesting claims to cooldown queue
|
||||
withdrawVesting[msg.sender].push(WithdrawVesting({
|
||||
vestingId: withdrawVestingCounter++,
|
||||
withdrawVestingActual[msg.sender].push(WithdrawVesting({
|
||||
vestingId: withdrawVestingCounterActual++,
|
||||
amount: amountToClaim,
|
||||
unlockTime: block.timestamp + unlockDelay,
|
||||
token: vesting.token
|
||||
}));
|
||||
|
||||
// Increment withdraw vesting liabilities for this token
|
||||
withdrawVestingLiabilities[vesting.token] += amountToClaim;
|
||||
|
||||
emit VestingClaimed(msg.sender, amountToClaim, 0);
|
||||
}
|
||||
@@ -1050,12 +1061,15 @@ function withdrawVestingToken(uint256 _vestingId) external nonReentrant {
|
||||
vestedTotal[_token] -= totalReward;
|
||||
|
||||
// Add vesting claims to cooldown queue
|
||||
withdrawVesting[msg.sender].push(WithdrawVesting({
|
||||
vestingId: withdrawVestingCounter++,
|
||||
withdrawVestingActual[msg.sender].push(WithdrawVesting({
|
||||
vestingId: withdrawVestingCounterActual++,
|
||||
amount: totalReward,
|
||||
unlockTime: block.timestamp + unlockDelay,
|
||||
token: _token
|
||||
}));
|
||||
|
||||
// Increment withdraw vesting liabilities for this token
|
||||
withdrawVestingLiabilities[_token] += totalReward;
|
||||
|
||||
emit RewardClaimed(msg.sender, totalReward);
|
||||
}
|
||||
@@ -1225,15 +1239,22 @@ function withdrawVestingToken(uint256 _vestingId) external nonReentrant {
|
||||
/// @param user The address to evaluate.
|
||||
/// @return An array of WithdrawVesting for the given user.
|
||||
function getAllWithdrawVestings(address user) external view returns (WithdrawVesting[] memory) {
|
||||
return withdrawVesting[user];
|
||||
return withdrawVestingActual[user];
|
||||
}
|
||||
|
||||
/// @notice Returns the current withdraw vesting counter value
|
||||
/// @return Current counter value for tracking unique withdrawal IDs
|
||||
function getWithdrawVestingCounter() external view returns (uint256) {
|
||||
return withdrawVestingCounter;
|
||||
return withdrawVestingCounterActual;
|
||||
}
|
||||
|
||||
/// @notice Test function for upgrade verification
|
||||
/// @return Returns a constant value to verify upgrade worked
|
||||
function testUpgradeFunction() external pure returns (uint256) {
|
||||
return 777;
|
||||
}
|
||||
|
||||
|
||||
/// @notice Function to put a stake for sale.
|
||||
/// Sets the original stake amount to 0 to prevent any alterations while for sale.
|
||||
/// @param _stakeId The stake to sell.
|
||||
|
||||
1435
contracts/sonic_paca.sol
Normal file
1435
contracts/sonic_paca.sol
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user