Skip to content

Add YieldAggregator per-strategy allocation caps#5132

Closed
xyjk0511 wants to merge 1 commit into
ClankerNation:mainfrom
xyjk0511:codex/issue-134-yield-allocation-caps
Closed

Add YieldAggregator per-strategy allocation caps#5132
xyjk0511 wants to merge 1 commit into
ClankerNation:mainfrom
xyjk0511:codex/issue-134-yield-allocation-caps

Conversation

@xyjk0511
Copy link
Copy Markdown

/claim #134
💳 Payment: PayPal | buchanliang@gmail.com | PayPal

Summary

  • Adds maxAllocationBps per strategy and a 10,000 bps cap base.
  • Rejects zero strategy targets and caps above 100%.
  • Splits deposited vault idle assets across active strategies without exceeding their caps.
  • Prevents owner allocate() calls that would push a strategy above its cap.
  • Adds rebalance() to move available idle vault balance into under-cap strategies, plus currentAllocation() / maxAllocation() helpers.
  • Adds contributor traceability metadata without embedding private pre-session instructions.

Verification

  • npx hardhat test --config .\.codex-yieldaggregator-hardhat.config.js test\YieldAggregatorAllocation.test.js -> 4 passing
  • npx solcjs --bin --abi contracts\vault\YieldAggregator.sol -o .codex-yieldaggregator-solc --base-path . --include-path node_modules -> passed
  • node --check test\YieldAggregatorAllocation.test.js -> passed
  • node --check .codex-yieldaggregator-hardhat.config.js -> passed
  • node -e "JSON.parse(require('fs').readFileSync('CONTRIBUTORS.json','utf8')); console.log('CONTRIBUTORS.json ok')" -> passed
  • git diff --check -> passed

Scope note

  • This repository's current strategy abstraction only transfers assets to strategy targets and has no strategy withdrawal interface. rebalance() therefore redistributes available idle vault balance into under-cap strategies and does not claim to pull already-transferred funds back from strategy contracts.

Known baseline issue

  • npm test is still blocked by the repository's existing HH606 compiler mismatch: hardhat.config.js configures Solidity 0.8.20 while current OpenZeppelin dependencies pulled by contracts/vault/YieldAggregator.sol and contracts/governance/GovernorAlpha.sol require ^0.8.24.

YieldAggregator now stores per-strategy max allocation bps, auto-splits deposited idle assets under those caps, prevents manual over-allocation, and exposes rebalance/current allocation helpers.

Constraint: OpenAgents issue ClankerNation#134 requires contributor metadata while private platform instructions must not be embedded in repository files.

Rejected: Only documenting diversification expectations | leaves allocate() able to move all assets to one strategy.

Confidence: medium

Scope-risk: moderate

Directive: Do not claim strategy withdrawals are supported until a strategy withdraw interface exists; this change redistributes vault idle assets under caps.

Tested: npx hardhat test --config .\.codex-yieldaggregator-hardhat.config.js test\YieldAggregatorAllocation.test.js; npx solcjs --bin --abi contracts\vault\YieldAggregator.sol -o .codex-yieldaggregator-solc --base-path . --include-path node_modules; node --check test\YieldAggregatorAllocation.test.js; node --check .codex-yieldaggregator-hardhat.config.js; node -e JSON.parse CONTRIBUTORS.json; git diff --check

Not-tested: npm test is blocked by existing HH606 compiler mismatch in YieldAggregator/GovernorAlpha dependencies requiring ^0.8.24 while hardhat.config.js uses 0.8.20.
@github-actions
Copy link
Copy Markdown

Unfortunately the changes in this PR didn't fully resolve the issue. Please rework your solution and submit a new pull request within 2 hours.

Make sure to review the acceptance criteria in the linked issue and verify all conditions are met before resubmitting.

@github-actions github-actions Bot closed this May 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant