GitXplorerGitXplorer
r

eth-pool

public
1 stars
0 forks
0 issues

Commits

List of commits on branch main.
Verified
b4c4a52b38304229275ca3a6264eff9d1b67bfbc

Fix typo

rrootulp committed 2 years ago
Verified
8b2258f29a75039c15b7d2d3f967e925e3244a37

Verify on Etherscan

rrootulp committed 2 years ago
Verified
913632359dfa40b56cf4c16daf5bb6f151fbb669

Deploy to Goerli

rrootulp committed 2 years ago
Verified
2056673d5b430a60dde06e075a1715a1e5173bbd

Make deposits internal

rrootulp committed 2 years ago
Verified
1484dcfeb955761755973d48870e16d04fbf1863

Label alice, bob, charlie

rrootulp committed 2 years ago
Verified
f83e47cb1a331e51bcd4bf8013e26e3764a9f39b

Reorder tests

rrootulp committed 2 years ago

README

The README file for this repository.

eth-pool

License

EthPool is a learning exercise motivated by this challenge. The goal is to write a contract (named "EthPool") that allows users to deposit and withdraw ETH from. Occasionally, a pool operator will deposit rewards (also denominated in ETH) into the pool. Rewards are distributed to depositors based on their percentage share of the pool.

Examples

Example 1

  1. Alice deposits 1 ETH.
  2. Bob deposits 1 ETH.
  3. Operator deposits 1 ETH of rewards in the pool. Since Alice and Bob both have 50% ownership of the pool, they both receive 50% of the rewards (.5 ETH).
  4. Alice can withdraw 1.5 ETH and Bob can withdraw 1.5 ETH.

Example 2

  1. Alice deposits 1 ETH.
  2. Bob deposits 3 ETH.
  3. Operator deposits 1 ETH of rewards in the pool. Alice recieves .25 ETH and Bob receives .75 ETH.
  4. Alice can withdraw 1.25 ETH and Bob can withdraw 3.75 ETH.

Local Development

Prerequisites

  1. Clone this repo
  2. Create a project on Alchemy
  3. Create an API key on Etherscan

Initial Setup

# Install git submodule dependencies
forge install

# Copy the default .env file
cp .env.default .env

# Populate .env with ETH_RPC_URL from Alchemy and PRIVATE_KEY from a testnet wallet
vim .env

# Source the .env file
source .env

Helpful Commands

# Build
forge build

# Test
forge test

# Deploy contract
forge create --rpc-url $ETH_RPC_URL --private-key $PRIVATE_KEY src/EthPool.sol:EthPool

# Verify on Etherscan
forge verify-contract --chain-id $CHAIN_ID --num-of-optimizations 200 --compiler-version $COMPILER_VERSION $CONTRACT_ADDRESS src/EthPool.sol:EthPool $ETHERSCAN_API_KEY

Deployments

Network Address
Goerli 0x69727e6c77dff8d16537887b8ebe0609f8548c35

To-do

  • [ ] Consider refactoring EthPool to not use a dynamically sized array

Contribute

I'd appreciate any feedback via issues.

Acknowledgements