revamped lock() conditionals

This commit is contained in:
hueso 2023-05-22 08:44:33 -03:00
parent 631c1d5dfb
commit 6f873785aa

View File

@ -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);
/* */}/* */}/* */}
}
/// @notice Lock release method that liquidate lock