-
Notifications
You must be signed in to change notification settings - Fork 23
Expand file tree
/
Copy pathEscrow.sol
More file actions
31 lines (25 loc) · 1.2 KB
/
Escrow.sol
File metadata and controls
31 lines (25 loc) · 1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.28;
import {Auth} from "./Auth.sol";
import {IERC20} from "./interfaces/IERC20.sol";
import {IEscrow} from "./interfaces/IEscrow.sol";
import {IERC6909} from "./interfaces/IERC6909.sol";
import {SafeTransferLib} from "./libraries/SafeTransferLib.sol";
/// @title Escrow
/// @notice This contract provides custody of ERC20 and ERC6909 tokens.
contract Escrow is Auth, IEscrow {
constructor(address deployer) Auth(deployer) {}
/// @inheritdoc IEscrow
function authTransferTo(address asset, uint256 tokenId, address receiver, uint256 amount) public auth {
if (tokenId == 0) {
uint256 balance = IERC20(asset).balanceOf(address(this));
require(balance >= amount, InsufficientBalance(asset, tokenId, amount, balance));
SafeTransferLib.safeTransfer(asset, receiver, amount);
} else {
uint256 balance = IERC6909(asset).balanceOf(address(this), tokenId);
require(balance >= amount, InsufficientBalance(asset, tokenId, amount, balance));
IERC6909(asset).transfer(receiver, tokenId, amount);
}
emit AuthTransferTo(asset, tokenId, receiver, amount);
}
}