Created
May 25, 2016 14:09
-
-
Save nmushegian/8777a842044ce83659f005022337a1b4 to your computer and use it in GitHub Desktop.
This file contains 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
import 'erc20/erc20.sol' | |
import 'feedbase/user.sol'; | |
contract TokenOption is FeedBaseUser(0) { | |
address _beneficiary; | |
ERC20 _token; | |
ERC20 _buy_with; | |
address _optionee; | |
uint _expiration; | |
uint _price; | |
function TokenOption(ERC20 token, address beneficiary, address optionee, uint strike_price, uint event_feed_id, uint expiration) { | |
_token = token; | |
_beneficiary = beneficiary; | |
_optionee = optionee; | |
_expiration = expiration; | |
} | |
function exercise() { | |
if( msg.sender != _optionee ) { | |
throw; | |
} | |
var (value, | |
_buy_with.transferFrom(msg.sender, _beneficiary, _price); | |
_token.transfer(_optionee, _token.balanceOf(this)); | |
} | |
function reclaim() { | |
if( msg.sender != _beneficiary ) { | |
throw; | |
} | |
_token.transfer(_beneficiary, _token.balanceOf(this)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment