VaultExecutor

Executes all pToken mint/redeem operations on behalf of Dual Investment flows, tracks protocol‑supplied amounts, and orchestrates swaps and settlement payouts.

Responsibilities

  • Redeem user pTokens, supply underlying back into markets under the vault, and mint cTokens to recipients.

  • Withdraw underlying for settlement (clamped to available balance).

  • Swap between underlyings via PancakeSwapAdapter, then mint target cTokens.

  • Track per‑market protocol balances and per‑user redeemed underlyings.

Key Functions

  • redeemAndSupplyToProtocol(user, cToken, cTokenAmount) [onlyAuthorized]

    • Redeems to underlying (delta), tracks userUnderlyingBalances, then supplies to market; updates protocolSuppliedAmounts.

  • withdrawUnderlyingFromProtocol(cToken, underlyingAmount) [onlyAuthorized]

    • Redeems required cTokens (based on exchangeRate) up to available balance.

  • swapUnderlying(tokenIn, tokenOut, amountIn, minOut) [onlyAuthorized]

  • swapAndMintTo(cTokenIn, cTokenOut, recipient, underlyingInAmount, minUnderlyingOut) [onlyAuthorized]

    • Swaps underlyings and mints cTokenOut to recipient; pays out raw underlying if amount too small to mint ≥1 cToken.

  • mintCTokensTo(cToken, recipient, underlyingAmount) [onlyAuthorized]

  • pullUnderlyingAndMintTo(cToken, fromUser, recipient, underlyingAmount) [onlyAuthorized]

  • Admin: setAuthorizedManager, setProtocolAccount, setSwapAdapter, emergencyWithdraw.

Notes

  • Uses forceApprove for safe allowance setting prior to mint.

  • Swap path tries V3 first, falls back to V2.

Last updated