Contract 0x94D8f036a0fbC216Bb532D33bDF6564157Af0cD7 5

 

Contract Overview

ReNFT: Renting
Balance:
0 Ether

EtherValue:
$0.00

Token:
 
Txn Hash
Method
Block
From
To
Value
0x2b154c721e9800acaa25587efdb417d5ed7e8e6dad2867b8da705d49c44f3298Stop Lending156414592022-09-29 20:43:471 day 1 hr agoENS Name yunqiao.eth IN  ReNFT: Renting0 Ether0.00093338 12.11288523
0x02e4b17a2c75ba425453848d58876e1fe9c9d63f2afab13ce2efbfa96e3c2394Lend156008652022-09-24 4:35:356 days 17 hrs agoENS Name shuanft.eth IN  ReNFT: Renting0 Ether0.00062442 3.769
0x642233652a5e26bea5fc8658ec93f281211edce7bc7922bfe8e2a39f1a8224bbLend156006802022-09-24 3:58:356 days 18 hrs ago0x473fbd6dd6485c2d1baa72d632d779291d295bf9 IN  ReNFT: Renting0 Ether0.00048093 4.059
0xc4f23de176d99b4d744e79dc3486e6038023e35b9cfb21e53847909da6fcc9eeClaim Collateral155965122022-09-23 14:01:477 days 8 hrs agoENS Name 0x00eth.eth IN  ReNFT: Renting0 Ether0.00383277 34.56311251
0xb1cad788918a66ecf7c5119aa6fa1ca20528cbb083b17a040bce17fa9765c78eStop Lending155770482022-09-20 20:23:5910 days 1 hr ago0x6b589c093ab0419288b041eeaa45a01693de2a00 IN  ReNFT: Renting0 Ether0.00524695 51.40994298
0x6dfd37402e4c55f692a0e9b6112a7bc9214d45f0e2d7dc7d03c209364a5b613cLend155767232022-09-20 19:18:4710 days 3 hrs ago0x6b589c093ab0419288b041eeaa45a01693de2a00 IN  ReNFT: Renting0 Ether0.00153113 12.9056943
0xf4c9a1522e206a3c92ef09abe2a716c23c0d8b1b29fc976d0c32ee47353b6967Lend155765832022-09-20 18:50:1110 days 3 hrs ago0x6b589c093ab0419288b041eeaa45a01693de2a00 IN  ReNFT: Renting0 Ether0.00187928 11.5718096
0x52fe5a39b7385e5472b1efddf100c455af8299f2dce3453b539c7c51fe79effdRent155685252022-09-19 15:43:1111 days 6 hrs ago0x98111289e72f43e528f9c0fe879f56805b57efe5 IN  ReNFT: Renting0 Ether0.00176881 10.35447615
0x10aa3f4aa8ca3132fa745fc9992b2b763f33d010864d59bfbd3a2c9c1e873873Stop Lending155561862022-09-17 22:11:1113 days 8 mins agoENS Name projectr.eth IN  ReNFT: Renting0 Ether0.0005093 6.19362786
0x5af74817ee41603de2e7cd7e2df8c644770d48e3cd8d0e9920b7a1b047c5b3bcLend155317932022-09-14 7:55:3716 days 14 hrs agoENS Name sisiaiwo.eth IN  ReNFT: Renting0 Ether0.00059046 5.6424
0xcc5cc27733d61ef0606f33b33c4790dad7a6931581a7b1598e22e188b77be328Stop Lending155309952022-09-14 4:38:2016 days 17 hrs agoENS Name xand3r.eth IN  ReNFT: Renting0 Ether0.00159414 12.22169435
0xad90a195bc1aa7508a9e20c72b11cde47153c576f0224d86be7cbdc86334653fLend155309852022-09-14 4:36:1316 days 17 hrs agoENS Name xand3r.eth IN  ReNFT: Renting0 Ether0.00164482 9.71882968
0x517220e63d9a3be44e70906ddd95dad7c1195318d61ed4348911fb24ba6bbe44Return It155250942022-09-13 5:08:3117 days 17 hrs agoENS Name custardcake.eth IN  ReNFT: Renting0 Ether0.00104462 7.54227814
0x879867e3fa0e123be6f65e736234a4e7059321655a5f02861c69799918e58312Rent155250212022-09-13 4:50:4117 days 17 hrs agoENS Name custardcake.eth IN  ReNFT: Renting0 Ether0.00115385 9.45964621
0xeb0ba377247d8caf3b95dbe03adcd799a241fa8b9c49b53593192b695056e93aLend155166742022-09-11 19:53:1519 days 2 hrs agoENS Name beyeod.eth IN  ReNFT: Renting0 Ether0.00191001 17.13928
0x9214d3b67238ae395ffdd3d186d6b8fc39cc1dc0d7e2ec09344f5c1abf04ddc4Lend154678262022-09-03 21:54:5627 days 24 mins agoENS Name zzzze.eth IN  ReNFT: Renting0 Ether0.00058979 3.56
0xb39de39226d133008be838ce7252b8222ff959a93c2d7f2f1eb0e01408a27409Stop Lending154646322022-09-03 9:42:3527 days 12 hrs agoENS Name zzzze.eth IN  ReNFT: Renting0 Ether0.00064291 4.32
0x330067adb55c212182e7bf17af9db019c1a212d5f9a5a1dba460aaff9bbb3543Stop Lending154643802022-09-03 8:47:1727 days 13 hrs ago0x8b0542ad5ab0c8f9e0263a5aa178c28161e3de04 IN  ReNFT: Renting0 Ether0.00063118 7.82801954
0xa422a5196ca2acc3ad4c0e896457a01f5ea6aad86cad9c38af1fe72c307b3374Lend154642322022-09-03 8:15:0827 days 14 hrs agoENS Name zzzze.eth IN  ReNFT: Renting0 Ether0.00086156 5.2
0x000cf4dbf3d1dab3279d5f8e490eba7051e6a1775f36e9d00dcb8801326e3ea2Lend154641742022-09-03 8:00:0127 days 14 hrs agoENS Name heyijieyou.eth IN  ReNFT: Renting0 Ether0.00108592 9.48357905
0x992cf63f05dcdcbf1c6213ff3e78c9cf28370e49c709d5e86ab91a5de2c4cb50Stop Lending154640542022-09-03 7:32:0527 days 14 hrs agoENS Name xiabing.eth IN  ReNFT: Renting0 Ether0.00110558 9.70394329
0x641712c27194d52abb7d37c0f83fcaeb7ca9cb91814b01c60e2db0d44fca38c7Claim Collateral154590942022-09-02 12:11:4028 days 10 hrs agoENS Name flowme.eth IN  ReNFT: Renting0 Ether0.00084076 9.22233388
0xbd9b935bbb463b9cdee9097c3fed5f138ff55eea2893ffc59939250f22de2a4fReturn It154574892022-09-02 6:03:1928 days 16 hrs agoENS Name pixsoul.eth IN  ReNFT: Renting0 Ether0.00185345 12.16411675
0x3342ff0fd2130800d1227b7557514dbdb3dee2b2ddc00e3d7642e5faac4c812cRent154573752022-09-02 5:34:0728 days 16 hrs agoENS Name pixsoul.eth IN  ReNFT: Renting0 Ether0.00145768 9.69979141
0x7f10d72cf77a1d3f27e10743d6cd514186699852fc585755fc98545af274aa2eReturn It154528032022-09-01 12:11:3529 days 10 hrs agoENS Name dimoo.eth IN  ReNFT: Renting0 Ether0.00246185 14.50639081
[ Download CSV Export 
View more zero value Internal Transactions in Advanced View mode
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
ReNFT

Compiler Version
v0.8.6+commit.11564f7e

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion
File 1 of 17 : ReNFT.sol
// SPDX-License-Identifier: MIT
pragma solidity =0.8.6;

import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts/token/ERC721/IERC721.sol";
import "@openzeppelin/contracts/token/ERC1155/IERC1155.sol";
import "@openzeppelin/contracts/token/ERC721/utils/ERC721Holder.sol";
import "@openzeppelin/contracts/token/ERC1155/utils/ERC1155Receiver.sol";
import "@openzeppelin/contracts/token/ERC1155/utils/ERC1155Holder.sol";

import "./interfaces/IResolver.sol";
import "./interfaces/IReNFT.sol";

//              @@@@@@@@@@@@@@@@        ,@@@@@@@@@@@@@@@@
//              @@@,,,,,,,,,,@@@        ,@@&,,,,,,,,,,@@@
//         @@@@@@@@,,,,,,,,,,@@@@@@@@&  ,@@&,,,,,,,,,,@@@@@@@@
//         @@@**********@@@@@@@@@@@@@&  ,@@@@@@@@**********@@@
//         @@@**********@@@@@@@@@@@@@&  ,@@@@@@@@**********@@@@@@@@
//         @@@**********@@@@@@@@@@@@@&       [email protected]@@**********@@@@@@@@
//    @@@@@@@@**********@@@@@@@@@@@@@&       [email protected]@@**********@@@@@@@@
//    @@@**********@@@@@@@@@@@@@&            [email protected]@@@@@@@**********@@@
//    @@@**********@@@@@@@@@@@@@&            [email protected]@@@@@@@**********@@@@@@@@
//    @@@@@@@@**********@@@@@@@@&            [email protected]@@**********@@@@@@@@@@@@@
//    @@@@@@@@//////////@@@@@@@@&            [email protected]@@//////////@@@@@@@@@@@@@
//         @@@//////////@@@@@@@@&            [email protected]@@//////////@@@@@@@@@@@@@
//         @@@//////////@@@@@@@@&       ,@@@@@@@@//////////@@@@@@@@@@@@@
//         @@@%%%%%/////(((((@@@&       ,@@@(((((/////%%%%%@@@@@@@@
//         @@@@@@@@//////////@@@@@@@@&  ,@@@//////////@@@@@@@@@@@@@
//              @@@%%%%%%%%%%@@@@@@@@&  ,@@@%%%%%%%%%%@@@@@@@@@@@@@
//              @@@@@@@@@@@@@@@@@@@@@&  ,@@@@@@@@@@@@@@@@@@@@@@@@@@
//                   @@@@@@@@@@@@@@@@&        @@@@@@@@@@@@@@@@
//                   @@@@@@@@@@@@@@@@&        @@@@@@@@@@@@@@@@

contract ReNFT is IReNft, ERC721Holder, ERC1155Receiver, ERC1155Holder {
    using SafeERC20 for ERC20;

    IResolver private resolver;
    address private admin;
    address payable private beneficiary;
    uint256 private lendingId = 1;
    bool public paused = false;

    // in bps. so 1000 => 1%
    uint256 public rentFee = 0;

    uint256 private constant SECONDS_IN_DAY = 86400;

    // single storage slot: address - 160 bits, 168, 200, 232, 240, 248
    struct Lending {
        address payable lenderAddress;
        uint8 maxRentDuration;
        bytes4 dailyRentPrice;
        bytes4 nftPrice;
        uint8 lentAmount;
        IResolver.PaymentToken paymentToken;
    }

    // single storage slot: 160 bits, 168, 200
    struct Renting {
        address payable renterAddress;
        uint8 rentDuration;
        uint32 rentedAt;
    }

    struct LendingRenting {
        Lending lending;
        Renting renting;
    }

    mapping(bytes32 => LendingRenting) private lendingRenting;

    struct CallData {
        uint256 left;
        uint256 right;
        address[] nfts;
        uint256[] tokenIds;
        uint256[] lentAmounts;
        uint8[] maxRentDurations;
        bytes4[] dailyRentPrices;
        bytes4[] nftPrices;
        uint256[] lendingIds;
        uint8[] rentDurations;
        IResolver.PaymentToken[] paymentTokens;
    }

    modifier onlyAdmin {
        require(msg.sender == admin, "ReNFT::not admin");
        _;
    }

    modifier notPaused {
        require(!paused, "ReNFT::paused");
        _;
    }

    constructor(
        address _resolver,
        address payable _beneficiary,
        address _admin
    ) {
        ensureIsNotZeroAddr(_resolver);
        ensureIsNotZeroAddr(_beneficiary);
        ensureIsNotZeroAddr(_admin);
        resolver = IResolver(_resolver);
        beneficiary = _beneficiary;
        admin = _admin;
    }

    function bundleCall(function(CallData memory) _handler, CallData memory _cd)
        private
    {
        require(_cd.nfts.length > 0, "ReNFT::no nfts");
        while (_cd.right != _cd.nfts.length) {
            if (
                (_cd.nfts[_cd.left] == _cd.nfts[_cd.right]) &&
                (is1155(_cd.nfts[_cd.right]))
            ) {
                _cd.right++;
            } else {
                _handler(_cd);
                _cd.left = _cd.right;
                _cd.right++;
            }
        }
        _handler(_cd);
    }

    // lend, rent, return, stop, claim

    function lend(
        address[] memory _nfts,
        uint256[] memory _tokenIds,
        uint256[] memory _lendAmounts,
        uint8[] memory _maxRentDurations,
        bytes4[] memory _dailyRentPrices,
        bytes4[] memory _nftPrices,
        IResolver.PaymentToken[] memory _paymentTokens
    ) external override notPaused {
        bundleCall(
            handleLend,
            createLendCallData(
                _nfts,
                _tokenIds,
                _lendAmounts,
                _maxRentDurations,
                _dailyRentPrices,
                _nftPrices,
                _paymentTokens
            )
        );
    }

    function rent(
        address[] memory _nfts,
        uint256[] memory _tokenIds,
        uint256[] memory _lendingIds,
        uint8[] memory _rentDurations
    ) external override notPaused {
        bundleCall(
            handleRent,
            createRentCallData(_nfts, _tokenIds, _lendingIds, _rentDurations)
        );
    }

    function returnIt(
        address[] memory _nfts,
        uint256[] memory _tokenIds,
        uint256[] memory _lendingIds
    ) external override notPaused {
        bundleCall(
            handleReturn,
            createActionCallData(_nfts, _tokenIds, _lendingIds)
        );
    }

    function stopLending(
        address[] memory _nfts,
        uint256[] memory _tokenIds,
        uint256[] memory _lendingIds
    ) external override notPaused {
        bundleCall(
            handleStopLending,
            createActionCallData(_nfts, _tokenIds, _lendingIds)
        );
    }

    function claimCollateral(
        address[] memory _nfts,
        uint256[] memory _tokenIds,
        uint256[] memory _lendingIds
    ) external override notPaused {
        bundleCall(
            handleClaimCollateral,
            createActionCallData(_nfts, _tokenIds, _lendingIds)
        );
    }

    //      .-.     .-.     .-.     .-.     .-.     .-.     .-.     .-.     .-.     .-.
    // `._.'   `._.'   `._.'   `._.'   `._.'   `._.'   `._.'   `._.'   `._.'   `._.'   `._.'

    function takeFee(uint256 _rent, IResolver.PaymentToken _paymentToken)
        private
        returns (uint256 fee)
    {
        fee = _rent * rentFee;
        fee /= 10000;
        uint8 paymentTokenIx = uint8(_paymentToken);
        ensureTokenNotSentinel(paymentTokenIx);
        ERC20 paymentToken = ERC20(resolver.getPaymentToken(paymentTokenIx));
        paymentToken.safeTransfer(beneficiary, fee);
    }

    function distributePayments(
        LendingRenting storage _lendingRenting,
        uint256 _secondsSinceRentStart
    ) private {
        uint8 paymentTokenIx = uint8(_lendingRenting.lending.paymentToken);
        ensureTokenNotSentinel(paymentTokenIx);
        address paymentToken = resolver.getPaymentToken(paymentTokenIx);
        uint256 decimals = ERC20(paymentToken).decimals();

        uint256 scale = 10**decimals;
        uint256 nftPrice =
            _lendingRenting.lending.lentAmount *
                unpackPrice(_lendingRenting.lending.nftPrice, scale);
        uint256 rentPrice =
            unpackPrice(_lendingRenting.lending.dailyRentPrice, scale);
        uint256 totalRenterPmtWoCollateral =
            rentPrice * _lendingRenting.renting.rentDuration;
        uint256 sendLenderAmt =
            (_secondsSinceRentStart * rentPrice) / SECONDS_IN_DAY;
        require(
            totalRenterPmtWoCollateral > 0,
            "ReNFT::total payment wo collateral is zero"
        );
        require(sendLenderAmt > 0, "ReNFT::lender payment is zero");
        uint256 sendRenterAmt = totalRenterPmtWoCollateral - sendLenderAmt;

        uint256 takenFee =
            takeFee(sendLenderAmt, _lendingRenting.lending.paymentToken);

        sendLenderAmt -= takenFee;
        sendRenterAmt += nftPrice;

        ERC20(paymentToken).safeTransfer(
            _lendingRenting.lending.lenderAddress,
            sendLenderAmt
        );
        ERC20(paymentToken).safeTransfer(
            _lendingRenting.renting.renterAddress,
            sendRenterAmt
        );
    }

    function distributeClaimPayment(LendingRenting memory _lendingRenting)
        private
    {
        uint8 paymentTokenIx = uint8(_lendingRenting.lending.paymentToken);
        ensureTokenNotSentinel(paymentTokenIx);
        ERC20 paymentToken = ERC20(resolver.getPaymentToken(paymentTokenIx));

        uint256 decimals = ERC20(paymentToken).decimals();
        uint256 scale = 10**decimals;
        uint256 nftPrice =
            _lendingRenting.lending.lentAmount *
                unpackPrice(_lendingRenting.lending.nftPrice, scale);
        uint256 rentPrice =
            unpackPrice(_lendingRenting.lending.dailyRentPrice, scale);
        uint256 maxRentPayment =
            rentPrice * _lendingRenting.renting.rentDuration;
        uint256 takenFee =
            takeFee(maxRentPayment, IResolver.PaymentToken(paymentTokenIx));
        uint256 finalAmt = maxRentPayment + nftPrice;

        require(maxRentPayment > 0, "ReNFT::collateral plus rent is zero");

        paymentToken.safeTransfer(
            _lendingRenting.lending.lenderAddress,
            finalAmt - takenFee
        );
    }

    function safeTransfer(
        CallData memory _cd,
        address _from,
        address _to,
        uint256[] memory _tokenIds,
        uint256[] memory _lentAmounts
    ) private {
        if (is721(_cd.nfts[_cd.left])) {
            IERC721(_cd.nfts[_cd.left]).transferFrom(
                _from,
                _to,
                _cd.tokenIds[_cd.left]
            );
        } else if (is1155(_cd.nfts[_cd.left])) {
            IERC1155(_cd.nfts[_cd.left]).safeBatchTransferFrom(
                _from,
                _to,
                _tokenIds,
                _lentAmounts,
                ""
            );
        } else {
            revert("ReNFT::unsupported token type");
        }
    }

    //      .-.     .-.     .-.     .-.     .-.     .-.     .-.     .-.     .-.     .-.
    // `._.'   `._.'   `._.'   `._.'   `._.'   `._.'   `._.'   `._.'   `._.'   `._.'   `._.'

    function handleLend(CallData memory _cd) private {
        for (uint256 i = _cd.left; i < _cd.right; i++) {
            ensureIsLendable(_cd, i);

            LendingRenting storage item =
                lendingRenting[
                    keccak256(
                        abi.encodePacked(
                            _cd.nfts[_cd.left],
                            _cd.tokenIds[i],
                            lendingId
                        )
                    )
                ];

            ensureIsNull(item.lending);
            ensureIsNull(item.renting);

            bool nftIs721 = is721(_cd.nfts[i]);
            item.lending = Lending({
                lenderAddress: payable(msg.sender),
                lentAmount: nftIs721 ? 1 : uint8(_cd.lentAmounts[i]),
                maxRentDuration: _cd.maxRentDurations[i],
                dailyRentPrice: _cd.dailyRentPrices[i],
                nftPrice: _cd.nftPrices[i],
                paymentToken: _cd.paymentTokens[i]
            });

            emit Lent(
                _cd.nfts[_cd.left],
                _cd.tokenIds[i],
                nftIs721 ? 1 : uint8(_cd.lentAmounts[i]),
                lendingId,
                msg.sender,
                _cd.maxRentDurations[i],
                _cd.dailyRentPrices[i],
                _cd.nftPrices[i],
                nftIs721,
                _cd.paymentTokens[i]
            );

            lendingId++;
        }

        safeTransfer(
            _cd,
            msg.sender,
            address(this),
            sliceArr(_cd.tokenIds, _cd.left, _cd.right, 0),
            sliceArr(_cd.lentAmounts, _cd.left, _cd.right, 0)
        );
    }

    function handleRent(CallData memory _cd) private {
        uint256[] memory lentAmounts = new uint256[](_cd.right - _cd.left);

        for (uint256 i = _cd.left; i < _cd.right; i++) {
            LendingRenting storage item =
                lendingRenting[
                    keccak256(
                        abi.encodePacked(
                            _cd.nfts[_cd.left],
                            _cd.tokenIds[i],
                            _cd.lendingIds[i]
                        )
                    )
                ];

            ensureIsNotNull(item.lending);
            ensureIsNull(item.renting);
            ensureIsRentable(item.lending, _cd, i, msg.sender);

            uint8 paymentTokenIx = uint8(item.lending.paymentToken);
            ensureTokenNotSentinel(paymentTokenIx);
            address paymentToken = resolver.getPaymentToken(paymentTokenIx);
            uint256 decimals = ERC20(paymentToken).decimals();

            {
                uint256 scale = 10**decimals;
                uint256 rentPrice =
                    _cd.rentDurations[i] *
                        unpackPrice(item.lending.dailyRentPrice, scale);
                uint256 nftPrice =
                    item.lending.lentAmount *
                        unpackPrice(item.lending.nftPrice, scale);

                require(rentPrice > 0, "ReNFT::rent price is zero");
                require(nftPrice > 0, "ReNFT::nft price is zero");

                ERC20(paymentToken).safeTransferFrom(
                    msg.sender,
                    address(this),
                    rentPrice + nftPrice
                );
            }

            lentAmounts[i - _cd.left] = item.lending.lentAmount;

            item.renting.renterAddress = payable(msg.sender);
            item.renting.rentDuration = _cd.rentDurations[i];
            item.renting.rentedAt = uint32(block.timestamp);

            emit Rented(
                _cd.lendingIds[i],
                msg.sender,
                _cd.rentDurations[i],
                item.renting.rentedAt
            );
        }

        safeTransfer(
            _cd,
            address(this),
            msg.sender,
            sliceArr(_cd.tokenIds, _cd.left, _cd.right, 0),
            sliceArr(lentAmounts, _cd.left, _cd.right, _cd.left)
        );
    }

    function handleReturn(CallData memory _cd) private {
        uint256[] memory lentAmounts = new uint256[](_cd.right - _cd.left);

        for (uint256 i = _cd.left; i < _cd.right; i++) {
            LendingRenting storage item =
                lendingRenting[
                    keccak256(
                        abi.encodePacked(
                            _cd.nfts[_cd.left],
                            _cd.tokenIds[i],
                            _cd.lendingIds[i]
                        )
                    )
                ];

            ensureIsNotNull(item.lending);
            ensureIsReturnable(item.renting, msg.sender, block.timestamp);

            uint256 secondsSinceRentStart =
                block.timestamp - item.renting.rentedAt;
            distributePayments(item, secondsSinceRentStart);

            lentAmounts[i - _cd.left] = item.lending.lentAmount;

            emit Returned(_cd.lendingIds[i], uint32(block.timestamp));

            delete item.renting;
        }

        safeTransfer(
            _cd,
            msg.sender,
            address(this),
            sliceArr(_cd.tokenIds, _cd.left, _cd.right, 0),
            sliceArr(lentAmounts, _cd.left, _cd.right, _cd.left)
        );
    }

    function handleStopLending(CallData memory _cd) private {
        uint256[] memory lentAmounts = new uint256[](_cd.right - _cd.left);

        for (uint256 i = _cd.left; i < _cd.right; i++) {
            LendingRenting storage item =
                lendingRenting[
                    keccak256(
                        abi.encodePacked(
                            _cd.nfts[_cd.left],
                            _cd.tokenIds[i],
                            _cd.lendingIds[i]
                        )
                    )
                ];

            ensureIsNotNull(item.lending);
            ensureIsNull(item.renting);
            ensureIsStoppable(item.lending, msg.sender);

            lentAmounts[i - _cd.left] = item.lending.lentAmount;

            emit LendingStopped(_cd.lendingIds[i], uint32(block.timestamp));

            delete item.lending;
        }

        safeTransfer(
            _cd,
            address(this),
            msg.sender,
            sliceArr(_cd.tokenIds, _cd.left, _cd.right, 0),
            sliceArr(lentAmounts, _cd.left, _cd.right, _cd.left)
        );
    }

    function handleClaimCollateral(CallData memory _cd) private {
        for (uint256 i = _cd.left; i < _cd.right; i++) {
            LendingRenting storage item =
                lendingRenting[
                    keccak256(
                        abi.encodePacked(
                            _cd.nfts[_cd.left],
                            _cd.tokenIds[i],
                            _cd.lendingIds[i]
                        )
                    )
                ];

            ensureIsNotNull(item.lending);
            ensureIsNotNull(item.renting);
            ensureIsClaimable(item.renting, block.timestamp);

            distributeClaimPayment(item);

            emit CollateralClaimed(_cd.lendingIds[i], uint32(block.timestamp));

            delete item.lending;
            delete item.renting;
        }
    }

    //      .-.     .-.     .-.     .-.     .-.     .-.     .-.     .-.     .-.     .-.
    // `._.'   `._.'   `._.'   `._.'   `._.'   `._.'   `._.'   `._.'   `._.'   `._.'   `._.'

    function is721(address _nft) private view returns (bool) {
        return IERC165(_nft).supportsInterface(type(IERC721).interfaceId);
    }

    function is1155(address _nft) private view returns (bool) {
        return IERC165(_nft).supportsInterface(type(IERC1155).interfaceId);
    }

    //      .-.     .-.     .-.     .-.     .-.     .-.     .-.     .-.     .-.     .-.
    // `._.'   `._.'   `._.'   `._.'   `._.'   `._.'   `._.'   `._.'   `._.'   `._.'   `._.'

    function createLendCallData(
        address[] memory _nfts,
        uint256[] memory _tokenIds,
        uint256[] memory _lendAmounts,
        uint8[] memory _maxRentDurations,
        bytes4[] memory _dailyRentPrices,
        bytes4[] memory _nftPrices,
        IResolver.PaymentToken[] memory _paymentTokens
    ) private pure returns (CallData memory cd) {
        cd = CallData({
            left: 0,
            right: 1,
            nfts: _nfts,
            tokenIds: _tokenIds,
            lentAmounts: _lendAmounts,
            lendingIds: new uint256[](0),
            rentDurations: new uint8[](0),
            maxRentDurations: _maxRentDurations,
            dailyRentPrices: _dailyRentPrices,
            nftPrices: _nftPrices,
            paymentTokens: _paymentTokens
        });
    }

    function createRentCallData(
        address[] memory _nfts,
        uint256[] memory _tokenIds,
        uint256[] memory _lendingIds,
        uint8[] memory _rentDurations
    ) private pure returns (CallData memory cd) {
        cd = CallData({
            left: 0,
            right: 1,
            nfts: _nfts,
            tokenIds: _tokenIds,
            lentAmounts: new uint256[](0),
            lendingIds: _lendingIds,
            rentDurations: _rentDurations,
            maxRentDurations: new uint8[](0),
            dailyRentPrices: new bytes4[](0),
            nftPrices: new bytes4[](0),
            paymentTokens: new IResolver.PaymentToken[](0)
        });
    }

    function createActionCallData(
        address[] memory _nfts,
        uint256[] memory _tokenIds,
        uint256[] memory _lendingIds
    ) private pure returns (CallData memory cd) {
        cd = CallData({
            left: 0,
            right: 1,
            nfts: _nfts,
            tokenIds: _tokenIds,
            lentAmounts: new uint256[](0),
            lendingIds: _lendingIds,
            rentDurations: new uint8[](0),
            maxRentDurations: new uint8[](0),
            dailyRentPrices: new bytes4[](0),
            nftPrices: new bytes4[](0),
            paymentTokens: new IResolver.PaymentToken[](0)
        });
    }

    function unpackPrice(bytes4 _price, uint256 _scale)
        private
        pure
        returns (uint256)
    {
        ensureIsUnpackablePrice(_price, _scale);

        uint16 whole = uint16(bytes2(_price));
        uint16 decimal = uint16(bytes2(_price << 16));
        uint256 decimalScale = _scale / 10000;

        if (whole > 9999) {
            whole = 9999;
        }
        if (decimal > 9999) {
            decimal = 9999;
        }

        uint256 w = whole * _scale;
        uint256 d = decimal * decimalScale;
        uint256 price = w + d;

        return price;
    }

    function sliceArr(
        uint256[] memory _arr,
        uint256 _fromIx,
        uint256 _toIx,
        uint256 _arrOffset
    ) private pure returns (uint256[] memory r) {
        r = new uint256[](_toIx - _fromIx);
        for (uint256 i = _fromIx; i < _toIx; i++) {
            r[i - _fromIx] = _arr[i - _arrOffset];
        }
    }

    //      .-.     .-.     .-.     .-.     .-.     .-.     .-.     .-.     .-.     .-.
    // `._.'   `._.'   `._.'   `._.'   `._.'   `._.'   `._.'   `._.'   `._.'   `._.'   `._.'

    function ensureIsNotZeroAddr(address _addr) private pure {
        require(_addr != address(0), "ReNFT::zero address");
    }

    function ensureIsZeroAddr(address _addr) private pure {
        require(_addr == address(0), "ReNFT::not a zero address");
    }

    function ensureIsNull(Lending memory _lending) private pure {
        ensureIsZeroAddr(_lending.lenderAddress);
        require(_lending.maxRentDuration == 0, "ReNFT::duration not zero");
        require(_lending.dailyRentPrice == 0, "ReNFT::rent price not zero");
        require(_lending.nftPrice == 0, "ReNFT::nft price not zero");
    }

    function ensureIsNotNull(Lending memory _lending) private pure {
        ensureIsNotZeroAddr(_lending.lenderAddress);
        require(_lending.maxRentDuration != 0, "ReNFT::duration zero");
        require(_lending.dailyRentPrice != 0, "ReNFT::rent price is zero");
        require(_lending.nftPrice != 0, "ReNFT::nft price is zero");
    }

    function ensureIsNull(Renting memory _renting) private pure {
        ensureIsZeroAddr(_renting.renterAddress);
        require(_renting.rentDuration == 0, "ReNFT::duration not zero");
        require(_renting.rentedAt == 0, "ReNFT::rented at not zero");
    }

    function ensureIsNotNull(Renting memory _renting) private pure {
        ensureIsNotZeroAddr(_renting.renterAddress);
        require(_renting.rentDuration != 0, "ReNFT::duration is zero");
        require(_renting.rentedAt != 0, "ReNFT::rented at is zero");
    }

    function ensureIsLendable(CallData memory _cd, uint256 _i) private pure {
        require(_cd.lentAmounts[_i] > 0, "ReNFT::lend amount is zero");
        require(_cd.lentAmounts[_i] <= type(uint8).max, "ReNFT::not uint8");
        require(_cd.maxRentDurations[_i] > 0, "ReNFT::duration is zero");
        require(
            _cd.maxRentDurations[_i] <= type(uint8).max,
            "ReNFT::not uint8"
        );
        require(
            uint32(_cd.dailyRentPrices[_i]) > 0,
            "ReNFT::rent price is zero"
        );
        require(uint32(_cd.nftPrices[_i]) > 0, "ReNFT::nft price is zero");
    }

    function ensureIsRentable(
        Lending memory _lending,
        CallData memory _cd,
        uint256 _i,
        address _msgSender
    ) private pure {
        require(
            _msgSender != _lending.lenderAddress,
            "ReNFT::cant rent own nft"
        );
        require(_cd.rentDurations[_i] <= type(uint8).max, "ReNFT::not uint8");
        require(_cd.rentDurations[_i] > 0, "ReNFT::duration is zero");
        require(
            _cd.rentDurations[_i] <= _lending.maxRentDuration,
            "ReNFT::rent duration exceeds allowed max"
        );
    }

    function ensureIsReturnable(
        Renting memory _renting,
        address _msgSender,
        uint256 _blockTimestamp
    ) private pure {
        require(_renting.renterAddress == _msgSender, "ReNFT::not renter");
        require(
            !isPastReturnDate(_renting, _blockTimestamp),
            "ReNFT::past return date"
        );
    }

    function ensureIsStoppable(Lending memory _lending, address _msgSender)
        private
        pure
    {
        require(_lending.lenderAddress == _msgSender, "ReNFT::not lender");
    }

    function ensureIsClaimable(Renting memory _renting, uint256 _blockTimestamp)
        private
        pure
    {
        require(
            isPastReturnDate(_renting, _blockTimestamp),
            "ReNFT::return date not passed"
        );
    }

    function ensureIsUnpackablePrice(bytes4 _price, uint256 _scale)
        private
        pure
    {
        require(uint32(_price) > 0, "ReNFT::invalid price");
        require(_scale >= 10000, "ReNFT::invalid scale");
    }

    function ensureTokenNotSentinel(uint8 _paymentIx) private pure {
        require(_paymentIx > 0, "ReNFT::token is sentinel");
    }

    function isPastReturnDate(Renting memory _renting, uint256 _now)
        private
        pure
        returns (bool)
    {
        require(_now > _renting.rentedAt, "ReNFT::now before rented");
        return
            _now - _renting.rentedAt > _renting.rentDuration * SECONDS_IN_DAY;
    }

    //      .-.     .-.     .-.     .-.     .-.     .-.     .-.     .-.     .-.     .-.
    // `._.'   `._.'   `._.'   `._.'   `._.'   `._.'   `._.'   `._.'   `._.'   `._.'   `._.'

    function setRentFee(uint256 _rentFee) external onlyAdmin {
        require(_rentFee < 10000, "ReNFT::fee exceeds 100pct");
        rentFee = _rentFee;
    }

    function setBeneficiary(address payable _newBeneficiary)
        external
        onlyAdmin
    {
        beneficiary = _newBeneficiary;
    }

    function setPaused(bool _paused) external onlyAdmin {
        paused = _paused;
    }
}

//              @@@@@@@@@@@@@@@@        ,@@@@@@@@@@@@@@@@
//              @@@,,,,,,,,,,@@@        ,@@&,,,,,,,,,,@@@
//         @@@@@@@@,,,,,,,,,,@@@@@@@@&  ,@@&,,,,,,,,,,@@@@@@@@
//         @@@**********@@@@@@@@@@@@@&  ,@@@@@@@@**********@@@
//         @@@**********@@@@@@@@@@@@@&  ,@@@@@@@@**********@@@@@@@@
//         @@@**********@@@@@@@@@@@@@&       [email protected]@@**********@@@@@@@@
//    @@@@@@@@**********@@@@@@@@@@@@@&       [email protected]@@**********@@@@@@@@
//    @@@**********@@@@@@@@@@@@@&            [email protected]@@@@@@@**********@@@
//    @@@**********@@@@@@@@@@@@@&            [email protected]@@@@@@@**********@@@@@@@@
//    @@@@@@@@**********@@@@@@@@&            [email protected]@@**********@@@@@@@@@@@@@
//    @@@@@@@@//////////@@@@@@@@&            [email protected]@@//////////@@@@@@@@@@@@@
//         @@@//////////@@@@@@@@&            [email protected]@@//////////@@@@@@@@@@@@@
//         @@@//////////@@@@@@@@&       ,@@@@@@@@//////////@@@@@@@@@@@@@
//         @@@%%%%%/////(((((@@@&       ,@@@(((((/////%%%%%@@@@@@@@
//         @@@@@@@@//////////@@@@@@@@&  ,@@@//////////@@@@@@@@@@@@@
//              @@@%%%%%%%%%%@@@@@@@@&  ,@@@%%%%%%%%%%@@@@@@@@@@@@@
//              @@@@@@@@@@@@@@@@@@@@@&  ,@@@@@@@@@@@@@@@@@@@@@@@@@@
//                   @@@@@@@@@@@@@@@@&        @@@@@@@@@@@@@@@@
//                   @@@@@@@@@@@@@@@@&        @@@@@@@@@@@@@@@@

File 2 of 17 : IERC20.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC20 standard as defined in the EIP.
 */
interface IERC20 {
    /**
     * @dev Returns the amount of tokens in existence.
     */
    function totalSupply() external view returns (uint256);

    /**
     * @dev Returns the amount of tokens owned by `account`.
     */
    function balanceOf(address account) external view returns (uint256);

    /**
     * @dev Moves `amount` tokens from the caller's account to `recipient`.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transfer(address recipient, uint256 amount) external returns (bool);

    /**
     * @dev Returns the remaining number of tokens that `spender` will be
     * allowed to spend on behalf of `owner` through {transferFrom}. This is
     * zero by default.
     *
     * This value changes when {approve} or {transferFrom} are called.
     */
    function allowance(address owner, address spender) external view returns (uint256);

    /**
     * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * IMPORTANT: Beware that changing an allowance with this method brings the risk
     * that someone may use both the old and the new allowance by unfortunate
     * transaction ordering. One possible solution to mitigate this race
     * condition is to first reduce the spender's allowance to 0 and set the
     * desired value afterwards:
     * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
     *
     * Emits an {Approval} event.
     */
    function approve(address spender, uint256 amount) external returns (bool);

    /**
     * @dev Moves `amount` tokens from `sender` to `recipient` using the
     * allowance mechanism. `amount` is then deducted from the caller's
     * allowance.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);

    /**
     * @dev Emitted when `value` tokens are moved from one account (`from`) to
     * another (`to`).
     *
     * Note that `value` may be zero.
     */
    event Transfer(address indexed from, address indexed to, uint256 value);

    /**
     * @dev Emitted when the allowance of a `spender` for an `owner` is set by
     * a call to {approve}. `value` is the new allowance.
     */
    event Approval(address indexed owner, address indexed spender, uint256 value);
}

File 3 of 17 : ERC20.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "./IERC20.sol";
import "../../utils/Context.sol";

/**
 * @dev Implementation of the {IERC20} interface.
 *
 * This implementation is agnostic to the way tokens are created. This means
 * that a supply mechanism has to be added in a derived contract using {_mint}.
 * For a generic mechanism see {ERC20PresetMinterPauser}.
 *
 * TIP: For a detailed writeup see our guide
 * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How
 * to implement supply mechanisms].
 *
 * We have followed general OpenZeppelin guidelines: functions revert instead
 * of returning `false` on failure. This behavior is nonetheless conventional
 * and does not conflict with the expectations of ERC20 applications.
 *
 * Additionally, an {Approval} event is emitted on calls to {transferFrom}.
 * This allows applications to reconstruct the allowance for all accounts just
 * by listening to said events. Other implementations of the EIP may not emit
 * these events, as it isn't required by the specification.
 *
 * Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
 * functions have been added to mitigate the well-known issues around setting
 * allowances. See {IERC20-approve}.
 */
contract ERC20 is Context, IERC20 {
    mapping (address => uint256) private _balances;

    mapping (address => mapping (address => uint256)) private _allowances;

    uint256 private _totalSupply;

    string private _name;
    string private _symbol;

    /**
     * @dev Sets the values for {name} and {symbol}.
     *
     * The defaut value of {decimals} is 18. To select a different value for
     * {decimals} you should overload it.
     *
     * All three of these values are immutable: they can only be set once during
     * construction.
     */
    constructor (string memory name_, string memory symbol_) {
        _name = name_;
        _symbol = symbol_;
    }

    /**
     * @dev Returns the name of the token.
     */
    function name() public view virtual returns (string memory) {
        return _name;
    }

    /**
     * @dev Returns the symbol of the token, usually a shorter version of the
     * name.
     */
    function symbol() public view virtual returns (string memory) {
        return _symbol;
    }

    /**
     * @dev Returns the number of decimals used to get its user representation.
     * For example, if `decimals` equals `2`, a balance of `505` tokens should
     * be displayed to a user as `5,05` (`505 / 10 ** 2`).
     *
     * Tokens usually opt for a value of 18, imitating the relationship between
     * Ether and Wei. This is the value {ERC20} uses, unless this function is
     * overloaded;
     *
     * NOTE: This information is only used for _display_ purposes: it in
     * no way affects any of the arithmetic of the contract, including
     * {IERC20-balanceOf} and {IERC20-transfer}.
     */
    function decimals() public view virtual returns (uint8) {
        return 18;
    }

    /**
     * @dev See {IERC20-totalSupply}.
     */
    function totalSupply() public view virtual override returns (uint256) {
        return _totalSupply;
    }

    /**
     * @dev See {IERC20-balanceOf}.
     */
    function balanceOf(address account) public view virtual override returns (uint256) {
        return _balances[account];
    }

    /**
     * @dev See {IERC20-transfer}.
     *
     * Requirements:
     *
     * - `recipient` cannot be the zero address.
     * - the caller must have a balance of at least `amount`.
     */
    function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
        _transfer(_msgSender(), recipient, amount);
        return true;
    }

    /**
     * @dev See {IERC20-allowance}.
     */
    function allowance(address owner, address spender) public view virtual override returns (uint256) {
        return _allowances[owner][spender];
    }

    /**
     * @dev See {IERC20-approve}.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     */
    function approve(address spender, uint256 amount) public virtual override returns (bool) {
        _approve(_msgSender(), spender, amount);
        return true;
    }

    /**
     * @dev See {IERC20-transferFrom}.
     *
     * Emits an {Approval} event indicating the updated allowance. This is not
     * required by the EIP. See the note at the beginning of {ERC20}.
     *
     * Requirements:
     *
     * - `sender` and `recipient` cannot be the zero address.
     * - `sender` must have a balance of at least `amount`.
     * - the caller must have allowance for ``sender``'s tokens of at least
     * `amount`.
     */
    function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {
        _transfer(sender, recipient, amount);

        uint256 currentAllowance = _allowances[sender][_msgSender()];
        require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance");
        _approve(sender, _msgSender(), currentAllowance - amount);

        return true;
    }

    /**
     * @dev Atomically increases the allowance granted to `spender` by the caller.
     *
     * This is an alternative to {approve} that can be used as a mitigation for
     * problems described in {IERC20-approve}.
     *
     * Emits an {Approval} event indicating the updated allowance.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     */
    function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
        _approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue);
        return true;
    }

    /**
     * @dev Atomically decreases the allowance granted to `spender` by the caller.
     *
     * This is an alternative to {approve} that can be used as a mitigation for
     * problems described in {IERC20-approve}.
     *
     * Emits an {Approval} event indicating the updated allowance.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     * - `spender` must have allowance for the caller of at least
     * `subtractedValue`.
     */
    function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
        uint256 currentAllowance = _allowances[_msgSender()][spender];
        require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero");
        _approve(_msgSender(), spender, currentAllowance - subtractedValue);

        return true;
    }

    /**
     * @dev Moves tokens `amount` from `sender` to `recipient`.
     *
     * This is internal function is equivalent to {transfer}, and can be used to
     * e.g. implement automatic token fees, slashing mechanisms, etc.
     *
     * Emits a {Transfer} event.
     *
     * Requirements:
     *
     * - `sender` cannot be the zero address.
     * - `recipient` cannot be the zero address.
     * - `sender` must have a balance of at least `amount`.
     */
    function _transfer(address sender, address recipient, uint256 amount) internal virtual {
        require(sender != address(0), "ERC20: transfer from the zero address");
        require(recipient != address(0), "ERC20: transfer to the zero address");

        _beforeTokenTransfer(sender, recipient, amount);

        uint256 senderBalance = _balances[sender];
        require(senderBalance >= amount, "ERC20: transfer amount exceeds balance");
        _balances[sender] = senderBalance - amount;
        _balances[recipient] += amount;

        emit Transfer(sender, recipient, amount);
    }

    /** @dev Creates `amount` tokens and assigns them to `account`, increasing
     * the total supply.
     *
     * Emits a {Transfer} event with `from` set to the zero address.
     *
     * Requirements:
     *
     * - `to` cannot be the zero address.
     */
    function _mint(address account, uint256 amount) internal virtual {
        require(account != address(0), "ERC20: mint to the zero address");

        _beforeTokenTransfer(address(0), account, amount);

        _totalSupply += amount;
        _balances[account] += amount;
        emit Transfer(address(0), account, amount);
    }

    /**
     * @dev Destroys `amount` tokens from `account`, reducing the
     * total supply.
     *
     * Emits a {Transfer} event with `to` set to the zero address.
     *
     * Requirements:
     *
     * - `account` cannot be the zero address.
     * - `account` must have at least `amount` tokens.
     */
    function _burn(address account, uint256 amount) internal virtual {
        require(account != address(0), "ERC20: burn from the zero address");

        _beforeTokenTransfer(account, address(0), amount);

        uint256 accountBalance = _balances[account];
        require(accountBalance >= amount, "ERC20: burn amount exceeds balance");
        _balances[account] = accountBalance - amount;
        _totalSupply -= amount;

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

    /**
     * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.
     *
     * This internal function is equivalent to `approve`, and can be used to
     * e.g. set automatic allowances for certain subsystems, etc.
     *
     * Emits an {Approval} event.
     *
     * Requirements:
     *
     * - `owner` cannot be the zero address.
     * - `spender` cannot be the zero address.
     */
    function _approve(address owner, address spender, uint256 amount) internal virtual {
        require(owner != address(0), "ERC20: approve from the zero address");
        require(spender != address(0), "ERC20: approve to the zero address");

        _allowances[owner][spender] = amount;
        emit Approval(owner, spender, amount);
    }

    /**
     * @dev Hook that is called before any transfer of tokens. This includes
     * minting and burning.
     *
     * Calling conditions:
     *
     * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
     * will be to transferred to `to`.
     * - when `from` is zero, `amount` tokens will be minted for `to`.
     * - when `to` is zero, `amount` of ``from``'s tokens will be burned.
     * - `from` and `to` are never both zero.
     *
     * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
     */
    function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { }
}

File 4 of 17 : IERC721.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "../../utils/introspection/IERC165.sol";

/**
 * @dev Required interface of an ERC721 compliant contract.
 */
interface IERC721 is IERC165 {
    /**
     * @dev Emitted when `tokenId` token is transferred from `from` to `to`.
     */
    event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);

    /**
     * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.
     */
    event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);

    /**
     * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.
     */
    event ApprovalForAll(address indexed owner, address indexed operator, bool approved);

    /**
     * @dev Returns the number of tokens in ``owner``'s account.
     */
    function balanceOf(address owner) external view returns (uint256 balance);

    /**
     * @dev Returns the owner of the `tokenId` token.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     */
    function ownerOf(uint256 tokenId) external view returns (address owner);

    /**
     * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
     * are aware of the ERC721 protocol to prevent tokens from being forever locked.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must exist and be owned by `from`.
     * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}.
     * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
     *
     * Emits a {Transfer} event.
     */
    function safeTransferFrom(address from, address to, uint256 tokenId) external;

    /**
     * @dev Transfers `tokenId` token from `from` to `to`.
     *
     * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must be owned by `from`.
     * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
     *
     * Emits a {Transfer} event.
     */
    function transferFrom(address from, address to, uint256 tokenId) external;

    /**
     * @dev Gives permission to `to` to transfer `tokenId` token to another account.
     * The approval is cleared when the token is transferred.
     *
     * Only a single account can be approved at a time, so approving the zero address clears previous approvals.
     *
     * Requirements:
     *
     * - The caller must own the token or be an approved operator.
     * - `tokenId` must exist.
     *
     * Emits an {Approval} event.
     */
    function approve(address to, uint256 tokenId) external;

    /**
     * @dev Returns the account approved for `tokenId` token.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     */
    function getApproved(uint256 tokenId) external view returns (address operator);

    /**
     * @dev Approve or remove `operator` as an operator for the caller.
     * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.
     *
     * Requirements:
     *
     * - The `operator` cannot be the caller.
     *
     * Emits an {ApprovalForAll} event.
     */
    function setApprovalForAll(address operator, bool _approved) external;

    /**
     * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.
     *
     * See {setApprovalForAll}
     */
    function isApprovedForAll(address owner, address operator) external view returns (bool);

    /**
      * @dev Safely transfers `tokenId` token from `from` to `to`.
      *
      * Requirements:
      *
      * - `from` cannot be the zero address.
      * - `to` cannot be the zero address.
      * - `tokenId` token must exist and be owned by `from`.
      * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
      * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
      *
      * Emits a {Transfer} event.
      */
    function safeTransferFrom(address from, address to, uint256 tokenId, bytes calldata data) external;
}

File 5 of 17 : IERC1155.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "../../utils/introspection/IERC165.sol";

/**
 * @dev Required interface of an ERC1155 compliant contract, as defined in the
 * https://eips.ethereum.org/EIPS/eip-1155[EIP].
 *
 * _Available since v3.1._
 */
interface IERC1155 is IERC165 {
    /**
     * @dev Emitted when `value` tokens of token type `id` are transferred from `from` to `to` by `operator`.
     */
    event TransferSingle(address indexed operator, address indexed from, address indexed to, uint256 id, uint256 value);

    /**
     * @dev Equivalent to multiple {TransferSingle} events, where `operator`, `from` and `to` are the same for all
     * transfers.
     */
    event TransferBatch(address indexed operator, address indexed from, address indexed to, uint256[] ids, uint256[] values);

    /**
     * @dev Emitted when `account` grants or revokes permission to `operator` to transfer their tokens, according to
     * `approved`.
     */
    event ApprovalForAll(address indexed account, address indexed operator, bool approved);

    /**
     * @dev Emitted when the URI for token type `id` changes to `value`, if it is a non-programmatic URI.
     *
     * If an {URI} event was emitted for `id`, the standard
     * https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[guarantees] that `value` will equal the value
     * returned by {IERC1155MetadataURI-uri}.
     */
    event URI(string value, uint256 indexed id);

    /**
     * @dev Returns the amount of tokens of token type `id` owned by `account`.
     *
     * Requirements:
     *
     * - `account` cannot be the zero address.
     */
    function balanceOf(address account, uint256 id) external view returns (uint256);

    /**
     * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {balanceOf}.
     *
     * Requirements:
     *
     * - `accounts` and `ids` must have the same length.
     */
    function balanceOfBatch(address[] calldata accounts, uint256[] calldata ids) external view returns (uint256[] memory);

    /**
     * @dev Grants or revokes permission to `operator` to transfer the caller's tokens, according to `approved`,
     *
     * Emits an {ApprovalForAll} event.
     *
     * Requirements:
     *
     * - `operator` cannot be the caller.
     */
    function setApprovalForAll(address operator, bool approved) external;

    /**
     * @dev Returns true if `operator` is approved to transfer ``account``'s tokens.
     *
     * See {setApprovalForAll}.
     */
    function isApprovedForAll(address account, address operator) external view returns (bool);

    /**
     * @dev Transfers `amount` tokens of token type `id` from `from` to `to`.
     *
     * Emits a {TransferSingle} event.
     *
     * Requirements:
     *
     * - `to` cannot be the zero address.
     * - If the caller is not `from`, it must be have been approved to spend ``from``'s tokens via {setApprovalForAll}.
     * - `from` must have a balance of tokens of type `id` of at least `amount`.
     * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the
     * acceptance magic value.
     */
    function safeTransferFrom(address from, address to, uint256 id, uint256 amount, bytes calldata data) external;

    /**
     * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {safeTransferFrom}.
     *
     * Emits a {TransferBatch} event.
     *
     * Requirements:
     *
     * - `ids` and `amounts` must have the same length.
     * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the
     * acceptance magic value.
     */
    function safeBatchTransferFrom(address from, address to, uint256[] calldata ids, uint256[] calldata amounts, bytes calldata data) external;
}

File 6 of 17 : ERC721Holder.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "../IERC721Receiver.sol";

  /**
   * @dev Implementation of the {IERC721Receiver} interface.
   *
   * Accepts all token transfers.
   * Make sure the contract is able to use its token with {IERC721-safeTransferFrom}, {IERC721-approve} or {IERC721-setApprovalForAll}.
   */
contract ERC721Holder is IERC721Receiver {

    /**
     * @dev See {IERC721Receiver-onERC721Received}.
     *
     * Always returns `IERC721Receiver.onERC721Received.selector`.
     */
    function onERC721Received(address, address, uint256, bytes memory) public virtual override returns (bytes4) {
        return this.onERC721Received.selector;
    }
}

File 7 of 17 : ERC1155Receiver.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "../IERC1155Receiver.sol";
import "../../../utils/introspection/ERC165.sol";

/**
 * @dev _Available since v3.1._
 */
abstract contract ERC1155Receiver is ERC165, IERC1155Receiver {
    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {
        return interfaceId == type(IERC1155Receiver).interfaceId
            || super.supportsInterface(interfaceId);
    }
}

File 8 of 17 : ERC1155Holder.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "./ERC1155Receiver.sol";

/**
 * @dev _Available since v3.1._
 */
contract ERC1155Holder is ERC1155Receiver {
    function onERC1155Received(address, address, uint256, uint256, bytes memory) public virtual override returns (bytes4) {
        return this.onERC1155Received.selector;
    }

    function onERC1155BatchReceived(address, address, uint256[] memory, uint256[] memory, bytes memory) public virtual override returns (bytes4) {
        return this.onERC1155BatchReceived.selector;
    }
}

File 9 of 17 : IResolver.sol
// SPDX-License-Identifier: MIT
pragma solidity =0.8.6;

interface IResolver {
    enum PaymentToken {SENTINEL, WETH, DAI, USDC, USDT, TUSD, RENT}

    function getPaymentToken(uint8 _pt) external view returns (address);

    function setPaymentToken(uint8 _pt, address _v) external;
}

File 10 of 17 : IReNFT.sol
// SPDX-License-Identifier: MIT
pragma solidity =0.8.6;

import "@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol";
import "@openzeppelin/contracts/token/ERC721/IERC721.sol";
import "@openzeppelin/contracts/token/ERC1155/IERC1155.sol";
import "@openzeppelin/contracts/token/ERC1155/IERC1155Receiver.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";

import "./IResolver.sol";

interface IReNft is IERC721Receiver, IERC1155Receiver {
    event Lent(
        address indexed nftAddress,
        uint256 indexed tokenId,
        uint8 lentAmount,
        uint256 lendingId,
        address indexed lenderAddress,
        uint8 maxRentDuration,
        bytes4 dailyRentPrice,
        bytes4 nftPrice,
        bool isERC721,
        IResolver.PaymentToken paymentToken
    );

    event Rented(
        uint256 lendingId,
        address indexed renterAddress,
        uint8 rentDuration,
        uint32 rentedAt
    );

    event Returned(uint256 indexed lendingId, uint32 returnedAt);

    event CollateralClaimed(uint256 indexed lendingId, uint32 claimedAt);

    event LendingStopped(uint256 indexed lendingId, uint32 stoppedAt);

    /**
     * @dev sends your NFT to ReNFT contract, which acts as an escrow
     * between the lender and the renter
     */
    function lend(
        address[] memory _nft,
        uint256[] memory _tokenId,
        uint256[] memory _lendAmounts,
        uint8[] memory _maxRentDuration,
        bytes4[] memory _dailyRentPrice,
        bytes4[] memory _nftPrice,
        IResolver.PaymentToken[] memory _paymentToken
    ) external;

    /**
     * @dev renter sends rentDuration * dailyRentPrice
     * to cover for the potentially full cost of renting. They also
     * must send the collateral (nft price set by the lender in lend)
     */
    function rent(
        address[] memory _nft,
        uint256[] memory _tokenId,
        uint256[] memory _lendingIds,
        uint8[] memory _rentDurations
    ) external;

    /**
     * @dev renters call this to return the rented NFT before the
     * deadline. If they fail to do so, they will lose the posted
     * collateral
     */
    function returnIt(
        address[] memory _nft,
        uint256[] memory _tokenId,
        uint256[] memory _lendingIds
    ) external;

    /**
     * @dev claim collateral on rentals that are past their due date
     */
    function claimCollateral(
        address[] memory _nfts,
        uint256[] memory _tokenIds,
        uint256[] memory _lendingIds
    ) external;

    /**
     * @dev stop lending releases the NFT from escrow and sends it back
     * to the lender
     */
    function stopLending(
        address[] memory _nft,
        uint256[] memory _tokenId,
        uint256[] memory _lendingIds
    ) external;
}

File 11 of 17 : Context.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

/*
 * @dev Provides information about the current execution context, including the
 * sender of the transaction and its data. While these are generally available
 * via msg.sender and msg.data, they should not be accessed in such a direct
 * manner, since when dealing with meta-transactions the account sending and
 * paying for execution may not be the actual sender (as far as an application
 * is concerned).
 *
 * This contract is only required for intermediate, library-like contracts.
 */
abstract contract Context {
    function _msgSender() internal view virtual returns (address) {
        return msg.sender;
    }

    function _msgData() internal view virtual returns (bytes calldata) {
        this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691
        return msg.data;
    }
}

File 12 of 17 : IERC165.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC165 standard, as defined in the
 * https://eips.ethereum.org/EIPS/eip-165[EIP].
 *
 * Implementers can declare support of contract interfaces, which can then be
 * queried by others ({ERC165Checker}).
 *
 * For an implementation, see {ERC165}.
 */
interface IERC165 {
    /**
     * @dev Returns true if this contract implements the interface defined by
     * `interfaceId`. See the corresponding
     * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
     * to learn more about how these ids are created.
     *
     * This function call must use less than 30 000 gas.
     */
    function supportsInterface(bytes4 interfaceId) external view returns (bool);
}

File 13 of 17 : IERC721Receiver.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

/**
 * @title ERC721 token receiver interface
 * @dev Interface for any contract that wants to support safeTransfers
 * from ERC721 asset contracts.
 */
interface IERC721Receiver {
    /**
     * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}
     * by `operator` from `from`, this function is called.
     *
     * It must return its Solidity selector to confirm the token transfer.
     * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted.
     *
     * The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`.
     */
    function onERC721Received(address operator, address from, uint256 tokenId, bytes calldata data) external returns (bytes4);
}

File 14 of 17 : IERC1155Receiver.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "../../utils/introspection/IERC165.sol";

/**
 * _Available since v3.1._
 */
interface IERC1155Receiver is IERC165 {

    /**
        @dev Handles the receipt of a single ERC1155 token type. This function is
        called at the end of a `safeTransferFrom` after the balance has been updated.
        To accept the transfer, this must return
        `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))`
        (i.e. 0xf23a6e61, or its own function selector).
        @param operator The address which initiated the transfer (i.e. msg.sender)
        @param from The address which previously owned the token
        @param id The ID of the token being transferred
        @param value The amount of tokens being transferred
        @param data Additional data with no specified format
        @return `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))` if transfer is allowed
    */
    function onERC1155Received(
        address operator,
        address from,
        uint256 id,
        uint256 value,
        bytes calldata data
    )
        external
        returns(bytes4);

    /**
        @dev Handles the receipt of a multiple ERC1155 token types. This function
        is called at the end of a `safeBatchTransferFrom` after the balances have
        been updated. To accept the transfer(s), this must return
        `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))`
        (i.e. 0xbc197c81, or its own function selector).
        @param operator The address which initiated the batch transfer (i.e. msg.sender)
        @param from The address which previously owned the token
        @param ids An array containing ids of each token being transferred (order and length must match values array)
        @param values An array containing amounts of each token being transferred (order and length must match ids array)
        @param data Additional data with no specified format
        @return `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))` if transfer is allowed
    */
    function onERC1155BatchReceived(
        address operator,
        address from,
        uint256[] calldata ids,
        uint256[] calldata values,
        bytes calldata data
    )
        external
        returns(bytes4);
}

File 15 of 17 : ERC165.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "./IERC165.sol";

/**
 * @dev Implementation of the {IERC165} interface.
 *
 * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check
 * for the additional interface id that will be supported. For example:
 *
 * ```solidity
 * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
 *     return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);
 * }
 * ```
 *
 * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.
 */
abstract contract ERC165 is IERC165 {
    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
        return interfaceId == type(IERC165).interfaceId;
    }
}

File 16 of 17 : SafeERC20.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "../IERC20.sol";
import "../../../utils/Address.sol";

/**
 * @title SafeERC20
 * @dev Wrappers around ERC20 operations that throw on failure (when the token
 * contract returns false). Tokens that return no value (and instead revert or
 * throw on failure) are also supported, non-reverting calls are assumed to be
 * successful.
 * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
 * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
 */
library SafeERC20 {
    using Address for address;

    function safeTransfer(IERC20 token, address to, uint256 value) internal {
        _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
    }

    function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {
        _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
    }

    /**
     * @dev Deprecated. This function has issues similar to the ones found in
     * {IERC20-approve}, and its usage is discouraged.
     *
     * Whenever possible, use {safeIncreaseAllowance} and
     * {safeDecreaseAllowance} instead.
     */
    function safeApprove(IERC20 token, address spender, uint256 value) internal {
        // safeApprove should only be called when setting an initial allowance,
        // or when resetting it to zero. To increase and decrease it, use
        // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
        // solhint-disable-next-line max-line-length
        require((value == 0) || (token.allowance(address(this), spender) == 0),
            "SafeERC20: approve from non-zero to non-zero allowance"
        );
        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
    }

    function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
        uint256 newAllowance = token.allowance(address(this), spender) + value;
        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
    }

    function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal {
        unchecked {
            uint256 oldAllowance = token.allowance(address(this), spender);
            require(oldAllowance >= value, "SafeERC20: decreased allowance below zero");
            uint256 newAllowance = oldAllowance - value;
            _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
        }
    }

    /**
     * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
     * on the return value: the return value is optional (but if data is returned, it must not be false).
     * @param token The token targeted by the call.
     * @param data The call data (encoded using abi.encode or one of its variants).
     */
    function _callOptionalReturn(IERC20 token, bytes memory data) private {
        // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
        // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that
        // the target address contains contract code and also asserts for success in the low-level call.

        bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed");
        if (returndata.length > 0) { // Return data is optional
            // solhint-disable-next-line max-line-length
            require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
        }
    }
}

File 17 of 17 : Address.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

/**
 * @dev Collection of functions related to the address type
 */
library Address {
    /**
     * @dev Returns true if `account` is a contract.
     *
     * [IMPORTANT]
     * ====
     * It is unsafe to assume that an address for which this function returns
     * false is an externally-owned account (EOA) and not a contract.
     *
     * Among others, `isContract` will return false for the following
     * types of addresses:
     *
     *  - an externally-owned account
     *  - a contract in construction
     *  - an address where a contract will be created
     *  - an address where a contract lived, but was destroyed
     * ====
     */
    function isContract(address account) internal view returns (bool) {
        // This method relies on extcodesize, which returns 0 for contracts in
        // construction, since the code is only stored at the end of the
        // constructor execution.

        uint256 size;
        // solhint-disable-next-line no-inline-assembly
        assembly { size := extcodesize(account) }
        return size > 0;
    }

    /**
     * @dev Replacement for Solidity's `transfer`: sends `amount` wei to
     * `recipient`, forwarding all available gas and reverting on errors.
     *
     * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
     * of certain opcodes, possibly making contracts go over the 2300 gas limit
     * imposed by `transfer`, making them unable to receive funds via
     * `transfer`. {sendValue} removes this limitation.
     *
     * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
     *
     * IMPORTANT: because control is transferred to `recipient`, care must be
     * taken to not create reentrancy vulnerabilities. Consider using
     * {ReentrancyGuard} or the
     * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
     */
    function sendValue(address payable recipient, uint256 amount) internal {
        require(address(this).balance >= amount, "Address: insufficient balance");

        // solhint-disable-next-line avoid-low-level-calls, avoid-call-value
        (bool success, ) = recipient.call{ value: amount }("");
        require(success, "Address: unable to send value, recipient may have reverted");
    }

    /**
     * @dev Performs a Solidity function call using a low level `call`. A
     * plain`call` is an unsafe replacement for a function call: use this
     * function instead.
     *
     * If `target` reverts with a revert reason, it is bubbled up by this
     * function (like regular Solidity function calls).
     *
     * Returns the raw returned data. To convert to the expected return value,
     * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
     *
     * Requirements:
     *
     * - `target` must be a contract.
     * - calling `target` with `data` must not revert.
     *
     * _Available since v3.1._
     */
    function functionCall(address target, bytes memory data) internal returns (bytes memory) {
      return functionCall(target, data, "Address: low-level call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
     * `errorMessage` as a fallback revert reason when `target` reverts.
     *
     * _Available since v3.1._
     */
    function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
        return functionCallWithValue(target, data, 0, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but also transferring `value` wei to `target`.
     *
     * Requirements:
     *
     * - the calling contract must have an ETH balance of at least `value`.
     * - the called Solidity function must be `payable`.
     *
     * _Available since v3.1._
     */
    function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
        return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
    }

    /**
     * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
     * with `errorMessage` as a fallback revert reason when `target` reverts.
     *
     * _Available since v3.1._
     */
    function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {
        require(address(this).balance >= value, "Address: insufficient balance for call");
        require(isContract(target), "Address: call to non-contract");

        // solhint-disable-next-line avoid-low-level-calls
        (bool success, bytes memory returndata) = target.call{ value: value }(data);
        return _verifyCallResult(success, returndata, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a static call.
     *
     * _Available since v3.3._
     */
    function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
        return functionStaticCall(target, data, "Address: low-level static call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
     * but performing a static call.
     *
     * _Available since v3.3._
     */
    function functionStaticCall(address target, bytes memory data, string memory errorMessage) internal view returns (bytes memory) {
        require(isContract(target), "Address: static call to non-contract");

        // solhint-disable-next-line avoid-low-level-calls
        (bool success, bytes memory returndata) = target.staticcall(data);
        return _verifyCallResult(success, returndata, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a delegate call.
     *
     * _Available since v3.4._
     */
    function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
        return functionDelegateCall(target, data, "Address: low-level delegate call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
     * but performing a delegate call.
     *
     * _Available since v3.4._
     */
    function functionDelegateCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
        require(isContract(target), "Address: delegate call to non-contract");

        // solhint-disable-next-line avoid-low-level-calls
        (bool success, bytes memory returndata) = target.delegatecall(data);
        return _verifyCallResult(success, returndata, errorMessage);
    }

    function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) {
        if (success) {
            return returndata;
        } else {
            // Look for revert reason and bubble it up if present
            if (returndata.length > 0) {
                // The easiest way to bubble the revert reason is using memory via assembly

                // solhint-disable-next-line no-inline-assembly
                assembly {
                    let returndata_size := mload(returndata)
                    revert(add(32, returndata), returndata_size)
                }
            } else {
                revert(errorMessage);
            }
        }
    }
}

Settings
{
  "optimizer": {
    "enabled": true,
    "runs": 200
  },
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "abi"
      ]
    }
  },
  "metadata": {
    "useLiteralContent": true
  },
  "libraries": {}
}

Contract Security Audit

Contract ABI

[{"inputs":[{"internalType":"address","name":"_resolver","type":"address"},{"internalType":"address payable","name":"_beneficiary","type":"address"},{"internalType":"address","name":"_admin","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"lendingId","type":"uint256"},{"indexed":false,"internalType":"uint32","name":"claimedAt","type":"uint32"}],"name":"CollateralClaimed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"lendingId","type":"uint256"},{"indexed":false,"internalType":"uint32","name":"stoppedAt","type":"uint32"}],"name":"LendingStopped","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"nftAddress","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"uint8","name":"lentAmount","type":"uint8"},{"indexed":false,"internalType":"uint256","name":"lendingId","type":"uint256"},{"indexed":true,"internalType":"address","name":"lenderAddress","type":"address"},{"indexed":false,"internalType":"uint8","name":"maxRentDuration","type":"uint8"},{"indexed":false,"internalType":"bytes4","name":"dailyRentPrice","type":"bytes4"},{"indexed":false,"internalType":"bytes4","name":"nftPrice","type":"bytes4"},{"indexed":false,"internalType":"bool","name":"isERC721","type":"bool"},{"indexed":false,"internalType":"enum IResolver.PaymentToken","name":"paymentToken","type":"uint8"}],"name":"Lent","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"lendingId","type":"uint256"},{"indexed":true,"internalType":"address","name":"renterAddress","type":"address"},{"indexed":false,"internalType":"uint8","name":"rentDuration","type":"uint8"},{"indexed":false,"internalType":"uint32","name":"rentedAt","type":"uint32"}],"name":"Rented","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"lendingId","type":"uint256"},{"indexed":false,"internalType":"uint32","name":"returnedAt","type":"uint32"}],"name":"Returned","type":"event"},{"inputs":[{"internalType":"address[]","name":"_nfts","type":"address[]"},{"internalType":"uint256[]","name":"_tokenIds","type":"uint256[]"},{"internalType":"uint256[]","name":"_lendingIds","type":"uint256[]"}],"name":"claimCollateral","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"_nfts","type":"address[]"},{"internalType":"uint256[]","name":"_tokenIds","type":"uint256[]"},{"internalType":"uint256[]","name":"_lendAmounts","type":"uint256[]"},{"internalType":"uint8[]","name":"_maxRentDurations","type":"uint8[]"},{"internalType":"bytes4[]","name":"_dailyRentPrices","type":"bytes4[]"},{"internalType":"bytes4[]","name":"_nftPrices","type":"bytes4[]"},{"internalType":"enum IResolver.PaymentToken[]","name":"_paymentTokens","type":"uint8[]"}],"name":"lend","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256[]","name":"","type":"uint256[]"},{"internalType":"uint256[]","name":"","type":"uint256[]"},{"internalType":"bytes","name":"","type":"bytes"}],"name":"onERC1155BatchReceived","outputs":[{"internalType":"bytes4","name":"","type":"bytes4"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bytes","name":"","type":"bytes"}],"name":"onERC1155Received","outputs":[{"internalType":"bytes4","name":"","type":"bytes4"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bytes","name":"","type":"bytes"}],"name":"onERC721Received","outputs":[{"internalType":"bytes4","name":"","type":"bytes4"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address[]","name":"_nfts","type":"address[]"},{"internalType":"uint256[]","name":"_tokenIds","type":"uint256[]"},{"internalType":"uint256[]","name":"_lendingIds","type":"uint256[]"},{"internalType":"uint8[]","name":"_rentDurations","type":"uint8[]"}],"name":"rent","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"rentFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address[]","name":"_nfts","type":"address[]"},{"internalType":"uint256[]","name":"_tokenIds","type":"uint256[]"},{"internalType":"uint256[]","name":"_lendingIds","type":"uint256[]"}],"name":"returnIt","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address payable","name":"_newBeneficiary","type":"address"}],"name":"setBeneficiary","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"_paused","type":"bool"}],"name":"setPaused","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_rentFee","type":"uint256"}],"name":"setRentFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"_nfts","type":"address[]"},{"internalType":"uint256[]","name":"_tokenIds","type":"uint256[]"},{"internalType":"uint256[]","name":"_lendingIds","type":"uint256[]"}],"name":"stopLending","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"}]

608060405260016003556004805460ff1916905560006005553480156200002557600080fd5b50604051620042ab380380620042ab83398101604081905262000048916200010a565b6200005383620000ac565b6200005e82620000ac565b6200006981620000ac565b600080546001600160a01b039485166001600160a01b03199182161790915560028054938516938216939093179092556001805491909316911617905562000174565b6001600160a01b038116620001075760405162461bcd60e51b815260206004820152601360248201527f52654e46543a3a7a65726f206164647265737300000000000000000000000000604482015260640160405180910390fd5b50565b6000806000606084860312156200012057600080fd5b83516200012d816200015e565b602085015190935062000140816200015e565b604085015190925062000153816200015e565b809150509250925092565b6001600160a01b03811681146200010757600080fd5b61412780620001846000396000f3fe608060405234801561001057600080fd5b50600436106100ea5760003560e01c80635de07ca31161008c578063bf2b23ea11610066578063bf2b23ea146101ee578063e50364b214610205578063f23a6e6114610218578063fb1585191461023757600080fd5b80635de07ca3146101a957806376774ea3146101bc578063bc197c81146101cf57600080fd5b806316c38b3c116100c857806316c38b3c146101635780631c31f7101461017657806359fe66e4146101895780635c975abb1461019c57600080fd5b806301ffc9a7146100ef578063098130df14610117578063150b7a021461012c575b600080fd5b6101026100fd366004613b89565b61024a565b60405190151581526020015b60405180910390f35b61012a61012536600461390e565b610281565b005b61014a61013a36600461383b565b630a85bd0160e11b949350505050565b6040516001600160e01b0319909116815260200161010e565b61012a610171366004613b4f565b6102c8565b61012a610184366004613771565b610305565b61012a61019736600461390e565b610351565b6004546101029060ff1681565b61012a6101b7366004613995565b610385565b61012a6101ca366004613ba4565b6103c0565b61014a6101dd36600461378e565b63bc197c8160e01b95945050505050565b6101f760055481565b60405190815260200161010e565b61012a610213366004613a35565b610440565b61014a6102263660046138a6565b63f23a6e6160e01b95945050505050565b61012a61024536600461390e565b610481565b60006001600160e01b03198216630271189760e51b148061027b57506301ffc9a760e01b6001600160e01b03198316145b92915050565b60045460ff16156102ad5760405162461bcd60e51b81526004016102a490613d81565b60405180910390fd5b6102c36104b56102be858585610844565b610980565b505050565b6001546001600160a01b031633146102f25760405162461bcd60e51b81526004016102a490613ddf565b6004805460ff1916911515919091179055565b6001546001600160a01b0316331461032f5760405162461bcd60e51b81526004016102a490613ddf565b600280546001600160a01b0319166001600160a01b0392909216919091179055565b60045460ff16156103745760405162461bcd60e51b81526004016102a490613d81565b6102c3610aa86102be858585610844565b60045460ff16156103a85760405162461bcd60e51b81526004016102a490613d81565b6103ba610dfa6102be868686866113eb565b50505050565b6001546001600160a01b031633146103ea5760405162461bcd60e51b81526004016102a490613ddf565b612710811061043b5760405162461bcd60e51b815260206004820152601960248201527f52654e46543a3a6665652065786365656473203130307063740000000000000060448201526064016102a4565b600555565b60045460ff16156104635760405162461bcd60e51b81526004016102a490613d81565b6104786115396102be89898989898989611a56565b50505050505050565b60045460ff16156104a45760405162461bcd60e51b81526004016102a490613d81565b6102c3611b246102be858585610844565b805160208201516000916104c891614009565b6001600160401b038111156104df576104df6140a9565b604051908082528060200260200182016040528015610508578160200160208202803683370190505b5082519091505b826020015181101561080857600060066000856040015186600001518151811061053b5761053b614093565b60200260200101518660600151858151811061055957610559614093565b6020026020010151876101000151868151811061057857610578614093565b602002602001015160405160200161059293929190613c15565b60408051601f198184030181529181528151602092830120835282820193909352908201600020825160c08101845281546001600160a01b038116825260ff600160a01b82048116948301949094526001600160e01b0319600160a81b820460e090811b821696840196909652600160c81b820490951b9094166060820152600160e81b840483166080820152909350610662929091849160a0840191600160f01b9091041660068111156106495761064961407d565b600681111561065a5761065a61407d565b905250611e0a565b6040805160608101825260018301546001600160a01b0381168252600160a01b810460ff166020830152600160a81b900463ffffffff16918101919091526106a990611eb6565b6040805160c08101825282546001600160a01b038116825260ff600160a01b8204811660208401526001600160e01b0319600160a81b830460e090811b821695850195909552600160c81b830490941b9093166060830152600160e81b81048316608083015261074e92849160a0840191600160f01b9091041660068111156107345761073461407d565b60068111156107455761074561407d565b90525033611f69565b80548451600160e81b90910460ff1690849061076a9085614009565b8151811061077a5761077a614093565b602002602001018181525050836101000151828151811061079d5761079d614093565b60200260200101517f61bcecd87c002ae006d9d8c760291b4f3646fa6109590b4b3ea93084aae4bb6a426040516107e0919063ffffffff91909116815260200190565b60405180910390a280546001600160f81b0319169055806108008161404c565b91505061050f565b506108408230336108288660600151876000015188602001516000611fc2565b8651602088015161083b91889181611fc2565b612081565b5050565b61084c613448565b604051806101600160405280600081526020016001815260200185815260200184815260200160006001600160401b0381111561088b5761088b6140a9565b6040519080825280602002602001820160405280156108b4578160200160208202803683370190505b50815260200160006040519080825280602002602001820160405280156108e5578160200160208202803683370190505b5081526020016000604051908082528060200260200182016040528015610916578160200160208202803683370190505b5081526020016000604051908082528060200260200182016040528015610947578160200160208202803683370190505b50815260208082019490945260408051600080825281870183528284019190915281519081529485019052606001929092525092915050565b6000816040015151116109c65760405162461bcd60e51b815260206004820152600e60248201526d52654e46543a3a6e6f206e66747360901b60448201526064016102a4565b806040015151816020015114610a9b5780604001518160200151815181106109f0576109f0614093565b60200260200101516001600160a01b03168160400151826000015181518110610a1b57610a1b614093565b60200260200101516001600160a01b0316148015610a5e5750610a5e8160400151826020015181518110610a5157610a51614093565b6020026020010151612225565b15610a7b5760208101805190610a738261404c565b9052506109c6565b610a88818363ffffffff16565b60208101805180835290610a738261404c565b610840818363ffffffff16565b80515b8160200151811015610840576000600660008460400151856000015181518110610ad757610ad7614093565b602002602001015185606001518581518110610af557610af5614093565b60200260200101518661010001518681518110610b1457610b14614093565b6020026020010151604051602001610b2e93929190613c15565b60408051601f198184030181529181528151602092830120835282820193909352908201600020825160c08101845281546001600160a01b038116825260ff600160a01b82048116948301949094526001600160e01b0319600160a81b820460e090811b821696840196909652600160c81b820490951b9094166060820152600160e81b840483166080820152909350610be5929091849160a0840191600160f01b9091041660068111156106495761064961407d565b6040805160608101825260018301546001600160a01b0381168252600160a01b810460ff166020830152600160a81b900463ffffffff1691810191909152610c2c906122a7565b6040805160608101825260018301546001600160a01b0381168252600160a01b810460ff166020830152600160a81b900463ffffffff1691810191909152610c74904261232d565b604080516101008101825282546001600160a01b03811692820192835260ff600160a01b8204811660608401526001600160e01b0319600160a81b830460e090811b82166080860152600160c81b8404811b90911660a0850152600160e81b8304821660c0850152610d6794869385939192859290850191600160f01b9004166006811115610d0557610d0561407d565b6006811115610d1657610d1661407d565b905250815260408051606081018252600193909301546001600160a01b0381168452600160a01b810460ff16602080860191909152600160a81b90910463ffffffff16918401919091520152612383565b8261010001518281518110610d7e57610d7e614093565b60200260200101517f8ac1440f996b8b13e31275705c447bd09a92005cf2ec131a8183afedc636f5a242604051610dc1919063ffffffff91909116815260200190565b60405180910390a280546001600160f81b031916815560010180546001600160c81b031916905580610df28161404c565b915050610aab565b80516020820151600091610e0d91614009565b6001600160401b03811115610e2457610e246140a9565b604051908082528060200260200182016040528015610e4d578160200160208202803683370190505b5082519091505b8260200151811015610808576000600660008560400151866000015181518110610e8057610e80614093565b602002602001015186606001518581518110610e9e57610e9e614093565b60200260200101518761010001518681518110610ebd57610ebd614093565b6020026020010151604051602001610ed793929190613c15565b60408051601f198184030181529181528151602092830120835282820193909352908201600020825160c08101845281546001600160a01b038116825260ff600160a01b82048116948301949094526001600160e01b0319600160a81b820460e090811b821696840196909652600160c81b820490951b9094166060820152600160e81b840483166080820152909350610f8e929091849160a0840191600160f01b9091041660068111156106495761064961407d565b6040805160608101825260018301546001600160a01b0381168252600160a01b810460ff166020830152600160a81b900463ffffffff1691810191909152610fd590611eb6565b6040805160c08101825282546001600160a01b038116825260ff600160a01b8204811660208401526001600160e01b0319600160a81b830460e090811b821695850195909552600160c81b830490941b9093166060830152600160e81b81048316608083015261107c92849160a0840191600160f01b9091041660068111156110605761106061407d565b60068111156110715761107161407d565b9052508584336125c4565b8054600090600160f01b900460ff16600681111561109c5761109c61407d565b90506110a78161272f565b6000805460405163c6ee427f60e01b815260ff841660048201526001600160a01b039091169063c6ee427f9060240160206040518083038186803b1580156110ee57600080fd5b505afa158015611102573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111269190613754565b90506000816001600160a01b031663313ce5676040518163ffffffff1660e01b815260040160206040518083038186803b15801561116357600080fd5b505afa158015611177573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061119b9190613bbd565b60ff16905060006111ad82600a613f42565b85549091506000906111c990600160a81b900460e01b83612782565b89610120015188815181106111e0576111e0614093565b602002602001015160ff166111f59190613fea565b865490915060009061121190600160c81b900460e01b84612782565b87546112279190600160e81b900460ff16613fea565b9050600082116112495760405162461bcd60e51b81526004016102a490613d20565b600081116112695760405162461bcd60e51b81526004016102a490613da8565b61128a33306112788486613ec5565b6001600160a01b038916929190612811565b505084548851600160e81b90910460ff16915087906112a99088614009565b815181106112b9576112b9614093565b60209081029190910101526001840180546001600160a01b031916331790556101208701518051869081106112f0576112f0614093565b602090810291909101015160018501805464ffffffffff60a01b1916600160a01b60ff9093169290920263ffffffff60a81b191691909117600160a81b4263ffffffff1602179055610100870151805133917f3140d73adcc923e4a0de3b1522aeec546a872bcdc06a3e25fe1209df30b954ec918890811061137457611374614093565b6020026020010151896101200151888151811061139357611393614093565b60209081029190910181015160018901546040805194855260ff90921692840192909252600160a81b90910463ffffffff169082015260600160405180910390a25050505080806113e39061404c565b915050610e54565b6113f3613448565b604051806101600160405280600081526020016001815260200186815260200185815260200160006001600160401b03811115611432576114326140a9565b60405190808252806020026020018201604052801561145b578160200160208202803683370190505b508152602001600060405190808252806020026020018201604052801561148c578160200160208202803683370190505b50815260200160006040519080825280602002602001820160405280156114bd578160200160208202803683370190505b50815260200160006040519080825280602002602001820160405280156114ee578160200160208202803683370190505b5081526020810185905260408101849052606001600060405190808252806020026020018201604052801561152d578160200160208202803683370190505b50905295945050505050565b80515b8160200151811015611a1a57611552828261287c565b600060066000846040015185600001518151811061157257611572614093565b60200260200101518560600151858151811061159057611590614093565b60200260200101516003546040516020016115ad93929190613c15565b60408051601f198184030181529181528151602092830120835282820193909352908201600020825160c08101845281546001600160a01b038116825260ff600160a01b82048116948301949094526001600160e01b0319600160a81b820460e090811b821696840196909652600160c81b820490951b9094166060820152600160e81b84048316608082015290935061167d929091849160a0840191600160f01b9091041660068111156116645761166461407d565b60068111156116755761167561407d565b905250612a38565b6040805160608101825260018301546001600160a01b0381168252600160a01b810460ff166020830152600160a81b900463ffffffff16918101919091526116c490611eb6565b60006116ec846040015184815181106116df576116df614093565b6020026020010151612b4b565b90506040518060c00160405280336001600160a01b031681526020018560a00151858151811061171e5761171e614093565b602002602001015160ff1681526020018560c00151858151811061174457611744614093565b60200260200101516001600160e01b03191681526020018560e00151858151811061177157611771614093565b60200260200101516001600160e01b0319168152602001826117b057856080015185815181106117a3576117a3614093565b60200260200101516117b3565b60015b60ff16815260200185610140015185815181106117d2576117d2614093565b602002602001015160068111156117eb576117eb61407d565b90528051835460208301516040840151606085015160808601516001600160a01b039095166001600160a81b031990941693909317600160a01b60ff938416021767ffffffffffffffff60a81b1916600160a81b60e092831c0263ffffffff60c81b191617600160c81b9390911c929092029190911760ff60e81b198116600160e81b9290931691909102918217855560a083015185929091839161ffff60e81b1990911660ff60f01b1990911617600160f01b8360068111156118b1576118b161407d565b0217905550905050336001600160a01b0316846060015184815181106118d9576118d9614093565b602002602001015185604001518660000151815181106118fb576118fb614093565b60200260200101516001600160a01b03167fc1b2f77226541f6b308379a3110d77af45464d9a161a6eb4b6cfdcd0fb2089c684611955578760800151878151811061194857611948614093565b6020026020010151611958565b60015b6003548960a00151898151811061197157611971614093565b60200260200101518a60c001518a8151811061198f5761198f614093565b60200260200101518b60e001518b815181106119ad576119ad614093565b6020026020010151898d61014001518d815181106119cd576119cd614093565b60200260200101516040516119e89796959493929190613e09565b60405180910390a460038054906000611a008361404c565b919050555050508080611a129061404c565b91505061153c565b50611a53813330611a3a8560600151866000015187602001516000611fc2565b61083b8660800151876000015188602001516000611fc2565b50565b611a5e613448565b604051806101600160405280600081526020016001815260200189815260200188815260200187815260200186815260200185815260200184815260200160006001600160401b03811115611ab557611ab56140a9565b604051908082528060200260200182016040528015611ade578160200160208202803683370190505b5081526020016000604051908082528060200260200182016040528015611b0f578160200160208202803683370190505b50815260200192909252509695505050505050565b80516020820151600091611b3791614009565b6001600160401b03811115611b4e57611b4e6140a9565b604051908082528060200260200182016040528015611b77578160200160208202803683370190505b5082519091505b8260200151811015611dea576000600660008560400151866000015181518110611baa57611baa614093565b602002602001015186606001518581518110611bc857611bc8614093565b60200260200101518761010001518681518110611be757611be7614093565b6020026020010151604051602001611c0193929190613c15565b60408051601f198184030181529181528151602092830120835282820193909352908201600020825160c08101845281546001600160a01b038116825260ff600160a01b82048116948301949094526001600160e01b0319600160a81b820460e090811b821696840196909652600160c81b820490951b9094166060820152600160e81b840483166080820152909350611cb8929091849160a0840191600160f01b9091041660068111156106495761064961407d565b6040805160608101825260018301546001600160a01b0381168252600160a01b810460ff166020830152600160a81b900463ffffffff1691810191909152611d01903342612b81565b6001810154600090611d2090600160a81b900463ffffffff1642614009565b9050611d2c8282612c31565b81548551600160e81b90910460ff16908590611d489086614009565b81518110611d5857611d58614093565b6020026020010181815250508461010001518381518110611d7b57611d7b614093565b60200260200101517f289da9cb3ecd362ad5ae230d4daa346e68abbd8972cd9c01df54b7b1b97ab15b42604051611dbe919063ffffffff91909116815260200190565b60405180910390a25060010180546001600160c81b031916905580611de28161404c565b915050611b7e565b506108408233306108288660600151876000015188602001516000611fc2565b8051611e1590612f27565b602081015160ff16611e605760405162461bcd60e51b815260206004820152601460248201527352654e46543a3a6475726174696f6e207a65726f60601b60448201526064016102a4565b60408101516001600160e01b031916611e8b5760405162461bcd60e51b81526004016102a490613d20565b60608101516001600160e01b031916611a535760405162461bcd60e51b81526004016102a490613da8565b8051611ec190612f73565b602081015160ff1615611f115760405162461bcd60e51b815260206004820152601860248201527752654e46543a3a6475726174696f6e206e6f74207a65726f60401b60448201526064016102a4565b604081015163ffffffff1615611a535760405162461bcd60e51b815260206004820152601960248201527f52654e46543a3a72656e746564206174206e6f74207a65726f0000000000000060448201526064016102a4565b806001600160a01b031682600001516001600160a01b0316146108405760405162461bcd60e51b81526020600482015260116024820152702932a7232a1d1d3737ba103632b73232b960791b60448201526064016102a4565b6060611fce8484614009565b6001600160401b03811115611fe557611fe56140a9565b60405190808252806020026020018201604052801561200e578160200160208202803683370190505b509050835b8381101561207857856120268483614009565b8151811061203657612036614093565b602002602001015182868361204b9190614009565b8151811061205b5761205b614093565b6020908102919091010152806120708161404c565b915050612013565b50949350505050565b61209e85604001518660000151815181106116df576116df614093565b156121645760408501518551815181106120ba576120ba614093565b60200260200101516001600160a01b03166323b872dd858588606001518960000151815181106120ec576120ec614093565b60209081029190910101516040516001600160e01b031960e086901b1681526001600160a01b03938416600482015292909116602483015260448201526064015b600060405180830381600087803b15801561214757600080fd5b505af115801561215b573d6000803e3d6000fd5b5050505061221e565b6121818560400151866000015181518110610a5157610a51614093565b156121d657604085015185518151811061219d5761219d614093565b60200260200101516001600160a01b0316632eb2c2d6858585856040518563ffffffff1660e01b815260040161212d9493929190613c5b565b60405162461bcd60e51b815260206004820152601d60248201527f52654e46543a3a756e737570706f7274656420746f6b656e207479706500000060448201526064016102a4565b5050505050565b6040516301ffc9a760e01b8152636cdb3d1360e11b60048201526000906001600160a01b038316906301ffc9a7906024015b60206040518083038186803b15801561226f57600080fd5b505afa158015612283573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061027b9190613b6c565b80516122b290612f27565b602081015160ff166122d65760405162461bcd60e51b81526004016102a490613ce9565b604081015163ffffffff16611a535760405162461bcd60e51b815260206004820152601860248201527f52654e46543a3a72656e746564206174206973207a65726f000000000000000060448201526064016102a4565b6123378282612fca565b6108405760405162461bcd60e51b815260206004820152601d60248201527f52654e46543a3a72657475726e2064617465206e6f742070617373656400000060448201526064016102a4565b805160a00151600090600681111561239d5761239d61407d565b90506123a88161272f565b6000805460405163c6ee427f60e01b815260ff841660048201526001600160a01b039091169063c6ee427f9060240160206040518083038186803b1580156123ef57600080fd5b505afa158015612403573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906124279190613754565b90506000816001600160a01b031663313ce5676040518163ffffffff1660e01b815260040160206040518083038186803b15801561246457600080fd5b505afa158015612478573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061249c9190613bbd565b60ff16905060006124ae82600a613f42565b905060006124c486600001516060015183612782565b8651608001516124d7919060ff16613fea565b905060006124ed87600001516040015184612782565b9050600087602001516020015160ff16826125089190613fea565b9050600061252a828960ff1660068111156125255761252561407d565b613058565b905060006125388584613ec5565b9050600083116125965760405162461bcd60e51b815260206004820152602360248201527f52654e46543a3a636f6c6c61746572616c20706c75732072656e74206973207a60448201526265726f60e81b60648201526084016102a4565b8951516125b8906125a78484614009565b6001600160a01b038b16919061313b565b50505050505050505050565b83516001600160a01b03828116911614156126215760405162461bcd60e51b815260206004820152601860248201527f52654e46543a3a63616e742072656e74206f776e206e6674000000000000000060448201526064016102a4565b60ff8016836101200151838151811061263c5761263c614093565b602002602001015160ff1611156126655760405162461bcd60e51b81526004016102a490613d57565b6000836101200151838151811061267e5761267e614093565b602002602001015160ff16116126a65760405162461bcd60e51b81526004016102a490613ce9565b836020015160ff1683610120015183815181106126c5576126c5614093565b602002602001015160ff1611156103ba5760405162461bcd60e51b815260206004820152602860248201527f52654e46543a3a72656e74206475726174696f6e206578636565647320616c6c6044820152670deeecac840dac2f60c31b60648201526084016102a4565b60008160ff1611611a535760405162461bcd60e51b815260206004820152601860248201527f52654e46543a3a746f6b656e2069732073656e74696e656c000000000000000060448201526064016102a4565b600061278e838361316b565b60f083901c61ffff60e085901c1660006127aa61271086613edd565b905061270f8361ffff1611156127c05761270f92505b61270f8261ffff1611156127d45761270f91505b60006127e48661ffff8616613fea565b905060006127f68361ffff8616613fea565b905060006128048284613ec5565b9998505050505050505050565b6040516001600160a01b03808516602483015283166044820152606481018290526103ba9085906323b872dd60e01b906084015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b0319909316929092179091526131fc565b60008260800151828151811061289457612894614093565b6020026020010151116128e95760405162461bcd60e51b815260206004820152601a60248201527f52654e46543a3a6c656e6420616d6f756e74206973207a65726f00000000000060448201526064016102a4565b60ff80168260800151828151811061290357612903614093565b602002602001015111156129295760405162461bcd60e51b81526004016102a490613d57565b60008260a00151828151811061294157612941614093565b602002602001015160ff16116129695760405162461bcd60e51b81526004016102a490613ce9565b60ff80168260a00151828151811061298357612983614093565b602002602001015160ff1611156129ac5760405162461bcd60e51b81526004016102a490613d57565b60008260c0015182815181106129c4576129c4614093565b602002602001015160e01c63ffffffff16116129f25760405162461bcd60e51b81526004016102a490613d20565b60008260e001518281518110612a0a57612a0a614093565b602002602001015160e01c63ffffffff16116108405760405162461bcd60e51b81526004016102a490613da8565b8051612a4390612f73565b602081015160ff1615612a935760405162461bcd60e51b815260206004820152601860248201527752654e46543a3a6475726174696f6e206e6f74207a65726f60401b60448201526064016102a4565b60408101516001600160e01b03191615612aef5760405162461bcd60e51b815260206004820152601a60248201527f52654e46543a3a72656e74207072696365206e6f74207a65726f00000000000060448201526064016102a4565b60608101516001600160e01b03191615611a535760405162461bcd60e51b815260206004820152601960248201527f52654e46543a3a6e6674207072696365206e6f74207a65726f0000000000000060448201526064016102a4565b6040516301ffc9a760e01b81526380ac58cd60e01b60048201526000906001600160a01b038316906301ffc9a790602401612257565b816001600160a01b031683600001516001600160a01b031614612bda5760405162461bcd60e51b81526020600482015260116024820152702932a7232a1d1d3737ba103932b73a32b960791b60448201526064016102a4565b612be48382612fca565b156102c35760405162461bcd60e51b815260206004820152601760248201527f52654e46543a3a706173742072657475726e206461746500000000000000000060448201526064016102a4565b8154600090600160f01b900460ff166006811115612c5157612c5161407d565b9050612c5c8161272f565b6000805460405163c6ee427f60e01b815260ff841660048201526001600160a01b039091169063c6ee427f9060240160206040518083038186803b158015612ca357600080fd5b505afa158015612cb7573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612cdb9190613754565b90506000816001600160a01b031663313ce5676040518163ffffffff1660e01b815260040160206040518083038186803b158015612d1857600080fd5b505afa158015612d2c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612d509190613bbd565b60ff1690506000612d6282600a613f42565b8654909150600090612d7e90600160c81b900460e01b83612782565b8754612d949190600160e81b900460ff16613fea565b8754909150600090612db090600160a81b900460e01b84612782565b6001890154909150600090612dcf90600160a01b900460ff1683613fea565b9050600062015180612de1848b613fea565b612deb9190613edd565b905060008211612e505760405162461bcd60e51b815260206004820152602a60248201527f52654e46543a3a746f74616c207061796d656e7420776f20636f6c6c61746572604482015269616c206973207a65726f60b01b60648201526084016102a4565b60008111612ea05760405162461bcd60e51b815260206004820152601d60248201527f52654e46543a3a6c656e646572207061796d656e74206973207a65726f00000060448201526064016102a4565b6000612eac8284614009565b8b54909150600090612ec9908490600160f01b900460ff16613058565b9050612ed58184614009565b9250612ee18683613ec5565b8c54909250612efd906001600160a01b038b811691168561313b565b60018c0154612f19906001600160a01b038b811691168461313b565b505050505050505050505050565b6001600160a01b038116611a535760405162461bcd60e51b815260206004820152601360248201527252654e46543a3a7a65726f206164647265737360681b60448201526064016102a4565b6001600160a01b03811615611a535760405162461bcd60e51b815260206004820152601960248201527f52654e46543a3a6e6f742061207a65726f20616464726573730000000000000060448201526064016102a4565b6000826040015163ffffffff1682116130255760405162461bcd60e51b815260206004820152601860248201527f52654e46543a3a6e6f77206265666f72652072656e746564000000000000000060448201526064016102a4565b62015180836020015160ff1661303b9190613fea565b60408401516130509063ffffffff1684614009565b119392505050565b6000600554836130689190613fea565b905061307661271082613edd565b9050600082600681111561308c5761308c61407d565b90506130978161272f565b6000805460405163c6ee427f60e01b815260ff841660048201526001600160a01b039091169063c6ee427f9060240160206040518083038186803b1580156130de57600080fd5b505afa1580156130f2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906131169190613754565b600254909150613133906001600160a01b0380841691168561313b565b505092915050565b6040516001600160a01b0383166024820152604481018290526102c390849063a9059cbb60e01b90606401612845565b60e082901c6131b35760405162461bcd60e51b815260206004820152601460248201527352654e46543a3a696e76616c696420707269636560601b60448201526064016102a4565b6127108110156108405760405162461bcd60e51b815260206004820152601460248201527352654e46543a3a696e76616c6964207363616c6560601b60448201526064016102a4565b6000613251826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166132ce9092919063ffffffff16565b8051909150156102c3578080602001905181019061326f9190613b6c565b6102c35760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b60648201526084016102a4565b60606132dd84846000856132e7565b90505b9392505050565b6060824710156133485760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b60648201526084016102a4565b843b6133965760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016102a4565b600080866001600160a01b031685876040516133b29190613c3f565b60006040518083038185875af1925050503d80600081146133ef576040519150601f19603f3d011682016040523d82523d6000602084013e6133f4565b606091505b509150915061340482828661340f565b979650505050505050565b6060831561341e5750816132e0565b82511561342e5782518084602001fd5b8160405162461bcd60e51b81526004016102a49190613cb6565b60405180610160016040528060008152602001600081526020016060815260200160608152602001606081526020016060815260200160608152602001606081526020016060815260200160608152602001606081525090565b600082601f8301126134b357600080fd5b813560206134c86134c383613ea2565b613e72565b80838252828201915082860187848660051b89010111156134e857600080fd5b60005b858110156135105781356134fe816140bf565b845292840192908401906001016134eb565b5090979650505050505050565b600082601f83011261352e57600080fd5b8135602061353e6134c383613ea2565b80838252828201915082860187848660051b890101111561355e57600080fd5b60005b8581101561351057613572826136c8565b84529284019290840190600101613561565b600082601f83011261359557600080fd5b813560206135a56134c383613ea2565b80838252828201915082860187848660051b89010111156135c557600080fd5b6000805b868110156135f1578235600781106135df578283fd5b855293850193918501916001016135c9565b509198975050505050505050565b600082601f83011261361057600080fd5b813560206136206134c383613ea2565b80838252828201915082860187848660051b890101111561364057600080fd5b60005b8581101561351057813584529284019290840190600101613643565b600082601f83011261367057600080fd5b813560206136806134c383613ea2565b80838252828201915082860187848660051b89010111156136a057600080fd5b60005b858110156135105781356136b6816140e2565b845292840192908401906001016136a3565b80356001600160e01b0319811681146136e057600080fd5b919050565b600082601f8301126136f657600080fd5b81356001600160401b0381111561370f5761370f6140a9565b613722601f8201601f1916602001613e72565b81815284602083860101111561373757600080fd5b816020850160208301376000918101602001919091529392505050565b60006020828403121561376657600080fd5b81516132e0816140bf565b60006020828403121561378357600080fd5b81356132e0816140bf565b600080600080600060a086880312156137a657600080fd5b85356137b1816140bf565b945060208601356137c1816140bf565b935060408601356001600160401b03808211156137dd57600080fd5b6137e989838a016135ff565b945060608801359150808211156137ff57600080fd5b61380b89838a016135ff565b9350608088013591508082111561382157600080fd5b5061382e888289016136e5565b9150509295509295909350565b6000806000806080858703121561385157600080fd5b843561385c816140bf565b9350602085013561386c816140bf565b92506040850135915060608501356001600160401b0381111561388e57600080fd5b61389a878288016136e5565b91505092959194509250565b600080600080600060a086880312156138be57600080fd5b85356138c9816140bf565b945060208601356138d9816140bf565b9350604086013592506060860135915060808601356001600160401b0381111561390257600080fd5b61382e888289016136e5565b60008060006060848603121561392357600080fd5b83356001600160401b038082111561393a57600080fd5b613946878388016134a2565b9450602086013591508082111561395c57600080fd5b613968878388016135ff565b9350604086013591508082111561397e57600080fd5b5061398b868287016135ff565b9150509250925092565b600080600080608085870312156139ab57600080fd5b84356001600160401b03808211156139c257600080fd5b6139ce888389016134a2565b955060208701359150808211156139e457600080fd5b6139f0888389016135ff565b94506040870135915080821115613a0657600080fd5b613a12888389016135ff565b93506060870135915080821115613a2857600080fd5b5061389a8782880161365f565b600080600080600080600060e0888a031215613a5057600080fd5b87356001600160401b0380821115613a6757600080fd5b613a738b838c016134a2565b985060208a0135915080821115613a8957600080fd5b613a958b838c016135ff565b975060408a0135915080821115613aab57600080fd5b613ab78b838c016135ff565b965060608a0135915080821115613acd57600080fd5b613ad98b838c0161365f565b955060808a0135915080821115613aef57600080fd5b613afb8b838c0161351d565b945060a08a0135915080821115613b1157600080fd5b613b1d8b838c0161351d565b935060c08a0135915080821115613b3357600080fd5b50613b408a828b01613584565b91505092959891949750929550565b600060208284031215613b6157600080fd5b81356132e0816140d4565b600060208284031215613b7e57600080fd5b81516132e0816140d4565b600060208284031215613b9b57600080fd5b6132e0826136c8565b600060208284031215613bb657600080fd5b5035919050565b600060208284031215613bcf57600080fd5b81516132e0816140e2565b600081518084526020808501945080840160005b83811015613c0a57815187529582019590820190600101613bee565b509495945050505050565b60609390931b6bffffffffffffffffffffffff191683526014830191909152603482015260540190565b60008251613c51818460208701614020565b9190910192915050565b6001600160a01b0385811682528416602082015260a060408201819052600090613c8790830185613bda565b8281036060840152613c998185613bda565b838103608090940193909352505060008152602001949350505050565b6020815260008251806020840152613cd5816040850160208701614020565b601f01601f19169190910160400192915050565b60208082526017908201527f52654e46543a3a6475726174696f6e206973207a65726f000000000000000000604082015260600190565b60208082526019908201527f52654e46543a3a72656e74207072696365206973207a65726f00000000000000604082015260600190565b60208082526010908201526f0a4ca9c8ca87474dcdee840ead2dce8760831b604082015260600190565b6020808252600d908201526c14995391950e8e9c185d5cd959609a1b604082015260600190565b60208082526018908201527f52654e46543a3a6e6674207072696365206973207a65726f0000000000000000604082015260600190565b60208082526010908201526f2932a7232a1d1d3737ba1030b236b4b760811b604082015260600190565b60ff888116825260208201889052861660408201526001600160e01b031985811660608301528416608082015282151560a082015260e0810160078310613e6057634e487b7160e01b600052602160045260246000fd5b8260c083015298975050505050505050565b604051601f8201601f191681016001600160401b0381118282101715613e9a57613e9a6140a9565b604052919050565b60006001600160401b03821115613ebb57613ebb6140a9565b5060051b60200190565b60008219821115613ed857613ed8614067565b500190565b600082613efa57634e487b7160e01b600052601260045260246000fd5b500490565b600181815b80851115613f3a578160001904821115613f2057613f20614067565b80851615613f2d57918102915b93841c9390800290613f04565b509250929050565b60006132e08383600082613f585750600161027b565b81613f655750600061027b565b8160018114613f7b5760028114613f8557613fa1565b600191505061027b565b60ff841115613f9657613f96614067565b50506001821b61027b565b5060208310610133831016604e8410600b8410161715613fc4575081810a61027b565b613fce8383613eff565b8060001904821115613fe257613fe2614067565b029392505050565b600081600019048311821515161561400457614004614067565b500290565b60008282101561401b5761401b614067565b500390565b60005b8381101561403b578181015183820152602001614023565b838111156103ba5750506000910152565b600060001982141561406057614060614067565b5060010190565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052602160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b0381168114611a5357600080fd5b8015158114611a5357600080fd5b60ff81168114611a5357600080fdfea2646970667358221220effd392b642f54fb8ed3a04acbf28ca9ae4d88a653d19cc780644a83150bcf5964736f6c63430008060033000000000000000000000000945e589a4715d1915e6fe14f08e4887bc401934100000000000000000000000028f11c3d76169361d22d8ae53551827ac03360b000000000000000000000000000000444e5a1a667663b0adfd853e8efa0470698

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

000000000000000000000000945e589a4715d1915e6fe14f08e4887bc401934100000000000000000000000028f11c3d76169361d22d8ae53551827ac03360b000000000000000000000000000000444e5a1a667663b0adfd853e8efa0470698

-----Decoded View---------------
Arg [0] : _resolver (address): 0x945E589A4715d1915e6FE14f08e4887Bc4019341
Arg [1] : _beneficiary (address): 0x28f11c3D76169361D22D8aE53551827Ac03360B0
Arg [2] : _admin (address): 0x00000444e5a1a667663b0ADfD853E8Efa0470698

-----Encoded View---------------
3 Constructor Arguments found :
Arg [0] : 000000000000000000000000945e589a4715d1915e6fe14f08e4887bc4019341
Arg [1] : 00000000000000000000000028f11c3d76169361d22d8ae53551827ac03360b0
Arg [2] : 00000000000000000000000000000444e5a1a667663b0adfd853e8efa0470698


Block Transaction Difficulty Gas Used Reward
Block Uncle Number Difficulty Gas Used Reward
Loading
Loading
Make sure to use the "Vote Down" button for any spammy posts, and the "Vote Up" for interesting conversations.

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.