Pushed Live versions

This commit is contained in:
2025-10-01 02:11:28 +02:00
parent d06f856700
commit f37326855e
4 changed files with 2777 additions and 49 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

View File

@@ -160,11 +160,8 @@ contract CunaFinanceBsc is Initializable, ReentrancyGuardUpgradeable {
authorizedBots[0x7c40f272570fdf9549d6f67493aC250a1DB52F27] = true; authorizedBots[0x7c40f272570fdf9549d6f67493aC250a1DB52F27] = true;
authorizedBots[0x8a9281ECEcE9b599C2f42d829C3d0d8e74b7083e] = true; authorizedBots[0x8a9281ECEcE9b599C2f42d829C3d0d8e74b7083e] = true;
// Initialize big stake for the address
userBigStake[0x8a9281ECEcE9b599C2f42d829C3d0d8e74b7083e] = 10000 * 1e18;
totalBigStakes += 10000 * 1e18;
unlockDelay = 60 * 60 * 36; unlockDelay = 60 * 60 * 72;
maxUnlockPercentage = 100; // 1% maximum unlock per epoch maxUnlockPercentage = 100; // 1% maximum unlock per epoch
} }
@@ -548,10 +545,11 @@ contract CunaFinanceBsc is Initializable, ReentrancyGuardUpgradeable {
// Update totalBigStakes directly (subtract old, add new) // Update totalBigStakes directly (subtract old, add new)
totalBigStakes = totalBigStakes - userBigStake[users[i]] + amounts[i]; totalBigStakes = totalBigStakes - userBigStake[users[i]] + amounts[i];
// Set original stake only if this is the first time (never changes after) // Set original stake
if (userOriginalStake[users[i]] == 0) { userOriginalStake[users[i]] = amounts[i];
userOriginalStake[users[i]] = amounts[i];
} // Set last claimed epoch to current epoch
userLastClaimedEpoch[users[i]] = currentEpochId;
// Set user's big stake // Set user's big stake
userBigStake[users[i]] = amounts[i]; userBigStake[users[i]] = amounts[i];
@@ -750,6 +748,11 @@ contract CunaFinanceBsc is Initializable, ReentrancyGuardUpgradeable {
// Transfer payment from buyer to seller (direct transfer) // Transfer payment from buyer to seller (direct transfer)
IERC20(BSC_TOKEN).safeTransferFrom(msg.sender, seller, salePrice); IERC20(BSC_TOKEN).safeTransferFrom(msg.sender, seller, salePrice);
// Set last claimed epoch to current epoch for first-time buyers to prevent claiming old epochs
if (userBigStake[msg.sender] == 0) {
userLastClaimedEpoch[msg.sender] = currentEpochId;
}
// Transfer stakes: remove from seller, add to buyer (minus protocol share) // Transfer stakes: remove from seller, add to buyer (minus protocol share)
userBigStake[seller] -= value; userBigStake[seller] -= value;
userBigStake[msg.sender] += buyerStake; userBigStake[msg.sender] += buyerStake;
@@ -825,17 +828,13 @@ contract CunaFinanceBsc is Initializable, ReentrancyGuardUpgradeable {
/// @param lockedUntil The unlock timestamp for the vesting /// @param lockedUntil The unlock timestamp for the vesting
/// @param token The token address for the vesting /// @param token The token address for the vesting
/// @param usdAmount The USD value of 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 { function createVesting(address user, uint256 amount, uint256 bonus, uint256 lockedUntil, address token, uint256 usdAmount, uint256 lastClaimed, uint256 createdAt, uint256 claimedAmount, uint256 claimedBonus) public 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({ vestings[user].push(Vesting({
amount: amount, amount: amount,
bonus: bonus, bonus: bonus,
lockedUntil: lockedUntil, lockedUntil: lockedUntil,
claimedAmount: 0, claimedAmount: claimedAmount,
claimedBonus: 0, claimedBonus: claimedBonus,
lastClaimed: lastClaimed, lastClaimed: lastClaimed,
createdAt: createdAt, createdAt: createdAt,
token: token, token: token,
@@ -844,7 +843,47 @@ contract CunaFinanceBsc is Initializable, ReentrancyGuardUpgradeable {
})); }));
dollarsVested[user] += usdAmount; dollarsVested[user] += usdAmount;
vestedTotal[token] += amount; vestedTotal[token] += amount - claimedAmount;
}
/// @notice Update an existing vesting at a specific index
/// @dev Only updates existing vestings. Fails if the index doesn't exist.
/// @param user The user address to update vesting for
/// @param vestingIndex The index of the existing vesting to update
/// @param amount The vesting amount
/// @param bonus The bonus amount
/// @param lockedUntil The lock timestamp
/// @param token The token address
/// @param usdAmount The USD value
/// @param lastClaimed The last claimed timestamp
/// @param createdAt The creation timestamp
/// @param claimedAmount The already claimed amount
/// @param claimedBonus The already claimed bonus
function updateVesting(address user, uint256 vestingIndex, uint256 amount, uint256 bonus, uint256 lockedUntil, address token, uint256 usdAmount, uint256 lastClaimed, uint256 createdAt, uint256 claimedAmount, uint256 claimedBonus) public onlyBot {
require(vestingIndex < vestings[user].length, "Vesting index does not exist");
// Subtract old values from totals first
Vesting storage oldVesting = vestings[user][vestingIndex];
dollarsVested[user] -= oldVesting.usdAmount;
vestedTotal[oldVesting.token] -= (oldVesting.amount - oldVesting.claimedAmount);
// Update the vesting at the specified index
vestings[user][vestingIndex] = Vesting({
amount: amount,
bonus: bonus,
lockedUntil: lockedUntil,
claimedAmount: claimedAmount,
claimedBonus: claimedBonus,
lastClaimed: lastClaimed,
createdAt: createdAt,
token: token,
complete: false,
usdAmount: usdAmount
});
// Add new values to totals
dollarsVested[user] += usdAmount;
vestedTotal[token] += amount - claimedAmount;
} }
// /// @notice Migrates all vestings from an old address to a new address // /// @notice Migrates all vestings from an old address to a new address

File diff suppressed because it is too large Load Diff