Skip to content

Commit

Permalink
Extend Readme
Browse files Browse the repository at this point in the history
  • Loading branch information
OxideDall committed Jan 27, 2025
1 parent 83addd1 commit fddf57f
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 42 deletions.
115 changes: 75 additions & 40 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,66 +1,101 @@
## Foundry
# Sweeper - 9Lives Protocol Automation Service

**Foundry is a blazing fast, portable and modular toolkit for Ethereum application development written in Rust.**
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](./LICENSE)

Foundry consists of:
Automated transaction management system for 9Lives protocol campaigns. Handles critical lifecycle operations including position closing, dispute resolution, and batch slashing on Arbitrum Stylus.

- **Forge**: Ethereum testing framework (like Truffle, Hardhat and DappTools).
- **Cast**: Swiss army knife for interacting with EVM smart contracts, sending transactions and getting chain data.
- **Anvil**: Local Ethereum node, akin to Ganache, Hardhat Network.
- **Chisel**: Fast, utilitarian, and verbose solidity REPL.
## Features

## Documentation
### Core Components

https://book.getfoundry.sh/
- **Event Orchestrator**
Real-time monitoring of protocol events (`MarketCreated2`, `CallMade`, `CommitmentRevealed`) with state machine transitions
- **Transaction Pipeline**
Gas-optimized batched transaction processing (`close`, `declare`, `sweepBatch`)
- **Mass Action Engine**
Parallelized settlement system for large-scale position management (optional)

## Usage
## Prerequisites

### Build
- [Foundry](https://book.getfoundry.sh/) (forge >= 0.2.0, anvil >= 0.2.0) for contract compilation and local testnet
- Node.js v18+

```shell
$ forge build
```
## Quick Start

### Test
```bash
# Install dependencies
npm install

```shell
$ forge test
```
# Configuration setup
cp .env.example .env # Update with your credentials

### Format
# Build contracts and generate TypeScript types
forge build
./typegen.sh # Generates TypeChain bindings for contracts

```shell
$ forge fmt
# Build project
npm run build

# Start service
npm start
```

### Gas Snapshots
## Configuration

```shell
$ forge snapshot
```
### Environment Variables

### Anvil
```ini
# Required
RPC_URL="arbitrum_rpc_endpoint"
WSS_URL="arbitrum_websocket_endpoint"
INFRA_MARKET_ADDRESS="0x...market_address"
BATCH_SWEEPER_ADDRESS="0x...sweeper_address"
ACTOR_PRIVATE_KEY="operator_wallet_key"

```shell
$ anvil
# Network settings
GAS_RATIO=20 # Base gas multiplier
CONFIRMATIONS=5 # Required block confirmations
RETRY_INTERVAL=2000 # Retry interval in milliseconds
```

### Deploy
## Testing

```shell
$ forge script script/Counter.s.sol:CounterScript --rpc-url <your_rpc_url> --private-key <your_private_key>
```
To run tests using the local Anvil node:

### Cast
```bash
# Make the test script executable
chmod +x tests.sh

```shell
$ cast <subcommand>
# Run tests
./tests.sh
```

### Help
The test script will:

1. Build contracts using Forge
2. Generate TypeChain types
3. Start a local Anvil node
4. Run the test suite
5. Clean up the Anvil process

## Available Commands

```shell
$ forge --help
$ anvil --help
$ cast --help
```bash
# Build TypeScript files
npm run build

# Start the service
npm start

# Run tests directly (without Anvil setup)
npm test
```

## License

This project is licensed under the MIT License. See [LICENSE](./LICENSE) for details.

## Roadmap

- [ ] Docker containerization
- [ ] Extend testing
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"scripts": {
"build": "tsc",
"start": "node dist/index.js",
"test": "mocha -r tsx test/market.test.ts --timeout 10000"
"test": "mocha -r tsx test/market.test.ts --timeout 0"
},
"keywords": [],
"author": "",
Expand Down
2 changes: 1 addition & 1 deletion tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ start_anvil() {

start_anvil

npx mocha -r tsx test/market.test.ts --timeout 0
npm run test

kill $ANVIL_PID

0 comments on commit fddf57f

Please sign in to comment.