Feat/p3 fee router#51
Open
robertocarlous wants to merge 6 commits into
Open
Conversation
Collaborator
Author
|
Hi @umeradl Pls can you review this, Thank you |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
P3 fees & treasury — implementation summary (#43)
What was built
New contracts
DinTreasury.sol— upgradeable custodial contract that holds ETH and ERC20 tokens on behalf of the protocol. Receives ETH viareceive(), supports partial-amountwithdrawETHandwithdrawERC20(SafeERC20). Owner-controlled, reentrancy-guarded,__gap[50].DinFeeRouter.sol— single router that splits incoming fees across five named buckets in basis points, summing to 10 000. Handles two assets independently:DinSplit { validatorPoolBps, treasuryBps, burnBps, storageBps, publicGoodsBps }. Pulls DIN viatransferFrom, burns the burn slice, transfers the treasury slice toDinTreasury, and accrues the rest into on-contract mappings (accruedDin) for future settlement.EthSplit { validatorPoolBps, treasuryBps, storageBps, publicGoodsBps }. No burn field — ETH burn is impossible by design (compile-time, not a runtime check). Forwards the treasury slice toDinTreasury, accrues the rest intoaccruedEth.storageBpsandpublicGoodsBpsreserved at 0 (RES-1 / public-goods slot).treasuryBpsCeiling), DAO-settable downward.onlyFeeSourceallowlist — only registered contracts (addFeeSource/removeFeeSource) can call routing functions.Modified contracts
DinToken.sol— addedburn(uint256 amount)(self-burn, no role required) andTokensBurnedevent. Required byDinFeeRouterto execute the burn slice of DIN fees.DinCoordinator.sol—withdraw()now sends the contract's full ETH balance to the configuredtreasuryaddress instead ofowner(). NewsetTreasury(address)setter andTreasuryNotSetguard. ETH continues to accumulate in the coordinator on everydepositAndMintcall (no per-deposit forwarding). One new storage slot;__gapreduced from[50]→[49].DINModelRegistry.sol— parallel DIN fee rail added alongside the existing ETH rail:requestModelRegistrationDIN(bytes32, address, address, bool)— same slasher/ownership validation as the ETH path; fee pulled from caller viafeeRouter.routeFeeDIN; flagsmodelRequestPaidInDIN[requestId] = true.requestManifestUpdateDIN(uint256, bytes32)— same pattern for manifest updates; flagsmanifestRequestPaidInDIN[reqId] = true.requestModelRegistration/requestManifestUpdate) — unchanged signatures, now routesmsg.valuethroughfeeRouter.routeFeeETHwhen a router is wired; falls back to the existingwithdrawFees()balance when it is not (backward-compatible).dinToken,feeRouter, four DIN fee amounts (openSourceFeeDIN,proprietaryFeeDIN,openSourceUpdateFeeDIN,proprietaryUpdateFeeDIN), two payment-flag mappings.__gapreduced from[50]→[42].Deploy script & fixtures
DeployPlatform.s.sol— updated to the 13-step wiring order: deploy treasury → token → coordinator → wire token → set treasury on coordinator → deploy fee router → deploy stake → wire stake → deploy registry → set DIN token on registry → set fee router on registry → add registry as fee source → set DIN fees.DeployPlatform.t.sol—_deployPlatform()rewritten to the same 13-step order; newProxyWiringTestassertions for every new wired address; newReInitializerProtectionTestentries forDinTreasuryandDinFeeRouter.SecurityFindings.t.sol—_deployPlatform()split into four private helpers to stay under the Yul stack-depth limit while incorporating the new wiring.UpgradeValidation.t.sol— extended withtest_validateImplementation_DinTreasuryandtest_validateImplementation_DinFeeRouter.Test coverage
File | Tests -- | -- DinTreasury.t.sol | 11 DinFeeRouter.t.sol | 21 (incl. split-sum fuzz + no-ETH-burn invariant) DinToken.t.sol | 6 DinCoordinator.t.sol | 7 DINModelRegistry.t.sol | 11 Total | 56 new · 109 suite total · 0 failed