Contract 0x3d6d7d77059fbdcf24757b4f312c8015f47adca4

 

Contract Overview

Balance:
0 FTM

FTM Value:
$0.00

Token:
Txn Hash Method
Block
From
To
Value [Txn Fee]
0xc80cf37a68a6147b1cfb4d330ffee511162c911a3651932a340ee09046781887Swap Back337579562022-03-18 14:15:05261 days 10 hrs ago0xa3879d47649a0598c25d2bf53610f9e08ec61537 IN  0x3d6d7d77059fbdcf24757b4f312c8015f47adca40 FTM0.32311821884
0x7a552cfbc4ba7d9f354fbf15e4e155d67f6810f04897a71d9a11b724f0a3faabSwap Back337431762022-03-18 10:04:14261 days 15 hrs ago0xa3879d47649a0598c25d2bf53610f9e08ec61537 IN  0x3d6d7d77059fbdcf24757b4f312c8015f47adca40 FTM0.199561128996
0x7a092aeee478e2b8783376ab051e43bc0db646faf767c4c6be050ac7ee2f17c3Swap Back337278882022-03-18 6:04:01261 days 19 hrs ago0xa3879d47649a0598c25d2bf53610f9e08ec61537 IN  0x3d6d7d77059fbdcf24757b4f312c8015f47adca40 FTM0.171352714868
0x865e10424f63847b266abfd83eb89ec0d498de4fd68a8678e408ead5674645adSwap Back337120372022-03-18 1:48:37261 days 23 hrs ago0xa3879d47649a0598c25d2bf53610f9e08ec61537 IN  0x3d6d7d77059fbdcf24757b4f312c8015f47adca40 FTM0.208520385368
0x0cda9fc5e955d5152dee3d56cb3131d64e9667a913cce82b5e8dd42ed9ee0a0bSwap Back336965582022-03-17 21:37:25262 days 3 hrs ago0xa3879d47649a0598c25d2bf53610f9e08ec61537 IN  0x3d6d7d77059fbdcf24757b4f312c8015f47adca40 FTM0.192278567732
0xdb119791a018edb5127c8c1fe5f9bfda5e18273fbb5e4c37aa089bdc5765fd42Swap Back336807152022-03-17 17:24:34262 days 7 hrs ago0xa3879d47649a0598c25d2bf53610f9e08ec61537 IN  0x3d6d7d77059fbdcf24757b4f312c8015f47adca40 FTM0.60502545776
0x3409d41dc34f12b4193209e9e784d10d22aa0573f9bb432b6a688bedf28898feSwap Back336670662022-03-17 13:10:47262 days 12 hrs ago0xa3879d47649a0598c25d2bf53610f9e08ec61537 IN  0x3d6d7d77059fbdcf24757b4f312c8015f47adca40 FTM0.370450141582
0x071a7275e0681e9bc0e14779b0f8fe513f942e23777af5e83b09f62872a64cb1Swap Back336511202022-03-17 8:58:33262 days 16 hrs ago0xa3879d47649a0598c25d2bf53610f9e08ec61537 IN  0x3d6d7d77059fbdcf24757b4f312c8015f47adca40 FTM0.246996865504
0xdbee86ecfc708b779eaf8350d057d66f4254bbac479cb21327b6317a3e4bb74fSwap Back336353082022-03-17 4:48:45262 days 20 hrs ago0xa3879d47649a0598c25d2bf53610f9e08ec61537 IN  0x3d6d7d77059fbdcf24757b4f312c8015f47adca40 FTM0.296747287102
0x577b65aa27211eef961d8a45e4a0d72103a46f3e75132d022ec380a20b288533Swap Back336194162022-03-17 0:41:56263 days 30 mins ago0xa3879d47649a0598c25d2bf53610f9e08ec61537 IN  0x3d6d7d77059fbdcf24757b4f312c8015f47adca40 FTM0.6182858648
0xc2fc49d66d1a333741b7d4f8f3b76fdb3789821f8c365d6819fb4f33a315dd3aSwap Back336057262022-03-16 20:33:55263 days 4 hrs ago0xa3879d47649a0598c25d2bf53610f9e08ec61537 IN  0x3d6d7d77059fbdcf24757b4f312c8015f47adca40 FTM0.612422157396
0x2aa26b208969912823b6c2a46f4df1c74bb12c81628fe71088ea52a44fcda09eSwap Back335916422022-03-16 16:37:20263 days 8 hrs ago0xa3879d47649a0598c25d2bf53610f9e08ec61537 IN  0x3d6d7d77059fbdcf24757b4f312c8015f47adca40 FTM0.382205666902
0xe27ae092fb460138bda87d7246c667b1ffb5c566fbf397c263cc0e32fa4d586dSwap Back335755542022-03-16 12:15:04263 days 12 hrs ago0xa3879d47649a0598c25d2bf53610f9e08ec61537 IN  0x3d6d7d77059fbdcf24757b4f312c8015f47adca40 FTM0.36544065518
0xa00ed2e4fa5a12756b96b9153d3259d62180e89ce7740d227eb47e1fb34c6a99Swap Back335603932022-03-16 8:07:26263 days 17 hrs ago0xa3879d47649a0598c25d2bf53610f9e08ec61537 IN  0x3d6d7d77059fbdcf24757b4f312c8015f47adca40 FTM0.256820666782
0x2b0a73ea370c70c01c86df28039b36b1dc77c0a639211f3121ad89447872b0c0Swap Back335441672022-03-16 3:53:50263 days 21 hrs ago0xa3879d47649a0598c25d2bf53610f9e08ec61537 IN  0x3d6d7d77059fbdcf24757b4f312c8015f47adca40 FTM0.44932290695
0x88502365f959914e15aaf2b25f27481a7d9f66bf83c1a5c9b83b10a6a820d94bSwap Back335296532022-03-15 23:53:21264 days 1 hr ago0xa3879d47649a0598c25d2bf53610f9e08ec61537 IN  0x3d6d7d77059fbdcf24757b4f312c8015f47adca40 FTM0.408112411694
0x6ee4d1abbf5e75c5b24d9871ddf2fc4736ffed12571eba25232c4f193f25b6e8Swap Back335135072022-03-15 19:38:31264 days 5 hrs ago0xa3879d47649a0598c25d2bf53610f9e08ec61537 IN  0x3d6d7d77059fbdcf24757b4f312c8015f47adca40 FTM1.419524312207
0xe5348017b338eb801686aa0df24bac2084983913719920a4e8f4caebc345c10bSwap Back334998272022-03-15 15:26:03264 days 9 hrs ago0xa3879d47649a0598c25d2bf53610f9e08ec61537 IN  0x3d6d7d77059fbdcf24757b4f312c8015f47adca40 FTM0.356406495407
0x6865bf60584a2faa2095c2b8b28ec371aaf9881103d9464a90b8fd3558d41f0eSwap Back334841182022-03-15 11:20:03264 days 13 hrs ago0xa3879d47649a0598c25d2bf53610f9e08ec61537 IN  0x3d6d7d77059fbdcf24757b4f312c8015f47adca40 FTM0.385024593892
0xfb9b012df2abf2046f4e2a3dd0ce2712bbb568f2dc453e481df1c82704cba094Swap Back334702342022-03-15 7:18:30264 days 17 hrs ago0xa3879d47649a0598c25d2bf53610f9e08ec61537 IN  0x3d6d7d77059fbdcf24757b4f312c8015f47adca40 FTM0.29671554161
0x9dd1a63ffe45715d526b007fcd3b69db96cf1220ac31af4f0463a7e27663da22Swap Back334543472022-03-15 3:05:35264 days 22 hrs ago0xa3879d47649a0598c25d2bf53610f9e08ec61537 IN  0x3d6d7d77059fbdcf24757b4f312c8015f47adca40 FTM0.24878651282
0x1af5c1f19996f71b6a4a2e9b614e46ff22905be1c0ea9f25eff25a6bd649d9e9Swap Back334386732022-03-14 22:57:54265 days 2 hrs ago0xa3879d47649a0598c25d2bf53610f9e08ec61537 IN  0x3d6d7d77059fbdcf24757b4f312c8015f47adca40 FTM0.37537650881
0x5e3a287f20c5c17871a33aef8dfa0ff0375b915b51b4335d27a65a65127a8ed4Swap Back334231152022-03-14 18:45:51265 days 6 hrs ago0xa3879d47649a0598c25d2bf53610f9e08ec61537 IN  0x3d6d7d77059fbdcf24757b4f312c8015f47adca40 FTM0.405585373598
0x33c3d709cf7a31a04426c937cf7e6792ed8ebeba136018618c6967eb094fc05bSwap Back334074102022-03-14 14:34:50265 days 10 hrs ago0xa3879d47649a0598c25d2bf53610f9e08ec61537 IN  0x3d6d7d77059fbdcf24757b4f312c8015f47adca40 FTM0.455419616572
0xd1ae5f16140600cde51b4f1fffcad8e10e4e6668dbe7215fe0a1ab4fded7b3baSwap Back333918362022-03-14 10:23:12265 days 14 hrs ago0xa3879d47649a0598c25d2bf53610f9e08ec61537 IN  0x3d6d7d77059fbdcf24757b4f312c8015f47adca40 FTM0.421105405372
[ Download CSV Export 
Latest 1 internal transaction
Parent Txn Hash Block From To Value
0xae568be8357ce5ec10f781c54a7ca13c64ed954051786a5a67050b8551ad4ddd274877852022-01-09 20:50:14329 days 4 hrs ago 0xa3879d47649a0598c25d2bf53610f9e08ec61537  Contract Creation0 FTM
[ Download CSV Export 
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
FTMSwapBackManager

Compiler Version
v0.8.7+commit.e28d00a7

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion

Contract Source Code (Solidity Standard Json-Input format)

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

import "./helpers/Auth.sol";
import "./interfaces/IUniswapV2Router02.sol";
import "./FTMPay.sol";

contract FTMSwapBackManager is Auth {

    uint256 public totalSupply = 1_000_000_000_000_000 * (10 ** 6);
    address public FantomPay = 0xAfF15DAe5C956f9D7d5B98F304863201EA47c656;
    address public WFTM= 0x21be370D5312f44cB42ce377BC9b8a0cEF1A4C83;
    address public DEAD = 0x000000000000000000000000000000000000dEaD;
    address public pair = 0xA62d46ff9EB5CBe2aBa0F8E720650C159046200a;
    address public routerAddress = 0xF491e7B69E4244ad4002BC14e878a34207E38c29;
    IUniswapV2Router02 public router;

    constructor () {
        router = IUniswapV2Router02(routerAddress);
        WFTM = 0x21be370D5312f44cB42ce377BC9b8a0cEF1A4C83;
    }

    function swapBack(uint256 amountToSwap, uint256 base) external payable authorized {
        FTMPay(payable(FantomPay)).setSwapBackSettings(true, amountToSwap);

        address[] memory path = new address[](2);
        path[0] = FantomPay;
        path[1] = WFTM;
        IERC20(FantomPay).approve(routerAddress, base);

        router.swapExactTokensForETHSupportingFeeOnTransferTokens(
            base,
            0,
            path,
            DEAD,
            block.timestamp
        );

        FTMPay(payable(FantomPay)).setSwapBackSettings(false, amountToSwap);
    }
}

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

import "@openzeppelin/contracts/access/Ownable.sol";

contract Auth is Ownable {
    mapping (address => bool) internal authorizations;

    constructor() {
        authorizations[msg.sender] = true;
    }

    /**
     * Return address' authorization status
     */
    function isAuthorized(address adr) public view returns (bool) {
        return authorizations[adr];
    }

    /**
     * Authorize address. Owner only
     */
    function authorize(address adr) public onlyOwner {
        authorizations[adr] = true;
    }

    /**
     * Remove address' authorization. Owner only
     */
    function unauthorize(address adr) public onlyOwner {
        authorizations[adr] = false;
    }

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

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

    /**
     * Function modifier to require caller to be authorized
     */
    modifier authorized() {
        require(isAuthorized(msg.sender), "!AUTHORIZED"); _;
    }


}

File 3 of 11 : IUniswapV2Router02.sol
// SPDX-License-Identifier: MIT
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 4 of 11 : FTMPay.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.7;

import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/utils/math/SafeMath.sol";

import "./interfaces/IUniswapV2Factory.sol";
import "./interfaces/IUniswapV2Router02.sol";

import "./helpers/Auth.sol";
import "./helpers/DividendDistributor.sol";

/*
Website: https://fantompayxyz.com
Discord: https://discord.gg/xes2v6C2ZR
Telegram: https://t.me/FTMPay
Twitter: https://twitter.com/FTM_Pay

Fantom Pay is a dividend token on the Fantom Opera blockchain. Hold FTMP and earn USDC. Claim your dividends using the dashboard on our website!

Liquidity will be locked on dx.app right after it has been added, and the proof posted on our website, docs and social media channels.

Use 16-20%+ Slippage to process transactions. 
If you have any issues, please change any zeros in the amount you are swapping to 1s, as this helps with rounding issues on DEXs. i.e Buying/Selling 261,111,111,111 instead of 260,000,000,000.
For all other questions, please join us in Discord where we will have dedicated support staff to help in chat.
*/

contract FTMPay is Auth {

  using SafeMath for uint256;

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

  event Transfer(address indexed from, address indexed to, uint256 value);
  event Approval(address indexed owner, address indexed spender, uint256 value);
  event AutoLiquify(uint256 _amountFTMLiquidity, uint256 _amountToLiquify);
  event BuybackMultiplierActive(uint256 _duration);

  /** ======= ERC20 PARAMS ======= */

  string constant _name =  "FTMPay";    
  string constant _symbol = "FTMP";        
  uint8 constant _decimals = 9;

  uint256 _totalSupply = 1_000_000_000_000_000 * (10 ** _decimals);
  
  mapping (address => uint256) _balances;
  mapping (address => mapping (address => uint256)) _allowances;

  /** ======= GLOBAL PARAMS ======= */

  uint256 public constant MASK = type(uint128).max;

  address DEAD = 0x000000000000000000000000000000000000dEaD;
  address ZERO = address(0);

  address public EP = address(0); 
  address public WFTM = 0x21be370D5312f44cB42ce377BC9b8a0cEF1A4C83;
  
  IUniswapV2Router02 public router;
  address public routerAddress; 
  address public pair;

  DividendDistributor distributor;
  address public distributorAddress;

  uint256 distributorGas = 500000;

  // 16% Fee in total; 
  uint256 totalFee = 1600;
  uint256 feeDenominator = 10000;
  
  // 3% goes to providing liquidity to the pair; 
  uint256 liquidityFee = 300;
  // 10% Goes to the reflections for token holders; 
  uint256 reflectionFee = 1000;
  // 1.5% Goes to the marketing team;
  uint256 marketingFee = 150;
  // 1.5% Goes to the dev team; 
  uint256 devFee = 150;

  uint256 buybackFee = 0;

  //liq address
  address public autoLiquidityReceiver= address(0); 

  // Address that gets the marketing fee's; 
  address public marketingFeeReceiver= address(0);

  // Dev address that recives the devFees;
  address public developerFeeReciver = address(0); 


  uint256 targetLiquidity = 5;
  uint256 targetLiquidityDenominator = 100;

  uint256 public _maxTxAmount = _totalSupply.div(100); // 1%
  uint256 public _maxWallet = _totalSupply.div(40); // 2.5%

  mapping (address => bool) isFeeExempt;        
  mapping (address => bool) isTxLimitExempt;    
  mapping (address => bool) isDividendExempt;   
  mapping (address => bool) public isFree;     

  // BlockNumber of launch; 
  uint256 public launchedAt;
  // Timestamp of launch; 
  uint256 public launchedAtTimestamp;

  uint256 buybackMultiplierNumerator = 200;
  uint256 buybackMultiplierDenominator = 100;
  uint256 buybackMultiplierLength = 30 minutes;

  uint256 buybackMultiplierTriggeredAt;

  bool public autoBuybackEnabled = false;

  mapping (address => bool) buyBacker;

  uint256 autoBuybackCap;
  uint256 autoBuybackAccumulator;
  uint256 autoBuybackAmount;
  uint256 autoBuybackBlockPeriod;
  uint256 autoBuybackBlockLast;

  bool public swapEnabled = true;
  uint256 public swapThreshold = _totalSupply / 1000; // 0.1%;

  bool inSwap;

  /** ======= CONSTRUCTOR ======= */

  constructor (
    address _router,
    address _marketer,
    address _ep
  ) {
    EP = _ep;

    autoLiquidityReceiver= msg.sender; 
    marketingFeeReceiver= _marketer;
    developerFeeReciver = msg.sender; 

    routerAddress = _router;
    // Initialize the router; 
    router = IUniswapV2Router02(_router);

    // Make a pair for WFTM/GSCRAB; 
    pair = IUniswapV2Factory(router.factory()).createPair(WFTM, address(this));

    _allowances[address(this)][address(_router)] = type(uint256).max;

    // Create a new Divdistributor contract; 
    distributor = new DividendDistributor(_router);

    // Set the address; 
    distributorAddress = address(distributor);

    isFeeExempt[msg.sender] = true;
    isTxLimitExempt[msg.sender] = true;
    isDividendExempt[pair] = true;
    isDividendExempt[address(this)] = true;
    isDividendExempt[DEAD] = true;
    buyBacker[msg.sender] = true;

    autoLiquidityReceiver = msg.sender;

    // Approve the router with totalSupply; 
    approve(_router, type(uint256).max);

    // Approve the pair with totalSupply; 
    approve(address(pair), type(uint256).max);
    
    // Send totalSupply to msg.sender; 
    _balances[msg.sender] = _totalSupply;

    // Emit transfer event; 
    emit Transfer(address(0), msg.sender, _totalSupply);

  }

  /** ======= PUBLIC VIEW FUNCTIONS ======= */

  function getTotalFee() public view returns (uint256) {
    return totalFee;
  }

  function getCirculatingSupply() public view returns (uint256) {
      return _totalSupply.sub(balanceOf(DEAD)).sub(balanceOf(ZERO));
  }

  function getLiquidityBacking(uint256 accuracy) public view returns (uint256) {
      return accuracy.mul(balanceOf(pair).mul(2)).div(getCirculatingSupply());
  }

  function isOverLiquified(uint256 target, uint256 accuracy) public view returns (bool) {
      return getLiquidityBacking(accuracy) > target;
  }


  /** ======= ERC20 FUNCTIONS ======= */

  function totalSupply() external view returns (uint256) { 
    return _totalSupply; 
  }

  function decimals() external pure returns (uint8) { 
    return _decimals; 
  }

  function symbol() external pure returns (string memory) { 
    return _symbol; 
  }

  function name() external pure  returns (string memory) { 
    return _name; 
  }

  function balanceOf(address account) public view returns (uint256) { 
    return _balances[account]; 
  }

  function allowance(address holder, address spender) public view returns (uint256) { 
    return _allowances[holder][spender]; 
  }

  function approve(address spender, uint256 amount) public returns (bool) {
    _allowances[msg.sender][spender] = amount;
    emit Approval(msg.sender, spender, amount);
    return true;
  }

  function approveMax(address spender) external returns (bool) {
      return approve(spender, _totalSupply);
  }

  function transfer(address recipient, uint256 amount) external returns (bool) {
    return _transferFrom(msg.sender, recipient, amount);
  }

  function transferFrom(address sender, address recipient, uint256 amount) external returns (bool) {
    if(_allowances[sender][msg.sender] != _totalSupply){
        _allowances[sender][msg.sender] = _allowances[sender][msg.sender].sub(amount, "Insufficient Allowance");
    }
    return _transferFrom(sender, recipient, amount);
  }


  function _transferFrom(address sender, address recipient, uint256 amount) internal returns (bool) {
    // If in swap just do a basic transfer. Same as normal ERC20 transferFrom function;
    if(inSwap) { 
        return _basicTransfer(sender, recipient, amount); 
    }
      
    bool isSell = recipient == pair || recipient == routerAddress;
    
    checkTxLimit(sender, amount);
    
    // Max wallet check excluding pair and router
    if (!isSell && !isFree[recipient]){
        require((_balances[recipient] + amount) < _maxWallet, "Max wallet has been triggered");
    }
    
    // No swapping on buy and tx
    if (isSell) {
        if(shouldSwapBack()){ 
            swapBack(); 
        }
        if(shouldAutoBuyback()){ 
            triggerAutoBuyback(); 
        }
    }
    

    _balances[sender] = _balances[sender].sub(amount, "Insufficient Balance");

    uint256 amountReceived = shouldTakeFee(sender) ? takeFee(sender, amount) : amount;

    _balances[recipient] = _balances[recipient].add(amountReceived);

    if(!isDividendExempt[sender]){ try distributor.setShare(sender, _balances[sender]) {} catch {} }
    if(!isDividendExempt[recipient]){ try distributor.setShare(recipient, _balances[recipient]) {} catch {} }

    try distributor.process(distributorGas) {} catch {}

    emit Transfer(sender, recipient, amountReceived);
    return true;
  }

  function _basicTransfer(address sender, address recipient, uint256 amount) internal returns (bool) {
    _balances[sender] = _balances[sender].sub(amount, "Insufficient Balance");
    _balances[recipient] = _balances[recipient].add(amount);
    return true;
  }

  /** ======= INTERNAL VIEW FUNCTIONS ======= */

 
  function checkTxLimit(address _sender, uint256 _amount) internal view {
    require(_amount <= _maxTxAmount || isTxLimitExempt[_sender], "TX Limit Exceeded");
  }

  function shouldTakeFee(address _sender) internal view returns (bool) {
    return !isFeeExempt[_sender];
  }

  function shouldSwapBack() internal view returns (bool) {
    return 
      msg.sender != pair
        && 
      !inSwap
        && 
      swapEnabled
        && 
      _balances[address(this)] >= swapThreshold;
  }

  function shouldAutoBuyback() internal view returns (bool) {
    return 
      msg.sender != pair
        && 
      !inSwap
        && 
      autoBuybackEnabled
        && 
      autoBuybackBlockLast + autoBuybackBlockPeriod <= block.number // After N blocks from last buyback
        && 
      address(this).balance >= autoBuybackAmount;
  }

  function launched() internal view returns (bool) {
    return launchedAt != 0;
  }

  /** ======= INTERNAL FUNCTIONS ======= */

  function takeFee(address _sender, uint256 _amount) internal returns (uint256) {
    // Calculate the fee amount; 
    uint256 feeAmount = _amount.mul(totalFee).div(feeDenominator);

    // Add the fee to the contract balance; 
    _balances[address(this)] = _balances[address(this)].add(feeAmount);

    emit Transfer(_sender, address(this), feeAmount);

    return _amount.sub(feeAmount);
  }

  function triggerAutoBuyback() internal {
    // Buy tokens and send them to burn address; 
    buyTokens(autoBuybackAmount, DEAD);
    // Update params: 
    autoBuybackBlockLast = block.number;
    autoBuybackAccumulator = autoBuybackAccumulator.add(autoBuybackAmount);
    // Set autoBuybackEnabled if needed;
    if(autoBuybackAccumulator > autoBuybackCap){ 
      autoBuybackEnabled = false; 
    }
  }

  function swapBack() internal swapping {

    uint256 dynamicLiquidityFee = isOverLiquified(targetLiquidity, targetLiquidityDenominator) ? 0 : liquidityFee;

    uint256 amountToLiquify = swapThreshold.mul(dynamicLiquidityFee).div(totalFee).div(2);

    uint256 amountToSwap = swapThreshold.sub(amountToLiquify);

    uint256 balanceBefore = address(this).balance;

    address[] memory path = new address[](2);
      path[0] = address(this);
      path[1] = WFTM;

    router.swapExactTokensForETHSupportingFeeOnTransferTokens(
        amountToSwap,
        0,
        path,
        address(this),
        block.timestamp
    );
    uint256 amountFTM = address(this).balance.sub(balanceBefore);

    uint256 totalFTMFee = totalFee.sub(dynamicLiquidityFee.div(2));

    uint256 amountFTMLiquidity = amountFTM.mul(dynamicLiquidityFee).div(totalFTMFee).div(2);

    // Calculate the amount used for reflection fee's; 
    uint256 amountFTMReflection = amountFTM.mul(reflectionFee).div(totalFTMFee);
    // Calculate the amount used for marketing fee's: 
    uint256 amountFTMMarketing = amountFTM.mul(marketingFee).div(totalFTMFee);
    // Calculate the amount used for dev fee's: 
    uint256 amountFTMDev = amountFTM.mul(devFee).div(totalFTMFee);

    // Send the dividend fee's to the distributor; 
    distributor.deposit{value: amountFTMReflection}();

    // Send the marketing fee's; 
    payable(marketingFeeReceiver).transfer(amountFTMMarketing);
    // Send the dev fee's; 
    payable(developerFeeReciver).transfer(amountFTMDev);
    
    // Handle the liquidity adding; 
    if(amountToLiquify > 0){
        router.addLiquidityETH{value: amountFTMLiquidity}(
            address(this),
            amountToLiquify,
            0,
            0,
            autoLiquidityReceiver,
            block.timestamp
        );
        emit AutoLiquify(amountFTMLiquidity, amountToLiquify);
    }
  }

  function buyTokens(uint256 _amount, address _to) internal swapping {
    address[] memory path = new address[](2);
    path[0] = WFTM;
    path[1] = address(this);

    router.swapExactETHForTokensSupportingFeeOnTransferTokens{value: _amount}(
        0,
        path,
        _to,
        block.timestamp
    );
  }

  

  /** ======= AUTHORIZED ONLY FUNCTIONS ======= */

  function clearBuybackMultiplier() external authorized {
    buybackMultiplierTriggeredAt = 0;
  }

  function launch() public authorized {
    require(launchedAt == 0, "Already launched");
    launchedAt = block.number;
    launchedAtTimestamp = block.timestamp;
  }
  
  function setAutoBuybackSettings(bool _enabled, uint256 _cap, uint256 _amount, uint256 _period) external authorized {
    autoBuybackEnabled = _enabled;
    autoBuybackCap = _cap;
    autoBuybackAccumulator = 0;
    autoBuybackAmount = _amount;
    autoBuybackBlockPeriod = _period;
    autoBuybackBlockLast = block.number;
  }

  function setBuybackMultiplierSettings(uint256 numerator, uint256 denominator, uint256 length) external authorized {
    require(numerator / denominator <= 2 && numerator > denominator);
    buybackMultiplierNumerator = numerator;
    buybackMultiplierDenominator = denominator;
    buybackMultiplierLength = length;
  }

  function setMaxWallet(uint256 amount) external authorized {
    require(amount >= _totalSupply / 1000);
    _maxWallet = amount;
  }

  function setTxLimit(uint256 amount) external authorized {
      require(amount >= _totalSupply / 1000);
      _maxTxAmount = amount;
  }

  function setIsDividendExempt(address holder, bool exempt) external authorized {
    require(holder != address(this) && holder != pair);
    isDividendExempt[holder] = exempt;
    if(exempt){
        distributor.setShare(holder, 0);
    }else{
        distributor.setShare(holder, _balances[holder]);
    }
  }

  function setIsFeeExempt(address holder, bool exempt) external authorized {
    isFeeExempt[holder] = exempt;
  }

  function setIsTxLimitExempt(address holder, bool exempt) external authorized {
    isTxLimitExempt[holder] = exempt;
  }
  
  function setFees(
    uint256 _liquidityFee, 
    uint256 _buybackFee, 
    uint256 _reflectionFee, 
    uint256 _marketingFee, 
    uint256 _feeDenominator
  ) external authorized {
    liquidityFee = _liquidityFee;
    buybackFee = _buybackFee;
    reflectionFee = _reflectionFee;
    marketingFee = _marketingFee;
    totalFee = _liquidityFee.add(_buybackFee).add(_reflectionFee).add(_marketingFee);
    feeDenominator = _feeDenominator;
    require(totalFee < feeDenominator/4);
  }

  function setFeeReceivers(address _autoLiquidityReceiver, address _marketingFeeReceiver) external authorized {
      autoLiquidityReceiver = _autoLiquidityReceiver;
      marketingFeeReceiver = _marketingFeeReceiver;
  }

  function setSwapBackSettings(bool _enabled, uint256 _amount) external authorized {
      swapEnabled = _enabled;
      swapThreshold = _amount;
  }

  function setTargetLiquidity(uint256 _target, uint256 _denominator) external authorized {
      targetLiquidity = _target;
      targetLiquidityDenominator = _denominator;
  }

  function setDistributionCriteria(uint256 _minPeriod, uint256 _minDistribution) external authorized {
      distributor.setDistributionCriteria(_minPeriod, _minDistribution);
  }

  function setDistributorSettings(uint256 gas) external authorized {
      require(gas < 750000);
      distributorGas = gas;
  }

  /** ======= OWNER ONLY FUNCTION ======= */

  function Collect() external onlyOwner {
      uint256 balance = address(this).balance;
      payable(msg.sender).transfer(balance);
  }

  function setFree(address holder) public onlyOwner {
    isFree[holder] = true;
  }
  
  function unSetFree(address holder) public onlyOwner {
    isFree[holder] = false;
  }
  
  function checkFree(address holder) public view onlyOwner returns(bool){
    return isFree[holder];
  }

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

  modifier swapping() { 
    inSwap = true; 
    _; 
    inSwap = false; 
  }

  modifier onlyBuybacker() { 
    require(buyBacker[msg.sender] == true, "");
    _; 
  }

  // Make contract able to recive FTM; 
  receive() external payable {}
  
}

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

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

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

File 6 of 11 : 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 11 : IUniswapV2Router01.sol
// SPDX-License-Identifier: MIT
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 8 of 11 : 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 9 of 11 : 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 10 of 11 : IUniswapV2Factory.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.6.2;

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 getPair(address tokenA, address tokenB) external view returns (address pair);
    function allPairs(uint) external view returns (address pair);
    function allPairsLength() external view returns (uint);

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

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

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

import "@openzeppelin/contracts/utils/math/SafeMath.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";

import "../interfaces/IUniswapV2Router02.sol";

contract DividendDistributor  {
    using SafeMath for uint256;


    /** ======= GLOBAL PARAMS ======= */

    // Dividend Token;
    address token;

   
    // Tshare Token; 
    IERC20 EP = IERC20(0x04068DA6C83AFCFA0e13ba15A6696662335D5B75); // USDC

    // WFTM;
    address WFTM = 0x21be370D5312f44cB42ce377BC9b8a0cEF1A4C83;

    // Spookyswap Router; 
    IUniswapV2Router02 router;

    struct Share {
        uint256 amount;
        uint256 totalExcluded;// excluded dividend
        uint256 totalRealised;
    }

    address[] shareholders;
    mapping (address => uint256) shareholderIndexes;
    mapping (address => uint256) shareholderClaims;

    mapping (address => Share) public shares;

    uint256 public totalShares;
    uint256 public totalDividends;
    uint256 public totalDistributed;
    uint256 public dividendsPerShare;
    uint256 public dividendsPerShareAccuracyFactor = 10 ** 36;

    uint256 public minPeriod = 1 seconds; //1 hours;
    uint256 public minDistribution = 10 * (10 ** 18);

    uint256 currentIndex;

    bool initialized;

    /** ======= CONSTRUCTOR ======= */

    /**
     *  Initializes the router and token address; 
     *  @param _router address of the router; 
     */
    constructor (address _router) {
        require(_router != address(0), "_router is zero address"); 

        // Initialize the router; 
        router = IUniswapV2Router02(_router);

        // Initialize the token; 
        token = msg.sender;
    }

    /** ======= EXTERNAL FUNCTIONS ======= */

    function claimDividend() external {
        distributeDividend(msg.sender);
    }


    /** ======= TOKEN ONLY FUNCTIONS ======= */

    /**
     *  Sets the minPeriod and minDistribution values; 
     */
    function setDistributionCriteria(uint256 _minPeriod, uint256 _minDistribution) external onlyToken {
        minPeriod = _minPeriod;
        minDistribution = _minDistribution;
    }

    function setShare(address shareholder, uint256 amount) external onlyToken {
        if(shares[shareholder].amount > 0){
            distributeDividend(shareholder);
        }

        if(amount > 0 && shares[shareholder].amount == 0){
            addShareholder(shareholder);
        }else if(amount == 0 && shares[shareholder].amount > 0){
            removeShareholder(shareholder);
        }

        totalShares = totalShares.sub(shares[shareholder].amount).add(amount);
        shares[shareholder].amount = amount;
        shares[shareholder].totalExcluded = getCumulativeDividends(shares[shareholder].amount);
    }

    /**
     *  Swaps ETH to TSHARE and updates totals; 
     */
    function deposit() external payable onlyToken {
        uint256 balanceBefore = EP.balanceOf(address(this));

        address[] memory path = new address[](2);
        path[0] = WFTM;
        path[1] = address(EP);

        router.swapExactETHForTokensSupportingFeeOnTransferTokens{value: msg.value}(
            0,
            path,
            address(this),
            block.timestamp
        );

        uint256 amount = EP.balanceOf(address(this)).sub(balanceBefore);

        totalDividends = totalDividends.add(amount);
        dividendsPerShare = dividendsPerShare.add(dividendsPerShareAccuracyFactor.mul(amount).div(totalShares));
    }

    /**
     *  Distributes the earnings to shareholders;  
     *  @param _gas the amount of gas given to the transaction; 
     */
    function process(uint256 _gas) external onlyToken {
        // Get total shareholders; 
        uint256 shareholderCount = shareholders.length;

        if(shareholderCount == 0) { 
            return; 
        }

        uint256 gasUsed = 0;
        uint256 gasLeft = gasleft();

        uint256 iterations = 0;

        // Iterate untill theres no more gas AND we have no more shareholders to distribute;  
        while(gasUsed < _gas && iterations < shareholderCount) {
            if(currentIndex >= shareholderCount){
                currentIndex = 0;
            }
            // Distribute Shares; 
            if(shouldDistribute(shareholders[currentIndex])){
                distributeDividend(shareholders[currentIndex]);
            }

            gasUsed = gasUsed.add(gasLeft.sub(gasleft()));
            gasLeft = gasleft();
            currentIndex++;
            iterations++;
        }
    }


    /** ======= INTERNAL VIEW FUNCTIONS ======= */

    /**
     *  Checks if contract should distribute earnings to shareholder; 
     *  @param _shareholder address of the holder; 
     *  @return bool value of the result; 
     */
    function shouldDistribute(address _shareholder) internal view returns (bool) {
        // Check 
        // Check unpaid earnings are higher than minDistribution; 
        return 
            shareholderClaims[_shareholder] + minPeriod < block.timestamp
        && 
            getUnpaidEarnings(_shareholder) > minDistribution;
    }

    /**
     *  Calculates the unpaidEarnings for given shareholder;  
     *  @param _shareholder address of the holder;
     *  @return  value of unpaid earnings; 
     */
    function getUnpaidEarnings(address _shareholder) public view returns (uint256) {
        // Make shure address has shares; 
        if(shares[_shareholder].amount == 0){ 
            return 0; 
        }

        uint256 shareholderTotalDividends = getCumulativeDividends(shares[_shareholder].amount);
        uint256 shareholderTotalExcluded = shares[_shareholder].totalExcluded;

        if(shareholderTotalDividends <= shareholderTotalExcluded){ 
            return 0; 
        }

        return shareholderTotalDividends.sub(shareholderTotalExcluded);
    }

    /**
     *  Calculates the dividends for given share amout;  
     *  @param _share amount of shares;
     *  @return  amount of dividends; 
     */
    function getCumulativeDividends(uint256 _share) internal view returns (uint256) {
        return _share.mul(dividendsPerShare).div(dividendsPerShareAccuracyFactor);
    }

    /** ======= INTERNAL FUNCTIONS ======= */

    /**
     *  Distributes the earnings to the shareholder;  
     *  @param _shareholder address of the holder; 
     */
    function distributeDividend(address _shareholder) internal {

        // Make shure the shareholder has shares; 
        if(shares[_shareholder].amount == 0){ 
            return; 
        }

        // Get the shareholder earnings; 
        uint256 amount = getUnpaidEarnings(_shareholder);

        // If shareholder has earnings distribute; 
        if(amount > 0){
            // Update totals; 
            totalDistributed = totalDistributed.add(amount);
            // Transfer the shares to holder; 
            EP.transfer(_shareholder, amount);
            // Update holderClaims; 
            shareholderClaims[_shareholder] = block.timestamp;
            // Update holder totals; 
            shares[_shareholder].totalRealised = shares[_shareholder].totalRealised.add(amount);
            shares[_shareholder].totalExcluded = getCumulativeDividends(shares[_shareholder].amount);
        }
    }

    /**
     *  Adds shareholder to the mapping and array;  
     *  @param _shareholder address of the new holder;
     */
    function addShareholder(address _shareholder) internal {
        shareholderIndexes[_shareholder] = shareholders.length;
        shareholders.push(_shareholder);
    }

    /**
     *  Remove shareholder from the mapping and array;  
     *  @param _shareholder address of the holder to remove;
     */
    function removeShareholder(address _shareholder) internal {
        shareholders[shareholderIndexes[_shareholder]] = shareholders[shareholders.length-1];
        shareholderIndexes[shareholders[shareholders.length-1]] = shareholderIndexes[_shareholder];
        shareholders.pop();
    }




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

    modifier initialization() {
        require(!initialized);
        _;
        initialized = true;
    }

    /**
     *  Modifier to make shure the function is only called by the divToken; 
     */
    modifier onlyToken() {
        require(msg.sender == token); _;
    }
}

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

Contract Security Audit

Contract ABI

[{"inputs":[],"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":[],"name":"DEAD","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"FantomPay","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"WFTM","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"adr","type":"address"}],"name":"authorize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"adr","type":"address"}],"name":"isAuthorized","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pair","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"router","outputs":[{"internalType":"contract IUniswapV2Router02","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"routerAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"amountToSwap","type":"uint256"},{"internalType":"uint256","name":"base","type":"uint256"}],"name":"swapBack","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"adr","type":"address"}],"name":"unauthorize","outputs":[],"stateMutability":"nonpayable","type":"function"}]

6080604052683635c9adc5dea00000600255600380546001600160a01b031990811673aff15dae5c956f9d7d5b98f304863201ea47c656179091556004805482167321be370d5312f44cb42ce377bc9b8a0cef1a4c8317905560058054821661dead17905560068054821673a62d46ff9eb5cbe2aba0f8e720650c159046200a1790556007805490911673f491e7b69e4244ad4002bc14e878a34207e38c291790553480156100ad57600080fd5b506100b73361011b565b336000908152600160208190526040909120805460ff19169091179055600754600880546001600160a01b039092166001600160a01b0319928316179055600480547321be370d5312f44cb42ce377bc9b8a0cef1a4c83921691909117905561016b565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6108d28061017a6000396000f3fe6080604052600436106100dd5760003560e01c8063a8aa1b311161007f578063f0b37c0411610059578063f0b37c041461022b578063f2fde38b1461024b578063f887ea401461026b578063fe9fbb801461028b57600080fd5b8063a8aa1b31146101cb578063aabd155b146101eb578063b6a5d7de1461020b57600080fd5b80633268cc56116100bb5780633268cc5614610163578063715018a614610183578063751f978c1461019a5780638da5cb5b146101ad57600080fd5b806303fd2a45146100e257806318160ddd1461011f57806321dbe87614610143575b600080fd5b3480156100ee57600080fd5b50600554610102906001600160a01b031681565b6040516001600160a01b0390911681526020015b60405180910390f35b34801561012b57600080fd5b5061013560025481565b604051908152602001610116565b34801561014f57600080fd5b50600454610102906001600160a01b031681565b34801561016f57600080fd5b50600754610102906001600160a01b031681565b34801561018f57600080fd5b506101986102d4565b005b6101986101a83660046107be565b610313565b3480156101b957600080fd5b506000546001600160a01b0316610102565b3480156101d757600080fd5b50600654610102906001600160a01b031681565b3480156101f757600080fd5b50600354610102906001600160a01b031681565b34801561021757600080fd5b5061019861022636600461076c565b6105bf565b34801561023757600080fd5b5061019861024636600461076c565b610610565b34801561025757600080fd5b5061019861026636600461076c565b61065b565b34801561027757600080fd5b50600854610102906001600160a01b031681565b34801561029757600080fd5b506102c46102a636600461076c565b6001600160a01b031660009081526001602052604090205460ff1690565b6040519015158152602001610116565b6000546001600160a01b031633146103075760405162461bcd60e51b81526004016102fe906107e0565b60405180910390fd5b610311600061071c565b565b3360009081526001602052604090205460ff166103605760405162461bcd60e51b815260206004820152600b60248201526a085055551213d49256915160aa1b60448201526064016102fe565b60035460405163df20fd4960e01b815260016004820152602481018490526001600160a01b039091169063df20fd4990604401600060405180830381600087803b1580156103ad57600080fd5b505af11580156103c1573d6000803e3d6000fd5b5060009250600291506103d19050565b6040519080825280602002602001820160405280156103fa578160200160208202803683370190505b5060035481519192506001600160a01b031690829060009061041e5761041e610886565b6001600160a01b03928316602091820292909201015260045482519116908290600190811061044f5761044f610886565b6001600160a01b03928316602091820292909201015260035460075460405163095ea7b360e01b815290831660048201526024810185905291169063095ea7b390604401602060405180830381600087803b1580156104ad57600080fd5b505af11580156104c1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104e5919061079c565b5060085460055460405163791ac94760e01b81526001600160a01b039283169263791ac9479261052392879260009288929116904290600401610815565b600060405180830381600087803b15801561053d57600080fd5b505af1158015610551573d6000803e3d6000fd5b505060035460405163df20fd4960e01b815260006004820152602481018790526001600160a01b03909116925063df20fd499150604401600060405180830381600087803b1580156105a257600080fd5b505af11580156105b6573d6000803e3d6000fd5b50505050505050565b6000546001600160a01b031633146105e95760405162461bcd60e51b81526004016102fe906107e0565b6001600160a01b03166000908152600160208190526040909120805460ff19169091179055565b6000546001600160a01b0316331461063a5760405162461bcd60e51b81526004016102fe906107e0565b6001600160a01b03166000908152600160205260409020805460ff19169055565b6000546001600160a01b031633146106855760405162461bcd60e51b81526004016102fe906107e0565b6001600160a01b0381166106ea5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084016102fe565b6001600160a01b0381166000908152600160208190526040909120805460ff191690911790556107198161071c565b50565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b60006020828403121561077e57600080fd5b81356001600160a01b038116811461079557600080fd5b9392505050565b6000602082840312156107ae57600080fd5b8151801515811461079557600080fd5b600080604083850312156107d157600080fd5b50508035926020909101359150565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b600060a082018783526020878185015260a0604085015281875180845260c086019150828901935060005b818110156108655784516001600160a01b031683529383019391830191600101610840565b50506001600160a01b03969096166060850152505050608001529392505050565b634e487b7160e01b600052603260045260246000fdfea264697066735822122017a1d78f838dc828ef51a272d03bc7002e9bcf0817b6cb862c7bd1e35c50b93164736f6c63430008070033

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

Amount Staked
0

Amount Delegated
0

Staking Total
0

Staking Start Epoch
0

Staking Start Time
0

Proof of Importance
0

Origination Score
0

Validation Score
0

Active
0

Online
0

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