Moved stack allocation from memory to calldata
This commit is contained in:
@@ -1,11 +1,11 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
pragma solidity 0.8.19;
|
||||
|
||||
import { ERC20, OwnerSettings } from "./OwnerSettings.sol";
|
||||
import { ERC20, OwnerSettings } from "contracts/core/OwnerSettings.sol";
|
||||
|
||||
import { ECDSA } from "../lib/utils/ECDSA.sol";
|
||||
import { MerkleProofLib as Merkle } from "../lib/utils/MerkleProofLib.sol";
|
||||
import { ReentrancyGuard } from "../lib/utils/ReentrancyGuard.sol";
|
||||
import { ECDSA } from "contracts/lib/utils/ECDSA.sol";
|
||||
import { MerkleProofLib as Merkle } from "contracts/lib/utils/MerkleProofLib.sol";
|
||||
import { ReentrancyGuard } from "contracts/lib/utils/ReentrancyGuard.sol";
|
||||
|
||||
abstract contract BaseUtils is
|
||||
OwnerSettings,
|
||||
@@ -93,7 +93,7 @@ abstract contract BaseUtils is
|
||||
}
|
||||
|
||||
function _setSellerBalance(
|
||||
uint256 _sellerKey,
|
||||
address _sellerKey,
|
||||
ERC20 _erc20,
|
||||
uint256 _packed,
|
||||
bytes32 _pixTarget
|
||||
@@ -101,7 +101,7 @@ abstract contract BaseUtils is
|
||||
assembly {
|
||||
mstore(0x20, _erc20)
|
||||
mstore(0x0c, _SELLER_BALANCE_SLOT_SEED)
|
||||
mstore(0x00, shr(0xc, _sellerKey))
|
||||
mstore(0x00, _sellerKey)
|
||||
let _loc := keccak256(0x0c, 0x34)
|
||||
sstore(add(_loc, 0x01), _packed)
|
||||
sstore(_loc, _pixTarget)
|
||||
@@ -109,55 +109,55 @@ abstract contract BaseUtils is
|
||||
}
|
||||
|
||||
function _setValidState(
|
||||
uint256 _sellerKey,
|
||||
address _sellerKey,
|
||||
ERC20 _erc20,
|
||||
uint256 _packed
|
||||
) internal {
|
||||
assembly {
|
||||
mstore(0x20, _erc20)
|
||||
mstore(0x0c, _SELLER_BALANCE_SLOT_SEED)
|
||||
mstore(0x00, shr(0xc, _sellerKey))
|
||||
mstore(0x00, _sellerKey)
|
||||
let _loc := keccak256(0x0c, 0x34)
|
||||
sstore(add(_loc, 0x01), _packed)
|
||||
}
|
||||
}
|
||||
|
||||
function _addSellerBalance(
|
||||
uint256 _sellerKey,
|
||||
address _sellerKey,
|
||||
ERC20 _erc20,
|
||||
uint256 _amount
|
||||
) internal {
|
||||
assembly {
|
||||
mstore(0x20, _erc20)
|
||||
mstore(0x0c, _SELLER_BALANCE_SLOT_SEED)
|
||||
mstore(0x00, shr(0xc, _sellerKey))
|
||||
mstore(0x00, _sellerKey)
|
||||
let _loc := add(keccak256(0x0c, 0x34), 0x01)
|
||||
sstore(_loc, add(sload(_loc), _amount))
|
||||
}
|
||||
}
|
||||
|
||||
function _decSellerBalance(
|
||||
uint256 _sellerKey,
|
||||
address _sellerKey,
|
||||
ERC20 _erc20,
|
||||
uint256 _amount
|
||||
) internal {
|
||||
assembly {
|
||||
mstore(0x20, _erc20)
|
||||
mstore(0x0c, _SELLER_BALANCE_SLOT_SEED)
|
||||
mstore(0x00, shr(0xc, _sellerKey))
|
||||
mstore(0x00, _sellerKey)
|
||||
let _loc := add(keccak256(0x0c, 0x34), 0x01)
|
||||
sstore(_loc, sub(sload(_loc), _amount))
|
||||
}
|
||||
}
|
||||
|
||||
function __sellerBalance(
|
||||
uint256 _sellerKey,
|
||||
address _sellerKey,
|
||||
ERC20 _erc20
|
||||
) internal view returns (uint256 _packed) {
|
||||
assembly {
|
||||
mstore(0x20, _erc20)
|
||||
mstore(0x0c, _SELLER_BALANCE_SLOT_SEED)
|
||||
mstore(0x00, shr(0xc, _sellerKey))
|
||||
mstore(0x00, _sellerKey)
|
||||
_packed := sload(add(keccak256(0x0c, 0x34), 0x01))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,15 +1,33 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
pragma solidity 0.8.19;
|
||||
|
||||
import { ERC20 } from "contracts/lib/tokens/ERC20.sol";
|
||||
|
||||
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 Lock {
|
||||
uint256 sellerKey;
|
||||
uint256 counter;
|
||||
uint256 expirationBlock;
|
||||
bytes32 pixTarget;
|
||||
uint80 amount;
|
||||
address token;
|
||||
address buyerAddress;
|
||||
address seller;
|
||||
}
|
||||
|
||||
// prettier-ignore
|
||||
|
||||
@@ -28,7 +28,7 @@ interface EventAndErrors {
|
||||
event LockAdded(
|
||||
address indexed buyer,
|
||||
uint256 indexed lockID,
|
||||
uint256 seller,
|
||||
address seller,
|
||||
uint256 amount
|
||||
);
|
||||
/// @dev 0x364537f14276f2a0ce9905588413f96454cbb8fb2e4f5308389307c1098bede8
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
pragma solidity 0.8.19;
|
||||
|
||||
import { ERC2771Context as ERC2771 } from "../lib/metatx/ERC2771Context.sol";
|
||||
import { ERC20, SafeTransferLib } from "../lib/utils/SafeTransferLib.sol";
|
||||
import { IReputation } from "../lib/interfaces/IReputation.sol";
|
||||
import { EventAndErrors } from "./EventAndErrors.sol";
|
||||
import { Constants } from "./Constants.sol";
|
||||
import { Owned } from "../lib/auth/Owned.sol";
|
||||
import { ERC2771Context as ERC2771 } from "contracts/lib/metatx/ERC2771Context.sol";
|
||||
import { ERC20, SafeTransferLib } from "contracts/lib/utils/SafeTransferLib.sol";
|
||||
import { IReputation } from "contracts/lib/interfaces/IReputation.sol";
|
||||
import { EventAndErrors } from "contracts/core/EventAndErrors.sol";
|
||||
import { Constants } from "contracts/core/Constants.sol";
|
||||
import { Owned } from "contracts/lib/auth/Owned.sol";
|
||||
|
||||
abstract contract OwnerSettings is
|
||||
Constants,
|
||||
@@ -121,7 +121,7 @@ abstract contract OwnerSettings is
|
||||
} iszero(returndatasize()) {
|
||||
/* */
|
||||
} {
|
||||
sstore(shl(12, mload(i)), true)
|
||||
sstore(shl(0xc, mload(i)), true)
|
||||
i := add(i, 0x20)
|
||||
|
||||
if iszero(lt(i, end)) {
|
||||
@@ -187,11 +187,11 @@ abstract contract OwnerSettings is
|
||||
}
|
||||
|
||||
function sellerAllowList(
|
||||
uint256 sellerKey
|
||||
address sellerKey
|
||||
) public view returns (bytes32 root) {
|
||||
assembly {
|
||||
mstore(0x0c, _SELLER_ALLOWLIST_SLOT_SEED)
|
||||
mstore(0x00, shr(12, sellerKey))
|
||||
mstore(0x00, sellerKey)
|
||||
root := sload(keccak256(0x00, 0x20))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user