> ## Documentation Index
> Fetch the complete documentation index at: https://docs.predictaa.xyz/llms.txt
> Use this file to discover all available pages before exploring further.

# Smart contract status

# Smart Contract Deployment Status

**Last Updated:** January 27, 2026\
**Network:** Base Sepolia (Chain ID: 84532)\
**Latest Deployment:** January 26, 2026 at 15:57:37 UTC

***

## ✅ Current Deployed Contracts (v2.1.0)

### 1. PredictaCoreV2 (UUPS Upgradeable Proxy)

**Proxy Address:** `0x0828FCc983E7d0e9DD58B2a0A985c62e3ecb6eB6`\
**Implementation Address:** `0xda057595F1667FfA1436eFCd98102b437c3bF7f1`\
**Version:** 2.1.0 (with Conditional Orders)\
**Deployment Date:** January 26, 2026 15:57:37 UTC\
**Upgrade Transaction:** `0x262c48eb0bc740e689ff96de61b438330de25e4575449b3100c15398e4345c3c`

**Features:**

* ✅ Gasless betting with PUSD token
* ✅ Market creation and resolution
* ✅ Limit orders (on-chain)
* ✅ Conditional orders: Take Profit, Stop Loss, Trailing Stop Loss
* ✅ UUPS upgradeable pattern
* ✅ ReentrancyGuard protection
* ✅ Ownable access control

**Code Reference:** [contracts/PredictaCoreV2.sol](../contracts/PredictaCoreV2.sol)

***

### 2. SimplePUSD (ERC-20 Token)

**Address:** `0x3a0bc621A6f1A80529C6C214c3dAa9386D045957`\
**Symbol:** PUSD\
**Decimals:** 18\
**Type:** Non-transferable platform token\
**Purpose:** Gasless betting currency

**Features:**

* ✅ Minting controlled by RewardsController
* ✅ Non-transferable (platform-specific)
* ✅ ERC-20 compatible for approvals

**Code Reference:** [contracts/SimplePUSD.sol](../contracts/SimplePUSD.sol)

***

### 3. SimplePUSDController (Rewards Controller)

**Proxy Address:** `0x0b861fBDEeC6f6800019453189EFfB25a5f84828`\
**Purpose:** Mint PUSD for user rewards and signup bonuses\
**Features:**

* ✅ 100 PUSD signup bonus
* ✅ Milestone-based rewards
* ✅ Admin-controlled minting

**Code Reference:** [contracts/SimplePUSDController.sol](../contracts/SimplePUSDController.sol)

***

## 📊 Deployment History

### v2.1.0 - Conditional Orders Upgrade

**Date:** January 26, 2026 15:57:37 UTC\
**Broadcast:** `/broadcast/UpgradePredictaCoreV2.s.sol/84532/run-1769443057484.json`

**Changes:**

* Added `ConditionalOrder` struct and mappings
* Added `ConditionalOrderType` enum (TP/SL/TSL)
* Added functions:
  * `createConditionalOrder()`
  * `executeConditionalOrder()`
  * `updateTrailingStop()`
  * `cancelConditionalOrder()`
  * `getUserConditionalOrders()`
  * `getMarketConditionalOrders()`

**Transactions:**

1. Deploy new implementation: `0x42bc2e8ae0ce59d4ed1d1e404a328287f5f9239eab86247a7e1486bef9005ec7`
2. Upgrade proxy: `0x262c48eb0bc740e689ff96de61b438330de25e4575449b3100c15398e4345c3c`
3. Configure PUSD token: `0xa54b3315e3295c619f4dcc8a2288181cca2cf35b69d1166b0e8c0341655b6181`
4. Configure rewards controller: `0x1c469b9823eeb9643592105f1d96bdffaf51d59e177d645935527dcf203416eb`

***

### v2.0.0 - PUSD Integration

**Date:** January 25, 2026 16:57 UTC\
**Broadcast:** `/broadcast/UpgradePredictaCoreV2.s.sol/84532/run-1769360223728.json`

**Changes:**

* Migrated from ETH-based to PUSD-based betting
* Added gasless transaction support
* Integrated with SimplePUSD token
* Added RewardsController support
* Maintained backward compatibility with ETH betting

***

### v1.0.0 - Initial PUSD Ecosystem Deployment

**Date:** January 25, 2026 16:55 UTC\
**Broadcast:** `/broadcast/DeployPUSDEcosystem.s.sol/84532/run-1769360100543.json`

**Deployed:**

* SimplePUSD token
* SimplePUSDController proxy
* Initial token configuration

***

## 🔍 Contract Verification Status

### PredictaCoreV2

* ✅ Source code deployed
* ✅ UUPS proxy verified
* ✅ Implementation contract functional
* ⚠️ Etherscan verification: **PENDING** (manual verification needed)

### SimplePUSD

* ✅ Source code deployed
* ⚠️ Etherscan verification: **PENDING**

### SimplePUSDController

* ✅ Source code deployed
* ✅ UUPS proxy configured
* ⚠️ Etherscan verification: **PENDING**

***

## 📝 Configuration Summary

### PredictaCoreV2 Settings

```solidity theme={null}
pusdToken: 0x3a0bc621A6f1A80529C6C214c3dAa9386D045957
rewardsController: 0x0b861fBDEeC6f6800019453189EFfB25a5f84828
minBetAmount: 1000000000000000000 (1 PUSD)
owner: 0x2aafc3579d8977dd29120f4600f9a2dce5804415
```

### Keeper Wallet

**Address:** Configured via `KEEPER_PRIVATE_KEY` environment variable\
**Purpose:** Execute automated limit orders and conditional orders\
**Gas:** Sponsored by Pimlico/CDP paymasters (gasless)\
**Execution Frequency:** Every 30 seconds via Cloud Scheduler

***

## 🔄 Upgrade Process

### UUPS Upgrade Pattern

The contract uses OpenZeppelin's UUPS (Universal Upgradeable Proxy Standard) pattern:

1. **Proxy Contract:** `0x0828FCc983E7d0e9DD58B2a0A985c62e3ecb6eB6` (never changes)
2. **Implementation Contract:** `0xda057595F1667FfA1436eFCd98102b437c3bF7f1` (can be upgraded)
3. **Storage:** All state stored in proxy, preserved during upgrades

### How to Upgrade

```bash theme={null}
# 1. Update contract code in contracts/PredictaCoreV2.sol
# 2. Run Foundry script
forge script scripts/UpgradePredictaCoreV2.s.sol:UpgradePredictaCoreV2 \
  --rpc-url base-sepolia \
  --broadcast \
  --verify \
  -vvvv

# 3. Verify deployment
cast call 0x0828FCc983E7d0e9DD58B2a0A985c62e3ecb6eB6 "version()(string)" \
  --rpc-url https://sepolia.base.org
```

***

## 🧪 Testing Status

### Unit Tests

* ✅ Market creation and betting
* ✅ PUSD approval and transfer
* ✅ Limit order placement
* ✅ Conditional order creation
* ⚠️ Conditional order execution: **NEEDS TESTING**
* ⚠️ Trailing stop loss updates: **NEEDS TESTING**

### Integration Tests

* ✅ Gasless transactions via Pimlico
* ✅ Gasless transactions via CDP
* ✅ PUSD minting and distribution
* ⚠️ Keeper wallet execution: **NEEDS TESTING**
* ⚠️ Cross-contract interactions: **NEEDS TESTING**

### Test Command

```bash theme={null}
# Run all tests
forge test -vv

# Run specific test file
forge test --match-contract PredictaCoreV2Test -vvv

# Run with gas reporting
forge test --gas-report
```

***

## 🐛 Known Issues

### Issue #1: Firestore Sync for Automated Orders

**Severity:** 🔴 Critical\
**Status:** Identified, solution proposed\
**Affected:** Limit orders, TP/SL/TSL executed by keeper wallet\
**Details:** See [TRADING\_SYSTEM\_ANALYSIS.md](./TRADING_SYSTEM_ANALYSIS.md#identified-issues)

### Issue #2: Etherscan Verification

**Severity:** 🟡 Medium\
**Status:** Pending manual verification\
**Affected:** All contracts\
**Action Required:** Manually verify contracts on Basescan

***

## 📦 Contract Sizes

| Contract             | Size    | Limit | Status |
| -------------------- | ------- | ----- | ------ |
| PredictaCoreV2       | \~18 KB | 24 KB | ✅ OK   |
| SimplePUSD           | \~2 KB  | 24 KB | ✅ OK   |
| SimplePUSDController | \~8 KB  | 24 KB | ✅ OK   |

***

## 🔗 Important Links

### Blockchain Explorers

* **Base Sepolia:** [https://sepolia.basescan.org](https://sepolia.basescan.org)
* **PredictaCoreV2 Proxy:** [https://sepolia.basescan.org/address/0x0828FCc983E7d0e9DD58B2a0A985c62e3ecb6eB6](https://sepolia.basescan.org/address/0x0828FCc983E7d0e9DD58B2a0A985c62e3ecb6eB6)
* **PUSD Token:** [https://sepolia.basescan.org/address/0x3a0bc621A6f1A80529C6C214c3dAa9386D045957](https://sepolia.basescan.org/address/0x3a0bc621A6f1A80529C6C214c3dAa9386D045957)
* **Controller:** [https://sepolia.basescan.org/address/0x0b861fBDEeC6f6800019453189EFfB25a5f84828](https://sepolia.basescan.org/address/0x0b861fBDEeC6f6800019453189EFfB25a5f84828)

### Documentation

* [Trading System Analysis](./TRADING_SYSTEM_ANALYSIS.md)
* [Smart Contract API](../CLOB_API_DOC.md)
* [Architecture Overview](./architecture.md)
* [Deployment Guide](./deployment-guide.md)

***

## 🚀 Next Steps

### Immediate Actions (This Week)

1. **Verify contracts on Basescan**
   * PredictaCoreV2 implementation
   * SimplePUSD token
   * SimplePUSDController

2. **Test keeper wallet execution**
   * Place limit orders on testnet
   * Verify automated execution works
   * Monitor Cloud Scheduler logs

3. **Implement Firestore sync fix**
   * Add Firestore updates to keeper execution
   * Test with real orders
   * Deploy updated Cloud Function

### Short-term (Next 2 Weeks)

4. **Add contract events indexing**
   * Event listener for `LimitOrderExecuted`
   * Event listener for `ConditionalOrderExecuted`
   * Event listener for `TrailingStopUpdated`

5. **Build event-driven indexer**
   * Cloud Function to parse events
   * Update Firestore portfolios
   * Handle all order types

### Long-term (Next Month)

6. **Security audit preparation**
   * Comprehensive test coverage
   * Gas optimization
   * Access control review

7. **Mainnet deployment planning**
   * Migration strategy
   * User communication
   * Rollback procedures

***

## 🔐 Security Considerations

### Access Control

* ✅ Owner-only functions protected with `onlyOwner` modifier
* ✅ UUPS upgrade restricted to owner
* ✅ Reentrancy guards on critical functions
* ✅ RewardsController minting limited to authorized address

### Emergency Procedures

* **Pause Trading:** Update `minBetAmount` to max value (temporary)
* **Upgrade Contract:** Deploy new implementation via UUPS
* **Emergency Withdrawal:** Admin can withdraw contract PUSD balance
* **Kill Switch:** Transfer ownership to multisig or burn (irreversible)

***

## 📈 Gas Optimization

### Function Gas Costs (Estimated)

| Function                    | Avg Gas   | Cost @ 1 Gwei |
| --------------------------- | --------- | ------------- |
| `placeBetWithPUSD()`        | \~150,000 | \$0.0002      |
| `placeLimitOrder()`         | \~180,000 | \$0.0003      |
| `createConditionalOrder()`  | \~200,000 | \$0.0003      |
| `executeConditionalOrder()` | \~120,000 | \$0.0002      |
| `updateTrailingStop()`      | \~80,000  | \$0.0001      |

**Note:** All user transactions are gasless (sponsored by paymasters)

***

## 🎯 Summary

### ✅ What's Working

* PredictaCoreV2 v2.1.0 deployed and operational
* PUSD token integrated with gasless transactions
* Limit orders and conditional orders on-chain
* UUPS upgradeable architecture
* Keeper wallet configured for automated execution

### ⚠️ What Needs Attention

* Etherscan verification pending
* Firestore sync for automated orders missing
* Keeper execution needs production testing
* Event indexing not yet implemented

### 🎉 Major Achievements

* Successfully upgraded to v2.1.0 with conditional orders
* All contracts deployed on Base Sepolia
* Gasless transaction architecture working
* Blockchain-first architecture implemented

**Status:** Production-ready for testnet, needs fixes before mainnet
