Compare commits
2 Commits
631c1d5dfb
...
9f28da6052
Author | SHA1 | Date | |
---|---|---|---|
|
9f28da6052 | ||
|
6f873785aa |
@ -31,7 +31,7 @@ library DataTypes {
|
|||||||
uint256 expirationBlock;
|
uint256 expirationBlock;
|
||||||
bytes32 pixTarget;
|
bytes32 pixTarget;
|
||||||
uint80 amount;
|
uint80 amount;
|
||||||
address token;
|
ERC20 token;
|
||||||
address buyerAddress;
|
address buyerAddress;
|
||||||
address seller;
|
address seller;
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
pragma solidity 0.8.19;
|
pragma solidity 0.8.19;
|
||||||
|
|
||||||
|
import { ERC20 } from "../lib/tokens/ERC20.sol";
|
||||||
|
|
||||||
// prettier-ignore
|
// prettier-ignore
|
||||||
interface EventAndErrors {
|
interface EventAndErrors {
|
||||||
/// ███ Events ████████████████████████████████████████████████████████████
|
/// ███ Events ████████████████████████████████████████████████████████████
|
||||||
@ -9,19 +11,19 @@ interface EventAndErrors {
|
|||||||
event DepositAdded(
|
event DepositAdded(
|
||||||
address indexed seller,
|
address indexed seller,
|
||||||
// uint256 depositID,
|
// uint256 depositID,
|
||||||
address token,
|
ERC20 token,
|
||||||
uint256 amount
|
uint256 amount
|
||||||
);
|
);
|
||||||
/// @dev 0xca585721b6b442dc9183932f7c84dc2880efb67c4da52cc06873e78971105d49
|
/// @dev 0xca585721b6b442dc9183932f7c84dc2880efb67c4da52cc06873e78971105d49
|
||||||
event ValidSet(
|
event ValidSet(
|
||||||
address indexed seller,
|
address indexed seller,
|
||||||
address token,
|
ERC20 token,
|
||||||
bool state
|
bool state
|
||||||
);
|
);
|
||||||
/// @dev 0x2cd6435b1b961c13f55202979edd0765a809f69a539d8a477436c94c1211e43e
|
/// @dev 0x2cd6435b1b961c13f55202979edd0765a809f69a539d8a477436c94c1211e43e
|
||||||
event DepositWithdrawn(
|
event DepositWithdrawn(
|
||||||
address indexed seller,
|
address indexed seller,
|
||||||
address token,
|
ERC20 token,
|
||||||
uint256 amount
|
uint256 amount
|
||||||
);
|
);
|
||||||
/// @dev 0x8fb3989f70bd172a37d15b41b015e48ea09d59329638377304a4198cd0c4ea65
|
/// @dev 0x8fb3989f70bd172a37d15b41b015e48ea09d59329638377304a4198cd0c4ea65
|
||||||
|
@ -31,7 +31,7 @@ abstract contract OwnerSettings is
|
|||||||
uint256 defaultBlocks,
|
uint256 defaultBlocks,
|
||||||
address[] memory validSigners,
|
address[] memory validSigners,
|
||||||
address _reputation,
|
address _reputation,
|
||||||
address[] memory tokens,
|
ERC20[] memory tokens,
|
||||||
bool[] memory tokenStates
|
bool[] memory tokenStates
|
||||||
) {
|
) {
|
||||||
setDefaultLockBlocks(defaultBlocks);
|
setDefaultLockBlocks(defaultBlocks);
|
||||||
@ -133,7 +133,7 @@ abstract contract OwnerSettings is
|
|||||||
}
|
}
|
||||||
|
|
||||||
function tokenSettings(
|
function tokenSettings(
|
||||||
address[] memory _tokens,
|
ERC20[] memory _tokens,
|
||||||
bool[] memory _states
|
bool[] memory _states
|
||||||
) public onlyOwner {
|
) public onlyOwner {
|
||||||
/* Yul Impl */
|
/* Yul Impl */
|
||||||
|
@ -39,7 +39,7 @@ contract P2PIX is BaseUtils {
|
|||||||
uint256 defaultBlocks,
|
uint256 defaultBlocks,
|
||||||
address[] memory validSigners,
|
address[] memory validSigners,
|
||||||
address _reputation,
|
address _reputation,
|
||||||
address[] memory tokens,
|
ERC20[] memory tokens,
|
||||||
bool[] memory tokenStates
|
bool[] memory tokenStates
|
||||||
)
|
)
|
||||||
OwnerSettings(
|
OwnerSettings(
|
||||||
@ -98,7 +98,7 @@ contract P2PIX is BaseUtils {
|
|||||||
|
|
||||||
clearReentrancyGuard();
|
clearReentrancyGuard();
|
||||||
|
|
||||||
emit DepositAdded(msg.sender, address(args.token), args.amount);
|
emit DepositAdded(msg.sender, args.token, args.amount);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @notice Enables seller to invalidate future
|
/// @notice Enables seller to invalidate future
|
||||||
@ -117,7 +117,7 @@ contract P2PIX is BaseUtils {
|
|||||||
|
|
||||||
_setValidState(msg.sender, token, _sellerBalance);
|
_setValidState(msg.sender, token, _sellerBalance);
|
||||||
|
|
||||||
emit ValidSet(msg.sender, address(token), state);
|
emit ValidSet(msg.sender, token, state);
|
||||||
} else revert NotInitialized();
|
} else revert NotInitialized();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -160,38 +160,34 @@ contract P2PIX is BaseUtils {
|
|||||||
(sender, forwarder) = _isTrustedForwarder();
|
(sender, forwarder) = _isTrustedForwarder();
|
||||||
bytes32 _pixTarget = getPixTarget(args.seller, args.token);
|
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(
|
DT.Lock memory l = DT.Lock(
|
||||||
c,
|
c,
|
||||||
(block.number + defaultLockBlocks),
|
(block.number + defaultLockBlocks),
|
||||||
_pixTarget,
|
_pixTarget,
|
||||||
args.amount,
|
args.amount,
|
||||||
address(args.token),
|
args.token,
|
||||||
sender,
|
sender,
|
||||||
args.seller
|
args.seller
|
||||||
);
|
);
|
||||||
|
|
||||||
if (args.merkleProof.length != 0) {
|
|
||||||
_merkleVerify(args.merkleProof, sellerAllowList(args.seller), sender);
|
|
||||||
lockID = _addLock(bal, l);
|
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
|
/// @notice Lock release method that liquidate lock
|
||||||
@ -272,12 +268,12 @@ contract P2PIX is BaseUtils {
|
|||||||
_notExpired(l);
|
_notExpired(l);
|
||||||
|
|
||||||
uint256 _sellerBalance =
|
uint256 _sellerBalance =
|
||||||
__sellerBalance(l.seller, ERC20(l.token)) & BITMASK_SB_ENTRY;
|
__sellerBalance(l.seller, l.token) & BITMASK_SB_ENTRY;
|
||||||
|
|
||||||
if ((_sellerBalance + l.amount) > MAXBALANCE_UPPERBOUND)
|
if ((_sellerBalance + l.amount) > MAXBALANCE_UPPERBOUND)
|
||||||
revert MaxBalExceeded();
|
revert MaxBalExceeded();
|
||||||
|
|
||||||
_addSellerBalance(l.seller, ERC20(l.token), l.amount);
|
_addSellerBalance(l.seller, l.token, l.amount);
|
||||||
|
|
||||||
l.amount = 0;
|
l.amount = 0;
|
||||||
|
|
||||||
@ -338,7 +334,7 @@ contract P2PIX is BaseUtils {
|
|||||||
|
|
||||||
emit DepositWithdrawn(
|
emit DepositWithdrawn(
|
||||||
msg.sender,
|
msg.sender,
|
||||||
address(token),
|
token,
|
||||||
amount
|
amount
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -142,7 +142,7 @@ const _abi = [
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
indexed: false,
|
indexed: false,
|
||||||
internalType: "address",
|
internalType: "contract ERC20",
|
||||||
name: "token",
|
name: "token",
|
||||||
type: "address",
|
type: "address",
|
||||||
},
|
},
|
||||||
@ -167,7 +167,7 @@ const _abi = [
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
indexed: false,
|
indexed: false,
|
||||||
internalType: "address",
|
internalType: "contract ERC20",
|
||||||
name: "token",
|
name: "token",
|
||||||
type: "address",
|
type: "address",
|
||||||
},
|
},
|
||||||
@ -369,7 +369,7 @@ const _abi = [
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
indexed: false,
|
indexed: false,
|
||||||
internalType: "address",
|
internalType: "contract ERC20",
|
||||||
name: "token",
|
name: "token",
|
||||||
type: "address",
|
type: "address",
|
||||||
},
|
},
|
||||||
@ -622,7 +622,7 @@ const _abi = [
|
|||||||
{
|
{
|
||||||
inputs: [
|
inputs: [
|
||||||
{
|
{
|
||||||
internalType: "address[]",
|
internalType: "contract ERC20[]",
|
||||||
name: "_tokens",
|
name: "_tokens",
|
||||||
type: "address[]",
|
type: "address[]",
|
||||||
},
|
},
|
||||||
|
@ -135,7 +135,7 @@ const _abi = [
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
indexed: false,
|
indexed: false,
|
||||||
internalType: "address",
|
internalType: "contract ERC20",
|
||||||
name: "token",
|
name: "token",
|
||||||
type: "address",
|
type: "address",
|
||||||
},
|
},
|
||||||
@ -160,7 +160,7 @@ const _abi = [
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
indexed: false,
|
indexed: false,
|
||||||
internalType: "address",
|
internalType: "contract ERC20",
|
||||||
name: "token",
|
name: "token",
|
||||||
type: "address",
|
type: "address",
|
||||||
},
|
},
|
||||||
@ -343,7 +343,7 @@ const _abi = [
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
indexed: false,
|
indexed: false,
|
||||||
internalType: "address",
|
internalType: "contract ERC20",
|
||||||
name: "token",
|
name: "token",
|
||||||
type: "address",
|
type: "address",
|
||||||
},
|
},
|
||||||
|
@ -140,7 +140,7 @@ const _abi = [
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
indexed: false,
|
indexed: false,
|
||||||
internalType: "address",
|
internalType: "contract ERC20",
|
||||||
name: "token",
|
name: "token",
|
||||||
type: "address",
|
type: "address",
|
||||||
},
|
},
|
||||||
@ -165,7 +165,7 @@ const _abi = [
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
indexed: false,
|
indexed: false,
|
||||||
internalType: "address",
|
internalType: "contract ERC20",
|
||||||
name: "token",
|
name: "token",
|
||||||
type: "address",
|
type: "address",
|
||||||
},
|
},
|
||||||
@ -367,7 +367,7 @@ const _abi = [
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
indexed: false,
|
indexed: false,
|
||||||
internalType: "address",
|
internalType: "contract ERC20",
|
||||||
name: "token",
|
name: "token",
|
||||||
type: "address",
|
type: "address",
|
||||||
},
|
},
|
||||||
@ -563,7 +563,7 @@ const _abi = [
|
|||||||
{
|
{
|
||||||
inputs: [
|
inputs: [
|
||||||
{
|
{
|
||||||
internalType: "address[]",
|
internalType: "contract ERC20[]",
|
||||||
name: "_tokens",
|
name: "_tokens",
|
||||||
type: "address[]",
|
type: "address[]",
|
||||||
},
|
},
|
||||||
|
File diff suppressed because one or more lines are too long
Loading…
x
Reference in New Issue
Block a user