编译器
0.8.20+commit.a1b79de6
文件 1 的 19:AccessControl.sol
pragma solidity ^0.8.0;
import "./IAccessControl.sol";
import "../utils/Context.sol";
import "../utils/Strings.sol";
import "../utils/introspection/ERC165.sol";
abstract contract AccessControl is Context, IAccessControl, ERC165 {
struct RoleData {
mapping(address => bool) members;
bytes32 adminRole;
}
mapping(bytes32 => RoleData) private _roles;
bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;
modifier onlyRole(bytes32 role) {
_checkRole(role);
_;
}
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);
}
function hasRole(bytes32 role, address account) public view virtual override returns (bool) {
return _roles[role].members[account];
}
function _checkRole(bytes32 role) internal view virtual {
_checkRole(role, _msgSender());
}
function _checkRole(bytes32 role, address account) internal view virtual {
if (!hasRole(role, account)) {
revert(
string(
abi.encodePacked(
"AccessControl: account ",
Strings.toHexString(account),
" is missing role ",
Strings.toHexString(uint256(role), 32)
)
)
);
}
}
function getRoleAdmin(bytes32 role) public view virtual override returns (bytes32) {
return _roles[role].adminRole;
}
function grantRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {
_grantRole(role, account);
}
function revokeRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {
_revokeRole(role, account);
}
function renounceRole(bytes32 role, address account) public virtual override {
require(account == _msgSender(), "AccessControl: can only renounce roles for self");
_revokeRole(role, account);
}
function _setupRole(bytes32 role, address account) internal virtual {
_grantRole(role, account);
}
function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {
bytes32 previousAdminRole = getRoleAdmin(role);
_roles[role].adminRole = adminRole;
emit RoleAdminChanged(role, previousAdminRole, adminRole);
}
function _grantRole(bytes32 role, address account) internal virtual {
if (!hasRole(role, account)) {
_roles[role].members[account] = true;
emit RoleGranted(role, account, _msgSender());
}
}
function _revokeRole(bytes32 role, address account) internal virtual {
if (hasRole(role, account)) {
_roles[role].members[account] = false;
emit RoleRevoked(role, account, _msgSender());
}
}
}
文件 2 的 19:CommonTypes.sol
pragma solidity ^0.8.0;
struct SwapInstructions {
uint8 swapperId;
bytes swapPayload;
}
struct FeeData {
bytes4 appId;
bytes4 affiliateId;
uint bridgeFee;
Fee[] appFees;
}
struct Fee {
address recipient;
address token;
uint amount;
}
struct SwapAndExecuteInstructions {
SwapInstructions swapInstructions;
address target;
address paymentOperator;
address refund;
bytes payload;
}
struct BridgeInstructions {
SwapInstructions preBridge;
SwapInstructions postBridge;
uint8 bridgeId;
uint256 dstChainId;
address target;
address paymentOperator;
address refund;
bytes payload;
bytes additionalArgs;
}
文件 3 的 19:Context.sol
pragma solidity ^0.8.0;
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
}
文件 4 的 19:ERC165.sol
pragma solidity ^0.8.0;
import "./IERC165.sol";
abstract contract ERC165 is IERC165 {
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
return interfaceId == type(IERC165).interfaceId;
}
}
文件 5 的 19:IAccessControl.sol
pragma solidity ^0.8.0;
interface IAccessControl {
event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);
event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);
event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);
function hasRole(bytes32 role, address account) external view returns (bool);
function getRoleAdmin(bytes32 role) external view returns (bytes32);
function grantRole(bytes32 role, address account) external;
function revokeRole(bytes32 role, address account) external;
function renounceRole(bytes32 role, address account) external;
}
文件 6 的 19:IBridgeAdapter.sol
pragma solidity ^0.8.0;
import {SwapInstructions} from "../CommonTypes.sol";
interface IBridgeAdapter {
error NoDstBridge();
function getId() external returns (uint8);
function getBridgeToken(
bytes calldata additionalArgs
) external returns (address);
function getBridgedAmount(
uint256 amt2Bridge,
address preBridgeToken,
address postBridgeToken,
bytes calldata additionalArgs
) external returns (uint256);
function bridge(
uint256 amt2Bridge,
SwapInstructions memory postBridge,
uint256 dstChainId,
address target,
address paymentOperator,
bytes memory payload,
bytes calldata additionalArgs,
address refund
) external payable returns (bytes memory);
}
文件 7 的 19:IERC165.sol
pragma solidity ^0.8.0;
interface IERC165 {
function supportsInterface(bytes4 interfaceId) external view returns (bool);
}
文件 8 的 19:IERC20.sol
pragma solidity >=0.6.2;
interface IERC20 {
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(address indexed owner, address indexed spender, uint256 value);
function totalSupply() external view returns (uint256);
function balanceOf(address account) external view returns (uint256);
function transfer(address to, uint256 amount) external returns (bool);
function allowance(address owner, address spender) external view returns (uint256);
function approve(address spender, uint256 amount) external returns (bool);
function transferFrom(address from, address to, uint256 amount) external returns (bool);
function name() external view returns (string memory);
function symbol() external view returns (string memory);
function decimals() external view returns (uint8);
}
文件 9 的 19:ISwapper.sol
pragma solidity ^0.8.0;
import {SwapParams} from "../swappers/SwapParams.sol";
interface ISwapper {
error RouterNotSet();
function getId() external returns (uint8);
function swap(
bytes memory swapPayload
) external returns (address tokenOut, uint256 amountOut);
function updateSwapParams(
SwapParams memory newSwapParams,
bytes memory payload
) external returns (bytes memory);
}
文件 10 的 19:IUTB.sol
pragma solidity ^0.8.0;
import {SwapInstructions, FeeData, BridgeInstructions, SwapAndExecuteInstructions} from "../CommonTypes.sol";
interface IUTB {
event Swapped();
event BridgeCalled();
event RecievedFromBridge();
error ProtocolFeeCannotBeFetched();
error UTBPaused();
error NotEnoughNative();
error OnlyBridgeAdapter();
function swapAndExecute(
SwapAndExecuteInstructions memory instructions,
FeeData memory feeData,
bytes memory signature
) external payable;
function bridgeAndExecute(
BridgeInstructions memory instructions,
FeeData memory feeData,
bytes memory signature
) external payable returns (bytes memory);
function receiveFromBridge(
SwapInstructions memory postBridge,
address target,
address paymentOperator,
bytes memory payload,
address refund,
uint8 bridgeId
) external payable;
function registerBridge(address bridge) external;
function registerSwapper(address swapper) external;
function setExecutor(address _executor) external;
function setFeeManager(address _feeManager) external;
function setWrapped(address _wrapped) external;
}
文件 11 的 19:IUTBExecutor.sol
pragma solidity ^0.8.0;
interface IUTBExecutor {
function execute(
address target,
address paymentOperator,
bytes memory payload,
address token,
uint256 amount,
address refund
) external payable;
function execute(
address target,
address paymentOperator,
bytes memory payload,
address token,
uint256 amount,
address refund,
uint256 extraNative
) external;
}
文件 12 的 19:IUTBFeeManager.sol
pragma solidity ^0.8.0;
interface IUTBFeeManager {
error WrongSig();
error WrongSigLength();
function verifySignature(
bytes memory packedInfo,
bytes memory signature
) external;
function setSigner(address _signer) external;
}
文件 13 的 19:IWETH.sol
pragma solidity ^0.8.0;
import {IERC20} from "forge-std/interfaces/IERC20.sol";
interface IWETH is IERC20 {
function deposit() external payable;
function withdraw(uint) external;
}
文件 14 的 19:Math.sol
pragma solidity ^0.8.0;
library Math {
enum Rounding {
Down,
Up,
Zero
}
function max(uint256 a, uint256 b) internal pure returns (uint256) {
return a > b ? a : b;
}
function min(uint256 a, uint256 b) internal pure returns (uint256) {
return a < b ? a : b;
}
function average(uint256 a, uint256 b) internal pure returns (uint256) {
return (a & b) + (a ^ b) / 2;
}
function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {
return a == 0 ? 0 : (a - 1) / b + 1;
}
function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) {
unchecked {
uint256 prod0;
uint256 prod1;
assembly {
let mm := mulmod(x, y, not(0))
prod0 := mul(x, y)
prod1 := sub(sub(mm, prod0), lt(mm, prod0))
}
if (prod1 == 0) {
return prod0 / denominator;
}
require(denominator > prod1, "Math: mulDiv overflow");
uint256 remainder;
assembly {
remainder := mulmod(x, y, denominator)
prod1 := sub(prod1, gt(remainder, prod0))
prod0 := sub(prod0, remainder)
}
uint256 twos = denominator & (~denominator + 1);
assembly {
denominator := div(denominator, twos)
prod0 := div(prod0, twos)
twos := add(div(sub(0, twos), twos), 1)
}
prod0 |= prod1 * twos;
uint256 inverse = (3 * denominator) ^ 2;
inverse *= 2 - denominator * inverse;
inverse *= 2 - denominator * inverse;
inverse *= 2 - denominator * inverse;
inverse *= 2 - denominator * inverse;
inverse *= 2 - denominator * inverse;
inverse *= 2 - denominator * inverse;
result = prod0 * inverse;
return result;
}
}
function mulDiv(uint256 x, uint256 y, uint256 denominator, Rounding rounding) internal pure returns (uint256) {
uint256 result = mulDiv(x, y, denominator);
if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) {
result += 1;
}
return result;
}
function sqrt(uint256 a) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
uint256 result = 1 << (log2(a) >> 1);
unchecked {
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
return min(result, a / result);
}
}
function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = sqrt(a);
return result + (rounding == Rounding.Up && result * result < a ? 1 : 0);
}
}
function log2(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
unchecked {
if (value >> 128 > 0) {
value >>= 128;
result += 128;
}
if (value >> 64 > 0) {
value >>= 64;
result += 64;
}
if (value >> 32 > 0) {
value >>= 32;
result += 32;
}
if (value >> 16 > 0) {
value >>= 16;
result += 16;
}
if (value >> 8 > 0) {
value >>= 8;
result += 8;
}
if (value >> 4 > 0) {
value >>= 4;
result += 4;
}
if (value >> 2 > 0) {
value >>= 2;
result += 2;
}
if (value >> 1 > 0) {
result += 1;
}
}
return result;
}
function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log2(value);
return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0);
}
}
function log10(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
unchecked {
if (value >= 10 ** 64) {
value /= 10 ** 64;
result += 64;
}
if (value >= 10 ** 32) {
value /= 10 ** 32;
result += 32;
}
if (value >= 10 ** 16) {
value /= 10 ** 16;
result += 16;
}
if (value >= 10 ** 8) {
value /= 10 ** 8;
result += 8;
}
if (value >= 10 ** 4) {
value /= 10 ** 4;
result += 4;
}
if (value >= 10 ** 2) {
value /= 10 ** 2;
result += 2;
}
if (value >= 10 ** 1) {
result += 1;
}
}
return result;
}
function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log10(value);
return result + (rounding == Rounding.Up && 10 ** result < value ? 1 : 0);
}
}
function log256(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
unchecked {
if (value >> 128 > 0) {
value >>= 128;
result += 16;
}
if (value >> 64 > 0) {
value >>= 64;
result += 8;
}
if (value >> 32 > 0) {
value >>= 32;
result += 4;
}
if (value >> 16 > 0) {
value >>= 16;
result += 2;
}
if (value >> 8 > 0) {
result += 1;
}
}
return result;
}
function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log256(value);
return result + (rounding == Rounding.Up && 1 << (result << 3) < value ? 1 : 0);
}
}
}
文件 15 的 19:Roles.sol
pragma solidity ^0.8.13;
import {AccessControl} from "@openzeppelin/contracts/access/AccessControl.sol";
abstract contract Roles is AccessControl {
constructor(address admin) {
_grantRole(DEFAULT_ADMIN_ROLE, admin);
}
modifier onlyAdmin() {
require(hasRole(DEFAULT_ADMIN_ROLE, msg.sender), "Only admin");
_;
}
}
文件 16 的 19:SignedMath.sol
pragma solidity ^0.8.0;
library SignedMath {
function max(int256 a, int256 b) internal pure returns (int256) {
return a > b ? a : b;
}
function min(int256 a, int256 b) internal pure returns (int256) {
return a < b ? a : b;
}
function average(int256 a, int256 b) internal pure returns (int256) {
int256 x = (a & b) + ((a ^ b) >> 1);
return x + (int256(uint256(x) >> 255) & (a ^ b));
}
function abs(int256 n) internal pure returns (uint256) {
unchecked {
return uint256(n >= 0 ? n : -n);
}
}
}
文件 17 的 19:Strings.sol
pragma solidity ^0.8.0;
import "./math/Math.sol";
import "./math/SignedMath.sol";
library Strings {
bytes16 private constant _SYMBOLS = "0123456789abcdef";
uint8 private constant _ADDRESS_LENGTH = 20;
function toString(uint256 value) internal pure returns (string memory) {
unchecked {
uint256 length = Math.log10(value) + 1;
string memory buffer = new string(length);
uint256 ptr;
assembly {
ptr := add(buffer, add(32, length))
}
while (true) {
ptr--;
assembly {
mstore8(ptr, byte(mod(value, 10), _SYMBOLS))
}
value /= 10;
if (value == 0) break;
}
return buffer;
}
}
function toString(int256 value) internal pure returns (string memory) {
return string(abi.encodePacked(value < 0 ? "-" : "", toString(SignedMath.abs(value))));
}
function toHexString(uint256 value) internal pure returns (string memory) {
unchecked {
return toHexString(value, Math.log256(value) + 1);
}
}
function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
bytes memory buffer = new bytes(2 * length + 2);
buffer[0] = "0";
buffer[1] = "x";
for (uint256 i = 2 * length + 1; i > 1; --i) {
buffer[i] = _SYMBOLS[value & 0xf];
value >>= 4;
}
require(value == 0, "Strings: hex length insufficient");
return string(buffer);
}
function toHexString(address addr) internal pure returns (string memory) {
return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);
}
function equal(string memory a, string memory b) internal pure returns (bool) {
return keccak256(bytes(a)) == keccak256(bytes(b));
}
}
文件 18 的 19:SwapParams.sol
pragma solidity ^0.8.0;
library SwapDirection {
uint8 constant EXACT_IN = 0;
uint8 constant EXACT_OUT = 1;
}
struct SwapParams {
uint256 amountIn;
uint256 amountOut;
address tokenIn;
address tokenOut;
uint8 direction;
bytes path;
}
文件 19 的 19:UTB.sol
pragma solidity ^0.8.0;
import {Roles} from "decent-bridge/src/utils/Roles.sol";
import {SwapParams} from "./swappers/SwapParams.sol";
import {IUTB} from "./interfaces/IUTB.sol";
import {IUTBExecutor} from "./interfaces/IUTBExecutor.sol";
import {IERC20} from "forge-std/interfaces/IERC20.sol";
import {IWETH} from "decent-bridge/src/interfaces/IWETH.sol";
import {IUTBFeeManager} from "./interfaces/IUTBFeeManager.sol";
import {IBridgeAdapter} from "./interfaces/IBridgeAdapter.sol";
import {ISwapper} from "./interfaces/ISwapper.sol";
import {SwapInstructions, FeeData, Fee, BridgeInstructions, SwapAndExecuteInstructions} from "./CommonTypes.sol";
contract UTB is IUTB, Roles {
constructor() Roles(msg.sender) {}
IUTBExecutor public executor;
IUTBFeeManager public feeManager;
IWETH public wrapped;
mapping(uint8 => address) public swappers;
mapping(uint8 => address) public bridgeAdapters;
bool public isActive = true;
modifier isUtbActive() {
if (!isActive) revert UTBPaused();
_;
}
function _retrieveAndCollectFees(
FeeData calldata feeData,
bytes memory packedInfo,
bytes calldata signature
) private returns (uint256 value) {
if (address(feeManager) != address(0)) {
feeManager.verifySignature(packedInfo, signature);
value += feeData.bridgeFee;
Fee[] memory fees = feeData.appFees;
for (uint i = 0; i < fees.length; i++) {
Fee memory fee = fees[i];
if (fee.token != address(0)) {
IERC20(fee.token).transferFrom(
msg.sender,
fee.recipient,
fee.amount
);
} else {
(bool success, ) = address(fee.recipient).call{value: fee.amount}("");
value += fee.amount;
if (!success) revert ProtocolFeeCannotBeFetched();
}
}
}
}
function _refundLeftover(address to, uint256 leftover) internal {
if (leftover > 0) {
(bool success, ) = to.call{value: leftover}("");
require(success, "failed to refund leftover");
}
}
function setExecutor(address _executor) public onlyAdmin {
executor = IUTBExecutor(_executor);
}
function setWrapped(address _wrapped) public onlyAdmin {
wrapped = IWETH(_wrapped);
}
function setFeeManager(address _feeManager) public onlyAdmin {
feeManager = IUTBFeeManager(_feeManager);
}
function toggleActive() public onlyAdmin {
isActive = !isActive;
}
function performSwap(
SwapInstructions memory swapInstructions,
bool retrieveTokenIn
) private returns (address tokenOut, uint256 amountOut, uint256 value) {
ISwapper swapper = ISwapper(swappers[swapInstructions.swapperId]);
SwapParams memory swapParams = abi.decode(
swapInstructions.swapPayload,
(SwapParams)
);
if (swapParams.tokenIn == address(0)) {
if (msg.value < swapParams.amountIn) revert NotEnoughNative();
wrapped.deposit{value: swapParams.amountIn}();
value += swapParams.amountIn;
swapParams.tokenIn = address(wrapped);
swapInstructions.swapPayload = swapper.updateSwapParams(
swapParams,
swapInstructions.swapPayload
);
} else if (retrieveTokenIn) {
IERC20(swapParams.tokenIn).transferFrom(
msg.sender,
address(this),
swapParams.amountIn
);
}
IERC20(swapParams.tokenIn).approve(
address(swapper),
swapParams.amountIn
);
(tokenOut, amountOut) = swapper.swap(swapInstructions.swapPayload);
if (tokenOut == address(0)) {
wrapped.withdraw(amountOut);
}
}
function swapAndExecute(
SwapAndExecuteInstructions calldata instructions,
FeeData calldata feeData,
bytes calldata signature
)
public
payable
isUtbActive
{
uint256 value = _retrieveAndCollectFees(feeData, abi.encode(instructions, feeData), signature);
value += _swapAndExecute(
instructions.swapInstructions,
instructions.target,
instructions.paymentOperator,
instructions.payload,
instructions.refund
);
_refundLeftover(instructions.refund, msg.value - value);
emit Swapped();
}
function _swapAndExecute(
SwapInstructions memory swapInstructions,
address target,
address paymentOperator,
bytes memory payload,
address refund
) private returns (uint256 value) {
address tokenOut;
uint256 amountOut;
(tokenOut, amountOut, value) = performSwap(swapInstructions, true);
if (tokenOut == address(0)) {
executor.execute{value: amountOut}(
target,
paymentOperator,
payload,
tokenOut,
amountOut,
refund
);
} else {
IERC20(tokenOut).approve(address(executor), amountOut);
executor.execute(
target,
paymentOperator,
payload,
tokenOut,
amountOut,
refund
);
}
}
function swapAndModifyPostBridge(
BridgeInstructions memory instructions
)
private
returns (
uint256 amount2Bridge,
BridgeInstructions memory updatedInstructions,
uint256 value
)
{
address tokenOut;
uint256 amountOut;
(tokenOut, amountOut, value) = performSwap(
instructions.preBridge, true
);
SwapParams memory newPostSwapParams = abi.decode(
instructions.postBridge.swapPayload,
(SwapParams)
);
newPostSwapParams.amountIn = IBridgeAdapter(
bridgeAdapters[instructions.bridgeId]
).getBridgedAmount(amountOut, tokenOut, newPostSwapParams.tokenIn, instructions.additionalArgs);
updatedInstructions = instructions;
updatedInstructions.postBridge.swapPayload = ISwapper(swappers[
instructions.postBridge.swapperId
]).updateSwapParams(
newPostSwapParams,
instructions.postBridge.swapPayload
);
amount2Bridge = amountOut;
}
function approveAndCheckIfNative(
BridgeInstructions memory instructions,
uint256 amt2Bridge
) private returns (bool) {
IBridgeAdapter bridgeAdapter = IBridgeAdapter(bridgeAdapters[instructions.bridgeId]);
address bridgeToken = bridgeAdapter.getBridgeToken(
instructions.additionalArgs
);
if (bridgeToken != address(0)) {
IERC20(bridgeToken).approve(address(bridgeAdapter), amt2Bridge);
return false;
}
return true;
}
function bridgeAndExecute(
BridgeInstructions calldata instructions,
FeeData calldata feeData,
bytes calldata signature
)
public
payable
isUtbActive
returns (bytes memory)
{
uint256 feeValue = _retrieveAndCollectFees(feeData, abi.encode(instructions, feeData), signature);
(
uint256 amt2Bridge,
BridgeInstructions memory updatedInstructions,
uint256 swapValue
) = swapAndModifyPostBridge(instructions);
_refundLeftover(instructions.refund, msg.value - feeValue - swapValue);
return callBridge(amt2Bridge, feeData.bridgeFee, updatedInstructions);
}
function callBridge(
uint256 amt2Bridge,
uint bridgeFee,
BridgeInstructions memory instructions
) private returns (bytes memory) {
bool native = approveAndCheckIfNative(instructions, amt2Bridge);
emit BridgeCalled();
return
IBridgeAdapter(bridgeAdapters[instructions.bridgeId]).bridge{
value: bridgeFee + (native ? amt2Bridge : 0)
}(
amt2Bridge,
instructions.postBridge,
instructions.dstChainId,
instructions.target,
instructions.paymentOperator,
instructions.payload,
instructions.additionalArgs,
instructions.refund
);
}
function receiveFromBridge(
SwapInstructions memory postBridge,
address target,
address paymentOperator,
bytes memory payload,
address refund,
uint8 bridgeId
) public payable {
if (msg.sender != bridgeAdapters[bridgeId]) revert OnlyBridgeAdapter();
emit RecievedFromBridge();
_swapAndExecute(postBridge, target, paymentOperator, payload, refund);
}
function registerSwapper(address swapper) public onlyAdmin {
ISwapper s = ISwapper(swapper);
swappers[s.getId()] = swapper;
}
function registerBridge(address bridge) public onlyAdmin {
IBridgeAdapter b = IBridgeAdapter(bridge);
bridgeAdapters[b.getId()] = bridge;
}
receive() external payable {}
fallback() external payable {}
}
{
"compilationTarget": {
"src/UTB.sol": "UTB"
},
"evmVersion": "paris",
"libraries": {},
"metadata": {
"bytecodeHash": "ipfs"
},
"optimizer": {
"enabled": true,
"runs": 200
},
"remappings": [
":@openzeppelin/=lib/decent-bridge/lib/openzeppelin-contracts/",
":@openzeppelin/contracts/=lib/decent-bridge/lib/openzeppelin-contracts/contracts/",
":@uniswap/swap-contracts/=lib/swap-router-contracts/contracts/",
":@uniswap/v3-core/=lib/v3-core/",
":@uniswap/v3-periphery/=lib/v3-periphery/",
":LayerZero/=lib/forge-toolkit/lib/LayerZero/contracts/",
":better-deployer/=lib/decent-bridge/lib/better-deployer/src/",
":decent-bridge/=lib/decent-bridge/",
":ds-test/=lib/forge-std/lib/ds-test/src/",
":erc4626-tests/=lib/decent-bridge/lib/openzeppelin-contracts/lib/erc4626-tests/",
":forge-std/=lib/forge-std/src/",
":forge-toolkit/=lib/forge-toolkit/src/",
":openzeppelin-contracts/=lib/decent-bridge/lib/openzeppelin-contracts/contracts/",
":openzeppelin/=lib/decent-bridge/lib/openzeppelin-contracts/contracts/",
":solidity-examples/=lib/solidity-examples/contracts/",
":solidity-stringutils/=lib/decent-bridge/lib/solidity-stringutils/",
":solmate/=lib/solmate/src/",
":swap-router-contracts/=lib/swap-router-contracts/contracts/",
":v3-core/=lib/v3-core/",
":v3-periphery/=lib/v3-periphery/contracts/",
"lib/forge-std:ds-test/=lib/decent-bridge/lib/forge-std/lib/ds-test/src/",
"lib/openzeppelin-contracts:ds-test/=lib/decent-bridge/lib/openzeppelin-contracts/lib/forge-std/lib/ds-test/src/",
"lib/openzeppelin-contracts:erc4626-tests/=lib/decent-bridge/lib/openzeppelin-contracts/lib/erc4626-tests/",
"lib/openzeppelin-contracts:forge-std/=lib/decent-bridge/lib/openzeppelin-contracts/lib/forge-std/src/",
"lib/openzeppelin-contracts:openzeppelin/=lib/decent-bridge/lib/openzeppelin-contracts/contracts/"
]
}
[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"NotEnoughNative","type":"error"},{"inputs":[],"name":"OnlyBridgeAdapter","type":"error"},{"inputs":[],"name":"ProtocolFeeCannotBeFetched","type":"error"},{"inputs":[],"name":"UTBPaused","type":"error"},{"anonymous":false,"inputs":[],"name":"BridgeCalled","type":"event"},{"anonymous":false,"inputs":[],"name":"RecievedFromBridge","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"previousAdminRole","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"newAdminRole","type":"bytes32"}],"name":"RoleAdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleGranted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleRevoked","type":"event"},{"anonymous":false,"inputs":[],"name":"Swapped","type":"event"},{"stateMutability":"payable","type":"fallback"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint8","name":"","type":"uint8"}],"name":"bridgeAdapters","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"components":[{"internalType":"uint8","name":"swapperId","type":"uint8"},{"internalType":"bytes","name":"swapPayload","type":"bytes"}],"internalType":"struct SwapInstructions","name":"preBridge","type":"tuple"},{"components":[{"internalType":"uint8","name":"swapperId","type":"uint8"},{"internalType":"bytes","name":"swapPayload","type":"bytes"}],"internalType":"struct SwapInstructions","name":"postBridge","type":"tuple"},{"internalType":"uint8","name":"bridgeId","type":"uint8"},{"internalType":"uint256","name":"dstChainId","type":"uint256"},{"internalType":"address","name":"target","type":"address"},{"internalType":"address","name":"paymentOperator","type":"address"},{"internalType":"address","name":"refund","type":"address"},{"internalType":"bytes","name":"payload","type":"bytes"},{"internalType":"bytes","name":"additionalArgs","type":"bytes"}],"internalType":"struct BridgeInstructions","name":"instructions","type":"tuple"},{"components":[{"internalType":"bytes4","name":"appId","type":"bytes4"},{"internalType":"bytes4","name":"affiliateId","type":"bytes4"},{"internalType":"uint256","name":"bridgeFee","type":"uint256"},{"components":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"internalType":"struct Fee[]","name":"appFees","type":"tuple[]"}],"internalType":"struct FeeData","name":"feeData","type":"tuple"},{"internalType":"bytes","name":"signature","type":"bytes"}],"name":"bridgeAndExecute","outputs":[{"internalType":"bytes","name":"","type":"bytes"}],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"executor","outputs":[{"internalType":"contract IUTBExecutor","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"feeManager","outputs":[{"internalType":"contract IUTBFeeManager","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleAdmin","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"grantRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"hasRole","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"isActive","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"uint8","name":"swapperId","type":"uint8"},{"internalType":"bytes","name":"swapPayload","type":"bytes"}],"internalType":"struct SwapInstructions","name":"postBridge","type":"tuple"},{"internalType":"address","name":"target","type":"address"},{"internalType":"address","name":"paymentOperator","type":"address"},{"internalType":"bytes","name":"payload","type":"bytes"},{"internalType":"address","name":"refund","type":"address"},{"internalType":"uint8","name":"bridgeId","type":"uint8"}],"name":"receiveFromBridge","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"bridge","type":"address"}],"name":"registerBridge","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"swapper","type":"address"}],"name":"registerSwapper","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"renounceRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"revokeRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_executor","type":"address"}],"name":"setExecutor","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_feeManager","type":"address"}],"name":"setFeeManager","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_wrapped","type":"address"}],"name":"setWrapped","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"components":[{"internalType":"uint8","name":"swapperId","type":"uint8"},{"internalType":"bytes","name":"swapPayload","type":"bytes"}],"internalType":"struct SwapInstructions","name":"swapInstructions","type":"tuple"},{"internalType":"address","name":"target","type":"address"},{"internalType":"address","name":"paymentOperator","type":"address"},{"internalType":"address","name":"refund","type":"address"},{"internalType":"bytes","name":"payload","type":"bytes"}],"internalType":"struct SwapAndExecuteInstructions","name":"instructions","type":"tuple"},{"components":[{"internalType":"bytes4","name":"appId","type":"bytes4"},{"internalType":"bytes4","name":"affiliateId","type":"bytes4"},{"internalType":"uint256","name":"bridgeFee","type":"uint256"},{"components":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"internalType":"struct Fee[]","name":"appFees","type":"tuple[]"}],"internalType":"struct FeeData","name":"feeData","type":"tuple"},{"internalType":"bytes","name":"signature","type":"bytes"}],"name":"swapAndExecute","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint8","name":"","type":"uint8"}],"name":"swappers","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"toggleActive","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"wrapped","outputs":[{"internalType":"contract IWETH","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"stateMutability":"payable","type":"receive"}]