Skip to content
This repository was archived by the owner on Mar 19, 2019. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions contracts/LoopringProtocolImpl.sol
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,6 @@ contract LoopringProtocolImpl is LoopringProtocol {
private
view
{

uint ringSize = ctx.ringSize;
Order[] memory orders = ctx.orders;

Expand Down Expand Up @@ -645,7 +644,7 @@ contract LoopringProtocolImpl is LoopringProtocol {
// If the order is selling LRC, we need to calculate how much LRC
// is left that can be used as fee.
if (order.tokenS == lrcTokenAddress) {
lrcSpendable -= order.fillAmountS;
lrcSpendable = lrcSpendable.sub(order.fillAmountS);
}

// If the order is buyign LRC, it will has more to pay as fee.
Expand All @@ -654,7 +653,7 @@ contract LoopringProtocolImpl is LoopringProtocol {
lrcReceiable = nextFillAmountS;
}

uint lrcTotal = lrcSpendable + lrcReceiable;
uint lrcTotal = lrcSpendable.add(lrcReceiable);

// If order doesn't have enough LRC, set margin split to 100%.
if (lrcTotal < order.lrcFeeState) {
Expand All @@ -673,7 +672,7 @@ contract LoopringProtocolImpl is LoopringProtocol {
order.lrcFeeState = 0;
} else {
order.splitB = lrcReceiable;
order.lrcFeeState -= lrcReceiable;
order.lrcFeeState = order.lrcFeeState.sub(lrcReceiable);
}
}
} else {
Expand Down Expand Up @@ -719,7 +718,7 @@ contract LoopringProtocolImpl is LoopringProtocol {
// be paid LRC reward first, so the orders in the ring does
// mater.
if (split > 0) {
minerLrcSpendable -= order.lrcFeeState;
minerLrcSpendable = minerLrcSpendable.sub(order.lrcFeeState);
order.lrcReward = order.lrcFeeState;
}
}
Expand Down
50 changes: 49 additions & 1 deletion contracts/TokenTransferDelegateImpl.sol
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import "./TokenTransferDelegate.sol";

/// @title An Implementation of TokenTransferDelegate.
/// @author Daniel Wang - <[email protected]>.
/// @author Kongliang Zhong - <[email protected]>.
contract TokenTransferDelegateImpl is TokenTransferDelegate, Claimable {
using MathUint for uint;

Expand All @@ -40,6 +41,9 @@ contract TokenTransferDelegateImpl is TokenTransferDelegate, Claimable {
require(_walletSplitPercentage >= 0 && _walletSplitPercentage <= 100);
walletSplitPercentage = _walletSplitPercentage;
}

bool public suspended = false;

struct AddressInfo {
address previous;
uint32 index;
Expand All @@ -55,6 +59,18 @@ contract TokenTransferDelegateImpl is TokenTransferDelegate, Claimable {
_;
}

modifier notSuspended()
{
require(!suspended);
_;
}

modifier isSuspended()
{
require(suspended);
_;
}

/// @dev Disable default function.
function ()
payable
Expand Down Expand Up @@ -134,6 +150,7 @@ contract TokenTransferDelegateImpl is TokenTransferDelegate, Claimable {
uint value
)
onlyAuthorized
notSuspended
external
{
if (value > 0 && from != to && to != 0x0) {
Expand All @@ -151,6 +168,7 @@ contract TokenTransferDelegateImpl is TokenTransferDelegate, Claimable {
bytes32[] batch
)
onlyAuthorized
notSuspended
external
{
// require(batch.length % 9 == 0);
Expand Down Expand Up @@ -306,6 +324,7 @@ contract TokenTransferDelegateImpl is TokenTransferDelegate, Claimable {
uint cancelAmount
)
onlyAuthorized
notSuspended
external
{
cancelled[orderHash] = cancelled[orderHash].add(cancelAmount);
Expand All @@ -316,15 +335,18 @@ contract TokenTransferDelegateImpl is TokenTransferDelegate, Claimable {
uint cancelOrFillAmount
)
onlyAuthorized
external
notSuspended
public
{
cancelledOrFilled[orderHash] = cancelledOrFilled[orderHash].add(cancelOrFillAmount);
}


function setCutoffs(
uint cutoff
)
onlyAuthorized
notSuspended
external
{
cutoffs[tx.origin] = cutoff;
Expand All @@ -335,6 +357,7 @@ contract TokenTransferDelegateImpl is TokenTransferDelegate, Claimable {
uint cutoff
)
onlyAuthorized
notSuspended
external
{
tradingPairCutoffs[tx.origin][tokenPair] = cutoff;
Expand All @@ -358,4 +381,29 @@ contract TokenTransferDelegateImpl is TokenTransferDelegate, Claimable {
}
}

function suspend()
onlyOwner
notSuspended
public
{
suspended = true;
}

function resume()
onlyOwner
isSuspended
public
{
suspended = false;
}

/// owner must suspend delegate first before invoke kill method.
function kill()
onlyOwner
isSuspended
external
{
owner = 0x0;
emit OwnershipTransferred(owner, 0x0);
}
}