🏗️
This commit is contained in:
parent
545887baec
commit
0b9b0307d2
@ -6,6 +6,7 @@
|
|||||||
|
|
||||||
```rs
|
```rs
|
||||||
./contracts/
|
./contracts/
|
||||||
|
├── Constants.sol
|
||||||
├── DataTypes.sol
|
├── DataTypes.sol
|
||||||
├── EventAndErrors.sol
|
├── EventAndErrors.sol
|
||||||
├── lib
|
├── lib
|
||||||
@ -18,6 +19,7 @@
|
|||||||
│ ├── tokens
|
│ ├── tokens
|
||||||
│ │ └── ERC20.sol
|
│ │ └── ERC20.sol
|
||||||
│ └── utils
|
│ └── utils
|
||||||
|
│ ├── ECDSA.sol
|
||||||
│ ├── MerkleProofLib.sol
|
│ ├── MerkleProofLib.sol
|
||||||
│ ├── Multicall.sol
|
│ ├── Multicall.sol
|
||||||
│ ├── ReentrancyGuard.sol
|
│ ├── ReentrancyGuard.sol
|
||||||
|
4
artifacts/contracts/Constants.sol/Constants.dbg.json
Normal file
4
artifacts/contracts/Constants.sol/Constants.dbg.json
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
{
|
||||||
|
"_format": "hh-sol-dbg-1",
|
||||||
|
"buildInfo": "../../build-info/249d92249de0943da88155e04b92fb7f.json"
|
||||||
|
}
|
10
artifacts/contracts/Constants.sol/Constants.json
Normal file
10
artifacts/contracts/Constants.sol/Constants.json
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
{
|
||||||
|
"_format": "hh-sol-artifact-1",
|
||||||
|
"contractName": "Constants",
|
||||||
|
"sourceName": "contracts/Constants.sol",
|
||||||
|
"abi": [],
|
||||||
|
"bytecode": "0x",
|
||||||
|
"deployedBytecode": "0x",
|
||||||
|
"linkReferences": {},
|
||||||
|
"deployedLinkReferences": {}
|
||||||
|
}
|
@ -1,4 +1,4 @@
|
|||||||
{
|
{
|
||||||
"_format": "hh-sol-dbg-1",
|
"_format": "hh-sol-dbg-1",
|
||||||
"buildInfo": "../../build-info/cec3ec245aa8292dcd32990ec72987ab.json"
|
"buildInfo": "../../build-info/3511ccc4f632d4fc1741b59d8fb89855.json"
|
||||||
}
|
}
|
||||||
|
@ -3,8 +3,8 @@
|
|||||||
"contractName": "DataTypes",
|
"contractName": "DataTypes",
|
||||||
"sourceName": "contracts/DataTypes.sol",
|
"sourceName": "contracts/DataTypes.sol",
|
||||||
"abi": [],
|
"abi": [],
|
||||||
"bytecode": "0x60808060405234601757603a9081601d823930815050f35b600080fdfe600080fdfea26469706673582212206adb3dae064942e78abcd2b6adb116d65e8b719b79e9f02514e62a1b01f8a03b64736f6c63430008130033",
|
"bytecode": "0x60808060405234601757603a9081601d823930815050f35b600080fdfe600080fdfea2646970667358221220e2b83942b5818cc4f73c29200b41672c082782c77a5936ed5de9e316913cd2d264736f6c63430008130033",
|
||||||
"deployedBytecode": "0x600080fdfea26469706673582212206adb3dae064942e78abcd2b6adb116d65e8b719b79e9f02514e62a1b01f8a03b64736f6c63430008130033",
|
"deployedBytecode": "0x600080fdfea2646970667358221220e2b83942b5818cc4f73c29200b41672c082782c77a5936ed5de9e316913cd2d264736f6c63430008130033",
|
||||||
"linkReferences": {},
|
"linkReferences": {},
|
||||||
"deployedLinkReferences": {}
|
"deployedLinkReferences": {}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
{
|
{
|
||||||
"_format": "hh-sol-dbg-1",
|
"_format": "hh-sol-dbg-1",
|
||||||
"buildInfo": "../../build-info/cec3ec245aa8292dcd32990ec72987ab.json"
|
"buildInfo": "../../build-info/6c3e670658cfbeb3de636ecbaa8ad53a.json"
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
{
|
{
|
||||||
"_format": "hh-sol-dbg-1",
|
"_format": "hh-sol-dbg-1",
|
||||||
"buildInfo": "../../build-info/906fc0dd8b27e18481e135d1f328d0ae.json"
|
"buildInfo": "../../build-info/6c3e670658cfbeb3de636ecbaa8ad53a.json"
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
{
|
{
|
||||||
"_format": "hh-sol-dbg-1",
|
"_format": "hh-sol-dbg-1",
|
||||||
"buildInfo": "../../../../build-info/b608b6eb28957aeb71328924500ce935.json"
|
"buildInfo": "../../../../build-info/6c3e670658cfbeb3de636ecbaa8ad53a.json"
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
{
|
{
|
||||||
"_format": "hh-sol-dbg-1",
|
"_format": "hh-sol-dbg-1",
|
||||||
"buildInfo": "../../../../build-info/cec3ec245aa8292dcd32990ec72987ab.json"
|
"buildInfo": "../../../../build-info/6c3e670658cfbeb3de636ecbaa8ad53a.json"
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
{
|
{
|
||||||
"_format": "hh-sol-dbg-1",
|
"_format": "hh-sol-dbg-1",
|
||||||
"buildInfo": "../../../../build-info/cec3ec245aa8292dcd32990ec72987ab.json"
|
"buildInfo": "../../../../build-info/6c3e670658cfbeb3de636ecbaa8ad53a.json"
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
{
|
{
|
||||||
"_format": "hh-sol-dbg-1",
|
"_format": "hh-sol-dbg-1",
|
||||||
"buildInfo": "../../../../build-info/cec3ec245aa8292dcd32990ec72987ab.json"
|
"buildInfo": "../../../../build-info/6c3e670658cfbeb3de636ecbaa8ad53a.json"
|
||||||
}
|
}
|
||||||
|
4
artifacts/contracts/lib/utils/ECDSA.sol/ECDSA.dbg.json
Normal file
4
artifacts/contracts/lib/utils/ECDSA.sol/ECDSA.dbg.json
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
{
|
||||||
|
"_format": "hh-sol-dbg-1",
|
||||||
|
"buildInfo": "../../../../build-info/7e64ed907e656944d305af383d70ed0c.json"
|
||||||
|
}
|
16
artifacts/contracts/lib/utils/ECDSA.sol/ECDSA.json
Normal file
16
artifacts/contracts/lib/utils/ECDSA.sol/ECDSA.json
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
{
|
||||||
|
"_format": "hh-sol-artifact-1",
|
||||||
|
"contractName": "ECDSA",
|
||||||
|
"sourceName": "contracts/lib/utils/ECDSA.sol",
|
||||||
|
"abi": [
|
||||||
|
{
|
||||||
|
"inputs": [],
|
||||||
|
"name": "InvalidSignature",
|
||||||
|
"type": "error"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"bytecode": "0x60808060405234601757603a9081601d823930815050f35b600080fdfe600080fdfea26469706673582212201f6fe8a460e1235bb7e19365d8e3cc56b718d44f5db82f5fa3c90d3c7da59ebf64736f6c63430008130033",
|
||||||
|
"deployedBytecode": "0x600080fdfea26469706673582212201f6fe8a460e1235bb7e19365d8e3cc56b718d44f5db82f5fa3c90d3c7da59ebf64736f6c63430008130033",
|
||||||
|
"linkReferences": {},
|
||||||
|
"deployedLinkReferences": {}
|
||||||
|
}
|
@ -1,4 +1,4 @@
|
|||||||
{
|
{
|
||||||
"_format": "hh-sol-dbg-1",
|
"_format": "hh-sol-dbg-1",
|
||||||
"buildInfo": "../../../../build-info/cec3ec245aa8292dcd32990ec72987ab.json"
|
"buildInfo": "../../../../build-info/6c3e670658cfbeb3de636ecbaa8ad53a.json"
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
{
|
{
|
||||||
"_format": "hh-sol-dbg-1",
|
"_format": "hh-sol-dbg-1",
|
||||||
"buildInfo": "../../../../build-info/cec3ec245aa8292dcd32990ec72987ab.json"
|
"buildInfo": "../../../../build-info/6c3e670658cfbeb3de636ecbaa8ad53a.json"
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
{
|
{
|
||||||
"_format": "hh-sol-dbg-1",
|
"_format": "hh-sol-dbg-1",
|
||||||
"buildInfo": "../../../../build-info/cec3ec245aa8292dcd32990ec72987ab.json"
|
"buildInfo": "../../../../build-info/6c3e670658cfbeb3de636ecbaa8ad53a.json"
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
{
|
{
|
||||||
"_format": "hh-sol-dbg-1",
|
"_format": "hh-sol-dbg-1",
|
||||||
"buildInfo": "../../../../build-info/cec3ec245aa8292dcd32990ec72987ab.json"
|
"buildInfo": "../../../../build-info/6c3e670658cfbeb3de636ecbaa8ad53a.json"
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
{
|
{
|
||||||
"_format": "hh-sol-dbg-1",
|
"_format": "hh-sol-dbg-1",
|
||||||
"buildInfo": "../../build-info/b608b6eb28957aeb71328924500ce935.json"
|
"buildInfo": "../../build-info/249d92249de0943da88155e04b92fb7f.json"
|
||||||
}
|
}
|
||||||
|
File diff suppressed because one or more lines are too long
49
contracts/Constants.sol
Normal file
49
contracts/Constants.sol
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
pragma solidity 0.8.19;
|
||||||
|
|
||||||
|
abstract contract Constants {
|
||||||
|
/// ███ Constants ██████████████████████████████████████████████████████████
|
||||||
|
|
||||||
|
uint256 constant _ROOT_UPDATED_EVENT_SIGNATURE =
|
||||||
|
0x0b294da292f26e55fd442b5c0164fbb9013036ff00c5cfdde0efd01c1baaf632;
|
||||||
|
uint256 constant _ALLOWED_ERC20_UPDATED_EVENT_SIGNATURE =
|
||||||
|
0x5d6e86e5341d57a92c49934296c51542a25015c9b1782a1c2722a940131c3d9a;
|
||||||
|
|
||||||
|
/// @dev Seller casted to key => Seller's allowlist merkleroot.
|
||||||
|
/// mapping(uint256 => bytes32) public sellerAllowList;
|
||||||
|
uint256 constant _SELLER_ALLOWLIST_SLOT_SEED = 0x74dfee70;
|
||||||
|
/// @dev Tokens allowed to serve as the underlying amount of a deposit.
|
||||||
|
/// mapping(ERC20 => bool) public allowedERC20s;
|
||||||
|
uint256 constant _ALLOWED_ERC20_SLOT_SEED = 0xcbc9d1c4;
|
||||||
|
|
||||||
|
/// @dev `balance` max. value = 10**26.
|
||||||
|
/// @dev `pixTarget` keys are restricted to 160 bits.
|
||||||
|
/// mapping(uint256 => mapping(ERC20 => uint256)) public sellerBalance;
|
||||||
|
|
||||||
|
/// @dev Bits layout:
|
||||||
|
/// `uint96` [0...94] := balance
|
||||||
|
/// `uint160` [95...254] := pixTarget
|
||||||
|
/// `bool` [255] := valid
|
||||||
|
|
||||||
|
/// @dev Value in custom storage slot given by:
|
||||||
|
/// mstore(0x20, token)
|
||||||
|
/// mstore(0x0c, _SELLER_BALANCE_SLOT_SEED)
|
||||||
|
/// mstore(0x00, seller)
|
||||||
|
/// let value := sload(keccak256(0x0c, 0x34)).
|
||||||
|
uint256 constant _SELLER_BALANCE_SLOT_SEED = 0x739094b1;
|
||||||
|
|
||||||
|
/// @dev The bitmask of `sellerBalance` entry.
|
||||||
|
uint256 constant BITMASK_SB_ENTRY = (1 << 94) - 1;
|
||||||
|
/// @dev The bit position of `pixTarget` in `sellerBalance`.
|
||||||
|
uint256 constant BITPOS_PIXTARGET = 95;
|
||||||
|
/// @dev The bit position of `valid` in `sellerBalance`.
|
||||||
|
uint256 constant BITPOS_VALID = 255;
|
||||||
|
/// @dev The bitmask of all 256 bits of `sellerBalance` except for the last one.
|
||||||
|
uint256 constant BITMASK_VALID = (1 << 255) - 1;
|
||||||
|
|
||||||
|
/// @dev The scalar of BRZ token.
|
||||||
|
uint256 constant WAD = 1e18;
|
||||||
|
uint256 constant MAXBALANCE_UPPERBOUND = 1e8 ether;
|
||||||
|
uint256 constant REPUTATION_LOWERBOUND = 1e2 ether;
|
||||||
|
uint256 constant LOCKAMOUNT_UPPERBOUND = 1e6 ether;
|
||||||
|
}
|
@ -5,14 +5,14 @@ library DataTypes {
|
|||||||
struct Lock {
|
struct Lock {
|
||||||
uint256 sellerKey;
|
uint256 sellerKey;
|
||||||
uint256 counter;
|
uint256 counter;
|
||||||
/// @dev Amount to be paid for relayer.
|
|
||||||
uint256 relayerPremium;
|
|
||||||
/// @dev Amount to be tranfered via PIX.
|
|
||||||
uint256 amount;
|
|
||||||
/// @dev If not paid at this block will be expired.
|
/// @dev If not paid at this block will be expired.
|
||||||
uint256 expirationBlock;
|
uint256 expirationBlock;
|
||||||
uint160 pixTarget;
|
uint160 pixTarget;
|
||||||
|
/// @dev Amount to be paid for relayer.
|
||||||
|
uint80 relayerPremium;
|
||||||
/// @dev Where the tokens are sent the when order gets validated.
|
/// @dev Where the tokens are sent the when order gets validated.
|
||||||
|
/// @dev Amount to be tranfered via PIX.
|
||||||
|
uint80 amount;
|
||||||
address buyerAddress;
|
address buyerAddress;
|
||||||
/// @dev Relayer address (msg.sender) that facilitated this transaction.
|
/// @dev Relayer address (msg.sender) that facilitated this transaction.
|
||||||
/// @dev Relayer's target address that receives `relayerPremium` funds.
|
/// @dev Relayer's target address that receives `relayerPremium` funds.
|
||||||
|
78
contracts/lib/utils/ECDSA.sol
Normal file
78
contracts/lib/utils/ECDSA.sol
Normal file
@ -0,0 +1,78 @@
|
|||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
pragma solidity >=0.8.4;
|
||||||
|
|
||||||
|
/// @notice Gas optimized ECDSA wrapper.
|
||||||
|
/// @author Solady (https://github.com/vectorized/solady/blob/main/src/utils/ECDSA.sol)
|
||||||
|
/// @author Modified from Solmate (https://github.com/transmissions11/solmate/blob/main/src/utils/ECDSA.sol)
|
||||||
|
/// @author Modified from OpenZeppelin (https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/cryptography/ECDSA.sol)
|
||||||
|
library ECDSA {
|
||||||
|
/// @dev The signature is invalid.
|
||||||
|
error InvalidSignature();
|
||||||
|
|
||||||
|
/// @dev The number which `s` must not exceed in order for
|
||||||
|
/// the signature to be non-malleable.
|
||||||
|
bytes32 private constant _MALLEABILITY_THRESHOLD =
|
||||||
|
0x7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a0;
|
||||||
|
|
||||||
|
/// @dev Recovers the signer's address from a message digest `hash`,
|
||||||
|
/// and the signature defined by `v`, `r`, `s`.
|
||||||
|
function recover(
|
||||||
|
bytes32 hash,
|
||||||
|
uint8 v,
|
||||||
|
bytes32 r,
|
||||||
|
bytes32 s
|
||||||
|
) internal view returns (address result) {
|
||||||
|
/// @solidity memory-safe-assembly
|
||||||
|
assembly {
|
||||||
|
// Copy the free memory pointer so that we can restore it later.
|
||||||
|
let m := mload(0x40)
|
||||||
|
mstore(0x00, hash)
|
||||||
|
mstore(0x20, and(v, 0xff))
|
||||||
|
mstore(0x40, r)
|
||||||
|
mstore(0x60, s)
|
||||||
|
pop(
|
||||||
|
staticcall(
|
||||||
|
gas(), // Amount of gas left for the transaction.
|
||||||
|
// If `s` in lower half order, such that the signature is not malleable.
|
||||||
|
lt(s, add(_MALLEABILITY_THRESHOLD, 1)), // Address of `ecrecover`.
|
||||||
|
0x00, // Start of input.
|
||||||
|
0x80, // Size of input.
|
||||||
|
0x00, // Start of output.
|
||||||
|
0x20 // Size of output.
|
||||||
|
)
|
||||||
|
)
|
||||||
|
result := mload(0x00)
|
||||||
|
// `returndatasize()` will be `0x20` upon success, and `0x00` otherwise.
|
||||||
|
if iszero(returndatasize()) {
|
||||||
|
// Store the function selector of `InvalidSignature()`.
|
||||||
|
mstore(0x00, 0x8baa579f)
|
||||||
|
// Revert with (offset, size).
|
||||||
|
revert(0x1c, 0x04)
|
||||||
|
}
|
||||||
|
// Restore the zero slot.
|
||||||
|
mstore(0x60, 0)
|
||||||
|
// Restore the free memory pointer.
|
||||||
|
mstore(0x40, m)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @dev Returns an Ethereum Signed Message, created from a `hash`.
|
||||||
|
/// This produces a hash corresponding to the one signed with the
|
||||||
|
/// [`eth_sign`](https://eth.wiki/json-rpc/API#eth_sign)
|
||||||
|
/// JSON-RPC method as part of EIP-191.
|
||||||
|
function toEthSignedMessageHash(
|
||||||
|
bytes32 hash
|
||||||
|
) internal pure returns (bytes32 result) {
|
||||||
|
/// @solidity memory-safe-assembly
|
||||||
|
assembly {
|
||||||
|
// Store into scratch space for keccak256.
|
||||||
|
mstore(0x20, hash)
|
||||||
|
mstore(
|
||||||
|
0x00,
|
||||||
|
"\x00\x00\x00\x00\x19Ethereum Signed Message:\n32"
|
||||||
|
)
|
||||||
|
// 0x40 - 0x04 = 0x3c
|
||||||
|
result := keccak256(0x04, 0x3c)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -12,11 +12,15 @@ import { Owned } from "./lib/auth/Owned.sol";
|
|||||||
import { ERC20, SafeTransferLib } from "./lib/utils/SafeTransferLib.sol";
|
import { ERC20, SafeTransferLib } from "./lib/utils/SafeTransferLib.sol";
|
||||||
import { IReputation } from "./lib/interfaces/IReputation.sol";
|
import { IReputation } from "./lib/interfaces/IReputation.sol";
|
||||||
import { MerkleProofLib as Merkle } from "./lib/utils/MerkleProofLib.sol";
|
import { MerkleProofLib as Merkle } from "./lib/utils/MerkleProofLib.sol";
|
||||||
|
import { ECDSA } from "./lib/utils/ECDSA.sol";
|
||||||
import { ReentrancyGuard } from "./lib/utils/ReentrancyGuard.sol";
|
import { ReentrancyGuard } from "./lib/utils/ReentrancyGuard.sol";
|
||||||
import { EventAndErrors } from "./EventAndErrors.sol";
|
import { EventAndErrors } from "./EventAndErrors.sol";
|
||||||
import { DataTypes as DT } from "./DataTypes.sol";
|
import { DataTypes as DT } from "./DataTypes.sol";
|
||||||
|
import { Constants } from "./Constants.sol";
|
||||||
|
|
||||||
|
|
||||||
contract P2PIX is
|
contract P2PIX is
|
||||||
|
Constants,
|
||||||
EventAndErrors,
|
EventAndErrors,
|
||||||
Owned(msg.sender),
|
Owned(msg.sender),
|
||||||
ReentrancyGuard
|
ReentrancyGuard
|
||||||
@ -28,53 +32,17 @@ contract P2PIX is
|
|||||||
using DT for DT.Lock;
|
using DT for DT.Lock;
|
||||||
using DT for DT.LockStatus;
|
using DT for DT.LockStatus;
|
||||||
|
|
||||||
/// ███ Constants ██████████████████████████████████████████████████████████
|
|
||||||
|
|
||||||
uint256 private constant _ROOT_UPDATED_EVENT_SIGNATURE =
|
|
||||||
0x0b294da292f26e55fd442b5c0164fbb9013036ff00c5cfdde0efd01c1baaf632;
|
|
||||||
uint256 private constant _ALLOWED_ERC20_UPDATED_EVENT_SIGNATURE =
|
|
||||||
0x5d6e86e5341d57a92c49934296c51542a25015c9b1782a1c2722a940131c3d9a;
|
|
||||||
|
|
||||||
/// @dev Seller casted to key => Seller's allowlist merkleroot.
|
|
||||||
/// mapping(uint256 => bytes32) public sellerAllowList;
|
|
||||||
uint256 private constant _SELLER_ALLOWLIST_SLOT_SEED = 0x74dfee70;
|
|
||||||
/// @dev Tokens allowed to serve as the underlying amount of a deposit.
|
|
||||||
/// mapping(ERC20 => bool) public allowedERC20s;
|
|
||||||
uint256 private constant _ALLOWED_ERC20_SLOT_SEED = 0xcbc9d1c4;
|
|
||||||
|
|
||||||
// BITS LAYOUT
|
|
||||||
// `uint96` [0...94] := balance
|
|
||||||
// `uint160` [95...254] := pixTarget
|
|
||||||
// `bool` [255] := valid
|
|
||||||
|
|
||||||
/// @dev `balance` max. value = 10**26.
|
|
||||||
/// @dev `pixTarget` keys are restricted to 160 bits.
|
|
||||||
// mapping(uint256 => mapping(ERC20 => uint256)) public sellerBalance;
|
|
||||||
uint256 private constant _SELLER_BALANCE_SLOT_SEED = 0x739094b1;
|
|
||||||
|
|
||||||
/// @dev The bitmask of `sellerBalance` entry.
|
|
||||||
uint256 private constant BITMASK_SB_ENTRY = (1 << 94) - 1;
|
|
||||||
/// @dev The bit position of `pixTarget` in `sellerBalance`.
|
|
||||||
uint256 private constant BITPOS_PIXTARGET = 95;
|
|
||||||
/// @dev The bit position of `valid` in `sellerBalance`.
|
|
||||||
uint256 private constant BITPOS_VALID = 255;
|
|
||||||
/// @dev The bitmask of all 256 bits of `sellerBalance` except for the last one.
|
|
||||||
uint256 private constant BITMASK_VALID = (1 << 255) - 1;
|
|
||||||
|
|
||||||
/// @dev The scalar of BRZ token.
|
|
||||||
uint256 public constant WAD = 1e18;
|
|
||||||
|
|
||||||
/// ███ Storage ████████████████████████████████████████████████████████████
|
/// ███ Storage ████████████████████████████████████████████████████████████
|
||||||
|
|
||||||
/// @dev List of valid Bacen signature addresses
|
/// @dev List of valid Bacen signature addresses
|
||||||
|
/// mapping(uint256 => bool) public validBacenSigners;
|
||||||
/// @dev Value in custom storage slot given by:
|
/// @dev Value in custom storage slot given by:
|
||||||
/// let slot := sload(shl(12, address)).
|
/// let value := sload(shl(12, address)).
|
||||||
// mapping(uint256 => bool) public validBacenSigners;
|
|
||||||
|
|
||||||
/// @dev List of Pix transactions already signed.
|
/// @dev List of Pix transactions already signed.
|
||||||
|
/// mapping(bytes32 => bool) public usedTransactions;
|
||||||
/// @dev Value in custom storage slot given by:
|
/// @dev Value in custom storage slot given by:
|
||||||
/// let slot := sload(bytes32).
|
/// let value := sload(bytes32).
|
||||||
// mapping(bytes32 => bool) public usedTransactions;
|
|
||||||
|
|
||||||
IReputation public reputation;
|
IReputation public reputation;
|
||||||
|
|
||||||
@ -126,7 +94,7 @@ contract P2PIX is
|
|||||||
uint256 _sellerBalance = sellerBalance(k,t);
|
uint256 _sellerBalance = sellerBalance(k,t);
|
||||||
|
|
||||||
uint256 currBal = _sellerBalance & BITMASK_SB_ENTRY;
|
uint256 currBal = _sellerBalance & BITMASK_SB_ENTRY;
|
||||||
if ((currBal + _amount) > 1e8 ether)
|
if ((currBal + _amount) > MAXBALANCE_UPPERBOUND)
|
||||||
revert MaxBalExceeded();
|
revert MaxBalExceeded();
|
||||||
|
|
||||||
setReentrancyGuard();
|
setReentrancyGuard();
|
||||||
@ -210,12 +178,11 @@ contract P2PIX is
|
|||||||
address _seller,
|
address _seller,
|
||||||
address _token,
|
address _token,
|
||||||
address _buyerAddress,
|
address _buyerAddress,
|
||||||
// address _relayerTarget,
|
uint80 _relayerPremium,
|
||||||
uint256 _relayerPremium,
|
uint80 _amount,
|
||||||
uint256 _amount,
|
|
||||||
bytes32[] calldata merkleProof,
|
bytes32[] calldata merkleProof,
|
||||||
uint256[] calldata expiredLocks
|
uint256[] calldata expiredLocks
|
||||||
) public nonReentrant returns (uint256) {
|
) public nonReentrant returns (uint256 lockID) {
|
||||||
unlockExpired(expiredLocks);
|
unlockExpired(expiredLocks);
|
||||||
|
|
||||||
ERC20 t = ERC20(_token);
|
ERC20 t = ERC20(_token);
|
||||||
@ -235,58 +202,32 @@ contract P2PIX is
|
|||||||
DT.Lock memory l = DT.Lock(
|
DT.Lock memory l = DT.Lock(
|
||||||
k,
|
k,
|
||||||
cCounter,
|
cCounter,
|
||||||
_relayerPremium,
|
|
||||||
_amount,
|
|
||||||
(block.number + defaultLockBlocks),
|
(block.number + defaultLockBlocks),
|
||||||
uint160(sellerBalance(k, t) >> BITPOS_PIXTARGET),
|
uint160(sellerBalance(k, t) >> BITPOS_PIXTARGET),
|
||||||
|
_relayerPremium,
|
||||||
|
_amount,
|
||||||
_buyerAddress,
|
_buyerAddress,
|
||||||
// _relayerTarget,
|
|
||||||
msg.sender,
|
msg.sender,
|
||||||
address(t)
|
address(t)
|
||||||
);
|
);
|
||||||
|
|
||||||
if (merkleProof.length != 0) {
|
if (merkleProof.length != 0) {
|
||||||
_merkleVerify(
|
_merkleVerify( merkleProof, sellerAllowList(k), msg.sender);
|
||||||
merkleProof,
|
lockID = _addLock(bal, _amount, cCounter, l, t, k);
|
||||||
sellerAllowList(k),
|
|
||||||
msg.sender
|
|
||||||
);
|
|
||||||
|
|
||||||
_addLock(bal, _amount, cCounter, l, t, k);
|
|
||||||
|
|
||||||
lockCounter++;
|
|
||||||
|
|
||||||
// Halt execution and output `lockID`.
|
|
||||||
return cCounter;
|
|
||||||
} else {
|
} else {
|
||||||
if (l.amount <= 1e2 ether) {
|
if (l.amount <= REPUTATION_LOWERBOUND) {
|
||||||
_addLock(bal, _amount, cCounter, l, t, k);
|
lockID = _addLock(bal, _amount, cCounter, l, t, k);
|
||||||
|
|
||||||
lockCounter++;
|
} 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);
|
||||||
|
|
||||||
// Halt execution and output `lockID`.
|
/* */}/* */}
|
||||||
return cCounter;
|
|
||||||
} else {
|
|
||||||
uint256 userCredit = userRecord[
|
|
||||||
_castAddrToKey(msg.sender)
|
|
||||||
];
|
|
||||||
|
|
||||||
uint256 spendLimit;
|
|
||||||
(spendLimit) = _limiter(userCredit / WAD);
|
|
||||||
|
|
||||||
if (
|
|
||||||
l.amount > (spendLimit * WAD) ||
|
|
||||||
l.amount > 1e6 ether
|
|
||||||
) revert AmountNotAllowed();
|
|
||||||
|
|
||||||
_addLock(bal, _amount, cCounter, l, t, k);
|
|
||||||
|
|
||||||
lockCounter++;
|
|
||||||
|
|
||||||
// Halt execution and output `lockID`.
|
|
||||||
return cCounter;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @notice Lock release method that liquidate lock
|
/// @notice Lock release method that liquidate lock
|
||||||
@ -294,7 +235,7 @@ contract P2PIX is
|
|||||||
/// @dev This method can be called by any public actor
|
/// @dev This method can be called by any public actor
|
||||||
/// as long the signature provided is valid.
|
/// as long the signature provided is valid.
|
||||||
/// @dev `relayerPremium` gets splitted equaly
|
/// @dev `relayerPremium` gets splitted equaly
|
||||||
/// if `relayerTarget` addresses differ.
|
/// if relayer addresses differ.
|
||||||
/// @dev If the `msg.sender` of this method and `l.relayerAddress` are the same,
|
/// @dev If the `msg.sender` of this method and `l.relayerAddress` are the same,
|
||||||
/// `msg.sender` accrues both l.amount and l.relayerPremium as userRecord credit.
|
/// `msg.sender` accrues both l.amount and l.relayerPremium as userRecord credit.
|
||||||
/// In case of they differing:
|
/// In case of they differing:
|
||||||
@ -303,7 +244,6 @@ contract P2PIX is
|
|||||||
/// @dev Function sighash: 0x4e1389ed.
|
/// @dev Function sighash: 0x4e1389ed.
|
||||||
function release(
|
function release(
|
||||||
uint256 lockID,
|
uint256 lockID,
|
||||||
// address _relayerTarget,
|
|
||||||
bytes32 pixTimestamp,
|
bytes32 pixTimestamp,
|
||||||
bytes32 r,
|
bytes32 r,
|
||||||
bytes32 s,
|
bytes32 s,
|
||||||
@ -322,22 +262,13 @@ contract P2PIX is
|
|||||||
pixTimestamp
|
pixTimestamp
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
bytes32 messageDigest = keccak256(
|
|
||||||
abi.encodePacked(
|
|
||||||
"\x19Ethereum Signed Message:\n32",
|
|
||||||
message
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
if (usedTransactions(message) == true)
|
if (usedTransactions(message)) revert TxAlreadyUsed();
|
||||||
revert TxAlreadyUsed();
|
|
||||||
|
|
||||||
uint256 signer = _castAddrToKey(
|
if (!validBacenSigners(_castAddrToKey(
|
||||||
ecrecover(messageDigest, v, r, s)
|
ECDSA.recover(
|
||||||
);
|
ECDSA.toEthSignedMessageHash(message), v, r, s)
|
||||||
|
))) revert InvalidSigner();
|
||||||
if (!validBacenSigners(signer))
|
|
||||||
revert InvalidSigner();
|
|
||||||
|
|
||||||
ERC20 t = ERC20(l.token);
|
ERC20 t = ERC20(l.token);
|
||||||
|
|
||||||
@ -410,7 +341,7 @@ contract P2PIX is
|
|||||||
|
|
||||||
uint256 _sellerBalance = sellerBalance(l.sellerKey, ERC20(l.token)) & BITMASK_SB_ENTRY;
|
uint256 _sellerBalance = sellerBalance(l.sellerKey, ERC20(l.token)) & BITMASK_SB_ENTRY;
|
||||||
|
|
||||||
if ((_sellerBalance + l.amount) > 1e8 ether)
|
if ((_sellerBalance + l.amount) > MAXBALANCE_UPPERBOUND)
|
||||||
revert MaxBalExceeded();
|
revert MaxBalExceeded();
|
||||||
|
|
||||||
_addSellerBalance(l.sellerKey, ERC20(l.token), l.amount);
|
_addSellerBalance(l.sellerKey, ERC20(l.token), l.amount);
|
||||||
@ -423,8 +354,8 @@ contract P2PIX is
|
|||||||
uint256 _newUserRecord = (userRecord[userKey] >>
|
uint256 _newUserRecord = (userRecord[userKey] >>
|
||||||
1);
|
1);
|
||||||
|
|
||||||
if (_newUserRecord <= 1e2 ether) {
|
if (_newUserRecord <= REPUTATION_LOWERBOUND) {
|
||||||
userRecord[userKey] = 1e2 ether;
|
userRecord[userKey] = REPUTATION_LOWERBOUND;
|
||||||
} else {
|
} else {
|
||||||
userRecord[userKey] = _newUserRecord;
|
userRecord[userKey] = _newUserRecord;
|
||||||
}
|
}
|
||||||
@ -455,9 +386,8 @@ contract P2PIX is
|
|||||||
) public nonReentrant {
|
) public nonReentrant {
|
||||||
unlockExpired(expiredLocks);
|
unlockExpired(expiredLocks);
|
||||||
|
|
||||||
if (getValid(msg.sender, token) == true) {
|
if (getValid(msg.sender, token))
|
||||||
setValidState(token, false);
|
setValidState(token, false);
|
||||||
}
|
|
||||||
|
|
||||||
uint256 key = _castAddrToKey(msg.sender);
|
uint256 key = _castAddrToKey(msg.sender);
|
||||||
_decBal(
|
_decBal(
|
||||||
@ -623,10 +553,12 @@ contract P2PIX is
|
|||||||
DT.Lock memory _l,
|
DT.Lock memory _l,
|
||||||
ERC20 _t,
|
ERC20 _t,
|
||||||
uint256 _k
|
uint256 _k
|
||||||
) internal {
|
) internal returns(uint256 counter){
|
||||||
mapLocks[_lockID] = _l;
|
mapLocks[_lockID] = _l;
|
||||||
|
|
||||||
_decBal(_bal, _amount, _t, _k);
|
_decBal(_bal, _amount, _t, _k);
|
||||||
|
lockCounter++;
|
||||||
|
counter = _lockID;
|
||||||
|
|
||||||
emit LockAdded(
|
emit LockAdded(
|
||||||
_l.buyerAddress,
|
_l.buyerAddress,
|
||||||
@ -655,16 +587,11 @@ contract P2PIX is
|
|||||||
view
|
view
|
||||||
returns (uint256 _spendLimit)
|
returns (uint256 _spendLimit)
|
||||||
{
|
{
|
||||||
// enconde the fx sighash and args
|
|
||||||
bytes memory encodedParams = abi.encodeWithSelector(
|
bytes memory encodedParams = abi.encodeWithSelector(
|
||||||
IReputation.limiter.selector,
|
IReputation.limiter.selector,
|
||||||
_userCredit
|
_userCredit
|
||||||
);
|
);
|
||||||
// cast the uninitialized return values to memory
|
|
||||||
bool success;
|
bool success;
|
||||||
// uint256 returnSize;
|
|
||||||
// uint256 returnValue;
|
|
||||||
// perform staticcall from the stack w yul
|
|
||||||
assembly {
|
assembly {
|
||||||
success := staticcall(
|
success := staticcall(
|
||||||
// gas
|
// gas
|
||||||
@ -680,11 +607,7 @@ contract P2PIX is
|
|||||||
// retSize
|
// retSize
|
||||||
0x20
|
0x20
|
||||||
)
|
)
|
||||||
// returnSize := returndatasize()
|
|
||||||
// returnValue := mload(0x00)
|
|
||||||
// _spendLimit := returnValue
|
|
||||||
_spendLimit := mload(0x00)
|
_spendLimit := mload(0x00)
|
||||||
// reverts if call does not succeed.
|
|
||||||
if iszero(success) {
|
if iszero(success) {
|
||||||
// StaticCallFailed()
|
// StaticCallFailed()
|
||||||
mstore(0x00, 0xe10bf1cc)
|
mstore(0x00, 0xe10bf1cc)
|
||||||
|
@ -113,10 +113,16 @@ const config: HardhatUserConfig = {
|
|||||||
version: "0.8.19",
|
version: "0.8.19",
|
||||||
settings: {
|
settings: {
|
||||||
viaIR: true,
|
viaIR: true,
|
||||||
|
evmVersion: "paris",
|
||||||
optimizer: {
|
optimizer: {
|
||||||
enabled: true,
|
enabled: true,
|
||||||
runs: 20_000,
|
runs: 20_000,
|
||||||
details: {
|
details: {
|
||||||
|
deduplicate: true,
|
||||||
|
cse: true,
|
||||||
|
constantOptimizer: true,
|
||||||
|
peephole: true,
|
||||||
|
jumpdestRemover: true,
|
||||||
yul: true,
|
yul: true,
|
||||||
yulDetails: {
|
yulDetails: {
|
||||||
stackAllocation: true,
|
stackAllocation: true,
|
||||||
|
62
src/types/factories/lib/utils/ECDSA__factory.ts
Normal file
62
src/types/factories/lib/utils/ECDSA__factory.ts
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
/* Autogenerated file. Do not edit manually. */
|
||||||
|
/* tslint:disable */
|
||||||
|
/* eslint-disable */
|
||||||
|
import { Signer, utils, Contract, ContractFactory, Overrides } from "ethers";
|
||||||
|
import type { Provider, TransactionRequest } from "@ethersproject/providers";
|
||||||
|
import type { PromiseOrValue } from "../../../common";
|
||||||
|
import type { ECDSA, ECDSAInterface } from "../../../lib/utils/ECDSA";
|
||||||
|
|
||||||
|
const _abi = [
|
||||||
|
{
|
||||||
|
inputs: [],
|
||||||
|
name: "InvalidSignature",
|
||||||
|
type: "error",
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
const _bytecode =
|
||||||
|
"0x60808060405234601757603a9081601d823930815050f35b600080fdfe600080fdfea26469706673582212201f6fe8a460e1235bb7e19365d8e3cc56b718d44f5db82f5fa3c90d3c7da59ebf64736f6c63430008130033";
|
||||||
|
|
||||||
|
type ECDSAConstructorParams =
|
||||||
|
| [signer?: Signer]
|
||||||
|
| ConstructorParameters<typeof ContractFactory>;
|
||||||
|
|
||||||
|
const isSuperArgs = (
|
||||||
|
xs: ECDSAConstructorParams
|
||||||
|
): xs is ConstructorParameters<typeof ContractFactory> => xs.length > 1;
|
||||||
|
|
||||||
|
export class ECDSA__factory extends ContractFactory {
|
||||||
|
constructor(...args: ECDSAConstructorParams) {
|
||||||
|
if (isSuperArgs(args)) {
|
||||||
|
super(...args);
|
||||||
|
} else {
|
||||||
|
super(_abi, _bytecode, args[0]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override deploy(
|
||||||
|
overrides?: Overrides & { from?: PromiseOrValue<string> }
|
||||||
|
): Promise<ECDSA> {
|
||||||
|
return super.deploy(overrides || {}) as Promise<ECDSA>;
|
||||||
|
}
|
||||||
|
override getDeployTransaction(
|
||||||
|
overrides?: Overrides & { from?: PromiseOrValue<string> }
|
||||||
|
): TransactionRequest {
|
||||||
|
return super.getDeployTransaction(overrides || {});
|
||||||
|
}
|
||||||
|
override attach(address: string): ECDSA {
|
||||||
|
return super.attach(address) as ECDSA;
|
||||||
|
}
|
||||||
|
override connect(signer: Signer): ECDSA__factory {
|
||||||
|
return super.connect(signer) as ECDSA__factory;
|
||||||
|
}
|
||||||
|
|
||||||
|
static readonly bytecode = _bytecode;
|
||||||
|
static readonly abi = _abi;
|
||||||
|
static createInterface(): ECDSAInterface {
|
||||||
|
return new utils.Interface(_abi) as ECDSAInterface;
|
||||||
|
}
|
||||||
|
static connect(address: string, signerOrProvider: Signer | Provider): ECDSA {
|
||||||
|
return new Contract(address, _abi, signerOrProvider) as ECDSA;
|
||||||
|
}
|
||||||
|
}
|
@ -1,6 +1,7 @@
|
|||||||
/* Autogenerated file. Do not edit manually. */
|
/* Autogenerated file. Do not edit manually. */
|
||||||
/* tslint:disable */
|
/* tslint:disable */
|
||||||
/* eslint-disable */
|
/* eslint-disable */
|
||||||
|
export { ECDSA__factory } from "./ECDSA__factory";
|
||||||
export { Multicall__factory } from "./Multicall__factory";
|
export { Multicall__factory } from "./Multicall__factory";
|
||||||
export { ReentrancyGuard__factory } from "./ReentrancyGuard__factory";
|
export { ReentrancyGuard__factory } from "./ReentrancyGuard__factory";
|
||||||
export { SafeTransferLib__factory } from "./SafeTransferLib__factory";
|
export { SafeTransferLib__factory } from "./SafeTransferLib__factory";
|
||||||
|
File diff suppressed because one or more lines are too long
9
src/types/hardhat.d.ts
vendored
9
src/types/hardhat.d.ts
vendored
@ -32,6 +32,10 @@ declare module "hardhat/types/runtime" {
|
|||||||
name: "ERC20",
|
name: "ERC20",
|
||||||
signerOrOptions?: ethers.Signer | FactoryOptions
|
signerOrOptions?: ethers.Signer | FactoryOptions
|
||||||
): Promise<Contracts.ERC20__factory>;
|
): Promise<Contracts.ERC20__factory>;
|
||||||
|
getContractFactory(
|
||||||
|
name: "ECDSA",
|
||||||
|
signerOrOptions?: ethers.Signer | FactoryOptions
|
||||||
|
): Promise<Contracts.ECDSA__factory>;
|
||||||
getContractFactory(
|
getContractFactory(
|
||||||
name: "Multicall",
|
name: "Multicall",
|
||||||
signerOrOptions?: ethers.Signer | FactoryOptions
|
signerOrOptions?: ethers.Signer | FactoryOptions
|
||||||
@ -78,6 +82,11 @@ declare module "hardhat/types/runtime" {
|
|||||||
address: string,
|
address: string,
|
||||||
signer?: ethers.Signer
|
signer?: ethers.Signer
|
||||||
): Promise<Contracts.ERC20>;
|
): Promise<Contracts.ERC20>;
|
||||||
|
getContractAt(
|
||||||
|
name: "ECDSA",
|
||||||
|
address: string,
|
||||||
|
signer?: ethers.Signer
|
||||||
|
): Promise<Contracts.ECDSA>;
|
||||||
getContractAt(
|
getContractAt(
|
||||||
name: "Multicall",
|
name: "Multicall",
|
||||||
address: string,
|
address: string,
|
||||||
|
@ -17,6 +17,8 @@ export type { MockToken } from "./lib/mock/mockToken.sol/MockToken";
|
|||||||
export { MockToken__factory } from "./factories/lib/mock/mockToken.sol/MockToken__factory";
|
export { MockToken__factory } from "./factories/lib/mock/mockToken.sol/MockToken__factory";
|
||||||
export type { ERC20 } from "./lib/tokens/ERC20";
|
export type { ERC20 } from "./lib/tokens/ERC20";
|
||||||
export { ERC20__factory } from "./factories/lib/tokens/ERC20__factory";
|
export { ERC20__factory } from "./factories/lib/tokens/ERC20__factory";
|
||||||
|
export type { ECDSA } from "./lib/utils/ECDSA";
|
||||||
|
export { ECDSA__factory } from "./factories/lib/utils/ECDSA__factory";
|
||||||
export type { Multicall } from "./lib/utils/Multicall";
|
export type { Multicall } from "./lib/utils/Multicall";
|
||||||
export { Multicall__factory } from "./factories/lib/utils/Multicall__factory";
|
export { Multicall__factory } from "./factories/lib/utils/Multicall__factory";
|
||||||
export type { ReentrancyGuard } from "./lib/utils/ReentrancyGuard";
|
export type { ReentrancyGuard } from "./lib/utils/ReentrancyGuard";
|
||||||
|
56
src/types/lib/utils/ECDSA.ts
Normal file
56
src/types/lib/utils/ECDSA.ts
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
/* Autogenerated file. Do not edit manually. */
|
||||||
|
/* tslint:disable */
|
||||||
|
/* eslint-disable */
|
||||||
|
import type { BaseContract, Signer, utils } from "ethers";
|
||||||
|
|
||||||
|
import type { Listener, Provider } from "@ethersproject/providers";
|
||||||
|
import type {
|
||||||
|
TypedEventFilter,
|
||||||
|
TypedEvent,
|
||||||
|
TypedListener,
|
||||||
|
OnEvent,
|
||||||
|
PromiseOrValue,
|
||||||
|
} from "../../common";
|
||||||
|
|
||||||
|
export interface ECDSAInterface extends utils.Interface {
|
||||||
|
functions: {};
|
||||||
|
|
||||||
|
events: {};
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ECDSA extends BaseContract {
|
||||||
|
connect(signerOrProvider: Signer | Provider | string): this;
|
||||||
|
attach(addressOrName: string): this;
|
||||||
|
deployed(): Promise<this>;
|
||||||
|
|
||||||
|
interface: ECDSAInterface;
|
||||||
|
|
||||||
|
queryFilter<TEvent extends TypedEvent>(
|
||||||
|
event: TypedEventFilter<TEvent>,
|
||||||
|
fromBlockOrBlockhash?: string | number | undefined,
|
||||||
|
toBlock?: string | number | undefined
|
||||||
|
): Promise<Array<TEvent>>;
|
||||||
|
|
||||||
|
listeners<TEvent extends TypedEvent>(
|
||||||
|
eventFilter?: TypedEventFilter<TEvent>
|
||||||
|
): Array<TypedListener<TEvent>>;
|
||||||
|
listeners(eventName?: string): Array<Listener>;
|
||||||
|
removeAllListeners<TEvent extends TypedEvent>(
|
||||||
|
eventFilter: TypedEventFilter<TEvent>
|
||||||
|
): this;
|
||||||
|
removeAllListeners(eventName?: string): this;
|
||||||
|
off: OnEvent<this>;
|
||||||
|
on: OnEvent<this>;
|
||||||
|
once: OnEvent<this>;
|
||||||
|
removeListener: OnEvent<this>;
|
||||||
|
|
||||||
|
functions: {};
|
||||||
|
|
||||||
|
callStatic: {};
|
||||||
|
|
||||||
|
filters: {};
|
||||||
|
|
||||||
|
estimateGas: {};
|
||||||
|
|
||||||
|
populateTransaction: {};
|
||||||
|
}
|
@ -1,6 +1,7 @@
|
|||||||
/* Autogenerated file. Do not edit manually. */
|
/* Autogenerated file. Do not edit manually. */
|
||||||
/* tslint:disable */
|
/* tslint:disable */
|
||||||
/* eslint-disable */
|
/* eslint-disable */
|
||||||
|
export type { ECDSA } from "./ECDSA";
|
||||||
export type { Multicall } from "./Multicall";
|
export type { Multicall } from "./Multicall";
|
||||||
export type { ReentrancyGuard } from "./ReentrancyGuard";
|
export type { ReentrancyGuard } from "./ReentrancyGuard";
|
||||||
export type { SafeTransferLib } from "./SafeTransferLib";
|
export type { SafeTransferLib } from "./SafeTransferLib";
|
||||||
|
@ -29,7 +29,6 @@ import type {
|
|||||||
|
|
||||||
export interface P2PIXInterface extends utils.Interface {
|
export interface P2PIXInterface extends utils.Interface {
|
||||||
functions: {
|
functions: {
|
||||||
"WAD()": FunctionFragment;
|
|
||||||
"_castAddrToKey(address)": FunctionFragment;
|
"_castAddrToKey(address)": FunctionFragment;
|
||||||
"_castKeyToAddr(uint256)": FunctionFragment;
|
"_castKeyToAddr(uint256)": FunctionFragment;
|
||||||
"allowedERC20s(address)": FunctionFragment;
|
"allowedERC20s(address)": FunctionFragment;
|
||||||
@ -40,7 +39,7 @@ export interface P2PIXInterface extends utils.Interface {
|
|||||||
"getLocksStatus(uint256[])": FunctionFragment;
|
"getLocksStatus(uint256[])": FunctionFragment;
|
||||||
"getPixTarget(address,address)": FunctionFragment;
|
"getPixTarget(address,address)": FunctionFragment;
|
||||||
"getValid(address,address)": FunctionFragment;
|
"getValid(address,address)": FunctionFragment;
|
||||||
"lock(address,address,address,uint256,uint256,bytes32[],uint256[])": FunctionFragment;
|
"lock(address,address,address,uint80,uint80,bytes32[],uint256[])": FunctionFragment;
|
||||||
"lockCounter()": FunctionFragment;
|
"lockCounter()": FunctionFragment;
|
||||||
"mapLocks(uint256)": FunctionFragment;
|
"mapLocks(uint256)": FunctionFragment;
|
||||||
"owner()": FunctionFragment;
|
"owner()": FunctionFragment;
|
||||||
@ -65,7 +64,6 @@ export interface P2PIXInterface extends utils.Interface {
|
|||||||
|
|
||||||
getFunction(
|
getFunction(
|
||||||
nameOrSignatureOrTopic:
|
nameOrSignatureOrTopic:
|
||||||
| "WAD"
|
|
||||||
| "_castAddrToKey"
|
| "_castAddrToKey"
|
||||||
| "_castKeyToAddr"
|
| "_castKeyToAddr"
|
||||||
| "allowedERC20s"
|
| "allowedERC20s"
|
||||||
@ -99,7 +97,6 @@ export interface P2PIXInterface extends utils.Interface {
|
|||||||
| "withdrawBalance"
|
| "withdrawBalance"
|
||||||
): FunctionFragment;
|
): FunctionFragment;
|
||||||
|
|
||||||
encodeFunctionData(functionFragment: "WAD", values?: undefined): string;
|
|
||||||
encodeFunctionData(
|
encodeFunctionData(
|
||||||
functionFragment: "_castAddrToKey",
|
functionFragment: "_castAddrToKey",
|
||||||
values: [PromiseOrValue<string>]
|
values: [PromiseOrValue<string>]
|
||||||
@ -246,7 +243,6 @@ export interface P2PIXInterface extends utils.Interface {
|
|||||||
values?: undefined
|
values?: undefined
|
||||||
): string;
|
): string;
|
||||||
|
|
||||||
decodeFunctionResult(functionFragment: "WAD", data: BytesLike): Result;
|
|
||||||
decodeFunctionResult(
|
decodeFunctionResult(
|
||||||
functionFragment: "_castAddrToKey",
|
functionFragment: "_castAddrToKey",
|
||||||
data: BytesLike
|
data: BytesLike
|
||||||
@ -545,8 +541,6 @@ export interface P2PIX extends BaseContract {
|
|||||||
removeListener: OnEvent<this>;
|
removeListener: OnEvent<this>;
|
||||||
|
|
||||||
functions: {
|
functions: {
|
||||||
WAD(overrides?: CallOverrides): Promise<[BigNumber]>;
|
|
||||||
|
|
||||||
_castAddrToKey(
|
_castAddrToKey(
|
||||||
_addr: PromiseOrValue<string>,
|
_addr: PromiseOrValue<string>,
|
||||||
overrides?: CallOverrides
|
overrides?: CallOverrides
|
||||||
@ -632,10 +626,10 @@ export interface P2PIX extends BaseContract {
|
|||||||
] & {
|
] & {
|
||||||
sellerKey: BigNumber;
|
sellerKey: BigNumber;
|
||||||
counter: BigNumber;
|
counter: BigNumber;
|
||||||
relayerPremium: BigNumber;
|
|
||||||
amount: BigNumber;
|
|
||||||
expirationBlock: BigNumber;
|
expirationBlock: BigNumber;
|
||||||
pixTarget: BigNumber;
|
pixTarget: BigNumber;
|
||||||
|
relayerPremium: BigNumber;
|
||||||
|
amount: BigNumber;
|
||||||
buyerAddress: string;
|
buyerAddress: string;
|
||||||
relayerAddress: string;
|
relayerAddress: string;
|
||||||
token: string;
|
token: string;
|
||||||
@ -736,8 +730,6 @@ export interface P2PIX extends BaseContract {
|
|||||||
): Promise<ContractTransaction>;
|
): Promise<ContractTransaction>;
|
||||||
};
|
};
|
||||||
|
|
||||||
WAD(overrides?: CallOverrides): Promise<BigNumber>;
|
|
||||||
|
|
||||||
_castAddrToKey(
|
_castAddrToKey(
|
||||||
_addr: PromiseOrValue<string>,
|
_addr: PromiseOrValue<string>,
|
||||||
overrides?: CallOverrides
|
overrides?: CallOverrides
|
||||||
@ -823,10 +815,10 @@ export interface P2PIX extends BaseContract {
|
|||||||
] & {
|
] & {
|
||||||
sellerKey: BigNumber;
|
sellerKey: BigNumber;
|
||||||
counter: BigNumber;
|
counter: BigNumber;
|
||||||
relayerPremium: BigNumber;
|
|
||||||
amount: BigNumber;
|
|
||||||
expirationBlock: BigNumber;
|
expirationBlock: BigNumber;
|
||||||
pixTarget: BigNumber;
|
pixTarget: BigNumber;
|
||||||
|
relayerPremium: BigNumber;
|
||||||
|
amount: BigNumber;
|
||||||
buyerAddress: string;
|
buyerAddress: string;
|
||||||
relayerAddress: string;
|
relayerAddress: string;
|
||||||
token: string;
|
token: string;
|
||||||
@ -927,8 +919,6 @@ export interface P2PIX extends BaseContract {
|
|||||||
): Promise<ContractTransaction>;
|
): Promise<ContractTransaction>;
|
||||||
|
|
||||||
callStatic: {
|
callStatic: {
|
||||||
WAD(overrides?: CallOverrides): Promise<BigNumber>;
|
|
||||||
|
|
||||||
_castAddrToKey(
|
_castAddrToKey(
|
||||||
_addr: PromiseOrValue<string>,
|
_addr: PromiseOrValue<string>,
|
||||||
overrides?: CallOverrides
|
overrides?: CallOverrides
|
||||||
@ -1014,10 +1004,10 @@ export interface P2PIX extends BaseContract {
|
|||||||
] & {
|
] & {
|
||||||
sellerKey: BigNumber;
|
sellerKey: BigNumber;
|
||||||
counter: BigNumber;
|
counter: BigNumber;
|
||||||
relayerPremium: BigNumber;
|
|
||||||
amount: BigNumber;
|
|
||||||
expirationBlock: BigNumber;
|
expirationBlock: BigNumber;
|
||||||
pixTarget: BigNumber;
|
pixTarget: BigNumber;
|
||||||
|
relayerPremium: BigNumber;
|
||||||
|
amount: BigNumber;
|
||||||
buyerAddress: string;
|
buyerAddress: string;
|
||||||
relayerAddress: string;
|
relayerAddress: string;
|
||||||
token: string;
|
token: string;
|
||||||
@ -1231,8 +1221,6 @@ export interface P2PIX extends BaseContract {
|
|||||||
};
|
};
|
||||||
|
|
||||||
estimateGas: {
|
estimateGas: {
|
||||||
WAD(overrides?: CallOverrides): Promise<BigNumber>;
|
|
||||||
|
|
||||||
_castAddrToKey(
|
_castAddrToKey(
|
||||||
_addr: PromiseOrValue<string>,
|
_addr: PromiseOrValue<string>,
|
||||||
overrides?: CallOverrides
|
overrides?: CallOverrides
|
||||||
@ -1401,8 +1389,6 @@ export interface P2PIX extends BaseContract {
|
|||||||
};
|
};
|
||||||
|
|
||||||
populateTransaction: {
|
populateTransaction: {
|
||||||
WAD(overrides?: CallOverrides): Promise<PopulatedTransaction>;
|
|
||||||
|
|
||||||
_castAddrToKey(
|
_castAddrToKey(
|
||||||
_addr: PromiseOrValue<string>,
|
_addr: PromiseOrValue<string>,
|
||||||
overrides?: CallOverrides
|
overrides?: CallOverrides
|
||||||
|
@ -850,7 +850,7 @@ describe("P2PIX", () => {
|
|||||||
const endtoendID = ethers.constants.HashZero;
|
const endtoendID = ethers.constants.HashZero;
|
||||||
const target = ethers.BigNumber.from(101);
|
const target = ethers.BigNumber.from(101);
|
||||||
const messageToSign = ethers.utils.solidityKeccak256(
|
const messageToSign = ethers.utils.solidityKeccak256(
|
||||||
["uint160", "uint256", "bytes32"],
|
["uint160", "uint80", "bytes32"],
|
||||||
[target, price, endtoendID],
|
[target, price, endtoendID],
|
||||||
);
|
);
|
||||||
const messageHashBytes =
|
const messageHashBytes =
|
||||||
@ -1257,7 +1257,7 @@ describe("P2PIX", () => {
|
|||||||
it("should revert if lock has expired", async () => {
|
it("should revert if lock has expired", async () => {
|
||||||
const target = ethers.BigNumber.from(101);
|
const target = ethers.BigNumber.from(101);
|
||||||
const messageToSign = ethers.utils.solidityKeccak256(
|
const messageToSign = ethers.utils.solidityKeccak256(
|
||||||
["uint160", "uint256", "bytes32"],
|
["uint160", "uint80", "bytes32"],
|
||||||
[target, 100, ethers.constants.HashZero],
|
[target, 100, ethers.constants.HashZero],
|
||||||
);
|
);
|
||||||
const flatSig = await acc01.signMessage(
|
const flatSig = await acc01.signMessage(
|
||||||
@ -1302,7 +1302,7 @@ describe("P2PIX", () => {
|
|||||||
const target = ethers.BigNumber.from("1");
|
const target = ethers.BigNumber.from("1");
|
||||||
const hashZero = ethers.constants.HashZero;
|
const hashZero = ethers.constants.HashZero;
|
||||||
const messageToSign = ethers.utils.solidityKeccak256(
|
const messageToSign = ethers.utils.solidityKeccak256(
|
||||||
["uint160", "uint256", "bytes32"],
|
["uint160", "uint80", "bytes32"],
|
||||||
[target, 100, hashZero],
|
[target, 100, hashZero],
|
||||||
);
|
);
|
||||||
const flatSig = await acc01.signMessage(
|
const flatSig = await acc01.signMessage(
|
||||||
@ -1352,7 +1352,7 @@ describe("P2PIX", () => {
|
|||||||
it("should revert if signed message has already been used", async () => {
|
it("should revert if signed message has already been used", async () => {
|
||||||
const target = ethers.BigNumber.from(101);
|
const target = ethers.BigNumber.from(101);
|
||||||
const messageToSign = ethers.utils.solidityKeccak256(
|
const messageToSign = ethers.utils.solidityKeccak256(
|
||||||
["uint160", "uint256", "bytes32"],
|
["uint160", "uint80", "bytes32"],
|
||||||
[target, 100, ethers.constants.HashZero],
|
[target, 100, ethers.constants.HashZero],
|
||||||
);
|
);
|
||||||
const flatSig = await owner.signMessage(
|
const flatSig = await owner.signMessage(
|
||||||
@ -1417,7 +1417,7 @@ describe("P2PIX", () => {
|
|||||||
it("should revert if ecrecovered signer is invalid", async () => {
|
it("should revert if ecrecovered signer is invalid", async () => {
|
||||||
const target = ethers.BigNumber.from(101);
|
const target = ethers.BigNumber.from(101);
|
||||||
const messageToSign = ethers.utils.solidityKeccak256(
|
const messageToSign = ethers.utils.solidityKeccak256(
|
||||||
["uint160", "uint256", "bytes32"],
|
["uint160", "uint80", "bytes32"],
|
||||||
[target, 100, ethers.constants.HashZero],
|
[target, 100, ethers.constants.HashZero],
|
||||||
);
|
);
|
||||||
const flatSig = await acc03.signMessage(
|
const flatSig = await acc03.signMessage(
|
||||||
@ -1464,7 +1464,7 @@ describe("P2PIX", () => {
|
|||||||
const endtoendID = ethers.constants.HashZero;
|
const endtoendID = ethers.constants.HashZero;
|
||||||
const pixTarget = ethers.BigNumber.from(101);
|
const pixTarget = ethers.BigNumber.from(101);
|
||||||
const messageToSign = ethers.utils.solidityKeccak256(
|
const messageToSign = ethers.utils.solidityKeccak256(
|
||||||
["uint160", "uint256", "bytes32"],
|
["uint160", "uint80", "bytes32"],
|
||||||
[pixTarget, 100, endtoendID],
|
[pixTarget, 100, endtoendID],
|
||||||
);
|
);
|
||||||
// Note: messageToSign is a string, that is 66-bytes long, to sign the
|
// Note: messageToSign is a string, that is 66-bytes long, to sign the
|
||||||
@ -1632,7 +1632,7 @@ describe("P2PIX", () => {
|
|||||||
acc03Key,
|
acc03Key,
|
||||||
);
|
);
|
||||||
const messageToSign1 = ethers.utils.solidityKeccak256(
|
const messageToSign1 = ethers.utils.solidityKeccak256(
|
||||||
["uint160", "uint256", "bytes32"],
|
["uint160", "uint80", "bytes32"],
|
||||||
[pixTarget, 100, endtoendID],
|
[pixTarget, 100, endtoendID],
|
||||||
);
|
);
|
||||||
const flatSig1 = await owner.signMessage(
|
const flatSig1 = await owner.signMessage(
|
||||||
@ -1640,7 +1640,7 @@ describe("P2PIX", () => {
|
|||||||
);
|
);
|
||||||
const sig1 = ethers.utils.splitSignature(flatSig1);
|
const sig1 = ethers.utils.splitSignature(flatSig1);
|
||||||
const messageToSign2 = ethers.utils.solidityKeccak256(
|
const messageToSign2 = ethers.utils.solidityKeccak256(
|
||||||
["uint160", "uint256", "bytes32"],
|
["uint160", "uint80", "bytes32"],
|
||||||
[pixTarget, 50, endtoendID],
|
[pixTarget, 50, endtoendID],
|
||||||
);
|
);
|
||||||
const flatSig2 = await owner.signMessage(
|
const flatSig2 = await owner.signMessage(
|
||||||
@ -1648,7 +1648,7 @@ describe("P2PIX", () => {
|
|||||||
);
|
);
|
||||||
const sig2 = ethers.utils.splitSignature(flatSig2);
|
const sig2 = ethers.utils.splitSignature(flatSig2);
|
||||||
const messageToSign3 = ethers.utils.solidityKeccak256(
|
const messageToSign3 = ethers.utils.solidityKeccak256(
|
||||||
["uint160", "uint256", "bytes32"],
|
["uint160", "uint80", "bytes32"],
|
||||||
[pixTarget, 25, endtoendID],
|
[pixTarget, 25, endtoendID],
|
||||||
);
|
);
|
||||||
const flatSig3 = await owner.signMessage(
|
const flatSig3 = await owner.signMessage(
|
||||||
@ -1885,7 +1885,7 @@ describe("P2PIX", () => {
|
|||||||
const endtoendID = ethers.constants.HashZero;
|
const endtoendID = ethers.constants.HashZero;
|
||||||
const pixTarget = ethers.BigNumber.from(101);
|
const pixTarget = ethers.BigNumber.from(101);
|
||||||
const messageToSign = ethers.utils.solidityKeccak256(
|
const messageToSign = ethers.utils.solidityKeccak256(
|
||||||
["uint160", "uint256", "bytes32"],
|
["uint160", "uint80", "bytes32"],
|
||||||
[pixTarget, 1, endtoendID],
|
[pixTarget, 1, endtoendID],
|
||||||
);
|
);
|
||||||
const messageHashBytes =
|
const messageHashBytes =
|
||||||
|
Loading…
x
Reference in New Issue
Block a user