Contract 0xee13c86ee4eb1ec3a05e2cc3ab70576f31666b3b 2

 
 
Txn Hash
Method
Block
From
To
Value [Txn Fee]
0x64ba75163f8919afd580f0c006edfcc31f308f67e93c723e0ee432afd4bda971Deposit Portfoli...436600402023-06-08 3:38:471 hr 33 mins ago0xcf02a27a739d1066e7aa06a5901e1eeb304a8b9e IN  0xee13c86ee4eb1ec3a05e2cc3ab70576f31666b3b0 MATIC0.154646831049 184.40610365
0xd67e1bc8273e4f3574a75b0ecbee71238d57845a1bdd46e6fe29a5cd5bce61d0Withdraw Portfol...436600022023-06-08 3:37:271 hr 35 mins ago0xcf02a27a739d1066e7aa06a5901e1eeb304a8b9e IN  0xee13c86ee4eb1ec3a05e2cc3ab70576f31666b3b0 MATIC0.180312239968 185.403227184
0x5226cdff996d7d87b536cacb744ee09903cedfc9ddffb942a0f57ff36f1dc833Create Portfolio436576512023-06-08 2:05:043 hrs 7 mins ago0xcf02a27a739d1066e7aa06a5901e1eeb304a8b9e IN  0xee13c86ee4eb1ec3a05e2cc3ab70576f31666b3b0 MATIC0.188823423648 179.186249587
0x227af55828cd87ffdf12372aa8b09cc4d2b23406237da0c59117fd166533a663Create Portfolio436576232023-06-08 2:03:563 hrs 8 mins ago0xcf02a27a739d1066e7aa06a5901e1eeb304a8b9e IN  0xee13c86ee4eb1ec3a05e2cc3ab70576f31666b3b0 MATIC0.226421022822 184.698243672
0x76448b131e46c770ff8e5f24887fa73d17931b9b370a3a37d001eeff8efc9d9aCreate Portfolio436569212023-06-08 1:37:203 hrs 35 mins ago0x7e877ec6b00f042bbe6a99043cd74f6dcf2fc3c0 IN  0xee13c86ee4eb1ec3a05e2cc3ab70576f31666b3b0 MATIC0.196146148696 182.760240408
0xab365e6ff9a9ed04fa6bbdabe22c5d52ec152a39ef3861c654feda81df4b8046Create Portfolio436544002023-06-07 23:59:375 hrs 13 mins ago0x89709fd8fa769b2bf9d5550b049c20e3a660fbcb IN  0xee13c86ee4eb1ec3a05e2cc3ab70576f31666b3b0 MATIC0.265838130852 179.224490536
0xcbacc071ff7da2fe8305d791e66e29d850ad4b57341b007a0e48bdfb8f97531cCreate Portfolio436508422023-06-07 21:46:497 hrs 25 mins ago0xfe7ebb62d7263ca6cf426c400c70b73f20e830a5 IN  0xee13c86ee4eb1ec3a05e2cc3ab70576f31666b3b0 MATIC0.216821921721 181.922004398
0x4f8253c6c09c73f47a50103c2fe68d77cca3027b0016437eba11b89e4c384420Create Portfolio436507622023-06-07 21:43:597 hrs 28 mins ago0x3f5650aa67fb5222f9dd586846d9e4a6cc37f595 IN  0xee13c86ee4eb1ec3a05e2cc3ab70576f31666b3b0 MATIC0.199556307637 191.034268902
0x3fa63e285233abf58bc76ecff36be4160638c90b2e2662f091dda4415bf79966Withdraw Portfol...436501182023-06-07 21:19:387 hrs 52 mins ago0xba89bd87b8c7d461668ca5771d87328d3d0c1e7b IN  0xee13c86ee4eb1ec3a05e2cc3ab70576f31666b3b0 MATIC0.072815418044 171.783094378
0xab40d5b5f9a68c8b55fb9887ae9c77ae6c7a75db1a38639f8d5df68011dcc350Create Portfolio436493932023-06-07 20:52:118 hrs 20 mins ago0x38b54ccbba99c9896cdd87c37001a561b194fac9 IN  0xee13c86ee4eb1ec3a05e2cc3ab70576f31666b3b0 MATIC0.236748586161 180.050776646
0xdb9d9e1f9107f5dfb96c41fa2ef6c0396138c58d7e0333b9beb63d2ea5ae3592Create Portfolio436476982023-06-07 19:48:499 hrs 23 mins ago0xba89bd87b8c7d461668ca5771d87328d3d0c1e7b IN  0xee13c86ee4eb1ec3a05e2cc3ab70576f31666b3b0 MATIC0.058599344346 179.912082634
0x43024096999512ce4afcaab8a6c67110eab641236ebef2ce77473e8d6bcff987Withdraw Portfol...436445122023-06-07 17:51:1211 hrs 21 mins ago0xdf098b48de8a7024d1b7c0f3f0b22994c3e0efe1 IN  0xee13c86ee4eb1ec3a05e2cc3ab70576f31666b3b0 MATIC0.224711936566 151.899512735
0x4ca4b3efe62618ddb5aecab158dda2f42f99cd048d84aabc631fd1b4d27ed7c9Withdraw Portfol...436444552023-06-07 17:49:1011 hrs 23 mins ago0xdf098b48de8a7024d1b7c0f3f0b22994c3e0efe1 IN  0xee13c86ee4eb1ec3a05e2cc3ab70576f31666b3b0 MATIC0.342036981104 155.139708661
0xaa94b335cc2d7149798fac753cc595834bcef0a736a7f332eb9aabb3092d33deCreate Portfolio436437662023-06-07 17:23:2411 hrs 49 mins ago0xda20c62cc3e1fca9222690dc93a680dfae756943 IN  0xee13c86ee4eb1ec3a05e2cc3ab70576f31666b3b0 MATIC0.194405532598 183.088123342
0x7a3b9b1ef865ca5d53b99a4958ee3d668671b2de753ec2aecd455cab74071cebCreate Portfolio436425712023-06-07 16:38:2012 hrs 34 mins ago0x472b842af05e0f00a73077ac6fcb33476223c842 IN  0xee13c86ee4eb1ec3a05e2cc3ab70576f31666b3b0 MATIC0.186934044404 185.618012694
0x77ccc0b1ea2ed2dd87c0e17ea893007dd3fadf1b0c3c42f8b45c9cb8ae45876bWithdraw Portfol...436410892023-06-07 15:45:5013 hrs 26 mins ago0xfe85cd9f77339895d2936adf9111fea05e771184 IN  0xee13c86ee4eb1ec3a05e2cc3ab70576f31666b3b0 MATIC0.181851488313 182.060858301
0x38364ca468aebca209f69f3cbafcb29adb277f4c7763af818346a4fb326a1c4bDeposit Portfoli...436395182023-06-07 14:49:5514 hrs 22 mins ago0xefda8d746308d7dd531f59a63f932256812e1d27 IN  0xee13c86ee4eb1ec3a05e2cc3ab70576f31666b3b0 MATIC0.096305172582 228.967117957
0x28fe6e12dd9f52c54e3cc9e53954992f54f94df060a8c328fc43032997f8e42aCreate Portfolio436394752023-06-07 14:48:2514 hrs 24 mins ago0x7579cc1e7cb18b41699de4b59d7d5f6891baa7a3 IN  0xee13c86ee4eb1ec3a05e2cc3ab70576f31666b3b0 MATIC0.217054467409 211.838164448
0x10415d55fbab96d5b7f05eae207ba0d66fb4b02758e2ed9119271c3bca1fbb23Create Portfolio436388422023-06-07 14:25:5914 hrs 46 mins ago0xa3debba147048bef1fb93d9945c8511610d9250f IN  0xee13c86ee4eb1ec3a05e2cc3ab70576f31666b3b0 MATIC0.347304474073 315.31455156
0xa953249428dc905b802f17910b0969fadaac74af7d4ed3ff4afe548b865bbaddDeposit Portfoli...436387882023-06-07 14:24:0514 hrs 48 mins ago0xbde6f2791e4bb1688ad4435e9434ef320d81d7d7 IN  0xee13c86ee4eb1ec3a05e2cc3ab70576f31666b3b0 MATIC0.203074756801 197.97897594
0xf14e3023b6c3e877425ad86e3a3613c7eaec63c7db2fa76bcd372cd9d7a04159Create Portfolio436387452023-06-07 14:22:3314 hrs 50 mins ago0xfe85cd9f77339895d2936adf9111fea05e771184 IN  0xee13c86ee4eb1ec3a05e2cc3ab70576f31666b3b0 MATIC0.263858097242 213.746683518
0x23a372056b6c2269882421387bceb62b64781d196e365d0a5f8fcf8edf6138bbCreate Portfolio436386732023-06-07 14:20:0114 hrs 52 mins ago0x5937c5d79a8ba7a504a703aa5588e46bd88a26f6 IN  0xee13c86ee4eb1ec3a05e2cc3ab70576f31666b3b0 MATIC0.215810704245 210.958036531
0xbd36b48783a473db29c5bd8ed5b7f414a353e58699c3a59a6c35f5ea4fddb4ebCreate Portfolio436385192023-06-07 14:14:3314 hrs 58 mins ago0x1a8834fd7612ec6ec3d527f78027574b9ddcfb1b IN  0xee13c86ee4eb1ec3a05e2cc3ab70576f31666b3b0 MATIC0.097057469284 185.557402291
0x655367a94e97d9530a95cfcba51027c51607447822820d5c1c97380586cb6d0bCreate Portfolio436383432023-06-07 14:08:1915 hrs 4 mins ago0xbde6f2791e4bb1688ad4435e9434ef320d81d7d7 IN  0xee13c86ee4eb1ec3a05e2cc3ab70576f31666b3b0 MATIC0.273285153575 222.752428627
0xac943f608e02e6fdedc576dc182bba51603276c8bc09899fdaa31a9f6a745e53Create Portfolio436381552023-06-07 14:01:0115 hrs 11 mins ago0xec0853df3175f5c7a67b2c3db4812361e503596c IN  0xee13c86ee4eb1ec3a05e2cc3ab70576f31666b3b0 MATIC0.265329110806 252.617884114
[ Download CSV Export 
Latest 25 internal transaction
Parent Txn Hash Block From To Value
0x5226cdff996d7d87b536cacb744ee09903cedfc9ddffb942a0f57ff36f1dc833436576512023-06-08 2:05:043 hrs 7 mins ago 0xee13c86ee4eb1ec3a05e2cc3ab70576f31666b3b  Contract Creation0 MATIC
0x227af55828cd87ffdf12372aa8b09cc4d2b23406237da0c59117fd166533a663436576232023-06-08 2:03:563 hrs 8 mins ago 0xee13c86ee4eb1ec3a05e2cc3ab70576f31666b3b  Contract Creation0 MATIC
0x76448b131e46c770ff8e5f24887fa73d17931b9b370a3a37d001eeff8efc9d9a436569212023-06-08 1:37:203 hrs 35 mins ago 0xee13c86ee4eb1ec3a05e2cc3ab70576f31666b3b  Contract Creation0 MATIC
0xab365e6ff9a9ed04fa6bbdabe22c5d52ec152a39ef3861c654feda81df4b8046436544002023-06-07 23:59:375 hrs 13 mins ago 0xee13c86ee4eb1ec3a05e2cc3ab70576f31666b3b  Contract Creation0 MATIC
0xcbacc071ff7da2fe8305d791e66e29d850ad4b57341b007a0e48bdfb8f97531c436508422023-06-07 21:46:497 hrs 25 mins ago 0xee13c86ee4eb1ec3a05e2cc3ab70576f31666b3b  Contract Creation0 MATIC
0x4f8253c6c09c73f47a50103c2fe68d77cca3027b0016437eba11b89e4c384420436507622023-06-07 21:43:597 hrs 28 mins ago 0xee13c86ee4eb1ec3a05e2cc3ab70576f31666b3b  Contract Creation0 MATIC
0xab40d5b5f9a68c8b55fb9887ae9c77ae6c7a75db1a38639f8d5df68011dcc350436493932023-06-07 20:52:118 hrs 20 mins ago 0xee13c86ee4eb1ec3a05e2cc3ab70576f31666b3b  Contract Creation0 MATIC
0xdb9d9e1f9107f5dfb96c41fa2ef6c0396138c58d7e0333b9beb63d2ea5ae3592436476982023-06-07 19:48:499 hrs 23 mins ago 0xee13c86ee4eb1ec3a05e2cc3ab70576f31666b3b  Contract Creation0 MATIC
0xaa94b335cc2d7149798fac753cc595834bcef0a736a7f332eb9aabb3092d33de436437662023-06-07 17:23:2411 hrs 49 mins ago 0xee13c86ee4eb1ec3a05e2cc3ab70576f31666b3b  Contract Creation0 MATIC
0x7a3b9b1ef865ca5d53b99a4958ee3d668671b2de753ec2aecd455cab74071ceb436425712023-06-07 16:38:2012 hrs 34 mins ago 0xee13c86ee4eb1ec3a05e2cc3ab70576f31666b3b  Contract Creation0 MATIC
0x28fe6e12dd9f52c54e3cc9e53954992f54f94df060a8c328fc43032997f8e42a436394752023-06-07 14:48:2514 hrs 24 mins ago 0xee13c86ee4eb1ec3a05e2cc3ab70576f31666b3b  Contract Creation0 MATIC
0x10415d55fbab96d5b7f05eae207ba0d66fb4b02758e2ed9119271c3bca1fbb23436388422023-06-07 14:25:5914 hrs 46 mins ago 0xee13c86ee4eb1ec3a05e2cc3ab70576f31666b3b  Contract Creation0 MATIC
0xf14e3023b6c3e877425ad86e3a3613c7eaec63c7db2fa76bcd372cd9d7a04159436387452023-06-07 14:22:3314 hrs 50 mins ago 0xee13c86ee4eb1ec3a05e2cc3ab70576f31666b3b  Contract Creation0 MATIC
0x23a372056b6c2269882421387bceb62b64781d196e365d0a5f8fcf8edf6138bb436386732023-06-07 14:20:0114 hrs 52 mins ago 0xee13c86ee4eb1ec3a05e2cc3ab70576f31666b3b  Contract Creation0 MATIC
0xbd36b48783a473db29c5bd8ed5b7f414a353e58699c3a59a6c35f5ea4fddb4eb436385192023-06-07 14:14:3314 hrs 58 mins ago 0xee13c86ee4eb1ec3a05e2cc3ab70576f31666b3b  Contract Creation0 MATIC
0x655367a94e97d9530a95cfcba51027c51607447822820d5c1c97380586cb6d0b436383432023-06-07 14:08:1915 hrs 4 mins ago 0xee13c86ee4eb1ec3a05e2cc3ab70576f31666b3b  Contract Creation0 MATIC
0xac943f608e02e6fdedc576dc182bba51603276c8bc09899fdaa31a9f6a745e53436381552023-06-07 14:01:0115 hrs 11 mins ago 0xee13c86ee4eb1ec3a05e2cc3ab70576f31666b3b  Contract Creation0 MATIC
0x382025c0f34a811223fb4619e1277dafd2b51e08b6c28f482c6def4082cf6521436204812023-06-07 3:14:521 day 1 hr ago 0xee13c86ee4eb1ec3a05e2cc3ab70576f31666b3b  Contract Creation0 MATIC
0x4f23ea026b1bf37687beb671980a903df0fed74b95e6c6982281545053218a8a436151072023-06-06 23:52:431 day 5 hrs ago 0xee13c86ee4eb1ec3a05e2cc3ab70576f31666b3b  Contract Creation0 MATIC
0xefe27c9e812da7e663c2f4db263957359417b6ebfe4da02dbb78c9e432f7d79a436083202023-06-06 19:45:461 day 9 hrs ago 0xee13c86ee4eb1ec3a05e2cc3ab70576f31666b3b  Contract Creation0 MATIC
0xe88381c234846602d57939c641a57cabcff7dd5006bba8cf6e6ae26e85810e73435724352023-06-05 21:48:382 days 7 hrs ago 0xee13c86ee4eb1ec3a05e2cc3ab70576f31666b3b  Contract Creation0 MATIC
0xd5b33fd648244f9da256995e1d8f646a30ef4d55dd79cad6933593749d2c3b52434926242023-06-03 20:01:174 days 9 hrs ago 0xee13c86ee4eb1ec3a05e2cc3ab70576f31666b3b  Contract Creation0 MATIC
0x4432a075ab120261e07329ee915ba41677ccd1d99721160cad3493caa3edc48e434565312023-06-02 19:53:575 days 9 hrs ago 0xee13c86ee4eb1ec3a05e2cc3ab70576f31666b3b  Contract Creation0 MATIC
0xf3454e168215d75e00a74a5ea45f17512aee7f1dee4180f839000465170fca03434549922023-06-02 18:24:315 days 10 hrs ago 0xee13c86ee4eb1ec3a05e2cc3ab70576f31666b3b  Contract Creation0 MATIC
0x1dabf4441fa2b0b6df386a7df29a7f8237280e33878b72f2e8909ca61e7402f7434502662023-06-02 15:00:545 days 14 hrs ago 0xee13c86ee4eb1ec3a05e2cc3ab70576f31666b3b  Contract Creation0 MATIC
[ Download CSV Export 
Loading
This contract may be a proxy contract. Click on More Options and select Is this a proxy? to confirm and enable the "Read as Proxy" & "Write as Proxy" tabs.

Contract Source Code Verified (Exact Match)

Contract Name:
DeFiBasket

Compiler Version
v0.8.6+commit.11564f7e

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion
File 1 of 18 : DeFiBasket.sol
// SPDX-License-Identifier: GPL-3.0-or-later

pragma solidity ^0.8.6;

import "./interfaces/IDeFiBasket.sol";
import "./Wallet.sol";
import "./libraries/DBDataTypes.sol";
import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/proxy/Clones.sol";

/**
 * @title DeFiBasket
 * @author DeFi Basket
 *
 * @notice Coordinates portfolio creation, deposits/withdrawals, and fee payments.
 *
 * @dev This contract has 3 main functions:
 *
 * 1. Mint and manage NFTs
 * 1.1 Track ownership of NFTs
 * 1.2 Track NFT and Wallet relationship
 * 2. Create and manage wallets
 * 2.1 Control deposits / withdrawals to wallets
 * 2.2 Control the permissions for delegate calls to bridges
 * 3. Collect fees for the DeFi Basket protocol
 */

contract DeFiBasket is IDeFiBasket, ERC721, Ownable {
    using SafeERC20 for IERC20;

    // Modifiers
    modifier onlyNFTOwner(uint256 nftId) {
        require(
            msg.sender == ownerOf(nftId),
            "DEFIBASKET: ONLY NFT OWNER CAN CALL THIS FUNCTION"
        );
        _;
    }

    modifier checkInputs(DBDataTypes.TokenData calldata inputs, uint256 ethAmount) {
        require(
            inputs.tokens.length == inputs.amounts.length,
            "DEFIBASKET: MISMATCH IN LENGTH BETWEEN TOKENS AND AMOUNTS"
        );
        for (uint16 i = 0; i < inputs.amounts.length; i++) {
            require(
                inputs.amounts[i] > 0,
                "DEFIBASKET WALLET: ERC20 TOKEN AMOUNTS NEED TO BE > 0"
            );
        }
        require(
            inputs.amounts.length > 0 || ethAmount > 0, // ERC20 Tokens or ETH is needed
            "DEFIBASKET: AN AMOUNT IN ETHER OR ERC20 TOKENS IS NEEDED"
        );
        _;
    }

    modifier checkBridgeCalls(address[] calldata bridgeAddresses, bytes[] calldata bridgeEncodedCalls) {
        require(
            bridgeAddresses.length == bridgeEncodedCalls.length,
            "DEFIBASKET: BRIDGE ENCODED CALLS AND ADDRESSES MUST HAVE THE SAME LENGTH"
        );
        _;
    }

    // NFT properties
    uint256 public tokenCounter = 0;
    mapping(uint256 => address) private _nftIdToWallet;
    string _nftImageURI = "https://www.defibasket.org/api/get-nft-metadata/";

    // Address of the implementation of the Wallet contract
    address immutable implementationWalletAddress;    

    // Constructor
    constructor() ERC721("DeFi Basket NFT", "BASKETNFT") Ownable() {
        // Deploy a Wallet implementation that will be used as template for clones
        implementationWalletAddress = address(new Wallet());
    }

    // External functions

    /**
     * @notice Returns wallet address of a given NFT Id.
     *
     * @dev Each NFT Id is associated to its own Wallet, which is a contract
     * that holds funds separately from other users' funds.
     *
     * @param nftId NFT Id
     */
    function walletOf(uint256 nftId) public view returns (address)  {
        return _nftIdToWallet[nftId];
    }

    /**
     * @notice Create a portfolio.
     *
     * @dev The first step to create a portfolio is composed of 3 steps:
     *
     * 1. Mint an NFT and Wallet for the corresponding NFT.
     * 2. Transfer resources (ETH and ERC20 tokens) to Wallet.
     * 3. Process bridge calls (interact with Uniswap/Aave...).
     *
     * @param inputs ERC20 token addresses and amounts that will enter the contract
     * @param bridgeAddresses Addresses of deployed bridge contracts
     * @param bridgeEncodedCalls Encoded calls to be passed on to delegate calls
     */
    function createPortfolio(
        DBDataTypes.TokenData calldata inputs,
        address[] calldata bridgeAddresses,
        bytes[] calldata bridgeEncodedCalls
    ) payable external
        checkInputs(inputs, msg.value)
        checkBridgeCalls(bridgeAddresses, bridgeEncodedCalls) override
    {
        uint256 nftId = _mintNFT(msg.sender);

        _depositToWallet(nftId, inputs, msg.value);
        _writeToWallet(nftId, bridgeAddresses, bridgeEncodedCalls);
    }

    /**
     * @notice Deposit more funds into an existing portfolio.
     *
     * @dev The deposit function is composed of 2 steps:
     *
     * 1. Transfer resources (ETH and ERC20 tokens) to Wallet.
     * 2. Process bridge calls (interact with Uniswap/Aave...).
     *
     * @param nftId NFT Id
     * @param inputs ERC20 token addresses and amounts that will enter the contract
     * @param bridgeAddresses Addresses of deployed bridge contracts
     * @param bridgeEncodedCalls Encoded calls to be passed on to delegate calls
     */
    function depositPortfolio(
        uint256 nftId,
        DBDataTypes.TokenData calldata inputs,
        address[] calldata bridgeAddresses,
        bytes[] calldata bridgeEncodedCalls
    ) payable external
        checkInputs(inputs, msg.value)
        checkBridgeCalls(bridgeAddresses, bridgeEncodedCalls)
        onlyNFTOwner(nftId) override
    {
        emit DEFIBASKET_DEPOSIT();

        _depositToWallet(nftId, inputs, msg.value);
        _writeToWallet(nftId, bridgeAddresses, bridgeEncodedCalls);
    }

    /**
     * @notice Edit positions of an existing portfolio. No deposits or withdrawals allowed.
     *
     * @dev This functions only processes bridge calls, no deposits or withdrawals on the wallet.
     *
     * @param nftId NFT Id
     * @param bridgeAddresses Addresses of deployed bridge contracts
     * @param bridgeEncodedCalls Encoded calls to be passed on to delegate calls
     */
    function editPortfolio(
        uint256 nftId,
        address[] calldata bridgeAddresses,
        bytes[] calldata bridgeEncodedCalls
    ) external
        checkBridgeCalls(bridgeAddresses, bridgeEncodedCalls)
        onlyNFTOwner(nftId) override
    {
        emit DEFIBASKET_EDIT();

        _writeToWallet(nftId, bridgeAddresses, bridgeEncodedCalls);
    }

    /**
    * @notice Deposit more funds into an existing portfolio.
    *
    * @dev The withdraw function is composed of 3 steps:
    *
    * 1. Process bridge calls (interact with Uniswap/Aave...).
    * 2. Transfer resources (ETH and ERC20 tokens) to NFT owner.
    *
    * @param nftId NFT Id
    * @param outputs ERC20 token addresses and percentages that will exit the contract
    * @param outputEthPercentage percentage of ETH in portfolio that will exit the contract
    * @param bridgeAddresses Addresses of deployed bridge contracts
    * @param bridgeEncodedCalls Encoded calls to be passed on to delegate calls
    */
    function withdrawPortfolio(
        uint256 nftId,
        DBDataTypes.TokenData calldata outputs,
        uint256 outputEthPercentage,
        address[] calldata bridgeAddresses,
        bytes[] calldata bridgeEncodedCalls
    ) external
        checkInputs(outputs, outputEthPercentage)
        checkBridgeCalls(bridgeAddresses, bridgeEncodedCalls)
        onlyNFTOwner(nftId) override
    {
        _writeToWallet(nftId, bridgeAddresses, bridgeEncodedCalls);
        _withdrawFromWallet(nftId, outputs, outputEthPercentage);
    }

    // Internal functions

    /**
     * @notice Mints an NFT given an NFT owner.
     *
     * @dev All NFTs inside this contract have a wallet linked to it. So, whenever an NFT is minted a new wallet is
     * created that will hold funds that corresponds to the portfolio owned by this NFT.
     *
     * @param nftOwner address of NFT owner
     */
    function _mintNFT(address nftOwner) internal returns (uint256){
        // Clone Wallet using implementation Wallet as template
        // See https://eips.ethereum.org/EIPS/eip-1167 for reference
        address walletAddress = Clones.clone(implementationWalletAddress);
        
        // Save NFT data
        uint256 nftId = tokenCounter;
        _nftIdToWallet[nftId] = walletAddress;
        tokenCounter = tokenCounter + 1;

        // Mint NFT
        _safeMint(nftOwner, nftId);

        emit DEFIBASKET_CREATE(nftId, walletAddress);

        return nftId;
    }

    /**
      * @notice Transfer deposited ETH and ERC20 tokens to the Wallet linked to the referenced NFT.
      *
      * @dev Transfer assets to the corresponding Wallet going through the following steps:
      * 1. Transfer deposited ETH into the DeFi Basket contract to the Wallet contract.
      * 2. Transfer approved ERC20 tokens from the user account to the Wallet contract.
      * 3. Charge 0.1% fee for DeFi Basket
      *
      * @param nftId NFT Id
      * @param inputs ERC20 token addresses and amounts that entered the contract and will go to Wallet
      * @param ethAmount ETH amount that entered the contract and will go to Wallet
      */
    function _depositToWallet(
        uint256 nftId,
        DBDataTypes.TokenData calldata inputs,
        uint256 ethAmount
    ) internal {
        // Pay 0.1% fee on ETH deposit to DeFi Basket
        address defibasketContractOwner = owner();
        uint256 defibasketFee = ethAmount / 1000;
        payable(defibasketContractOwner).call{value: defibasketFee}("");

        // Transfer 99.9% of ETH deposit to Wallet
        address walletAddress = walletOf(nftId);
        payable(walletAddress).call{value: ethAmount - defibasketFee}("");

        // For each ERC20: Charge 0.1% DeFi Basket fee and transfer tokens to Wallet
        for (uint16 i = 0; i < inputs.tokens.length; i++) {
            // Pay 0.1% fee on ERC20 deposit to DeFi Basket
            defibasketFee = inputs.amounts[i] / 1000;
            IERC20(inputs.tokens[i]).safeTransferFrom(ownerOf(nftId), defibasketContractOwner, defibasketFee);

            // Transfer 99.9% of ERC20 token to Wallet
            IERC20(inputs.tokens[i]).safeTransferFrom(ownerOf(nftId), walletAddress, inputs.amounts[i] - defibasketFee);
        }
    }

    /**
      * @notice This is how DeFi Basket communicates with other protocols.
      *
      * @dev This is where the magic happens. Bridges interact with delegate calls to enable DeFi Basket to interact with
      * a wide and expanding variety of protocols.
      *
      * @param nftId NFT Id
      * @param _bridgeAddresses Addresses of deployed bridges that will be called
      * @param _bridgeEncodedCalls Encoded calls to be passed on to delegate calls
      */
    function _writeToWallet(
        uint256 nftId,
        address[] calldata _bridgeAddresses,
        bytes[] calldata _bridgeEncodedCalls
    ) internal {
        address walletAddress = walletOf(nftId);
        Wallet wallet = Wallet(payable(walletAddress));
        wallet.useBridges(_bridgeAddresses, _bridgeEncodedCalls);
    }

    /**
      * @notice Transfer ETH and ERC20 tokens back to the owner of the corresponding NFT.
      *
      * @param nftId NFT Id
      * @param outputs ERC20 token addresses and percentages that will exit the Wallet and go to NFT owner
      * @param outputEthPercentage ETH percentage that will exit the Wallet and go to NFT owner
      */
    function _withdrawFromWallet(
        uint256 nftId,
        DBDataTypes.TokenData calldata outputs,
        uint256 outputEthPercentage
    ) internal {
        uint256[] memory outputAmounts;
        uint256 outputEth;

        Wallet wallet = Wallet(payable(walletOf(nftId)));
        (outputAmounts, outputEth) = wallet.withdraw(outputs, outputEthPercentage, ownerOf(nftId));

        emit DEFIBASKET_WITHDRAW(outputAmounts, outputEth);
    }

    // Art related
    /**
     * @dev Internal function to set the base URI for all token IDs. It is
     * automatically added as a prefix to the value returned in {tokenURI},
     * or to the token ID if {tokenURI} is empty.
     */
    function setBaseURI(string memory nftImageURI) external onlyOwner {
        _nftImageURI = nftImageURI;
    }

    /**
     * @notice Returns the base URI for the NFT metadata
     *
     * @dev The URI of a specific token will be the base URI concatenated with the token id, e.g. for token 0
     * the URI will be http://placeholder.com/0.
     */
    function _baseURI() internal view override returns (string memory) {
        return _nftImageURI;
    }    
}

File 2 of 18 : IDeFiBasket.sol
// SPDX-License-Identifier: GPL-3.0-or-later

pragma solidity ^0.8.6;
import "@openzeppelin/contracts/token/ERC721/IERC721.sol";
import "../libraries/DBDataTypes.sol";

interface IDeFiBasket is IERC721 {
    // Events
    event DEFIBASKET_CREATE(
        uint256 nftId,
        address wallet
    );

    event DEFIBASKET_DEPOSIT();

    event DEFIBASKET_EDIT();

    event DEFIBASKET_WITHDRAW(
        uint256[] outputAmounts,
        uint256 ethAmount
    );

    function createPortfolio(
        DBDataTypes.TokenData calldata inputs,
        address[] calldata _bridgeAddresses,
        bytes[] calldata _bridgeEncodedCalls
    ) payable external;

    function depositPortfolio(
        uint256 nftId,
        DBDataTypes.TokenData calldata inputs,
        address[] calldata _bridgeAddresses,
        bytes[] calldata _bridgeEncodedCalls
    ) payable external;

    function editPortfolio(
        uint256 nftId,
        address[] calldata _bridgeAddresses,
        bytes[] calldata _bridgeEncodedCalls
    ) external;

    function withdrawPortfolio(
        uint256 nftId,
        DBDataTypes.TokenData calldata outputs,
        uint256 outputEthPercentage,
        address[] calldata _bridgeAddresses,
        bytes[] calldata _bridgeEncodedCalls
    ) external;
}

File 3 of 18 : Wallet.sol
// SPDX-License-Identifier: GPL-3.0-or-later

pragma solidity ^0.8.6;

import "./interfaces/IWallet.sol";
import "./libraries/DBDataTypes.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";

/**
 * @title Wallet
 * @author DeFi Basket
 *
 * @notice Wallet holds assets for an NFT and interacts with bridges to integrate with other DeFi protocols.
 *
 * @dev Wallet holds the funds and is quite extensible as we decided to go with an architecture of delegate calls and
 * bridges, which are contracts that shape the interfaces we use to interact with other protocols.
 */

contract Wallet is IWallet {
    using SafeERC20 for IERC20;

    address immutable _defibasketAddress;

    // Wallet only talks with DeFi Basket contract
    modifier defibasketOnly() {
        require(
            _defibasketAddress == msg.sender,
            "WALLET: ONLY THE DEFIBASKET CONTRACT CAN CALL THIS FUNCTION"
        );
        _;
    }

    // This is needed for Wallet to receive funds from a contract
    event Received(address sender, uint256 amount);

    receive() external payable {
        emit Received(msg.sender, msg.value);
    }

    constructor() {
        _defibasketAddress = msg.sender;
    }

    /**
      * @notice This is how the Wallet interacts with DeFi protocols.
      *
      * @dev This gives the bridges control over the Wallet funds, so they can make all the transactions necessary to
      * build a portfolio. We need to ensure that all the bridges we support on the UI are as safe as they can be.
      * Example of bridges are QuickswapSwapBridge and AaveV2DepositBridge.
      *
      * @param bridgeAddresses Addresses of deployed bridge contracts
      * @param bridgeEncodedCalls Encoded calls to be passed on to delegate calls
      */
    function useBridges(
        address[] calldata bridgeAddresses,
        bytes[] calldata bridgeEncodedCalls
    ) external override defibasketOnly {
        bool isSuccess;
        bytes memory result;

        for (uint16 i = 0; i < bridgeAddresses.length; i++) {
            (isSuccess, result) = bridgeAddresses[i].delegatecall(bridgeEncodedCalls[i]);

            // Assembly code was the only way we found to display clean revert error messages from delegate calls
            if (!isSuccess) {
                assembly {
                    let ptr := mload(0x40)
                    let size := returndatasize()
                    returndatacopy(ptr, 0, size)
                    revert(ptr, size)
                }
            }
        }
    }

    /**
      * @notice Withdraws funds from wallet back to NFT owner.
      *
      * @dev Transfers requested percentages back to NFT owner.
      *
      * @param outputs ERC20 token addresses and percentages that will exit the Wallet and go to NFT owner
      * @param outputEthPercentage percentage of ETH that will exit the Wallet and go to NFT owner
      * @param nftOwner NFT owner address
      */
    function withdraw(
        DBDataTypes.TokenData calldata outputs,
        uint256 outputEthPercentage,
        address nftOwner
    ) external defibasketOnly override returns (uint256[] memory, uint256)
    {
        // Withdraws ERC20 tokens
        uint256[] memory outputTokenAmounts = new uint256[](outputs.tokens.length);
        for (uint16 i = 0; i < outputs.tokens.length; i++) {
            outputTokenAmounts[i] = IERC20(outputs.tokens[i]).balanceOf(address(this)) * outputs.amounts[i] / 100000;
            IERC20(outputs.tokens[i]).safeTransfer(nftOwner, outputTokenAmounts[i]);
        }

        // Withdraws ETH
        uint256 outputEthAmount = 0;
        if (outputEthPercentage > 0) {
            outputEthAmount = address(this).balance * outputEthPercentage / 100000;            
            payable(nftOwner).call{value: outputEthAmount}("");
        }

        return (outputTokenAmounts, outputEthAmount);
    }
}

File 4 of 18 : DBDataTypes.sol
// SPDX-License-Identifier: GPL-3.0-or-later

pragma solidity ^0.8.6;

library DBDataTypes {
    struct TokenData {
        address[] tokens;
        uint256[] amounts;
    }
}

File 5 of 18 : ERC721.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "./IERC721.sol";
import "./IERC721Receiver.sol";
import "./extensions/IERC721Metadata.sol";
import "../../utils/Address.sol";
import "../../utils/Context.sol";
import "../../utils/Strings.sol";
import "../../utils/introspection/ERC165.sol";

/**
 * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including
 * the Metadata extension, but not including the Enumerable extension, which is available separately as
 * {ERC721Enumerable}.
 */
contract ERC721 is Context, ERC165, IERC721, IERC721Metadata {
    using Address for address;
    using Strings for uint256;

    // Token name
    string private _name;

    // Token symbol
    string private _symbol;

    // Mapping from token ID to owner address
    mapping(uint256 => address) private _owners;

    // Mapping owner address to token count
    mapping(address => uint256) private _balances;

    // Mapping from token ID to approved address
    mapping(uint256 => address) private _tokenApprovals;

    // Mapping from owner to operator approvals
    mapping(address => mapping(address => bool)) private _operatorApprovals;

    /**
     * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection.
     */
    constructor(string memory name_, string memory symbol_) {
        _name = name_;
        _symbol = symbol_;
    }

    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {
        return
            interfaceId == type(IERC721).interfaceId ||
            interfaceId == type(IERC721Metadata).interfaceId ||
            super.supportsInterface(interfaceId);
    }

    /**
     * @dev See {IERC721-balanceOf}.
     */
    function balanceOf(address owner) public view virtual override returns (uint256) {
        require(owner != address(0), "ERC721: balance query for the zero address");
        return _balances[owner];
    }

    /**
     * @dev See {IERC721-ownerOf}.
     */
    function ownerOf(uint256 tokenId) public view virtual override returns (address) {
        address owner = _owners[tokenId];
        require(owner != address(0), "ERC721: owner query for nonexistent token");
        return owner;
    }

    /**
     * @dev See {IERC721Metadata-name}.
     */
    function name() public view virtual override returns (string memory) {
        return _name;
    }

    /**
     * @dev See {IERC721Metadata-symbol}.
     */
    function symbol() public view virtual override returns (string memory) {
        return _symbol;
    }

    /**
     * @dev See {IERC721Metadata-tokenURI}.
     */
    function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
        require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token");

        string memory baseURI = _baseURI();
        return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : "";
    }

    /**
     * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each
     * token will be the concatenation of the `baseURI` and the `tokenId`. Empty
     * by default, can be overriden in child contracts.
     */
    function _baseURI() internal view virtual returns (string memory) {
        return "";
    }

    /**
     * @dev See {IERC721-approve}.
     */
    function approve(address to, uint256 tokenId) public virtual override {
        address owner = ERC721.ownerOf(tokenId);
        require(to != owner, "ERC721: approval to current owner");

        require(
            _msgSender() == owner || isApprovedForAll(owner, _msgSender()),
            "ERC721: approve caller is not owner nor approved for all"
        );

        _approve(to, tokenId);
    }

    /**
     * @dev See {IERC721-getApproved}.
     */
    function getApproved(uint256 tokenId) public view virtual override returns (address) {
        require(_exists(tokenId), "ERC721: approved query for nonexistent token");

        return _tokenApprovals[tokenId];
    }

    /**
     * @dev See {IERC721-setApprovalForAll}.
     */
    function setApprovalForAll(address operator, bool approved) public virtual override {
        require(operator != _msgSender(), "ERC721: approve to caller");

        _operatorApprovals[_msgSender()][operator] = approved;
        emit ApprovalForAll(_msgSender(), operator, approved);
    }

    /**
     * @dev See {IERC721-isApprovedForAll}.
     */
    function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) {
        return _operatorApprovals[owner][operator];
    }

    /**
     * @dev See {IERC721-transferFrom}.
     */
    function transferFrom(
        address from,
        address to,
        uint256 tokenId
    ) public virtual override {
        //solhint-disable-next-line max-line-length
        require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved");

        _transfer(from, to, tokenId);
    }

    /**
     * @dev See {IERC721-safeTransferFrom}.
     */
    function safeTransferFrom(
        address from,
        address to,
        uint256 tokenId
    ) public virtual override {
        safeTransferFrom(from, to, tokenId, "");
    }

    /**
     * @dev See {IERC721-safeTransferFrom}.
     */
    function safeTransferFrom(
        address from,
        address to,
        uint256 tokenId,
        bytes memory _data
    ) public virtual override {
        require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved");
        _safeTransfer(from, to, tokenId, _data);
    }

    /**
     * @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.
     *
     * `_data` is additional data, it has no specified format and it is sent in call to `to`.
     *
     * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g.
     * implement alternative mechanisms to perform token transfer, such as signature-based.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must exist and be owned by `from`.
     * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
     *
     * Emits a {Transfer} event.
     */
    function _safeTransfer(
        address from,
        address to,
        uint256 tokenId,
        bytes memory _data
    ) internal virtual {
        _transfer(from, to, tokenId);
        require(_checkOnERC721Received(from, to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer");
    }

    /**
     * @dev Returns whether `tokenId` exists.
     *
     * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.
     *
     * Tokens start existing when they are minted (`_mint`),
     * and stop existing when they are burned (`_burn`).
     */
    function _exists(uint256 tokenId) internal view virtual returns (bool) {
        return _owners[tokenId] != address(0);
    }

    /**
     * @dev Returns whether `spender` is allowed to manage `tokenId`.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     */
    function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) {
        require(_exists(tokenId), "ERC721: operator query for nonexistent token");
        address owner = ERC721.ownerOf(tokenId);
        return (spender == owner || getApproved(tokenId) == spender || isApprovedForAll(owner, spender));
    }

    /**
     * @dev Safely mints `tokenId` and transfers it to `to`.
     *
     * Requirements:
     *
     * - `tokenId` must not exist.
     * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
     *
     * Emits a {Transfer} event.
     */
    function _safeMint(address to, uint256 tokenId) internal virtual {
        _safeMint(to, tokenId, "");
    }

    /**
     * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is
     * forwarded in {IERC721Receiver-onERC721Received} to contract recipients.
     */
    function _safeMint(
        address to,
        uint256 tokenId,
        bytes memory _data
    ) internal virtual {
        _mint(to, tokenId);
        require(
            _checkOnERC721Received(address(0), to, tokenId, _data),
            "ERC721: transfer to non ERC721Receiver implementer"
        );
    }

    /**
     * @dev Mints `tokenId` and transfers it to `to`.
     *
     * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible
     *
     * Requirements:
     *
     * - `tokenId` must not exist.
     * - `to` cannot be the zero address.
     *
     * Emits a {Transfer} event.
     */
    function _mint(address to, uint256 tokenId) internal virtual {
        require(to != address(0), "ERC721: mint to the zero address");
        require(!_exists(tokenId), "ERC721: token already minted");

        _beforeTokenTransfer(address(0), to, tokenId);

        _balances[to] += 1;
        _owners[tokenId] = to;

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

    /**
     * @dev Destroys `tokenId`.
     * The approval is cleared when the token is burned.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     *
     * Emits a {Transfer} event.
     */
    function _burn(uint256 tokenId) internal virtual {
        address owner = ERC721.ownerOf(tokenId);

        _beforeTokenTransfer(owner, address(0), tokenId);

        // Clear approvals
        _approve(address(0), tokenId);

        _balances[owner] -= 1;
        delete _owners[tokenId];

        emit Transfer(owner, address(0), tokenId);
    }

    /**
     * @dev Transfers `tokenId` from `from` to `to`.
     *  As opposed to {transferFrom}, this imposes no restrictions on msg.sender.
     *
     * Requirements:
     *
     * - `to` cannot be the zero address.
     * - `tokenId` token must be owned by `from`.
     *
     * Emits a {Transfer} event.
     */
    function _transfer(
        address from,
        address to,
        uint256 tokenId
    ) internal virtual {
        require(ERC721.ownerOf(tokenId) == from, "ERC721: transfer of token that is not own");
        require(to != address(0), "ERC721: transfer to the zero address");

        _beforeTokenTransfer(from, to, tokenId);

        // Clear approvals from the previous owner
        _approve(address(0), tokenId);

        _balances[from] -= 1;
        _balances[to] += 1;
        _owners[tokenId] = to;

        emit Transfer(from, to, tokenId);
    }

    /**
     * @dev Approve `to` to operate on `tokenId`
     *
     * Emits a {Approval} event.
     */
    function _approve(address to, uint256 tokenId) internal virtual {
        _tokenApprovals[tokenId] = to;
        emit Approval(ERC721.ownerOf(tokenId), to, tokenId);
    }

    /**
     * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address.
     * The call is not executed if the target address is not a contract.
     *
     * @param from address representing the previous owner of the given token ID
     * @param to target address that will receive the tokens
     * @param tokenId uint256 ID of the token to be transferred
     * @param _data bytes optional data to send along with the call
     * @return bool whether the call correctly returned the expected magic value
     */
    function _checkOnERC721Received(
        address from,
        address to,
        uint256 tokenId,
        bytes memory _data
    ) private returns (bool) {
        if (to.isContract()) {
            try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) {
                return retval == IERC721Receiver.onERC721Received.selector;
            } catch (bytes memory reason) {
                if (reason.length == 0) {
                    revert("ERC721: transfer to non ERC721Receiver implementer");
                } else {
                    assembly {
                        revert(add(32, reason), mload(reason))
                    }
                }
            }
        } else {
            return true;
        }
    }

    /**
     * @dev Hook that is called before any token transfer. This includes minting
     * and burning.
     *
     * Calling conditions:
     *
     * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be
     * transferred to `to`.
     * - When `from` is zero, `tokenId` will be minted for `to`.
     * - When `to` is zero, ``from``'s `tokenId` 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 tokenId
    ) internal virtual {}
}

File 6 of 18 : 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'
        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
            require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
        }
    }
}

File 7 of 18 : Ownable.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

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

/**
 * @dev Contract module which provides a basic access control mechanism, where
 * there is an account (an owner) that can be granted exclusive access to
 * specific functions.
 *
 * By default, the owner account will be the one that deploys the contract. This
 * can later be changed with {transferOwnership}.
 *
 * This module is used through inheritance. It will make available the modifier
 * `onlyOwner`, which can be applied to your functions to restrict their use to
 * the owner.
 */
abstract contract Ownable is Context {
    address private _owner;

    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);

    /**
     * @dev Initializes the contract setting the deployer as the initial owner.
     */
    constructor() {
        _setOwner(_msgSender());
    }

    /**
     * @dev Returns the address of the current owner.
     */
    function owner() public view virtual returns (address) {
        return _owner;
    }

    /**
     * @dev Throws if called by any account other than the owner.
     */
    modifier onlyOwner() {
        require(owner() == _msgSender(), "Ownable: caller is not the owner");
        _;
    }

    /**
     * @dev Leaves the contract without owner. It will not be possible to call
     * `onlyOwner` functions anymore. Can only be called by the current owner.
     *
     * NOTE: Renouncing ownership will leave the contract without an owner,
     * thereby removing any functionality that is only available to the owner.
     */
    function renounceOwnership() public virtual onlyOwner {
        _setOwner(address(0));
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Can only be called by the current owner.
     */
    function transferOwnership(address newOwner) public virtual onlyOwner {
        require(newOwner != address(0), "Ownable: new owner is the zero address");
        _setOwner(newOwner);
    }

    function _setOwner(address newOwner) private {
        address oldOwner = _owner;
        _owner = newOwner;
        emit OwnershipTransferred(oldOwner, newOwner);
    }
}

File 8 of 18 : Clones.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

/**
 * @dev https://eips.ethereum.org/EIPS/eip-1167[EIP 1167] is a standard for
 * deploying minimal proxy contracts, also known as "clones".
 *
 * > To simply and cheaply clone contract functionality in an immutable way, this standard specifies
 * > a minimal bytecode implementation that delegates all calls to a known, fixed address.
 *
 * The library includes functions to deploy a proxy using either `create` (traditional deployment) or `create2`
 * (salted deterministic deployment). It also includes functions to predict the addresses of clones deployed using the
 * deterministic method.
 *
 * _Available since v3.4._
 */
library Clones {
    /**
     * @dev Deploys and returns the address of a clone that mimics the behaviour of `implementation`.
     *
     * This function uses the create opcode, which should never revert.
     */
    function clone(address implementation) internal returns (address instance) {
        assembly {
            let ptr := mload(0x40)
            mstore(ptr, 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000)
            mstore(add(ptr, 0x14), shl(0x60, implementation))
            mstore(add(ptr, 0x28), 0x5af43d82803e903d91602b57fd5bf30000000000000000000000000000000000)
            instance := create(0, ptr, 0x37)
        }
        require(instance != address(0), "ERC1167: create failed");
    }

    /**
     * @dev Deploys and returns the address of a clone that mimics the behaviour of `implementation`.
     *
     * This function uses the create2 opcode and a `salt` to deterministically deploy
     * the clone. Using the same `implementation` and `salt` multiple time will revert, since
     * the clones cannot be deployed twice at the same address.
     */
    function cloneDeterministic(address implementation, bytes32 salt) internal returns (address instance) {
        assembly {
            let ptr := mload(0x40)
            mstore(ptr, 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000)
            mstore(add(ptr, 0x14), shl(0x60, implementation))
            mstore(add(ptr, 0x28), 0x5af43d82803e903d91602b57fd5bf30000000000000000000000000000000000)
            instance := create2(0, ptr, 0x37, salt)
        }
        require(instance != address(0), "ERC1167: create2 failed");
    }

    /**
     * @dev Computes the address of a clone deployed using {Clones-cloneDeterministic}.
     */
    function predictDeterministicAddress(
        address implementation,
        bytes32 salt,
        address deployer
    ) internal pure returns (address predicted) {
        assembly {
            let ptr := mload(0x40)
            mstore(ptr, 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000)
            mstore(add(ptr, 0x14), shl(0x60, implementation))
            mstore(add(ptr, 0x28), 0x5af43d82803e903d91602b57fd5bf3ff00000000000000000000000000000000)
            mstore(add(ptr, 0x38), shl(0x60, deployer))
            mstore(add(ptr, 0x4c), salt)
            mstore(add(ptr, 0x6c), keccak256(ptr, 0x37))
            predicted := keccak256(add(ptr, 0x37), 0x55)
        }
    }

    /**
     * @dev Computes the address of a clone deployed using {Clones-cloneDeterministic}.
     */
    function predictDeterministicAddress(address implementation, bytes32 salt)
        internal
        view
        returns (address predicted)
    {
        return predictDeterministicAddress(implementation, salt, address(this));
    }
}

File 9 of 18 : 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 10 of 18 : 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 11 of 18 : IWallet.sol
// SPDX-License-Identifier: GPL-3.0-or-later

pragma solidity ^0.8.6;
import "../libraries/DBDataTypes.sol";

interface IWallet {
    function useBridges(address[] calldata _bridgeAddresses, bytes[] calldata _bridgeEncodedCalls) external;

    function withdraw(
        DBDataTypes.TokenData calldata outputs,
        uint256 outputEthPercentage,
        address user) external returns (uint256[] memory, uint256);
}

File 12 of 18 : 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 13 of 18 : 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;
        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");

        (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");

        (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");

        (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");

        (bool success, bytes memory returndata) = target.delegatecall(data);
        return verifyCallResult(success, returndata, errorMessage);
    }

    /**
     * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the
     * revert reason using the provided one.
     *
     * _Available since v4.3._
     */
    function verifyCallResult(
        bool success,
        bytes memory returndata,
        string memory errorMessage
    ) internal 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

                assembly {
                    let returndata_size := mload(returndata)
                    revert(add(32, returndata), returndata_size)
                }
            } else {
                revert(errorMessage);
            }
        }
    }
}

File 14 of 18 : 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 15 of 18 : IERC721Metadata.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "../IERC721.sol";

/**
 * @title ERC-721 Non-Fungible Token Standard, optional metadata extension
 * @dev See https://eips.ethereum.org/EIPS/eip-721
 */
interface IERC721Metadata is IERC721 {
    /**
     * @dev Returns the token collection name.
     */
    function name() external view returns (string memory);

    /**
     * @dev Returns the token collection symbol.
     */
    function symbol() external view returns (string memory);

    /**
     * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.
     */
    function tokenURI(uint256 tokenId) external view returns (string memory);
}

File 16 of 18 : 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) {
        return msg.data;
    }
}

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

pragma solidity ^0.8.0;

/**
 * @dev String operations.
 */
library Strings {
    bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef";

    /**
     * @dev Converts a `uint256` to its ASCII `string` decimal representation.
     */
    function toString(uint256 value) internal pure returns (string memory) {
        // Inspired by OraclizeAPI's implementation - MIT licence
        // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol

        if (value == 0) {
            return "0";
        }
        uint256 temp = value;
        uint256 digits;
        while (temp != 0) {
            digits++;
            temp /= 10;
        }
        bytes memory buffer = new bytes(digits);
        while (value != 0) {
            digits -= 1;
            buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));
            value /= 10;
        }
        return string(buffer);
    }

    /**
     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
     */
    function toHexString(uint256 value) internal pure returns (string memory) {
        if (value == 0) {
            return "0x00";
        }
        uint256 temp = value;
        uint256 length = 0;
        while (temp != 0) {
            length++;
            temp >>= 8;
        }
        return toHexString(value, length);
    }

    /**
     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.
     */
    function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
        bytes memory buffer = new bytes(2 * length + 2);
        buffer[0] = "0";
        buffer[1] = "x";
        for (uint256 i = 2 * length + 1; i > 1; --i) {
            buffer[i] = _HEX_SYMBOLS[value & 0xf];
            value >>= 4;
        }
        require(value == 0, "Strings: hex length insufficient");
        return string(buffer);
    }
}

File 18 of 18 : 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;
    }
}

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

Contract Security Audit

Contract ABI

[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"approved","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":false,"internalType":"bool","name":"approved","type":"bool"}],"name":"ApprovalForAll","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"nftId","type":"uint256"},{"indexed":false,"internalType":"address","name":"wallet","type":"address"}],"name":"DEFIBASKET_CREATE","type":"event"},{"anonymous":false,"inputs":[],"name":"DEFIBASKET_DEPOSIT","type":"event"},{"anonymous":false,"inputs":[],"name":"DEFIBASKET_EDIT","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256[]","name":"outputAmounts","type":"uint256[]"},{"indexed":false,"internalType":"uint256","name":"ethAmount","type":"uint256"}],"name":"DEFIBASKET_WITHDRAW","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Transfer","type":"event"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"approve","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"address[]","name":"tokens","type":"address[]"},{"internalType":"uint256[]","name":"amounts","type":"uint256[]"}],"internalType":"struct DBDataTypes.TokenData","name":"inputs","type":"tuple"},{"internalType":"address[]","name":"bridgeAddresses","type":"address[]"},{"internalType":"bytes[]","name":"bridgeEncodedCalls","type":"bytes[]"}],"name":"createPortfolio","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"nftId","type":"uint256"},{"components":[{"internalType":"address[]","name":"tokens","type":"address[]"},{"internalType":"uint256[]","name":"amounts","type":"uint256[]"}],"internalType":"struct DBDataTypes.TokenData","name":"inputs","type":"tuple"},{"internalType":"address[]","name":"bridgeAddresses","type":"address[]"},{"internalType":"bytes[]","name":"bridgeEncodedCalls","type":"bytes[]"}],"name":"depositPortfolio","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"nftId","type":"uint256"},{"internalType":"address[]","name":"bridgeAddresses","type":"address[]"},{"internalType":"bytes[]","name":"bridgeEncodedCalls","type":"bytes[]"}],"name":"editPortfolio","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"getApproved","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"operator","type":"address"}],"name":"isApprovedForAll","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"ownerOf","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"bytes","name":"_data","type":"bytes"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"operator","type":"address"},{"internalType":"bool","name":"approved","type":"bool"}],"name":"setApprovalForAll","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"nftImageURI","type":"string"}],"name":"setBaseURI","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"tokenCounter","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"tokenURI","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"transferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"nftId","type":"uint256"}],"name":"walletOf","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"nftId","type":"uint256"},{"components":[{"internalType":"address[]","name":"tokens","type":"address[]"},{"internalType":"uint256[]","name":"amounts","type":"uint256[]"}],"internalType":"struct DBDataTypes.TokenData","name":"outputs","type":"tuple"},{"internalType":"uint256","name":"outputEthPercentage","type":"uint256"},{"internalType":"address[]","name":"bridgeAddresses","type":"address[]"},{"internalType":"bytes[]","name":"bridgeEncodedCalls","type":"bytes[]"}],"name":"withdrawPortfolio","outputs":[],"stateMutability":"nonpayable","type":"function"}]

6000600755610100604052603060a08181529062003aad60c03980516200002f9160099160209091019062000161565b503480156200003d57600080fd5b50604080518082018252600f81526e1119519a4810985cdad95d08139195608a1b602080830191825283518085019094526009845268109054d2d15513919560ba1b908401528151919291620000969160009162000161565b508051620000ac90600190602084019062000161565b505050620000c9620000c36200010b60201b60201c565b6200010f565b604051620000d790620001f0565b604051809103906000f080158015620000f4573d6000803e3d6000fd5b5060601b6001600160601b03191660805262000252565b3390565b600680546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b8280546200016f9062000215565b90600052602060002090601f016020900481019282620001935760008555620001de565b82601f10620001ae57805160ff1916838001178555620001de565b82800160010185558215620001de579182015b82811115620001de578251825591602001919060010190620001c1565b50620001ec929150620001fe565b5090565b610bd28062002edb83390190565b5b80821115620001ec5760008155600101620001ff565b600181811c908216806200022a57607f821691505b602082108114156200024c57634e487b7160e01b600052602260045260246000fd5b50919050565b60805160601c612c6a6200027160003960006113300152612c6a6000f3fe6080604052600436106101405760003560e01c80637804d8bd116100b6578063b88d4fde1161006f578063b88d4fde14610372578063c87b56dd14610392578063d082e381146103b2578063e0fa88e1146103c8578063e985e9c5146103fe578063f2fde38b1461044757600080fd5b80637804d8bd146102cc5780638da5cb5b146102ec57806391249f201461030a57806395d89b411461031d578063a22cb46514610332578063ad97faa41461035257600080fd5b806342842e0e1161010857806342842e0e1461021657806355f804b31461023657806362e33556146102565780636352211e1461026957806370a0823114610289578063715018a6146102b757600080fd5b806301ffc9a71461014557806306fdde031461017a578063081812fc1461019c578063095ea7b3146101d457806323b872dd146101f6575b600080fd5b34801561015157600080fd5b506101656101603660046121f4565b610467565b60405190151581526020015b60405180910390f35b34801561018657600080fd5b5061018f6104b9565b60405161017191906126b9565b3480156101a857600080fd5b506101bc6101b736600461230a565b61054b565b6040516001600160a01b039091168152602001610171565b3480156101e057600080fd5b506101f46101ef3660046120f9565b6105e5565b005b34801561020257600080fd5b506101f461021136600461200b565b6106fb565b34801561022257600080fd5b506101f461023136600461200b565b61072c565b34801561024257600080fd5b506101f461025136600461222e565b610747565b6101f4610264366004612276565b610788565b34801561027557600080fd5b506101bc61028436600461230a565b6108c8565b34801561029557600080fd5b506102a96102a4366004611fbd565b61093f565b604051908152602001610171565b3480156102c357600080fd5b506101f46109c6565b3480156102d857600080fd5b506101f46102e73660046123f6565b6109fc565b3480156102f857600080fd5b506006546001600160a01b03166101bc565b6101f4610318366004612359565b610b6b565b34801561032957600080fd5b5061018f610d02565b34801561033e57600080fd5b506101f461034d3660046120c2565b610d11565b34801561035e57600080fd5b506101f461036d366004612323565b610dd6565b34801561037e57600080fd5b506101f461038d366004612047565b610e75565b34801561039e57600080fd5b5061018f6103ad36600461230a565b610ead565b3480156103be57600080fd5b506102a960075481565b3480156103d457600080fd5b506101bc6103e336600461230a565b6000908152600860205260409020546001600160a01b031690565b34801561040a57600080fd5b50610165610419366004611fd8565b6001600160a01b03918216600090815260056020908152604080832093909416825291909152205460ff1690565b34801561045357600080fd5b506101f4610462366004611fbd565b610f88565b60006001600160e01b031982166380ac58cd60e01b148061049857506001600160e01b03198216635b5e139f60e01b145b806104b357506301ffc9a760e01b6001600160e01b03198316145b92915050565b6060600080546104c890612b32565b80601f01602080910402602001604051908101604052809291908181526020018280546104f490612b32565b80156105415780601f1061051657610100808354040283529160200191610541565b820191906000526020600020905b81548152906001019060200180831161052457829003601f168201915b5050505050905090565b6000818152600260205260408120546001600160a01b03166105c95760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b60648201526084015b60405180910390fd5b506000908152600460205260409020546001600160a01b031690565b60006105f0826108c8565b9050806001600160a01b0316836001600160a01b0316141561065e5760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656044820152603960f91b60648201526084016105c0565b336001600160a01b038216148061067a575061067a8133610419565b6106ec5760405162461bcd60e51b815260206004820152603860248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760448201527f6e6572206e6f7220617070726f76656420666f7220616c6c000000000000000060648201526084016105c0565b6106f68383611023565b505050565b6107053382611091565b6107215760405162461bcd60e51b81526004016105c0906127f9565b6106f6838383611188565b6106f683838360405180602001604052806000815250610e75565b6006546001600160a01b031633146107715760405162461bcd60e51b81526004016105c090612773565b8051610784906009906020840190611e53565b5050565b84346107976020830183612a02565b90506107a38380612a02565b9050146107c25760405162461bcd60e51b81526004016105c090612915565b60005b6107d26020840184612a02565b90508161ffff1610156108385760006107ee6020850185612a02565b8361ffff1681811061080257610802612be4565b90506020020135116108265760405162461bcd60e51b81526004016105c09061271e565b8061083081612b67565b9150506107c5565b5060006108486020840184612a02565b905011806108565750600081115b6108725760405162461bcd60e51b81526004016105c0906128b8565b858585858083146108955760405162461bcd60e51b81526004016105c09061284a565b60006108a033611328565b90506108ad818d346113e5565b6108ba818c8c8c8c6115cd565b505050505050505050505050565b6000818152600260205260408120546001600160a01b0316806104b35760405162461bcd60e51b815260206004820152602960248201527f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460448201526832b73a103a37b5b2b760b91b60648201526084016105c0565b60006001600160a01b0382166109aa5760405162461bcd60e51b815260206004820152602a60248201527f4552433732313a2062616c616e636520717565727920666f7220746865207a65604482015269726f206164647265737360b01b60648201526084016105c0565b506001600160a01b031660009081526003602052604090205490565b6006546001600160a01b031633146109f05760405162461bcd60e51b81526004016105c090612773565b6109fa6000611657565b565b8585610a0b6020830183612a02565b9050610a178380612a02565b905014610a365760405162461bcd60e51b81526004016105c090612915565b60005b610a466020840184612a02565b90508161ffff161015610aac576000610a626020850185612a02565b8361ffff16818110610a7657610a76612be4565b9050602002013511610a9a5760405162461bcd60e51b81526004016105c09061271e565b80610aa481612b67565b915050610a39565b506000610abc6020840184612a02565b90501180610aca5750600081115b610ae65760405162461bcd60e51b81526004016105c0906128b8565b85858585808314610b095760405162461bcd60e51b81526004016105c09061284a565b8c610b13816108c8565b6001600160a01b0316336001600160a01b031614610b435760405162461bcd60e51b81526004016105c0906127a8565b610b508e8c8c8c8c6115cd565b610b5b8e8e8e6116a9565b5050505050505050505050505050565b8434610b7a6020830183612a02565b9050610b868380612a02565b905014610ba55760405162461bcd60e51b81526004016105c090612915565b60005b610bb56020840184612a02565b90508161ffff161015610c1b576000610bd16020850185612a02565b8361ffff16818110610be557610be5612be4565b9050602002013511610c095760405162461bcd60e51b81526004016105c09061271e565b80610c1381612b67565b915050610ba8565b506000610c2b6020840184612a02565b90501180610c395750600081115b610c555760405162461bcd60e51b81526004016105c0906128b8565b85858585808314610c785760405162461bcd60e51b81526004016105c09061284a565b8b610c82816108c8565b6001600160a01b0316336001600160a01b031614610cb25760405162461bcd60e51b81526004016105c0906127a8565b6040517fec5edaa254eabbeb78800c10973d26937394311e5f63116baf1f5bc2ebb3d92590600090a1610ce68d8d346113e5565b610cf38d8c8c8c8c6115cd565b50505050505050505050505050565b6060600180546104c890612b32565b6001600160a01b038216331415610d6a5760405162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c65720000000000000060448201526064016105c0565b3360008181526005602090815260408083206001600160a01b03871680855290835292819020805460ff191686151590811790915590519081529192917f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a35050565b83838383808314610df95760405162461bcd60e51b81526004016105c09061284a565b88610e03816108c8565b6001600160a01b0316336001600160a01b031614610e335760405162461bcd60e51b81526004016105c0906127a8565b6040517f098a5c64764c319df560b46daf95a5edaa4ffdd24a9bad5c9de976d41cfdfaeb90600090a1610e698a8a8a8a8a6115cd565b50505050505050505050565b610e7f3383611091565b610e9b5760405162461bcd60e51b81526004016105c0906127f9565b610ea7848484846117a4565b50505050565b6000818152600260205260409020546060906001600160a01b0316610f2c5760405162461bcd60e51b815260206004820152602f60248201527f4552433732314d657461646174613a2055524920717565727920666f72206e6f60448201526e3732bc34b9ba32b73a103a37b5b2b760891b60648201526084016105c0565b6000610f366117d7565b90506000815111610f565760405180602001604052806000815250610f81565b80610f60846117e6565b604051602001610f71929190612555565b6040516020818303038152906040525b9392505050565b6006546001600160a01b03163314610fb25760405162461bcd60e51b81526004016105c090612773565b6001600160a01b0381166110175760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084016105c0565b61102081611657565b50565b600081815260046020526040902080546001600160a01b0319166001600160a01b0384169081179091558190611058826108c8565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b6000818152600260205260408120546001600160a01b031661110a5760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b60648201526084016105c0565b6000611115836108c8565b9050806001600160a01b0316846001600160a01b031614806111505750836001600160a01b03166111458461054b565b6001600160a01b0316145b8061118057506001600160a01b0380821660009081526005602090815260408083209388168352929052205460ff165b949350505050565b826001600160a01b031661119b826108c8565b6001600160a01b0316146112035760405162461bcd60e51b815260206004820152602960248201527f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960448201526839903737ba1037bbb760b91b60648201526084016105c0565b6001600160a01b0382166112655760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646044820152637265737360e01b60648201526084016105c0565b611270600082611023565b6001600160a01b0383166000908152600360205260408120805460019290611299908490612aef565b90915550506001600160a01b03821660009081526003602052604081208054600192906112c7908490612ac3565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b0386811691821790925591518493918716917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4505050565b6000806113547f00000000000000000000000000000000000000000000000000000000000000006118e3565b60078054600081815260086020526040902080546001600160a01b0319166001600160a01b038516179055905491925090611390906001612ac3565b60075561139d8482611980565b604080518281526001600160a01b03841660208201527f827c603e5fad3c3ec77bf9b91a9ea99943aebb693ca8c9e838194bca5ffff0b2910160405180910390a19392505050565b60006113f96006546001600160a01b031690565b905060006114096103e884612adb565b9050816001600160a01b03168160405160006040518083038185875af1925050503d8060008114611456576040519150601f19603f3d011682016040523d82523d6000602084013e61145b565b606091505b5050506000858152600860205260409020546001600160a01b0316806114818386612aef565b604051600081818185875af1925050503d80600081146114bd576040519150601f19603f3d011682016040523d82523d6000602084013e6114c2565b606091505b50505060005b6114d28680612a02565b90508161ffff1610156115c4576103e86114ef6020880188612a02565b8361ffff1681811061150357611503612be4565b905060200201356115149190612adb565b9250611568611522886108c8565b858561152e8a80612a02565b8661ffff1681811061154257611542612be4565b90506020020160208101906115579190611fbd565b6001600160a01b031692919061199a565b6115b2611574886108c8565b838561158360208b018b612a02565b8661ffff1681811061159757611597612be4565b905060200201356115a89190612aef565b61152e8a80612a02565b806115bc81612b67565b9150506114c8565b50505050505050565b6000858152600860205260408120546001600160a01b031660405163d124b3b760e01b815290915081906001600160a01b0382169063d124b3b79061161c9089908990899089906004016125c1565b600060405180830381600087803b15801561163657600080fd5b505af115801561164a573d6000803e3d6000fd5b5050505050505050505050565b600680546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b60606000806116cd866000908152600860205260409020546001600160a01b031690565b9050806001600160a01b031663642c438c86866116e98a6108c8565b6040518463ffffffff1660e01b815260040161170793929190612972565b600060405180830381600087803b15801561172157600080fd5b505af1158015611735573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261175d9190810190612123565b60405191945092507fb2d45cfa56b83d9af7e750bfaec5723ef33fb9cc10ae955cf6809e33a7ba57e4906117949085908590612671565b60405180910390a1505050505050565b6117af848484611188565b6117bb848484846119f4565b610ea75760405162461bcd60e51b81526004016105c0906126cc565b6060600980546104c890612b32565b60608161180a5750506040805180820190915260018152600360fc1b602082015290565b8160005b8115611834578061181e81612b89565b915061182d9050600a83612adb565b915061180e565b6000816001600160401b0381111561184e5761184e612bfa565b6040519080825280601f01601f191660200182016040528015611878576020820181803683370190505b5090505b84156111805761188d600183612aef565b915061189a600a86612ba4565b6118a5906030612ac3565b60f81b8183815181106118ba576118ba612be4565b60200101906001600160f81b031916908160001a9053506118dc600a86612adb565b945061187c565b6000604051733d602d80600a3d3981f3363d3d373d3d3d363d7360601b81528260601b60148201526e5af43d82803e903d91602b57fd5bf360881b60288201526037816000f09150506001600160a01b03811661197b5760405162461bcd60e51b8152602060048201526016602482015275115490cc4c4d8dce8818dc99585d194819985a5b195960521b60448201526064016105c0565b919050565b610784828260405180602001604052806000815250611b01565b604080516001600160a01b0385811660248301528416604482015260648082018490528251808303909101815260849091019091526020810180516001600160e01b03166323b872dd60e01b179052610ea7908590611b34565b60006001600160a01b0384163b15611af657604051630a85bd0160e11b81526001600160a01b0385169063150b7a0290611a38903390899088908890600401612584565b602060405180830381600087803b158015611a5257600080fd5b505af1925050508015611a82575060408051601f3d908101601f19168201909252611a7f91810190612211565b60015b611adc573d808015611ab0576040519150601f19603f3d011682016040523d82523d6000602084013e611ab5565b606091505b508051611ad45760405162461bcd60e51b81526004016105c0906126cc565b805181602001fd5b6001600160e01b031916630a85bd0160e11b149050611180565b506001949350505050565b611b0b8383611c06565b611b1860008484846119f4565b6106f65760405162461bcd60e51b81526004016105c0906126cc565b6000611b89826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316611d489092919063ffffffff16565b8051909150156106f65780806020019051810190611ba791906121d7565b6106f65760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b60648201526084016105c0565b6001600160a01b038216611c5c5760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f206164647265737360448201526064016105c0565b6000818152600260205260409020546001600160a01b031615611cc15760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e7465640000000060448201526064016105c0565b6001600160a01b0382166000908152600360205260408120805460019290611cea908490612ac3565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b03861690811790915590518392907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b6060611180848460008585843b611da15760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016105c0565b600080866001600160a01b03168587604051611dbd9190612539565b60006040518083038185875af1925050503d8060008114611dfa576040519150601f19603f3d011682016040523d82523d6000602084013e611dff565b606091505b5091509150611e0f828286611e1a565b979650505050505050565b60608315611e29575081610f81565b825115611e395782518084602001fd5b8160405162461bcd60e51b81526004016105c091906126b9565b828054611e5f90612b32565b90600052602060002090601f016020900481019282611e815760008555611ec7565b82601f10611e9a57805160ff1916838001178555611ec7565b82800160010185558215611ec7579182015b82811115611ec7578251825591602001919060010190611eac565b50611ed3929150611ed7565b5090565b5b80821115611ed35760008155600101611ed8565b60006001600160401b03831115611f0557611f05612bfa565b611f18601f8401601f1916602001612a4b565b9050828152838383011115611f2c57600080fd5b828260208301376000602084830101529392505050565b80356001600160a01b038116811461197b57600080fd5b60008083601f840112611f6c57600080fd5b5081356001600160401b03811115611f8357600080fd5b6020830191508360208260051b8501011115611f9e57600080fd5b9250929050565b600060408284031215611fb757600080fd5b50919050565b600060208284031215611fcf57600080fd5b610f8182611f43565b60008060408385031215611feb57600080fd5b611ff483611f43565b915061200260208401611f43565b90509250929050565b60008060006060848603121561202057600080fd5b61202984611f43565b925061203760208501611f43565b9150604084013590509250925092565b6000806000806080858703121561205d57600080fd5b61206685611f43565b935061207460208601611f43565b92506040850135915060608501356001600160401b0381111561209657600080fd5b8501601f810187136120a757600080fd5b6120b687823560208401611eec565b91505092959194509250565b600080604083850312156120d557600080fd5b6120de83611f43565b915060208301356120ee81612c10565b809150509250929050565b6000806040838503121561210c57600080fd5b61211583611f43565b946020939093013593505050565b6000806040838503121561213657600080fd5b82516001600160401b038082111561214d57600080fd5b818501915085601f83011261216157600080fd5b815160208282111561217557612175612bfa565b8160051b9250612186818401612a4b565b8281528181019085830185870184018b10156121a157600080fd5b600096505b848710156121c45780518352600196909601959183019183016121a6565b5097909101519698969750505050505050565b6000602082840312156121e957600080fd5b8151610f8181612c10565b60006020828403121561220657600080fd5b8135610f8181612c1e565b60006020828403121561222357600080fd5b8151610f8181612c1e565b60006020828403121561224057600080fd5b81356001600160401b0381111561225657600080fd5b8201601f8101841361226757600080fd5b61118084823560208401611eec565b60008060008060006060868803121561228e57600080fd5b85356001600160401b03808211156122a557600080fd5b6122b189838a01611fa5565b965060208801359150808211156122c757600080fd5b6122d389838a01611f5a565b909650945060408801359150808211156122ec57600080fd5b506122f988828901611f5a565b969995985093965092949392505050565b60006020828403121561231c57600080fd5b5035919050565b60008060008060006060868803121561233b57600080fd5b8535945060208601356001600160401b03808211156122c757600080fd5b6000806000806000806080878903121561237257600080fd5b8635955060208701356001600160401b038082111561239057600080fd5b61239c8a838b01611fa5565b965060408901359150808211156123b257600080fd5b6123be8a838b01611f5a565b909650945060608901359150808211156123d757600080fd5b506123e489828a01611f5a565b979a9699509497509295939492505050565b600080600080600080600060a0888a03121561241157600080fd5b8735965060208801356001600160401b038082111561242f57600080fd5b61243b8b838c01611fa5565b975060408a0135965060608a013591508082111561245857600080fd5b6124648b838c01611f5a565b909650945060808a013591508082111561247d57600080fd5b5061248a8a828b01611f5a565b989b979a50959850939692959293505050565b8183526000602080850194508260005b858110156124d9576001600160a01b036124c683611f43565b16875295820195908201906001016124ad565b509495945050505050565b81835281816020850137506000828201602090810191909152601f909101601f19169091010190565b60008151808452612525816020860160208601612b06565b601f01601f19169290920160200192915050565b6000825161254b818460208701612b06565b9190910192915050565b60008351612567818460208801612b06565b83519083019061257b818360208801612b06565b01949350505050565b6001600160a01b03858116825284166020820152604081018390526080606082018190526000906125b79083018461250d565b9695505050505050565b6040815260006125d560408301868861249d565b602083820381850152818583528183019050818660051b8401018760005b8881101561266157858303601f190184528135368b9003601e1901811261261957600080fd5b8a0180356001600160401b0381111561263157600080fd5b8036038c131561264057600080fd5b61264d85828985016124e4565b9587019594505050908401906001016125f3565b50909a9950505050505050505050565b604080825283519082018190526000906020906060840190828701845b828110156126aa5781518452928401929084019060010161268e565b50505092019290925292915050565b602081526000610f81602083018461250d565b60208082526032908201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b606082015260800190565b60208082526035908201527f444546494241534b45542057414c4c45543a20455243323020544f4b454e204160408201527404d4f554e5453204e45454420544f204245203e203605c1b606082015260800190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b60208082526031908201527f444546494241534b45543a204f4e4c59204e4654204f574e45522043414e204360408201527020a626102a2424a990232aa721aa24a7a760791b606082015260800190565b60208082526031908201527f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f6040820152701ddb995c881b9bdc88185c1c1c9bdd9959607a1b606082015260800190565b60208082526048908201527f444546494241534b45543a2042524944474520454e434f4445442043414c4c5360408201527f20414e4420414444524553534553204d5553542048415645205448452053414d60608201526708a40988a9c8ea8960c31b608082015260a00190565b60208082526038908201527f444546494241534b45543a20414e20414d4f554e5420494e204554484552204f60408201527f5220455243323020544f4b454e53204953204e45454445440000000000000000606082015260800190565b60208082526039908201527f444546494241534b45543a204d49534d4154434820494e204c454e475448204260408201527f45545745454e20544f4b454e5320414e4420414d4f554e545300000000000000606082015260800190565b6060815260006129828586612a7b565b6040606085015261299760a08501828461249d565b9150506129a76020870187612a7b565b848303605f190160808601528083526001600160fb1b038111156129ca57600080fd5b60051b808260208501376000920160209081019283528401959095526001600160a01b03939093166040909201919091525092915050565b6000808335601e19843603018112612a1957600080fd5b8301803591506001600160401b03821115612a3357600080fd5b6020019150600581901b3603821315611f9e57600080fd5b604051601f8201601f191681016001600160401b0381118282101715612a7357612a73612bfa565b604052919050565b6000808335601e19843603018112612a9257600080fd5b83016020810192503590506001600160401b03811115612ab157600080fd5b8060051b3603831315611f9e57600080fd5b60008219821115612ad657612ad6612bb8565b500190565b600082612aea57612aea612bce565b500490565b600082821015612b0157612b01612bb8565b500390565b60005b83811015612b21578181015183820152602001612b09565b83811115610ea75750506000910152565b600181811c90821680612b4657607f821691505b60208210811415611fb757634e487b7160e01b600052602260045260246000fd5b600061ffff80831681811415612b7f57612b7f612bb8565b6001019392505050565b6000600019821415612b9d57612b9d612bb8565b5060010190565b600082612bb357612bb3612bce565b500690565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b801515811461102057600080fd5b6001600160e01b03198116811461102057600080fdfea26469706673582212202848aa60643eeef72a3a828544f71e17a313fc95ce748089ed4b77cebeeb732564736f6c6343000806003360a060405234801561001057600080fd5b5033606081901b608052610b9a6100386000396000818160d0015261039b0152610b9a6000f3fe60806040526004361061002d5760003560e01c8063642c438c14610071578063d124b3b7146100a857600080fd5b3661006c57604080513381523460208201527f88a5966d370b9919b20f3e2c13ff65706f196a4e32cc2c12bf57088f88525874910160405180910390a1005b600080fd5b34801561007d57600080fd5b5061009161008c366004610885565b6100ca565b60405161009f929190610926565b60405180910390f35b3480156100b457600080fd5b506100c86100c33660046107f7565b610399565b005b606060007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316331461011f5760405162461bcd60e51b8152600401610116906109a1565b60405180910390fd5b600061012b86806109fe565b905067ffffffffffffffff81111561014557610145610b4e565b60405190808252806020026020018201604052801561016e578160200160208202803683370190505b50905060005b61017e87806109fe565b90508161ffff16101561031657620186a061019c60208901896109fe565b8361ffff168181106101b0576101b0610b38565b602002919091013590506101c489806109fe565b8461ffff168181106101d8576101d8610b38565b90506020020160208101906101ed91906107dc565b6040516370a0823160e01b81523060048201526001600160a01b0391909116906370a082319060240160206040518083038186803b15801561022e57600080fd5b505afa158015610242573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061026691906108e1565b6102709190610ab1565b61027a9190610a8f565b828261ffff168151811061029057610290610b38565b60200260200101818152505061030485838361ffff16815181106102b6576102b6610b38565b60209081029190910101516102cb8a806109fe565b8561ffff168181106102df576102df610b38565b90506020020160208101906102f491906107dc565b6001600160a01b031691906104d1565b8061030e81610b00565b915050610174565b506000851561038d57620186a061032d8747610ab1565b6103379190610a8f565b9050846001600160a01b03168160405160006040518083038185875af1925050503d8060008114610384576040519150601f19603f3d011682016040523d82523d6000602084013e610389565b606091505b5050505b90969095509350505050565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031633146103e15760405162461bcd60e51b8152600401610116906109a1565b6000606060005b61ffff81168611156104c85786868261ffff1681811061040a5761040a610b38565b905060200201602081019061041f91906107dc565b6001600160a01b031685858361ffff1681811061043e5761043e610b38565b90506020028101906104509190610a48565b60405161045e9291906108fa565b600060405180830381855af49150503d8060008114610499576040519150601f19603f3d011682016040523d82523d6000602084013e61049e565b606091505b509093509150826104b6576040513d806000833e8082fd5b806104c081610b00565b9150506103e8565b50505050505050565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b179052610523908490610528565b505050565b600061057d826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166105fa9092919063ffffffff16565b805190915015610523578080602001905181019061059b9190610863565b6105235760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610116565b60606106098484600085610613565b90505b9392505050565b6060824710156106745760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b6064820152608401610116565b843b6106c25760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610116565b600080866001600160a01b031685876040516106de919061090a565b60006040518083038185875af1925050503d806000811461071b576040519150601f19603f3d011682016040523d82523d6000602084013e610720565b606091505b509150915061073082828661073b565b979650505050505050565b6060831561074a57508161060c565b82511561075a5782518084602001fd5b8160405162461bcd60e51b8152600401610116919061096e565b80356001600160a01b038116811461078b57600080fd5b919050565b60008083601f8401126107a257600080fd5b50813567ffffffffffffffff8111156107ba57600080fd5b6020830191508360208260051b85010111156107d557600080fd5b9250929050565b6000602082840312156107ee57600080fd5b61060c82610774565b6000806000806040858703121561080d57600080fd5b843567ffffffffffffffff8082111561082557600080fd5b61083188838901610790565b9096509450602087013591508082111561084a57600080fd5b5061085787828801610790565b95989497509550505050565b60006020828403121561087557600080fd5b8151801515811461060c57600080fd5b60008060006060848603121561089a57600080fd5b833567ffffffffffffffff8111156108b157600080fd5b8401604081870312156108c357600080fd5b9250602084013591506108d860408501610774565b90509250925092565b6000602082840312156108f357600080fd5b5051919050565b8183823760009101908152919050565b6000825161091c818460208701610ad0565b9190910192915050565b604080825283519082018190526000906020906060840190828701845b8281101561095f57815184529284019290840190600101610943565b50505092019290925292915050565b602081526000825180602084015261098d816040850160208701610ad0565b601f01601f19169190910160400192915050565b6020808252603b908201527f57414c4c45543a204f4e4c592054484520444546494241534b455420434f4e5460408201527f524143542043414e2043414c4c20544849532046554e4354494f4e0000000000606082015260800190565b6000808335601e19843603018112610a1557600080fd5b83018035915067ffffffffffffffff821115610a3057600080fd5b6020019150600581901b36038213156107d557600080fd5b6000808335601e19843603018112610a5f57600080fd5b83018035915067ffffffffffffffff821115610a7a57600080fd5b6020019150368190038213156107d557600080fd5b600082610aac57634e487b7160e01b600052601260045260246000fd5b500490565b6000816000190483118215151615610acb57610acb610b22565b500290565b60005b83811015610aeb578181015183820152602001610ad3565b83811115610afa576000848401525b50505050565b600061ffff80831681811415610b1857610b18610b22565b6001019392505050565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052604160045260246000fdfea26469706673582212201b47d25559b2bbb1b6e83a59af601f2ed0c146b09a00ebff5fdd0684398a492364736f6c6343000806003368747470733a2f2f7777772e646566696261736b65742e6f72672f6170692f6765742d6e66742d6d657461646174612f

Block Transaction Gas Used Reward
Age Block Fee Address BC Fee Address Voting Power Jailed Incoming
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.