Skip to content

Commit

Permalink
documentation generation
Browse files Browse the repository at this point in the history
  • Loading branch information
Turupawn committed Feb 1, 2023
1 parent 02754ed commit 2d9183e
Show file tree
Hide file tree
Showing 13 changed files with 439 additions and 234 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ npx hardhat test
npx hardhat coverage
```

# 🗎 Generate Documentation

```
npx hardhat docgen
```

# 📝 Take note

* This contracts are based on OpenZeppelin libraries but changed `private` variables to `internal` for flexibility
Expand Down
28 changes: 28 additions & 0 deletions contracts/ERC20/BalancerV2FeeToken.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,35 @@ pragma solidity ^0.8.0;
import "./ERC20.sol";
import "./interfaces/BalancerInterfaces.sol";

/// @title ERC20 token that takes fees on P2P, buy and sell on Balancer and transfer them to a Vault.
/// @author Filosofía Codigo
/// @notice You can use this contract launch your own token or to study the Balancer ecosystem
/// @dev Based on top OpenZeppelin contracts but changed balances from private to internal for flexibility
/// @custom:experimental This is an experimental contract.
abstract contract BalancerV2FeeToken is ERC20
{
/// @notice List of address that won't pay transaction fees
mapping(address => bool) public isTaxless;
/// @notice Address that will recieve fees taken from each transaction
address public feeReceiver;
/// @notice If set to true, no fees will be taken on any transaction
bool public isFeeActive;
/// @notice Array that defines the transactions fees. Index 0 is buy fee, 1 is sell fee and 2 is peer to peer fee
uint[] public fees;
/// @notice Number if fee decimals. Default is 2 so for example 250 means 2.5% in percentage numbers
uint public feeDecimals = 2;
/// @notice Balancer vault constant address
address public balancerVault = 0xBA12222222228d8Ba445958a75a0704d566BF2C8;

/// @notice Contract constructor
/// @dev All percentage numbers are two digit decimals. For example 250 means 2.5%
/// @param name Token Name
/// @param symbol Token Symbol
/// @param totalSupply_ Total supply, all supply will be sent to contract deployer
/// @param buyFeePercentage Percent of tokens that will be sent to the feeReciever when token is bought on Balancer
/// @param sellFeePercentage Percent of tokens that will be sent to the feeReciever when token is sold on Balancer
/// @param p2pFeePercentage Percent of tokens that will be sent to the feeReciever when token is transfered outside of Balancer
/// @param feeReceiver_ Address that will recieve the fees taken every transaction
constructor(string memory name, string memory symbol,
uint totalSupply_,
uint buyFeePercentage, uint sellFeePercentage, uint p2pFeePercentage,
Expand All @@ -35,6 +55,7 @@ abstract contract BalancerV2FeeToken is ERC20
isFeeActive = true;
}

/// @notice This functions is inherited from OpenZeppelin and implements the transaction fee distribution
function _transfer(
address from,
address to,
Expand All @@ -61,10 +82,17 @@ abstract contract BalancerV2FeeToken is ERC20
super._transfer(from, to, amount);
}

/// @notice Set excemptions for transaction fee payments
/// @param account Address that tax configuration will be affected
/// @param value If set to true the account will not pay transaction fees
/// @custom:ownable This function can only be executed by the contract owner.
function setTaxless(address account, bool value) external onlyOwner {
isTaxless[account] = value;
}

/// @notice Set excemptions for all transaction fee payments
/// @param value If set to true all transaction fees will not be charged
/// @custom:ownable This function can only be executed by the contract owner.
function setFeeActive(bool value) public onlyOwner {
isFeeActive = value;
}
Expand Down
Empty file removed docs/BalancerFeeToken.md
Empty file.
115 changes: 115 additions & 0 deletions docs/ERC20/BalancerV2FeeToken.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
# Solidity API

## BalancerV2FeeToken

You can use this contract launch your own token or to study the Balancer ecosystem

_Based on top OpenZeppelin contracts but changed balances from private to internal for flexibility_

### isTaxless

```solidity
mapping(address => bool) isTaxless
```

List of address that won't pay transaction fees

### feeReceiver

```solidity
address feeReceiver
```

Address that will recieve fees taken from each transaction

### isFeeActive

```solidity
bool isFeeActive
```

If set to true, no fees will be taken on any transaction

### fees

```solidity
uint256[] fees
```

Array that defines the transactions fees. Index 0 is buy fee, 1 is sell fee and 2 is peer to peer fee

### feeDecimals

```solidity
uint256 feeDecimals
```

Number if fee decimals. Default is 2 so for example 250 means 2.5% in percentage numbers

### balancerVault

```solidity
address balancerVault
```

Balancer vault constant address

### constructor

```solidity
constructor(string name, string symbol, uint256 totalSupply_, uint256 buyFeePercentage, uint256 sellFeePercentage, uint256 p2pFeePercentage, address feeReceiver_) internal
```

Contract constructor

_All percentage numbers are two digit decimals. For example 250 means 2.5%_

#### Parameters

| Name | Type | Description |
| ---- | ---- | ----------- |
| name | string | Token Name |
| symbol | string | Token Symbol |
| totalSupply_ | uint256 | Total supply, all supply will be sent to contract deployer |
| buyFeePercentage | uint256 | Percent of tokens that will be sent to the feeReciever when token is bought on Balancer |
| sellFeePercentage | uint256 | Percent of tokens that will be sent to the feeReciever when token is sold on Balancer |
| p2pFeePercentage | uint256 | Percent of tokens that will be sent to the feeReciever when token is transfered outside of Balancer |
| feeReceiver_ | address | Address that will recieve the fees taken every transaction |

### _transfer

```solidity
function _transfer(address from, address to, uint256 amount) internal virtual
```

This functions is inherited from OpenZeppelin and implements the transaction fee distribution

### setTaxless

```solidity
function setTaxless(address account, bool value) external
```

Set excemptions for transaction fee payments

#### Parameters

| Name | Type | Description |
| ---- | ---- | ----------- |
| account | address | Address that tax configuration will be affected |
| value | bool | If set to true the account will not pay transaction fees |

### setFeeActive

```solidity
function setFeeActive(bool value) public
```

Set excemptions for all transaction fee payments

#### Parameters

| Name | Type | Description |
| ---- | ---- | ----------- |
| value | bool | If set to true all transaction fees will not be charged |

52 changes: 52 additions & 0 deletions docs/ERC20/UniswapV2AutoSwapToken.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Solidity API

## UniswapV2AutoSwapToken

### minTokensBeforeSwap

```solidity
uint256 minTokensBeforeSwap
```

### autoSwapReciever

```solidity
address autoSwapReciever
```

### lastFeeActive

```solidity
bool lastFeeActive
```

### Swap

```solidity
event Swap(uint256 amountSent)
```

### constructor

```solidity
constructor(string name, string symbol, uint256 totalSupply_, uint256 buyFeePercentage, uint256 sellFeePercentage, uint256 p2pFeePercentage, address autoSwapReciever_, address routerAddress, address baseTokenAddress, uint256 minTokensBeforeSwapPercent) internal
```

### lockTheSwap

```solidity
modifier lockTheSwap()
```

### _transfer

```solidity
function _transfer(address from, address to, uint256 amount) internal virtual
```

### setMinTokensBeforeSwapPercent

```solidity
function setMinTokensBeforeSwapPercent(uint256 percentage) public
```

94 changes: 94 additions & 0 deletions docs/ERC20/UniswapV2FeeToken.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
# Solidity API

## UniswapV2FeeToken

### isTaxless

```solidity
mapping(address => bool) isTaxless
```

### feeReceiver

```solidity
address feeReceiver
```

### isFeeActive

```solidity
bool isFeeActive
```

### fees

```solidity
uint256[] fees
```

### feeDecimals

```solidity
uint256 feeDecimals
```

### pair

```solidity
address pair
```

### router

```solidity
contract ISwapRouter router
```

### baseToken

```solidity
contract IERC20 baseToken
```

### constructor

```solidity
constructor(string name, string symbol, uint256 totalSupply_, uint256 buyFeePercentage, uint256 sellFeePercentage, uint256 p2pFeePercentage, address feeReceiver_, address routerAddress, address baseTokenAddress) internal
```

### _transfer

```solidity
function _transfer(address from, address to, uint256 amount) internal virtual
```

### _setTaxless

```solidity
function _setTaxless(address account, bool isTaxless_) internal
```

### _setFeeReceiver

```solidity
function _setFeeReceiver(address feeReceiver_) internal
```

### _setFeeActive

```solidity
function _setFeeActive(bool isFeeActive_) internal
```

### _setPair

```solidity
function _setPair(address router_, address baseToken_) internal
```

### _setFees

```solidity
function _setFees(uint256 buyFeePercentage, uint256 sellFeePercentage, uint256 p2pFeePercentage) internal
```

Loading

0 comments on commit 2d9183e

Please sign in to comment.