> ## Documentation Index
> Fetch the complete documentation index at: https://docs.railnet.org/llms.txt
> Use this file to discover all available pages before exploring further.

# Create an Allocation Strategy

> Step-by-step guide to deploying an Allocation Strategy ecosystem

<Info>In Railnet smart contracts, an Allocation Strategy is implemented as a **MultiVehicle**. See [Glossary](/developers/glossary) for all terminology.</Info>

This guide walks you through creating an Allocation Strategy on Railnet. By the end, you will have a fully deployed ecosystem with its External Access Control, optional Fee Manager, and the Allocation Strategy itself (MultiVehicle).

<Note>
  If you are a Conduit owner deploying a strategy you will own and delegate to an asset manager, see [Use a Strategy](/conduits/use-a-strategy) instead.
</Note>

## Prerequisites

* A wallet with funds — the deposit asset (e.g. USDC) for the initial deposit and ETH for gas
* The `FACTORY_SPAWN` role on the Multi-Vehicle factory (or access to a public factory)
* The deposit asset authorized in the [AssetRegistry](/developers/contracts/asset-registry) — the factory reads the initial deposit amount from there at spawn time
* The factory must not be deprecated

<Note>
  Every Allocation Strategy deployment requires an initial deposit. This is a security measure to prevent inflation attacks (zero-share vulnerability). The amount is configured in the [AssetRegistry](/developers/contracts/asset-registry) per asset. The shares minted from the initial deposit are sent to the burn address and can never be withdrawn.
</Note>

<Steps>
  <Step title="Deploy External Access Control (EAC)">
    Railnet uses an External Access Control contract to provide Role-Based Access Control (RBAC) across all strategies you operate. You define roles and grant them to different addresses from this single contract.

    You must deploy at least one EAC before creating any Allocation Strategy.

    **Parameters:**

    * `initialDelay` — delay for admin operations (in seconds), set to `0` for immediate access
    * `initialDefaultAdmin` — the address granted `DEFAULT_ADMIN_ROLE`
    * `initialRoles` — array of initial role attributions (can be empty and configured later)
    * `deploymentSalt` — salt for deterministic CREATE2 deployment

    <CodeGroup>
      ```solidity Solidity theme={null}
      // Deploy External Access Control via the EAC Factory
      ExternalAccessControlFactory.SpawnParams memory params = ExternalAccessControlFactory.SpawnParams({
          initialDelay: 0,
          initialDefaultAdmin: msg.sender,
          initialRoles: new ExternalAccessControlFactory.RoleAttribution[](0),
          deploymentSalt: keccak256("my-eac-v1")
      });

      ExternalAccessControl eac = eacFactory.spawn(params);
      ```

      ```typescript TypeScript theme={null}
      // Coming soon
      ```
    </CodeGroup>
  </Step>

  <Step title="Deploy Fee Manager (optional)">
    The Fee Manager contract handles all fee-related operations for your Allocation Strategy: performance fees, management fees, deposit fees, and redemption fees. You can configure initial fee rates, maximum fee caps, and fee recipients.

    If you do not need fees, you can pass the zero address (`0x0000...0000`) when deploying the Allocation Strategy.

    **Parameters:**

    * `accessControl` — your EAC contract address
    * `initialFees` — fee rates in basis points (1 bps = 0.01%)
    * `initialMaxFees` — maximum fee caps that can never be exceeded
    * `initialRecipients` — fee recipients with their share in bps (must sum to 10,000)
    * `deploymentSalt` — salt for deterministic CREATE2 deployment

    <CodeGroup>
      ```solidity Solidity theme={null}
      FeeManagerFactory.SpawnParams memory params = FeeManagerFactory.SpawnParams({
          accessControl: externalAccessControl,
          initialFees: FeeManager.Fees({
              performanceFeeBps: 1000,  // 10% performance fee
              managementFeeBps: 200,    // 2% annual management fee
              depositFeeBps: 0,         // No deposit fee
              redeemFeeBps: 0           // No redeem fee
          }),
          initialMaxFees: FeeManager.Fees({
              performanceFeeBps: 2000,  // 20% max performance fee
              managementFeeBps: 500,    // 5% max management fee
              depositFeeBps: 100,       // 1% max deposit fee
              redeemFeeBps: 100         // 1% max redeem fee
          }),
          initialRecipients: recipients,  // Array of FeeRecipient structs
          deploymentSalt: keccak256("my-fee-manager-v1")
      });

      FeeManager feeManager = feeManagerFactory.spawn(params);
      ```

      ```typescript TypeScript theme={null}
      // Coming soon
      ```
    </CodeGroup>

    <Tip>
      Set `initialMaxFees` carefully. These caps are immutable and define the absolute ceiling for each fee type. You can always lower fees later, but you can never exceed the max.
    </Tip>
  </Step>

  <Step title="Approve the initial deposit">
    When creating an Allocation Strategy, you select a single deposit asset (e.g. USDC). The factory will pull the initial deposit from your wallet at spawn time using the amount configured for that asset in the [AssetRegistry](/developers/contracts/asset-registry).

    Read the configured amount and approve the Multi-Vehicle Factory to spend it.

    <CodeGroup>
      ```solidity Solidity theme={null}
      // Read the registry-configured initial deposit for the chosen asset
      uint256 initialDepositAmount = assetRegistry.getInitialDepositAmount(usdc);

      // Approve the Multi-Vehicle Factory
      IERC20(usdc).approve(address(multiVehicleFactory), initialDepositAmount);
      ```

      ```typescript TypeScript theme={null}
      // Coming soon
      ```
    </CodeGroup>
  </Step>

  <Step title="Deploy the Allocation Strategy">
    Deploy the full Allocation Strategy ecosystem in a single transaction. The factory creates the MultiVehicle, Sector Accounting Engine, Queue Strategy Engine, Sub Query Engine, and Query Redeem Queue — all correctly linked and initialized.

    **Parameters:**

    * `asset` — the underlying deposit asset (e.g. USDC)
    * `name` — the ERC-20 token name for Allocation Strategy shares
    * `symbol` — the ERC-20 token symbol for Allocation Strategy shares
    * `initialInterceptions` — interceptor rules for reward distribution (can be empty)
    * `accessControl` — your EAC contract address
    * `feeManager` — Fee Manager address (or zero address for no fees)
    * `modulesManager` — Modules Manager address (or zero address)
    * `salts` — collection of deployment salts for all underlying contracts
    * `initialExpectedSupply` — minimum expected supply after initial deposit (generally `1e18`)

    The initial deposit amount itself is read from the AssetRegistry — it is not passed here.

    <CodeGroup>
      ```solidity Solidity theme={null}
      MultiVehicleFactory.SpawnParams memory params = MultiVehicleFactory.SpawnParams({
          asset: IERC20(usdc),
          name: "Diversified USDC",
          symbol: "dUSDC",
          initialInterceptions: new Interceptor.Interception[](0),
          accessControl: externalAccessControl,
          feeManager: feeManager,
          modulesManager: modulesManager,
          salts: MultiVehicleFactory.Salts({
              multiVehicle: keccak256("mv"),
              queryRedeemQueue: keccak256("qrq"),
              queueStrategyEngine: keccak256("qse"),
              sectorAccountingEngine: keccak256("sae"),
              subQueryEngine: keccak256("sqe"),
              vehicleRegistry: keccak256("vr"),
              initialDepositQuery: keccak256("idq")
          }),
          initialExpectedSupply: 1e18
      });

      MultiVehicleFactory.Contracts memory contracts = factory.spawn(params);

      // contracts.multiVehicle      — main Allocation Strategy contract
      // contracts.accountingEngine   — Sector Accounting Engine
      // contracts.strategyEngine     — Queue Strategy Engine
      // contracts.subQueryEngine     — Sub Query Engine
      // contracts.redeemQueue        — Query Redeem Queue
      ```

      ```typescript TypeScript theme={null}
      // Coming soon
      ```
    </CodeGroup>
  </Step>

  <Step title="Verify the deployment">
    After deployment, verify your Allocation Strategy's status and configuration by querying the Railnet subgraph or reading the contract state directly.

    <CodeGroup>
      ```solidity Solidity theme={null}
      // Read the deployed MultiVehicle state
      address multiVehicle = address(contracts.multiVehicle);

      // Verify the asset
      address asset = MultiVehicle(multiVehicle).asset();

      // Verify the total supply (should reflect initial deposit)
      uint256 totalSupply = MultiVehicle(multiVehicle).totalSupply();

      // Verify the accounting engine link
      ISectorAccountingEngine accounting = MultiVehicle(multiVehicle).accountingEngine();
      ```

      ```typescript TypeScript theme={null}
      // Coming soon
      ```
    </CodeGroup>

    You can also query the Railnet subgraph using GraphQL:

    ```graphql theme={null}
    query VerifyDeployment($address: String!) {
      Vehicle(where: { address: { _ilike: $address } }) {
        address
        id
        name
        vehicleType
        symbol
        supply
      }
    }
    ```
  </Step>
</Steps>

## What you deployed

Your Allocation Strategy ecosystem now consists of five interconnected contracts:

| Contract                     | Purpose                                                                     |
| ---------------------------- | --------------------------------------------------------------------------- |
| **MultiVehicle**             | Main Allocation Strategy contract. Users deposit and receive ERC-20 shares. |
| **Sector Accounting Engine** | Tracks all asset allocations across yield sources and idle sectors.         |
| **Queue Strategy Engine**    | Defines deposit/redeem priority queues for automated allocation.            |
| **Sub Query Engine**         | Executes deposit and redeem queries on yield sources.                       |
| **Query Redeem Queue**       | Handles asynchronous redemption processing.                                 |

## Next steps

<CardGroup cols={2}>
  <Card title="Operate an Allocation Strategy" icon="sliders" href="/strategies/allocation/operate">
    Authorize yield sources, configure allocation queues, and operate your Allocation Strategy.
  </Card>

  <Card title="Configure fees" icon="percent" href="/developers/contracts/fee-manager">
    Set up fee structures for your Allocation Strategy.
  </Card>
</CardGroup>
