# Huff Hackathon Project Ideas
## A Deterministic Address Contract Factory based on CREATE3
`CREATE3` is a combination of the `create` and `create2` opcode allowing contract deployments to deterministic addresses solely depending on a provided `salt`.
An immutable and permissionless `CREATE3`-based factory deployed on many chains to the same address (e.g. via [Nick's method](https://eips.ethereum.org/EIPS/eip-1820#single-use-registry-deployment-account)) could provide some real value.
Some contracts to get inspired from:
- Chronicle Protocol's [`Greenhouse Factory`](https://github.com/chronicleprotocol/greenhouse)
- Arachnid's [`Deterministic Contract Factory`](https://github.com/Arachnid/deterministic-deployment-proxy/tree/master)
## Efficient ECC Addition for Public Key Aggregation
Aggregating public keys is a necessary operation to verify Schnorr multi signatures.
Chronicle Protocol's [`Scribe`]() contract was the first to optimize this expensive operation enough to open the door to Schnorr signatures on EVM chains.
However, lots of optimizations are still possible! Maybe even via a dedicated, public goods, "Public Key Aggregator" contract?
Scribe's `LibSecp256k1` library: https://github.com/chronicleprotocol/scribe/blob/main/src/libs/LibSecp256k1.sol
Scribe's `LibSchnorr` library: https://github.com/chronicleprotocol/scribe/blob/main/src/libs/LibSchnorr.sol
Eth Magician post providing more context: https://ethereum-magicians.org/t/an-efficient-schnorr-multi-signature-implementation/15510
## MakerDAO's `Median` Oracle
Optimizing the gas costs of updating the oracle's value is of utmost importance for oracle providers due to the frequency of the updates.
Also, the `Median` contract is conceptually quite simple. The update function, called `poke`, receives a set of ECDSA signed `(value, timestamp)` tuples and sets the oracle's value to their median. After verifying each signature of course ;)
Repo link: https://github.com/makerdao/median/blob/master/src/median.sol
Disclaimer: The `Median` contract is in the process of being deprecated and an optimized Huff version __will not__ be commercially used by MakerDAO.
## UniswapV4 Hooks
A lot is possible here. Maybe a pool that arbitrages itself after a trade?
## Foundry Cheatcode Macros
Wrapper over commonly used cheatcodes in foundry tests such as:
- timestamp setter (warp)
- caller setter (prank)
- call external commands (ffi)
- assertions (assertEq, etc)
- breakpoint (breakpoint)
## Macro Expansion Tooling
Perform partial compilation, expanding macros in place.
before:
```huff
#define macro SAFE_ADD() = takes (2) returns (1) {
// takes: // [a, b]
dup2
add
swap1
dup2
lt
iszero
no_overflow
jumpi
0x00 0x00 revert
no_overflow:
}
#define macro MAIN() = takes (0) returns (0) {
0x00 calldataload
0x20 calldataload
SAFE_ADD()
0x00 mstore
0x00 0x20 return
}
```
after:
```huff
#define macro MAIN() = takes (0) returns (0) {
0x00 calldataload
0x20 calldataload
// macro SAFE_ADD() = takes (2) returns (1) {
dup2
add
swap1
dup2
lt
iszero
no_overflow
jumpi
0x00 0x00 revert
no_overflow:
// }
0x00 mstore
0x00 0x20 return
}
```