Contract 0x3309a431de850ec554e5f22b2d9fc0b245a2023e

Contract Overview

Balance:
0 GLMR

GLMR Value:
$0.00

Token:
Txn Hash Method
Block
From
To
Value [Txn Fee]
0xe5022d1fbe00bac11fb4da523284695d72231b0d9b2da88f19eb6e4177736ef7Burn To Withdraw31322552023-03-13 18:28:4819 days 14 hrs ago0x609e8e718a4c9f3300aea14fbc0884b6877b19a8 IN  0x3309a431de850ec554e5f22b2d9fc0b245a2023e0 GLMR0.01088283
0x9eff5a3b338b3097fcd1975ec431852153b72fa0df8cdddee953edf5de892d4bBurn To Withdraw31322362023-03-13 18:25:0019 days 14 hrs ago0x9c39a7e06dca3954b68ce2fd982a5ff3ef66c986 IN  0x3309a431de850ec554e5f22b2d9fc0b245a2023e0 GLMR0.0108644585
0x5413d75e0e3e7ecfef355d5caa54ef714b57192bf2799a480883ccff404f3a43Burn To Withdraw31255242023-03-12 4:31:4321 days 4 hrs ago0xbd1f7d88c76a86c60d41bddd4819fae404e7151e IN  0x3309a431de850ec554e5f22b2d9fc0b245a2023e0 GLMR0.00914645704
0x99c2b54fa9a44ad847ad251370423164965896a994e4f0d7396f1713fb5e87beBurn To Withdraw29542312023-02-15 12:15:1845 days 20 hrs ago0x8330a84d3c16a55302f921c36979b1067418053a IN  0x3309a431de850ec554e5f22b2d9fc0b245a2023e0 GLMR0.011341785
0x4f1feedb1734d852c4ee2e735d8b6bcdb01e6786047602f825f0db69eb18c0a4Burn To Withdraw28257472023-01-28 8:06:2464 days 1 hr ago0x8f95adb1e97fdb9015806acbbad5becc818bed5d IN  0x3309a431de850ec554e5f22b2d9fc0b245a2023e0 GLMR0.009140684
0x9e2511ce454836126f2494594ad7be99d3395f762fb86b4ec260147927257314Burn To Withdraw28257432023-01-28 8:05:3664 days 1 hr ago0x8f95adb1e97fdb9015806acbbad5becc818bed5d IN  0x3309a431de850ec554e5f22b2d9fc0b245a2023e0 GLMR0.00741153
0x074c4b3ad3080e381ba2cb66dd5d7d1afec97f57765060dd62abfc15e68119c5Burn To Withdraw28257402023-01-28 8:05:0064 days 1 hr ago0x8f95adb1e97fdb9015806acbbad5becc818bed5d IN  0x3309a431de850ec554e5f22b2d9fc0b245a2023e0 GLMR0.009144338
0x55339808e9aed82ae95ceda7386f097097eb3b357065cf774c60a13dbf32b336Burn To Withdraw28257302023-01-28 8:03:0064 days 1 hr ago0x8f95adb1e97fdb9015806acbbad5becc818bed5d IN  0x3309a431de850ec554e5f22b2d9fc0b245a2023e0 GLMR0.010876334
0xf223fd965cc07d766cdbb4f80d72f2b8b6b923507beedcfda56e9e82dc8080b2Burn To Withdraw28244192023-01-28 3:35:4264 days 5 hrs ago0x2df1d592300168c3f066e6285066adfd299a2828 IN  0x3309a431de850ec554e5f22b2d9fc0b245a2023e0 GLMR0.0107192
0x0de1351931477ecf9b3c7a4154b16d4395afe1fa3e07de0824a10ed30a10474dBurn To Withdraw28135242023-01-26 14:41:0665 days 18 hrs ago0x21a23e89bf76a6093ecaac516d09d852ffc11b40 IN  0x3309a431de850ec554e5f22b2d9fc0b245a2023e0 GLMR0.010879988
0x30df65ec1a7a84cb6dd335d00effec16ab0b76540e0ebb894cb008d551f5080fBurn To Withdraw27949032023-01-23 23:32:0068 days 9 hrs ago0x53c450d75dcc363224b436cfba8111c563617ee6 IN  0x3309a431de850ec554e5f22b2d9fc0b245a2023e0 GLMR0.009144338
0xbf955964634f9d55833b8b059c30573575c72035bc332d935788fbfb9c69376bBurn To Withdraw27880162023-01-23 0:07:2469 days 9 hrs ago0xcef4bf48bf8015bca7f9f198acedca7c758e0aa1 IN  0x3309a431de850ec554e5f22b2d9fc0b245a2023e0 GLMR0.009189384
0xd475ee4dc20528d8348f688086daca80a497171496307ade63dcc4e0a00ff367Burn To Withdraw27158402023-01-12 19:38:1879 days 13 hrs ago0x4f9484348af66460fc3d5f79f091b6ff4f0aae5f IN  0x3309a431de850ec554e5f22b2d9fc0b245a2023e0 GLMR0.007405034
0xffbbddf3e8614d4ae3e27e8d2d5108e4d8dee1261fb0da4a9955d39f83f47239Burn To Withdraw26284022022-12-31 11:59:4891 days 21 hrs ago0x84346a71dc3e3990e17b12cbb69f660fa5eb9f45 IN  0x3309a431de850ec554e5f22b2d9fc0b245a2023e0 GLMR0.009365608
0x26087177ec715d3f37d38a774f0494ae47b77b45105efbefcb25634ad3bdb2bfBurn To Withdraw26283582022-12-31 11:50:5491 days 21 hrs ago0xae0a65186636531ed21cccfa70ceb6d51184800d IN  0x3309a431de850ec554e5f22b2d9fc0b245a2023e0 GLMR0.011101258
0xf187bd2824eb1d17d14c58f036085f6b658f97a11e6b0234e7c85fdffc2c824eBurn To Withdraw25656042022-12-22 14:59:18100 days 18 hrs ago0xf9d896ab8d62e3f00e7e51288549f4e464feacfa IN  0x3309a431de850ec554e5f22b2d9fc0b245a2023e0 GLMR0.0107156
0xd73f55e12afc7951b64eb396b145bbdcb519b94568d6195932c07eb48f22e290Burn To Withdraw25599042022-12-21 19:41:54101 days 13 hrs ago0x6ed1aed0e03d843f2456e1e4d34b307bdbd09b60 IN  0x3309a431de850ec554e5f22b2d9fc0b245a2023e0 GLMR0.0107192
0x9e103d2d7eea49026394d5da71b29622efed714de5598b679d2fdf682031d14cBurn To Withdraw25404412022-12-19 2:01:00104 days 7 hrs ago0x0ea05c8b55de589f984839d7657da24507720a25 IN  0x3309a431de850ec554e5f22b2d9fc0b245a2023e0 GLMR0.009144338
0xed8e0e09bba5e51303d2589166d961beec03f86748cdb9462f6ce8d084e1f8e5Burn To Withdraw25043272022-12-13 23:41:12109 days 9 hrs ago0xa2e7002e0ffc42e4228292d67c13a81fdd191870 IN  0x3309a431de850ec554e5f22b2d9fc0b245a2023e0 GLMR0.009099292
0xa87aa9fe1ece9ea226e80afcd154861ed82128951f18e49d9811588f7bb54045Burn To Withdraw25043242022-12-13 23:40:36109 days 9 hrs ago0xa2e7002e0ffc42e4228292d67c13a81fdd191870 IN  0x3309a431de850ec554e5f22b2d9fc0b245a2023e0 GLMR0.010822756
0xe0d8d07bb847df0ef6c7b0926be620806b80d24ca865ac385203ad962d145763Burn To Withdraw24935082022-12-12 10:13:48110 days 22 hrs ago0x660e9f304787f9486838a62b1dcafe328b4ea015 IN  0x3309a431de850ec554e5f22b2d9fc0b245a2023e0 GLMR0.009140684
0x3dce362ed9f40044a75d4a16f91c20d4b43923e50417cbdf841171e12284e1d8Transmit And Sel...24807022022-12-10 14:51:06112 days 18 hrs ago0x4b0783b5b2e6086520a4156e4277091a0e2ed409 IN  0x3309a431de850ec554e5f22b2d9fc0b245a2023e0 GLMR0.003601423
0xf3fee8d4571f6ad30a39f6c9b66f8b984b66115f9a9b78a8b304db08e1fcfa5bTransmit And Sel...24806782022-12-10 14:46:06112 days 18 hrs ago0x4b0783b5b2e6086520a4156e4277091a0e2ed409 IN  0x3309a431de850ec554e5f22b2d9fc0b245a2023e0 GLMR0.003608148
0xc349a719a52d83833da7d28db48ffd653dcb023a3c78be35adad77ce3e7bfb6aTransmit And Sel...24806752022-12-10 14:45:30112 days 18 hrs ago0x4b0783b5b2e6086520a4156e4277091a0e2ed409 IN  0x3309a431de850ec554e5f22b2d9fc0b245a2023e0 GLMR0.003608148
0xfa21a0c1708a821e263157da38936aa6f830e65f70752d5cc33b7b30c6db770eTransmit And Sel...24806432022-12-10 14:38:54112 days 18 hrs ago0x4b0783b5b2e6086520a4156e4277091a0e2ed409 IN  0x3309a431de850ec554e5f22b2d9fc0b245a2023e0 GLMR0.003614268
[ Download CSV Export 
Latest 25 internal transaction
Parent Txn Hash Block From To Value
0xd2a257e61c15fc4af029fa08b3cc5f8c1e5adcb5595b58d19ac293ee4ea5650815749842022-08-03 14:43:42241 days 18 hrs ago 0x3309a431de850ec554e5f22b2d9fc0b245a2023e 0xce37051a3e60587157dc4c0391b4c555c6e68255662.69 GLMR
0xaa5f1310c5bba3d2768548f2ecbc4e841e53d60f51b6c29fda8a04ca0a8ff88e15741612022-08-03 11:49:18241 days 21 hrs ago 0x3309a431de850ec554e5f22b2d9fc0b245a2023e 0xce37051a3e60587157dc4c0391b4c555c6e6825510 GLMR
0x17dbbaaf3fcaa60f1cf223709bbda241d8a083312f4f5bb7732318f9140d9c1a15741332022-08-03 11:43:18241 days 21 hrs ago 0x3309a431de850ec554e5f22b2d9fc0b245a2023e 0xce37051a3e60587157dc4c0391b4c555c6e6825530 GLMR
0x6298ecad737cc5827d9b15dc257ad985a117ee140e83174afd4777a8d8762aef15741142022-08-03 11:39:24241 days 21 hrs ago 0x3309a431de850ec554e5f22b2d9fc0b245a2023e 0xce37051a3e60587157dc4c0391b4c555c6e6825515 GLMR
0xb1dc124459b4758ce818a3a7f5adc81e701e927d188293f7f6677015b84b3c4c15740982022-08-03 11:35:48241 days 21 hrs ago 0x3309a431de850ec554e5f22b2d9fc0b245a2023e 0xce37051a3e60587157dc4c0391b4c555c6e6825590 GLMR
0x585822b1dd6137743247e3ba347562dcb778a673fa7eee7b7670a83f552b9e9715740812022-08-03 11:32:12241 days 21 hrs ago 0x3309a431de850ec554e5f22b2d9fc0b245a2023e 0xce37051a3e60587157dc4c0391b4c555c6e6825550 GLMR
0x592c2d541ca904c1316de867ee5e1d7a79498f104a5c4b0123fa7eac438baa0a15740642022-08-03 11:28:36241 days 21 hrs ago 0x3309a431de850ec554e5f22b2d9fc0b245a2023e 0xce37051a3e60587157dc4c0391b4c555c6e6825525 GLMR
0x417b093064c2c80133a33f2f96e3598c0bf88b46643a3322dbfe0cf9878899e315740522022-08-03 11:26:06241 days 21 hrs ago 0x3309a431de850ec554e5f22b2d9fc0b245a2023e 0xce37051a3e60587157dc4c0391b4c555c6e6825525 GLMR
0x651defe969a9cce7eabb08820ddf71441863298dd46a063cd91856d04257e68b15740132022-08-03 11:18:06241 days 21 hrs ago 0x3309a431de850ec554e5f22b2d9fc0b245a2023e 0xce37051a3e60587157dc4c0391b4c555c6e6825535 GLMR
0x87cd400d2b3c6341916aa6887b2bd3908b9ed59b1a092ccffa8d3bc922b1ae8a15721382022-08-03 4:42:48242 days 4 hrs ago 0x3309a431de850ec554e5f22b2d9fc0b245a2023e 0xce37051a3e60587157dc4c0391b4c555c6e682558 GLMR
0x4eaf2e5d036528204102329588211612c942f58dd86ce8b173b82d7a918f9da415721222022-08-03 4:39:36242 days 4 hrs ago 0x3309a431de850ec554e5f22b2d9fc0b245a2023e 0xce37051a3e60587157dc4c0391b4c555c6e6825512 GLMR
0x34a0aa63e890196d8483a9da4152e3e856acda910af1a9680710e8b9d25c9acb15702402022-08-02 22:05:48242 days 11 hrs ago 0x3309a431de850ec554e5f22b2d9fc0b245a2023e 0xce37051a3e60587157dc4c0391b4c555c6e68255960.1 GLMR
0xb6e98c007606f05dbe80babedcd59d3ec68f696677cb9735cab06fa0fd1e54ff15695062022-08-02 19:30:48242 days 13 hrs ago 0x3309a431de850ec554e5f22b2d9fc0b245a2023e 0xce37051a3e60587157dc4c0391b4c555c6e682551 GLMR
0x706241a355c94e94b4aed765b9e70b975f38266b2aecb6bcc37fdcdc739f019b15684792022-08-02 15:53:00242 days 17 hrs ago 0x3309a431de850ec554e5f22b2d9fc0b245a2023e 0xce37051a3e60587157dc4c0391b4c555c6e682553 GLMR
0x09c926d8aea7ecab2219bf717fa3e792c5016e023ac747eb8e611ae3b067ea1515681652022-08-02 14:47:36242 days 18 hrs ago 0x3309a431de850ec554e5f22b2d9fc0b245a2023e 0xce37051a3e60587157dc4c0391b4c555c6e682555 GLMR
0xa1276cafad5801b66cd5e5f69682f595f6fbc615f9142a244a8fefc86d555b3215681172022-08-02 14:37:30242 days 18 hrs ago 0x3309a431de850ec554e5f22b2d9fc0b245a2023e 0xce37051a3e60587157dc4c0391b4c555c6e6825520 GLMR
0xd701d3e467ee2566351acf8e884cb3d5fe3e3f0e2127a83574f01a4d7e55151215677652022-08-02 13:23:30242 days 19 hrs ago 0x3309a431de850ec554e5f22b2d9fc0b245a2023e 0xce37051a3e60587157dc4c0391b4c555c6e6825510 GLMR
0x65b6768695756d5784eed0eed0a44d5b8f23bdc71270415536bf3a22ebb4ca2f15677392022-08-02 13:17:54242 days 19 hrs ago 0x3309a431de850ec554e5f22b2d9fc0b245a2023e 0xce37051a3e60587157dc4c0391b4c555c6e682552 GLMR
0xe359efdc00ed8704b512acf75c3207cb4b2a1b774b1b7e4f3cebece28c265fbd15675392022-08-02 12:35:42242 days 20 hrs ago 0x3309a431de850ec554e5f22b2d9fc0b245a2023e 0xce37051a3e60587157dc4c0391b4c555c6e6825525 GLMR
0x05b245d904e850351e39faf7e4f7535b7b56926f82cd10347ce3c9c006aeb9db15675232022-08-02 12:32:18242 days 20 hrs ago 0x3309a431de850ec554e5f22b2d9fc0b245a2023e 0xce37051a3e60587157dc4c0391b4c555c6e6825525 GLMR
0x08d4545345e65feb2ef4c39163d23e76a5e62441e47148b9fe4d0b6534f33e8c15674792022-08-02 12:23:06242 days 20 hrs ago 0x3309a431de850ec554e5f22b2d9fc0b245a2023e 0xce37051a3e60587157dc4c0391b4c555c6e6825520 GLMR
0x30ee4c28947d8344cb36fdd97d240c9a5937e528e0a1b0631e2daa022dd5e7d315666662022-08-02 9:30:48242 days 23 hrs ago 0x3309a431de850ec554e5f22b2d9fc0b245a2023e 0xce37051a3e60587157dc4c0391b4c555c6e682555 GLMR
0xd551aacf1e0aac6c566aff57bf7620a35d9011dc83d082212d7335df44feaa1515666212022-08-02 9:21:18242 days 23 hrs ago 0x3309a431de850ec554e5f22b2d9fc0b245a2023e 0xce37051a3e60587157dc4c0391b4c555c6e682551 GLMR
0x31b86c25ee2226d184930feeacf5281aacdb15c2d33a152d428cfa944bfdc58115664062022-08-02 8:35:54243 days 36 mins ago 0x3309a431de850ec554e5f22b2d9fc0b245a2023e 0xce37051a3e60587157dc4c0391b4c555c6e682551,821 GLMR
0x274a07d444f00aed139ad77d70b2db39916120f6d17e382d3615f1927605016915663802022-08-02 8:30:36243 days 41 mins ago 0x3309a431de850ec554e5f22b2d9fc0b245a2023e 0xce37051a3e60587157dc4c0391b4c555c6e682551,558 GLMR
[ 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

Contract Source Code (Solidity Standard Json-Input format)

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 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"}]

60a06040523480156200001157600080fd5b506040516200222d3803806200222d8339810160408190526200003491620000b2565b6200003f3362000062565b6001805560609290921b6001600160601b031916608052600755600655620000f5565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b600080600060608486031215620000c7578283fd5b83516001600160a01b0381168114620000de578384fd5b602085015160409095015190969495509392505050565b60805160601c6120cc62000161600039600081816101410152818161065a015281816106c8015281816108660152818161094e015281816109ed01528181610c0801528181610e2201528181610eb9015281816110fd01528181611129015261121b01526120cc6000f3fe6080604052600436106101235760003560e01c8063715018a6116100a0578063d61f72ab11610064578063d61f72ab14610327578063e0a5a5c01461035f578063e2bf31861461037f578063ecc7633d14610395578063f2fde38b146103c257600080fd5b8063715018a6146102a95780638da5cb5b146102be578063a20b3b24146102dc578063be040fb0146102fc578063d3c537201461031157600080fd5b80635673eef6116100e75780635673eef6146102065780635bc9b31c146102265780635e75968e146102535780635faad8c51461027357806366271b561461028957600080fd5b806306bd93101461012f57806321ecff5b1461018057806324e7a801146101a25780632963d983146101c35780634bf0d331146101d657600080fd5b3661012a57005b600080fd5b34801561013b57600080fd5b506101637f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b0390911681526020015b60405180910390f35b34801561018c57600080fd5b506101a061019b366004611ebe565b6103e2565b005b6101b56101b0366004611d2c565b610420565b604051908152602001610177565b6101b56101d1366004611d9b565b61058d565b3480156101e257600080fd5b506101f66101f1366004611b90565b610656565b6040519015158152602001610177565b34801561021257600080fd5b506101a0610221366004611c5a565b61074a565b34801561023257600080fd5b506101b5610241366004611b90565b60036020526000908152604090205481565b34801561025f57600080fd5b506101f661026e366004611b90565b610902565b34801561027f57600080fd5b506101b560075481565b34801561029557600080fd5b506101b56102a4366004611c00565b61091f565b3480156102b557600080fd5b506101a0610b9b565b3480156102ca57600080fd5b506000546001600160a01b0316610163565b3480156102e857600080fd5b506101b56102f7366004611cc6565b610bd1565b34801561030857600080fd5b506101b5610dd1565b34801561031d57600080fd5b506101b560055481565b34801561033357600080fd5b506101b5610342366004611bc8565b600460209081526000928352604080842090915290825290205481565b34801561036b57600080fd5b506101b561037a366004611c85565b610eaa565b34801561038b57600080fd5b506101b560065481565b3480156103a157600080fd5b506101b56103b0366004611b90565b60026020526000908152604090205481565b3480156103ce57600080fd5b506101a06103dd366004611b90565b611001565b6000546001600160a01b031633146104155760405162461bcd60e51b815260040161040c90611f2e565b60405180910390fd5b600791909155600655565b6000600260015414156104455760405162461bcd60e51b815260040161040c90611f9a565b600260015561045388610656565b61049f5760405162461bcd60e51b815260206004820152601b60248201527f436c6970706572436f76653a2043616e6e6f74206465706f7369740000000000604482015260640161040c565b6000806104ab8a61109c565b9150915060006104bb83836110c8565b9050600080891180156104ce5750600088115b156104f1576104ee8a8a8a8a6104e9368c90038c018c611e34565b6110dc565b90505b8a1561050c5761050c6001600160a01b038d1633308e6112b9565b600061052a61051b8387611fd1565b6105258e87611fd1565b6110c8565b905082811161053857600080fd5b6105546105458387611fd1565b61054f8e87611fd1565b61132a565b6001600160a01b038e166000908152600260205260409020556105788d8285611361565b600180559d9c50505050505050505050505050565b6000600260015414156105b25760405162461bcd60e51b815260040161040c90611f9a565b600260015560006105cf888888886104e9368a90038a018a611e34565b90506105dc8a828b611421565b91506105f26001600160a01b038b1633846114a2565b604080518881526020810184905290810184905233906001600160a01b038c811691908b16907f824d347b9cee60e7fd0533596f246476ec3a93b42c381ed12170ef1f42a75f9e9060600160405180910390a4506001805598975050505050505050565b60007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316826001600160a01b0316141580156106a257506001600160a01b03821615155b801561074457506040516319f3736160e01b81526001600160a01b0383811660048301527f000000000000000000000000000000000000000000000000000000000000000016906319f373619060240160206040518083038186803b15801561070a57600080fd5b505afa15801561071e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107429190611e14565b155b92915050565b6002600154141561076d5760405162461bcd60e51b815260040161040c90611f9a565b600260015561077b82610902565b6107975760405162461bcd60e51b815260040161040c90611f63565b6001600160a01b0382166000908152600360205260408120546107c283670de0b6b3a7640000612009565b6107cc9190611fe9565b90506107d98333846114d7565b6000806107e58561109c565b90925090506000670de0b6b3a76400006107ff8486612009565b6108099190611fe9565b90506000670de0b6b3a76400006108208487612009565b61082a9190611fe9565b90506108436108398386612028565b61054f8386612028565b6001600160a01b0380891660009081526002602052604090209190915561088d907f00000000000000000000000000000000000000000000000000000000000000001633846114a2565b6108a16001600160a01b03881633836114a2565b6001600160a01b0387166000818152600360209081526040918290205482518a8152918201523392917f30c77c0c787eb0ec5c1a0f57808bcba3adccf40f465be7d70318e3c24d212197910160405180910390a35050600180555050505050565b6001600160a01b0316600090815260036020526040902054151590565b6000600260015414156109445760405162461bcd60e51b815260040161040c90611f9a565b60026001819055507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316866001600160a01b031614156109ce5760405162461bcd60e51b815260206004820152601f60248201527f436c6970706572436f76653a204e6f74207472616461626c65206173796e6300604482015260640161040c565b6000806109da8861109c565b9150915060006109e9896115b5565b90507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316886001600160a01b031614610af757610a2d89610902565b8015610a3d5750610a3d88610902565b610a595760405162461bcd60e51b815260040161040c90611f63565b600080610a658a61109c565b90925090506000610a828587610a7b8288612028565b6000611685565b9050610a908383838d611685565b9650610aa5610a9f8288612028565b8561132a565b6001600160a01b038d16600090815260026020526040902055610ad5610acb8285611fd1565b61054f8985612028565b6001600160a01b038c1660009081526002602052604090205550610b0e915050565b610b0b89610b058484612028565b8961178b565b93505b610b226001600160a01b03891687866114a2565b856001600160a01b0316886001600160a01b03168a6001600160a01b03167f824d347b9cee60e7fd0533596f246476ec3a93b42c381ed12170ef1f42a75f9e8585610b6d9190612028565b60408051918252602082018a905281018a905260600160405180910390a45050600180555095945050505050565b6000546001600160a01b03163314610bc55760405162461bcd60e51b815260040161040c90611f2e565b610bcf60006117e7565b565b600060026001541415610bf65760405162461bcd60e51b815260040161040c90611f9a565b60026001556001600160a01b038781167f000000000000000000000000000000000000000000000000000000000000000082168181149288161490610c3d9033308b6112b9565b81158015610c49575080155b15610d3057610c5789610902565b8015610c675750610c6787610902565b610c835760405162461bcd60e51b815260040161040c90611f63565b6000806000610c918c61109c565b91509150610ca281838d6000611685565b9250610cbb610cb18484612028565b61054f8d84611fd1565b6001600160a01b038d166000908152600260205260408120919091559150819050610ce58a61109c565b91509150610cf58282858c611685565b9550610d0e610d048484611fd1565b61054f8884612028565b6001600160a01b038b1660009081526002602052604090205550610d59915050565b8115610d4857610d41878988611421565b9250610d59565b801561012a57610d4189898861178b565b610d6d6001600160a01b03881686856114a2565b60408051898152602081018590529081018590526001600160a01b0380871691898216918c16907f824d347b9cee60e7fd0533596f246476ec3a93b42c381ed12170ef1f42a75f9e9060600160405180910390a45050600180559695505050505050565b600080546001600160a01b03163314610dfc5760405162461bcd60e51b815260040161040c90611f2e565b5060058054600090915560405163a9059cbb60e01b8152336004820152602481018290527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03169063a9059cbb90604401602060405180830381600087803b158015610e6e57600080fd5b505af1158015610e82573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ea69190611e14565b5090565b60006001600160a01b038481167f00000000000000000000000000000000000000000000000000000000000000008216908114918416148280610eec8861109c565b91509150600080610efc8861109c565b9150915085158015610f0c575084155b15610f7257610f1a8a610902565b8015610f2a5750610f2a88610902565b610f465760405162461bcd60e51b815260040161040c90611f63565b6000610f5584868c6000611685565b9050610f648383836000611685565b975050505050505050610ffa565b8515610fb757610f8188610902565b610f9d5760405162461bcd60e51b815260040161040c90611f63565b610faa82828b6000611685565b9650505050505050610ffa565b8415610fef57610fc68a610902565b610fe25760405162461bcd60e51b815260040161040c90611f63565b610faa83858b6000611685565b600096505050505050505b9392505050565b6000546001600160a01b0316331461102b5760405162461bcd60e51b815260040161040c90611f2e565b6001600160a01b0381166110905760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b606482015260840161040c565b611099816117e7565b50565b6001600160a01b0316600090815260026020526040902054608081901c916001600160801b0390911690565b6000610ffa6110d78385612009565b611837565b60006001600160a01b03861615611127576111226001600160a01b038716337f0000000000000000000000000000000000000000000000000000000000000000886112b9565b6111bb565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316635aecdda56040518163ffffffff1660e01b815260040160206040518083038186803b15801561118057600080fd5b505afa158015611194573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111b89190611bac565b95505b604080516387e08c2560e01b81523060048201526001600160a01b03888116602483015260448201889052600060648301526084820187905260a48201869052845160ff1660c4830152602085015160e4830152918401516101048201527f0000000000000000000000000000000000000000000000000000000000000000909116906387e08c25903490610124016000604051808303818588803b15801561126357600080fd5b505af1158015611277573d6000803e3d6000fd5b50505050506112858461186d565b9050808411156112b0576112998185612028565b600560008282546112aa9190611fd1565b90915550505b95945050505050565b6040516001600160a01b03808516602483015283166044820152606481018290526113249085906323b872dd60e01b906084015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152611896565b50505050565b600061133582611968565b6001600160801b03169050608061134b84611968565b6001600160801b0316901b81610ffa9190611fd1565b600081156113aa576001600160a01b038416600090815260036020526040902054828161138e8287612028565b6113989190612009565b6113a29190611fe9565b9150506113bb565b6113b8836305f5e100612009565b90505b6113c68433836119d1565b6001600160a01b038416600081815260036020908152604091829020548251858152918201523392917f441124588da230790bd3b0c494e2bc687c5c2b95e6882164cd77881957d60017910160405180910390a39392505050565b600061142c84610902565b6114485760405162461bcd60e51b815260040161040c90611f63565b6000806114548661109c565b9150915061146482828787611685565b925061147d6114738684611fd1565b61054f8584612028565b6001600160a01b03909616600090815260026020526040902095909555509392505050565b6040516001600160a01b0383166024820152604481018290526114d290849063a9059cbb60e01b906064016112ed565b505050565b6001600160a01b038084166000908152600460209081526040808320938616835292905220548111156115625760405162461bcd60e51b815260206004820152602d60248201527f436c6970706572436f76653a204275726e20616d6f756e74206578636565647360448201526c20757365722062616c616e636560981b606482015260840161040c565b6001600160a01b038084166000818152600460209081526040808320948716835293815283822080548690039055918152600390915290812080548392906115ab908490612028565b9091555050505050565b604080513060248083019190915282518083039091018152604490910182526020810180516001600160e01b03166370a0823160e01b1790529051600091829182916001600160a01b0386169161160c9190611edf565b600060405180830381855afa9150503d8060008114611647576040519150601f19603f3d011682016040523d82523d6000602084013e61164c565b606091505b509150915081801561166057506020815110155b61166957600080fd5b8080602001905181019061167d9190611ea6565b949350505050565b60008083116116ce5760405162461bcd60e51b815260206004820152601560248201527410db1a5c1c195c90dbdd994e88139bc8125b9c1d5d605a1b604482015260640161040c565b6000612710846007546127106116e49190612028565b6116ee9190612009565b6116f89190611fe9565b90506117048682611fd1565b61170e8683612009565b6117189190611fe9565b915084821115611726578491505b828210156117825760405162461bcd60e51b8152602060048201526024808201527f436c6970706572436f76653a20496e73756666696369656e742062757920616d6044820152631bdd5b9d60e21b606482015260840161040c565b50949350505050565b600061179684610902565b6117b25760405162461bcd60e51b815260040161040c90611f63565b6000806117be8661109c565b915091506117ce81838787611685565b925061147d6117dd8484612028565b61054f8784611fd1565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6000670853a0d2313c000082046e4742688f149ec8077594740000000083116118635750600160028304015b610ffa8382611a35565b60006127106006546127106118829190612028565b61188c9084612009565b6107449190611fe9565b60006118eb826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316611a6e9092919063ffffffff16565b8051909150156114d257808060200190518101906119099190611e14565b6114d25760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b606482015260840161040c565b60006001600160801b03821115610ea65760405162461bcd60e51b815260206004820152602760248201527f53616665436173743a2076616c756520646f65736e27742066697420696e20316044820152663238206269747360c81b606482015260840161040c565b6001600160a01b03808416600090815260046020908152604080832093861683529290529081208054839290611a08908490611fd1565b90915550506001600160a01b038316600090815260036020526040812080548392906115ab908490611fd1565b6000825b80831015610ffa575081600181808681611a6357634e487b7160e01b600052601260045260246000fd5b0401901c9250611a39565b606061167d848460008585843b611ac75760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015260640161040c565b600080866001600160a01b03168587604051611ae39190611edf565b60006040518083038185875af1925050503d8060008114611b20576040519150601f19603f3d011682016040523d82523d6000602084013e611b25565b606091505b5091509150611b35828286611b40565b979650505050505050565b60608315611b4f575081610ffa565b825115611b5f5782518084602001fd5b8160405162461bcd60e51b815260040161040c9190611efb565b600060608284031215611b8a578081fd5b50919050565b600060208284031215611ba1578081fd5b8135610ffa81612081565b600060208284031215611bbd578081fd5b8151610ffa81612081565b60008060408385031215611bda578081fd5b8235611be581612081565b91506020830135611bf581612081565b809150509250929050565b600080600080600060a08688031215611c17578081fd5b8535611c2281612081565b94506020860135611c3281612081565b9350604086013592506060860135611c4981612081565b949793965091946080013592915050565b60008060408385031215611c6c578182fd5b8235611c7781612081565b946020939093013593505050565b600080600060608486031215611c99578283fd5b8335611ca481612081565b9250602084013591506040840135611cbb81612081565b809150509250925092565b60008060008060008060c08789031215611cde578081fd5b8635611ce981612081565b9550602087013594506040870135611d0081612081565b9350606087013592506080870135611d1781612081565b8092505060a087013590509295509295509295565b6000806000806000806000610120888a031215611d47578081fd5b8735611d5281612081565b9650602088013595506040880135611d6981612081565b9450606088013593506080880135925060a08801359150611d8d8960c08a01611b79565b905092959891949750929550565b600080600080600080600080610140898b031215611db7578081fd5b8835611dc281612081565b9750602089013596506040890135611dd981612081565b9550606089013594506080890135935060a08901359250611dfd8a60c08b01611b79565b915061012089013590509295985092959890939650565b600060208284031215611e25578081fd5b81518015158114610ffa578182fd5b600060608284031215611e45578081fd5b6040516060810181811067ffffffffffffffff82111715611e7457634e487b7160e01b83526041600452602483fd5b604052823560ff81168114611e87578283fd5b8152602083810135908201526040928301359281019290925250919050565b600060208284031215611eb7578081fd5b5051919050565b60008060408385031215611ed0578182fd5b50508035926020909101359150565b60008251611ef181846020870161203f565b9190910192915050565b6020815260008251806020840152611f1a81604085016020870161203f565b601f01601f19169190910160400192915050565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b60208082526017908201527f436c6970706572436f76653a204e6f7420747261646564000000000000000000604082015260600190565b6020808252601f908201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604082015260600190565b60008219821115611fe457611fe461206b565b500190565b60008261200457634e487b7160e01b81526012600452602481fd5b500490565b60008160001904831182151516156120235761202361206b565b500290565b60008282101561203a5761203a61206b565b500390565b60005b8381101561205a578181015183820152602001612042565b838111156113245750506000910152565b634e487b7160e01b600052601160045260246000fd5b6001600160a01b038116811461109957600080fdfea26469706673582212209eac6cbaabf25bdbfdaa3909fc7f5f06864da1138fe9e1b15dce299dc0233c6364736f6c63430008040033000000000000000000000000ce37051a3e60587157dc4c0391b4c555c6e6825500000000000000000000000000000000000000000000000000000000000000050000000000000000000000000000000000000000000000000000000000000000

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

000000000000000000000000ce37051a3e60587157dc4c0391b4c555c6e6825500000000000000000000000000000000000000000000000000000000000000050000000000000000000000000000000000000000000000000000000000000000

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

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


Block Transaction Gas Used Reward
Age Block Fee Address BC Fee Address Voting Power Jailed Incoming
Block Uncle Number Difficulty Gas Used Reward
Loading
Make sure to use the "Vote Down" button for any spammy posts, and the "Vote Up" for interesting conversations.