Skip to content

Repository files navigation

🏦 NewLo Point (NLP) Contract System

⚠️ Disclaimer: This smart contract is experimental software. Please conduct thorough testing and auditing before using in production environments.

License: MIT Solidity

πŸ” Overview

NewLo Point is an ERC20 point token with gradual transfer control functionality. During the initial service phase, user-to-user transfers are restricted, allowing only minting from the service operator. As the service evolves and exchanges are prepared, transfers can be gradually enabled.

The NewLo Point (NLP) Contract System is a comprehensive DeFi protocol suite that provides everything from NLP token issuance and management to multi-token exchange systems.

πŸ“¦ Contract List

1. πŸ’Ž NewLoPoint.sol

  • Function: ERC20-compliant NLP token issuance and management
  • Features:
    • Upgradeable proxy pattern
    • Supply adjustment through admin privileges
    • Standard ERC20 functionality

2. 🏭 NewLoPointFactory.sol

  • Function: Factory contract for NewLoPoint tokens
  • Features:
    • Creation of multiple NLP token instances
    • Unified management interface

3. πŸ”„ NLPToMultiTokenExchange.sol ⭐ Latest Version

  • Function: Exchange NLP to multiple tokens (ETH, USDC, USDT)
  • Features:
    • πŸ›‘οΈ Role-based Access Control: Granular permission management
    • πŸ’° Operational Fee System: Independent operational fee configuration and management
    • πŸ”— Flexible Price Management: Chainlink Oracle + external price data
    • ⚑ Gasless Exchange: Free transactions using permit signatures
    • 🎯 Soneium Optimization: Optimized for oracle-limited environments

4. πŸ“Š MultiTokenDistribution.sol

  • Function: Batch distribution system for multiple tokens
  • Features:
    • Efficient batch processing
    • Simultaneous distribution of multiple token types
    • Gas efficiency optimization

5. πŸŒ‰ NLPToJPYCExchangeAdapter.sol ⭐ Cross-Chain Bridge

  • Function: Cross-chain escrow adapter for NLP (Soneium) to JPYC (Polygon) exchange
  • Features:
    • 🌐 Cross-Chain Support: Soneium ↔ Polygon bridge functionality
    • πŸ” Backend-Controlled: All operations executed by OPERATOR_ROLE
    • ⚑ Gasless Transactions: EIP-2612 permit-based approvals
    • πŸ’Ό Escrow Management: User-specific NLP escrow tracking
    • πŸ’° Flexible Fee System: Configurable exchange and operational fees
    • πŸ›‘οΈ Security First: ReentrancyGuard, Pausable, AccessControl
    • πŸ“Š Transparent Operations: Comprehensive event logging for off-chain tracking
  • Documentation: See docs/NLPToJPYCExchangeAdapter.md

🎭 Role-Based Access Control

πŸ”‘ Access Control Roles

Role Permissions Purpose
DEFAULT_ADMIN_ROLE Full permissions Super admin
CONFIG_MANAGER_ROLE / CONFIG_ROLE Configuration management Token settings, fee configuration
PRICE_UPDATER_ROLE Price updates External price data updates
EMERGENCY_MANAGER_ROLE Emergency management Emergency stops, fund withdrawals
FEE_MANAGER_ROLE Fee management Operational fee configuration and withdrawals
OPERATOR_ROLE Backend operations Execute escrow deposits, burns, and transfers (NLPToJPYCExchangeAdapter)
PAUSER_ROLE Pause control Emergency pause functionality (NLPToJPYCExchangeAdapter)

πŸ’° Operational Fee System

πŸ“Š Fee Types

  1. Exchange Fee: Basic exchange fee
  2. Operational Fee: Additional fee for operational revenue

🎯 Fee Limits

  • Maximum Exchange Fee: 5% (500 basis points)
  • Maximum Operational Fee: 2% (200 basis points)

πŸš€ Main Features

πŸ’± Multi-Token Exchange

// Standard exchange
exchange.exchangeNLP(TokenType.ETH, nlpAmount);

// Gasless exchange
exchange.exchangeNLPWithPermit(TokenType.ETH, nlpAmount, deadline, v, r, s, user);

πŸ”§ Management Functions

// Grant roles
exchange.grantRole(exchange.PRICE_UPDATER_ROLE(), updaterAddress);

// Configure operational fees
exchange.configureOperationalFee(TokenType.ETH, 50, feeRecipient, true);

// Update price data
exchange.updateExternalPrice(TokenType.ETH, 2500e18);

πŸ›‘οΈ Security Features

πŸ”’ Key Security Measures

  • Reentrancy Protection: Uses ReentrancyGuard
  • Access Control: Uses OpenZeppelin AccessControl
  • Price Data Validation: Freshness checks and validity confirmation
  • Emergency Stop: Pausable functionality for immediate stops
  • Audited: Comprehensive security audit completed

πŸ“‹ Security Score

  • Overall Rating: A-grade (Excellent)
  • Test Success Rate: 100% (34/34 tests passed)
  • Slither Analysis: No critical vulnerabilities

πŸ”§ Technical Specifications

πŸ“Š Supported Blockchains

  • Soneium: Optimized for oracle-limited environments
  • Ethereum: Full Chainlink Oracle support
  • Other EVM-compatible chains: Flexible configuration support

🎯 Price Management

  • Chainlink Oracle: Automatic price fetching
  • External Price Data: Manual and automatic update support
  • Batch Updates: Efficient bulk price updates

πŸ“ Directory Structure

newlo-point-contract/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ NewLoPoint.sol                    # NLP Token
β”‚   β”œβ”€β”€ NewLoPointFactory.sol            # Factory
β”‚   β”œβ”€β”€ NLPToMultiTokenExchange.sol      # Multi-token exchange (Latest)
β”‚   β”œβ”€β”€ MultiTokenDistribution.sol       # Distribution system
β”‚   β”œβ”€β”€ interfaces/                      # Interfaces
β”‚   β”œβ”€β”€ tokens/                          # Token implementations
β”‚   └── mocks/                           # Test mocks
β”œβ”€β”€ test/                                # Test files
β”œβ”€β”€ script/                              # Deploy scripts
β”œβ”€β”€ docs/                                # Documentation
β”‚   β”œβ”€β”€ MULTI_TOKEN_EXCHANGE_GUIDE.md    # Complete operation guide
β”‚   β”œβ”€β”€ SECURITY_AUDIT_REPORT.md         # Security audit report
β”‚   └── ...
└── README.md                            # This file

πŸš€ Quick Start

1. Environment Setup

# Clone the repository
git clone <repository-url>
cd newlo-point-contract

# Install dependencies
forge install

# Run tests
forge test

2. Local Development Environment Deploy

# Set environment variables
export PRIVATE_KEY="your-private-key"

# Deploy to local environment
forge script script/DeployMultiTokenExchange.s.sol:DeployMultiTokenExchangeLocal \
  --rpc-url http://localhost:8545 \
  --private-key $PRIVATE_KEY \
  --broadcast

3. Soneium Production Environment Deploy

# Deploy to Soneium environment
forge script script/DeployMultiTokenExchange.s.sol:DeployMultiTokenExchange \
  --rpc-url https://rpc.soneium.org \
  --private-key $PRIVATE_KEY \
  --broadcast

πŸ“š Documentation

πŸ“– Detailed Guides

πŸ” Feature-Specific Guides

πŸ§ͺ Testing

πŸ”¬ Test Execution

# Run all tests
forge test

# Run tests with verbose output
forge test -vv

# Run specific tests
forge test --match-contract NLPToMultiTokenExchangeTest

# Check coverage
forge coverage

πŸ“Š Test Results

  • Test Success Rate: 100% (34/34 tests passed)
  • Coverage: High-level code coverage
  • Test Categories:
    • Basic functionality tests
    • Security tests
    • Error handling tests
    • Integration tests
    • Fuzz tests

πŸ”„ Version History

v0.4.0 (Latest)

  • βœ… Role-based Access Control implementation
  • βœ… Operational fee system addition
  • βœ… Security enhancements
  • βœ… 34 test items completed
  • βœ… Comprehensive security audit completed

v0.3.0

  • βœ… Basic multi-token exchange functionality
  • βœ… Chainlink Oracle support
  • βœ… Gasless exchange functionality

v0.1.0

  • βœ… NewLo Point token
  • βœ… NLP distribution functionality

🀝 Contributing

πŸ“ Contribution Guidelines

  1. Fork and create pull requests
  2. Add/update tests
  3. Report security vulnerabilities
  4. Improve documentation

πŸ› Bug Reports

  • Report bugs via GitHub Issues
  • Contact directly for security-related issues

πŸ“„ License

MIT License - See LICENSE for details

πŸ”— Links


NewLo Point Contract System - Next-generation DeFi protocol suite πŸš€

Releases

Packages

Used by

Contributors

Languages