Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save nmushegian/8777a842044ce83659f005022337a1b4 to your computer and use it in GitHub Desktop.
Save nmushegian/8777a842044ce83659f005022337a1b4 to your computer and use it in GitHub Desktop.
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