Compare commits
50 Commits
8e2323a099
...
zktls
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a63b58e741 | ||
|
|
4bf8841a89 | ||
|
|
0151910b0d | ||
|
|
7a2aec7e71 | ||
|
|
5737ab1623 | ||
|
|
183db96fda | ||
|
|
7f6efc4cb6 | ||
|
|
e57428525b | ||
|
|
538258a709 | ||
|
|
30335bbe5b | ||
|
|
f924593ee2 | ||
|
|
811d5344a3 | ||
|
|
4f1f8d6025 | ||
|
|
c25fa24b2f | ||
|
|
4f63d17eb1 | ||
|
|
d27bdda15e | ||
|
|
1ffa9c6b5c | ||
|
|
f02dad07c8 | ||
|
|
db7407e299 | ||
|
|
e95828b7dd | ||
|
|
a3e6aa5879 | ||
|
|
f5f9923833 | ||
|
|
b571d6c47e | ||
|
|
95463cdfa3 | ||
|
|
1a91b64024 | ||
|
|
631c1d5dfb | ||
|
|
26a495246e | ||
|
|
4281526d77 | ||
|
|
28245db8dd | ||
|
|
32469e2480 | ||
|
|
2129566a27 | ||
|
|
c927f741e6 | ||
|
|
ce5f3e4265 | ||
|
|
440048453b | ||
|
|
0b9b0307d2 | ||
|
|
545887baec | ||
|
|
d8147bd58e | ||
|
|
8ebef3aaf1 | ||
|
|
9d14f053d5 | ||
|
|
6a3bea432c | ||
|
|
a0e39bafab | ||
|
|
55fc45fc73 | ||
|
|
8310e013f6 | ||
|
|
4c8016080d | ||
|
|
8f51b7841c | ||
|
|
d946c239dc | ||
|
|
ce28faae9d | ||
|
|
bb10cf953f | ||
|
|
6fe1e794d0 | ||
|
|
0d612572c6 |
@@ -1,2 +0,0 @@
|
||||
extends:
|
||||
- "@commitlint/config-conventional"
|
||||
@@ -9,4 +9,4 @@ POLYGONSCAN_API_KEY="{INSERT_API_KEY}"
|
||||
GASPRICE_API_ENDPOINT="https://api.etherscan.io/api?module=proxy&action=eth_gasPrice"
|
||||
COINMARKETCAP_API_KEY="{INSERT_API_KEY}"
|
||||
|
||||
REPORT_GAS="true"
|
||||
REPORT_GAS="true"
|
||||
5
.gitignore
vendored
5
.gitignore
vendored
@@ -5,7 +5,8 @@
|
||||
!.yarn/plugins
|
||||
!.yarn/sdks
|
||||
!.yarn/versions
|
||||
# **/artifacts
|
||||
artifacts
|
||||
**/artifacts
|
||||
artifacts/build-info
|
||||
**/build
|
||||
**/ref
|
||||
@@ -16,6 +17,8 @@ artifacts/build-info
|
||||
**/.coverage_contracts
|
||||
**/dist
|
||||
**/node_modules
|
||||
.deps
|
||||
src/types
|
||||
|
||||
# files
|
||||
*.env
|
||||
|
||||
1
.husky/.gitignore
vendored
1
.husky/.gitignore
vendored
@@ -1 +0,0 @@
|
||||
_
|
||||
@@ -1,4 +0,0 @@
|
||||
#!/bin/sh
|
||||
. "$(dirname "$0")/_/husky.sh"
|
||||
|
||||
yarn dlx commitlint --edit $1
|
||||
@@ -1,4 +0,0 @@
|
||||
#!/bin/sh
|
||||
. "$(dirname "$0")/_/husky.sh"
|
||||
|
||||
yarn dlx lint-staged
|
||||
@@ -18,4 +18,6 @@
|
||||
coverage.json
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
yarn-error.log*
|
||||
|
||||
contracts/p2pix.sol
|
||||
13
.solcover.js
13
.solcover.js
@@ -1,7 +1,18 @@
|
||||
module.exports = {
|
||||
configureYulOptimizer: true,
|
||||
solcOptimizerDetails: {
|
||||
deduplicate: true,
|
||||
cse: true,
|
||||
constantOptimizer: true,
|
||||
peephole: true,
|
||||
jumpdestRemover: true,
|
||||
yul: true,
|
||||
// inliner: false,
|
||||
// orderLiterals: true,
|
||||
},
|
||||
istanbulReporter: ["html", "lcov"],
|
||||
providerOptions: {
|
||||
mnemonic: process.env.MNEMONIC,
|
||||
},
|
||||
skipFiles: ["test"],
|
||||
skipFiles: ["test", 'core/BaseUtils.sol', 'core/OwnerSettings.sol'],
|
||||
};
|
||||
|
||||
546
.yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs
vendored
546
.yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs
vendored
File diff suppressed because one or more lines are too long
786
.yarn/releases/yarn-3.2.1.cjs
vendored
786
.yarn/releases/yarn-3.2.1.cjs
vendored
File diff suppressed because one or more lines are too long
942
.yarn/releases/yarn-4.9.2.cjs
vendored
Executable file
942
.yarn/releases/yarn-4.9.2.cjs
vendored
Executable file
File diff suppressed because one or more lines are too long
10
.yarnrc.yml
10
.yarnrc.yml
@@ -1,7 +1,7 @@
|
||||
compressionLevel: mixed
|
||||
|
||||
enableGlobalCache: false
|
||||
|
||||
nodeLinker: node-modules
|
||||
|
||||
plugins:
|
||||
- path: .yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs
|
||||
spec: "@yarnpkg/plugin-interactive-tools"
|
||||
|
||||
yarnPath: .yarn/releases/yarn-3.2.1.cjs
|
||||
yarnPath: .yarn/releases/yarn-4.9.2.cjs
|
||||
|
||||
33
README.md
33
README.md
@@ -6,6 +6,7 @@
|
||||
|
||||
```rs
|
||||
./contracts/
|
||||
├── Constants.sol
|
||||
├── DataTypes.sol
|
||||
├── EventAndErrors.sol
|
||||
├── lib
|
||||
@@ -18,8 +19,9 @@
|
||||
│ ├── tokens
|
||||
│ │ └── ERC20.sol
|
||||
│ └── utils
|
||||
│ ├── Counters.sol
|
||||
│ ├── ECDSA.sol
|
||||
│ ├── MerkleProofLib.sol
|
||||
│ ├── Multicall.sol
|
||||
│ ├── ReentrancyGuard.sol
|
||||
│ └── SafeTransferLib.sol
|
||||
├── p2pix.sol
|
||||
@@ -32,10 +34,12 @@
|
||||
|
||||
## Current Deployment addresses
|
||||
|
||||
| Testnet | Token Address | P2pix Address |
|
||||
|--------- |-------------------------------------------- |-------------------------------------------- |
|
||||
| Goerli | 0x294003F602c321627152c6b7DED3EAb5bEa853Ee | 0x5f3EFA9A90532914545CEf527C530658af87e196 |
|
||||
| Mumbai | 0x294003F602c321627152c6b7DED3EAb5bEa853Ee | 0x5f3EFA9A90532914545CEf527C530658af87e196 |
|
||||
### V1
|
||||
|
||||
| Testnet | Token Address | P2pix Address |
|
||||
| ------- | ------------------------------------------ | ------------------------------------------ |
|
||||
| Goerli | 0x294003F602c321627152c6b7DED3EAb5bEa853Ee | 0x5f3EFA9A90532914545CEf527C530658af87e196 |
|
||||
| Mumbai | 0x294003F602c321627152c6b7DED3EAb5bEa853Ee | 0x5f3EFA9A90532914545CEf527C530658af87e196 |
|
||||
|
||||
<!-- All contracts deployed by 0x8dC06F985C131166570825F52447E8c88d64aE20 -->
|
||||
|
||||
@@ -47,6 +51,24 @@
|
||||
|
||||
<!-- https://mumbai.polygonscan.com/address/0x5f3EFA9A90532914545CEf527C530658af87e196#code -->
|
||||
|
||||
### V2
|
||||
|
||||
| Testnet | Token Address | P2pix Address | Reputation Address | Multicall Address |
|
||||
| ------- | ------------------------------------------ | ------------------------------------------ | ------------------------------------------ | ------------------------------------------ |
|
||||
| Goerli | 0x4A2886EAEc931e04297ed336Cc55c4eb7C75BA00 | 0x2414817FF64A114d91eCFA16a834d3fCf69103d4 | 0x2CFD9354Ec7614fEf036EFd6A730dA1d5fC2762A | 0x8FE009992d96A86c7f0Bccdaf1eC3471E302a8a6 |
|
||||
| Mumbai | 0xC86042E9F2977C62Da8c9dDF7F9c40fde4796A29 | 0x4A2886EAEc931e04297ed336Cc55c4eb7C75BA00 | 0x570445E3eF413bCDb5De79ed27B1c3840683e385 | 0x718B2C4DE4F9654E1349F610ff561249bfe1c418 |
|
||||
|
||||
<!-- All contracts deployed by 0x8dC06F985C131166570825F52447E8c88d64aE20 -->
|
||||
<!-- https://goerli.etherscan.io/address/0x4A2886EAEc931e04297ed336Cc55c4eb7C75BA00#code -->
|
||||
<!-- https://goerli.etherscan.io/address/0x2414817FF64A114d91eCFA16a834d3fCf69103d4#code -->
|
||||
<!-- https://goerli.etherscan.io/address/0x2CFD9354Ec7614fEf036EFd6A730dA1d5fC2762A#code -->
|
||||
<!-- https://goerli.etherscan.io/address/0x8FE009992d96A86c7f0Bccdaf1eC3471E302a8a6#code -->
|
||||
|
||||
<!-- https://mumbai.polygonscan.com/address/0xC86042E9F2977C62Da8c9dDF7F9c40fde4796A29#code -->
|
||||
<!-- https://mumbai.polygonscan.com/address/0x4A2886EAEc931e04297ed336Cc55c4eb7C75BA00#code -->
|
||||
<!-- https://mumbai.polygonscan.com/address/0x570445e3ef413bcdb5de79ed27b1c3840683e385#code -->
|
||||
<!-- https://mumbai.polygonscan.com/address/0x718B2C4DE4F9654E1349F610ff561249bfe1c418#code -->
|
||||
|
||||
## Usage
|
||||
|
||||
### Pre Requisites
|
||||
@@ -121,7 +143,6 @@ yarn deploy2:localhost
|
||||
**_NOTE_:** The second script transfers 2M tokens to the first wallet of the node.
|
||||
To use the P2Pix smart contract first transfer some of the tokens to other wallets.
|
||||
|
||||
|
||||
## Deploying to testnets
|
||||
|
||||
Deploy to Ethereum's Goerli testnet:
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
{
|
||||
"_format": "hh-sol-dbg-1",
|
||||
"buildInfo": "../../build-info/7e875699b08052f41af96a3837e5d6fb.json"
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
{
|
||||
"_format": "hh-sol-artifact-1",
|
||||
"contractName": "DataTypes",
|
||||
"sourceName": "contracts/DataTypes.sol",
|
||||
"abi": [],
|
||||
"bytecode": "0x602d6037600b82828239805160001a607314602a57634e487b7160e01b600052600060045260246000fd5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600080fdfea164736f6c6343000809000a",
|
||||
"deployedBytecode": "0x73000000000000000000000000000000000000000030146080604052600080fdfea164736f6c6343000809000a",
|
||||
"linkReferences": {},
|
||||
"deployedLinkReferences": {}
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
{
|
||||
"_format": "hh-sol-dbg-1",
|
||||
"buildInfo": "../../build-info/7e875699b08052f41af96a3837e5d6fb.json"
|
||||
}
|
||||
@@ -1,337 +0,0 @@
|
||||
{
|
||||
"_format": "hh-sol-artifact-1",
|
||||
"contractName": "EventAndErrors",
|
||||
"sourceName": "contracts/EventAndErrors.sol",
|
||||
"abi": [
|
||||
{
|
||||
"inputs": [],
|
||||
"name": "AddressDenied",
|
||||
"type": "error"
|
||||
},
|
||||
{
|
||||
"inputs": [],
|
||||
"name": "AlreadyReleased",
|
||||
"type": "error"
|
||||
},
|
||||
{
|
||||
"inputs": [],
|
||||
"name": "AmountNotAllowed",
|
||||
"type": "error"
|
||||
},
|
||||
{
|
||||
"inputs": [],
|
||||
"name": "DepositAlreadyExists",
|
||||
"type": "error"
|
||||
},
|
||||
{
|
||||
"inputs": [],
|
||||
"name": "InvalidDeposit",
|
||||
"type": "error"
|
||||
},
|
||||
{
|
||||
"inputs": [],
|
||||
"name": "InvalidSigner",
|
||||
"type": "error"
|
||||
},
|
||||
{
|
||||
"inputs": [],
|
||||
"name": "LengthMismatch",
|
||||
"type": "error"
|
||||
},
|
||||
{
|
||||
"inputs": [],
|
||||
"name": "LockExpired",
|
||||
"type": "error"
|
||||
},
|
||||
{
|
||||
"inputs": [],
|
||||
"name": "LoopOverflow",
|
||||
"type": "error"
|
||||
},
|
||||
{
|
||||
"inputs": [],
|
||||
"name": "NoTokens",
|
||||
"type": "error"
|
||||
},
|
||||
{
|
||||
"inputs": [],
|
||||
"name": "NotEnoughTokens",
|
||||
"type": "error"
|
||||
},
|
||||
{
|
||||
"inputs": [],
|
||||
"name": "NotExpired",
|
||||
"type": "error"
|
||||
},
|
||||
{
|
||||
"inputs": [],
|
||||
"name": "OnlySeller",
|
||||
"type": "error"
|
||||
},
|
||||
{
|
||||
"inputs": [],
|
||||
"name": "StaticCallFailed",
|
||||
"type": "error"
|
||||
},
|
||||
{
|
||||
"inputs": [],
|
||||
"name": "TokenDenied",
|
||||
"type": "error"
|
||||
},
|
||||
{
|
||||
"inputs": [],
|
||||
"name": "TxAlreadyUsed",
|
||||
"type": "error"
|
||||
},
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{
|
||||
"indexed": true,
|
||||
"internalType": "address",
|
||||
"name": "token",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": true,
|
||||
"internalType": "bool",
|
||||
"name": "state",
|
||||
"type": "bool"
|
||||
}
|
||||
],
|
||||
"name": "AllowedERC20Updated",
|
||||
"type": "event"
|
||||
},
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{
|
||||
"indexed": true,
|
||||
"internalType": "address",
|
||||
"name": "seller",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"internalType": "uint256",
|
||||
"name": "depositID",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"internalType": "address",
|
||||
"name": "token",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"internalType": "uint256",
|
||||
"name": "amount",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "DepositAdded",
|
||||
"type": "event"
|
||||
},
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{
|
||||
"indexed": true,
|
||||
"internalType": "address",
|
||||
"name": "seller",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"internalType": "uint256",
|
||||
"name": "depositID",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "DepositClosed",
|
||||
"type": "event"
|
||||
},
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{
|
||||
"indexed": true,
|
||||
"internalType": "address",
|
||||
"name": "seller",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"internalType": "uint256",
|
||||
"name": "depositID",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"internalType": "uint256",
|
||||
"name": "amount",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "DepositWithdrawn",
|
||||
"type": "event"
|
||||
},
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{
|
||||
"indexed": false,
|
||||
"internalType": "address",
|
||||
"name": "owner",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"internalType": "uint256",
|
||||
"name": "amount",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "FundsWithdrawn",
|
||||
"type": "event"
|
||||
},
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{
|
||||
"indexed": true,
|
||||
"internalType": "address",
|
||||
"name": "buyer",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": true,
|
||||
"internalType": "bytes32",
|
||||
"name": "lockID",
|
||||
"type": "bytes32"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"internalType": "uint256",
|
||||
"name": "depositID",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"internalType": "uint256",
|
||||
"name": "amount",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "LockAdded",
|
||||
"type": "event"
|
||||
},
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{
|
||||
"indexed": false,
|
||||
"internalType": "uint256",
|
||||
"name": "blocks",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "LockBlocksUpdated",
|
||||
"type": "event"
|
||||
},
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{
|
||||
"indexed": true,
|
||||
"internalType": "address",
|
||||
"name": "buyer",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"internalType": "bytes32",
|
||||
"name": "lockId",
|
||||
"type": "bytes32"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"internalType": "uint256",
|
||||
"name": "amount",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "LockReleased",
|
||||
"type": "event"
|
||||
},
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{
|
||||
"indexed": true,
|
||||
"internalType": "address",
|
||||
"name": "buyer",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"internalType": "bytes32",
|
||||
"name": "lockId",
|
||||
"type": "bytes32"
|
||||
}
|
||||
],
|
||||
"name": "LockReturned",
|
||||
"type": "event"
|
||||
},
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{
|
||||
"indexed": false,
|
||||
"internalType": "address",
|
||||
"name": "reputation",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"name": "ReputationUpdated",
|
||||
"type": "event"
|
||||
},
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{
|
||||
"indexed": false,
|
||||
"internalType": "address",
|
||||
"name": "seller",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"internalType": "bytes32",
|
||||
"name": "merkleRoot",
|
||||
"type": "bytes32"
|
||||
}
|
||||
],
|
||||
"name": "RootUpdated",
|
||||
"type": "event"
|
||||
},
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{
|
||||
"indexed": false,
|
||||
"internalType": "address[]",
|
||||
"name": "signers",
|
||||
"type": "address[]"
|
||||
}
|
||||
],
|
||||
"name": "ValidSignersUpdated",
|
||||
"type": "event"
|
||||
}
|
||||
],
|
||||
"bytecode": "0x",
|
||||
"deployedBytecode": "0x",
|
||||
"linkReferences": {},
|
||||
"deployedLinkReferences": {}
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
{
|
||||
"_format": "hh-sol-dbg-1",
|
||||
"buildInfo": "../../build-info/7e875699b08052f41af96a3837e5d6fb.json"
|
||||
}
|
||||
@@ -1,106 +0,0 @@
|
||||
{
|
||||
"_format": "hh-sol-artifact-1",
|
||||
"contractName": "Reputation",
|
||||
"sourceName": "contracts/Reputation.sol",
|
||||
"abi": [
|
||||
{
|
||||
"inputs": [],
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "constructor"
|
||||
},
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{
|
||||
"indexed": true,
|
||||
"internalType": "address",
|
||||
"name": "user",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": true,
|
||||
"internalType": "address",
|
||||
"name": "newOwner",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"name": "OwnerUpdated",
|
||||
"type": "event"
|
||||
},
|
||||
{
|
||||
"inputs": [
|
||||
{
|
||||
"internalType": "uint256",
|
||||
"name": "_userCredit",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "limiter",
|
||||
"outputs": [
|
||||
{
|
||||
"internalType": "uint256",
|
||||
"name": "_spendLimit",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"stateMutability": "pure",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [],
|
||||
"name": "magicValue",
|
||||
"outputs": [
|
||||
{
|
||||
"internalType": "uint256",
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [],
|
||||
"name": "maxLimit",
|
||||
"outputs": [
|
||||
{
|
||||
"internalType": "uint256",
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [],
|
||||
"name": "owner",
|
||||
"outputs": [
|
||||
{
|
||||
"internalType": "address",
|
||||
"name": "",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [
|
||||
{
|
||||
"internalType": "address",
|
||||
"name": "newOwner",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"name": "setOwner",
|
||||
"outputs": [],
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
}
|
||||
],
|
||||
"bytecode": "0x608060405234801561001057600080fd5b50600080546001600160a01b031916339081178255604051909182917f8292fce18fa69edf4db7b94ea2e58241df0ae57f97e0a6c9b29067028bf92d76908290a350610416806100616000396000f3fe608060405234801561001057600080fd5b50600436106100675760003560e01c80634d2b1791116100505780634d2b17911461009e5780638da5cb5b146100b1578063a4b34557146100f657600080fd5b806313af40351461006c5780631a861d2614610081575b600080fd5b61007f61007a3660046102f4565b610102565b005b61008b620f424081565b6040519081526020015b60405180910390f35b61008b6100ac366004610331565b6101f7565b6000546100d19073ffffffffffffffffffffffffffffffffffffffff1681565b60405173ffffffffffffffffffffffffffffffffffffffff9091168152602001610095565b61008b643a3529440081565b60005473ffffffffffffffffffffffffffffffffffffffff163314610187576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600c60248201527f554e415554484f52495a45440000000000000000000000000000000000000000604482015260640160405180910390fd5b600080547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff83169081178255604051909133917f8292fce18fa69edf4db7b94ea2e58241df0ae57f97e0a6c9b29067028bf92d769190a350565b600061021a6102068380610379565b61021590643a352944006103b6565b610242565b61022783620f4240610379565b61023191906103ce565b61023c9060016103b6565b92915050565b60b5817101000000000000000000000000000000000081106102695760409190911b9060801c5b690100000000000000000081106102855760209190911b9060401c5b65010000000000811061029d5760109190911b9060201c5b630100000081106102b35760089190911b9060101c5b62010000010260121c80820401600190811c80830401811c80830401811c80830401811c80830401811c80830401811c80830401901c908190048111900390565b60006020828403121561030657600080fd5b813573ffffffffffffffffffffffffffffffffffffffff8116811461032a57600080fd5b9392505050565b60006020828403121561034357600080fd5b5035919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b6000817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff04831182151516156103b1576103b161034a565b500290565b600082198211156103c9576103c961034a565b500190565b600082610404577f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b50049056fea164736f6c6343000809000a",
|
||||
"deployedBytecode": "0x608060405234801561001057600080fd5b50600436106100675760003560e01c80634d2b1791116100505780634d2b17911461009e5780638da5cb5b146100b1578063a4b34557146100f657600080fd5b806313af40351461006c5780631a861d2614610081575b600080fd5b61007f61007a3660046102f4565b610102565b005b61008b620f424081565b6040519081526020015b60405180910390f35b61008b6100ac366004610331565b6101f7565b6000546100d19073ffffffffffffffffffffffffffffffffffffffff1681565b60405173ffffffffffffffffffffffffffffffffffffffff9091168152602001610095565b61008b643a3529440081565b60005473ffffffffffffffffffffffffffffffffffffffff163314610187576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600c60248201527f554e415554484f52495a45440000000000000000000000000000000000000000604482015260640160405180910390fd5b600080547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff83169081178255604051909133917f8292fce18fa69edf4db7b94ea2e58241df0ae57f97e0a6c9b29067028bf92d769190a350565b600061021a6102068380610379565b61021590643a352944006103b6565b610242565b61022783620f4240610379565b61023191906103ce565b61023c9060016103b6565b92915050565b60b5817101000000000000000000000000000000000081106102695760409190911b9060801c5b690100000000000000000081106102855760209190911b9060401c5b65010000000000811061029d5760109190911b9060201c5b630100000081106102b35760089190911b9060101c5b62010000010260121c80820401600190811c80830401811c80830401811c80830401811c80830401811c80830401811c80830401901c908190048111900390565b60006020828403121561030657600080fd5b813573ffffffffffffffffffffffffffffffffffffffff8116811461032a57600080fd5b9392505050565b60006020828403121561034357600080fd5b5035919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b6000817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff04831182151516156103b1576103b161034a565b500290565b600082198211156103c9576103c961034a565b500190565b600082610404577f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b50049056fea164736f6c6343000809000a",
|
||||
"linkReferences": {},
|
||||
"deployedLinkReferences": {}
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
{
|
||||
"_format": "hh-sol-dbg-1",
|
||||
"buildInfo": "../../../../build-info/7e875699b08052f41af96a3837e5d6fb.json"
|
||||
}
|
||||
@@ -1,56 +0,0 @@
|
||||
{
|
||||
"_format": "hh-sol-artifact-1",
|
||||
"contractName": "Owned",
|
||||
"sourceName": "contracts/lib/auth/Owned.sol",
|
||||
"abi": [
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{
|
||||
"indexed": true,
|
||||
"internalType": "address",
|
||||
"name": "user",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": true,
|
||||
"internalType": "address",
|
||||
"name": "newOwner",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"name": "OwnerUpdated",
|
||||
"type": "event"
|
||||
},
|
||||
{
|
||||
"inputs": [],
|
||||
"name": "owner",
|
||||
"outputs": [
|
||||
{
|
||||
"internalType": "address",
|
||||
"name": "",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [
|
||||
{
|
||||
"internalType": "address",
|
||||
"name": "newOwner",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"name": "setOwner",
|
||||
"outputs": [],
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
}
|
||||
],
|
||||
"bytecode": "0x",
|
||||
"deployedBytecode": "0x",
|
||||
"linkReferences": {},
|
||||
"deployedLinkReferences": {}
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
{
|
||||
"_format": "hh-sol-dbg-1",
|
||||
"buildInfo": "../../../../build-info/7e875699b08052f41af96a3837e5d6fb.json"
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
{
|
||||
"_format": "hh-sol-artifact-1",
|
||||
"contractName": "IReputation",
|
||||
"sourceName": "contracts/lib/interfaces/IReputation.sol",
|
||||
"abi": [
|
||||
{
|
||||
"inputs": [
|
||||
{
|
||||
"internalType": "uint256",
|
||||
"name": "_userCredit",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "limiter",
|
||||
"outputs": [
|
||||
{
|
||||
"internalType": "uint256",
|
||||
"name": "_spendLimit",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"stateMutability": "pure",
|
||||
"type": "function"
|
||||
}
|
||||
],
|
||||
"bytecode": "0x",
|
||||
"deployedBytecode": "0x",
|
||||
"linkReferences": {},
|
||||
"deployedLinkReferences": {}
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
{
|
||||
"_format": "hh-sol-dbg-1",
|
||||
"buildInfo": "../../../../build-info/7e875699b08052f41af96a3837e5d6fb.json"
|
||||
}
|
||||
File diff suppressed because one or more lines are too long
@@ -1,4 +0,0 @@
|
||||
{
|
||||
"_format": "hh-sol-dbg-1",
|
||||
"buildInfo": "../../../../build-info/7e875699b08052f41af96a3837e5d6fb.json"
|
||||
}
|
||||
@@ -1,308 +0,0 @@
|
||||
{
|
||||
"_format": "hh-sol-artifact-1",
|
||||
"contractName": "ERC20",
|
||||
"sourceName": "contracts/lib/tokens/ERC20.sol",
|
||||
"abi": [
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{
|
||||
"indexed": true,
|
||||
"internalType": "address",
|
||||
"name": "owner",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": true,
|
||||
"internalType": "address",
|
||||
"name": "spender",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"internalType": "uint256",
|
||||
"name": "amount",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "Approval",
|
||||
"type": "event"
|
||||
},
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{
|
||||
"indexed": true,
|
||||
"internalType": "address",
|
||||
"name": "from",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": true,
|
||||
"internalType": "address",
|
||||
"name": "to",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"internalType": "uint256",
|
||||
"name": "amount",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "Transfer",
|
||||
"type": "event"
|
||||
},
|
||||
{
|
||||
"inputs": [],
|
||||
"name": "DOMAIN_SEPARATOR",
|
||||
"outputs": [
|
||||
{
|
||||
"internalType": "bytes32",
|
||||
"name": "",
|
||||
"type": "bytes32"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [
|
||||
{
|
||||
"internalType": "address",
|
||||
"name": "",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"internalType": "address",
|
||||
"name": "",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"name": "allowance",
|
||||
"outputs": [
|
||||
{
|
||||
"internalType": "uint256",
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [
|
||||
{
|
||||
"internalType": "address",
|
||||
"name": "spender",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"internalType": "uint256",
|
||||
"name": "amount",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "approve",
|
||||
"outputs": [
|
||||
{
|
||||
"internalType": "bool",
|
||||
"name": "",
|
||||
"type": "bool"
|
||||
}
|
||||
],
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [
|
||||
{
|
||||
"internalType": "address",
|
||||
"name": "",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"name": "balanceOf",
|
||||
"outputs": [
|
||||
{
|
||||
"internalType": "uint256",
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [],
|
||||
"name": "decimals",
|
||||
"outputs": [
|
||||
{
|
||||
"internalType": "uint8",
|
||||
"name": "",
|
||||
"type": "uint8"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [],
|
||||
"name": "name",
|
||||
"outputs": [
|
||||
{
|
||||
"internalType": "string",
|
||||
"name": "",
|
||||
"type": "string"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [
|
||||
{
|
||||
"internalType": "address",
|
||||
"name": "",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"name": "nonces",
|
||||
"outputs": [
|
||||
{
|
||||
"internalType": "uint256",
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [
|
||||
{
|
||||
"internalType": "address",
|
||||
"name": "owner",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"internalType": "address",
|
||||
"name": "spender",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"internalType": "uint256",
|
||||
"name": "value",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"internalType": "uint256",
|
||||
"name": "deadline",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"internalType": "uint8",
|
||||
"name": "v",
|
||||
"type": "uint8"
|
||||
},
|
||||
{
|
||||
"internalType": "bytes32",
|
||||
"name": "r",
|
||||
"type": "bytes32"
|
||||
},
|
||||
{
|
||||
"internalType": "bytes32",
|
||||
"name": "s",
|
||||
"type": "bytes32"
|
||||
}
|
||||
],
|
||||
"name": "permit",
|
||||
"outputs": [],
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [],
|
||||
"name": "symbol",
|
||||
"outputs": [
|
||||
{
|
||||
"internalType": "string",
|
||||
"name": "",
|
||||
"type": "string"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [],
|
||||
"name": "totalSupply",
|
||||
"outputs": [
|
||||
{
|
||||
"internalType": "uint256",
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [
|
||||
{
|
||||
"internalType": "address",
|
||||
"name": "to",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"internalType": "uint256",
|
||||
"name": "amount",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "transfer",
|
||||
"outputs": [
|
||||
{
|
||||
"internalType": "bool",
|
||||
"name": "",
|
||||
"type": "bool"
|
||||
}
|
||||
],
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [
|
||||
{
|
||||
"internalType": "address",
|
||||
"name": "from",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"internalType": "address",
|
||||
"name": "to",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"internalType": "uint256",
|
||||
"name": "amount",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "transferFrom",
|
||||
"outputs": [
|
||||
{
|
||||
"internalType": "bool",
|
||||
"name": "",
|
||||
"type": "bool"
|
||||
}
|
||||
],
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
}
|
||||
],
|
||||
"bytecode": "0x",
|
||||
"deployedBytecode": "0x",
|
||||
"linkReferences": {},
|
||||
"deployedLinkReferences": {}
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
{
|
||||
"_format": "hh-sol-dbg-1",
|
||||
"buildInfo": "../../../../build-info/7e875699b08052f41af96a3837e5d6fb.json"
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
{
|
||||
"_format": "hh-sol-artifact-1",
|
||||
"contractName": "Counters",
|
||||
"sourceName": "contracts/lib/utils/Counters.sol",
|
||||
"abi": [
|
||||
{
|
||||
"inputs": [],
|
||||
"name": "DecOverflow",
|
||||
"type": "error"
|
||||
}
|
||||
],
|
||||
"bytecode": "0x602d6037600b82828239805160001a607314602a57634e487b7160e01b600052600060045260246000fd5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600080fdfea164736f6c6343000809000a",
|
||||
"deployedBytecode": "0x73000000000000000000000000000000000000000030146080604052600080fdfea164736f6c6343000809000a",
|
||||
"linkReferences": {},
|
||||
"deployedLinkReferences": {}
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
{
|
||||
"_format": "hh-sol-dbg-1",
|
||||
"buildInfo": "../../../../build-info/7e875699b08052f41af96a3837e5d6fb.json"
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
{
|
||||
"_format": "hh-sol-artifact-1",
|
||||
"contractName": "MerkleProofLib",
|
||||
"sourceName": "contracts/lib/utils/MerkleProofLib.sol",
|
||||
"abi": [],
|
||||
"bytecode": "0x602d6037600b82828239805160001a607314602a57634e487b7160e01b600052600060045260246000fd5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600080fdfea164736f6c6343000809000a",
|
||||
"deployedBytecode": "0x73000000000000000000000000000000000000000030146080604052600080fdfea164736f6c6343000809000a",
|
||||
"linkReferences": {},
|
||||
"deployedLinkReferences": {}
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
{
|
||||
"_format": "hh-sol-dbg-1",
|
||||
"buildInfo": "../../../../build-info/7e875699b08052f41af96a3837e5d6fb.json"
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
{
|
||||
"_format": "hh-sol-artifact-1",
|
||||
"contractName": "ReentrancyGuard",
|
||||
"sourceName": "contracts/lib/utils/ReentrancyGuard.sol",
|
||||
"abi": [
|
||||
{
|
||||
"inputs": [],
|
||||
"name": "Reentrancy",
|
||||
"type": "error"
|
||||
}
|
||||
],
|
||||
"bytecode": "0x",
|
||||
"deployedBytecode": "0x",
|
||||
"linkReferences": {},
|
||||
"deployedLinkReferences": {}
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
{
|
||||
"_format": "hh-sol-dbg-1",
|
||||
"buildInfo": "../../../../build-info/7e875699b08052f41af96a3837e5d6fb.json"
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
{
|
||||
"_format": "hh-sol-artifact-1",
|
||||
"contractName": "SafeTransferLib",
|
||||
"sourceName": "contracts/lib/utils/SafeTransferLib.sol",
|
||||
"abi": [],
|
||||
"bytecode": "0x602d6037600b82828239805160001a607314602a57634e487b7160e01b600052600060045260246000fd5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600080fdfea164736f6c6343000809000a",
|
||||
"deployedBytecode": "0x73000000000000000000000000000000000000000030146080604052600080fdfea164736f6c6343000809000a",
|
||||
"linkReferences": {},
|
||||
"deployedLinkReferences": {}
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
{
|
||||
"_format": "hh-sol-dbg-1",
|
||||
"buildInfo": "../../build-info/7e875699b08052f41af96a3837e5d6fb.json"
|
||||
}
|
||||
File diff suppressed because one or more lines are too long
@@ -1,33 +0,0 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
pragma solidity 0.8.9;
|
||||
|
||||
library DataTypes {
|
||||
struct Deposit {
|
||||
/// @dev Remaining tokens available.
|
||||
uint256 remaining;
|
||||
/// @dev The PIX account for the seller receive transactions.
|
||||
string pixTarget;
|
||||
address seller;
|
||||
/// @dev ERC20 stable token address.
|
||||
address token;
|
||||
/// @dev Could be invalidated by the seller.
|
||||
bool valid;
|
||||
}
|
||||
|
||||
struct Lock {
|
||||
uint256 depositID;
|
||||
/// @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.
|
||||
uint256 expirationBlock;
|
||||
/// @dev Where the tokens are sent the when order gets validated.
|
||||
address buyerAddress;
|
||||
/// @dev Relayer's target address that receives `relayerPremium` funds.
|
||||
address relayerTarget;
|
||||
/// @dev Relayer address (msg.sender) that facilitated this transaction.
|
||||
/// @dev Reputation points accruer.
|
||||
address relayerAddress;
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,9 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
pragma solidity 0.8.9;
|
||||
pragma solidity ^0.8.19;
|
||||
|
||||
import { IReputation } from "./lib/interfaces/IReputation.sol";
|
||||
import { Owned } from "./lib/auth/Owned.sol";
|
||||
|
||||
contract Reputation is IReputation, Owned(msg.sender) {
|
||||
contract Reputation is IReputation {
|
||||
/// @dev Asymptote numerator constant value for the `limiter` fx.
|
||||
uint256 public constant maxLimit = 1e6;
|
||||
/// @dev Denominator's constant operand for the `limiter` fx.
|
||||
@@ -13,7 +12,7 @@ contract Reputation is IReputation, Owned(msg.sender) {
|
||||
// prettier-ignore
|
||||
// solhint-disable no-inline-assembly
|
||||
// solhint-disable-next-line no-empty-blocks
|
||||
constructor(/* */) {/* */}
|
||||
constructor(/* */) payable {/* */}
|
||||
|
||||
function limiter(
|
||||
uint256 _userCredit
|
||||
|
||||
182
contracts/core/BaseUtils.sol
Normal file
182
contracts/core/BaseUtils.sol
Normal file
@@ -0,0 +1,182 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
pragma solidity ^0.8.19;
|
||||
|
||||
import { ERC20, OwnerSettings } from "contracts/core/OwnerSettings.sol";
|
||||
|
||||
import { ECDSA } from "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";
|
||||
import { MessageHashUtils } from "@openzeppelin/contracts/utils/cryptography/MessageHashUtils.sol";
|
||||
import { MerkleProof as Merkle } from "@openzeppelin/contracts/utils/cryptography/MerkleProof.sol";
|
||||
import { ReentrancyGuard } from "@openzeppelin/contracts/utils/ReentrancyGuard.sol";
|
||||
|
||||
abstract contract BaseUtils is
|
||||
OwnerSettings,
|
||||
ReentrancyGuard
|
||||
{
|
||||
/// ███ Storage ████████████████████████████████████████████████████████████
|
||||
|
||||
/// @dev List of Pix transactions already signed.
|
||||
/// mapping(bytes32 => bool) public usedTransactions;
|
||||
/// @dev Value in custom storage slot given by:
|
||||
/// let value := sload(bytes32).
|
||||
|
||||
/// ███ Helper FX ██████████████████████████████████████████████████████████
|
||||
function _setUsedTransactions(bytes32 message) internal {
|
||||
assembly ("memory-safe") {
|
||||
sstore(message, true)
|
||||
}
|
||||
}
|
||||
|
||||
function usedTransactions(
|
||||
bytes32 message
|
||||
) public view returns (bool used) {
|
||||
assembly ("memory-safe") {
|
||||
used := sload(message)
|
||||
}
|
||||
}
|
||||
|
||||
function _signerCheck(
|
||||
bytes32 _message,
|
||||
bytes calldata _signature
|
||||
) internal view {
|
||||
if (usedTransactions(_message))
|
||||
revert TxAlreadyUsed();
|
||||
|
||||
if (
|
||||
!validBacenSigners(
|
||||
_castAddrToKey(
|
||||
ECDSA.recover(
|
||||
MessageHashUtils.toEthSignedMessageHash(
|
||||
_message
|
||||
),
|
||||
_signature
|
||||
)
|
||||
)
|
||||
)
|
||||
) revert InvalidSigner();
|
||||
}
|
||||
|
||||
function _merkleVerify(
|
||||
bytes32[] calldata _merkleProof,
|
||||
bytes32 _root,
|
||||
address _addr
|
||||
) internal pure {
|
||||
if (
|
||||
!Merkle.verify(
|
||||
_merkleProof,
|
||||
_root,
|
||||
bytes32(uint256(uint160(_addr)))
|
||||
)
|
||||
) revert AddressDenied();
|
||||
}
|
||||
|
||||
function _castBool(
|
||||
bool _valid
|
||||
) internal pure returns (uint256 _validCasted) {
|
||||
assembly ("memory-safe") {
|
||||
_validCasted := _valid
|
||||
}
|
||||
}
|
||||
|
||||
function getStr(
|
||||
string memory str
|
||||
) public pure returns (bytes32 strEnc) {
|
||||
bytes memory enc = bytes(abi.encodePacked(str));
|
||||
assembly ("memory-safe") {
|
||||
if lt(0x20, mload(enc)) {
|
||||
invalid()
|
||||
}
|
||||
strEnc := mload(add(enc, 0x20))
|
||||
}
|
||||
}
|
||||
|
||||
function _setSellerBalance(
|
||||
address _sellerKey,
|
||||
ERC20 _erc20,
|
||||
uint256 _packed,
|
||||
bytes32 _pixTarget
|
||||
) internal {
|
||||
assembly ("memory-safe") {
|
||||
mstore(0x20, _erc20)
|
||||
mstore(0x0c, _SELLER_BALANCE_SLOT_SEED)
|
||||
mstore(0x00, _sellerKey)
|
||||
let _loc := keccak256(0x0c, 0x34)
|
||||
sstore(add(_loc, 0x01), _packed)
|
||||
sstore(_loc, _pixTarget)
|
||||
}
|
||||
}
|
||||
|
||||
function _setValidState(
|
||||
address _sellerKey,
|
||||
ERC20 _erc20,
|
||||
uint256 _packed
|
||||
) internal {
|
||||
assembly ("memory-safe") {
|
||||
mstore(0x20, _erc20)
|
||||
mstore(0x0c, _SELLER_BALANCE_SLOT_SEED)
|
||||
mstore(0x00, _sellerKey)
|
||||
let _loc := keccak256(0x0c, 0x34)
|
||||
sstore(add(_loc, 0x01), _packed)
|
||||
}
|
||||
}
|
||||
|
||||
function _addSellerBalance(
|
||||
address _sellerKey,
|
||||
ERC20 _erc20,
|
||||
uint256 _amount
|
||||
) internal {
|
||||
assembly ("memory-safe") {
|
||||
mstore(0x20, _erc20)
|
||||
mstore(0x0c, _SELLER_BALANCE_SLOT_SEED)
|
||||
mstore(0x00, _sellerKey)
|
||||
let _loc := add(keccak256(0x0c, 0x34), 0x01)
|
||||
sstore(_loc, add(sload(_loc), _amount))
|
||||
}
|
||||
}
|
||||
|
||||
function _decSellerBalance(
|
||||
address _sellerKey,
|
||||
ERC20 _erc20,
|
||||
uint256 _amount
|
||||
) internal {
|
||||
assembly ("memory-safe") {
|
||||
mstore(0x20, _erc20)
|
||||
mstore(0x0c, _SELLER_BALANCE_SLOT_SEED)
|
||||
mstore(0x00, _sellerKey)
|
||||
let _loc := add(keccak256(0x0c, 0x34), 0x01)
|
||||
sstore(_loc, sub(sload(_loc), _amount))
|
||||
}
|
||||
}
|
||||
|
||||
function __sellerBalance(
|
||||
address _sellerKey,
|
||||
ERC20 _erc20
|
||||
) internal view returns (uint256 _packed) {
|
||||
assembly ("memory-safe") {
|
||||
mstore(0x20, _erc20)
|
||||
mstore(0x0c, _SELLER_BALANCE_SLOT_SEED)
|
||||
mstore(0x00, _sellerKey)
|
||||
_packed := sload(add(keccak256(0x0c, 0x34), 0x01))
|
||||
}
|
||||
}
|
||||
|
||||
/// @notice Public method that handles `address`
|
||||
/// to `uint256` safe type casting.
|
||||
/// @dev Function sighash: 0x4b2ae980.
|
||||
function _castAddrToKey(
|
||||
address _addr
|
||||
) public pure returns (uint256 _key) {
|
||||
// _key = uint256(uint160(address(_addr))) << 12;
|
||||
assembly ("memory-safe") {
|
||||
_key := shl(0xc, _addr)
|
||||
}
|
||||
}
|
||||
|
||||
function _castKeyToAddr(
|
||||
uint256 _key
|
||||
) public pure returns (address _addr) {
|
||||
// _addr = address(uint160(uint256(_key >> 12)));
|
||||
assembly ("memory-safe") {
|
||||
_addr := shr(0xc, _key)
|
||||
}
|
||||
}
|
||||
}
|
||||
47
contracts/core/Constants.sol
Normal file
47
contracts/core/Constants.sol
Normal file
@@ -0,0 +1,47 @@
|
||||
// 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;
|
||||
uint256 constant _TRUSTED_FORWARDER_UPDATED_EVENT_SIGNATURE =
|
||||
0xbee55516e29d3969d3cb8eb01351eb3c52d06f9e2435bd5a8bfe3647e185df92;
|
||||
|
||||
/// @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`, `uint96` } )) public sellerBalance;
|
||||
|
||||
/// @dev Bits layout:
|
||||
/// `bytes32` [0...255] := pixTarget
|
||||
/// `uint96` [0...94] := balance
|
||||
/// `bool` [95] := 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 `valid` in `sellerBalance`.
|
||||
uint256 constant BITPOS_VALID = 95;
|
||||
|
||||
/// @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;
|
||||
}
|
||||
25
contracts/core/DataTypes.sol
Normal file
25
contracts/core/DataTypes.sol
Normal file
@@ -0,0 +1,25 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
pragma solidity ^0.8.19;
|
||||
|
||||
import { ERC20 } from "@openzeppelin/contracts/token/ERC20/ERC20.sol";
|
||||
|
||||
library DataTypes {
|
||||
|
||||
struct Lock {
|
||||
uint256 counter;
|
||||
uint256 expirationBlock;
|
||||
bytes32 pixTarget;
|
||||
uint80 amount;
|
||||
ERC20 token;
|
||||
address buyerAddress;
|
||||
address seller;
|
||||
}
|
||||
|
||||
// prettier-ignore
|
||||
enum LockStatus {
|
||||
Inexistent, // 0 := Uninitialized Lock.
|
||||
Active, // 1 := Valid Lock.
|
||||
Expired, // 2 := Expired Lock.
|
||||
Released // 3 := Already released Lock.
|
||||
}
|
||||
}
|
||||
@@ -1,61 +1,79 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
pragma solidity 0.8.9;
|
||||
pragma solidity ^0.8.19;
|
||||
|
||||
import { ERC20 } from "@openzeppelin/contracts/token/ERC20/ERC20.sol";
|
||||
|
||||
// prettier-ignore
|
||||
interface EventAndErrors {
|
||||
/// ███ Events ████████████████████████████████████████████████████████████
|
||||
|
||||
/// @dev 0x63d8d7d5e63e9840ec91a12a160d27b7cfab294f6ba070b7359692acfe6b03bf
|
||||
event DepositAdded(
|
||||
address indexed seller,
|
||||
uint256 depositID,
|
||||
address token,
|
||||
// uint256 depositID,
|
||||
ERC20 token,
|
||||
uint256 amount
|
||||
);
|
||||
event DepositClosed(
|
||||
/// @dev 0xca585721b6b442dc9183932f7c84dc2880efb67c4da52cc06873e78971105d49
|
||||
event ValidSet(
|
||||
address indexed seller,
|
||||
uint256 depositID
|
||||
ERC20 token,
|
||||
bool state
|
||||
);
|
||||
/// @dev 0x2cd6435b1b961c13f55202979edd0765a809f69a539d8a477436c94c1211e43e
|
||||
event DepositWithdrawn(
|
||||
address indexed seller,
|
||||
uint256 depositID,
|
||||
ERC20 token,
|
||||
uint256 amount
|
||||
);
|
||||
/// @dev 0x8fb3989f70bd172a37d15b41b015e48ea09d59329638377304a4198cd0c4ea65
|
||||
event LockAdded(
|
||||
address indexed buyer,
|
||||
bytes32 indexed lockID,
|
||||
uint256 depositID,
|
||||
uint256 indexed lockID,
|
||||
address seller,
|
||||
uint256 amount
|
||||
);
|
||||
/// @dev 0x364537f14276f2a0ce9905588413f96454cbb8fb2e4f5308389307c1098bede8
|
||||
event LockReleased(
|
||||
address indexed buyer,
|
||||
bytes32 lockId,
|
||||
uint256 lockId,
|
||||
uint256 amount
|
||||
);
|
||||
/// @dev 0x830501e61b8b075e170b22a430e39454bdb12ed3e9620e586430b6ac00079da5
|
||||
event LockReturned(
|
||||
address indexed buyer,
|
||||
bytes32 lockId
|
||||
uint256 lockId
|
||||
);
|
||||
/// @dev 0xeaff4b37086828766ad3268786972c0cd24259d4c87a80f9d3963a3c3d999b0d
|
||||
event FundsWithdrawn(
|
||||
address owner,
|
||||
uint256 amount
|
||||
);
|
||||
/// @dev 0x0b294da292f26e55fd442b5c0164fbb9013036ff00c5cfdde0efd01c1baaf632
|
||||
event RootUpdated(
|
||||
address seller,
|
||||
bytes32 merkleRoot
|
||||
address indexed seller,
|
||||
bytes32 indexed merkleRoot
|
||||
);
|
||||
/// @dev 0x5d6e86e5341d57a92c49934296c51542a25015c9b1782a1c2722a940131c3d9a
|
||||
event AllowedERC20Updated(
|
||||
address indexed token,
|
||||
bool indexed state
|
||||
);
|
||||
/// @dev 0xbee55516e29d3969d3cb8eb01351eb3c52d06f9e2435bd5a8bfe3647e185df92
|
||||
event TrustedForwarderUpdated(
|
||||
address indexed forwarder,
|
||||
bool indexed state
|
||||
);
|
||||
/// @dev 0xe127cf589a3879da0156d4a24f43b44f65cfa3570de594806b0bfa2fcf06884f
|
||||
event ReputationUpdated(address reputation);
|
||||
/// @dev 0x70fa43ca70216ad905ade86b9e650a691b2ce5a01980d0a81bdd8324141b8511
|
||||
event LockBlocksUpdated(uint256 blocks);
|
||||
/// @dev 0x14a422d2412784a5749d03da98921fe468c98577b767851389a9f58ea5a363d7
|
||||
event ValidSignersUpdated(address[] signers);
|
||||
|
||||
|
||||
/// ███ Errors ████████████████████████████████████████████████████████████
|
||||
|
||||
/// @dev Deposit already exist and it is still valid.
|
||||
/// @dev 0xc44bd765
|
||||
error DepositAlreadyExists();
|
||||
/// @dev Only seller could call this function.
|
||||
/// @dev `msg.sender` and the seller differ.
|
||||
/// @dev 0x85d1f726
|
||||
@@ -104,4 +122,12 @@ interface EventAndErrors {
|
||||
/// @dev Reverts on an expired lock.
|
||||
/// @dev 0xf6fafba0
|
||||
error LockExpired();
|
||||
/// @dev 0xce3a3d37
|
||||
error DecOverflow();
|
||||
/// @dev 0xf3fb0eb9
|
||||
error MaxBalExceeded();
|
||||
/// @dev 0x6a3bc53e
|
||||
error EmptyPixTarget();
|
||||
/// @dev 0x87138d5c
|
||||
error NotInitialized();
|
||||
}
|
||||
241
contracts/core/OwnerSettings.sol
Normal file
241
contracts/core/OwnerSettings.sol
Normal file
@@ -0,0 +1,241 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
pragma solidity ^0.8.19;
|
||||
|
||||
import { ERC2771 } from "contracts/lib/metatx/ERC2771Context.sol";
|
||||
import { ERC20, SafeTransferLib } from "contracts/lib/utils/SafeTransferLib.sol";
|
||||
import { IReputation } from "contracts/lib/interfaces/IReputation.sol";
|
||||
import { EventAndErrors } from "contracts/core/EventAndErrors.sol";
|
||||
import { Constants } from "contracts/core/Constants.sol";
|
||||
import { Owned } from "contracts/lib/auth/Owned.sol";
|
||||
|
||||
abstract contract OwnerSettings is
|
||||
Constants,
|
||||
EventAndErrors,
|
||||
Owned(msg.sender),
|
||||
ERC2771
|
||||
{
|
||||
/// ███ Storage ████████████████████████████████████████████████████████████
|
||||
|
||||
/// @dev List of valid Bacen signature addresses
|
||||
/// mapping(uint256 => bool) public validBacenSigners;
|
||||
/// @dev Value in custom storage slot given by:
|
||||
/// let value := sload(shl(12, address)).
|
||||
|
||||
IReputation public reputation;
|
||||
/// @dev Default blocks that lock will hold tokens.
|
||||
uint256 public defaultLockBlocks;
|
||||
|
||||
/// ███ Constructor ████████████████████████████████████████████████████████
|
||||
|
||||
constructor(
|
||||
uint256 defaultBlocks,
|
||||
address[] memory validSigners,
|
||||
address _reputation,
|
||||
ERC20[] memory tokens,
|
||||
bool[] memory tokenStates
|
||||
) {
|
||||
setDefaultLockBlocks(defaultBlocks);
|
||||
setValidSigners(validSigners);
|
||||
setReputation(IReputation(_reputation));
|
||||
tokenSettings(tokens, tokenStates);
|
||||
}
|
||||
|
||||
/// ███ Owner Only █████████████████████████████████████████████████████████
|
||||
|
||||
function setTrustedFowarders(
|
||||
address[] memory forwarders,
|
||||
bool[] memory states
|
||||
) external onlyOwner {
|
||||
assembly ("memory-safe") {
|
||||
// first 32 bytes eq to array's length
|
||||
let fLen := mload(forwarders)
|
||||
// halts execution if forwarders.length eq 0
|
||||
if iszero(fLen) {
|
||||
invalid()
|
||||
}
|
||||
// revert with `LengthMismatch()`
|
||||
if iszero(eq(fLen, mload(states))) {
|
||||
mstore(0x00, 0xff633a38)
|
||||
revert(0x1c, 0x04)
|
||||
}
|
||||
let fLoc := add(forwarders, 0x20)
|
||||
let sLoc := add(states, 0x20)
|
||||
for {
|
||||
let end := add(fLoc, shl(5, fLen))
|
||||
} iszero(eq(fLoc, end)) {
|
||||
fLoc := add(fLoc, 0x20)
|
||||
sLoc := add(sLoc, 0x20)
|
||||
} {
|
||||
// cache hashmap entry in scratch space
|
||||
mstore(0x20, trustedForwarders.slot)
|
||||
mstore(0x00, mload(fLoc))
|
||||
// let mapSlot := keccak256(0x00, 0x40)
|
||||
sstore(keccak256(0x00, 0x40), mload(sLoc))
|
||||
|
||||
// emit TrustedForwarderUpdated(address, bool)
|
||||
log3(
|
||||
0,
|
||||
0,
|
||||
_TRUSTED_FORWARDER_UPDATED_EVENT_SIGNATURE,
|
||||
mload(fLoc),
|
||||
mload(sLoc)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// @dev Contract's underlying balance withdraw method.
|
||||
/// @dev Function sighash: 0x5fd8c710.
|
||||
function withdrawBalance() external onlyOwner {
|
||||
uint256 balance = address(this).balance;
|
||||
SafeTransferLib.safeTransferETH(msg.sender, balance);
|
||||
emit FundsWithdrawn(msg.sender, balance);
|
||||
}
|
||||
|
||||
function setReputation(
|
||||
IReputation _reputation
|
||||
) public onlyOwner {
|
||||
assembly ("memory-safe") {
|
||||
sstore(reputation.slot, _reputation)
|
||||
}
|
||||
emit ReputationUpdated(address(_reputation));
|
||||
}
|
||||
|
||||
function setDefaultLockBlocks(
|
||||
uint256 _blocks
|
||||
) public onlyOwner {
|
||||
assembly ("memory-safe") {
|
||||
sstore(defaultLockBlocks.slot, _blocks)
|
||||
}
|
||||
emit LockBlocksUpdated(_blocks);
|
||||
}
|
||||
|
||||
function setValidSigners(
|
||||
address[] memory _validSigners
|
||||
) public onlyOwner {
|
||||
assembly ("memory-safe") {
|
||||
let i := add(_validSigners, 0x20)
|
||||
let end := add(i, shl(0x05, mload(_validSigners)))
|
||||
for {
|
||||
/* */
|
||||
} iszero(returndatasize()) {
|
||||
/* */
|
||||
} {
|
||||
sstore(shl(0xc, mload(i)), true)
|
||||
i := add(i, 0x20)
|
||||
|
||||
if iszero(lt(i, end)) {
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
emit ValidSignersUpdated(_validSigners);
|
||||
}
|
||||
|
||||
function tokenSettings(
|
||||
ERC20[] memory _tokens,
|
||||
bool[] memory _states
|
||||
) public onlyOwner {
|
||||
/* Yul Impl */
|
||||
assembly ("memory-safe") {
|
||||
// first 32 bytes eq to array's length
|
||||
let tLen := mload(_tokens)
|
||||
// NoTokens()
|
||||
if iszero(tLen) {
|
||||
mstore(0x00, 0xdf957883)
|
||||
revert(0x1c, 0x04)
|
||||
}
|
||||
// LengthMismatch()
|
||||
if iszero(eq(tLen, mload(_states))) {
|
||||
mstore(0x00, 0xff633a38)
|
||||
revert(0x1c, 0x04)
|
||||
}
|
||||
let tLoc := add(_tokens, 0x20)
|
||||
let sLoc := add(_states, 0x20)
|
||||
for {
|
||||
let end := add(tLoc, shl(5, tLen))
|
||||
} iszero(eq(tLoc, end)) {
|
||||
tLoc := add(tLoc, 0x20)
|
||||
sLoc := add(sLoc, 0x20)
|
||||
} {
|
||||
// cache hashmap entry in scratch space
|
||||
mstore(0x0c, _ALLOWED_ERC20_SLOT_SEED)
|
||||
mstore(0x00, mload(tLoc))
|
||||
// let mapSlot := keccak256(0x0c, 0x20)
|
||||
sstore(keccak256(0x0c, 0x20), mload(sLoc))
|
||||
|
||||
// emit AllowedERC20Updated(address, bool)
|
||||
log3(
|
||||
0,
|
||||
0,
|
||||
_ALLOWED_ERC20_UPDATED_EVENT_SIGNATURE,
|
||||
mload(tLoc),
|
||||
mload(sLoc)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// ███ View FX ████████████████████████████████████████████████████████████
|
||||
|
||||
function validBacenSigners(
|
||||
uint256 signer
|
||||
) public view returns (bool valid) {
|
||||
assembly ("memory-safe") {
|
||||
valid := sload(signer)
|
||||
}
|
||||
}
|
||||
|
||||
function sellerAllowList(
|
||||
address sellerKey
|
||||
) public view returns (bytes32 root) {
|
||||
assembly ("memory-safe") {
|
||||
mstore(0x0c, _SELLER_ALLOWLIST_SLOT_SEED)
|
||||
mstore(0x00, sellerKey)
|
||||
root := sload(keccak256(0x00, 0x20))
|
||||
}
|
||||
}
|
||||
|
||||
function allowedERC20s(
|
||||
ERC20 erc20
|
||||
) public view returns (bool state) {
|
||||
assembly ("memory-safe") {
|
||||
mstore(0x0c, _ALLOWED_ERC20_SLOT_SEED)
|
||||
mstore(0x00, erc20)
|
||||
state := sload(keccak256(0x0c, 0x20))
|
||||
}
|
||||
}
|
||||
|
||||
function _limiter(
|
||||
uint256 _userCredit
|
||||
) internal view returns (uint256 _spendLimit) {
|
||||
bytes memory encodedParams = abi.encodeWithSelector(
|
||||
// IReputation.limiter.selector,
|
||||
0x4d2b1791,
|
||||
_userCredit
|
||||
);
|
||||
bool success;
|
||||
assembly ("memory-safe") {
|
||||
success := staticcall(
|
||||
// gas
|
||||
gas(),
|
||||
// address
|
||||
sload(reputation.slot),
|
||||
// argsOffset
|
||||
add(encodedParams, 0x20),
|
||||
// argsSize
|
||||
mload(encodedParams),
|
||||
// retOffset
|
||||
0x00,
|
||||
// retSize
|
||||
0x20
|
||||
)
|
||||
_spendLimit := mload(0x00)
|
||||
if iszero(success) {
|
||||
// StaticCallFailed()
|
||||
mstore(0x00, 0xe10bf1cc)
|
||||
revert(0x1c, 0x04)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,8 @@ pragma solidity >=0.8.4;
|
||||
/// @notice Simple single owner authorization mixin.
|
||||
/// @author Solmate (https://github.com/Rari-Capital/solmate/blob/main/src/auth/Owned.sol)
|
||||
abstract contract Owned {
|
||||
error Unauthorized();
|
||||
|
||||
/*//////////////////////////////////////////////////////////////
|
||||
EVENTS
|
||||
//////////////////////////////////////////////////////////////*/
|
||||
@@ -20,7 +22,7 @@ abstract contract Owned {
|
||||
address public owner;
|
||||
|
||||
modifier onlyOwner() virtual {
|
||||
require(msg.sender == owner, "UNAUTHORIZED");
|
||||
if (msg.sender != owner) revert Unauthorized();
|
||||
|
||||
_;
|
||||
}
|
||||
|
||||
14
contracts/lib/metatx/ERC2771Context.sol
Normal file
14
contracts/lib/metatx/ERC2771Context.sol
Normal file
@@ -0,0 +1,14 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
pragma solidity ^0.8.20;
|
||||
|
||||
import { ERC2771Context } from "@openzeppelin/contracts/metatx/ERC2771Context.sol";
|
||||
|
||||
abstract contract ERC2771 is ERC2771Context(address(0)) {
|
||||
mapping(address => bool) public trustedForwarders;
|
||||
|
||||
function isTrustedForwarder(address forwarder) public view override returns (bool) {
|
||||
return trustedForwarders[forwarder];
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,10 +1,10 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
pragma solidity 0.8.9;
|
||||
pragma solidity ^0.8.19;
|
||||
|
||||
import { ERC20 } from "../tokens/ERC20.sol";
|
||||
import { ERC20 } from "@openzeppelin/contracts/token/ERC20/ERC20.sol";
|
||||
|
||||
contract MockToken is ERC20 {
|
||||
constructor(uint256 supply) ERC20("MockBRL", "MBRL", 18) {
|
||||
constructor(uint256 supply) ERC20("MockBRL", "MBRL") {
|
||||
_mint(msg.sender, supply);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,250 +0,0 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
pragma solidity >=0.8.4;
|
||||
|
||||
/// @notice Modern and gas efficient ERC20 + EIP-2612 implementation.
|
||||
/// @author Solmate (https://github.com/Rari-Capital/solmate/blob/main/src/tokens/ERC20.sol)
|
||||
/// @author Modified from Uniswap (https://github.com/Uniswap/uniswap-v2-core/blob/master/contracts/UniswapV2ERC20.sol)
|
||||
/// @dev Do not manually set balances without updating totalSupply, as the sum of all user balances must not exceed it.
|
||||
abstract contract ERC20 {
|
||||
/*//////////////////////////////////////////////////////////////
|
||||
EVENTS
|
||||
//////////////////////////////////////////////////////////////*/
|
||||
|
||||
event Transfer(
|
||||
address indexed from,
|
||||
address indexed to,
|
||||
uint256 amount
|
||||
);
|
||||
|
||||
event Approval(
|
||||
address indexed owner,
|
||||
address indexed spender,
|
||||
uint256 amount
|
||||
);
|
||||
|
||||
/*//////////////////////////////////////////////////////////////
|
||||
METADATA STORAGE
|
||||
//////////////////////////////////////////////////////////////*/
|
||||
|
||||
string public name;
|
||||
|
||||
string public symbol;
|
||||
|
||||
uint8 public immutable decimals;
|
||||
|
||||
/*//////////////////////////////////////////////////////////////
|
||||
ERC20 STORAGE
|
||||
//////////////////////////////////////////////////////////////*/
|
||||
|
||||
uint256 public totalSupply;
|
||||
|
||||
mapping(address => uint256) public balanceOf;
|
||||
|
||||
mapping(address => mapping(address => uint256))
|
||||
public allowance;
|
||||
|
||||
/*//////////////////////////////////////////////////////////////
|
||||
EIP-2612 STORAGE
|
||||
//////////////////////////////////////////////////////////////*/
|
||||
|
||||
uint256 internal immutable INITIAL_CHAIN_ID;
|
||||
|
||||
bytes32 internal immutable INITIAL_DOMAIN_SEPARATOR;
|
||||
|
||||
mapping(address => uint256) public nonces;
|
||||
|
||||
/*//////////////////////////////////////////////////////////////
|
||||
CONSTRUCTOR
|
||||
//////////////////////////////////////////////////////////////*/
|
||||
|
||||
constructor(
|
||||
string memory _name,
|
||||
string memory _symbol,
|
||||
uint8 _decimals
|
||||
) {
|
||||
name = _name;
|
||||
symbol = _symbol;
|
||||
decimals = _decimals;
|
||||
|
||||
INITIAL_CHAIN_ID = block.chainid;
|
||||
INITIAL_DOMAIN_SEPARATOR = computeDomainSeparator();
|
||||
}
|
||||
|
||||
/*//////////////////////////////////////////////////////////////
|
||||
ERC20 LOGIC
|
||||
//////////////////////////////////////////////////////////////*/
|
||||
|
||||
function approve(
|
||||
address spender,
|
||||
uint256 amount
|
||||
) public virtual returns (bool) {
|
||||
allowance[msg.sender][spender] = amount;
|
||||
|
||||
emit Approval(msg.sender, spender, amount);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function transfer(
|
||||
address to,
|
||||
uint256 amount
|
||||
) public virtual returns (bool) {
|
||||
balanceOf[msg.sender] -= amount;
|
||||
|
||||
// Cannot overflow because the sum of all user
|
||||
// balances can't exceed the max uint256 value.
|
||||
unchecked {
|
||||
balanceOf[to] += amount;
|
||||
}
|
||||
|
||||
emit Transfer(msg.sender, to, amount);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function transferFrom(
|
||||
address from,
|
||||
address to,
|
||||
uint256 amount
|
||||
) public virtual returns (bool) {
|
||||
uint256 allowed = allowance[from][msg.sender]; // Saves gas for limited approvals.
|
||||
|
||||
if (allowed != type(uint256).max)
|
||||
allowance[from][msg.sender] = allowed - amount;
|
||||
|
||||
balanceOf[from] -= amount;
|
||||
|
||||
// Cannot overflow because the sum of all user
|
||||
// balances can't exceed the max uint256 value.
|
||||
unchecked {
|
||||
balanceOf[to] += amount;
|
||||
}
|
||||
|
||||
emit Transfer(from, to, amount);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/*//////////////////////////////////////////////////////////////
|
||||
EIP-2612 LOGIC
|
||||
//////////////////////////////////////////////////////////////*/
|
||||
|
||||
function permit(
|
||||
address owner,
|
||||
address spender,
|
||||
uint256 value,
|
||||
uint256 deadline,
|
||||
uint8 v,
|
||||
bytes32 r,
|
||||
bytes32 s
|
||||
) public virtual {
|
||||
require(
|
||||
deadline >= block.timestamp,
|
||||
"PERMIT_DEADLINE_EXPIRED"
|
||||
);
|
||||
|
||||
// Unchecked because the only math done is incrementing
|
||||
// the owner's nonce which cannot realistically overflow.
|
||||
unchecked {
|
||||
address recoveredAddress = ecrecover(
|
||||
keccak256(
|
||||
abi.encodePacked(
|
||||
"\x19\x01",
|
||||
DOMAIN_SEPARATOR(),
|
||||
keccak256(
|
||||
abi.encode(
|
||||
keccak256(
|
||||
"Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)"
|
||||
),
|
||||
owner,
|
||||
spender,
|
||||
value,
|
||||
nonces[owner]++,
|
||||
deadline
|
||||
)
|
||||
)
|
||||
)
|
||||
),
|
||||
v,
|
||||
r,
|
||||
s
|
||||
);
|
||||
|
||||
require(
|
||||
recoveredAddress != address(0) &&
|
||||
recoveredAddress == owner,
|
||||
"INVALID_SIGNER"
|
||||
);
|
||||
|
||||
allowance[recoveredAddress][spender] = value;
|
||||
}
|
||||
|
||||
emit Approval(owner, spender, value);
|
||||
}
|
||||
|
||||
function DOMAIN_SEPARATOR()
|
||||
public
|
||||
view
|
||||
virtual
|
||||
returns (bytes32)
|
||||
{
|
||||
return
|
||||
block.chainid == INITIAL_CHAIN_ID
|
||||
? INITIAL_DOMAIN_SEPARATOR
|
||||
: computeDomainSeparator();
|
||||
}
|
||||
|
||||
function computeDomainSeparator()
|
||||
internal
|
||||
view
|
||||
virtual
|
||||
returns (bytes32)
|
||||
{
|
||||
return
|
||||
keccak256(
|
||||
abi.encode(
|
||||
keccak256(
|
||||
"EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)"
|
||||
),
|
||||
keccak256(bytes(name)),
|
||||
keccak256("1"),
|
||||
block.chainid,
|
||||
address(this)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/*//////////////////////////////////////////////////////////////
|
||||
INTERNAL MINT/BURN LOGIC
|
||||
//////////////////////////////////////////////////////////////*/
|
||||
|
||||
function _mint(
|
||||
address to,
|
||||
uint256 amount
|
||||
) internal virtual {
|
||||
totalSupply += amount;
|
||||
|
||||
// Cannot overflow because the sum of all user
|
||||
// balances can't exceed the max uint256 value.
|
||||
unchecked {
|
||||
balanceOf[to] += amount;
|
||||
}
|
||||
|
||||
emit Transfer(address(0), to, amount);
|
||||
}
|
||||
|
||||
function _burn(
|
||||
address from,
|
||||
uint256 amount
|
||||
) internal virtual {
|
||||
balanceOf[from] -= amount;
|
||||
|
||||
// Cannot underflow because a user's balance
|
||||
// will never be larger than the total supply.
|
||||
unchecked {
|
||||
totalSupply -= amount;
|
||||
}
|
||||
|
||||
emit Transfer(from, address(0), amount);
|
||||
}
|
||||
}
|
||||
@@ -1,52 +0,0 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
pragma solidity >=0.8.4;
|
||||
|
||||
/// @title Counters
|
||||
/// @author buf0t9
|
||||
/// @author Modified from OpenZeppelin Contracts
|
||||
/// (https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/Counters.sol)
|
||||
/// @notice Provides counters that can only be incremented, decrementedor reset.
|
||||
/// @dev Include with `using Counters for Counters.Counter;`
|
||||
library Counters {
|
||||
// solhint-disable no-inline-assembly
|
||||
struct Counter {
|
||||
/// @dev Interactions must be restricted to the library's function.
|
||||
uint256 _val; // := 0
|
||||
}
|
||||
|
||||
/// @dev 0xce3a3d37
|
||||
error DecOverflow();
|
||||
|
||||
function current(
|
||||
Counter storage counter
|
||||
) internal view returns (uint256 _val) {
|
||||
assembly {
|
||||
_val := sload(counter.slot)
|
||||
}
|
||||
}
|
||||
|
||||
function increment(Counter storage counter) internal {
|
||||
assembly {
|
||||
let _val := sload(counter.slot)
|
||||
sstore(counter.slot, add(_val, 0x01))
|
||||
}
|
||||
}
|
||||
|
||||
function decrement(Counter storage counter) internal {
|
||||
assembly {
|
||||
let _val := sload(counter.slot)
|
||||
if or(iszero(_val), lt(_val, 0x00)) {
|
||||
mstore(0x00, 0xce3a3d37)
|
||||
revert(0x1c, 0x04)
|
||||
}
|
||||
sstore(counter.slot, sub(_val, 0x01))
|
||||
}
|
||||
}
|
||||
|
||||
function reset(Counter storage counter) internal {
|
||||
assembly {
|
||||
sstore(counter.slot, 0)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,58 +0,0 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
pragma solidity >=0.8.4;
|
||||
|
||||
/// @notice Gas optimized verification of proof of inclusion for a leaf in a Merkle tree.
|
||||
/// @author Solady
|
||||
/// (https://github.com/vectorized/solady/blob/main/src/utils/MerkleProofLib.sol)
|
||||
/// @author Modified from Solmate
|
||||
/// (https://github.com/transmissions11/solmate/blob/main/src/utils/MerkleProofLib.sol)
|
||||
/// @author Modified from OpenZeppelin
|
||||
/// (https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/cryptography/MerkleProof.sol)
|
||||
library MerkleProofLib {
|
||||
/// @dev Returns whether `leaf` exists in the Merkle tree with `root`, given `proof`.
|
||||
function verify(
|
||||
bytes32[] calldata proof,
|
||||
bytes32 root,
|
||||
bytes32 leaf
|
||||
) internal pure returns (bool isValid) {
|
||||
/// @solidity memory-safe-assembly
|
||||
assembly {
|
||||
if proof.length {
|
||||
// Left shift by 5 is equivalent to multiplying by 0x20.
|
||||
let end := add(
|
||||
proof.offset,
|
||||
shl(5, proof.length)
|
||||
)
|
||||
// Initialize `offset` to the offset of `proof` in the calldata.
|
||||
let offset := proof.offset
|
||||
// Iterate over proof elements to compute root hash.
|
||||
for {
|
||||
|
||||
} 1 {
|
||||
|
||||
} {
|
||||
// Slot of `leaf` in scratch space.
|
||||
// If the condition is true: 0x20, otherwise: 0x00.
|
||||
let scratch := shl(
|
||||
5,
|
||||
gt(leaf, calldataload(offset))
|
||||
)
|
||||
// Store elements to hash contiguously in scratch space.
|
||||
// Scratch space is 64 bytes (0x00 - 0x3f) and both elements are 32 bytes.
|
||||
mstore(scratch, leaf)
|
||||
mstore(
|
||||
xor(scratch, 0x20),
|
||||
calldataload(offset)
|
||||
)
|
||||
// Reuse `leaf` to store the hash to reduce stack operations.
|
||||
leaf := keccak256(0x00, 0x40)
|
||||
offset := add(offset, 0x20)
|
||||
if iszero(lt(offset, end)) {
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
isValid := eq(leaf, root)
|
||||
}
|
||||
}
|
||||
}
|
||||
80
contracts/lib/utils/Multicall.sol
Normal file
80
contracts/lib/utils/Multicall.sol
Normal file
@@ -0,0 +1,80 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
pragma solidity >=0.8.4;
|
||||
|
||||
/// @title Multicall.
|
||||
/// @notice Contract that batches view function calls and aggregates their results.
|
||||
/// @author Adapted from Makerdao's Multicall2 (https://github.com/makerdao/multicall/blob/master/src/Multicall2.sol).
|
||||
|
||||
contract Multicall {
|
||||
/// @dev 0x
|
||||
error CallFailed(string reason);
|
||||
|
||||
struct Call {
|
||||
address target;
|
||||
bytes callData;
|
||||
}
|
||||
struct Result {
|
||||
bool success;
|
||||
bytes returnData;
|
||||
}
|
||||
|
||||
//prettier-ignore
|
||||
constructor(/* */) payable {/* */}
|
||||
|
||||
function mtc1(Call[] calldata calls)
|
||||
external
|
||||
returns (uint256, bytes[] memory)
|
||||
{
|
||||
uint256 bn = block.number;
|
||||
uint256 len = calls.length;
|
||||
bytes[] memory res = new bytes[](len);
|
||||
uint256 j;
|
||||
|
||||
while (j < len) {
|
||||
(bool success, bytes memory ret) = calls[j]
|
||||
.target
|
||||
.call(calls[j].callData);
|
||||
if (!success) {
|
||||
if (ret.length < 0x44) revert CallFailed("");
|
||||
assembly {
|
||||
ret := add(ret, 0x04)
|
||||
}
|
||||
revert CallFailed({
|
||||
reason: abi.decode(ret, (string))
|
||||
});
|
||||
}
|
||||
res[j] = ret;
|
||||
++j;
|
||||
}
|
||||
return (bn, res);
|
||||
}
|
||||
|
||||
function mtc2(Call[] calldata calls)
|
||||
external
|
||||
returns (
|
||||
uint256,
|
||||
bytes32,
|
||||
Result[] memory
|
||||
)
|
||||
{
|
||||
uint256 bn = block.number;
|
||||
// µ 0 s [0] ≡ P(IHp , µs [0], 0) ∴ P is the hash of a block of a particular number, up to a maximum age.
|
||||
// 0 is left on the stack if the looked for `block.number` is >= to the current `block.number` or more than 256
|
||||
// blocks behind the current block (Yellow Paper, p. 33, https://ethereum.github.io/yellowpaper/paper.pdf).
|
||||
bytes32 bh = blockhash(
|
||||
bn /* - 1 */
|
||||
);
|
||||
uint256 len = calls.length;
|
||||
Result[] memory res = new Result[](len);
|
||||
uint256 i;
|
||||
for (i; i < len; ) {
|
||||
(bool success, bytes memory ret) = calls[i]
|
||||
.target
|
||||
.call(calls[i].callData);
|
||||
|
||||
res[i] = Result(success, ret);
|
||||
++i;
|
||||
}
|
||||
return (bn, bh, res);
|
||||
}
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
pragma solidity >=0.8.4;
|
||||
|
||||
/// @notice Reentrancy protection for smart contracts.
|
||||
/// @author z0r0z.eth
|
||||
/// @author Modified from Seaport
|
||||
/// (https://github.com/ProjectOpenSea/seaport/blob/main/contracts/lib/ReentrancyGuard.sol)
|
||||
/// @author Modified from Solmate
|
||||
/// (https://github.com/Rari-Capital/solmate/blob/main/src/utils/ReentrancyGuard.sol)
|
||||
abstract contract ReentrancyGuard {
|
||||
error Reentrancy();
|
||||
|
||||
uint256 private guard = 1;
|
||||
|
||||
modifier nonReentrant() virtual {
|
||||
setReentrancyGuard();
|
||||
|
||||
_;
|
||||
|
||||
clearReentrancyGuard();
|
||||
}
|
||||
|
||||
/// @dev Check guard sentinel value and set it.
|
||||
function setReentrancyGuard() internal virtual {
|
||||
if (guard == 2) revert Reentrancy();
|
||||
|
||||
guard = 2;
|
||||
}
|
||||
|
||||
/// @dev Unset sentinel value.
|
||||
function clearReentrancyGuard() internal virtual {
|
||||
guard = 1;
|
||||
}
|
||||
}
|
||||
@@ -1,159 +1,143 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
pragma solidity >=0.8.4;
|
||||
|
||||
import { ERC20 } from "../tokens/ERC20.sol";
|
||||
import { ERC20 } from "@openzeppelin/contracts/token/ERC20/ERC20.sol";
|
||||
|
||||
/// @notice Safe ETH and ERC20 transfer library that gracefully handles missing return values.
|
||||
/// @author Solmate (https://github.com/Rari-Capital/solmate/blob/main/src/utils/SafeTransferLib.sol)
|
||||
/// @author Solady (https://github.com/vectorized/solady/blob/main/src/utils/SafeTransferLib.sol)
|
||||
/// @author Modified from Solmate (https://github.com/transmissions11/solmate/blob/main/src/utils/SafeTransferLib.sol)
|
||||
/// @dev Caution! This library won't check that a token has code, responsibility is delegated to the caller.
|
||||
library SafeTransferLib {
|
||||
/*//////////////////////////////////////////////////////////////
|
||||
CUSTOM ERRORS
|
||||
//////////////////////////////////////////////////////////////*/
|
||||
|
||||
/// @dev The ETH transfer has failed.
|
||||
error ETHTransferFailed();
|
||||
/// @dev The ERC20 `transferFrom` has failed.
|
||||
error TransferFromFailed();
|
||||
/// @dev The ERC20 `transfer` has failed.
|
||||
error TransferFailed();
|
||||
|
||||
/*//////////////////////////////////////////////////////////////
|
||||
ETH OPERATIONS
|
||||
//////////////////////////////////////////////////////////////*/
|
||||
|
||||
/// @dev Sends `amount` (in wei) ETH to `to`.
|
||||
/// Reverts upon failure.
|
||||
function safeTransferETH(
|
||||
address to,
|
||||
uint256 amount
|
||||
) internal {
|
||||
bool success;
|
||||
|
||||
/// @solidity memory-safe-assembly
|
||||
assembly {
|
||||
// Transfer the ETH and store if it succeeded or not.
|
||||
success := call(gas(), to, amount, 0, 0, 0, 0)
|
||||
// Transfer the ETH and check if it succeeded or not.
|
||||
if iszero(call(gas(), to, amount, 0, 0, 0, 0)) {
|
||||
// Store the function selector of `ETHTransferFailed()`.
|
||||
mstore(0x00, 0xb12d13eb)
|
||||
// Revert with (offset, size).
|
||||
revert(0x1c, 0x04)
|
||||
}
|
||||
}
|
||||
|
||||
require(success, "ETH_TRANSFER_FAILED");
|
||||
}
|
||||
|
||||
/*//////////////////////////////////////////////////////////////
|
||||
ERC20 OPERATIONS
|
||||
//////////////////////////////////////////////////////////////*/
|
||||
|
||||
/// @dev Sends `amount` of ERC20 `token` from `from` to `to`.
|
||||
/// Reverts upon failure.
|
||||
///
|
||||
/// The `from` account must have at least `amount` approved for
|
||||
/// the current contract to manage.
|
||||
function safeTransferFrom(
|
||||
ERC20 token,
|
||||
address from,
|
||||
address to,
|
||||
uint256 amount
|
||||
) internal {
|
||||
bool success;
|
||||
|
||||
/// @solidity memory-safe-assembly
|
||||
assembly {
|
||||
// We'll write our calldata to this slot below, but restore it later.
|
||||
let memPointer := mload(0x40)
|
||||
let m := mload(0x40) // Cache the free memory pointer.
|
||||
|
||||
// Write the abi-encoded calldata into memory, beginning with the function selector.
|
||||
mstore(
|
||||
0,
|
||||
0x23b872dd00000000000000000000000000000000000000000000000000000000
|
||||
)
|
||||
mstore(4, from) // Append the "from" argument.
|
||||
mstore(36, to) // Append the "to" argument.
|
||||
mstore(68, amount) // Append the "amount" argument.
|
||||
mstore(0x60, amount) // Store the `amount` argument.
|
||||
mstore(0x40, to) // Store the `to` argument.
|
||||
mstore(0x2c, shl(96, from)) // Store the `from` argument.
|
||||
// Store the function selector of `transferFrom(address,address,uint256)`.
|
||||
mstore(0x0c, 0x23b872dd000000000000000000000000)
|
||||
|
||||
success := and(
|
||||
// Set success to whether the call reverted, if not we check it either
|
||||
// returned exactly 1 (can't just be non-zero data), or had no return data.
|
||||
or(
|
||||
and(
|
||||
eq(mload(0), 1),
|
||||
gt(returndatasize(), 31)
|
||||
if iszero(
|
||||
and(
|
||||
// The arguments of `and` are evaluated from right to left.
|
||||
// Set success to whether the call reverted, if not we check it either
|
||||
// returned exactly 1 (can't just be non-zero data), or had no return data.
|
||||
or(
|
||||
eq(mload(0x00), 1),
|
||||
iszero(returndatasize())
|
||||
),
|
||||
iszero(returndatasize())
|
||||
),
|
||||
// We use 100 because that's the total length of our calldata (4 + 32 * 3)
|
||||
// Counterintuitively, this call() must be positioned after the or() in the
|
||||
// surrounding and() because and() evaluates its arguments from right to left.
|
||||
call(gas(), token, 0, 0, 100, 0, 32)
|
||||
)
|
||||
call(
|
||||
gas(),
|
||||
token,
|
||||
0,
|
||||
0x1c,
|
||||
0x64,
|
||||
0x00,
|
||||
0x20
|
||||
)
|
||||
)
|
||||
) {
|
||||
// Store the function selector of `TransferFromFailed()`.
|
||||
mstore(0x00, 0x7939f424)
|
||||
// Revert with (offset, size).
|
||||
revert(0x1c, 0x04)
|
||||
}
|
||||
|
||||
mstore(0x60, 0) // Restore the zero slot to zero.
|
||||
mstore(0x40, memPointer) // Restore the memPointer.
|
||||
mstore(0x40, m) // Restore the free memory pointer.
|
||||
}
|
||||
|
||||
require(success, "TRANSFER_FROM_FAILED");
|
||||
}
|
||||
|
||||
/// @dev Sends `amount` of ERC20 `token` from the current contract to `to`.
|
||||
/// Reverts upon failure.
|
||||
function safeTransfer(
|
||||
ERC20 token,
|
||||
address to,
|
||||
uint256 amount
|
||||
) internal {
|
||||
bool success;
|
||||
|
||||
/// @solidity memory-safe-assembly
|
||||
assembly {
|
||||
// We'll write our calldata to this slot below, but restore it later.
|
||||
let memPointer := mload(0x40)
|
||||
mstore(0x14, to) // Store the `to` argument.
|
||||
mstore(0x34, amount) // Store the `amount` argument.
|
||||
// Store the function selector of `transfer(address,uint256)`.
|
||||
mstore(0x00, 0xa9059cbb000000000000000000000000)
|
||||
|
||||
// Write the abi-encoded calldata into memory, beginning with the function selector.
|
||||
mstore(
|
||||
0,
|
||||
0xa9059cbb00000000000000000000000000000000000000000000000000000000
|
||||
)
|
||||
mstore(4, to) // Append the "to" argument.
|
||||
mstore(36, amount) // Append the "amount" argument.
|
||||
|
||||
success := and(
|
||||
// Set success to whether the call reverted, if not we check it either
|
||||
// returned exactly 1 (can't just be non-zero data), or had no return data.
|
||||
or(
|
||||
and(
|
||||
eq(mload(0), 1),
|
||||
gt(returndatasize(), 31)
|
||||
if iszero(
|
||||
and(
|
||||
// The arguments of `and` are evaluated from right to left.
|
||||
// Set success to whether the call reverted, if not we check it either
|
||||
// returned exactly 1 (can't just be non-zero data), or had no return data.
|
||||
or(
|
||||
eq(mload(0x00), 1),
|
||||
iszero(returndatasize())
|
||||
),
|
||||
iszero(returndatasize())
|
||||
),
|
||||
// We use 68 because that's the total length of our calldata (4 + 32 * 2)
|
||||
// Counterintuitively, this call() must be positioned after the or() in the
|
||||
// surrounding and() because and() evaluates its arguments from right to left.
|
||||
call(gas(), token, 0, 0, 68, 0, 32)
|
||||
)
|
||||
|
||||
mstore(0x60, 0) // Restore the zero slot to zero.
|
||||
mstore(0x40, memPointer) // Restore the memPointer.
|
||||
call(
|
||||
gas(),
|
||||
token,
|
||||
0,
|
||||
0x10,
|
||||
0x44,
|
||||
0x00,
|
||||
0x20
|
||||
)
|
||||
)
|
||||
) {
|
||||
// Store the function selector of `TransferFailed()`.
|
||||
mstore(0x00, 0x90b8ec18)
|
||||
// Revert with (offset, size).
|
||||
revert(0x1c, 0x04)
|
||||
}
|
||||
// Restore the part of the free memory pointer that was overwritten.
|
||||
mstore(0x34, 0)
|
||||
}
|
||||
|
||||
require(success, "TRANSFER_FAILED");
|
||||
}
|
||||
|
||||
function safeApprove(
|
||||
ERC20 token,
|
||||
address to,
|
||||
uint256 amount
|
||||
) internal {
|
||||
bool success;
|
||||
|
||||
assembly {
|
||||
// We'll write our calldata to this slot below, but restore it later.
|
||||
let memPointer := mload(0x40)
|
||||
|
||||
// Write the abi-encoded calldata into memory, beginning with the function selector.
|
||||
mstore(
|
||||
0,
|
||||
0x095ea7b300000000000000000000000000000000000000000000000000000000
|
||||
)
|
||||
mstore(4, to) // Append the "to" argument.
|
||||
mstore(36, amount) // Append the "amount" argument.
|
||||
|
||||
success := and(
|
||||
// Set success to whether the call reverted, if not we check it either
|
||||
// returned exactly 1 (can't just be non-zero data), or had no return data.
|
||||
or(
|
||||
and(
|
||||
eq(mload(0), 1),
|
||||
gt(returndatasize(), 31)
|
||||
),
|
||||
iszero(returndatasize())
|
||||
),
|
||||
// We use 68 because that's the total length of our calldata (4 + 32 * 2)
|
||||
// Counterintuitively, this call() must be positioned after the or() in the
|
||||
// surrounding and() because and() evaluates its arguments from right to left.
|
||||
call(gas(), token, 0, 0, 68, 0, 32)
|
||||
)
|
||||
|
||||
mstore(0x60, 0) // Restore the zero slot to zero.
|
||||
mstore(0x40, memPointer) // Restore the memPointer.
|
||||
}
|
||||
|
||||
require(success, "APPROVE_FAILED");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
pragma solidity 0.8.9;
|
||||
pragma solidity ^0.8.19;
|
||||
|
||||
/// ______ __
|
||||
/// .-----.|__ |.-----.|__|.--.--.
|
||||
@@ -8,242 +8,199 @@ pragma solidity 0.8.9;
|
||||
/// |__| |__|
|
||||
///
|
||||
|
||||
import { Owned } from "./lib/auth/Owned.sol";
|
||||
import { Counters } from "./lib/utils/Counters.sol";
|
||||
import { ERC20, SafeTransferLib } from "./lib/utils/SafeTransferLib.sol";
|
||||
import { IReputation } from "./lib/interfaces/IReputation.sol";
|
||||
import { MerkleProofLib as Merkle } from "./lib/utils/MerkleProofLib.sol";
|
||||
import { ReentrancyGuard } from "./lib/utils/ReentrancyGuard.sol";
|
||||
import { EventAndErrors } from "./EventAndErrors.sol";
|
||||
import { DataTypes as DT } from "./DataTypes.sol";
|
||||
import { OwnerSettings, ERC20, SafeTransferLib } from "contracts/core/OwnerSettings.sol";
|
||||
import { BaseUtils } from "contracts/core/BaseUtils.sol";
|
||||
import { DataTypes as DT } from "contracts/core/DataTypes.sol";
|
||||
import { IPrimusZKTLS, Attestation } from "@primuslabs/zktls-contracts/src/IPrimusZKTLS.sol";
|
||||
|
||||
contract P2PIX is
|
||||
EventAndErrors,
|
||||
Owned(msg.sender),
|
||||
ReentrancyGuard
|
||||
{
|
||||
contract P2PIX is BaseUtils {
|
||||
// solhint-disable use-forbidden-name
|
||||
// solhint-disable no-inline-assembly
|
||||
// solhint-disable no-empty-blocks
|
||||
|
||||
using Counters for Counters.Counter;
|
||||
using DT for DT.Deposit;
|
||||
using DT for DT.Lock;
|
||||
using DT for DT.LockStatus;
|
||||
|
||||
/// ███ Storage ████████████████████████████████████████████████████████████
|
||||
|
||||
IReputation public reputation;
|
||||
Counters.Counter public depositCount;
|
||||
|
||||
/// @dev Default blocks that lock will hold tokens.
|
||||
uint256 public defaultLockBlocks;
|
||||
/// @dev The scalar of BRZ token.
|
||||
uint256 public constant WAD = 1e18;
|
||||
uint256 public lockCounter;
|
||||
|
||||
/// @dev List of Locks.
|
||||
mapping(uint256 => DT.Lock) public mapLocks;
|
||||
/// @dev Stores an relayer's last computed credit.
|
||||
mapping(uint256 => uint256) public userRecord;
|
||||
/// @dev List of valid Bacen signature addresses
|
||||
mapping(uint256 => bool) public validBacenSigners;
|
||||
/// @dev Seller list of deposits
|
||||
mapping(uint256 => DT.Deposit) public mapDeposits;
|
||||
/// @dev List of Locks.
|
||||
mapping(bytes32 => DT.Lock) public mapLocks;
|
||||
/// @dev List of Pix transactions already signed.
|
||||
mapping(bytes32 => bool) public usedTransactions;
|
||||
/// @dev Seller casted to key => Seller's allowlist merkleroot.
|
||||
mapping(uint256 => bytes32) public sellerAllowList;
|
||||
/// @dev Tokens allowed to serve as the underlying amount of a deposit.
|
||||
mapping(ERC20 => bool) public allowedERC20s;
|
||||
|
||||
/// ███ Constructor ████████████████████████████████████████████████████████
|
||||
|
||||
constructor(
|
||||
uint256 defaultBlocks,
|
||||
address[] memory validSigners,
|
||||
IReputation _reputation,
|
||||
address[] memory tokens,
|
||||
bool[] memory tokenStates
|
||||
) payable {
|
||||
setDefaultLockBlocks(defaultBlocks);
|
||||
setReputation(_reputation);
|
||||
setValidSigners(validSigners);
|
||||
tokenSettings(tokens, tokenStates);
|
||||
}
|
||||
|
||||
/// ███ Public FX ██████████████████████████████████████████████████████████
|
||||
address _reputation,
|
||||
ERC20[] memory tokens,
|
||||
bool[] memory tokenStates,
|
||||
address primusAddress
|
||||
)
|
||||
OwnerSettings(
|
||||
defaultBlocks,
|
||||
validSigners,
|
||||
_reputation,
|
||||
tokens,
|
||||
tokenStates
|
||||
)
|
||||
payable {/* */}
|
||||
|
||||
/// @notice Creates a deposit order based on a seller's
|
||||
/// offer of an amount of ERC20 tokens.
|
||||
/// @dev Seller needs to send his tokens to the P2PIX smart contract.
|
||||
/// @param _pixTarget Pix key destination provided by the offer's seller.
|
||||
/// @notice Seller needs to send his tokens to the P2PIX smart contract.
|
||||
/// @param pixTarget Pix key destination provided by the offer's seller.
|
||||
/// @param allowlistRoot Optional allow list merkleRoot update `bytes32` value.
|
||||
/// @return depositID The `uint256` return value provided
|
||||
/// as the deposit identifier.
|
||||
/// @dev Function sighash: 0xbfe07da6.
|
||||
/// @dev Function sighash: 0x5e918943
|
||||
function deposit(
|
||||
address _token,
|
||||
uint256 _amount,
|
||||
string calldata _pixTarget,
|
||||
bytes32 allowlistRoot
|
||||
) public returns (uint256 depositID) {
|
||||
ERC20 t = ERC20(_token);
|
||||
if (!allowedERC20s[t]) revert TokenDenied();
|
||||
string calldata pixTarget,
|
||||
bytes32 allowlistRoot,
|
||||
ERC20 token,
|
||||
uint96 amount,
|
||||
bool valid
|
||||
) public nonReentrant {
|
||||
|
||||
(depositID) = _encodeDepositID();
|
||||
if (bytes(pixTarget).length == 0) revert EmptyPixTarget();
|
||||
if (!allowedERC20s(token)) revert TokenDenied();
|
||||
uint256 _sellerBalance = __sellerBalance(msg.sender, token);
|
||||
|
||||
DT.Deposit memory d = DT.Deposit({
|
||||
remaining: _amount,
|
||||
pixTarget: _pixTarget,
|
||||
seller: msg.sender,
|
||||
token: _token,
|
||||
valid: true
|
||||
});
|
||||
|
||||
setReentrancyGuard();
|
||||
uint256 currBal = _sellerBalance & BITMASK_SB_ENTRY;
|
||||
uint256 _newBal = uint256(currBal + amount);
|
||||
if (_newBal > MAXBALANCE_UPPERBOUND)
|
||||
revert MaxBalExceeded();
|
||||
|
||||
if (allowlistRoot != 0) {
|
||||
setRoot(msg.sender, allowlistRoot);
|
||||
}
|
||||
|
||||
mapDeposits[depositID] = d;
|
||||
depositCount.increment();
|
||||
bytes32 pixTargetCasted = getStr(pixTarget);
|
||||
uint256 validCasted = _castBool(valid);
|
||||
|
||||
_setSellerBalance(
|
||||
msg.sender,
|
||||
token,
|
||||
(_newBal | (validCasted << BITPOS_VALID)),
|
||||
pixTargetCasted
|
||||
);
|
||||
|
||||
SafeTransferLib.safeTransferFrom(
|
||||
t,
|
||||
token,
|
||||
msg.sender,
|
||||
address(this),
|
||||
_amount
|
||||
amount
|
||||
);
|
||||
|
||||
clearReentrancyGuard();
|
||||
|
||||
emit DepositAdded(
|
||||
msg.sender,
|
||||
depositID,
|
||||
_token,
|
||||
_amount
|
||||
);
|
||||
emit DepositAdded(msg.sender, token, amount);
|
||||
}
|
||||
|
||||
/// @notice Enables seller to invalidate future
|
||||
/// locks made to his/her token offering order.
|
||||
/// @dev This function does not affect any ongoing active locks.
|
||||
/// @dev Function sighash: 0x72fada5c.
|
||||
/// @notice This function does not affect any ongoing active locks.
|
||||
/// @dev Function sighash: 0x6d82d9e0
|
||||
function setValidState(ERC20 token, bool state) public {
|
||||
uint256 _sellerBalance = __sellerBalance(msg.sender, token);
|
||||
|
||||
function cancelDeposit(uint256 depositID) public {
|
||||
_onlySeller(depositID);
|
||||
mapDeposits[depositID].valid = false;
|
||||
emit DepositClosed(
|
||||
mapDeposits[depositID].seller,
|
||||
depositID
|
||||
);
|
||||
if (_sellerBalance != 0) {
|
||||
uint256 _valid = _castBool(state);
|
||||
|
||||
_sellerBalance =
|
||||
(_sellerBalance & BITMASK_SB_ENTRY) |
|
||||
(_valid << BITPOS_VALID);
|
||||
|
||||
_setValidState(msg.sender, token, _sellerBalance);
|
||||
|
||||
emit ValidSet(msg.sender, token, state);
|
||||
} else revert NotInitialized();
|
||||
}
|
||||
|
||||
/// @notice Public method designed to lock an remaining amount of
|
||||
/// the deposit order of a seller.
|
||||
/// @dev This method can be performed either by:
|
||||
/// @notice Transaction forwarding must leave `merkleProof` empty;
|
||||
/// otherwise, the trustedForwarder must be previously added
|
||||
/// to a seller whitelist.
|
||||
/// @notice This method can be performed either by:
|
||||
/// - An user allowed via the seller's allowlist;
|
||||
/// - An user with enough userRecord to lock the wished amount;
|
||||
/// @dev There can only exist a lock per each `_amount` partitioned
|
||||
/// @notice There can only exist a lock per each `amount` partitioned
|
||||
/// from the total `remaining` value.
|
||||
/// @dev Locks can only be performed in valid orders.
|
||||
/// @param _buyerAddress The address of the buyer of a `_depositID`.
|
||||
/// @param _relayerTarget Target address entitled to the `relayerPremium`.
|
||||
/// @param _relayerPremium The refund/premium owed to a relayer.
|
||||
/// @param _amount The deposit's remaining amount wished to be locked.
|
||||
/// @param merkleProof This value should be:
|
||||
/// - Provided as a pass if the `msg.sender` is in the seller's allowlist;
|
||||
/// - Left empty otherwise;
|
||||
/// @param expiredLocks An array of `bytes32` identifiers to be
|
||||
/// @notice Locks can only be performed in valid orders.
|
||||
/// @param amount The deposit's remaining amount wished to be locked.
|
||||
/// @param merkleProof Provided as a pass if the `msg.sender` is in the
|
||||
/// seller's allowlist; Left empty otherwise;
|
||||
/// @param expiredLocks An array of identifiers to be
|
||||
/// provided so to unexpire locks using this transaction gas push.
|
||||
/// @return lockID The `bytes32` value returned as the lock identifier.
|
||||
/// @dev Function sighash: 0x03aaf306.
|
||||
/// @return lockID The lock identifier.
|
||||
/// @dev Function sighash: 0xdc43221c
|
||||
function lock(
|
||||
uint256 _depositID,
|
||||
address _buyerAddress,
|
||||
address _relayerTarget,
|
||||
uint256 _relayerPremium,
|
||||
uint256 _amount,
|
||||
address seller,
|
||||
ERC20 token,
|
||||
uint80 amount,
|
||||
bytes32[] calldata merkleProof,
|
||||
bytes32[] calldata expiredLocks
|
||||
) public nonReentrant returns (bytes32 lockID) {
|
||||
uint256[] calldata expiredLocks
|
||||
) public nonReentrant returns (uint256 lockID) {
|
||||
unlockExpired(expiredLocks);
|
||||
DT.Deposit storage d = mapDeposits[_depositID];
|
||||
|
||||
if (!d.valid) revert InvalidDeposit();
|
||||
if (d.remaining < _amount) revert NotEnoughTokens();
|
||||
if (!getValid(seller, token)) revert InvalidDeposit();
|
||||
|
||||
(lockID) = _encodeLockID(
|
||||
_depositID,
|
||||
_amount,
|
||||
_buyerAddress
|
||||
uint256 bal = getBalance(seller, token);
|
||||
if (bal < amount) revert NotEnoughTokens();
|
||||
|
||||
unchecked {
|
||||
lockID = ++lockCounter;
|
||||
}
|
||||
|
||||
if (
|
||||
mapLocks[lockID].expirationBlock >= block.number
|
||||
) revert NotExpired();
|
||||
|
||||
bytes32 _pixTarget = getPixTarget(seller, token);
|
||||
|
||||
// transaction forwarding must leave `merkleProof` empty;
|
||||
// otherwise, the trustedForwarder must be previously added
|
||||
// to a seller whitelist.
|
||||
if (merkleProof.length != 0) {
|
||||
_merkleVerify( merkleProof, sellerAllowList(seller), _msgSender());
|
||||
|
||||
} else if ( amount > REPUTATION_LOWERBOUND && msg.sender == _msgSender() ) {
|
||||
|
||||
uint256 spendLimit; uint256 userCredit =
|
||||
userRecord[_castAddrToKey(_msgSender())];
|
||||
(spendLimit) = _limiter(userCredit / WAD);
|
||||
if (
|
||||
amount > (spendLimit * WAD) ||
|
||||
amount > LOCKAMOUNT_UPPERBOUND
|
||||
) revert AmountNotAllowed();
|
||||
}
|
||||
|
||||
DT.Lock memory l = DT.Lock(
|
||||
lockID,
|
||||
(block.number + defaultLockBlocks),
|
||||
_pixTarget,
|
||||
amount,
|
||||
token,
|
||||
_msgSender(),
|
||||
seller
|
||||
);
|
||||
|
||||
DT.Lock memory l = DT.Lock({
|
||||
depositID: _depositID,
|
||||
relayerPremium: _relayerPremium,
|
||||
amount: _amount,
|
||||
expirationBlock: (block.number +
|
||||
defaultLockBlocks),
|
||||
buyerAddress: _buyerAddress,
|
||||
relayerTarget: _relayerTarget,
|
||||
relayerAddress: msg.sender
|
||||
});
|
||||
|
||||
if (merkleProof.length != 0) {
|
||||
merkleVerify(
|
||||
merkleProof,
|
||||
sellerAllowList[_castAddrToKey(d.seller)],
|
||||
msg.sender
|
||||
);
|
||||
|
||||
_addLock(lockID, l, d);
|
||||
|
||||
// Halt execution and output `lockID`.
|
||||
return lockID;
|
||||
} else {
|
||||
if (l.amount <= 1e2 ether) {
|
||||
_addLock(lockID, l, d);
|
||||
// Halt execution and output `lockID`.
|
||||
return lockID;
|
||||
} 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(lockID, l, d);
|
||||
// Halt execution and output `lockID`.
|
||||
return lockID;
|
||||
}
|
||||
}
|
||||
_addLock(bal, l);
|
||||
}
|
||||
|
||||
/// @notice Lock release method that liquidate lock
|
||||
/// orders and distributes relayer fees.
|
||||
/// @dev This method can be called by any public actor
|
||||
/// @notice This method can be called by any public actor
|
||||
/// as long the signature provided is valid.
|
||||
/// @dev `relayerPremium` gets splitted equaly
|
||||
/// if `relayerTarget` addresses differ.
|
||||
/// @dev If the `msg.sender` of this method and `l.relayerAddress` are the same,
|
||||
/// @notice `relayerPremium` gets splitted equaly
|
||||
/// if relayer addresses differ.
|
||||
/// @notice 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.
|
||||
/// In case of they differing:
|
||||
/// - `lock` caller gets accrued with `l.amount` as userRecord credit;
|
||||
/// - `release` caller gets accrued with `l.relayerPremium` as userRecord credit;
|
||||
/// @param _relayerTarget Target address entitled to the `relayerPremim`.
|
||||
/// @dev Function sighash: 0x4e1389ed.
|
||||
/// @dev Function sighash: 0x11fc7f9a
|
||||
function release(
|
||||
bytes32 lockID,
|
||||
address _relayerTarget,
|
||||
uint256 lockID,
|
||||
bytes32 pixTimestamp,
|
||||
bytes32 r,
|
||||
bytes32 s,
|
||||
uint8 v
|
||||
bytes calldata signature
|
||||
) public nonReentrant {
|
||||
DT.Lock storage l = mapLocks[lockID];
|
||||
|
||||
@@ -251,90 +208,49 @@ contract P2PIX is
|
||||
if (l.expirationBlock < block.number)
|
||||
revert LockExpired();
|
||||
|
||||
DT.Deposit storage d = mapDeposits[l.depositID];
|
||||
bytes32 message = keccak256(
|
||||
abi.encodePacked(
|
||||
d.pixTarget,
|
||||
l.pixTarget,
|
||||
l.amount,
|
||||
pixTimestamp
|
||||
)
|
||||
);
|
||||
bytes32 messageDigest = keccak256(
|
||||
abi.encodePacked(
|
||||
"\x19Ethereum Signed Message:\n32",
|
||||
message
|
||||
)
|
||||
);
|
||||
|
||||
if (usedTransactions[message] == true)
|
||||
revert TxAlreadyUsed();
|
||||
_signerCheck(message, signature);
|
||||
|
||||
uint256 signer = _castAddrToKey(
|
||||
ecrecover(messageDigest, v, r, s)
|
||||
);
|
||||
ERC20 t = ERC20(l.token);
|
||||
|
||||
if (!validBacenSigners[signer])
|
||||
revert InvalidSigner();
|
||||
|
||||
ERC20 t = ERC20(d.token);
|
||||
|
||||
// We cache values before zeroing them out.
|
||||
// We cache lockAmount value before zeroing it out.
|
||||
uint256 lockAmount = l.amount;
|
||||
uint256 totalAmount = (lockAmount - l.relayerPremium);
|
||||
|
||||
l.amount = 0;
|
||||
l.expirationBlock = 0;
|
||||
usedTransactions[message] = true;
|
||||
|
||||
if (msg.sender != l.relayerAddress) {
|
||||
userRecord[_castAddrToKey(msg.sender)] += l
|
||||
.relayerPremium;
|
||||
userRecord[
|
||||
_castAddrToKey(l.relayerAddress)
|
||||
] += lockAmount;
|
||||
_setUsedTransactions(message);
|
||||
|
||||
if (_msgSender() == msg.sender) {
|
||||
if (msg.sender != l.buyerAddress) {
|
||||
userRecord[_castAddrToKey(msg.sender)] += (lockAmount >> 1);
|
||||
userRecord[_castAddrToKey(l.buyerAddress)] += (lockAmount >> 1);
|
||||
} else {
|
||||
userRecord[_castAddrToKey(msg.sender)] += (l
|
||||
.relayerPremium + lockAmount);
|
||||
}
|
||||
userRecord[_castAddrToKey(msg.sender)] += lockAmount;
|
||||
}}
|
||||
|
||||
SafeTransferLib.safeTransfer(
|
||||
t,
|
||||
l.buyerAddress,
|
||||
totalAmount
|
||||
lockAmount
|
||||
);
|
||||
|
||||
// Method doesn't check for zero address.
|
||||
if (l.relayerPremium != 0) {
|
||||
if (_relayerTarget != l.relayerTarget) {
|
||||
SafeTransferLib.safeTransfer(
|
||||
t,
|
||||
l.relayerTarget,
|
||||
(l.relayerPremium >> 1)
|
||||
);
|
||||
SafeTransferLib.safeTransfer(
|
||||
t,
|
||||
_relayerTarget,
|
||||
(l.relayerPremium >> 1)
|
||||
);
|
||||
} else {
|
||||
SafeTransferLib.safeTransfer(
|
||||
t,
|
||||
_relayerTarget,
|
||||
l.relayerPremium
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
emit LockReleased(l.buyerAddress, lockID, lockAmount);
|
||||
}
|
||||
|
||||
/// @notice Unlocks expired locks.
|
||||
/// @dev Triggered in the callgraph by both `lock` and `withdraw` functions.
|
||||
/// @dev This method can also have any public actor as its `tx.origin`.
|
||||
/// @dev For each successfull unexpired lock recovered,
|
||||
/// @notice Triggered in the callgraph by both `lock` and `withdraw` functions.
|
||||
/// @notice This method can also have any public actor as its `tx.origin`.
|
||||
/// @notice For each successfull unexpired lock recovered,
|
||||
/// `userRecord[_castAddrToKey(l.relayerAddress)]` is decreased by half of its value.
|
||||
/// @dev Function sighash: 0x8e2749d6.
|
||||
function unlockExpired(bytes32[] calldata lockIDs)
|
||||
/// @dev Function sighash: 0xb0983d39
|
||||
function unlockExpired(uint256[] calldata lockIDs)
|
||||
public
|
||||
{
|
||||
uint256 i;
|
||||
@@ -345,17 +261,24 @@ contract P2PIX is
|
||||
|
||||
_notExpired(l);
|
||||
|
||||
mapDeposits[l.depositID].remaining += l.amount;
|
||||
uint256 _sellerBalance =
|
||||
__sellerBalance(l.seller, l.token) & BITMASK_SB_ENTRY;
|
||||
|
||||
if ((_sellerBalance + l.amount) > MAXBALANCE_UPPERBOUND)
|
||||
revert MaxBalExceeded();
|
||||
|
||||
_addSellerBalance(l.seller, l.token, l.amount);
|
||||
|
||||
l.amount = 0;
|
||||
|
||||
uint256 userKey = _castAddrToKey(
|
||||
l.relayerAddress
|
||||
l.buyerAddress
|
||||
);
|
||||
uint256 _newUserRecord = (userRecord[userKey] >>
|
||||
1);
|
||||
|
||||
if (_newUserRecord <= 1e2 ether) {
|
||||
userRecord[userKey] = 1e2 ether;
|
||||
if (_newUserRecord <= REPUTATION_LOWERBOUND) {
|
||||
userRecord[userKey] = REPUTATION_LOWERBOUND;
|
||||
} else {
|
||||
userRecord[userKey] = _newUserRecord;
|
||||
}
|
||||
@@ -366,7 +289,7 @@ contract P2PIX is
|
||||
}
|
||||
}
|
||||
|
||||
assembly {
|
||||
assembly ("memory-safe") {
|
||||
if lt(i, locksSize) {
|
||||
// LoopOverflow()
|
||||
mstore(0x00, 0xdfb035c9)
|
||||
@@ -376,271 +299,257 @@ contract P2PIX is
|
||||
}
|
||||
|
||||
/// @notice Seller's expired deposit fund sweeper.
|
||||
/// @dev A seller may use this method to recover
|
||||
/// @notice A seller may use this method to recover
|
||||
/// tokens from expired deposits.
|
||||
/// @dev Function sighash: 0x36317972.
|
||||
/// @dev Function sighash: 0xfb8c5ef0
|
||||
function withdraw(
|
||||
uint256 depositID,
|
||||
bytes32[] calldata expiredLocks
|
||||
ERC20 token,
|
||||
uint256 amount,
|
||||
uint256[] calldata expiredLocks
|
||||
) public nonReentrant {
|
||||
_onlySeller(depositID);
|
||||
unlockExpired(expiredLocks);
|
||||
|
||||
DT.Deposit storage d = mapDeposits[depositID];
|
||||
if (getValid(msg.sender, token))
|
||||
setValidState(token, false);
|
||||
|
||||
if (d.valid == true) {
|
||||
cancelDeposit(depositID);
|
||||
}
|
||||
|
||||
ERC20 token = ERC20(d.token);
|
||||
|
||||
// Withdraw remaining tokens from mapDeposit[depositID]
|
||||
uint256 amount = d.remaining;
|
||||
d.remaining = 0;
|
||||
_decBal(
|
||||
(__sellerBalance(msg.sender, token) & BITMASK_SB_ENTRY),
|
||||
amount,
|
||||
token,
|
||||
msg.sender
|
||||
);
|
||||
|
||||
// safeTransfer tokens to seller
|
||||
SafeTransferLib.safeTransfer(token, d.seller, amount);
|
||||
SafeTransferLib.safeTransfer(
|
||||
token,
|
||||
msg.sender,
|
||||
amount
|
||||
);
|
||||
|
||||
emit DepositWithdrawn(msg.sender, depositID, amount);
|
||||
emit DepositWithdrawn(
|
||||
msg.sender,
|
||||
token,
|
||||
amount
|
||||
);
|
||||
}
|
||||
|
||||
function setRoot(address addr, bytes32 merkleroot)
|
||||
public
|
||||
{
|
||||
if (addr == msg.sender) {
|
||||
sellerAllowList[
|
||||
_castAddrToKey(addr)
|
||||
] = merkleroot;
|
||||
emit RootUpdated(addr, merkleroot);
|
||||
} else revert OnlySeller();
|
||||
}
|
||||
|
||||
/// ███ Owner Only █████████████████████████████████████████████████████████
|
||||
|
||||
/// @dev Contract's underlying balance withdraw method.
|
||||
/// @dev Function sighash: 0x5fd8c710.
|
||||
function withdrawBalance() external onlyOwner {
|
||||
uint256 balance = address(this).balance;
|
||||
SafeTransferLib.safeTransferETH(msg.sender, balance);
|
||||
emit FundsWithdrawn(msg.sender, balance);
|
||||
}
|
||||
|
||||
function setReputation(IReputation _reputation)
|
||||
public
|
||||
onlyOwner
|
||||
{
|
||||
assembly {
|
||||
sstore(reputation.slot, _reputation)
|
||||
}
|
||||
emit ReputationUpdated(address(_reputation));
|
||||
}
|
||||
|
||||
function setDefaultLockBlocks(uint256 _blocks)
|
||||
public
|
||||
onlyOwner
|
||||
{
|
||||
assembly {
|
||||
sstore(defaultLockBlocks.slot, _blocks)
|
||||
}
|
||||
emit LockBlocksUpdated(_blocks);
|
||||
}
|
||||
|
||||
function setValidSigners(address[] memory _validSigners)
|
||||
public
|
||||
onlyOwner
|
||||
{
|
||||
unchecked {
|
||||
uint256 i;
|
||||
uint256 len = _validSigners.length;
|
||||
for (i; i < len; ) {
|
||||
uint256 key = _castAddrToKey(
|
||||
_validSigners[i]
|
||||
);
|
||||
validBacenSigners[key] = true;
|
||||
++i;
|
||||
}
|
||||
}
|
||||
emit ValidSignersUpdated(_validSigners);
|
||||
}
|
||||
|
||||
function tokenSettings(
|
||||
address[] memory _tokens,
|
||||
bool[] memory _states
|
||||
) public onlyOwner {
|
||||
/* Yul Impl */
|
||||
assembly {
|
||||
// first 32 bytes eq to array's length
|
||||
let tLen := mload(_tokens)
|
||||
// NoTokens()
|
||||
if iszero(tLen) {
|
||||
mstore(0x00, 0xdf957883)
|
||||
assembly ("memory-safe") {
|
||||
// if (addr != msg.sender)
|
||||
if iszero(eq(addr, caller())) {
|
||||
// revert OnlySeller()
|
||||
mstore(0x00, 0x85d1f726)
|
||||
revert(0x1c, 0x04)
|
||||
}
|
||||
// LengthMismatch()
|
||||
if iszero(eq(tLen, mload(_states))) {
|
||||
mstore(0x00, 0xff633a38)
|
||||
revert(0x1c, 0x04)
|
||||
}
|
||||
let tLoc := add(_tokens, 0x20)
|
||||
let sLoc := add(_states, 0x20)
|
||||
for {
|
||||
let end := add(tLoc, mul(tLen, 0x20))
|
||||
} iszero(eq(tLoc, end)) {
|
||||
tLoc := add(tLoc, 0x20)
|
||||
sLoc := add(sLoc, 0x20)
|
||||
} {
|
||||
// cache hashmap entry in scratch space
|
||||
mstore(0x00, mload(tLoc))
|
||||
mstore(0x20, allowedERC20s.slot)
|
||||
let mapSlot := keccak256(0x00, 0x40)
|
||||
sstore(mapSlot, mload(sLoc))
|
||||
log3(
|
||||
0,
|
||||
0,
|
||||
// AllowedERC20Updated(address, bool)
|
||||
0x5d6e86e5341d57a92c49934296c51542a25015c9b1782a1c2722a940131c3d9a,
|
||||
mload(tLoc),
|
||||
mload(sLoc)
|
||||
)
|
||||
}
|
||||
// sets root to SellerAllowlist's storage slot
|
||||
mstore(0x0c, _SELLER_ALLOWLIST_SLOT_SEED)
|
||||
mstore(0x00, addr)
|
||||
sstore(keccak256(0x00, 0x20), merkleroot)
|
||||
|
||||
// emit RootUpdated(addr, merkleroot);
|
||||
log3(
|
||||
0,
|
||||
0,
|
||||
_ROOT_UPDATED_EVENT_SIGNATURE,
|
||||
addr,
|
||||
merkleroot
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
/// ███ Helper FX ██████████████████████████████████████████████████████████
|
||||
|
||||
// solhint-disable-next-line no-empty-blocks
|
||||
receive() external payable {}
|
||||
|
||||
/// @notice Access control private view method that
|
||||
/// performs auth check on an deposit's seller.
|
||||
/// @dev Function sighash: 0x4125a4d9.
|
||||
function _onlySeller(uint256 _depositID) private view {
|
||||
if (mapDeposits[_depositID].seller != msg.sender)
|
||||
revert OnlySeller();
|
||||
}
|
||||
|
||||
/// @notice Private view auxiliar logic that reverts
|
||||
/// on a not expired lock passed as argument of the function.
|
||||
/// @dev Called exclusively by the `unlockExpired` method.
|
||||
/// @dev Function sighash: 0x74e2a0bb.
|
||||
function _notExpired(DT.Lock storage _l) private view {
|
||||
if (_l.expirationBlock > block.number)
|
||||
revert NotExpired();
|
||||
if (_l.amount == 0) revert AlreadyReleased();
|
||||
}
|
||||
|
||||
/// @notice Internal view auxiliar logic that returns a new valid `_depositID`.
|
||||
/// @dev It reverts on an already valid counter (`uint256`) value.
|
||||
/// @dev Function sighash: 0xdb51d697.
|
||||
function _encodeDepositID()
|
||||
internal
|
||||
view
|
||||
returns (uint256 _depositID)
|
||||
{
|
||||
(_depositID) = depositCount.current();
|
||||
}
|
||||
|
||||
function _addLock(
|
||||
bytes32 _lockID,
|
||||
DT.Lock memory _l,
|
||||
DT.Deposit storage _d
|
||||
uint256 _bal,
|
||||
DT.Lock memory _l
|
||||
) internal {
|
||||
mapLocks[_lockID] = _l;
|
||||
_d.remaining -= _l.amount;
|
||||
mapLocks[_l.counter] = _l;
|
||||
|
||||
_decBal(_bal, _l.amount, ERC20(_l.token), _l.seller);
|
||||
|
||||
emit LockAdded(
|
||||
_l.buyerAddress,
|
||||
_lockID,
|
||||
_l.depositID,
|
||||
_l.counter,
|
||||
_l.seller,
|
||||
_l.amount
|
||||
);
|
||||
}
|
||||
|
||||
/// @notice Private view auxiliar logic that encodes/returns
|
||||
/// the `bytes32` identifier of an lock.
|
||||
/// @dev reverts on a not expired lock with the same ID passed
|
||||
/// as argument of the function.
|
||||
/// @dev Called exclusively by the `lock` method.
|
||||
/// @dev Function sighash: 0x3fc5fb52.
|
||||
function _encodeLockID(
|
||||
uint256 _depositID,
|
||||
function _decBal(
|
||||
uint256 _bal,
|
||||
uint256 _amount,
|
||||
address _buyerAddress
|
||||
) private view returns (bytes32 _lockID) {
|
||||
_lockID = keccak256(
|
||||
abi.encodePacked(
|
||||
_depositID,
|
||||
_amount,
|
||||
_buyerAddress
|
||||
)
|
||||
);
|
||||
if (mapLocks[_lockID].expirationBlock >= block.number)
|
||||
revert NotExpired();
|
||||
}
|
||||
|
||||
function merkleVerify(
|
||||
bytes32[] calldata _merkleProof,
|
||||
bytes32 root,
|
||||
address _addr
|
||||
) private pure {
|
||||
if (
|
||||
!Merkle.verify(
|
||||
_merkleProof,
|
||||
root,
|
||||
bytes32(uint256(uint160(_addr)))
|
||||
)
|
||||
) revert AddressDenied();
|
||||
}
|
||||
|
||||
function _limiter(uint256 _userCredit)
|
||||
internal
|
||||
view
|
||||
returns (uint256 _spendLimit)
|
||||
{
|
||||
// enconde the fx sighash and args
|
||||
bytes memory encodedParams = abi.encodeWithSelector(
|
||||
IReputation.limiter.selector,
|
||||
_userCredit
|
||||
);
|
||||
// cast the uninitialized return values to memory
|
||||
bool success;
|
||||
uint256 returnSize;
|
||||
uint256 returnValue;
|
||||
// perform staticcall from the stack w yul
|
||||
assembly {
|
||||
success := staticcall(
|
||||
// gas
|
||||
0x7530,
|
||||
// address
|
||||
sload(reputation.slot),
|
||||
// argsOffset
|
||||
add(encodedParams, 0x20),
|
||||
// argsSize
|
||||
mload(encodedParams),
|
||||
// retOffset
|
||||
0x00,
|
||||
// retSize
|
||||
0x20
|
||||
)
|
||||
returnSize := returndatasize()
|
||||
returnValue := mload(0x00)
|
||||
_spendLimit := returnValue
|
||||
// reverts if call does not succeed.
|
||||
if iszero(success) {
|
||||
mstore(0x00, 0xe10bf1cc)
|
||||
ERC20 _t,
|
||||
address _k
|
||||
) private {
|
||||
assembly ("memory-safe") {
|
||||
if iszero(
|
||||
iszero(
|
||||
or(
|
||||
iszero(_bal),
|
||||
gt(sub(_bal, _amount), _bal)
|
||||
)
|
||||
)
|
||||
) {
|
||||
// DecOverflow()
|
||||
mstore(0x00, 0xce3a3d37)
|
||||
revert(0x1c, 0x04)
|
||||
}
|
||||
}
|
||||
|
||||
// we can directly dec from packed uint entry value
|
||||
_decSellerBalance(_k,_t, _amount);
|
||||
}
|
||||
|
||||
function getBalance(address seller, ERC20 token)
|
||||
public
|
||||
view
|
||||
returns (uint256 bal)
|
||||
{
|
||||
assembly ("memory-safe") {
|
||||
for {
|
||||
/* */
|
||||
} iszero(returndatasize()) {
|
||||
/* */
|
||||
} {
|
||||
mstore(0x20, token)
|
||||
mstore(0x0c, _SELLER_BALANCE_SLOT_SEED)
|
||||
mstore(0x00, seller)
|
||||
bal := and(
|
||||
BITMASK_SB_ENTRY,
|
||||
sload(add(keccak256(0x0c, 0x34), 0x01))
|
||||
)
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// @notice Public method that handles `address`
|
||||
/// to `uint256` safe type casting.
|
||||
/// @dev Function sighash: 0x4b2ae980.
|
||||
function _castAddrToKey(address _addr)
|
||||
function getValid(address seller, ERC20 token)
|
||||
public
|
||||
pure
|
||||
returns (uint256 _key)
|
||||
view
|
||||
returns (bool valid)
|
||||
{
|
||||
_key = uint256(uint160(address(_addr))) << 12;
|
||||
assembly ("memory-safe") {
|
||||
for {
|
||||
/* */
|
||||
} iszero(returndatasize()) {
|
||||
/* */
|
||||
} {
|
||||
mstore(0x20, token)
|
||||
mstore(0x0c, _SELLER_BALANCE_SLOT_SEED)
|
||||
mstore(0x00, seller)
|
||||
valid := and(
|
||||
BITMASK_SB_ENTRY,
|
||||
shr(
|
||||
BITPOS_VALID,
|
||||
sload(add(keccak256(0x0c, 0x34), 0x01))
|
||||
)
|
||||
)
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function getPixTarget(address seller, ERC20 token)
|
||||
public
|
||||
view
|
||||
returns (bytes32 pixTarget)
|
||||
{
|
||||
assembly ("memory-safe") {
|
||||
for {
|
||||
/* */
|
||||
} iszero(returndatasize()) {
|
||||
/* */
|
||||
} {
|
||||
mstore(0x20, token)
|
||||
mstore(0x0c, _SELLER_BALANCE_SLOT_SEED)
|
||||
mstore(0x00, seller)
|
||||
pixTarget := sload(keccak256(0x0c, 0x34))
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function getPixTargetString(address seller, ERC20 token) public view returns (string memory pixTarget) {
|
||||
bytes32 _pixEnc = getPixTarget(seller, token);
|
||||
pixTarget = string(abi.encodePacked(_pixEnc));
|
||||
}
|
||||
|
||||
function getBalances(
|
||||
address[] memory sellers,
|
||||
ERC20 token
|
||||
) external view returns (uint256[] memory) {
|
||||
uint256 j;
|
||||
uint256 len = sellers.length;
|
||||
uint256[] memory balances = new uint256[](len);
|
||||
while (j < len) {
|
||||
uint256 bal = getBalance(sellers[j], token);
|
||||
balances[j] = bal;
|
||||
unchecked {
|
||||
++j;
|
||||
}
|
||||
}
|
||||
|
||||
return balances;
|
||||
}
|
||||
|
||||
/// @notice External getter that returns the status of a lockIDs array.
|
||||
/// @notice Call will not revert if provided with an empty array as parameter.
|
||||
/// @dev Function sighash: 0x49ef8448
|
||||
function getLocksStatus(uint256[] memory ids)
|
||||
external
|
||||
view
|
||||
returns (uint256[] memory, DT.LockStatus[] memory)
|
||||
{
|
||||
if (ids.length == 0) {
|
||||
uint256[] memory null1 = new uint256[](0);
|
||||
DT.LockStatus[]
|
||||
memory null2 = new DT.LockStatus[](0);
|
||||
return (null1, null2);
|
||||
}
|
||||
|
||||
uint256 c;
|
||||
uint256 len = ids.length;
|
||||
|
||||
uint256[] memory sortedIDs = new uint256[](len);
|
||||
DT.LockStatus[] memory status = new DT.LockStatus[](
|
||||
len
|
||||
);
|
||||
unchecked {
|
||||
for (c; c < len; ) {
|
||||
if (mapLocks[ids[c]].seller == address(0)) {
|
||||
sortedIDs[c] = ids[c];
|
||||
status[c] = type(DT.LockStatus).min;
|
||||
++c;
|
||||
} else if (mapLocks[ids[c]].amount == 0x0) {
|
||||
sortedIDs[c] = ids[c];
|
||||
status[c] = type(DT.LockStatus).max;
|
||||
++c;
|
||||
} else if (
|
||||
mapLocks[ids[c]].expirationBlock <
|
||||
block.number
|
||||
) {
|
||||
sortedIDs[c] = ids[c];
|
||||
status[c] = DT.LockStatus.Expired;
|
||||
++c;
|
||||
} else {
|
||||
sortedIDs[c] = ids[c];
|
||||
status[c] = DT.LockStatus.Active;
|
||||
++c;
|
||||
}
|
||||
}
|
||||
}
|
||||
return (sortedIDs, status);
|
||||
}
|
||||
}
|
||||
|
||||
4
deploys/deploy.d.ts
vendored
Normal file
4
deploys/deploy.d.ts
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
declare module '*.json' {
|
||||
const value: any
|
||||
export default value
|
||||
}
|
||||
@@ -3,6 +3,6 @@
|
||||
"0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266",
|
||||
"0x70997970C51812dc3A010C7d01b50e0d17dc79C8"
|
||||
],
|
||||
"p2pix": "0x5f3EFA9A90532914545CEf527C530658af87e196",
|
||||
"token": "0x294003F602c321627152c6b7DED3EAb5bEa853Ee"
|
||||
"p2pix": "0x2414817FF64A114d91eCFA16a834d3fCf69103d4",
|
||||
"token": "0x4A2886EAEc931e04297ed336Cc55c4eb7C75BA00"
|
||||
}
|
||||
@@ -3,6 +3,6 @@
|
||||
"0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266",
|
||||
"0x70997970C51812dc3A010C7d01b50e0d17dc79C8"
|
||||
],
|
||||
"p2pix": "0x37c856F4d5bC2597da60f607b1335738468453F3",
|
||||
"token": "0x294003F602c321627152c6b7DED3EAb5bEa853Ee"
|
||||
"p2pix": "0xC86042E9F2977C62Da8c9dDF7F9c40fde4796A29",
|
||||
"token": "0xD38D6367f452D097ccBfDe4490b7de570B6A72Db"
|
||||
}
|
||||
|
||||
@@ -3,6 +3,6 @@
|
||||
"0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266",
|
||||
"0x70997970C51812dc3A010C7d01b50e0d17dc79C8"
|
||||
],
|
||||
"p2pix": "0x5f3EFA9A90532914545CEf527C530658af87e196",
|
||||
"token": "0x294003F602c321627152c6b7DED3EAb5bEa853Ee"
|
||||
"p2pix": "0x4A2886EAEc931e04297ed336Cc55c4eb7C75BA00",
|
||||
"token": "0xC86042E9F2977C62Da8c9dDF7F9c40fde4796A29"
|
||||
}
|
||||
9
deploys/rsktestnet.json
Normal file
9
deploys/rsktestnet.json
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"signers": [
|
||||
"0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266",
|
||||
"0x70997970C51812dc3A010C7d01b50e0d17dc79C8",
|
||||
"0x8963E134E6d22Ee9A26ac62a99964aB391ead816"
|
||||
],
|
||||
"token": "0xfE841c74250e57640390f46d914C88d22C51e82e",
|
||||
"p2pix": "0x57Dcba05980761169508886eEdc6f5E7EC0411Dc"
|
||||
}
|
||||
8
deploys/sepolia.json
Normal file
8
deploys/sepolia.json
Normal file
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"signers": [
|
||||
"0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266",
|
||||
"0x70997970C51812dc3A010C7d01b50e0d17dc79C8"
|
||||
],
|
||||
"p2pix": "0xb7cD135F5eFD9760981e02E2a898790b688939fe",
|
||||
"token": "0x3eBE67A2C7bdB2081CBd34ba3281E90377462289"
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
# DataTypes
|
||||
@@ -1,264 +0,0 @@
|
||||
# EventAndErrors
|
||||
|
||||
## Events
|
||||
|
||||
### AllowedERC20Updated
|
||||
|
||||
```solidity
|
||||
event AllowedERC20Updated(address indexed token, bool indexed state)
|
||||
```
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| --------------- | ------- | ----------- |
|
||||
| token `indexed` | address | undefined |
|
||||
| state `indexed` | bool | undefined |
|
||||
|
||||
### DepositAdded
|
||||
|
||||
```solidity
|
||||
event DepositAdded(address indexed seller, uint256 depositID, address token, uint256 amount)
|
||||
```
|
||||
|
||||
███ Events ████████████████████████████████████████████████████████████
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| ---------------- | ------- | ----------- |
|
||||
| seller `indexed` | address | undefined |
|
||||
| depositID | uint256 | undefined |
|
||||
| token | address | undefined |
|
||||
| amount | uint256 | undefined |
|
||||
|
||||
### DepositClosed
|
||||
|
||||
```solidity
|
||||
event DepositClosed(address indexed seller, uint256 depositID)
|
||||
```
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| ---------------- | ------- | ----------- |
|
||||
| seller `indexed` | address | undefined |
|
||||
| depositID | uint256 | undefined |
|
||||
|
||||
### DepositWithdrawn
|
||||
|
||||
```solidity
|
||||
event DepositWithdrawn(address indexed seller, uint256 depositID, uint256 amount)
|
||||
```
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| ---------------- | ------- | ----------- |
|
||||
| seller `indexed` | address | undefined |
|
||||
| depositID | uint256 | undefined |
|
||||
| amount | uint256 | undefined |
|
||||
|
||||
### FundsWithdrawn
|
||||
|
||||
```solidity
|
||||
event FundsWithdrawn(address owner, uint256 amount)
|
||||
```
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| ------ | ------- | ----------- |
|
||||
| owner | address | undefined |
|
||||
| amount | uint256 | undefined |
|
||||
|
||||
### LockAdded
|
||||
|
||||
```solidity
|
||||
event LockAdded(address indexed buyer, bytes32 indexed lockID, uint256 depositID, uint256 amount)
|
||||
```
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| ---------------- | ------- | ----------- |
|
||||
| buyer `indexed` | address | undefined |
|
||||
| lockID `indexed` | bytes32 | undefined |
|
||||
| depositID | uint256 | undefined |
|
||||
| amount | uint256 | undefined |
|
||||
|
||||
### LockBlocksUpdated
|
||||
|
||||
```solidity
|
||||
event LockBlocksUpdated(uint256 blocks)
|
||||
```
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| ------ | ------- | ----------- |
|
||||
| blocks | uint256 | undefined |
|
||||
|
||||
### LockReleased
|
||||
|
||||
```solidity
|
||||
event LockReleased(address indexed buyer, bytes32 lockId)
|
||||
```
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| --------------- | ------- | ----------- |
|
||||
| buyer `indexed` | address | undefined |
|
||||
| lockId | bytes32 | undefined |
|
||||
|
||||
### LockReturned
|
||||
|
||||
```solidity
|
||||
event LockReturned(address indexed buyer, bytes32 lockId)
|
||||
```
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| --------------- | ------- | ----------- |
|
||||
| buyer `indexed` | address | undefined |
|
||||
| lockId | bytes32 | undefined |
|
||||
|
||||
### ReputationUpdated
|
||||
|
||||
```solidity
|
||||
event ReputationUpdated(address reputation)
|
||||
```
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| ---------- | ------- | ----------- |
|
||||
| reputation | address | undefined |
|
||||
|
||||
### ValidSignersUpdated
|
||||
|
||||
```solidity
|
||||
event ValidSignersUpdated(address[] signers)
|
||||
```
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| ------- | --------- | ----------- |
|
||||
| signers | address[] | undefined |
|
||||
|
||||
## Errors
|
||||
|
||||
### AddressDenied
|
||||
|
||||
```solidity
|
||||
error AddressDenied()
|
||||
```
|
||||
|
||||
_Address doesn't exist in a MerkleTree.Address not allowed as relayer.0x3b8474be_
|
||||
|
||||
### AlreadyReleased
|
||||
|
||||
```solidity
|
||||
error AlreadyReleased()
|
||||
```
|
||||
|
||||
_Lock already released or returned.0x63b4904e_
|
||||
|
||||
### AmountNotAllowed
|
||||
|
||||
```solidity
|
||||
error AmountNotAllowed()
|
||||
```
|
||||
|
||||
_Wished amount to be locked exceeds the limit allowed.0x1c18f846_
|
||||
|
||||
### DepositAlreadyExists
|
||||
|
||||
```solidity
|
||||
error DepositAlreadyExists()
|
||||
```
|
||||
|
||||
_Deposit already exist and it is still valid.0xc44bd765_
|
||||
|
||||
### InvalidDeposit
|
||||
|
||||
```solidity
|
||||
error InvalidDeposit()
|
||||
```
|
||||
|
||||
_Deposit not valid anymore.0xb2e532de_
|
||||
|
||||
### InvalidSigner
|
||||
|
||||
```solidity
|
||||
error InvalidSigner()
|
||||
```
|
||||
|
||||
_Signer is not a valid signer.0x815e1d64_
|
||||
|
||||
### LengthMismatch
|
||||
|
||||
```solidity
|
||||
error LengthMismatch()
|
||||
```
|
||||
|
||||
_Arrays' length don't match.0xff633a38_
|
||||
|
||||
### LoopOverflow
|
||||
|
||||
```solidity
|
||||
error LoopOverflow()
|
||||
```
|
||||
|
||||
_Loop bounds have overflowed.0xdfb035c9_
|
||||
|
||||
### NoTokens
|
||||
|
||||
```solidity
|
||||
error NoTokens()
|
||||
```
|
||||
|
||||
_No tokens array provided as argument.0xdf957883_
|
||||
|
||||
### NotEnoughTokens
|
||||
|
||||
```solidity
|
||||
error NotEnoughTokens()
|
||||
```
|
||||
|
||||
_Not enough token remaining on deposit.0x22bbb43c_
|
||||
|
||||
### NotExpired
|
||||
|
||||
```solidity
|
||||
error NotExpired()
|
||||
```
|
||||
|
||||
_Lock not expired or already released.Another lock with same ID is not expired yet.0xd0404f85_
|
||||
|
||||
### OnlySeller
|
||||
|
||||
```solidity
|
||||
error OnlySeller()
|
||||
```
|
||||
|
||||
_Only seller could call this function.`msg.sender` and the seller differ.0x85d1f726_
|
||||
|
||||
### TokenDenied
|
||||
|
||||
```solidity
|
||||
error TokenDenied()
|
||||
```
|
||||
|
||||
_Token address not allowed to be deposited.0x1578328e_
|
||||
|
||||
### TxAlreadyUsed
|
||||
|
||||
```solidity
|
||||
error TxAlreadyUsed()
|
||||
```
|
||||
|
||||
_Transaction already used to unlock payment.0xf490a6ea_
|
||||
694
docs/P2PIX.md
694
docs/P2PIX.md
@@ -1,694 +0,0 @@
|
||||
# P2PIX
|
||||
|
||||
## Methods
|
||||
|
||||
### \_castAddrToKey
|
||||
|
||||
```solidity
|
||||
function _castAddrToKey(address _addr) external pure returns (uint256 _key)
|
||||
```
|
||||
|
||||
Public method that handles `address` to `uint256` safe type casting.
|
||||
|
||||
_Function sighash: 0x4b2ae980._
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| ------ | ------- | ----------- |
|
||||
| \_addr | address | undefined |
|
||||
|
||||
#### Returns
|
||||
|
||||
| Name | Type | Description |
|
||||
| ----- | ------- | ----------- |
|
||||
| \_key | uint256 | undefined |
|
||||
|
||||
### allowedERC20s
|
||||
|
||||
```solidity
|
||||
function allowedERC20s(contract ERC20) external view returns (bool)
|
||||
```
|
||||
|
||||
_Tokens allowed to serve as the underlying amount of a deposit._
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| ---- | -------------- | ----------- |
|
||||
| \_0 | contract ERC20 | undefined |
|
||||
|
||||
#### Returns
|
||||
|
||||
| Name | Type | Description |
|
||||
| ---- | ---- | ----------- |
|
||||
| \_0 | bool | undefined |
|
||||
|
||||
### cancelDeposit
|
||||
|
||||
```solidity
|
||||
function cancelDeposit(uint256 depositID) external nonpayable
|
||||
```
|
||||
|
||||
Enables seller to invalidate future locks made to his/her token offering order.
|
||||
|
||||
_This function does not affect any ongoing active locks.Function sighash: 0x72fada5c._
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| --------- | ------- | ----------- |
|
||||
| depositID | uint256 | undefined |
|
||||
|
||||
### defaultLockBlocks
|
||||
|
||||
```solidity
|
||||
function defaultLockBlocks() external view returns (uint256)
|
||||
```
|
||||
|
||||
_Default blocks that lock will hold tokens._
|
||||
|
||||
#### Returns
|
||||
|
||||
| Name | Type | Description |
|
||||
| ---- | ------- | ----------- |
|
||||
| \_0 | uint256 | undefined |
|
||||
|
||||
### deposit
|
||||
|
||||
```solidity
|
||||
function deposit(address _token, uint256 _amount, string _pixTarget, bytes32 allowlistRoot) external nonpayable returns (uint256 depositID)
|
||||
```
|
||||
|
||||
Creates a deposit order based on a seller's offer of an amount of ERC20 tokens.
|
||||
|
||||
_Seller needs to send his tokens to the P2PIX smart contract.Function sighash: 0xbfe07da6._
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| ------------- | ------- | ------------------------------------------------------- |
|
||||
| \_token | address | undefined |
|
||||
| \_amount | uint256 | undefined |
|
||||
| \_pixTarget | string | Pix key destination provided by the offer's seller. |
|
||||
| allowlistRoot | bytes32 | Optional allow list merkleRoot update `bytes32` value. |
|
||||
|
||||
#### Returns
|
||||
|
||||
| Name | Type | Description |
|
||||
| --------- | ------- | -------------------------------------------------------------- |
|
||||
| depositID | uint256 | The `uint256` return value provided as the deposit identifier. |
|
||||
|
||||
### depositCount
|
||||
|
||||
```solidity
|
||||
function depositCount() external view returns (uint256 _val)
|
||||
```
|
||||
|
||||
#### Returns
|
||||
|
||||
| Name | Type | Description |
|
||||
| ----- | ------- | ----------- |
|
||||
| \_val | uint256 | undefined |
|
||||
|
||||
### lock
|
||||
|
||||
```solidity
|
||||
function lock(uint256 _depositID, address _buyerAddress, address _relayerTarget, uint256 _relayerPremium, uint256 _amount, bytes32[] merkleProof, bytes32[] expiredLocks) external nonpayable returns (bytes32 lockID)
|
||||
```
|
||||
|
||||
Public method designed to lock an remaining amount of the deposit order of a seller.
|
||||
|
||||
_This method can be performed either by: - An user allowed via the seller's allowlist; - An user with enough userRecord to lock the wished amount; There can only exist a lock per each `_amount` partitioned from the total `remaining` value.Locks can only be performed in valid orders.Function sighash: 0x03aaf306._
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| ---------------- | --------- | ------------------------------------------------------------------------------------------------------------------------ |
|
||||
| \_depositID | uint256 | undefined |
|
||||
| \_buyerAddress | address | The address of the buyer of a `_depositID`. |
|
||||
| \_relayerTarget | address | Target address entitled to the `relayerPremim`. |
|
||||
| \_relayerPremium | uint256 | The refund/premium owed to a relayer. |
|
||||
| \_amount | uint256 | The deposit's remaining amount wished to be locked. |
|
||||
| merkleProof | bytes32[] | This value should be: - Provided as a pass if the `msg.sender` is in the seller's allowlist; - Left empty otherwise; |
|
||||
| expiredLocks | bytes32[] | An array of `bytes32` identifiers to be provided so to unexpire locks using this transaction gas push. |
|
||||
|
||||
#### Returns
|
||||
|
||||
| Name | Type | Description |
|
||||
| ------ | ------- | ---------------------------------------------------- |
|
||||
| lockID | bytes32 | The `bytes32` value returned as the lock identifier. |
|
||||
|
||||
### mapDeposits
|
||||
|
||||
```solidity
|
||||
function mapDeposits(uint256) external view returns (uint256 remaining, string pixTarget, address seller, address token, bool valid)
|
||||
```
|
||||
|
||||
_Seller list of deposits_
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| ---- | ------- | ----------- |
|
||||
| \_0 | uint256 | undefined |
|
||||
|
||||
#### Returns
|
||||
|
||||
| Name | Type | Description |
|
||||
| --------- | ------- | ----------- |
|
||||
| remaining | uint256 | undefined |
|
||||
| pixTarget | string | undefined |
|
||||
| seller | address | undefined |
|
||||
| token | address | undefined |
|
||||
| valid | bool | undefined |
|
||||
|
||||
### mapLocks
|
||||
|
||||
```solidity
|
||||
function mapLocks(bytes32) external view returns (uint256 depositID, uint256 relayerPremium, uint256 amount, uint256 expirationBlock, address buyerAddress, address relayerTarget, address relayerAddress)
|
||||
```
|
||||
|
||||
_List of Locks._
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| ---- | ------- | ----------- |
|
||||
| \_0 | bytes32 | undefined |
|
||||
|
||||
#### Returns
|
||||
|
||||
| Name | Type | Description |
|
||||
| --------------- | ------- | ----------- |
|
||||
| depositID | uint256 | undefined |
|
||||
| relayerPremium | uint256 | undefined |
|
||||
| amount | uint256 | undefined |
|
||||
| expirationBlock | uint256 | undefined |
|
||||
| buyerAddress | address | undefined |
|
||||
| relayerTarget | address | undefined |
|
||||
| relayerAddress | address | undefined |
|
||||
|
||||
### owner
|
||||
|
||||
```solidity
|
||||
function owner() external view returns (address)
|
||||
```
|
||||
|
||||
#### Returns
|
||||
|
||||
| Name | Type | Description |
|
||||
| ---- | ------- | ----------- |
|
||||
| \_0 | address | undefined |
|
||||
|
||||
### release
|
||||
|
||||
```solidity
|
||||
function release(bytes32 lockID, address _relayerTarget, uint256 pixTimestamp, bytes32 r, bytes32 s, uint8 v) external nonpayable
|
||||
```
|
||||
|
||||
Lock release method that liquidate lock orders and distributes relayer fees.
|
||||
|
||||
_This method can be called by any public actor as long the signature provided is valid.`relayerPremium` gets splitted equaly if `relayerTarget` addresses differ.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. In case of they differing: - `lock` caller gets accrued with `l.amount` as userRecord credit; - `release` caller gets accrued with `l.relayerPremium` as userRecord credit; Function sighash: 0x4e1389ed._
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| --------------- | ------- | ----------------------------------------------- |
|
||||
| lockID | bytes32 | undefined |
|
||||
| \_relayerTarget | address | Target address entitled to the `relayerPremim`. |
|
||||
| pixTimestamp | uint256 | undefined |
|
||||
| r | bytes32 | undefined |
|
||||
| s | bytes32 | undefined |
|
||||
| v | uint8 | undefined |
|
||||
|
||||
### reputation
|
||||
|
||||
```solidity
|
||||
function reputation() external view returns (contract IReputation)
|
||||
```
|
||||
|
||||
███ Storage ████████████████████████████████████████████████████████████
|
||||
|
||||
#### Returns
|
||||
|
||||
| Name | Type | Description |
|
||||
| ---- | -------------------- | ----------- |
|
||||
| \_0 | contract IReputation | undefined |
|
||||
|
||||
### sellerAllowList
|
||||
|
||||
```solidity
|
||||
function sellerAllowList(uint256) external view returns (bytes32)
|
||||
```
|
||||
|
||||
_Seller casted to key => Seller's allowlist merkleroot._
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| ---- | ------- | ----------- |
|
||||
| \_0 | uint256 | undefined |
|
||||
|
||||
#### Returns
|
||||
|
||||
| Name | Type | Description |
|
||||
| ---- | ------- | ----------- |
|
||||
| \_0 | bytes32 | undefined |
|
||||
|
||||
### setDefaultLockBlocks
|
||||
|
||||
```solidity
|
||||
function setDefaultLockBlocks(uint256 _blocks) external nonpayable
|
||||
```
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| -------- | ------- | ----------- |
|
||||
| \_blocks | uint256 | undefined |
|
||||
|
||||
### setOwner
|
||||
|
||||
```solidity
|
||||
function setOwner(address newOwner) external nonpayable
|
||||
```
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| -------- | ------- | ----------- |
|
||||
| newOwner | address | undefined |
|
||||
|
||||
### setReputation
|
||||
|
||||
```solidity
|
||||
function setReputation(contract IReputation _reputation) external nonpayable
|
||||
```
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| ------------ | -------------------- | ----------- |
|
||||
| \_reputation | contract IReputation | undefined |
|
||||
|
||||
### setRoot
|
||||
|
||||
```solidity
|
||||
function setRoot(address addr, bytes32 merkleroot) external nonpayable
|
||||
```
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| ---------- | ------- | ----------- |
|
||||
| addr | address | undefined |
|
||||
| merkleroot | bytes32 | undefined |
|
||||
|
||||
### setValidSigners
|
||||
|
||||
```solidity
|
||||
function setValidSigners(address[] _validSigners) external nonpayable
|
||||
```
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| -------------- | --------- | ----------- |
|
||||
| \_validSigners | address[] | undefined |
|
||||
|
||||
### tokenSettings
|
||||
|
||||
```solidity
|
||||
function tokenSettings(address[] _tokens, bool[] _states) external nonpayable
|
||||
```
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| -------- | --------- | ----------- |
|
||||
| \_tokens | address[] | undefined |
|
||||
| \_states | bool[] | undefined |
|
||||
|
||||
### unlockExpired
|
||||
|
||||
```solidity
|
||||
function unlockExpired(bytes32[] lockIDs) external nonpayable
|
||||
```
|
||||
|
||||
Unlocks expired locks.
|
||||
|
||||
_Triggered in the callgraph by both `lock` and `withdraw` functions.This method can also have any public actor as its `tx.origin`.For each successfull unexpired lock recovered, `userRecord[_castAddrToKey(l.relayerAddress)]` is decreased by half of its value.Function sighash: 0x8e2749d6._
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| ------- | --------- | ----------- |
|
||||
| lockIDs | bytes32[] | undefined |
|
||||
|
||||
### userRecord
|
||||
|
||||
```solidity
|
||||
function userRecord(uint256) external view returns (uint256)
|
||||
```
|
||||
|
||||
_Stores an relayer's last computed credit._
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| ---- | ------- | ----------- |
|
||||
| \_0 | uint256 | undefined |
|
||||
|
||||
#### Returns
|
||||
|
||||
| Name | Type | Description |
|
||||
| ---- | ------- | ----------- |
|
||||
| \_0 | uint256 | undefined |
|
||||
|
||||
### validBacenSigners
|
||||
|
||||
```solidity
|
||||
function validBacenSigners(uint256) external view returns (bool)
|
||||
```
|
||||
|
||||
_List of valid Bacen signature addresses_
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| ---- | ------- | ----------- |
|
||||
| \_0 | uint256 | undefined |
|
||||
|
||||
#### Returns
|
||||
|
||||
| Name | Type | Description |
|
||||
| ---- | ---- | ----------- |
|
||||
| \_0 | bool | undefined |
|
||||
|
||||
### withdraw
|
||||
|
||||
```solidity
|
||||
function withdraw(uint256 depositID, bytes32[] expiredLocks) external nonpayable
|
||||
```
|
||||
|
||||
Seller's expired deposit fund sweeper.
|
||||
|
||||
_A seller may use this method to recover tokens from expired deposits.Function sighash: 0x36317972._
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| ------------ | --------- | ----------- |
|
||||
| depositID | uint256 | undefined |
|
||||
| expiredLocks | bytes32[] | undefined |
|
||||
|
||||
### withdrawBalance
|
||||
|
||||
```solidity
|
||||
function withdrawBalance() external nonpayable
|
||||
```
|
||||
|
||||
_Contract's underlying balance withdraw method.Function sighash: 0x5fd8c710._
|
||||
|
||||
## Events
|
||||
|
||||
### AllowedERC20Updated
|
||||
|
||||
```solidity
|
||||
event AllowedERC20Updated(address indexed token, bool indexed state)
|
||||
```
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| --------------- | ------- | ----------- |
|
||||
| token `indexed` | address | undefined |
|
||||
| state `indexed` | bool | undefined |
|
||||
|
||||
### DepositAdded
|
||||
|
||||
```solidity
|
||||
event DepositAdded(address indexed seller, uint256 depositID, address token, uint256 amount)
|
||||
```
|
||||
|
||||
███ Events ████████████████████████████████████████████████████████████
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| ---------------- | ------- | ----------- |
|
||||
| seller `indexed` | address | undefined |
|
||||
| depositID | uint256 | undefined |
|
||||
| token | address | undefined |
|
||||
| amount | uint256 | undefined |
|
||||
|
||||
### DepositClosed
|
||||
|
||||
```solidity
|
||||
event DepositClosed(address indexed seller, uint256 depositID)
|
||||
```
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| ---------------- | ------- | ----------- |
|
||||
| seller `indexed` | address | undefined |
|
||||
| depositID | uint256 | undefined |
|
||||
|
||||
### DepositWithdrawn
|
||||
|
||||
```solidity
|
||||
event DepositWithdrawn(address indexed seller, uint256 depositID, uint256 amount)
|
||||
```
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| ---------------- | ------- | ----------- |
|
||||
| seller `indexed` | address | undefined |
|
||||
| depositID | uint256 | undefined |
|
||||
| amount | uint256 | undefined |
|
||||
|
||||
### FundsWithdrawn
|
||||
|
||||
```solidity
|
||||
event FundsWithdrawn(address owner, uint256 amount)
|
||||
```
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| ------ | ------- | ----------- |
|
||||
| owner | address | undefined |
|
||||
| amount | uint256 | undefined |
|
||||
|
||||
### LockAdded
|
||||
|
||||
```solidity
|
||||
event LockAdded(address indexed buyer, bytes32 indexed lockID, uint256 depositID, uint256 amount)
|
||||
```
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| ---------------- | ------- | ----------- |
|
||||
| buyer `indexed` | address | undefined |
|
||||
| lockID `indexed` | bytes32 | undefined |
|
||||
| depositID | uint256 | undefined |
|
||||
| amount | uint256 | undefined |
|
||||
|
||||
### LockBlocksUpdated
|
||||
|
||||
```solidity
|
||||
event LockBlocksUpdated(uint256 blocks)
|
||||
```
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| ------ | ------- | ----------- |
|
||||
| blocks | uint256 | undefined |
|
||||
|
||||
### LockReleased
|
||||
|
||||
```solidity
|
||||
event LockReleased(address indexed buyer, bytes32 lockId)
|
||||
```
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| --------------- | ------- | ----------- |
|
||||
| buyer `indexed` | address | undefined |
|
||||
| lockId | bytes32 | undefined |
|
||||
|
||||
### LockReturned
|
||||
|
||||
```solidity
|
||||
event LockReturned(address indexed buyer, bytes32 lockId)
|
||||
```
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| --------------- | ------- | ----------- |
|
||||
| buyer `indexed` | address | undefined |
|
||||
| lockId | bytes32 | undefined |
|
||||
|
||||
### OwnerUpdated
|
||||
|
||||
```solidity
|
||||
event OwnerUpdated(address indexed user, address indexed newOwner)
|
||||
```
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| ------------------ | ------- | ----------- |
|
||||
| user `indexed` | address | undefined |
|
||||
| newOwner `indexed` | address | undefined |
|
||||
|
||||
### ReputationUpdated
|
||||
|
||||
```solidity
|
||||
event ReputationUpdated(address reputation)
|
||||
```
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| ---------- | ------- | ----------- |
|
||||
| reputation | address | undefined |
|
||||
|
||||
### ValidSignersUpdated
|
||||
|
||||
```solidity
|
||||
event ValidSignersUpdated(address[] signers)
|
||||
```
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| ------- | --------- | ----------- |
|
||||
| signers | address[] | undefined |
|
||||
|
||||
## Errors
|
||||
|
||||
### AddressDenied
|
||||
|
||||
```solidity
|
||||
error AddressDenied()
|
||||
```
|
||||
|
||||
_Address doesn't exist in a MerkleTree.Address not allowed as relayer.0x3b8474be_
|
||||
|
||||
### AlreadyReleased
|
||||
|
||||
```solidity
|
||||
error AlreadyReleased()
|
||||
```
|
||||
|
||||
_Lock already released or returned.0x63b4904e_
|
||||
|
||||
### AmountNotAllowed
|
||||
|
||||
```solidity
|
||||
error AmountNotAllowed()
|
||||
```
|
||||
|
||||
_Wished amount to be locked exceeds the limit allowed.0x1c18f846_
|
||||
|
||||
### DepositAlreadyExists
|
||||
|
||||
```solidity
|
||||
error DepositAlreadyExists()
|
||||
```
|
||||
|
||||
_Deposit already exist and it is still valid.0xc44bd765_
|
||||
|
||||
### InvalidDeposit
|
||||
|
||||
```solidity
|
||||
error InvalidDeposit()
|
||||
```
|
||||
|
||||
_Deposit not valid anymore.0xb2e532de_
|
||||
|
||||
### InvalidSigner
|
||||
|
||||
```solidity
|
||||
error InvalidSigner()
|
||||
```
|
||||
|
||||
_Signer is not a valid signer.0x815e1d64_
|
||||
|
||||
### LengthMismatch
|
||||
|
||||
```solidity
|
||||
error LengthMismatch()
|
||||
```
|
||||
|
||||
_Arrays' length don't match.0xff633a38_
|
||||
|
||||
### LoopOverflow
|
||||
|
||||
```solidity
|
||||
error LoopOverflow()
|
||||
```
|
||||
|
||||
_Loop bounds have overflowed.0xdfb035c9_
|
||||
|
||||
### NoTokens
|
||||
|
||||
```solidity
|
||||
error NoTokens()
|
||||
```
|
||||
|
||||
_No tokens array provided as argument.0xdf957883_
|
||||
|
||||
### NotEnoughTokens
|
||||
|
||||
```solidity
|
||||
error NotEnoughTokens()
|
||||
```
|
||||
|
||||
_Not enough token remaining on deposit.0x22bbb43c_
|
||||
|
||||
### NotExpired
|
||||
|
||||
```solidity
|
||||
error NotExpired()
|
||||
```
|
||||
|
||||
_Lock not expired or already released.Another lock with same ID is not expired yet.0xd0404f85_
|
||||
|
||||
### OnlySeller
|
||||
|
||||
```solidity
|
||||
error OnlySeller()
|
||||
```
|
||||
|
||||
_Only seller could call this function.`msg.sender` and the seller differ.0x85d1f726_
|
||||
|
||||
### Reentrancy
|
||||
|
||||
```solidity
|
||||
error Reentrancy()
|
||||
```
|
||||
|
||||
### TokenDenied
|
||||
|
||||
```solidity
|
||||
error TokenDenied()
|
||||
```
|
||||
|
||||
_Token address not allowed to be deposited.0x1578328e_
|
||||
|
||||
### TxAlreadyUsed
|
||||
|
||||
```solidity
|
||||
error TxAlreadyUsed()
|
||||
```
|
||||
|
||||
_Transaction already used to unlock payment.0xf490a6ea_
|
||||
@@ -1,6 +1,28 @@
|
||||
# Reputation
|
||||
# Solidity API
|
||||
|
||||
## Methods
|
||||
## Reputation
|
||||
|
||||
### maxLimit
|
||||
|
||||
```solidity
|
||||
uint256 maxLimit
|
||||
```
|
||||
|
||||
_Asymptote numerator constant value for the `limiter` fx._
|
||||
|
||||
### magicValue
|
||||
|
||||
```solidity
|
||||
uint256 magicValue
|
||||
```
|
||||
|
||||
_Denominator's constant operand for the `limiter` fx._
|
||||
|
||||
### constructor
|
||||
|
||||
```solidity
|
||||
constructor() public payable
|
||||
```
|
||||
|
||||
### limiter
|
||||
|
||||
@@ -8,81 +30,12 @@
|
||||
function limiter(uint256 _userCredit) external pure returns (uint256 _spendLimit)
|
||||
```
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| ------------ | ------- | ----------- |
|
||||
| \_userCredit | uint256 | undefined |
|
||||
|
||||
#### Returns
|
||||
|
||||
| Name | Type | Description |
|
||||
| ------------ | ------- | ----------- |
|
||||
| \_spendLimit | uint256 | undefined |
|
||||
|
||||
### magicValue
|
||||
### sqrt
|
||||
|
||||
```solidity
|
||||
function magicValue() external view returns (uint256)
|
||||
function sqrt(uint256 x) internal pure returns (uint256 z)
|
||||
```
|
||||
|
||||
_Denominator's constant operand for the `limiter` fx. _
|
||||
Taken from Solmate's FixedPointMathLib.
|
||||
(https://github.com/transmissions11/solmate/blob/main/src/utils/FixedPointMathLib.sol)
|
||||
|
||||
#### Returns
|
||||
|
||||
| Name | Type | Description |
|
||||
| ---- | ------- | ----------- |
|
||||
| \_0 | uint256 | undefined |
|
||||
|
||||
### maxLimit
|
||||
|
||||
```solidity
|
||||
function maxLimit() external view returns (uint256)
|
||||
```
|
||||
|
||||
_Asymptote numerator constant value for the `limiter` fx._
|
||||
|
||||
#### Returns
|
||||
|
||||
| Name | Type | Description |
|
||||
| ---- | ------- | ----------- |
|
||||
| \_0 | uint256 | undefined |
|
||||
|
||||
### owner
|
||||
|
||||
```solidity
|
||||
function owner() external view returns (address)
|
||||
```
|
||||
|
||||
#### Returns
|
||||
|
||||
| Name | Type | Description |
|
||||
| ---- | ------- | ----------- |
|
||||
| \_0 | address | undefined |
|
||||
|
||||
### setOwner
|
||||
|
||||
```solidity
|
||||
function setOwner(address newOwner) external nonpayable
|
||||
```
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| -------- | ------- | ----------- |
|
||||
| newOwner | address | undefined |
|
||||
|
||||
## Events
|
||||
|
||||
### OwnerUpdated
|
||||
|
||||
```solidity
|
||||
event OwnerUpdated(address indexed user, address indexed newOwner)
|
||||
```
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| ------------------ | ------- | ----------- |
|
||||
| user `indexed` | address | undefined |
|
||||
| newOwner `indexed` | address | undefined |
|
||||
|
||||
1021
docs/callgraph.svg
1021
docs/callgraph.svg
File diff suppressed because it is too large
Load Diff
|
Before Width: | Height: | Size: 53 KiB After Width: | Height: | Size: 66 KiB |
89
docs/core/BaseUtils.md
Normal file
89
docs/core/BaseUtils.md
Normal file
@@ -0,0 +1,89 @@
|
||||
# Solidity API
|
||||
|
||||
## BaseUtils
|
||||
|
||||
### _setUsedTransactions
|
||||
|
||||
```solidity
|
||||
function _setUsedTransactions(bytes32 message) internal
|
||||
```
|
||||
|
||||
███ Helper FX ██████████████████████████████████████████████████████████
|
||||
|
||||
### usedTransactions
|
||||
|
||||
```solidity
|
||||
function usedTransactions(bytes32 message) public view returns (bool used)
|
||||
```
|
||||
|
||||
### _signerCheck
|
||||
|
||||
```solidity
|
||||
function _signerCheck(bytes32 _message, bytes _signature) internal view
|
||||
```
|
||||
|
||||
### _merkleVerify
|
||||
|
||||
```solidity
|
||||
function _merkleVerify(bytes32[] _merkleProof, bytes32 _root, address _addr) internal pure
|
||||
```
|
||||
|
||||
### _castBool
|
||||
|
||||
```solidity
|
||||
function _castBool(bool _valid) internal pure returns (uint256 _validCasted)
|
||||
```
|
||||
|
||||
### getStr
|
||||
|
||||
```solidity
|
||||
function getStr(string str) public pure returns (bytes32 strEnc)
|
||||
```
|
||||
|
||||
### _setSellerBalance
|
||||
|
||||
```solidity
|
||||
function _setSellerBalance(address _sellerKey, contract ERC20 _erc20, uint256 _packed, bytes32 _pixTarget) internal
|
||||
```
|
||||
|
||||
### _setValidState
|
||||
|
||||
```solidity
|
||||
function _setValidState(address _sellerKey, contract ERC20 _erc20, uint256 _packed) internal
|
||||
```
|
||||
|
||||
### _addSellerBalance
|
||||
|
||||
```solidity
|
||||
function _addSellerBalance(address _sellerKey, contract ERC20 _erc20, uint256 _amount) internal
|
||||
```
|
||||
|
||||
### _decSellerBalance
|
||||
|
||||
```solidity
|
||||
function _decSellerBalance(address _sellerKey, contract ERC20 _erc20, uint256 _amount) internal
|
||||
```
|
||||
|
||||
### __sellerBalance
|
||||
|
||||
```solidity
|
||||
function __sellerBalance(address _sellerKey, contract ERC20 _erc20) internal view returns (uint256 _packed)
|
||||
```
|
||||
|
||||
### _castAddrToKey
|
||||
|
||||
```solidity
|
||||
function _castAddrToKey(address _addr) public pure returns (uint256 _key)
|
||||
```
|
||||
|
||||
Public method that handles `address`
|
||||
to `uint256` safe type casting.
|
||||
|
||||
_Function sighash: 0x4b2ae980._
|
||||
|
||||
### _castKeyToAddr
|
||||
|
||||
```solidity
|
||||
function _castKeyToAddr(uint256 _key) public pure returns (address _addr)
|
||||
```
|
||||
|
||||
96
docs/core/Constants.md
Normal file
96
docs/core/Constants.md
Normal file
@@ -0,0 +1,96 @@
|
||||
# Solidity API
|
||||
|
||||
## Constants
|
||||
|
||||
### _ROOT_UPDATED_EVENT_SIGNATURE
|
||||
|
||||
```solidity
|
||||
uint256 _ROOT_UPDATED_EVENT_SIGNATURE
|
||||
```
|
||||
|
||||
███ Constants ██████████████████████████████████████████████████████████
|
||||
|
||||
### _ALLOWED_ERC20_UPDATED_EVENT_SIGNATURE
|
||||
|
||||
```solidity
|
||||
uint256 _ALLOWED_ERC20_UPDATED_EVENT_SIGNATURE
|
||||
```
|
||||
|
||||
### _TRUSTED_FORWARDER_UPDATED_EVENT_SIGNATURE
|
||||
|
||||
```solidity
|
||||
uint256 _TRUSTED_FORWARDER_UPDATED_EVENT_SIGNATURE
|
||||
```
|
||||
|
||||
### _SELLER_ALLOWLIST_SLOT_SEED
|
||||
|
||||
```solidity
|
||||
uint256 _SELLER_ALLOWLIST_SLOT_SEED
|
||||
```
|
||||
|
||||
_Seller casted to key => Seller's allowlist merkleroot.
|
||||
mapping(uint256 => bytes32) public sellerAllowList;_
|
||||
|
||||
### _ALLOWED_ERC20_SLOT_SEED
|
||||
|
||||
```solidity
|
||||
uint256 _ALLOWED_ERC20_SLOT_SEED
|
||||
```
|
||||
|
||||
_Tokens allowed to serve as the underlying amount of a deposit.
|
||||
mapping(ERC20 => bool) public allowedERC20s;_
|
||||
|
||||
### _SELLER_BALANCE_SLOT_SEED
|
||||
|
||||
```solidity
|
||||
uint256 _SELLER_BALANCE_SLOT_SEED
|
||||
```
|
||||
|
||||
_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))._
|
||||
|
||||
### BITMASK_SB_ENTRY
|
||||
|
||||
```solidity
|
||||
uint256 BITMASK_SB_ENTRY
|
||||
```
|
||||
|
||||
_The bitmask of `sellerBalance` entry._
|
||||
|
||||
### BITPOS_VALID
|
||||
|
||||
```solidity
|
||||
uint256 BITPOS_VALID
|
||||
```
|
||||
|
||||
_The bit position of `valid` in `sellerBalance`._
|
||||
|
||||
### WAD
|
||||
|
||||
```solidity
|
||||
uint256 WAD
|
||||
```
|
||||
|
||||
_The scalar of BRZ token._
|
||||
|
||||
### MAXBALANCE_UPPERBOUND
|
||||
|
||||
```solidity
|
||||
uint256 MAXBALANCE_UPPERBOUND
|
||||
```
|
||||
|
||||
### REPUTATION_LOWERBOUND
|
||||
|
||||
```solidity
|
||||
uint256 REPUTATION_LOWERBOUND
|
||||
```
|
||||
|
||||
### LOCKAMOUNT_UPPERBOUND
|
||||
|
||||
```solidity
|
||||
uint256 LOCKAMOUNT_UPPERBOUND
|
||||
```
|
||||
|
||||
29
docs/core/DataTypes.md
Normal file
29
docs/core/DataTypes.md
Normal file
@@ -0,0 +1,29 @@
|
||||
# Solidity API
|
||||
|
||||
## DataTypes
|
||||
|
||||
### Lock
|
||||
|
||||
```solidity
|
||||
struct Lock {
|
||||
uint256 counter;
|
||||
uint256 expirationBlock;
|
||||
bytes32 pixTarget;
|
||||
uint80 amount;
|
||||
contract ERC20 token;
|
||||
address buyerAddress;
|
||||
address seller;
|
||||
}
|
||||
```
|
||||
|
||||
### LockStatus
|
||||
|
||||
```solidity
|
||||
enum LockStatus {
|
||||
Inexistent,
|
||||
Active,
|
||||
Expired,
|
||||
Released
|
||||
}
|
||||
```
|
||||
|
||||
278
docs/core/EventAndErrors.md
Normal file
278
docs/core/EventAndErrors.md
Normal file
@@ -0,0 +1,278 @@
|
||||
# Solidity API
|
||||
|
||||
## EventAndErrors
|
||||
|
||||
### DepositAdded
|
||||
|
||||
```solidity
|
||||
event DepositAdded(address seller, contract ERC20 token, uint256 amount)
|
||||
```
|
||||
|
||||
_0x63d8d7d5e63e9840ec91a12a160d27b7cfab294f6ba070b7359692acfe6b03bf_
|
||||
|
||||
### ValidSet
|
||||
|
||||
```solidity
|
||||
event ValidSet(address seller, contract ERC20 token, bool state)
|
||||
```
|
||||
|
||||
_0xca585721b6b442dc9183932f7c84dc2880efb67c4da52cc06873e78971105d49_
|
||||
|
||||
### DepositWithdrawn
|
||||
|
||||
```solidity
|
||||
event DepositWithdrawn(address seller, contract ERC20 token, uint256 amount)
|
||||
```
|
||||
|
||||
_0x2cd6435b1b961c13f55202979edd0765a809f69a539d8a477436c94c1211e43e_
|
||||
|
||||
### LockAdded
|
||||
|
||||
```solidity
|
||||
event LockAdded(address buyer, uint256 lockID, address seller, uint256 amount)
|
||||
```
|
||||
|
||||
_0x8fb3989f70bd172a37d15b41b015e48ea09d59329638377304a4198cd0c4ea65_
|
||||
|
||||
### LockReleased
|
||||
|
||||
```solidity
|
||||
event LockReleased(address buyer, uint256 lockId, uint256 amount)
|
||||
```
|
||||
|
||||
_0x364537f14276f2a0ce9905588413f96454cbb8fb2e4f5308389307c1098bede8_
|
||||
|
||||
### LockReturned
|
||||
|
||||
```solidity
|
||||
event LockReturned(address buyer, uint256 lockId)
|
||||
```
|
||||
|
||||
_0x830501e61b8b075e170b22a430e39454bdb12ed3e9620e586430b6ac00079da5_
|
||||
|
||||
### FundsWithdrawn
|
||||
|
||||
```solidity
|
||||
event FundsWithdrawn(address owner, uint256 amount)
|
||||
```
|
||||
|
||||
_0xeaff4b37086828766ad3268786972c0cd24259d4c87a80f9d3963a3c3d999b0d_
|
||||
|
||||
### RootUpdated
|
||||
|
||||
```solidity
|
||||
event RootUpdated(address seller, bytes32 merkleRoot)
|
||||
```
|
||||
|
||||
_0x0b294da292f26e55fd442b5c0164fbb9013036ff00c5cfdde0efd01c1baaf632_
|
||||
|
||||
### AllowedERC20Updated
|
||||
|
||||
```solidity
|
||||
event AllowedERC20Updated(address token, bool state)
|
||||
```
|
||||
|
||||
_0x5d6e86e5341d57a92c49934296c51542a25015c9b1782a1c2722a940131c3d9a_
|
||||
|
||||
### TrustedForwarderUpdated
|
||||
|
||||
```solidity
|
||||
event TrustedForwarderUpdated(address forwarder, bool state)
|
||||
```
|
||||
|
||||
_0xbee55516e29d3969d3cb8eb01351eb3c52d06f9e2435bd5a8bfe3647e185df92_
|
||||
|
||||
### ReputationUpdated
|
||||
|
||||
```solidity
|
||||
event ReputationUpdated(address reputation)
|
||||
```
|
||||
|
||||
_0xe127cf589a3879da0156d4a24f43b44f65cfa3570de594806b0bfa2fcf06884f_
|
||||
|
||||
### LockBlocksUpdated
|
||||
|
||||
```solidity
|
||||
event LockBlocksUpdated(uint256 blocks)
|
||||
```
|
||||
|
||||
_0x70fa43ca70216ad905ade86b9e650a691b2ce5a01980d0a81bdd8324141b8511_
|
||||
|
||||
### ValidSignersUpdated
|
||||
|
||||
```solidity
|
||||
event ValidSignersUpdated(address[] signers)
|
||||
```
|
||||
|
||||
_0x14a422d2412784a5749d03da98921fe468c98577b767851389a9f58ea5a363d7_
|
||||
|
||||
### OnlySeller
|
||||
|
||||
```solidity
|
||||
error OnlySeller()
|
||||
```
|
||||
|
||||
_Only seller could call this function.
|
||||
`msg.sender` and the seller differ.
|
||||
0x85d1f726_
|
||||
|
||||
### NotExpired
|
||||
|
||||
```solidity
|
||||
error NotExpired()
|
||||
```
|
||||
|
||||
_Lock not expired or already released.
|
||||
Another lock with same ID is not expired yet.
|
||||
0xd0404f85_
|
||||
|
||||
### LoopOverflow
|
||||
|
||||
```solidity
|
||||
error LoopOverflow()
|
||||
```
|
||||
|
||||
_Loop bounds have overflowed.
|
||||
0xdfb035c9_
|
||||
|
||||
### InvalidDeposit
|
||||
|
||||
```solidity
|
||||
error InvalidDeposit()
|
||||
```
|
||||
|
||||
_Deposit not valid anymore.
|
||||
0xb2e532de_
|
||||
|
||||
### NotEnoughTokens
|
||||
|
||||
```solidity
|
||||
error NotEnoughTokens()
|
||||
```
|
||||
|
||||
_Not enough token remaining on deposit.
|
||||
0x22bbb43c_
|
||||
|
||||
### AlreadyReleased
|
||||
|
||||
```solidity
|
||||
error AlreadyReleased()
|
||||
```
|
||||
|
||||
_Lock already released or returned.
|
||||
0x63b4904e_
|
||||
|
||||
### TxAlreadyUsed
|
||||
|
||||
```solidity
|
||||
error TxAlreadyUsed()
|
||||
```
|
||||
|
||||
_Transaction already used to unlock payment.
|
||||
0xf490a6ea_
|
||||
|
||||
### InvalidSigner
|
||||
|
||||
```solidity
|
||||
error InvalidSigner()
|
||||
```
|
||||
|
||||
_Signer is not a valid signer.
|
||||
0x815e1d64_
|
||||
|
||||
### AddressDenied
|
||||
|
||||
```solidity
|
||||
error AddressDenied()
|
||||
```
|
||||
|
||||
_Address doesn't exist in a MerkleTree.
|
||||
Address not allowed as relayer.
|
||||
0x3b8474be_
|
||||
|
||||
### LengthMismatch
|
||||
|
||||
```solidity
|
||||
error LengthMismatch()
|
||||
```
|
||||
|
||||
_Arrays' length don't match.
|
||||
0xff633a38_
|
||||
|
||||
### NoTokens
|
||||
|
||||
```solidity
|
||||
error NoTokens()
|
||||
```
|
||||
|
||||
_No tokens array provided as argument.
|
||||
0xdf957883_
|
||||
|
||||
### TokenDenied
|
||||
|
||||
```solidity
|
||||
error TokenDenied()
|
||||
```
|
||||
|
||||
_Token address not allowed to be deposited.
|
||||
0x1578328e_
|
||||
|
||||
### AmountNotAllowed
|
||||
|
||||
```solidity
|
||||
error AmountNotAllowed()
|
||||
```
|
||||
|
||||
_Wished amount to be locked exceeds the limit allowed.
|
||||
0x1c18f846_
|
||||
|
||||
### StaticCallFailed
|
||||
|
||||
```solidity
|
||||
error StaticCallFailed()
|
||||
```
|
||||
|
||||
_Reverts when success return value returns false.
|
||||
0xe10bf1cc_
|
||||
|
||||
### LockExpired
|
||||
|
||||
```solidity
|
||||
error LockExpired()
|
||||
```
|
||||
|
||||
_Reverts on an expired lock.
|
||||
0xf6fafba0_
|
||||
|
||||
### DecOverflow
|
||||
|
||||
```solidity
|
||||
error DecOverflow()
|
||||
```
|
||||
|
||||
_0xce3a3d37_
|
||||
|
||||
### MaxBalExceeded
|
||||
|
||||
```solidity
|
||||
error MaxBalExceeded()
|
||||
```
|
||||
|
||||
_0xf3fb0eb9_
|
||||
|
||||
### EmptyPixTarget
|
||||
|
||||
```solidity
|
||||
error EmptyPixTarget()
|
||||
```
|
||||
|
||||
_0x6a3bc53e_
|
||||
|
||||
### NotInitialized
|
||||
|
||||
```solidity
|
||||
error NotInitialized()
|
||||
```
|
||||
|
||||
_0x87138d5c_
|
||||
|
||||
98
docs/core/OwnerSettings.md
Normal file
98
docs/core/OwnerSettings.md
Normal file
@@ -0,0 +1,98 @@
|
||||
# Solidity API
|
||||
|
||||
## OwnerSettings
|
||||
|
||||
### reputation
|
||||
|
||||
```solidity
|
||||
contract IReputation reputation
|
||||
```
|
||||
|
||||
_List of valid Bacen signature addresses
|
||||
mapping(uint256 => bool) public validBacenSigners;
|
||||
Value in custom storage slot given by:
|
||||
let value := sload(shl(12, address))._
|
||||
|
||||
### defaultLockBlocks
|
||||
|
||||
```solidity
|
||||
uint256 defaultLockBlocks
|
||||
```
|
||||
|
||||
_Default blocks that lock will hold tokens._
|
||||
|
||||
### constructor
|
||||
|
||||
```solidity
|
||||
constructor(uint256 defaultBlocks, address[] validSigners, address _reputation, contract ERC20[] tokens, bool[] tokenStates) internal
|
||||
```
|
||||
|
||||
███ Constructor ████████████████████████████████████████████████████████
|
||||
|
||||
### setTrustedFowarders
|
||||
|
||||
```solidity
|
||||
function setTrustedFowarders(address[] forwarders, bool[] states) external
|
||||
```
|
||||
|
||||
███ Owner Only █████████████████████████████████████████████████████████
|
||||
|
||||
### withdrawBalance
|
||||
|
||||
```solidity
|
||||
function withdrawBalance() external
|
||||
```
|
||||
|
||||
_Contract's underlying balance withdraw method.
|
||||
Function sighash: 0x5fd8c710._
|
||||
|
||||
### setReputation
|
||||
|
||||
```solidity
|
||||
function setReputation(contract IReputation _reputation) public
|
||||
```
|
||||
|
||||
### setDefaultLockBlocks
|
||||
|
||||
```solidity
|
||||
function setDefaultLockBlocks(uint256 _blocks) public
|
||||
```
|
||||
|
||||
### setValidSigners
|
||||
|
||||
```solidity
|
||||
function setValidSigners(address[] _validSigners) public
|
||||
```
|
||||
|
||||
### tokenSettings
|
||||
|
||||
```solidity
|
||||
function tokenSettings(contract ERC20[] _tokens, bool[] _states) public
|
||||
```
|
||||
|
||||
### validBacenSigners
|
||||
|
||||
```solidity
|
||||
function validBacenSigners(uint256 signer) public view returns (bool valid)
|
||||
```
|
||||
|
||||
███ View FX ████████████████████████████████████████████████████████████
|
||||
|
||||
### sellerAllowList
|
||||
|
||||
```solidity
|
||||
function sellerAllowList(address sellerKey) public view returns (bytes32 root)
|
||||
```
|
||||
|
||||
### allowedERC20s
|
||||
|
||||
```solidity
|
||||
function allowedERC20s(contract ERC20 erc20) public view returns (bool state)
|
||||
```
|
||||
|
||||
### _limiter
|
||||
|
||||
```solidity
|
||||
function _limiter(uint256 _userCredit) internal view returns (uint256 _spendLimit)
|
||||
```
|
||||
|
||||
@@ -1,46 +1,42 @@
|
||||
# Owned
|
||||
# Solidity API
|
||||
|
||||
_Solmate (https://github.com/Rari-Capital/solmate/blob/main/src/auth/Owned.sol)_
|
||||
## Owned
|
||||
|
||||
Simple single owner authorization mixin.
|
||||
|
||||
## Methods
|
||||
|
||||
### owner
|
||||
### Unauthorized
|
||||
|
||||
```solidity
|
||||
function owner() external view returns (address)
|
||||
error Unauthorized()
|
||||
```
|
||||
|
||||
#### Returns
|
||||
|
||||
| Name | Type | Description |
|
||||
| ---- | ------- | ----------- |
|
||||
| \_0 | address | undefined |
|
||||
|
||||
### setOwner
|
||||
|
||||
```solidity
|
||||
function setOwner(address newOwner) external nonpayable
|
||||
```
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| -------- | ------- | ----------- |
|
||||
| newOwner | address | undefined |
|
||||
|
||||
## Events
|
||||
|
||||
### OwnerUpdated
|
||||
|
||||
```solidity
|
||||
event OwnerUpdated(address indexed user, address indexed newOwner)
|
||||
event OwnerUpdated(address user, address newOwner)
|
||||
```
|
||||
|
||||
#### Parameters
|
||||
### owner
|
||||
|
||||
```solidity
|
||||
address owner
|
||||
```
|
||||
|
||||
### onlyOwner
|
||||
|
||||
```solidity
|
||||
modifier onlyOwner()
|
||||
```
|
||||
|
||||
### constructor
|
||||
|
||||
```solidity
|
||||
constructor(address _owner) internal
|
||||
```
|
||||
|
||||
### setOwner
|
||||
|
||||
```solidity
|
||||
function setOwner(address newOwner) public virtual
|
||||
```
|
||||
|
||||
| Name | Type | Description |
|
||||
| ------------------ | ------- | ----------- |
|
||||
| user `indexed` | address | undefined |
|
||||
| newOwner `indexed` | address | undefined |
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# IReputation
|
||||
# Solidity API
|
||||
|
||||
## Methods
|
||||
## IReputation
|
||||
|
||||
### limiter
|
||||
|
||||
@@ -8,14 +8,3 @@
|
||||
function limiter(uint256 _userCredit) external pure returns (uint256 _spendLimit)
|
||||
```
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| ------------ | ------- | ----------- |
|
||||
| \_userCredit | uint256 | undefined |
|
||||
|
||||
#### Returns
|
||||
|
||||
| Name | Type | Description |
|
||||
| ------------ | ------- | ----------- |
|
||||
| \_spendLimit | uint256 | undefined |
|
||||
|
||||
53
docs/lib/metatx/ERC2771Context.md
Normal file
53
docs/lib/metatx/ERC2771Context.md
Normal file
@@ -0,0 +1,53 @@
|
||||
# Solidity API
|
||||
|
||||
## Context
|
||||
|
||||
_Provides information about the current execution context, including the
|
||||
sender of the transaction and its data. While these are generally available
|
||||
via msg.sender and msg.data, they should not be accessed in such a direct
|
||||
manner, since when dealing with meta-transactions the account sending and
|
||||
paying for execution may not be the actual sender (as far as an application
|
||||
is concerned).
|
||||
|
||||
This contract is only required for intermediate, library-like contracts._
|
||||
|
||||
### _msgSender
|
||||
|
||||
```solidity
|
||||
function _msgSender() internal view virtual returns (address)
|
||||
```
|
||||
|
||||
### _msgData
|
||||
|
||||
```solidity
|
||||
function _msgData() internal view virtual returns (bytes)
|
||||
```
|
||||
|
||||
## ERC2771Context
|
||||
|
||||
_Context variant with ERC2771 support._
|
||||
|
||||
### trustedForwarders
|
||||
|
||||
```solidity
|
||||
mapping(address => bool) trustedForwarders
|
||||
```
|
||||
|
||||
### _msgSender
|
||||
|
||||
```solidity
|
||||
function _msgSender() internal view virtual returns (address sender)
|
||||
```
|
||||
|
||||
### isTrustedForwarder
|
||||
|
||||
```solidity
|
||||
function isTrustedForwarder(address forwarder) public view virtual returns (bool)
|
||||
```
|
||||
|
||||
### _msgData
|
||||
|
||||
```solidity
|
||||
function _msgData() internal view virtual returns (bytes)
|
||||
```
|
||||
|
||||
16
docs/lib/mock/mockToken.md
Normal file
16
docs/lib/mock/mockToken.md
Normal file
@@ -0,0 +1,16 @@
|
||||
# Solidity API
|
||||
|
||||
## MockToken
|
||||
|
||||
### constructor
|
||||
|
||||
```solidity
|
||||
constructor(uint256 supply) public
|
||||
```
|
||||
|
||||
### mint
|
||||
|
||||
```solidity
|
||||
function mint(address[] to, uint256 value) public virtual
|
||||
```
|
||||
|
||||
@@ -1,230 +1,128 @@
|
||||
# ERC20
|
||||
# Solidity API
|
||||
|
||||
_Solmate (https://github.com/Rari-Capital/solmate/blob/main/src/tokens/ERC20.sol)Modified from Uniswap (https://github.com/Uniswap/uniswap-v2-core/blob/master/contracts/UniswapV2ERC20.sol)_
|
||||
## ERC20
|
||||
|
||||
Modern and gas efficient ERC20 + EIP-2612 implementation.
|
||||
|
||||
_Do not manually set balances without updating totalSupply, as the sum of all user balances must not exceed it._
|
||||
|
||||
## Methods
|
||||
|
||||
### DOMAIN_SEPARATOR
|
||||
### Transfer
|
||||
|
||||
```solidity
|
||||
function DOMAIN_SEPARATOR() external view returns (bytes32)
|
||||
event Transfer(address from, address to, uint256 amount)
|
||||
```
|
||||
|
||||
#### Returns
|
||||
|
||||
| Name | Type | Description |
|
||||
| ---- | ------- | ----------- |
|
||||
| \_0 | bytes32 | undefined |
|
||||
|
||||
### allowance
|
||||
|
||||
```solidity
|
||||
function allowance(address, address) external view returns (uint256)
|
||||
```
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| ---- | ------- | ----------- |
|
||||
| \_0 | address | undefined |
|
||||
| \_1 | address | undefined |
|
||||
|
||||
#### Returns
|
||||
|
||||
| Name | Type | Description |
|
||||
| ---- | ------- | ----------- |
|
||||
| \_0 | uint256 | undefined |
|
||||
|
||||
### approve
|
||||
|
||||
```solidity
|
||||
function approve(address spender, uint256 amount) external nonpayable returns (bool)
|
||||
```
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| ------- | ------- | ----------- |
|
||||
| spender | address | undefined |
|
||||
| amount | uint256 | undefined |
|
||||
|
||||
#### Returns
|
||||
|
||||
| Name | Type | Description |
|
||||
| ---- | ---- | ----------- |
|
||||
| \_0 | bool | undefined |
|
||||
|
||||
### balanceOf
|
||||
|
||||
```solidity
|
||||
function balanceOf(address) external view returns (uint256)
|
||||
```
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| ---- | ------- | ----------- |
|
||||
| \_0 | address | undefined |
|
||||
|
||||
#### Returns
|
||||
|
||||
| Name | Type | Description |
|
||||
| ---- | ------- | ----------- |
|
||||
| \_0 | uint256 | undefined |
|
||||
|
||||
### decimals
|
||||
|
||||
```solidity
|
||||
function decimals() external view returns (uint8)
|
||||
```
|
||||
|
||||
#### Returns
|
||||
|
||||
| Name | Type | Description |
|
||||
| ---- | ----- | ----------- |
|
||||
| \_0 | uint8 | undefined |
|
||||
|
||||
### name
|
||||
|
||||
```solidity
|
||||
function name() external view returns (string)
|
||||
```
|
||||
|
||||
#### Returns
|
||||
|
||||
| Name | Type | Description |
|
||||
| ---- | ------ | ----------- |
|
||||
| \_0 | string | undefined |
|
||||
|
||||
### nonces
|
||||
|
||||
```solidity
|
||||
function nonces(address) external view returns (uint256)
|
||||
```
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| ---- | ------- | ----------- |
|
||||
| \_0 | address | undefined |
|
||||
|
||||
#### Returns
|
||||
|
||||
| Name | Type | Description |
|
||||
| ---- | ------- | ----------- |
|
||||
| \_0 | uint256 | undefined |
|
||||
|
||||
### permit
|
||||
|
||||
```solidity
|
||||
function permit(address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) external nonpayable
|
||||
```
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| -------- | ------- | ----------- |
|
||||
| owner | address | undefined |
|
||||
| spender | address | undefined |
|
||||
| value | uint256 | undefined |
|
||||
| deadline | uint256 | undefined |
|
||||
| v | uint8 | undefined |
|
||||
| r | bytes32 | undefined |
|
||||
| s | bytes32 | undefined |
|
||||
|
||||
### symbol
|
||||
|
||||
```solidity
|
||||
function symbol() external view returns (string)
|
||||
```
|
||||
|
||||
#### Returns
|
||||
|
||||
| Name | Type | Description |
|
||||
| ---- | ------ | ----------- |
|
||||
| \_0 | string | undefined |
|
||||
|
||||
### totalSupply
|
||||
|
||||
```solidity
|
||||
function totalSupply() external view returns (uint256)
|
||||
```
|
||||
|
||||
#### Returns
|
||||
|
||||
| Name | Type | Description |
|
||||
| ---- | ------- | ----------- |
|
||||
| \_0 | uint256 | undefined |
|
||||
|
||||
### transfer
|
||||
|
||||
```solidity
|
||||
function transfer(address to, uint256 amount) external nonpayable returns (bool)
|
||||
```
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| ------ | ------- | ----------- |
|
||||
| to | address | undefined |
|
||||
| amount | uint256 | undefined |
|
||||
|
||||
#### Returns
|
||||
|
||||
| Name | Type | Description |
|
||||
| ---- | ---- | ----------- |
|
||||
| \_0 | bool | undefined |
|
||||
|
||||
### transferFrom
|
||||
|
||||
```solidity
|
||||
function transferFrom(address from, address to, uint256 amount) external nonpayable returns (bool)
|
||||
```
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| ------ | ------- | ----------- |
|
||||
| from | address | undefined |
|
||||
| to | address | undefined |
|
||||
| amount | uint256 | undefined |
|
||||
|
||||
#### Returns
|
||||
|
||||
| Name | Type | Description |
|
||||
| ---- | ---- | ----------- |
|
||||
| \_0 | bool | undefined |
|
||||
|
||||
## Events
|
||||
|
||||
### Approval
|
||||
|
||||
```solidity
|
||||
event Approval(address indexed owner, address indexed spender, uint256 amount)
|
||||
event Approval(address owner, address spender, uint256 amount)
|
||||
```
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| ----------------- | ------- | ----------- |
|
||||
| owner `indexed` | address | undefined |
|
||||
| spender `indexed` | address | undefined |
|
||||
| amount | uint256 | undefined |
|
||||
|
||||
### Transfer
|
||||
### name
|
||||
|
||||
```solidity
|
||||
event Transfer(address indexed from, address indexed to, uint256 amount)
|
||||
string name
|
||||
```
|
||||
|
||||
#### Parameters
|
||||
### symbol
|
||||
|
||||
```solidity
|
||||
string symbol
|
||||
```
|
||||
|
||||
### decimals
|
||||
|
||||
```solidity
|
||||
uint8 decimals
|
||||
```
|
||||
|
||||
### totalSupply
|
||||
|
||||
```solidity
|
||||
uint256 totalSupply
|
||||
```
|
||||
|
||||
### balanceOf
|
||||
|
||||
```solidity
|
||||
mapping(address => uint256) balanceOf
|
||||
```
|
||||
|
||||
### allowance
|
||||
|
||||
```solidity
|
||||
mapping(address => mapping(address => uint256)) allowance
|
||||
```
|
||||
|
||||
### INITIAL_CHAIN_ID
|
||||
|
||||
```solidity
|
||||
uint256 INITIAL_CHAIN_ID
|
||||
```
|
||||
|
||||
### INITIAL_DOMAIN_SEPARATOR
|
||||
|
||||
```solidity
|
||||
bytes32 INITIAL_DOMAIN_SEPARATOR
|
||||
```
|
||||
|
||||
### nonces
|
||||
|
||||
```solidity
|
||||
mapping(address => uint256) nonces
|
||||
```
|
||||
|
||||
### constructor
|
||||
|
||||
```solidity
|
||||
constructor(string _name, string _symbol, uint8 _decimals) internal
|
||||
```
|
||||
|
||||
### approve
|
||||
|
||||
```solidity
|
||||
function approve(address spender, uint256 amount) public virtual returns (bool)
|
||||
```
|
||||
|
||||
### transfer
|
||||
|
||||
```solidity
|
||||
function transfer(address to, uint256 amount) public virtual returns (bool)
|
||||
```
|
||||
|
||||
### transferFrom
|
||||
|
||||
```solidity
|
||||
function transferFrom(address from, address to, uint256 amount) public virtual returns (bool)
|
||||
```
|
||||
|
||||
### permit
|
||||
|
||||
```solidity
|
||||
function permit(address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) public virtual
|
||||
```
|
||||
|
||||
### DOMAIN_SEPARATOR
|
||||
|
||||
```solidity
|
||||
function DOMAIN_SEPARATOR() public view virtual returns (bytes32)
|
||||
```
|
||||
|
||||
### computeDomainSeparator
|
||||
|
||||
```solidity
|
||||
function computeDomainSeparator() internal view virtual returns (bytes32)
|
||||
```
|
||||
|
||||
### _mint
|
||||
|
||||
```solidity
|
||||
function _mint(address to, uint256 amount) internal virtual
|
||||
```
|
||||
|
||||
### _burn
|
||||
|
||||
```solidity
|
||||
function _burn(address from, uint256 amount) internal virtual
|
||||
```
|
||||
|
||||
| Name | Type | Description |
|
||||
| -------------- | ------- | ----------- |
|
||||
| from `indexed` | address | undefined |
|
||||
| to `indexed` | address | undefined |
|
||||
| amount | uint256 | undefined |
|
||||
|
||||
38
docs/lib/utils/ECDSA.md
Normal file
38
docs/lib/utils/ECDSA.md
Normal file
@@ -0,0 +1,38 @@
|
||||
# Solidity API
|
||||
|
||||
## ECDSA
|
||||
|
||||
Gas optimized ECDSA wrapper.
|
||||
|
||||
### InvalidSignature
|
||||
|
||||
```solidity
|
||||
error InvalidSignature()
|
||||
```
|
||||
|
||||
_The signature is invalid._
|
||||
|
||||
### recoverCalldata
|
||||
|
||||
```solidity
|
||||
function recoverCalldata(bytes32 hash, bytes signature) internal view returns (address result)
|
||||
```
|
||||
|
||||
_Recovers the signer's address from a message digest `hash`,
|
||||
and the `signature`.
|
||||
|
||||
This function does NOT accept EIP-2098 short form signatures.
|
||||
Use `recover(bytes32 hash, bytes32 r, bytes32 vs)` for EIP-2098
|
||||
short form signatures instead._
|
||||
|
||||
### toEthSignedMessageHash
|
||||
|
||||
```solidity
|
||||
function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32 result)
|
||||
```
|
||||
|
||||
_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._
|
||||
|
||||
@@ -1,5 +1,14 @@
|
||||
# MerkleProofLib
|
||||
# Solidity API
|
||||
|
||||
_Solady (https://github.com/vectorized/solady/blob/main/src/utils/MerkleProofLib.sol)Modified from Solmate (https://github.com/transmissions11/solmate/blob/main/src/utils/MerkleProofLib.sol)Modified from OpenZeppelin (https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/cryptography/MerkleProof.sol)_
|
||||
## MerkleProofLib
|
||||
|
||||
Gas optimized verification of proof of inclusion for a leaf in a Merkle tree.
|
||||
|
||||
### verify
|
||||
|
||||
```solidity
|
||||
function verify(bytes32[] proof, bytes32 root, bytes32 leaf) internal pure returns (bool isValid)
|
||||
```
|
||||
|
||||
_Returns whether `leaf` exists in the Merkle tree with `root`, given `proof`._
|
||||
|
||||
|
||||
50
docs/lib/utils/Multicall.md
Normal file
50
docs/lib/utils/Multicall.md
Normal file
@@ -0,0 +1,50 @@
|
||||
# Solidity API
|
||||
|
||||
## Multicall
|
||||
|
||||
Contract that batches view function calls and aggregates their results.
|
||||
|
||||
### CallFailed
|
||||
|
||||
```solidity
|
||||
error CallFailed(string reason)
|
||||
```
|
||||
|
||||
_0x_
|
||||
|
||||
### Call
|
||||
|
||||
```solidity
|
||||
struct Call {
|
||||
address target;
|
||||
bytes callData;
|
||||
}
|
||||
```
|
||||
|
||||
### Result
|
||||
|
||||
```solidity
|
||||
struct Result {
|
||||
bool success;
|
||||
bytes returnData;
|
||||
}
|
||||
```
|
||||
|
||||
### constructor
|
||||
|
||||
```solidity
|
||||
constructor() public payable
|
||||
```
|
||||
|
||||
### mtc1
|
||||
|
||||
```solidity
|
||||
function mtc1(struct Multicall.Call[] calls) external returns (uint256, bytes[])
|
||||
```
|
||||
|
||||
### mtc2
|
||||
|
||||
```solidity
|
||||
function mtc2(struct Multicall.Call[] calls) external returns (uint256, bytes32, struct Multicall.Result[])
|
||||
```
|
||||
|
||||
@@ -1,13 +1,34 @@
|
||||
# ReentrancyGuard
|
||||
# Solidity API
|
||||
|
||||
_z0r0z.ethModified from Seaport (https://github.com/ProjectOpenSea/seaport/blob/main/contracts/lib/ReentrancyGuard.sol)Modified from Solmate (https://github.com/Rari-Capital/solmate/blob/main/src/utils/ReentrancyGuard.sol)_
|
||||
## ReentrancyGuard
|
||||
|
||||
Reentrancy protection for smart contracts.
|
||||
|
||||
## Errors
|
||||
|
||||
### Reentrancy
|
||||
|
||||
```solidity
|
||||
error Reentrancy()
|
||||
```
|
||||
|
||||
### nonReentrant
|
||||
|
||||
```solidity
|
||||
modifier nonReentrant()
|
||||
```
|
||||
|
||||
### setReentrancyGuard
|
||||
|
||||
```solidity
|
||||
function setReentrancyGuard() internal virtual
|
||||
```
|
||||
|
||||
_Check guard sentinel value and set it._
|
||||
|
||||
### clearReentrancyGuard
|
||||
|
||||
```solidity
|
||||
function clearReentrancyGuard() internal virtual
|
||||
```
|
||||
|
||||
_Unset sentinel value._
|
||||
|
||||
|
||||
@@ -1,7 +1,62 @@
|
||||
# SafeTransferLib
|
||||
# Solidity API
|
||||
|
||||
_Solmate (https://github.com/Rari-Capital/solmate/blob/main/src/utils/SafeTransferLib.sol)_
|
||||
## SafeTransferLib
|
||||
|
||||
Safe ETH and ERC20 transfer library that gracefully handles missing return values.
|
||||
|
||||
_Caution! This library won't check that a token has code, responsibility is delegated to the caller._
|
||||
_Caution! This library won't check that a token has code, responsibility is delegated to the caller._
|
||||
|
||||
### ETHTransferFailed
|
||||
|
||||
```solidity
|
||||
error ETHTransferFailed()
|
||||
```
|
||||
|
||||
_The ETH transfer has failed._
|
||||
|
||||
### TransferFromFailed
|
||||
|
||||
```solidity
|
||||
error TransferFromFailed()
|
||||
```
|
||||
|
||||
_The ERC20 `transferFrom` has failed._
|
||||
|
||||
### TransferFailed
|
||||
|
||||
```solidity
|
||||
error TransferFailed()
|
||||
```
|
||||
|
||||
_The ERC20 `transfer` has failed._
|
||||
|
||||
### safeTransferETH
|
||||
|
||||
```solidity
|
||||
function safeTransferETH(address to, uint256 amount) internal
|
||||
```
|
||||
|
||||
_Sends `amount` (in wei) ETH to `to`.
|
||||
Reverts upon failure._
|
||||
|
||||
### safeTransferFrom
|
||||
|
||||
```solidity
|
||||
function safeTransferFrom(contract ERC20 token, address from, address to, uint256 amount) internal
|
||||
```
|
||||
|
||||
_Sends `amount` of ERC20 `token` from `from` to `to`.
|
||||
Reverts upon failure.
|
||||
|
||||
The `from` account must have at least `amount` approved for
|
||||
the current contract to manage._
|
||||
|
||||
### safeTransfer
|
||||
|
||||
```solidity
|
||||
function safeTransfer(contract ERC20 token, address to, uint256 amount) internal
|
||||
```
|
||||
|
||||
_Sends `amount` of ERC20 `token` from the current contract to `to`.
|
||||
Reverts upon failure._
|
||||
|
||||
|
||||
207
docs/p2pix.md
Normal file
207
docs/p2pix.md
Normal file
@@ -0,0 +1,207 @@
|
||||
# Solidity API
|
||||
|
||||
## P2PIX
|
||||
|
||||
### lockCounter
|
||||
|
||||
```solidity
|
||||
uint256 lockCounter
|
||||
```
|
||||
|
||||
### mapLocks
|
||||
|
||||
```solidity
|
||||
mapping(uint256 => struct DataTypes.Lock) mapLocks
|
||||
```
|
||||
|
||||
_List of Locks._
|
||||
|
||||
### userRecord
|
||||
|
||||
```solidity
|
||||
mapping(uint256 => uint256) userRecord
|
||||
```
|
||||
|
||||
_Stores an relayer's last computed credit._
|
||||
|
||||
### constructor
|
||||
|
||||
```solidity
|
||||
constructor(uint256 defaultBlocks, address[] validSigners, address _reputation, contract ERC20[] tokens, bool[] tokenStates) public payable
|
||||
```
|
||||
|
||||
### deposit
|
||||
|
||||
```solidity
|
||||
function deposit(string pixTarget, bytes32 allowlistRoot, contract ERC20 token, uint96 amount, bool valid) public
|
||||
```
|
||||
|
||||
Creates a deposit order based on a seller's
|
||||
offer of an amount of ERC20 tokens.
|
||||
Seller needs to send his tokens to the P2PIX smart contract.
|
||||
|
||||
_Function sighash: 0x5e918943_
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| ---- | ---- | ----------- |
|
||||
| pixTarget | string | Pix key destination provided by the offer's seller. |
|
||||
| allowlistRoot | bytes32 | Optional allow list merkleRoot update `bytes32` value. as the deposit identifier. |
|
||||
| token | contract ERC20 | |
|
||||
| amount | uint96 | |
|
||||
| valid | bool | |
|
||||
|
||||
### setValidState
|
||||
|
||||
```solidity
|
||||
function setValidState(contract ERC20 token, bool state) public
|
||||
```
|
||||
|
||||
Enables seller to invalidate future
|
||||
locks made to his/her token offering order.
|
||||
This function does not affect any ongoing active locks.
|
||||
|
||||
_Function sighash: 0x6d82d9e0_
|
||||
|
||||
### lock
|
||||
|
||||
```solidity
|
||||
function lock(address seller, contract ERC20 token, uint80 amount, bytes32[] merkleProof, uint256[] expiredLocks) public returns (uint256 lockID)
|
||||
```
|
||||
|
||||
Public method designed to lock an remaining amount of
|
||||
the deposit order of a seller.
|
||||
Transaction forwarding must leave `merkleProof` empty;
|
||||
otherwise, the trustedForwarder must be previously added
|
||||
to a seller whitelist.
|
||||
This method can be performed either by:
|
||||
- An user allowed via the seller's allowlist;
|
||||
- An user with enough userRecord to lock the wished amount;
|
||||
There can only exist a lock per each `_amount` partitioned
|
||||
from the total `remaining` value.
|
||||
Locks can only be performed in valid orders.
|
||||
|
||||
_Function sighash: 0xdc43221c_
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| ---- | ---- | ----------- |
|
||||
| seller | address | |
|
||||
| token | contract ERC20 | |
|
||||
| amount | uint80 | The deposit's remaining amount wished to be locked. |
|
||||
| merkleProof | bytes32[] | Provided as a pass if the `msg.sender` is in the seller's allowlist; Left empty otherwise; |
|
||||
| expiredLocks | uint256[] | An array of identifiers to be provided so to unexpire locks using this transaction gas push. |
|
||||
|
||||
#### Return Values
|
||||
|
||||
| Name | Type | Description |
|
||||
| ---- | ---- | ----------- |
|
||||
| lockID | uint256 | The lock identifier. |
|
||||
|
||||
### release
|
||||
|
||||
```solidity
|
||||
function release(uint256 lockID, bytes32 pixTimestamp, bytes signature) public
|
||||
```
|
||||
|
||||
Lock release method that liquidate lock
|
||||
orders and distributes relayer fees.
|
||||
This method can be called by any public actor
|
||||
as long the signature provided is valid.
|
||||
`relayerPremium` gets splitted equaly
|
||||
if relayer addresses differ.
|
||||
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.
|
||||
In case of they differing:
|
||||
- `lock` caller gets accrued with `l.amount` as userRecord credit;
|
||||
- `release` caller gets accrued with `l.relayerPremium` as userRecord credit;
|
||||
|
||||
_Function sighash: 0x11fc7f9a_
|
||||
|
||||
### unlockExpired
|
||||
|
||||
```solidity
|
||||
function unlockExpired(uint256[] lockIDs) public
|
||||
```
|
||||
|
||||
Unlocks expired locks.
|
||||
Triggered in the callgraph by both `lock` and `withdraw` functions.
|
||||
This method can also have any public actor as its `tx.origin`.
|
||||
For each successfull unexpired lock recovered,
|
||||
`userRecord[_castAddrToKey(l.relayerAddress)]` is decreased by half of its value.
|
||||
|
||||
_Function sighash: 0xb0983d39_
|
||||
|
||||
### withdraw
|
||||
|
||||
```solidity
|
||||
function withdraw(contract ERC20 token, uint256 amount, uint256[] expiredLocks) public
|
||||
```
|
||||
|
||||
Seller's expired deposit fund sweeper.
|
||||
A seller may use this method to recover
|
||||
tokens from expired deposits.
|
||||
|
||||
_Function sighash: 0xfb8c5ef0_
|
||||
|
||||
### setRoot
|
||||
|
||||
```solidity
|
||||
function setRoot(address addr, bytes32 merkleroot) public
|
||||
```
|
||||
|
||||
### receive
|
||||
|
||||
```solidity
|
||||
receive() external payable
|
||||
```
|
||||
|
||||
### _addLock
|
||||
|
||||
```solidity
|
||||
function _addLock(uint256 _bal, struct DataTypes.Lock _l) internal
|
||||
```
|
||||
|
||||
### getBalance
|
||||
|
||||
```solidity
|
||||
function getBalance(address seller, contract ERC20 token) public view returns (uint256 bal)
|
||||
```
|
||||
|
||||
### getValid
|
||||
|
||||
```solidity
|
||||
function getValid(address seller, contract ERC20 token) public view returns (bool valid)
|
||||
```
|
||||
|
||||
### getPixTarget
|
||||
|
||||
```solidity
|
||||
function getPixTarget(address seller, contract ERC20 token) public view returns (bytes32 pixTarget)
|
||||
```
|
||||
|
||||
### getPixTargetString
|
||||
|
||||
```solidity
|
||||
function getPixTargetString(address seller, contract ERC20 token) public view returns (string pixTarget)
|
||||
```
|
||||
|
||||
### getBalances
|
||||
|
||||
```solidity
|
||||
function getBalances(address[] sellers, contract ERC20 token) external view returns (uint256[])
|
||||
```
|
||||
|
||||
### getLocksStatus
|
||||
|
||||
```solidity
|
||||
function getLocksStatus(uint256[] ids) external view returns (uint256[], enum DataTypes.LockStatus[])
|
||||
```
|
||||
|
||||
External getter that returns the status of a lockIDs array.
|
||||
Call will not revert if provided with an empty array as parameter.
|
||||
|
||||
_Function sighash: 0x49ef8448_
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
import "@nomicfoundation/hardhat-chai-matchers";
|
||||
import "@nomicfoundation/hardhat-toolbox";
|
||||
import { config as dotenvConfig } from "dotenv";
|
||||
import "hardhat-tracer";
|
||||
import { HardhatUserConfig } from "hardhat/config";
|
||||
import { NetworkUserConfig } from "hardhat/types";
|
||||
import "hardhat-contract-sizer";
|
||||
import { resolve } from "path";
|
||||
import "solidity-docgen";
|
||||
|
||||
dotenvConfig({ path: resolve(__dirname, "./.env") });
|
||||
|
||||
@@ -13,14 +14,6 @@ if (!mnemonic) {
|
||||
throw new Error("Please set your MNEMONIC in a .env file");
|
||||
}
|
||||
|
||||
const infuraApiKey: string | undefined =
|
||||
process.env.INFURA_API_KEY;
|
||||
if (!infuraApiKey) {
|
||||
throw new Error(
|
||||
"Please set your INFURA_API_KEY in a .env file",
|
||||
);
|
||||
}
|
||||
|
||||
const alchemyApiKey: string | undefined =
|
||||
process.env.ALCHEMY_API_KEY;
|
||||
if (!alchemyApiKey) {
|
||||
@@ -33,23 +26,16 @@ const chainIds = {
|
||||
// "{INSERT_NAME}": {INSERT_ID},
|
||||
hardhat: 31337,
|
||||
mainnet: 1,
|
||||
sepolia: 11155111,
|
||||
goerli : 5,
|
||||
"eth-sepolia": 11155111,
|
||||
"polygon-mumbai": 80001,
|
||||
rootstock:30,
|
||||
"rootstock-testnet":31,
|
||||
};
|
||||
|
||||
function getChainConfig(
|
||||
chain: keyof typeof chainIds,
|
||||
): NetworkUserConfig {
|
||||
let jsonRpcUrl: string;
|
||||
switch (chain) {
|
||||
case "polygon-mumbai":
|
||||
jsonRpcUrl = "https://polygon-mumbai.g.alchemy.com/v2/" + alchemyApiKey;
|
||||
break;
|
||||
default:
|
||||
jsonRpcUrl =
|
||||
"https://" + chain + ".infura.io/v3/" + infuraApiKey;
|
||||
}
|
||||
let jsonRpcUrl = "https://" + chain + ".g.alchemy.com/v2/" + alchemyApiKey;
|
||||
return {
|
||||
// Comment out for default hardhat account settings
|
||||
accounts: {
|
||||
@@ -72,23 +58,13 @@ const config: HardhatUserConfig = {
|
||||
goerli: process.env.ETHERSCAN_API_KEY || "",
|
||||
polygonMumbai: process.env.POLYGONSCAN_API_KEY || "",
|
||||
},
|
||||
// customChains: [
|
||||
// {
|
||||
// // network: {INSERT_NAME},
|
||||
// // chainId: {INSERT_ID},
|
||||
// // urls: {
|
||||
// // apiURL:
|
||||
// // "{INSERT_URL}",
|
||||
// // browserURL: "{INSERT_URL}",
|
||||
// // },
|
||||
// },
|
||||
// ],
|
||||
},
|
||||
gasReporter: {
|
||||
enabled: !!(
|
||||
process.env.REPORT_GAS &&
|
||||
process.env.REPORT_GAS != "false"
|
||||
),
|
||||
offline: true,
|
||||
showTimeSpent: true,
|
||||
showMethodSig: true,
|
||||
token: "ETH",
|
||||
@@ -108,9 +84,10 @@ const config: HardhatUserConfig = {
|
||||
},
|
||||
// network: getChainConfig("{INSERT_NAME}"),
|
||||
mainnet: getChainConfig("mainnet"),
|
||||
goerli: getChainConfig("goerli"),
|
||||
sepolia: getChainConfig("sepolia"),
|
||||
"polygon-mumbai": getChainConfig("polygon-mumbai"),
|
||||
sepolia: getChainConfig("eth-sepolia"),
|
||||
mumbai: getChainConfig("polygon-mumbai"),
|
||||
rootstock: getChainConfig("rootstock"),
|
||||
rsktestnet: getChainConfig("rootstock-testnet"),
|
||||
},
|
||||
paths: {
|
||||
artifacts: "./artifacts",
|
||||
@@ -119,21 +96,34 @@ const config: HardhatUserConfig = {
|
||||
tests: "./test",
|
||||
},
|
||||
solidity: {
|
||||
version: "0.8.9",
|
||||
version: "0.8.28",
|
||||
settings: {
|
||||
metadata: {
|
||||
bytecodeHash: "none",
|
||||
},
|
||||
viaIR: true,
|
||||
evmVersion: "cancun",
|
||||
optimizer: {
|
||||
enabled: true,
|
||||
runs: 2000,
|
||||
runs: 20_000,
|
||||
details: {
|
||||
deduplicate: true,
|
||||
cse: true,
|
||||
constantOptimizer: true,
|
||||
peephole: true,
|
||||
jumpdestRemover: true,
|
||||
yul: true,
|
||||
yulDetails: {
|
||||
stackAllocation: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
typechain: {
|
||||
outDir: "src/types",
|
||||
target: "ethers-v5",
|
||||
target: "ethers-v6",
|
||||
},
|
||||
docgen: {
|
||||
pages: "files",
|
||||
}
|
||||
};
|
||||
|
||||
export default config;
|
||||
|
||||
96
package.json
96
package.json
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "p2pix-smart-contracts",
|
||||
"version": "1.0.0",
|
||||
"version": "2.0.0",
|
||||
"description": "Repository for P2Pix EVM contracts to be imported by the project.",
|
||||
"homepage": "https://github.com/doiim/p2pix-smart-contracts#readme",
|
||||
"author": "Filipe Soccol (doiim)",
|
||||
@@ -9,10 +9,9 @@
|
||||
"url": "https://github.com/doiim/p2pix-smart-contracts/issues"
|
||||
},
|
||||
"scripts": {
|
||||
"clean": "shx rm -rf ./artifacts ./cache ./coverage ./src/types ./coverage.json && yarn typechain",
|
||||
"commit": "git-cz",
|
||||
"compile": "cross-env TS_NODE_TRANSPILE_ONLY=true hardhat compile",
|
||||
"typechain": "cross-env TS_NODE_TRANSPILE_ONLY=true hardhat typechain",
|
||||
"clean": "hardhat clean",
|
||||
"compile": "hardhat compile",
|
||||
"typechain": "hardhat typechain",
|
||||
"test": "hardhat test",
|
||||
"deploy1:localhost": "hardhat run scripts/1-deploy-mockToken.ts --network localhost",
|
||||
"deploy2:localhost": "hardhat run scripts/2-deploy-p2pix.ts --network localhost",
|
||||
@@ -24,69 +23,50 @@
|
||||
"lint": "yarn lint:sol && yarn lint:ts && yarn prettier:check",
|
||||
"lint:sol": "solhint --config ./.solhint.json --max-warnings 0 \"contracts/**/*.sol\"",
|
||||
"lint:ts": "eslint --config ./.eslintrc.yaml --ignore-path ./.eslintignore --ext .js,.ts .",
|
||||
"_postinstall": "husky install",
|
||||
"postpublish": "pinst --enable",
|
||||
"prepublishOnly": "pinst --disable",
|
||||
"prettier": "prettier --config ./.prettierrc.yaml --write \"**/*.{js,json,md,sol,ts,yaml,yml}\"",
|
||||
"prettier:check": "prettier --check --config ./.prettierrc.yaml \"**/*.{js,json,md,sol,ts,yaml,yml}\""
|
||||
},
|
||||
"devDependencies": {
|
||||
"@commitlint/cli": "^17.2.0",
|
||||
"@commitlint/config-conventional": "^17.2.0",
|
||||
"@ethersproject/abi": "^5.7.0",
|
||||
"@ethersproject/abstract-signer": "^5.7.0",
|
||||
"@ethersproject/bignumber": "^5.7.0",
|
||||
"@ethersproject/bytes": "^5.7.0",
|
||||
"@ethersproject/providers": "^5.7.2",
|
||||
"@nomicfoundation/hardhat-chai-matchers": "^1.0.4",
|
||||
"@nomicfoundation/hardhat-network-helpers": "1.0.6",
|
||||
"@nomicfoundation/hardhat-toolbox": "^2.0.0",
|
||||
"@nomiclabs/hardhat-ethers": "^2.2.1",
|
||||
"@nomiclabs/hardhat-etherscan": "^3.1.2",
|
||||
"@trivago/prettier-plugin-sort-imports": "^3.4.0",
|
||||
"@typechain/ethers-v5": "^10.1.1",
|
||||
"@typechain/hardhat": "^6.1.4",
|
||||
"@types/chai": "^4.3.3",
|
||||
"@types/fs-extra": "^9.0.13",
|
||||
"@types/mocha": "^9.1.1",
|
||||
"@types/node": "^18.11.9",
|
||||
"@typescript-eslint/eslint-plugin": "^5.42.0",
|
||||
"@typescript-eslint/parser": "^5.42.0",
|
||||
"chai": "^4.3.6",
|
||||
"chalk": "4.x",
|
||||
"commitizen": "^4.2.5",
|
||||
"cross-env": "^7.0.3",
|
||||
"cz-conventional-changelog": "^3.3.0",
|
||||
"dotenv": "^16.0.3",
|
||||
"eslint": "^8.26.0",
|
||||
"eslint-config-prettier": "^8.5.0",
|
||||
"ethers": "^5.7.2",
|
||||
"fs-extra": "^10.1.0",
|
||||
"hardhat": "^2.12.2",
|
||||
"hardhat-gas-reporter": "^1.0.9",
|
||||
"hardhat-tracer": "^1.2.0",
|
||||
"husky": "^8.0.1",
|
||||
"@ethersproject/abi": "^5.8.0",
|
||||
"@ethersproject/providers": "^5.8.0",
|
||||
"@nomicfoundation/hardhat-chai-matchers": "^2.1.0",
|
||||
"@nomicfoundation/hardhat-ethers": "^3.1.0",
|
||||
"@nomicfoundation/hardhat-ignition": "^0.15.13",
|
||||
"@nomicfoundation/hardhat-ignition-ethers": "^0.15.14",
|
||||
"@nomicfoundation/hardhat-network-helpers": "^1.1.0",
|
||||
"@nomicfoundation/hardhat-toolbox": "^6.1.0",
|
||||
"@nomicfoundation/hardhat-verify": "^2.1.0",
|
||||
"@nomicfoundation/hardhat-viem": "^2.1.0",
|
||||
"@nomicfoundation/ignition-core": "^0.15.13",
|
||||
"@openzeppelin/contracts": "5.5.0",
|
||||
"@typechain/ethers-v6": "^0.5.1",
|
||||
"@typechain/hardhat": "^9.1.0",
|
||||
"@types/chai": "^4.3.20",
|
||||
"@types/mocha": "^10.0.10",
|
||||
"@types/node": "^24.1.0",
|
||||
"chai": "4.5.0",
|
||||
"dotenv": "^16.6.1",
|
||||
"eslint": "^9.32.0",
|
||||
"eslint-config-prettier": "^10.1.8",
|
||||
"ethers": "^6.15.0",
|
||||
"hardhat": "^2.26.1",
|
||||
"hardhat-contract-sizer": "^2.10.0",
|
||||
"hardhat-gas-reporter": "^2.3.0",
|
||||
"keccak256": "^1.0.6",
|
||||
"lint-staged": "^13.0.3",
|
||||
"lodash": "^4.17.21",
|
||||
"merkletreejs": "^0.2.32",
|
||||
"mocha": "^10.1.0",
|
||||
"pinst": "^3.0.0",
|
||||
"prettier": "^2.7.1",
|
||||
"prettier-plugin-solidity": "^1.0.0-rc.1",
|
||||
"shx": "^0.3.4",
|
||||
"solhint": "^3.3.7",
|
||||
"solhint-plugin-prettier": "^0.0.5",
|
||||
"solidity-coverage": "^0.8.2",
|
||||
"ts-generator": "^0.1.1",
|
||||
"ts-node": "^10.9.1",
|
||||
"typechain": "^8.1.1",
|
||||
"typescript": "^4.8.4"
|
||||
"merkletreejs": "^0.5.2",
|
||||
"mocha": "^10.8.2",
|
||||
"solidity-coverage": "^0.8.16",
|
||||
"solidity-docgen": "^0.6.0-beta.36",
|
||||
"ts-node": "^10.9.2",
|
||||
"typechain": "^8.3.2",
|
||||
"typescript": "^5.8.3",
|
||||
"viem": "^2.33.1"
|
||||
},
|
||||
"files": [
|
||||
"/contracts"
|
||||
],
|
||||
"packageManager": "yarn@3.2.1",
|
||||
"packageManager": "yarn@4.9.2",
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
}
|
||||
|
||||
@@ -1,15 +1,11 @@
|
||||
import "@nomiclabs/hardhat-ethers";
|
||||
import "@nomiclabs/hardhat-etherscan";
|
||||
import { BigNumber } from "ethers";
|
||||
import "@nomicfoundation/hardhat-ethers";
|
||||
import * as fs from "fs";
|
||||
import { ethers, network } from "hardhat";
|
||||
|
||||
import { Deploys } from "../test/utils/fixtures";
|
||||
|
||||
import hre from "hardhat";
|
||||
import { Deploys } from "../test/utils/interfaces";
|
||||
|
||||
let deploysJson: Deploys;
|
||||
const supply: BigNumber = ethers.utils.parseEther("20000000");
|
||||
const supply: BigInt = ethers.parseEther("20000000");
|
||||
|
||||
const main = async () => {
|
||||
try {
|
||||
@@ -26,15 +22,11 @@ const main = async () => {
|
||||
const [deployer] = await ethers.getSigners();
|
||||
console.log(`Deploying contracts with ${deployer.address}`);
|
||||
|
||||
const ERC20Factory = await ethers.getContractFactory(
|
||||
"MockToken",
|
||||
);
|
||||
const erc20 = await ERC20Factory.deploy(supply);
|
||||
await erc20.deployed();
|
||||
let erc20 = await ethers.deployContract("MockToken", [supply]);
|
||||
erc20 = await erc20.waitForDeployment();
|
||||
|
||||
deploysJson.token = erc20.address;
|
||||
console.log("🚀 Mock Token Deployed:", erc20.address);
|
||||
await erc20.deployTransaction.wait(6);
|
||||
deploysJson.token = await erc20.getAddress();
|
||||
console.log("🚀 Mock Token Deployed:", await erc20.getAddress());
|
||||
|
||||
fs.writeFileSync(
|
||||
`./deploys/${network.name}.json`,
|
||||
@@ -43,10 +35,10 @@ const main = async () => {
|
||||
|
||||
/* UNCOMMENT WHEN DEPLOYING TO MAINNET/PUBLIC TESTNETS */
|
||||
// verify
|
||||
await hre.run("verify:verify", {
|
||||
address: erc20.address,
|
||||
constructorArguments: [supply],
|
||||
});
|
||||
// await hre.run("verify:verify", {
|
||||
// address: erc20.address,
|
||||
// constructorArguments: [supply],
|
||||
// });
|
||||
};
|
||||
|
||||
main()
|
||||
|
||||
@@ -1,11 +1,8 @@
|
||||
import "@nomiclabs/hardhat-ethers";
|
||||
import "@nomiclabs/hardhat-etherscan";
|
||||
import "@nomicfoundation/hardhat-ethers";
|
||||
import * as fs from "fs";
|
||||
import { ethers, network } from "hardhat";
|
||||
|
||||
import { Deploys } from "../test/utils/fixtures";
|
||||
|
||||
import hre from "hardhat";
|
||||
import { Deploys } from "../test/utils/interfaces";
|
||||
|
||||
let deploysJson: Deploys;
|
||||
|
||||
@@ -24,25 +21,24 @@ const main = async () => {
|
||||
const [deployer] = await ethers.getSigners();
|
||||
console.log(`Deploying contracts with ${deployer.address}`);
|
||||
|
||||
const Reputation = await ethers.getContractFactory(
|
||||
"Reputation",
|
||||
);
|
||||
const reputation = await Reputation.deploy();
|
||||
await reputation.deployed();
|
||||
|
||||
const P2PIX = await ethers.getContractFactory("P2PIX");
|
||||
const p2pix = await P2PIX.deploy(
|
||||
let reputation = await ethers.deployContract("Reputation");
|
||||
let multicall = await ethers.deployContract("Multicall");
|
||||
let p2pix = await ethers.deployContract("P2PIX", [
|
||||
10,
|
||||
deploysJson.signers,
|
||||
reputation.address,
|
||||
reputation.target,
|
||||
[deploysJson.token],
|
||||
[true],
|
||||
);
|
||||
await p2pix.deployed();
|
||||
]);
|
||||
|
||||
deploysJson.p2pix = p2pix.address;
|
||||
console.log("🚀 P2PIX Deployed:", p2pix.address);
|
||||
await p2pix.deployTransaction.wait(6);
|
||||
reputation = await reputation.waitForDeployment();
|
||||
multicall = await multicall.waitForDeployment();
|
||||
p2pix = await p2pix.waitForDeployment();
|
||||
|
||||
deploysJson.p2pix = await p2pix.getAddress();
|
||||
console.log("🚀 P2PIX Deployed:", await p2pix.getAddress());
|
||||
console.log("🌠 Reputation Deployed:", await reputation.getAddress());
|
||||
console.log("🛰 Multicall Deployed:", await multicall.getAddress());
|
||||
|
||||
fs.writeFileSync(
|
||||
`./deploys/${network.name}.json`,
|
||||
@@ -51,17 +47,24 @@ const main = async () => {
|
||||
|
||||
/* UNCOMMENT WHEN DEPLOYING TO MAINNET/PUBLIC TESTNETS */
|
||||
//verify
|
||||
await hre.run("verify:verify", {
|
||||
address: p2pix.address,
|
||||
constructorArguments:
|
||||
[
|
||||
10,
|
||||
deploysJson.signers,
|
||||
reputation.address,
|
||||
[deploysJson.token],
|
||||
[true],
|
||||
],
|
||||
});
|
||||
// await hre.run("verify:verify", {
|
||||
// address: p2pix.address,
|
||||
// constructorArguments: [
|
||||
// 10,
|
||||
// deploysJson.signers,
|
||||
// reputation.address,
|
||||
// [deploysJson.token],
|
||||
// [true],
|
||||
// ],
|
||||
// });
|
||||
// await hre.run("verify:verify", {
|
||||
// address: reputation.address,
|
||||
// constructorArguments: [],
|
||||
// });
|
||||
// await hre.run("verify:verify", {
|
||||
// address: mutlicall.address,
|
||||
// constructorArguments: [],
|
||||
// });
|
||||
};
|
||||
|
||||
main()
|
||||
|
||||
38
scripts/setDefaultBlocks.ts
Normal file
38
scripts/setDefaultBlocks.ts
Normal file
@@ -0,0 +1,38 @@
|
||||
import "@nomiclabs/hardhat-ethers";
|
||||
import "@nomiclabs/hardhat-etherscan";
|
||||
import * as fs from "fs";
|
||||
import { ethers, network } from "hardhat";
|
||||
import { Deploys } from "../test/utils/interfaces";
|
||||
import { P2PIX__factory } from "../src/types";
|
||||
|
||||
let deploysJson: Deploys;
|
||||
|
||||
const main = async () => {
|
||||
try {
|
||||
const data = fs.readFileSync(
|
||||
`./deploys/${network.name}.json`,
|
||||
{ encoding: "utf-8" },
|
||||
);
|
||||
deploysJson = JSON.parse(data);
|
||||
} catch (err) {
|
||||
console.log("Error loading Master address: ", err);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
const [deployer] = await ethers.getSigners();
|
||||
console.log(`Signing transactions with ${deployer.address}`);
|
||||
|
||||
const iface = new ethers.utils.Interface(P2PIX__factory.abi);
|
||||
const calldata = iface.encodeFunctionData("setDefaultLockBlocks", ["10000"]);
|
||||
|
||||
const tx = await deployer.sendTransaction({to:deploysJson.p2pix, data: calldata});
|
||||
const done = await tx.wait();
|
||||
console.log(done.transactionHash);
|
||||
};
|
||||
|
||||
main()
|
||||
.then(() => process.exit(0))
|
||||
.catch(error => {
|
||||
console.log(error);
|
||||
process.exit(1);
|
||||
});
|
||||
@@ -1,322 +0,0 @@
|
||||
/* Autogenerated file. Do not edit manually. */
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
import type { BaseContract, BigNumber, BytesLike, Signer, utils } from "ethers";
|
||||
import type { EventFragment } from "@ethersproject/abi";
|
||||
import type { Listener, Provider } from "@ethersproject/providers";
|
||||
import type {
|
||||
TypedEventFilter,
|
||||
TypedEvent,
|
||||
TypedListener,
|
||||
OnEvent,
|
||||
PromiseOrValue,
|
||||
} from "./common";
|
||||
|
||||
export interface EventAndErrorsInterface extends utils.Interface {
|
||||
functions: {};
|
||||
|
||||
events: {
|
||||
"AllowedERC20Updated(address,bool)": EventFragment;
|
||||
"DepositAdded(address,uint256,address,uint256)": EventFragment;
|
||||
"DepositClosed(address,uint256)": EventFragment;
|
||||
"DepositWithdrawn(address,uint256,uint256)": EventFragment;
|
||||
"FundsWithdrawn(address,uint256)": EventFragment;
|
||||
"LockAdded(address,bytes32,uint256,uint256)": EventFragment;
|
||||
"LockBlocksUpdated(uint256)": EventFragment;
|
||||
"LockReleased(address,bytes32,uint256)": EventFragment;
|
||||
"LockReturned(address,bytes32)": EventFragment;
|
||||
"ReputationUpdated(address)": EventFragment;
|
||||
"RootUpdated(address,bytes32)": EventFragment;
|
||||
"ValidSignersUpdated(address[])": EventFragment;
|
||||
};
|
||||
|
||||
getEvent(nameOrSignatureOrTopic: "AllowedERC20Updated"): EventFragment;
|
||||
getEvent(nameOrSignatureOrTopic: "DepositAdded"): EventFragment;
|
||||
getEvent(nameOrSignatureOrTopic: "DepositClosed"): EventFragment;
|
||||
getEvent(nameOrSignatureOrTopic: "DepositWithdrawn"): EventFragment;
|
||||
getEvent(nameOrSignatureOrTopic: "FundsWithdrawn"): EventFragment;
|
||||
getEvent(nameOrSignatureOrTopic: "LockAdded"): EventFragment;
|
||||
getEvent(nameOrSignatureOrTopic: "LockBlocksUpdated"): EventFragment;
|
||||
getEvent(nameOrSignatureOrTopic: "LockReleased"): EventFragment;
|
||||
getEvent(nameOrSignatureOrTopic: "LockReturned"): EventFragment;
|
||||
getEvent(nameOrSignatureOrTopic: "ReputationUpdated"): EventFragment;
|
||||
getEvent(nameOrSignatureOrTopic: "RootUpdated"): EventFragment;
|
||||
getEvent(nameOrSignatureOrTopic: "ValidSignersUpdated"): EventFragment;
|
||||
}
|
||||
|
||||
export interface AllowedERC20UpdatedEventObject {
|
||||
token: string;
|
||||
state: boolean;
|
||||
}
|
||||
export type AllowedERC20UpdatedEvent = TypedEvent<
|
||||
[string, boolean],
|
||||
AllowedERC20UpdatedEventObject
|
||||
>;
|
||||
|
||||
export type AllowedERC20UpdatedEventFilter =
|
||||
TypedEventFilter<AllowedERC20UpdatedEvent>;
|
||||
|
||||
export interface DepositAddedEventObject {
|
||||
seller: string;
|
||||
depositID: BigNumber;
|
||||
token: string;
|
||||
amount: BigNumber;
|
||||
}
|
||||
export type DepositAddedEvent = TypedEvent<
|
||||
[string, BigNumber, string, BigNumber],
|
||||
DepositAddedEventObject
|
||||
>;
|
||||
|
||||
export type DepositAddedEventFilter = TypedEventFilter<DepositAddedEvent>;
|
||||
|
||||
export interface DepositClosedEventObject {
|
||||
seller: string;
|
||||
depositID: BigNumber;
|
||||
}
|
||||
export type DepositClosedEvent = TypedEvent<
|
||||
[string, BigNumber],
|
||||
DepositClosedEventObject
|
||||
>;
|
||||
|
||||
export type DepositClosedEventFilter = TypedEventFilter<DepositClosedEvent>;
|
||||
|
||||
export interface DepositWithdrawnEventObject {
|
||||
seller: string;
|
||||
depositID: BigNumber;
|
||||
amount: BigNumber;
|
||||
}
|
||||
export type DepositWithdrawnEvent = TypedEvent<
|
||||
[string, BigNumber, BigNumber],
|
||||
DepositWithdrawnEventObject
|
||||
>;
|
||||
|
||||
export type DepositWithdrawnEventFilter =
|
||||
TypedEventFilter<DepositWithdrawnEvent>;
|
||||
|
||||
export interface FundsWithdrawnEventObject {
|
||||
owner: string;
|
||||
amount: BigNumber;
|
||||
}
|
||||
export type FundsWithdrawnEvent = TypedEvent<
|
||||
[string, BigNumber],
|
||||
FundsWithdrawnEventObject
|
||||
>;
|
||||
|
||||
export type FundsWithdrawnEventFilter = TypedEventFilter<FundsWithdrawnEvent>;
|
||||
|
||||
export interface LockAddedEventObject {
|
||||
buyer: string;
|
||||
lockID: string;
|
||||
depositID: BigNumber;
|
||||
amount: BigNumber;
|
||||
}
|
||||
export type LockAddedEvent = TypedEvent<
|
||||
[string, string, BigNumber, BigNumber],
|
||||
LockAddedEventObject
|
||||
>;
|
||||
|
||||
export type LockAddedEventFilter = TypedEventFilter<LockAddedEvent>;
|
||||
|
||||
export interface LockBlocksUpdatedEventObject {
|
||||
blocks: BigNumber;
|
||||
}
|
||||
export type LockBlocksUpdatedEvent = TypedEvent<
|
||||
[BigNumber],
|
||||
LockBlocksUpdatedEventObject
|
||||
>;
|
||||
|
||||
export type LockBlocksUpdatedEventFilter =
|
||||
TypedEventFilter<LockBlocksUpdatedEvent>;
|
||||
|
||||
export interface LockReleasedEventObject {
|
||||
buyer: string;
|
||||
lockId: string;
|
||||
amount: BigNumber;
|
||||
}
|
||||
export type LockReleasedEvent = TypedEvent<
|
||||
[string, string, BigNumber],
|
||||
LockReleasedEventObject
|
||||
>;
|
||||
|
||||
export type LockReleasedEventFilter = TypedEventFilter<LockReleasedEvent>;
|
||||
|
||||
export interface LockReturnedEventObject {
|
||||
buyer: string;
|
||||
lockId: string;
|
||||
}
|
||||
export type LockReturnedEvent = TypedEvent<
|
||||
[string, string],
|
||||
LockReturnedEventObject
|
||||
>;
|
||||
|
||||
export type LockReturnedEventFilter = TypedEventFilter<LockReturnedEvent>;
|
||||
|
||||
export interface ReputationUpdatedEventObject {
|
||||
reputation: string;
|
||||
}
|
||||
export type ReputationUpdatedEvent = TypedEvent<
|
||||
[string],
|
||||
ReputationUpdatedEventObject
|
||||
>;
|
||||
|
||||
export type ReputationUpdatedEventFilter =
|
||||
TypedEventFilter<ReputationUpdatedEvent>;
|
||||
|
||||
export interface RootUpdatedEventObject {
|
||||
seller: string;
|
||||
merkleRoot: string;
|
||||
}
|
||||
export type RootUpdatedEvent = TypedEvent<
|
||||
[string, string],
|
||||
RootUpdatedEventObject
|
||||
>;
|
||||
|
||||
export type RootUpdatedEventFilter = TypedEventFilter<RootUpdatedEvent>;
|
||||
|
||||
export interface ValidSignersUpdatedEventObject {
|
||||
signers: string[];
|
||||
}
|
||||
export type ValidSignersUpdatedEvent = TypedEvent<
|
||||
[string[]],
|
||||
ValidSignersUpdatedEventObject
|
||||
>;
|
||||
|
||||
export type ValidSignersUpdatedEventFilter =
|
||||
TypedEventFilter<ValidSignersUpdatedEvent>;
|
||||
|
||||
export interface EventAndErrors extends BaseContract {
|
||||
connect(signerOrProvider: Signer | Provider | string): this;
|
||||
attach(addressOrName: string): this;
|
||||
deployed(): Promise<this>;
|
||||
|
||||
interface: EventAndErrorsInterface;
|
||||
|
||||
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: {
|
||||
"AllowedERC20Updated(address,bool)"(
|
||||
token?: PromiseOrValue<string> | null,
|
||||
state?: PromiseOrValue<boolean> | null
|
||||
): AllowedERC20UpdatedEventFilter;
|
||||
AllowedERC20Updated(
|
||||
token?: PromiseOrValue<string> | null,
|
||||
state?: PromiseOrValue<boolean> | null
|
||||
): AllowedERC20UpdatedEventFilter;
|
||||
|
||||
"DepositAdded(address,uint256,address,uint256)"(
|
||||
seller?: PromiseOrValue<string> | null,
|
||||
depositID?: null,
|
||||
token?: null,
|
||||
amount?: null
|
||||
): DepositAddedEventFilter;
|
||||
DepositAdded(
|
||||
seller?: PromiseOrValue<string> | null,
|
||||
depositID?: null,
|
||||
token?: null,
|
||||
amount?: null
|
||||
): DepositAddedEventFilter;
|
||||
|
||||
"DepositClosed(address,uint256)"(
|
||||
seller?: PromiseOrValue<string> | null,
|
||||
depositID?: null
|
||||
): DepositClosedEventFilter;
|
||||
DepositClosed(
|
||||
seller?: PromiseOrValue<string> | null,
|
||||
depositID?: null
|
||||
): DepositClosedEventFilter;
|
||||
|
||||
"DepositWithdrawn(address,uint256,uint256)"(
|
||||
seller?: PromiseOrValue<string> | null,
|
||||
depositID?: null,
|
||||
amount?: null
|
||||
): DepositWithdrawnEventFilter;
|
||||
DepositWithdrawn(
|
||||
seller?: PromiseOrValue<string> | null,
|
||||
depositID?: null,
|
||||
amount?: null
|
||||
): DepositWithdrawnEventFilter;
|
||||
|
||||
"FundsWithdrawn(address,uint256)"(
|
||||
owner?: null,
|
||||
amount?: null
|
||||
): FundsWithdrawnEventFilter;
|
||||
FundsWithdrawn(owner?: null, amount?: null): FundsWithdrawnEventFilter;
|
||||
|
||||
"LockAdded(address,bytes32,uint256,uint256)"(
|
||||
buyer?: PromiseOrValue<string> | null,
|
||||
lockID?: PromiseOrValue<BytesLike> | null,
|
||||
depositID?: null,
|
||||
amount?: null
|
||||
): LockAddedEventFilter;
|
||||
LockAdded(
|
||||
buyer?: PromiseOrValue<string> | null,
|
||||
lockID?: PromiseOrValue<BytesLike> | null,
|
||||
depositID?: null,
|
||||
amount?: null
|
||||
): LockAddedEventFilter;
|
||||
|
||||
"LockBlocksUpdated(uint256)"(blocks?: null): LockBlocksUpdatedEventFilter;
|
||||
LockBlocksUpdated(blocks?: null): LockBlocksUpdatedEventFilter;
|
||||
|
||||
"LockReleased(address,bytes32,uint256)"(
|
||||
buyer?: PromiseOrValue<string> | null,
|
||||
lockId?: null,
|
||||
amount?: null
|
||||
): LockReleasedEventFilter;
|
||||
LockReleased(
|
||||
buyer?: PromiseOrValue<string> | null,
|
||||
lockId?: null,
|
||||
amount?: null
|
||||
): LockReleasedEventFilter;
|
||||
|
||||
"LockReturned(address,bytes32)"(
|
||||
buyer?: PromiseOrValue<string> | null,
|
||||
lockId?: null
|
||||
): LockReturnedEventFilter;
|
||||
LockReturned(
|
||||
buyer?: PromiseOrValue<string> | null,
|
||||
lockId?: null
|
||||
): LockReturnedEventFilter;
|
||||
|
||||
"ReputationUpdated(address)"(
|
||||
reputation?: null
|
||||
): ReputationUpdatedEventFilter;
|
||||
ReputationUpdated(reputation?: null): ReputationUpdatedEventFilter;
|
||||
|
||||
"RootUpdated(address,bytes32)"(
|
||||
seller?: null,
|
||||
merkleRoot?: null
|
||||
): RootUpdatedEventFilter;
|
||||
RootUpdated(seller?: null, merkleRoot?: null): RootUpdatedEventFilter;
|
||||
|
||||
"ValidSignersUpdated(address[])"(
|
||||
signers?: null
|
||||
): ValidSignersUpdatedEventFilter;
|
||||
ValidSignersUpdated(signers?: null): ValidSignersUpdatedEventFilter;
|
||||
};
|
||||
|
||||
estimateGas: {};
|
||||
|
||||
populateTransaction: {};
|
||||
}
|
||||
@@ -1,211 +0,0 @@
|
||||
/* Autogenerated file. Do not edit manually. */
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
import type {
|
||||
BaseContract,
|
||||
BigNumber,
|
||||
BigNumberish,
|
||||
BytesLike,
|
||||
CallOverrides,
|
||||
ContractTransaction,
|
||||
Overrides,
|
||||
PopulatedTransaction,
|
||||
Signer,
|
||||
utils,
|
||||
} from "ethers";
|
||||
import type {
|
||||
FunctionFragment,
|
||||
Result,
|
||||
EventFragment,
|
||||
} from "@ethersproject/abi";
|
||||
import type { Listener, Provider } from "@ethersproject/providers";
|
||||
import type {
|
||||
TypedEventFilter,
|
||||
TypedEvent,
|
||||
TypedListener,
|
||||
OnEvent,
|
||||
PromiseOrValue,
|
||||
} from "./common";
|
||||
|
||||
export interface ReputationInterface extends utils.Interface {
|
||||
functions: {
|
||||
"limiter(uint256)": FunctionFragment;
|
||||
"magicValue()": FunctionFragment;
|
||||
"maxLimit()": FunctionFragment;
|
||||
"owner()": FunctionFragment;
|
||||
"setOwner(address)": FunctionFragment;
|
||||
};
|
||||
|
||||
getFunction(
|
||||
nameOrSignatureOrTopic:
|
||||
| "limiter"
|
||||
| "magicValue"
|
||||
| "maxLimit"
|
||||
| "owner"
|
||||
| "setOwner"
|
||||
): FunctionFragment;
|
||||
|
||||
encodeFunctionData(
|
||||
functionFragment: "limiter",
|
||||
values: [PromiseOrValue<BigNumberish>]
|
||||
): string;
|
||||
encodeFunctionData(
|
||||
functionFragment: "magicValue",
|
||||
values?: undefined
|
||||
): string;
|
||||
encodeFunctionData(functionFragment: "maxLimit", values?: undefined): string;
|
||||
encodeFunctionData(functionFragment: "owner", values?: undefined): string;
|
||||
encodeFunctionData(
|
||||
functionFragment: "setOwner",
|
||||
values: [PromiseOrValue<string>]
|
||||
): string;
|
||||
|
||||
decodeFunctionResult(functionFragment: "limiter", data: BytesLike): Result;
|
||||
decodeFunctionResult(functionFragment: "magicValue", data: BytesLike): Result;
|
||||
decodeFunctionResult(functionFragment: "maxLimit", data: BytesLike): Result;
|
||||
decodeFunctionResult(functionFragment: "owner", data: BytesLike): Result;
|
||||
decodeFunctionResult(functionFragment: "setOwner", data: BytesLike): Result;
|
||||
|
||||
events: {
|
||||
"OwnerUpdated(address,address)": EventFragment;
|
||||
};
|
||||
|
||||
getEvent(nameOrSignatureOrTopic: "OwnerUpdated"): EventFragment;
|
||||
}
|
||||
|
||||
export interface OwnerUpdatedEventObject {
|
||||
user: string;
|
||||
newOwner: string;
|
||||
}
|
||||
export type OwnerUpdatedEvent = TypedEvent<
|
||||
[string, string],
|
||||
OwnerUpdatedEventObject
|
||||
>;
|
||||
|
||||
export type OwnerUpdatedEventFilter = TypedEventFilter<OwnerUpdatedEvent>;
|
||||
|
||||
export interface Reputation extends BaseContract {
|
||||
connect(signerOrProvider: Signer | Provider | string): this;
|
||||
attach(addressOrName: string): this;
|
||||
deployed(): Promise<this>;
|
||||
|
||||
interface: ReputationInterface;
|
||||
|
||||
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: {
|
||||
limiter(
|
||||
_userCredit: PromiseOrValue<BigNumberish>,
|
||||
overrides?: CallOverrides
|
||||
): Promise<[BigNumber] & { _spendLimit: BigNumber }>;
|
||||
|
||||
magicValue(overrides?: CallOverrides): Promise<[BigNumber]>;
|
||||
|
||||
maxLimit(overrides?: CallOverrides): Promise<[BigNumber]>;
|
||||
|
||||
owner(overrides?: CallOverrides): Promise<[string]>;
|
||||
|
||||
setOwner(
|
||||
newOwner: PromiseOrValue<string>,
|
||||
overrides?: Overrides & { from?: PromiseOrValue<string> }
|
||||
): Promise<ContractTransaction>;
|
||||
};
|
||||
|
||||
limiter(
|
||||
_userCredit: PromiseOrValue<BigNumberish>,
|
||||
overrides?: CallOverrides
|
||||
): Promise<BigNumber>;
|
||||
|
||||
magicValue(overrides?: CallOverrides): Promise<BigNumber>;
|
||||
|
||||
maxLimit(overrides?: CallOverrides): Promise<BigNumber>;
|
||||
|
||||
owner(overrides?: CallOverrides): Promise<string>;
|
||||
|
||||
setOwner(
|
||||
newOwner: PromiseOrValue<string>,
|
||||
overrides?: Overrides & { from?: PromiseOrValue<string> }
|
||||
): Promise<ContractTransaction>;
|
||||
|
||||
callStatic: {
|
||||
limiter(
|
||||
_userCredit: PromiseOrValue<BigNumberish>,
|
||||
overrides?: CallOverrides
|
||||
): Promise<BigNumber>;
|
||||
|
||||
magicValue(overrides?: CallOverrides): Promise<BigNumber>;
|
||||
|
||||
maxLimit(overrides?: CallOverrides): Promise<BigNumber>;
|
||||
|
||||
owner(overrides?: CallOverrides): Promise<string>;
|
||||
|
||||
setOwner(
|
||||
newOwner: PromiseOrValue<string>,
|
||||
overrides?: CallOverrides
|
||||
): Promise<void>;
|
||||
};
|
||||
|
||||
filters: {
|
||||
"OwnerUpdated(address,address)"(
|
||||
user?: PromiseOrValue<string> | null,
|
||||
newOwner?: PromiseOrValue<string> | null
|
||||
): OwnerUpdatedEventFilter;
|
||||
OwnerUpdated(
|
||||
user?: PromiseOrValue<string> | null,
|
||||
newOwner?: PromiseOrValue<string> | null
|
||||
): OwnerUpdatedEventFilter;
|
||||
};
|
||||
|
||||
estimateGas: {
|
||||
limiter(
|
||||
_userCredit: PromiseOrValue<BigNumberish>,
|
||||
overrides?: CallOverrides
|
||||
): Promise<BigNumber>;
|
||||
|
||||
magicValue(overrides?: CallOverrides): Promise<BigNumber>;
|
||||
|
||||
maxLimit(overrides?: CallOverrides): Promise<BigNumber>;
|
||||
|
||||
owner(overrides?: CallOverrides): Promise<BigNumber>;
|
||||
|
||||
setOwner(
|
||||
newOwner: PromiseOrValue<string>,
|
||||
overrides?: Overrides & { from?: PromiseOrValue<string> }
|
||||
): Promise<BigNumber>;
|
||||
};
|
||||
|
||||
populateTransaction: {
|
||||
limiter(
|
||||
_userCredit: PromiseOrValue<BigNumberish>,
|
||||
overrides?: CallOverrides
|
||||
): Promise<PopulatedTransaction>;
|
||||
|
||||
magicValue(overrides?: CallOverrides): Promise<PopulatedTransaction>;
|
||||
|
||||
maxLimit(overrides?: CallOverrides): Promise<PopulatedTransaction>;
|
||||
|
||||
owner(overrides?: CallOverrides): Promise<PopulatedTransaction>;
|
||||
|
||||
setOwner(
|
||||
newOwner: PromiseOrValue<string>,
|
||||
overrides?: Overrides & { from?: PromiseOrValue<string> }
|
||||
): Promise<PopulatedTransaction>;
|
||||
};
|
||||
}
|
||||
@@ -1,46 +0,0 @@
|
||||
/* Autogenerated file. Do not edit manually. */
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
import type { Listener } from "@ethersproject/providers";
|
||||
import type { Event, EventFilter } from "ethers";
|
||||
|
||||
export interface TypedEvent<
|
||||
TArgsArray extends Array<any> = any,
|
||||
TArgsObject = any
|
||||
> extends Event {
|
||||
args: TArgsArray & TArgsObject;
|
||||
}
|
||||
|
||||
export interface TypedEventFilter<_TEvent extends TypedEvent>
|
||||
extends EventFilter {}
|
||||
|
||||
export interface TypedListener<TEvent extends TypedEvent> {
|
||||
(...listenerArg: [...__TypechainArgsArray<TEvent>, TEvent]): void;
|
||||
}
|
||||
|
||||
type __TypechainArgsArray<T> = T extends TypedEvent<infer U> ? U : never;
|
||||
|
||||
export interface OnEvent<TRes> {
|
||||
<TEvent extends TypedEvent>(
|
||||
eventFilter: TypedEventFilter<TEvent>,
|
||||
listener: TypedListener<TEvent>
|
||||
): TRes;
|
||||
(eventName: string, listener: Listener): TRes;
|
||||
}
|
||||
|
||||
export type MinEthersFactory<C, ARGS> = {
|
||||
deploy(...a: ARGS[]): Promise<C>;
|
||||
};
|
||||
|
||||
export type GetContractTypeFromFactory<F> = F extends MinEthersFactory<
|
||||
infer C,
|
||||
any
|
||||
>
|
||||
? C
|
||||
: never;
|
||||
|
||||
export type GetARGsTypeFromFactory<F> = F extends MinEthersFactory<any, any>
|
||||
? Parameters<F["deploy"]>
|
||||
: never;
|
||||
|
||||
export type PromiseOrValue<T> = T | Promise<T>;
|
||||
@@ -1,352 +0,0 @@
|
||||
/* Autogenerated file. Do not edit manually. */
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
|
||||
import { Contract, Signer, utils } from "ethers";
|
||||
import type { Provider } from "@ethersproject/providers";
|
||||
import type {
|
||||
EventAndErrors,
|
||||
EventAndErrorsInterface,
|
||||
} from "../EventAndErrors";
|
||||
|
||||
const _abi = [
|
||||
{
|
||||
inputs: [],
|
||||
name: "AddressDenied",
|
||||
type: "error",
|
||||
},
|
||||
{
|
||||
inputs: [],
|
||||
name: "AlreadyReleased",
|
||||
type: "error",
|
||||
},
|
||||
{
|
||||
inputs: [],
|
||||
name: "AmountNotAllowed",
|
||||
type: "error",
|
||||
},
|
||||
{
|
||||
inputs: [],
|
||||
name: "DepositAlreadyExists",
|
||||
type: "error",
|
||||
},
|
||||
{
|
||||
inputs: [],
|
||||
name: "InvalidDeposit",
|
||||
type: "error",
|
||||
},
|
||||
{
|
||||
inputs: [],
|
||||
name: "InvalidSigner",
|
||||
type: "error",
|
||||
},
|
||||
{
|
||||
inputs: [],
|
||||
name: "LengthMismatch",
|
||||
type: "error",
|
||||
},
|
||||
{
|
||||
inputs: [],
|
||||
name: "LockExpired",
|
||||
type: "error",
|
||||
},
|
||||
{
|
||||
inputs: [],
|
||||
name: "LoopOverflow",
|
||||
type: "error",
|
||||
},
|
||||
{
|
||||
inputs: [],
|
||||
name: "NoTokens",
|
||||
type: "error",
|
||||
},
|
||||
{
|
||||
inputs: [],
|
||||
name: "NotEnoughTokens",
|
||||
type: "error",
|
||||
},
|
||||
{
|
||||
inputs: [],
|
||||
name: "NotExpired",
|
||||
type: "error",
|
||||
},
|
||||
{
|
||||
inputs: [],
|
||||
name: "OnlySeller",
|
||||
type: "error",
|
||||
},
|
||||
{
|
||||
inputs: [],
|
||||
name: "StaticCallFailed",
|
||||
type: "error",
|
||||
},
|
||||
{
|
||||
inputs: [],
|
||||
name: "TokenDenied",
|
||||
type: "error",
|
||||
},
|
||||
{
|
||||
inputs: [],
|
||||
name: "TxAlreadyUsed",
|
||||
type: "error",
|
||||
},
|
||||
{
|
||||
anonymous: false,
|
||||
inputs: [
|
||||
{
|
||||
indexed: true,
|
||||
internalType: "address",
|
||||
name: "token",
|
||||
type: "address",
|
||||
},
|
||||
{
|
||||
indexed: true,
|
||||
internalType: "bool",
|
||||
name: "state",
|
||||
type: "bool",
|
||||
},
|
||||
],
|
||||
name: "AllowedERC20Updated",
|
||||
type: "event",
|
||||
},
|
||||
{
|
||||
anonymous: false,
|
||||
inputs: [
|
||||
{
|
||||
indexed: true,
|
||||
internalType: "address",
|
||||
name: "seller",
|
||||
type: "address",
|
||||
},
|
||||
{
|
||||
indexed: false,
|
||||
internalType: "uint256",
|
||||
name: "depositID",
|
||||
type: "uint256",
|
||||
},
|
||||
{
|
||||
indexed: false,
|
||||
internalType: "address",
|
||||
name: "token",
|
||||
type: "address",
|
||||
},
|
||||
{
|
||||
indexed: false,
|
||||
internalType: "uint256",
|
||||
name: "amount",
|
||||
type: "uint256",
|
||||
},
|
||||
],
|
||||
name: "DepositAdded",
|
||||
type: "event",
|
||||
},
|
||||
{
|
||||
anonymous: false,
|
||||
inputs: [
|
||||
{
|
||||
indexed: true,
|
||||
internalType: "address",
|
||||
name: "seller",
|
||||
type: "address",
|
||||
},
|
||||
{
|
||||
indexed: false,
|
||||
internalType: "uint256",
|
||||
name: "depositID",
|
||||
type: "uint256",
|
||||
},
|
||||
],
|
||||
name: "DepositClosed",
|
||||
type: "event",
|
||||
},
|
||||
{
|
||||
anonymous: false,
|
||||
inputs: [
|
||||
{
|
||||
indexed: true,
|
||||
internalType: "address",
|
||||
name: "seller",
|
||||
type: "address",
|
||||
},
|
||||
{
|
||||
indexed: false,
|
||||
internalType: "uint256",
|
||||
name: "depositID",
|
||||
type: "uint256",
|
||||
},
|
||||
{
|
||||
indexed: false,
|
||||
internalType: "uint256",
|
||||
name: "amount",
|
||||
type: "uint256",
|
||||
},
|
||||
],
|
||||
name: "DepositWithdrawn",
|
||||
type: "event",
|
||||
},
|
||||
{
|
||||
anonymous: false,
|
||||
inputs: [
|
||||
{
|
||||
indexed: false,
|
||||
internalType: "address",
|
||||
name: "owner",
|
||||
type: "address",
|
||||
},
|
||||
{
|
||||
indexed: false,
|
||||
internalType: "uint256",
|
||||
name: "amount",
|
||||
type: "uint256",
|
||||
},
|
||||
],
|
||||
name: "FundsWithdrawn",
|
||||
type: "event",
|
||||
},
|
||||
{
|
||||
anonymous: false,
|
||||
inputs: [
|
||||
{
|
||||
indexed: true,
|
||||
internalType: "address",
|
||||
name: "buyer",
|
||||
type: "address",
|
||||
},
|
||||
{
|
||||
indexed: true,
|
||||
internalType: "bytes32",
|
||||
name: "lockID",
|
||||
type: "bytes32",
|
||||
},
|
||||
{
|
||||
indexed: false,
|
||||
internalType: "uint256",
|
||||
name: "depositID",
|
||||
type: "uint256",
|
||||
},
|
||||
{
|
||||
indexed: false,
|
||||
internalType: "uint256",
|
||||
name: "amount",
|
||||
type: "uint256",
|
||||
},
|
||||
],
|
||||
name: "LockAdded",
|
||||
type: "event",
|
||||
},
|
||||
{
|
||||
anonymous: false,
|
||||
inputs: [
|
||||
{
|
||||
indexed: false,
|
||||
internalType: "uint256",
|
||||
name: "blocks",
|
||||
type: "uint256",
|
||||
},
|
||||
],
|
||||
name: "LockBlocksUpdated",
|
||||
type: "event",
|
||||
},
|
||||
{
|
||||
anonymous: false,
|
||||
inputs: [
|
||||
{
|
||||
indexed: true,
|
||||
internalType: "address",
|
||||
name: "buyer",
|
||||
type: "address",
|
||||
},
|
||||
{
|
||||
indexed: false,
|
||||
internalType: "bytes32",
|
||||
name: "lockId",
|
||||
type: "bytes32",
|
||||
},
|
||||
{
|
||||
indexed: false,
|
||||
internalType: "uint256",
|
||||
name: "amount",
|
||||
type: "uint256",
|
||||
},
|
||||
],
|
||||
name: "LockReleased",
|
||||
type: "event",
|
||||
},
|
||||
{
|
||||
anonymous: false,
|
||||
inputs: [
|
||||
{
|
||||
indexed: true,
|
||||
internalType: "address",
|
||||
name: "buyer",
|
||||
type: "address",
|
||||
},
|
||||
{
|
||||
indexed: false,
|
||||
internalType: "bytes32",
|
||||
name: "lockId",
|
||||
type: "bytes32",
|
||||
},
|
||||
],
|
||||
name: "LockReturned",
|
||||
type: "event",
|
||||
},
|
||||
{
|
||||
anonymous: false,
|
||||
inputs: [
|
||||
{
|
||||
indexed: false,
|
||||
internalType: "address",
|
||||
name: "reputation",
|
||||
type: "address",
|
||||
},
|
||||
],
|
||||
name: "ReputationUpdated",
|
||||
type: "event",
|
||||
},
|
||||
{
|
||||
anonymous: false,
|
||||
inputs: [
|
||||
{
|
||||
indexed: false,
|
||||
internalType: "address",
|
||||
name: "seller",
|
||||
type: "address",
|
||||
},
|
||||
{
|
||||
indexed: false,
|
||||
internalType: "bytes32",
|
||||
name: "merkleRoot",
|
||||
type: "bytes32",
|
||||
},
|
||||
],
|
||||
name: "RootUpdated",
|
||||
type: "event",
|
||||
},
|
||||
{
|
||||
anonymous: false,
|
||||
inputs: [
|
||||
{
|
||||
indexed: false,
|
||||
internalType: "address[]",
|
||||
name: "signers",
|
||||
type: "address[]",
|
||||
},
|
||||
],
|
||||
name: "ValidSignersUpdated",
|
||||
type: "event",
|
||||
},
|
||||
];
|
||||
|
||||
export class EventAndErrors__factory {
|
||||
static readonly abi = _abi;
|
||||
static createInterface(): EventAndErrorsInterface {
|
||||
return new utils.Interface(_abi) as EventAndErrorsInterface;
|
||||
}
|
||||
static connect(
|
||||
address: string,
|
||||
signerOrProvider: Signer | Provider
|
||||
): EventAndErrors {
|
||||
return new Contract(address, _abi, signerOrProvider) as EventAndErrors;
|
||||
}
|
||||
}
|
||||
@@ -1,155 +0,0 @@
|
||||
/* 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 { Reputation, ReputationInterface } from "../Reputation";
|
||||
|
||||
const _abi = [
|
||||
{
|
||||
inputs: [],
|
||||
stateMutability: "nonpayable",
|
||||
type: "constructor",
|
||||
},
|
||||
{
|
||||
anonymous: false,
|
||||
inputs: [
|
||||
{
|
||||
indexed: true,
|
||||
internalType: "address",
|
||||
name: "user",
|
||||
type: "address",
|
||||
},
|
||||
{
|
||||
indexed: true,
|
||||
internalType: "address",
|
||||
name: "newOwner",
|
||||
type: "address",
|
||||
},
|
||||
],
|
||||
name: "OwnerUpdated",
|
||||
type: "event",
|
||||
},
|
||||
{
|
||||
inputs: [
|
||||
{
|
||||
internalType: "uint256",
|
||||
name: "_userCredit",
|
||||
type: "uint256",
|
||||
},
|
||||
],
|
||||
name: "limiter",
|
||||
outputs: [
|
||||
{
|
||||
internalType: "uint256",
|
||||
name: "_spendLimit",
|
||||
type: "uint256",
|
||||
},
|
||||
],
|
||||
stateMutability: "pure",
|
||||
type: "function",
|
||||
},
|
||||
{
|
||||
inputs: [],
|
||||
name: "magicValue",
|
||||
outputs: [
|
||||
{
|
||||
internalType: "uint256",
|
||||
name: "",
|
||||
type: "uint256",
|
||||
},
|
||||
],
|
||||
stateMutability: "view",
|
||||
type: "function",
|
||||
},
|
||||
{
|
||||
inputs: [],
|
||||
name: "maxLimit",
|
||||
outputs: [
|
||||
{
|
||||
internalType: "uint256",
|
||||
name: "",
|
||||
type: "uint256",
|
||||
},
|
||||
],
|
||||
stateMutability: "view",
|
||||
type: "function",
|
||||
},
|
||||
{
|
||||
inputs: [],
|
||||
name: "owner",
|
||||
outputs: [
|
||||
{
|
||||
internalType: "address",
|
||||
name: "",
|
||||
type: "address",
|
||||
},
|
||||
],
|
||||
stateMutability: "view",
|
||||
type: "function",
|
||||
},
|
||||
{
|
||||
inputs: [
|
||||
{
|
||||
internalType: "address",
|
||||
name: "newOwner",
|
||||
type: "address",
|
||||
},
|
||||
],
|
||||
name: "setOwner",
|
||||
outputs: [],
|
||||
stateMutability: "nonpayable",
|
||||
type: "function",
|
||||
},
|
||||
];
|
||||
|
||||
const _bytecode =
|
||||
"0x608060405234801561001057600080fd5b50600080546001600160a01b031916339081178255604051909182917f8292fce18fa69edf4db7b94ea2e58241df0ae57f97e0a6c9b29067028bf92d76908290a350610416806100616000396000f3fe608060405234801561001057600080fd5b50600436106100675760003560e01c80634d2b1791116100505780634d2b17911461009e5780638da5cb5b146100b1578063a4b34557146100f657600080fd5b806313af40351461006c5780631a861d2614610081575b600080fd5b61007f61007a3660046102f4565b610102565b005b61008b620f424081565b6040519081526020015b60405180910390f35b61008b6100ac366004610331565b6101f7565b6000546100d19073ffffffffffffffffffffffffffffffffffffffff1681565b60405173ffffffffffffffffffffffffffffffffffffffff9091168152602001610095565b61008b643a3529440081565b60005473ffffffffffffffffffffffffffffffffffffffff163314610187576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600c60248201527f554e415554484f52495a45440000000000000000000000000000000000000000604482015260640160405180910390fd5b600080547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff83169081178255604051909133917f8292fce18fa69edf4db7b94ea2e58241df0ae57f97e0a6c9b29067028bf92d769190a350565b600061021a6102068380610379565b61021590643a352944006103b6565b610242565b61022783620f4240610379565b61023191906103ce565b61023c9060016103b6565b92915050565b60b5817101000000000000000000000000000000000081106102695760409190911b9060801c5b690100000000000000000081106102855760209190911b9060401c5b65010000000000811061029d5760109190911b9060201c5b630100000081106102b35760089190911b9060101c5b62010000010260121c80820401600190811c80830401811c80830401811c80830401811c80830401811c80830401811c80830401901c908190048111900390565b60006020828403121561030657600080fd5b813573ffffffffffffffffffffffffffffffffffffffff8116811461032a57600080fd5b9392505050565b60006020828403121561034357600080fd5b5035919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b6000817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff04831182151516156103b1576103b161034a565b500290565b600082198211156103c9576103c961034a565b500190565b600082610404577f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b50049056fea164736f6c6343000809000a";
|
||||
|
||||
type ReputationConstructorParams =
|
||||
| [signer?: Signer]
|
||||
| ConstructorParameters<typeof ContractFactory>;
|
||||
|
||||
const isSuperArgs = (
|
||||
xs: ReputationConstructorParams
|
||||
): xs is ConstructorParameters<typeof ContractFactory> => xs.length > 1;
|
||||
|
||||
export class Reputation__factory extends ContractFactory {
|
||||
constructor(...args: ReputationConstructorParams) {
|
||||
if (isSuperArgs(args)) {
|
||||
super(...args);
|
||||
} else {
|
||||
super(_abi, _bytecode, args[0]);
|
||||
}
|
||||
}
|
||||
|
||||
override deploy(
|
||||
overrides?: Overrides & { from?: PromiseOrValue<string> }
|
||||
): Promise<Reputation> {
|
||||
return super.deploy(overrides || {}) as Promise<Reputation>;
|
||||
}
|
||||
override getDeployTransaction(
|
||||
overrides?: Overrides & { from?: PromiseOrValue<string> }
|
||||
): TransactionRequest {
|
||||
return super.getDeployTransaction(overrides || {});
|
||||
}
|
||||
override attach(address: string): Reputation {
|
||||
return super.attach(address) as Reputation;
|
||||
}
|
||||
override connect(signer: Signer): Reputation__factory {
|
||||
return super.connect(signer) as Reputation__factory;
|
||||
}
|
||||
|
||||
static readonly bytecode = _bytecode;
|
||||
static readonly abi = _abi;
|
||||
static createInterface(): ReputationInterface {
|
||||
return new utils.Interface(_abi) as ReputationInterface;
|
||||
}
|
||||
static connect(
|
||||
address: string,
|
||||
signerOrProvider: Signer | Provider
|
||||
): Reputation {
|
||||
return new Contract(address, _abi, signerOrProvider) as Reputation;
|
||||
}
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
/* Autogenerated file. Do not edit manually. */
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
export * as lib from "./lib";
|
||||
export * as p2PixSol from "./p2pix.sol";
|
||||
export { EventAndErrors__factory } from "./EventAndErrors__factory";
|
||||
export { Reputation__factory } from "./Reputation__factory";
|
||||
@@ -1,65 +0,0 @@
|
||||
/* Autogenerated file. Do not edit manually. */
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
|
||||
import { Contract, Signer, utils } from "ethers";
|
||||
import type { Provider } from "@ethersproject/providers";
|
||||
import type { Owned, OwnedInterface } from "../../../lib/auth/Owned";
|
||||
|
||||
const _abi = [
|
||||
{
|
||||
anonymous: false,
|
||||
inputs: [
|
||||
{
|
||||
indexed: true,
|
||||
internalType: "address",
|
||||
name: "user",
|
||||
type: "address",
|
||||
},
|
||||
{
|
||||
indexed: true,
|
||||
internalType: "address",
|
||||
name: "newOwner",
|
||||
type: "address",
|
||||
},
|
||||
],
|
||||
name: "OwnerUpdated",
|
||||
type: "event",
|
||||
},
|
||||
{
|
||||
inputs: [],
|
||||
name: "owner",
|
||||
outputs: [
|
||||
{
|
||||
internalType: "address",
|
||||
name: "",
|
||||
type: "address",
|
||||
},
|
||||
],
|
||||
stateMutability: "view",
|
||||
type: "function",
|
||||
},
|
||||
{
|
||||
inputs: [
|
||||
{
|
||||
internalType: "address",
|
||||
name: "newOwner",
|
||||
type: "address",
|
||||
},
|
||||
],
|
||||
name: "setOwner",
|
||||
outputs: [],
|
||||
stateMutability: "nonpayable",
|
||||
type: "function",
|
||||
},
|
||||
];
|
||||
|
||||
export class Owned__factory {
|
||||
static readonly abi = _abi;
|
||||
static createInterface(): OwnedInterface {
|
||||
return new utils.Interface(_abi) as OwnedInterface;
|
||||
}
|
||||
static connect(address: string, signerOrProvider: Signer | Provider): Owned {
|
||||
return new Contract(address, _abi, signerOrProvider) as Owned;
|
||||
}
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
/* Autogenerated file. Do not edit manually. */
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
export { Owned__factory } from "./Owned__factory";
|
||||
@@ -1,8 +0,0 @@
|
||||
/* Autogenerated file. Do not edit manually. */
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
export * as auth from "./auth";
|
||||
export * as interfaces from "./interfaces";
|
||||
export * as mock from "./mock";
|
||||
export * as tokens from "./tokens";
|
||||
export * as utils from "./utils";
|
||||
@@ -1,45 +0,0 @@
|
||||
/* Autogenerated file. Do not edit manually. */
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
|
||||
import { Contract, Signer, utils } from "ethers";
|
||||
import type { Provider } from "@ethersproject/providers";
|
||||
import type {
|
||||
IReputation,
|
||||
IReputationInterface,
|
||||
} from "../../../lib/interfaces/IReputation";
|
||||
|
||||
const _abi = [
|
||||
{
|
||||
inputs: [
|
||||
{
|
||||
internalType: "uint256",
|
||||
name: "_userCredit",
|
||||
type: "uint256",
|
||||
},
|
||||
],
|
||||
name: "limiter",
|
||||
outputs: [
|
||||
{
|
||||
internalType: "uint256",
|
||||
name: "_spendLimit",
|
||||
type: "uint256",
|
||||
},
|
||||
],
|
||||
stateMutability: "pure",
|
||||
type: "function",
|
||||
},
|
||||
];
|
||||
|
||||
export class IReputation__factory {
|
||||
static readonly abi = _abi;
|
||||
static createInterface(): IReputationInterface {
|
||||
return new utils.Interface(_abi) as IReputationInterface;
|
||||
}
|
||||
static connect(
|
||||
address: string,
|
||||
signerOrProvider: Signer | Provider
|
||||
): IReputation {
|
||||
return new Contract(address, _abi, signerOrProvider) as IReputation;
|
||||
}
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
/* Autogenerated file. Do not edit manually. */
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
export { IReputation__factory } from "./IReputation__factory";
|
||||
@@ -1,4 +0,0 @@
|
||||
/* Autogenerated file. Do not edit manually. */
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
export * as mockTokenSol from "./mockToken.sol";
|
||||
File diff suppressed because one or more lines are too long
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user