Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
JoscelynFarr committed Jan 26, 2024
1 parent aca8529 commit 763de53
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/JOJOOperation.sol
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ abstract contract JOJOOperation is JOJOStorage, IDealer {
Operation.setFastWithdrawalWhitelist(state, target, isValid);
}

function setWithdrawlWhitelist(address target, bool isValid) external onlyOwner {
Operation.setWithdrawalWhitelist(state, target, isValid);
}

function disableFastWithdraw(bool disabled) external onlyOwner {
Operation.disableFastWithdraw(state, disabled);
}
Expand Down
1 change: 1 addition & 0 deletions src/libraries/Funding.sol
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ library Funding {

if (param.length != 0) {
require(Address.isContract(to), "target is not a contract");
require(state.isWithdrawalWhitelist[to], "target is not in whiteList");
(bool success,) = to.call(param);
if (success == false) {
assembly {
Expand Down
7 changes: 7 additions & 0 deletions src/libraries/Operation.sol
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ library Operation {

event SetFastWithdrawalWhitelist(address target, bool isValid);

event SetWithdrawalWhitelist(address target, bool isValid);

event FastWithdrawDisabled(bool disabled);

event SetOperator(address indexed client, address indexed operator, bool isValid);
Expand Down Expand Up @@ -116,6 +118,11 @@ library Operation {
emit FastWithdrawDisabled(disabled);
}

function setWithdrawalWhitelist(Types.State storage state, address target, bool isValid) external {
state.isWithdrawalWhitelist[target] = isValid;
emit SetFastWithdrawalWhitelist(target, isValid);
}

function setOperator(Types.State storage state, address client, address operator, bool isValid) external {
state.operatorRegistry[client][operator] = isValid;
emit SetOperator(client, operator, isValid);
Expand Down
1 change: 1 addition & 0 deletions src/libraries/Types.sol
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ library Types {
// funding rate keeper, normally an EOA account
address fundingRateKeeper;
uint256 maxPositionAmount;
mapping(address => bool) isWithdrawalWhitelist;
}

struct Order {
Expand Down
2 changes: 1 addition & 1 deletion test/impl/DealerFundTest.sol
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ contract FundTest is Checkers {
vm.startPrank(traders[1]);
jojoDealer.fastWithdraw(traders[0], traders[0], 100e6, 0, false, "");
jojoDealer.fastWithdraw(traders[0], traders[0], 0, 100e6, false, "");
cheats.expectRevert("Ownable: caller is not the owner");
cheats.expectRevert("target is not in whiteList");
jojoDealer.fastWithdraw(
traders[1],
address(jojoDealer),
Expand Down
1 change: 1 addition & 0 deletions test/impl/Subaccount.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ contract SubaccountTest is JUSDBankInitTest {
usdc.mint(alice, 1000e6);
jusd.mint(1000e6);
jusd.transfer(alice, 1000e6);
jojoDealer.setWithdrawlWhitelist(address(jusdRepayHelper), true);
vm.startPrank(alice);
eth.approve(address(jusdBank), 10e18);
address aliceSub = subaccountFactory.newSubaccount();
Expand Down

0 comments on commit 763de53

Please sign in to comment.