You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It imports "./oz/SafeMath.sol" but already ./Moloch.sol imports "./oz/SafeMath.sol" too.
So maybe imports somehow need to deal with this situation and not import it twice.
Would be cool to analyze this situation to see what can be done about it.
Here's the source code with imports from the gist (it only compiles if you remove second and third import statments)
// Pool.sol// - mints a pool share when someone donates tokens// - syncs with Moloch proposal queue to mint shares for grantees// - allows donors to withdraw tokens at any timepragmasolidity0.5.3;import"https://gist.githubusercontent.com/ninabreznik/7ac01549fdd415e02af745c1763181fa/raw/033dec615c6ec962e433a1cd341e6d2d1d6f81fa/Moloch";import"https://gist.githubusercontent.com/ninabreznik/a66bdae5fa18c7618b445b24fe97cce0/raw/f4df88ce6d58d959b854188a6a2daa49ba641e4f/SafeMath";import"https://gist.githubusercontent.com/ninabreznik/765408b436e6d354da74a1a4c32d4aff/raw/2826f04d23a436d273e4134b351c40507ba8e62c/IERC20";contractMolochPool{usingSafeMathforuint256;eventSync(uint256currentProposalIndex);eventDeposit(uint256tokenAmount,addressdonor);eventWithdraw(uint256sharesToBurn,addressdonor);eventKeeperWithdraw(uint256sharesToBurn,addressdonor,addresskeeper);eventAddKeepers(address[]addedKeepers);eventRemoveKeepers(address[]removedKeepers);eventSharesMinted(uint256sharesToMint,addressrecipient,uint256totalPoolShares);eventSharesBurned(uint256sharesToBurn,addressrecipient,uint256totalPoolShares);uint256publictotalPoolShares=0;// the total shares outstanding of the pooluint256publiccurrentProposalIndex=0;// the moloch proposal index that this pool has been synced toMolochpublicmoloch;// moloch contract referenceIERC20publicapprovedToken;// approved token contract reference (copied from moloch contract)boollocked;// prevent re-entrancyuint256constantMAX_NUMBER_OF_SHARES=10**30;// maximum number of shares that can be mintedstructDonor{uint256shares;mapping(address=>bool)keepers;}// the amount of shares each pool shareholder hasmapping(address=>Donor)publicdonors;modifieractive{require(totalPoolShares>0,"MolochPool: Not active");_;}modifiernoReentrancy(){require(!locked,"MolochPool: Reentrant call");locked=true;_;locked=false;}constructor(address_moloch)public{moloch=Moloch(_moloch);approvedToken=IERC20(moloch.approvedToken());}functionactivate(uint256initialTokens,uint256initialPoolShares)publicnoReentrancy{require(totalPoolShares==0,"MolochPool: Already active");require(approvedToken.transferFrom(msg.sender,address(this),initialTokens),"MolochPool: Initial tokens transfer failed");_mintSharesForAddress(initialPoolShares,msg.sender);}// updates Pool state based on Moloch proposal queue// - we only want to mint shares for grants, which are 0 tribute// - mints pool shares to applicants based on sharesRequested / maxTotalSharesAtYesVote// - use maxTotalSharesAtYesVote because:// - cant read shares at the time of proposal processing (womp womp)// - should be close enough if grant shares are small relative to total shares, which they should be// - protects pool contributors if many Moloch members ragequit before the proposal is processed by reducing follow on funding// - e.g. if 50% of Moloch shares ragequit after someone voted yes, the grant proposal would get 50% less follow-on from the poolfunctionsync(uint256toIndex)publicactivenoReentrancy{require(toIndex<=moloch.getProposalQueueLength(),"MolochPool: Proposal index too high");// declare proposal paramsaddressapplicant;uint256sharesRequested;boolprocessed;booldidPass;boolaborted;uint256tokenTribute;uint256maxTotalSharesAtYesVote;uint256i=currentProposalIndex;while(i<toIndex){(, applicant, sharesRequested,,,, processed, didPass, aborted, tokenTribute,, maxTotalSharesAtYesVote)=moloch.proposalQueue(i);if(!processed){break;}// passing grant proposal, mint pool shares proportionally on behalf of the applicantif(!aborted&&didPass&&tokenTribute==0&&sharesRequested>0){// This can't revert:// 1. maxTotalSharesAtYesVote > 0, otherwise nobody could have voted.// 2. sharesRequested is <= 10**18 (see Moloch.sol:172), and// totalPoolShares <= 10**30, so multiplying them is <= 10**48 and < 2**160uint256sharesToMint=totalPoolShares.mul(sharesRequested).div(maxTotalSharesAtYesVote);// for a passing proposal, maxTotalSharesAtYesVote is > 0_mintSharesForAddress(sharesToMint,applicant);}i++;}currentProposalIndex=i;emitSync(currentProposalIndex);}// add tokens to the pool, mint new shares proportionallyfunctiondeposit(uint256tokenAmount)publicactivenoReentrancy{uint256sharesToMint=totalPoolShares.mul(tokenAmount).div(approvedToken.balanceOf(address(this)));require(approvedToken.transferFrom(msg.sender,address(this),tokenAmount),"MolochPool: Deposit transfer failed");_mintSharesForAddress(sharesToMint,msg.sender);emitDeposit(tokenAmount,msg.sender);}// burn shares to proportionally withdraw tokens in poolfunctionwithdraw(uint256sharesToBurn)publicactivenoReentrancy{_withdraw(msg.sender,sharesToBurn);emitWithdraw(sharesToBurn,msg.sender);}// keeper burns shares to withdraw on behalf of the donorfunctionkeeperWithdraw(uint256sharesToBurn,addressrecipient)publicactivenoReentrancy{require(donors[recipient].keepers[msg.sender],"MolochPool: Sender is not a keeper");_withdraw(recipient,sharesToBurn);emitKeeperWithdraw(sharesToBurn,recipient,msg.sender);}functionaddKeepers(address[]calldatanewKeepers)externalactivenoReentrancy{Donorstorage donor =donors[msg.sender];for(uint256i=0;i<newKeepers.length;i++){donor.keepers[newKeepers[i]]=true;}emitAddKeepers(newKeepers);}functionremoveKeepers(address[]calldatakeepersToRemove)externalactivenoReentrancy{Donorstorage donor =donors[msg.sender];for(uint256i=0;i<keepersToRemove.length;i++){donor.keepers[keepersToRemove[i]]=false;}emitRemoveKeepers(keepersToRemove);}function_mintSharesForAddress(uint256sharesToMint,addressrecipient)internal{totalPoolShares=totalPoolShares.add(sharesToMint);donors[recipient].shares=donors[recipient].shares.add(sharesToMint);require(totalPoolShares<=MAX_NUMBER_OF_SHARES,"MolochPool: Max number of shares exceeded");emitSharesMinted(sharesToMint,recipient,totalPoolShares);}function_withdraw(addressrecipient,uint256sharesToBurn)internal{Donorstoragedonor=donors[recipient];require(donor.shares>=sharesToBurn,"MolochPool: Not enough shares to burn");uint256tokensToWithdraw=approvedToken.balanceOf(address(this)).mul(sharesToBurn).div(totalPoolShares);totalPoolShares=totalPoolShares.sub(sharesToBurn);donor.shares=donor.shares.sub(sharesToBurn);require(approvedToken.transfer(recipient,tokensToWithdraw),"MolochPool: Withdrawal transfer failed");emitSharesBurned(sharesToBurn,recipient,totalPoolShares);}}
The text was updated successfully, but these errors were encountered:
@todo
one more thing:
It imports
"./oz/SafeMath.sol"
but already./Moloch.sol
imports"./oz/SafeMath.sol"
too.So maybe imports somehow need to deal with this situation and not import it twice.
Would be cool to analyze this situation to see what can be done about it.
Here's the source code with imports from the gist (it only compiles if you remove second and third import statments)
The text was updated successfully, but these errors were encountered: