Contract

0xF04C3aA2AD0B7bb95f7e3b99120EA565298D32A5

Overview

S Balance

Sonic LogoSonic LogoSonic Logo0 S

S Value

-

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To

There are no matching entries

1 Internal Transaction found.

Latest 1 internal transaction

Parent Transaction Hash Block From To
6189642024-12-18 21:10:1311 days ago1734556213  Contract Creation0 S
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
PaymentSplitter

Compiler Version
v0.8.21+commit.d9974bed

Optimization Enabled:
Yes with 200 runs

Other Settings:
london EvmVersion
File 1 of 5 : PaymentSplitter.sol
pragma solidity 0.8.21;

import {FixedPointMathLib} from "@solmate/utils/FixedPointMathLib.sol";
import {ERC20} from "@solmate/tokens/ERC20.sol";
import {SafeTransferLib} from "@solmate/utils/SafeTransferLib.sol";
import {Auth, Authority} from "@solmate/auth/Auth.sol";

contract PaymentSplitter is Auth {
    using FixedPointMathLib for uint256;
    using SafeTransferLib for ERC20;

    //============================== STRUCTS ===============================

    /**
     * @dev Represents a split of fee payments.
     * @param percent The percentage of the total fee to send to this address.
     * @param to The address to send the split to.
     */
    struct SplitInformation {
        uint96 percent;
        address to;
    }

    //============================== STATE ===============================

    /**
     * @notice Contains split information for each address.
     */
    SplitInformation[] public splits;

    //============================== IMMUTABLES ===============================

    /**
     * @notice The cumualative percents of all splits.
     */
    uint256 internal immutable totalPercent;

    constructor(address _owner, uint256 _totalPercent, SplitInformation[] memory _splits)
        Auth(_owner, Authority(address(0)))
    {
        totalPercent = _totalPercent;
        uint256 totalSplitPercent;
        for (uint256 i = 0; i < _splits.length; i++) {
            totalSplitPercent += _splits[i].percent;
            splits.push(_splits[i]);
        }

        require(totalSplitPercent == totalPercent, "PaymentSplitter: total percent is not 100%");
    }

    // ========================================= ADMIN =========================================

    /**
     * @notice Adjusts the splits of fee payments.
     */
    function adjustSplits(SplitInformation[] calldata _splits) external requiresAuth {
        // Empty out old splits.
        uint256 splitsLength = splits.length;
        for (uint256 i; i < splitsLength; i++) {
            splits.pop();
        }

        uint256 totalSplitPercent;
        for (uint256 i = 0; i < _splits.length; i++) {
            totalSplitPercent += _splits[i].percent;
            splits.push(_splits[i]);
        }

        require(totalSplitPercent == totalPercent, "PaymentSplitter: total percent is not 100%");
    }

    /**
     * @notice Rescues any ERC20 asset sent to this contract.
     */
    function rescueERC20(ERC20 asset) external requiresAuth {
        asset.safeTransfer(msg.sender, asset.balanceOf(address(this)));
    }

    // ========================================= PAYOUT =========================================

    /**
     * @notice Pays out the splits to the respective addresses.
     */
    function payoutSplits(ERC20 asset) external requiresAuth {
        // Subtract 1 from balance so we revert if balance is 0, and to also leave dust in this contract,
        // to reduce gas costs for future transactions.
        uint256 balance = asset.balanceOf(address(this)) - 1;
        for (uint256 i = 0; i < splits.length; ++i) {
            uint256 amount = balance.mulDivDown(splits[i].percent, totalPercent);
            asset.safeTransfer(splits[i].to, amount);
        }
    }
}

File 2 of 5 : FixedPointMathLib.sol
// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity >=0.8.0;

/// @notice Arithmetic library with operations for fixed-point numbers.
/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/utils/FixedPointMathLib.sol)
/// @author Inspired by USM (https://github.com/usmfum/USM/blob/master/contracts/WadMath.sol)
library FixedPointMathLib {
    /*//////////////////////////////////////////////////////////////
                    SIMPLIFIED FIXED POINT OPERATIONS
    //////////////////////////////////////////////////////////////*/

    uint256 internal constant MAX_UINT256 = 2**256 - 1;

    uint256 internal constant WAD = 1e18; // The scalar of ETH and most ERC20s.

    function mulWadDown(uint256 x, uint256 y) internal pure returns (uint256) {
        return mulDivDown(x, y, WAD); // Equivalent to (x * y) / WAD rounded down.
    }

    function mulWadUp(uint256 x, uint256 y) internal pure returns (uint256) {
        return mulDivUp(x, y, WAD); // Equivalent to (x * y) / WAD rounded up.
    }

    function divWadDown(uint256 x, uint256 y) internal pure returns (uint256) {
        return mulDivDown(x, WAD, y); // Equivalent to (x * WAD) / y rounded down.
    }

    function divWadUp(uint256 x, uint256 y) internal pure returns (uint256) {
        return mulDivUp(x, WAD, y); // Equivalent to (x * WAD) / y rounded up.
    }

    /*//////////////////////////////////////////////////////////////
                    LOW LEVEL FIXED POINT OPERATIONS
    //////////////////////////////////////////////////////////////*/

    function mulDivDown(
        uint256 x,
        uint256 y,
        uint256 denominator
    ) internal pure returns (uint256 z) {
        /// @solidity memory-safe-assembly
        assembly {
            // Equivalent to require(denominator != 0 && (y == 0 || x <= type(uint256).max / y))
            if iszero(mul(denominator, iszero(mul(y, gt(x, div(MAX_UINT256, y)))))) {
                revert(0, 0)
            }

            // Divide x * y by the denominator.
            z := div(mul(x, y), denominator)
        }
    }

    function mulDivUp(
        uint256 x,
        uint256 y,
        uint256 denominator
    ) internal pure returns (uint256 z) {
        /// @solidity memory-safe-assembly
        assembly {
            // Equivalent to require(denominator != 0 && (y == 0 || x <= type(uint256).max / y))
            if iszero(mul(denominator, iszero(mul(y, gt(x, div(MAX_UINT256, y)))))) {
                revert(0, 0)
            }

            // If x * y modulo the denominator is strictly greater than 0,
            // 1 is added to round up the division of x * y by the denominator.
            z := add(gt(mod(mul(x, y), denominator), 0), div(mul(x, y), denominator))
        }
    }

    function rpow(
        uint256 x,
        uint256 n,
        uint256 scalar
    ) internal pure returns (uint256 z) {
        /// @solidity memory-safe-assembly
        assembly {
            switch x
            case 0 {
                switch n
                case 0 {
                    // 0 ** 0 = 1
                    z := scalar
                }
                default {
                    // 0 ** n = 0
                    z := 0
                }
            }
            default {
                switch mod(n, 2)
                case 0 {
                    // If n is even, store scalar in z for now.
                    z := scalar
                }
                default {
                    // If n is odd, store x in z for now.
                    z := x
                }

                // Shifting right by 1 is like dividing by 2.
                let half := shr(1, scalar)

                for {
                    // Shift n right by 1 before looping to halve it.
                    n := shr(1, n)
                } n {
                    // Shift n right by 1 each iteration to halve it.
                    n := shr(1, n)
                } {
                    // Revert immediately if x ** 2 would overflow.
                    // Equivalent to iszero(eq(div(xx, x), x)) here.
                    if shr(128, x) {
                        revert(0, 0)
                    }

                    // Store x squared.
                    let xx := mul(x, x)

                    // Round to the nearest number.
                    let xxRound := add(xx, half)

                    // Revert if xx + half overflowed.
                    if lt(xxRound, xx) {
                        revert(0, 0)
                    }

                    // Set x to scaled xxRound.
                    x := div(xxRound, scalar)

                    // If n is even:
                    if mod(n, 2) {
                        // Compute z * x.
                        let zx := mul(z, x)

                        // If z * x overflowed:
                        if iszero(eq(div(zx, x), z)) {
                            // Revert if x is non-zero.
                            if iszero(iszero(x)) {
                                revert(0, 0)
                            }
                        }

                        // Round to the nearest number.
                        let zxRound := add(zx, half)

                        // Revert if zx + half overflowed.
                        if lt(zxRound, zx) {
                            revert(0, 0)
                        }

                        // Return properly scaled zxRound.
                        z := div(zxRound, scalar)
                    }
                }
            }
        }
    }

    /*//////////////////////////////////////////////////////////////
                        GENERAL NUMBER UTILITIES
    //////////////////////////////////////////////////////////////*/

    function sqrt(uint256 x) internal pure returns (uint256 z) {
        /// @solidity memory-safe-assembly
        assembly {
            let y := x // We start y at x, which will help us make our initial estimate.

            z := 181 // The "correct" value is 1, but this saves a multiplication later.

            // This segment is to get a reasonable initial estimate for the Babylonian method. With a bad
            // start, the correct # of bits increases ~linearly each iteration instead of ~quadratically.

            // We check y >= 2^(k + 8) but shift right by k bits
            // each branch to ensure that if x >= 256, then y >= 256.
            if iszero(lt(y, 0x10000000000000000000000000000000000)) {
                y := shr(128, y)
                z := shl(64, z)
            }
            if iszero(lt(y, 0x1000000000000000000)) {
                y := shr(64, y)
                z := shl(32, z)
            }
            if iszero(lt(y, 0x10000000000)) {
                y := shr(32, y)
                z := shl(16, z)
            }
            if iszero(lt(y, 0x1000000)) {
                y := shr(16, y)
                z := shl(8, z)
            }

            // Goal was to get z*z*y within a small factor of x. More iterations could
            // get y in a tighter range. Currently, we will have y in [256, 256*2^16).
            // We ensured y >= 256 so that the relative difference between y and y+1 is small.
            // That's not possible if x < 256 but we can just verify those cases exhaustively.

            // Now, z*z*y <= x < z*z*(y+1), and y <= 2^(16+8), and either y >= 256, or x < 256.
            // Correctness can be checked exhaustively for x < 256, so we assume y >= 256.
            // Then z*sqrt(y) is within sqrt(257)/sqrt(256) of sqrt(x), or about 20bps.

            // For s in the range [1/256, 256], the estimate f(s) = (181/1024) * (s+1) is in the range
            // (1/2.84 * sqrt(s), 2.84 * sqrt(s)), with largest error when s = 1 and when s = 256 or 1/256.

            // Since y is in [256, 256*2^16), let a = y/65536, so that a is in [1/256, 256). Then we can estimate
            // sqrt(y) using sqrt(65536) * 181/1024 * (a + 1) = 181/4 * (y + 65536)/65536 = 181 * (y + 65536)/2^18.

            // There is no overflow risk here since y < 2^136 after the first branch above.
            z := shr(18, mul(z, add(y, 65536))) // A mul() is saved from starting z at 181.

            // Given the worst case multiplicative error of 2.84 above, 7 iterations should be enough.
            z := shr(1, add(z, div(x, z)))
            z := shr(1, add(z, div(x, z)))
            z := shr(1, add(z, div(x, z)))
            z := shr(1, add(z, div(x, z)))
            z := shr(1, add(z, div(x, z)))
            z := shr(1, add(z, div(x, z)))
            z := shr(1, add(z, div(x, z)))

            // If x+1 is a perfect square, the Babylonian method cycles between
            // floor(sqrt(x)) and ceil(sqrt(x)). This statement ensures we return floor.
            // See: https://en.wikipedia.org/wiki/Integer_square_root#Using_only_integer_division
            // Since the ceil is rare, we save gas on the assignment and repeat division in the rare case.
            // If you don't care whether the floor or ceil square root is returned, you can remove this statement.
            z := sub(z, lt(div(x, z), z))
        }
    }

    function unsafeMod(uint256 x, uint256 y) internal pure returns (uint256 z) {
        /// @solidity memory-safe-assembly
        assembly {
            // Mod x by y. Note this will return
            // 0 instead of reverting if y is zero.
            z := mod(x, y)
        }
    }

    function unsafeDiv(uint256 x, uint256 y) internal pure returns (uint256 r) {
        /// @solidity memory-safe-assembly
        assembly {
            // Divide x by y. Note this will return
            // 0 instead of reverting if y is zero.
            r := div(x, y)
        }
    }

    function unsafeDivUp(uint256 x, uint256 y) internal pure returns (uint256 z) {
        /// @solidity memory-safe-assembly
        assembly {
            // Add 1 to x * y if x % y > 0. Note this will
            // return 0 instead of reverting if y is zero.
            z := add(gt(mod(x, y), 0), div(x, y))
        }
    }
}

File 3 of 5 : ERC20.sol
// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity >=0.8.0;

/// @notice Modern and gas efficient ERC20 + EIP-2612 implementation.
/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/tokens/ERC20.sol)
/// @author Modified from Uniswap (https://github.com/Uniswap/uniswap-v2-core/blob/master/contracts/UniswapV2ERC20.sol)
/// @dev Do not manually set balances without updating totalSupply, as the sum of all user balances must not exceed it.
abstract contract ERC20 {
    /*//////////////////////////////////////////////////////////////
                                 EVENTS
    //////////////////////////////////////////////////////////////*/

    event Transfer(address indexed from, address indexed to, uint256 amount);

    event Approval(address indexed owner, address indexed spender, uint256 amount);

    /*//////////////////////////////////////////////////////////////
                            METADATA STORAGE
    //////////////////////////////////////////////////////////////*/

    string public name;

    string public symbol;

    uint8 public immutable decimals;

    /*//////////////////////////////////////////////////////////////
                              ERC20 STORAGE
    //////////////////////////////////////////////////////////////*/

    uint256 public totalSupply;

    mapping(address => uint256) public balanceOf;

    mapping(address => mapping(address => uint256)) public allowance;

    /*//////////////////////////////////////////////////////////////
                            EIP-2612 STORAGE
    //////////////////////////////////////////////////////////////*/

    uint256 internal immutable INITIAL_CHAIN_ID;

    bytes32 internal immutable INITIAL_DOMAIN_SEPARATOR;

    mapping(address => uint256) public nonces;

    /*//////////////////////////////////////////////////////////////
                               CONSTRUCTOR
    //////////////////////////////////////////////////////////////*/

    constructor(
        string memory _name,
        string memory _symbol,
        uint8 _decimals
    ) {
        name = _name;
        symbol = _symbol;
        decimals = _decimals;

        INITIAL_CHAIN_ID = block.chainid;
        INITIAL_DOMAIN_SEPARATOR = computeDomainSeparator();
    }

    /*//////////////////////////////////////////////////////////////
                               ERC20 LOGIC
    //////////////////////////////////////////////////////////////*/

    function approve(address spender, uint256 amount) public virtual returns (bool) {
        allowance[msg.sender][spender] = amount;

        emit Approval(msg.sender, spender, amount);

        return true;
    }

    function transfer(address to, uint256 amount) public virtual returns (bool) {
        balanceOf[msg.sender] -= amount;

        // Cannot overflow because the sum of all user
        // balances can't exceed the max uint256 value.
        unchecked {
            balanceOf[to] += amount;
        }

        emit Transfer(msg.sender, to, amount);

        return true;
    }

    function transferFrom(
        address from,
        address to,
        uint256 amount
    ) public virtual returns (bool) {
        uint256 allowed = allowance[from][msg.sender]; // Saves gas for limited approvals.

        if (allowed != type(uint256).max) allowance[from][msg.sender] = allowed - amount;

        balanceOf[from] -= amount;

        // Cannot overflow because the sum of all user
        // balances can't exceed the max uint256 value.
        unchecked {
            balanceOf[to] += amount;
        }

        emit Transfer(from, to, amount);

        return true;
    }

    /*//////////////////////////////////////////////////////////////
                             EIP-2612 LOGIC
    //////////////////////////////////////////////////////////////*/

    function permit(
        address owner,
        address spender,
        uint256 value,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) public virtual {
        require(deadline >= block.timestamp, "PERMIT_DEADLINE_EXPIRED");

        // Unchecked because the only math done is incrementing
        // the owner's nonce which cannot realistically overflow.
        unchecked {
            address recoveredAddress = ecrecover(
                keccak256(
                    abi.encodePacked(
                        "\x19\x01",
                        DOMAIN_SEPARATOR(),
                        keccak256(
                            abi.encode(
                                keccak256(
                                    "Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)"
                                ),
                                owner,
                                spender,
                                value,
                                nonces[owner]++,
                                deadline
                            )
                        )
                    )
                ),
                v,
                r,
                s
            );

            require(recoveredAddress != address(0) && recoveredAddress == owner, "INVALID_SIGNER");

            allowance[recoveredAddress][spender] = value;
        }

        emit Approval(owner, spender, value);
    }

    function DOMAIN_SEPARATOR() public view virtual returns (bytes32) {
        return block.chainid == INITIAL_CHAIN_ID ? INITIAL_DOMAIN_SEPARATOR : computeDomainSeparator();
    }

    function computeDomainSeparator() internal view virtual returns (bytes32) {
        return
            keccak256(
                abi.encode(
                    keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)"),
                    keccak256(bytes(name)),
                    keccak256("1"),
                    block.chainid,
                    address(this)
                )
            );
    }

    /*//////////////////////////////////////////////////////////////
                        INTERNAL MINT/BURN LOGIC
    //////////////////////////////////////////////////////////////*/

    function _mint(address to, uint256 amount) internal virtual {
        totalSupply += amount;

        // Cannot overflow because the sum of all user
        // balances can't exceed the max uint256 value.
        unchecked {
            balanceOf[to] += amount;
        }

        emit Transfer(address(0), to, amount);
    }

    function _burn(address from, uint256 amount) internal virtual {
        balanceOf[from] -= amount;

        // Cannot underflow because a user's balance
        // will never be larger than the total supply.
        unchecked {
            totalSupply -= amount;
        }

        emit Transfer(from, address(0), amount);
    }
}

File 4 of 5 : SafeTransferLib.sol
// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity >=0.8.0;

import {ERC20} from "../tokens/ERC20.sol";

/// @notice Safe ETH and ERC20 transfer library that gracefully handles missing return values.
/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/utils/SafeTransferLib.sol)
/// @dev Use with caution! Some functions in this library knowingly create dirty bits at the destination of the free memory pointer.
/// @dev Note that none of the functions in this library check that a token has code at all! That responsibility is delegated to the caller.
library SafeTransferLib {
    /*//////////////////////////////////////////////////////////////
                             ETH OPERATIONS
    //////////////////////////////////////////////////////////////*/

    function safeTransferETH(address to, uint256 amount) internal {
        bool success;

        /// @solidity memory-safe-assembly
        assembly {
            // Transfer the ETH and store if it succeeded or not.
            success := call(gas(), to, amount, 0, 0, 0, 0)
        }

        require(success, "ETH_TRANSFER_FAILED");
    }

    /*//////////////////////////////////////////////////////////////
                            ERC20 OPERATIONS
    //////////////////////////////////////////////////////////////*/

    function safeTransferFrom(
        ERC20 token,
        address from,
        address to,
        uint256 amount
    ) internal {
        bool success;

        /// @solidity memory-safe-assembly
        assembly {
            // Get a pointer to some free memory.
            let freeMemoryPointer := mload(0x40)

            // Write the abi-encoded calldata into memory, beginning with the function selector.
            mstore(freeMemoryPointer, 0x23b872dd00000000000000000000000000000000000000000000000000000000)
            mstore(add(freeMemoryPointer, 4), and(from, 0xffffffffffffffffffffffffffffffffffffffff)) // Append and mask the "from" argument.
            mstore(add(freeMemoryPointer, 36), and(to, 0xffffffffffffffffffffffffffffffffffffffff)) // Append and mask the "to" argument.
            mstore(add(freeMemoryPointer, 68), amount) // Append the "amount" argument. Masking not required as it's a full 32 byte type.

            success := and(
                // Set success to whether the call reverted, if not we check it either
                // returned exactly 1 (can't just be non-zero data), or had no return data.
                or(and(eq(mload(0), 1), gt(returndatasize(), 31)), iszero(returndatasize())),
                // We use 100 because the length of our calldata totals up like so: 4 + 32 * 3.
                // We use 0 and 32 to copy up to 32 bytes of return data into the scratch space.
                // Counterintuitively, this call must be positioned second to the or() call in the
                // surrounding and() call or else returndatasize() will be zero during the computation.
                call(gas(), token, 0, freeMemoryPointer, 100, 0, 32)
            )
        }

        require(success, "TRANSFER_FROM_FAILED");
    }

    function safeTransfer(
        ERC20 token,
        address to,
        uint256 amount
    ) internal {
        bool success;

        /// @solidity memory-safe-assembly
        assembly {
            // Get a pointer to some free memory.
            let freeMemoryPointer := mload(0x40)

            // Write the abi-encoded calldata into memory, beginning with the function selector.
            mstore(freeMemoryPointer, 0xa9059cbb00000000000000000000000000000000000000000000000000000000)
            mstore(add(freeMemoryPointer, 4), and(to, 0xffffffffffffffffffffffffffffffffffffffff)) // Append and mask the "to" argument.
            mstore(add(freeMemoryPointer, 36), amount) // Append the "amount" argument. Masking not required as it's a full 32 byte type.

            success := and(
                // Set success to whether the call reverted, if not we check it either
                // returned exactly 1 (can't just be non-zero data), or had no return data.
                or(and(eq(mload(0), 1), gt(returndatasize(), 31)), iszero(returndatasize())),
                // We use 68 because the length of our calldata totals up like so: 4 + 32 * 2.
                // We use 0 and 32 to copy up to 32 bytes of return data into the scratch space.
                // Counterintuitively, this call must be positioned second to the or() call in the
                // surrounding and() call or else returndatasize() will be zero during the computation.
                call(gas(), token, 0, freeMemoryPointer, 68, 0, 32)
            )
        }

        require(success, "TRANSFER_FAILED");
    }

    function safeApprove(
        ERC20 token,
        address to,
        uint256 amount
    ) internal {
        bool success;

        /// @solidity memory-safe-assembly
        assembly {
            // Get a pointer to some free memory.
            let freeMemoryPointer := mload(0x40)

            // Write the abi-encoded calldata into memory, beginning with the function selector.
            mstore(freeMemoryPointer, 0x095ea7b300000000000000000000000000000000000000000000000000000000)
            mstore(add(freeMemoryPointer, 4), and(to, 0xffffffffffffffffffffffffffffffffffffffff)) // Append and mask the "to" argument.
            mstore(add(freeMemoryPointer, 36), amount) // Append the "amount" argument. Masking not required as it's a full 32 byte type.

            success := and(
                // Set success to whether the call reverted, if not we check it either
                // returned exactly 1 (can't just be non-zero data), or had no return data.
                or(and(eq(mload(0), 1), gt(returndatasize(), 31)), iszero(returndatasize())),
                // We use 68 because the length of our calldata totals up like so: 4 + 32 * 2.
                // We use 0 and 32 to copy up to 32 bytes of return data into the scratch space.
                // Counterintuitively, this call must be positioned second to the or() call in the
                // surrounding and() call or else returndatasize() will be zero during the computation.
                call(gas(), token, 0, freeMemoryPointer, 68, 0, 32)
            )
        }

        require(success, "APPROVE_FAILED");
    }
}

File 5 of 5 : Auth.sol
// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity >=0.8.0;

/// @notice Provides a flexible and updatable auth pattern which is completely separate from application logic.
/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/auth/Auth.sol)
/// @author Modified from Dappsys (https://github.com/dapphub/ds-auth/blob/master/src/auth.sol)
abstract contract Auth {
    event OwnershipTransferred(address indexed user, address indexed newOwner);

    event AuthorityUpdated(address indexed user, Authority indexed newAuthority);

    address public owner;

    Authority public authority;

    constructor(address _owner, Authority _authority) {
        owner = _owner;
        authority = _authority;

        emit OwnershipTransferred(msg.sender, _owner);
        emit AuthorityUpdated(msg.sender, _authority);
    }

    modifier requiresAuth() virtual {
        require(isAuthorized(msg.sender, msg.sig), "UNAUTHORIZED");

        _;
    }

    function isAuthorized(address user, bytes4 functionSig) internal view virtual returns (bool) {
        Authority auth = authority; // Memoizing authority saves us a warm SLOAD, around 100 gas.

        // Checking if the caller is the owner only after calling the authority saves gas in most cases, but be
        // aware that this makes protected functions uncallable even to the owner if the authority is out of order.
        return (address(auth) != address(0) && auth.canCall(user, address(this), functionSig)) || user == owner;
    }

    function setAuthority(Authority newAuthority) public virtual {
        // We check if the caller is the owner first because we want to ensure they can
        // always swap out the authority even if it's reverting or using up a lot of gas.
        require(msg.sender == owner || authority.canCall(msg.sender, address(this), msg.sig));

        authority = newAuthority;

        emit AuthorityUpdated(msg.sender, newAuthority);
    }

    function transferOwnership(address newOwner) public virtual requiresAuth {
        owner = newOwner;

        emit OwnershipTransferred(msg.sender, newOwner);
    }
}

/// @notice A generic interface for a contract which provides authorization data to an Auth instance.
/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/auth/Auth.sol)
/// @author Modified from Dappsys (https://github.com/dapphub/ds-auth/blob/master/src/auth.sol)
interface Authority {
    function canCall(
        address user,
        address target,
        bytes4 functionSig
    ) external view returns (bool);
}

Settings
{
  "remappings": [
    "@solmate/=lib/solmate/src/",
    "@forge-std/=lib/forge-std/src/",
    "@ds-test/=lib/forge-std/lib/ds-test/src/",
    "ds-test/=lib/forge-std/lib/ds-test/src/",
    "@openzeppelin/=lib/openzeppelin-contracts/",
    "@ccip/=lib/ccip/",
    "@oapp-auth/=lib/OAppAuth/src/",
    "@devtools-oapp-evm/=lib/OAppAuth/lib/devtools/packages/oapp-evm/contracts/oapp/",
    "@layerzerolabs/lz-evm-messagelib-v2/=lib/OAppAuth/node_modules/@layerzerolabs/lz-evm-messagelib-v2/",
    "@layerzerolabs/lz-evm-protocol-v2/=lib/OAppAuth/lib/LayerZero-V2/packages/layerzero-v2/evm/protocol/",
    "@layerzerolabs/oapp-evm/=lib/OAppAuth/lib/devtools/packages/oapp-evm/",
    "@lz-oapp-evm/=lib/OAppAuth/lib/LayerZero-V2/packages/layerzero-v2/evm/oapp/contracts/oapp/",
    "@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/",
    "@sbu/=lib/OAppAuth/lib/solidity-bytes-utils/",
    "LayerZero-V2/=lib/OAppAuth/lib/",
    "OAppAuth/=lib/OAppAuth/",
    "ccip/=lib/ccip/contracts/",
    "erc4626-tests/=lib/openzeppelin-contracts/lib/erc4626-tests/",
    "forge-std/=lib/forge-std/src/",
    "halmos-cheatcodes/=lib/OAppAuth/lib/openzeppelin-contracts/lib/halmos-cheatcodes/src/",
    "openzeppelin-contracts/=lib/openzeppelin-contracts/",
    "solidity-bytes-utils/=lib/OAppAuth/node_modules/solidity-bytes-utils/",
    "solmate/=lib/solmate/src/"
  ],
  "optimizer": {
    "enabled": true,
    "runs": 200
  },
  "metadata": {
    "useLiteralContent": false,
    "bytecodeHash": "ipfs",
    "appendCBOR": true
  },
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "devdoc",
        "userdoc",
        "metadata",
        "abi"
      ]
    }
  },
  "evmVersion": "london",
  "viaIR": false,
  "libraries": {}
}

Contract Security Audit

Contract ABI

[{"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"uint256","name":"_totalPercent","type":"uint256"},{"components":[{"internalType":"uint96","name":"percent","type":"uint96"},{"internalType":"address","name":"to","type":"address"}],"internalType":"struct PaymentSplitter.SplitInformation[]","name":"_splits","type":"tuple[]"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":true,"internalType":"contract Authority","name":"newAuthority","type":"address"}],"name":"AuthorityUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"inputs":[{"components":[{"internalType":"uint96","name":"percent","type":"uint96"},{"internalType":"address","name":"to","type":"address"}],"internalType":"struct PaymentSplitter.SplitInformation[]","name":"_splits","type":"tuple[]"}],"name":"adjustSplits","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"authority","outputs":[{"internalType":"contract Authority","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract ERC20","name":"asset","type":"address"}],"name":"payoutSplits","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract ERC20","name":"asset","type":"address"}],"name":"rescueERC20","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract Authority","name":"newAuthority","type":"address"}],"name":"setAuthority","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"splits","outputs":[{"internalType":"uint96","name":"percent","type":"uint96"},{"internalType":"address","name":"to","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"}]

60a06040523480156200001157600080fd5b5060405162000ebf38038062000ebf83398101604081905262000034916200028a565b600080546001600160a01b0385166001600160a01b031991821681178355600180549092169091556040518592919033907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908490a36040516001600160a01b0382169033907fa3396fd7f6e0a21b50e5089d2da70d5ac0a3bbbd1f617a93f134b7638998019890600090a3505060808290526000805b82518110156200018557828181518110620000ea57620000ea620003a0565b6020026020010151600001516001600160601b0316826200010c9190620003cc565b91506002838281518110620001255762000125620003a0565b6020908102919091018101518254600181018455600093845292829020815191909201516001600160a01b03166c01000000000000000000000000026001600160601b0390911617910155806200017c81620003e8565b915050620000cb565b506080518114620001ef5760405162461bcd60e51b815260206004820152602a60248201527f5061796d656e7453706c69747465723a20746f74616c2070657263656e74206960448201526973206e6f74203130302560b01b606482015260840160405180910390fd5b5050505062000404565b80516001600160a01b03811681146200021157600080fd5b919050565b634e487b7160e01b600052604160045260246000fd5b604080519081016001600160401b038111828210171562000251576200025162000216565b60405290565b604051601f8201601f191681016001600160401b038111828210171562000282576200028262000216565b604052919050565b600080600060608486031215620002a057600080fd5b620002ab84620001f9565b9250602080850151925060408086015160018060401b0380821115620002d057600080fd5b818801915088601f830112620002e557600080fd5b815181811115620002fa57620002fa62000216565b6200030a858260051b0162000257565b818152858101925060069190911b83018501908a8211156200032b57600080fd5b928501925b81841015620003905784848c0312156200034a5760008081fd5b620003546200022c565b84516001600160601b03811681146200036d5760008081fd5b81526200037c858801620001f9565b818801528352928401929185019162000330565b8096505050505050509250925092565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b80820180821115620003e257620003e2620003b6565b92915050565b600060018201620003fd57620003fd620003b6565b5060010190565b608051610a98620004276000396000818161029101526104010152610a986000f3fe608060405234801561001057600080fd5b50600436106100885760003560e01c80638da5cb5b1161005b5780638da5cb5b14610107578063bf7e214f14610132578063ccec371614610145578063f2fde38b1461015857600080fd5b80630a62787e1461008d5780633d3d9fbf146100a25780637a9e5e4b146100b5578063884c3006146100c8575b600080fd5b6100a061009b36600461081a565b61016b565b005b6100a06100b03660046108a4565b610317565b6100a06100c33660046108a4565b610479565b6100db6100d63660046108c8565b610563565b604080516001600160601b0390931683526001600160a01b039091166020830152015b60405180910390f35b60005461011a906001600160a01b031681565b6040516001600160a01b0390911681526020016100fe565b60015461011a906001600160a01b031681565b6100a06101533660046108a4565b61059e565b6100a06101663660046108a4565b610652565b610181336000356001600160e01b0319166106cf565b6101a65760405162461bcd60e51b815260040161019d906108e1565b60405180910390fd5b60025460005b818110156101ef5760028054806101c5576101c5610907565b600082815260208120820160001990810191909155019055806101e781610933565b9150506101ac565b506000805b8381101561028e5784848281811061020e5761020e61094c565b6102249260206040909202019081019150610977565b610237906001600160601b031683610994565b9150600285858381811061024d5761024d61094c565b8354600181018555600094855260209094206040909102929092019291909101905061027982826109a7565b5050808061028690610933565b9150506101f4565b507f000000000000000000000000000000000000000000000000000000000000000081146103115760405162461bcd60e51b815260206004820152602a60248201527f5061796d656e7453706c69747465723a20746f74616c2070657263656e74206960448201526973206e6f74203130302560b01b606482015260840161019d565b50505050565b61032d336000356001600160e01b0319166106cf565b6103495760405162461bcd60e51b815260040161019d906108e1565b6040516370a0823160e01b81523060048201526000906001906001600160a01b038416906370a0823190602401602060405180830381865afa158015610393573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906103b791906109e7565b6103c19190610a00565b905060005b600254811015610474576000610425600283815481106103e8576103e861094c565b60009182526020909120015484906001600160601b03167f000000000000000000000000000000000000000000000000000000000000000061077b565b90506104636002838154811061043d5761043d61094c565b6000918252602090912001546001600160a01b0386811691600160601b90041683610799565b5061046d81610933565b90506103c6565b505050565b6000546001600160a01b031633148061050e575060015460405163b700961360e01b81526001600160a01b039091169063b7009613906104cd90339030906001600160e01b03196000351690600401610a13565b602060405180830381865afa1580156104ea573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061050e9190610a40565b61051757600080fd5b600180546001600160a01b0319166001600160a01b03831690811790915560405133907fa3396fd7f6e0a21b50e5089d2da70d5ac0a3bbbd1f617a93f134b7638998019890600090a350565b6002818154811061057357600080fd5b6000918252602090912001546001600160601b0381169150600160601b90046001600160a01b031682565b6105b4336000356001600160e01b0319166106cf565b6105d05760405162461bcd60e51b815260040161019d906108e1565b6040516370a0823160e01b815230600482015261064f9033906001600160a01b038416906370a0823190602401602060405180830381865afa15801561061a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061063e91906109e7565b6001600160a01b0384169190610799565b50565b610668336000356001600160e01b0319166106cf565b6106845760405162461bcd60e51b815260040161019d906108e1565b600080546001600160a01b0319166001600160a01b0383169081178255604051909133917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a350565b6001546000906001600160a01b03168015801590610759575060405163b700961360e01b81526001600160a01b0382169063b70096139061071890879030908890600401610a13565b602060405180830381865afa158015610735573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107599190610a40565b8061077157506000546001600160a01b038581169116145b9150505b92915050565b600082600019048411830215820261079257600080fd5b5091020490565b600060405163a9059cbb60e01b81526001600160a01b0384166004820152826024820152602060006044836000895af13d15601f3d11600160005114161716915050806103115760405162461bcd60e51b815260206004820152600f60248201526e1514905394d1915497d19052531151608a1b604482015260640161019d565b6000806020838503121561082d57600080fd5b823567ffffffffffffffff8082111561084557600080fd5b818501915085601f83011261085957600080fd5b81358181111561086857600080fd5b8660208260061b850101111561087d57600080fd5b60209290920196919550909350505050565b6001600160a01b038116811461064f57600080fd5b6000602082840312156108b657600080fd5b81356108c18161088f565b9392505050565b6000602082840312156108da57600080fd5b5035919050565b6020808252600c908201526b15539055551213d49256915160a21b604082015260600190565b634e487b7160e01b600052603160045260246000fd5b634e487b7160e01b600052601160045260246000fd5b6000600182016109455761094561091d565b5060010190565b634e487b7160e01b600052603260045260246000fd5b6001600160601b038116811461064f57600080fd5b60006020828403121561098957600080fd5b81356108c181610962565b808201808211156107755761077561091d565b81356109b281610962565b6001600160601b03811690506001600160601b0319818184541617835560208401356109dd8161088f565b60601b1617905550565b6000602082840312156109f957600080fd5b5051919050565b818103818111156107755761077561091d565b6001600160a01b0393841681529190921660208201526001600160e01b0319909116604082015260600190565b600060208284031215610a5257600080fd5b815180151581146108c157600080fdfea2646970667358221220b4c2575e37c3b35afb19014268a7a0f94701f0f93a2eb5f6e97401aabad4619e64736f6c634300081500330000000000000000000000005f2f11ad8656439d5c14d9b351f8b09cdac2a02d00000000000000000000000000000000000000000000000000000000000027100000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000013880000000000000000000000000463e60c7ce10e57911ab7bd1667eaa21de3e79b0000000000000000000000000000000000000000000000000000000000001388000000000000000000000000f8553c8552f906c19286f21711721e206ee4909e

Deployed Bytecode

0x608060405234801561001057600080fd5b50600436106100885760003560e01c80638da5cb5b1161005b5780638da5cb5b14610107578063bf7e214f14610132578063ccec371614610145578063f2fde38b1461015857600080fd5b80630a62787e1461008d5780633d3d9fbf146100a25780637a9e5e4b146100b5578063884c3006146100c8575b600080fd5b6100a061009b36600461081a565b61016b565b005b6100a06100b03660046108a4565b610317565b6100a06100c33660046108a4565b610479565b6100db6100d63660046108c8565b610563565b604080516001600160601b0390931683526001600160a01b039091166020830152015b60405180910390f35b60005461011a906001600160a01b031681565b6040516001600160a01b0390911681526020016100fe565b60015461011a906001600160a01b031681565b6100a06101533660046108a4565b61059e565b6100a06101663660046108a4565b610652565b610181336000356001600160e01b0319166106cf565b6101a65760405162461bcd60e51b815260040161019d906108e1565b60405180910390fd5b60025460005b818110156101ef5760028054806101c5576101c5610907565b600082815260208120820160001990810191909155019055806101e781610933565b9150506101ac565b506000805b8381101561028e5784848281811061020e5761020e61094c565b6102249260206040909202019081019150610977565b610237906001600160601b031683610994565b9150600285858381811061024d5761024d61094c565b8354600181018555600094855260209094206040909102929092019291909101905061027982826109a7565b5050808061028690610933565b9150506101f4565b507f000000000000000000000000000000000000000000000000000000000000271081146103115760405162461bcd60e51b815260206004820152602a60248201527f5061796d656e7453706c69747465723a20746f74616c2070657263656e74206960448201526973206e6f74203130302560b01b606482015260840161019d565b50505050565b61032d336000356001600160e01b0319166106cf565b6103495760405162461bcd60e51b815260040161019d906108e1565b6040516370a0823160e01b81523060048201526000906001906001600160a01b038416906370a0823190602401602060405180830381865afa158015610393573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906103b791906109e7565b6103c19190610a00565b905060005b600254811015610474576000610425600283815481106103e8576103e861094c565b60009182526020909120015484906001600160601b03167f000000000000000000000000000000000000000000000000000000000000271061077b565b90506104636002838154811061043d5761043d61094c565b6000918252602090912001546001600160a01b0386811691600160601b90041683610799565b5061046d81610933565b90506103c6565b505050565b6000546001600160a01b031633148061050e575060015460405163b700961360e01b81526001600160a01b039091169063b7009613906104cd90339030906001600160e01b03196000351690600401610a13565b602060405180830381865afa1580156104ea573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061050e9190610a40565b61051757600080fd5b600180546001600160a01b0319166001600160a01b03831690811790915560405133907fa3396fd7f6e0a21b50e5089d2da70d5ac0a3bbbd1f617a93f134b7638998019890600090a350565b6002818154811061057357600080fd5b6000918252602090912001546001600160601b0381169150600160601b90046001600160a01b031682565b6105b4336000356001600160e01b0319166106cf565b6105d05760405162461bcd60e51b815260040161019d906108e1565b6040516370a0823160e01b815230600482015261064f9033906001600160a01b038416906370a0823190602401602060405180830381865afa15801561061a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061063e91906109e7565b6001600160a01b0384169190610799565b50565b610668336000356001600160e01b0319166106cf565b6106845760405162461bcd60e51b815260040161019d906108e1565b600080546001600160a01b0319166001600160a01b0383169081178255604051909133917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a350565b6001546000906001600160a01b03168015801590610759575060405163b700961360e01b81526001600160a01b0382169063b70096139061071890879030908890600401610a13565b602060405180830381865afa158015610735573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107599190610a40565b8061077157506000546001600160a01b038581169116145b9150505b92915050565b600082600019048411830215820261079257600080fd5b5091020490565b600060405163a9059cbb60e01b81526001600160a01b0384166004820152826024820152602060006044836000895af13d15601f3d11600160005114161716915050806103115760405162461bcd60e51b815260206004820152600f60248201526e1514905394d1915497d19052531151608a1b604482015260640161019d565b6000806020838503121561082d57600080fd5b823567ffffffffffffffff8082111561084557600080fd5b818501915085601f83011261085957600080fd5b81358181111561086857600080fd5b8660208260061b850101111561087d57600080fd5b60209290920196919550909350505050565b6001600160a01b038116811461064f57600080fd5b6000602082840312156108b657600080fd5b81356108c18161088f565b9392505050565b6000602082840312156108da57600080fd5b5035919050565b6020808252600c908201526b15539055551213d49256915160a21b604082015260600190565b634e487b7160e01b600052603160045260246000fd5b634e487b7160e01b600052601160045260246000fd5b6000600182016109455761094561091d565b5060010190565b634e487b7160e01b600052603260045260246000fd5b6001600160601b038116811461064f57600080fd5b60006020828403121561098957600080fd5b81356108c181610962565b808201808211156107755761077561091d565b81356109b281610962565b6001600160601b03811690506001600160601b0319818184541617835560208401356109dd8161088f565b60601b1617905550565b6000602082840312156109f957600080fd5b5051919050565b818103818111156107755761077561091d565b6001600160a01b0393841681529190921660208201526001600160e01b0319909116604082015260600190565b600060208284031215610a5257600080fd5b815180151581146108c157600080fdfea2646970667358221220b4c2575e37c3b35afb19014268a7a0f94701f0f93a2eb5f6e97401aabad4619e64736f6c63430008150033

Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)

0000000000000000000000005f2f11ad8656439d5c14d9b351f8b09cdac2a02d00000000000000000000000000000000000000000000000000000000000027100000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000013880000000000000000000000000463e60c7ce10e57911ab7bd1667eaa21de3e79b0000000000000000000000000000000000000000000000000000000000001388000000000000000000000000f8553c8552f906c19286f21711721e206ee4909e

-----Decoded View---------------
Arg [0] : _owner (address): 0x5F2F11ad8656439d5C14d9B351f8b09cDaC2A02d
Arg [1] : _totalPercent (uint256): 10000
Arg [2] : _splits (tuple[]): System.Collections.Generic.List`1[Nethereum.ABI.FunctionEncoding.ParameterOutput],System.Collections.Generic.List`1[Nethereum.ABI.FunctionEncoding.ParameterOutput]

-----Encoded View---------------
8 Constructor Arguments found :
Arg [0] : 0000000000000000000000005f2f11ad8656439d5c14d9b351f8b09cdac2a02d
Arg [1] : 0000000000000000000000000000000000000000000000000000000000002710
Arg [2] : 0000000000000000000000000000000000000000000000000000000000000060
Arg [3] : 0000000000000000000000000000000000000000000000000000000000000002
Arg [4] : 0000000000000000000000000000000000000000000000000000000000001388
Arg [5] : 0000000000000000000000000463e60c7ce10e57911ab7bd1667eaa21de3e79b
Arg [6] : 0000000000000000000000000000000000000000000000000000000000001388
Arg [7] : 000000000000000000000000f8553c8552f906c19286f21711721e206ee4909e


Block Transaction Gas Used Reward
view all blocks produced

Block Uncle Number Difficulty Gas Used Reward
View All Uncles
Loading...
Loading
Loading...
Loading

Validator Index Block Amount
View All Withdrawals

Transaction Hash Block Value Eth2 PubKey Valid
View All Deposits
[ Download: CSV Export  ]

A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.