Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions PiRC1/4-allocation/4-allocation design 1.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,4 +151,56 @@ xychart-beta
- Starting LP spot price is $p_{list} = \frac{C}{T}$
- Highly engaged participants pay $0.909p_{list}$. Medimum engaged participants pay $0.952p_{list}$. Least engaged participants pay $p_{list}$

---

## 4.X Allocation Invariants and Consistency Conditions

To preserve economic integrity and deterministic behavior of the allocation model,
the following invariants must hold:

### (1) Emission Conservation

Total tokens distributed to participants must equal:

Tpurchase + Tengage

Formally:

Σ_i (t_i^base + t_i^engage) = Tpurchase + Tengage

---

### (2) Liquidity Conservation

All committed Pi must enter the Liquidity Pool:

Σ_i c_i = C

The LP must be initialized strictly with:

(C, Tliquidity)

No intermediate swap operation is allowed during initialization.

---

### (3) Monotonicity

For any two participants i and j within the same engagement tier:

If c_i > c_j ⇒ t_i^base > t_j^base
If c_i > c_j ⇒ t_i^engage ≥ t_j^engage

---

### (4) Determinism

Given identical inputs:

{c_i}, engagement ranks {r_i}, and fixed parameters,

the allocation outcome must be uniquely determined.

No stochastic or discretionary adjustment may alter final token amounts.

Next: [`5-tge-state`](<../5-tge-state/5-tge-state design 1.md>)
166 changes: 166 additions & 0 deletions PiRC1/6-adaptive-proof-of-contribution.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,166 @@
# 6 — Adaptive Proof of Contribution (APoC)

## Overview
Adaptive Proof of Contribution (APoC) is an AI-assisted reward allocation layer designed to complement the existing ecosystem token allocation models.

Instead of distributing tokens purely based on activity quantity, APoC evaluates **quality, authenticity, economic impact, and trustworthiness** of contributions.

Goal:
Transform token distribution from "activity mining" → "value mining".

---

## Problem Addressed

Traditional Web3 incentive models suffer from:

- Bot farming
- Sybil attacks
- Engagement spam
- Liquidity extraction behavior
- Short-term participation incentives

Even activity-based models can be gamed if quantity > quality.

APoC introduces a dynamic scoring layer to ensure:
> Tokens flow to contributors who create real economic value.

---

## Core Concept

Each participant receives a dynamic **Contribution Score (CS)**:

CS = Activity × Impact × Trust × NetworkEffect × Integrity

Reward emission is proportional to CS instead of raw activity.

---

## Contribution Score Components

### 1. Activity Score (A)
Measures measurable actions:
- Transactions
- Purchases
- Listings
- Development commits
- Service usage

Normalized logarithmically to prevent spam inflation.

---

### 2. Impact Score (I)
Measures economic usefulness:
- User retention caused
- Volume generated
- Repeat usage
- External adoption

---

### 3. Trust Score (T)
Derived from:
- Account age
- KYC confidence
- Historical behavior
- Dispute history
- Counterparty feedback

Non-transferable and slowly changing.

---

### 4. Network Effect Score (N)
Rewards users who bring valuable participants:
- Active referrals
- Builder ecosystems
- Marketplace creation

Not based on count — based on downstream contribution quality.

---

### 5. Integrity Score (G)
AI fraud detection output:
- Bot probability
- Sybil clustering detection
- Abnormal interaction patterns
- Velocity anomalies

If flagged → reward decay multiplier applies.

---

## Final Formula

RewardShare = CS_user / Σ(CS_all_users)

TokenReward = DailyEmission × RewardShare

---

## Emission Dampening
To prevent reward draining:

If ecosystem velocity spikes:
EmissionRate decreases

If ecosystem utility increases:
EmissionRate increases

---

## Anti-Manipulation Design

| Attack Type | Mitigation |
|-----------|------|
| Bot farms | Behavioral clustering AI |
| Sybil accounts | Graph identity analysis |
| Wash trading | Economic circularity detection |
| Spam actions | Log normalization |
| Referral abuse | Downstream contribution weighting |

---

## Architecture

Client Activity → App Server → AI Scoring Engine → Oracle → Smart Contract

AI does NOT distribute tokens.
AI only produces a signed Contribution Score.

Smart contract verifies signature and releases rewards trustlessly.

---

## Smart Contract Pseudocode

```solidity
struct Contribution {
uint256 score;
uint256 timestamp;
}

mapping(address => Contribution) public contributions;

function submitScore(
address user,
uint256 score,
bytes calldata oracleSignature
) external {

require(verifyOracle(user, score, oracleSignature), "Invalid oracle");

contributions[user] = Contribution(score, block.timestamp);
}

function claimReward() external {

uint256 reward = calculateReward(msg.sender);

require(reward > 0, "No reward");

token.mint(msg.sender, reward);
}
14 changes: 14 additions & 0 deletions PiRC2_Implementation_Pack/PROPOSAL_V2.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# PiRC2 & PiRC-45: Integrated Economic & Technical Framework

## 1. Mathematical Specification (WCF)
The Working Capital Factor (WCF) is calculated as:
$$WCF_{t} = (WCF_{t-1} \cdot e^{-\lambda \Delta t}) + \alpha \sum \ln(V_i + 1)$$

## 2. Technical Scope
- **PiRC-45:** Standardizes Metadata Schema to resolve Issue #16.
- **PiRC2:** Introduces the "Justice Engine" on Soroban Smart Contracts.

## 3. Threat Model & Mitigations
- **Sybil Attacks:** Mitigated via PoV (Proof of Value) using PiRC-45 metadata.
- **State Bloat:** Mitigated via Lazy State Initialization.

35 changes: 35 additions & 0 deletions PiRC2_Implementation_Pack/PiRC2Connect.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/**
* PiRC2 Connect SDK v1.0
* Unified interface for Retail, Gaming, and Services.
*/
class PiRC2Connect {
constructor(apiKey, sector) {
this.apiKey = apiKey;
this.sector = sector;
this.protocolFee = 0.005; // 0.5% fixed fee
}

async createPayment(amount, description) {
const feeAmount = amount * this.protocolFee;
console.log(`[PiRC2-${this.sector}] Initiating Payment...`);

const txPayload = {
total: amount,
net_to_merchant: amount - feeAmount,
protocol_fee: feeAmount,
metadata: {
desc: description,
pirc2_compliant: true,
timestamp: Date.now()
}
};

// Logic to interface with Pi Wallet goes here
return txPayload;
}
}

// Usage Example:
// const retailApp = new PiRC2Connect("STORE_001", "Retail");
// retailApp.createPayment(100, "Coffee & Sandwich");

37 changes: 37 additions & 0 deletions PiRC2_Implementation_Pack/PiRC2JusticeEngine.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;

/**
* @title PiRC2 Justice Engine
* @author Muhammad Kamel Qadah
* @notice Protects Mined Pi by applying the 10,000,000:1 Weighted Contribution Factor.
*/
contract PiRC2JusticeEngine {
// Constants for WCF (Weighted Contribution Factor)
uint256 public constant W_MINED = 10**7; // Weight: 1.0 (internal precision)
uint256 public constant W_EXTERNAL = 1; // Weight: 0.0000001

struct PioneerProfile {
uint256 minedBalance; // Captured from Mainnet Snapshot
uint256 externalBalance; // Bought from exchanges
uint256 engagementScore; // Bonus for real-world usage
}

mapping(address => PioneerProfile) public registry;
uint256 public totalGlobalPower;

// Updates the power (L_eff) of a wallet
function getEffectivePower(address _pioneer) public view returns (uint256) {
PioneerProfile memory p = registry[_pioneer];
// Formula: L_eff = (Mined * 10,000,000) + (External * 1)
uint256 basePower = (p.minedBalance * W_MINED) + (p.externalBalance * W_EXTERNAL);

if (p.engagementScore > 0) {
return basePower + (basePower * p.engagementScore / 100);
}
return basePower;
}

// Records fee contribution to the global pool
receive() external payable {}
}
21 changes: 21 additions & 0 deletions PiRC2_Implementation_Pack/PiRC2Metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"protocol": "PiRC2",
"version": "2.0",
"asset_classification": {
"type": "Mined_Pi",
"wcf_multiplier": 10000000,
"liquidity_status": "Locked_Escrow",
"provenance": "Original_Mining_Phase"
},
"utility_sectors": [
"Retail",
"Gaming",
"Advertising",
"RealEstate"
],
"compliance": {
"product_first": true,
"zero_inflation": true
}
}

26 changes: 26 additions & 0 deletions PiRC2_Implementation_Pack/PiRC2Simulator.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import math

class PiRC2Economy:
def __init__(self, initial_tvl=0, fee_rate=0.005):
self.tvl = initial_tvl
self.fee_rate = fee_rate

def simulate_growth(self, daily_volume, days=365):
print(f"{'Day':<10} | {'Daily Volume (Pi)':<20} | {'Total TVL (Pi)':<20}")
print("-" * 55)

current_volume = daily_volume
for day in range(1, days + 1):
fees = current_volume * self.fee_rate
self.tvl += fees

if day % 30 == 0: # Print update every month
print(f"{day:<10} | {current_volume:<20,.2f} | {self.tvl:<20,.2f}")

# 1% organic growth in daily usage due to PiRC2 adoption
current_volume *= 1.01

# Example Run: Start with 1 Million Pi daily transaction volume
pirc2 = PiRC2Economy()
pirc2.simulate_growth(daily_volume=1000000)

Loading