@rev-net/core-v6 0.0.53 → 0.0.54

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/foundry.toml CHANGED
@@ -1,5 +1,6 @@
1
1
  [profile.default]
2
2
  solc = '0.8.28'
3
+ bytecode_hash = "none"
3
4
  evm_version = 'cancun'
4
5
  via_ir = true
5
6
  optimizer_runs = 200
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rev-net/core-v6",
3
- "version": "0.0.53",
3
+ "version": "0.0.54",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",
package/src/REVOwner.sol CHANGED
@@ -261,12 +261,23 @@ contract REVOwner is IJBRulesetDataHook, IJBCashOutHook, IJBPeerChainAdjustedAcc
261
261
  }
262
262
  }
263
263
 
264
- // Build a context for the buyback hook using the non-fee token count and cross-chain-adjusted values
265
- // so the buyback hook sees the global state for its swap-vs-passthrough routing decision.
264
+ // Build a context for the buyback hook using the non-fee token count and the surplus that
265
+ // produces the LOCALLY-CAPPED direct reclaim. The buyback hook compares this direct reclaim
266
+ // against its pool route to decide noop-vs-swap; passing the global pre-cap surplus would
267
+ // make it score the direct path against an amount the terminal cannot actually deliver,
268
+ // so the hook would skip pools that would have paid more than the final local reclaim.
269
+ // `cashOutFrom` is linear in surplus, so scaling the surplus by the same factor that
270
+ // scaled the reclaim recovers the locally-capped reclaim at the same cashOutCount/
271
+ // totalSupply/tax inputs.
272
+ uint256 buybackSurplus = effectiveSurplusValue;
273
+ if (postFeeReclaimedAmount != unscaledReclaim && unscaledReclaim != 0) {
274
+ buybackSurplus = mulDiv({x: effectiveSurplusValue, y: postFeeReclaimedAmount, denominator: unscaledReclaim});
275
+ }
276
+
266
277
  JBBeforeCashOutRecordedContext memory buybackHookContext = context;
267
278
  buybackHookContext.cashOutCount = nonFeeCashOutCount;
268
279
  buybackHookContext.totalSupply = totalSupply;
269
- buybackHookContext.surplus.value = effectiveSurplusValue;
280
+ buybackHookContext.surplus.value = buybackSurplus;
270
281
 
271
282
  // Let the buyback hook adjust the cash out parameters and optionally return a hook specification.
272
283
  JBCashOutHookSpecification[] memory buybackHookSpecifications;