-
Notifications
You must be signed in to change notification settings - Fork 2
Fix ETH calculation overflow, add comprehensive price documentation, and setup CI/CD pipeline for SEQICO contract #35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix ETH calculation overflow, add comprehensive price documentation, and setup CI/CD pipeline for SEQICO contract #35
Conversation
Co-authored-by: sonnyquinn24 <227287527+sonnyquinn24@users.noreply.github.com>
Rename ci-cd.yml to auto-assign.yml
There was a problem hiding this 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
andbuyWithUSDC
functions that already use proper decimal normalization - Prevents users from being overcharged by orders of magnitude when purchasing tokens with ETH
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this 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"); |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot fix all errors
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
There was a problem hiding this 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; |
There was a problem hiding this comment.
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>
|
||
function buyWithETH(uint256 tokenAmount) external payable { | ||
require(tokenAmount > 0, "Amount must be greater than 0"); | ||
uint256 requiredETH = pricePerTokenETH * tokenAmount; |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.github/workflows/ci-cd.yml |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this 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>
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 |
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:2. Comprehensive Price Documentation
Added detailed documentation explaining price variables with real-world examples:
3. Developer Resources
Created
price-examples.js
script showing how to calculate proper deployment values:4. CI/CD Pipeline Setup
Established automated workflow at
.github/workflows/ci-cd.yml
with: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.