Skip to content

Commit 67b6b36

Browse files
authored
Merge pull request #35 from sonnyquinn24/copilot/fix-fb563af2-b166-4946-a42e-032251e1dffc
2 parents 28a74b0 + f87f73d commit 67b6b36

File tree

4 files changed

+200
-2
lines changed

4 files changed

+200
-2
lines changed

.github/workflows/auto-assign.yml

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
name: CI/CD Pipeline
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
branches:
9+
- main
10+
workflow_dispatch: # Allows you to manually trigger the workflow
11+
12+
jobs:
13+
build:
14+
name: Build Contracts
15+
runs-on: ubuntu-latest
16+
17+
steps:
18+
- name: Checkout code
19+
uses: actions/checkout@v3
20+
21+
- name: Set up Node.js
22+
uses: actions/setup-node@v3
23+
with:
24+
node-version: 18
25+
26+
- name: Install dependencies
27+
run: npm install
28+
29+
- name: Compile contracts
30+
run: npx hardhat compile
31+
32+
test:
33+
name: Run Tests
34+
runs-on: ubuntu-latest
35+
needs: build # Ensures tests run after build stage
36+
37+
steps:
38+
- name: Checkout code
39+
uses: actions/checkout@v3
40+
41+
- name: Set up Node.js
42+
uses: actions/setup-node@v3
43+
with:
44+
node-version: 18
45+
46+
- name: Install dependencies
47+
run: npm install
48+
49+
- name: Run tests
50+
run: npx hardhat test
51+
52+
deploy:
53+
name: Deploy Contracts
54+
runs-on: ubuntu-latest
55+
needs: test # Ensures deployment runs after tests pass
56+
57+
steps:
58+
- name: Checkout code
59+
uses: actions/checkout@v3
60+
61+
- name: Set up Node.js
62+
uses: actions/setup-node@v3
63+
with:
64+
node-version: 18
65+
66+
- name: Install dependencies
67+
run: npm install
68+
69+
- name: Deploy contracts
70+
run: npx hardhat run scripts/deploy.js --network mainnet
71+
env:
72+
PRIVATE_KEY: ${{ secrets.PRIVATE_KEY }}
73+
INFURA_API_KEY: ${{ secrets.INFURA_API_KEY }}

contracts/SEQICO.sol

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,16 @@ contract SEQICO is Ownable {
99
IERC20 public usdt;
1010
IERC20 public usdc;
1111

12+
// Price per token in wei (ETH has 18 decimals)
13+
// Example: 0.00189 ETH per token (approximately $3.79 at $2000/ETH)
1214
uint256 public pricePerTokenETH;
15+
16+
// Price per token in USDT units (USDT has 6 decimals)
17+
// Example: 3790000 = 3.79 USDT per token
1318
uint256 public pricePerTokenUSDT;
19+
20+
// Price per token in USDC units (USDC has 6 decimals)
21+
// Example: 3790000 = 3.79 USDC per token
1422
uint256 public pricePerTokenUSDC;
1523

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

3846
function buyWithETH(uint256 tokenAmount) external payable {
3947
require(tokenAmount > 0, "Amount must be greater than 0");
40-
uint256 requiredETH = pricePerTokenETH * tokenAmount;
48+
// Calculate required ETH: price per token * number of tokens / 1e18
49+
// Division by 1e18 converts from wei units to prevent overflow
50+
uint256 requiredETH = pricePerTokenETH * tokenAmount / 1e18;
4151
require(msg.value >= requiredETH, "Insufficient ETH sent");
4252
require(seqToken.balanceOf(address(this)) >= tokenAmount, "Not enough SEQ tokens");
4353

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

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

6677
function buyWithUSDC(uint256 tokenAmount) external {
6778
require(tokenAmount > 0, "Amount must be greater than 0");
79+
// Calculate required USDC: price per token * number of tokens / 1e18
6880
uint256 requiredUSDC = pricePerTokenUSDC * tokenAmount / 1e18;
6981
require(seqToken.balanceOf(address(this)) >= tokenAmount, "Not enough SEQ tokens");
7082
require(usdc.allowance(msg.sender, address(this)) >= requiredUSDC, "Approve USDC first");
@@ -82,4 +94,4 @@ contract SEQICO is Ownable {
8294
function withdrawERC20(address token, address recipient) public onlyOwner {
8395
IERC20(token).transfer(recipient, IERC20(token).balanceOf(address(this)));
8496
}
85-
}
97+
}

scripts/example-values.js

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
// Example values for SEQICO contract deployment
2+
// Token price: $3.79 USD per SEQ token
3+
4+
import { ethers } from "hardhat";
5+
6+
// Example price values for a $3.79 token
7+
async function calculatePriceValues() {
8+
console.log("=== SEQICO Price Calculation Examples ===");
9+
console.log("Target token price: $3.79 USD per SEQ token\n");
10+
11+
// ETH Price Calculation
12+
// Assuming ETH = $2000 USD (adjust based on current market price)
13+
const ethPriceUSD = 2000; // Current ETH price in USD
14+
const tokenPriceUSD = 3.79;
15+
const tokenPriceETH = tokenPriceUSD / ethPriceUSD; // 3.79 / 2000 = 0.001895 ETH
16+
17+
const pricePerTokenETH = ethers.parseEther(tokenPriceETH.toString());
18+
console.log(`ETH Price Calculation:`);
19+
console.log(`- ETH price: $${ethPriceUSD} USD`);
20+
console.log(`- Token price in ETH: ${tokenPriceETH} ETH`);
21+
console.log(`- pricePerTokenETH: ${pricePerTokenETH.toString()} wei`);
22+
console.log(`- For deployment: ethers.parseEther("${tokenPriceETH}")\n`);
23+
24+
// USDT Price Calculation
25+
// USDT has 6 decimal places
26+
const pricePerTokenUSDT = ethers.parseUnits(tokenPriceUSD.toString(), 6);
27+
console.log(`USDT Price Calculation:`);
28+
console.log(`- Token price: $${tokenPriceUSD} USDT`);
29+
console.log(`- pricePerTokenUSDT: ${pricePerTokenUSDT.toString()} (6 decimals)`);
30+
console.log(`- For deployment: ethers.parseUnits("${tokenPriceUSD}", 6)\n`);
31+
32+
// USDC Price Calculation
33+
// USDC has 6 decimal places
34+
const pricePerTokenUSDC = ethers.parseUnits(tokenPriceUSD.toString(), 6);
35+
console.log(`USDC Price Calculation:`);
36+
console.log(`- Token price: $${tokenPriceUSD} USDC`);
37+
console.log(`- pricePerTokenUSDC: ${pricePerTokenUSDC.toString()} (6 decimals)`);
38+
console.log(`- For deployment: ethers.parseUnits("${tokenPriceUSD}", 6)\n`);
39+
40+
console.log("=== Complete Deployment Example ===");
41+
console.log(`
42+
const SEQICO = await ethers.getContractFactory("SEQICO");
43+
const seqICO = await SEQICO.deploy(
44+
seqTokenAddress,
45+
usdtAddress,
46+
usdcAddress,
47+
ethers.parseEther("${tokenPriceETH}"), // ${tokenPriceETH} ETH per token
48+
ethers.parseUnits("${tokenPriceUSD}", 6), // ${tokenPriceUSD} USDT per token
49+
ethers.parseUnits("${tokenPriceUSD}", 6) // ${tokenPriceUSD} USDC per token
50+
);
51+
`);
52+
53+
return {
54+
pricePerTokenETH,
55+
pricePerTokenUSDT,
56+
pricePerTokenUSDC
57+
};
58+
}
59+
60+
// Run the calculation
61+
calculatePriceValues().catch(console.error);

scripts/price-examples.js

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
// Example values for SEQICO contract deployment
2+
// Token price: $3.79 USD per SEQ token
3+
4+
console.log("=== SEQICO Price Calculation Examples ===");
5+
console.log("Target token price: $3.79 USD per SEQ token\n");
6+
7+
// ETH Price Calculation
8+
// Assuming ETH = $2000 USD (adjust based on current market price)
9+
const ethPriceUSD = 2000; // Current ETH price in USD
10+
const tokenPriceUSD = 3.79;
11+
const tokenPriceETH = tokenPriceUSD / ethPriceUSD; // 3.79 / 2000 = 0.001895 ETH
12+
13+
// Calculate wei value (1 ETH = 1e18 wei)
14+
const pricePerTokenETHWei = Math.floor(tokenPriceETH * 1e18);
15+
16+
console.log(`ETH Price Calculation:`);
17+
console.log(`- ETH price: $${ethPriceUSD} USD`);
18+
console.log(`- Token price in ETH: ${tokenPriceETH} ETH`);
19+
console.log(`- pricePerTokenETH: ${pricePerTokenETHWei} wei`);
20+
console.log(`- For deployment: ethers.parseEther("${tokenPriceETH}")\n`);
21+
22+
// USDT Price Calculation (6 decimal places)
23+
const pricePerTokenUSDT = Math.floor(tokenPriceUSD * 1e6);
24+
console.log(`USDT Price Calculation:`);
25+
console.log(`- Token price: $${tokenPriceUSD} USDT`);
26+
console.log(`- pricePerTokenUSDT: ${pricePerTokenUSDT} (6 decimals)`);
27+
console.log(`- For deployment: ethers.parseUnits("${tokenPriceUSD}", 6)\n`);
28+
29+
// USDC Price Calculation (6 decimal places)
30+
const pricePerTokenUSDC = Math.floor(tokenPriceUSD * 1e6);
31+
console.log(`USDC Price Calculation:`);
32+
console.log(`- Token price: $${tokenPriceUSD} USDC`);
33+
console.log(`- pricePerTokenUSDC: ${pricePerTokenUSDC} (6 decimals)`);
34+
console.log(`- For deployment: ethers.parseUnits("${tokenPriceUSD}", 6)\n`);
35+
36+
console.log("=== Raw Values for Constructor ===");
37+
console.log(`pricePerTokenETH: ${pricePerTokenETHWei}`);
38+
console.log(`pricePerTokenUSDT: ${pricePerTokenUSDT}`);
39+
console.log(`pricePerTokenUSDC: ${pricePerTokenUSDC}\n`);
40+
41+
console.log("=== Complete Deployment Example ===");
42+
console.log(`
43+
const SEQICO = await ethers.getContractFactory("SEQICO");
44+
const seqICO = await SEQICO.deploy(
45+
seqTokenAddress,
46+
usdtAddress,
47+
usdcAddress,
48+
ethers.parseEther("${tokenPriceETH}"), // ${tokenPriceETH} ETH per token
49+
ethers.parseUnits("${tokenPriceUSD}", 6), // ${tokenPriceUSD} USDT per token
50+
ethers.parseUnits("${tokenPriceUSD}", 6) // ${tokenPriceUSD} USDC per token
51+
);
52+
`);

0 commit comments

Comments
 (0)