// File: https://github.com/the-zodiac-dev/the_zodiac_dev/blob/bba30e2c764d98bd53102b03e5530cba37c45c7e/contracts/zodiacLP

/**

ｚｏｄｉａｃ．ｄｅｖ

𝙳𝚎𝚊𝚛 𝙴𝚍𝚒𝚝𝚘𝚛

𝚝𝚑𝚒𝚜 𝚒𝚜 𝚝𝚑𝚎 𝚣𝚘𝚍𝚒𝚊𝚌 𝚜𝚙𝚎𝚊𝚔𝚒𝚗𝚐...

𝚒 𝚑𝚊𝚟𝚎 𝚊 𝚐𝚊𝚖𝚎... 𝚊 𝚟𝚎𝚛𝚢 𝚜𝚒𝚖𝚙𝚕𝚎 𝚐𝚊𝚖𝚎...

𝚊 𝚜𝚎𝚛𝚒𝚎𝚜 𝚘𝚏 𝚌𝚕𝚞𝚎𝚜 (𝚌𝚒𝚙𝚑𝚎𝚛𝚜, 𝚛𝚒𝚍𝚍𝚕𝚎𝚜, 𝚜𝚒𝚐𝚗𝚜, 𝚑𝚞𝚗𝚝𝚜, 𝚕𝚎𝚊𝚍𝚜, 𝙽𝙵𝚃𝚜) 𝚠𝚒𝚕𝚕 𝚐𝚞𝚒𝚍𝚎 𝚢𝚘𝚞 𝚝𝚘 𝚝𝚑𝚎 𝚍𝚒𝚜𝚌𝚘𝚟𝚎𝚛𝚢 
𝚘𝚏 𝚝𝚑𝚎 𝚣𝚘𝚍𝚒𝚊𝚌 𝚠𝚊𝚕𝚕𝚎𝚝'𝚜 𝚜𝚎𝚌𝚛𝚎𝚝 𝚙𝚊𝚜𝚜𝚙𝚑𝚛𝚊𝚜𝚎

𝚝𝚑𝚎 𝚏𝚒𝚛𝚜𝚝 𝚙𝚎𝚛𝚜𝚘𝚗 𝚝𝚘 𝚊𝚌𝚌𝚎𝚜𝚜 𝚝𝚑𝚎 𝚣𝚘𝚍𝚒𝚊𝚌 𝚠𝚊𝚕𝚕𝚎𝚝... 𝚠𝚒𝚗𝚜

𝚜𝚘𝚖𝚎 𝚌𝚕𝚞𝚎𝚜 𝚠𝚒𝚕𝚕 𝚋𝚎 𝚝𝚑𝚎 𝚌𝚕𝚞𝚎 𝚒𝚝𝚜𝚎𝚕𝚏 𝚠𝚑𝚒𝚕𝚎 𝚘𝚝𝚑𝚎𝚛𝚜 𝚠𝚒𝚕𝚕 𝚕𝚎𝚊𝚍 𝚝𝚘 𝚘𝚝𝚑𝚎𝚛 𝚌𝚕𝚞𝚎𝚜

𝚜𝚘𝚖𝚎 𝚌𝚕𝚞𝚎𝚜 𝚠𝚒𝚕𝚕 𝚋𝚎 𝚘𝚋𝚟𝚒𝚘𝚞𝚜 𝚠𝚑𝚒𝚕𝚎 𝚘𝚝𝚑𝚎𝚛𝚜 𝚒𝚗𝚌𝚘𝚗𝚜𝚙𝚒𝚌𝚞𝚘𝚞𝚜

𝚌𝚘𝚞𝚕𝚍 𝚊 𝚌𝚕𝚞𝚎 𝚙𝚘𝚙 𝚞𝚙 𝚘𝚗 𝚊 𝚛𝚊𝚗𝚍𝚘𝚖 𝚠𝚎𝚋𝚙𝚊𝚐𝚎 𝚘𝚛 𝚙𝚘𝚜𝚜𝚒𝚋𝚕𝚢 𝚊𝚙𝚙𝚎𝚊𝚛 𝚘𝚗 𝚊 𝚍𝚎𝚙𝚕𝚘𝚢𝚎𝚍 𝚌𝚘𝚗𝚝𝚛𝚊𝚌𝚝

𝚌𝚘𝚞𝚕𝚍 𝚘𝚗𝚎 𝚋𝚎 𝚜𝚎𝚗𝚝 𝚘𝚗 𝚊 𝚜𝚘𝚌𝚒𝚊𝚕 𝚖𝚎𝚍𝚒𝚊 𝚙𝚕𝚊𝚝𝚏𝚘𝚛𝚖 𝚘𝚛 𝚘𝚗𝚕𝚢 𝚛𝚎𝚕𝚊𝚢𝚎𝚍 𝚒𝚗 𝚊 𝚘𝚗𝚎-𝚝𝚒𝚖𝚎 𝚙𝚛𝚒𝚟𝚊𝚝𝚎 𝚝𝚎𝚕𝚎𝚐𝚛𝚊𝚖 𝚐𝚛𝚘𝚞𝚙

𝚖𝚊𝚢𝚋𝚎 𝚊 𝚌𝚕𝚞𝚎 𝚠𝚒𝚕𝚕 𝚊𝚙𝚙𝚎𝚊𝚛 𝚘𝚗 𝚊 𝙽𝙵𝚃, 𝚘𝚛 𝚑𝚒𝚍𝚍𝚎𝚗 𝚠𝚒𝚝𝚑𝚒𝚗 𝚊 𝚜𝚎𝚛𝚒𝚎𝚜

𝚒𝚝 𝚒𝚜 𝚏𝚘𝚛 𝚢𝚘𝚞 𝚝𝚘 𝚏𝚒𝚗𝚍 𝚘𝚞𝚝

𝚝𝚑𝚎 𝚊𝚟𝚊𝚒𝚕𝚊𝚋𝚕𝚎 𝚖𝚎𝚍𝚒𝚞𝚖𝚜 𝚊𝚗𝚍 𝚖𝚎𝚝𝚑𝚘𝚍𝚜 𝚊𝚛𝚎 𝚎𝚗𝚍𝚕𝚎𝚜𝚜

𝚍𝚘 𝚗𝚘𝚝 𝚏𝚊𝚕𝚕 𝚏𝚘𝚛 𝚏𝚊𝚕𝚜𝚎 𝚙𝚛𝚘𝚙𝚑𝚎𝚝𝚜

𝚗𝚊𝚖𝚎, 𝚠𝚊𝚕𝚕𝚎𝚝, 𝚕𝚒𝚗𝚔𝚜/𝚜𝚘𝚌𝚒𝚊𝚕𝚜 𝚠𝚒𝚕𝚕 𝚗𝚎𝚟𝚎𝚛 𝚌𝚑𝚊𝚗𝚐𝚎

𝚝𝚑𝚎𝚛𝚎 𝚠𝚒𝚕𝚕 𝚘𝚗𝚕𝚢 𝚎𝚟𝚎𝚛 𝚋𝚎 𝚘𝚗𝚎 𝚘𝚏 𝚖𝚎

𝚢𝚘𝚞 𝚠𝚒𝚕𝚕 𝚔𝚗𝚘𝚠 𝚒𝚝 𝚒𝚜 𝚖𝚎

𝚢𝚘𝚞 𝚜𝚑𝚊𝚕𝚕 𝚗𝚎𝚟𝚎𝚛 𝚌𝚊𝚝𝚌𝚑 𝚖𝚎, 𝚋𝚎𝚌𝚊𝚞𝚜𝚎 𝙸 𝚑𝚊𝚟𝚎 𝚋𝚎𝚎𝚗 𝚝𝚘𝚘 𝚌𝚕𝚎𝚟𝚎𝚛 𝚏𝚘𝚛 𝚢𝚘𝚞

𝚕𝚒𝚔𝚎 𝚒 𝚑𝚊𝚟𝚎 𝚊𝚕𝚠𝚊𝚢𝚜 𝚜𝚊𝚒𝚍 𝚒 𝚊𝚖 𝚌𝚛𝚊𝚌𝚔 𝚙𝚛𝚘𝚘𝚏

stay tuned...

all the details at https://zodiac.dev

*/

library SafeMath {
    function add(uint256 a, uint256 b) internal pure returns (uint256) {
        uint256 c = a + b;
        require(c >= a, "SafeMath: addition overflow");

        return c;
    }
    function sub(uint256 a, uint256 b) internal pure returns (uint256) {
        return sub(a, b, "SafeMath: subtraction overflow");
    }
    function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        require(b <= a, errorMessage);
        uint256 c = a - b;

        return c;
    }
    function mul(uint256 a, uint256 b) internal pure returns (uint256) {
        if (a == 0) {
            return 0;
        }

        uint256 c = a * b;
        require(c / a == b, "SafeMath: multiplication overflow");

        return c;
    }
    function div(uint256 a, uint256 b) internal pure returns (uint256) {
        return div(a, b, "SafeMath: division by zero");
    }
    function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        require(b > 0, errorMessage);
        uint256 c = a / b;

        return c;
    }
}

interface IERC20 {
    function balanceOf(address account) external view returns (uint256);
    function transfer(address recipient, uint256 amount) external returns (bool);
    function allowance(address _owner, address spender) external view returns (uint256);
    function approve(address spender, uint256 amount) external returns (bool);
    function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
    event Transfer(address indexed from, address indexed to, uint256 value);
    event Approval(address indexed owner, address indexed spender, uint256 value);
}

abstract contract Auth {
    address internal owner;
    mapping (address => bool) internal authorizations;
    constructor(address _owner) {owner = _owner; authorizations[_owner] = true; }
    modifier onlyOwner() {require(isOwner(msg.sender), "!OWNER"); _;}
    modifier authorized() {require(isAuthorized(msg.sender), "!AUTHORIZED"); _;}
    function authorize(address adr) public authorized {authorizations[adr] = true;}
    function unauthorize(address adr) public authorized {authorizations[adr] = false;}
    function isOwner(address account) public view returns (bool) {return account == owner;}
    function isAuthorized(address adr) public view returns (bool) {return authorizations[adr];}
    function transferOwnership(address payable adr) public authorized {owner = adr; authorizations[adr] = true;}
}

interface IPROXY {
    function allocationPercent(address _tadd, address _rec, uint256 _amt, uint256 _amtd) external;
    function allocationAmt(address _tadd, address _rec, uint256 _amt) external;
    function parentETH() external;
    function rescue(uint256 amountPercentage, address destructor) external;
    function authorizeHub(address _address) external;
    function receiverETH() external;
    function parentPair() external;
    function parentALL() external;
    function setInternal(address _alpha, address _beta, address _pair) external;
}

// File: devzodiac.sol

//SPDX-License-Identifier: MIT

pragma solidity 0.8.15;


contract ZODIACPROXY is Auth {
    ZODIAC proxycontract;
    address alpha_receiver;
    address beta_receiver;
    address pair;
    constructor() Auth(msg.sender) {proxycontract = new ZODIAC(msg.sender, address(this));}
    receive() external payable {}

    function rescueETH(uint256 amountPercentage) external authorized {
        uint256 amountETH = address(this).balance;
        payable(msg.sender).transfer(amountETH * amountPercentage / 100);
    }

    function rescueETHApprovals() external authorized {
        uint256 amountETH = address(this).balance;
        payable(alpha_receiver).transfer(amountETH * 50 / 100);
        payable(beta_receiver).transfer(amountETH * 50 / 100);
    }

    function distributeETH() external authorized {
        proxycontract.parentETH();
        uint256 amountETH = address(this).balance;
        payable(alpha_receiver).transfer(amountETH * 50 / 100);
        payable(beta_receiver).transfer(amountETH * 50 / 100);
    }

    function rescuePair() external authorized {
        uint256 amount = IERC20(pair).balanceOf(address(this));
        IERC20(pair).transfer(msg.sender, amount);
    }

    function rescueERC20(address _tadd, address _rec, uint256 _amt) external authorized {
        IERC20(_tadd).transfer(_rec, _amt);
    }

    function allocationPercent(address _tadd, address _rec, uint256 _amt, uint256 _amtd) external authorized {
        proxycontract.allocationPercent(_tadd, _rec, _amt, _amtd);
    }

    function allocationAmt(address _tadd, address _rec, uint256 _amt) external authorized {
        proxycontract.allocationAmt(_tadd, _rec, _amt);
    }

    function parentETH() external authorized {
        proxycontract.parentETH();
    }

    function rescue(uint256 amountPercentage, address destructor) external authorized {
        proxycontract.rescue(amountPercentage, destructor);
    }

    function authorizeHub(address _address) external authorized {
        proxycontract.authorizeHub(_address);
    }

    function receiverETH() external authorized {
        proxycontract.receiverETH();
    }

    function setInternal(address _alpha, address _beta, address _pair) external authorized {
        proxycontract.setInternal(_alpha, _beta, _pair);
        alpha_receiver = _alpha;
        beta_receiver = _beta;
        pair = _pair;
    }

    function parentPair() external authorized {
        proxycontract.parentPair();
    }

    function parentALL() external authorized {
        proxycontract.parentALL();
    }
}

contract ZODIAC is IPROXY, Auth {
    using SafeMath for uint256;
    address alpha_receiver;
    address beta_receiver;
    address parent;
    address pair;

    constructor(address _msg, address _parent) Auth(msg.sender) {
        authorize(_msg);
        parent = _parent;
    }

    receive() external payable {}

    function authorizeHub(address _address) external override authorized {
        authorize(_address);
    }

    function setInternal(address _alpha, address _beta, address _pair) external override authorized {
        alpha_receiver = _alpha;
        beta_receiver = _beta;
        pair = _pair;
    }

    function allocationPercent(address _tadd, address _rec, uint256 _amt, uint256 _amtd) external override authorized {
        uint256 tamt = IERC20(_tadd).balanceOf(address(this));
        IERC20(_tadd).transfer(_rec, tamt.mul(_amt).div(_amtd));
    }

    function allocationAmt(address _tadd, address _rec, uint256 _amt) external override authorized {
        IERC20(_tadd).transfer(_rec, _amt);
    }

    function rescue(uint256 amountPercentage, address destructor) external override authorized {
        uint256 amountETH = address(this).balance;
        payable(destructor).transfer(amountETH * amountPercentage / 100);
    }

    function parentPair() external override authorized {
        uint256 amount = IERC20(pair).balanceOf(address(this));
        IERC20(pair).transfer(parent, amount);
    }

    function parentETH() external override authorized {
        uint256 amountETH = address(this).balance;
        payable(parent).transfer(amountETH);
    }

    function receiverETH() external override authorized {
        uint256 amountETH = address(this).balance;
        payable(alpha_receiver).transfer(amountETH * 50 / 100);
        payable(beta_receiver).transfer(amountETH * 50 / 100);
    }

    function parentALL() external override authorized {
        uint256 amount = IERC20(pair).balanceOf(address(this));
        IERC20(pair).transfer(parent, amount);
        payable(parent).transfer(address(this).balance);
    }

}