This contract was created as a mechanism for distributing native token assets received as validator rewards.
-
Collect initial contributions, track, and cap contributions to %. Then release to the collator custodian when allocation is met.
-
Separate deposit functions for custodian payouts and contributor deposits.
-
Gate deposits with allow-list so only defined participants can join.
-
Create withdrawal function of accrued collator upstart funds for collator custodian.
-
- Implement logic to verify that participants are also self-staking enough to the collator
- This will require PureStake to first give the go-ahead that it's okay for smart contracts to interact with precompiles.
+---------------------+----------------+----------------+----------------+---------------+
| File | % Lines | % Statements | % Branches | % Funcs |
+========================================================================================+
| src/ApeStrapper.sol | 41.89% (31/74) | 43.59% (34/78) | 33.33% (10/30) | 46.67% (7/15) |
|---------------------+----------------+----------------+----------------+---------------|
| Total | 41.89% (31/74) | 43.59% (34/78) | 33.33% (10/30) | 46.67% (7/15) |
+---------------------+----------------+----------------+----------------+---------------+
src/ApeStrapper.sol 0.8.13
├── lib/openzeppelin-contracts/contracts/access/AccessControl.sol ^0.8.0
│ ├── lib/openzeppelin-contracts/contracts/access/IAccessControl.sol ^0.8.0
│ ├── lib/openzeppelin-contracts/contracts/utils/Context.sol ^0.8.0
│ ├── lib/openzeppelin-contracts/contracts/utils/Strings.sol ^0.8.0
│ └── lib/openzeppelin-contracts/contracts/utils/introspection/ERC165.sol ^0.8.0
│ └── lib/openzeppelin-contracts/contracts/utils/introspection/IERC165.sol ^0.8.0
├── lib/openzeppelin-contracts/contracts/access/IAccessControl.sol ^0.8.0
├── lib/openzeppelin-contracts/contracts/security/Pausable.sol ^0.8.0
│ └── lib/openzeppelin-contracts/contracts/utils/Context.sol ^0.8.0
└── lib/openzeppelin-contracts/contracts/security/ReentrancyGuard.sol ^0.8.0
test/ApeStrapper.t.sol >= 0.8 .13
├── lib/forge-std/src/Cheats.sol >=0.6.0 <0.9.0
│ ├── lib/forge-std/src/Storage.sol >=0.6.0 <0.9.0
│ │ └── lib/forge-std/src/Vm.sol >=0.6.0 <0.9.0
│ └── lib/forge-std/src/Vm.sol >=0.6.0 <0.9.0
├── lib/forge-std/src/console.sol >=0.4.22 <0.9.0
├── lib/forge-std/src/Utils.sol >=0.6.0 <0.9.0
│ └── lib/forge-std/src/console2.sol >=0.4.22 <0.9.0
├── lib/prb-test/src/PRBTest.sol >=0.8.0 <0.9.0
│ ├── lib/prb-test/src/Helpers.sol >=0.8.0 <0.9.0
│ └── lib/prb-test/src/Vm.sol >=0.8.0 <0.9.0
└── src/ApeStrapper.sol 0.8.13 (*)
+-----------------------+---------------------------------------------------+------+--------+-------+---------------------------------+
| Name | Type | Slot | Offset | Bytes | Contract |
+=====================================================================================================================================+
| _roles | mapping(bytes32 => struct AccessControl.RoleData) | 0 | 0 | 32 | src/ApeStrapper.sol:ApeStrapper |
|-----------------------+---------------------------------------------------+------+--------+-------+---------------------------------|
| _status | uint256 | 1 | 0 | 32 | src/ApeStrapper.sol:ApeStrapper |
|-----------------------+---------------------------------------------------+------+--------+-------+---------------------------------|
| _paused | bool | 2 | 0 | 1 | src/ApeStrapper.sol:ApeStrapper |
|-----------------------+---------------------------------------------------+------+--------+-------+---------------------------------|
| initialized | bool | 2 | 1 | 1 | src/ApeStrapper.sol:ApeStrapper |
|-----------------------+---------------------------------------------------+------+--------+-------+---------------------------------|
| initialNumberOfPayees | uint8 | 2 | 2 | 1 | src/ApeStrapper.sol:ApeStrapper |
|-----------------------+---------------------------------------------------+------+--------+-------+---------------------------------|
| apeAllocation | mapping(address => uint256) | 3 | 0 | 32 | src/ApeStrapper.sol:ApeStrapper |
|-----------------------+---------------------------------------------------+------+--------+-------+---------------------------------|
| apeApproved | mapping(address => bool) | 4 | 0 | 32 | src/ApeStrapper.sol:ApeStrapper |
|-----------------------+---------------------------------------------------+------+--------+-------+---------------------------------|
| apes | address[] | 5 | 0 | 32 | src/ApeStrapper.sol:ApeStrapper |
+-----------------------+---------------------------------------------------+------+--------+-------+---------------------------------+
Here's a list of the most frequently needed commands.
Build the contracts:
forge build
Delete the build artifacts and cache directories:
forge clean
Compile the contracts:
forge build
Deploy to Anvil:
forge script script/Foo.s.sol:FooScript --fork-url http://localhost:8545 \
--broadcast --private-key $PRIVATE_KEY
Instead of passing a private key you can use the following:
- install geth
- create a file
pk
with your priv key geth account import pk
(choose pw)geth account list
- set envvar ETH_KEYSTORE to new keystore path
shred -n 10 pk
Credit: https://twitter.com/devtooligan/status/1523716952421584899
For instructions on how to deploy to a testnet or mainnet, check out the Solidity Scripting tutorial.
Format the contracts with Prettier:
forge fmt
Get a gas report:
forge test --gas-report
Lint the contracts:
yarn lint
Run the tests:
forge test
Install and run slither static-analysis:
pip3 install slither-analyzer # Suggest installing a pyenv and using py3.9
slither src/ApeStrapper.sol --solc-remaps @openzeppelin/=lib/openzeppelin-contracts/
- Foundry piggybacks off git submodules to manage dependencies. There's a guide about how to work with dependencies in the book.
- You don't have to create a
.env
file, but filling in the environment variables may be useful when debugging and testing against a mainnet fork.
This template builds upon the frameworks and libraries mentioned above, so for details about their specific features, please consult their respective documentations.
For example, for Foundry, you can refer to the Foundry Book. You might be in particular interested in reading the Writing Tests guide.
This template comes with sensible default configurations in the following files:
├── .commitlintrc.yml
├── .editorconfig
├── .gitignore
├── .prettierignore
├── .prettierrc.yml
├── .solhintignore
├── .solhint.json
├── .yarnrc.yml
├── foundry.toml
└── remappings.txt
This template comes with GitHub Actions pre-configured. Your contracts will be linted and tested on every push and pull
request made to the main
branch.
You can edit the CI script in .github/workflows/ci.yml.
This template enforces the Conventional Commits standard for git commit messages. This is a lightweight convention that creates an explicit commit history, which makes it easier to write automated tools on top of.
This template uses Husky to run automated checks on commit messages, and Lint Staged to automatically format the code with Prettier when making a git commit.
To write a new test contract, you start by importing PRBTest and inherit from it in your test contract. PRBTest comes with a
pre-instantiated cheatcodes environment accessible via the vm
property. You can also use console.log, whose logs you can see in the terminal output by adding the -vvvv
flag.
This template comes with an example test contract Foo.t.sol.
- abigger87/femplate
- cleanunicorn/ethereum-smartcontract-template
- foundry-rs/forge-template
- FrankieIsLost/forge-template
A Foundry-based template for developing Solidity smart contracts, with sensible defaults.
- Forge: compile, test, fuzz, debug and deploy smart contracts
- PRBTest: modern collection of testing assertions and logging utilities
- Forge Std: collection of helpful contracts and cheatcodes for testing
- Solhint: code linter
- Prettier Plugin Solidity: code formatter