File: contracts/JBSingleTokenPaymentTerminalStore.sol   #1

372       // Add the amount to the token balance of the project.
373       balanceOf[IJBSingleTokenPaymentTerminal(msg.sender)][_projectId] =
374         balanceOf[IJBSingleTokenPaymentTerminal(msg.sender)][_projectId] +
375         _amount.value;
File: contracts/JBSingleTokenPaymentTerminalStore.sol   #2

597       // Removed the distributed funds from the project's token balance.
598       balanceOf[IJBSingleTokenPaymentTerminal(msg.sender)][_projectId] =
599         balanceOf[IJBSingleTokenPaymentTerminal(msg.sender)][_projectId] -
600         distributedAmount;
File: contracts/abstract/JBPayoutRedemptionPaymentTerminal.sol   #3

817       (JBFundingCycle memory _fundingCycle, uint256 _distributedAmount) = store.recordDistributionFor(
818         _projectId,
819         _amount,
820         _currency
821       );
822   
823       // The amount being distributed must be at least as much as was expected.
824       if (_distributedAmount < _minReturnedTokens) revert INADEQUATE_DISTRIBUTION_AMOUNT();
825   
826       // Get a reference to the project owner, which will receive tokens from paying the platform fee
827       // and receive any extra distributable funds not allocated to payout splits.
828       address payable _projectOwner = payable(projects.ownerOf(_projectId));
829   
830       // Define variables that will be needed outside the scoped section below.
831       // Keep a reference to the fee amount that was paid.
832       uint256 _fee;
833   
834       // Scoped section prevents stack too deep. `_feeDiscount`, `_feeEligibleDistributionAmount`, and `_leftoverDistributionAmount` only used within scope.
835       {
836         // Get the amount of discount that should be applied to any fees taken.
837         // If the fee is zero or if the fee is being used by an address that doesn't incur fees, set the discount to 100% for convinience.
838         uint256 _feeDiscount = fee == 0 || isFeelessAddress[msg.sender]
839           ? JBConstants.MAX_FEE_DISCOUNT
840           : _currentFeeDiscount(_projectId);
841   
842         // The amount distributed that is eligible for incurring fees.
843         uint256 _feeEligibleDistributionAmount;
844   
845         // The amount leftover after distributing to the splits.
846         uint256 _leftoverDistributionAmount;
847   
848         // Payout to splits and get a reference to the leftover transfer amount after all splits have been paid.
849         // Also get a reference to the amount that was distributed to splits from which fees should be taken.
850         (_leftoverDistributionAmount, _feeEligibleDistributionAmount) = _distributeToPayoutSplitsOf(
851           _projectId,
852           _fundingCycle.configuration,
853           payoutSplitsGroup,
854           _distributedAmount,
855           _feeDiscount
856         );
File: contracts/abstract/JBPayoutRedemptionPaymentTerminal.sol   #4

332     function pay(
333       uint256 _projectId,
334       uint256 _amount,
335       address _token,
336       address _beneficiary,
337       uint256 _minReturnedTokens,
338       bool _preferClaimedTokens,
339       string calldata _memo,
340       bytes calldata _metadata
341     ) external payable virtual override isTerminalOf(_projectId) returns (uint256) {
342       _token; // Prevents unused var compiler and natspec complaints.
343   
344       // ETH shouldn't be sent if this terminal's token isn't ETH.
345       if (token != JBTokens.ETH) {
346         if (msg.value > 0) revert NO_MSG_VALUE_ALLOWED();
347   
348         // Transfer tokens to this terminal from the msg sender.
349         _transferFrom(msg.sender, payable(address(this)), _amount);
350       }
351       // If this terminal's token is ETH, override _amount with msg.value.
352       else _amount = msg.value;
353   
354       return
355         _pay(
356           _amount,
357           msg.sender,
358           _projectId,
359           _beneficiary,
360           _minReturnedTokens,
361           _preferClaimedTokens,
362           _memo,
363           _metadata
364         );
365     }
File: contracts/abstract/JBPayoutRedemptionPaymentTerminal.sol   #5

540     function addToBalanceOf(
541       uint256 _projectId,
542       uint256 _amount,
543       address _token,
544       string calldata _memo,
545       bytes calldata _metadata
546     ) external payable virtual override isTerminalOf(_projectId) {
547       _token; // Prevents unused var compiler and natspec complaints.
548   
549       // If this terminal's token isn't ETH, make sure no msg.value was sent, then transfer the tokens in from msg.sender.
550       if (token != JBTokens.ETH) {
551         // Amount must be greater than 0.
552         if (msg.value > 0) revert NO_MSG_VALUE_ALLOWED();
553   
554         // Transfer tokens to this terminal from the msg sender.
555         _transferFrom(msg.sender, payable(address(this)), _amount);
556       }
557       // If the terminal's token is ETH, override `_amount` with msg.value.
558       else _amount = msg.value;
559   
560       // Add to balance while only refunding held fees if the funds aren't originating from a feeless terminal.
561       _addToBalanceOf(_projectId, _amount, !isFeelessAddress[msg.sender], _memo, _metadata);
562     }
