Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SC-1020] Cross-chain settlement extension #2

Merged
merged 11 commits into from
Jan 8, 2024
17 changes: 5 additions & 12 deletions contracts/EscrowFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,36 +5,29 @@ pragma solidity 0.8.23;
import { IOrderMixin } from "@1inch/limit-order-protocol-contract/contracts/interfaces/IOrderMixin.sol";
import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";

import { ExtensionBase } from "@1inch/limit-order-settlement/contracts/ExtensionBase.sol";
import { Address, AddressLib } from "@1inch/solidity-utils/contracts/libraries/AddressLib.sol";
import { SafeERC20 } from "@1inch/solidity-utils/contracts/libraries/SafeERC20.sol";
import { ClonesWithImmutableArgs } from "clones-with-immutable-args/ClonesWithImmutableArgs.sol";

import { IEscrowFactory } from "./interfaces/IEscrowFactory.sol";
import { Escrow } from "./Escrow.sol";

contract EscrowFactory is IEscrowFactory {
contract EscrowFactory is IEscrowFactory, ExtensionBase {
using AddressLib for Address;
using ClonesWithImmutableArgs for address;
using SafeERC20 for IERC20;

address public immutable IMPLEMENTATION;
address public immutable LIMIT_ORDER_PROTOCOL;

/// @dev Modifier to check if the caller is the limit order protocol contract.
modifier onlyLimitOrderProtocol {
if (msg.sender != LIMIT_ORDER_PROTOCOL) revert OnlyLimitOrderProtocol();
_;
}

constructor(address implementation, address limitOrderProtocol) {
constructor(address implementation, address limitOrderProtocol) ExtensionBase(limitOrderProtocol) {
IMPLEMENTATION = implementation;
LIMIT_ORDER_PROTOCOL = limitOrderProtocol;
}

/**
* @dev Creates a new escrow contract for maker.
*/
function postInteraction(
function _postInteraction(
IOrderMixin.Order calldata order,
bytes calldata /* extension */,
bytes32 orderHash,
Expand All @@ -43,7 +36,7 @@ contract EscrowFactory is IEscrowFactory {
uint256 takingAmount,
uint256 /* remainingMakingAmount */,
bytes calldata extraData
) external onlyLimitOrderProtocol {
) internal override {
bytes memory interactionParams = abi.encode(
order.maker,
taker,
Expand Down
1 change: 0 additions & 1 deletion contracts/interfaces/IEscrowFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,4 @@ interface IEscrowFactory {

error InsufficientEscrowBalance();
error InvalidCreationTime();
error OnlyLimitOrderProtocol();
}
2 changes: 1 addition & 1 deletion hardhat.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ require('@nomicfoundation/hardhat-ethers');
require('@nomicfoundation/hardhat-verify');
require('dotenv').config();
require('hardhat-dependency-compiler');
// require('hardhat-deploy');
require('hardhat-deploy');
require('hardhat-gas-reporter');
// require('hardhat-tracer');
require('solidity-coverage');
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@
},
"license": "MIT",
"dependencies": {
"@1inch/solidity-utils": "3.5.4",
"@1inch/solidity-utils": "3.5.5",
"@openzeppelin/contracts": "5.0.1",
"@1inch/limit-order-protocol-contract": "4.0.0-prerelease-15"
"@1inch/limit-order-protocol-contract": "4.0.0-prerelease-16",
"@1inch/limit-order-settlement": "2.0.0-prerelease-3"
},
"devDependencies": {
"@nomicfoundation/hardhat-chai-matchers": "2.0.2",
Expand Down
Loading