Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 21 additions & 10 deletions contracts/ContributionAccountingToken.sol
Original file line number Diff line number Diff line change
Expand Up @@ -42,25 +42,36 @@ contract ContributionAccountingToken is ERC20, ERC20Permit, AccessControl {
lastMintTimestamp = block.timestamp;
}

function mint(address to, uint256 amount) public onlyRole(MINTER_ROLE) {
function maxMintableAmount() public view returns (uint256) {
uint256 currentSupply = totalSupply();

// If current supply is less than threshold, return remaining amount to threshold
if (currentSupply < thresholdSupply) {
return thresholdSupply - currentSupply;
}

// Calculate based on expansion rate
uint256 elapsedTime = block.timestamp - lastMintTimestamp;
uint256 maxMintableAmount = (currentSupply * maxExpansionRate * elapsedTime) / (365 days * 100);

// Also check against remaining max supply
uint256 remainingSupply = maxSupply - currentSupply;

return maxMintableAmount < remainingSupply ? maxMintableAmount : remainingSupply;
}

function mint(address to, uint256 amount) public onlyRole(MINTER_ROLE) {

// Minting fee calculation
uint256 feeAmount = (amount * clowderFee) / denominator;

// Check against max mintable amount
require(amount + feeAmount <= maxMintableAmount(), "Exceeds maximum mintable amount");

// Perform the actual minting
_mint(to, amount);
_mint(clowderTreasury, feeAmount);
lastMintTimestamp = block.timestamp;

// Require statements moved after fee calculation and minting
require(currentSupply + amount + feeAmount <= maxSupply, "Exceeds maximum supply");

if (currentSupply >= thresholdSupply) {
uint256 elapsedTime = block.timestamp - lastMintTimestamp;
uint256 maxMintableAmount = (currentSupply * maxExpansionRate * elapsedTime) / (365 days * 100);
require(amount + feeAmount <= maxMintableAmount, "Exceeds maximum expansion rate");
}
}

function reduceMaxSupply(uint256 newMaxSupply) public onlyRole(DEFAULT_ADMIN_ROLE) {
Expand Down
115 changes: 114 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
"hardhat": "^2.22.17"
},
"dependencies": {
"@openzeppelin/contracts": "^5.1.0"
"@openzeppelin/contracts": "^5.1.0",
"@radix-ui/react-separator": "^1.1.7",
"sonner": "^2.0.5"
Comment on lines +9 to +10
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Verification agent

🧩 Analysis chain

Verify new package versions for security and compatibility.

The new dependencies support enhanced UI features, but ensure they are current and secure versions.


🌐 Web query:

What are the latest versions of @radix-ui/react-separator and sonner npm packages? Are there any known security vulnerabilities in versions 1.1.7 and 2.0.5 respectively?

💡 Result:

As of June 8, 2025, the latest versions of the specified npm packages are:

  • @radix-ui/react-separator: Version 1.1.2, published approximately a month ago. (npmjs.com)

  • sonner: Version 2.0.5, released on May 26, 2023. (radix-ui.com)

Regarding security vulnerabilities:

  • @radix-ui/react-separator: No direct vulnerabilities have been found in this package. (security.snyk.io)

  • sonner: No specific security vulnerabilities are reported for version 2.0.5.

It's important to note that while no vulnerabilities are reported for these versions, security landscapes can evolve. Regularly monitoring official repositories and security advisories is recommended to stay informed about potential issues.

Citations:


Fix invalid @radix-ui/react-separator version

The version specifier ^1.1.7 does not exist on npm (latest is 1.1.2), which will cause install failures. The sonner@^2.0.5 dependency is up-to-date and has no known vulnerabilities.

  • package.json (line 9): update the version specifier for @radix-ui/react-separator
-    "@radix-ui/react-separator": "^1.1.7",
+    "@radix-ui/react-separator": "^1.1.2",
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
"@radix-ui/react-separator": "^1.1.7",
"sonner": "^2.0.5"
"@radix-ui/react-separator": "^1.1.2",
"sonner": "^2.0.5"
🤖 Prompt for AI Agents
In package.json around lines 9 to 10, the version specifier for
@radix-ui/react-separator is set to ^1.1.7, which does not exist and will cause
install failures. Update the version specifier to the latest valid version,
which is 1.1.2. The sonner dependency version is correct and does not require
changes.

}
}
Loading