Skip to content

Documentation

Contracts

The five PORTION contracts on Base, their role and their main public functions. Addresses are published at launch.

ContractRole
PortionFactoryCreates series, mints ERC-1155 units, holds provider bonds
PortionMarketPrimary sales at fixed price or Dutch auction, collects the fee
PortionHookUniswap v4 hook: blocks expired or defaulted series, collects the secondary fee
RedeemerVerifies x402 redemptions and burns consumed units
SlasherWatcher staking, attestations, disputes, bond seizure and refunds

PortionFactory

Issues series and custodies bonds. Implements ERC-1155 for portion balances.

solidity
enum SaleType { Fixed, Dutch }
 
struct SeriesParams {
    string endpoint;
    string model;
    bytes8 unit;
    uint256 quantity;
    uint64 expiry;
    SaleType saleType;
    uint256 price;          // fixed price, or Dutch floor (USDC, 6 decimals)
    uint256 startPrice;     // Dutch start price, ignored for Fixed
    uint64 auctionDuration; // seconds, ignored for Fixed
}
 
function issue(SeriesParams calldata params, uint256 bondAmount) external returns (uint256 seriesId);
function topUpBond(uint256 seriesId, uint256 amount) external;
function withdrawExcessBond(uint256 seriesId, uint256 amount) external;
function requiredBond(uint256 seriesId) external view returns (uint256 prtnAmount);
function bondOf(uint256 seriesId) external view returns (uint256 prtnAmount);
function outstanding(uint256 seriesId) external view returns (uint256 units);
function seriesInfo(uint256 seriesId) external view returns (SeriesParams memory, address provider);
 
event SeriesIssued(uint256 indexed seriesId, address indexed provider, uint256 quantity, uint64 expiry, uint256 bond);
event BondChanged(uint256 indexed seriesId, uint256 newBond);

PortionMarket

Sells newly issued units. Pays the provider in the buyer's transaction.

solidity
function buy(uint256 seriesId, uint256 units, uint256 maxCost, address to) external returns (uint256 cost);
function priceOf(uint256 seriesId) external view returns (uint256 pricePerUnit);
function unsold(uint256 seriesId) external view returns (uint256 units);
function averagePrice(uint256 seriesId) external view returns (uint256 pricePerUnit);
function cancelUnsold(uint256 seriesId, uint256 units) external;
function feeBps() external view returns (uint16);
 
event Bought(uint256 indexed seriesId, address indexed buyer, uint256 units, uint256 cost, uint256 fee);

PortionHook

Attached to every PORTION pool on Uniswap v4.

solidity
function getHookPermissions() external pure returns (Hooks.Permissions memory);
function beforeSwap(address sender, PoolKey calldata key, SwapParams calldata params, bytes calldata hookData)
    external returns (bytes4, BeforeSwapDelta, uint24);
function afterSwap(address sender, PoolKey calldata key, SwapParams calldata params, BalanceDelta delta, bytes calldata hookData)
    external returns (bytes4, int128);
function beforeAddLiquidity(address sender, PoolKey calldata key, ModifyLiquidityParams calldata params, bytes calldata hookData)
    external returns (bytes4);
function isTradable(uint256 seriesId) external view returns (bool);

Redeemer

Called by providers after serving an x402 request paid with a portion.

solidity
struct Redemption {
    address holder;
    uint256 seriesId;
    uint256 maxUnits;
    uint256 units;      // set by the provider, at most maxUnits
    bytes32 requestId;
    uint64 deadline;
    uint256 nonce;
}
 
function verify(Redemption calldata r, bytes calldata signature) external view returns (bool);
function redeem(Redemption calldata r, bytes calldata signature) external returns (uint256 burned);
function redeemBatch(Redemption[] calldata rs, bytes[] calldata signatures) external returns (uint256 burned);
function isUsed(bytes32 requestId) external view returns (bool);
 
event Redeemed(uint256 indexed seriesId, address indexed holder, address indexed provider, uint256 units, bytes32 requestId);

Slasher

Staking, attestations, disputes and refunds.

solidity
function stake(uint256 amount) external;
function requestUnstake(uint256 amount) external;
function withdraw() external;
function attest(Attestation calldata a, bytes calldata signature) external returns (uint256 disputeId);
function contest(uint256 disputeId, bytes calldata evidence) external;
function resolve(uint256 disputeId) external;
function claimRefund(uint256 seriesId) external returns (uint256 usdcAmount);
function claimFees() external returns (uint256 usdcAmount);
function isInDefault(uint256 seriesId) external view returns (bool);
function disputeOf(uint256 seriesId) external view returns (uint256 disputeId, uint64 closesAt, bool contested);
 
event Attested(uint256 indexed disputeId, uint256 indexed seriesId, address indexed watcher, uint8 check);
event DisputeOpened(uint256 indexed disputeId, uint256 indexed seriesId, uint64 closesAt);
event Contested(uint256 indexed disputeId, address provider);
event Slashed(uint256 indexed seriesId, uint256 bondSeized, uint256 refundPool, uint256 watcherReward);
event Refunded(uint256 indexed seriesId, address indexed holder, uint256 units, uint256 usdcAmount);

Addresses

ContractBase mainnet (8453)
PortionFactoryTo be published at launch
PortionMarketTo be published at launch
PortionHookTo be published at launch
RedeemerTo be published at launch
SlasherTo be published at launch
$PRTNTo be published at launch