Fix requiredETH calculation in buyWithETH function to account for decimal scaling#31
Open
Fix requiredETH calculation in buyWithETH function to account for decimal scaling#31
Conversation
There was a problem hiding this comment.
Copilot wasn't able to review any files in this pull request.
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Owner
|
Fix errors |
Co-authored-by: sonnyquinn24 <227287527+sonnyquinn24@users.noreply.github.com>
Co-authored-by: sonnyquinn24 <227287527+sonnyquinn24@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix requiredETH calculation in buyWithETH to handle decimal scaling
Fix requiredETH calculation in buyWithETH function to account for decimal scaling
Sep 1, 2025
Open
sonnyquinn24
approved these changes
Sep 7, 2025
Open
This was
linked to
issues
Sep 7, 2025
This was
unlinked from
issues
Sep 7, 2025
sonnyquinn24
requested changes
Sep 8, 2025
| @@ -9,7 +9,7 @@ contract SEQToken is ERC20, Ownable { | |||
| uint256 totalSupply, | |||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The
buyWithETHfunction incontracts/SEQICO.solhad an incorrect calculation forrequiredETHthat didn't account for decimal scaling whenpricePerTokenETHuses 18 decimals (standard for ERC20 tokens).Before:
This resulted in astronomically large ETH requirements. For example, with a price of 0.01 ETH per token, purchasing 1 SEQ token would require 10,000,000,000,000,000 ETH instead of the expected 0.01 ETH.
Solution
Updated the calculation to include division by
1e18to properly handle decimal scaling:After:
This brings the
buyWithETHfunction in line with the existing correct implementations inbuyWithUSDTandbuyWithUSDCfunctions, which already include the/1e18division.Verification
buyWithETH,buyWithUSDT,buyWithUSDC)Additional Changes
Ownableconstructor compatibility issues in bothSEQICO.solandSEQToken.solto work with the newer version of OpenZeppelin contractsThe core fix is minimal and surgical, changing only the problematic calculation line while maintaining all existing functionality.
This pull request was created as a result of the following prompt from Copilot chat.
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.