Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions plume/SPIN.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ The contract calculates a user's streak of consecutive daily spins to reward con
| `startSpin()` | User-callable function to initiate a spin by sending the required `spinPrice`. | Public |
| `handleRandomness(...)` | The callback function for the Supra oracle. Processes the spin result and updates user state. | `SUPRA_ROLE` |
| `spendRaffleTickets(...)` | Allows the `Raffle` contract to deduct tickets from a user's balance. | `raffleContract` only |
| `addRaffleTickets(...)` | Allows the admin to add tickets to a user's balance. | `ADMIN_ROLE` |
| `pause()` / `unpause()` | Pauses or unpauses the `startSpin` functionality. | `ADMIN_ROLE` |
| `adminWithdraw(...)` | Allows admin to withdraw PLUME tokens from the contract balance. | `ADMIN_ROLE` |
| `cancelPendingSpin(address user)` | Escape hatch to cancel a user's spin request that is stuck pending an oracle callback. | `ADMIN_ROLE` |
Expand All @@ -145,6 +146,7 @@ The contract calculates a user's streak of consecutive daily spins to reward con
- `SpinRequested(uint256 indexed nonce, address indexed user)`: Emitted when a user successfully initiates a spin.
- `SpinCompleted(address indexed walletAddress, string rewardCategory, uint256 rewardAmount)`: Emitted after the oracle callback is processed, detailing the reward.
- `RaffleTicketsSpent(address indexed walletAddress, uint256 ticketsUsed, uint256 remainingTickets)`: Emitted when the `Raffle` contract spends a user's tickets.
- `RaffleTicketsAdded(address indexed walletAddress, uint256 ticketsAdded, uint256 newBalance)`: Emitted when an admin adds tickets to a user's balance.
- `NotEnoughStreak(string message)`: Emitted if a user meets the odds for a jackpot but does not have the required streak count.
- `JackpotAlreadyClaimed(string message)`: Emitted if a user meets the odds for a jackpot but it has already been won that week.

Expand Down
14 changes: 12 additions & 2 deletions plume/src/spin/Spin.sol
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ contract Spin is
uint256 plumeTokenThreshold; // Range start depends on daily jackpot threshold, ends here.
uint256 raffleTicketThreshold; // Starts after plumeTokenThreshold, ends here.
uint256 ppThreshold; // Starts after raffleTicketThreshold, ends here.
// anything above ppThreshold is "Nothing"
}
// anything above ppThreshold is "Nothing"

// Roles
bytes32 public constant ADMIN_ROLE = keccak256("ADMIN_ROLE");
Expand Down Expand Up @@ -74,6 +74,7 @@ contract Spin is
address indexed walletAddress, string rewardCategory, uint256 rewardAmount, uint256 currentStreak
);
event RaffleTicketsSpent(address indexed walletAddress, uint256 ticketsUsed, uint256 remainingTickets);
event RaffleTicketsAdded(address indexed walletAddress, uint256 ticketsAdded, uint256 newBalance);
event NotEnoughStreak(string message);
event JackpotAlreadyClaimed(string message);

Expand Down Expand Up @@ -132,8 +133,8 @@ contract Spin is
plumeTokenThreshold: 200_000, // Up to 200,000 (Approx 20%)
raffleTicketThreshold: 600_000, // Up to 600,000 (Approx 40%)
ppThreshold: 900_000 // Up to 900,000 (Approx 30%)
// Above 900,000 is "Nothing" (Approx 10%)
});
// Above 900,000 is "Nothing" (Approx 10%)
}

/// @notice Ensures that the user can only spin once per day by checking their last spin date.
Expand Down Expand Up @@ -353,6 +354,15 @@ contract Spin is
emit RaffleTicketsSpent(user, amount, userDataStorage.raffleTicketsBalance);
}

/// @notice Allows the admin to add tickets to a user\'s balance.
function addRaffleTickets(address user, uint256 amount) external onlyRole(ADMIN_ROLE) {
require(user != address(0), "Invalid user address");
UserData storage userDataStorage = userData[user];
userDataStorage.raffleTicketsBalance += amount;
userDataStorage.raffleTicketsGained += amount;
emit RaffleTicketsAdded(user, amount, userDataStorage.raffleTicketsBalance);
}

/// @notice Allows the admin to withdraw PLUME tokens from the contract.
function adminWithdraw(address payable recipient, uint256 amount) external onlyRole(ADMIN_ROLE) {
require(recipient != address(0), "Invalid recipient address");
Expand Down