Skip to content

Optic is the new way of chatting with friends on the self-writing internet. Make you time worthwhile by earn from you interactions.

Notifications You must be signed in to change notification settings

divin3circle/optic

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

OPTIC

Internet Computer TypeScript React Azle Motoko

A fully on-chain chat application that redefines what Web3 messaging should look like - built on the Internet Computer blockchain.

OPTIC combines decentralized messaging with DeFi actions, allowing users to turn their chat rooms into collaborative investment pools. Every message sent contributes to a shared treasury that generates passive income for all participants through intelligent liquidity provision on ICPSwap.

โœจ Key Features

  • ๐Ÿ”’ Fully Decentralized: No central servers - everything runs on-chain
  • ๐Ÿ’ฐ Earn While You Chat: Convert chat rooms into investment pools
  • ๐Ÿค– AI-Powered Analytics: Built-in AI agent for investment insights
  • ๐Ÿ”„ Automated DeFi: Intelligent liquidity provision on ICPSwap v3
  • ๐Ÿ’Ž Chain-Key Tokens: Support for ICP, ckUSDC, ckETH, ckBTC, and more
  • ๐Ÿ“ฑ Modern UI: Clean, responsive interface with real-time messaging
  • ๐Ÿ† Reward System: Earn fees proportional to your contributions

Table of Contents

๐ŸŒ The Web3 Way

OPTIC is a paradigm shift in how we think about messaging applications. Instead of extracting value from users' data and attention, we create value for every interaction.

How It Works

  1. ๐Ÿ’ฌ Chat Naturally: Join or create chat rooms just like any messaging app
  2. ๐Ÿ’ฐ Contribute to Pool: Members contribute ICP/ckUSDC to the room's investment treasury
  3. ๐Ÿค– AI Agent Invests: Our smart agent analyzes ICPSwap pools and executes optimal strategies
  4. ๐Ÿ“ˆ Earn Passive Income: Collect fees from liquidity provision proportional to your contribution
  5. ๐Ÿ”„ Withdraw Anytime: Leave with your principal + accumulated rewards

Technical Implementation

Our platform leverages the Internet Computer's unique capabilities to deliver:

  • ๐Ÿ” True Decentralization: All data stored on-chain, no centralized servers
  • โšก Near Real-time: IC's 2-second finality enables smooth chat experiences
  • ๐Ÿ”„ Automated DeFi: Smart contracts handle all investment operations
  • ๐Ÿ’Ž Chain-Key Integration: Seamless interaction with Bitcoin, Ethereum tokens
  • ๐Ÿฆ Transparent Treasury: All fund movements are auditable on-chain

๐Ÿš€ Additional Features

Beyond making DeFi as simple as sending a message, OPTIC includes powerful features that enhance the Web3 experience:

๐Ÿ’ณ Integrated Wallet Dashboard

  • Multi-Token Support: Manage ICP, ckBTC, ckETH, ckUSDC, and more
  • Real-time Balances: Live token price feeds and portfolio tracking
  • Transaction History: Complete on-chain transaction explorer
  • Secure Integration: Seamless Plug Wallet connectivity

๐Ÿค– AI-Powered Insights

  • Smart Notifications: AI-generated summaries of pool performance
  • Investment Analytics: Automated analysis of DeFi opportunities
  • Risk Assessment: Real-time evaluation of liquidity pool risks
  • Personalized Reports: Customized insights based on your investment style

๐Ÿ† Gamification & Rewards

  • Contribution Leaderboards: Recognition for top pool contributors
  • Achievement System: Unlock badges for milestones and activities
  • Referral Rewards: Earn bonuses for bringing new users to rooms
  • Social Trading: Follow successful room strategies

๐Ÿ” Enterprise-Grade Security

  • Multi-Signature Support: Enhanced security for high-value rooms
  • Audit Trail: Complete transparency of all fund movements
  • Emergency Procedures: Built-in safeguards and recovery mechanisms

๐Ÿ—๏ธ Canister Topology & Architecture

OPTIC uses a sophisticated multi-canister microservices architecture designed for scalability, security, and maintainability. This separation of concerns allows us to optimize each component for its specific role while maintaining secure inter-canister communication.

Optic Backend Canister

Primary Role: CRUD Operations & Data Management

  • ๐Ÿ” Authentication: User identity management using Internet Identity
  • ๐Ÿ’ฌ Chat Management: Real-time messaging, room administration, and history
  • ๐Ÿ‘ฅ User Management: Profiles, preferences, and social features
  • ๐Ÿ—„๏ธ Persistent Storage: Optimized data structures for chat and user data
  • ๐Ÿ”ง Technology: Built with Azle (TypeScript for IC)
  • ๐ŸŒ Deployment: View on IC Dashboard

Optic Agent Canister

Primary Role: DeFi Operations & Treasury Management

  • ๐Ÿ’ฐ Treasury Management: Secure handling of user contributions
  • ๐Ÿ“Š Pool Analysis: Real-time evaluation of ICPSwap opportunities
  • ๐Ÿ”„ Automated Trading: Smart contract-based token swapping
  • ๐Ÿฆ Liquidity Provision: Automated LP position management
  • ๐Ÿ’Ž Reward Distribution: Proportional fee allocation to contributors
  • ๐Ÿ”ง Technology: Built with Motoko (IC's native language)
  • ๐ŸŒ Deployment: View on IC Dashboard

Architecture

Optic follows a multi-canister microservices architecture designed for scalability, security, and maintainability. The system is built on the Internet Computer blockchain with two main canisters that work together to provide a seamless DeFi-enabled chat experience.

graph TB
    %% User Interface Layer
    subgraph "Frontend Layer"
        UI[React Frontend]
        Plug[Plug Wallet Extension]
    end

    %% Canister Layer
    subgraph "Canister Layer"
        subgraph "Backend Canister (Azle)"
            Auth[Authentication]
            Chat[Chat Management]
            User[User Management]
            Storage[Data Storage]
        end

        subgraph "Agent Canister (Motoko)"
            DeFi[DeFi Operations]
            Swap[Token Swapping]
            Pool[Liquidity Management]
            Treasury[Treasury Management]
        end
    end

    %% External Services
    subgraph "External Services"
        ICPSwap[ICPSwap v3]
        ICPLedger[ICP Ledger]
        ckUSDC[ckUSDC Ledger]
    end

    %% Data Flow
    UI --> Plug
    Plug --> Auth
    UI --> Chat
    UI --> User
    UI --> DeFi

    Chat --> Storage
    User --> Storage
    Auth --> Storage

    DeFi --> Swap
    DeFi --> Pool
    DeFi --> Treasury

    Swap --> ICPSwap
    Pool --> ICPSwap
    Treasury --> ICPLedger
    Treasury --> ckUSDC

    %% Cross-canister communication
    Storage -.->|Contribution Records| DeFi
    DeFi -.->|User Data| Storage


    class UI,Plug frontend
    class Auth,Chat,User,Storage,DeFi,Swap,Pool,Treasury canister
    class ICPSwap,ICPLedger,ckUSDC external
    class Storage storage
Loading

System Components

๐Ÿ”น Frontend Layer

  • React Application: Modern UI built with React, TypeScript, and Tailwind CSS
  • Plug Wallet Integration: Secure wallet connection and transaction signing
  • Real-time Chat Interface: Messaging system with near realtime capabilities, thanks to Tanstack Query

๐Ÿ”น Backend Canister (Azle)

  • Authentication & Authorization: User identity management and session handling
  • Chat Management: Room creation, message handling, and group administration
  • User Management: Profile management, preferences, and user data
  • Data Storage: Persistent storage for chat history, user data, and metadata

๐Ÿ”น Agent Canister (Motoko)

  • DeFi Operations: Automated investment strategies and pool analysis
  • Token Swapping: Integration with ICPSwap for token exchanges
  • Liquidity Management: Pool participation and liquidity provision
  • Treasury Management: Fund allocation, fee collection, and reward distribution

๐Ÿ”น External Integrations

  • ICPSwap v3: Decentralized exchange for token trading
  • ICP Ledger: Native ICP token transactions
  • ckUSDC Ledger: Chain-key USDC token operations

Data Flow Architecture

  1. User Authentication Flow
sequenceDiagram
    participant U as User
    participant P as Plug Wallet
    participant B as Backend Canister
    participant S as Storage

    U->>P: Request Connection
    P->>B: Authenticate User
    B->>S: Store User Session
    S-->>B: Session Confirmed
    B-->>P: Authentication Success
    P-->>U: Connected & Authenticated
Loading
  1. Contribution Flow
sequenceDiagram
    participant U as User
    participant F as Frontend
    participant P as Plug Wallet
    participant A as Agent Canister
    participant I as ICPSwap
    participant L as Pool

    U->>F: Initiate Contribution
    F->>P: Request ICP Transfer
    P->>A: Send ICP to Treasury
    A->>I: Swap ICP for Pool Tokens
    I-->>A: Tokens Received
    A->>L: Provide Liquidity
    L-->>A: Send Position Id
    A-->>F: Contribution Complete
    F-->>U: Success Notification
Loading
  1. Chat & Investment Integration
sequenceDiagram
    participant U as User
    participant B as Backend Canister
    participant A as Agent Canister
    participant D as DeFi Operations
    participant E as External Pool

    U->>B: Send Chat Message
    B->>A: Trigger Investment Logic
    A->>D: Analyze Pool Opportunities
    D->>E: Execute DeFi Strategy
    E-->>D: Strategy Results
    D-->>A: Investment Complete
    A-->>B: Update Chat Context
    B-->>U: Enhanced Chat Response
Loading
  1. Reward Distribution Flow
sequenceDiagram
    participant P as Pool
    participant A as Agent Canister
    participant S as Share Calculator
    participant B as Backend Canister
    participant U as User

    P->>A: Pool Fees Generated
    A->>S: Calculate User Shares
    S->>A: Share Percentages
    A->>B: Update User Rewards
    B->>U: Reward Notification
    U->>B: Request Reward Claim
    B->>A: Process Withdrawal
    A->>U: Transfer Rewards
Loading

Security Architecture

  • Canister Isolation: Separate canisters for different concerns
  • Cross-Canister Authentication: Secure communication between canisters
  • Wallet Integration: User-controlled private keys via Plug wallet
  • On-Chain Verification: All transactions verified on the IC blockchain

Scalability Features

  • Modular Design: Independent canisters can be upgraded separately
  • Horizontal Scaling: Multiple canister instances for high load
  • Efficient Storage: Optimized data structures for chat and financial data
  • Caching Layer: In-memory caching for frequently accessed data

โšก Quick Start

Get OPTIC running locally in just a few minutes!

Prerequisites

Before you begin, ensure you have the following installed:

Installation

  1. Clone the repository
# Fork and clone your own copy
git clone https://github.com/<YOUR_USERNAME>/optic.git

# Or clone directly from main repository
git clone https://github.com/divin3circle/optic.git

cd optic
  1. Install dependencies
# Install root dependencies
pnpm install

# Install frontend dependencies
cd src/frontend && pnpm install && cd ../..

Development

  1. Start the Internet Computer replica
# Start IC replica in background
dfx start --clean --background

# Verify it's running
dfx ping
  1. Deploy canisters locally
# Deploy backend canister
dfx deploy backend

# Deploy frontend canister
dfx deploy frontend

# Or deploy all at once
dfx deploy
  1. Start the development server
# Navigate to frontend and start dev server
cd src/frontend
pnpm run dev
  1. Set up the Agent Canister

The agent canister requires special setup. Follow the detailed guide at: ๐Ÿ‘‰ Optic Agent Setup

# Note: Agent canister should be deployed on the playground
# to avoid cross-subnet call errors

Troubleshooting

๐Ÿ”ง Common Issues & Solutions

Problem: dfx start fails with port errors

# Solution: Kill existing processes and restart
sudo lsof -ti:4943 | xargs kill -9
dfx start --clean --background

Problem: Frontend can't connect to backend

# Solution: Regenerate canister declarations
dfx generate backend
cd src/frontend && pnpm run dev

Problem: Plug Wallet connection issues

  • Ensure you're on the correct network (Local/Mainnet)
  • Clear browser cache and reconnect wallet
  • Check that canisters are deployed and running

Problem: Build failures

# Solution: Clean and reinstall dependencies
rm -rf node_modules src/frontend/node_modules
pnpm install
cd src/frontend && pnpm install

Need help? Open an issue on GitHub with:

  • Operating system and versions
  • Full error messages
  • Steps to reproduce the problem

๐Ÿ’ฐ Revenue Model

OPTIC employs a sustainable, value-aligned revenue model that grows with platform usage:

๐Ÿ  Room Creation Fees

  • Small setup fee for creating new chat rooms
  • Cycle funding included to power room operations
  • Anti-spam measure while keeping barriers low

๐Ÿ“ˆ Performance-Based Fees

  • Success fee charged only on profitable withdrawals
  • Percentage of earnings (not principal) ensures alignment
  • Transparent calculation shown before each withdrawal

๐Ÿค– Premium AI Features

  • Freemium model for basic AI insights
  • Subscription tiers for advanced analytics and predictions
  • Pay-per-query option for occasional users

๐Ÿ”ฎ Future Revenue Streams

  • Premium room features (advanced analytics, custom branding)
  • Enterprise solutions for organizations and DAOs
  • Third-party integrations and API access
  • NFT marketplace for room achievements and badges

All fees are transparent, competitive, and designed to sustain long-term platform development while maximizing user value.

๐Ÿ”„ Limitations and Improvements

OPTIC is actively evolving. Here are current limitations and our roadmap for addressing them:

๐Ÿšง Current Limitations

1. Single Treasury Model

  • Issue: All funds currently route to a single treasury canister
  • Impact: Limited scalability and increased risk concentration
  • Roadmap: Individual canister per chat room with dedicated treasury

2. Fixed Room Parameters

  • Issue: Room settings are immutable after creation
  • Impact: No flexibility for changing investment strategies
  • Roadmap: DAO-like governance system for parameter updates via proposals

3. Limited Token Support

  • Issue: Currently supports only ICP/ckUSDC pool
  • Impact: Reduced diversification options for users
  • Roadmap: Multi-token contributions and diversified pool strategies

4. No User Verification

  • Issue: Anonymous users may create spam or abuse systems
  • Impact: Potential security and compliance concerns
  • Roadmap: Optional KYC with mobile OTP verification

๐Ÿš€ Planned Improvements

Phase 1: Decentralized Architecture

  • Individual canister per chat room
  • Isolated treasury management
  • Cross-canister communication protocols

Phase 2: Advanced DeFi Features

  • Multi-pool investment strategies
  • Yield farming optimization
  • Cross-chain liquidity provision

Phase 3: Governance & DAO Features

  • Community-driven room management
  • Proposal-based parameter updates
  • Decentralized dispute resolution

Phase 4: Enterprise & Compliance

  • Optional KYC/AML integration
  • Institutional treasury management
  • Regulatory compliance tools

๐Ÿ’ก Community Contributions

We're not actively looking for community contributions! We hope to open this as soon as possible.


OPTIC represents a unique approach to Web3 messaging on the Internet Computer. By seamlessly bridging social interaction with DeFi opportunities, we're making blockchain adoption intuitive and rewarding for everyday users.

Built with โค๏ธ on the Internet Computer

About

Optic is the new way of chatting with friends on the self-writing internet. Make you time worthwhile by earn from you interactions.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •