This repository contains an automated market maker (AMM) strategy that implements a yield optimizer with arbitrage detection for the NEAR blockchain ecosystem. The strategy focuses on selling CRANS tokens to obtain other tokens (primarily NEAR/stNEAR) while detecting and exploiting arbitrage opportunities across different liquidity pool routes.
- Direction: Sells CRANS tokens to acquire NEAR/stNEAR
- Method: Multi-path arbitrage detection across various LP pairs
- Optimization: Yield maximization through route comparison and selection
The main yield optimization engine that:
- Manages the complete trading cycle
- Handles CRANS token sales across multiple routes
- Coordinates with Ref Finance DEX
- Implements safety mechanisms and cooldown periods
- Tracks and reports profit/loss
The arbitrage detection system that:
- Simulates multiple trading routes in real-time
- Compares expected returns across different LP paths
- Identifies the most profitable route
- Validates arbitrage opportunities before execution
The system evaluates multiple routes for CRANS token sales:
Primary Routes:
- CRANS → NEAR → stNEAR
- CRANS → SHITZU → NEAR → stNEAR
- CRANS → BD → NEAR → stNEAR
- CRANS → SIN → NEAR → stNEAR
- CRANS → PUMP → NEAR → stNEAR
Complex Multi-hop Routes:
- CRANS → SHITZU → BD → NEAR → stNEAR
- CRANS → BD → SHITZU → NEAR → stNEAR
- Base Amount: 500 CRANS per trade
- Cooldown: 1-3 minutes between cycles
- Safety Margin: 99.9% slippage protection
- Gas Limit: 300 TGas
- React: Frontend framework
- NEAR: Priv Keys interaction
- Rhea Finance SDK: DEX integration
- Big.js: Precision arithmetic
- TypeScript: Type safety
- NEAR wallet with CRANS tokens
- Rhea Finance deposit to DEX contract
- Private key configuration
import { ArbitrageSupervisor } from './yieldOptimizer';
import { CransArbitrage } from './arbitrageDetector';
// Initialize yield optimizer
<ArbitrageSupervisor
isEnabled={true}
onProfit={(profit) => console.log('Profit:', profit)}
onRouteFound={(route) => console.log('Best route:', route)}
/>The system provides real-time monitoring of:
- Trade execution success rate
- Profit/loss tracking
- Route performance comparison
- Gas usage optimization
- Market conditions analysis
- Balance Check: Verify CRANS token availability
- Route Simulation: Test all possible trading paths
- Arbitrage Detection: Identify most profitable route
- Execution: Execute trades with safety margins
- Profit Calculation: Track and report returns
- Cooldown: Wait before next cycle