# Autocap MVP allocator current workflow This document describes the architecture and flow of the Autocap MVP: a programmable, auction-based [Filecoin Plus allocator implemented in Rust](https://github.com/CELtd/filplus-autocap). The system allows storage providers (SPs) to send FIL along with encoded deal metadata to a dummy client wallet. An off-chain bot monitors these contributions, runs auction rounds, computes proportional datacap credit, and creates verified allocations via the Verified Registry actor when sufficient credit is accumulated. A portion of FIL is burned after each round, and datacap is replenished through the FIDL MetaAllocator smart contract. ## Components - FIDL `Metallocator Smart Contract` (SC), minting datacap in the wallet of a client; - An `allocator wallet` owning the rights to request minting of datacap from the FIDL `Metallocator SC`; - A `dummy client wallet` - The `bot` running offchain and owning the rights to sign transactions from the two wallets ## Step 1 SP sends a tx in FIL to the `dummy client wallet` encoding in the `params` section of the tx the metadata referring to the deal he wants to seal and for which it wants datacap ``` Params: Metadata { provider: <SP-ID>, data: Cid(baga...), size: PaddedPieceSize(<size>), term_min: 518400, term_max: 1036800, expiration: 2880 } ``` Example: ``` ~/lotus-local-net/lotus send --from <SP-addr> --params-hex a66870726... <Dummy-wallet-addr> 0.001 ``` ## Step 2 `bot` is scanning the blocks looking for valid txs inbound in the `dummy client wallet` ``` 📓 Logger initialized. đŸ“Ŧ Filecoin wallet (testnet): t1ypey2rhkbtdassaz5ydtlri3slupzhrylbbguoa 💰 FIL balance: 88769611802956714707 attoFIL ✅ Datacap balance: 954 KiB 🤖 MasterBot started at block 131001 đŸ“Ļ MasterBot processing block 131001 ⌛ Waiting for next auction round in 14 blocks đŸ“Ļ MasterBot processing block 131002 ``` When detects a tx it adds it to the auction ``` đŸ“Ļ MasterBot processing block 131017 đŸĒ™ Detected tx: bafy2bzaceafjruuldanru5x2oqtslk3r3jkwwxswx6egiha2seseeww7a5cmg from t1ixvovumsfzdwkumced26rfdcklmhlsr52rrsvjy with 0.00001 FIL đŸĒ™ Detected tx: bafy2bzacebk2y572qn3ngumo2trcou2msnzrh4jagakux26bolc3olf5sk74q from t1sj5c63tp5m64kg37bloierr3ehlxemgcmxc65va with 0.00001 FIL ``` The auction is a private file looking like ``` { "block_number": 142854, "transactions": [ { "cid": "bafy2bzacebylzrjdbwhkyvl2out7ytqmqn6rjlfvfyjpubkmcmdsrjc6ubxnc", "from": "t1sj5c63tp5m64kg37bloierr3ehlxemgcmxc65va", "to": "t1ypey2rhkbtdassaz5ydtlri3slupzhrylbbguoa", "value_fil": 0.00001, "block_number": 142853, "metadata": { "provider": 1000, "data": "baga6ea4seaqcbzdyshqeqxw2hw2nbv2a45vruq54mc7f3ukgdtqjmdv7n7p7gqq", "size": 1024, "term_min": 518400, "term_max": 1036800, "expiration": 2880 } }, { "cid": "bafy2bzacedv4f7lnopvkcmdn3ytswckgeym25ln6walnnbx5iszghl33dtt6c", "from": "t1ixvovumsfzdwkumced26rfdcklmhlsr52rrsvjy", "to": "t1ypey2rhkbtdassaz5ydtlri3slupzhrylbbguoa", "value_fil": 0.00001, "block_number": 142853, "metadata": { "provider": 1000, "data": "baga6ea4seaqcbzdyshqeqxw2hw2nbv2a45vruq54mc7f3ukgdtqjmdv7n7p61qq", "size": 1024, "term_min": 518400, "term_max": 1036800, "expiration": 2880 } } ] } ``` ## Step 3 At the end of the auction, after X blocks, the datacap rewards are computed ``` 🚀 Executing auction round... 💸 t1ixvovumsfzdwkumced26rfdcklmhlsr52rrsvjy gained 640 B DataCap 💸 t1sj5c63tp5m64kg37bloierr3ehlxemgcmxc65va gained 640 B DataCap ``` And the registry of datacap credits are updated ```{ "block_number": 142672, "credits": { "t1ixvovumsfzdwkumced26rfdcklmhlsr52rrsvjy": 1024, "t1sj5c63tp5m64kg37bloierr3ehlxemgcmxc65va": 640 } } ``` ## Step 4 If the SP has sufficient DataCap credit the allocations are created The allocations are now created for the SPs with sufficient credit ``` 💰 SP t1ixvovumsfzdwkumced26rfdcklmhlsr52rrsvjy has 1024 bytes of credit ✅ Allocation created for SP t1ixvovumsfzdwkumced26rfdcklmhlsr52rrsvjy → Tx CID: "bafy2bzacebdxrtkme5ixelbur3w7rgbejc3ilaodxtnzg7q5auoobxo4b6xps" 💰 SP t1ixvovumsfzdwkumced26rfdcklmhlsr52rrsvjy has 0 bytes of credit remaining âš ī¸ SP t1sj5c63tp5m64kg37bloierr3ehlxemgcmxc65va has insufficient credit for allocation. Required: 1024, Available: 640 ``` The allocation is created in the Verified Registry ``` AllocationID Client Miner PieceCid PieceSize TermMin TermMax Expiration 15 1003 <SP> baga6ea4seaqcbzdyshqeqxw2hw2nbv2a45vruq54mc7f3ukgdtqjmdv7n7p7gqq 1024 518400 1036800 48618 ``` ## Step 5 Then we burn a part of the FIL received ``` đŸ”Ĩ Sent 515000000000000 aFIL to burn address. CID: bafy2bzaced5j2tsygs32ucs3kbagqelbeakgzy2ue7eqzgx66cijbosniz4v6 ✅ Auction cleared. ```` ## Step 6 The `bot` requests to mint datacap in the `dummy client wallet` from the `Metallocator SC` signing from the `allocator wallet` ``` â„šī¸ Masterbot spent 1024 of DataCap. Requesting 1024 of DataCap to Allocator đŸ›°ī¸ DataCap requested. Tx id Eth 0x956d41437a5fc732bd58d9cccb9981c4caf4e7336d9897ec2e0b73f42263c738 đŸ“Ļ MasterBot processing block 131317 ```