-
Notifications
You must be signed in to change notification settings - Fork 12
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
[H01] Check for ETH deposited in buyOTokens. #185
Conversation
…_amt = 0, then buyOTokens will spend all of msg.value
I want to make sure it's ok to switch uniswapBuyOToken to internal ? |
FYI, it still does not "return any ETH deposited in excess." |
OK, I changed uniswapBuyOToken so that it always sends back excess ETH. Let me know if that sounds good? |
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.
LGTM
@@ -241,20 +241,33 @@ contract OptionsExchange { | |||
uniswapFactory.getExchange(address(oToken)) | |||
); | |||
|
|||
uint256 ethToTransfer = exchange.getEthToTokenOutputPrice(_amt); | |||
uint256 ethToTransfer; | |||
uint256 amount = _amt; |
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.
Awesome work 🔥 , but why here re-assigning _amt
into amount
?
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.
OpenZeppelin suggested providing a way to buy as many oTokens as msg.value can afford.
So, if _amt == 0, we get the amount from the exchange contract.
Otherwise, amount = _amt.
Then we emit the event and send the exchange transfer with amount.
Happy to do it a different way, or get rid of the _amt == 0 thing.
contracts/OptionsExchange.sol
Outdated
ethToTransfer = msg.value; | ||
amount = exchange.getTokenToEthOutputPrice(msg.value); |
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.
Here u are assigning ethToTransfer = msg.value
but using msg.value
in getTokenToEthOutputPrice
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.
they are equal, but we can switch msg.value to ethToTransfer in line 258 if that's more clear.
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 think that would be more clear!
Added a check to make sure msg.value is sufficient to purchase the amount specified.
Also added functionality to set amount = 0 and spend all of msg.value.
This is in response to openZeppelin:
"Additionally, consider implementing a way to either return any ETH deposited in excess, or trade all ETH sent for oTokens."