Skip to content
Open
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
42 changes: 40 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@ This project contains:

### SEQICO Contract
- Buy SEQ tokens with ETH, USDT, or USDC
- Configurable pricing for each payment method
- Configurable pricing for each payment method with $3 minimum enforcement
- Owner-only functions for token management and fund withdrawal
- Price setting functions with minimum validation
- Automatic ETH refunds for overpayments
- Event logging for all purchases
- Event logging for all purchases and price updates

### SEQToken Contract
- Standard ERC20 token
Expand Down Expand Up @@ -44,13 +45,22 @@ npx hardhat run scripts/deploy.js
npx hardhat run scripts/deploy-DE.js
```

4. Set prices after deployment (optional):
```bash
# Update the SEQICO_ADDRESS in set-prices.js first
npx hardhat run scripts/set-prices.js
```

## Contract Functions

### SEQICO Contract
- `buyWithETH(uint256 tokenAmount)`: Purchase tokens with ETH
- `buyWithUSDT(uint256 tokenAmount)`: Purchase tokens with USDT
- `buyWithUSDC(uint256 tokenAmount)`: Purchase tokens with USDC
- `setSEQToken(address _seqToken)`: Update SEQ token address (owner only)
- `setPriceETH(uint256 _pricePerTokenETH)`: Set ETH price per token (owner only, >= $3 minimum)
- `setPriceUSDT(uint256 _pricePerTokenUSDT)`: Set USDT price per token (owner only, >= $3 minimum)
- `setPriceUSDC(uint256 _pricePerTokenUSDC)`: Set USDC price per token (owner only, >= $3 minimum)
- `withdrawETH(address payable recipient)`: Withdraw collected ETH (owner only)
- `withdrawERC20(address token, address recipient)`: Withdraw ERC20 tokens (owner only)

Expand All @@ -62,6 +72,34 @@ The deployment scripts include configurable parameters:
- Token pricing for ETH, USDT, and USDC
- Total supply (500,000 SEQ tokens)

### Price Floor Policy

The SEQICO contract enforces a **$3 minimum price** for all payment methods:

#### Price Minimums:
- **USDT/USDC**: 3,000,000 (representing $3.00 with 6 decimals)
- **ETH**: 0.001 ETH (assuming ETH > $3,000, this represents > $3.00)

#### Setting Prices:
- Prices can only be set by the contract owner
- All prices must meet the $3 minimum requirement
- Price updates emit `PriceUpdated` events
- Initial prices are validated during contract deployment

#### Examples:
```solidity
// Valid prices (>= $3 minimum)
setPriceUSDT(3_000_000); // Exactly $3.00
setPriceUSDC(5_000_000); // $5.00
setPriceETH(0.001 ether); // 0.001 ETH (assuming ETH > $3,000)

// Invalid prices (< $3 minimum) - these will revert
setPriceUSDT(2_000_000); // $2.00 - too low!
setPriceETH(0.0005 ether); // 0.0005 ETH - too low!
```

To update prices after deployment, use the `scripts/set-prices.js` script.

## License

MIT
25 changes: 25 additions & 0 deletions contracts/MockERC20.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;

import "@openzeppelin/contracts/token/ERC20/ERC20.sol";

contract MockERC20 is ERC20 {
uint8 private _decimals;

constructor(
string memory name,
string memory symbol,
uint8 decimals_
) ERC20(name, symbol) {
_decimals = decimals_;
_mint(msg.sender, 1000000 * 10**decimals_); // Mint 1M tokens to deployer
}

function decimals() public view virtual override returns (uint8) {
return _decimals;
}

function mint(address to, uint256 amount) public {
_mint(to, amount);
}
}
41 changes: 41 additions & 0 deletions contracts/SEQICO.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ contract SEQICO is Ownable {
uint256 public pricePerTokenUSDC;

event TokensPurchased(address indexed buyer, uint256 amount, string payment);
event PriceUpdated(string indexed paymentMethod, uint256 newPrice);

// Minimum price constants (representing $3 minimum)
uint256 public constant MIN_PRICE_USD_STABLECOINS = 3_000_000; // $3 with 6 decimals
uint256 public constant MIN_PRICE_ETH = 0.001 ether; // 0.001 ETH minimum (assuming ETH > $3000)

constructor(
address _seqToken,
Expand All @@ -26,6 +31,12 @@ contract SEQICO is Ownable {
seqToken = IERC20(_seqToken);
usdt = IERC20(_usdt);
usdc = IERC20(_usdc);

// Validate minimum prices
require(_pricePerTokenETH >= MIN_PRICE_ETH, "ETH price below $3 minimum");
require(_pricePerTokenUSDT >= MIN_PRICE_USD_STABLECOINS, "USDT price below $3 minimum");
require(_pricePerTokenUSDC >= MIN_PRICE_USD_STABLECOINS, "USDC price below $3 minimum");

pricePerTokenETH = _pricePerTokenETH;
pricePerTokenUSDT = _pricePerTokenUSDT;
pricePerTokenUSDC = _pricePerTokenUSDC;
Expand All @@ -35,6 +46,36 @@ contract SEQICO is Ownable {
seqToken = IERC20(_seqToken);
}

/**
* @dev Set the price per token for ETH purchases
* @param _pricePerTokenETH New price in wei per token (must be >= $3 minimum)
*/
function setPriceETH(uint256 _pricePerTokenETH) external onlyOwner {
require(_pricePerTokenETH >= MIN_PRICE_ETH, "ETH price below $3 minimum");
pricePerTokenETH = _pricePerTokenETH;
emit PriceUpdated("ETH", _pricePerTokenETH);
}

/**
* @dev Set the price per token for USDT purchases
* @param _pricePerTokenUSDT New price with 6 decimals (must be >= $3)
*/
function setPriceUSDT(uint256 _pricePerTokenUSDT) external onlyOwner {
require(_pricePerTokenUSDT >= MIN_PRICE_USD_STABLECOINS, "USDT price below $3 minimum");
pricePerTokenUSDT = _pricePerTokenUSDT;
emit PriceUpdated("USDT", _pricePerTokenUSDT);
}

/**
* @dev Set the price per token for USDC purchases
* @param _pricePerTokenUSDC New price with 6 decimals (must be >= $3)
*/
function setPriceUSDC(uint256 _pricePerTokenUSDC) external onlyOwner {
require(_pricePerTokenUSDC >= MIN_PRICE_USD_STABLECOINS, "USDC price below $3 minimum");
pricePerTokenUSDC = _pricePerTokenUSDC;
emit PriceUpdated("USDC", _pricePerTokenUSDC);
}

function buyWithETH(uint256 tokenAmount) external payable {
require(tokenAmount > 0, "Amount must be greater than 0");
uint256 requiredETH = pricePerTokenETH * tokenAmount;
Expand Down
55 changes: 55 additions & 0 deletions demo.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#!/bin/bash

# SEQICO Price Setting Demo Script
# This script demonstrates the price-setting functionality

echo "🚀 SEQICO Price Setting Functionality Demo"
echo "=========================================="
echo

echo "📋 What this implementation provides:"
echo " ✅ setPriceETH() - Set ETH price per token (min 0.001 ETH)"
echo " ✅ setPriceUSDT() - Set USDT price per token (min \$3.00)"
echo " ✅ setPriceUSDC() - Set USDC price per token (min \$3.00)"
echo " ✅ Price validation enforcing \$3 minimum"
echo " ✅ Owner-only access control"
echo " ✅ Event logging for price changes"
echo " ✅ Constructor validation"
echo

echo "💰 Price Floor Policy:"
echo " • USDT/USDC minimum: 3,000,000 (representing \$3.00 with 6 decimals)"
echo " • ETH minimum: 0.001 ETH (assuming ETH > \$3,000)"
echo

echo "📁 Files Added/Modified:"
echo " 📄 contracts/SEQICO.sol - Added price setter functions"
echo " 📄 test/SEQICO.test.js - Comprehensive test suite"
echo " 📄 scripts/set-prices.js - Price setting utility script"
echo " 📄 scripts/deploy.js - Updated with validation"
echo " 📄 scripts/deploy-DE.js - Updated with validation"
echo " 📄 README.md - Updated documentation"
echo

echo "🔧 Usage Examples:"
echo
echo "1. Deploy with validation:"
echo " npx hardhat run scripts/deploy.js"
echo
echo "2. Set new prices after deployment:"
echo " # Edit SEQICO_ADDRESS in set-prices.js first"
echo " npx hardhat run scripts/set-prices.js"
echo
echo "3. Test the functionality:"
echo " npx hardhat test"
echo

echo "⚠️ Important Notes:"
echo " • All price updates must be done by contract owner"
echo " • Prices below \$3 minimum will be rejected"
echo " • Price changes emit PriceUpdated events"
echo " • Initial deployment validates all prices"
echo

echo "🎉 Implementation Complete!"
echo "The SEQICO contract now supports dynamic price setting with proper validation."
23 changes: 12 additions & 11 deletions hardhat.config.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
require("@nomicfoundation/hardhat-toolbox");

/** @type import('hardhat/config').HardhatUserConfig */
const config = {
solidity: "0.8.24",
networks: {
hardhat: {},
hardhat: {
chainId: 31337
},
sepolia: {
url: process.env.SEPOLIA_RPC_URL || `https://sepolia.infura.io/v3/${process.env.INFURA_API_KEY}`,
accounts: process.env.PRIVATE_KEY ? [process.env.PRIVATE_KEY] : [],
Expand All @@ -22,13 +22,14 @@ const config = {
accounts: process.env.PRIVATE_KEY ? [process.env.PRIVATE_KEY] : [],
},
},
gasReporter: {
enabled: process.env.REPORT_GAS !== undefined,
currency: "USD",
},
etherscan: {
apiKey: process.env.ETHERSCAN_API_KEY,
},
// Price configuration for deployment scripts
priceConfig: {
defaultPriceETH: "0.01",
defaultPriceUSDT: 10_000_000,
defaultPriceUSDC: 10_000_000,
minPriceETH: "0.001",
minPriceUSDStable: 3_000_000
}
};

module.exports = config;
export default config;
Loading