Skip to content

CELtd/filplus-autocap

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

69 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AutoCap

Automated DataCap allocation for Filecoin Storage Providers based on Burn-to-Earn mechanism.

AutoCap is a Filecoin FVM smart contract that automates the allocation of DataCap to Storage Providers (SPs) based on how much FIL they have burned through the Filecoin Pay rail.

Overview

The contract operates on a per-round basis:

  1. Registration Phase: SPs register by paying a fee and providing their Actor ID
  2. Calculation Phase: Owner inputs off-chain burn verification data
  3. Distribution Phase: DataCap is distributed proportionally to each SP's FIL burn
Allocation = (ParticipantBurnt × DistributableDataCap) / TotalGlobalBurnt

Architecture

┌─────────────────────────────────────────────────────────────┐
│                         AutoCap                              │
├─────────────────────────────────────────────────────────────┤
│  State: RegistrationOpen → Calculation → Distributing       │
├─────────────────────────────────────────────────────────────┤
│  Participants                                                │
│  ├── isRegistered                                           │
│  ├── datacapActorId (destination for DataCap)               │
│  ├── filBurnt (set by oracle)                               │
│  └── hasClaimed                                             │
├─────────────────────────────────────────────────────────────┤
│  DataCap Actor (f07) ←──── FRC42 ────→ AutoCap              │
└─────────────────────────────────────────────────────────────┘

Installation

Prerequisites

Setup

# Clone the repository
git clone https://github.com/your-org/autocap-v0.git
cd autocap-v0

# Install dependencies
forge install OpenZeppelin/openzeppelin-contracts
forge install Zondax/filecoin-solidity

# Build
forge build

Usage

Build

forge build

Test

forge test

Test with verbosity

forge test -vvvv

Format

forge fmt

Gas Snapshots

forge snapshot

Deployment

Environment Setup

Create a .env file:

PRIVATE_KEY=your_private_key
PAYMENT_CONTRACT=0x...  # Filecoin Pay contract address
REGISTRATION_FEE=100000000000000000  # 0.1 FIL in AttoFIL

Deploy to Filecoin Calibration Testnet

source .env

forge script script/Deploy.s.sol:DeployAutoCap \
    --rpc-url https://api.calibration.node.glif.io/rpc/v1 \
    --broadcast

Deploy Locally

# Start local node
anvil

# Deploy
forge script script/Deploy.s.sol:DeployAutoCapLocal \
    --rpc-url http://localhost:8545 \
    --broadcast

Contract Interface

For Storage Providers

// Register for the round
function register(uint64 _datacapActorId) external payable;

For Oracle (Owner)

// Close registration phase
function closeRegistration() external;

// Set burn statistics (batched)
function setParticipantBurnStats(address[] calldata _sps, uint256[] calldata _amounts) external;

// Finalize round and enable distribution
function finalizeRound(uint256 _totalFilBurntInRound) external;

// Withdraw collected registration fees
function withdrawFees() external;

For Anyone

// Claim DataCap for beneficiaries (batched)
function claimDataCap(address[] calldata _beneficiaries) external;

Events

event Registered(address indexed sp, uint64 datacapActorId);
event BurnStatsUpdated(address indexed sp, uint256 amount);
event RoundFinalized(uint256 totalFilBurnt, uint256 distributableDataCap);
event DataCapClaimed(address indexed sp, uint256 amount);
event DataCapReceived(uint256 amount, bytes operatorData);
event RegistrationClosed();
event FeesWithdrawn(address indexed owner, uint256 amount);

Security Considerations

  • Owner Trust: The contract relies on the owner as an oracle for burn verification
  • Actor ID Validation: Users must provide correct Actor IDs; invalid IDs result in lost DataCap
  • Gas Limits: Batch operations (setParticipantBurnStats, claimDataCap) should be split if too many participants

Dependencies

License

MIT

About

A programmable datacap allocation system for Filecoin that distributes datacap to Storage Providers based on their economic contribution to the network.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors