Skip to content

Commit

Permalink
chore: fix stack too deep compile error
Browse files Browse the repository at this point in the history
  • Loading branch information
mixplore committed Nov 12, 2024
1 parent f3343ba commit 1ea19ff
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 11 deletions.
30 changes: 19 additions & 11 deletions contracts/modules/viewer/NexusViewer.sol
Original file line number Diff line number Diff line change
Expand Up @@ -40,22 +40,30 @@ contract NexusViewer is INexusViewer, Multicall {

// Assessment
IAssessmentViewer.AssessmentRewards memory assessmentRewards = assessmentViewer.getRewards(member);
(uint assessmentStake, IAssessmentViewer.AssessmentStakeLockedState memory stakeLockedState) = _getAssessmentStake(member);
uint assessmentStakeValue = 0;
// Workaround for stack too deep error
{
(uint assessmentStake, IAssessmentViewer.AssessmentStakeLockedState memory stakeLockedState) = _getAssessmentStake(member);
assessmentStakeValue = stakeLockedState.isStakeLocked ? 0 : assessmentStake;
}

// Staking Pool
IStakingViewer.AggregatedTokens memory aggregatedTokens = stakingViewer.getAggregatedTokens(tokenIds);
uint managerTotalRewards = stakingViewer.getManagerTotalRewards(member);

IStakingViewer.TokenPoolMap[] memory tokenPools = stakingViewer.getStakingPoolsOf(tokenIds);
uint poolManagerNXMLockedForMV = 0;
// for each token, get the pool and manager
for (uint i = 0; i < tokenPools.length; i++) {
IStakingViewer.Pool memory pool = stakingViewer.getPool(tokenPools[i].poolId);
// check if pool manager is locked for MV
uint lockedForMV = nxm.isLockedForMV(pool.manager);
// get the latest date locked for MV
if (lockedForMV > 0 && lockedForMV > poolManagerNXMLockedForMV) {
poolManagerNXMLockedForMV = lockedForMV;
// Workaround for stack too deep error
{
IStakingViewer.TokenPoolMap[] memory tokenPools = stakingViewer.getStakingPoolsOf(tokenIds);
// for each token, get the pool and manager
for (uint i = 0; i < tokenPools.length; i++) {
IStakingViewer.Pool memory pool = stakingViewer.getPool(tokenPools[i].poolId);
// check if pool manager is locked for MV
uint lockedForMV = nxm.isLockedForMV(pool.manager);
// get the latest date locked for MV
if (lockedForMV > 0 && lockedForMV > poolManagerNXMLockedForMV) {
poolManagerNXMLockedForMV = lockedForMV;
}
}
}

Expand All @@ -68,7 +76,7 @@ contract NexusViewer is INexusViewer, Multicall {
return ClaimableNXM({
governanceRewards: governanceRewards,
assessmentRewards: assessmentRewards.withdrawableAmountInNXM,
assessmentStake: stakeLockedState.isStakeLocked ? 0 : assessmentStake,
assessmentStake: assessmentStakeValue,
stakingPoolTotalRewards: aggregatedTokens.totalRewards,
stakingPoolTotalExpiredStake: aggregatedTokens.totalExpiredStake,
stakingPoolManagerIsNXMLockedForMV: poolManagerNXMLockedForMV,
Expand Down
1 change: 1 addition & 0 deletions scripts/deploy/assessment-and-nexus-viewer-deploy.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const main = async () => {

console.log('AssessmentViewer implementation address:', assessmentViewerImplementation.address);
console.log('NexusViewer implementation address:', nexusViewerImplementation.address);
console.log('NexusViewer ABI', nexusViewerImplementation.interface.format(ethers.utils.FormatTypes.json));
};
main()
.then(() => process.exit(0))
Expand Down

0 comments on commit 1ea19ff

Please sign in to comment.