> For the complete documentation index, see [llms.txt](https://peridot-finance.gitbook.io/peridot-protocol/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://peridot-finance.gitbook.io/peridot-protocol/technical-architecture/evm/dual-investment/dualinvestmentmanager.md).

# DualInvestmentManager

Main entry for creating Dual Investment positions. Validates inputs, coordinates collateral/borrow flows, mints ERC‑1155 positions, and updates risk tracking.

## Key Responsibilities

* Validate position params (supported markets, size bounds, direction, time window).
* Compute position value in USD using pToken exchange rate + oracle.
* Route via VaultExecutor for collateral path; via CompoundBorrowRouter for borrow path.
* Mint ERC‑1155 position tokens (`ERC1155DualPosition`).

## Primary Functions

* `enterPosition(cTokenIn, cTokenOut, amount, direction, strike, expiry, useCollateral)`
  * Validates inputs; generates tokenId; chooses path:
  * Collateral: `vaultExecutor.redeemAndSupplyToProtocol(msg.sender, cTokenIn, amount)`; mint position.
  * Borrow: compute `underlyingAmount = amount * exchangeRate / 1e18`; `borrowRouter.borrowAndRoute(... -> vaultExecutor)`; `vaultExecutor.mintCTokensTo(...)`; mint position.
* `enterPositionWithBorrowed(cToken, cTokenOut, underlyingAmount, direction, strike, expiry)`
  * User borrows externally; vault pulls underlying and mints cTokens; position minted from actual minted amount.
* `canEnterPosition(user, cTokenIn, amount, useCollateral) -> (bool, reason)`
  * Pre‑checks size, balances (collateral) or liquidity (borrow).
* `getPositionInfo(tokenId) -> (Position, canSettle, isSettled)`
* Admin: `setSupportedCToken(cToken, supported)`, `setRiskParameters(maxPos, minPos, maxExpiry, minExpiry)`.

## Events

* `PositionEntered(tokenId, user, cTokenIn, cTokenOut, amount, strike, expiry, direction, useCollateral)`

## Notes

* Position tokenId is user‑scoped (`generateTokenIdForUser`) to avoid collisions.
* Uses `exchangeRateStored()` for deterministic conversions during entry.
