@bananapus/core-v6 0.0.70 → 0.0.71

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bananapus/core-v6",
3
- "version": "0.0.70",
3
+ "version": "0.0.71",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",
@@ -168,12 +168,15 @@ contract JBMultiTerminal is JBPermissioned, ERC2771Context, IJBMultiTerminal {
168
168
  //*********************************************************************//
169
169
 
170
170
  /// @notice Whether this terminal is currently measuring an incoming ERC-20 balance delta.
171
- bool transient _acceptingToken;
171
+ bool internal transient _acceptingToken;
172
172
 
173
173
  /// @notice Source project ID for the same-terminal split pay currently being recorded.
174
174
  /// @dev After `_pay` consumes and clears this value, `_fulfillPayHookSpecificationsFor` reuses the slot to return
175
175
  /// the fee basis to `executePayout`.
176
- uint256 transient _internalSplitPayProjectId;
176
+ uint256 internal transient _internalSplitPayProjectId;
177
+
178
+ /// @notice The in-flight fee amount that can credit `currentReferralProjectId`.
179
+ uint256 internal transient _feeReferralCreditAmount;
177
180
 
178
181
  //*********************************************************************//
179
182
  // -------------------------- constructor ---------------------------- //
@@ -1764,6 +1767,17 @@ contract JBMultiTerminal is JBPermissioned, ERC2771Context, IJBMultiTerminal {
1764
1767
  // Keep a reference to the token amount to forward to the store.
1765
1768
  JBTokenAmount memory tokenAmount = _tokenAmountOf({projectId: projectId, token: token, value: amount});
1766
1769
 
1770
+ // Credit only the one pay call currently being made by `_processFee`. Ordinary split pays to project #1 can
1771
+ // happen while `currentReferralProjectId` is set, but they are not protocol-fee payments. Consume this before
1772
+ // recording the payment so fee-project data hooks cannot reenter and use the in-flight credit.
1773
+ if (
1774
+ projectId == JBConstants.FEE_BENEFICIARY_PROJECT_ID && currentReferralProjectId != 0
1775
+ && _feeReferralCreditAmount != 0
1776
+ ) {
1777
+ delete _feeReferralCreditAmount;
1778
+ STORE.recordFeeReferralCreditOf({referralProjectId: currentReferralProjectId, amount: tokenAmount});
1779
+ }
1780
+
1767
1781
  // Record the payment.
1768
1782
  // Keep a reference to the ruleset the payment is being made during.
1769
1783
  // Keep a reference to the pay hook specifications.
@@ -1772,15 +1786,6 @@ contract JBMultiTerminal is JBPermissioned, ERC2771Context, IJBMultiTerminal {
1772
1786
  payer: payer, amount: tokenAmount, projectId: projectId, beneficiary: beneficiary, metadata: metadata
1773
1787
  });
1774
1788
 
1775
- // Credit the originating fee-paying call's referral project. This is only meaningful when this pay is a
1776
- // protocol-fee payment landing on the fee project AND a referral was set by the outer entry point (or
1777
- // restored from a held fee by `processHeldFeesOf`). The store handles the no-op case when either input is
1778
- // zero. Done here (after `recordPaymentFrom`) instead of inside the store so the credit logic stays in the
1779
- // terminal and the store is never asked to call back into us.
1780
- if (projectId == JBConstants.FEE_BENEFICIARY_PROJECT_ID && currentReferralProjectId != 0) {
1781
- STORE.recordFeeReferralCreditOf({referralProjectId: currentReferralProjectId, amount: tokenAmount});
1782
- }
1783
-
1784
1789
  // Only the value retained in the destination balance needs later cashout fee recovery. Non-feeless pay-hook
1785
1790
  // forwards pay their source-equivalent fee inline before leaving the project.
1786
1791
  if (internalSplitPayProjectId != 0) {
@@ -1862,9 +1867,11 @@ contract JBMultiTerminal is JBPermissioned, ERC2771Context, IJBMultiTerminal {
1862
1867
  )
1863
1868
  internal
1864
1869
  {
1870
+ if (feeTerminal == IJBTerminal(address(this))) _feeReferralCreditAmount = amount;
1865
1871
  try this.executeProcessFee({
1866
1872
  projectId: projectId, token: token, amount: amount, beneficiary: beneficiary, feeTerminal: feeTerminal
1867
1873
  }) {
1874
+ delete _feeReferralCreditAmount;
1868
1875
  emit ProcessFee({
1869
1876
  projectId: projectId,
1870
1877
  token: token,
@@ -1874,6 +1881,7 @@ contract JBMultiTerminal is JBPermissioned, ERC2771Context, IJBMultiTerminal {
1874
1881
  caller: _msgSender()
1875
1882
  });
1876
1883
  } catch (bytes memory reason) {
1884
+ delete _feeReferralCreditAmount;
1877
1885
  // Fee processing is fail-open for project liveness: a broken project #1 terminal or fee route must not
1878
1886
  // trap payouts, cash outs, allowances, held-fee processing, or terminal migration. The fee is forgiven,
1879
1887
  // credited back to the originating project on this terminal, and surfaced through `FeeReverted`.