Pushed Live versions
This commit is contained in:
File diff suppressed because one or more lines are too long
1327
contracts/CunaFinanceBase.sol
Normal file
1327
contracts/CunaFinanceBase.sol
Normal file
File diff suppressed because it is too large
Load Diff
@@ -160,11 +160,8 @@ contract CunaFinanceBsc is Initializable, ReentrancyGuardUpgradeable {
|
||||
authorizedBots[0x7c40f272570fdf9549d6f67493aC250a1DB52F27] = 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
|
||||
}
|
||||
|
||||
@@ -548,10 +545,11 @@ contract CunaFinanceBsc is Initializable, ReentrancyGuardUpgradeable {
|
||||
// Update totalBigStakes directly (subtract old, add new)
|
||||
totalBigStakes = totalBigStakes - userBigStake[users[i]] + amounts[i];
|
||||
|
||||
// Set original stake only if this is the first time (never changes after)
|
||||
if (userOriginalStake[users[i]] == 0) {
|
||||
userOriginalStake[users[i]] = amounts[i];
|
||||
}
|
||||
// Set original stake
|
||||
userOriginalStake[users[i]] = amounts[i];
|
||||
|
||||
// Set last claimed epoch to current epoch
|
||||
userLastClaimedEpoch[users[i]] = currentEpochId;
|
||||
|
||||
// Set user's big stake
|
||||
userBigStake[users[i]] = amounts[i];
|
||||
@@ -750,6 +748,11 @@ contract CunaFinanceBsc is Initializable, ReentrancyGuardUpgradeable {
|
||||
// Transfer payment from buyer to seller (direct transfer)
|
||||
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)
|
||||
userBigStake[seller] -= value;
|
||||
userBigStake[msg.sender] += buyerStake;
|
||||
@@ -825,17 +828,13 @@ contract CunaFinanceBsc is Initializable, ReentrancyGuardUpgradeable {
|
||||
/// @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 {
|
||||
function createVesting(address user, uint256 amount, uint256 bonus, uint256 lockedUntil, address token, uint256 usdAmount, uint256 lastClaimed, uint256 createdAt, uint256 claimedAmount, uint256 claimedBonus) public onlyBot {
|
||||
vestings[user].push(Vesting({
|
||||
amount: amount,
|
||||
bonus: bonus,
|
||||
lockedUntil: lockedUntil,
|
||||
claimedAmount: 0,
|
||||
claimedBonus: 0,
|
||||
claimedAmount: claimedAmount,
|
||||
claimedBonus: claimedBonus,
|
||||
lastClaimed: lastClaimed,
|
||||
createdAt: createdAt,
|
||||
token: token,
|
||||
@@ -844,7 +843,47 @@ contract CunaFinanceBsc is Initializable, ReentrancyGuardUpgradeable {
|
||||
}));
|
||||
|
||||
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
|
||||
|
||||
1327
contracts/CunaFinanceSonic.sol
Normal file
1327
contracts/CunaFinanceSonic.sol
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user