Compare commits
4 Commits
dev
...
4c8eb63c38
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4c8eb63c38 | ||
|
|
8adccd2739 | ||
|
|
e2ae92563e | ||
|
|
a3fd8bee16 |
2
.commitlintrc.yaml
Normal file
2
.commitlintrc.yaml
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
extends:
|
||||||
|
- "@commitlint/config-conventional"
|
||||||
1
.husky/.gitignore
vendored
Normal file
1
.husky/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
_
|
||||||
4
.husky/commit-msg
Executable file
4
.husky/commit-msg
Executable file
@@ -0,0 +1,4 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
. "$(dirname "$0")/_/husky.sh"
|
||||||
|
|
||||||
|
yarn dlx commitlint --edit $1
|
||||||
4
.husky/pre-commit
Executable file
4
.husky/pre-commit
Executable file
@@ -0,0 +1,4 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
. "$(dirname "$0")/_/husky.sh"
|
||||||
|
|
||||||
|
yarn dlx lint-staged
|
||||||
546
.yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs
vendored
Normal file
546
.yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs
vendored
Normal file
File diff suppressed because one or more lines are too long
786
.yarn/releases/yarn-3.2.1.cjs
vendored
Executable file
786
.yarn/releases/yarn-3.2.1.cjs
vendored
Executable file
File diff suppressed because one or more lines are too long
942
.yarn/releases/yarn-4.9.2.cjs
vendored
942
.yarn/releases/yarn-4.9.2.cjs
vendored
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
|
nodeLinker: node-modules
|
||||||
|
|
||||||
yarnPath: .yarn/releases/yarn-4.9.2.cjs
|
plugins:
|
||||||
|
- path: .yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs
|
||||||
|
spec: "@yarnpkg/plugin-interactive-tools"
|
||||||
|
|
||||||
|
yarnPath: .yarn/releases/yarn-3.2.1.cjs
|
||||||
|
|||||||
4
artifacts/contracts/p2pix.sol/P2PIX.dbg.json
Normal file
4
artifacts/contracts/p2pix.sol/P2PIX.dbg.json
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
{
|
||||||
|
"_format": "hh-sol-dbg-1",
|
||||||
|
"buildInfo": "../../build-info/eceac9979aa58fac0d83cf0060ae7a91.json"
|
||||||
|
}
|
||||||
1134
artifacts/contracts/p2pix.sol/P2PIX.json
Normal file
1134
artifacts/contracts/p2pix.sol/P2PIX.json
Normal file
File diff suppressed because one or more lines are too long
@@ -1,5 +1,5 @@
|
|||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
pragma solidity ^0.8.19;
|
pragma solidity 0.8.19;
|
||||||
|
|
||||||
import { IReputation } from "./lib/interfaces/IReputation.sol";
|
import { IReputation } from "./lib/interfaces/IReputation.sol";
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
pragma solidity ^0.8.19;
|
pragma solidity 0.8.19;
|
||||||
|
|
||||||
import { ERC20, OwnerSettings } from "contracts/core/OwnerSettings.sol";
|
import { ERC20, OwnerSettings } from "contracts/core/OwnerSettings.sol";
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
pragma solidity ^0.8.19;
|
pragma solidity 0.8.19;
|
||||||
|
|
||||||
abstract contract Constants {
|
abstract contract Constants {
|
||||||
/// ███ Constants ██████████████████████████████████████████████████████████
|
/// ███ Constants ██████████████████████████████████████████████████████████
|
||||||
|
|||||||
@@ -1,9 +1,30 @@
|
|||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
pragma solidity ^0.8.19;
|
pragma solidity 0.8.19;
|
||||||
|
|
||||||
import { ERC20 } from "contracts/lib/tokens/ERC20.sol";
|
import { ERC20 } from "contracts/lib/tokens/ERC20.sol";
|
||||||
|
|
||||||
library DataTypes {
|
library DataTypes {
|
||||||
|
struct DepositArgs {
|
||||||
|
string pixTarget;
|
||||||
|
bytes32 allowlistRoot;
|
||||||
|
ERC20 token;
|
||||||
|
uint96 amount;
|
||||||
|
bool valid;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct LockArgs {
|
||||||
|
address seller;
|
||||||
|
ERC20 token;
|
||||||
|
uint80 amount;
|
||||||
|
bytes32[] merkleProof;
|
||||||
|
uint256[] expiredLocks;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct ReleaseArgs {
|
||||||
|
uint256 lockID;
|
||||||
|
bytes32 pixTimestamp;
|
||||||
|
bytes signature;
|
||||||
|
}
|
||||||
|
|
||||||
struct Lock {
|
struct Lock {
|
||||||
uint256 counter;
|
uint256 counter;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
pragma solidity ^0.8.19;
|
pragma solidity 0.8.19;
|
||||||
|
|
||||||
import { ERC20 } from "contracts/lib/tokens/ERC20.sol";
|
import { ERC20 } from "contracts/lib/tokens/ERC20.sol";
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
pragma solidity ^0.8.19;
|
pragma solidity 0.8.19;
|
||||||
|
|
||||||
import { ERC2771Context as ERC2771 } from "contracts/lib/metatx/ERC2771Context.sol";
|
import { ERC2771Context as ERC2771 } from "contracts/lib/metatx/ERC2771Context.sol";
|
||||||
import { ERC20, SafeTransferLib } from "contracts/lib/utils/SafeTransferLib.sol";
|
import { ERC20, SafeTransferLib } from "contracts/lib/utils/SafeTransferLib.sol";
|
||||||
@@ -67,7 +67,7 @@ abstract contract OwnerSettings is
|
|||||||
sLoc := add(sLoc, 0x20)
|
sLoc := add(sLoc, 0x20)
|
||||||
} {
|
} {
|
||||||
// cache hashmap entry in scratch space
|
// cache hashmap entry in scratch space
|
||||||
mstore(0x20, trustedForwarders.slot)
|
mstore(0x20, isTrustedForwarder.slot)
|
||||||
mstore(0x00, mload(fLoc))
|
mstore(0x00, mload(fLoc))
|
||||||
// let mapSlot := keccak256(0x00, 0x40)
|
// let mapSlot := keccak256(0x00, 0x40)
|
||||||
sstore(keccak256(0x00, 0x40), mload(sLoc))
|
sstore(keccak256(0x00, 0x40), mload(sLoc))
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ abstract contract Context {
|
|||||||
/// @dev Context variant with ERC2771 support.
|
/// @dev Context variant with ERC2771 support.
|
||||||
abstract contract ERC2771Context is Context {
|
abstract contract ERC2771Context is Context {
|
||||||
// address private immutable _trustedForwarder;
|
// address private immutable _trustedForwarder;
|
||||||
mapping(address => bool) public trustedForwarders;
|
mapping(address => bool) public isTrustedForwarder;
|
||||||
|
|
||||||
/// @custom:oz-upgrades-unsafe-allow constructor
|
/// @custom:oz-upgrades-unsafe-allow constructor
|
||||||
// constructor(address trustedForwarder) {
|
// constructor(address trustedForwarder) {
|
||||||
@@ -53,7 +53,7 @@ abstract contract ERC2771Context is Context {
|
|||||||
override
|
override
|
||||||
returns (address sender)
|
returns (address sender)
|
||||||
{
|
{
|
||||||
if (trustedForwarders[msg.sender]) {
|
if (isTrustedForwarder[msg.sender]) {
|
||||||
// The assembly code is more direct than the Solidity version using `abi.decode`.
|
// The assembly code is more direct than the Solidity version using `abi.decode`.
|
||||||
/// @solidity memory-safe-assembly
|
/// @solidity memory-safe-assembly
|
||||||
assembly {
|
assembly {
|
||||||
@@ -67,8 +67,15 @@ abstract contract ERC2771Context is Context {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function isTrustedForwarder(address forwarder) public view virtual returns (bool) {
|
function _isTrustedForwarder()
|
||||||
return trustedForwarders[forwarder];
|
internal
|
||||||
|
view
|
||||||
|
returns (address _sender, uint256 _forwarder)
|
||||||
|
{
|
||||||
|
_sender = _msgSender();
|
||||||
|
_forwarder = (_sender != msg.sender)
|
||||||
|
? uint256(1)
|
||||||
|
: uint256(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
function _msgData()
|
function _msgData()
|
||||||
@@ -78,7 +85,7 @@ abstract contract ERC2771Context is Context {
|
|||||||
override
|
override
|
||||||
returns (bytes calldata)
|
returns (bytes calldata)
|
||||||
{
|
{
|
||||||
if (isTrustedForwarder(msg.sender)) {
|
if (isTrustedForwarder[msg.sender]) {
|
||||||
return msg.data[:msg.data.length - 20];
|
return msg.data[:msg.data.length - 20];
|
||||||
} else {
|
} else {
|
||||||
return super._msgData();
|
return super._msgData();
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
pragma solidity ^0.8.19;
|
pragma solidity 0.8.19;
|
||||||
|
|
||||||
import { ERC20 } from "../tokens/ERC20.sol";
|
import { ERC20 } from "../tokens/ERC20.sol";
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
pragma solidity ^0.8.19;
|
pragma solidity 0.8.19;
|
||||||
|
|
||||||
/// ______ __
|
/// ______ __
|
||||||
/// .-----.|__ |.-----.|__|.--.--.
|
/// .-----.|__ |.-----.|__|.--.--.
|
||||||
@@ -18,9 +18,14 @@ contract P2PIX is BaseUtils {
|
|||||||
// solhint-disable no-inline-assembly
|
// solhint-disable no-inline-assembly
|
||||||
// solhint-disable no-empty-blocks
|
// solhint-disable no-empty-blocks
|
||||||
|
|
||||||
|
using DT for DT.DepositArgs;
|
||||||
|
using DT for DT.LockArgs;
|
||||||
|
using DT for DT.ReleaseArgs;
|
||||||
using DT for DT.Lock;
|
using DT for DT.Lock;
|
||||||
using DT for DT.LockStatus;
|
using DT for DT.LockStatus;
|
||||||
|
|
||||||
|
/// ███ Storage ████████████████████████████████████████████████████████████
|
||||||
|
|
||||||
uint256 public lockCounter;
|
uint256 public lockCounter;
|
||||||
|
|
||||||
/// @dev List of Locks.
|
/// @dev List of Locks.
|
||||||
@@ -28,6 +33,8 @@ contract P2PIX is BaseUtils {
|
|||||||
/// @dev Stores an relayer's last computed credit.
|
/// @dev Stores an relayer's last computed credit.
|
||||||
mapping(uint256 => uint256) public userRecord;
|
mapping(uint256 => uint256) public userRecord;
|
||||||
|
|
||||||
|
/// ███ Constructor ████████████████████████████████████████████████████████
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
uint256 defaultBlocks,
|
uint256 defaultBlocks,
|
||||||
address[] memory validSigners,
|
address[] memory validSigners,
|
||||||
@@ -44,58 +51,60 @@ contract P2PIX is BaseUtils {
|
|||||||
)
|
)
|
||||||
payable {/* */}
|
payable {/* */}
|
||||||
|
|
||||||
|
/// ███ Public FX ██████████████████████████████████████████████████████████
|
||||||
|
|
||||||
/// @notice Creates a deposit order based on a seller's
|
/// @notice Creates a deposit order based on a seller's
|
||||||
/// offer of an amount of ERC20 tokens.
|
/// offer of an amount of ERC20 tokens.
|
||||||
/// @notice Seller needs to send his tokens to the P2PIX smart contract.
|
/// @dev Seller needs to send his tokens to the P2PIX smart contract.
|
||||||
/// @param pixTarget Pix key destination provided by the offer's seller.
|
/* /// @param _pixTarget Pix key destination provided by the offer's seller. */
|
||||||
/// @param allowlistRoot Optional allow list merkleRoot update `bytes32` value.
|
/* /// @param allowlistRoot Optional allow list merkleRoot update `bytes32` value. */
|
||||||
/// as the deposit identifier.
|
/* /// as the deposit identifier. */
|
||||||
/// @dev Function sighash: 0x5e918943
|
/// @dev Function sighash: 0xbfe07da6.
|
||||||
function deposit(
|
function deposit(
|
||||||
string calldata pixTarget,
|
DT.DepositArgs calldata args
|
||||||
bytes32 allowlistRoot,
|
) public {
|
||||||
ERC20 token,
|
|
||||||
uint96 amount,
|
|
||||||
bool valid
|
|
||||||
) public nonReentrant {
|
|
||||||
|
|
||||||
if (bytes(pixTarget).length == 0) revert EmptyPixTarget();
|
if (bytes(args.pixTarget).length == 0) revert EmptyPixTarget();
|
||||||
if (!allowedERC20s(token)) revert TokenDenied();
|
if (!allowedERC20s(args.token)) revert TokenDenied();
|
||||||
uint256 _sellerBalance = __sellerBalance(msg.sender, token);
|
uint256 _sellerBalance = __sellerBalance(msg.sender, args.token);
|
||||||
|
|
||||||
uint256 currBal = _sellerBalance & BITMASK_SB_ENTRY;
|
uint256 currBal = _sellerBalance & BITMASK_SB_ENTRY;
|
||||||
uint256 _newBal = uint256(currBal + amount);
|
uint256 _newBal = uint256(currBal + args.amount);
|
||||||
if (_newBal > MAXBALANCE_UPPERBOUND)
|
if (_newBal > MAXBALANCE_UPPERBOUND)
|
||||||
revert MaxBalExceeded();
|
revert MaxBalExceeded();
|
||||||
|
|
||||||
if (allowlistRoot != 0) {
|
setReentrancyGuard();
|
||||||
setRoot(msg.sender, allowlistRoot);
|
|
||||||
|
if (args.allowlistRoot != 0) {
|
||||||
|
setRoot(msg.sender, args.allowlistRoot);
|
||||||
}
|
}
|
||||||
|
|
||||||
bytes32 pixTargetCasted = getStr(pixTarget);
|
bytes32 pixTargetCasted = getStr(args.pixTarget);
|
||||||
uint256 validCasted = _castBool(valid);
|
uint256 validCasted = _castBool(args.valid);
|
||||||
|
|
||||||
_setSellerBalance(
|
_setSellerBalance(
|
||||||
msg.sender,
|
msg.sender,
|
||||||
token,
|
args.token,
|
||||||
(_newBal | (validCasted << BITPOS_VALID)),
|
(_newBal | (validCasted << BITPOS_VALID)),
|
||||||
pixTargetCasted
|
pixTargetCasted
|
||||||
);
|
);
|
||||||
|
|
||||||
SafeTransferLib.safeTransferFrom(
|
SafeTransferLib.safeTransferFrom(
|
||||||
token,
|
args.token,
|
||||||
msg.sender,
|
msg.sender,
|
||||||
address(this),
|
address(this),
|
||||||
amount
|
args.amount
|
||||||
);
|
);
|
||||||
|
|
||||||
emit DepositAdded(msg.sender, token, amount);
|
clearReentrancyGuard();
|
||||||
|
|
||||||
|
emit DepositAdded(msg.sender, args.token, args.amount);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @notice Enables seller to invalidate future
|
/// @notice Enables seller to invalidate future
|
||||||
/// locks made to his/her token offering order.
|
/// locks made to his/her token offering order.
|
||||||
/// @notice This function does not affect any ongoing active locks.
|
/// @dev This function does not affect any ongoing active locks.
|
||||||
/// @dev Function sighash: 0x6d82d9e0
|
/// @dev Function sighash: 0x72fada5c.
|
||||||
function setValidState(ERC20 token, bool state) public {
|
function setValidState(ERC20 token, bool state) public {
|
||||||
uint256 _sellerBalance = __sellerBalance(msg.sender, token);
|
uint256 _sellerBalance = __sellerBalance(msg.sender, token);
|
||||||
|
|
||||||
@@ -114,35 +123,32 @@ contract P2PIX is BaseUtils {
|
|||||||
|
|
||||||
/// @notice Public method designed to lock an remaining amount of
|
/// @notice Public method designed to lock an remaining amount of
|
||||||
/// the deposit order of a seller.
|
/// the deposit order of a seller.
|
||||||
/// @notice Transaction forwarding must leave `merkleProof` empty;
|
/// @dev Transaction forwarding must leave `merkleProof` empty;
|
||||||
/// otherwise, the trustedForwarder must be previously added
|
/// otherwise, the trustedForwarder must be previously added
|
||||||
/// to a seller whitelist.
|
/// to a seller whitelist.
|
||||||
/// @notice This method can be performed either by:
|
/// @dev This method can be performed either by:
|
||||||
/// - An user allowed via the seller's allowlist;
|
/// - An user allowed via the seller's allowlist;
|
||||||
/// - An user with enough userRecord to lock the wished amount;
|
/// - An user with enough userRecord to lock the wished amount;
|
||||||
/// @notice There can only exist a lock per each `amount` partitioned
|
/// @dev There can only exist a lock per each `_amount` partitioned
|
||||||
/// from the total `remaining` value.
|
/// from the total `remaining` value.
|
||||||
/// @notice Locks can only be performed in valid orders.
|
/// @dev Locks can only be performed in valid orders.
|
||||||
/// @param amount The deposit's remaining amount wished to be locked.
|
/* /// @param _amount The deposit's remaining amount wished to be locked. */
|
||||||
/// @param merkleProof Provided as a pass if the `msg.sender` is in the
|
/* /// @param merkleProof This value should be: */
|
||||||
/// seller's allowlist; Left empty otherwise;
|
/* /// - Provided as a pass if the `msg.sender` is in the seller's allowlist; */
|
||||||
/// @param expiredLocks An array of identifiers to be
|
/* /// - Left empty otherwise; */
|
||||||
/// provided so to unexpire locks using this transaction gas push.
|
/* /// @param expiredLocks An array of `bytes32` identifiers to be */
|
||||||
/// @return lockID The lock identifier.
|
/* /// provided so to unexpire locks using this transaction gas push. */
|
||||||
/// @dev Function sighash: 0xdc43221c
|
/// @return lockID The `bytes32` value returned as the lock identifier.
|
||||||
|
/// @dev Function sighash: 0x03aaf306.
|
||||||
function lock(
|
function lock(
|
||||||
address seller,
|
DT.LockArgs calldata args
|
||||||
ERC20 token,
|
|
||||||
uint80 amount,
|
|
||||||
bytes32[] calldata merkleProof,
|
|
||||||
uint256[] calldata expiredLocks
|
|
||||||
) public nonReentrant returns (uint256 lockID) {
|
) public nonReentrant returns (uint256 lockID) {
|
||||||
unlockExpired(expiredLocks);
|
unlockExpired(args.expiredLocks);
|
||||||
|
|
||||||
if (!getValid(seller, token)) revert InvalidDeposit();
|
if (!getValid(args.seller, args.token)) revert InvalidDeposit();
|
||||||
|
|
||||||
uint256 bal = getBalance(seller, token);
|
uint256 bal = getBalance(args.seller, args.token);
|
||||||
if (bal < amount) revert NotEnoughTokens();
|
if (bal < args.amount) revert NotEnoughTokens();
|
||||||
|
|
||||||
unchecked {
|
unchecked {
|
||||||
lockID = ++lockCounter;
|
lockID = ++lockCounter;
|
||||||
@@ -152,22 +158,24 @@ contract P2PIX is BaseUtils {
|
|||||||
mapLocks[lockID].expirationBlock >= block.number
|
mapLocks[lockID].expirationBlock >= block.number
|
||||||
) revert NotExpired();
|
) revert NotExpired();
|
||||||
|
|
||||||
bytes32 _pixTarget = getPixTarget(seller, token);
|
address sender; uint256 forwarder;
|
||||||
|
(sender, forwarder) = _isTrustedForwarder();
|
||||||
|
bytes32 _pixTarget = getPixTarget(args.seller, args.token);
|
||||||
|
|
||||||
// transaction forwarding must leave `merkleProof` empty;
|
// transaction forwarding must leave `merkleProof` empty;
|
||||||
// otherwise, the trustedForwarder must be previously added
|
// otherwise, the trustedForwarder must be previously added
|
||||||
// to a seller whitelist.
|
// to a seller whitelist.
|
||||||
if (merkleProof.length != 0) {
|
if (args.merkleProof.length != 0) {
|
||||||
_merkleVerify( merkleProof, sellerAllowList(seller), _msgSender());
|
_merkleVerify( args.merkleProof, sellerAllowList(args.seller), sender);
|
||||||
|
|
||||||
} else if ( amount > REPUTATION_LOWERBOUND && msg.sender == _msgSender() ) {
|
} else if (args.amount > REPUTATION_LOWERBOUND && forwarder == 0) {
|
||||||
|
|
||||||
uint256 spendLimit; uint256 userCredit =
|
uint256 spendLimit; uint256 userCredit =
|
||||||
userRecord[_castAddrToKey(_msgSender())];
|
userRecord[_castAddrToKey(msg.sender)];
|
||||||
(spendLimit) = _limiter(userCredit / WAD);
|
(spendLimit) = _limiter(userCredit / WAD);
|
||||||
if (
|
if (
|
||||||
amount > (spendLimit * WAD) ||
|
args.amount > (spendLimit * WAD) ||
|
||||||
amount > LOCKAMOUNT_UPPERBOUND
|
args.amount > LOCKAMOUNT_UPPERBOUND
|
||||||
) revert AmountNotAllowed();
|
) revert AmountNotAllowed();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -175,33 +183,31 @@ contract P2PIX is BaseUtils {
|
|||||||
lockID,
|
lockID,
|
||||||
(block.number + defaultLockBlocks),
|
(block.number + defaultLockBlocks),
|
||||||
_pixTarget,
|
_pixTarget,
|
||||||
amount,
|
args.amount,
|
||||||
token,
|
args.token,
|
||||||
_msgSender(),
|
sender,
|
||||||
seller
|
args.seller
|
||||||
);
|
);
|
||||||
|
|
||||||
_addLock(bal, l);
|
lockID = _addLock(bal, l);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @notice Lock release method that liquidate lock
|
/// @notice Lock release method that liquidate lock
|
||||||
/// orders and distributes relayer fees.
|
/// orders and distributes relayer fees.
|
||||||
/// @notice This method can be called by any public actor
|
/// @dev This method can be called by any public actor
|
||||||
/// as long the signature provided is valid.
|
/// as long the signature provided is valid.
|
||||||
/// @notice `relayerPremium` gets splitted equaly
|
/// @dev `relayerPremium` gets splitted equaly
|
||||||
/// if relayer addresses differ.
|
/// if relayer addresses differ.
|
||||||
/// @notice If the `msg.sender` of this method and `l.relayerAddress` are the same,
|
/// @dev If the `msg.sender` of this method and `l.relayerAddress` are the same,
|
||||||
/// `msg.sender` accrues both l.amount and l.relayerPremium as userRecord credit.
|
/// `msg.sender` accrues both l.amount and l.relayerPremium as userRecord credit.
|
||||||
/// In case of they differing:
|
/// In case of they differing:
|
||||||
/// - `lock` caller gets accrued with `l.amount` as userRecord credit;
|
/// - `lock` caller gets accrued with `l.amount` as userRecord credit;
|
||||||
/// - `release` caller gets accrued with `l.relayerPremium` as userRecord credit;
|
/// - `release` caller gets accrued with `l.relayerPremium` as userRecord credit;
|
||||||
/// @dev Function sighash: 0x11fc7f9a
|
/// @dev Function sighash: 0x4e1389ed.
|
||||||
function release(
|
function release(
|
||||||
uint256 lockID,
|
DT.ReleaseArgs calldata args
|
||||||
bytes32 pixTimestamp,
|
|
||||||
bytes calldata signature
|
|
||||||
) public nonReentrant {
|
) public nonReentrant {
|
||||||
DT.Lock storage l = mapLocks[lockID];
|
DT.Lock storage l = mapLocks[args.lockID];
|
||||||
|
|
||||||
if (l.amount == 0) revert AlreadyReleased();
|
if (l.amount == 0) revert AlreadyReleased();
|
||||||
if (l.expirationBlock < block.number)
|
if (l.expirationBlock < block.number)
|
||||||
@@ -211,11 +217,11 @@ contract P2PIX is BaseUtils {
|
|||||||
abi.encodePacked(
|
abi.encodePacked(
|
||||||
l.pixTarget,
|
l.pixTarget,
|
||||||
l.amount,
|
l.amount,
|
||||||
pixTimestamp
|
args.pixTimestamp
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
_signerCheck(message, signature);
|
_signerCheck(message, args.signature);
|
||||||
|
|
||||||
ERC20 t = ERC20(l.token);
|
ERC20 t = ERC20(l.token);
|
||||||
|
|
||||||
@@ -226,7 +232,10 @@ contract P2PIX is BaseUtils {
|
|||||||
l.expirationBlock = 0;
|
l.expirationBlock = 0;
|
||||||
_setUsedTransactions(message);
|
_setUsedTransactions(message);
|
||||||
|
|
||||||
if (_msgSender() == msg.sender) {
|
address sender; uint256 forwarder;
|
||||||
|
(sender, forwarder) = _isTrustedForwarder();
|
||||||
|
|
||||||
|
if (forwarder == 0) {
|
||||||
if (msg.sender != l.buyerAddress) {
|
if (msg.sender != l.buyerAddress) {
|
||||||
userRecord[_castAddrToKey(msg.sender)] += (lockAmount >> 1);
|
userRecord[_castAddrToKey(msg.sender)] += (lockAmount >> 1);
|
||||||
userRecord[_castAddrToKey(l.buyerAddress)] += (lockAmount >> 1);
|
userRecord[_castAddrToKey(l.buyerAddress)] += (lockAmount >> 1);
|
||||||
@@ -240,15 +249,15 @@ contract P2PIX is BaseUtils {
|
|||||||
lockAmount
|
lockAmount
|
||||||
);
|
);
|
||||||
|
|
||||||
emit LockReleased(l.buyerAddress, lockID, lockAmount);
|
emit LockReleased(l.buyerAddress, args.lockID, lockAmount);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @notice Unlocks expired locks.
|
/// @notice Unlocks expired locks.
|
||||||
/// @notice Triggered in the callgraph by both `lock` and `withdraw` functions.
|
/// @dev Triggered in the callgraph by both `lock` and `withdraw` functions.
|
||||||
/// @notice This method can also have any public actor as its `tx.origin`.
|
/// @dev This method can also have any public actor as its `tx.origin`.
|
||||||
/// @notice For each successfull unexpired lock recovered,
|
/// @dev For each successfull unexpired lock recovered,
|
||||||
/// `userRecord[_castAddrToKey(l.relayerAddress)]` is decreased by half of its value.
|
/// `userRecord[_castAddrToKey(l.relayerAddress)]` is decreased by half of its value.
|
||||||
/// @dev Function sighash: 0xb0983d39
|
/// @dev Function sighash: 0x8e2749d6.
|
||||||
function unlockExpired(uint256[] calldata lockIDs)
|
function unlockExpired(uint256[] calldata lockIDs)
|
||||||
public
|
public
|
||||||
{
|
{
|
||||||
@@ -298,9 +307,9 @@ contract P2PIX is BaseUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// @notice Seller's expired deposit fund sweeper.
|
/// @notice Seller's expired deposit fund sweeper.
|
||||||
/// @notice A seller may use this method to recover
|
/// @dev A seller may use this method to recover
|
||||||
/// tokens from expired deposits.
|
/// tokens from expired deposits.
|
||||||
/// @dev Function sighash: 0xfb8c5ef0
|
/// @dev Function sighash: 0x36317972.
|
||||||
function withdraw(
|
function withdraw(
|
||||||
ERC20 token,
|
ERC20 token,
|
||||||
uint256 amount,
|
uint256 amount,
|
||||||
@@ -358,12 +367,15 @@ contract P2PIX is BaseUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// ███ Helper FX ██████████████████████████████████████████████████████████
|
||||||
|
|
||||||
// solhint-disable-next-line no-empty-blocks
|
// solhint-disable-next-line no-empty-blocks
|
||||||
receive() external payable {}
|
receive() external payable {}
|
||||||
|
|
||||||
/// @notice Private view auxiliar logic that reverts
|
/// @notice Private view auxiliar logic that reverts
|
||||||
/// on a not expired lock passed as argument of the function.
|
/// on a not expired lock passed as argument of the function.
|
||||||
/// @dev Called exclusively by the `unlockExpired` method.
|
/// @dev Called exclusively by the `unlockExpired` method.
|
||||||
|
/// @dev Function sighash: 0x74e2a0bb.
|
||||||
function _notExpired(DT.Lock storage _l) private view {
|
function _notExpired(DT.Lock storage _l) private view {
|
||||||
if (_l.expirationBlock > block.number)
|
if (_l.expirationBlock > block.number)
|
||||||
revert NotExpired();
|
revert NotExpired();
|
||||||
@@ -504,7 +516,7 @@ contract P2PIX is BaseUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// @notice External getter that returns the status of a lockIDs array.
|
/// @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 Call will not revert if provided with an empty array as parameter.
|
||||||
/// @dev Function sighash: 0x49ef8448
|
/// @dev Function sighash: 0x49ef8448
|
||||||
function getLocksStatus(uint256[] memory ids)
|
function getLocksStatus(uint256[] memory ids)
|
||||||
external
|
external
|
||||||
|
|||||||
@@ -1,9 +0,0 @@
|
|||||||
{
|
|
||||||
"signers": [
|
|
||||||
"0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266",
|
|
||||||
"0x70997970C51812dc3A010C7d01b50e0d17dc79C8",
|
|
||||||
"0x8963E134E6d22Ee9A26ac62a99964aB391ead816"
|
|
||||||
],
|
|
||||||
"token": "0xfE841c74250e57640390f46d914C88d22C51e82e",
|
|
||||||
"p2pix": "0x57Dcba05980761169508886eEdc6f5E7EC0411Dc"
|
|
||||||
}
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
{
|
|
||||||
"signers": [
|
|
||||||
"0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266",
|
|
||||||
"0x70997970C51812dc3A010C7d01b50e0d17dc79C8"
|
|
||||||
],
|
|
||||||
"p2pix": "0xb7cD135F5eFD9760981e02E2a898790b688939fe",
|
|
||||||
"token": "0x3eBE67A2C7bdB2081CBd34ba3281E90377462289"
|
|
||||||
}
|
|
||||||
1
docs/DataTypes.md
Normal file
1
docs/DataTypes.md
Normal file
@@ -0,0 +1 @@
|
|||||||
|
# DataTypes
|
||||||
264
docs/EventAndErrors.md
Normal file
264
docs/EventAndErrors.md
Normal file
@@ -0,0 +1,264 @@
|
|||||||
|
# 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
Normal file
694
docs/P2PIX.md
Normal file
@@ -0,0 +1,694 @@
|
|||||||
|
# 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,28 +1,6 @@
|
|||||||
# Solidity API
|
# Reputation
|
||||||
|
|
||||||
## Reputation
|
## Methods
|
||||||
|
|
||||||
### 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
|
### limiter
|
||||||
|
|
||||||
@@ -30,12 +8,81 @@ constructor() public payable
|
|||||||
function limiter(uint256 _userCredit) external pure returns (uint256 _spendLimit)
|
function limiter(uint256 _userCredit) external pure returns (uint256 _spendLimit)
|
||||||
```
|
```
|
||||||
|
|
||||||
### sqrt
|
#### Parameters
|
||||||
|
|
||||||
|
| Name | Type | Description |
|
||||||
|
| ------------ | ------- | ----------- |
|
||||||
|
| \_userCredit | uint256 | undefined |
|
||||||
|
|
||||||
|
#### Returns
|
||||||
|
|
||||||
|
| Name | Type | Description |
|
||||||
|
| ------------ | ------- | ----------- |
|
||||||
|
| \_spendLimit | uint256 | undefined |
|
||||||
|
|
||||||
|
### magicValue
|
||||||
|
|
||||||
```solidity
|
```solidity
|
||||||
function sqrt(uint256 x) internal pure returns (uint256 z)
|
function magicValue() external view returns (uint256)
|
||||||
```
|
```
|
||||||
|
|
||||||
Taken from Solmate's FixedPointMathLib.
|
_Denominator's constant operand for the `limiter` fx. _
|
||||||
(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 |
|
||||||
|
|||||||
@@ -1,89 +0,0 @@
|
|||||||
# 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)
|
|
||||||
```
|
|
||||||
|
|
||||||
@@ -1,96 +0,0 @@
|
|||||||
# 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
|
|
||||||
```
|
|
||||||
|
|
||||||
@@ -1,29 +0,0 @@
|
|||||||
# 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
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
@@ -1,278 +0,0 @@
|
|||||||
# 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_
|
|
||||||
|
|
||||||
@@ -1,98 +0,0 @@
|
|||||||
# 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,42 +1,46 @@
|
|||||||
# Solidity API
|
# Owned
|
||||||
|
|
||||||
## Owned
|
_Solmate (https://github.com/Rari-Capital/solmate/blob/main/src/auth/Owned.sol)_
|
||||||
|
|
||||||
Simple single owner authorization mixin.
|
Simple single owner authorization mixin.
|
||||||
|
|
||||||
### Unauthorized
|
## Methods
|
||||||
|
|
||||||
```solidity
|
|
||||||
error Unauthorized()
|
|
||||||
```
|
|
||||||
|
|
||||||
### OwnerUpdated
|
|
||||||
|
|
||||||
```solidity
|
|
||||||
event OwnerUpdated(address user, address newOwner)
|
|
||||||
```
|
|
||||||
|
|
||||||
### owner
|
### owner
|
||||||
|
|
||||||
```solidity
|
```solidity
|
||||||
address owner
|
function owner() external view returns (address)
|
||||||
```
|
```
|
||||||
|
|
||||||
### onlyOwner
|
#### Returns
|
||||||
|
|
||||||
```solidity
|
| Name | Type | Description |
|
||||||
modifier onlyOwner()
|
| ---- | ------- | ----------- |
|
||||||
```
|
| \_0 | address | undefined |
|
||||||
|
|
||||||
### constructor
|
|
||||||
|
|
||||||
```solidity
|
|
||||||
constructor(address _owner) internal
|
|
||||||
```
|
|
||||||
|
|
||||||
### setOwner
|
### setOwner
|
||||||
|
|
||||||
```solidity
|
```solidity
|
||||||
function setOwner(address newOwner) public virtual
|
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 |
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
# Solidity API
|
# IReputation
|
||||||
|
|
||||||
## IReputation
|
## Methods
|
||||||
|
|
||||||
### limiter
|
### limiter
|
||||||
|
|
||||||
@@ -8,3 +8,14 @@
|
|||||||
function limiter(uint256 _userCredit) external pure returns (uint256 _spendLimit)
|
function limiter(uint256 _userCredit) external pure returns (uint256 _spendLimit)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
#### Parameters
|
||||||
|
|
||||||
|
| Name | Type | Description |
|
||||||
|
| ------------ | ------- | ----------- |
|
||||||
|
| \_userCredit | uint256 | undefined |
|
||||||
|
|
||||||
|
#### Returns
|
||||||
|
|
||||||
|
| Name | Type | Description |
|
||||||
|
| ------------ | ------- | ----------- |
|
||||||
|
| \_spendLimit | uint256 | undefined |
|
||||||
|
|||||||
@@ -1,53 +0,0 @@
|
|||||||
# 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)
|
|
||||||
```
|
|
||||||
|
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
# Solidity API
|
|
||||||
|
|
||||||
## MockToken
|
|
||||||
|
|
||||||
### constructor
|
|
||||||
|
|
||||||
```solidity
|
|
||||||
constructor(uint256 supply) public
|
|
||||||
```
|
|
||||||
|
|
||||||
### mint
|
|
||||||
|
|
||||||
```solidity
|
|
||||||
function mint(address[] to, uint256 value) public virtual
|
|
||||||
```
|
|
||||||
|
|
||||||
@@ -1,128 +1,230 @@
|
|||||||
# Solidity API
|
# ERC20
|
||||||
|
|
||||||
## ERC20
|
_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)_
|
||||||
|
|
||||||
Modern and gas efficient ERC20 + EIP-2612 implementation.
|
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._
|
_Do not manually set balances without updating totalSupply, as the sum of all user balances must not exceed it._
|
||||||
|
|
||||||
### Transfer
|
## Methods
|
||||||
|
|
||||||
```solidity
|
|
||||||
event Transfer(address from, address to, uint256 amount)
|
|
||||||
```
|
|
||||||
|
|
||||||
### Approval
|
|
||||||
|
|
||||||
```solidity
|
|
||||||
event Approval(address owner, address spender, uint256 amount)
|
|
||||||
```
|
|
||||||
|
|
||||||
### name
|
|
||||||
|
|
||||||
```solidity
|
|
||||||
string name
|
|
||||||
```
|
|
||||||
|
|
||||||
### 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
|
### DOMAIN_SEPARATOR
|
||||||
|
|
||||||
```solidity
|
```solidity
|
||||||
function DOMAIN_SEPARATOR() public view virtual returns (bytes32)
|
function DOMAIN_SEPARATOR() external view returns (bytes32)
|
||||||
```
|
```
|
||||||
|
|
||||||
### computeDomainSeparator
|
#### Returns
|
||||||
|
|
||||||
|
| Name | Type | Description |
|
||||||
|
| ---- | ------- | ----------- |
|
||||||
|
| \_0 | bytes32 | undefined |
|
||||||
|
|
||||||
|
### allowance
|
||||||
|
|
||||||
```solidity
|
```solidity
|
||||||
function computeDomainSeparator() internal view virtual returns (bytes32)
|
function allowance(address, address) external view returns (uint256)
|
||||||
```
|
```
|
||||||
|
|
||||||
### _mint
|
#### Parameters
|
||||||
|
|
||||||
|
| Name | Type | Description |
|
||||||
|
| ---- | ------- | ----------- |
|
||||||
|
| \_0 | address | undefined |
|
||||||
|
| \_1 | address | undefined |
|
||||||
|
|
||||||
|
#### Returns
|
||||||
|
|
||||||
|
| Name | Type | Description |
|
||||||
|
| ---- | ------- | ----------- |
|
||||||
|
| \_0 | uint256 | undefined |
|
||||||
|
|
||||||
|
### approve
|
||||||
|
|
||||||
```solidity
|
```solidity
|
||||||
function _mint(address to, uint256 amount) internal virtual
|
function approve(address spender, uint256 amount) external nonpayable returns (bool)
|
||||||
```
|
```
|
||||||
|
|
||||||
### _burn
|
#### Parameters
|
||||||
|
|
||||||
|
| Name | Type | Description |
|
||||||
|
| ------- | ------- | ----------- |
|
||||||
|
| spender | address | undefined |
|
||||||
|
| amount | uint256 | undefined |
|
||||||
|
|
||||||
|
#### Returns
|
||||||
|
|
||||||
|
| Name | Type | Description |
|
||||||
|
| ---- | ---- | ----------- |
|
||||||
|
| \_0 | bool | undefined |
|
||||||
|
|
||||||
|
### balanceOf
|
||||||
|
|
||||||
```solidity
|
```solidity
|
||||||
function _burn(address from, uint256 amount) internal virtual
|
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)
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Parameters
|
||||||
|
|
||||||
|
| Name | Type | Description |
|
||||||
|
| ----------------- | ------- | ----------- |
|
||||||
|
| owner `indexed` | address | undefined |
|
||||||
|
| spender `indexed` | address | undefined |
|
||||||
|
| amount | uint256 | undefined |
|
||||||
|
|
||||||
|
### Transfer
|
||||||
|
|
||||||
|
```solidity
|
||||||
|
event Transfer(address indexed from, address indexed to, uint256 amount)
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Parameters
|
||||||
|
|
||||||
|
| Name | Type | Description |
|
||||||
|
| -------------- | ------- | ----------- |
|
||||||
|
| from `indexed` | address | undefined |
|
||||||
|
| to `indexed` | address | undefined |
|
||||||
|
| amount | uint256 | undefined |
|
||||||
|
|||||||
@@ -1,38 +0,0 @@
|
|||||||
# 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,14 +1,5 @@
|
|||||||
# Solidity API
|
# MerkleProofLib
|
||||||
|
|
||||||
## MerkleProofLib
|
_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)_
|
||||||
|
|
||||||
Gas optimized verification of proof of inclusion for a leaf in a Merkle tree.
|
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`._
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,50 +0,0 @@
|
|||||||
# 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,34 +1,13 @@
|
|||||||
# Solidity API
|
# ReentrancyGuard
|
||||||
|
|
||||||
## ReentrancyGuard
|
_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)_
|
||||||
|
|
||||||
Reentrancy protection for smart contracts.
|
Reentrancy protection for smart contracts.
|
||||||
|
|
||||||
|
## Errors
|
||||||
|
|
||||||
### Reentrancy
|
### Reentrancy
|
||||||
|
|
||||||
```solidity
|
```solidity
|
||||||
error Reentrancy()
|
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,62 +1,7 @@
|
|||||||
# Solidity API
|
# SafeTransferLib
|
||||||
|
|
||||||
## SafeTransferLib
|
_Solmate (https://github.com/Rari-Capital/solmate/blob/main/src/utils/SafeTransferLib.sol)_
|
||||||
|
|
||||||
Safe ETH and ERC20 transfer library that gracefully handles missing return values.
|
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
207
docs/p2pix.md
@@ -1,207 +0,0 @@
|
|||||||
# 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,11 +1,11 @@
|
|||||||
import "@nomicfoundation/hardhat-chai-matchers";
|
import "@nomicfoundation/hardhat-chai-matchers";
|
||||||
import "@nomicfoundation/hardhat-toolbox";
|
import "@nomicfoundation/hardhat-toolbox";
|
||||||
import { config as dotenvConfig } from "dotenv";
|
import { config as dotenvConfig } from "dotenv";
|
||||||
|
import "hardhat-tracer";
|
||||||
import { HardhatUserConfig } from "hardhat/config";
|
import { HardhatUserConfig } from "hardhat/config";
|
||||||
import { NetworkUserConfig } from "hardhat/types";
|
import { NetworkUserConfig } from "hardhat/types";
|
||||||
import "hardhat-contract-sizer";
|
import "hardhat-contract-sizer";
|
||||||
import { resolve } from "path";
|
import { resolve } from "path";
|
||||||
import "solidity-docgen";
|
|
||||||
|
|
||||||
dotenvConfig({ path: resolve(__dirname, "./.env") });
|
dotenvConfig({ path: resolve(__dirname, "./.env") });
|
||||||
|
|
||||||
@@ -14,6 +14,14 @@ if (!mnemonic) {
|
|||||||
throw new Error("Please set your MNEMONIC in a .env file");
|
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 =
|
const alchemyApiKey: string | undefined =
|
||||||
process.env.ALCHEMY_API_KEY;
|
process.env.ALCHEMY_API_KEY;
|
||||||
if (!alchemyApiKey) {
|
if (!alchemyApiKey) {
|
||||||
@@ -26,16 +34,25 @@ const chainIds = {
|
|||||||
// "{INSERT_NAME}": {INSERT_ID},
|
// "{INSERT_NAME}": {INSERT_ID},
|
||||||
hardhat: 31337,
|
hardhat: 31337,
|
||||||
mainnet: 1,
|
mainnet: 1,
|
||||||
"eth-sepolia": 11155111,
|
sepolia: 11155111,
|
||||||
|
goerli: 5,
|
||||||
"polygon-mumbai": 80001,
|
"polygon-mumbai": 80001,
|
||||||
rootstock:30,
|
|
||||||
"rootstock-testnet":31,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
function getChainConfig(
|
function getChainConfig(
|
||||||
chain: keyof typeof chainIds,
|
chain: keyof typeof chainIds,
|
||||||
): NetworkUserConfig {
|
): NetworkUserConfig {
|
||||||
let jsonRpcUrl = "https://" + chain + ".g.alchemy.com/v2/" + alchemyApiKey;
|
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;
|
||||||
|
}
|
||||||
return {
|
return {
|
||||||
// Comment out for default hardhat account settings
|
// Comment out for default hardhat account settings
|
||||||
accounts: {
|
accounts: {
|
||||||
@@ -64,7 +81,6 @@ const config: HardhatUserConfig = {
|
|||||||
process.env.REPORT_GAS &&
|
process.env.REPORT_GAS &&
|
||||||
process.env.REPORT_GAS != "false"
|
process.env.REPORT_GAS != "false"
|
||||||
),
|
),
|
||||||
offline: true,
|
|
||||||
showTimeSpent: true,
|
showTimeSpent: true,
|
||||||
showMethodSig: true,
|
showMethodSig: true,
|
||||||
token: "ETH",
|
token: "ETH",
|
||||||
@@ -84,10 +100,9 @@ const config: HardhatUserConfig = {
|
|||||||
},
|
},
|
||||||
// network: getChainConfig("{INSERT_NAME}"),
|
// network: getChainConfig("{INSERT_NAME}"),
|
||||||
mainnet: getChainConfig("mainnet"),
|
mainnet: getChainConfig("mainnet"),
|
||||||
sepolia: getChainConfig("eth-sepolia"),
|
goerli: getChainConfig("goerli"),
|
||||||
mumbai: getChainConfig("polygon-mumbai"),
|
sepolia: getChainConfig("sepolia"),
|
||||||
rootstock: getChainConfig("rootstock"),
|
"polygon-mumbai": getChainConfig("polygon-mumbai"),
|
||||||
rsktestnet: getChainConfig("rootstock-testnet"),
|
|
||||||
},
|
},
|
||||||
paths: {
|
paths: {
|
||||||
artifacts: "./artifacts",
|
artifacts: "./artifacts",
|
||||||
@@ -96,10 +111,10 @@ const config: HardhatUserConfig = {
|
|||||||
tests: "./test",
|
tests: "./test",
|
||||||
},
|
},
|
||||||
solidity: {
|
solidity: {
|
||||||
version: "0.8.28",
|
version: "0.8.19",
|
||||||
settings: {
|
settings: {
|
||||||
viaIR: true,
|
viaIR: true,
|
||||||
evmVersion: "cancun",
|
evmVersion: "paris",
|
||||||
optimizer: {
|
optimizer: {
|
||||||
enabled: true,
|
enabled: true,
|
||||||
runs: 20_000,
|
runs: 20_000,
|
||||||
@@ -119,11 +134,8 @@ const config: HardhatUserConfig = {
|
|||||||
},
|
},
|
||||||
typechain: {
|
typechain: {
|
||||||
outDir: "src/types",
|
outDir: "src/types",
|
||||||
target: "ethers-v6",
|
target: "ethers-v5",
|
||||||
},
|
},
|
||||||
docgen: {
|
|
||||||
pages: "files",
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export default config;
|
export default config;
|
||||||
|
|||||||
94
package.json
94
package.json
@@ -9,9 +9,10 @@
|
|||||||
"url": "https://github.com/doiim/p2pix-smart-contracts/issues"
|
"url": "https://github.com/doiim/p2pix-smart-contracts/issues"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"clean": "hardhat clean",
|
"clean": "shx rm -rf ./artifacts ./cache ./coverage ./src/types ./coverage.json && yarn typechain",
|
||||||
"compile": "hardhat compile",
|
"commit": "git-cz",
|
||||||
"typechain": "hardhat typechain",
|
"compile": "cross-env TS_NODE_TRANSPILE_ONLY=true hardhat compile",
|
||||||
|
"typechain": "cross-env TS_NODE_TRANSPILE_ONLY=true hardhat typechain",
|
||||||
"test": "hardhat test",
|
"test": "hardhat test",
|
||||||
"deploy1:localhost": "hardhat run scripts/1-deploy-mockToken.ts --network localhost",
|
"deploy1:localhost": "hardhat run scripts/1-deploy-mockToken.ts --network localhost",
|
||||||
"deploy2:localhost": "hardhat run scripts/2-deploy-p2pix.ts --network localhost",
|
"deploy2:localhost": "hardhat run scripts/2-deploy-p2pix.ts --network localhost",
|
||||||
@@ -23,49 +24,70 @@
|
|||||||
"lint": "yarn lint:sol && yarn lint:ts && yarn prettier:check",
|
"lint": "yarn lint:sol && yarn lint:ts && yarn prettier:check",
|
||||||
"lint:sol": "solhint --config ./.solhint.json --max-warnings 0 \"contracts/**/*.sol\"",
|
"lint:sol": "solhint --config ./.solhint.json --max-warnings 0 \"contracts/**/*.sol\"",
|
||||||
"lint:ts": "eslint --config ./.eslintrc.yaml --ignore-path ./.eslintignore --ext .js,.ts .",
|
"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": "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}\""
|
"prettier:check": "prettier --check --config ./.prettierrc.yaml \"**/*.{js,json,md,sol,ts,yaml,yml}\""
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@ethersproject/abi": "^5.8.0",
|
"@commitlint/cli": "^17.2.0",
|
||||||
"@ethersproject/providers": "^5.8.0",
|
"@commitlint/config-conventional": "^17.2.0",
|
||||||
"@nomicfoundation/hardhat-chai-matchers": "^2.1.0",
|
"@ethersproject/abi": "^5.7.0",
|
||||||
"@nomicfoundation/hardhat-ethers": "^3.1.0",
|
"@ethersproject/abstract-signer": "^5.7.0",
|
||||||
"@nomicfoundation/hardhat-ignition": "^0.15.13",
|
"@ethersproject/bignumber": "^5.7.0",
|
||||||
"@nomicfoundation/hardhat-ignition-ethers": "^0.15.14",
|
"@ethersproject/bytes": "^5.7.0",
|
||||||
"@nomicfoundation/hardhat-network-helpers": "^1.1.0",
|
"@ethersproject/providers": "^5.7.2",
|
||||||
"@nomicfoundation/hardhat-toolbox": "^6.1.0",
|
"@nomicfoundation/hardhat-chai-matchers": "^1.0.4",
|
||||||
"@nomicfoundation/hardhat-verify": "^2.1.0",
|
"@nomicfoundation/hardhat-network-helpers": "1.0.6",
|
||||||
"@nomicfoundation/hardhat-viem": "^2.1.0",
|
"@nomicfoundation/hardhat-toolbox": "^2.0.0",
|
||||||
"@nomicfoundation/ignition-core": "^0.15.13",
|
"@nomiclabs/hardhat-ethers": "^2.2.1",
|
||||||
"@typechain/ethers-v6": "^0.5.1",
|
"@nomiclabs/hardhat-etherscan": "^3.1.2",
|
||||||
"@typechain/hardhat": "^9.1.0",
|
"@trivago/prettier-plugin-sort-imports": "^3.4.0",
|
||||||
"@types/chai": "^4.3.20",
|
"@typechain/ethers-v5": "^10.1.1",
|
||||||
"@types/mocha": "^10.0.10",
|
"@typechain/hardhat": "^6.1.4",
|
||||||
"@types/node": "^24.1.0",
|
"@types/chai": "^4.3.3",
|
||||||
"chai": "4.5.0",
|
"@types/fs-extra": "^9.0.13",
|
||||||
"dotenv": "^16.6.1",
|
"@types/mocha": "^9.1.1",
|
||||||
"eslint": "^9.32.0",
|
"@types/node": "^18.11.9",
|
||||||
"eslint-config-prettier": "^10.1.8",
|
"@typescript-eslint/eslint-plugin": "^5.42.0",
|
||||||
"ethers": "^6.15.0",
|
"@typescript-eslint/parser": "^5.42.0",
|
||||||
"hardhat": "^2.26.1",
|
"chai": "^4.3.6",
|
||||||
"hardhat-contract-sizer": "^2.10.0",
|
"chalk": "4.x",
|
||||||
"hardhat-gas-reporter": "^2.3.0",
|
"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-contract-sizer": "^2.8.0",
|
||||||
|
"hardhat-gas-reporter": "^1.0.9",
|
||||||
|
"hardhat-tracer": "beta",
|
||||||
|
"husky": "^8.0.1",
|
||||||
"keccak256": "^1.0.6",
|
"keccak256": "^1.0.6",
|
||||||
|
"lint-staged": "^13.0.3",
|
||||||
"lodash": "^4.17.21",
|
"lodash": "^4.17.21",
|
||||||
"merkletreejs": "^0.5.2",
|
"merkletreejs": "^0.2.32",
|
||||||
"mocha": "^10.8.2",
|
"mocha": "^10.1.0",
|
||||||
"solidity-coverage": "^0.8.16",
|
"pinst": "^3.0.0",
|
||||||
"solidity-docgen": "^0.6.0-beta.36",
|
"prettier": "^2.7.1",
|
||||||
"ts-node": "^10.9.2",
|
"prettier-plugin-solidity": "^1.0.0-rc.1",
|
||||||
"typechain": "^8.3.2",
|
"shx": "^0.3.4",
|
||||||
"typescript": "^5.8.3",
|
"solhint": "^3.3.7",
|
||||||
"viem": "^2.33.1"
|
"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"
|
||||||
},
|
},
|
||||||
"files": [
|
"files": [
|
||||||
"/contracts"
|
"/contracts"
|
||||||
],
|
],
|
||||||
"packageManager": "yarn@4.9.2",
|
"packageManager": "yarn@3.2.1",
|
||||||
"publishConfig": {
|
"publishConfig": {
|
||||||
"access": "public"
|
"access": "public"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,14 @@
|
|||||||
import "@nomicfoundation/hardhat-ethers";
|
import "@nomiclabs/hardhat-ethers";
|
||||||
|
import "@nomiclabs/hardhat-etherscan";
|
||||||
|
import { BigNumber } from "ethers";
|
||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
import { ethers, network } from "hardhat";
|
import { ethers, network } from "hardhat";
|
||||||
|
import hre from "hardhat";
|
||||||
|
|
||||||
import { Deploys } from "../test/utils/interfaces";
|
import { Deploys } from "../test/utils/interfaces";
|
||||||
|
|
||||||
let deploysJson: Deploys;
|
let deploysJson: Deploys;
|
||||||
const supply: BigInt = ethers.parseEther("20000000");
|
const supply: BigNumber = ethers.utils.parseEther("20000000");
|
||||||
|
|
||||||
const main = async () => {
|
const main = async () => {
|
||||||
try {
|
try {
|
||||||
@@ -22,11 +25,15 @@ const main = async () => {
|
|||||||
const [deployer] = await ethers.getSigners();
|
const [deployer] = await ethers.getSigners();
|
||||||
console.log(`Deploying contracts with ${deployer.address}`);
|
console.log(`Deploying contracts with ${deployer.address}`);
|
||||||
|
|
||||||
let erc20 = await ethers.deployContract("MockToken", [supply]);
|
const ERC20Factory = await ethers.getContractFactory(
|
||||||
erc20 = await erc20.waitForDeployment();
|
"MockToken",
|
||||||
|
);
|
||||||
|
const erc20 = await ERC20Factory.deploy(supply);
|
||||||
|
await erc20.deployed();
|
||||||
|
|
||||||
deploysJson.token = await erc20.getAddress();
|
deploysJson.token = erc20.address;
|
||||||
console.log("🚀 Mock Token Deployed:", await erc20.getAddress());
|
console.log("🚀 Mock Token Deployed:", erc20.address);
|
||||||
|
await erc20.deployTransaction.wait(6);
|
||||||
|
|
||||||
fs.writeFileSync(
|
fs.writeFileSync(
|
||||||
`./deploys/${network.name}.json`,
|
`./deploys/${network.name}.json`,
|
||||||
@@ -35,10 +42,10 @@ const main = async () => {
|
|||||||
|
|
||||||
/* UNCOMMENT WHEN DEPLOYING TO MAINNET/PUBLIC TESTNETS */
|
/* UNCOMMENT WHEN DEPLOYING TO MAINNET/PUBLIC TESTNETS */
|
||||||
// verify
|
// verify
|
||||||
// await hre.run("verify:verify", {
|
await hre.run("verify:verify", {
|
||||||
// address: erc20.address,
|
address: erc20.address,
|
||||||
// constructorArguments: [supply],
|
constructorArguments: [supply],
|
||||||
// });
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
main()
|
main()
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
import "@nomicfoundation/hardhat-ethers";
|
import "@nomiclabs/hardhat-ethers";
|
||||||
|
import "@nomiclabs/hardhat-etherscan";
|
||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
import { ethers, network } from "hardhat";
|
import { ethers, network } from "hardhat";
|
||||||
|
import hre from "hardhat";
|
||||||
|
|
||||||
import { Deploys } from "../test/utils/interfaces";
|
import { Deploys } from "../test/utils/interfaces";
|
||||||
|
|
||||||
@@ -21,24 +23,32 @@ const main = async () => {
|
|||||||
const [deployer] = await ethers.getSigners();
|
const [deployer] = await ethers.getSigners();
|
||||||
console.log(`Deploying contracts with ${deployer.address}`);
|
console.log(`Deploying contracts with ${deployer.address}`);
|
||||||
|
|
||||||
let reputation = await ethers.deployContract("Reputation");
|
const Reputation = await ethers.getContractFactory(
|
||||||
let multicall = await ethers.deployContract("Multicall");
|
"Reputation",
|
||||||
let p2pix = await ethers.deployContract("P2PIX", [
|
);
|
||||||
|
const Multicall = await ethers.getContractFactory(
|
||||||
|
"Multicall",
|
||||||
|
);
|
||||||
|
const reputation = await Reputation.deploy();
|
||||||
|
await reputation.deployed();
|
||||||
|
const mutlicall = await Multicall.deploy();
|
||||||
|
await mutlicall.deployed();
|
||||||
|
|
||||||
|
const P2PIX = await ethers.getContractFactory("P2PIX");
|
||||||
|
const p2pix = await P2PIX.deploy(
|
||||||
10,
|
10,
|
||||||
deploysJson.signers,
|
deploysJson.signers,
|
||||||
reputation.target,
|
reputation.address,
|
||||||
[deploysJson.token],
|
[deploysJson.token],
|
||||||
[true],
|
[true],
|
||||||
]);
|
);
|
||||||
|
await p2pix.deployed();
|
||||||
|
|
||||||
reputation = await reputation.waitForDeployment();
|
deploysJson.p2pix = p2pix.address;
|
||||||
multicall = await multicall.waitForDeployment();
|
console.log("🚀 P2PIX Deployed:", p2pix.address);
|
||||||
p2pix = await p2pix.waitForDeployment();
|
console.log("🌠 Reputation Deployed:", reputation.address);
|
||||||
|
console.log("🛰 Multicall Deployed:", mutlicall.address);
|
||||||
deploysJson.p2pix = await p2pix.getAddress();
|
await p2pix.deployTransaction.wait(6);
|
||||||
console.log("🚀 P2PIX Deployed:", await p2pix.getAddress());
|
|
||||||
console.log("🌠 Reputation Deployed:", await reputation.getAddress());
|
|
||||||
console.log("🛰 Multicall Deployed:", await multicall.getAddress());
|
|
||||||
|
|
||||||
fs.writeFileSync(
|
fs.writeFileSync(
|
||||||
`./deploys/${network.name}.json`,
|
`./deploys/${network.name}.json`,
|
||||||
@@ -47,24 +57,24 @@ const main = async () => {
|
|||||||
|
|
||||||
/* UNCOMMENT WHEN DEPLOYING TO MAINNET/PUBLIC TESTNETS */
|
/* UNCOMMENT WHEN DEPLOYING TO MAINNET/PUBLIC TESTNETS */
|
||||||
//verify
|
//verify
|
||||||
// await hre.run("verify:verify", {
|
await hre.run("verify:verify", {
|
||||||
// address: p2pix.address,
|
address: p2pix.address,
|
||||||
// constructorArguments: [
|
constructorArguments: [
|
||||||
// 10,
|
10,
|
||||||
// deploysJson.signers,
|
deploysJson.signers,
|
||||||
// reputation.address,
|
reputation.address,
|
||||||
// [deploysJson.token],
|
[deploysJson.token],
|
||||||
// [true],
|
[true],
|
||||||
// ],
|
],
|
||||||
// });
|
});
|
||||||
// await hre.run("verify:verify", {
|
await hre.run("verify:verify", {
|
||||||
// address: reputation.address,
|
address: reputation.address,
|
||||||
// constructorArguments: [],
|
constructorArguments: [],
|
||||||
// });
|
});
|
||||||
// await hre.run("verify:verify", {
|
await hre.run("verify:verify", {
|
||||||
// address: mutlicall.address,
|
address: mutlicall.address,
|
||||||
// constructorArguments: [],
|
constructorArguments: [],
|
||||||
// });
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
main()
|
main()
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import "@nomicfoundation/hardhat-chai-matchers";
|
import "@nomicfoundation/hardhat-chai-matchers";
|
||||||
import { loadFixture } from "@nomicfoundation/hardhat-network-helpers";
|
import { loadFixture } from "@nomicfoundation/hardhat-network-helpers";
|
||||||
import { SignerWithAddress } from "@nomicfoundation/hardhat-ethers/signers";
|
import { SignerWithAddress } from "@nomiclabs/hardhat-ethers/signers";
|
||||||
import { expect } from "chai";
|
import { expect } from "chai";
|
||||||
import { ethers, network } from "hardhat";
|
import { ethers, network } from "hardhat";
|
||||||
|
|
||||||
@@ -15,7 +15,7 @@ describe("Reputation", () => {
|
|||||||
|
|
||||||
before("Set signers and reset network", async () => {
|
before("Set signers and reset network", async () => {
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
[owner] = await ethers.getSigners();
|
[owner] = await (ethers as any).getSigners();
|
||||||
|
|
||||||
await network.provider.send("hardhat_reset");
|
await network.provider.send("hardhat_reset");
|
||||||
});
|
});
|
||||||
@@ -60,7 +60,7 @@ describe("Reputation", () => {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
x: Number.MAX_SAFE_INTEGER,
|
x: Number.MAX_SAFE_INTEGER,
|
||||||
expected: curve(Number.MAX_SAFE_INTEGER),
|
shouldRevert: "overflow",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
x: Number.POSITIVE_INFINITY,
|
x: Number.POSITIVE_INFINITY,
|
||||||
|
|||||||
1099
test/p2pix.test.ts
1099
test/p2pix.test.ts
File diff suppressed because it is too large
Load Diff
@@ -1,5 +1,5 @@
|
|||||||
import { SignerWithAddress } from "@nomicfoundation/hardhat-ethers/signers";
|
import { SignerWithAddress } from "@nomiclabs/hardhat-ethers/signers";
|
||||||
import { Signer } from "ethers";
|
import { BigNumber, Signer } from "ethers";
|
||||||
import { ethers } from "hardhat";
|
import { ethers } from "hardhat";
|
||||||
import keccak256 from "keccak256";
|
import keccak256 from "keccak256";
|
||||||
import { MerkleTree } from "merkletreejs";
|
import { MerkleTree } from "merkletreejs";
|
||||||
@@ -14,7 +14,30 @@ import {
|
|||||||
|
|
||||||
import { Call, RepFixture, P2PixAndReputation, DepositArgs, LockArgs, ReleaseArgs } from "./interfaces";
|
import { Call, RepFixture, P2PixAndReputation, DepositArgs, LockArgs, ReleaseArgs } from "./interfaces";
|
||||||
|
|
||||||
|
|
||||||
// exported constants
|
// exported constants
|
||||||
|
export const createDepositArgs = (pixTarget: string, allowlistRoot: string, token: string, amount: BigNumber, valid:boolean): DepositArgs => ({
|
||||||
|
pixTarget,
|
||||||
|
allowlistRoot,
|
||||||
|
token,
|
||||||
|
amount,
|
||||||
|
valid,
|
||||||
|
});
|
||||||
|
|
||||||
|
export const createLockArgs = (seller: string, token: string, amount: BigNumber, merkleProof: string[], expiredLocks: BigNumber[]): LockArgs => ({
|
||||||
|
seller,
|
||||||
|
token,
|
||||||
|
amount,
|
||||||
|
merkleProof,
|
||||||
|
expiredLocks,
|
||||||
|
});
|
||||||
|
|
||||||
|
export const createReleaseArgs = (lockID: BigNumber, pixTimestamp: string, signature: string): ReleaseArgs => ({
|
||||||
|
lockID,
|
||||||
|
pixTimestamp,
|
||||||
|
signature,
|
||||||
|
});
|
||||||
|
|
||||||
export const getSignerAddrs = (
|
export const getSignerAddrs = (
|
||||||
amount: number,
|
amount: number,
|
||||||
addrs: SignerWithAddress[],
|
addrs: SignerWithAddress[],
|
||||||
@@ -22,16 +45,16 @@ export const getSignerAddrs = (
|
|||||||
return addrs.slice(0, amount).map(({ address }) => address);
|
return addrs.slice(0, amount).map(({ address }) => address);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getBnFrom = (nums: number[]): BigInt[] => {
|
export const getBnFrom = (nums: number[]): BigNumber[] => {
|
||||||
const bns = nums.map(num => BigInt(num));
|
const bns = nums.map(num => ethers.BigNumber.from(num));
|
||||||
return bns;
|
return bns;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getLockData = (
|
export const getLockData = (
|
||||||
addr: string,
|
addr: string,
|
||||||
locks: BigInt[][],
|
locks: BigNumber[][],
|
||||||
): Call[] => {
|
): Call[] => {
|
||||||
const iface = new ethers.Interface(
|
const iface = new ethers.utils.Interface(
|
||||||
P2PIX__factory.abi,
|
P2PIX__factory.abi,
|
||||||
);
|
);
|
||||||
return locks.map(lock => ({
|
return locks.map(lock => ({
|
||||||
@@ -71,8 +94,13 @@ export const curve = (x: number): number => {
|
|||||||
|
|
||||||
// exported async functions
|
// exported async functions
|
||||||
export async function repFixture(): Promise<RepFixture> {
|
export async function repFixture(): Promise<RepFixture> {
|
||||||
const reputation = await ethers.deployContract("Reputation");
|
const Reputation = await ethers.getContractFactory(
|
||||||
return { reputation: await reputation.waitForDeployment() };
|
"Reputation",
|
||||||
|
);
|
||||||
|
const reputation =
|
||||||
|
(await Reputation.deploy()) as Reputation;
|
||||||
|
|
||||||
|
return { reputation };
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function p2pixFixture(): Promise<P2PixAndReputation> {
|
export async function p2pixFixture(): Promise<P2PixAndReputation> {
|
||||||
@@ -81,21 +109,30 @@ export async function p2pixFixture(): Promise<P2PixAndReputation> {
|
|||||||
await ethers.getSigners(),
|
await ethers.getSigners(),
|
||||||
);
|
);
|
||||||
|
|
||||||
const reputation = await ethers.deployContract("Reputation");
|
const Reputation = await ethers.getContractFactory(
|
||||||
|
"Reputation",
|
||||||
|
);
|
||||||
|
const reputation =
|
||||||
|
(await Reputation.deploy()) as Reputation;
|
||||||
|
|
||||||
const erc20 = await ethers.deployContract("MockToken", [
|
const ERC20 = await ethers.getContractFactory("MockToken");
|
||||||
ethers.parseEther("20000000") // 20M
|
const erc20 = (await ERC20.deploy(
|
||||||
]) as MockToken;
|
ethers.utils.parseEther("20000000"), // 20M
|
||||||
|
)) as MockToken;
|
||||||
|
|
||||||
const p2pix = await ethers.deployContract("P2PIX", [
|
const P2PIX = await ethers.getContractFactory("P2PIX");
|
||||||
|
const p2pix = (await P2PIX.deploy(
|
||||||
10,
|
10,
|
||||||
validSigners,
|
validSigners,
|
||||||
reputation.target,
|
reputation.address,
|
||||||
[erc20.target],
|
[erc20.address],
|
||||||
[true],
|
[true],
|
||||||
]);
|
)) as P2PIX;
|
||||||
|
|
||||||
const multicall = await ethers.deployContract("Multicall");
|
const Multicall = await ethers.getContractFactory(
|
||||||
|
"Multicall",
|
||||||
|
);
|
||||||
|
const multicall = (await Multicall.deploy()) as Multicall;
|
||||||
|
|
||||||
const signers = await ethers.getSigners();
|
const signers = await ethers.getSigners();
|
||||||
const whitelisted = signers.slice(0, 2);
|
const whitelisted = signers.slice(0, 2);
|
||||||
@@ -111,10 +148,10 @@ export async function p2pixFixture(): Promise<P2PixAndReputation> {
|
|||||||
);
|
);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
multicall: await multicall.waitForDeployment(),
|
multicall,
|
||||||
reputation: await reputation.waitForDeployment(),
|
reputation,
|
||||||
erc20: await erc20.waitForDeployment(),
|
erc20,
|
||||||
p2pix: await p2pix.waitForDeployment(),
|
p2pix,
|
||||||
merkleRoot,
|
merkleRoot,
|
||||||
proof,
|
proof,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
import { BigNumber } from "ethers";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
MockToken,
|
MockToken,
|
||||||
Multicall,
|
Multicall,
|
||||||
@@ -17,29 +19,29 @@ export interface DepositArgs {
|
|||||||
pixTarget: string;
|
pixTarget: string;
|
||||||
allowlistRoot: string;
|
allowlistRoot: string;
|
||||||
token: string;
|
token: string;
|
||||||
amount: BigInt;
|
amount: BigNumber;
|
||||||
valid: boolean;
|
valid: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface LockArgs {
|
export interface LockArgs {
|
||||||
seller: string;
|
seller: string;
|
||||||
token: string;
|
token: string;
|
||||||
amount: BigInt;
|
amount: BigNumber;
|
||||||
merkleProof: string[];
|
merkleProof: string[];
|
||||||
expiredLocks: BigInt[];
|
expiredLocks: BigNumber[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ReleaseArgs {
|
export interface ReleaseArgs {
|
||||||
lockID: BigInt;
|
lockID: BigNumber;
|
||||||
pixTimestamp: string;
|
pixTimestamp: string;
|
||||||
signature: string;
|
signature: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Lock {
|
export interface Lock {
|
||||||
counter: BigInt;
|
counter: BigNumber;
|
||||||
expirationBlock: BigInt;
|
expirationBlock: BigNumber;
|
||||||
pixTarget: string;
|
pixTarget: string;
|
||||||
amount: BigInt;
|
amount: BigNumber;
|
||||||
token: string;
|
token: string;
|
||||||
buyerAddress: string;
|
buyerAddress: string;
|
||||||
seller: string;
|
seller: string;
|
||||||
|
|||||||
Reference in New Issue
Block a user