Arrange the loan so the funds are available and committed before filing, and so repayments through the conditional period can be met from income rather than from the invested capital.
Match the loan term to the immigration timeline, not the other way round
The sequence is loan first, investment second, petition third, because the petition must show capital already invested or actively in the process of being invested. That means the security documents, the appraisal and the advance all precede the filing, and the source-of-funds work for the collateral should run in parallel with the loan negotiation. Afterwards comes USCIS processing of the investor petition, the immigrant visa or adjustment stage, two years of conditional residence, with Form I-829 filed in the 90 days before the second anniversary.
A loan maturing inside that window creates a genuine conflict, because refinancing while an application is pending introduces new documents and new questions, and repaying from the investment is not permitted. Ask the lender for a term long enough to clear the condition-removal stage with margin, and check visa availability considerations in the Visa Bulletin before assuming a total duration.