Skip to content

Commit

Permalink
organized params
Browse files Browse the repository at this point in the history
  • Loading branch information
Turupawn committed Jan 31, 2023
1 parent 648d6aa commit 725d658
Show file tree
Hide file tree
Showing 21 changed files with 98 additions and 103 deletions.
24 changes: 12 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ contract MyUniswapV2FeeToken is UniswapV2FeeToken
constructor() UniswapV2FeeToken(
"My Token", "MTKN", // Name and Symbol
1_000_000_000 ether, // 1 billion supply
address(this), // Vault Address
100, 200, 0, // Fees: 2% buy 1% sell 0% P2P
0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D, // Router Address
0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48) // Base Token Address
100, 200, 50, // Fees: 1% buy 2% sell 0.5% P2P
msg.sender, // Fee Receiver
0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D, // Router Address: Uniswap V2
0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48) // Base Token Address: USDC
{
}
}
Expand All @@ -71,10 +71,10 @@ contract MyUniswapV2AutoSwapToken is UniswapV2AutoSwapToken
constructor() UniswapV2AutoSwapToken(
"My Token", "MTKN", // Name and Symbol
1_000_000_000 ether, // 1 billion supply
100, 200, 0, // Fees: 2% buy 1% sell 0% P2P
0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D, // Router Address
0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48, // Base Token Address
msg.sender, // AutoSwap Recipient
100, 200, 50, // Fees: 1% buy 2% sell 0.5% P2P
msg.sender, // AutoSwap Receiver
0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D, // Router Address: Uniswap V2
0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48, // Base Token Address: USDC
100) // 1% in tokens before swap percent
{
}
Expand All @@ -96,8 +96,8 @@ contract MyBalancerFeeToken is BalancerV2FeeToken
constructor() BalancerV2FeeToken(
"My Token", "MTKN", // Name and Symbol
1_000_000_000 ether, // 1 billion supply
address(this), // Vault Address
100, 200, 0) // Fees: 2% buy 1% sell 0% P2P
100, 200, 50, // Fees: 2% buy 1% sell 0.5% P2P
msg.sender) // Fee Receiver
{
}
}
Expand All @@ -118,10 +118,10 @@ contract MyUniswapV3FeeToken is UniswapV3FeeToken
constructor() UniswapV3FeeToken(
"My Token", "MTKN", // Name and Symbol
1_000_000_000 ether, // 1 billion supply
msg.sender, // Vault Address
100, 200, // Fees: 1% buy 2% P2P
msg.sender, // Vault Address
0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2, // Base token: WETH
1000) // Initial rate: 1 Base Tokens = 1000 tokens
1000) // Initial rate: 1 WETH = 1000 tokens
{
}
}
Expand Down
22 changes: 11 additions & 11 deletions contracts/ERC20/BalancerV2FeeToken.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,33 +4,33 @@
pragma solidity ^0.8.0;

import "./ERC20.sol";
import "./BalancerInterfaces.sol";
import "./interfaces/BalancerInterfaces.sol";

abstract contract BalancerV2FeeToken is ERC20
{
mapping(address => bool) public isTaxless;
address public tokenVaultAddress;
address public feeReceiver;
bool public isFeeActive;
uint[] public fees;
uint public feeDecimals = 2;
address public balancerVault = 0xBA12222222228d8Ba445958a75a0704d566BF2C8;

constructor(string memory name, string memory symbol,
uint totalSupply_,
address tokenVaultAddress_,
uint buyFee, uint sellFee, uint p2pFee)
uint buyFeePercentage, uint sellFeePercentage, uint p2pFeePercentage,
address feeReceiver_)
ERC20(name, symbol, totalSupply_)
{
tokenVaultAddress = tokenVaultAddress_;
feeReceiver = feeReceiver_;

isTaxless[msg.sender] = true;
isTaxless[address(this)] = true;
isTaxless[tokenVaultAddress] = true;
isTaxless[feeReceiver] = true;
isTaxless[address(0)] = true;

fees.push(buyFee);
fees.push(sellFee);
fees.push(p2pFee);
fees.push(buyFeePercentage);
fees.push(sellFeePercentage);
fees.push(p2pFeePercentage);

isFeeActive = true;
}
Expand All @@ -50,9 +50,9 @@ abstract contract BalancerV2FeeToken is ERC20

amount -= feesCollected;
_balances[from] -= feesCollected;
_balances[tokenVaultAddress] += feesCollected;
_balances[feeReceiver] += feesCollected;

emit Transfer(from, tokenVaultAddress, amount);
emit Transfer(from, feeReceiver, amount);

super._transfer(from, to, amount);
}
Expand Down
14 changes: 7 additions & 7 deletions contracts/ERC20/UniswapV2AutoSwapToken.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,30 @@
pragma solidity ^0.8.0;

import "./UniswapV2FeeToken.sol";
import "./UniswapV2Interfaces.sol";
import "./interfaces/UniswapV2Interfaces.sol";

abstract contract UniswapV2AutoSwapToken is UniswapV2FeeToken
{
uint256 public minTokensBeforeSwap;
address public autoSwapRecipient;
address public autoSwapReciever;
bool lastFeeActive;
event Swap(uint amountSent);

constructor(string memory name, string memory symbol,
uint totalSupply_,
uint buyFee, uint sellFee, uint p2pFee,
uint buyFeePercentage, uint sellFeePercentage, uint p2pFeePercentage,
address autoSwapReciever_,
address routerAddress,
address baseTokenAddress,
address autoSwapRecipient_,
uint minTokensBeforeSwapPercent) UniswapV2FeeToken(name, symbol,
totalSupply_,
buyFeePercentage, sellFeePercentage, p2pFeePercentage,
address(this),
buyFee, sellFee, p2pFee,
routerAddress,
baseTokenAddress
)
{
autoSwapRecipient = autoSwapRecipient_;
autoSwapReciever = autoSwapReciever_;
setMinTokensBeforeSwapPercent(minTokensBeforeSwapPercent);
}

Expand All @@ -52,7 +52,7 @@ abstract contract UniswapV2AutoSwapToken is UniswapV2FeeToken
totalSwap,
0,
sellPath,
autoSwapRecipient,
autoSwapReciever,
block.timestamp
);

Expand Down
18 changes: 9 additions & 9 deletions contracts/ERC20/UniswapV2FeeToken.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
pragma solidity ^0.8.0;

import "./ERC20.sol";
import "./UniswapV2Interfaces.sol";
import "./interfaces/UniswapV2Interfaces.sol";

abstract contract UniswapV2FeeToken is ERC20
{
mapping(address => bool) public isTaxless;
address public feeReceiverAddress;
address public feeReceiver;
bool public isFeeActive;
uint[] public fees;
uint public feeDecimals = 2;
Expand All @@ -20,20 +20,20 @@ abstract contract UniswapV2FeeToken is ERC20

constructor(string memory name, string memory symbol,
uint totalSupply_,
address feeReceiverAddress_,
uint buyFeePercentage, uint sellFeePercentage, uint p2pFeePercentage,
address feeReceiver_,
address routerAddress,
address baseTokenAddress) ERC20(name, symbol, totalSupply_)
{
router = ISwapRouter(routerAddress);
pair = ISwapFactory(router.factory()).createPair(address(this), baseTokenAddress);
baseToken = IERC20(baseTokenAddress);

feeReceiverAddress = feeReceiverAddress_;
feeReceiver = feeReceiver_;

isTaxless[msg.sender] = true;
isTaxless[address(this)] = true;
isTaxless[feeReceiverAddress] = true;
isTaxless[feeReceiver] = true;
isTaxless[address(0)] = true;

fees.push(buyFeePercentage);
Expand All @@ -59,9 +59,9 @@ abstract contract UniswapV2FeeToken is ERC20

amount -= feesCollected;
_balances[from] -= feesCollected;
_balances[feeReceiverAddress] += feesCollected;
_balances[feeReceiver] += feesCollected;

emit Transfer(from, feeReceiverAddress, amount);
emit Transfer(from, feeReceiver, amount);

super._transfer(from, to, amount);
}
Expand All @@ -71,9 +71,9 @@ abstract contract UniswapV2FeeToken is ERC20
isTaxless[account] = isTaxless_;
}

function _setFeeReceiverAddress(address feeReceiverAddress_) internal
function _setFeeReceiver(address feeReceiver_) internal
{
feeReceiverAddress = feeReceiverAddress_;
feeReceiver = feeReceiver_;
}

function _setFeeActive(bool isFeeActive_) internal
Expand Down
33 changes: 14 additions & 19 deletions contracts/ERC20/UniswapV3FeeToken.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
pragma solidity ^0.8.0;

import "./ERC20.sol";
import "./UniswapV3Interfaces.sol";
import "./interfaces/UniswapV3Interfaces.sol";

abstract contract UniswapV3FeeToken is ERC20
{
mapping(address => bool) public isTaxless;
address public tokenVaultAddress;
address public feeReceiver;
bool public isFeeActive;
uint buyFee;
uint p2pFee;
uint buyFeePercentage;
uint p2pFeePercentage;
uint public feeDecimals = 2;
IERC20 baseToken;
address public pool1;
Expand All @@ -25,26 +25,21 @@ abstract contract UniswapV3FeeToken is ERC20

constructor(string memory name, string memory symbol,
uint totalSupply_,
address tokenVaultAddress_,
uint buyFee_, uint p2pFee_,
uint buyFeePercentage_, uint p2pFeePercentage_,
address feeReceiver_,
address baseTokenAddress,
uint160 rate) ERC20(name, symbol, totalSupply_)
{
tokenVaultAddress = tokenVaultAddress_;
feeReceiver = feeReceiver_;
baseToken = IERC20(baseTokenAddress);

isTaxless[msg.sender] = true;
isTaxless[address(this)] = true;
isTaxless[tokenVaultAddress] = true;
isTaxless[feeReceiver] = true;
isTaxless[address(0)] = true;

p2pFee = p2pFee_;
buyFee = buyFee_;

isTaxless[msg.sender] = true;
isTaxless[address(this)] = true;
isTaxless[tokenVaultAddress] = true;
isTaxless[address(0)] = true;
p2pFeePercentage = p2pFeePercentage_;
buyFeePercentage = buyFeePercentage_;

address token0;
address token1;
Expand Down Expand Up @@ -106,18 +101,18 @@ abstract contract UniswapV3FeeToken is ERC20
if (!isTaxless[from] && !isTaxless[to]) {
if(isPool(from))
{
feesCollected = (amount * buyFee) / (10**(feeDecimals + 2));
feesCollected = (amount * buyFeePercentage) / (10**(feeDecimals + 2));
}else if(!isPool(to))
{
feesCollected = (amount * p2pFee) / (10**(feeDecimals + 2));
feesCollected = (amount * p2pFeePercentage) / (10**(feeDecimals + 2));
}
}

amount -= feesCollected;
_balances[from] -= feesCollected;
_balances[tokenVaultAddress] += feesCollected;
_balances[feeReceiver] += feesCollected;

emit Transfer(from, tokenVaultAddress, amount);
emit Transfer(from, feeReceiver, amount);

super._transfer(from, to, amount);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

pragma solidity ^0.8.0;

import "./ERC20.sol";
import "../ERC20.sol";

struct JoinPoolRequest {
address[] assets;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

pragma solidity ^0.8.0;

import "./ERC20.sol";
import "../ERC20.sol";

interface IWETH is IERC20 {
function deposit() external payable;
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.17;

import "../ERC20/BalancerV2FeeToken.sol";
import "../../ERC20/BalancerV2FeeToken.sol";

contract MyBalancerFeeToken is BalancerV2FeeToken
{
constructor() BalancerV2FeeToken(
"My Token", "MTKN", // Name and Symbol
1_000_000_000 ether, // 1 billion supply
address(this), // Vault Address
100, 200, 50) // Fees: 2% buy 1% sell 0.5% P2P
100, 200, 50, // Fees: 2% buy 1% sell 0.5% P2P
msg.sender) // Fee Receiver
{
}
}
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.17;

import "../ERC20/UniswapV2AutoSwapToken.sol";
import "../../ERC20/UniswapV2AutoSwapToken.sol";

contract MyUniswapV2AutoSwapToken is UniswapV2AutoSwapToken
{
constructor() UniswapV2AutoSwapToken(
"My Token", "MTKN", // Name and Symbol
1_000_000_000 ether, // 1 billion supply
100, 200, 50, // Fees: 1% buy 2% sell 0.5% P2P
0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D, // Router Address
msg.sender, // AutoSwap Receiver
0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D, // Router Address: Uniswap V2
0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48, // Base Token Address: USDC
msg.sender, // AutoSwap Recipient
100) // 1% in tokens before swap percent
{
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.17;

import "../ERC20/UniswapV2FeeToken.sol";
import "../../ERC20/UniswapV2FeeToken.sol";

contract MyUniswapV2FeeToken is UniswapV2FeeToken
{
constructor() UniswapV2FeeToken(
"My Token", "MTKN", // Name and Symbol
1_000_000_000 ether, // 1 billion supply
msg.sender, // Vault Address
100, 200, 50, // Fees: 1% buy 2% sell 0.5% P2P
0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D, // Router Address
msg.sender, // Fee Receiver
0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D, // Router Address: Uniswap V2
0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48) // Base Token Address: USDC
{
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.17;

import "../ERC20/UniswapV3FeeToken.sol";
import "../../ERC20/UniswapV3FeeToken.sol";

contract MyUniswapV3FeeToken is UniswapV3FeeToken
{
constructor() UniswapV3FeeToken(
"My Token", "MTKN", // Name and Symbol
1_000_000_000 ether, // 1 billion supply
msg.sender, // Vault Address
100, 200, // Fees: 1% buy 2% P2P
msg.sender, // Vault Address
0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2, // Base token: WETH
1000) // Initial rate: 1 Base Tokens = 1000 tokens
1000) // Initial rate: 1 WETH = 1000 tokens
{
}
}
Loading

0 comments on commit 725d658

Please sign in to comment.