From 9c15bfb38c91ff761da6de5e978aa8bcf84982de Mon Sep 17 00:00:00 2001 From: hueso Date: Mon, 22 May 2023 02:12:25 -0300 Subject: [PATCH] revamped lock() conditionals --- contracts/p2pix.sol | 40 ++++++++++++++++------------------------ 1 file changed, 16 insertions(+), 24 deletions(-) diff --git a/contracts/p2pix.sol b/contracts/p2pix.sol index 56569e5..053ea5e 100644 --- a/contracts/p2pix.sol +++ b/contracts/p2pix.sol @@ -167,6 +167,21 @@ contract P2PIX is BaseUtils { address sender; uint256 forwarder; (sender, forwarder) = _isTrustedForwarder(); + // transaction forwarding must leave `merkleProof` empty; + // otherwise, the trustedForwarder must be previously added + // to a seller whitelist. + if (merkleProof.length != 0) { + _merkleVerify( merkleProof, sellerAllowList(k), sender); + + } else if (_amount > REPUTATION_LOWERBOUND && forwarder == 0) { + + uint256 userCredit = userRecord[_castAddrToKey(msg.sender)]; + uint256 spendLimit; (spendLimit) = _limiter(userCredit / WAD); + if ( + _amount > (spendLimit * WAD) || _amount > LOCKAMOUNT_UPPERBOUND + ) revert AmountNotAllowed(); + } + DT.Lock memory l = DT.Lock( k, cCounter, @@ -177,30 +192,7 @@ contract P2PIX is BaseUtils { sender ); - // transaction forwarding must leave `merkleProof` empty; - // otherwise, the trustedForwarder must be previously added - // to a seller whitelist. - if (merkleProof.length != 0) { - _merkleVerify(merkleProof, sellerAllowList(k), sender); - lockID = _addLock(bal, _amount, cCounter, l, t, k); - - } else { - if (l.amount <= REPUTATION_LOWERBOUND) { - lockID = _addLock(bal, _amount, cCounter, l, t, k); - - } else { - if (forwarder != 0) { - lockID = _addLock(bal, _amount, cCounter, l, t, k); - } else { - uint256 userCredit = userRecord[_castAddrToKey(msg.sender)]; - uint256 spendLimit; (spendLimit) = _limiter(userCredit / WAD); - if ( - l.amount > (spendLimit * WAD) || - l.amount > LOCKAMOUNT_UPPERBOUND - ) revert AmountNotAllowed(); - lockID = _addLock(bal, _amount, cCounter, l, t, k); - - /* */}/* */}/* */} + lockID = _addLock(bal, _amount, cCounter, l, t, k); } /// @notice Lock release method that liquidate lock