-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathGxCallableByTrader.sol
More file actions
35 lines (27 loc) · 953 Bytes
/
GxCallableByTrader.sol
File metadata and controls
35 lines (27 loc) · 953 Bytes
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
pragma solidity ^0.4.2;
import './GxCallableByDeploymentAdmin.sol';
import './GxUsesConstants.sol';
import './GxUsesTraders.sol';
import './GxUsesWallet.sol';
import './GxCoinInterface.sol';
contract GxCallableByTrader is GxCallableByDeploymentAdmin, GxUsesConstants, GxUsesTraders, GxUsesWallet {
GxCoinInterface public gxCoin;
function setGxCoinContract(address gxCoinAddress) public callableByDeploymentAdmin {
gxCoin = GxCoinInterface(gxCoinAddress);
}
modifier callableByTrader {
uint initialGas = msg.gas;
if (traders.contains(msg.sender)) {
if (gxCoin.isTradingOpen()) {
_;
}
uint refund = tx.gasprice * (initialGas - msg.gas + constants.REFUND_EXTRA_GAS());
if (!wallet.pay(msg.sender, refund)) {
// TODO: should this throw?
//throw;
}
} else {
throw;
}
}
}