Allow call option writers to bid on spread#3
Conversation
HOOK-805 [call options] allow option writer to bid using only the spread
The option writer currently must put up the full amount of ETH to make a settlement bid. This would allow them to bid using only the difference between the strike and their spread. It also requires that all points where eth is distributed are aware of this (possible refactoring). |
jake-nyquist
left a comment
There was a problem hiding this comment.
I think we should discuss the following alternative method:
if bidder == writer:
_writerBid();
else:
_generalBid();
....
factoring out methods to return the previous high bidders funds & to distribute the assets correctly.
....
src/HookCoveredCallImplV1.sol
Outdated
| uint256 unnormalizedHighBid = call.bid; | ||
| if (call.highBidder == call.writer) { | ||
| unnormalizedHighBid -= call.strike; | ||
| } | ||
|
|
||
| // return current bidder's money | ||
| (bool sent, ) = call.highBidder.call{value: call.bid}(""); | ||
| (bool sent, ) = call.highBidder.call{value: unnormalizedHighBid}(""); | ||
| require(sent, "Failed to send Ether"); |
There was a problem hiding this comment.
my sense is that this string of logic (+ the previous logic) may have enough complexity to just be factored out into _acceptBidFromNewBidder and _returnBidToPreviousBidder
src/HookCoveredCallImplV1.sol
Outdated
|
|
||
| ) = call.writer.call{value: call.strike}(""); | ||
| require(writerSent, "Failed to send Ether to option writer"); | ||
| // If the option writer is the high bidder then they don't recieve the strike and only the underlying asset |
There was a problem hiding this comment.
... they don't receive [sp] the strike because, when they place a bid, they only paid the spread.
src/test/HookCoveredCallTests.sol
Outdated
| ); | ||
| } | ||
|
|
||
| function testWriterCanOutbidOnSpread() public { |
There was a problem hiding this comment.
I would like to see a test for these cases:
- writer gets outbid again themselves
- settlement happens in each case (writer bids first, writer bids last, writer outbid again)
- reclaiming happens in each case
- multiple options exist in the contract at once.
There was a problem hiding this comment.
in particular, I think testing the reclaim logic is important here. Even if it works now I'm concerned that future changes might be breaking for the reclaims.
|
nit: in the future, would be good to do the PR for removing all of the .gitignored files separate from this PR. |
b29eeb9 to
4f90328
Compare
src/HookCoveredCallImplV1.sol
Outdated
| ReentrancyGuard, | ||
| Initializable | ||
| Initializable, | ||
| Test |
src/HookCoveredCallImplV1.sol
Outdated
| import "./interfaces/IHookProtocol.sol"; | ||
| import "./interfaces/IWETH.sol"; | ||
|
|
||
| import "forge-std/Test.sol"; |
|
lgtm |
If the strike price of a call option is
1000 weiand the current high bid (from non option writer) is1001 weithe option writer would only need to bid2 weito become the new high bidder.This PR adds that functionality for bidding and logic for settling. Also tests for this.