Skip to content

Latest commit

 

History

History
203 lines (145 loc) · 6.17 KB

File metadata and controls

203 lines (145 loc) · 6.17 KB

IntentLP — Testing Guide

Contract: 0x8BFBAA48cB579600FBDe29aAAf04965C3FDBDac0 (Arbitrum Sepolia)
Frontend: https://intent-lp-hook.vercel.app
Chain ID: 421614


Prerequisites

  • MetaMask (or any WalletConnect wallet)
  • ETH on Arbitrum Sepolia — you have ~0.224 ETH (enough for ~20+ txs)
  • USDC on Arbitrum Sepolia — you have ~20 USDC (from Circle faucet)

⚡ Gas-Saving Tips

Action Gas Cost Notes
Swap Simulator (Simulated mode) Free No tx needed — uses sample data
Swap Simulator (Live mode) Free Read-only previewSwap() call
Register Intent ~85,000 gas 1 tx — ~0.0003 ETH
Approve USDC ~46,000 gas 1 tx — one-time
Deposit USDC ~60,000 gas 1 tx — ~0.0002 ETH
Claim Rewards ~50,000 gas 1 tx — ~0.0002 ETH
Set Reward Rate ~35,000 gas 1 tx — ~0.0001 ETH
Bridge Intent ~200,000 gas Heaviest — ~0.0007 ETH

Full test run costs < 0.002 ETH total. Your 0.224 ETH covers ~100 test cycles.


1. Gas-Free: Simulate Swaps (No Transaction Needed)

This is the fastest way to verify the hook logic — zero cost, zero txs.

Simulated Mode (Default)

  1. Go to https://intent-lp-hook.vercel.app/swap
  2. Connect your wallet
  3. Enter a volume and click Simulate
  4. The app uses sample intent data to preview results

Edge Cases to Test

Volume Expected Result
0.05 ETH Violation (below min 0.1)
5 ETH Compliant (within window)
75 ETH Violation (above max 50)

Live Mode

  1. Click the Live toggle (visible when connected)
  2. Queries the deployed contract's previewSwap() directly — free, read-only
  3. If no intents exist yet on-chain, it falls back to sample data

2. Low-Gas: Register an Intent (1 tx)

Flow

  1. Open https://intent-lp-hook.vercel.app/register
  2. Connect your wallet (Arbitrum Sepolia)
  3. Set conditions:
    • Min Swap Volume: 0.1 ETH
    • Max Swap Volume: 50 ETH
    • Max Slippage: 100 bps (1%)
    • Active Hours: 917 UTC
  4. Review the Intent Preview card
  5. Click Register Intent → Confirm MetaMask tx (~$0.001)
  6. ✅ Success screen: "Intent Registered!"

Verify

  • Check the success green banner
  • Navigate to /bridge — the "Active Intent Found" banner confirms it's stored on-chain
  • Go back to /swap and toggle Live — now your real intent is queried

3. Low-Gas: Rewards (2-3 txs)

Quick Check (no tx needed)

  1. Go to https://intent-lp-hook.vercel.app/rewards
  2. View stats: Your USDC balance, Pending Rewards, Reward Pool — all read-only

Full Cycle (optional, ~3 txs)

  1. Approve USDC (one-time, ~46K gas)
  2. Deposit some of your 20 USDC into the reward pool
  3. Set Rate (USDC per second distribution rate)
  4. Wait a moment for accrual, then Claim your pending USDC

4. Medium-Gas: Bridge an Intent (1 tx)

Requires an active intent (step 2) and USDC balance.

  1. Go to https://intent-lp-hook.vercel.app/bridge
  2. Confirm the green "Active Intent Found" banner
  3. Fill the form (use 10 USDC input to conserve balance):
    • Input Amount: 10 USDC
    • Output Amount: 9.8 USDC
    • Destination Chain: Arbitrum One (42161)
    • Recipient: your address (auto-filled)
  4. Click Bridge Intent → Confirm MetaMask tx
  5. ✅ "Bridge submitted! Your intent is deactivated on this chain."

Verify

  • Go back to /register → simulate → intent is no longer counted
  • Go to /bridge → shows "No active intent found"

5. No-Gas: Run Tests Locally

Best way to test everything — uses Foundry's local EVM, zero real gas cost.

Unit Tests (39 tests)

forge test --match-path test/IntentLPHook.t.sol -vvv

Integration Tests (23 tests — needs .env RPC)

forge test --match-path test/IntentLPHookIntegration.t.sol -vvv

All 63 Tests

make test-v

Local Fork + Frontend (full E2E, 0 wallet gas)

# Terminal 1: Fork Arbitrum Sepolia
anvil --fork-url $ARBITRUM_SEPOLIA_RPC_URL

# Terminal 2: Deploy to fork
forge script script/Deploy.s.sol \
  --rpc-url http://localhost:8545 \
  --broadcast \
  --private-key 0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80

# Terminal 3: Frontend on localhost
cd frontend && npm run dev

Then use http://localhost:5173 with MetaMask on localhost:8545 (chain ID 31337) — all txs are free.


6. Recommended Test Order

Step Method Gas Cost Time
1 Run make test-v (63 forge tests) Zero 30s
2 Swap Simulator on live site Zero 30s
3 Register one intent (live) ~0.0003 ETH 15s
4 Live mode swap preview Zero 10s
5 Rewards read-only check Zero 10s
6 Bridge intent (optional) ~0.0007 ETH 20s

Demo Day Checklist

  • Wallet funded — 0.224 ETH + 20 USDC on Arbitrum Sepolia ✅
  • Network added to MetaMask (Arbitrum Sepolia, Chain ID 421614)
  • Frontend loaded at https://intent-lp-hook.vercel.app
  • Run make test-v — all 63 tests pass
  • Swap Simulator — test compliant + violating volumes
  • Toggle Live on-chain preview
  • Register intent (1 tx, ~0.0003 ETH)
  • Live mode confirms intent counted
  • Rewards page — view balances (read-only)
  • Bridge intent (1 tx, ~0.0007 ETH)
  • Verify deactivation after bridge
  • Backup plan ready: local anvil fork + local frontend
  • Total gas spent: ~0.001 ETH — leaves 0.223 ETH remaining

Troubleshooting

Problem Fix
"No contract deployed on this chain" Switch MetaMask to Arbitrum Sepolia (421614)
Transaction keeps pending Increase gas limit or use a higher max priority fee
"No active intent found" Register an intent first on /register
USDC approval fails Ensure you have enough USDC balance
Bridge confirmation shows wrong amounts Check USDC decimals (6, not 18)
Live mode shows zero intents No one has registered an intent in that pool — switch to sample data