GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — EnCore/FeeApprover.sol at master · encorevault/EnCore Expand file tree/ Copy pathFeeApprover.solMore file actions 147 lines (120 loc) · 5.87 KB / Copy pathFeeApprover.solFile metadata and controls147 lines (120 loc) · 5.87 KB 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 // SPDX-License-Identifier: MIT pragma solidity ^0.6.0; import "@openzeppelin/contracts-ethereum-package/contracts/access/Ownable.sol"; import "@openzeppelin/contracts-ethereum-package/contracts/math/SafeMath.sol"; import "@openzeppelin/contracts-ethereum-package/contracts/token/ERC20/IERC20.sol"; // for WETH import "@nomiclabs/buidler/console.sol"; import '@uniswap/v2-core/contracts/interfaces/IUniswapV2Factory.sol'; import "@openzeppelin/contracts-ethereum-package/contracts/Initializable.sol"; contract FeeApprover is OwnableUpgradeSafe { using SafeMath for uint256; function initialize( address _ENCOREAddress, address _WETHAddress, address _uniswapFactory ) public initializer { OwnableUpgradeSafe.__Ownable_init(); encoreTokenAddress = _ENCOREAddress; WETHAddress = _WETHAddress; tokenETHPair = IUniswapV2Factory(_uniswapFactory).getPair(WETHAddress,encoreTokenAddress); feePercentX100 = 12; paused = true; sync(); //minFinney = 5000; } address tokenETHPair; address tokenLINKPair; IUniswapV2Factory public uniswapFactory; address internal WETHAddress; address encoreTokenAddress; address encoreVaultAddress; uint8 public feePercentX100; // max 255 = 25.5% artificial clamp uint256 public lastTotalSupplyOfLPTokens; bool paused; uint256 private lastSupplyOfEncoreInPair; uint256 private lastSupplyOfWETHInPair; address LGE; mapping (address => bool) public voidSenderList; mapping (address => bool) public voidReceiverList; mapping (address => bool) public discountFeeList; mapping (address => bool) public blockedReceiverList; function setPaused(bool _pause) public onlyOwner { paused = _pause; sync(); } function setFeeMultiplier(uint8 _feeMultiplier) public onlyOwner { feePercentX100 = _feeMultiplier; } function setEncoreVaultAddress(address _encoreVaultAddress) public onlyOwner { encoreVaultAddress = _encoreVaultAddress; voidSenderList[encoreVaultAddress] = true; } function editVoidSenderList(address _address, bool noFee) public onlyOwner{ voidSenderList[_address] = noFee; } function editDiscountFeeList(address _address, bool discFee) public onlyOwner{ discountFeeList[_address] = discFee; } function editBlockedReceiverList(address _address, bool _block) public onlyOwner{ blockedReceiverList[_address] = _block; } // uint minFinney; // 2x for $ liq amount // function setMinimumLiquidityToTriggerStop(uint finneyAmnt) public onlyOwner{ // 1000 = 1eth // minFinney = finneyAmnt; // } // function sync() public returns (bool lastIsMint, bool lpTokenBurn) { // // This will update the state of lastIsMint, when called publically // // So we have to sync it before to the last LP token value. // uint256 _LPSupplyOfPairTotal = IERC20(tokenUniswapPair).totalSupply(); // lpTokenBurn = lastTotalSupplyOfLPTokens > _LPSupplyOfPairTotal; // lastTotalSupplyOfLPTokens = _LPSupplyOfPairTotal; // uint256 _balanceWETH = IERC20(WETHAddress).balanceOf(tokenUniswapPair); // uint256 _balanceENCORE = IERC20(encoreTokenAddress).balanceOf(tokenUniswapPair); // // Do not block after small liq additions // // you can only withdraw 350$ now with front running // // And cant front run buys with liq add ( adversary drain ) // lastIsMint = _balanceENCORE > lastSupplyOfEncoreInPair && _balanceWETH > lastSupplyOfWETHInPair.add(minFinney.mul(1 finney)); // lastSupplyOfEncoreInPair = _balanceENCORE; // lastSupplyOfWETHInPair = _balanceWETH; // } uint256 internal _LPSupplyOfPairTotal; function sync() public { _LPSupplyOfPairTotal = IERC20(tokenETHPair).totalSupply(); } function calculateAmountsAfterFee( address sender, address recipient, // unusued maybe use din future uint256 amount ) public returns (uint256 transferToAmount, uint256 transferToFeeDistributorAmount) { require(paused == false, "FEE APPROVER: Transfers Paused"); sync(); // console.log("sender is " , sender); // console.log("recipient is is " , recipient, 'pair is :', tokenUniswapPair); // console.log("Old LP supply", lastTotalSupplyOfLPTokens); // console.log("Current LP supply", _LPSupplyOfPairTotal); if(sender == tokenETHPair) { require(lastTotalSupplyOfLPTokens <= _LPSupplyOfPairTotal, "Liquidity withdrawals forbidden"); //require(lastIsMint == false, "Liquidity withdrawals forbidden"); //require(lpTokenBurn == false, "Liquidity withdrawals forbidden"); } require(blockedReceiverList[recipient] == false, "Blocked Recipient"); if(sender == encoreVaultAddress || voidSenderList[sender]) { // Dont have a fee when encorevault is sending, or infinite loop console.log("Sending without fee"); transferToFeeDistributorAmount = 0; transferToAmount = amount; } else { if(discountFeeList[sender]) { // half fee if offered fee discount console.log("Discount fee transfer"); transferToFeeDistributorAmount = amount.mul(feePercentX100).div(2000); transferToAmount = amount.sub(transferToFeeDistributorAmount); } else { console.log("Normal fee transfer"); transferToFeeDistributorAmount = amount.mul(feePercentX100).div(1000); transferToAmount = amount.sub(transferToFeeDistributorAmount); } } lastTotalSupplyOfLPTokens = _LPSupplyOfPairTotal; } } |
| You are visitor 01402792 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |