Skip to content
cranspaulPublic

About

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

Repository files navigation

AMM Minus Strategy - Yield Optimizer with Arbitrage Detection

📋 Overview

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 buying CRANS tokens using NEAR while detecting and exploiting arbitrage opportunities across different liquidity pool routes.

🎯 Strategy Description

Core Concept

  • Direction: Buys CRANS tokens using NEAR
  • Method: Multi-path arbitrage detection across various LP pairs
  • Optimization: Yield maximization through route comparison and selection

Key Components

1. Supervisor (yieldOptimizer.tsx)

The main yield optimization engine that:

  • Manages the complete trading cycle from NEAR to CRANS
  • Handles circular arbitrage routes for maximum yield
  • Coordinates with Ref Finance DEX
  • Implements safety mechanisms and cooldown periods
  • Tracks and reports profit/loss

2. Arbitrage (arbitrageDetector.tsx)

The arbitrage detection system that:

  • Simulates multiple trading routes in real-time
  • Compares expected returns across different LP paths
  • Identifies the most profitable route for NEAR → CRANS conversion
  • Validates arbitrage opportunities before execution

🛠 Technical Architecture

Trading Routes

The system evaluates multiple routes for NEAR to CRANS conversion:

Primary Routes:
- NEAR → CRANS (direct)
- NEAR → SHITZU → CRANS
- NEAR → BD → CRANS
- NEAR → SIN → CRANS
- NEAR → PUMP → CRANS

Complex Multi-hop Routes:
- NEAR → SHITZU → BD → CRANS
- NEAR → BD → SHITZU → CRANS

Circular Arbitrage Routes:
- NEAR → CRANS → SHITZU → CRANS
- NEAR → CRANS → BD → CRANS
- NEAR → CRANS → SIN → CRANS
- NEAR → CRANS → PUMP → CRANS

Configuration

  • Base Amount: 0.3 NEAR per trade
  • Cooldown: 1-3 minutes between cycles
  • Safety Margin: 99.9% slippage protection
  • Gas Limit: 300 TGas
  • Minimum Threshold: 3 CRANS minimum output

🔧 Dependencies

  • React
  • NEAR
  • Ref Finance SDK
  • Big.js
  • TypeScript

🚀 Usage

Prerequisites

  • NEAR wallet with NEAR tokens
  • Ref Finance deposit for gas optimization
  • Private key configuration

Integration

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)}
/>

📊 Performance Metrics

The system provides real-time monitoring of:

  • NEAR to CRANS conversion efficiency
  • Profit/loss tracking on circular routes
  • Route performance comparison
  • Gas usage optimization
  • Market conditions analysis

📈 Strategy Logic

  1. Balance Check: Verify NEAR token availability on Ref Finance
  2. Route Simulation: Test all possible NEAR → CRANS paths
  3. Arbitrage Detection: Identify most profitable route
  4. Circular Route Execution: Execute multi-step arbitrage cycles
  5. Profit Calculation: Track and report returns
  6. Withdrawal & Transfer: Move profits and manage liquidity
  7. Cooldown: Wait before next cycle

🔄 Circular Arbitrage Mechanism

The strategy implements sophisticated circular arbitrage:

  1. NEAR Deposit: Ensures sufficient NEAR on Ref Finance
  2. Multi-step Swaps: Executes circular paths like NEAR → CRANS → Token → CRANS
  3. Profit Extraction: Withdraws accumulated CRANS tokens
  4. Balance Management: Maintains optimal liquidity ratios

🔍 Monitoring & Logging

Comprehensive logging system with:

  • Detailed transaction logs with [ARB_LOG] prefix
  • Route comparison data
  • Balance tracking
  • Error tracking and reporting
  • Performance metrics
  • Market condition alerts

About

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages