revamped lock() conditionals

This commit is contained in:
hueso 2023-05-22 08:44:33 -03:00
parent 1a91b64024
commit 95463cdfa3
1 changed files with 18 additions and 23 deletions

View File

@ -162,6 +162,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(
lockID,
(block.number + defaultLockBlocks),
@ -172,29 +189,7 @@ contract P2PIX is BaseUtils {
args.seller
);
if (args.merkleProof.length != 0) {
_merkleVerify(args.merkleProof, sellerAllowList(args.seller), sender);
_addLock(bal, l);
} else {
if (l.amount <= REPUTATION_LOWERBOUND) {
_addLock(bal, l);
} else {
if (forwarder != 0) {
_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();
_addLock(bal, l);
/* */}/* */}/* */}
_addLock(bal, l);
}
/// @notice Lock release method that liquidate lock