use ERC20 datatype

This commit is contained in:
hueso 2023-05-22 02:13:41 -03:00
parent 9c15bfb38c
commit 2596b58e76
8 changed files with 39 additions and 35 deletions

View File

@ -1,6 +1,8 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.19;
import { ERC20 } from "../lib/tokens/ERC20.sol";
library DataTypes {
struct Lock {
uint256 sellerKey;
@ -8,7 +10,7 @@ library DataTypes {
uint256 expirationBlock;
bytes32 pixTarget;
uint80 amount;
address token;
ERC20 token;
address buyerAddress;
}

View File

@ -1,6 +1,8 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.19;
import { ERC20 } from "../lib/tokens/ERC20.sol";
// prettier-ignore
interface EventAndErrors {
/// Events
@ -9,19 +11,19 @@ interface EventAndErrors {
event DepositAdded(
address indexed seller,
// uint256 depositID,
address token,
ERC20 token,
uint256 amount
);
/// @dev 0xca585721b6b442dc9183932f7c84dc2880efb67c4da52cc06873e78971105d49
event ValidSet(
address indexed seller,
address token,
ERC20 token,
bool state
);
/// @dev 0x2cd6435b1b961c13f55202979edd0765a809f69a539d8a477436c94c1211e43e
event DepositWithdrawn(
address indexed seller,
address token,
ERC20 token,
uint256 amount
);
/// @dev 0x8fb3989f70bd172a37d15b41b015e48ea09d59329638377304a4198cd0c4ea65

View File

@ -31,7 +31,7 @@ abstract contract OwnerSettings is
uint256 defaultBlocks,
address[] memory validSigners,
address _reputation,
address[] memory tokens,
ERC20[] memory tokens,
bool[] memory tokenStates
) {
setDefaultLockBlocks(defaultBlocks);
@ -133,7 +133,7 @@ abstract contract OwnerSettings is
}
function tokenSettings(
address[] memory _tokens,
ERC20[] memory _tokens,
bool[] memory _states
) public onlyOwner {
/* Yul Impl */

View File

@ -36,7 +36,7 @@ contract P2PIX is BaseUtils {
uint256 defaultBlocks,
address[] memory validSigners,
address _reputation,
address[] memory tokens,
ERC20[] memory tokens,
bool[] memory tokenStates
)
OwnerSettings(
@ -58,7 +58,7 @@ contract P2PIX is BaseUtils {
/// as the deposit identifier.
/// @dev Function sighash: 0xbfe07da6.
function deposit(
address _token,
ERC20 _token,
uint96 _amount,
string memory _pixTarget,
bool _valid,
@ -121,7 +121,7 @@ contract P2PIX is BaseUtils {
_setValidState(key, token, _sellerBalance);
emit ValidSet(msg.sender, address(token), state);
emit ValidSet(msg.sender, token, state);
} else revert NotInitialized();
}
@ -143,14 +143,14 @@ contract P2PIX is BaseUtils {
/// @dev Function sighash: 0x03aaf306.
function lock(
address _seller,
address _token,
ERC20 _token,
uint80 _amount,
bytes32[] calldata merkleProof,
uint256[] calldata expiredLocks
) public nonReentrant returns (uint256 lockID) {
unlockExpired(expiredLocks);
ERC20 t = ERC20(_token);
ERC20 t = _token;
if (!getValid(_seller, t)) revert InvalidDeposit();
uint256 bal = getBalance(_seller, t);
@ -188,7 +188,7 @@ contract P2PIX is BaseUtils {
(block.number + defaultLockBlocks),
getPixTarget(_seller, t),
_amount,
address(t),
t,
sender
);
@ -277,12 +277,12 @@ contract P2PIX is BaseUtils {
_notExpired(l);
uint256 _sellerBalance =
__sellerBalance(l.sellerKey, ERC20(l.token)) & BITMASK_SB_ENTRY;
__sellerBalance(l.sellerKey, l.token) & BITMASK_SB_ENTRY;
if ((_sellerBalance + l.amount) > MAXBALANCE_UPPERBOUND)
revert MaxBalExceeded();
_addSellerBalance(l.sellerKey, ERC20(l.token), l.amount);
_addSellerBalance(l.sellerKey, l.token, l.amount);
l.amount = 0;
@ -344,7 +344,7 @@ contract P2PIX is BaseUtils {
emit DepositWithdrawn(
msg.sender,
address(token),
token,
amount
);
}

View File

@ -142,7 +142,7 @@ const _abi = [
},
{
indexed: false,
internalType: "address",
internalType: "contract ERC20",
name: "token",
type: "address",
},
@ -167,7 +167,7 @@ const _abi = [
},
{
indexed: false,
internalType: "address",
internalType: "contract ERC20",
name: "token",
type: "address",
},
@ -369,7 +369,7 @@ const _abi = [
},
{
indexed: false,
internalType: "address",
internalType: "contract ERC20",
name: "token",
type: "address",
},
@ -622,7 +622,7 @@ const _abi = [
{
inputs: [
{
internalType: "address[]",
internalType: "contract ERC20[]",
name: "_tokens",
type: "address[]",
},

View File

@ -135,7 +135,7 @@ const _abi = [
},
{
indexed: false,
internalType: "address",
internalType: "contract ERC20",
name: "token",
type: "address",
},
@ -160,7 +160,7 @@ const _abi = [
},
{
indexed: false,
internalType: "address",
internalType: "contract ERC20",
name: "token",
type: "address",
},
@ -343,7 +343,7 @@ const _abi = [
},
{
indexed: false,
internalType: "address",
internalType: "contract ERC20",
name: "token",
type: "address",
},

View File

@ -140,7 +140,7 @@ const _abi = [
},
{
indexed: false,
internalType: "address",
internalType: "contract ERC20",
name: "token",
type: "address",
},
@ -165,7 +165,7 @@ const _abi = [
},
{
indexed: false,
internalType: "address",
internalType: "contract ERC20",
name: "token",
type: "address",
},
@ -367,7 +367,7 @@ const _abi = [
},
{
indexed: false,
internalType: "address",
internalType: "contract ERC20",
name: "token",
type: "address",
},
@ -563,7 +563,7 @@ const _abi = [
{
inputs: [
{
internalType: "address[]",
internalType: "contract ERC20[]",
name: "_tokens",
type: "address[]",
},

File diff suppressed because one or more lines are too long