Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
I
interface
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
LuckySwap
interface
Commits
77810772
Commit
77810772
authored
Nov 09, 2017
by
Hayden Adams
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix eth purchase bug
parent
348bcfdd
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
3 deletions
+22
-3
uniswap.sol
smart_contracts/uniswap.sol
+22
-3
No files found.
smart_contracts/uniswap.sol
View file @
77810772
...
...
@@ -97,15 +97,15 @@ contract uniswap is Ownable{
}
function ethToTokens(uint256 minimumTokens, uint256 timeout) public payable {
require(msg.value != 0 && timeout != 0);
uint256 fee = msg.value/500;
uint256 ethInPurchase = msg.value.sub(fee);
uint256 newTotalEth = totalEthQuantity.add(ethInPurchase);
uint256 newTotalTokens = invariant/newTotalEth;
uint256 purchasedTokens = totalTokenQuantity.sub(newTotalTokens);
require(purchasedTokens >= minimumTokens);
require(now < timeout);
require(now < timeout);
token.transfer(msg.sender, purchasedTokens);
totalEthQuantity = newTotalEth;
totalTokenQuantity = newTotalTokens;
...
...
@@ -114,9 +114,11 @@ contract uniswap is Ownable{
function tokenToEth(uint256 sellQuantity, uint256 minimumEth, uint256 timeout) public {
require(sellQuantity!=0 && minimumEth != 0 && timeout != 0);
token.transferFrom(msg.sender, address(this), sellQuantity);
uint256 fee = sellQuantity/500;
uint256 tokensInPurchase = sellQuantity - fee;
uint256 newTotalTokens = totalTokenQuantity.
sub(fe
e);
uint256 newTotalTokens = totalTokenQuantity.
add(tokensInPurchas
e);
uint256 newTotalEth = invariant/newTotalTokens;
uint256 purchasedEth = totalEthQuantity.sub(newTotalEth);
require(purchasedEth >= minimumEth);
...
...
@@ -128,7 +130,23 @@ contract uniswap is Ownable{
}
function ownerTokenDeposit(uint256 tokenAmount) public onlyOwner {
require(tokenAmount !=0);
token.transferFrom(msg.sender, address(this), tokenAmount);
totalTokenQuantity = totalTokenQuantity.add(tokenAmount);
invariant = totalTokenQuantity.mul(totalEthQuantity);
}
function ownerEthDeposit() public payable onlyOwner {
require(msg.value != 0);
totalEthQuantity = totalEthQuantity.add(msg.value);
invariant = totalEthQuantity.mul(totalTokenQuantity);
}
function ownerTokenWithdraw(uint256 tokenAmount) public onlyOwner {
require(tokenAmount !=0);
token.transfer(msg.sender, tokenAmount);
totalTokenQuantity = totalTokenQuantity.sub(tokenAmount);
invariant = totalTokenQuantity.mul(totalEthQuantity);
...
...
@@ -136,6 +154,7 @@ contract uniswap is Ownable{
function ownerEthWithdraw(uint256 ethAmount) public onlyOwner {
require(ethAmount !=0);
msg.sender.transfer(ethAmount);
totalEthQuantity = totalEthQuantity.sub(ethAmount);
invariant = totalEthQuantity.mul(totalTokenQuantity);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment