Skip to content

feat: PIP-12 Community Treasury Wallet and Capital Operations#30

Merged
nihen merged 1 commit into
mainfrom
feature/pip-12-treasury-wallet
Apr 17, 2026
Merged

feat: PIP-12 Community Treasury Wallet and Capital Operations#30
nihen merged 1 commit into
mainfrom
feature/pip-12-treasury-wallet

Conversation

@nihen
Copy link
Copy Markdown
Contributor

@nihen nihen commented Mar 13, 2026

Summary

  • PCECommunityToken: Add treasury wallet storage, RATE_MANAGER_ROLE with lightweight role system, initializeTreasury, setTreasuryWallet, increaseTokenValue, splitToken, grantRateManagerRole, revokeRateManagerRole, and hasRole functions
  • PCEToken: Add addReserve function that manages PCE reserves and adjusts exchangeRate via Math.mulDiv
  • Tests: 6 new test cases covering treasury initialization, token value increase/split with exchange rate verification, unauthorized access, and role management
  • Version: Both contracts updated to 1.0.13
  • PIP Specification: PIP-12: Community Treasury Wallet and Capital Operations PIPs#7
  • Tally Proposal: https://www.tally.xyz/gov/pce-dao/draft/2811448980645349015

⚠️ Rework Required

This implementation predates the current PIP-12 spec and needs significant rework:

  • addReserve() must use transferFrom (currently uses internal _transfer — allows moving PCE without approval)
  • splitToken() must be implemented with rebase factor mechanism (no PCE withdrawal)
  • All function/event/role names need renaming to match current spec
  • See PR comment for full rework checklist

Changed Files

File Changes
src/PCECommunityToken.sol Treasury wallet storage, role system, token value operations, events
src/PCEToken.sol addReserve function (needs transferFrom fix)
test/PCE.t.sol Test cases, version test updated

Test plan

  • forge build succeeds
  • forge test -- all tests pass
  • Rework to match current PIP-12 spec (see PR comment)
  • Verify storage layout compatibility with deployed proxies before upgrade

日本語版(参考)

概要

PIP-12 (コミュニティ・トレジャリーウォレットとトークン価値操作) の実装。

PCECommunityToken.sol:

  • ストレージ追加: treasuryWallet, RATE_MANAGER_ROLE, _roles, rebaseFactor
  • 新関数: initializeTreasury, setTreasuryWallet, increaseTokenValue, splitToken
  • ロール関数: hasRole, grantRateManagerRole, revokeRateManagerRole

PCEToken.sol:

  • 新関数: addReserve (PCE準備金管理と exchangeRate 調整)

バージョン: 両コントラクトを "1.0.13" に更新

⚠️ 要修正

現在の実装はPIP-12仕様改訂前のものであり、大幅な修正が必要。詳細はPRコメント参照。

🤖 Generated with Claude Code

@nihen
Copy link
Copy Markdown
Contributor Author

nihen commented Mar 27, 2026

Rework checklist (PIP-12 spec updated 2026-03-27)

1. addReserve() must use transferFrom

  • Current: _transfer(_treasuryWallet, address(this), pceAmount) — moves PCE without approval
  • Required: transferFrom so treasury wallet must approve first

2. Implement splitToken() with rebase factor

  • Remove removeCapital() from PCEToken
  • splitToken(uint256 mintAmount) adjusts rebaseFactor to distribute new tokens proportionally
  • No PCE leaves the system (prevents daily swap limit bypass)
  • New storage: uint256 public rebaseFactor (initialized to INITIAL_FACTOR)
  • Display balance: rawBalance * INITIAL_FACTOR / getCurrentFactor() * rebaseFactor / INITIAL_FACTOR

3. Full rename

Old New
capitalIncrease increaseTokenValue
capitalDecrease splitToken
TREASURY_MANAGER_ROLE RATE_MANAGER_ROLE
grantTreasuryManagerRole grantRateManagerRole
revokeTreasuryManagerRole revokeRateManagerRole
addCapital addReserve
removeCapital (remove)
CapitalIncreased TokenValueIncreased
CapitalDecreased TokenSplit
TreasuryManagerRoleGranted RateManagerRoleGranted
TreasuryManagerRoleRevoked RateManagerRoleRevoked

4. Add tests

  • addReserve reverts without prior approve
  • addReserve cannot pull from arbitrary third-party addresses
  • splitToken increases all holders' display balances proportionally
  • splitToken preserves proportional ownership
  • splitToken does not change depositedPCEToken

@nihen nihen force-pushed the feature/pip-12-treasury-wallet branch from 70dfb3b to 5b926fe Compare April 17, 2026 05:45
Add treasury wallet mechanism with two operations on PCECommunityToken:
- increaseTokenValue: add PCE reserves to raise exchange rate
- splitToken: mint tokens proportionally via rebaseFactor-based stock split

New functions on PCECommunityToken:
- initializeTreasury, setTreasuryWallet
- increaseTokenValue (calls PCEToken.addReserve)
- splitToken (calls PCEToken.adjustExchangeRate, adjusts rebaseFactor)
- grantRateManagerRole, revokeRateManagerRole, hasRole

New functions on PCEToken:
- addReserve: transfer PCE from treasury, adjust exchange rate
- adjustExchangeRate: update rate without moving PCE (used by splitToken)

Bump PCECommunityToken to v1.0.14.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@nihen nihen force-pushed the feature/pip-12-treasury-wallet branch from 5b926fe to f764a6b Compare April 17, 2026 05:51
@nihen nihen merged commit d9e6031 into main Apr 17, 2026
@nihen nihen deleted the feature/pip-12-treasury-wallet branch April 17, 2026 05:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant