# 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.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://peridot-finance.gitbook.io/peridot-protocol/technical-architecture/evm/dual-investment/dualinvestmentmanager.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
