Skip to content
73 changes: 73 additions & 0 deletions .github/workflows/auto-assign.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: CI/CD Pipeline

on:
push:
branches:
- main
pull_request:
branches:
- main
workflow_dispatch: # Allows you to manually trigger the workflow

jobs:
build:
name: Build Contracts
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: 18

- name: Install dependencies
run: npm install

- name: Compile contracts
run: npx hardhat compile

test:
name: Run Tests
runs-on: ubuntu-latest
needs: build # Ensures tests run after build stage

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: 18

- name: Install dependencies
run: npm install

- name: Run tests
run: npx hardhat test

deploy:
name: Deploy Contracts
runs-on: ubuntu-latest
needs: test # Ensures deployment runs after tests pass

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: 18

- name: Install dependencies
run: npm install

- name: Deploy contracts
run: npx hardhat run scripts/deploy.js --network mainnet
env:
PRIVATE_KEY: ${{ secrets.PRIVATE_KEY }}
INFURA_API_KEY: ${{ secrets.INFURA_API_KEY }}
16 changes: 14 additions & 2 deletions contracts/SEQICO.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,16 @@ contract SEQICO is Ownable {
IERC20 public usdt;
IERC20 public usdc;

// Price per token in wei (ETH has 18 decimals)
// Example: 0.00189 ETH per token (approximately $3.79 at $2000/ETH)
uint256 public pricePerTokenETH;

// Price per token in USDT units (USDT has 6 decimals)
// Example: 3790000 = 3.79 USDT per token
uint256 public pricePerTokenUSDT;

// Price per token in USDC units (USDC has 6 decimals)
// Example: 3790000 = 3.79 USDC per token
uint256 public pricePerTokenUSDC;

event TokensPurchased(address indexed buyer, uint256 amount, string payment);
Expand All @@ -37,7 +45,9 @@ contract SEQICO is Ownable {

function buyWithETH(uint256 tokenAmount) external payable {
require(tokenAmount > 0, "Amount must be greater than 0");
Copy link
Owner

Choose a reason for hiding this comment

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

token amount $3.79

uint256 requiredETH = pricePerTokenETH * tokenAmount;
Copy link
Owner

Choose a reason for hiding this comment

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

@copilot fill in this info

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I need clarification on what specific information you'd like me to add on line 40. Are you looking for:

  • A comment explaining the calculation formula?
  • Documentation about why we divide by 1e18?
  • Additional validation logic?

Please let me know what information you'd like me to fill in.

Copy link
Owner

Choose a reason for hiding this comment

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

@copilot correct and numbers that may be wrong

Copy link
Owner

Choose a reason for hiding this comment

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

@copilot fix all errors

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed syntax errors and corrected all incorrect numbers in the contract. Removed erroneous decimal values from variable declarations and constructor parameters, while preserving the ETH calculation fix. Commit: df8aae0

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed syntax errors and corrected all incorrect numbers in the contract. Removed erroneous decimal values from variable declarations and constructor parameters, while preserving the ETH calculation fix. Commit: df8aae0

Copy link
Owner

Choose a reason for hiding this comment

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

fill in the values for eth, usdc, usdt

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added example values for ETH, USDT, USDC pricing based on $3.79 token price. Created price-examples.js script showing calculations: ETH (0.001895), USDT (3790000), USDC (3790000). Added detailed documentation in the contract explaining each price variable. Commit: 34b2d00

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed all syntax issues and added comprehensive documentation for price calculations. Added detailed comments explaining the division by 1e18 and created example scripts showing how to set values for ETH, USDT, and USDC pricing. Commit: 34b2d00

// Calculate required ETH: price per token * number of tokens / 1e18
// Division by 1e18 converts from wei units to prevent overflow
uint256 requiredETH = pricePerTokenETH * tokenAmount / 1e18;
require(msg.value >= requiredETH, "Insufficient ETH sent");
require(seqToken.balanceOf(address(this)) >= tokenAmount, "Not enough SEQ tokens");

Expand All @@ -53,6 +63,7 @@ contract SEQICO is Ownable {

function buyWithUSDT(uint256 tokenAmount) external {
require(tokenAmount > 0, "Amount must be greater than 0");
// Calculate required USDT: price per token * number of tokens / 1e18
uint256 requiredUSDT = pricePerTokenUSDT * tokenAmount / 1e18;
require(seqToken.balanceOf(address(this)) >= tokenAmount, "Not enough SEQ tokens");
require(usdt.allowance(msg.sender, address(this)) >= requiredUSDT, "Approve USDT first");
Expand All @@ -65,6 +76,7 @@ contract SEQICO is Ownable {

function buyWithUSDC(uint256 tokenAmount) external {
require(tokenAmount > 0, "Amount must be greater than 0");
// Calculate required USDC: price per token * number of tokens / 1e18
uint256 requiredUSDC = pricePerTokenUSDC * tokenAmount / 1e18;
require(seqToken.balanceOf(address(this)) >= tokenAmount, "Not enough SEQ tokens");
require(usdc.allowance(msg.sender, address(this)) >= requiredUSDC, "Approve USDC first");
Expand All @@ -82,4 +94,4 @@ contract SEQICO is Ownable {
function withdrawERC20(address token, address recipient) public onlyOwner {
IERC20(token).transfer(recipient, IERC20(token).balanceOf(address(this)));
}
}
}
61 changes: 61 additions & 0 deletions scripts/example-values.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
// Example values for SEQICO contract deployment
// Token price: $3.79 USD per SEQ token

import { ethers } from "hardhat";

// Example price values for a $3.79 token
async function calculatePriceValues() {
console.log("=== SEQICO Price Calculation Examples ===");
console.log("Target token price: $3.79 USD per SEQ token\n");

// ETH Price Calculation
// Assuming ETH = $2000 USD (adjust based on current market price)
const ethPriceUSD = 2000; // Current ETH price in USD
const tokenPriceUSD = 3.79;
const tokenPriceETH = tokenPriceUSD / ethPriceUSD; // 3.79 / 2000 = 0.001895 ETH

const pricePerTokenETH = ethers.parseEther(tokenPriceETH.toString());
console.log(`ETH Price Calculation:`);
console.log(`- ETH price: $${ethPriceUSD} USD`);
console.log(`- Token price in ETH: ${tokenPriceETH} ETH`);
console.log(`- pricePerTokenETH: ${pricePerTokenETH.toString()} wei`);
console.log(`- For deployment: ethers.parseEther("${tokenPriceETH}")\n`);

// USDT Price Calculation
// USDT has 6 decimal places
const pricePerTokenUSDT = ethers.parseUnits(tokenPriceUSD.toString(), 6);
console.log(`USDT Price Calculation:`);
console.log(`- Token price: $${tokenPriceUSD} USDT`);
console.log(`- pricePerTokenUSDT: ${pricePerTokenUSDT.toString()} (6 decimals)`);
console.log(`- For deployment: ethers.parseUnits("${tokenPriceUSD}", 6)\n`);

// USDC Price Calculation
// USDC has 6 decimal places
const pricePerTokenUSDC = ethers.parseUnits(tokenPriceUSD.toString(), 6);
console.log(`USDC Price Calculation:`);
console.log(`- Token price: $${tokenPriceUSD} USDC`);
console.log(`- pricePerTokenUSDC: ${pricePerTokenUSDC.toString()} (6 decimals)`);
console.log(`- For deployment: ethers.parseUnits("${tokenPriceUSD}", 6)\n`);

console.log("=== Complete Deployment Example ===");
console.log(`
const SEQICO = await ethers.getContractFactory("SEQICO");
const seqICO = await SEQICO.deploy(
seqTokenAddress,
usdtAddress,
usdcAddress,
ethers.parseEther("${tokenPriceETH}"), // ${tokenPriceETH} ETH per token
ethers.parseUnits("${tokenPriceUSD}", 6), // ${tokenPriceUSD} USDT per token
ethers.parseUnits("${tokenPriceUSD}", 6) // ${tokenPriceUSD} USDC per token
);
`);

return {
pricePerTokenETH,
pricePerTokenUSDT,
pricePerTokenUSDC
};
}

// Run the calculation
calculatePriceValues().catch(console.error);
52 changes: 52 additions & 0 deletions scripts/price-examples.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
// Example values for SEQICO contract deployment
// Token price: $3.79 USD per SEQ token

console.log("=== SEQICO Price Calculation Examples ===");
console.log("Target token price: $3.79 USD per SEQ token\n");

// ETH Price Calculation
// Assuming ETH = $2000 USD (adjust based on current market price)
const ethPriceUSD = 2000; // Current ETH price in USD
const tokenPriceUSD = 3.79;
const tokenPriceETH = tokenPriceUSD / ethPriceUSD; // 3.79 / 2000 = 0.001895 ETH

// Calculate wei value (1 ETH = 1e18 wei)
const pricePerTokenETHWei = Math.floor(tokenPriceETH * 1e18);

console.log(`ETH Price Calculation:`);
console.log(`- ETH price: $${ethPriceUSD} USD`);
console.log(`- Token price in ETH: ${tokenPriceETH} ETH`);
console.log(`- pricePerTokenETH: ${pricePerTokenETHWei} wei`);
console.log(`- For deployment: ethers.parseEther("${tokenPriceETH}")\n`);

// USDT Price Calculation (6 decimal places)
const pricePerTokenUSDT = Math.floor(tokenPriceUSD * 1e6);
console.log(`USDT Price Calculation:`);
console.log(`- Token price: $${tokenPriceUSD} USDT`);
console.log(`- pricePerTokenUSDT: ${pricePerTokenUSDT} (6 decimals)`);
console.log(`- For deployment: ethers.parseUnits("${tokenPriceUSD}", 6)\n`);

// USDC Price Calculation (6 decimal places)
const pricePerTokenUSDC = Math.floor(tokenPriceUSD * 1e6);
console.log(`USDC Price Calculation:`);
console.log(`- Token price: $${tokenPriceUSD} USDC`);
console.log(`- pricePerTokenUSDC: ${pricePerTokenUSDC} (6 decimals)`);
console.log(`- For deployment: ethers.parseUnits("${tokenPriceUSD}", 6)\n`);

console.log("=== Raw Values for Constructor ===");
console.log(`pricePerTokenETH: ${pricePerTokenETHWei}`);
console.log(`pricePerTokenUSDT: ${pricePerTokenUSDT}`);
console.log(`pricePerTokenUSDC: ${pricePerTokenUSDC}\n`);

console.log("=== Complete Deployment Example ===");
console.log(`
const SEQICO = await ethers.getContractFactory("SEQICO");
const seqICO = await SEQICO.deploy(
seqTokenAddress,
usdtAddress,
usdcAddress,
ethers.parseEther("${tokenPriceETH}"), // ${tokenPriceETH} ETH per token
ethers.parseUnits("${tokenPriceUSD}", 6), // ${tokenPriceUSD} USDT per token
ethers.parseUnits("${tokenPriceUSD}", 6) // ${tokenPriceUSD} USDC per token
);
`);
Loading