SettlementEngine
Settles Dual Investment positions by reading oracle prices at/near expiry, calculating the winning side, executing payout in the correct pToken, and burning the position.
Responsibilities
Enforce settlement window after
expiry.Fetch or cache settlement price (
SimplePriceOracle).Compute winning pToken based on strike and direction;
payout 1:1 notional in winning cToken units.
Withdraw/mint directly where possible; else withdraw from source and swap to target before minting.
Key Functions
settlePosition(tokenId, user)Validates window, balance; gets price; determines winning cToken; burns position; executes payout via VaultExecutor.
batchSettlePositions(tokenIds, users)best‑effort loop using internal helper to continue on failures.Views:
canSettlePosition(tokenId),getSettlementInfo(tokenId).Admin:
setSettlementWindow(seconds),emergencySetSettlementPrice(tokenId, price).
Payout Path
Try
withdrawUnderlyingFromProtocol(payoutCToken, underlyingOutRequested); if >0,mintCTokensTo(payoutCToken, user, withdrawn).Else withdraw from source (
position.cTokenIn), swap to payout underlying, thenmintCTokensTothe user.
Last updated