Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New ERC20 token #8

Open
wants to merge 32 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
07ef28a
Update node and use hardhat
Feb 5, 2023
f5ba935
Make contract upgradable and use snapshot, use deterministic deploy
Feb 5, 2023
1b2ef20
Remove from repo files that are in gitinore
Feb 5, 2023
ea24e71
Add batchMint add contractVersion
Feb 5, 2023
7b244ec
Compile fixes
Feb 6, 2023
d1ad92f
Fix env variables
Feb 6, 2023
2c5568d
Delte Vesting and PercentageCalculator
Feb 6, 2023
fecf09e
Use Fixture fore tests
Feb 6, 2023
4a5245a
Add more tests check size
Feb 6, 2023
6731e0a
Add missing test and configurations
Feb 7, 2023
bd853bc
Prettier fix
Feb 7, 2023
10a2379
Update readme
Feb 7, 2023
0a4e1a8
Remove unnecesary code
Feb 7, 2023
b4ed345
Remove forking
Feb 7, 2023
fa5fec4
Add burn tests, remove open zeppelin non upgradable
Feb 7, 2023
302628f
Added cap or maxTotalSupply
Xaleee Feb 7, 2023
0c2b952
Added revert test for cap reached
Xaleee Feb 7, 2023
533a62b
ABT-01C: Enhancement of State Validation
Feb 9, 2023
a2fbb60
Merge pull request #17 from Stichting-AllianceBlock-Foundation/ABT-01C
pmprete Feb 9, 2023
06d9297
[ABT-03C] Potential Batch Mint Optimization
Feb 9, 2023
1eff70f
Merge pull request #18 from Stichting-AllianceBlock-Foundation/abt-03c
pmprete Feb 9, 2023
972e764
ABT-02C: Loop Iterator Optimization
Feb 9, 2023
02bf906
Merge pull request #19 from Stichting-AllianceBlock-Foundation/ABT-02C
pmprete Feb 9, 2023
a543606
ABT-02M: Insufficient Prevention of Contract Token Ownership
Feb 9, 2023
56590af
Merge pull request #20 from Stichting-AllianceBlock-Foundation/ABT-02M
pmprete Feb 9, 2023
5673224
[ABT-01M] Inexistent Initialization Protection of Base Implementation
Feb 9, 2023
60a8c7e
Merge pull request #21 from Stichting-AllianceBlock-Foundation/ABT-01M
pmprete Feb 9, 2023
8beb0a0
[ABT-02S] Inexistent Sanitization of Input Addresses
Feb 9, 2023
95daefa
Merge pull request #22 from Stichting-AllianceBlock-Foundation/ABT-02S
pmprete Feb 9, 2023
64ce2b5
[ABT-02S] Inexistent Sanitization of Input Addresses
Feb 9, 2023
5bde836
Merge pull request #23 from Stichting-AllianceBlock-Foundation/ABT-01S
pmprete Feb 9, 2023
cba978d
Use initialized instead of init in the constructor
Feb 10, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# EditorConfig http://EditorConfig.org

# top-most EditorConfig file
root = true

# All files
[*]
charset = utf-8
end_of_line = lf
indent_size = 2
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true

[*.sol]
indent_size = 4
12 changes: 12 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
PRIVATE_KEY=<USE THIS OR MNEMONIC>
HDWALLET_MNEMONIC=<USE THIS OR PRIVATE KEY>
INFURA_API_KEY=
MULTISIG_ADDRESS=
SALT=
ETHERSCAN_API_KEY=
AVALANCHE_API_KEY=
OPTIMISM_API_KEY=
POLYGONSCAN_API_KEY=
ARBISCAN_API_KEY=
BSCSCAN_API_KEY=
GNOSIS_API_KEY=
25 changes: 23 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,25 @@
node_modules
build
.etherlime-store
coverage

node_modules
.env
.envrc
.npmrc
coverage
coverage.json
typechain
typechain-types
deployments/localhost/
yarn-error.log

#Hardhat files
cache
artifacts

abi/
package-lock.json
yarn.lock

.DS_Store
.vscode
hardhat-dependency-compiler
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
18
22 changes: 22 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# directories
.yarn/
**/.coverage_artifacts
**/.coverage_cache
**/.coverage_contracts
**/artifacts
**/build
**/cache
**/coverage
**/dist
**/node_modules
**/types
**/typechain-types

# files
*.env
*.log
.pnp.*
coverage.json
npm-debug.log*
yarn-debug.log*
yarn-error.log*
13 changes: 13 additions & 0 deletions .prettierrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
bracketSpacing: true
printWidth: 120
proseWrap: "always"
singleQuote: false
tabWidth: 2
trailingComma: "all"

overrides:
- files: "*.sol"
options:
compiler: "0.8.17"
tabWidth: 4
- files: "*.ts"
19 changes: 19 additions & 0 deletions .solhint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"extends": "solhint:recommended",
"plugins": ["prettier"],
"rules": {
"code-complexity": ["error", 8],
"compiler-version": ["error", ">=0.8.4"],
"func-visibility": ["error", { "ignoreConstructors": true }],
"max-line-length": ["error", 120],
"not-rely-on-time": "off",
"prettier/prettier": [
"error",
{
"endOfLine": "auto"
}
],
"reason-string": ["warn", { "maxLength": 64 }]
}
}

3 changes: 3 additions & 0 deletions .solhintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# directories
**/artifacts
**/node_modules
55 changes: 38 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,28 +1,49 @@
<h2 align="center">AllianceBlock Smart Contracts</h2>
# AllianceBlock Smart Contracts

## NXRA token contract
An upgradable ERC20 contract owned by a multi-signature wallet. Also, it allows creating snapshots, pausing it, support (EIP-2612)[https://eips.ethereum.org/EIPS/eip-2612] and batch minting.

### ALBT token contract
A standard ERC20 contract owned by a multisignature wallet
## Env variables
You will need to generate a .env file using .env.example as a boilerplate. PrivateKey or Mnemonic is necessary for live deployment but can be skipped for local development. SALT is needed for deterministic deployment, if none is provided it will use the default form constants.

### Vesting Smart Contract
Vesting smart contract able to handle vesting schedules for 24 months. Recipients withdraw amounts are presented as percentages, and vesting periods are presented with acumulative amounts of ALBT tokens.

### Percentage Calculator
Library used for more precise calculation of percentages
## Usage
Need node 18 installed and yarn.
First, install the dependencies
```bash
yarn install
```

### Batch Transfer Smart Contract
Contract handling batch transfers of ALBT tokens.
Then compile the contracts to get types from typechain
```bash
yarn compile
```

To run tests use
```bash
yarn test
```
It will also show gas used

## Usage
To check converage run
```bash
npm install
npm install -g etherlime
yarn coverage
```

# Compile
etherlime compile
## Deploy
To deploy use
```bash
yarn deploy <NetworkName>
```
Where NetworkName is one of the networks configured in (hardhat.networks.ts)[./hardhat.networks.ts]
Deployment is deterministic, this means that it can be precalculated and that it will have the same address across all chains.
**Important to keep the same address, SALT and BYTECODE must be the same, bytecode includes not just the compiled contracts, but the parameters used in the constructor as well**

# Deploy
etherlime deploy --network=<predefined-network> --secret=<your-private-key>
## Verification
The deployment script also verifies the smart contracts using `hardhat-etherscan`, but it needs the API KEY from the explorers, you will need to add them in the .env file.

If the network where you are deploying uses Blockscout, use Sourcify instead.
```bash
yarn hardhat --network <NetworkName> sourcify
```


Loading