-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathGxCoin.sol
More file actions
43 lines (36 loc) · 1.45 KB
/
GxCoin.sol
File metadata and controls
43 lines (36 loc) · 1.45 KB
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
pragma solidity ^0.4.2;
import './GxEditable.sol';
import './GxCallableByDeploymentAdmin.sol';
import './GxRaisesEvents.sol';
import './GxCallableByTrader.sol';
import './GxCallableByAdmin.sol';
import './GxUsesTradersProxy.sol';
import './GxUsesCoinTotals.sol';
//Externally available functions which are affected by a modifier (ie, callableByVerifiedTrader or callableByAdmin)
// should not explicitly execute a return, and should instead allow execution to reach the end of the function call
// so that additional modifier code is executed.
contract GxCoin is
GxCallableByDeploymentAdmin,
GxEditable,
GxRaisesEvents,
GxCallableByTrader,
GxCallableByAdmin,
GxUsesTradersProxy,
GxUsesCoinTotals {
bool public isTradingOpen = false;
function GxCoin(address gxDeploymentAdminsAddress) GxCallableByDeploymentAdmin(gxDeploymentAdminsAddress) {
isEditable = true;
// this is a short-circuit for `GxCallableByTrader` base contract
gxCoin = GxCoinInterface(this);
}
function setTradingOpen(bool isOpen) callableWhenEditable callableByAdmin {
isTradingOpen = isOpen;
}
function withdraw(uint80 amount) callableWhenEditable callableByTrader {
int160 balance = traders.dollarBalance(msg.sender) - int160(amount);
if (balance >= 0) {
tradersProxy.setDollarBalance(msg.sender, balance);
events.raiseDollarsWithdrew(msg.sender, amount, balance);
}
}
}