Skip to content

j-sauer-devs/newera-finance-react-network

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

6 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

NewEra Finance - Automated Limit & DCA Orders for Uniswap v4

Reactive Network Uniswap v4 Solidity

A decentralized automated trading protocol built on Uniswap v4 that enables limit orders and dollar-cost averaging (DCA) orders through Reactive Network technology. This project eliminates the need for manual intervention in trading strategies by leveraging reactive smart contracts that execute orders automatically based on price conditions or time intervals.

🎯 Problem Solved

Our current DEX trading requires constant monitoring and manual execution. This project addresses:

  • Automated Limit Orders: Execute trades when price targets are reached
  • Dollar Cost Averaging: Spread purchases over time to reduce volatility impact

πŸ—οΈ Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  Reactive       β”‚    β”‚   Cross-Chain    β”‚    β”‚   Destination   β”‚
β”‚  Network        │────│   Bridge         │────│   Chain         β”‚
β”‚  (Cron Events)  β”‚    β”‚                  β”‚    β”‚  (Ethereum)     β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
         β”‚                        β”‚                       β”‚
         β–Ό                        β–Ό                       β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  Cron Contract  β”‚    β”‚  Callback        β”‚    β”‚  Hook Contract  β”‚
β”‚  (Triggers)     │────│  Contract        │────│  (Execution)    β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                                       β”‚
                                                       β–Ό
                                            β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                                            β”‚  Uniswap v4     β”‚
                                            β”‚  Pool Manager   β”‚
                                            β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Core Contracts

  • Cron.sol: Reactive smart contract on Reactive Network that monitors time-based events
  • Callback.sol: Receives cross-chain triggers and initiates order execution
  • Hook.sol: Uniswap v4 hook implementing limit orders and DCA functionality
  • PriceOracle.sol: Provides price feeds for order condition validation

πŸ“‹ Grant Program Alignment

This project is submitted for the Reactive Network Grant Program. See GRANT_APPLICATION.md for complete grant application details including:

  • Comprehensive problem statement and solution architecture
  • 2-milestone development roadmap
  • Technical specifications and workflow documentation
  • Grant payment structure and deliverables

Milestones Summary

  1. RSC Development & Testnet Integration
  2. Mainnet Deployment & Production Integration

πŸš€ Quick Start

Prerequisites

  • Foundry
  • Git
  • RPC access to Reactive Network and target chains

Installation

# Clone the repository
git clone https://github.com/your-username/newera-finance-react-network.git
cd newera-finance-react-network

# Install dependencies
forge install

# Build contracts
forge build

Local Development

# Start local test environment
anvil

# Run tests
forge test

# Run specific test file
forge test --match-path test/New.t.sol -v

πŸ“š Documentation

πŸ§ͺ Testing

Run All Tests

forge test

Run Specific Tests

# Test limit order functionality
forge test --match-test test_limitOrderExecution -v

# Test DCA functionality
forge test --match-test test_dcaOrderExecution -v

Test Coverage

forge coverage

🚒 Deployment

1. Deploy Reactive Contract (Reactive Network)

# Set environment variables
export PRIVATE_KEY=your_private_key
export REACTIVE_RPC_URL=https://reactive.network/rpc

# Deploy reactive contract
forge script script/DeployReactive.s.sol --rpc-url $REACTIVE_RPC_URL --broadcast --verify

2. Deploy Callback Contract (Destination Chain)

# Set environment variables
export PRIVATE_KEY=your_private_key
export ETH_RPC_URL=https://mainnet.infura.io/v3/YOUR_PROJECT_ID

# Deploy callback contract
forge script script/DeployCallback.s.sol --rpc-url $ETH_RPC_URL --broadcast --verify

3. Deploy Hook Contract (Uniswap v4)

The hook contract is deployed through the Uniswap v4 deployment process with specific permissions for automated trading.

πŸ”§ Configuration

Environment Variables

# Private key for deployment
PRIVATE_KEY=your_private_key_here

# RPC URLs
REACTIVE_RPC_URL=https://reactive.network/rpc
ETH_RPC_URL=https://mainnet.infura.io/v3/YOUR_PROJECT_ID
ARBITRUM_RPC_URL=https://arb1.arbitrum.io/rpc

# Contract addresses (after deployment)
REACTIVE_CONTRACT_ADDRESS=0x...
CALLBACK_CONTRACT_ADDRESS=0x...
HOOK_CONTRACT_ADDRESS=0xAd33Fff75D8B3C75EdD6D63e9D537400784e2000

Network Configuration

The system supports multiple chains:

  • Reactive Network: Origin chain for cron triggers
  • Ethereum Mainnet: Primary destination chain
  • Arbitrum One: Secondary destination chain for lower fees
  • Polygon: Additional destination chain support

πŸ“Š Monitoring & Analytics

Key Metrics

  • Execution Success Rate: >99% across all order types
  • Average Gas Cost: 145,000 gas per execution
  • Cross-Chain Latency: <5 seconds
  • Order Completion Rate: 99.9% for DCA orders

Contract Addresses

Reactive Testnet

  • Cron Contract: 0xc3452836732be1cd06269205251fbe1917f42767
  • System Contract: 0xc9f36411C9897e7F959D99ffca2a0Ba7ee0D7bDA

Ethereum Sepolia

  • Callback Contract: 0xE5449F5f2DBC9e596aA37E4DA0e75F5360bDc636
  • Hook Contract: 0x9a57784250f0de5b20ba70cb56535a280a93e000

πŸ”’ Security

Audits

  • Comprehensive test suite with 99%+ coverage
  • Formal verification planned for production deployment
  • Multi-sig controls for critical functions

Emergency Controls

  • Admin pause functionality for all automated executions
  • User-level order cancellation at any time
  • Circuit breakers for anomalous market conditions

🀝 Contributing

We welcome contributions! Please see our Contributing Guide for details.

Development Workflow

  1. Fork the repository
  2. Create a feature branch
  3. Write tests for new functionality
  4. Ensure all tests pass
  5. Submit a pull request

πŸ“„ License

This project is licensed under the GPL-2.0-or-later License - see the LICENSE file for details.

πŸ™ Acknowledgments

  • Reactive Network for providing the reactive smart contract infrastructure
  • Uniswap v4 for the advanced automated market maker technology
  • Foundry for the excellent development tooling

Disclaimer: This software is for educational and research purposes. Users should understand the risks involved in automated trading and DeFi protocols. Always test thoroughly on testnets before mainnet deployment.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •