Contract 0xc5ed01c046C67F36DeA2b22B73338F5124687f75 1

Contract Overview

Balance:
0 MATIC
Txn Hash Method
Block
From
To
Value [Txn Fee]
0xb893c936060707326cb880ff6e0d941b23b6aefbb36341257d00ffdc2f03d796Repay Index Toke...239138482022-01-15 13:41:4413 days 5 hrs ago0x8e1d4ee6c2948316fe34b76613284eeea8f5aff0 IN  0xc5ed01c046c67f36dea2b22b73338f5124687f750 MATIC0.0001219159991.999999999
0x528edcddcaef69066c8f8035e8f529f3c55ceaf2421bbf35cbd188e789607e71Borrow Against I...239138452022-01-15 13:41:3213 days 5 hrs ago0x8e1d4ee6c2948316fe34b76613284eeea8f5aff0 IN  0xc5ed01c046c67f36dea2b22b73338f5124687f750 MATIC0.0004577959991.999999999
0x11a88a18a66b7ac2043ff2fee1a3dc4af3ded1a2cf6fca60b876d048741c1550Borrow Against I...239138412022-01-15 13:41:1613 days 5 hrs ago0x8e1d4ee6c2948316fe34b76613284eeea8f5aff0 IN  0xc5ed01c046c67f36dea2b22b73338f5124687f750 MATIC0.0002094359991.999999999
0xe49e2390c40c456a9653be131dc53af01cef445ebc1b2ec4f31c5e556af207a4Borrow Against I...239138382022-01-15 13:41:0413 days 5 hrs ago0x8e1d4ee6c2948316fe34b76613284eeea8f5aff0 IN  0xc5ed01c046c67f36dea2b22b73338f5124687f750 MATIC0.000457822
0x13a683074ff6ee05021a37d4f98931343a6dba704cd2925697ebd0e963b1edc8Add Pool To Farm239138202022-01-15 13:39:5213 days 5 hrs ago0x8e1d4ee6c2948316fe34b76613284eeea8f5aff0 IN  0xc5ed01c046c67f36dea2b22b73338f5124687f750 MATIC0.0003324939991.999999997
0x9420d5f911db77c50a5166e3b43e2dea3c673ab0527598d87676737228589f4fAdd Pool To Farm239138142022-01-15 13:39:2813 days 5 hrs ago0x8e1d4ee6c2948316fe34b76613284eeea8f5aff0 IN  0xc5ed01c046c67f36dea2b22b73338f5124687f750 MATIC0.0002843259991.999999997
0x4a0002eeb50adf19fb6516f7ca87c15ec710caa9c7aeb929127c831488524cccAdd Pool To Farm239138072022-01-15 13:39:0013 days 5 hrs ago0x8e1d4ee6c2948316fe34b76613284eeea8f5aff0 IN  0xc5ed01c046c67f36dea2b22b73338f5124687f750 MATIC0.0002965579991.999999997
0x93a7ea966737db149165ddf60acb9b7ec1ca6cc59e27bd4c8f8de0e876de6ae0Mint239135362022-01-15 13:27:0213 days 6 hrs ago0x8e1d4ee6c2948316fe34b76613284eeea8f5aff0 IN  0xc5ed01c046c67f36dea2b22b73338f5124687f750 MATIC0.0004539219991.999999997
0x56296528170f380e456c2e27037443bf563a01cee7395acaeb38a2a2e4b23756Mint239135322022-01-15 13:26:4413 days 6 hrs ago0x8e1d4ee6c2948316fe34b76613284eeea8f5aff0 IN  0xc5ed01c046c67f36dea2b22b73338f5124687f750 MATIC0.0005222979991.999999997
0xf83b3c2e35b38f94e32ff8362ea25491e0b5af3d2b2b9730d894260cc6eb3012Mint239135292022-01-15 13:26:3213 days 6 hrs ago0x8e1d4ee6c2948316fe34b76613284eeea8f5aff0 IN  0xc5ed01c046c67f36dea2b22b73338f5124687f750 MATIC0.0005223219991.999999997
0x767dbac3c7fea41438950d99900ca0e0dc796d49f36ef49c5e848c56f026a2c0Add Supported As...239131762022-01-15 13:06:5613 days 6 hrs ago0x8e1d4ee6c2948316fe34b76613284eeea8f5aff0 IN  0xc5ed01c046c67f36dea2b22b73338f5124687f750 MATIC0.0002929142
0x511c75c9af70ad7544d508606c9fa087abc2ec259ec3d07b0a40a610749fdb5aAdd Supported As...239131752022-01-15 13:06:5213 days 6 hrs ago0x8e1d4ee6c2948316fe34b76613284eeea8f5aff0 IN  0xc5ed01c046c67f36dea2b22b73338f5124687f750 MATIC0.0002531382.000000001
0x0dbb27707a3df12bab90501ab60b87b4022dead9b833e439610e322198757d84Add Supported To...239131732022-01-15 13:06:4413 days 6 hrs ago0x8e1d4ee6c2948316fe34b76613284eeea8f5aff0 IN  0xc5ed01c046c67f36dea2b22b73338f5124687f750 MATIC0.0002248082.000000001
0x5cfb0d72e478f45b53bb31ba92e8b201c26de9980a81c0ce0fa8fe185c31d007Create Token239131722022-01-15 13:06:4013 days 6 hrs ago0x8e1d4ee6c2948316fe34b76613284eeea8f5aff0 IN  0xc5ed01c046c67f36dea2b22b73338f5124687f750 MATIC0.0023088140022.000000002
0xcafc1b3180a48c32320f20650c480a03159da9e56efc1acaa669781148062257Add Supported To...239131712022-01-15 13:06:3613 days 6 hrs ago0x8e1d4ee6c2948316fe34b76613284eeea8f5aff0 IN  0xc5ed01c046c67f36dea2b22b73338f5124687f750 MATIC0.0002988082.000000002
0xa246facf261d804c320ce92393afcd022c63570aeabed52146c2f741bfc7dc28Create Token239131702022-01-15 13:06:3213 days 6 hrs ago0x8e1d4ee6c2948316fe34b76613284eeea8f5aff0 IN  0xc5ed01c046c67f36dea2b22b73338f5124687f750 MATIC0.0023089580022.000000002
0x9d88cfa4c9ad986e80517c47825612072259d34884fc768cb0cb6e2cc95c7221Add Supported To...239131692022-01-15 13:06:2813 days 6 hrs ago0x8e1d4ee6c2948316fe34b76613284eeea8f5aff0 IN  0xc5ed01c046c67f36dea2b22b73338f5124687f750 MATIC0.0002590082.000000001
0xb904c834786993a3ce2caf417d793724855f9e061ce03076576b993573a89211Create Token239131672022-01-15 13:06:2013 days 6 hrs ago0x8e1d4ee6c2948316fe34b76613284eeea8f5aff0 IN  0xc5ed01c046c67f36dea2b22b73338f5124687f750 MATIC0.0023430379981.999999999
0x679630c1a09d298425b3b9e6369c1d544b1c47d3ddbb29b87458cf51ab16f10cAdd Supported Cu...239131592022-01-15 13:05:4813 days 6 hrs ago0x8e1d4ee6c2948316fe34b76613284eeea8f5aff0 IN  0xc5ed01c046c67f36dea2b22b73338f5124687f750 MATIC0.0002847099991.999999999
0x148ca988055f87a725c35713c617a5fc1e00b87ec3fc93907c4f18f187d7ee77Create Coin239131572022-01-15 13:05:4013 days 6 hrs ago0x8e1d4ee6c2948316fe34b76613284eeea8f5aff0 IN  0xc5ed01c046c67f36dea2b22b73338f5124687f750 MATIC0.0024236279981.999999999
0x753b403c3c9c76c95a2df7e990b69a3b144b1678d0a5d173d2c1b44f2d73de10Add Supported Cu...239131562022-01-15 13:05:3613 days 6 hrs ago0x8e1d4ee6c2948316fe34b76613284eeea8f5aff0 IN  0xc5ed01c046c67f36dea2b22b73338f5124687f750 MATIC0.0002791099991.999999998
0xb79c8a3e7060726030c6fcfe067121bb326aa80881ffed783236ec1b78f6e4eeCreate Coin239131542022-01-15 13:05:2813 days 6 hrs ago0x8e1d4ee6c2948316fe34b76613284eeea8f5aff0 IN  0xc5ed01c046c67f36dea2b22b73338f5124687f750 MATIC0.0023782279971.999999998
0x4d192e07a90f022fd37c8b7a821a839d93e6fe7e2610c5bbc0aafffb485de0c0Fund Farm239131272022-01-15 13:03:3613 days 6 hrs ago0x8e1d4ee6c2948316fe34b76613284eeea8f5aff0 IN  0xc5ed01c046c67f36dea2b22b73338f5124687f750 MATIC0.0002595659991.999999999
0x41b0ae770deacbdace29168b4332b0b32b7cf0e88ea65ddb8bb3d99ec8b72f950x60806040239131002022-01-15 13:01:4813 days 6 hrs ago0x8e1d4ee6c2948316fe34b76613284eeea8f5aff0 IN  Create: Treasury0 MATIC0.0096140720092.000000002
[ Download CSV Export 
Parent Txn Hash Block From To Value
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
Treasury

Compiler Version
v0.8.10+commit.fc410830

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion, MIT license

Contract Source Code (Solidity Standard Json-Input format)

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

import {IndexToken} from "IndexToken.sol";
import {IOracle} from "IOracle.sol";
import "ERC20.sol";
import { SafeERC20 } from "SafeERC20.sol";


import { SafeMath } from "SafeMath.sol";
import { StableMath } from "StableMath.sol";
import {IUniswapV2Router02} from "IUniswapV2Router02.sol";
import {IUniswapV2Factory} from "IUniswapV2Factory.sol";
import {IUniswapV2Pair} from "IUniswapV2Pair.sol";
import {PortfolioToken} from "PortfolioToken.sol";
import {Farm} from "Farm.sol";
import {IndexTokenFactory} from "IndexTokenFactory.sol";
import {AbstractLender} from "AbstractLender.sol";
import {StableCoin} from "StableCoin.sol";
import {StableCoinFactory} from "StableCoinFactory.sol";

contract Treasury is AbstractLender{
    using SafeERC20 for IERC20;
    using StableMath for uint256;
    using SafeMath for uint256;
    
    
    constructor(address _oracle, address _factory, address _stableCoinFactory, address portfolioTokenAddress, 
                address farmAddress, address uniswapRouterAddress, address uniswapFactoryAddress){
        oracle = IOracle(_oracle);
        factory = IndexTokenFactory(_factory);
        stableCoinFactory = StableCoinFactory(_stableCoinFactory);
        portfolioToken = PortfolioToken(portfolioTokenAddress);
        farm = Farm(farmAddress);
        uniswapRouter = IUniswapV2Router02(uniswapRouterAddress);
        uniswapFactory = IUniswapV2Factory(uniswapFactoryAddress);
    }

    function mint(address _asset, address _token, uint collateralAmount, uint tokenAmount) public{
        require(assets[_asset].isSupported, "Asset is not supported");
        require(tokens[_token].isSupported, "Token is not supported");
        require(assets[_asset].currency == tokens[_token].currency, "Asset and token must have same currency");
        IERC20 asset = IERC20(_asset);
        IndexToken token = IndexToken(_token);
        tokenAmount.scaleBy(18, _assetDecimals[_asset]);
        collateralAmount.scaleBy(18, _assetDecimals[_asset]);
        uint price = oracle.getPrice(token.symbol());
        uint collateralValue = token.getTotalAmountPaid(msg.sender);
        uint min_collateral = price.mulTruncate(token.getTotalTokenMinted(msg.sender)).mulTruncate(_min_collateral_ratio);
        uint excessCollateral = 0;
        if (collateralValue > min_collateral){
            excessCollateral = collateralValue  -  min_collateral;
        }
        require(collateralAmount + excessCollateral >= tokenAmount.mulTruncate(price).mulTruncate(_min_collateral_ratio),
                                                                             "Provide more collateral!");
        uint transaction_fee = tokenAmount.mulTruncate(price).mulTruncate(_transaction_fee);
        asset.safeTransferFrom(msg.sender, address(this), collateralAmount + transaction_fee);
        token.mint(msg.sender, tokenAmount, collateralAmount);
        asset.approve(msg.sender, token.getTotalAmountPaid(msg.sender));
    }

    function redeem(address _asset, address _token, uint tokenAmount) public {
        require(assets[_asset].isSupported, "Asset is not supported");
        require(tokens[_token].isSupported, "Token is not supported");
        require(assets[_asset].currency == tokens[_token].currency, "Asset and token must have same currency");

        IndexToken token = IndexToken(_token);
        require(token.getTotalTokenMinted(msg.sender) >= tokenAmount, "Cannot redeem more than minted amount");
        
        IERC20 asset = IERC20(_asset);
        uint price = oracle.getPrice(token.symbol());
        uint amountToRedeem = price.mulTruncate(tokenAmount);
        require(asset.balanceOf(address(this)) > amountToRedeem, "Insufficent balance of this asset in treasury");
        token.burn(msg.sender, tokenAmount, amountToRedeem);
        asset.safeTransfer(msg.sender, amountToRedeem);
        asset.approve(msg.sender, token.getTotalAmountPaid(msg.sender));
    }

    function liquidate(address account, address _token, address _asset, uint slippage) public {
        require(tokens[_token].isSupported, "Token is not supported");
        require(assets[_asset].isSupported, "Asset is not supported");
        require(assets[_asset].currency == tokens[_token].currency, "Asset and token must have same currency");

        IndexToken token = IndexToken(_token);
        uint price = oracle.getPrice(token.symbol());

        uint collateralValue = token.getTotalAmountPaid(account);
        uint mintedValue = token.getTotalTokenMinted(account).mulTruncate(price);

        require(mintedValue.mulTruncate(_liquidation_ratio) > collateralValue, "Does not meet liquidation criteria");

        uint amountToLiquidate = (mintedValue.mulTruncate(_liquidation_ratio) - collateralValue).divPrecisely(
                                                                            _liquidation_ratio - 10**18);
        uint tokenToLiquidate = amountToLiquidate.divPrecisely(price);

        IUniswapV2Pair pair = IUniswapV2Pair(uniswapFactory.getPair(_token, _asset));

        // there might be a better way to do this
        if (pair.token0() == _token){
            require(price >= pair.price0CumulativeLast().mulTruncate(uint(1003).divPrecisely(1000))
                                                        , "Oracle Price less then Uniswap Price");
        }
        else {
            require(price >= pair.price1CumulativeLast().mulTruncate(uint(1003).divPrecisely(1000))
                                                        , "Oracle Price less then Uniswap Price");
        }
        
        address[] memory path = new address[](2);
        path[0] = _asset;
        path[1] = _token;
        
        uint maxAmoutOut = amountToLiquidate.mulTruncate(slippage);
        IERC20(_asset).approve(address(uniswapRouter), maxAmoutOut + 1);
        (uint[] memory amounts) = uniswapRouter.swapTokensForExactTokens(tokenToLiquidate, maxAmoutOut,
                             path, address(this), 100*10**18);
        token.burnLiquidate(account, tokenToLiquidate,  amounts[0]);
    }

    function getCollateralValue(address account, address _token) public view returns(uint){
        IndexToken token = IndexToken(_token);
        return token.getTotalAmountPaid(account);
    }

    function getExcessCollateralValue(address account, address _token) public view returns(uint){
        IndexToken token = IndexToken(_token);
        uint price = oracle.getPrice(token.symbol());
        uint collateralValue = token.getTotalAmountPaid(account);
        uint min_collateral = price.mulTruncate(token.getTotalTokenMinted(account)).mulTruncate(_min_collateral_ratio);
        uint excessCollateral = 0;
        if (collateralValue > min_collateral){
            uint excessCollateral = collateralValue  -  min_collateral;
        }
        return excessCollateral;
    }

    function getCollateralRatio(address account, address _token) public view returns(uint){
        IndexToken token = IndexToken(_token);
        uint price = oracle.getPrice(token.symbol());
        uint collateralValue = token.getTotalAmountPaid(account);
        uint mintedValue = price.mulTruncate(token.getTotalTokenMinted(account));
        if (mintedValue == 0){
            return 0;
        }
        uint collateralRatio = collateralValue.divPrecisely(mintedValue);
        return collateralRatio;
    }

    function addCollateral(address _asset, address _token, uint amount) public{
        require(tokens[_token].isSupported, "Token is not supported");
        require(assets[_asset].isSupported, "Asset is not supported");
        require(assets[_asset].currency == tokens[_token].currency, "Asset and token must have same currency");

        IERC20 asset = IERC20(_asset);
        IndexToken token = IndexToken(_token);
        amount = amount.scaleBy(18, _assetDecimals[_asset]);
        asset.safeTransferFrom(msg.sender, address(this), amount); 
        token.setTotalAmountPaid(msg.sender, token.getTotalAmountPaid(msg.sender) + amount);
        asset.approve(msg.sender, token.getTotalAmountPaid(msg.sender));
    }

    function reduceCollateral(address _asset, address _token, uint amount) public{
        require(tokens[_token].isSupported, "Token is not supported");
        require(assets[_asset].isSupported, "Asset is not supported");
        require(assets[_asset].currency == tokens[_token].currency, "Asset and token must have same currency");

        IndexToken token = IndexToken(_token);
        uint price = oracle.getPrice(token.symbol());
        uint collateralValue = token.getTotalAmountPaid(msg.sender);
        uint excessCollateral = collateralValue  -  price.mulTruncate(token.getTotalTokenMinted(msg.sender 
                                                        )).mulTruncate(_min_collateral_ratio);

        IERC20 asset = IERC20(_asset);
        amount = amount.scaleBy(18, _assetDecimals[_asset]);
        require(amount <= excessCollateral, "You need to maintain sufficient collateral!");
        
        asset.safeTransfer(msg.sender, amount);  
        token.setTotalAmountPaid(msg.sender, token.getTotalAmountPaid(msg.sender) - amount);
        asset.approve(msg.sender, token.getTotalAmountPaid(msg.sender));
    }

    function treasuryAssetBalance(string memory currencyName) view public returns(uint){
        uint balance = 0;
        for (uint i = 0; i < allAssets[currencyName].length; i++){
            uint assetBalance = IERC20(allAssets[currencyName][i]).balanceOf(address(this));
            balance += assetBalance.scaleBy(_assetDecimals[allAssets[currencyName][i]], 18);
        }
        return balance;
    }

    function allowance(address account, address _asset) view public returns (uint){
        IERC20 asset = IERC20(_asset);
        return asset.allowance(account, address(this));
    }

    function getMinters(address _token) public view returns (address[] memory){
        IndexToken token = IndexToken(_token);
        return token.getMinters();
    }

    function fundFarm(uint amount) external onlyOwner{
        portfolioToken.mint(address(this), amount);
        portfolioToken.approve(address(farm), amount + 1);
        farm.fund(amount);
    }

    function createToken(string memory name, string memory symbol) external onlyOwner{
        factory.createIndexToken(name, symbol);
    }

    function addPoolToFarm(uint256 _allocPoint, IERC20 _lpToken, bool _withUpdate) external onlyOwner {
        for (uint i = 0; i < farm.poolLength(); i++){
            (IERC20 lpToken,uint256 a,uint256 b,uint256 c) = farm.poolInfo(i);
            require(address(_lpToken) != address(lpToken), "LP Token already in farm");
        }
        farm.add(_allocPoint, _lpToken, _withUpdate);
    }
}

File 2 of 25 : IndexToken.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.7;

import { ERC20 } from "ERC20.sol";
import "Ownable.sol";

contract IndexToken is ERC20, Ownable{
    string private _name;
    string private _symbol;
    uint8 private _decimals;
    address private _factory;

    function _initialize(string memory nameArg, string memory symbolArg, uint8 decimalsArg) internal {
        _name = nameArg;
        _symbol = symbolArg;
        _decimals = decimalsArg;
        _factory = msg.sender;
    }

    function name() public override view returns (string memory) {
        return _name;
    }

    function symbol() public override view returns (string memory) {
        return _symbol;
    }

    function decimals() public override view returns (uint8) {
        return _decimals;
    }
    function factory() public view returns (address) {
        return _factory;
    }

    mapping(address => uint) private _totalTokenMinted;
    mapping(address => uint) private _totalAmountPaid;
     
    address[] private minters; 
    
    constructor(string memory _name, string memory _symbol) ERC20(_name, _symbol){
        _initialize(_name, _symbol, 18);
    }
    function mint(address _account, uint _tokenMinted, uint _amountPaid) external onlyOwner{
        _mint(_account, _tokenMinted);
        _totalTokenMinted[_account] += _tokenMinted;
        _totalAmountPaid[_account] += _amountPaid;
        minters.push(_account);
    }
    function burn(address _account, uint _tokenBurned, uint _amountRedeemed) external onlyOwner{
        _burn(_account, _tokenBurned);
        _totalTokenMinted[_account] -= _tokenBurned;
        _totalAmountPaid[_account] -= _amountRedeemed;
    }
    function burnLiquidate(address _account, uint _tokenBurned, uint _amountRedeemed) external onlyOwner{
        _burn(msg.sender, _tokenBurned);
        _totalTokenMinted[_account] -= _tokenBurned;
        _totalAmountPaid[_account] -= _amountRedeemed;
    }
    function getTotalTokenMinted(address _account) external view returns (uint){
        return _totalTokenMinted[_account];
    }
    function getTotalAmountPaid(address _account) external view returns (uint){
        return _totalAmountPaid[_account];
    }
    function setTotalAmountPaid(address _account, uint amount) external onlyOwner{
        _totalAmountPaid[_account] =  amount;
    }
    function getMinters() external view  onlyOwner returns (address[] memory) {
        return minters;
    }   
}

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

pragma solidity ^0.8.0;

import "IERC20.sol";
import "IERC20Metadata.sol";
import "Context.sol";

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

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

    uint256 private _totalSupply;

    string private _name;
    string private _symbol;

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

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

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

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

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

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

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

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

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

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

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

        return true;
    }

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

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

        return true;
    }

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

        _beforeTokenTransfer(sender, recipient, amount);

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

        emit Transfer(sender, recipient, amount);

        _afterTokenTransfer(sender, recipient, amount);
    }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

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

pragma solidity ^0.8.0;

import "IERC20.sol";

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

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

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

File 6 of 25 : Context.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)

pragma solidity ^0.8.0;

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

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

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

pragma solidity ^0.8.0;

import "Context.sol";

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

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

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

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

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

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

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

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

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

interface IOracle{
    function getPrice(string memory symbol) external view returns (uint);
}

File 9 of 25 : SafeERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/utils/SafeERC20.sol)

pragma solidity ^0.8.0;

import "IERC20.sol";
import "Address.sol";

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

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

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

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

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

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

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

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

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

pragma solidity ^0.8.0;

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

        uint256 size;
        assembly {
            size := extcodesize(account)
        }
        return size > 0;
    }

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

        (bool success, ) = recipient.call{value: amount}("");
        require(success, "Address: unable to send value, recipient may have reverted");
    }

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

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

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

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

        (bool success, bytes memory returndata) = target.call{value: value}(data);
        return verifyCallResult(success, returndata, errorMessage);
    }

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

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

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

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

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

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

    /**
     * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the
     * revert reason using the provided one.
     *
     * _Available since v4.3._
     */
    function verifyCallResult(
        bool success,
        bytes memory returndata,
        string memory errorMessage
    ) internal pure returns (bytes memory) {
        if (success) {
            return returndata;
        } else {
            // Look for revert reason and bubble it up if present
            if (returndata.length > 0) {
                // The easiest way to bubble the revert reason is using memory via assembly

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

File 11 of 25 : SafeMath.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/math/SafeMath.sol)

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 generally not needed starting with Solidity 0.8, since 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 12 of 25 : StableMath.sol
// SPDX-License-Identifier: agpl-3.0
pragma solidity ^0.8.0;

import { SafeMath } from "SafeMath.sol";

// Based on StableMath from Stability Labs Pty. Ltd.
// https://github.com/mstable/mStable-contracts/blob/master/contracts/shared/StableMath.sol

library StableMath {
    using SafeMath for uint256;

    /**
     * @dev Scaling unit for use in specific calculations,
     * where 1 * 10**18, or 1e18 represents a unit '1'
     */
    uint256 private constant FULL_SCALE = 1e18;

    /***************************************
                    Helpers
    ****************************************/

    /**
     * @dev Adjust the scale of an integer
     * @param to Decimals to scale to
     * @param from Decimals to scale from
     */
    function scaleBy(
        uint256 x,
        uint256 to,
        uint256 from
    ) internal pure returns (uint256) {
        if (to > from) {
            x = x.mul(10**(to - from));
        } else if (to < from) {
            x = x.div(10**(from - to));
        }
        return x;
    }

    /***************************************
               Precise Arithmetic
    ****************************************/

    /**
     * @dev Multiplies two precise units, and then truncates by the full scale
     * @param x Left hand input to multiplication
     * @param y Right hand input to multiplication
     * @return Result after multiplying the two inputs and then dividing by the shared
     *         scale unit
     */
    function mulTruncate(uint256 x, uint256 y) internal pure returns (uint256) {
        return mulTruncateScale(x, y, FULL_SCALE);
    }

    /**
     * @dev Multiplies two precise units, and then truncates by the given scale. For example,
     * when calculating 90% of 10e18, (10e18 * 9e17) / 1e18 = (9e36) / 1e18 = 9e18
     * @param x Left hand input to multiplication
     * @param y Right hand input to multiplication
     * @param scale Scale unit
     * @return Result after multiplying the two inputs and then dividing by the shared
     *         scale unit
     */
    function mulTruncateScale(
        uint256 x,
        uint256 y,
        uint256 scale
    ) internal pure returns (uint256) {
        // e.g. assume scale = fullScale
        // z = 10e18 * 9e17 = 9e36
        uint256 z = x.mul(y);
        // return 9e36 / 1e18 = 9e18
        return z.div(scale);
    }

    /**
     * @dev Multiplies two precise units, and then truncates by the full scale, rounding up the result
     * @param x Left hand input to multiplication
     * @param y Right hand input to multiplication
     * @return Result after multiplying the two inputs and then dividing by the shared
     *          scale unit, rounded up to the closest base unit.
     */
    function mulTruncateCeil(uint256 x, uint256 y)
        internal
        pure
        returns (uint256)
    {
        // e.g. 8e17 * 17268172638 = 138145381104e17
        uint256 scaled = x.mul(y);
        // e.g. 138145381104e17 + 9.99...e17 = 138145381113.99...e17
        uint256 ceil = scaled.add(FULL_SCALE.sub(1));
        // e.g. 13814538111.399...e18 / 1e18 = 13814538111
        return ceil.div(FULL_SCALE);
    }

    /**
     * @dev Precisely divides two units, by first scaling the left hand operand. Useful
     *      for finding percentage weightings, i.e. 8e18/10e18 = 80% (or 8e17)
     * @param x Left hand input to division
     * @param y Right hand input to division
     * @return Result after multiplying the left operand by the scale, and
     *         executing the division on the right hand input.
     */
    function divPrecisely(uint256 x, uint256 y)
        internal
        pure
        returns (uint256)
    {
        // e.g. 8e18 * 1e18 = 8e36
        uint256 z = x.mul(FULL_SCALE);
        // e.g. 8e36 / 10e18 = 8e17
        return z.div(y);
    }
}

File 13 of 25 : IUniswapV2Router02.sol
// SPDX-License-Identifier: GPL-3.0

pragma solidity >=0.6.2;

import "IUniswapV2Router01.sol";

interface IUniswapV2Router02 is IUniswapV2Router01 {
    function removeLiquidityETHSupportingFeeOnTransferTokens(
        address token,
        uint liquidity,
        uint amountTokenMin,
        uint amountETHMin,
        address to,
        uint deadline
    ) external returns (uint amountETH);
    function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens(
        address token,
        uint liquidity,
        uint amountTokenMin,
        uint amountETHMin,
        address to,
        uint deadline,
        bool approveMax, uint8 v, bytes32 r, bytes32 s
    ) external returns (uint amountETH);

    function swapExactTokensForTokensSupportingFeeOnTransferTokens(
        uint amountIn,
        uint amountOutMin,
        address[] calldata path,
        address to,
        uint deadline
    ) external;
    function swapExactETHForTokensSupportingFeeOnTransferTokens(
        uint amountOutMin,
        address[] calldata path,
        address to,
        uint deadline
    ) external payable;
    function swapExactTokensForETHSupportingFeeOnTransferTokens(
        uint amountIn,
        uint amountOutMin,
        address[] calldata path,
        address to,
        uint deadline
    ) external;
}

File 14 of 25 : IUniswapV2Router01.sol
// SPDX-License-Identifier: GPL-3.0

pragma solidity >=0.6.2;

interface IUniswapV2Router01 {
    function factory() external pure returns (address);
    function WETH() external pure 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);
}

File 15 of 25 : IUniswapV2Factory.sol
// SPDX-License-Identifier: GPL-3.0

pragma solidity >=0.5.0;

interface IUniswapV2Factory {
    event PairCreated(address indexed token0, address indexed token1, address pair, uint);

    function feeTo() external view returns (address);
    function feeToSetter() external view returns (address);
    function migrator() 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;
    function setMigrator(address) external;
}

File 16 of 25 : IUniswapV2Pair.sol
// SPDX-License-Identifier: GPL-3.0

pragma solidity >=0.5.0;

interface IUniswapV2Pair {
    event Approval(address indexed owner, address indexed spender, uint value);
    event Transfer(address indexed from, address indexed to, uint value);

    function name() external pure returns (string memory);
    function symbol() external pure returns (string memory);
    function decimals() external pure returns (uint8);
    function totalSupply() external view returns (uint);
    function balanceOf(address owner) external view returns (uint);
    function allowance(address owner, address spender) external view returns (uint);

    function approve(address spender, uint value) external returns (bool);
    function transfer(address to, uint value) external returns (bool);
    function transferFrom(address from, address to, uint value) external returns (bool);

    function DOMAIN_SEPARATOR() external view returns (bytes32);
    function PERMIT_TYPEHASH() external pure returns (bytes32);
    function nonces(address owner) external view returns (uint);

    function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external;

    event Mint(address indexed sender, uint amount0, uint amount1);
    event Burn(address indexed sender, uint amount0, uint amount1, address indexed to);
    event Swap(
        address indexed sender,
        uint amount0In,
        uint amount1In,
        uint amount0Out,
        uint amount1Out,
        address indexed to
    );
    event Sync(uint112 reserve0, uint112 reserve1);

    function MINIMUM_LIQUIDITY() external pure returns (uint);
    function factory() external view returns (address);
    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 (uint);
    function price1CumulativeLast() external view returns (uint);
    function kLast() external view returns (uint);

    function mint(address to) external returns (uint liquidity);
    function burn(address to) external returns (uint amount0, uint amount1);
    function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data) external;
    function skim(address to) external;
    function sync() external;

    function initialize(address, address) external;
}

File 17 of 25 : PortfolioToken.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.7;

import "ERC20.sol";
import "Ownable.sol";


contract PortfolioToken is ERC20, Ownable {
    uint private _MAX_SUPPLY = 10**27;
    constructor() ERC20("Portfolio Token", "PORT") {
    }

    function mint(address account, uint amount) external onlyOwner{
        require (totalSupply() + amount < _MAX_SUPPLY, "Can't mint more that MAX_SUPPLY");
        _mint(account, amount);
    }
}

File 18 of 25 : Farm.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.7;

import "IERC20.sol";
import "SafeERC20.sol";
import "EnumerableSet.sol";
import "SafeMath.sol";
import "Ownable.sol";

// Farm distributes the ERC20 rewards based on staked LP to each user.
//
// Cloned from https://github.com/SashimiProject/sashimiswap/blob/master/contracts/MasterChef.sol
// Modified by LTO Network to work for non-mintable ERC20.
contract Farm is Ownable {
    using SafeMath for uint256;
    using SafeERC20 for IERC20;

    // Info of each user.
    struct UserInfo {
        uint256 amount;     // How many LP tokens the user has provided.
        uint256 rewardDebt; // Reward debt. See explanation below.
        //
        // We do some fancy math here. Basically, any point in time, the amount of ERC20s
        // entitled to a user but is pending to be distributed is:
        //
        //   pending reward = (user.amount * pool.accERC20PerShare) - user.rewardDebt
        //
        // Whenever a user deposits or withdraws LP tokens to a pool. Here's what happens:
        //   1. The pool's `accERC20PerShare` (and `lastRewardBlock`) gets updated.
        //   2. User receives the pending reward sent to his/her address.
        //   3. User's `amount` gets updated.
        //   4. User's `rewardDebt` gets updated.
    }

    // Info of each pool.
    struct PoolInfo {
        IERC20 lpToken;             // Address of LP token contract.
        uint256 allocPoint;         // How many allocation points assigned to this pool. ERC20s to distribute per block.
        uint256 lastRewardBlock;    // Last block number that ERC20s distribution occurs.
        uint256 accERC20PerShare;   // Accumulated ERC20s per share, times 1e36.
    }

    // Address of the ERC20 Token contract.
    IERC20 public erc20;
    // The total amount of ERC20 that's paid out as reward.
    uint256 public paidOut = 0;
    // ERC20 tokens rewarded per block.
    uint256 public rewardPerBlock;

    // Info of each pool.
    PoolInfo[] public poolInfo;
    // Info of each user that stakes LP tokens.
    mapping (uint256 => mapping (address => UserInfo)) public userInfo;
    // Total allocation points. Must be the sum of all allocation points in all pools.
    uint256 public totalAllocPoint = 0;

    // The block number when farming starts.
    uint256 public startBlock;
    // The block number when farming ends.
    uint256 public endBlock;

    event Deposit(address indexed user, uint256 indexed pid, uint256 amount);
    event Withdraw(address indexed user, uint256 indexed pid, uint256 amount);
    event EmergencyWithdraw(address indexed user, uint256 indexed pid, uint256 amount);

    constructor(IERC20 _erc20, uint256 _rewardPerBlock, uint256 _startBlock) public {
        erc20 = _erc20;
        rewardPerBlock = _rewardPerBlock;
        startBlock = _startBlock;
        endBlock = _startBlock;
    }

    // Number of LP pools
    function poolLength() external view returns (uint256) {
        return poolInfo.length;
    }

    // Fund the farm, increase the end block
    function fund(uint256 _amount) public {
        require(block.number < endBlock, "fund: too late, the farm is closed");

        erc20.safeTransferFrom(address(msg.sender), address(this), _amount);
        endBlock += _amount.div(rewardPerBlock);
    }

    // Add a new lp to the pool. Can only be called by the owner.
    // DO NOT add the same LP token more than once. Rewards will be messed up if you do.
    function add(uint256 _allocPoint, IERC20 _lpToken, bool _withUpdate) public onlyOwner {
        if (_withUpdate) {
            massUpdatePools();
        }
        uint256 lastRewardBlock = block.number > startBlock ? block.number : startBlock;
        totalAllocPoint = totalAllocPoint.add(_allocPoint);
        poolInfo.push(PoolInfo({
            lpToken: _lpToken,
            allocPoint: _allocPoint,
            lastRewardBlock: lastRewardBlock,
            accERC20PerShare: 0
        }));
    }

    // Update the given pool's ERC20 allocation point. Can only be called by the owner.
    function set(uint256 _pid, uint256 _allocPoint, bool _withUpdate) public onlyOwner {
        if (_withUpdate) {
            massUpdatePools();
        }
        totalAllocPoint = totalAllocPoint.sub(poolInfo[_pid].allocPoint).add(_allocPoint);
        poolInfo[_pid].allocPoint = _allocPoint;
    }

    // View function to see deposited LP for a user.
    function deposited(uint256 _pid, address _user) external view returns (uint256) {
        UserInfo storage user = userInfo[_pid][_user];
        return user.amount;
    }

    // View function to see pending ERC20s for a user.
    function pending(uint256 _pid, address _user) external view returns (uint256) {
        PoolInfo storage pool = poolInfo[_pid];
        UserInfo storage user = userInfo[_pid][_user];
        uint256 accERC20PerShare = pool.accERC20PerShare;
        uint256 lpSupply = pool.lpToken.balanceOf(address(this));
        uint256 lastBlock = block.number < endBlock ? block.number : endBlock;

        if (lastBlock > pool.lastRewardBlock && block.number > pool.lastRewardBlock && lpSupply != 0) {
            uint256 nrOfBlocks = lastBlock.sub(pool.lastRewardBlock);
            uint256 erc20Reward = nrOfBlocks.mul(rewardPerBlock).mul(pool.allocPoint).div(totalAllocPoint);
            accERC20PerShare = accERC20PerShare.add(erc20Reward.mul(1e36).div(lpSupply));
        }

        return user.amount.mul(accERC20PerShare).div(1e36).sub(user.rewardDebt);
    }

    // View function for total reward the farm has yet to pay out.
    function totalPending() external view returns (uint256) {
        if (block.number <= startBlock) {
            return 0;
        }

        uint256 lastBlock = block.number < endBlock ? block.number : endBlock;
        return rewardPerBlock.mul(lastBlock - startBlock).sub(paidOut);
    }

    // Update reward variables for all pools. Be careful of gas spending!
    function massUpdatePools() public {
        uint256 length = poolInfo.length;
        for (uint256 pid = 0; pid < length; ++pid) {
            updatePool(pid);
        }
    }

    // Update reward variables of the given pool to be up-to-date.
    function updatePool(uint256 _pid) public {
        PoolInfo storage pool = poolInfo[_pid];
        uint256 lastBlock = block.number < endBlock ? block.number : endBlock;

        if (lastBlock <= pool.lastRewardBlock) {
            return;
        }
        uint256 lpSupply = pool.lpToken.balanceOf(address(this));
        if (lpSupply == 0) {
            pool.lastRewardBlock = lastBlock;
            return;
        }

        uint256 nrOfBlocks = lastBlock.sub(pool.lastRewardBlock);
        uint256 erc20Reward = nrOfBlocks.mul(rewardPerBlock).mul(pool.allocPoint).div(totalAllocPoint);

        pool.accERC20PerShare = pool.accERC20PerShare.add(erc20Reward.mul(1e36).div(lpSupply));
        pool.lastRewardBlock = block.number;
    }

    // Deposit LP tokens to Farm for ERC20 allocation.
    function deposit(uint256 _pid, uint256 _amount) public {
        PoolInfo storage pool = poolInfo[_pid];
        UserInfo storage user = userInfo[_pid][msg.sender];
        updatePool(_pid);
        if (user.amount > 0) {
            uint256 pendingAmount = user.amount.mul(pool.accERC20PerShare).div(1e36).sub(user.rewardDebt);
            erc20Transfer(msg.sender, pendingAmount);
        }
        pool.lpToken.safeTransferFrom(address(msg.sender), address(this), _amount);
        user.amount = user.amount.add(_amount);
        user.rewardDebt = user.amount.mul(pool.accERC20PerShare).div(1e36);
        emit Deposit(msg.sender, _pid, _amount);
    }

    // Withdraw LP tokens from Farm.
    function withdraw(uint256 _pid, uint256 _amount) public {
        PoolInfo storage pool = poolInfo[_pid];
        UserInfo storage user = userInfo[_pid][msg.sender];
        require(user.amount >= _amount, "withdraw: can't withdraw more than deposit");
        updatePool(_pid);
        uint256 pendingAmount = user.amount.mul(pool.accERC20PerShare).div(1e36).sub(user.rewardDebt);
        erc20Transfer(msg.sender, pendingAmount);
        user.amount = user.amount.sub(_amount);
        user.rewardDebt = user.amount.mul(pool.accERC20PerShare).div(1e36);
        pool.lpToken.safeTransfer(address(msg.sender), _amount);
        emit Withdraw(msg.sender, _pid, _amount);
    }

    function claimReward(uint256 _pid) public {
        PoolInfo storage pool = poolInfo[_pid];
        UserInfo storage user = userInfo[_pid][msg.sender];
        updatePool(_pid);
        uint256 pendingAmount = user.amount.mul(pool.accERC20PerShare).div(1e36).sub(user.rewardDebt);
        erc20Transfer(msg.sender, pendingAmount);
    }


    // Withdraw without caring about rewards. EMERGENCY ONLY.
    function emergencyWithdraw(uint256 _pid) public {
        PoolInfo storage pool = poolInfo[_pid];
        UserInfo storage user = userInfo[_pid][msg.sender];
        pool.lpToken.safeTransfer(address(msg.sender), user.amount);
        emit EmergencyWithdraw(msg.sender, _pid, user.amount);
        user.amount = 0;
        user.rewardDebt = 0;
    }

    // Transfer ERC20 and update the required ERC20 to payout all rewards
    function erc20Transfer(address _to, uint256 _amount) internal {
        erc20.transfer(_to, _amount);
        paidOut += _amount;
    }
}

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

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

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

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

            return true;
        } else {
            return false;
        }
    }

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

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

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

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

    // Bytes32Set

    struct Bytes32Set {
        Set _inner;
    }

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

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

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

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

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

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

    // AddressSet

    struct AddressSet {
        Set _inner;
    }

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

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

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

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

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

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

        assembly {
            result := store
        }

        return result;
    }

    // UintSet

    struct UintSet {
        Set _inner;
    }

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

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

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

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

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

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

        assembly {
            result := store
        }

        return result;
    }
}

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


import "Ownable.sol";
import {IndexToken} from "IndexToken.sol";

contract IndexTokenFactory is Ownable{
    address[] private allTokens;
    mapping(string => address) private _getToken;
    mapping(address => string) private _getSymbol;

    function createIndexToken(string memory name, string memory symbol) external onlyOwner{
        require (_getToken[symbol] == address(0), "Token already exists!");
        IndexToken token = new IndexToken(name, symbol);
        token.transferOwnership(owner());
        allTokens.push(address(token));
        _getToken[symbol] = address(token);
        _getSymbol[address(token)] = symbol;
    }

    function latestToken() external view returns(address){
        return allTokens[allTokens.length -1];
    }

    function getToken(string memory symbol) public view returns(address){
        return _getToken[symbol];
    }

    function getSymbol(address token) public view returns(string memory){
        return _getSymbol[token];
    }
}

File 21 of 25 : AbstractLender.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.7;

import { SafeMath } from "SafeMath.sol";
import { StableMath } from "StableMath.sol";
import {IndexToken} from "IndexToken.sol";
import {StableCoin} from "StableCoin.sol";
import {StableCoinFactory} from "StableCoinFactory.sol";
import {AbstractTreasury} from "AbstractTreasury.sol";

abstract contract AbstractLender is AbstractTreasury{
    using StableMath for uint256;
    using SafeMath for uint256;

    StableCoinFactory internal stableCoinFactory;

    function createCoin(string memory name, string memory symbol) external onlyOwner{
        stableCoinFactory.createStableCoin(name, symbol);
    }

    function borrowAgainstIndexToken(address _token, uint collateralAmount, uint borrowAmount) public{
        require(tokens[_token].isSupported, "Token is not supported");
        IndexToken token = IndexToken(_token);
        StableCoin stableCoin = StableCoin(stableCoinFactory.getCoin(tokens[_token].currency));
        
        uint existingCollateralAmount = stableCoin.getIndexWiseCollateral(msg.sender, _token);
        uint existingBorrowedAmount = stableCoin.getIndexWiseCoinBorrowed(msg.sender, _token);
        uint price = oracle.getPrice(token.symbol());
        uint maxBorrowAmount = (existingCollateralAmount + collateralAmount).mulTruncate(price).mulTruncate(_max_borrow_limit);
        require (borrowAmount + existingBorrowedAmount <= maxBorrowAmount, "Borrow Limit Exceeded");

        token.transferFrom(msg.sender, address(this), collateralAmount);
        stableCoin.mint(msg.sender, _token, borrowAmount, collateralAmount);
        // minting fees
    }

    function repayIndexTokenLoan(address _token, uint amount) public{
        require(tokens[_token].isSupported, "Token is not supported");
        IndexToken token = IndexToken(_token);
        StableCoin stableCoin = StableCoin(stableCoinFactory.getCoin(tokens[_token].currency));
        uint existingBorrowedAmount = stableCoin.getIndexWiseCoinBorrowed(msg.sender, _token);
        require(amount <= existingBorrowedAmount, "Amount exceeds the total borrowed amount against this token");
        stableCoin.burn(msg.sender, _token, amount, 0);
    }

    function addIndexTokenCollateral(address _token, uint amount) public{
        require(tokens[_token].isSupported, "Token is not supported");
        IndexToken token = IndexToken(_token);
        token.transferFrom(msg.sender, address(this), amount);
        StableCoin stableCoin = StableCoin(stableCoinFactory.getCoin(tokens[_token].currency));
        stableCoin.mint(msg.sender, _token, 0, amount);
    }
    function reduceIndexTokenCollateral(address _token, uint amount) public{
        require(tokens[_token].isSupported, "Token is not supported");
        IndexToken token = IndexToken(_token);
        StableCoin stableCoin = StableCoin(stableCoinFactory.getCoin(tokens[_token].currency));
        uint existingCollateralAmount = stableCoin.getIndexWiseCollateral(msg.sender, _token);
        uint existingBorrowedAmount = stableCoin.getIndexWiseCoinBorrowed(msg.sender, _token);
        uint price = oracle.getPrice(token.symbol());
        uint maxBorrowAmount = (existingCollateralAmount - amount).mulTruncate(price).mulTruncate(_max_borrow_limit);
        require(existingBorrowedAmount <= maxBorrowAmount, "Borrow Limit Exceeded");
        
        stableCoin.burn(msg.sender, _token, 0, amount);
        token.transfer(msg.sender, amount);
    }
    function indexTokenCollateral(address _account, address _token) public view returns (uint){
        StableCoin stableCoin = StableCoin(stableCoinFactory.getCoin(tokens[_token].currency));
        return stableCoin.getIndexWiseCollateral(_account, _token);
    }
    function indexTokenExcessCollateral(address _account, address _token) public view returns (uint){
        StableCoin stableCoin = StableCoin(stableCoinFactory.getCoin(tokens[_token].currency));
        IndexToken token = IndexToken(_token);
        uint price = oracle.getPrice(token.symbol());
        uint excessCollateral = (stableCoin.getIndexWiseCollateral(_account, _token).mulTruncate(price).mulTruncate(
                    _max_borrow_limit) - stableCoin.getIndexWiseCoinBorrowed(msg.sender, _token)).divPrecisely(price);
        return excessCollateral;
    }
    function coinBorrowedAmount(address _account, address _token) public view returns (uint){
        StableCoin stableCoin = StableCoin(stableCoinFactory.getCoin(tokens[_token].currency));
        return stableCoin.getIndexWiseCoinBorrowed(_account, _token);
    }
}

File 22 of 25 : StableCoin.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.7;

import { ERC20 } from "ERC20.sol";
import "Ownable.sol";

contract StableCoin is ERC20, Ownable{
    string private _name;
    string private _symbol;
    uint private _currency; 
    uint8 private _decimals;
    address private _factory;

    function _initialize(string memory nameArg, string memory symbolArg, uint currencyArg, uint8 decimalsArg) internal {
        _name = nameArg;
        _symbol = symbolArg;
        _decimals = decimalsArg;
        _currency = currencyArg;
        _factory = msg.sender;
    }

    function name() public override view returns (string memory) {
        return _name;
    }

    function symbol() public override view returns (string memory) {
        return _symbol;
    }
    function currency() public  view returns (uint) {
        return _currency;
    }

    function decimals() public override view returns (uint8) {
        return _decimals;
    }
    function factory() public view returns (address) {
        return _factory;
    }

    mapping(address => mapping(address => uint)) private _indexWiseCoinBorrowed;
    mapping(address => mapping(address => uint)) private _indexWiseCollateral;
    address[] private borrowers; 

    constructor(string memory _name, string memory _symbol, uint _currency) ERC20(_name, _symbol){
        _initialize(_name, _symbol, _currency, 18);
    }
    function mint(address _account, address _token, uint borrowedAmount, uint collateralAmount) external onlyOwner{
        if (borrowedAmount > 0){
            _mint(_account, borrowedAmount);
        }
        _indexWiseCoinBorrowed[_account][_token] += borrowedAmount;
        _indexWiseCollateral[_account][_token] += collateralAmount;
        borrowers.push(_account);  // can contain duplicate entrees
    }
    function burn(address _account, address _token, uint borrowedAmount, uint collateralAmount) external onlyOwner{
        if (borrowedAmount > 0){
            _burn(_account, borrowedAmount);
        }
        _indexWiseCoinBorrowed[_account][_token] -= borrowedAmount;
        _indexWiseCollateral[_account][_token] -= collateralAmount;
    }

    function getIndexWiseCoinBorrowed(address _account, address _token) external view returns (uint){
        return _indexWiseCoinBorrowed[_account][_token];
    }
    function getIndexWiseCollateral(address _account, address _token) external view returns (uint){
        return _indexWiseCollateral[_account][_token];
    }
    function getBorrowers() external view  onlyOwner returns (address[] memory) {
        return borrowers;
    }

}

File 23 of 25 : StableCoinFactory.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.7;


import "Ownable.sol";
import {StableCoin} from "StableCoin.sol";

contract StableCoinFactory is Ownable{
    address[] private allCoins;
    mapping(uint => address) private _getCoin;
    mapping(string => address) _getCoinByName;
    mapping(address => string) private _getSymbol;
    mapping(address => uint) private _getCurrency; 

    function createStableCoin(string memory name, string memory symbol) external onlyOwner{
        require (_getCoinByName[name] == address(0), "Coin already exists!");
        uint currency = allCoins.length;
        StableCoin coin = new StableCoin(name, symbol, currency);
        coin.transferOwnership(owner());
        _getCoin[currency] = address(coin);
        _getSymbol[address(coin)] = symbol;
        _getCurrency[address(coin)] = currency;
        _getCoinByName[name] = address(coin);
        allCoins.push(address(coin));
    }

    function latestCoin() external view returns(address){
        return allCoins[allCoins.length -1];
    }

    function getCoin(uint currency) public view returns(address){
        return _getCoin[currency];
    }

    function getSymbol(address coin) public view returns(string memory){
        return _getSymbol[coin];
    }
    function getCurrency(address coin) public view returns(uint){
        return _getCurrency[coin];
    }
    function getCoinByName(string memory name) public view returns(address){
        return _getCoinByName[name];
    }
}

File 24 of 25 : AbstractTreasury.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.7;

import {Params} from "Params.sol";
import {IndexToken} from "IndexToken.sol";
import {IOracle} from "IOracle.sol";
import "ERC20.sol";
import { SafeERC20 } from "SafeERC20.sol";
import "Ownable.sol";

import { SafeMath } from "SafeMath.sol";
import { StableMath } from "StableMath.sol";
import {IUniswapV2Router02} from "IUniswapV2Router02.sol";
import {IUniswapV2Factory} from "IUniswapV2Factory.sol";
import {PortfolioToken} from "PortfolioToken.sol";
import {Farm} from "Farm.sol";
import {IndexTokenFactory} from "IndexTokenFactory.sol";


abstract contract AbstractTreasury is Params, Ownable{

    IOracle internal oracle;
    IndexTokenFactory internal factory;
    PortfolioToken internal portfolioToken;
    Farm internal farm;

    
    
    mapping(address => uint) internal _assetDecimals;
    mapping(address => uint) internal _tokenDecimals;

    struct Currency {
        bool isSupported;
        string name;
        uint id;
    }
    mapping(string => Currency) internal currencyNames;
    string[] internal allCurrencyNames;
    
    mapping(uint => string) internal currencyIdToName;

    struct Asset {
        bool isSupported;
        uint currency;
    }

    mapping(address => Asset) internal assets;
    mapping(string => address[]) internal allAssets;

    struct Token {
        bool isSupported;
        uint currency;
    }

    mapping(address => Token) internal tokens;
    mapping(string => address[]) internal allTokens;

    IUniswapV2Router02 internal uniswapRouter;
    IUniswapV2Factory internal uniswapFactory;

    function getPortfolioToken() public view returns (address){
        return address(portfolioToken);
    }
    
    function getFarm() public view returns (address){
        return address(farm);
    }

    function getSupportedAssets(string memory currencyName) external view returns (address [] memory){
        return allAssets[currencyName];
    }
    function getSupportedTokens(string memory currencyName) external view returns (address [] memory){
        return allTokens[currencyName];
    }
    function getSupportedCurrencies() external view returns (string [] memory){
        return allCurrencyNames;
    }
    
    function addSupportedCurrency(string memory name) onlyOwner external{
        require(!currencyNames[name].isSupported, "Currency already supported");
        currencyNames[name] = Currency({isSupported: true, name: name, id:allCurrencyNames.length});
        currencyIdToName[allCurrencyNames.length] = name;
        allCurrencyNames.push(name);
    }

    function addSupportedAsset(address _asset, string memory currencyName) onlyOwner external {
        require (currencyNames[currencyName].isSupported, "Currency not supported!");
        require(!assets[_asset].isSupported, "Asset already supported");
        assets[_asset] = Asset({ isSupported: true, currency: currencyNames[currencyName].id });
        allAssets[currencyName].push(_asset);
        _assetDecimals[_asset] = ERC20(_asset).decimals();
    }

    function addSupportedToken(address _token, string memory currencyName) onlyOwner external {
        require (currencyNames[currencyName].isSupported, "Currency not supported!");
        require(!tokens[_token].isSupported, "Token already supported");
        require(IndexToken(_token).factory() == address(factory), "Token Not created from approved factory");
        tokens[_token] = Token({ isSupported: true, currency: currencyNames[currencyName].id });
        allTokens[currencyName].push(_token);
        _tokenDecimals[_token] = ERC20(_token).decimals();
    }

    function isCompatible(address _asset, address _token) public view returns (bool){
        return assets[_asset].currency == tokens[_token].currency;
    }
    function getCurrencyIdToName(uint id) public view returns (string memory){
        return currencyIdToName[id];
    }
    function getAssetCurrency(address _asset) public view returns (string memory){

        return currencyIdToName[assets[_asset].currency];
    }
    function getTokenCurrency(address _token) public view returns (string memory){

        return currencyIdToName[tokens[_token].currency];
    }
}

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

import { SafeMath } from "SafeMath.sol";
import { StableMath } from "StableMath.sol";


abstract contract Params {
    using StableMath for uint256;
    using SafeMath for uint256;
    
    uint internal _min_collateral_ratio = uint(130).divPrecisely(100);          // 130%
    uint internal _liquidation_ratio = uint(110).divPrecisely(100);             // 110%
    uint internal _transaction_fee = uint(5).divPrecisely(1000);                // 0.5% 
    uint internal _max_borrow_limit = uint(70).divPrecisely(100);               // 70%
}

Settings
{
  "evmVersion": "istanbul",
  "optimizer": {
    "enabled": true,
    "runs": 200
  },
  "libraries": {
    "Treasury.sol": {}
  },
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "abi"
      ]
    }
  }
}

Contract ABI

[{"inputs":[{"internalType":"address","name":"_oracle","type":"address"},{"internalType":"address","name":"_factory","type":"address"},{"internalType":"address","name":"_stableCoinFactory","type":"address"},{"internalType":"address","name":"portfolioTokenAddress","type":"address"},{"internalType":"address","name":"farmAddress","type":"address"},{"internalType":"address","name":"uniswapRouterAddress","type":"address"},{"internalType":"address","name":"uniswapFactoryAddress","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"inputs":[{"internalType":"address","name":"_asset","type":"address"},{"internalType":"address","name":"_token","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"addCollateral","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_token","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"addIndexTokenCollateral","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_allocPoint","type":"uint256"},{"internalType":"contract IERC20","name":"_lpToken","type":"address"},{"internalType":"bool","name":"_withUpdate","type":"bool"}],"name":"addPoolToFarm","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_asset","type":"address"},{"internalType":"string","name":"currencyName","type":"string"}],"name":"addSupportedAsset","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"name","type":"string"}],"name":"addSupportedCurrency","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_token","type":"address"},{"internalType":"string","name":"currencyName","type":"string"}],"name":"addSupportedToken","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"address","name":"_asset","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_token","type":"address"},{"internalType":"uint256","name":"collateralAmount","type":"uint256"},{"internalType":"uint256","name":"borrowAmount","type":"uint256"}],"name":"borrowAgainstIndexToken","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_account","type":"address"},{"internalType":"address","name":"_token","type":"address"}],"name":"coinBorrowedAmount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"name","type":"string"},{"internalType":"string","name":"symbol","type":"string"}],"name":"createCoin","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"name","type":"string"},{"internalType":"string","name":"symbol","type":"string"}],"name":"createToken","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"fundFarm","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_asset","type":"address"}],"name":"getAssetCurrency","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"address","name":"_token","type":"address"}],"name":"getCollateralRatio","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"address","name":"_token","type":"address"}],"name":"getCollateralValue","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"id","type":"uint256"}],"name":"getCurrencyIdToName","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"address","name":"_token","type":"address"}],"name":"getExcessCollateralValue","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getFarm","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_token","type":"address"}],"name":"getMinters","outputs":[{"internalType":"address[]","name":"","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getPortfolioToken","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"currencyName","type":"string"}],"name":"getSupportedAssets","outputs":[{"internalType":"address[]","name":"","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getSupportedCurrencies","outputs":[{"internalType":"string[]","name":"","type":"string[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"currencyName","type":"string"}],"name":"getSupportedTokens","outputs":[{"internalType":"address[]","name":"","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_token","type":"address"}],"name":"getTokenCurrency","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_account","type":"address"},{"internalType":"address","name":"_token","type":"address"}],"name":"indexTokenCollateral","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_account","type":"address"},{"internalType":"address","name":"_token","type":"address"}],"name":"indexTokenExcessCollateral","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_asset","type":"address"},{"internalType":"address","name":"_token","type":"address"}],"name":"isCompatible","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"address","name":"_token","type":"address"},{"internalType":"address","name":"_asset","type":"address"},{"internalType":"uint256","name":"slippage","type":"uint256"}],"name":"liquidate","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_asset","type":"address"},{"internalType":"address","name":"_token","type":"address"},{"internalType":"uint256","name":"collateralAmount","type":"uint256"},{"internalType":"uint256","name":"tokenAmount","type":"uint256"}],"name":"mint","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_asset","type":"address"},{"internalType":"address","name":"_token","type":"address"},{"internalType":"uint256","name":"tokenAmount","type":"uint256"}],"name":"redeem","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_asset","type":"address"},{"internalType":"address","name":"_token","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"reduceCollateral","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_token","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"reduceIndexTokenCollateral","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_token","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"repayIndexTokenLoan","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"currencyName","type":"string"}],"name":"treasuryAssetBalance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"}]

608060405262000020606460826200013e60201b6200410f1790919060201c565b6000556200003f6064606e6200013e60201b6200410f1790919060201c565b6001556200005f6103e860056200013e60201b6200410f1790919060201c565b6002556200007e606460466200013e60201b6200410f1790919060201c565b6003553480156200008e57600080fd5b50604051620053f0380380620053f0833981016040819052620000b19162000219565b620000bc3362000187565b600580546001600160a01b03199081166001600160a01b03998a1617909155600680548216978916979097179096556014805487169588169590951790945560078054861693871693909317909255600880548516918616919091179055601280548416918516919091179055601380549092169216919091179055620002ff565b60008062000163670de0b6b3a764000085620001d960201b620041301790919060201c565b90506200017f8382620001ee60201b6200413c1790919060201c565b949350505050565b600480546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b6000620001e78284620002ae565b9392505050565b6000620001e78284620002dc565b80516001600160a01b03811681146200021457600080fd5b919050565b600080600080600080600060e0888a0312156200023557600080fd5b6200024088620001fc565b96506200025060208901620001fc565b95506200026060408901620001fc565b94506200027060608901620001fc565b93506200028060808901620001fc565b92506200029060a08901620001fc565b9150620002a060c08901620001fc565b905092959891949750929550565b6000816000190483118215151615620002d757634e487b7160e01b600052601160045260246000fd5b500290565b600082620002fa57634e487b7160e01b600052601260045260246000fd5b500490565b6150e1806200030f6000396000f3fe608060405234801561001057600080fd5b50600436106102275760003560e01c806381532e9e11610130578063ca07fd72116100b8578063e839d55d1161007c578063e839d55d146104c0578063ef62e33f146104d3578063f2fde38b146104e6578063f7d61d2f146104f9578063fee0d3331461050c57600080fd5b8063ca07fd7214610461578063ca3d0e5814610474578063cf1675ef14610487578063d69bde0c1461049a578063dd62ed3e146104ad57600080fd5b80639c50e357116100ff5780639c50e35714610404578063aab3f86814610415578063b061104e14610428578063b3f1c93d1461043b578063c6ab7ba91461044e57600080fd5b806381532e9e146103ba5780638da5cb5b146103cd5780638ef4941d146103de57806397e95a07146103f157600080fd5b806337561749116101b3578063597810341161018257806359781034146103665780635ac75edd14610379578063715018a61461038c578063720138e8146103945780637918f1cf146103a757600080fd5b806337561749146102fb5780633a357a271461030e57806344e6f28b146103215780634daf490c1461034157600080fd5b80631eee3aa3116101fa5780631eee3aa31461027a578063292f0b8b146102a057806329825db0146102c05780632ce75863146102d35780632f2f2d56146102e857600080fd5b806301e512b71461022c5780630542e75c146102415780630e6dfcd514610254578063172de6da14610267575b600080fd5b61023f61023a3660046145b4565b61055f565b005b61023f61024f3660046146ba565b610a57565b61023f6102623660046145b4565b610bca565b61023f6102753660046146ef565b611064565b61028d610288366004614753565b6110f6565b6040519081526020015b60405180910390f35b6102b36102ae36600461478c565b611170565b6040516102979190614801565b61028d6102ce366004614753565b61122c565b6102db6112e7565b6040516102979190614814565b61023f6102f63660046146ef565b6113c0565b61023f610309366004614876565b61141c565b61028d61031c366004614753565b61164e565b61033461032f3660046146ba565b611855565b6040516102979190614900565b6008546001600160a01b03165b6040516001600160a01b039091168152602001610297565b61023f6103743660046145b4565b6118ce565b61028d610387366004614753565b611b73565b61023f611d37565b61023f6103a2366004614876565b611d6d565b6103346103b53660046146ba565b612075565b61023f6103c8366004614913565b612087565b6004546001600160a01b031661034e565b61023f6103ec36600461493f565b612297565b61028d6103ff3660046146ba565b61240b565b6007546001600160a01b031661034e565b61023f610423366004614958565b61256a565b61023f6104363660046149b7565b612cc2565b61023f6104493660046149f9565b612ed8565b6102b361045c36600461493f565b613384565b61023f61046f366004614913565b6133a1565b61023f610482366004614913565b61372d565b61033461049536600461478c565b6138c9565b6102b36104a836600461478c565b61393d565b61028d6104bb366004614753565b613974565b61023f6104ce366004614a3f565b6139a7565b61028d6104e1366004614753565b613d90565b61023f6104f436600461478c565b613e4b565b61028d610507366004614753565b613ee6565b61054f61051a366004614753565b6001600160a01b039081166000908152601060209081526040808320600190810154959094168352600e909152902001541490565b6040519015158152602001610297565b6001600160a01b03821660009081526010602052604090205460ff166105a05760405162461bcd60e51b815260040161059790614a74565b60405180910390fd5b6001600160a01b0383166000908152600e602052604090205460ff166105d85760405162461bcd60e51b815260040161059790614aa4565b6001600160a01b0380831660009081526010602090815260408083206001908101549488168452600e9092529091200154146106265760405162461bcd60e51b815260040161059790614ad4565b600554604080516395d89b4160e01b8152905184926000926001600160a01b039182169263524f3889928616916395d89b4191600480830192889291908290030181865afa15801561067c573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526106a49190810190614b1b565b6040518263ffffffff1660e01b81526004016106c09190614801565b602060405180830381865afa1580156106dd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107019190614b89565b604051638433f12f60e01b81523360048201529091506000906001600160a01b03841690638433f12f90602401602060405180830381865afa15801561074b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061076f9190614b89565b6000805460405163baa3c88b60e01b815233600482015292935090916107f791906107f1906001600160a01b0388169063baa3c88b906024015b602060405180830381865afa1580156107c6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107ea9190614b89565b8690614148565b90614148565b6108019083614bb8565b6001600160a01b038816600090815260096020526040902054909150879061082d90879060129061415d565b9550818611156108935760405162461bcd60e51b815260206004820152602b60248201527f596f75206e65656420746f206d61696e7461696e2073756666696369656e742060448201526a636f6c6c61746572616c2160a81b6064820152608401610597565b6108a76001600160a01b03821633886141bf565b604051638433f12f60e01b815233600482018190526001600160a01b0387169163e96b1471919089908490638433f12f90602401602060405180830381865afa1580156108f8573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061091c9190614b89565b6109269190614bb8565b6040518363ffffffff1660e01b8152600401610943929190614bcf565b600060405180830381600087803b15801561095d57600080fd5b505af1158015610971573d6000803e3d6000fd5b5050604051638433f12f60e01b815233600482018190526001600160a01b03808616945063095ea7b39350909190891690638433f12f90602401602060405180830381865afa1580156109c8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109ec9190614b89565b6040518363ffffffff1660e01b8152600401610a09929190614bcf565b6020604051808303816000875af1158015610a28573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a4c9190614be8565b505050505050505050565b6004546001600160a01b03163314610a815760405162461bcd60e51b815260040161059790614c05565b600b81604051610a919190614c3a565b9081526040519081900360200190205460ff1615610af15760405162461bcd60e51b815260206004820152601a60248201527f43757272656e637920616c726561647920737570706f727465640000000000006044820152606401610597565b604080516060810182526001815260208101839052600c54818301529051600b90610b1d908490614c3a565b908152604051602091819003820190208251815460ff19169015151781558282015180519192610b5592600185019290910190614506565b50604091820151600290910155600c546000908152600d60209081529190208251610b8292840190614506565b50600c80546001810182556000919091528151610bc6917fdf6966c971051c3d54ec59162606531493a51404a002842f56009d7e5cf4a8c701906020840190614506565b5050565b6001600160a01b0383166000908152600e602052604090205460ff16610c025760405162461bcd60e51b815260040161059790614aa4565b6001600160a01b03821660009081526010602052604090205460ff16610c3a5760405162461bcd60e51b815260040161059790614a74565b6001600160a01b0380831660009081526010602090815260408083206001908101549488168452600e909252909120015414610c885760405162461bcd60e51b815260040161059790614ad4565b60405163baa3c88b60e01b8152336004820152829082906001600160a01b0383169063baa3c88b90602401602060405180830381865afa158015610cd0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610cf49190614b89565b1015610d505760405162461bcd60e51b815260206004820152602560248201527f43616e6e6f742072656465656d206d6f7265207468616e206d696e74656420616044820152641b5bdd5b9d60da1b6064820152608401610597565b600554604080516395d89b4160e01b8152905186926000926001600160a01b039182169263524f3889928716916395d89b4191600480830192889291908290030181865afa158015610da6573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610dce9190810190614b1b565b6040518263ffffffff1660e01b8152600401610dea9190614801565b602060405180830381865afa158015610e07573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e2b9190614b89565b90506000610e398286614148565b6040516370a0823160e01b815230600482015290915081906001600160a01b038516906370a0823190602401602060405180830381865afa158015610e82573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ea69190614b89565b11610f095760405162461bcd60e51b815260206004820152602d60248201527f496e737566666963656e742062616c616e6365206f662074686973206173736560448201526c7420696e20747265617375727960981b6064820152608401610597565b604051637a94c56560e11b815233600482015260248101869052604481018290526001600160a01b0385169063f5298aca90606401600060405180830381600087803b158015610f5857600080fd5b505af1158015610f6c573d6000803e3d6000fd5b50610f85925050506001600160a01b03841633836141bf565b604051638433f12f60e01b815233600482018190526001600160a01b038086169263095ea7b39291881690638433f12f90602401602060405180830381865afa158015610fd6573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ffa9190614b89565b6040518363ffffffff1660e01b8152600401611017929190614bcf565b6020604051808303816000875af1158015611036573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061105a9190614be8565b5050505050505050565b6004546001600160a01b0316331461108e5760405162461bcd60e51b815260040161059790614c05565b601454604051639c90720f60e01b81526001600160a01b0390911690639c90720f906110c09085908590600401614c56565b600060405180830381600087803b1580156110da57600080fd5b505af11580156110ee573d6000803e3d6000fd5b505050505050565b604051638433f12f60e01b81526001600160a01b0383811660048301526000918391821690638433f12f906024015b602060405180830381865afa158015611142573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111669190614b89565b9150505b92915050565b6001600160a01b0381166000908152601060209081526040808320600101548352600d90915290208054606091906111a790614c7b565b80601f01602080910402602001604051908101604052809291908181526020018280546111d390614c7b565b80156112205780601f106111f557610100808354040283529160200191611220565b820191906000526020600020905b81548152906001019060200180831161120357829003601f168201915b50505050509050919050565b6014546001600160a01b03828116600090815260106020526040808220600101549051631b4622b160e31b815291938493169163da311588916112759160040190815260200190565b602060405180830381865afa158015611292573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112b69190614cb6565b60405163e26edb1960e01b81529091506001600160a01b0382169063e26edb19906111259087908790600401614cd3565b6060600c805480602002602001604051908101604052809291908181526020016000905b828210156113b757838290600052602060002001805461132a90614c7b565b80601f016020809104026020016040519081016040528092919081815260200182805461135690614c7b565b80156113a35780601f10611378576101008083540402835291602001916113a3565b820191906000526020600020905b81548152906001019060200180831161138657829003601f168201915b50505050508152602001906001019061130b565b50505050905090565b6004546001600160a01b031633146113ea5760405162461bcd60e51b815260040161059790614c05565b6006546040516378c261db60e11b81526001600160a01b039091169063f184c3b6906110c09085908590600401614c56565b6004546001600160a01b031633146114465760405162461bcd60e51b815260040161059790614c05565b600b816040516114569190614c3a565b9081526040519081900360200190205460ff166114af5760405162461bcd60e51b815260206004820152601760248201527643757272656e6379206e6f7420737570706f727465642160481b6044820152606401610597565b6001600160a01b0382166000908152600e602052604090205460ff16156115185760405162461bcd60e51b815260206004820152601760248201527f417373657420616c726561647920737570706f727465640000000000000000006044820152606401610597565b6040518060400160405280600115158152602001600b8360405161153c9190614c3a565b9081526040805160209281900383019020600201549092526001600160a01b0385166000908152600e82528290208351815460ff191690151517815592015160019092019190915551600f90611593908390614c3a565b908152604080516020928190038301812080546001810182556000918252908490200180546001600160a01b0319166001600160a01b03871690811790915563313ce56760e01b82529151919263313ce567926004808401938290030181865afa158015611605573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116299190614ced565b6001600160a01b03909216600090815260096020526040902060ff9290921690915550565b6000808290506000600560009054906101000a90046001600160a01b03166001600160a01b031663524f3889836001600160a01b03166395d89b416040518163ffffffff1660e01b8152600401600060405180830381865afa1580156116b8573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526116e09190810190614b1b565b6040518263ffffffff1660e01b81526004016116fc9190614801565b602060405180830381865afa158015611719573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061173d9190614b89565b604051638433f12f60e01b81526001600160a01b038781166004830152919250600091841690638433f12f90602401602060405180830381865afa158015611789573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117ad9190614b89565b60405163baa3c88b60e01b81526001600160a01b038881166004830152919250600091611829919086169063baa3c88b90602401602060405180830381865afa1580156117fe573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906118229190614b89565b8490614148565b90508061183d57600094505050505061116a565b6000611849838361410f565b98975050505050505050565b60606011826040516118679190614c3a565b908152604080519182900360209081018320805480830285018301909352828452919083018282801561122057602002820191906000526020600020905b81546001600160a01b031681526001909101906020018083116118a55750505050509050919050565b6001600160a01b03821660009081526010602052604090205460ff166119065760405162461bcd60e51b815260040161059790614a74565b6001600160a01b0383166000908152600e602052604090205460ff1661193e5760405162461bcd60e51b815260040161059790614aa4565b6001600160a01b0380831660009081526010602090815260408083206001908101549488168452600e90925290912001541461198c5760405162461bcd60e51b815260040161059790614ad4565b6001600160a01b038316600090815260096020526040902054839083906119b790849060129061415d565b92506119ce6001600160a01b03831633308661421a565b604051638433f12f60e01b815233600482018190526001600160a01b0383169163e96b1471919086908490638433f12f90602401602060405180830381865afa158015611a1f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a439190614b89565b611a4d9190614d10565b6040518363ffffffff1660e01b8152600401611a6a929190614bcf565b600060405180830381600087803b158015611a8457600080fd5b505af1158015611a98573d6000803e3d6000fd5b5050604051638433f12f60e01b815233600482018190526001600160a01b03808716945063095ea7b39350909190851690638433f12f90602401602060405180830381865afa158015611aef573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b139190614b89565b6040518363ffffffff1660e01b8152600401611b30929190614bcf565b6020604051808303816000875af1158015611b4f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110ee9190614be8565b6000808290506000600560009054906101000a90046001600160a01b03166001600160a01b031663524f3889836001600160a01b03166395d89b416040518163ffffffff1660e01b8152600401600060405180830381865afa158015611bdd573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052611c059190810190614b1b565b6040518263ffffffff1660e01b8152600401611c219190614801565b602060405180830381865afa158015611c3e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c629190614b89565b604051638433f12f60e01b81526001600160a01b038781166004830152919250600091841690638433f12f90602401602060405180830381865afa158015611cae573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611cd29190614b89565b6000805460405163baa3c88b60e01b81526001600160a01b038a811660048301529394509192611d11926107f19188169063baa3c88b906024016107a9565b9050600081831115611d2c576000611d298385614bb8565b50505b979650505050505050565b6004546001600160a01b03163314611d615760405162461bcd60e51b815260040161059790614c05565b611d6b6000614258565b565b6004546001600160a01b03163314611d975760405162461bcd60e51b815260040161059790614c05565b600b81604051611da79190614c3a565b9081526040519081900360200190205460ff16611e005760405162461bcd60e51b815260206004820152601760248201527643757272656e6379206e6f7420737570706f727465642160481b6044820152606401610597565b6001600160a01b03821660009081526010602052604090205460ff1615611e695760405162461bcd60e51b815260206004820152601760248201527f546f6b656e20616c726561647920737570706f727465640000000000000000006044820152606401610597565b6006546040805163c45a015560e01b815290516001600160a01b039283169285169163c45a01559160048083019260209291908290030181865afa158015611eb5573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ed99190614cb6565b6001600160a01b031614611f3f5760405162461bcd60e51b815260206004820152602760248201527f546f6b656e204e6f7420637265617465642066726f6d20617070726f76656420604482015266666163746f727960c81b6064820152608401610597565b6040518060400160405280600115158152602001600b83604051611f639190614c3a565b9081526040805160209281900383019020600201549092526001600160a01b0385166000908152601082528290208351815460ff191690151517815592015160019092019190915551601190611fba908390614c3a565b908152604080516020928190038301812080546001810182556000918252908490200180546001600160a01b0319166001600160a01b03871690811790915563313ce56760e01b82529151919263313ce567926004808401938290030181865afa15801561202c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906120509190614ced565b6001600160a01b039092166000908152600a6020526040902060ff9290921690915550565b6060600f826040516118679190614c3a565b6001600160a01b03821660009081526010602052604090205460ff166120bf5760405162461bcd60e51b815260040161059790614a74565b6014546001600160a01b03808416600090815260106020526040808220600101549051631b4622b160e31b8152869492939092169163da3115889161210a9160040190815260200190565b602060405180830381865afa158015612127573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061214b9190614cb6565b90506000816001600160a01b031663e26edb1933876040518363ffffffff1660e01b815260040161217d929190614cd3565b602060405180830381865afa15801561219a573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906121be9190614b89565b9050808411156122365760405162461bcd60e51b815260206004820152603b60248201527f416d6f756e7420657863656564732074686520746f74616c20626f72726f776560448201527f6420616d6f756e7420616761696e7374207468697320746f6b656e00000000006064820152608401610597565b604051636b81068560e11b81526001600160a01b0383169063d7020d0a9061226990339089908990600090600401614d28565b600060405180830381600087803b15801561228357600080fd5b505af1158015610a4c573d6000803e3d6000fd5b6004546001600160a01b031633146122c15760405162461bcd60e51b815260040161059790614c05565b6007546040516340c10f1960e01b81526001600160a01b03909116906340c10f19906122f39030908590600401614bcf565b600060405180830381600087803b15801561230d57600080fd5b505af1158015612321573d6000803e3d6000fd5b50506007546008546001600160a01b03918216935063095ea7b3925016612349846001614d10565b6040518363ffffffff1660e01b8152600401612366929190614bcf565b6020604051808303816000875af1158015612385573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123a99190614be8565b5060085460405163ca1d209d60e01b8152600481018390526001600160a01b039091169063ca1d209d90602401600060405180830381600087803b1580156123f057600080fd5b505af1158015612404573d6000803e3d6000fd5b5050505050565b600080805b600f846040516124209190614c3a565b90815260405190819003602001902054811015612563576000600f856040516124499190614c3a565b9081526020016040518091039020828154811061246857612468614d51565b6000918252602090912001546040516370a0823160e01b81523060048201526001600160a01b03909116906370a0823190602401602060405180830381865afa1580156124b9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906124dd9190614b89565b905061254360096000600f886040516124f69190614c3a565b9081526020016040518091039020858154811061251557612515614d51565b60009182526020808320909101546001600160a01b031683528201929092526040019020548290601261415d565b61254d9084614d10565b925050808061255b90614d67565b915050612410565b5092915050565b6001600160a01b03831660009081526010602052604090205460ff166125a25760405162461bcd60e51b815260040161059790614a74565b6001600160a01b0382166000908152600e602052604090205460ff166125da5760405162461bcd60e51b815260040161059790614aa4565b6001600160a01b0380841660009081526010602090815260408083206001908101549487168452600e9092529091200154146126285760405162461bcd60e51b815260040161059790614ad4565b600554604080516395d89b4160e01b8152905185926000926001600160a01b039182169263524f3889928616916395d89b4191600480830192889291908290030181865afa15801561267e573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526126a69190810190614b1b565b6040518263ffffffff1660e01b81526004016126c29190614801565b602060405180830381865afa1580156126df573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906127039190614b89565b604051638433f12f60e01b81526001600160a01b038881166004830152919250600091841690638433f12f90602401602060405180830381865afa15801561274f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906127739190614b89565b60405163baa3c88b60e01b81526001600160a01b0389811660048301529192506000916127ea91859187169063baa3c88b906024015b602060405180830381865afa1580156127c6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107f19190614b89565b9050816128026001548361414890919063ffffffff16565b1161285a5760405162461bcd60e51b815260206004820152602260248201527f446f6573206e6f74206d656574206c69717569646174696f6e20637269746572604482015261696160f01b6064820152608401610597565b600061289b670de0b6b3a76400006001546128759190614bb8565b8461288b6001548661414890919063ffffffff16565b6128959190614bb8565b9061410f565b905060006128a9828661410f565b60135460405163e6a4390560e01b81529192506000916001600160a01b039091169063e6a43905906128e1908d908d90600401614cd3565b602060405180830381865afa1580156128fe573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906129229190614cb6565b9050896001600160a01b0316816001600160a01b0316630dfe16816040518163ffffffff1660e01b8152600401602060405180830381865afa15801561296c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906129909190614cb6565b6001600160a01b03161415612a12576129ee6129b06103eb6103e861410f565b826001600160a01b0316635909c0d56040518163ffffffff1660e01b8152600401602060405180830381865afa1580156127c6573d6000803e3d6000fd5b861015612a0d5760405162461bcd60e51b815260040161059790614d82565b612a80565b612a61612a236103eb6103e861410f565b826001600160a01b0316635a3d54936040518163ffffffff1660e01b8152600401602060405180830381865afa1580156127c6573d6000803e3d6000fd5b861015612a805760405162461bcd60e51b815260040161059790614d82565b6040805160028082526060820183526000926020830190803683370190505090508981600081518110612ab557612ab5614d51565b60200260200101906001600160a01b031690816001600160a01b0316815250508a81600181518110612ae957612ae9614d51565b6001600160a01b03909216602092830291909101909101526000612b0d858b614148565b6012549091506001600160a01b03808d169163095ea7b39116612b31846001614d10565b6040518363ffffffff1660e01b8152600401612b4e929190614bcf565b6020604051808303816000875af1158015612b6d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612b919190614be8565b50601254604051634401edf760e11b81526000916001600160a01b031690638803dbee90612bd490889086908890309068056bc75e2d6310000090600401614dc6565b6000604051808303816000875af1158015612bf3573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052612c1b9190810190614e26565b9050896001600160a01b031663d5216e1f8f8784600081518110612c4157612c41614d51565b60209081029190910101516040516001600160e01b031960e086901b1681526001600160a01b03909316600484015260248301919091526044820152606401600060405180830381600087803b158015612c9a57600080fd5b505af1158015612cae573d6000803e3d6000fd5b505050505050505050505050505050505050565b6004546001600160a01b03163314612cec5760405162461bcd60e51b815260040161059790614c05565b60005b600860009054906101000a90046001600160a01b03166001600160a01b031663081e3eda6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612d42573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612d669190614b89565b811015612e6457600854604051631526fe2760e01b8152600481018390526000918291829182916001600160a01b0390911690631526fe2790602401608060405180830381865afa158015612dbf573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612de39190614eac565b9350935093509350836001600160a01b0316876001600160a01b03161415612e4d5760405162461bcd60e51b815260206004820152601860248201527f4c5020546f6b656e20616c726561647920696e206661726d00000000000000006044820152606401610597565b505050508080612e5c90614d67565b915050612cef565b50600854604051631eaaa04560e01b8152600481018590526001600160a01b038481166024830152831515604483015290911690631eaaa04590606401600060405180830381600087803b158015612ebb57600080fd5b505af1158015612ecf573d6000803e3d6000fd5b50505050505050565b6001600160a01b0384166000908152600e602052604090205460ff16612f105760405162461bcd60e51b815260040161059790614aa4565b6001600160a01b03831660009081526010602052604090205460ff16612f485760405162461bcd60e51b815260040161059790614a74565b6001600160a01b0380841660009081526010602090815260408083206001908101549489168452600e909252909120015414612f965760405162461bcd60e51b815260040161059790614ad4565b6001600160a01b03841660009081526009602052604090205484908490612fc190849060129061415d565b506001600160a01b038616600090815260096020526040902054612fe990859060129061415d565b506000600560009054906101000a90046001600160a01b03166001600160a01b031663524f3889836001600160a01b03166395d89b416040518163ffffffff1660e01b8152600401600060405180830381865afa15801561304e573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526130769190810190614b1b565b6040518263ffffffff1660e01b81526004016130929190614801565b602060405180830381865afa1580156130af573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906130d39190614b89565b604051638433f12f60e01b81523360048201529091506000906001600160a01b03841690638433f12f90602401602060405180830381865afa15801561311d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906131419190614b89565b6000805460405163baa3c88b60e01b8152336004820152929350909161317f91906107f1906001600160a01b0388169063baa3c88b906024016107a9565b9050600081831115613198576131958284614bb8565b90505b6000546131a9906107f18987614148565b6131b3828a614d10565b10156132015760405162461bcd60e51b815260206004820152601860248201527f50726f76696465206d6f726520636f6c6c61746572616c2100000000000000006044820152606401610597565b600254600090613215906107f18a88614148565b90506132383330613226848d614d10565b6001600160a01b038b1692919061421a565b604051630ab714fb60e11b815233600482015260248101899052604481018a90526001600160a01b0387169063156e29f690606401600060405180830381600087803b15801561328757600080fd5b505af115801561329b573d6000803e3d6000fd5b5050604051638433f12f60e01b815233600482018190526001600160a01b03808c16945063095ea7b393509091908a1690638433f12f90602401602060405180830381865afa1580156132f2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906133169190614b89565b6040518363ffffffff1660e01b8152600401613333929190614bcf565b6020604051808303816000875af1158015613352573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906133769190614be8565b505050505050505050505050565b6000818152600d602052604090208054606091906111a790614c7b565b6001600160a01b03821660009081526010602052604090205460ff166133d95760405162461bcd60e51b815260040161059790614a74565b6014546001600160a01b03808416600090815260106020526040808220600101549051631b4622b160e31b8152869492939092169163da311588916134249160040190815260200190565b602060405180830381865afa158015613441573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906134659190614cb6565b90506000816001600160a01b031663c712cdd933876040518363ffffffff1660e01b8152600401613497929190614cd3565b602060405180830381865afa1580156134b4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906134d89190614b89565b90506000826001600160a01b031663e26edb1933886040518363ffffffff1660e01b815260040161350a929190614cd3565b602060405180830381865afa158015613527573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061354b9190614b89565b90506000600560009054906101000a90046001600160a01b03166001600160a01b031663524f3889866001600160a01b03166395d89b416040518163ffffffff1660e01b8152600401600060405180830381865afa1580156135b1573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526135d99190810190614b1b565b6040518263ffffffff1660e01b81526004016135f59190614801565b602060405180830381865afa158015613612573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906136369190614b89565b905060006136506003546107f1848a886107f19190614bb8565b90508083111561369a5760405162461bcd60e51b8152602060048201526015602482015274109bdc9c9bddc8131a5b5a5d08115e18d959591959605a1b6044820152606401610597565b604051636b81068560e11b81526001600160a01b0386169063d7020d0a906136cd9033908c906000908d90600401614d28565b600060405180830381600087803b1580156136e757600080fd5b505af11580156136fb573d6000803e3d6000fd5b505060405163a9059cbb60e01b81526001600160a01b038916925063a9059cbb9150610a099033908b90600401614bcf565b6001600160a01b03821660009081526010602052604090205460ff166137655760405162461bcd60e51b815260040161059790614a74565b6040516323b872dd60e01b81523360048201523060248201526044810182905282906001600160a01b038216906323b872dd906064016020604051808303816000875af11580156137ba573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906137de9190614be8565b506014546001600160a01b03848116600090815260106020526040808220600101549051631b4622b160e31b815260048101919091529092919091169063da31158890602401602060405180830381865afa158015613841573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906138659190614cb6565b60405163b3f1c93d60e01b81529091506001600160a01b0382169063b3f1c93d9061389b90339088906000908990600401614d28565b600060405180830381600087803b1580156138b557600080fd5b505af115801561105a573d6000803e3d6000fd5b60606000829050806001600160a01b0316636b32810b6040518163ffffffff1660e01b8152600401600060405180830381865afa15801561390e573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526139369190810190614eeb565b9392505050565b6001600160a01b0381166000908152600e60209081526040808320600101548352600d90915290208054606091906111a790614c7b565b604051636eb1769f60e11b815260009082906001600160a01b0382169063dd62ed3e906111259087903090600401614cd3565b6001600160a01b03831660009081526010602052604090205460ff166139df5760405162461bcd60e51b815260040161059790614a74565b6014546001600160a01b03808516600090815260106020526040808220600101549051631b4622b160e31b8152879492939092169163da31158891613a2a9160040190815260200190565b602060405180830381865afa158015613a47573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613a6b9190614cb6565b90506000816001600160a01b031663c712cdd933886040518363ffffffff1660e01b8152600401613a9d929190614cd3565b602060405180830381865afa158015613aba573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613ade9190614b89565b90506000826001600160a01b031663e26edb1933896040518363ffffffff1660e01b8152600401613b10929190614cd3565b602060405180830381865afa158015613b2d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613b519190614b89565b90506000600560009054906101000a90046001600160a01b03166001600160a01b031663524f3889866001600160a01b03166395d89b416040518163ffffffff1660e01b8152600401600060405180830381865afa158015613bb7573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052613bdf9190810190614b1b565b6040518263ffffffff1660e01b8152600401613bfb9190614801565b602060405180830381865afa158015613c18573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613c3c9190614b89565b90506000613c566003546107f1848b886107f19190614d10565b905080613c638489614d10565b1115613ca95760405162461bcd60e51b8152602060048201526015602482015274109bdc9c9bddc8131a5b5a5d08115e18d959591959605a1b6044820152606401610597565b6040516323b872dd60e01b8152336004820152306024820152604481018990526001600160a01b038716906323b872dd906064016020604051808303816000875af1158015613cfc573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613d209190614be8565b5060405163b3f1c93d60e01b81526001600160a01b0386169063b3f1c93d90613d539033908d908c908e90600401614d28565b600060405180830381600087803b158015613d6d57600080fd5b505af1158015613d81573d6000803e3d6000fd5b50505050505050505050505050565b6014546001600160a01b03828116600090815260106020526040808220600101549051631b4622b160e31b815291938493169163da31158891613dd99160040190815260200190565b602060405180830381865afa158015613df6573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613e1a9190614cb6565b60405163c712cdd960e01b81529091506001600160a01b0382169063c712cdd9906111259087908790600401614cd3565b6004546001600160a01b03163314613e755760405162461bcd60e51b815260040161059790614c05565b6001600160a01b038116613eda5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610597565b613ee381614258565b50565b6014546001600160a01b03828116600090815260106020526040808220600101549051631b4622b160e31b815291938493169163da31158891613f2f9160040190815260200190565b602060405180830381865afa158015613f4c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613f709190614cb6565b905060008390506000600560009054906101000a90046001600160a01b03166001600160a01b031663524f3889836001600160a01b03166395d89b416040518163ffffffff1660e01b8152600401600060405180830381865afa158015613fdb573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526140039190810190614b1b565b6040518263ffffffff1660e01b815260040161401f9190614801565b602060405180830381865afa15801561403c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906140609190614b89565b90506000611d2c82856001600160a01b031663e26edb19338a6040518363ffffffff1660e01b8152600401614096929190614cd3565b602060405180830381865afa1580156140b3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906140d79190614b89565b61288b6003546107f1878a6001600160a01b031663c712cdd98f8f6040518363ffffffff1660e01b81526004016127a9929190614cd3565b60008061412484670de0b6b3a7640000614130565b9050611166818461413c565b60006139368284614f7a565b60006139368284614f99565b60006139368383670de0b6b3a76400006142aa565b60008183111561418d576141866141748385614bb8565b61417f90600a61509f565b8590614130565b93506141b7565b818310156141b7576141b46141a28484614bb8565b6141ad90600a61509f565b859061413c565b93505b509192915050565b6142158363a9059cbb60e01b84846040516024016141de929190614bcf565b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b0319909316929092179091526142cc565b505050565b6040516001600160a01b03808516602483015283166044820152606481018290526142529085906323b872dd60e01b906084016141de565b50505050565b600480546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b6000806142b78585614130565b90506142c3818461413c565b95945050505050565b6000614321826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b031661439e9092919063ffffffff16565b805190915015614215578080602001905181019061433f9190614be8565b6142155760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610597565b60606143ad84846000856143b5565b949350505050565b6060824710156144165760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b6064820152608401610597565b843b6144645760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610597565b600080866001600160a01b031685876040516144809190614c3a565b60006040518083038185875af1925050503d80600081146144bd576040519150601f19603f3d011682016040523d82523d6000602084013e6144c2565b606091505b5091509150611d2c828286606083156144dc575081613936565b8251156144ec5782518084602001fd5b8160405162461bcd60e51b81526004016105979190614801565b82805461451290614c7b565b90600052602060002090601f016020900481019282614534576000855561457a565b82601f1061454d57805160ff191683800117855561457a565b8280016001018555821561457a579182015b8281111561457a57825182559160200191906001019061455f565b5061458692915061458a565b5090565b5b80821115614586576000815560010161458b565b6001600160a01b0381168114613ee357600080fd5b6000806000606084860312156145c957600080fd5b83356145d48161459f565b925060208401356145e48161459f565b929592945050506040919091013590565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f1916810167ffffffffffffffff81118282101715614634576146346145f5565b604052919050565b600067ffffffffffffffff821115614656576146566145f5565b50601f01601f191660200190565b600082601f83011261467557600080fd5b81356146886146838261463c565b61460b565b81815284602083860101111561469d57600080fd5b816020850160208301376000918101602001919091529392505050565b6000602082840312156146cc57600080fd5b813567ffffffffffffffff8111156146e357600080fd5b61116684828501614664565b6000806040838503121561470257600080fd5b823567ffffffffffffffff8082111561471a57600080fd5b61472686838701614664565b9350602085013591508082111561473c57600080fd5b5061474985828601614664565b9150509250929050565b6000806040838503121561476657600080fd5b82356147718161459f565b915060208301356147818161459f565b809150509250929050565b60006020828403121561479e57600080fd5b81356139368161459f565b60005b838110156147c45781810151838201526020016147ac565b838111156142525750506000910152565b600081518084526147ed8160208601602086016147a9565b601f01601f19169290920160200192915050565b60208152600061393660208301846147d5565b6000602080830181845280855180835260408601915060408160051b870101925083870160005b8281101561486957603f198886030184526148578583516147d5565b9450928501929085019060010161483b565b5092979650505050505050565b6000806040838503121561488957600080fd5b82356148948161459f565b9150602083013567ffffffffffffffff8111156148b057600080fd5b61474985828601614664565b600081518084526020808501945080840160005b838110156148f55781516001600160a01b0316875295820195908201906001016148d0565b509495945050505050565b60208152600061393660208301846148bc565b6000806040838503121561492657600080fd5b82356149318161459f565b946020939093013593505050565b60006020828403121561495157600080fd5b5035919050565b6000806000806080858703121561496e57600080fd5b84356149798161459f565b935060208501356149898161459f565b925060408501356149998161459f565b9396929550929360600135925050565b8015158114613ee357600080fd5b6000806000606084860312156149cc57600080fd5b8335925060208401356149de8161459f565b915060408401356149ee816149a9565b809150509250925092565b60008060008060808587031215614a0f57600080fd5b8435614a1a8161459f565b93506020850135614a2a8161459f565b93969395505050506040820135916060013590565b600080600060608486031215614a5457600080fd5b8335614a5f8161459f565b95602085013595506040909401359392505050565b602080825260169082015275151bdad95b881a5cc81b9bdd081cdd5c1c1bdc9d195960521b604082015260600190565b602080825260169082015275105cdcd95d081a5cc81b9bdd081cdd5c1c1bdc9d195960521b604082015260600190565b60208082526027908201527f417373657420616e6420746f6b656e206d75737420686176652073616d652063604082015266757272656e637960c81b606082015260800190565b600060208284031215614b2d57600080fd5b815167ffffffffffffffff811115614b4457600080fd5b8201601f81018413614b5557600080fd5b8051614b636146838261463c565b818152856020838501011115614b7857600080fd5b6142c38260208301602086016147a9565b600060208284031215614b9b57600080fd5b5051919050565b634e487b7160e01b600052601160045260246000fd5b600082821015614bca57614bca614ba2565b500390565b6001600160a01b03929092168252602082015260400190565b600060208284031215614bfa57600080fd5b8151613936816149a9565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b60008251614c4c8184602087016147a9565b9190910192915050565b604081526000614c6960408301856147d5565b82810360208401526142c381856147d5565b600181811c90821680614c8f57607f821691505b60208210811415614cb057634e487b7160e01b600052602260045260246000fd5b50919050565b600060208284031215614cc857600080fd5b81516139368161459f565b6001600160a01b0392831681529116602082015260400190565b600060208284031215614cff57600080fd5b815160ff8116811461393657600080fd5b60008219821115614d2357614d23614ba2565b500190565b6001600160a01b0394851681529290931660208301526040820152606081019190915260800190565b634e487b7160e01b600052603260045260246000fd5b6000600019821415614d7b57614d7b614ba2565b5060010190565b60208082526024908201527f4f7261636c65205072696365206c657373207468656e20556e697377617020506040820152637269636560e01b606082015260800190565b85815284602082015260a060408201526000614de560a08301866148bc565b6001600160a01b0394909416606083015250608001529392505050565b600067ffffffffffffffff821115614e1c57614e1c6145f5565b5060051b60200190565b60006020808385031215614e3957600080fd5b825167ffffffffffffffff811115614e5057600080fd5b8301601f81018513614e6157600080fd5b8051614e6f61468382614e02565b81815260059190911b82018301908381019087831115614e8e57600080fd5b928401925b82841015611d2c57835182529284019290840190614e93565b60008060008060808587031215614ec257600080fd5b8451614ecd8161459f565b60208601516040870151606090970151919890975090945092505050565b60006020808385031215614efe57600080fd5b825167ffffffffffffffff811115614f1557600080fd5b8301601f81018513614f2657600080fd5b8051614f3461468382614e02565b81815260059190911b82018301908381019087831115614f5357600080fd5b928401925b82841015611d2c578351614f6b8161459f565b82529284019290840190614f58565b6000816000190483118215151615614f9457614f94614ba2565b500290565b600082614fb657634e487b7160e01b600052601260045260246000fd5b500490565b600181815b80851115614ff6578160001904821115614fdc57614fdc614ba2565b80851615614fe957918102915b93841c9390800290614fc0565b509250929050565b60008261500d5750600161116a565b8161501a5750600061116a565b8160018114615030576002811461503a57615056565b600191505061116a565b60ff84111561504b5761504b614ba2565b50506001821b61116a565b5060208310610133831016604e8410600b8410161715615079575081810a61116a565b6150838383614fbb565b806000190482111561509757615097614ba2565b029392505050565b60006139368383614ffe56fea2646970667358221220709eb55bc4408136d30475f7f9fba641aa15144b887bd4ca0814894abf62cc3d64736f6c634300080a00330000000000000000000000008cc12723a3df1777517eadc905a64558ef42fd97000000000000000000000000eefb9fc58018841bbc90a89e43990ae2409cbd6b0000000000000000000000007301540899b8643df3e56d51bc5b483d19a6281c000000000000000000000000168c723f84cc2aed781023f8672b254b4904f53900000000000000000000000012b390d281f57fa9f5a39f6f78bd0e21ea5d5afd0000000000000000000000001b02da8cb0d097eb8d57a175b88c7d8b47997506000000000000000000000000c35dadb65012ec5796536bd9864ed8773abc74c4

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

0000000000000000000000008cc12723a3df1777517eadc905a64558ef42fd97000000000000000000000000eefb9fc58018841bbc90a89e43990ae2409cbd6b0000000000000000000000007301540899b8643df3e56d51bc5b483d19a6281c000000000000000000000000168c723f84cc2aed781023f8672b254b4904f53900000000000000000000000012b390d281f57fa9f5a39f6f78bd0e21ea5d5afd0000000000000000000000001b02da8cb0d097eb8d57a175b88c7d8b47997506000000000000000000000000c35dadb65012ec5796536bd9864ed8773abc74c4

-----Decoded View---------------
Arg [0] : _oracle (address): 0x8cc12723a3df1777517eadc905a64558ef42fd97
Arg [1] : _factory (address): 0xeefb9fc58018841bbc90a89e43990ae2409cbd6b
Arg [2] : _stableCoinFactory (address): 0x7301540899b8643df3e56d51bc5b483d19a6281c
Arg [3] : portfolioTokenAddress (address): 0x168c723f84cc2aed781023f8672b254b4904f539
Arg [4] : farmAddress (address): 0x12b390d281f57fa9f5a39f6f78bd0e21ea5d5afd
Arg [5] : uniswapRouterAddress (address): 0x1b02da8cb0d097eb8d57a175b88c7d8b47997506
Arg [6] : uniswapFactoryAddress (address): 0xc35dadb65012ec5796536bd9864ed8773abc74c4

-----Encoded View---------------
7 Constructor Arguments found :
Arg [0] : 0000000000000000000000008cc12723a3df1777517eadc905a64558ef42fd97
Arg [1] : 000000000000000000000000eefb9fc58018841bbc90a89e43990ae2409cbd6b
Arg [2] : 0000000000000000000000007301540899b8643df3e56d51bc5b483d19a6281c
Arg [3] : 000000000000000000000000168c723f84cc2aed781023f8672b254b4904f539
Arg [4] : 00000000000000000000000012b390d281f57fa9f5a39f6f78bd0e21ea5d5afd
Arg [5] : 0000000000000000000000001b02da8cb0d097eb8d57a175b88c7d8b47997506
Arg [6] : 000000000000000000000000c35dadb65012ec5796536bd9864ed8773abc74c4


Block Transaction Gas Used Reward
Age Block Fee Address BC Fee Address Voting Power Jailed Incoming
Block Uncle Number Difficulty Gas Used Reward
Loading