Implement native coin fee mechanism#52
Conversation
| mapping(address => uint256) claimedRewardsPerAccount; | ||
| } | ||
|
|
||
| struct Storage { |
There was a problem hiding this comment.
No need for two structs for FeeDistributor
| bytes32 constant STORAGE_POSITION = keccak256("fee.distributor.storage"); | ||
|
|
||
| /// @notice Accumulates fees distributed among validators | ||
| struct FeeCalculator { |
| view | ||
| override | ||
| returns ( | ||
| uint256 feesAccrued, |
There was a problem hiding this comment.
no need for named returns, we don't use them
| LibDiamond.enforceIsContractOwner(); | ||
|
|
||
| if (_status) { | ||
| for (uint256 i = 0; i < LibRouter.nativeTokensCount(); i++) { |
There was a problem hiding this comment.
move LibRouter.nativeTokensCount() outside of for loop
move i++ inside unchecked block
| @@ -0,0 +1,24 @@ | |||
| // SPDX-License-Identifier: MIT | |||
| pragma solidity 0.8.3; | |||
There was a problem hiding this comment.
Lets add IGovernanceV3.sol. With a spec doc explaining why it exists, I think for clarity is better to not have GovernanceFacetV3 implement IGovernanceV2.
| @@ -0,0 +1,60 @@ | |||
| // SPDX-License-Identifier: MIT | |||
| pragma solidity 0.8.3; | |||
There was a problem hiding this comment.
Can we use current convention for facet versioning: GovernanceV3Facet
| return claimableAmount; | ||
| } | ||
|
|
||
| /// @notice Records an incoming fees into the accumulator |
There was a problem hiding this comment.
It's not recording into the accumulator. Also I think distributeFee is a little misleading name. Let's stick with accrueFee
| event Lock( | ||
| uint256 targetChain, | ||
| address token, | ||
| uint256 amount, |
There was a problem hiding this comment.
Check params order compared to IRouteV1
| uint256 claimableFees = LibFeeCalculator.claimReward( | ||
| _account, | ||
| token | ||
| ); |
Replaced the per-token percentage-based fee system with a native gas coin fee collected via
msg.valueonlockandburnoperations.New contracts
LibFeeDistributor/FeeDistributorFacet— accumulates and distributes native coin fees to validatorsGovernanceFacetV3— upgradesupdateMemberto handle both ERC-20 (legacy) and native coin fee claims on member removalRouterFacetV2—lock,burn,lockWithPermit,burnWithPermitare nowpayable;updateNativeTokensimplified to(address, bool)(fee percentage removed)IRouterV2/IFeeDistributor/IGovernanceV2— corresponding interfacesUpgrade path (backward-compatible with mainnet)
upgrade-governance-v2.js— V1 → V2 (replacesupdateMemberwithLibPaymentsupport)upgrade-governance-v3.js— V2 → V3 + addsFeeDistributorFacet+ replaces router functions withRouterFacetV2deploy-router.js— fresh deployments now chain V1 → V2 → V3Updated scripts
lock-erc-20,burn-erc-20— acceptserviceFeeparam, send asmsg.valueupdate-native-token— removedfeePercentageparamerc-20-unlock— usesIRouterV2ABITests
FeeDistributorFacet,RouterFacetV2, and native coin fee flow