Skip to content

dinxsh/PolyShark

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

20 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🦈 PolyShark

"If markets contradict themselves, eat the contradiction."

PolyShark

Permission-safe arbitrage agent for Polymarket using ERC-7715 Advanced Permissions + Envio HyperIndex.

MetaMask Envio Rust Polygon


⚑ The Problem β†’ Solution

Traditional Bots PolyShark + ERC-7715
❌ Popup every trade βœ… One popup, then autonomous
❌ Trust-based limits βœ… Cryptographic enforcement
❌ Unlimited risk βœ… $10/day max, instant revoke
❌ No data freshness βœ… Halts on stale data

πŸ’‘ This is the last popup you'll see for the next thousand trades.


🎯 How It Works

USER β†’ Grant Permission (once)
        ↓
MetaMask Smart Account (ERC-7715) β†’ Enforced Daily Limit
        ↓
PolyShark Agent (Rust)
β”œβ”€β”€ Constraint Engine    β†’ YES + NO = 1 violations
β”œβ”€β”€ Arbitrage Detector   β†’ Expected profit calculation
└── Execution Engine     β†’ Permission-validated trades
        ↓                       ↑
Polymarket Contracts ←── Envio HyperIndex (~150ms)

5 Steps: Detect mispricing β†’ Validate allowance β†’ Execute trade β†’ Adapt strategy β†’ Halt if stale


πŸ›‘οΈ Safety by Design

Layer Protection
ERC-7715 Cryptographic daily limits, instant revocation
Envio ~150ms latency, auto-halt if >5s stale
Strategy Aggressive→Normal→Conservative based on budget
Failures 3 strikes β†’ Safe mode (5 min cooldown)
# config.toml
[safety]
max_data_delay_ms = 5000
max_consecutive_failures = 3

πŸ—οΈ Architecture

Architecture

src/
β”œβ”€β”€ metamask.rs    β†’ ERC-7715 client, strategy modes
β”œβ”€β”€ wallet.rs      β†’ Permission-aware execution
β”œβ”€β”€ market.rs      β†’ Envio data consumer
β”œβ”€β”€ constraint.rs  β†’ Logical arbitrage (YES+NO=1)
β”œβ”€β”€ arb.rs         β†’ Profit calculation
β”œβ”€β”€ execution.rs   β†’ Trade engine (fees, slippage, fills)
└── engine.rs      β†’ Main loop + safety halt

πŸ“Š Permission Spec

{
  "erc7715:permission": {
    "type": "spend",
    "token": { "symbol": "USDC", "address": "0x2791Bca1f2..." },
    "limit": { "amount": 10.0, "period": "day" },
    "duration": { "days": 30 },
    "scope": { "protocol": "polymarket" }
  }
}
Property Value
Token USDC (Polygon)
Limit 10 USDC/day (configurable 5-50)
Duration 30 days
Revocation Instant, one-click

πŸ› οΈ Tech Stack

Component Tech
Agent Rust (async, high-perf)
Wallet MetaMask Smart Account
Permissions ERC-7715
Data Envio HyperIndex
Chain Polygon (137)
UI HTML/CSS/JS Dashboard

πŸš€ Quick Start

git clone https://github.com/dinxsh/polyshark
cp .env.example .env
cargo build --release && cargo run

Open dashboard/index.html β†’ Connect MetaMask β†’ Grant permission β†’ Watch autonomous trading.


πŸ“ˆ Strategy Modes

Mode Budget Min Edge
🟒 Aggressive >70% left β‰₯1%
🟑 Normal 30-70% β‰₯2%
πŸ”΄ Conservative <30% β‰₯5%

πŸ”§ Use as Template

PolyShark = reference implementation for ERC-7715 agents.

Swap layers:

  • market.rs β†’ Your data source (Uniswap, OpenSea, etc.)
  • constraint.rs β†’ Your domain logic (DEX routes, NFT bids)
  • Keep permission layer unchanged

See examples/gator-bridge.ts for TypeScript example.


πŸ“š Docs

Doc Purpose
metamask/v1.md ERC-7715 Architecture
spec.md Technical Spec
demo-script.md Demo Walkthrough
HACKQUEST_SUBMISSION.md Hackathon Submission

πŸ”— Resources

Delegation Toolkit β€’ Smart Accounts β€’ ERC-7715 β€’ create-gator-app β€’ Envio


MIT License β€’ Built for MetaMask x Envio Hackathon

About

find mispriced edges between related Polymarket markets 🦈

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published