Gas optimized fork - https://github.com/Tofunmi1/hats-contracts
- after adding optimizations =
6973951
- Use
++nonce
instead ofnonce++
(nonce is a state variable) - for calculations that wont overflow or underflow, use the
unchecked{}
block - making a privileged function payable would save gas
- for calculations that wont overflow or underflow, use the
unchecked{}
block
- for calculations that wont overflow or underflow, use the
unchecked{}
block
- making priviledged functions payable would save some gas
- aftter adding payable average cost is
458734
- saved 24 gas
- in
logclaim
payable(address).transfer(), would take a constant gas of21000
- use
address.call
instead
- use
-
use very efficient loops in
swapAndSend
, using unchecked increments, likeunchecked {++i;}
,and dont access an array's length in every iteration(cache the array's length in a local variable
The Hats protocol is designed to give white hats hackers the opportunity to gain more on their good behaviour and contribution. Trying to tilt the balance of incentives, and incentivizing more hackers to act responsively. It is doing so by letting projects publish on-chain bounties for their protocols, with committees in-charge of approving or rejecting claims. To further increase the efficiency of this model, the HAT token is introduced, to help bootstrap both ends in this two-sided market.
Installation:
npm install
Create .env
files as needed. There is a file called .env.example
that you can use as a template.
Run the tests:
npx hardhat test
Audit reports are in the audit directory.
Please report any security issues you find to contact@hats.finance
npx hardhat run --network {rinkeby|mainnet} scripts/checks/check.js
Hats.finance is released under the MIT License.