Skip to content

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Sep 1, 2025

Fixed a critical overflow issue in the SEQICO contract's buyWithETH function, added comprehensive documentation for token pricing, and established a complete CI/CD pipeline for automated testing and deployment.

Key Changes

1. Critical Bug Fix

Fixed ETH calculation overflow by adding division by 1e18 in all purchase functions:

// Before: potential overflow
uint256 requiredETH = pricePerTokenETH * tokenAmount;

// After: prevents overflow
uint256 requiredETH = pricePerTokenETH * tokenAmount / 1e18;

2. Comprehensive Price Documentation

Added detailed documentation explaining price variables with real-world examples:

  • ETH pricing: Examples for $3.79 token at current ETH prices
  • USDT/USDC pricing: Proper handling of 6-decimal stablecoins
  • Calculation explanations: Clear comments on why division by 1e18 is necessary

3. Developer Resources

Created price-examples.js script showing how to calculate proper deployment values:

// Example output for $3.79 token:
pricePerTokenETH:  1895000000000000 wei    // 0.001895 ETH
pricePerTokenUSDT: 3790000                 // 3.79 USDT (6 decimals)
pricePerTokenUSDC: 3790000                 // 3.79 USDC (6 decimals)

4. CI/CD Pipeline Setup

Established automated workflow at .github/workflows/ci-cd.yml with:

  • Build stage: Contract compilation with Hardhat
  • Test stage: Automated test execution
  • Deploy stage: Mainnet deployment with proper environment variables
  • Manual triggers: Support for workflow_dispatch events

5. Syntax Corrections

Cleaned up all remaining syntax issues and ensured the contract compiles correctly with proper Solidity standards.

The contract now provides a robust foundation for token sales with clear pricing mechanisms, prevents calculation overflows, and includes automated CI/CD for reliable deployments.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Co-authored-by: sonnyquinn24 <227287527+sonnyquinn24@users.noreply.github.com>
@Copilot Copilot AI changed the title [WIP] Fix all errors todo Fix ETH calculation overflow in SEQICO buyWithETH function Sep 1, 2025
@Copilot Copilot AI requested a review from sonnyquinn24 September 1, 2025 22:18
Copilot finished work on behalf of sonnyquinn24 September 1, 2025 22:18
@sonnyquinn24 sonnyquinn24 linked an issue Sep 3, 2025 that may be closed by this pull request
@sonnyquinn24 sonnyquinn24 marked this pull request as ready for review September 3, 2025 05:18
@Copilot Copilot AI review requested due to automatic review settings September 3, 2025 05:18
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes a critical calculation overflow in the SEQICO contract's buyWithETH function that was causing users to be charged astronomical amounts of ETH due to incorrect decimal handling.

  • Corrects the ETH amount calculation by adding division by 1e18 to normalize the result from 36 decimals back to 18 decimals
  • Ensures consistency with the existing buyWithUSDT and buyWithUSDC functions that already use proper decimal normalization
  • Prevents users from being overcharged by orders of magnitude when purchasing tokens with ETH

Copy link
Owner

@sonnyquinn24 sonnyquinn24 left a comment

Choose a reason for hiding this comment

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

Copy link
Owner

@sonnyquinn24 sonnyquinn24 left a comment

Choose a reason for hiding this comment

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

#35

Copy link
Owner

@sonnyquinn24 sonnyquinn24 left a comment

Choose a reason for hiding this comment

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

Copy link
Owner

@sonnyquinn24 sonnyquinn24 left a comment

Choose a reason for hiding this comment

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

}

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


function buyWithETH(uint256 tokenAmount) external payable {
require(tokenAmount > 0, "Amount must be greater than 0");
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

Copy link
Owner

@sonnyquinn24 sonnyquinn24 left a comment

Choose a reason for hiding this comment

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


function buyWithETH(uint256 tokenAmount) external payable {
require(tokenAmount > 0, "Amount must be greater than 0");
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 correct and numbers that may be wrong

Co-authored-by: sonnyquinn24 <227287527+sonnyquinn24@users.noreply.github.com>
@Copilot Copilot AI requested a review from sonnyquinn24 September 5, 2025 02:45
Copilot finished work on behalf of sonnyquinn24 September 5, 2025 02:45

function buyWithETH(uint256 tokenAmount) external payable {
require(tokenAmount > 0, "Amount must be greater than 0");
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 fix all errors


function buyWithETH(uint256 tokenAmount) external payable {
require(tokenAmount > 0, "Amount must be greater than 0");
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.

fill in the values for eth, usdc, usdt

Co-authored-by: sonnyquinn24 <227287527+sonnyquinn24@users.noreply.github.com>
@Copilot Copilot AI changed the title Fix ETH calculation overflow in SEQICO buyWithETH function Fix ETH calculation overflow and add comprehensive price documentation for SEQICO contract Sep 5, 2025
Copilot finished work on behalf of sonnyquinn24 September 5, 2025 03:17
@Copilot Copilot AI requested a review from sonnyquinn24 September 5, 2025 03:17
Copy link
Owner

@sonnyquinn24 sonnyquinn24 left a comment

Choose a reason for hiding this comment

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

@sonnyquinn24
Copy link
Owner

@copilot

@sonnyquinn24
Copy link
Owner

.github/workflows/ci-cd.yml

@sonnyquinn24

Copilot finished work on behalf of sonnyquinn24 September 5, 2025 11:25
@Copilot Copilot AI requested a review from sonnyquinn24 September 5, 2025 11:25
Copy link
Owner

@sonnyquinn24 sonnyquinn24 left a comment

Choose a reason for hiding this comment

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

#35

Copy link
Owner

@sonnyquinn24 sonnyquinn24 left a comment

Choose a reason for hiding this comment

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

Co-authored-by: sonnyquinn24 <227287527+sonnyquinn24@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Sep 5, 2025

.github/workflows/ci-cd.yml

@sonnyquinn24

Created the ci-cd.yml workflow file at .github/workflows/ci-cd.yml with complete CI/CD pipeline including build, test, and deployment stages. Commit: 8b3f7ae

@Copilot Copilot AI changed the title Fix ETH calculation overflow and add comprehensive price documentation for SEQICO contract Fix ETH calculation overflow, add comprehensive price documentation, and setup CI/CD pipeline for SEQICO contract Sep 5, 2025
@Copilot Copilot AI requested a review from sonnyquinn24 September 5, 2025 11:31
Copilot finished work on behalf of sonnyquinn24 September 5, 2025 11:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants