diff --git a/contracts/DataTypes.sol b/contracts/DataTypes.sol index 656094c..29f4b9f 100644 --- a/contracts/DataTypes.sol +++ b/contracts/DataTypes.sol @@ -1,6 +1,8 @@ // SPDX-License-Identifier: MIT pragma solidity 0.8.9; +import { ERC20 } from "./lib/tokens/ERC20.sol"; + library DataTypes { struct Lock { uint256 sellerKey; @@ -19,7 +21,7 @@ library DataTypes { /// @dev Relayer address (msg.sender) that facilitated this transaction. /// @dev Reputation points accruer. address relayerAddress; - address token; + ERC20 token; } // prettier-ignore diff --git a/contracts/EventAndErrors.sol b/contracts/EventAndErrors.sol index a59062d..4e7f2fd 100644 --- a/contracts/EventAndErrors.sol +++ b/contracts/EventAndErrors.sol @@ -1,6 +1,8 @@ // SPDX-License-Identifier: MIT pragma solidity 0.8.9; +import { ERC20 } from "./lib/tokens/ERC20.sol"; + // prettier-ignore interface EventAndErrors { /// ███ Events ████████████████████████████████████████████████████████████ @@ -8,17 +10,17 @@ interface EventAndErrors { event DepositAdded( address indexed seller, // uint256 depositID, - address token, + ERC20 token, uint256 amount ); event ValidSet( address indexed seller, - address token, + ERC20 token, bool state ); event DepositWithdrawn( address indexed seller, - address token, + ERC20 token, uint256 amount ); event LockAdded( diff --git a/contracts/p2pix.sol b/contracts/p2pix.sol index 3754508..f68bc1e 100644 --- a/contracts/p2pix.sol +++ b/contracts/p2pix.sol @@ -78,7 +78,7 @@ contract P2PIX is uint256 defaultBlocks, address[] memory validSigners, IReputation _reputation, - address[] memory tokens, + ERC20[] memory tokens, bool[] memory tokenStates ) payable { setDefaultLockBlocks(defaultBlocks); @@ -97,7 +97,7 @@ contract P2PIX is /// as the deposit identifier. /// @dev Function sighash: 0xbfe07da6. function deposit( - address _token, + ERC20 _token, uint96 _amount, uint160 _pixTarget, bool _valid, @@ -166,7 +166,7 @@ contract P2PIX is sellerBalance[key][token] = _sellerBalance; - emit ValidSet(msg.sender, address(token), state); + emit ValidSet(msg.sender, token, state); } else revert NotInitialized(); } @@ -191,7 +191,7 @@ contract P2PIX is /// @dev Function sighash: 0x03aaf306. function lock( address _seller, - address _token, + ERC20 _token, address _buyerAddress, address _relayerTarget, uint256 _relayerPremium, @@ -201,7 +201,7 @@ contract P2PIX is ) public nonReentrant returns (uint256) { unlockExpired(expiredLocks); - ERC20 t = ERC20(_token); + ERC20 t = _token; if (!getValid(_seller, t)) revert InvalidDeposit(); uint256 bal = getBalance(_seller, t); @@ -246,7 +246,7 @@ contract P2PIX is _buyerAddress, _relayerTarget, msg.sender, - address(t) + t ); _addLock(bal, _amount, cCounter, l, t, k); @@ -379,12 +379,12 @@ contract P2PIX is uint256 _sellerBalance = sellerBalance[ l.sellerKey - ][ERC20(l.token)] & BITMASK_SB_ENTRY; + ][l.token] & BITMASK_SB_ENTRY; if ((_sellerBalance + l.amount) > 1e8 ether) revert MaxBalExceeded(); - sellerBalance[l.sellerKey][ERC20(l.token)] += l + sellerBalance[l.sellerKey][l.token] += l .amount; l.amount = 0; @@ -448,7 +448,7 @@ contract P2PIX is emit DepositWithdrawn( msg.sender, - address(token), + token, amount ); } @@ -513,7 +513,7 @@ contract P2PIX is } function tokenSettings( - address[] memory _tokens, + ERC20[] memory _tokens, bool[] memory _states ) public onlyOwner { /* Yul Impl */