Contract 0x93bab043d534fbfdd13b405241be9267d393b827 12

 

Contract Overview

Clipper Exchange: Clipper Coves
Balance:
0 ETH

EtherValue:
$0.00

Token:
Txn Hash Method
Block
From
To
Value
0xd4cb0a27175d12600bf2e413758cb080bc79e692ee9153928927cf8286098739Burn To Withdraw1164376662024-02-21 0:08:299 hrs 8 mins ago0x08df8038f91418efb5571f9f51d084beb0ed0cb8 IN Clipper Exchange: Clipper Coves0 ETH0.0000661474410.004011189
0x86a1ebcdddc43136e638146906fac02966c4e61d2aa25a1d78ea9c08dbed14c0Burn To Withdraw1164109032024-02-20 9:16:231 day ago0xf9a0da0ec84cabf0ce7053f38349bcfcd53db4fe IN Clipper Exchange: Clipper Coves0 ETH0.0000607005480.003912429
0x95355827c77741b13921cafd8cec1edb69640a2daeba602328d3a8f2d2ab607aBurn To Withdraw1163901802024-02-19 21:45:371 day 11 hrs ago0x5a3a2fe2219cbc261be900c9ec094360d43621c0 IN Clipper Exchange: Clipper Coves0 ETH0.0000690728570.004532705
0xe75d13dc8c08701376d8a87bdcc4ec27009e982f4a23acdb7391e5e7a9864b32Burn To Withdraw1163839172024-02-19 18:16:511 day 14 hrs ago0xb5f9883a9318f3c7bc50a40be24f975885fe13a5 IN Clipper Exchange: Clipper Coves0 ETH0.0000714578890.0045166
0xeb9c58952586d2b8e042f05e6e2b398006dcb71956b8517d8168615acb135178Burn To Withdraw1163712592024-02-19 11:14:551 day 22 hrs ago0xb557286b7b2c6eb28fcfab8783a44830cdc6da24 IN Clipper Exchange: Clipper Coves0 ETH0.0000481581280.005965508
0x0c7e663ec380ebd2af2846e3ba661a00633802af302d1a934e4e9427282d2d61Burn To Withdraw1163709662024-02-19 11:05:091 day 22 hrs ago0x14b8c523e7167f66f1058e4fbb38d43b98f717c7 IN Clipper Exchange: Clipper Coves0 ETH0.0000575320470.005280934
0x285dac42f93c86efe81c2f7b84d710ad2d9853d09a4d577338854c4818cfd0a4Burn To Withdraw1163678382024-02-19 9:20:531 day 23 hrs ago0xdcb502463351c938218e15377ccb130970e3f4fa IN Clipper Exchange: Clipper Coves0 ETH0.0000741837450.004690063
0x0a52197dbdda08f86340ebd42bfd6944e0402b5d6c202ff69eea0b8226e9e0d2Burn To Withdraw1162041432024-02-15 14:24:235 days 18 hrs ago0x558041548dda2c26d43b603b9c532dd316e03656 IN Clipper Exchange: Clipper Coves0 ETH0.0000673457360.00475901
0x47afb4cfc734a456b2a19d49ae52d561cbb771cb6327559cf42fd462c0b7af58Burn To Withdraw1161850132024-02-15 3:46:436 days 5 hrs ago0x13ae5042d3abe5371b6b24b73e57ec718222a4da IN Clipper Exchange: Clipper Coves0 ETH0.0000396672390.037122769
0x9acf8c02bcd6826121bb4761ec7b68306af6348748518030dae00b1dcc916476Burn To Withdraw1161849882024-02-15 3:45:536 days 5 hrs ago0x0cbd39f71c68dfe81a89d39c24100f44374282d7 IN Clipper Exchange: Clipper Coves0 ETH0.0000423569860.039100715
0xd23fc2afed7932c57ab775667f87ef16b8fa860329b14413549b1c130cb13e8cBurn To Withdraw1161700032024-02-14 19:26:236 days 13 hrs ago0xc5c0584615fabbadddabcd1b1f602d98ac2d7632 IN Clipper Exchange: Clipper Coves0 ETH0.0000763138150.102879578
0xc723e077701951b3e674f121f27be1c37faf176fae54e8b890bdc36c836f7e51Burn To Withdraw1160763112024-02-12 15:23:198 days 17 hrs ago0xdfb973aef43638d73e7f84698531453e142729fe IN Clipper Exchange: Clipper Coves0 ETH0.000072516640.101190747
0x6bda1663c00cd7a3243c49cf0bc87e30dc94e7376c9701651b477d048b46724eBurn To Withdraw1159188992024-02-08 23:56:1512 days 9 hrs ago0x16dae220fe54183bf652a69018334a6c2ae5cd42 IN Clipper Exchange: Clipper Coves0 ETH0.0001086769880.000788525
0xad1891cac379c084fcef1b0e097fd9d732c3ff6c1afae6707f14733f1f1172c0Burn To Withdraw1158384162024-02-07 3:13:2914 days 6 hrs ago0x0a5705735bce97b08233192c1001ad8f326275ef IN Clipper Exchange: Clipper Coves0 ETH0.0000646435910.002075
0xe00d7552b5a210a2edf451298546990abae8588cb563992f24cbbe889c934846Burn To Withdraw1158029222024-02-06 7:30:2115 days 1 hr ago0x266f1f486e6a6ee8c6bc5d99084dc8833d3069cb IN Clipper Exchange: Clipper Coves0 ETH0.0001959645680.003995236
0x845d41a7c3fe7585e776cf0d62076aa4fb2d655f378ce0ef5d07f73df130d5daBurn To Withdraw1157604562024-02-05 7:54:4916 days 1 hr ago0xcb630c28658d8b4f0509d628d8d947e6f95ea20a IN Clipper Exchange: Clipper Coves0 ETH0.0000238449260.004765753
0x61690d4f3049081c7fecd349e4a9b644b2ec808621f0ed6bcd3124b8f9d276bdBurn To Withdraw1157349362024-02-04 17:44:0916 days 15 hrs ago0x403f620b8bad3d09b3209643f46c22981c78cac7 IN Clipper Exchange: Clipper Coves0 ETH0.0000330553270.004915844
0x5140b7263e0c1f80e7d4f8db1bc7e6c445776cf2d7c9eaa9121077947b2c896fBurn To Withdraw1157300352024-02-04 15:00:4716 days 18 hrs ago0x4ac4ff89b9d4b3daf54942e3df63751a4a54c735 IN Clipper Exchange: Clipper Coves0 ETH0.000038817960.004578195
0x7c4f4e25d767b6f44770a71b0bf66284e0c0f4d47066cab21b51b3ba955b1a13Burn To Withdraw1157298852024-02-04 14:55:4716 days 18 hrs ago0x4ac4ff89b9d4b3daf54942e3df63751a4a54c735 IN Clipper Exchange: Clipper Coves0 ETH0.0000335977540.004702295
0x9b84e3f7fd4eff76769800af2043fd026beb24e11691ddae3561bbff3e529133Burn To Withdraw1156684812024-02-03 4:48:5918 days 4 hrs ago0x1bb5e8ce6fd1736e5291146e112e0f404345a242 IN Clipper Exchange: Clipper Coves0 ETH0.0000269161320.004954323
0x01f572eb792852930e8f6ceffe31037f412f4d83fcf915be40dc8cceb326205dBurn To Withdraw1156400862024-02-02 13:02:2918 days 20 hrs ago0xf2458b6d28e4c7ed310591cc4d4615efbcfcf2fb IN Clipper Exchange: Clipper Coves0 ETH0.0000458618820.005534704
0xab384fe06d94b44dc79068b08b8b6466fe7c4c9c278825c70df2036d82aad31fBurn To Withdraw1156238582024-02-02 4:01:3319 days 5 hrs ago0x0aa5b39bc9e7e2ff26dcfec7040db0cdcb61cfae IN Clipper Exchange: Clipper Coves0 ETH0.0000385813020.005450304
0xa181ac3aeeaf122bda54b99534a0d442ada1f6228da23a4fbd15881c94623dffBurn To Withdraw1155921932024-02-01 10:26:0319 days 22 hrs ago0x3585e1e97012c0d84a491b91a95776a083d7c910 IN Clipper Exchange: Clipper Coves0 ETH0.000034518560.006432209
0xe37e6c1ab5199cbdf281d01bc97fd26305534485d1defb14a0f074e0b545bcc0Burn To Withdraw1154685052024-01-29 13:43:0722 days 19 hrs ago0xf4b905869c9e2c0c1433a0809ec9f076b46afe1a IN Clipper Exchange: Clipper Coves0 ETH0.0000278415240.004932239
0x54512e311da7abd45f5f6a4daeba5c71e4f4dd85b5e4e8dca71b92789225df03Burn To Withdraw1154351492024-01-28 19:11:1523 days 14 hrs ago0x166f2e250ac6c8ef7aaaadf9853720376a6c4b86 IN Clipper Exchange: Clipper Coves0 ETH0.0000246335990.005505701
[ Download CSV Export 
Latest 25 internal transaction
Parent Txn Hash Block From To Value
0x93bfd2adc1a28b765dbd381d6c1064dcae5cd0ea3b9cb9a1932f400e45a831fe1124080842023-11-19 17:29:0593 days 15 hrs ago Clipper Exchange: Clipper CovesClipper Exchange: Pool0.00455 ETH
0x8a67be9b40a651d3412505fc952f608c334cdaf3f0c15582d00312fba5ffbc2a1123975872023-11-19 11:39:1193 days 21 hrs ago Clipper Exchange: Clipper CovesClipper Exchange: Pool0.012 ETH
0x761e8900966dfb017ce468bf5d6a4f0b69c8f7a2260a3d27df75f328fe7521691121829862023-11-14 12:25:4998 days 20 hrs ago Clipper Exchange: Clipper CovesClipper Exchange: Pool0.00224 ETH
0x78fdc7a2559fdca96e85b1d8c41f2b7fe251ccd406b8210768105f0970e883671121230072023-11-13 3:06:31100 days 6 hrs ago Clipper Exchange: Clipper CovesClipper Exchange: Pool0.015 ETH
0x5e0bbad9941753c5b598d166f4f0d99ff2610e01c43bbfb187293a08c0e350601119432462023-11-08 23:14:29104 days 10 hrs ago Clipper Exchange: Clipper CovesClipper Exchange: Pool0.15 ETH
0xb4514902c356eea73962bc5cd9b36305e0656676d240669fcb1660e9937761601117672392023-11-04 21:27:35108 days 11 hrs ago Clipper Exchange: Clipper CovesClipper Exchange: Pool0.001 ETH
0x5431fc97179288687070c76d597753af949a27f2f75e995883d5c4f40829ec6d1117359742023-11-04 4:05:25109 days 5 hrs ago Clipper Exchange: Clipper CovesClipper Exchange: Pool0.038 ETH
0xfd1e3c55f76de8407f5478772a081cac355c3a9f844fb90e145a8e8bfa2bbdbc1116900122023-11-03 2:33:21110 days 6 hrs ago Clipper Exchange: Clipper CovesClipper Exchange: Pool0.15 ETH
0x12ab7e05080213bca281ee74bff8665d1b1aceaf1d53ccc7eeba7362e928f4db1116767862023-11-02 19:12:29110 days 14 hrs ago Clipper Exchange: Clipper CovesClipper Exchange: Pool0.1 ETH
0x2f812db42ac1a9277c0de20959cbf271325511d1850897733d969fc8431acf6b1114898952023-10-29 11:22:47114 days 21 hrs ago Clipper Exchange: Clipper CovesClipper Exchange: Pool0.039 ETH
0xa8d3041922a7bcd8d5ad34f085ac5614f3c860bc10af3ad6ff4bdcfd2ff40f291113891742023-10-27 3:25:25117 days 5 hrs ago Clipper Exchange: Clipper CovesClipper Exchange: Pool0.01 ETH
0xa8bc2bd39c4b9b2c5080715d4a580959f9b64d841be787e076ff3e1292fc97481109847522023-10-17 18:44:41126 days 14 hrs ago Clipper Exchange: Clipper CovesClipper Exchange: Pool0.02 ETH
0x90f02facf83beba47a693658e69ef0cd6434c9a37a62c7afb82402ca7e4a0dc61107466202023-10-12 6:26:57132 days 2 hrs ago Clipper Exchange: Clipper CovesClipper Exchange: Pool0.01 ETH
0x668b36f434ff18f21b7497ab869fb3a2c438b9095cb721dbde0bc4f822eafa6f1103691432023-10-03 12:44:23140 days 20 hrs ago Clipper Exchange: Clipper CovesClipper Exchange: Pool0.01 ETH
0xccfeedc098d48c95502dfe6f9ed6483a5957137e9e18db2f1e25abb8ed9a642c1101964232023-09-29 12:47:03144 days 20 hrs ago Clipper Exchange: Clipper CovesClipper Exchange: Pool0.030549 ETH
0x2f4796324fd952a6c9914034afdc67ba5f4ee97d7f339741d84674ee7f71f23b1101447592023-09-28 8:04:55146 days 1 hr ago Clipper Exchange: Clipper CovesClipper Exchange: Pool0.002 ETH
0x4a9df1b7dcfbeaa4d4ac84234025ffc55893a7c48fa8af6d810e949c02b72c471101265662023-09-27 21:58:29146 days 11 hrs ago Clipper Exchange: Clipper CovesClipper Exchange: Pool0.0005 ETH
0x77685fb9cdc9f281f3dd27b1a56b6b3543e1ab71fe5403038ba9515f6bf59da21101262852023-09-27 21:49:07146 days 11 hrs ago Clipper Exchange: Clipper CovesClipper Exchange: Pool0.0007 ETH
0xdd38560e44c69356c6a54ba0b70f32d5ef7abb66b584cffacd55fc3b769769491100892282023-09-27 1:13:53147 days 8 hrs ago Clipper Exchange: Clipper CovesClipper Exchange: Pool0.00029 ETH
0xb5f75a336f0fd3281dc11f43a5f69f79f2e939f0e24d2aecbf4f9819f6716f3a1100780912023-09-26 19:02:39147 days 14 hrs ago Clipper Exchange: Clipper CovesClipper Exchange: Pool0.001 ETH
0xe4fdefc34b6cb9cfccd60bcbcd954665c91b712713e5f58938ac86e22ad203e21100779572023-09-26 18:58:11147 days 14 hrs ago Clipper Exchange: Clipper CovesClipper Exchange: Pool0.001 ETH
0xdc97fb7e11e49569426cbe692f98eb874ec9613a277c45ade58141834dd991431100733222023-09-26 16:23:41147 days 16 hrs ago Clipper Exchange: Clipper CovesClipper Exchange: Pool0.002 ETH
0x596f0e0e1cd725eb52ff8a8ae2b9ac03ce4007b2dfd88d51550edf1b32339ab41100231742023-09-25 12:32:05148 days 20 hrs ago Clipper Exchange: Clipper CovesClipper Exchange: Pool0.0002 ETH
0xc63f19a582886501fc0c51480573ab42cbb43b450e372c066d672a8434181d671099802992023-09-24 12:42:55149 days 20 hrs ago Clipper Exchange: Clipper CovesClipper Exchange: Pool0.04 ETH
0xb7b602d5aa7ecd305739cc707435a5d3b599c7ac158fef5e5361c1e4ae988f261099802812023-09-24 12:42:19149 days 20 hrs ago Clipper Exchange: Clipper CovesClipper Exchange: Pool0.01 ETH
[ Download CSV Export 
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
ClipperCove

Compiler Version
v0.8.4+commit.c7e474f2

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion
File 1 of 16 : ClipperCove.sol
//SPDX-License-Identifier: Copyright 2022 Shipyard Software, Inc.
pragma solidity ^0.8.0;

import "@openzeppelin/contracts/security/ReentrancyGuard.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "@openzeppelin/contracts/utils/math/SafeCast.sol";
import "@openzeppelin/contracts/access/Ownable.sol";

import "./ClipperCommonExchange.sol";
import "./libraries/Sqrt.sol";

contract ClipperCove is Ownable, ReentrancyGuard {
    using SafeERC20 for IERC20;
    using SafeCast for uint256;
    using Sqrt for uint256;

    mapping(address => uint256) public lastBalances;
    mapping(address => uint256) public totalDepositTokenSupply;
    mapping(address => mapping (address => uint256)) public depositTokenRegistry;

    address payable immutable public CLIPPER_EXCHANGE;
    address constant CLIPPER_ETH_SIGIL=address(0);

    uint256 constant ONE_IN_BASIS_POINTS = 10000;

    uint256 public totalClipperFees;
    uint256 public clipperFeeBps;
    uint256 public tradeFeeBps;

    event CoveSwapped(
        address indexed inAsset,
        address indexed outAsset,
        address indexed recipient,
        uint256 inAmount,
        uint256 outAmount,
        bytes32 auxiliaryData
    );

    event CoveDeposited(
        address indexed tokenAddress,
        address indexed depositor,
        uint256 poolTokens,
        uint256 poolTokensAfterDeposit
    );

    event CoveWithdrawn(
        address indexed tokenAddress,
        address indexed withdrawer,
        uint256 poolTokens,
        uint256 poolTokensAfterWithdrawal
    );

    constructor(address theExchange, uint256 tradeFee, uint256 clipperFee) {
        CLIPPER_EXCHANGE = payable(theExchange);
        tradeFeeBps = tradeFee;
        clipperFeeBps = clipperFee;
    }

    // Allows the receipt of ETH directly
    receive() external payable {
    }

    function changeFees(uint256 tradeFee, uint256 clipperFee) external onlyOwner {
        tradeFeeBps = tradeFee;
        clipperFeeBps = clipperFee;
    }

    function redeem() external onlyOwner returns (uint256 currentFees) {
        currentFees = totalClipperFees;
        totalClipperFees = 0;
        IERC20(CLIPPER_EXCHANGE).transfer(msg.sender, currentFees);
    }

    function pack256(uint256 x, uint256 y) internal pure returns (uint256 retval) {
        retval = y.toUint128();
        retval += (uint256(x.toUint128()) << 128);
    }

    function unpack256(uint256 packed) internal pure returns (uint256 x, uint256 y) {
        y = uint256(uint128(packed));
        x = packed >> 128;
    }

    function hasMarket(address token) public view returns (bool) {
        return totalDepositTokenSupply[token] > 0;
    }

    function canDeposit(address token) public view returns (bool) {
        return (token != CLIPPER_EXCHANGE) && (token != CLIPPER_ETH_SIGIL) && !ClipperCommonExchange(CLIPPER_EXCHANGE).isToken(token);
    }

    function tokenBalance(address token) internal view returns (uint256) {
        (bool success, bytes memory data) = token.staticcall(abi.encodeWithSelector(IERC20.balanceOf.selector, address(this)));
        require(success && data.length >= 32);
        return abi.decode(data, (uint256));
    }

    function invariant(uint256 x, uint256 y) internal pure returns (uint256){
        return (x*y).sqrt();
    }

    function lastLPAndToken(address token) internal view returns (uint256, uint256) {
        uint256 packedLPandToken = lastBalances[token];
        return unpack256(packedLPandToken);
    }

    function swapReturn(uint256 x, uint256 y, uint256 a, uint256 minBuyAmount) internal view returns (uint256 b) {
        require(a>0, "ClipperCove: No Input");
        uint256 adjA = ((ONE_IN_BASIS_POINTS-tradeFeeBps)*a)/ONE_IN_BASIS_POINTS;
        b = (adjA*y)/(adjA+x);
        if(b > y){
            b = y;
        }
        require(b>=minBuyAmount, "ClipperCove: Insufficient buy amount");
    }

    function shaveLPByFee(uint256 theLP) internal view returns (uint256) {
        return (theLP*(ONE_IN_BASIS_POINTS-clipperFeeBps))/ONE_IN_BASIS_POINTS;
    }

    function getSellQuote(address sellToken, uint256 sellAmount, address buyToken) public view returns (uint256) {
        bool _sellClipper = (sellToken==CLIPPER_EXCHANGE);
        bool _buyClipper = (buyToken==CLIPPER_EXCHANGE);
        (uint256 sellLP, uint256 sellTokenBalance) = lastLPAndToken(sellToken);
        (uint256 buyLP, uint256 buyTokenBalance) = lastLPAndToken(buyToken);

        if(!_sellClipper && !_buyClipper){
            require(hasMarket(sellToken) && hasMarket(buyToken), "ClipperCove: Not traded");
            uint256 outToBuyCove = swapReturn(sellTokenBalance, sellLP, sellAmount, 0);
            return swapReturn(buyLP, buyTokenBalance, outToBuyCove, 0);
        } else if(_sellClipper) {
            require(hasMarket(buyToken), "ClipperCove: Not traded");
            return swapReturn(buyLP, buyTokenBalance, sellAmount, 0);
        } else if(_buyClipper) {
            require(hasMarket(sellToken), "ClipperCove: Not traded");
            return swapReturn(sellTokenBalance, sellLP, sellAmount, 0);
        }
        return 0;
    }

    /*
        Three kinds of coins:
        1) "5" -> shorttail tokens traded on Clipper
        2) "ClipperLP" -> Clipper LP tokens
        3) N -> longtail tokens not on Clipper

        That means there are 8 swap operations (ClipperLP -> ClipperLP is no op)
        5 -> 5: Clipper swap, not handled here
        5 -> ClipperLP: Clipper deposit, not handled here
        5 -> N: depositForCoin function. One shot.
        ClipperLP -> 5: Clipper single-asset withdrawal, not handled here
        ClipperLP -> N: sellTokenForToken (single cove).
        N -> 5: Two txs, first do N -> ClipperLP here, then single-asset withdrawal
        N -> ClipperLP: sellTokenForToken (single cove).
        N -> N: sellTokenForToken (two coves)

    */

    function sellClipperForToken(address buyToken, uint256 sellAmount, uint256 minBuyAmount) internal returns (uint256 buyAmount) {
        require(hasMarket(buyToken), "ClipperCove: Not traded");
        (uint256 buyLP, uint256 buyTokenBalance) = lastLPAndToken(buyToken);

        buyAmount = swapReturn(buyLP, buyTokenBalance, sellAmount, minBuyAmount);
        lastBalances[buyToken] = pack256(buyLP+sellAmount, buyTokenBalance-buyAmount);
    }

    function sellTokenForClipper(address sellToken, uint256 sellAmount, uint256 minBuyAmount) internal returns (uint256 buyAmount) {
        require(hasMarket(sellToken), "ClipperCove: Not traded");
        (uint256 sellLP, uint256 sellTokenBalance) = lastLPAndToken(sellToken);

        buyAmount = swapReturn(sellTokenBalance, sellLP, sellAmount, minBuyAmount);
        lastBalances[sellToken] = pack256(sellLP-buyAmount, sellTokenBalance+sellAmount);
    }

    // Pull from msg.sender
    function transmitAndSellTokenForToken(address sellToken, uint256 sellAmount, address buyToken, uint256 minBuyAmount, address destinationAddress, bytes32 auxData) external nonReentrant returns (uint256 buyAmount) {
        bool _sellClipper = sellToken==CLIPPER_EXCHANGE;
        bool _buyClipper = buyToken==CLIPPER_EXCHANGE;
        
        IERC20(sellToken).safeTransferFrom(msg.sender, address(this), sellAmount);

        if(!_sellClipper && !_buyClipper){
            require(hasMarket(sellToken) && hasMarket(buyToken), "ClipperCove: Not traded");
            // Transfer sellToken from msg.sender to sellToken cove
            // Get LP token amount to move
            uint256 lpTokenOut;
            {
                (uint256 sellLP, uint256 sellTokenBalance) = lastLPAndToken(sellToken);
                lpTokenOut = swapReturn(sellTokenBalance, sellLP, sellAmount, 0);
                lastBalances[sellToken] = pack256(sellLP-lpTokenOut, sellTokenBalance+sellAmount);
            }

            (uint256 buyLP, uint256 buyTokenBalance) = lastLPAndToken(buyToken);
            buyAmount = swapReturn(buyLP, buyTokenBalance, lpTokenOut, minBuyAmount);
            lastBalances[buyToken] = pack256(buyLP+lpTokenOut, buyTokenBalance-buyAmount);
        } else if(_sellClipper) {
            buyAmount = sellClipperForToken(buyToken, sellAmount, minBuyAmount);
        } else if(_buyClipper) {
            buyAmount = sellTokenForClipper(sellToken, sellAmount, minBuyAmount);
        } else {
            revert();
        }
        IERC20(buyToken).safeTransfer(destinationAddress, buyAmount);

        emit CoveSwapped(sellToken, buyToken, destinationAddress, sellAmount, buyAmount, auxData);
    }

    // async, assumes sellToken has already been transferred
    // NB: sellToken cannot be Clipper LP token, since we don't track that balance
    function sellTokenForToken(address sellToken, address buyToken, uint256 minBuyAmount, address destinationAddress, bytes32 auxData) external nonReentrant returns (uint256 buyAmount){
        require(sellToken != CLIPPER_EXCHANGE, "ClipperCove: Not tradable async");
        
        (uint256 sellLP, uint256 lastTokenBalance) = lastLPAndToken(sellToken);
        uint256 _sellBalance = tokenBalance(sellToken);
        
        if(buyToken != CLIPPER_EXCHANGE){
            require(hasMarket(sellToken) && hasMarket(buyToken), "ClipperCove: Not traded");
            // Transfer sellToken from msg.sender to sellToken cove
            // Get LP token amount to move
            (uint256 buyLP, uint256 buyTokenBalance) = lastLPAndToken(buyToken);
            uint256 lpTokenOut = swapReturn(lastTokenBalance, sellLP, _sellBalance-lastTokenBalance, 0);
            buyAmount = swapReturn(buyLP, buyTokenBalance, lpTokenOut, minBuyAmount);
            
            // Update values:
            // Sell balances: [LP - lpTokenOut, token + sellToken]
            // Buy balances: [LP + lpTokenOut, token - buyAmount]
            lastBalances[sellToken] = pack256(sellLP-lpTokenOut, _sellBalance);
            lastBalances[buyToken] = pack256(buyLP+lpTokenOut, buyTokenBalance-buyAmount);
        } else {
            buyAmount = sellTokenForClipper(sellToken, _sellBalance-lastTokenBalance, minBuyAmount);
        }
        IERC20(buyToken).safeTransfer(destinationAddress, buyAmount);

        emit CoveSwapped(sellToken, buyToken, destinationAddress, _sellBalance-lastTokenBalance, buyAmount, auxData);
    }

    // Internal function to assist with deposits
    // Returns net amount deposited after fees
    // Use CLIPPER_ETH_SIGIL if depositing raw native token as msg.value
    function transferAndClipperDeposit(address clipperAsset, uint256 depositAmount, uint256 poolTokens, uint256 goodUntil, ClipperCommonExchange.Signature memory theSignature) internal returns (uint256 tokensAfterShave) {
        if(clipperAsset != CLIPPER_ETH_SIGIL){
            IERC20(clipperAsset).safeTransferFrom(msg.sender, CLIPPER_EXCHANGE, depositAmount);
        } else {
            clipperAsset = ClipperCommonExchange(CLIPPER_EXCHANGE).WRAPPER_CONTRACT();
        }
        ClipperCommonExchange(CLIPPER_EXCHANGE).depositSingleAsset{ value:msg.value }(address(this), clipperAsset, depositAmount, 0, poolTokens, goodUntil, theSignature);
        tokensAfterShave = shaveLPByFee(poolTokens);
        if(poolTokens > tokensAfterShave){
            totalClipperFees += poolTokens-tokensAfterShave;
        }
    }

    // One-shot 5 -> N swap. Clipper fees get charged.
    function depositForCoin(address buyToken, uint256 minBuyAmount, address clipperAsset, uint256 depositAmount, uint256 poolTokens, uint256 goodUntil, ClipperCommonExchange.Signature calldata theSignature, bytes32 auxData) external payable nonReentrant returns (uint256 buyAmount) {
        uint256 netDepositedTokens = transferAndClipperDeposit(clipperAsset, depositAmount, poolTokens, goodUntil, theSignature);
        
        buyAmount = sellClipperForToken(buyToken, netDepositedTokens, minBuyAmount);

        IERC20(buyToken).safeTransfer(msg.sender, buyAmount);
        emit CoveSwapped(clipperAsset, buyToken, msg.sender, depositAmount, buyAmount, auxData);
    }

    function _mint(address coin, address user, uint256 amount) internal {
        depositTokenRegistry[coin][user] += amount;
        totalDepositTokenSupply[coin] += amount;
    }

    function _burn(address coin, address user, uint256 amount) internal {
        // reverts on underflow
        require(depositTokenRegistry[coin][user] >= amount, "ClipperCove: Burn amount exceeds user balance");
        unchecked {
            depositTokenRegistry[coin][user] -= amount;
        }
        totalDepositTokenSupply[coin] -= amount;
    }

    function _mintHandler(address coin, uint256 nextInvariant, uint256 lastInvariant) internal returns (uint256 toMint) {
        if(lastInvariant > 0){
            uint256 lastSupply = totalDepositTokenSupply[coin];
            toMint = ((nextInvariant - lastInvariant)*lastSupply)/lastInvariant;
        } else {
            toMint = 1e8 * nextInvariant;
        }
        // Mint coins for msg.sender
        _mint(coin, msg.sender, toMint);
        emit CoveDeposited(coin, msg.sender, toMint, totalDepositTokenSupply[coin]);
    }

    // Pulls from msg.sender. Can omit deposit of either Clipper or Coin
    function transmitAndDeposit(address coin, uint256 coinDepositAmount, address clipperAsset, uint256 clipperDepositAmount, uint256 poolTokens, uint256 goodUntil, ClipperCommonExchange.Signature calldata theSignature) external payable nonReentrant returns (uint256) {
        require(canDeposit(coin), "ClipperCove: Cannot deposit");

        (uint256 lastLP, uint256 lastToken) = lastLPAndToken(coin);
        uint256 lastInvariant = invariant(lastLP, lastToken);

        uint256 netDepositedTokens = 0;
        if(clipperDepositAmount>0 && poolTokens>0){
            netDepositedTokens = transferAndClipperDeposit(clipperAsset, clipperDepositAmount, poolTokens, goodUntil, theSignature);
        }
        // Transfer coins to the cove, if relevant
        if(coinDepositAmount > 0){
            IERC20(coin).safeTransferFrom(msg.sender, address(this), coinDepositAmount);            
        }
        /* Deleted for local stack...
        uint256 nextLP = lastLP + netDepositedTokens;
        uint256 nextToken = lastToken + coinDepositAmount;
        */

        uint256 nextInvariant = invariant(lastLP + netDepositedTokens, lastToken + coinDepositAmount);
        require(nextInvariant > lastInvariant);
        // Update balances
        lastBalances[coin] = pack256(lastLP + netDepositedTokens, lastToken + coinDepositAmount);
        return _mintHandler(coin, nextInvariant, lastInvariant);
    }

    // Burn to Withdraw
    function burnToWithdraw(address coin, uint256 tokenAmount) external nonReentrant {
        require(hasMarket(coin), "ClipperCove: Not traded");
        uint256 fractionBurntInDefaultDecimals = (tokenAmount*(1 ether))/totalDepositTokenSupply[coin];
        _burn(coin, msg.sender, tokenAmount);
        (uint256 lastLP, uint256 lastToken) = lastLPAndToken(coin);
        uint256 lpToSend = (fractionBurntInDefaultDecimals*lastLP)/(1 ether);
        uint256 tokenToSend = (fractionBurntInDefaultDecimals*lastToken)/(1 ether);

        lastBalances[coin] = pack256(lastLP - lpToSend, lastToken - tokenToSend);
        IERC20(CLIPPER_EXCHANGE).safeTransfer(msg.sender, lpToSend);
        IERC20(coin).safeTransfer(msg.sender, tokenToSend);

        emit CoveWithdrawn(coin, msg.sender, tokenAmount, totalDepositTokenSupply[coin]);
    }

}

File 2 of 16 : ReentrancyGuard.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (security/ReentrancyGuard.sol)

pragma solidity ^0.8.0;

/**
 * @dev Contract module that helps prevent reentrant calls to a function.
 *
 * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
 * available, which can be applied to functions to make sure there are no nested
 * (reentrant) calls to them.
 *
 * Note that because there is a single `nonReentrant` guard, functions marked as
 * `nonReentrant` may not call one another. This can be worked around by making
 * those functions `private`, and then adding `external` `nonReentrant` entry
 * points to them.
 *
 * TIP: If you would like to learn more about reentrancy and alternative ways
 * to protect against it, check out our blog post
 * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
 */
abstract contract ReentrancyGuard {
    // Booleans are more expensive than uint256 or any type that takes up a full
    // word because each write operation emits an extra SLOAD to first read the
    // slot's contents, replace the bits taken up by the boolean, and then write
    // back. This is the compiler's defense against contract upgrades and
    // pointer aliasing, and it cannot be disabled.

    // The values being non-zero value makes deployment a bit more expensive,
    // but in exchange the refund on every call to nonReentrant will be lower in
    // amount. Since refunds are capped to a percentage of the total
    // transaction's gas, it is best to keep them low in cases like this one, to
    // increase the likelihood of the full refund coming into effect.
    uint256 private constant _NOT_ENTERED = 1;
    uint256 private constant _ENTERED = 2;

    uint256 private _status;

    constructor() {
        _status = _NOT_ENTERED;
    }

    /**
     * @dev Prevents a contract from calling itself, directly or indirectly.
     * Calling a `nonReentrant` function from another `nonReentrant`
     * function is not supported. It is possible to prevent this from happening
     * by making the `nonReentrant` function external, and making it call a
     * `private` function that does the actual work.
     */
    modifier nonReentrant() {
        // On the first call to nonReentrant, _notEntered will be true
        require(_status != _ENTERED, "ReentrancyGuard: reentrant call");

        // Any calls to nonReentrant after this point will fail
        _status = _ENTERED;

        _;

        // By storing the original value once again, a refund is triggered (see
        // https://eips.ethereum.org/EIPS/eip-2200)
        _status = _NOT_ENTERED;
    }
}

File 3 of 16 : IERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/IERC20.sol)

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 4 of 16 : SafeERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/utils/SafeERC20.sol)

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 5 of 16 : SafeCast.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/math/SafeCast.sol)

pragma solidity ^0.8.0;

/**
 * @dev Wrappers over Solidity's uintXX/intXX casting operators with added overflow
 * checks.
 *
 * Downcasting from uint256/int256 in Solidity does not revert on overflow. This can
 * easily result in undesired exploitation or bugs, since developers usually
 * assume that overflows raise errors. `SafeCast` restores this intuition by
 * reverting the transaction when such an operation overflows.
 *
 * Using this library instead of the unchecked operations eliminates an entire
 * class of bugs, so it's recommended to use it always.
 *
 * Can be combined with {SafeMath} and {SignedSafeMath} to extend it to smaller types, by performing
 * all math on `uint256` and `int256` and then downcasting.
 */
library SafeCast {
    /**
     * @dev Returns the downcasted uint224 from uint256, reverting on
     * overflow (when the input is greater than largest uint224).
     *
     * Counterpart to Solidity's `uint224` operator.
     *
     * Requirements:
     *
     * - input must fit into 224 bits
     */
    function toUint224(uint256 value) internal pure returns (uint224) {
        require(value <= type(uint224).max, "SafeCast: value doesn't fit in 224 bits");
        return uint224(value);
    }

    /**
     * @dev Returns the downcasted uint128 from uint256, reverting on
     * overflow (when the input is greater than largest uint128).
     *
     * Counterpart to Solidity's `uint128` operator.
     *
     * Requirements:
     *
     * - input must fit into 128 bits
     */
    function toUint128(uint256 value) internal pure returns (uint128) {
        require(value <= type(uint128).max, "SafeCast: value doesn't fit in 128 bits");
        return uint128(value);
    }

    /**
     * @dev Returns the downcasted uint96 from uint256, reverting on
     * overflow (when the input is greater than largest uint96).
     *
     * Counterpart to Solidity's `uint96` operator.
     *
     * Requirements:
     *
     * - input must fit into 96 bits
     */
    function toUint96(uint256 value) internal pure returns (uint96) {
        require(value <= type(uint96).max, "SafeCast: value doesn't fit in 96 bits");
        return uint96(value);
    }

    /**
     * @dev Returns the downcasted uint64 from uint256, reverting on
     * overflow (when the input is greater than largest uint64).
     *
     * Counterpart to Solidity's `uint64` operator.
     *
     * Requirements:
     *
     * - input must fit into 64 bits
     */
    function toUint64(uint256 value) internal pure returns (uint64) {
        require(value <= type(uint64).max, "SafeCast: value doesn't fit in 64 bits");
        return uint64(value);
    }

    /**
     * @dev Returns the downcasted uint32 from uint256, reverting on
     * overflow (when the input is greater than largest uint32).
     *
     * Counterpart to Solidity's `uint32` operator.
     *
     * Requirements:
     *
     * - input must fit into 32 bits
     */
    function toUint32(uint256 value) internal pure returns (uint32) {
        require(value <= type(uint32).max, "SafeCast: value doesn't fit in 32 bits");
        return uint32(value);
    }

    /**
     * @dev Returns the downcasted uint16 from uint256, reverting on
     * overflow (when the input is greater than largest uint16).
     *
     * Counterpart to Solidity's `uint16` operator.
     *
     * Requirements:
     *
     * - input must fit into 16 bits
     */
    function toUint16(uint256 value) internal pure returns (uint16) {
        require(value <= type(uint16).max, "SafeCast: value doesn't fit in 16 bits");
        return uint16(value);
    }

    /**
     * @dev Returns the downcasted uint8 from uint256, reverting on
     * overflow (when the input is greater than largest uint8).
     *
     * Counterpart to Solidity's `uint8` operator.
     *
     * Requirements:
     *
     * - input must fit into 8 bits.
     */
    function toUint8(uint256 value) internal pure returns (uint8) {
        require(value <= type(uint8).max, "SafeCast: value doesn't fit in 8 bits");
        return uint8(value);
    }

    /**
     * @dev Converts a signed int256 into an unsigned uint256.
     *
     * Requirements:
     *
     * - input must be greater than or equal to 0.
     */
    function toUint256(int256 value) internal pure returns (uint256) {
        require(value >= 0, "SafeCast: value must be positive");
        return uint256(value);
    }

    /**
     * @dev Returns the downcasted int128 from int256, reverting on
     * overflow (when the input is less than smallest int128 or
     * greater than largest int128).
     *
     * Counterpart to Solidity's `int128` operator.
     *
     * Requirements:
     *
     * - input must fit into 128 bits
     *
     * _Available since v3.1._
     */
    function toInt128(int256 value) internal pure returns (int128) {
        require(value >= type(int128).min && value <= type(int128).max, "SafeCast: value doesn't fit in 128 bits");
        return int128(value);
    }

    /**
     * @dev Returns the downcasted int64 from int256, reverting on
     * overflow (when the input is less than smallest int64 or
     * greater than largest int64).
     *
     * Counterpart to Solidity's `int64` operator.
     *
     * Requirements:
     *
     * - input must fit into 64 bits
     *
     * _Available since v3.1._
     */
    function toInt64(int256 value) internal pure returns (int64) {
        require(value >= type(int64).min && value <= type(int64).max, "SafeCast: value doesn't fit in 64 bits");
        return int64(value);
    }

    /**
     * @dev Returns the downcasted int32 from int256, reverting on
     * overflow (when the input is less than smallest int32 or
     * greater than largest int32).
     *
     * Counterpart to Solidity's `int32` operator.
     *
     * Requirements:
     *
     * - input must fit into 32 bits
     *
     * _Available since v3.1._
     */
    function toInt32(int256 value) internal pure returns (int32) {
        require(value >= type(int32).min && value <= type(int32).max, "SafeCast: value doesn't fit in 32 bits");
        return int32(value);
    }

    /**
     * @dev Returns the downcasted int16 from int256, reverting on
     * overflow (when the input is less than smallest int16 or
     * greater than largest int16).
     *
     * Counterpart to Solidity's `int16` operator.
     *
     * Requirements:
     *
     * - input must fit into 16 bits
     *
     * _Available since v3.1._
     */
    function toInt16(int256 value) internal pure returns (int16) {
        require(value >= type(int16).min && value <= type(int16).max, "SafeCast: value doesn't fit in 16 bits");
        return int16(value);
    }

    /**
     * @dev Returns the downcasted int8 from int256, reverting on
     * overflow (when the input is less than smallest int8 or
     * greater than largest int8).
     *
     * Counterpart to Solidity's `int8` operator.
     *
     * Requirements:
     *
     * - input must fit into 8 bits.
     *
     * _Available since v3.1._
     */
    function toInt8(int256 value) internal pure returns (int8) {
        require(value >= type(int8).min && value <= type(int8).max, "SafeCast: value doesn't fit in 8 bits");
        return int8(value);
    }

    /**
     * @dev Converts an unsigned uint256 into a signed int256.
     *
     * Requirements:
     *
     * - input must be less than or equal to maxInt256.
     */
    function toInt256(uint256 value) internal pure returns (int256) {
        // Note: Unsafe cast below is okay because `type(int256).max` is guaranteed to be positive
        require(value <= uint256(type(int256).max), "SafeCast: value doesn't fit in an int256");
        return int256(value);
    }
}

File 6 of 16 : Ownable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (access/Ownable.sol)

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() {
        _transferOwnership(_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 {
        _transferOwnership(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");
        _transferOwnership(newOwner);
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Internal function without access restriction.
     */
    function _transferOwnership(address newOwner) internal virtual {
        address oldOwner = _owner;
        _owner = newOwner;
        emit OwnershipTransferred(oldOwner, newOwner);
    }
}

File 7 of 16 : ClipperCommonExchange.sol
//SPDX-License-Identifier: Copyright 2021 Shipyard Software, Inc.
pragma solidity ^0.8.0;


import "@openzeppelin/contracts/security/ReentrancyGuard.sol";
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";
import "@openzeppelin/contracts/utils/structs/EnumerableSet.sol";

import "./interfaces/WrapperContractInterface.sol";

abstract contract ClipperCommonExchange is ERC20, ReentrancyGuard {

  using SafeERC20 for IERC20;
  using EnumerableSet for EnumerableSet.AddressSet;

  struct Signature {
    uint8 v;
    bytes32 r;
    bytes32 s;
  }

  struct Deposit {
      uint lockedUntil;
      uint256 poolTokenAmount;
  }

  uint256 constant ONE_IN_TEN_DECIMALS = 1e10;
  // Allow for inputs up to 0.5% more than quoted values to have scaled output.
  // Inputs higher than this value just get 0.5% more.
  uint256 constant MAX_ALLOWED_OVER_TEN_DECIMALS = ONE_IN_TEN_DECIMALS+50*1e6;

  // Signer is passed in on construction, hence "immutable"
  address immutable public DESIGNATED_SIGNER;
  address immutable public WRAPPER_CONTRACT;
  // Constant values for EIP-712 signing
  bytes32 immutable DOMAIN_SEPARATOR;
  string constant VERSION = "1.0.0";
  string constant NAME = "ClipperDirect";

  address constant CLIPPER_ETH_SIGIL = address(0);

  bytes32 constant EIP712DOMAIN_TYPEHASH = keccak256(
     abi.encodePacked("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)")
  );

  bytes32 constant OFFERSTRUCT_TYPEHASH = keccak256(
    abi.encodePacked("OfferStruct(address input_token,address output_token,uint256 input_amount,uint256 output_amount,uint256 good_until,address destination_address)")
  );

  bytes32 constant DEPOSITSTRUCT_TYPEHASH = keccak256(
    abi.encodePacked("DepositStruct(address sender,uint256[] deposit_amounts,uint256 days_locked,uint256 pool_tokens,uint256 good_until)")
  );

  bytes32 constant SINGLEDEPOSITSTRUCT_TYPEHASH = keccak256(
    abi.encodePacked("SingleDepositStruct(address sender,address token,uint256 amount,uint256 days_locked,uint256 pool_tokens,uint256 good_until)")
  );

  bytes32 constant WITHDRAWALSTRUCT_TYPEHASH = keccak256(
    abi.encodePacked("WithdrawalStruct(address token_holder,uint256 pool_token_amount_to_burn,address asset_address,uint256 asset_amount,uint256 good_until)")
  );

  // Assets
  // lastBalances: used for "transmit then swap then sync" modality
  // assetSet is a set of keys that have lastBalances
  mapping(address => uint256) public lastBalances;
  EnumerableSet.AddressSet assetSet;


  // Allows lookup
  mapping(address => Deposit) public vestingDeposits;

  // Events
  event Swapped(
    address indexed inAsset,
    address indexed outAsset,
    address indexed recipient,
    uint256 inAmount,
    uint256 outAmount,
    bytes auxiliaryData
  );

  event Deposited(
    address indexed depositor,
    uint256 poolTokens,
    uint256 nDays
  );

  event Withdrawn(
    address indexed withdrawer,
    uint256 poolTokens,
    uint256 fractionOfPool
  );

  event AssetWithdrawn(
    address indexed withdrawer,
    uint256 poolTokens,    
    address indexed assetAddress,
    uint256 assetAmount
  );

  // Take in the designated signer address and the token list
  constructor(address theSigner, address theWrapper, address[] memory tokens) ERC20("ClipperDirect Pool Token", "CLPRDRPL") {
    DESIGNATED_SIGNER = theSigner;
    uint i;
    uint n = tokens.length;
    while(i < n) {
        assetSet.add(tokens[i]);
        i++;
    }
    DOMAIN_SEPARATOR = createDomainSeparator(NAME, VERSION, address(this));
    WRAPPER_CONTRACT = theWrapper;
  }

  // Allows the receipt of ETH directly
  receive() external payable {
  }

  function safeEthSend(address recipient, uint256 howMuch) internal {
    (bool success, ) = payable(recipient).call{value: howMuch}("");
    require(success, "Call with value failed");
  }

  /* TOKEN AND ASSET FUNCTIONS */
  function nTokens() public view returns (uint) {
    return assetSet.length();
  }

  function tokenAt(uint i) public view returns (address) {
    return assetSet.at(i);
  }

  function isToken(address token) public view returns (bool) {
    return assetSet.contains(token);
  }

  function _sync(address token) internal virtual;

  // Can be overridden as in Caravel
  function getLastBalance(address token) public view virtual returns (uint256) {
    return lastBalances[token];
  }

  function allTokensBalance() external view returns (uint256[] memory, address[] memory, uint256){
    uint n = nTokens();
    uint256[] memory balances = new uint256[](n);
    address[] memory tokens = new address[](n);
    for (uint i = 0; i < n; i++) {
      address token = tokenAt(i);
      balances[i] = getLastBalance(token);
      tokens[i] = token;
    }

    return (balances, tokens, totalSupply());
  }

  // nonReentrant asset transfer
  function transferAsset(address token, address recipient, uint256 amount) internal nonReentrant {
    IERC20(token).safeTransfer(recipient, amount);
    // We never want to transfer an asset without sync'ing
    _sync(token);
  }

  function calculateFairOutput(uint256 statedInput, uint256 actualInput, uint256 statedOutput) internal pure returns (uint256) {
    if(actualInput == statedInput) {
      return statedOutput;
    } else {
      uint256 theFraction = (ONE_IN_TEN_DECIMALS*actualInput)/statedInput;
      if(theFraction >= MAX_ALLOWED_OVER_TEN_DECIMALS) {
        return (MAX_ALLOWED_OVER_TEN_DECIMALS*statedOutput)/ONE_IN_TEN_DECIMALS;
      } else {
        return (theFraction*statedOutput)/ONE_IN_TEN_DECIMALS;
      }
    }
  }

  /* DEPOSIT FUNCTIONALITY */
  function canUnlockDeposit(address theAddress) public view returns (bool) {
      Deposit storage myDeposit = vestingDeposits[theAddress];
      return (myDeposit.poolTokenAmount > 0) && (myDeposit.lockedUntil <= block.timestamp);
  }

  function unlockDeposit() external returns (uint256 poolTokens) {
    require(canUnlockDeposit(msg.sender), "ClipperDirect: Deposit cannot be unlocked");
    poolTokens = vestingDeposits[msg.sender].poolTokenAmount;
    delete vestingDeposits[msg.sender];

    _transfer(address(this), msg.sender, poolTokens);
  }

  function _mintOrVesting(address sender, uint256 nDays, uint256 poolTokens) internal {
    if(nDays==0){
      // No vesting period required - mint tokens directly for the user
      _mint(sender, poolTokens);
    } else {
      // Set up a vesting deposit for the sender
      _createVestingDeposit(sender, nDays, poolTokens);
    }
  }

  // Mints tokens to this contract to hold for vesting
  function _createVestingDeposit(address theAddress, uint256 nDays, uint256 numPoolTokens) internal {
    require(nDays > 0, "ClipperDirect: Cannot create vesting deposit without positive vesting period");
    require(vestingDeposits[theAddress].poolTokenAmount==0, "ClipperDirect: Depositor already has an active deposit");

    Deposit memory myDeposit = Deposit({
      lockedUntil: block.timestamp + (nDays * 1 days),
      poolTokenAmount: numPoolTokens
    });
    vestingDeposits[theAddress] = myDeposit;
    _mint(address(this), numPoolTokens);
  }

  function transmitAndDeposit(uint256[] calldata depositAmounts, uint256 nDays, uint256 poolTokens, uint256 goodUntil, Signature calldata theSignature) external {
    uint i=0;
    uint n = depositAmounts.length;
    while(i < n){
      uint256 transferAmount = depositAmounts[i];
      if(transferAmount > 0){
        IERC20(tokenAt(i)).safeTransferFrom(msg.sender, address(this), transferAmount);
      }
      i++;
    }
    deposit(msg.sender, depositAmounts, nDays, poolTokens, goodUntil, theSignature);
  }

  function transmitAndDepositSingleAsset(address inputToken, uint256 inputAmount, uint256 nDays, uint256 poolTokens, uint256 goodUntil, Signature calldata theSignature) external virtual;

  function deposit(address sender, uint256[] calldata depositAmounts, uint256 nDays, uint256 poolTokens, uint256 goodUntil, Signature calldata theSignature) public payable virtual;

  function depositSingleAsset(address sender, address inputToken, uint256 inputAmount, uint256 nDays, uint256 poolTokens, uint256 goodUntil, Signature calldata theSignature) public payable virtual;

  /* WITHDRAWAL FUNCTIONALITY */
  function _proportionalWithdrawal(uint256 myFraction) internal {
    uint256 toTransfer;

    uint i;
    uint n = nTokens();
    while(i < n) {
        address theToken = tokenAt(i);
        toTransfer = (myFraction*getLastBalance(theToken)) / ONE_IN_TEN_DECIMALS;
        // syncs done automatically on transfer
        transferAsset(theToken, msg.sender, toTransfer);
        i++;
    }
  }

  function burnToWithdraw(uint256 amount) external {
    // Capture the fraction first, before burning
    uint256 theFractionBaseTen = (ONE_IN_TEN_DECIMALS*amount)/totalSupply();
    
    // Reverts if balance is insufficient
    _burn(msg.sender, amount);

    _proportionalWithdrawal(theFractionBaseTen);
    emit Withdrawn(msg.sender, amount, theFractionBaseTen);
  }

  function withdrawSingleAsset(address tokenHolder, uint256 poolTokenAmountToBurn, address assetAddress, uint256 assetAmount, uint256 goodUntil, Signature calldata theSignature) external virtual;

  /* SWAP Functionality: Virtual */
  function sellEthForToken(address outputToken, uint256 inputAmount, uint256 outputAmount, uint256 goodUntil, address destinationAddress, Signature calldata theSignature, bytes calldata auxiliaryData) external payable virtual;
  function sellTokenForEth(address inputToken, uint256 inputAmount, uint256 outputAmount, uint256 goodUntil, address destinationAddress, Signature calldata theSignature, bytes calldata auxiliaryData) external virtual;
  function transmitAndSellTokenForEth(address inputToken, uint256 inputAmount, uint256 outputAmount, uint256 goodUntil, address destinationAddress, Signature calldata theSignature, bytes calldata auxiliaryData) external virtual;
  function transmitAndSwap(address inputToken, address outputToken, uint256 inputAmount, uint256 outputAmount, uint256 goodUntil, address destinationAddress, Signature calldata theSignature, bytes calldata auxiliaryData) external virtual;
  function swap(address inputToken, address outputToken, uint256 inputAmount, uint256 outputAmount, uint256 goodUntil, address destinationAddress, Signature calldata theSignature, bytes calldata auxiliaryData) public virtual;

  /* SIGNING Functionality */
  function createDomainSeparator(string memory name, string memory version, address theSigner) internal view returns (bytes32) {
    return keccak256(abi.encode(
        EIP712DOMAIN_TYPEHASH,
        keccak256(abi.encodePacked(name)),
        keccak256(abi.encodePacked(version)),
        uint256(block.chainid),
        theSigner
      ));
  }

  function hashInputOffer(address inputToken, address outputToken, uint256 inputAmount, uint256 outputAmount, uint256 goodUntil, address destinationAddress) internal pure returns (bytes32) {
    return keccak256(abi.encode(
            OFFERSTRUCT_TYPEHASH,
            inputToken,
            outputToken,
            inputAmount,
            outputAmount,
            goodUntil,
            destinationAddress
        ));
  }

  function hashDeposit(address sender, uint256[] calldata depositAmounts, uint256 daysLocked, uint256 poolTokens, uint256 goodUntil) internal pure returns (bytes32) {
    bytes32 depositAmountsHash = keccak256(abi.encodePacked(depositAmounts));
    return keccak256(abi.encode(
        DEPOSITSTRUCT_TYPEHASH,
        sender,
        depositAmountsHash,
        daysLocked,
        poolTokens,
        goodUntil
      ));
  }

  function hashSingleDeposit(address sender, address inputToken, uint256 inputAmount, uint256 daysLocked, uint256 poolTokens, uint256 goodUntil) internal pure returns (bytes32) {
    return keccak256(abi.encode(
        SINGLEDEPOSITSTRUCT_TYPEHASH,
        sender,
        inputToken,
        inputAmount,
        daysLocked,
        poolTokens,
        goodUntil
      ));
  }

  function hashWithdrawal(address tokenHolder, uint256 poolTokenAmountToBurn, address assetAddress, uint256 assetAmount,
                    uint256 goodUntil) internal pure returns (bytes32) {
    return keccak256(abi.encode(
        WITHDRAWALSTRUCT_TYPEHASH,
        tokenHolder,
        poolTokenAmountToBurn,
        assetAddress,
        assetAmount,
        goodUntil
      ));
  }

  function createSwapDigest(address inputToken, address outputToken, uint256 inputAmount, uint256 outputAmount, uint256 goodUntil, address destinationAddress) internal view returns (bytes32 digest){
    bytes32 hashedInput = hashInputOffer(inputToken, outputToken, inputAmount, outputAmount, goodUntil, destinationAddress);    
    digest = ECDSA.toTypedDataHash(DOMAIN_SEPARATOR, hashedInput);
  }

  function createDepositDigest(address sender, uint256[] calldata depositAmounts, uint256 nDays, uint256 poolTokens, uint256 goodUntil) internal view returns (bytes32 depositDigest){
    bytes32 hashedInput = hashDeposit(sender, depositAmounts, nDays, poolTokens, goodUntil);    
    depositDigest = ECDSA.toTypedDataHash(DOMAIN_SEPARATOR, hashedInput);
  }

  function createSingleDepositDigest(address sender, address inputToken, uint256 inputAmount, uint256 nDays, uint256 poolTokens, uint256 goodUntil) internal view returns (bytes32 depositDigest){
    bytes32 hashedInput = hashSingleDeposit(sender, inputToken, inputAmount, nDays, poolTokens, goodUntil);
    depositDigest = ECDSA.toTypedDataHash(DOMAIN_SEPARATOR, hashedInput);
  }

  function createWithdrawalDigest(address tokenHolder, uint256 poolTokenAmountToBurn, address assetAddress, uint256 assetAmount,
                    uint256 goodUntil) internal view returns (bytes32 withdrawalDigest){
    bytes32 hashedInput = hashWithdrawal(tokenHolder, poolTokenAmountToBurn, assetAddress, assetAmount, goodUntil);
    withdrawalDigest = ECDSA.toTypedDataHash(DOMAIN_SEPARATOR, hashedInput);
  }

  function verifyDigestSignature(bytes32 theDigest, Signature calldata theSignature) internal view {
    address signingAddress = ecrecover(theDigest, theSignature.v, theSignature.r, theSignature.s);

    require(signingAddress==DESIGNATED_SIGNER, "Message signed by incorrect address");
  }

}

File 8 of 16 : Sqrt.sol
// SPDX-License-Identifier: Business Source License 1.1 see LICENSE.txt
pragma solidity ^0.8.0;

// Optimized sqrt library originally based on code from Uniswap v2
library Sqrt {
    // y is the number to sqrt
    // x MUST BE > int(sqrt(y)). This is NOT CHECKED.
    function sqrt(uint256 y, uint256 x) internal pure returns (uint256) {
        unchecked {
            uint256 z = y;
            while (x < z) {
                z = x;
                x = (y / x + x) >> 1;
            }
            return z;
        }
    }

    function sqrt(uint256 y) internal pure returns (uint256) {
        unchecked {
            uint256 x = y / 6e17;
            if(y <= 37e34){
                x = y/2 +1;
            }
            return sqrt(y,x); 
        }
    }
}

File 9 of 16 : Address.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Address.sol)

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 10 of 16 : Context.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)

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 11 of 16 : ERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/ERC20.sol)

pragma solidity ^0.8.0;

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

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

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

    uint256 private _totalSupply;

    string private _name;
    string private _symbol;

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

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

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

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

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

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

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

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

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

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

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

        return true;
    }

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

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

        return true;
    }

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

        _beforeTokenTransfer(sender, recipient, amount);

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

        emit Transfer(sender, recipient, amount);

        _afterTokenTransfer(sender, recipient, amount);
    }

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

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

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

        _afterTokenTransfer(address(0), account, amount);
    }

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

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

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

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

        _afterTokenTransfer(account, address(0), amount);
    }

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

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

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

    /**
     * @dev Hook that is called after any transfer of tokens. This includes
     * minting and burning.
     *
     * Calling conditions:
     *
     * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
     * has been transferred to `to`.
     * - when `from` is zero, `amount` tokens have been minted for `to`.
     * - when `to` is zero, `amount` of ``from``'s tokens have been 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 _afterTokenTransfer(
        address from,
        address to,
        uint256 amount
    ) internal virtual {}
}

File 12 of 16 : ECDSA.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/cryptography/ECDSA.sol)

pragma solidity ^0.8.0;

import "../Strings.sol";

/**
 * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations.
 *
 * These functions can be used to verify that a message was signed by the holder
 * of the private keys of a given address.
 */
library ECDSA {
    enum RecoverError {
        NoError,
        InvalidSignature,
        InvalidSignatureLength,
        InvalidSignatureS,
        InvalidSignatureV
    }

    function _throwError(RecoverError error) private pure {
        if (error == RecoverError.NoError) {
            return; // no error: do nothing
        } else if (error == RecoverError.InvalidSignature) {
            revert("ECDSA: invalid signature");
        } else if (error == RecoverError.InvalidSignatureLength) {
            revert("ECDSA: invalid signature length");
        } else if (error == RecoverError.InvalidSignatureS) {
            revert("ECDSA: invalid signature 's' value");
        } else if (error == RecoverError.InvalidSignatureV) {
            revert("ECDSA: invalid signature 'v' value");
        }
    }

    /**
     * @dev Returns the address that signed a hashed message (`hash`) with
     * `signature` or error string. This address can then be used for verification purposes.
     *
     * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:
     * this function rejects them by requiring the `s` value to be in the lower
     * half order, and the `v` value to be either 27 or 28.
     *
     * IMPORTANT: `hash` _must_ be the result of a hash operation for the
     * verification to be secure: it is possible to craft signatures that
     * recover to arbitrary addresses for non-hashed data. A safe way to ensure
     * this is by receiving a hash of the original message (which may otherwise
     * be too long), and then calling {toEthSignedMessageHash} on it.
     *
     * Documentation for signature generation:
     * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js]
     * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers]
     *
     * _Available since v4.3._
     */
    function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) {
        // Check the signature length
        // - case 65: r,s,v signature (standard)
        // - case 64: r,vs signature (cf https://eips.ethereum.org/EIPS/eip-2098) _Available since v4.1._
        if (signature.length == 65) {
            bytes32 r;
            bytes32 s;
            uint8 v;
            // ecrecover takes the signature parameters, and the only way to get them
            // currently is to use assembly.
            assembly {
                r := mload(add(signature, 0x20))
                s := mload(add(signature, 0x40))
                v := byte(0, mload(add(signature, 0x60)))
            }
            return tryRecover(hash, v, r, s);
        } else if (signature.length == 64) {
            bytes32 r;
            bytes32 vs;
            // ecrecover takes the signature parameters, and the only way to get them
            // currently is to use assembly.
            assembly {
                r := mload(add(signature, 0x20))
                vs := mload(add(signature, 0x40))
            }
            return tryRecover(hash, r, vs);
        } else {
            return (address(0), RecoverError.InvalidSignatureLength);
        }
    }

    /**
     * @dev Returns the address that signed a hashed message (`hash`) with
     * `signature`. This address can then be used for verification purposes.
     *
     * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:
     * this function rejects them by requiring the `s` value to be in the lower
     * half order, and the `v` value to be either 27 or 28.
     *
     * IMPORTANT: `hash` _must_ be the result of a hash operation for the
     * verification to be secure: it is possible to craft signatures that
     * recover to arbitrary addresses for non-hashed data. A safe way to ensure
     * this is by receiving a hash of the original message (which may otherwise
     * be too long), and then calling {toEthSignedMessageHash} on it.
     */
    function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {
        (address recovered, RecoverError error) = tryRecover(hash, signature);
        _throwError(error);
        return recovered;
    }

    /**
     * @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately.
     *
     * See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures]
     *
     * _Available since v4.3._
     */
    function tryRecover(
        bytes32 hash,
        bytes32 r,
        bytes32 vs
    ) internal pure returns (address, RecoverError) {
        bytes32 s;
        uint8 v;
        assembly {
            s := and(vs, 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
            v := add(shr(255, vs), 27)
        }
        return tryRecover(hash, v, r, s);
    }

    /**
     * @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately.
     *
     * _Available since v4.2._
     */
    function recover(
        bytes32 hash,
        bytes32 r,
        bytes32 vs
    ) internal pure returns (address) {
        (address recovered, RecoverError error) = tryRecover(hash, r, vs);
        _throwError(error);
        return recovered;
    }

    /**
     * @dev Overload of {ECDSA-tryRecover} that receives the `v`,
     * `r` and `s` signature fields separately.
     *
     * _Available since v4.3._
     */
    function tryRecover(
        bytes32 hash,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) internal pure returns (address, RecoverError) {
        // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature
        // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines
        // the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most
        // signatures from current libraries generate a unique signature with an s-value in the lower half order.
        //
        // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value
        // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or
        // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept
        // these malleable signatures as well.
        if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {
            return (address(0), RecoverError.InvalidSignatureS);
        }
        if (v != 27 && v != 28) {
            return (address(0), RecoverError.InvalidSignatureV);
        }

        // If the signature is valid (and not malleable), return the signer address
        address signer = ecrecover(hash, v, r, s);
        if (signer == address(0)) {
            return (address(0), RecoverError.InvalidSignature);
        }

        return (signer, RecoverError.NoError);
    }

    /**
     * @dev Overload of {ECDSA-recover} that receives the `v`,
     * `r` and `s` signature fields separately.
     */
    function recover(
        bytes32 hash,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) internal pure returns (address) {
        (address recovered, RecoverError error) = tryRecover(hash, v, r, s);
        _throwError(error);
        return recovered;
    }

    /**
     * @dev Returns an Ethereum Signed Message, created from a `hash`. This
     * produces hash corresponding to the one signed with the
     * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]
     * JSON-RPC method as part of EIP-191.
     *
     * See {recover}.
     */
    function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32) {
        // 32 is the length in bytes of hash,
        // enforced by the type signature above
        return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", hash));
    }

    /**
     * @dev Returns an Ethereum Signed Message, created from `s`. This
     * produces hash corresponding to the one signed with the
     * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]
     * JSON-RPC method as part of EIP-191.
     *
     * See {recover}.
     */
    function toEthSignedMessageHash(bytes memory s) internal pure returns (bytes32) {
        return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n", Strings.toString(s.length), s));
    }

    /**
     * @dev Returns an Ethereum Signed Typed Data, created from a
     * `domainSeparator` and a `structHash`. This produces hash corresponding
     * to the one signed with the
     * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`]
     * JSON-RPC method as part of EIP-712.
     *
     * See {recover}.
     */
    function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32) {
        return keccak256(abi.encodePacked("\x19\x01", domainSeparator, structHash));
    }
}

File 13 of 16 : EnumerableSet.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/structs/EnumerableSet.sol)

pragma solidity ^0.8.0;

/**
 * @dev Library for managing
 * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive
 * types.
 *
 * Sets have the following properties:
 *
 * - Elements are added, removed, and checked for existence in constant time
 * (O(1)).
 * - Elements are enumerated in O(n). No guarantees are made on the ordering.
 *
 * ```
 * contract Example {
 *     // Add the library methods
 *     using EnumerableSet for EnumerableSet.AddressSet;
 *
 *     // Declare a set state variable
 *     EnumerableSet.AddressSet private mySet;
 * }
 * ```
 *
 * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)
 * and `uint256` (`UintSet`) are supported.
 */
library EnumerableSet {
    // To implement this library for multiple types with as little code
    // repetition as possible, we write it in terms of a generic Set type with
    // bytes32 values.
    // The Set implementation uses private functions, and user-facing
    // implementations (such as AddressSet) are just wrappers around the
    // underlying Set.
    // This means that we can only create new EnumerableSets for types that fit
    // in bytes32.

    struct Set {
        // Storage of set values
        bytes32[] _values;
        // Position of the value in the `values` array, plus 1 because index 0
        // means a value is not in the set.
        mapping(bytes32 => uint256) _indexes;
    }

    /**
     * @dev Add a value to a set. O(1).
     *
     * Returns true if the value was added to the set, that is if it was not
     * already present.
     */
    function _add(Set storage set, bytes32 value) private returns (bool) {
        if (!_contains(set, value)) {
            set._values.push(value);
            // The value is stored at length-1, but we add 1 to all indexes
            // and use 0 as a sentinel value
            set._indexes[value] = set._values.length;
            return true;
        } else {
            return false;
        }
    }

    /**
     * @dev Removes a value from a set. O(1).
     *
     * Returns true if the value was removed from the set, that is if it was
     * present.
     */
    function _remove(Set storage set, bytes32 value) private returns (bool) {
        // We read and store the value's index to prevent multiple reads from the same storage slot
        uint256 valueIndex = set._indexes[value];

        if (valueIndex != 0) {
            // Equivalent to contains(set, value)
            // To delete an element from the _values array in O(1), we swap the element to delete with the last one in
            // the array, and then remove the last element (sometimes called as 'swap and pop').
            // This modifies the order of the array, as noted in {at}.

            uint256 toDeleteIndex = valueIndex - 1;
            uint256 lastIndex = set._values.length - 1;

            if (lastIndex != toDeleteIndex) {
                bytes32 lastvalue = set._values[lastIndex];

                // Move the last value to the index where the value to delete is
                set._values[toDeleteIndex] = lastvalue;
                // Update the index for the moved value
                set._indexes[lastvalue] = valueIndex; // Replace lastvalue's index to valueIndex
            }

            // Delete the slot where the moved value was stored
            set._values.pop();

            // Delete the index for the deleted slot
            delete set._indexes[value];

            return true;
        } else {
            return false;
        }
    }

    /**
     * @dev Returns true if the value is in the set. O(1).
     */
    function _contains(Set storage set, bytes32 value) private view returns (bool) {
        return set._indexes[value] != 0;
    }

    /**
     * @dev Returns the number of values on the set. O(1).
     */
    function _length(Set storage set) private view returns (uint256) {
        return set._values.length;
    }

    /**
     * @dev Returns the value stored at position `index` in the set. O(1).
     *
     * Note that there are no guarantees on the ordering of values inside the
     * array, and it may change when more values are added or removed.
     *
     * Requirements:
     *
     * - `index` must be strictly less than {length}.
     */
    function _at(Set storage set, uint256 index) private view returns (bytes32) {
        return set._values[index];
    }

    /**
     * @dev Return the entire set in an array
     *
     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
     * this function has an unbounded cost, and using it as part of a state-changing function may render the function
     * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
     */
    function _values(Set storage set) private view returns (bytes32[] memory) {
        return set._values;
    }

    // Bytes32Set

    struct Bytes32Set {
        Set _inner;
    }

    /**
     * @dev Add a value to a set. O(1).
     *
     * Returns true if the value was added to the set, that is if it was not
     * already present.
     */
    function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {
        return _add(set._inner, value);
    }

    /**
     * @dev Removes a value from a set. O(1).
     *
     * Returns true if the value was removed from the set, that is if it was
     * present.
     */
    function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {
        return _remove(set._inner, value);
    }

    /**
     * @dev Returns true if the value is in the set. O(1).
     */
    function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {
        return _contains(set._inner, value);
    }

    /**
     * @dev Returns the number of values in the set. O(1).
     */
    function length(Bytes32Set storage set) internal view returns (uint256) {
        return _length(set._inner);
    }

    /**
     * @dev Returns the value stored at position `index` in the set. O(1).
     *
     * Note that there are no guarantees on the ordering of values inside the
     * array, and it may change when more values are added or removed.
     *
     * Requirements:
     *
     * - `index` must be strictly less than {length}.
     */
    function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {
        return _at(set._inner, index);
    }

    /**
     * @dev Return the entire set in an array
     *
     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
     * this function has an unbounded cost, and using it as part of a state-changing function may render the function
     * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
     */
    function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {
        return _values(set._inner);
    }

    // AddressSet

    struct AddressSet {
        Set _inner;
    }

    /**
     * @dev Add a value to a set. O(1).
     *
     * Returns true if the value was added to the set, that is if it was not
     * already present.
     */
    function add(AddressSet storage set, address value) internal returns (bool) {
        return _add(set._inner, bytes32(uint256(uint160(value))));
    }

    /**
     * @dev Removes a value from a set. O(1).
     *
     * Returns true if the value was removed from the set, that is if it was
     * present.
     */
    function remove(AddressSet storage set, address value) internal returns (bool) {
        return _remove(set._inner, bytes32(uint256(uint160(value))));
    }

    /**
     * @dev Returns true if the value is in the set. O(1).
     */
    function contains(AddressSet storage set, address value) internal view returns (bool) {
        return _contains(set._inner, bytes32(uint256(uint160(value))));
    }

    /**
     * @dev Returns the number of values in the set. O(1).
     */
    function length(AddressSet storage set) internal view returns (uint256) {
        return _length(set._inner);
    }

    /**
     * @dev Returns the value stored at position `index` in the set. O(1).
     *
     * Note that there are no guarantees on the ordering of values inside the
     * array, and it may change when more values are added or removed.
     *
     * Requirements:
     *
     * - `index` must be strictly less than {length}.
     */
    function at(AddressSet storage set, uint256 index) internal view returns (address) {
        return address(uint160(uint256(_at(set._inner, index))));
    }

    /**
     * @dev Return the entire set in an array
     *
     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
     * this function has an unbounded cost, and using it as part of a state-changing function may render the function
     * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
     */
    function values(AddressSet storage set) internal view returns (address[] memory) {
        bytes32[] memory store = _values(set._inner);
        address[] memory result;

        assembly {
            result := store
        }

        return result;
    }

    // UintSet

    struct UintSet {
        Set _inner;
    }

    /**
     * @dev Add a value to a set. O(1).
     *
     * Returns true if the value was added to the set, that is if it was not
     * already present.
     */
    function add(UintSet storage set, uint256 value) internal returns (bool) {
        return _add(set._inner, bytes32(value));
    }

    /**
     * @dev Removes a value from a set. O(1).
     *
     * Returns true if the value was removed from the set, that is if it was
     * present.
     */
    function remove(UintSet storage set, uint256 value) internal returns (bool) {
        return _remove(set._inner, bytes32(value));
    }

    /**
     * @dev Returns true if the value is in the set. O(1).
     */
    function contains(UintSet storage set, uint256 value) internal view returns (bool) {
        return _contains(set._inner, bytes32(value));
    }

    /**
     * @dev Returns the number of values on the set. O(1).
     */
    function length(UintSet storage set) internal view returns (uint256) {
        return _length(set._inner);
    }

    /**
     * @dev Returns the value stored at position `index` in the set. O(1).
     *
     * Note that there are no guarantees on the ordering of values inside the
     * array, and it may change when more values are added or removed.
     *
     * Requirements:
     *
     * - `index` must be strictly less than {length}.
     */
    function at(UintSet storage set, uint256 index) internal view returns (uint256) {
        return uint256(_at(set._inner, index));
    }

    /**
     * @dev Return the entire set in an array
     *
     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
     * this function has an unbounded cost, and using it as part of a state-changing function may render the function
     * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
     */
    function values(UintSet storage set) internal view returns (uint256[] memory) {
        bytes32[] memory store = _values(set._inner);
        uint256[] memory result;

        assembly {
            result := store
        }

        return result;
    }
}

File 14 of 16 : WrapperContractInterface.sol
//SPDX-License-Identifier: Copyright 2021 Shipyard Software, Inc.
pragma solidity ^0.8.0;

interface WrapperContractInterface {
  function withdraw(uint256 amount) external;
}

File 15 of 16 : IERC20Metadata.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)

pragma solidity ^0.8.0;

import "../IERC20.sol";

/**
 * @dev Interface for the optional metadata functions from the ERC20 standard.
 *
 * _Available since v4.1._
 */
interface IERC20Metadata is IERC20 {
    /**
     * @dev Returns the name of the token.
     */
    function name() external view returns (string memory);

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

    /**
     * @dev Returns the decimals places of the token.
     */
    function decimals() external view returns (uint8);
}

File 16 of 16 : Strings.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Strings.sol)

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);
    }
}

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

Contract Security Audit

Contract ABI

[{"inputs":[{"internalType":"address","name":"theExchange","type":"address"},{"internalType":"uint256","name":"tradeFee","type":"uint256"},{"internalType":"uint256","name":"clipperFee","type":"uint256"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"tokenAddress","type":"address"},{"indexed":true,"internalType":"address","name":"depositor","type":"address"},{"indexed":false,"internalType":"uint256","name":"poolTokens","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"poolTokensAfterDeposit","type":"uint256"}],"name":"CoveDeposited","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"inAsset","type":"address"},{"indexed":true,"internalType":"address","name":"outAsset","type":"address"},{"indexed":true,"internalType":"address","name":"recipient","type":"address"},{"indexed":false,"internalType":"uint256","name":"inAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"outAmount","type":"uint256"},{"indexed":false,"internalType":"bytes32","name":"auxiliaryData","type":"bytes32"}],"name":"CoveSwapped","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"tokenAddress","type":"address"},{"indexed":true,"internalType":"address","name":"withdrawer","type":"address"},{"indexed":false,"internalType":"uint256","name":"poolTokens","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"poolTokensAfterWithdrawal","type":"uint256"}],"name":"CoveWithdrawn","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"},{"inputs":[],"name":"CLIPPER_EXCHANGE","outputs":[{"internalType":"address payable","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"coin","type":"address"},{"internalType":"uint256","name":"tokenAmount","type":"uint256"}],"name":"burnToWithdraw","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"canDeposit","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tradeFee","type":"uint256"},{"internalType":"uint256","name":"clipperFee","type":"uint256"}],"name":"changeFees","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"clipperFeeBps","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"buyToken","type":"address"},{"internalType":"uint256","name":"minBuyAmount","type":"uint256"},{"internalType":"address","name":"clipperAsset","type":"address"},{"internalType":"uint256","name":"depositAmount","type":"uint256"},{"internalType":"uint256","name":"poolTokens","type":"uint256"},{"internalType":"uint256","name":"goodUntil","type":"uint256"},{"components":[{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"internalType":"struct ClipperCommonExchange.Signature","name":"theSignature","type":"tuple"},{"internalType":"bytes32","name":"auxData","type":"bytes32"}],"name":"depositForCoin","outputs":[{"internalType":"uint256","name":"buyAmount","type":"uint256"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"}],"name":"depositTokenRegistry","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"sellToken","type":"address"},{"internalType":"uint256","name":"sellAmount","type":"uint256"},{"internalType":"address","name":"buyToken","type":"address"}],"name":"getSellQuote","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"hasMarket","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"lastBalances","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"redeem","outputs":[{"internalType":"uint256","name":"currentFees","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"sellToken","type":"address"},{"internalType":"address","name":"buyToken","type":"address"},{"internalType":"uint256","name":"minBuyAmount","type":"uint256"},{"internalType":"address","name":"destinationAddress","type":"address"},{"internalType":"bytes32","name":"auxData","type":"bytes32"}],"name":"sellTokenForToken","outputs":[{"internalType":"uint256","name":"buyAmount","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"totalClipperFees","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"totalDepositTokenSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"tradeFeeBps","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"coin","type":"address"},{"internalType":"uint256","name":"coinDepositAmount","type":"uint256"},{"internalType":"address","name":"clipperAsset","type":"address"},{"internalType":"uint256","name":"clipperDepositAmount","type":"uint256"},{"internalType":"uint256","name":"poolTokens","type":"uint256"},{"internalType":"uint256","name":"goodUntil","type":"uint256"},{"components":[{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"internalType":"struct ClipperCommonExchange.Signature","name":"theSignature","type":"tuple"}],"name":"transmitAndDeposit","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"sellToken","type":"address"},{"internalType":"uint256","name":"sellAmount","type":"uint256"},{"internalType":"address","name":"buyToken","type":"address"},{"internalType":"uint256","name":"minBuyAmount","type":"uint256"},{"internalType":"address","name":"destinationAddress","type":"address"},{"internalType":"bytes32","name":"auxData","type":"bytes32"}],"name":"transmitAndSellTokenForToken","outputs":[{"internalType":"uint256","name":"buyAmount","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"stateMutability":"payable","type":"receive"}]

60a06040523480156200001157600080fd5b506040516200222d3803806200222d8339810160408190526200003491620000b2565b6200003f3362000062565b6001805560609290921b6001600160601b031916608052600755600655620000f5565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b600080600060608486031215620000c7578283fd5b83516001600160a01b0381168114620000de578384fd5b602085015160409095015190969495509392505050565b60805160601c6120cc62000161600039600081816101410152818161065a015281816106c8015281816108660152818161094e015281816109ed01528181610c0801528181610e2201528181610eb9015281816110fd01528181611129015261121b01526120cc6000f3fe6080604052600436106101235760003560e01c8063715018a6116100a0578063d61f72ab11610064578063d61f72ab14610327578063e0a5a5c01461035f578063e2bf31861461037f578063ecc7633d14610395578063f2fde38b146103c257600080fd5b8063715018a6146102a95780638da5cb5b146102be578063a20b3b24146102dc578063be040fb0146102fc578063d3c537201461031157600080fd5b80635673eef6116100e75780635673eef6146102065780635bc9b31c146102265780635e75968e146102535780635faad8c51461027357806366271b561461028957600080fd5b806306bd93101461012f57806321ecff5b1461018057806324e7a801146101a25780632963d983146101c35780634bf0d331146101d657600080fd5b3661012a57005b600080fd5b34801561013b57600080fd5b506101637f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b0390911681526020015b60405180910390f35b34801561018c57600080fd5b506101a061019b366004611ebe565b6103e2565b005b6101b56101b0366004611d2c565b610420565b604051908152602001610177565b6101b56101d1366004611d9b565b61058d565b3480156101e257600080fd5b506101f66101f1366004611b90565b610656565b6040519015158152602001610177565b34801561021257600080fd5b506101a0610221366004611c5a565b61074a565b34801561023257600080fd5b506101b5610241366004611b90565b60036020526000908152604090205481565b34801561025f57600080fd5b506101f661026e366004611b90565b610902565b34801561027f57600080fd5b506101b560075481565b34801561029557600080fd5b506101b56102a4366004611c00565b61091f565b3480156102b557600080fd5b506101a0610b9b565b3480156102ca57600080fd5b506000546001600160a01b0316610163565b3480156102e857600080fd5b506101b56102f7366004611cc6565b610bd1565b34801561030857600080fd5b506101b5610dd1565b34801561031d57600080fd5b506101b560055481565b34801561033357600080fd5b506101b5610342366004611bc8565b600460209081526000928352604080842090915290825290205481565b34801561036b57600080fd5b506101b561037a366004611c85565b610eaa565b34801561038b57600080fd5b506101b560065481565b3480156103a157600080fd5b506101b56103b0366004611b90565b60026020526000908152604090205481565b3480156103ce57600080fd5b506101a06103dd366004611b90565b611001565b6000546001600160a01b031633146104155760405162461bcd60e51b815260040161040c90611f2e565b60405180910390fd5b600791909155600655565b6000600260015414156104455760405162461bcd60e51b815260040161040c90611f9a565b600260015561045388610656565b61049f5760405162461bcd60e51b815260206004820152601b60248201527f436c6970706572436f76653a2043616e6e6f74206465706f7369740000000000604482015260640161040c565b6000806104ab8a61109c565b9150915060006104bb83836110c8565b9050600080891180156104ce5750600088115b156104f1576104ee8a8a8a8a6104e9368c90038c018c611e34565b6110dc565b90505b8a1561050c5761050c6001600160a01b038d1633308e6112b9565b600061052a61051b8387611fd1565b6105258e87611fd1565b6110c8565b905082811161053857600080fd5b6105546105458387611fd1565b61054f8e87611fd1565b61132a565b6001600160a01b038e166000908152600260205260409020556105788d8285611361565b600180559d9c50505050505050505050505050565b6000600260015414156105b25760405162461bcd60e51b815260040161040c90611f9a565b600260015560006105cf888888886104e9368a90038a018a611e34565b90506105dc8a828b611421565b91506105f26001600160a01b038b1633846114a2565b604080518881526020810184905290810184905233906001600160a01b038c811691908b16907f824d347b9cee60e7fd0533596f246476ec3a93b42c381ed12170ef1f42a75f9e9060600160405180910390a4506001805598975050505050505050565b60007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316826001600160a01b0316141580156106a257506001600160a01b03821615155b801561074457506040516319f3736160e01b81526001600160a01b0383811660048301527f000000000000000000000000000000000000000000000000000000000000000016906319f373619060240160206040518083038186803b15801561070a57600080fd5b505afa15801561071e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107429190611e14565b155b92915050565b6002600154141561076d5760405162461bcd60e51b815260040161040c90611f9a565b600260015561077b82610902565b6107975760405162461bcd60e51b815260040161040c90611f63565b6001600160a01b0382166000908152600360205260408120546107c283670de0b6b3a7640000612009565b6107cc9190611fe9565b90506107d98333846114d7565b6000806107e58561109c565b90925090506000670de0b6b3a76400006107ff8486612009565b6108099190611fe9565b90506000670de0b6b3a76400006108208487612009565b61082a9190611fe9565b90506108436108398386612028565b61054f8386612028565b6001600160a01b0380891660009081526002602052604090209190915561088d907f00000000000000000000000000000000000000000000000000000000000000001633846114a2565b6108a16001600160a01b03881633836114a2565b6001600160a01b0387166000818152600360209081526040918290205482518a8152918201523392917f30c77c0c787eb0ec5c1a0f57808bcba3adccf40f465be7d70318e3c24d212197910160405180910390a35050600180555050505050565b6001600160a01b0316600090815260036020526040902054151590565b6000600260015414156109445760405162461bcd60e51b815260040161040c90611f9a565b60026001819055507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316866001600160a01b031614156109ce5760405162461bcd60e51b815260206004820152601f60248201527f436c6970706572436f76653a204e6f74207472616461626c65206173796e6300604482015260640161040c565b6000806109da8861109c565b9150915060006109e9896115b5565b90507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316886001600160a01b031614610af757610a2d89610902565b8015610a3d5750610a3d88610902565b610a595760405162461bcd60e51b815260040161040c90611f63565b600080610a658a61109c565b90925090506000610a828587610a7b8288612028565b6000611685565b9050610a908383838d611685565b9650610aa5610a9f8288612028565b8561132a565b6001600160a01b038d16600090815260026020526040902055610ad5610acb8285611fd1565b61054f8985612028565b6001600160a01b038c1660009081526002602052604090205550610b0e915050565b610b0b89610b058484612028565b8961178b565b93505b610b226001600160a01b03891687866114a2565b856001600160a01b0316886001600160a01b03168a6001600160a01b03167f824d347b9cee60e7fd0533596f246476ec3a93b42c381ed12170ef1f42a75f9e8585610b6d9190612028565b60408051918252602082018a905281018a905260600160405180910390a45050600180555095945050505050565b6000546001600160a01b03163314610bc55760405162461bcd60e51b815260040161040c90611f2e565b610bcf60006117e7565b565b600060026001541415610bf65760405162461bcd60e51b815260040161040c90611f9a565b60026001556001600160a01b038781167f000000000000000000000000000000000000000000000000000000000000000082168181149288161490610c3d9033308b6112b9565b81158015610c49575080155b15610d3057610c5789610902565b8015610c675750610c6787610902565b610c835760405162461bcd60e51b815260040161040c90611f63565b6000806000610c918c61109c565b91509150610ca281838d6000611685565b9250610cbb610cb18484612028565b61054f8d84611fd1565b6001600160a01b038d166000908152600260205260408120919091559150819050610ce58a61109c565b91509150610cf58282858c611685565b9550610d0e610d048484611fd1565b61054f8884612028565b6001600160a01b038b1660009081526002602052604090205550610d59915050565b8115610d4857610d41878988611421565b9250610d59565b801561012a57610d4189898861178b565b610d6d6001600160a01b03881686856114a2565b60408051898152602081018590529081018590526001600160a01b0380871691898216918c16907f824d347b9cee60e7fd0533596f246476ec3a93b42c381ed12170ef1f42a75f9e9060600160405180910390a45050600180559695505050505050565b600080546001600160a01b03163314610dfc5760405162461bcd60e51b815260040161040c90611f2e565b5060058054600090915560405163a9059cbb60e01b8152336004820152602481018290527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03169063a9059cbb90604401602060405180830381600087803b158015610e6e57600080fd5b505af1158015610e82573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ea69190611e14565b5090565b60006001600160a01b038481167f00000000000000000000000000000000000000000000000000000000000000008216908114918416148280610eec8861109c565b91509150600080610efc8861109c565b9150915085158015610f0c575084155b15610f7257610f1a8a610902565b8015610f2a5750610f2a88610902565b610f465760405162461bcd60e51b815260040161040c90611f63565b6000610f5584868c6000611685565b9050610f648383836000611685565b975050505050505050610ffa565b8515610fb757610f8188610902565b610f9d5760405162461bcd60e51b815260040161040c90611f63565b610faa82828b6000611685565b9650505050505050610ffa565b8415610fef57610fc68a610902565b610fe25760405162461bcd60e51b815260040161040c90611f63565b610faa83858b6000611685565b600096505050505050505b9392505050565b6000546001600160a01b0316331461102b5760405162461bcd60e51b815260040161040c90611f2e565b6001600160a01b0381166110905760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b606482015260840161040c565b611099816117e7565b50565b6001600160a01b0316600090815260026020526040902054608081901c916001600160801b0390911690565b6000610ffa6110d78385612009565b611837565b60006001600160a01b03861615611127576111226001600160a01b038716337f0000000000000000000000000000000000000000000000000000000000000000886112b9565b6111bb565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316635aecdda56040518163ffffffff1660e01b815260040160206040518083038186803b15801561118057600080fd5b505afa158015611194573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111b89190611bac565b95505b604080516387e08c2560e01b81523060048201526001600160a01b03888116602483015260448201889052600060648301526084820187905260a48201869052845160ff1660c4830152602085015160e4830152918401516101048201527f0000000000000000000000000000000000000000000000000000000000000000909116906387e08c25903490610124016000604051808303818588803b15801561126357600080fd5b505af1158015611277573d6000803e3d6000fd5b50505050506112858461186d565b9050808411156112b0576112998185612028565b600560008282546112aa9190611fd1565b90915550505b95945050505050565b6040516001600160a01b03808516602483015283166044820152606481018290526113249085906323b872dd60e01b906084015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152611896565b50505050565b600061133582611968565b6001600160801b03169050608061134b84611968565b6001600160801b0316901b81610ffa9190611fd1565b600081156113aa576001600160a01b038416600090815260036020526040902054828161138e8287612028565b6113989190612009565b6113a29190611fe9565b9150506113bb565b6113b8836305f5e100612009565b90505b6113c68433836119d1565b6001600160a01b038416600081815260036020908152604091829020548251858152918201523392917f441124588da230790bd3b0c494e2bc687c5c2b95e6882164cd77881957d60017910160405180910390a39392505050565b600061142c84610902565b6114485760405162461bcd60e51b815260040161040c90611f63565b6000806114548661109c565b9150915061146482828787611685565b925061147d6114738684611fd1565b61054f8584612028565b6001600160a01b03909616600090815260026020526040902095909555509392505050565b6040516001600160a01b0383166024820152604481018290526114d290849063a9059cbb60e01b906064016112ed565b505050565b6001600160a01b038084166000908152600460209081526040808320938616835292905220548111156115625760405162461bcd60e51b815260206004820152602d60248201527f436c6970706572436f76653a204275726e20616d6f756e74206578636565647360448201526c20757365722062616c616e636560981b606482015260840161040c565b6001600160a01b038084166000818152600460209081526040808320948716835293815283822080548690039055918152600390915290812080548392906115ab908490612028565b9091555050505050565b604080513060248083019190915282518083039091018152604490910182526020810180516001600160e01b03166370a0823160e01b1790529051600091829182916001600160a01b0386169161160c9190611edf565b600060405180830381855afa9150503d8060008114611647576040519150601f19603f3d011682016040523d82523d6000602084013e61164c565b606091505b509150915081801561166057506020815110155b61166957600080fd5b8080602001905181019061167d9190611ea6565b949350505050565b60008083116116ce5760405162461bcd60e51b815260206004820152601560248201527410db1a5c1c195c90dbdd994e88139bc8125b9c1d5d605a1b604482015260640161040c565b6000612710846007546127106116e49190612028565b6116ee9190612009565b6116f89190611fe9565b90506117048682611fd1565b61170e8683612009565b6117189190611fe9565b915084821115611726578491505b828210156117825760405162461bcd60e51b8152602060048201526024808201527f436c6970706572436f76653a20496e73756666696369656e742062757920616d6044820152631bdd5b9d60e21b606482015260840161040c565b50949350505050565b600061179684610902565b6117b25760405162461bcd60e51b815260040161040c90611f63565b6000806117be8661109c565b915091506117ce81838787611685565b925061147d6117dd8484612028565b61054f8784611fd1565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6000670853a0d2313c000082046e4742688f149ec8077594740000000083116118635750600160028304015b610ffa8382611a35565b60006127106006546127106118829190612028565b61188c9084612009565b6107449190611fe9565b60006118eb826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316611a6e9092919063ffffffff16565b8051909150156114d257808060200190518101906119099190611e14565b6114d25760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b606482015260840161040c565b60006001600160801b03821115610ea65760405162461bcd60e51b815260206004820152602760248201527f53616665436173743a2076616c756520646f65736e27742066697420696e20316044820152663238206269747360c81b606482015260840161040c565b6001600160a01b03808416600090815260046020908152604080832093861683529290529081208054839290611a08908490611fd1565b90915550506001600160a01b038316600090815260036020526040812080548392906115ab908490611fd1565b6000825b80831015610ffa575081600181808681611a6357634e487b7160e01b600052601260045260246000fd5b0401901c9250611a39565b606061167d848460008585843b611ac75760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015260640161040c565b600080866001600160a01b03168587604051611ae39190611edf565b60006040518083038185875af1925050503d8060008114611b20576040519150601f19603f3d011682016040523d82523d6000602084013e611b25565b606091505b5091509150611b35828286611b40565b979650505050505050565b60608315611b4f575081610ffa565b825115611b5f5782518084602001fd5b8160405162461bcd60e51b815260040161040c9190611efb565b600060608284031215611b8a578081fd5b50919050565b600060208284031215611ba1578081fd5b8135610ffa81612081565b600060208284031215611bbd578081fd5b8151610ffa81612081565b60008060408385031215611bda578081fd5b8235611be581612081565b91506020830135611bf581612081565b809150509250929050565b600080600080600060a08688031215611c17578081fd5b8535611c2281612081565b94506020860135611c3281612081565b9350604086013592506060860135611c4981612081565b949793965091946080013592915050565b60008060408385031215611c6c578182fd5b8235611c7781612081565b946020939093013593505050565b600080600060608486031215611c99578283fd5b8335611ca481612081565b9250602084013591506040840135611cbb81612081565b809150509250925092565b60008060008060008060c08789031215611cde578081fd5b8635611ce981612081565b9550602087013594506040870135611d0081612081565b9350606087013592506080870135611d1781612081565b8092505060a087013590509295509295509295565b6000806000806000806000610120888a031215611d47578081fd5b8735611d5281612081565b9650602088013595506040880135611d6981612081565b9450606088013593506080880135925060a08801359150611d8d8960c08a01611b79565b905092959891949750929550565b600080600080600080600080610140898b031215611db7578081fd5b8835611dc281612081565b9750602089013596506040890135611dd981612081565b9550606089013594506080890135935060a08901359250611dfd8a60c08b01611b79565b915061012089013590509295985092959890939650565b600060208284031215611e25578081fd5b81518015158114610ffa578182fd5b600060608284031215611e45578081fd5b6040516060810181811067ffffffffffffffff82111715611e7457634e487b7160e01b83526041600452602483fd5b604052823560ff81168114611e87578283fd5b8152602083810135908201526040928301359281019290925250919050565b600060208284031215611eb7578081fd5b5051919050565b60008060408385031215611ed0578182fd5b50508035926020909101359150565b60008251611ef181846020870161203f565b9190910192915050565b6020815260008251806020840152611f1a81604085016020870161203f565b601f01601f19169190910160400192915050565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b60208082526017908201527f436c6970706572436f76653a204e6f7420747261646564000000000000000000604082015260600190565b6020808252601f908201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604082015260600190565b60008219821115611fe457611fe461206b565b500190565b60008261200457634e487b7160e01b81526012600452602481fd5b500490565b60008160001904831182151516156120235761202361206b565b500290565b60008282101561203a5761203a61206b565b500390565b60005b8381101561205a578181015183820152602001612042565b838111156113245750506000910152565b634e487b7160e01b600052601160045260246000fd5b6001600160a01b038116811461109957600080fdfea26469706673582212209eac6cbaabf25bdbfdaa3909fc7f5f06864da1138fe9e1b15dce299dc0233c6364736f6c634300080400330000000000000000000000005130f6ce257b8f9bf7fac0a0b519bd588120ed4000000000000000000000000000000000000000000000000000000000000000050000000000000000000000000000000000000000000000000000000000000000

Deployed Bytecode

0x6080604052600436106101235760003560e01c8063715018a6116100a0578063d61f72ab11610064578063d61f72ab14610327578063e0a5a5c01461035f578063e2bf31861461037f578063ecc7633d14610395578063f2fde38b146103c257600080fd5b8063715018a6146102a95780638da5cb5b146102be578063a20b3b24146102dc578063be040fb0146102fc578063d3c537201461031157600080fd5b80635673eef6116100e75780635673eef6146102065780635bc9b31c146102265780635e75968e146102535780635faad8c51461027357806366271b561461028957600080fd5b806306bd93101461012f57806321ecff5b1461018057806324e7a801146101a25780632963d983146101c35780634bf0d331146101d657600080fd5b3661012a57005b600080fd5b34801561013b57600080fd5b506101637f0000000000000000000000005130f6ce257b8f9bf7fac0a0b519bd588120ed4081565b6040516001600160a01b0390911681526020015b60405180910390f35b34801561018c57600080fd5b506101a061019b366004611ebe565b6103e2565b005b6101b56101b0366004611d2c565b610420565b604051908152602001610177565b6101b56101d1366004611d9b565b61058d565b3480156101e257600080fd5b506101f66101f1366004611b90565b610656565b6040519015158152602001610177565b34801561021257600080fd5b506101a0610221366004611c5a565b61074a565b34801561023257600080fd5b506101b5610241366004611b90565b60036020526000908152604090205481565b34801561025f57600080fd5b506101f661026e366004611b90565b610902565b34801561027f57600080fd5b506101b560075481565b34801561029557600080fd5b506101b56102a4366004611c00565b61091f565b3480156102b557600080fd5b506101a0610b9b565b3480156102ca57600080fd5b506000546001600160a01b0316610163565b3480156102e857600080fd5b506101b56102f7366004611cc6565b610bd1565b34801561030857600080fd5b506101b5610dd1565b34801561031d57600080fd5b506101b560055481565b34801561033357600080fd5b506101b5610342366004611bc8565b600460209081526000928352604080842090915290825290205481565b34801561036b57600080fd5b506101b561037a366004611c85565b610eaa565b34801561038b57600080fd5b506101b560065481565b3480156103a157600080fd5b506101b56103b0366004611b90565b60026020526000908152604090205481565b3480156103ce57600080fd5b506101a06103dd366004611b90565b611001565b6000546001600160a01b031633146104155760405162461bcd60e51b815260040161040c90611f2e565b60405180910390fd5b600791909155600655565b6000600260015414156104455760405162461bcd60e51b815260040161040c90611f9a565b600260015561045388610656565b61049f5760405162461bcd60e51b815260206004820152601b60248201527f436c6970706572436f76653a2043616e6e6f74206465706f7369740000000000604482015260640161040c565b6000806104ab8a61109c565b9150915060006104bb83836110c8565b9050600080891180156104ce5750600088115b156104f1576104ee8a8a8a8a6104e9368c90038c018c611e34565b6110dc565b90505b8a1561050c5761050c6001600160a01b038d1633308e6112b9565b600061052a61051b8387611fd1565b6105258e87611fd1565b6110c8565b905082811161053857600080fd5b6105546105458387611fd1565b61054f8e87611fd1565b61132a565b6001600160a01b038e166000908152600260205260409020556105788d8285611361565b600180559d9c50505050505050505050505050565b6000600260015414156105b25760405162461bcd60e51b815260040161040c90611f9a565b600260015560006105cf888888886104e9368a90038a018a611e34565b90506105dc8a828b611421565b91506105f26001600160a01b038b1633846114a2565b604080518881526020810184905290810184905233906001600160a01b038c811691908b16907f824d347b9cee60e7fd0533596f246476ec3a93b42c381ed12170ef1f42a75f9e9060600160405180910390a4506001805598975050505050505050565b60007f0000000000000000000000005130f6ce257b8f9bf7fac0a0b519bd588120ed406001600160a01b0316826001600160a01b0316141580156106a257506001600160a01b03821615155b801561074457506040516319f3736160e01b81526001600160a01b0383811660048301527f0000000000000000000000005130f6ce257b8f9bf7fac0a0b519bd588120ed4016906319f373619060240160206040518083038186803b15801561070a57600080fd5b505afa15801561071e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107429190611e14565b155b92915050565b6002600154141561076d5760405162461bcd60e51b815260040161040c90611f9a565b600260015561077b82610902565b6107975760405162461bcd60e51b815260040161040c90611f63565b6001600160a01b0382166000908152600360205260408120546107c283670de0b6b3a7640000612009565b6107cc9190611fe9565b90506107d98333846114d7565b6000806107e58561109c565b90925090506000670de0b6b3a76400006107ff8486612009565b6108099190611fe9565b90506000670de0b6b3a76400006108208487612009565b61082a9190611fe9565b90506108436108398386612028565b61054f8386612028565b6001600160a01b0380891660009081526002602052604090209190915561088d907f0000000000000000000000005130f6ce257b8f9bf7fac0a0b519bd588120ed401633846114a2565b6108a16001600160a01b03881633836114a2565b6001600160a01b0387166000818152600360209081526040918290205482518a8152918201523392917f30c77c0c787eb0ec5c1a0f57808bcba3adccf40f465be7d70318e3c24d212197910160405180910390a35050600180555050505050565b6001600160a01b0316600090815260036020526040902054151590565b6000600260015414156109445760405162461bcd60e51b815260040161040c90611f9a565b60026001819055507f0000000000000000000000005130f6ce257b8f9bf7fac0a0b519bd588120ed406001600160a01b0316866001600160a01b031614156109ce5760405162461bcd60e51b815260206004820152601f60248201527f436c6970706572436f76653a204e6f74207472616461626c65206173796e6300604482015260640161040c565b6000806109da8861109c565b9150915060006109e9896115b5565b90507f0000000000000000000000005130f6ce257b8f9bf7fac0a0b519bd588120ed406001600160a01b0316886001600160a01b031614610af757610a2d89610902565b8015610a3d5750610a3d88610902565b610a595760405162461bcd60e51b815260040161040c90611f63565b600080610a658a61109c565b90925090506000610a828587610a7b8288612028565b6000611685565b9050610a908383838d611685565b9650610aa5610a9f8288612028565b8561132a565b6001600160a01b038d16600090815260026020526040902055610ad5610acb8285611fd1565b61054f8985612028565b6001600160a01b038c1660009081526002602052604090205550610b0e915050565b610b0b89610b058484612028565b8961178b565b93505b610b226001600160a01b03891687866114a2565b856001600160a01b0316886001600160a01b03168a6001600160a01b03167f824d347b9cee60e7fd0533596f246476ec3a93b42c381ed12170ef1f42a75f9e8585610b6d9190612028565b60408051918252602082018a905281018a905260600160405180910390a45050600180555095945050505050565b6000546001600160a01b03163314610bc55760405162461bcd60e51b815260040161040c90611f2e565b610bcf60006117e7565b565b600060026001541415610bf65760405162461bcd60e51b815260040161040c90611f9a565b60026001556001600160a01b038781167f0000000000000000000000005130f6ce257b8f9bf7fac0a0b519bd588120ed4082168181149288161490610c3d9033308b6112b9565b81158015610c49575080155b15610d3057610c5789610902565b8015610c675750610c6787610902565b610c835760405162461bcd60e51b815260040161040c90611f63565b6000806000610c918c61109c565b91509150610ca281838d6000611685565b9250610cbb610cb18484612028565b61054f8d84611fd1565b6001600160a01b038d166000908152600260205260408120919091559150819050610ce58a61109c565b91509150610cf58282858c611685565b9550610d0e610d048484611fd1565b61054f8884612028565b6001600160a01b038b1660009081526002602052604090205550610d59915050565b8115610d4857610d41878988611421565b9250610d59565b801561012a57610d4189898861178b565b610d6d6001600160a01b03881686856114a2565b60408051898152602081018590529081018590526001600160a01b0380871691898216918c16907f824d347b9cee60e7fd0533596f246476ec3a93b42c381ed12170ef1f42a75f9e9060600160405180910390a45050600180559695505050505050565b600080546001600160a01b03163314610dfc5760405162461bcd60e51b815260040161040c90611f2e565b5060058054600090915560405163a9059cbb60e01b8152336004820152602481018290527f0000000000000000000000005130f6ce257b8f9bf7fac0a0b519bd588120ed406001600160a01b03169063a9059cbb90604401602060405180830381600087803b158015610e6e57600080fd5b505af1158015610e82573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ea69190611e14565b5090565b60006001600160a01b038481167f0000000000000000000000005130f6ce257b8f9bf7fac0a0b519bd588120ed408216908114918416148280610eec8861109c565b91509150600080610efc8861109c565b9150915085158015610f0c575084155b15610f7257610f1a8a610902565b8015610f2a5750610f2a88610902565b610f465760405162461bcd60e51b815260040161040c90611f63565b6000610f5584868c6000611685565b9050610f648383836000611685565b975050505050505050610ffa565b8515610fb757610f8188610902565b610f9d5760405162461bcd60e51b815260040161040c90611f63565b610faa82828b6000611685565b9650505050505050610ffa565b8415610fef57610fc68a610902565b610fe25760405162461bcd60e51b815260040161040c90611f63565b610faa83858b6000611685565b600096505050505050505b9392505050565b6000546001600160a01b0316331461102b5760405162461bcd60e51b815260040161040c90611f2e565b6001600160a01b0381166110905760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b606482015260840161040c565b611099816117e7565b50565b6001600160a01b0316600090815260026020526040902054608081901c916001600160801b0390911690565b6000610ffa6110d78385612009565b611837565b60006001600160a01b03861615611127576111226001600160a01b038716337f0000000000000000000000005130f6ce257b8f9bf7fac0a0b519bd588120ed40886112b9565b6111bb565b7f0000000000000000000000005130f6ce257b8f9bf7fac0a0b519bd588120ed406001600160a01b0316635aecdda56040518163ffffffff1660e01b815260040160206040518083038186803b15801561118057600080fd5b505afa158015611194573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111b89190611bac565b95505b604080516387e08c2560e01b81523060048201526001600160a01b03888116602483015260448201889052600060648301526084820187905260a48201869052845160ff1660c4830152602085015160e4830152918401516101048201527f0000000000000000000000005130f6ce257b8f9bf7fac0a0b519bd588120ed40909116906387e08c25903490610124016000604051808303818588803b15801561126357600080fd5b505af1158015611277573d6000803e3d6000fd5b50505050506112858461186d565b9050808411156112b0576112998185612028565b600560008282546112aa9190611fd1565b90915550505b95945050505050565b6040516001600160a01b03808516602483015283166044820152606481018290526113249085906323b872dd60e01b906084015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152611896565b50505050565b600061133582611968565b6001600160801b03169050608061134b84611968565b6001600160801b0316901b81610ffa9190611fd1565b600081156113aa576001600160a01b038416600090815260036020526040902054828161138e8287612028565b6113989190612009565b6113a29190611fe9565b9150506113bb565b6113b8836305f5e100612009565b90505b6113c68433836119d1565b6001600160a01b038416600081815260036020908152604091829020548251858152918201523392917f441124588da230790bd3b0c494e2bc687c5c2b95e6882164cd77881957d60017910160405180910390a39392505050565b600061142c84610902565b6114485760405162461bcd60e51b815260040161040c90611f63565b6000806114548661109c565b9150915061146482828787611685565b925061147d6114738684611fd1565b61054f8584612028565b6001600160a01b03909616600090815260026020526040902095909555509392505050565b6040516001600160a01b0383166024820152604481018290526114d290849063a9059cbb60e01b906064016112ed565b505050565b6001600160a01b038084166000908152600460209081526040808320938616835292905220548111156115625760405162461bcd60e51b815260206004820152602d60248201527f436c6970706572436f76653a204275726e20616d6f756e74206578636565647360448201526c20757365722062616c616e636560981b606482015260840161040c565b6001600160a01b038084166000818152600460209081526040808320948716835293815283822080548690039055918152600390915290812080548392906115ab908490612028565b9091555050505050565b604080513060248083019190915282518083039091018152604490910182526020810180516001600160e01b03166370a0823160e01b1790529051600091829182916001600160a01b0386169161160c9190611edf565b600060405180830381855afa9150503d8060008114611647576040519150601f19603f3d011682016040523d82523d6000602084013e61164c565b606091505b509150915081801561166057506020815110155b61166957600080fd5b8080602001905181019061167d9190611ea6565b949350505050565b60008083116116ce5760405162461bcd60e51b815260206004820152601560248201527410db1a5c1c195c90dbdd994e88139bc8125b9c1d5d605a1b604482015260640161040c565b6000612710846007546127106116e49190612028565b6116ee9190612009565b6116f89190611fe9565b90506117048682611fd1565b61170e8683612009565b6117189190611fe9565b915084821115611726578491505b828210156117825760405162461bcd60e51b8152602060048201526024808201527f436c6970706572436f76653a20496e73756666696369656e742062757920616d6044820152631bdd5b9d60e21b606482015260840161040c565b50949350505050565b600061179684610902565b6117b25760405162461bcd60e51b815260040161040c90611f63565b6000806117be8661109c565b915091506117ce81838787611685565b925061147d6117dd8484612028565b61054f8784611fd1565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6000670853a0d2313c000082046e4742688f149ec8077594740000000083116118635750600160028304015b610ffa8382611a35565b60006127106006546127106118829190612028565b61188c9084612009565b6107449190611fe9565b60006118eb826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316611a6e9092919063ffffffff16565b8051909150156114d257808060200190518101906119099190611e14565b6114d25760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b606482015260840161040c565b60006001600160801b03821115610ea65760405162461bcd60e51b815260206004820152602760248201527f53616665436173743a2076616c756520646f65736e27742066697420696e20316044820152663238206269747360c81b606482015260840161040c565b6001600160a01b03808416600090815260046020908152604080832093861683529290529081208054839290611a08908490611fd1565b90915550506001600160a01b038316600090815260036020526040812080548392906115ab908490611fd1565b6000825b80831015610ffa575081600181808681611a6357634e487b7160e01b600052601260045260246000fd5b0401901c9250611a39565b606061167d848460008585843b611ac75760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015260640161040c565b600080866001600160a01b03168587604051611ae39190611edf565b60006040518083038185875af1925050503d8060008114611b20576040519150601f19603f3d011682016040523d82523d6000602084013e611b25565b606091505b5091509150611b35828286611b40565b979650505050505050565b60608315611b4f575081610ffa565b825115611b5f5782518084602001fd5b8160405162461bcd60e51b815260040161040c9190611efb565b600060608284031215611b8a578081fd5b50919050565b600060208284031215611ba1578081fd5b8135610ffa81612081565b600060208284031215611bbd578081fd5b8151610ffa81612081565b60008060408385031215611bda578081fd5b8235611be581612081565b91506020830135611bf581612081565b809150509250929050565b600080600080600060a08688031215611c17578081fd5b8535611c2281612081565b94506020860135611c3281612081565b9350604086013592506060860135611c4981612081565b949793965091946080013592915050565b60008060408385031215611c6c578182fd5b8235611c7781612081565b946020939093013593505050565b600080600060608486031215611c99578283fd5b8335611ca481612081565b9250602084013591506040840135611cbb81612081565b809150509250925092565b60008060008060008060c08789031215611cde578081fd5b8635611ce981612081565b9550602087013594506040870135611d0081612081565b9350606087013592506080870135611d1781612081565b8092505060a087013590509295509295509295565b6000806000806000806000610120888a031215611d47578081fd5b8735611d5281612081565b9650602088013595506040880135611d6981612081565b9450606088013593506080880135925060a08801359150611d8d8960c08a01611b79565b905092959891949750929550565b600080600080600080600080610140898b031215611db7578081fd5b8835611dc281612081565b9750602089013596506040890135611dd981612081565b9550606089013594506080890135935060a08901359250611dfd8a60c08b01611b79565b915061012089013590509295985092959890939650565b600060208284031215611e25578081fd5b81518015158114610ffa578182fd5b600060608284031215611e45578081fd5b6040516060810181811067ffffffffffffffff82111715611e7457634e487b7160e01b83526041600452602483fd5b604052823560ff81168114611e87578283fd5b8152602083810135908201526040928301359281019290925250919050565b600060208284031215611eb7578081fd5b5051919050565b60008060408385031215611ed0578182fd5b50508035926020909101359150565b60008251611ef181846020870161203f565b9190910192915050565b6020815260008251806020840152611f1a81604085016020870161203f565b601f01601f19169190910160400192915050565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b60208082526017908201527f436c6970706572436f76653a204e6f7420747261646564000000000000000000604082015260600190565b6020808252601f908201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604082015260600190565b60008219821115611fe457611fe461206b565b500190565b60008261200457634e487b7160e01b81526012600452602481fd5b500490565b60008160001904831182151516156120235761202361206b565b500290565b60008282101561203a5761203a61206b565b500390565b60005b8381101561205a578181015183820152602001612042565b838111156113245750506000910152565b634e487b7160e01b600052601160045260246000fd5b6001600160a01b038116811461109957600080fdfea26469706673582212209eac6cbaabf25bdbfdaa3909fc7f5f06864da1138fe9e1b15dce299dc0233c6364736f6c63430008040033

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

0000000000000000000000005130f6ce257b8f9bf7fac0a0b519bd588120ed4000000000000000000000000000000000000000000000000000000000000000050000000000000000000000000000000000000000000000000000000000000000

-----Decoded View---------------
Arg [0] : theExchange (address): 0x5130f6cE257B8F9bF7fac0A0b519Bd588120ed40
Arg [1] : tradeFee (uint256): 5
Arg [2] : clipperFee (uint256): 0

-----Encoded View---------------
3 Constructor Arguments found :
Arg [0] : 0000000000000000000000005130f6ce257b8f9bf7fac0a0b519bd588120ed40
Arg [1] : 0000000000000000000000000000000000000000000000000000000000000005
Arg [2] : 0000000000000000000000000000000000000000000000000000000000000000


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