Compare commits

2 Commits

Author SHA1 Message Date
hueso
124abb35be use ERC20 datatype 2023-05-21 19:23:57 -03:00
hueso
6c5b784782 revamped lock conditionals 2023-05-21 17:46:14 -03:00
29 changed files with 91 additions and 91 deletions

View File

@@ -1,4 +1,4 @@
{ {
"_format": "hh-sol-dbg-1", "_format": "hh-sol-dbg-1",
"buildInfo": "../../build-info/e227c161b97af39988677e65180082ec.json" "buildInfo": "../../build-info/48e41d4e5101419dba9d0e289a5fae78.json"
} }

View File

@@ -1,4 +1,4 @@
{ {
"_format": "hh-sol-dbg-1", "_format": "hh-sol-dbg-1",
"buildInfo": "../../../build-info/e227c161b97af39988677e65180082ec.json" "buildInfo": "../../../build-info/48e41d4e5101419dba9d0e289a5fae78.json"
} }

View File

@@ -133,7 +133,7 @@
}, },
{ {
"indexed": false, "indexed": false,
"internalType": "address", "internalType": "contract ERC20",
"name": "token", "name": "token",
"type": "address" "type": "address"
}, },
@@ -158,7 +158,7 @@
}, },
{ {
"indexed": false, "indexed": false,
"internalType": "address", "internalType": "contract ERC20",
"name": "token", "name": "token",
"type": "address" "type": "address"
}, },
@@ -341,7 +341,7 @@
}, },
{ {
"indexed": false, "indexed": false,
"internalType": "address", "internalType": "contract ERC20",
"name": "token", "name": "token",
"type": "address" "type": "address"
}, },
@@ -538,7 +538,7 @@
{ {
"inputs": [ "inputs": [
{ {
"internalType": "address[]", "internalType": "contract ERC20[]",
"name": "_tokens", "name": "_tokens",
"type": "address[]" "type": "address[]"
}, },

View File

@@ -1,4 +1,4 @@
{ {
"_format": "hh-sol-dbg-1", "_format": "hh-sol-dbg-1",
"buildInfo": "../../../build-info/e227c161b97af39988677e65180082ec.json" "buildInfo": "../../../build-info/48e41d4e5101419dba9d0e289a5fae78.json"
} }

View File

@@ -1,4 +1,4 @@
{ {
"_format": "hh-sol-dbg-1", "_format": "hh-sol-dbg-1",
"buildInfo": "../../../build-info/e227c161b97af39988677e65180082ec.json" "buildInfo": "../../../build-info/48e41d4e5101419dba9d0e289a5fae78.json"
} }

View File

@@ -3,8 +3,8 @@
"contractName": "DataTypes", "contractName": "DataTypes",
"sourceName": "contracts/core/DataTypes.sol", "sourceName": "contracts/core/DataTypes.sol",
"abi": [], "abi": [],
"bytecode": "0x60808060405234601757603a9081601d823930815050f35b600080fdfe600080fdfea264697066735822122078bdfdfbb98192401098df5a6389aadd2cb5cf76b3e1f5af04f14038376f40f464736f6c63430008130033", "bytecode": "0x60808060405234601757603a9081601d823930815050f35b600080fdfe600080fdfea26469706673582212209226ebeaaf7b795b2ae23b66ef299a5f0c68da0ab93c77d38a95452bea1a6eaa64736f6c63430008130033",
"deployedBytecode": "0x600080fdfea264697066735822122078bdfdfbb98192401098df5a6389aadd2cb5cf76b3e1f5af04f14038376f40f464736f6c63430008130033", "deployedBytecode": "0x600080fdfea26469706673582212209226ebeaaf7b795b2ae23b66ef299a5f0c68da0ab93c77d38a95452bea1a6eaa64736f6c63430008130033",
"linkReferences": {}, "linkReferences": {},
"deployedLinkReferences": {} "deployedLinkReferences": {}
} }

View File

@@ -1,4 +1,4 @@
{ {
"_format": "hh-sol-dbg-1", "_format": "hh-sol-dbg-1",
"buildInfo": "../../../build-info/e227c161b97af39988677e65180082ec.json" "buildInfo": "../../../build-info/48e41d4e5101419dba9d0e289a5fae78.json"
} }

View File

@@ -128,7 +128,7 @@
}, },
{ {
"indexed": false, "indexed": false,
"internalType": "address", "internalType": "contract ERC20",
"name": "token", "name": "token",
"type": "address" "type": "address"
}, },
@@ -153,7 +153,7 @@
}, },
{ {
"indexed": false, "indexed": false,
"internalType": "address", "internalType": "contract ERC20",
"name": "token", "name": "token",
"type": "address" "type": "address"
}, },
@@ -317,7 +317,7 @@
}, },
{ {
"indexed": false, "indexed": false,
"internalType": "address", "internalType": "contract ERC20",
"name": "token", "name": "token",
"type": "address" "type": "address"
}, },

View File

@@ -1,4 +1,4 @@
{ {
"_format": "hh-sol-dbg-1", "_format": "hh-sol-dbg-1",
"buildInfo": "../../../build-info/e227c161b97af39988677e65180082ec.json" "buildInfo": "../../../build-info/48e41d4e5101419dba9d0e289a5fae78.json"
} }

View File

@@ -133,7 +133,7 @@
}, },
{ {
"indexed": false, "indexed": false,
"internalType": "address", "internalType": "contract ERC20",
"name": "token", "name": "token",
"type": "address" "type": "address"
}, },
@@ -158,7 +158,7 @@
}, },
{ {
"indexed": false, "indexed": false,
"internalType": "address", "internalType": "contract ERC20",
"name": "token", "name": "token",
"type": "address" "type": "address"
}, },
@@ -341,7 +341,7 @@
}, },
{ {
"indexed": false, "indexed": false,
"internalType": "address", "internalType": "contract ERC20",
"name": "token", "name": "token",
"type": "address" "type": "address"
}, },
@@ -500,7 +500,7 @@
{ {
"inputs": [ "inputs": [
{ {
"internalType": "address[]", "internalType": "contract ERC20[]",
"name": "_tokens", "name": "_tokens",
"type": "address[]" "type": "address[]"
}, },

View File

@@ -1,4 +1,4 @@
{ {
"_format": "hh-sol-dbg-1", "_format": "hh-sol-dbg-1",
"buildInfo": "../../../../build-info/e227c161b97af39988677e65180082ec.json" "buildInfo": "../../../../build-info/48e41d4e5101419dba9d0e289a5fae78.json"
} }

View File

@@ -1,4 +1,4 @@
{ {
"_format": "hh-sol-dbg-1", "_format": "hh-sol-dbg-1",
"buildInfo": "../../../../build-info/e227c161b97af39988677e65180082ec.json" "buildInfo": "../../../../build-info/48e41d4e5101419dba9d0e289a5fae78.json"
} }

View File

@@ -1,4 +1,4 @@
{ {
"_format": "hh-sol-dbg-1", "_format": "hh-sol-dbg-1",
"buildInfo": "../../../../build-info/e227c161b97af39988677e65180082ec.json" "buildInfo": "../../../../build-info/48e41d4e5101419dba9d0e289a5fae78.json"
} }

View File

@@ -1,4 +1,4 @@
{ {
"_format": "hh-sol-dbg-1", "_format": "hh-sol-dbg-1",
"buildInfo": "../../../../build-info/e227c161b97af39988677e65180082ec.json" "buildInfo": "../../../../build-info/48e41d4e5101419dba9d0e289a5fae78.json"
} }

View File

@@ -1,4 +1,4 @@
{ {
"_format": "hh-sol-dbg-1", "_format": "hh-sol-dbg-1",
"buildInfo": "../../../../build-info/e227c161b97af39988677e65180082ec.json" "buildInfo": "../../../../build-info/48e41d4e5101419dba9d0e289a5fae78.json"
} }

View File

@@ -1,4 +1,4 @@
{ {
"_format": "hh-sol-dbg-1", "_format": "hh-sol-dbg-1",
"buildInfo": "../../../../build-info/e227c161b97af39988677e65180082ec.json" "buildInfo": "../../../../build-info/48e41d4e5101419dba9d0e289a5fae78.json"
} }

View File

@@ -1,4 +1,4 @@
{ {
"_format": "hh-sol-dbg-1", "_format": "hh-sol-dbg-1",
"buildInfo": "../../../../build-info/e227c161b97af39988677e65180082ec.json" "buildInfo": "../../../../build-info/48e41d4e5101419dba9d0e289a5fae78.json"
} }

View File

@@ -1,4 +1,4 @@
{ {
"_format": "hh-sol-dbg-1", "_format": "hh-sol-dbg-1",
"buildInfo": "../../../../build-info/e227c161b97af39988677e65180082ec.json" "buildInfo": "../../../../build-info/48e41d4e5101419dba9d0e289a5fae78.json"
} }

View File

@@ -1,4 +1,4 @@
{ {
"_format": "hh-sol-dbg-1", "_format": "hh-sol-dbg-1",
"buildInfo": "../../../../build-info/e227c161b97af39988677e65180082ec.json" "buildInfo": "../../../../build-info/48e41d4e5101419dba9d0e289a5fae78.json"
} }

View File

@@ -1,4 +1,4 @@
{ {
"_format": "hh-sol-dbg-1", "_format": "hh-sol-dbg-1",
"buildInfo": "../../build-info/e227c161b97af39988677e65180082ec.json" "buildInfo": "../../build-info/48e41d4e5101419dba9d0e289a5fae78.json"
} }

File diff suppressed because one or more lines are too long

View File

@@ -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";
library DataTypes { library DataTypes {
struct Lock { struct Lock {
uint256 sellerKey; uint256 sellerKey;
@@ -18,7 +20,7 @@ library DataTypes {
/// @dev Relayer's target address that receives `relayerPremium` funds. /// @dev Relayer's target address that receives `relayerPremium` funds.
/// @dev Reputation points accruer. /// @dev Reputation points accruer.
address relayerAddress; address relayerAddress;
address token; ERC20 token;
} }
// prettier-ignore // prettier-ignore

View File

@@ -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

View File

@@ -29,7 +29,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);
@@ -89,7 +89,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 */

View File

@@ -38,7 +38,7 @@ contract P2PIX is BaseUtils, ReentrancyGuard {
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(
@@ -60,7 +60,7 @@ contract P2PIX is BaseUtils, ReentrancyGuard {
/// as the deposit identifier. /// as the deposit identifier.
/// @dev Function sighash: 0xbfe07da6. /// @dev Function sighash: 0xbfe07da6.
function deposit( function deposit(
address _token, ERC20 _token,
uint96 _amount, uint96 _amount,
uint160 _pixTarget, uint160 _pixTarget,
bool _valid, bool _valid,
@@ -132,7 +132,7 @@ contract P2PIX is BaseUtils, ReentrancyGuard {
_setSellerBalance(key, token, _sellerBalance); _setSellerBalance(key, token, _sellerBalance);
emit ValidSet(msg.sender, address(token), state); emit ValidSet(msg.sender, token, state);
} else revert NotInitialized(); } else revert NotInitialized();
} }
@@ -156,7 +156,7 @@ contract P2PIX is BaseUtils, ReentrancyGuard {
/// @dev Function sighash: 0x03aaf306. /// @dev Function sighash: 0x03aaf306.
function lock( function lock(
address _seller, address _seller,
address _token, ERC20 _token,
address _buyerAddress, address _buyerAddress,
uint80 _relayerPremium, uint80 _relayerPremium,
uint80 _amount, uint80 _amount,
@@ -165,7 +165,7 @@ contract P2PIX is BaseUtils, ReentrancyGuard {
) public nonReentrant returns (uint256 lockID) { ) public nonReentrant returns (uint256 lockID) {
unlockExpired(expiredLocks); unlockExpired(expiredLocks);
ERC20 t = ERC20(_token); ERC20 t = _token;
if (!getValid(_seller, t)) revert InvalidDeposit(); if (!getValid(_seller, t)) revert InvalidDeposit();
uint256 bal = getBalance(_seller, t); uint256 bal = getBalance(_seller, t);
@@ -179,6 +179,18 @@ contract P2PIX is BaseUtils, ReentrancyGuard {
mapLocks[cCounter].expirationBlock >= block.number mapLocks[cCounter].expirationBlock >= block.number
) revert NotExpired(); ) revert NotExpired();
if (merkleProof.length != 0) {
_merkleVerify( merkleProof, sellerAllowList(k), msg.sender);
} else if (_amount > REPUTATION_LOWERBOUND) {
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( DT.Lock memory l = DT.Lock(
k, k,
cCounter, cCounter,
@@ -188,26 +200,10 @@ contract P2PIX is BaseUtils, ReentrancyGuard {
_amount, _amount,
_buyerAddress, _buyerAddress,
msg.sender, msg.sender,
address(t) t
); );
if (merkleProof.length != 0) { lockID = _addLock(bal, _amount, cCounter, l, t, k);
_merkleVerify( merkleProof, sellerAllowList(k), msg.sender);
lockID = _addLock(bal, _amount, cCounter, l, t, k);
} else {
if (l.amount <= REPUTATION_LOWERBOUND) {
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);
/* */}/* */}
} }
/// @notice Lock release method that liquidate lock /// @notice Lock release method that liquidate lock
@@ -314,12 +310,12 @@ contract P2PIX is BaseUtils, ReentrancyGuard {
_notExpired(l); _notExpired(l);
uint256 _sellerBalance = sellerBalance(l.sellerKey, ERC20(l.token)) & BITMASK_SB_ENTRY; uint256 _sellerBalance = sellerBalance(l.sellerKey, l.token) & BITMASK_SB_ENTRY;
if ((_sellerBalance + l.amount) > MAXBALANCE_UPPERBOUND) if ((_sellerBalance + l.amount) > MAXBALANCE_UPPERBOUND)
revert MaxBalExceeded(); revert MaxBalExceeded();
_addSellerBalance(l.sellerKey, ERC20(l.token), l.amount); _addSellerBalance(l.sellerKey, l.token, l.amount);
l.amount = 0; l.amount = 0;
@@ -381,7 +377,7 @@ contract P2PIX is BaseUtils, ReentrancyGuard {
emit DepositWithdrawn( emit DepositWithdrawn(
msg.sender, msg.sender,
address(token), token,
amount amount
); );
} }

View File

@@ -137,7 +137,7 @@ const _abi = [
}, },
{ {
indexed: false, indexed: false,
internalType: "address", internalType: "contract ERC20",
name: "token", name: "token",
type: "address", type: "address",
}, },
@@ -162,7 +162,7 @@ const _abi = [
}, },
{ {
indexed: false, indexed: false,
internalType: "address", internalType: "contract ERC20",
name: "token", name: "token",
type: "address", type: "address",
}, },
@@ -345,7 +345,7 @@ const _abi = [
}, },
{ {
indexed: false, indexed: false,
internalType: "address", internalType: "contract ERC20",
name: "token", name: "token",
type: "address", type: "address",
}, },
@@ -542,7 +542,7 @@ const _abi = [
{ {
inputs: [ inputs: [
{ {
internalType: "address[]", internalType: "contract ERC20[]",
name: "_tokens", name: "_tokens",
type: "address[]", type: "address[]",
}, },

View File

@@ -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",
}, },
@@ -324,7 +324,7 @@ const _abi = [
}, },
{ {
indexed: false, indexed: false,
internalType: "address", internalType: "contract ERC20",
name: "token", name: "token",
type: "address", type: "address",
}, },

View File

@@ -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",
}, },
@@ -348,7 +348,7 @@ const _abi = [
}, },
{ {
indexed: false, indexed: false,
internalType: "address", internalType: "contract ERC20",
name: "token", name: "token",
type: "address", type: "address",
}, },
@@ -507,7 +507,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