From 6f873785aaf956313bbee42fb7cfc47571625b68 Mon Sep 17 00:00:00 2001 From: hueso Date: Mon, 22 May 2023 08:44:33 -0300 Subject: [PATCH] revamped lock() conditionals --- contracts/p2pix.sol | 40 ++++++++++++++++++---------------------- 1 file changed, 18 insertions(+), 22 deletions(-) diff --git a/contracts/p2pix.sol b/contracts/p2pix.sol index b909c2e..8e088f7 100644 --- a/contracts/p2pix.sol +++ b/contracts/p2pix.sol @@ -160,6 +160,23 @@ contract P2PIX is BaseUtils { (sender, forwarder) = _isTrustedForwarder(); bytes32 _pixTarget = getPixTarget(args.seller, args.token); + // transaction forwarding must leave `merkleProof` empty; + // otherwise, the trustedForwarder must be previously added + // to a seller whitelist. + if (args.merkleProof.length != 0) { + _merkleVerify( args.merkleProof, sellerAllowList(args.seller), sender); + + } else if (args.amount > REPUTATION_LOWERBOUND && forwarder == 0) { + + uint256 spendLimit; uint256 userCredit = + userRecord[_castAddrToKey(msg.sender)]; + (spendLimit) = _limiter(userCredit / WAD); + if ( + args.amount > (spendLimit * WAD) || + args.amount > LOCKAMOUNT_UPPERBOUND + ) revert AmountNotAllowed(); + } + DT.Lock memory l = DT.Lock( c, (block.number + defaultLockBlocks), @@ -170,28 +187,7 @@ contract P2PIX is BaseUtils { args.seller ); - if (args.merkleProof.length != 0) { - _merkleVerify(args.merkleProof, sellerAllowList(args.seller), sender); - lockID = _addLock(bal, l); - - } else { - if (l.amount <= REPUTATION_LOWERBOUND) { - lockID = _addLock(bal, l); - - } else { - if (forwarder != 0) { - lockID = _addLock(bal, l); - } else { - uint256 spendLimit; uint256 userCredit = - userRecord[_castAddrToKey(msg.sender)]; - (spendLimit) = _limiter(userCredit / WAD); - if ( - l.amount > (spendLimit * WAD) || - l.amount > LOCKAMOUNT_UPPERBOUND - ) revert AmountNotAllowed(); - lockID = _addLock(bal, l); - - /* */}/* */}/* */} + lockID = _addLock(bal, l); } /// @notice Lock release method that liquidate lock