Contract 0x593Ab53baFfaF1E821845cf7080428366F030a9c 1

 

Contract Overview

Coffin Finance: COFFIN Token
Balance:
0 FTM

FTM Value:
$0.00
Txn Hash Method
Block
From
To
Value [Txn Fee]
0x9f2999b88dcce6e64b00f6dc943001e825d9e3cc054a4cf42e1c8cf6106ea372Approve546806172023-01-29 20:49:461 hr 11 mins ago0xee0a97e3701b73b3e092891a0ee033f678623e04 IN  Coffin Finance: COFFIN Token0 FTM0.002238384021
0x8a772c6028fd1339ed0160007a7f4aea9c083bdb3cf4b801758bfef4717a93f8Approve546610592023-01-29 12:48:159 hrs 13 mins ago0x42a1ef5ffdaf134eb958814e443db9c244375c8f IN  Coffin Finance: COFFIN Token0 FTM0.00248698637
0x609558000eb334c6017c9ab9fd2b6b1d49dc050920515f91429082311845303eApprove546581572023-01-29 11:53:2210 hrs 8 mins ago0xee88c9b7321cd55f339323df2db0f5cb98161695 IN  Coffin Finance: COFFIN Token0 FTM0.001935621231
0x6f65ccd79d5da32364bef1339098289bb0fd60d1657a489db1e1063a05ac5efeTransfer542922882023-01-23 18:55:576 days 3 hrs ago0xf8e94a2ac949fa4b214397eacb58c09fad6b3a61 IN  Coffin Finance: COFFIN Token0 FTM0.02106286
0xdb9474387780954055060cf37437569452857233e226ba584dfde487059fc699Approve541251712023-01-21 6:09:528 days 15 hrs ago0xf51989555d4a7d5b9750de43a8a8b1945ab33439 IN  Coffin Finance: COFFIN Token0 FTM0.00313808
0xe3bbd57832fc57c978a71da266d8822bb0865487ccf4eed3ca7f60bd4fff4847Approve541248712023-01-21 6:04:598 days 15 hrs ago0xf51989555d4a7d5b9750de43a8a8b1945ab33439 IN  Coffin Finance: COFFIN Token0 FTM0.00510818
0xba8f69faceb1db9a368dc8f80b834eb0fd044c950ab0970b8dcace0d8ef25899Approve540865302023-01-20 17:39:519 days 4 hrs ago0x04b0a112ffc0e3eb8df1fd8cc370a1e30a53baa9 IN  Coffin Finance: COFFIN Token0 FTM0.001897184003
0x259c256a7c7e8c33482e86aa4cf8514385a0581c9ef9b015f046078d38e0597aApprove540863902023-01-20 17:37:239 days 4 hrs ago0x04b0a112ffc0e3eb8df1fd8cc370a1e30a53baa9 IN  Coffin Finance: COFFIN Token0 FTM0.001897184003
0x35601c02e3dddb958d7095e135bc21225ee0e48bce72f0e89f25351d21dc5850Transfer540791212023-01-20 14:24:199 days 7 hrs ago0xf6b5b7a183bafa19dbefcc073f7b2697c311869e IN  Coffin Finance: COFFIN Token0 FTM0.004876418551
0xde197bcb1305abd07bc16e7ffca0766ca5e4f03d835300265c2c4cdf39b777b9Approve540557492023-01-19 23:03:109 days 22 hrs ago0xe6c278a529266bba3445b0cc25e162641f0a0e2c IN  Coffin Finance: COFFIN Token0 FTM0.00167206011
0xd9706495a83eefc383c8c02685e2a57588117cede9c6c804cdf0df28d26e66c0Approve540430382023-01-19 17:57:2110 days 4 hrs ago0xfe329c5370748b25cdb214048a697315d1666a27 IN  Coffin Finance: COFFIN Token0 FTM0.001822260492
0x7fe4bb9ad59c1df643bed52fe428db9e98fec476f6c0406488d2aa1b51591264Approve540285282023-01-19 9:32:3710 days 12 hrs ago0x95a877173ffe90a57e90d376ace7b77aeb2a8f95 IN  Coffin Finance: COFFIN Token0 FTM0.001240337952
0xdaaf7ae4e42ffe3525cf430d9e9f75ef6a21f2ef8e6141e35bbcce556e392488Approve539798812023-01-18 11:28:5711 days 10 hrs ago0xe6d42211c81a40ffb2d1db919d4b0fbc4e7630f5 IN  Coffin Finance: COFFIN Token0 FTM0.000968620197
0x191265500cfd1523fe0e943703e5ac1620c172e113504649a9386cd18464df5dApprove537193252023-01-13 23:43:4615 days 22 hrs ago0xf51989555d4a7d5b9750de43a8a8b1945ab33439 IN  Coffin Finance: COFFIN Token0 FTM0.0046866
0x4b6b6c72305687ca0b4ff6e23bac369752bc5dc367553447e4dc9927ebddabf6Approve533950432023-01-07 18:13:2122 days 3 hrs ago0x2dfa923fa80e5ef56661c4caa010df8f484634c8 IN  Coffin Finance: COFFIN Token0 FTM0.000725751514
0xaa9b0f9d4e96d6248fa45f72e420701781d1095e107b78af336a6c9b1734a78fApprove533923202023-01-07 16:55:3422 days 5 hrs ago0xf51989555d4a7d5b9750de43a8a8b1945ab33439 IN  Coffin Finance: COFFIN Token0 FTM0.002624496
0xd7e825f6c5f4c9437f9b4fd8d3bfe6ebc8b109117f5847a70ed13286b027504fApprove533611782023-01-07 1:21:1422 days 20 hrs ago0x54ba3ff9ddbd2dee95cda54e863b07b0cdad2ee4 IN  Coffin Finance: COFFIN Token0 FTM0.001909191864
0x3a772effa494d2fa91765b65610b7bcaaaa66f18cba5128edb857aac517a202fApprove531972732023-01-04 5:22:5025 days 16 hrs ago0x2b9f4d7fc4312485bcbf3e7f7e0ed778cd21b36d IN  Coffin Finance: COFFIN Token0 FTM0.004679656387
0x044462247bc97d02069b6ae1392cf5cdfbe3993228216a0cb5b834c192b2f75aApprove530636992023-01-01 0:34:0128 days 21 hrs ago0x218d75b17f491793a96ab4326c7875950359a80c IN  Coffin Finance: COFFIN Token0 FTM0.001967264822
0x0e4c22f2daceed94f640af26e993fd40356f6f43243c8a30c28da5a3870564afApprove530627962022-12-31 23:40:2528 days 22 hrs ago0x40f8515449d65e259562e2782259467ea5f85f5c IN  Coffin Finance: COFFIN Token0 FTM0.008384441192
0xba70207952b8ea7df63645bcb7565fc9dc38c65f77a24c507dee65be916bba98Approve530556482022-12-31 14:25:2829 days 7 hrs ago0xff78ad09bd572c0c2909aa1c473c766397b0c075 IN  Coffin Finance: COFFIN Token0 FTM0.012812514185
0xa4ca606539c5f9273e96a5b9d7ea65581ce16398797d262f952e74f3b106bda4Approve530195332022-12-29 22:09:2230 days 23 hrs ago0x40f8515449d65e259562e2782259467ea5f85f5c IN  Coffin Finance: COFFIN Token0 FTM0.003190899559
0xba8dbbaf159b84c5064cbd088ac632a5b6c620f6a91a51d02bcf2e5925f3dbc1Approve530195172022-12-29 22:07:5430 days 23 hrs ago0x40f8515449d65e259562e2782259467ea5f85f5c IN  Coffin Finance: COFFIN Token0 FTM0.084267437749
0x4e2334d97b945bd8980df11ade5e63f2c037402725e56b771e48afbc6eb685dcApprove530195172022-12-29 22:07:5430 days 23 hrs ago0x40f8515449d65e259562e2782259467ea5f85f5c IN  Coffin Finance: COFFIN Token0 FTM0.003065237131
0xaf7c97bd2978f4b1c46a44037168818d9b948ee91751cc5ec0a76332927d2413Approve529111292022-12-27 1:47:4833 days 20 hrs ago0x3d6e4a3857edb49d0704e1940cacf5b8512d121b IN  Coffin Finance: COFFIN Token0 FTM0.001059056404
[ Download CSV Export 

OVERVIEW

Decentralized and capital-efficient partially collateralized stablecoin protocol on Fantom Opera!

Latest 1 internal transaction
Parent Txn Hash Block From To Value
0x0194b0214aed0c5f0d886064802e8fd5cee2e00abc76597058fbd2e940c902f0183122362021-10-04 20:40:18482 days 1 hr ago Coffin Finance: Deployer  Contract Creation0 FTM
[ Download CSV Export 
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
Coffin

Compiler Version
v0.8.7+commit.e28d00a7

Optimization Enabled:
Yes with 500 runs

Other Settings:
default evmVersion

Contract Source Code (Solidity Standard Json-Input format)

File 1 of 20 : Coffin.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.7;

import "@openzeppelin/contracts/proxy/utils/Initializable.sol";
import "./TaxableToken.sol";

contract Coffin is TaxableToken, Initializable {
    using SafeMath for uint256;
    uint256 public constant genesis_supply = 3_000_000 ether; // for initial liquidity. 
    // 
    uint256 public constant REWARD_ALLOCATION = 97_000_000 ether; // 
    uint256 public rewardClaimed;
    function init(
        address _maker
    ) external initializer onlyOwner {
        coffin_pools[_maker] = true;
        coffin_pools_array.push(_maker);

        // coffin_pools[msg.sender] = true;
        // coffin_pools_array.push(msg.sender);
        
        _mint(msg.sender, genesis_supply);
    }

    function reward_mint(address recipient, uint256 amount) public onlyPools {
        require(amount > 0, "invalidAmount");
        require(recipient != address(0), "!rewardController");
        uint256 _remainingRewards = REWARD_ALLOCATION - rewardClaimed;
        require(amount <= _remainingRewards, "exceedRewards");
        rewardClaimed = rewardClaimed + amount;
        super._mint(recipient, amount);
        emit Minted(msg.sender, recipient, amount);
    }
    
    // constructor() TaxableToken("TestToken", "testSHARE") {}
    constructor() TaxableToken("CoffinToken", "COFFIN") {}

    event MaxTotalSupplyUpdated(uint256 _newCap);
}

File 2 of 20 : Initializable.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

/**
 * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed
 * behind a proxy. Since a proxied contract can't have a constructor, it's common to move constructor logic to an
 * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer
 * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.
 *
 * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as
 * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.
 *
 * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure
 * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.
 */
abstract contract Initializable {
    /**
     * @dev Indicates that the contract has been initialized.
     */
    bool private _initialized;

    /**
     * @dev Indicates that the contract is in the process of being initialized.
     */
    bool private _initializing;

    /**
     * @dev Modifier to protect an initializer function from being invoked twice.
     */
    modifier initializer() {
        require(_initializing || !_initialized, "Initializable: contract is already initialized");

        bool isTopLevelCall = !_initializing;
        if (isTopLevelCall) {
            _initializing = true;
            _initialized = true;
        }

        _;

        if (isTopLevelCall) {
            _initializing = false;
        }
    }
}

File 3 of 20 : TaxableToken.sol
// SPDX-License-Identifier: MIT
// coffin finance
pragma solidity ^0.8.7;
// pragma experimental ABIEncoderV2;

import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Burnable.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/utils/math/SafeMath.sol";
import "./CoffinOracle.sol";
import "./PoolToken.sol";
import "./libs/Babylonian.sol";
import './interfaces/ITaxableTokenPolicy.sol';

contract TaxableToken is PoolToken {
    using SafeMath for uint256;
    address public coffinOracle;
    // fixed tax rate
    uint16 public staticTaxRate = 0;
    // latest tax rate
    uint16 public latestTaxRate = 0;
    // Address of the Tax Office
    address public taxOffice;
    // Address of the tax collector wallet
    address public taxCollectorAddress;
    // Tax Policy
    address public policy; 
    // 
    bool public using_twap;
    // Dollar Price threshold below which taxes will get burned
    uint256 public burnThreshold = 0.98e18;
    uint256 public taxThreshold = 1e18;
    //
    bool public taxActivated = false;
    bool public autoCalculateTax = false;
    address public constant BURN_ADDRESS = 0x000000000000000000000000000000000000dEaD;

    uint16 public maxTaxRate = 2000;

    // basis tax rate. 0.05% by default.
    // believe it should be bigger than flashloan fee.
    //  C.R.E.A.M => 0.03% , AAVE => 0.09%.
    uint16 public basisTaxRate = 5;
    uint32 public adjustTaxRateA = 2000000;
    uint32 public adjustTaxRateB = 4;

    mapping(address => bool) private _isExcluded;
    address[] private _excluded;

    // modifier
    modifier onlyOwnerOrTaxOffice() {
        require(
            owner() == msg.sender || taxOffice == msg.sender,
            "Caller is not the owner or the tax office"
        );
        _;
    }

    // constructor
    constructor(string memory _name, string memory _symbol)
        PoolToken(_name, _symbol)
    {}

    // internal

    // get current coUSD price
    function _getCoUSDPrice() public view returns (uint256 _price) {
        if (using_twap) {
            (uint256 __price, uint8 __d) = ICoffinOracle(coffinOracle)
                .getTwapCOUSDUSD();
            _price = __price * (10**(18 - __d));
        } else {
            (uint256 __price, uint8 __d) = ICoffinOracle(coffinOracle)
                .getCOUSDUSD();
            _price = __price * (10**(18 - __d));
        }
    }
    function setTaxPolicy(address _policy) external onlyOwner {
        require(_policy!=address(0), 'wrong tax policy' );
        policy = _policy;
    }
    function calcAutoTaxRate(uint256 _cousdPrice) public view returns (uint16) {
        if (policy==address(0)) {
            return 0;
        }

        return ITaxableTokenPolicy(policy).calcTaxRate(
            _cousdPrice, 
            taxThreshold, 
            adjustTaxRateA, 
            adjustTaxRateB, 
            basisTaxRate,
            maxTaxRate
        );
    }

    function getTaxInfo()
        private
        view
        returns (
            uint16 _currentTaxRate,
            uint16 _staticTaxRate,
            uint256 _burnThreshold,
            uint256 _taxThreshold,
            bool _taxActivated,
            bool _autoCalculateTax,
            uint16 _maxTaxRate,
            uint32 _adjustTaxRateA,
            bool _burnTax,
            uint256 _currentCoUSDPrice,
            uint256 __rawPrice,
            uint8 __rawDecimal,
            uint32 _adjustTaxRateB
        )
    {
        _burnThreshold = burnThreshold;
        _taxThreshold = taxThreshold;
        _taxActivated = taxActivated;
        _autoCalculateTax = autoCalculateTax;
        _maxTaxRate = maxTaxRate;
        _adjustTaxRateA = adjustTaxRateA;
        _staticTaxRate = staticTaxRate;
        (_currentTaxRate, _burnTax, _currentCoUSDPrice) = _getTaxInfo();
        (__rawPrice, __rawDecimal) = ICoffinOracle(coffinOracle).getCOUSDUSD();
        _adjustTaxRateB = adjustTaxRateB;
    }

    function _getTaxInfo()
        private
        view
        returns (
            uint16 currentTaxRate,
            bool burnTax,
            uint256 currentCoUSDPrice
        )
    {
        if (taxActivated) {
            (currentCoUSDPrice) = _getCoUSDPrice();
            if (currentCoUSDPrice > 0 && currentCoUSDPrice < taxThreshold) {
                if (currentCoUSDPrice < burnThreshold) {
                    burnTax = true;
                }
                if (autoCalculateTax) {
                    currentTaxRate = calcAutoTaxRate(currentCoUSDPrice);
                } else {
                    currentTaxRate = staticTaxRate;
                }
            }
        }
    }
    
    function _transfer(
        address sender,
        address recipient,
        uint256 amount
    ) internal override {
        require(sender != address(0), "ERC20: transfer from the zero address");
        require(recipient != address(0), "ERC20: transfer to the zero address");
        require(amount > 0, "Transfer amount must be greater than zero");
        
        
        (uint16 currentTaxRate, bool burnTax, ) = _getTaxInfo();

        latestTaxRate = currentTaxRate;
        if (
            currentTaxRate == 0 ||
            coffin_pools[sender] ||
            coffin_pools[recipient] ||
            _isExcluded[sender] ||
            _isExcluded[recipient]
        ) {
            super._transfer(sender, recipient, amount);
        } else {
            _transferWithTax(
                sender,
                recipient,
                amount,
                currentTaxRate,
                burnTax
            );
        }
        
    }


    function _transferWithTax(
        address sender,
        address recipient,
        uint256 amount,
        uint16 _taxRate,
        bool burnTax
    ) internal returns (bool) {

        if (_taxRate>maxTaxRate) {
            _taxRate = maxTaxRate;
        }

        uint256 taxAmount = amount.mul(_taxRate).div(10000);
        uint256 amountAfterTax = amount.sub(taxAmount);

        require(taxAmount < amount, "the tax amount should be less than the transferred amount.");

        if (burnTax) {
            // Burn tax
            if (taxAmount>0) {
                super._burn(sender, taxAmount);
            }
        } else {
            // Transfer tax to tax collector
            if (taxAmount>0) {
                super._transfer(sender, taxCollectorAddress, taxAmount);
            }   
        }

        // Transfer amount after tax to recipient
        if (amountAfterTax>0) {
            super._transfer(sender, recipient, amountAfterTax);
        }
        
        return true;
    }

    /********** onlyOwnerOrTaxOffice ************/
    // set coffinOracle
    function setCoffinOracle(address _coffinOracle)
        public
        onlyOwnerOrTaxOffice
    {
        require(
            _coffinOracle != address(0),
            "oracle address cannot be 0 address"
        );
        coffinOracle = _coffinOracle;
    }

    function enableAutoCalculateTax() public onlyOwnerOrTaxOffice {
        autoCalculateTax = true;
    }

    function disableAutoCalculateTax() public onlyOwnerOrTaxOffice {
        autoCalculateTax = false;
    }
    
    function enableTwap() public onlyOwnerOrTaxOffice {
        using_twap = true;
    }

    function disablTwap() public onlyOwnerOrTaxOffice {
        using_twap = false;
    }

    function enableTax() public onlyOwnerOrTaxOffice {
        taxActivated = true;
    }

    function disableTax() public onlyOwnerOrTaxOffice {
        taxActivated = false;
    }

    function setTaxOffice(address _taxOffice) public onlyOwnerOrTaxOffice {
        require(
            _taxOffice != address(0),
            "tax office address cannot be 0 address"
        );
        emit TaxOfficeTransferred(taxOffice, _taxOffice);
        taxOffice = _taxOffice;
    }

    function setTaxCollectorAddress(address _taxCollectorAddress)
        public
        onlyOwnerOrTaxOffice
    {
        require(
            _taxCollectorAddress != address(0),
            "tax collector address must be non-zero address"
        );
        taxCollectorAddress = _taxCollectorAddress;
    }



    function excludeAddressFromTax(address account)
        external
        onlyOwnerOrTaxOffice
        returns (bool)
    {
        require(!_isExcluded[account], "Account is already excluded");
        _isExcluded[account] = true;
        return true;
    }

    function includeAddressInTax(address account)
        external
        onlyOwnerOrTaxOffice
        returns (bool)
    {
        require(_isExcluded[account], "Account is already included");
        _isExcluded[account] = false;
        return true;
    }

    function isExcluded(address account) public view returns (bool) {
        return _isExcluded[account];
    }

    function setTaxThreshold(uint256 _taxThreshold)
        public
        onlyOwnerOrTaxOffice
        returns (bool)
    {
        taxThreshold = _taxThreshold;
        return true;
    }

    function setBurnThreshold(uint256 _burnThreshold)
        public
        onlyOwnerOrTaxOffice
        returns (bool)
    {
        burnThreshold = _burnThreshold;
        return true;
    }

    function setStaticTaxRate(uint16 _staticTaxRate)
        public
        onlyOwnerOrTaxOffice
    {
        require(staticTaxRate < 2500, "Tax rates are too high. ");
        staticTaxRate = _staticTaxRate;
    }

    function setBasisTaxRate(uint16 _basisTaxRate) public onlyOwnerOrTaxOffice {
        require(basisTaxRate < 300, "basis tax rates should be only few. ");
        basisTaxRate = _basisTaxRate;
    }

    function setMaxTaxRate(uint16 _maxTaxRate) public onlyOwnerOrTaxOffice {
        require(_maxTaxRate < 5000, "Tax rates are too high.");
        maxTaxRate = _maxTaxRate;
    }

    function setAdjustTaxRateA(uint32 _adjustTaxRate)
        public
        onlyOwnerOrTaxOffice
    {
        // for adjustmentA
        adjustTaxRateA = _adjustTaxRate;
    }

    function setAdjustTaxRateB(uint32 _adjustTaxRate)
        public
        onlyOwnerOrTaxOffice
    {
        // for adjustmentB
        adjustTaxRateB = _adjustTaxRate;
    }

    event TaxOfficeTransferred(address oldAddress, address newAddress);
}

File 4 of 20 : ERC20Burnable.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

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

/**
 * @dev Extension of {ERC20} that allows token holders to destroy both their own
 * tokens and those that they have an allowance for, in a way that can be
 * recognized off-chain (via event analysis).
 */
abstract contract ERC20Burnable is Context, ERC20 {
    /**
     * @dev Destroys `amount` tokens from the caller.
     *
     * See {ERC20-_burn}.
     */
    function burn(uint256 amount) public virtual {
        _burn(_msgSender(), amount);
    }

    /**
     * @dev Destroys `amount` tokens from `account`, deducting from the caller's
     * allowance.
     *
     * See {ERC20-_burn} and {ERC20-allowance}.
     *
     * Requirements:
     *
     * - the caller must have allowance for ``accounts``'s tokens of at least
     * `amount`.
     */
    function burnFrom(address account, uint256 amount) public virtual {
        uint256 currentAllowance = allowance(account, _msgSender());
        require(currentAllowance >= amount, "ERC20: burn amount exceeds allowance");
        unchecked {
            _approve(account, _msgSender(), currentAllowance - amount);
        }
        _burn(account, amount);
    }
}

File 5 of 20 : Ownable.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

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

File 6 of 20 : SafeMath.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

// CAUTION
// This version of SafeMath should only be used with Solidity 0.8 or later,
// because it relies on the compiler's built in overflow checks.

/**
 * @dev Wrappers over Solidity's arithmetic operations.
 *
 * NOTE: `SafeMath` is no longer needed starting with Solidity 0.8. The compiler
 * now has built in overflow checking.
 */
library SafeMath {
    /**
     * @dev Returns the addition of two unsigned integers, with an overflow flag.
     *
     * _Available since v3.4._
     */
    function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            uint256 c = a + b;
            if (c < a) return (false, 0);
            return (true, c);
        }
    }

    /**
     * @dev Returns the substraction of two unsigned integers, with an overflow flag.
     *
     * _Available since v3.4._
     */
    function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            if (b > a) return (false, 0);
            return (true, a - b);
        }
    }

    /**
     * @dev Returns the multiplication of two unsigned integers, with an overflow flag.
     *
     * _Available since v3.4._
     */
    function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            // Gas optimization: this is cheaper than requiring 'a' not being zero, but the
            // benefit is lost if 'b' is also tested.
            // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
            if (a == 0) return (true, 0);
            uint256 c = a * b;
            if (c / a != b) return (false, 0);
            return (true, c);
        }
    }

    /**
     * @dev Returns the division of two unsigned integers, with a division by zero flag.
     *
     * _Available since v3.4._
     */
    function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            if (b == 0) return (false, 0);
            return (true, a / b);
        }
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.
     *
     * _Available since v3.4._
     */
    function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            if (b == 0) return (false, 0);
            return (true, a % b);
        }
    }

    /**
     * @dev Returns the addition of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `+` operator.
     *
     * Requirements:
     *
     * - Addition cannot overflow.
     */
    function add(uint256 a, uint256 b) internal pure returns (uint256) {
        return a + b;
    }

    /**
     * @dev Returns the subtraction of two unsigned integers, reverting on
     * overflow (when the result is negative).
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     *
     * - Subtraction cannot overflow.
     */
    function sub(uint256 a, uint256 b) internal pure returns (uint256) {
        return a - b;
    }

    /**
     * @dev Returns the multiplication of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `*` operator.
     *
     * Requirements:
     *
     * - Multiplication cannot overflow.
     */
    function mul(uint256 a, uint256 b) internal pure returns (uint256) {
        return a * b;
    }

    /**
     * @dev Returns the integer division of two unsigned integers, reverting on
     * division by zero. The result is rounded towards zero.
     *
     * Counterpart to Solidity's `/` operator.
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function div(uint256 a, uint256 b) internal pure returns (uint256) {
        return a / b;
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * reverting when dividing by zero.
     *
     * Counterpart to Solidity's `%` operator. This function uses a `revert`
     * opcode (which leaves remaining gas untouched) while Solidity uses an
     * invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function mod(uint256 a, uint256 b) internal pure returns (uint256) {
        return a % b;
    }

    /**
     * @dev Returns the subtraction of two unsigned integers, reverting with custom message on
     * overflow (when the result is negative).
     *
     * CAUTION: This function is deprecated because it requires allocating memory for the error
     * message unnecessarily. For custom revert reasons use {trySub}.
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     *
     * - Subtraction cannot overflow.
     */
    function sub(
        uint256 a,
        uint256 b,
        string memory errorMessage
    ) internal pure returns (uint256) {
        unchecked {
            require(b <= a, errorMessage);
            return a - b;
        }
    }

    /**
     * @dev Returns the integer division of two unsigned integers, reverting with custom message on
     * division by zero. The result is rounded towards zero.
     *
     * Counterpart to Solidity's `/` operator. Note: this function uses a
     * `revert` opcode (which leaves remaining gas untouched) while Solidity
     * uses an invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function div(
        uint256 a,
        uint256 b,
        string memory errorMessage
    ) internal pure returns (uint256) {
        unchecked {
            require(b > 0, errorMessage);
            return a / b;
        }
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * reverting with custom message when dividing by zero.
     *
     * CAUTION: This function is deprecated because it requires allocating memory for the error
     * message unnecessarily. For custom revert reasons use {tryMod}.
     *
     * Counterpart to Solidity's `%` operator. This function uses a `revert`
     * opcode (which leaves remaining gas untouched) while Solidity uses an
     * invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function mod(
        uint256 a,
        uint256 b,
        string memory errorMessage
    ) internal pure returns (uint256) {
        unchecked {
            require(b > 0, errorMessage);
            return a % b;
        }
    }
}

File 7 of 20 : CoffinOracle.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.7;
pragma experimental ABIEncoderV2;
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts/utils/math/SafeMath.sol";
import "@openzeppelin/contracts/proxy/utils/Initializable.sol";

import "@openzeppelin/contracts/access/Ownable.sol";
import "./interfaces/IUniswapV2Router02.sol";
import "./interfaces/IUniswapV2Factory.sol";
import "./interfaces/IUniswapLP.sol";
import "./libs/FixedPoint.sol";
import "./interfaces/IBandStdReference.sol";


interface ICoffinOracle {
    function PERIOD() external view returns (uint32);
    function getCOFFINUSD() external view returns (uint256, uint8);
    function updateTwap(address token0, address token1) external ;
    function getCOUSDUSD() external view returns (uint256, uint8);
    function getTwapCOUSDUSD() external view returns (uint256, uint8);
    function getTwapCOFFINUSD() external view returns (uint256, uint8);
    function getTwapXCOFFINUSD() external view returns (uint256, uint8);
    function updateTwapDollar() external ;
    function updateTwapCoffin() external ;
    function updateTwapXCoffin() external ;
    function getXCOFFINUSD() external view returns (uint256, uint8);
    function getCOUSDFTM() external view returns (uint256, uint8);
    function getXCOFFINFTM() external view returns (uint256, uint8);
    function getCOFFINFTM() external view returns (uint256, uint8);
    function getFTMUSD() external view returns (uint256, uint8);

}

contract MockCoffinOracle is ICoffinOracle, Ownable {
    uint256 public xcoffinftm = (1 / 2) * 1 * 10**18;
    uint256 public coffinftm = 2 * 1 * 10**18;
    uint256 public ftmusd = (1 / 4) * 1 * 10**18;
    uint256 public cousdftm = (101 / 100) * 4 * 1 * 10**18;
    uint32 public override PERIOD = 600; // 10-minute TWAP 

    function updateTwap(address token0, address token1) external override {

    }
    function updateTwapDollar() external override{

    }
    function updateTwapCoffin() external override{

    }
    function updateTwapXCoffin() external override{

    }
    function setCOUSDFTM(uint256 val) external {
        cousdftm = val;
    }

    function getCOUSDFTM() public view override returns (uint256, uint8) {
        return (cousdftm, 18);
    }

    function setXCOFFINFTM(uint256 val) external {
        xcoffinftm = val;
    }

    function getXCOFFINFTM() public view override returns (uint256, uint8) {
        return (xcoffinftm, 18);
    }

    function setCOFFINFTM(uint256 val) external {
        coffinftm = val;
    }

    function getCOFFINFTM() public view override returns (uint256, uint8) {
        return (coffinftm, 18);
    }

 
    uint256 public cousdusd = 1030000000000000000;
    function setCOUSDUSD(uint256 val) external {
        cousdusd = val;// decimal 18 
    }
    function getCOUSDUSD() public view override returns(uint256,uint8){
        return (cousdusd,18);// decimal 18 
    }
    
 
    
    function setFTMUSD(uint256 val) external {
        ftmusd = val;
    }

    function getFTMUSD() public view override returns (uint256, uint8) {
        return (ftmusd, 18);
    }


    function getCOFFINUSD() public view override returns (uint256, uint8) {
        (uint256 v1, uint8 d1) = getCOFFINFTM();
        (uint256 v2, uint8 d2) = getFTMUSD();
        return ((v1 * v2) / (10**d1), d2);
    }

    function getXCOFFINUSD() public view override returns (uint256, uint8) {
        (uint256 v1, uint8 d1) = getXCOFFINFTM();
        (uint256 v2, uint8 d2) = getFTMUSD();
        return ((v1 * v2) / (10**d1), d2);
    }

    function getTwapCOUSDUSD() external view override returns (uint256, uint8){
        return getCOUSDUSD();
    }
    function getTwapCOFFINUSD() external view override returns (uint256, uint8){
        return getCOFFINUSD();
    }
    function getTwapXCOFFINUSD() external view override returns (uint256, uint8){
        return getXCOFFINUSD();
    }

}


contract CoffinOracle is ICoffinOracle, Initializable,Ownable {
    using SafeMath for uint256;
    using FixedPoint for *;

    IUniswapV2Router02 public uniswapv2router;
    address public coffin;
    address public dollar;
    address public xcoffin;
    address public wftm = 0x21be370D5312f44cB42ce377BC9b8a0cEF1A4C83;
    address public usdc = 0x04068DA6C83AFCFA0e13ba15A6696662335D5B75;
    address public dai = 0x8D11eC38a3EB5E956B052f67Da8Bdc9bef8Abf3E;
    address public boo = 0x841FAD6EAe12c286d1Fd18d1d525DFfA75C7EFFE;
    IBandStdReference bandRef;
    uint32 public override PERIOD = 600; // 10-minute TWAP

    struct Pair {
        uint256 price0CumulativeLast;
        uint256 price1CumulativeLast;
        uint32 blockTimestampLast;
        FixedPoint.uq112x112 price0Average;
        FixedPoint.uq112x112 price1Average;
        bool initialized;
    }

    mapping(address => Pair) public getPair;

    function setPeriod(uint32 _period) external onlyOwner {
        PERIOD = _period;
    }

    function init(
        address _coffinAddress,
        address _cousdAddress,
        address _xcoffinAddress
    ) external  initializer onlyOwner{
        // router address. it's spooky router by default. 
        address routerAddress = 0xF491e7B69E4244ad4002BC14e878a34207E38c29;
        setRouter(routerAddress);

        address fantomBandProtocol = 0x56E2898E0ceFF0D1222827759B56B28Ad812f92F;

        setBandOracle(fantomBandProtocol);
        setCOFFINAddress(_coffinAddress);
        setDollarAddress(_cousdAddress);
        setXCOFFINAddress(_xcoffinAddress);
    }

    function getBandRate(string memory token0, string memory token1)
        public
        view
        returns (uint256)
    {
        IBandStdReference.ReferenceData memory data = bandRef.getReferenceData(
            token0,
            token1
        );
        return data.rate;
    }


    function getFTMUSD() public view override returns (uint256, uint8) {
        return (getBandRate("FTM","USD"), 18);
    }

    



    function setCOFFINAddress(address _coffinAddress) public onlyOwner {
        coffin = _coffinAddress;
    }

    function setXCOFFINAddress(address _xcoffinAddress) public onlyOwner {
        xcoffin = _xcoffinAddress;
    }

    function setDollarAddress(address _cousdAddress) public onlyOwner {
        dollar = _cousdAddress;
    }

    function setRouter(address _uniswapv2routeraddress)
        public
        onlyOwner
    {
        uniswapv2router = IUniswapV2Router02(_uniswapv2routeraddress);
    }

    function setBandOracle(address _bandOracleAddress) public onlyOwner {
        bandRef = IBandStdReference(_bandOracleAddress);
    }


    function getCOFFINUSD() external view override returns (uint256, uint8) {
        (uint256 v1, uint8 d1) = getCOFFINFTM();
        (uint256 v2, uint8 d2) = getFTMUSD();
        return ((v1 * v2) / (10**d1), d2);
    }

    function getTwapCOFFINUSD() external view override returns (uint256, uint8) {
        (uint256 v1, uint8 d1) = getTwapCOFFINFTM();
        (uint256 v2, uint8 d2) = getFTMUSD();
        return ((v1 * v2) / (10**d1), d2);
    }
    
    function getUSDCUSD() public view  returns (uint256, uint8) {
        return (getBandRate("USDC","USD"), 18);
    }
    function getDAIUSD() public view  returns (uint256, uint8) {
        return (getBandRate("DAI","USD"), 18);
    }
    
    uint8 public oracleMode = 0; 

    function enableFTMOracle() external onlyOwner {
        oracleMode = 1;
    }
    function enableDAIOracle() external onlyOwner {
        oracleMode = 2 ;
    }
    function enableUSDCracle() external onlyOwner {
        oracleMode = 0 ;
    }

    function getCOUSDUSD() external view override returns (uint256, uint8) {
        if (oracleMode==1) {
            (uint256 v1, uint8 d1) = getCOUSDFTM();
            (uint256 v2, uint8 d2) = getFTMUSD();
            return ((v1 * v2) / (10**d1), d2);
        } else if (oracleMode==2) {
            (uint256 v1, uint8 d1) = getCOUSDDAI();
            (uint256 v2, uint8 d2) = getDAIUSD();
            return ((v1 * v2) / (10**d1), d2);
        } else {
            (uint256 v1, uint8 d1) = getCOUSDUSDC();
            (uint256 v2, uint8 d2) = getUSDCUSD();
            return ((v1 * v2) / (10**d1), d2);
        }
    }

    function getTwapCOUSDUSD() external view override returns (uint256, uint8) {
        if (oracleMode==1) {
            (uint256 v1, uint8 d1) = getTwapCOUSDFTM();
            (uint256 v2, uint8 d2) = getFTMUSD();
            return ((v1 * v2) / (10**d1), d2);
        } else if (oracleMode==2) {   
            (uint256 v1, uint8 d1) = getTwapCOUSDDAI();
            (uint256 v2, uint8 d2) = getDAIUSD();
            return ((v1 * v2) / (10**d1), d2);
        } else {
            (uint256 v1, uint8 d1) = getTwapCOUSDUSDC();
            (uint256 v2, uint8 d2) = getUSDCUSD();
            return ((v1 * v2) / (10**d1), d2);     
        }

    }

    
    


    function getXCOFFINUSD() external view override returns (uint256, uint8) {
        (uint256 v1, uint8 d1) = getXCOFFINFTM();
        (uint256 v2, uint8 d2) = getFTMUSD();
        return ((v1 * v2) / (10**d1), d2);
    }

    function getTwapXCOFFINUSD() external view override returns (uint256, uint8) {
        (uint256 v1, uint8 d1) = getTwapXCOFFINFTM();
        (uint256 v2, uint8 d2) = getFTMUSD();
        return ((v1 * v2) / (10**d1), d2);
    }

    function getTwapCOUSDFTM() public view  returns (uint256, uint8) {
        (uint256 a, uint8 b) = getTwapRate(dollar,wftm);
        if (a>0) {
            return (a,b);
        }
        return getRealtimeRate(dollar,wftm);
    }
    
    function getTwapCOUSDDAI() public view  returns (uint256, uint8) {
        (uint256 a, uint8 b) = getTwapRate(dollar,dai);
        if (a>0) {
            return (a,b);
        }
        return getRealtimeRate(dollar,usdc);
    }
    function getTwapCOUSDUSDC() public view  returns (uint256, uint8) {
        (uint256 a, uint8 b) = getTwapRate(dollar,usdc);
        if (a>0) {
            return (a,b);
        }
        return getRealtimeRate(dollar,usdc);
    }
    
    function getCOUSDFTM() public view override returns (uint256, uint8) {
        return getRealtimeRate(dollar,wftm);
    }
    function getCOUSDUSDC() public view returns (uint256, uint8) {
        return getRealtimeRate(dollar,usdc);
    }
    function getCOUSDDAI() public view returns (uint256, uint8) {
        return getRealtimeRate(dollar,dai);
    }
    

    function getTwapXCOFFINFTM() public view  returns (uint256, uint8) {
        (uint256 a, uint8 b) = getTwapRate(xcoffin,wftm);
        if (a>0) {
            return (a,b);
        }
        return getRealtimeRate(xcoffin,wftm);
    }

    function getXCOFFINFTM() public view override returns (uint256, uint8) {
        return getRealtimeRate(xcoffin,wftm);
    }

    function getTwapCOFFINFTM() public view returns (uint256, uint8) {
        (uint256 a, uint8 b) = getTwapRate(coffin,wftm);
        if (a>0) {
            return (a,b);
        }
        return getRealtimeRate(coffin,wftm);
    }
    function getCOFFINFTM() public view override returns (uint256, uint8) {
        return getRealtimeRate(coffin,wftm);
    }


    function currentBlockTimestamp() internal view returns (uint32) {
        return uint32(block.timestamp % 2**32);
    }

    function currentCumulativePrices(address uniswapV2Pair)
        internal
        view
        returns (
            uint256 price0Cumulative,
            uint256 price1Cumulative,
            uint32 blockTimestamp
        )
    {
        // Pair storage pairStorage = getPair[uniswapV2Pair];

        blockTimestamp = currentBlockTimestamp();
        IUniswapLP uniswapPair = IUniswapLP(uniswapV2Pair);
        price0Cumulative = uniswapPair.price0CumulativeLast();
        price1Cumulative = uniswapPair.price1CumulativeLast();

        // if time has elapsed since the last update on the pair, mock the accumulated price values
        (uint112 reserve0, uint112 reserve1, uint32 _blockTimestampLast) = uniswapPair.getReserves();
        if (_blockTimestampLast != blockTimestamp) {
            // subtraction overflow is desired
            uint32 timeElapsed = blockTimestamp - _blockTimestampLast;
            // addition overflow is desired
            // counterfactual
            price0Cumulative += uint256(FixedPoint.fraction(reserve1, reserve0)._x) * timeElapsed;
            // counterfactual
            price1Cumulative += uint256(FixedPoint.fraction(reserve0, reserve1)._x) * timeElapsed;
        }
    }


    function getTwapRate(address token0, address token1)
        public
        view
        returns (uint256 priceLatest, uint8 decimals)
    {
        address[] memory path = new address[](2);
        path[0] = token0;
        path[1] = token1;
        address factory = address(uniswapv2router.factory());
        address uniswapV2Pair = IUniswapV2Factory(factory).getPair(token0, token1);

        if (uniswapV2Pair== address(0)) {
            return (0,0);
        } 

        // Pair memory pair = getPair[uniswapV2Pair];
        Pair storage pairStorage = getPair[uniswapV2Pair];

        // require(pairStorage.initialized, "need to setup first");
        if (!pairStorage.initialized) {
            return getRealtimeRate(token0, token1);
            // return (0,0);
        }
        
        (uint256 price0Cumulative, uint256 price1Cumulative, uint32 blockTimestamp) = currentCumulativePrices(
            address(uniswapV2Pair)
        );
        uint32 timeElapsed = blockTimestamp - pairStorage.blockTimestampLast; // Overflow is desired

        FixedPoint.uq112x112 memory price0Average 
            = FixedPoint.uq112x112(uint224((price0Cumulative - pairStorage.price0CumulativeLast) / timeElapsed));
        FixedPoint.uq112x112 memory price1Average 
            = FixedPoint.uq112x112(uint224((price1Cumulative - pairStorage.price1CumulativeLast) / timeElapsed));

        uint256 amountIn = 1e18;
        if (IUniswapLP(uniswapV2Pair).token0() == token0) {
            priceLatest = uint256(price0Average.mul(amountIn).decode144());
            decimals = ERC20(token1).decimals();
        } else {
            require(IUniswapLP(uniswapV2Pair).token0() == token1, "TwapOracle: INVALID_TOKEN");
            priceLatest = uint256(price1Average.mul(amountIn).decode144());
            decimals = ERC20(token0).decimals();
        }
    }

    function getTwapRateWithUpdate(address token0, address token1)
        external
        returns (uint256 priceLatest, uint8 decimals)
    {
        updateTwap(token0,token1);
        return getTwapRate(token0,token1);
    }
    

    function updateTwapDollarFTM() public  {
        updateTwap(dollar, wftm);
    }
    function updateTwapDollar() public override {
        updateTwap(dollar, dai);
    }
    function updateTwapDollarUSDC() public  {
        updateTwap(dollar, usdc);
    }
    function updateTwapCoffin() public override {
        updateTwap(coffin, wftm);
    }
    function updateTwapXCoffin() public override {
        updateTwap(xcoffin, wftm);
    }

    function updateTwap(address token0, address token1) public override {

        address[] memory path = new address[](2);
        path[0] = token0;
        path[1] = token1;
        address factory = address(uniswapv2router.factory());
        address uniswapV2Pair = IUniswapV2Factory(factory).getPair(token0, token1);

        if (uniswapV2Pair== address(0)) {
            return;
        }
        Pair storage pairStorage = getPair[uniswapV2Pair];
        // require(pairStorage.initialized, "need to setup first");
        
        (uint256 price0Cumulative, uint256 price1Cumulative, uint32 blockTimestamp) = currentCumulativePrices(
            address(uniswapV2Pair)
        );

        if (!pairStorage.initialized) {
            // first time 
            pairStorage.price0CumulativeLast = price0Cumulative;
            pairStorage.price1CumulativeLast = price1Cumulative;
            pairStorage.blockTimestampLast = blockTimestamp;
            pairStorage.initialized = true;
            return;
        }

        // Overflow is desired
        uint32 timeElapsed = blockTimestamp - pairStorage.blockTimestampLast; 
        
        // Ensure that at least one full period has passed since the last update
        if (timeElapsed < PERIOD) {
            return ;
        }
        
        pairStorage.price0Average 
            = FixedPoint.uq112x112(uint224((price0Cumulative - pairStorage.price0CumulativeLast) / timeElapsed));
        pairStorage.price1Average 
            = FixedPoint.uq112x112(uint224((price1Cumulative - pairStorage.price1CumulativeLast) / timeElapsed));
        pairStorage.price0CumulativeLast = price0Cumulative;
        pairStorage.price1CumulativeLast = price1Cumulative;
        pairStorage.blockTimestampLast = blockTimestamp;
    }

    function getRealtimeRate(address tokenA, address tokenB)
        public
        view
        returns (uint256 priceLatest, uint8 decimals)
    {

        address factory = address(uniswapv2router.factory());
        address pair = IUniswapV2Factory(factory).getPair(tokenA, tokenB);
        if (pair== address(0)) {
            return (0,0);
        }
        
        (uint112 reserve0, uint112 reserve1,) =
            IUniswapLP(pair).getReserves();
        if (IUniswapLP(pair).token0()==address(tokenA)) {
            priceLatest = uint256(reserve1).mul(uint256(10**ERC20(tokenA).decimals())).div(uint256(reserve0));
            decimals = ERC20(tokenB).decimals();
        } else {
            priceLatest = uint256(reserve0).mul(uint256(10**ERC20(tokenA).decimals())).div(uint256(reserve1));
            decimals = ERC20(tokenB).decimals();
        }

        if ((18-decimals)>0) { 
            priceLatest = priceLatest.mul(10**(18-decimals));
            decimals = 18;
        }
    }
}

File 8 of 20 : PoolToken.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.7;

import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/utils/math/SafeMath.sol";
import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Burnable.sol";

contract PoolToken is ERC20Burnable , Ownable{
    using SafeMath for uint256;

    // The addresses in this array are added by the oracle and these contracts are able to mint coffin
    address[] public coffin_pools_array;

    // Mapping is also used for faster verification
    mapping(address => bool) public coffin_pools; 

    /* ========== MODIFIERS ========== */

    modifier onlyPools() {
        require(coffin_pools[msg.sender] == true, "Only coffin pools can call this function");
        _;
    }
    

    modifier onlyByOwnerOrPool() {
        require(
            msg.sender == owner()
            || coffin_pools[msg.sender] == true, 
            "You are not the owner, or a pool");
        _;
    }

    function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
        _transfer(_msgSender(), recipient, amount);
        return true;
    }

    /* ========== constructor ========== */
    constructor(string memory _name, string memory _symbol) ERC20(_name, _symbol) {}
    /* ========== view ========== */
    function poolLength() view public returns(uint256) {
        return coffin_pools_array.length;
    }

    /* ========== onlyPools ========== */

    // Used by pools when user redeems
    function pool_burn_from(address addr, uint256 amount) public onlyPools {
        super.burnFrom(addr, amount);
        emit Burned(addr, msg.sender, amount);
    }
    // This function is what other pools will call to mint new token 
    function pool_mint(address addr, uint256 amount) public onlyPools {
        super._mint(addr, amount);
        emit Minted(msg.sender, addr, amount);
    }

    /* ========== onlyOwner  ========== */

    // 
    function burnFrom(address addr, uint256 amount) public override onlyOwner {
        super.burnFrom(addr, amount);
        emit Minted(msg.sender, addr, amount);
    }
    
    // pools which can mint/burn 
    function addPool(address pool_address) public onlyOwner {
        require(pool_address != address(0), "Zero address detected");

        require(coffin_pools[pool_address] == false, "Address already exists");
        coffin_pools[pool_address] = true; 
        coffin_pools_array.push(pool_address);

        emit PoolAdded(pool_address);
    }

    // Remove a pool 
    function removePool(address pool_address) public onlyOwner {
        require(pool_address != address(0), "Zero address detected");
        require(coffin_pools[pool_address] == true, "Address nonexistant");
        
        // Delete from the mapping
        delete coffin_pools[pool_address];

        // 'Delete' from the array by setting the address to 0x0
        for (uint i = 0; i < coffin_pools_array.length; i++){ 
            if (coffin_pools_array[i] == pool_address) {
                coffin_pools_array[i] = address(0); // This will leave a null in the array and keep the indices the same
                break;
            }
        }

        emit PoolRemoved(pool_address);
    }

    /* ========== EVENTS ========== */


    event Burned(address indexed from, address indexed by, uint256 amount);
    event Minted(address indexed from, address indexed to, uint256 amount);
    event PoolAdded(address pool_address);
    event PoolRemoved(address pool_address);

}

File 9 of 20 : Babylonian.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.7;

// computes square roots using the babylonian method
// https://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Babylonian_method
library Babylonian {
    function sqrt(uint256 y) internal pure returns (uint256 z) {
        if (y > 3) {
            z = y;
            uint256 x = y / 2 + 1;
            while (x < z) {
                z = x;
                x = (y / x + x) / 2;
            }
        } else if (y != 0) {
            z = 1;
        }
        // else z = 0
    }
}

File 10 of 20 : ITaxableTokenPolicy.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.7;

    
interface ITaxableTokenPolicy  {
    function calcTaxRate(
        uint256 dollarPrice, 
        uint256 taxThreshold, 
        uint256 paramA, 
        uint256 paramB, 
        uint256 basisTaxRate,
        uint256 maxTaxRate
    ) external pure returns (uint16) ;
    }

File 11 of 20 : ERC20.sol
// SPDX-License-Identifier: MIT

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 guidelines: functions revert instead
 * of returning `false` on failure. This behavior is nonetheless conventional
 * and does not conflict with the expectations of ERC20 applications.
 *
 * Additionally, an {Approval} event is emitted on calls to {transferFrom}.
 * This allows applications to reconstruct the allowance for all accounts just
 * by listening to said events. Other implementations of the EIP may not emit
 * these events, as it isn't required by the specification.
 *
 * Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
 * functions have been added to mitigate the well-known issues around setting
 * allowances. See {IERC20-approve}.
 */
contract ERC20 is Context, IERC20, 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 20 : Context.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

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

    function _msgData() internal view virtual returns (bytes calldata) {
        return msg.data;
    }
}

File 13 of 20 : IERC20.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

File 14 of 20 : IERC20Metadata.sol
// SPDX-License-Identifier: MIT

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 15 of 20 : IUniswapV2Router02.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.6.11;

import "./IUniswapV2Router01.sol";

interface IUniswapV2Router02 is IUniswapV2Router01 {
    function removeLiquidityETHSupportingFeeOnTransferTokens(
        address token,
        uint256 liquidity,
        uint256 amountTokenMin,
        uint256 amountETHMin,
        address to,
        uint256 deadline
    ) external returns (uint256 amountETH);

    function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens(
        address token,
        uint256 liquidity,
        uint256 amountTokenMin,
        uint256 amountETHMin,
        address to,
        uint256 deadline,
        bool approveMax,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) external returns (uint256 amountETH);

    function swapExactTokensForTokensSupportingFeeOnTransferTokens(
        uint256 amountIn,
        uint256 amountOutMin,
        address[] calldata path,
        address to,
        uint256 deadline
    ) external;

    function swapExactETHForTokensSupportingFeeOnTransferTokens(
        uint256 amountOutMin,
        address[] calldata path,
        address to,
        uint256 deadline
    ) external payable;

    function swapExactTokensForETHSupportingFeeOnTransferTokens(
        uint256 amountIn,
        uint256 amountOutMin,
        address[] calldata path,
        address to,
        uint256 deadline
    ) external;

}

File 16 of 20 : IUniswapV2Factory.sol
// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.7;
interface IUniswapV2Factory {

    function feeTo() external view returns (address);
    function feeToSetter() external view returns (address);

    function getPair(address tokenA, address tokenB) external view returns (address pair);
    function allPairs(uint) external view returns (address pair);
    function allPairsLength() external view returns (uint);

    function createPair(address tokenA, address tokenB) external returns (address pair);

    function setFeeTo(address) external;
    function setFeeToSetter(address) external;
}

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

pragma solidity 0.8.7;
pragma experimental ABIEncoderV2;

interface IUniswapLP {
    function token0() external view returns (address);

    function token1() external view returns (address);

    function getReserves()
        external
        view
        returns (
            uint112 reserve0,
            uint112 reserve1,
            uint32 blockTimestampLast
        );

    function price0CumulativeLast() external view returns (uint256);

    function price1CumulativeLast() external view returns (uint256);

    function getTokenWeights() external view returns (uint32 tokenWeight0, uint32 tokenWeight1);
}

File 18 of 20 : FixedPoint.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.7;

import "./Babylonian.sol";

// a library for handling binary fixed point numbers (https://en.wikipedia.org/wiki/Q_(number_format))
library FixedPoint {
    // range: [0, 2**112 - 1]
    // resolution: 1 / 2**112
    struct uq112x112 {
        uint224 _x;
    }

    // range: [0, 2**144 - 1]
    // resolution: 1 / 2**112
    struct uq144x112 {
        uint256 _x;
    }

    uint8 private constant RESOLUTION = 112;
    uint256 private constant Q112 = uint256(1) << RESOLUTION;
    uint256 private constant Q224 = Q112 << RESOLUTION;

    // encode a uint112 as a UQ112x112
    function encode(uint112 x) internal pure returns (uq112x112 memory) {
        return uq112x112(uint224(x) << RESOLUTION);
    }

    // encodes a uint144 as a UQ144x112
    function encode144(uint144 x) internal pure returns (uq144x112 memory) {
        return uq144x112(uint256(x) << RESOLUTION);
    }

    // divide a UQ112x112 by a uint112, returning a UQ112x112
    function div(uq112x112 memory self, uint112 x) internal pure returns (uq112x112 memory) {
        require(x != 0, "FixedPoint: DIV_BY_ZERO");
        return uq112x112(self._x / uint224(x));
    }

    // multiply a UQ112x112 by a uint, returning a UQ144x112
    // reverts on overflow
    function mul(uq112x112 memory self, uint256 y) internal pure returns (uq144x112 memory) {
        uint256 z;
        require(y == 0 || (z = uint256(self._x) * y) / y == uint256(self._x), "FixedPoint: MULTIPLICATION_OVERFLOW");
        return uq144x112(z);
    }

    // returns a UQ112x112 which represents the ratio of the numerator to the denominator
    // equivalent to encode(numerator).div(denominator)
    function fraction(uint112 numerator, uint112 denominator) internal pure returns (uq112x112 memory) {
        require(denominator > 0, "FixedPoint: DIV_BY_ZERO");
        return uq112x112((uint224(numerator) << RESOLUTION) / denominator);
    }

    // decode a UQ112x112 into a uint112 by truncating after the radix point
    function decode(uq112x112 memory self) internal pure returns (uint112) {
        return uint112(self._x >> RESOLUTION);
    }

    // decode a UQ144x112 into a uint144 by truncating after the radix point
    function decode144(uq144x112 memory self) internal pure returns (uint144) {
        return uint144(self._x >> RESOLUTION);
    }

    // take the reciprocal of a UQ112x112
    function reciprocal(uq112x112 memory self) internal pure returns (uq112x112 memory) {
        require(self._x != 0, "FixedPoint: ZERO_RECIPROCAL");
        return uq112x112(uint224(Q224 / self._x));
    }

    // square root of a UQ112x112
    function sqrt(uq112x112 memory self) internal pure returns (uq112x112 memory) {
        return uq112x112(uint224(Babylonian.sqrt(uint256(self._x)) << 56));
    }
}

File 19 of 20 : IBandStdReference.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.7;

interface IBandStdReference {
    /// A structure returned whenever someone requests for standard reference data.
    struct ReferenceData {
        uint256 rate; // base/quote exchange rate, multiplied by 1e18.
        uint256 lastUpdatedBase; // UNIX epoch of the last time when base price gets updated.
        uint256 lastUpdatedQuote; // UNIX epoch of the last time when quote price gets updated.
    }

    /// Returns the price data for the given base/quote pair. Revert if not available.
    function getReferenceData(string memory _base, string memory _quote)
        external
        view
        returns (ReferenceData memory);
    
    /// Similar to getReferenceData, but with multiple base/quote pairs at once.
    function getReferenceDataBulk(
        string[] memory _bases,
        string[] memory _quotes
    ) external view returns (ReferenceData[] memory);
}

File 20 of 20 : IUniswapV2Router01.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.7;

interface IUniswapV2Router01 {
    function factory() external view   returns (address);
    function WETH() external view  returns (address);

    function addLiquidity(
        address tokenA,
        address tokenB,
        uint amountADesired,
        uint amountBDesired,
        uint amountAMin,
        uint amountBMin,
        address to,
        uint deadline
    ) external returns (uint amountA, uint amountB, uint liquidity);
    function addLiquidityETH(
        address token,
        uint amountTokenDesired,
        uint amountTokenMin,
        uint amountETHMin,
        address to,
        uint deadline
    ) external payable returns (uint amountToken, uint amountETH, uint liquidity);
    function removeLiquidity(
        address tokenA,
        address tokenB,
        uint liquidity,
        uint amountAMin,
        uint amountBMin,
        address to,
        uint deadline
    ) external returns (uint amountA, uint amountB);
    function removeLiquidityETH(
        address token,
        uint liquidity,
        uint amountTokenMin,
        uint amountETHMin,
        address to,
        uint deadline
    ) external returns (uint amountToken, uint amountETH);
    function removeLiquidityWithPermit(
        address tokenA,
        address tokenB,
        uint liquidity,
        uint amountAMin,
        uint amountBMin,
        address to,
        uint deadline,
        bool approveMax, uint8 v, bytes32 r, bytes32 s
    ) external returns (uint amountA, uint amountB);
    function removeLiquidityETHWithPermit(
        address token,
        uint liquidity,
        uint amountTokenMin,
        uint amountETHMin,
        address to,
        uint deadline,
        bool approveMax, uint8 v, bytes32 r, bytes32 s
    ) external returns (uint amountToken, uint amountETH);
    function swapExactTokensForTokens(
        uint amountIn,
        uint amountOutMin,
        address[] calldata path,
        address to,
        uint deadline
    ) external returns (uint[] memory amounts);
    function swapTokensForExactTokens(
        uint amountOut,
        uint amountInMax,
        address[] calldata path,
        address to,
        uint deadline
    ) external returns (uint[] memory amounts);
    function swapExactETHForTokens(uint amountOutMin, address[] calldata path, address to, uint deadline)
        external
        payable
        returns (uint[] memory amounts);
    function swapTokensForExactETH(uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline)
        external
        returns (uint[] memory amounts);
    function swapExactTokensForETH(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline)
        external
        returns (uint[] memory amounts);
    function swapETHForExactTokens(uint amountOut, address[] calldata path, address to, uint deadline)
        external
        payable
        returns (uint[] memory amounts);

    function quote(uint amountA, uint reserveA, uint reserveB) external pure returns (uint amountB);
    function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) external pure returns (uint amountOut);
    function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) external pure returns (uint amountIn);
    function getAmountsOut(uint amountIn, address[] calldata path) external view returns (uint[] memory amounts);
    function getAmountsIn(uint amountOut, address[] calldata path) external view returns (uint[] memory amounts);
}

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

Contract Security Audit

Contract ABI

[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"by","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Burned","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"_newCap","type":"uint256"}],"name":"MaxTotalSupplyUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Minted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"pool_address","type":"address"}],"name":"PoolAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"pool_address","type":"address"}],"name":"PoolRemoved","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"oldAddress","type":"address"},{"indexed":false,"internalType":"address","name":"newAddress","type":"address"}],"name":"TaxOfficeTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"inputs":[],"name":"BURN_ADDRESS","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"REWARD_ALLOCATION","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"_getCoUSDPrice","outputs":[{"internalType":"uint256","name":"_price","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"pool_address","type":"address"}],"name":"addPool","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"adjustTaxRateA","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"adjustTaxRateB","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"autoCalculateTax","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"basisTaxRate","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"burn","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"addr","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"burnFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"burnThreshold","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_cousdPrice","type":"uint256"}],"name":"calcAutoTaxRate","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"coffinOracle","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"coffin_pools","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"coffin_pools_array","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"subtractedValue","type":"uint256"}],"name":"decreaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"disablTwap","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"disableAutoCalculateTax","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"disableTax","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"enableAutoCalculateTax","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"enableTax","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"enableTwap","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"excludeAddressFromTax","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"genesis_supply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"includeAddressInTax","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"addedValue","type":"uint256"}],"name":"increaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_maker","type":"address"}],"name":"init","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"isExcluded","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"latestTaxRate","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxTaxRate","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"policy","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"poolLength","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"addr","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"pool_burn_from","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"addr","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"pool_mint","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"pool_address","type":"address"}],"name":"removePool","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"rewardClaimed","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"reward_mint","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint32","name":"_adjustTaxRate","type":"uint32"}],"name":"setAdjustTaxRateA","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint32","name":"_adjustTaxRate","type":"uint32"}],"name":"setAdjustTaxRateB","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint16","name":"_basisTaxRate","type":"uint16"}],"name":"setBasisTaxRate","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_burnThreshold","type":"uint256"}],"name":"setBurnThreshold","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_coffinOracle","type":"address"}],"name":"setCoffinOracle","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint16","name":"_maxTaxRate","type":"uint16"}],"name":"setMaxTaxRate","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint16","name":"_staticTaxRate","type":"uint16"}],"name":"setStaticTaxRate","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_taxCollectorAddress","type":"address"}],"name":"setTaxCollectorAddress","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_taxOffice","type":"address"}],"name":"setTaxOffice","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_policy","type":"address"}],"name":"setTaxPolicy","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_taxThreshold","type":"uint256"}],"name":"setTaxThreshold","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"staticTaxRate","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"taxActivated","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"taxCollectorAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"taxOffice","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"taxThreshold","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"using_twap","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"}]

60806040526008805463ffffffff60a01b19169055670d99a8cec7e20000600c55670de0b6b3a7640000600d55600e80546001600160701b0319166a04001e8480000507d000001790553480156200005657600080fd5b506040518060400160405280600b81526020016a21b7b33334b72a37b5b2b760a91b8152506040518060400160405280600681526020016521a7a32324a760d11b815250818181818160039080519060200190620000b692919062000149565b508051620000cc90600490602084019062000149565b505050620000e9620000e3620000f360201b60201c565b620000f7565b505050506200022c565b3390565b600580546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b8280546200015790620001ef565b90600052602060002090601f0160209004810192826200017b5760008555620001c6565b82601f106200019657805160ff1916838001178555620001c6565b82800160010185558215620001c6579182015b82811115620001c6578251825591602001919060010190620001a9565b50620001d4929150620001d8565b5090565b5b80821115620001d45760008155600101620001d9565b600181811c908216806200020457607f821691505b602082108114156200022657634e487b7160e01b600052602260045260246000fd5b50919050565b6130eb806200023c6000396000f3fe608060405234801561001057600080fd5b50600436106103e65760003560e01c806370a082311161020a578063b4f56b2611610125578063dd62ed3e116100b8578063f2fde38b11610087578063f2fde38b146108a0578063f6a2db8a146108b3578063fb1c80b2146108d6578063fccc2813146108f0578063ff87fc7c146108f957600080fd5b8063dd62ed3e1461082e578063e06c73b114610867578063e48849b214610879578063e7b462181461088d57600080fd5b8063cba0e996116100f4578063cba0e996146107d4578063cd428af314610800578063ced695a414610813578063d914cd4b1461081b57600080fd5b8063b4f56b2614610793578063be8ec6d2146107a6578063be94f86b146107ae578063c3bdf613146107c157600080fd5b80638e6c77221161019d578063a457c2d71161016c578063a457c2d714610745578063a6e7ab1614610758578063a8a778ae1461076d578063a9059cbb1461078057600080fd5b80638e6c77221461070457806395d89b41146107175780639d6b5f211461071f578063a0025c4a1461073257600080fd5b806379cc6790116101d957806379cc6790146106b8578063887d882f146106cb5780638d3cc818146106e15780638da5cb5b146106f357600080fd5b806370a0823114610676578063715018a61461069f578063739272ad146106a757806377d1440d146106af57600080fd5b806339509351116103055780635024ec1f1161029857806353eb3bcf1161026757806353eb3bcf1461062d5780635c26606a146106355780635c6b16c11461064857806365bbacd91461065b57806369356d471461066357600080fd5b80635024ec1f146105d757806351e238e3146105ff57806352b779ea1461061157806353788a6b1461062557600080fd5b80633f07d76a116102d45780633f07d76a1461059557806342966c68146105a85780634cace7ae146105bb5780634f6d38d0146105ce57600080fd5b806339509351146105495780633a9874891461055c5780633b7d09461461056f5780633e5f13d41461058257600080fd5b806318160ddd1161037d57806323b872dd1161034c57806323b872dd14610507578063242b8f641461051a578063313ce5671461052757806332adb9a51461053657600080fd5b806318160ddd146104c457806319ab453c146104cc57806319db099d146104e15780632084acbc146104f457600080fd5b806307a212be116103b957806307a212be14610473578063081e3eda14610496578063095ea7b31461049e578063105481af146104b157600080fd5b806301b62b78146103eb5780630505c8c91461040757806305a04aae1461043257806306fdde031461045e575b600080fd5b6103f460125481565b6040519081526020015b60405180910390f35b600b5461041a906001600160a01b031681565b6040516001600160a01b0390911681526020016103fe565b600e5461044990600160501b900463ffffffff1681565b60405163ffffffff90911681526020016103fe565b610466610901565b6040516103fe9190612e0d565b610486610481366004612d98565b610993565b60405190151581526020016103fe565b6006546103f4565b6104866104ac366004612d34565b6109fa565b60085461041a906001600160a01b031681565b6002546103f4565b6104df6104da366004612caa565b610a11565b005b6104866104ef366004612caa565b610b96565b6104df610502366004612de7565b610c73565b610486610515366004612cf8565b610cee565b600e546104869060ff1681565b604051601281526020016103fe565b61041a610544366004612d98565b610d98565b610486610557366004612d34565b610dc2565b6104df61056a366004612de7565b610dfe565b6104df61057d366004612caa565b610e78565b60095461041a906001600160a01b031681565b6104df6105a3366004612caa565b611079565b6104df6105b6366004612d98565b611195565b6104df6105c9366004612caa565b6111a2565b6103f4600c5481565b6008546105ec90600160a01b900461ffff1681565b60405161ffff90911681526020016103fe565b6103f46a027b46536c66c8e300000081565b600b5461048690600160a01b900460ff1681565b6104df611262565b6104df6112c5565b6104df610643366004612d5e565b611322565b6104df610656366004612d34565b6113f1565b6104df6115ba565b6104df610671366004612caa565b611615565b6103f4610684366004612caa565b6001600160a01b031660009081526020819052604090205490565b6104df611701565b6103f4611755565b6103f4600d5481565b6104df6106c6366004612d34565b611858565b600e546105ec90640100000000900461ffff1681565b600e5461048690610100900460ff1681565b6005546001600160a01b031661041a565b6104df610712366004612caa565b6118ef565b6104666119c0565b61048661072d366004612d98565b6119cf565b6104df610740366004612d5e565b611a28565b610486610753366004612d34565b611aeb565b6008546105ec90600160b01b900461ffff1681565b6104df61077b366004612d34565b611b84565b61048661078e366004612d34565b611c40565b6104df6107a1366004612d34565b611c4d565b6104df611ccc565b6104866107bc366004612caa565b611d29565b600a5461041a906001600160a01b031681565b6104866107e2366004612caa565b6001600160a01b03166000908152600f602052604090205460ff1690565b6104df61080e366004612d5e565b611e0b565b6104df611ee9565b6104df610829366004612caa565b611f43565b6103f461083c366004612cc5565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b6103f46a503c8c895ba60a0100000081565b600e546105ec9062010000900461ffff1681565b6105ec61089b366004612d98565b6120d8565b6104df6108ae366004612caa565b6121bf565b6104866108c1366004612caa565b60076020526000908152604090205460ff1681565b600e54610449906601000000000000900463ffffffff1681565b61041a61dead81565b6104df612275565b6060600380546109109061302c565b80601f016020809104026020016040519081016040528092919081815260200182805461093c9061302c565b80156109895780601f1061095e57610100808354040283529160200191610989565b820191906000526020600020905b81548152906001019060200180831161096c57829003601f168201915b5050505050905090565b6000336109a86005546001600160a01b031690565b6001600160a01b031614806109c757506009546001600160a01b031633145b6109ec5760405162461bcd60e51b81526004016109e390612e62565b60405180910390fd5b50600d81905560015b919050565b6000610a073384846122d4565b5060015b92915050565b601154610100900460ff1680610a2a575060115460ff16155b610a9c5760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201527f647920696e697469616c697a656400000000000000000000000000000000000060648201526084016109e3565b601154610100900460ff16158015610abe576011805461ffff19166101011790555b6005546001600160a01b03163314610b065760405162461bcd60e51b815260206004820181905260248201526000805160206130bf83398151915260448201526064016109e3565b6001600160a01b0382166000818152600760205260408120805460ff191660019081179091556006805491820181559091527ff652222313e28459528d920b65115c16c04f3efc82aaedc97be59f3f377c0d3f0180546001600160a01b0319169091179055610b80336a027b46536c66c8e30000006123f0565b8015610b92576011805461ff00191690555b5050565b600033610bab6005546001600160a01b031690565b6001600160a01b03161480610bca57506009546001600160a01b031633145b610be65760405162461bcd60e51b81526004016109e390612e62565b6001600160a01b0382166000908152600f602052604090205460ff16610c4e5760405162461bcd60e51b815260206004820152601b60248201527f4163636f756e7420697320616c726561647920696e636c75646564000000000060448201526064016109e3565b506001600160a01b03166000908152600f60205260409020805460ff19169055600190565b33610c866005546001600160a01b031690565b6001600160a01b03161480610ca557506009546001600160a01b031633145b610cc15760405162461bcd60e51b81526004016109e390612e62565b600e805463ffffffff909216600160501b026dffffffff0000000000000000000019909216919091179055565b6000610cfb8484846124cf565b6001600160a01b038416600090815260016020908152604080832033845290915290205482811015610d805760405162461bcd60e51b815260206004820152602860248201527f45524332303a207472616e7366657220616d6f756e74206578636565647320616044820152676c6c6f77616e636560c01b60648201526084016109e3565b610d8d85338584036122d4565b506001949350505050565b60068181548110610da857600080fd5b6000918252602090912001546001600160a01b0316905081565b3360008181526001602090815260408083206001600160a01b03871684529091528120549091610a07918590610df9908690612eab565b6122d4565b33610e116005546001600160a01b031690565b6001600160a01b03161480610e3057506009546001600160a01b031633145b610e4c5760405162461bcd60e51b81526004016109e390612e62565b600e805463ffffffff90921666010000000000000269ffffffff00000000000019909216919091179055565b6005546001600160a01b03163314610ec05760405162461bcd60e51b815260206004820181905260248201526000805160206130bf83398151915260448201526064016109e3565b6001600160a01b038116610f0e5760405162461bcd60e51b815260206004820152601560248201527416995c9bc81859191c995cdcc819195d1958dd1959605a1b60448201526064016109e3565b6001600160a01b03811660009081526007602052604090205460ff161515600114610f7b5760405162461bcd60e51b815260206004820152601360248201527f41646472657373206e6f6e6578697374616e740000000000000000000000000060448201526064016109e3565b6001600160a01b0381166000908152600760205260408120805460ff191690555b60065481101561103857816001600160a01b031660068281548110610fc357610fc3613098565b6000918252602090912001546001600160a01b0316141561102657600060068281548110610ff357610ff3613098565b9060005260206000200160006101000a8154816001600160a01b0302191690836001600160a01b03160217905550611038565b8061103081613067565b915050610f9c565b506040516001600160a01b03821681527f4106dfdaa577573db51c0ca93f766dbedfa0758faa2e7f5bcdb7c142be803c3f906020015b60405180910390a150565b3361108c6005546001600160a01b031690565b6001600160a01b031614806110ab57506009546001600160a01b031633145b6110c75760405162461bcd60e51b81526004016109e390612e62565b6001600160a01b03811661112c5760405162461bcd60e51b815260206004820152602660248201527f746178206f666669636520616464726573732063616e6e6f742062652030206160448201526564647265737360d01b60648201526084016109e3565b600954604080516001600160a01b03928316815291831660208301527f75237613d1cfb394eb7979839ecbeacaca4592ef0cf96791979625803948a601910160405180910390a1600980546001600160a01b0319166001600160a01b0392909216919091179055565b61119f33826126e0565b50565b6005546001600160a01b031633146111ea5760405162461bcd60e51b815260206004820181905260248201526000805160206130bf83398151915260448201526064016109e3565b6001600160a01b0381166112405760405162461bcd60e51b815260206004820152601060248201527f77726f6e672074617820706f6c6963790000000000000000000000000000000060448201526064016109e3565b600b80546001600160a01b0319166001600160a01b0392909216919091179055565b336112756005546001600160a01b031690565b6001600160a01b0316148061129457506009546001600160a01b031633145b6112b05760405162461bcd60e51b81526004016109e390612e62565b600b805460ff60a01b1916600160a01b179055565b336112d86005546001600160a01b031690565b6001600160a01b031614806112f757506009546001600160a01b031633145b6113135760405162461bcd60e51b81526004016109e390612e62565b600e805460ff19166001179055565b336113356005546001600160a01b031690565b6001600160a01b0316148061135457506009546001600160a01b031633145b6113705760405162461bcd60e51b81526004016109e390612e62565b6008546109c4600160a01b90910461ffff16106113cf5760405162461bcd60e51b815260206004820152601860248201527f5461782072617465732061726520746f6f20686967682e20000000000000000060448201526064016109e3565b6008805461ffff909216600160a01b0261ffff60a01b19909216919091179055565b3360009081526007602052604090205460ff1615156001146114665760405162461bcd60e51b815260206004820152602860248201527f4f6e6c7920636f6666696e20706f6f6c732063616e2063616c6c207468697320604482015267333ab731ba34b7b760c11b60648201526084016109e3565b600081116114a65760405162461bcd60e51b815260206004820152600d60248201526c1a5b9d985b1a59105b5bdd5b9d609a1b60448201526064016109e3565b6001600160a01b0382166114fc5760405162461bcd60e51b815260206004820152601160248201527f21726577617264436f6e74726f6c6c657200000000000000000000000000000060448201526064016109e3565b60006012546a503c8c895ba60a010000006115179190612ff2565b9050808211156115595760405162461bcd60e51b815260206004820152600d60248201526c6578636565645265776172647360981b60448201526064016109e3565b816012546115679190612eab565b60125561157483836123f0565b6040518281526001600160a01b0384169033907f9d228d69b5fdb8d273a2336f8fb8612d039631024ea9bf09c424a9503aa078f0906020015b60405180910390a3505050565b336115cd6005546001600160a01b031690565b6001600160a01b031614806115ec57506009546001600160a01b031633145b6116085760405162461bcd60e51b81526004016109e390612e62565b600e805461ff0019169055565b336116286005546001600160a01b031690565b6001600160a01b0316148061164757506009546001600160a01b031633145b6116635760405162461bcd60e51b81526004016109e390612e62565b6001600160a01b0381166116df5760405162461bcd60e51b815260206004820152602e60248201527f74617820636f6c6c6563746f722061646472657373206d757374206265206e6f60448201527f6e2d7a65726f206164647265737300000000000000000000000000000000000060648201526084016109e3565b600a80546001600160a01b0319166001600160a01b0392909216919091179055565b6005546001600160a01b031633146117495760405162461bcd60e51b815260206004820181905260248201526000805160206130bf83398151915260448201526064016109e3565b611753600061282b565b565b600b54600090600160a01b900460ff161561181357600854604080516369a2085d60e11b8152815160009384936001600160a01b039091169263d34410ba9260048083019392829003018186803b1580156117af57600080fd5b505afa1580156117c3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117e79190612db1565b90925090506117f7816012613009565b61180290600a612f28565b61180c9083612fd3565b9250505090565b60085460408051630e61574b60e41b8152815160009384936001600160a01b039091169263e61574b09260048083019392829003018186803b1580156117af57600080fd5b6005546001600160a01b031633146118a05760405162461bcd60e51b815260206004820181905260248201526000805160206130bf83398151915260448201526064016109e3565b6118aa828261287d565b6040518181526001600160a01b0383169033907f9d228d69b5fdb8d273a2336f8fb8612d039631024ea9bf09c424a9503aa078f0906020015b60405180910390a35050565b336119026005546001600160a01b031690565b6001600160a01b0316148061192157506009546001600160a01b031633145b61193d5760405162461bcd60e51b81526004016109e390612e62565b6001600160a01b03811661199e5760405162461bcd60e51b815260206004820152602260248201527f6f7261636c6520616464726573732063616e6e6f742062652030206164647265604482015261737360f01b60648201526084016109e3565b600880546001600160a01b0319166001600160a01b0392909216919091179055565b6060600480546109109061302c565b6000336119e46005546001600160a01b031690565b6001600160a01b03161480611a0357506009546001600160a01b031633145b611a1f5760405162461bcd60e51b81526004016109e390612e62565b50600c55600190565b33611a3b6005546001600160a01b031690565b6001600160a01b03161480611a5a57506009546001600160a01b031633145b611a765760405162461bcd60e51b81526004016109e390612e62565b6113888161ffff1610611acb5760405162461bcd60e51b815260206004820152601760248201527f5461782072617465732061726520746f6f20686967682e00000000000000000060448201526064016109e3565b600e805461ffff909216620100000263ffff000019909216919091179055565b3360009081526001602090815260408083206001600160a01b038616845290915281205482811015611b6d5760405162461bcd60e51b815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f77604482015264207a65726f60d81b60648201526084016109e3565b611b7a33858584036122d4565b5060019392505050565b3360009081526007602052604090205460ff161515600114611bf95760405162461bcd60e51b815260206004820152602860248201527f4f6e6c7920636f6666696e20706f6f6c732063616e2063616c6c207468697320604482015267333ab731ba34b7b760c11b60648201526084016109e3565b611c03828261287d565b60405181815233906001600160a01b038416907f6ab368f832c266c8eb942b84fbcaa20aedc24a699d2a05fae2568028733b1d09906020016118e3565b6000610a073384846124cf565b3360009081526007602052604090205460ff161515600114611cc25760405162461bcd60e51b815260206004820152602860248201527f4f6e6c7920636f6666696e20706f6f6c732063616e2063616c6c207468697320604482015267333ab731ba34b7b760c11b60648201526084016109e3565b6118aa82826123f0565b33611cdf6005546001600160a01b031690565b6001600160a01b03161480611cfe57506009546001600160a01b031633145b611d1a5760405162461bcd60e51b81526004016109e390612e62565b600b805460ff60a01b19169055565b600033611d3e6005546001600160a01b031690565b6001600160a01b03161480611d5d57506009546001600160a01b031633145b611d795760405162461bcd60e51b81526004016109e390612e62565b6001600160a01b0382166000908152600f602052604090205460ff1615611de25760405162461bcd60e51b815260206004820152601b60248201527f4163636f756e7420697320616c7265616479206578636c75646564000000000060448201526064016109e3565b506001600160a01b03166000908152600f60205260409020805460ff1916600190811790915590565b33611e1e6005546001600160a01b031690565b6001600160a01b03161480611e3d57506009546001600160a01b031633145b611e595760405162461bcd60e51b81526004016109e390612e62565b600e5461012c64010000000090910461ffff1610611ec55760405162461bcd60e51b8152602060048201526024808201527f6261736973207461782072617465732073686f756c64206265206f6e6c792066604482015263032bb97160e51b60648201526084016109e3565b600e805461ffff9092166401000000000265ffff0000000019909216919091179055565b33611efc6005546001600160a01b031690565b6001600160a01b03161480611f1b57506009546001600160a01b031633145b611f375760405162461bcd60e51b81526004016109e390612e62565b600e805460ff19169055565b6005546001600160a01b03163314611f8b5760405162461bcd60e51b815260206004820181905260248201526000805160206130bf83398151915260448201526064016109e3565b6001600160a01b038116611fd95760405162461bcd60e51b815260206004820152601560248201527416995c9bc81859191c995cdcc819195d1958dd1959605a1b60448201526064016109e3565b6001600160a01b03811660009081526007602052604090205460ff16156120425760405162461bcd60e51b815260206004820152601660248201527f4164647265737320616c7265616479206578697374730000000000000000000060448201526064016109e3565b6001600160a01b0381166000818152600760209081526040808320805460ff191660019081179091556006805491820181559093527ff652222313e28459528d920b65115c16c04f3efc82aaedc97be59f3f377c0d3f90920180546001600160a01b0319168417905590519182527f73cca62ab1b520c9715bf4e6c71e3e518c754e7148f65102f43289a7df0efea6910161106e565b600b546000906001600160a01b03166120f357506000919050565b600b54600d54600e5460405163855ee2f760e01b815260048101869052602481019290925263ffffffff6601000000000000820481166044840152600160501b820416606483015261ffff640100000000820481166084840152620100009091041660a48201526001600160a01b039091169063855ee2f79060c40160206040518083038186803b15801561218757600080fd5b505afa15801561219b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a0b9190612d7b565b6005546001600160a01b031633146122075760405162461bcd60e51b815260206004820181905260248201526000805160206130bf83398151915260448201526064016109e3565b6001600160a01b03811661226c5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084016109e3565b61119f8161282b565b336122886005546001600160a01b031690565b6001600160a01b031614806122a757506009546001600160a01b031633145b6122c35760405162461bcd60e51b81526004016109e390612e62565b600e805461ff001916610100179055565b6001600160a01b0383166123365760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b60648201526084016109e3565b6001600160a01b0382166123975760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b60648201526084016109e3565b6001600160a01b0383811660008181526001602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92591016115ad565b6001600160a01b0382166124465760405162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f20616464726573730060448201526064016109e3565b80600260008282546124589190612eab565b90915550506001600160a01b03821660009081526020819052604081208054839290612485908490612eab565b90915550506040518181526001600160a01b038316906000907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9060200160405180910390a35050565b6001600160a01b0383166125335760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604482015264647265737360d81b60648201526084016109e3565b6001600160a01b0382166125955760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201526265737360e81b60648201526084016109e3565b600081116125f75760405162461bcd60e51b815260206004820152602960248201527f5472616e7366657220616d6f756e74206d7573742062652067726561746572206044820152687468616e207a65726f60b81b60648201526084016109e3565b6000806126026128fe565b506008805461ffff60b01b1916600160b01b61ffff8516908102919091179091559193509150158061264c57506001600160a01b03851660009081526007602052604090205460ff165b8061266f57506001600160a01b03841660009081526007602052604090205460ff165b8061269257506001600160a01b0385166000908152600f602052604090205460ff165b806126b557506001600160a01b0384166000908152600f602052604090205460ff165b156126ca576126c5858585612975565b6126d9565b6126d78585858585612b44565b505b5050505050565b6001600160a01b0382166127405760405162461bcd60e51b815260206004820152602160248201527f45524332303a206275726e2066726f6d20746865207a65726f206164647265736044820152607360f81b60648201526084016109e3565b6001600160a01b038216600090815260208190526040902054818110156127b45760405162461bcd60e51b815260206004820152602260248201527f45524332303a206275726e20616d6f756e7420657863656564732062616c616e604482015261636560f01b60648201526084016109e3565b6001600160a01b03831660009081526020819052604081208383039055600280548492906127e3908490612ff2565b90915550506040518281526000906001600160a01b038516907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef906020016115ad565b505050565b600580546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b6000612889833361083c565b9050818110156128e75760405162461bcd60e51b8152602060048201526024808201527f45524332303a206275726e20616d6f756e74206578636565647320616c6c6f77604482015263616e636560e01b60648201526084016109e3565b6128f483338484036122d4565b61282683836126e0565b600e546000908190819060ff161561297057612918611755565b905060008111801561292b5750600d5481105b1561297057600c5481101561293f57600191505b600e54610100900460ff161561295f57612958816120d8565b9250909192565b600854600160a01b900461ffff1692505b909192565b6001600160a01b0383166129d95760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604482015264647265737360d81b60648201526084016109e3565b6001600160a01b038216612a3b5760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201526265737360e81b60648201526084016109e3565b6001600160a01b03831660009081526020819052604090205481811015612ab35760405162461bcd60e51b815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e7420657863656564732062604482015265616c616e636560d01b60648201526084016109e3565b6001600160a01b03808516600090815260208190526040808220858503905591851681529081208054849290612aea908490612eab565b92505081905550826001600160a01b0316846001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef84604051612b3691815260200190565b60405180910390a350505050565b600e5460009061ffff6201000090910481169084161115612b6f57600e5462010000900461ffff1692505b6000612b8b612710612b858761ffff8816612c68565b90612c7b565b90506000612b998683612c87565b9050858210612c105760405162461bcd60e51b815260206004820152603a60248201527f7468652074617820616d6f756e742073686f756c64206265206c65737320746860448201527f616e20746865207472616e7366657272656420616d6f756e742e00000000000060648201526084016109e3565b8315612c2b578115612c2657612c2688836126e0565b612c49565b8115612c4957600a54612c499089906001600160a01b031684612975565b8015612c5a57612c5a888883612975565b506001979650505050505050565b6000612c748284612fd3565b9392505050565b6000612c748284612ec3565b6000612c748284612ff2565b80356001600160a01b03811681146109f557600080fd5b600060208284031215612cbc57600080fd5b612c7482612c93565b60008060408385031215612cd857600080fd5b612ce183612c93565b9150612cef60208401612c93565b90509250929050565b600080600060608486031215612d0d57600080fd5b612d1684612c93565b9250612d2460208501612c93565b9150604084013590509250925092565b60008060408385031215612d4757600080fd5b612d5083612c93565b946020939093013593505050565b600060208284031215612d7057600080fd5b8135612c74816130ae565b600060208284031215612d8d57600080fd5b8151612c74816130ae565b600060208284031215612daa57600080fd5b5035919050565b60008060408385031215612dc457600080fd5b82519150602083015160ff81168114612ddc57600080fd5b809150509250929050565b600060208284031215612df957600080fd5b813563ffffffff81168114612c7457600080fd5b600060208083528351808285015260005b81811015612e3a57858101830151858201604001528201612e1e565b81811115612e4c576000604083870101525b50601f01601f1916929092016040019392505050565b60208082526029908201527f43616c6c6572206973206e6f7420746865206f776e6572206f722074686520746040820152686178206f666669636560b81b606082015260800190565b60008219821115612ebe57612ebe613082565b500190565b600082612ee057634e487b7160e01b600052601260045260246000fd5b500490565b600181815b80851115612f20578160001904821115612f0657612f06613082565b80851615612f1357918102915b93841c9390800290612eea565b509250929050565b6000612c7460ff841683600082612f4157506001610a0b565b81612f4e57506000610a0b565b8160018114612f645760028114612f6e57612f8a565b6001915050610a0b565b60ff841115612f7f57612f7f613082565b50506001821b610a0b565b5060208310610133831016604e8410600b8410161715612fad575081810a610a0b565b612fb78383612ee5565b8060001904821115612fcb57612fcb613082565b029392505050565b6000816000190483118215151615612fed57612fed613082565b500290565b60008282101561300457613004613082565b500390565b600060ff821660ff84168082101561302357613023613082565b90039392505050565b600181811c9082168061304057607f821691505b6020821081141561306157634e487b7160e01b600052602260045260246000fd5b50919050565b600060001982141561307b5761307b613082565b5060010190565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b61ffff8116811461119f57600080fdfe4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572a164736f6c6343000807000a

Block Transaction Gas Used Reward
Age Block Fee Address BC Fee Address Voting Power Jailed Incoming
Validator ID :
0 FTM

Amount Staked
0

Amount Delegated
0

Staking Total
0

Staking Start Epoch
0

Staking Start Time
0

Proof of Importance
0

Origination Score
0

Validation Score
0

Active
0

Online
0

Downtime
0 s
Address Amount claimed Rewards Created On Epoch Created On
Block Uncle Number Difficulty Gas Used Reward
Loading
Loading
Make sure to use the "Vote Down" button for any spammy posts, and the "Vote Up" for interesting conversations.