@bananapus/router-terminal-v6 0.0.58 → 0.0.59

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/router-terminal-v6",
3
- "version": "0.0.58",
3
+ "version": "0.0.59",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",
@@ -2,6 +2,7 @@
2
2
  pragma solidity 0.8.28;
3
3
 
4
4
  import {IJBCashOutTerminal} from "@bananapus/core-v6/src/interfaces/IJBCashOutTerminal.sol";
5
+ import {IJBController} from "@bananapus/core-v6/src/interfaces/IJBController.sol";
5
6
  import {IJBDirectory} from "@bananapus/core-v6/src/interfaces/IJBDirectory.sol";
6
7
  import {IJBPermitTerminal} from "@bananapus/core-v6/src/interfaces/IJBPermitTerminal.sol";
7
8
  import {IJBTerminal} from "@bananapus/core-v6/src/interfaces/IJBTerminal.sol";
@@ -1180,6 +1181,8 @@ contract JBRouterTerminal is
1180
1181
  sourceProjectId: sourceProjectId, destProjectId: destProjectId, preferredToken: preferredToken
1181
1182
  });
1182
1183
 
1184
+ _claimRouterCreditsFor({projectId: sourceProjectId});
1185
+
1183
1186
  uint256 cashOutCount = amount;
1184
1187
  uint256 balanceBefore = _balanceOf({token: tokenToReclaim, account: address(this)});
1185
1188
 
@@ -1235,6 +1238,20 @@ contract JBRouterTerminal is
1235
1238
  revert JBRouterTerminal_CashOutLoopLimit({maxIterations: _MAX_CASHOUT_ITERATIONS});
1236
1239
  }
1237
1240
 
1241
+ /// @notice Converts this router's internal project-token credits into ERC-20s before a source cash-out.
1242
+ /// @dev Core burns holder credits before ERC-20 balances. Normalizing first keeps a source cash-out scoped to
1243
+ /// transferable token balances already visible to the router.
1244
+ /// @param projectId The Juicebox project whose tokens are being cashed out.
1245
+ function _claimRouterCreditsFor(uint256 projectId) internal {
1246
+ uint256 creditCount = TOKENS.creditBalanceOf({holder: address(this), projectId: projectId});
1247
+ if (creditCount == 0) return;
1248
+
1249
+ IJBController controller = IJBController(address(DIRECTORY.controllerOf(projectId)));
1250
+ controller.claimTokensFor({
1251
+ holder: address(this), projectId: projectId, tokenCount: creditCount, beneficiary: address(this)
1252
+ });
1253
+ }
1254
+
1238
1255
  /// @notice Convert tokenIn to tokenOut. No-op if same, wrap/unwrap for native/wrapped-native, or swap via Uniswap.
1239
1256
  /// @param tokenIn The token to convert from.
1240
1257
  /// @param tokenOut The token to convert into.