> ## Documentation Index
> Fetch the complete documentation index at: https://mintlify.com/reserve-protocol/reserve-index-dtf/llms.txt
> Use this file to discover all available pages before exploring further.

# Deploying a Folio

> Learn how to deploy a new Folio instance with custom configuration and governance

## Overview

Folios can be deployed in two ways:

1. **Raw Folio** - with manually assigned roles
2. **Governed Folio** - with fully automated governance structure including timelocks and voting mechanisms

## Prerequisites

* Deployment wallet with sufficient ETH for gas
* Initial basket assets and amounts
* Fee registry and version registry addresses
* Trusted filler registry address (optional)

## Deploying a Raw Folio

A raw Folio gives you direct control over role assignments.

<Steps>
  <Step title="Prepare Basic Details">
    Define your Folio's core parameters:

    ```solidity theme={null}
    IFolio.FolioBasicDetails memory basicDetails = IFolio.FolioBasicDetails({
        name: "My Custom Folio",
        symbol: "MCF",
        assets: [address(usdc), address(weth), address(dai)],
        amounts: [1000e6, 1e18, 1000e18], // Initial basket amounts
        initialShares: 1000e18 // Shares minted to creator
    });
    ```

    <Note>
      The `amounts` array must match the length of the `assets` array. Each amount represents the initial quantity of each asset required.
    </Note>
  </Step>

  <Step title="Configure Additional Details">
    Set up fees, mandate, and auction parameters:

    ```solidity theme={null}
    IFolio.FeeRecipient[] memory recipients = new IFolio.FeeRecipient[](1);
    recipients[0] = IFolio.FeeRecipient({
        recipient: feeRecipientAddress,
        portion: 1e18 // 100% in D18 format
    });

    IFolio.FolioAdditionalDetails memory additionalDetails = IFolio.FolioAdditionalDetails({
        maxAuctionLength: 3 days,
        feeRecipients: recipients,
        tvlFee: 317097919837645, // ~1% annual (D18/second)
        mintFee: 0.01e18, // 1%
        folioFeeForSelf: 0, // No self-burn
        mandate: "A diversified stablecoin basket"
    });
    ```

    <Info>
      **Fee Limits:**

      * TVL Fee: Max 10% annually
      * Mint Fee: Max 5%
      * DAO takes minimum 15bps from all fees
    </Info>
  </Step>

  <Step title="Set Folio Flags">
    Configure rebalancing behavior:

    ```solidity theme={null}
    IFolio.FolioFlags memory flags = IFolio.FolioFlags({
        trustedFillerEnabled: true,
        rebalanceControl: IFolio.RebalanceControl({
            weightControl: true, // AUCTION_LAUNCHER can adjust weights
            priceControl: IFolio.PriceControl.PARTIAL // Can narrow prices
        }),
        bidsEnabled: true // Allow permissionless bidding
    });
    ```

    **Price Control Options:**

    * `NONE` - Cannot change prices from initial
    * `PARTIAL` - Can narrow price ranges within initial bounds
    * `ATOMIC_SWAP` - Can set instant swaps (start price = end price)
  </Step>

  <Step title="Approve Token Transfers">
    The deployer must approve the FolioDeployer to transfer initial basket assets:

    ```solidity theme={null}
    IERC20(usdc).approve(address(folioDeployer), 1000e6);
    IERC20(weth).approve(address(folioDeployer), 1e18);
    IERC20(dai).approve(address(folioDeployer), 1000e18);
    ```
  </Step>

  <Step title="Deploy the Folio">
    Call the deployment function:

    ```solidity theme={null}
    address[] memory basketManagers = new address[](1);
    basketManagers[0] = rebalanceManagerAddress;

    address[] memory auctionLaunchers = new address[](1);
    auctionLaunchers[0] = auctionLauncherAddress;

    address[] memory brandManagers = new address[](0);

    (Folio folio, address proxyAdmin) = folioDeployer.deployFolio(
        basicDetails,
        additionalDetails,
        flags,
        ownerAddress, // Admin
        basketManagers, // REBALANCE_MANAGER role
        auctionLaunchers, // AUCTION_LAUNCHER role
        brandManagers, // BRAND_MANAGER role (optional)
        keccak256(abi.encode("unique_salt")) // Deployment nonce
    );
    ```

    <Check>
      After deployment:

      * Verify the Folio address
      * Check that roles are assigned correctly
      * Confirm initial shares were minted
      * Ensure basket tokens were transferred
    </Check>
  </Step>
</Steps>

## Deploying a Governed Folio

A governed Folio includes complete governance infrastructure with voting tokens and timelocks.

<Steps>
  <Step title="Prepare Governance Parameters">
    Define governance settings for the owner and trading governors:

    ```solidity theme={null}
    // Owner governance controls admin functions
    IGovernanceDeployer.GovParams memory ownerGovParams = IGovernanceDeployer.GovParams({
        votingDelay: 1 days,
        votingPeriod: 7 days,
        proposalThreshold: 1000e18, // Min tokens to propose
        quorumThreshold: 4, // 4% quorum (in percentage)
        timelockDelay: 2 days,
        guardians: new address[](0) // Can cancel proposals
    });

    // Trading governance controls rebalancing
    IGovernanceDeployer.GovParams memory tradingGovParams = IGovernanceDeployer.GovParams({
        votingDelay: 6 hours,
        votingPeriod: 3 days,
        proposalThreshold: 500e18,
        quorumThreshold: 3,
        timelockDelay: 1 days,
        guardians: new address[](0)
    });
    ```
  </Step>

  <Step title="Configure Role Assignments">
    Specify existing role holders (or leave empty for governance-only control):

    ```solidity theme={null}
    IFolioDeployer.GovRoles memory govRoles = IFolioDeployer.GovRoles({
        existingBasketManagers: new address[](0), // Empty = deploy trading gov
        auctionLaunchers: [auctionLauncherEOA],
        brandManagers: new address[](0)
    });
    ```

    <Tip>
      Leave `existingBasketManagers` empty to automatically deploy a separate trading governor. Otherwise, use your own addresses.
    </Tip>
  </Step>

  <Step title="Choose Governance Model">
    Decide between self-governance (Folio shares = voting power) or separate staking token:

    ```solidity theme={null}
    // Option 1: Self-governed (stToken = address(0))
    IVotes stToken = IVotes(address(0));

    // Option 2: Separate staking token
    // IVotes stToken = IVotes(existingVotingTokenAddress);
    ```
  </Step>

  <Step title="Deploy Governed Folio">
    Execute the deployment:

    ```solidity theme={null}
    (Folio folio, address proxyAdmin) = folioDeployer.deployGovernedFolio(
        stToken, // address(0) for self-governance
        basicDetails,
        additionalDetails,
        flags,
        ownerGovParams,
        tradingGovParams,
        govRoles,
        keccak256(abi.encode("unique_salt_2"))
    );
    ```

    This will deploy:

    * Folio contract
    * Owner governor + timelock
    * Trading governor + timelock (if applicable)
    * Vote-locked staking vault (if self-governed)
  </Step>

  <Step title="Verify Deployment">
    Check the emitted events for deployed addresses:

    ```solidity theme={null}
    // Listen for GovernedFolioDeployed event
    event GovernedFolioDeployed(
        address stToken,
        address folio,
        address ownerGovernor,
        address ownerTimelock,
        address tradingGovernor,
        address tradingTimelock
    );
    ```

    <Warning>
      All admin functions must now go through the governance timelock. Immediate changes are no longer possible.
    </Warning>
  </Step>
</Steps>

## Post-Deployment

After deployment, you can:

* Set up additional role holders
* Configure trade allowlists (if needed)
* Add trusted fillers to the registry
* Begin minting shares
* Initiate your first rebalance

## Code Reference

* Deployment logic: `contracts/deployer/FolioDeployer.sol:45-203`
* Governance setup: `contracts/deployer/GovernanceDeployer.sol:40-109`
* Initialization: `contracts/Folio.sol:207-250`

## Next Steps

<CardGroup cols={2}>
  <Card title="Mint Shares" icon="coins" href="/guides/minting-redeeming">
    Learn how users can mint and redeem Folio shares
  </Card>

  <Card title="Start Rebalancing" icon="scale-balanced" href="/guides/managing-rebalances">
    Configure and execute your first rebalance
  </Card>
</CardGroup>
