Hello,
I am trying to add a Charity Tax feature to the SafeMoon contract and I am running into the “Stack Too Deep, Try Removing Local Variables.” error when trying to do this. Basically, I want 1% of the transactions to go into a wallet that will be used to donate to charity for my project. I’ve tried the different solutions I’ve read and I can’t seem to get them to work. Please let me know what I’m doing wrong or what I need to accomplish this. I’m using remix in order to edit and compile.
struct StoresValues {
uint256 rAmount;
uint256 rTransferAmount;
uint256 rFee;
uint256 rCharity;
}
mapping (uint256 => StoresValues) values;
function getStoresValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256, uint256, uint256, uint256) {
(uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity, uint256 tCharity) = _getTValues(tAmount);
(uint256 rTransferAmount, uint256 rLiquidity, uint256 rFee) = _getRValues(tAmount, tFee, tLiquidity, _getRate());
*** (uint256 rAmount, uint256 rCharity) = _getCharityValues(tAmount, tCharity, _getRate()); *** \\ This is the error \\
return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tLiquidity, tCharity);
}
function _getTValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256) {
uint256 tFee = calculateTaxFee(tAmount);
uint256 tLiquidity = calculateLiquidityFee(tAmount);
uint256 tCharity = calculateCharityFee(tAmount);
uint256 tTransferAmount = tAmount.sub(tFee).sub(tLiquidity).sub(tCharity);
return (tTransferAmount, tFee, tLiquidity, tCharity);
}
function _getRValues(uint256 tAmount, uint256 tFee, uint256 tLiquidity, uint256 currentRate) private pure returns (uint256, uint256, uint256) {
uint256 rAmount = tAmount.mul(currentRate);
uint256 rFee = tFee.mul(currentRate);
uint256 rLiquidity = tLiquidity.mul(currentRate);
uint256 rTransferAmount = rAmount.sub(rFee).sub(rLiquidity);
return (rAmount, rTransferAmount, rFee);
}
function _getCharityValues(uint256 rAmount, uint256 tCharity, uint256 currentRate) private pure returns (uint256, uint256) {
uint256 rCharity = tCharity.mul(currentRate);
uint256 rTransferAmount = rAmount.sub(rCharity);
return (rCharity, rTransferAmount);
}