Skip to content

Commit abaaf21

Browse files
authored
[Loopring 3] allow withdrawal of unregistered tokens (#2439)
1 parent b26d9ca commit abaaf21

File tree

3 files changed

+64
-26
lines changed

3 files changed

+64
-26
lines changed

packages/loopring_v3/contracts/aux/access/LoopringIOExchangeOwner.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ import "../../lib/Drainable.sol";
1212
import "../../lib/ERC1271.sol";
1313
import "../../lib/MathUint.sol";
1414
import "../../lib/SignatureUtil.sol";
15-
import "./SelectorBasedAccessManager.sol";
1615
import "./ITransactionReceiver.sol";
16+
import "./SelectorBasedAccessManager.sol";
1717

1818

1919
contract LoopringIOExchangeOwner is SelectorBasedAccessManager, ERC1271, Drainable

packages/loopring_v3/contracts/core/iface/IExchangeV3.sol

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -136,16 +136,6 @@ abstract contract IExchangeV3 is Claimable
136136
view
137137
returns (IDepositContract);
138138

139-
// @dev Exchange owner withdraws fees from the exchange.
140-
// @param token Fee token address
141-
// @param feeRecipient Fee recipient address
142-
function withdrawExchangeFees(
143-
address token,
144-
address feeRecipient
145-
)
146-
external
147-
virtual;
148-
149139
// -- Constants --
150140
/// @dev Returns a list of constants used by the exchange.
151141
/// @return constants The list of constants.
@@ -652,6 +642,29 @@ abstract contract IExchangeV3 is Claimable
652642
returns (bool);
653643

654644
// -- Admins --
645+
646+
// @dev Exchange owner withdraws fees from the exchange.
647+
// @param token Fee token address
648+
// @param feeRecipient Fee recipient address
649+
function withdrawExchangeFees(
650+
address token,
651+
address feeRecipient
652+
)
653+
external
654+
virtual;
655+
656+
// @dev Exchange owner withdraws unregistered tokens from the deposit contract.
657+
// @param token Fee token address
658+
// @param to The target address
659+
// @amount The amount to withdraw.
660+
function withdrawUnregisteredToken(
661+
address token,
662+
address to,
663+
uint amount
664+
)
665+
external
666+
virtual;
667+
655668
/// @dev Sets the max time deposits have to wait before becoming withdrawable.
656669
/// @param newValue The new value.
657670
/// @return The old value.

packages/loopring_v3/contracts/core/impl/ExchangeV3.sol

Lines changed: 40 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -151,21 +151,6 @@ contract ExchangeV3 is IExchangeV3, ReentrancyGuard
151151
return state.depositContract;
152152
}
153153

154-
function withdrawExchangeFees(
155-
address token,
156-
address recipient
157-
)
158-
external
159-
override
160-
nonReentrant
161-
onlyOwner
162-
{
163-
require(recipient != address(0), "INVALID_ADDRESS");
164-
165-
uint amount = token.selfBalance();
166-
token.transferOut(recipient, amount);
167-
}
168-
169154
function isUserOrAgent(address owner)
170155
public
171156
view
@@ -662,6 +647,46 @@ contract ExchangeV3 is IExchangeV3, ReentrancyGuard
662647
}
663648

664649
// -- Admins --
650+
function withdrawExchangeFees(
651+
address token,
652+
address recipient
653+
)
654+
external
655+
override
656+
nonReentrant
657+
onlyOwner
658+
{
659+
require(recipient != address(0), "INVALID_ADDRESS");
660+
661+
uint amount = token.selfBalance();
662+
token.transferOut(recipient, amount);
663+
}
664+
665+
function withdrawUnregisteredToken(
666+
address token,
667+
address to,
668+
uint amount
669+
)
670+
external
671+
override
672+
nonReentrant
673+
onlyOwner
674+
{
675+
try this.getTokenID(token) {
676+
revert("TOKEN_REGISTERED");
677+
} catch {
678+
require(to != address(0), "INVALID_ADDRESS");
679+
require(amount > 0, "INVALID_AMOUNT");
680+
state.depositContract.withdraw(
681+
address(state.depositContract),
682+
to,
683+
token,
684+
amount,
685+
new bytes(0)
686+
);
687+
}
688+
}
689+
665690
function setMaxAgeDepositUntilWithdrawable(
666691
uint32 newValue
667692
)

0 commit comments

Comments
 (0)