Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions interface/IEscrow.sol
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ interface IEscrow {
event TokenWhitelisted (address indexed token);
event TokenRemovedFromWhitelist(address indexed token);
event BatchDeposited (uint indexed batchId, uint repoId, uint timestamp, uint[] depositIds);
event SignerSet (address indexed newSigner);

/**
* @notice Deposits tokens into the escrow on behalf of a specified sender and recipient.
Expand Down
1 change: 1 addition & 0 deletions libraries/Params.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ pragma solidity =0.8.26;
library Params {
address constant MAINNET_USDC = 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48;
address constant OWNER = 0x9d8A62f656a8d1615C1294fd71e9CFb3E4855A4F;
address constant SIGNER = 0x9d8A62f656a8d1615C1294fd71e9CFb3E4855A4F;

// BASE
address constant BASE_WETH = 0x4200000000000000000000000000000000000006;
Expand Down
2 changes: 1 addition & 1 deletion script/Deploy.Base.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ contract DeployBase is Deploy {
address[] memory initialWhitelistedTokens = new address[](1);
initialWhitelistedTokens[0] = Params.BASE_USDC;

escrow = deploy(Params.OWNER, initialWhitelistedTokens, Params.BASE_FEE_BPS);
escrow = deploy(Params.OWNER, Params.SIGNER, initialWhitelistedTokens, Params.BASE_FEE_BPS);
}
}
3 changes: 2 additions & 1 deletion script/Deploy.BaseSepolia.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ contract DeployBaseSepolia is DeployTestBase {
testers,
Params.BASESEPOLIA_WETH,
Params.BASESEPOLIA_USDC,
Params.OWNER
Params.OWNER,
Params.SIGNER
);

createTestPayments(
Expand Down
3 changes: 2 additions & 1 deletion script/Deploy.Sepolia.sol
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ contract DeploySepolia is DeployTestBase {
testers,
Params.SEPOLIA_WETH,
Params.SEPOLIA_USDC,
Params.OWNER
Params.OWNER,
Params.SIGNER
);

createTestPayments(
Expand Down
5 changes: 3 additions & 2 deletions script/Deploy.Test.Base.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ abstract contract DeployTestBase is Deploy {
address[] memory testers,
address weth,
address usdc,
address owner
address owner,
address signer
) internal {
vm.startBroadcast();

Expand All @@ -34,7 +35,7 @@ abstract contract DeployTestBase is Deploy {
initialWhitelistedTokens[1] = usdc;
initialWhitelistedTokens[2] = address(mockUSDC);

escrow = deploy(owner, initialWhitelistedTokens, 0);
escrow = deploy(owner, signer, initialWhitelistedTokens, 0);
}

function createTestPayments(
Expand Down
2 changes: 2 additions & 0 deletions script/Deploy.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {Script} from "forge-std/Script.sol";
contract Deploy is Script {
function deploy(
address owner,
address signer,
address[] memory initialWhitelistedTokens,
uint feeBps
)
Expand All @@ -18,6 +19,7 @@ contract Deploy is Script {

escrow = new Escrow(
owner,
signer,
initialWhitelistedTokens,
feeBps
);
Expand Down
2 changes: 1 addition & 1 deletion script/utils/Gas.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ contract DeploySepolia is Script {
address[] memory initialWhitelistedTokens = new address[](1);
initialWhitelistedTokens[0] = address(mockUSDC);

Escrow escrow = new Deploy().deploy(Params.OWNER, initialWhitelistedTokens, 0);
Escrow escrow = new Deploy().deploy(Params.OWNER, Params.SIGNER, initialWhitelistedTokens, 0);

for (uint256 j = 0; j < NUM_DEPOSITS.length; j++) {
uint256 numDeposits = NUM_DEPOSITS[j];
Expand Down
16 changes: 14 additions & 2 deletions src/Escrow.sol
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ contract Escrow is Owned, IEscrow {
mapping(address => bool) public canClaim;
mapping(address => uint) public recipientNonces;

address public signer;

struct Deposit {
uint amount;
ERC20 token;
Expand All @@ -47,6 +49,7 @@ contract Escrow is Owned, IEscrow {

constructor(
address _owner,
address _signer,
address[] memory _initialWhitelistedTokens,
uint _initialFeeBps
) Owned(_owner) {
Expand All @@ -55,6 +58,7 @@ contract Escrow is Owned, IEscrow {
protocolFeeBps = _initialFeeBps;
CLAIM_INITIAL_CHAIN_ID = block.chainid;
CLAIM_INITIAL_DOMAIN_SEPARATOR = _computeClaimDomainSeparator();
signer = _signer;

for (uint256 i = 0; i < _initialWhitelistedTokens.length; i++) {
_whitelistedTokens.add(_initialWhitelistedTokens[i]);
Expand Down Expand Up @@ -240,8 +244,8 @@ contract Escrow is Owned, IEscrow {
abi.encodePacked("\x19\x01", CLAIM_DOMAIN_SEPARATOR(), structHash)
);

address signer = ECDSA.recover(digest, v, r, s);
require(signer == owner, Errors.INVALID_SIGNATURE);
address recoveredSigner = ECDSA.recover(digest, v, r, s);
require(recoveredSigner == signer, Errors.INVALID_SIGNATURE);

recipientNonces[recipient]++;

Expand Down Expand Up @@ -324,4 +328,12 @@ contract Escrow is Owned, IEscrow {
emit FeeRecipientSet(_newFeeRecipient);
}

/*//////////////////////////////////////////////////////////////
SIGNER MANAGEMENT (Owner Only)
//////////////////////////////////////////////////////////////*/
function setSigner(address _newSigner) external onlyOwner {
require(_newSigner != address(0), Errors.INVALID_ADDRESS);
signer = _newSigner;
emit SignerSet(_newSigner);
}
}
1 change: 1 addition & 0 deletions test/Deploy.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ contract Deploy_Test is Test {
assertTrue(address(escrow) != address(0), "Escrow not deployed");
assertTrue(escrow.isTokenWhitelisted(Params.BASE_USDC), "WETH not whitelisted");
assertEq (escrow.owner(), Params.OWNER, "Incorrect owner");
assertEq (escrow.signer(), Params.SIGNER, "Incorrect signer");
assertEq (escrow.feeRecipient(), Params.OWNER, "Incorrect fee recipient");
assertEq (escrow.protocolFeeBps(), Params.BASE_FEE_BPS, "Incorrect fee");
}
Expand Down
2 changes: 1 addition & 1 deletion test/Escrow.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ contract Base_Test is Test {
function setUp() public {
address[] memory initialWhitelistedTokens = new address[](1);
initialWhitelistedTokens[0] = address(wETH);
escrow = new Deploy().deploy(owner, initialWhitelistedTokens, 0);
escrow = new Deploy().deploy(owner, owner, initialWhitelistedTokens, 0);

alice = makeAddr("alice");
bob = makeAddr("bob");
Expand Down
2 changes: 1 addition & 1 deletion test/EscrowWithFee.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ contract Base_Test is Test {
function setUp() public {
address[] memory initialWhitelistedTokens = new address[](1);
initialWhitelistedTokens[0] = address(wETH);
escrow = new Deploy().deploy(owner, initialWhitelistedTokens, Params.BASE_FEE_BPS);
escrow = new Deploy().deploy(owner, owner, initialWhitelistedTokens, Params.BASE_FEE_BPS);

alice = makeAddr("alice");
bob = makeAddr("bob");
Expand Down
Loading