Problem:
The core logic currently triggers "Stack Too Deep" compiler warnings. This is caused by high function arity and excessive local variables, forcing the Solidity compiler to perform inefficient stack manipulations that increase gas costs.
Objective:
My aim is to optimize the contract's gas efficiency by refactoring the variable management and function architecture.
I would like to submit a Pull Request (PR) to implement these optimizations. Please let me know if you would like me to proceed with these refactors to improve the protocol's gas profile and maintainability.