https://github.com/pooltogether/v4-timelocks
Timelock contracts for v4 contracts
https://github.com/pooltogether/v4-timelocks
Last synced: 19 days ago
JSON representation
Timelock contracts for v4 contracts
- Host: GitHub
- URL: https://github.com/pooltogether/v4-timelocks
- Owner: pooltogether
- License: gpl-3.0
- Created: 2021-09-20T22:58:03.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2022-02-08T00:45:13.000Z (over 4 years ago)
- Last Synced: 2025-01-12T13:14:28.998Z (over 1 year ago)
- Language: TypeScript
- Homepage:
- Size: 1.23 MB
- Stars: 3
- Watchers: 3
- Forks: 5
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# PoolTogether V4 Timelocks Contracts

[](https://coveralls.io/github/pooltogether/v4-timelocks?branch=master&asdf=1)
[](https://docs.openzeppelin.com/)
[](http://perso.crans.org/besson/LICENSE.html)
Have questions or want the latest news?
Join the PoolTogether Discord or follow us on Twitter:
[](https://discord.gg/JFBPMxv5tr)
[](https://twitter.com/PoolTogether_)
**Documentation**
https://v4.docs.pooltogether.com
**Deployments**
- [Ethereum](https://v4.docs.pooltogether.com/protocol/deployments/mainnet#mainnet)
- [Polygon](https://v4.docs.pooltogether.com/protocol/deployments/mainnet#polygon)
- [Avalanche](https://v4.docs.pooltogether.com/protocol/deployments/mainnet#avalanche)
# Overview
- [BeaconTimelockTrigger](/contracts/BeaconTimelockTrigger.sol)
- [DrawCalculatorTimelock](/contracts/DrawCalculatorTimelock.sol)
- [L1TimelockTrigger](/contracts/L1TimelockTrigger.sol)
- [L2TimelockTrigger](/contracts/L2TimelockTrigger.sol)
- [ReceiverTimelockTrigger](/contracts/ReceiverTimelockTrigger.sol)
Timelock contracts assist with Phase 1 in the roll-out of V4. Granting authority to the operations teams to prevent a "bad actor" oracle from incorrectly setting a draw or prize distribution params.
### DrawCalculatorTimelock
The DrawCalculatorTimelock adds a timelock for PrizeDistributor to execute a claim with the most recently pushed PrizeDistribution params pushed.
### L1TimelockTrigger & L2TimelockTrigger
Both L1TimelockTrigger/L2TimelockTrigger contracts set a timelock or a "cooldown" period in the linked `DrawCalculatorTimelock` contract. The `DrawCalculatorTimelock` routes `calculate` execution through a `DrawCalculator` contract for the linked `PrizeDistributor` contract.
### L1TimelockTrigger
The `L1TimelockTrigger` contract pushes `DrawLib.Draw` and `DrawLib.PrizeDistribution` params onto the `DrawBuffer` and `PrizeDistributionBuffer` contracts.
### L2TimelockTrigger
The `L2TimelockTrigger` pushes `DrawLib.PrizeDistribution` params onto a `PrizeDistributionBuffer` contract.
**Core and Periphery contracts:**
- https://github.com/pooltogether/v4-core
- https://github.com/pooltogether/v4-periphery
# Getting Started
The project is made available as a NPM package.
```sh
$ yarn add @pooltogether/pooltogether-contracts
```
The repo can be cloned from Github for contributions.
```sh
$ git clone https://github.com/pooltogether/v4-timelock
```
```sh
$ yarn
```
We use [direnv](https://direnv.net/) to manage environment variables. You'll likely need to install it.
```sh
cp .envrc.example .envrc
```
To run fork scripts, deploy or perform any operation with a mainnet/testnet node you will need an Infura API key.
# Testing
We use [Hardhat](https://hardhat.dev) and [hardhat-deploy](https://github.com/wighawag/hardhat-deploy)
To run unit & integration tests:
```sh
$ yarn test
```
To run coverage:
```sh
$ yarn coverage
```
# Fork Testing
Ensure your environment variables are set up. Make sure your Alchemy URL is set. Now start a local fork:
```sh
$ yarn start-fork
```
Setup account impersonation and transfer eth:
```sh
$ ./scripts/setup.sh
```
# Deployment
## Deploy Locally
Start a local node and deploy the top-level contracts:
```bash
$ yarn start
```
NOTE: When you run this command it will reset the local blockchain.
## Testnets
Deployment is maintained in a different [repo](https://github.com/pooltogether/v4-testnet).
## Mainnet
Deployment is maintained in a different [repo](https://github.com/pooltogether/v4-mainnet).