From ad02740fa4d796fc576670594ecc4f185e5aa746 Mon Sep 17 00:00:00 2001 From: James Tuckett Date: Wed, 28 Feb 2024 12:51:47 +0000 Subject: [PATCH 1/2] refactor: Update deploy status to false and use constant for divisor --- packages/deploy-configurations/configs/arbitrum.conf.ts | 2 +- packages/deploy-configurations/configs/base.conf.ts | 2 +- packages/dma-contracts/contracts/actions/common/CollectFee.sol | 3 ++- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/deploy-configurations/configs/arbitrum.conf.ts b/packages/deploy-configurations/configs/arbitrum.conf.ts index 897f9f4a..6c7a0f2e 100644 --- a/packages/deploy-configurations/configs/arbitrum.conf.ts +++ b/packages/deploy-configurations/configs/arbitrum.conf.ts @@ -223,7 +223,7 @@ export const config: SystemConfig = { }, CollectFee: { name: 'CollectFee', - deploy: true, + deploy: false, address: '', serviceRegistryName: SERVICE_REGISTRY_NAMES.common.COLLECT_FEE, history: [], diff --git a/packages/deploy-configurations/configs/base.conf.ts b/packages/deploy-configurations/configs/base.conf.ts index 57fd1af9..72ed7858 100644 --- a/packages/deploy-configurations/configs/base.conf.ts +++ b/packages/deploy-configurations/configs/base.conf.ts @@ -188,7 +188,7 @@ export const config: SystemConfig = { }, CollectFee: { name: 'CollectFee', - deploy: true, + deploy: false, address: '', serviceRegistryName: SERVICE_REGISTRY_NAMES.common.COLLECT_FEE, history: [], diff --git a/packages/dma-contracts/contracts/actions/common/CollectFee.sol b/packages/dma-contracts/contracts/actions/common/CollectFee.sol index f6eeccc0..a1bce3ba 100644 --- a/packages/dma-contracts/contracts/actions/common/CollectFee.sol +++ b/packages/dma-contracts/contracts/actions/common/CollectFee.sol @@ -19,6 +19,7 @@ contract CollectFee is Executable, UseStorageSlot, UseRegistry { // Fee percentage (e.g., 1% = 100, 0.5% = 50) uint256 public feePercentage; address public feeRecipient; + uint256 constant DIVISOR = 10000; constructor(address _registry, uint256 _feePercentage, address _feeRecipient) UseRegistry(ServiceRegistry(_registry)) { feePercentage = _feePercentage; @@ -33,7 +34,7 @@ contract CollectFee is Executable, UseStorageSlot, UseRegistry { function execute(bytes calldata data, uint8[] memory paramsMap) external payable override { address asset = parseInputs(data); uint256 transactionAmount = store().readUint(bytes32(0), paramsMap[0]); - uint256 feeAmount = (transactionAmount * feePercentage) / 10000; + uint256 feeAmount = (transactionAmount * feePercentage) / DIVISOR; // Transfer fee from the user's proxy to the feeRecipient IERC20(asset).safeTransferFrom(msg.sender, feeRecipient, feeAmount); From 9cae822e498396f1fb7849b3eaf76a1e140ca29a Mon Sep 17 00:00:00 2001 From: James Tuckett Date: Wed, 28 Feb 2024 13:03:00 +0000 Subject: [PATCH 2/2] refactor: Use immutable keyword for feePercentage and feeRecipient --- .../dma-contracts/contracts/actions/common/CollectFee.sol | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/dma-contracts/contracts/actions/common/CollectFee.sol b/packages/dma-contracts/contracts/actions/common/CollectFee.sol index a1bce3ba..e2f207a7 100644 --- a/packages/dma-contracts/contracts/actions/common/CollectFee.sol +++ b/packages/dma-contracts/contracts/actions/common/CollectFee.sol @@ -17,8 +17,8 @@ contract CollectFee is Executable, UseStorageSlot, UseRegistry { using Read for StorageSlot.TransactionStorage; // Fee percentage (e.g., 1% = 100, 0.5% = 50) - uint256 public feePercentage; - address public feeRecipient; + uint256 public immutable feePercentage; + address public immutable feeRecipient; uint256 constant DIVISOR = 10000; constructor(address _registry, uint256 _feePercentage, address _feeRecipient) UseRegistry(ServiceRegistry(_registry)) {