-
Notifications
You must be signed in to change notification settings - Fork 0
[Contract] Royalty reduction, remove sunset, struct optimization (#38 Group A) #41
Copy link
Copy link
Closed
Labels
agent/T3Assigned to T3 builder agentAssigned to T3 builder agentenhancementNew feature or requestNew feature or request
Description
Summary
Group A of #38. Three tightly coupled changes to StoryFactory.sol — royalty rate, sunset removal, and struct packing. These must be done together because struct layout changes affect all three.
Parent issue: #38
Changes
1. Reduce Mint/Burn Royalty: 5% → 1%
// Before
uint16 public constant MINT_ROYALTY = 500;
uint16 public constant BURN_ROYALTY = 500;
// After
uint16 public constant MINT_ROYALTY = 100;
uint16 public constant BURN_ROYALTY = 100;2. Remove sunset Variable — Derive from lastPlotTime
- Remove
bool sunsetfrom Storyline struct - Remove
require(!s.sunset, "Storyline sunset")fromchainPlot() - The deadline check already handles this:
require(block.timestamp <= s.lastPlotTime + 168 hours, "Deadline passed") - Add view function:
function hasSunset(uint256 storylineId) external view returns (bool) { Storyline storage s = storylines[storylineId]; return s.hasDeadline && block.timestamp > s.lastPlotTime + 168 hours; }
3. Struct Storage Optimization (5 slots → 2 slots)
struct Storyline {
address writer; // slot 1: 160 bits
address token; // slot 2: 160 bits
uint24 plotCount; // slot 2: +24 = 184 bits (max 16.7M plots)
uint40 lastPlotTime; // slot 2: +40 = 224 bits (max year 36,812)
bool hasDeadline; // slot 2: +8 = 232 bits
}Update all references:
plotCount:uint256→uint24lastPlotTime:uint256→uint40- Cast
block.timestamptouint40when assigning plotIndexin events can remainuint256
Tests
- Update existing unit tests for removed
sunsetfield - Add test for
hasSunset()view function - Update royalty-related assertions if any exist
- Log gas comparison: before/after struct optimization
-
forge testpasses
Branch
task/{issue-number}-royalty-struct-sunset
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
agent/T3Assigned to T3 builder agentAssigned to T3 builder agentenhancementNew feature or requestNew feature or request