Good day y'all, i'm tying to write a contract which is supposed to interact with another one that has a big struct that i need to retrieve to do some calculation, the struct have 14 properties and it look like this:
mapping(uint256 => Round) public rounds;
struct Round {
uint256 epoch;
uint256 startTimestamp;
uint256 lockTimestamp;
uint256 closeTimestamp;
int256 lockPrice;
int256 closePrice;
uint256 lockOracleId;
uint256 closeOracleId;
uint256 totalAmount;
uint256 bullAmount;
uint256 bearAmount;
uint256 rewardBaseCalAmount;
uint256 rewardAmount;
bool oracleCalled;
}
Trying to simply get this struct and return the struct throws stack too deep error:
function getRound(address contractAddress, uint256 epoch) private view returns (Round memory round) {
(
,,,,,
round.closePrice,
,,
round.totalAmount,
round.bullAmount,
round.bearAmount,
,
round.rewardAmount,
round.oracleCalled
) = IContractInterface(contractAddress).rounds(epoch);
I'm not understanding the problem here, i know about the 16 variable limit and i tried to hardcode "contractAddress" and "epoch" to try only retrieving the 14 variables of the struct + 1 variable for the Round struct but still i'm receiving this error
CompilerError: Stack too deep. Try compiling with
--via-ir
(cli) or the equivalentviaIR: true
(standard JSON) while enabling the optimizer. Otherwise, try removing local variables. When compiling inline assembly: Variable dataEnd is 2 slot(s) too deep inside the stack. Stack too deep. Try compiling with--via-ir
(cli) or the equivalentviaIR: true
(standard JSON) while enabling the optimizer. Otherwise, try removing local variables.
Can you help me out understanding what i'm doing wrong? Thanks!