-
Notifications
You must be signed in to change notification settings - Fork 133
/
ShareToken.sol
77 lines (59 loc) · 2.74 KB
/
ShareToken.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
pragma solidity 0.4.20;
import 'trading/IShareToken.sol';
import 'libraries/DelegationTarget.sol';
import 'libraries/token/VariableSupplyToken.sol';
import 'libraries/ITyped.sol';
import 'libraries/Initializable.sol';
import 'reporting/IMarket.sol';
contract ShareToken is DelegationTarget, ITyped, Initializable, VariableSupplyToken, IShareToken {
string constant public name = "Shares";
uint8 constant public decimals = 0;
string constant public symbol = "SHARE";
IMarket private market;
uint256 private outcome;
function initialize(IMarket _market, uint256 _outcome) external beforeInitialized returns(bool) {
endInitialization();
market = _market;
outcome = _outcome;
return true;
}
function createShares(address _owner, uint256 _fxpValue) external onlyWhitelistedCallers returns(bool) {
mint(_owner, _fxpValue);
return true;
}
function destroyShares(address _owner, uint256 _fxpValue) external onlyWhitelistedCallers returns(bool) {
burn(_owner, _fxpValue);
return true;
}
function trustedOrderTransfer(address _source, address _destination, uint256 _attotokens) public onlyCaller("CreateOrder") onlyInGoodTimes afterInitialized returns (bool) {
return internalTransfer(_source, _destination, _attotokens);
}
function trustedFillOrderTransfer(address _source, address _destination, uint256 _attotokens) public onlyCaller("FillOrder") onlyInGoodTimes afterInitialized returns (bool) {
return internalTransfer(_source, _destination, _attotokens);
}
// Allowed to run in bad time so orders can be canceled
function trustedCancelOrderTransfer(address _source, address _destination, uint256 _attotokens) public onlyCaller("CancelOrder") afterInitialized returns (bool) {
return internalTransfer(_source, _destination, _attotokens);
}
function getTypeName() public view returns(bytes32) {
return "ShareToken";
}
function getMarket() external view returns(IMarket) {
return market;
}
function getOutcome() external view returns(uint256) {
return outcome;
}
function onTokenTransfer(address _from, address _to, uint256 _value) internal returns (bool) {
controller.getAugur().logShareTokensTransferred(market.getUniverse(), _from, _to, _value);
return true;
}
function onMint(address _target, uint256 _amount) internal returns (bool) {
controller.getAugur().logShareTokenMinted(market.getUniverse(), _target, _amount);
return true;
}
function onBurn(address _target, uint256 _amount) internal returns (bool) {
controller.getAugur().logShareTokenBurned(market.getUniverse(), _target, _amount);
return true;
}
}