57803 sc insight gas optimize paymentsinfo struct layout to save storage slots and reduce gas costs
Description
Summary
Current Struct Layout (UNOPTIMIZED) — 8 Slots
struct PaymentsInfo {
uint96 slippageBps; // Slot 0: 12 bytes
uint24 swapPoolFees; // Slot 0: + 3 bytes (15 total, 17 wasted)
address swapV3Factory; // Slot 1: 20 bytes (12 wasted)
address swapV3Router; // Slot 2: 20 bytes (12 wasted)
address swapV3Quoter; // Slot 3: 20 bytes (12 wasted)
address wNativeCurrency; // Slot 4: 20 bytes (12 wasted)
address usdc; // Slot 5: 20 bytes (12 wasted)
address long; // Slot 6: 20 bytes (12 wasted)
uint256 maxPriceFeedDelay; // Slot 7: 32 bytes
}Optimized Layout (PROPOSED) — 7 Slots
Gas Savings
Why This Matters
Recommendation
How to Run the POC
Proof of Concept (Test)
References
Previous57453 sc low attackers can drain user allowance provided to the belongcheckin solNext57634 sc medium unauthorized minting of nfts due to signature replay
Was this helpful?