Exhibit 10.31

EXECUTION

AMENDMENT NO. 2 TO

AMENDED AND RESTATED MASTER REPURCHASE AGREEMENT

Amendment No. 2, dated as of October 1, 2013 (this “Amendment”), among Credit
Suisse First Boston Mortgage Capital LLC (the “Buyer”), PennyMac Corp. (the
“Seller”) PennyMac Mortgage Investment Trust and PennyMac Operating Partnership,
L.P. (each, a “Guarantor” and collectively, the “Guarantors”).

RECITALS

The Buyer, the Seller and the Guarantors are parties to that certain Amended and
Restated Master Repurchase Agreement, dated as of June 1, 2013 (as amended by
Amendment No. 1, dated as of August 29, 2013, the “Existing Repurchase
Agreement”; as further amended by this Amendment, the “Repurchase Agreement”)
and the related Pricing Side Letter, dated as of June 1, 2013 (as amended from
time to time, the “Pricing Side Letter”). The Guarantors are parties to that
certain Guaranty (the “Guaranty”), dated as of November 2, 2010, as the same may
be further amended from time to time, by the Guarantors in favor of Buyer.
Capitalized terms used but not otherwise defined herein shall have the meanings
given to them in the Existing Repurchase Agreement and Guaranty, as applicable.

The Buyer and Seller have agreed, subject to the terms and conditions of this
Amendment, that the Existing Repurchase Agreement be amended to reflect certain
agreed upon revisions to the terms of the Existing Repurchase Agreement. As a
condition precedent to amending the Existing Repurchase Agreement, the Buyer has
required the Guarantors to ratify and affirm the Guaranty on the date hereof.

Accordingly, the Buyer, the Seller and the Guarantors hereby agree, in
consideration of the mutual promises and mutual obligations set forth herein,
that the Existing Repurchase Agreement is hereby amended as follows:

SECTION 1. Definitions. Section 2 of the Existing Repurchase Agreement is hereby
amended by:

1.1 deleting the definitions of “PMITH”, “PMITH Aggregate Purchase Price” and
“PMITH Facility” in their entirety.

1.2 adding the following definitions in their proper alphabetical order:

“PennyMac Holdings” means PennyMac Holdings, LLC.

“PennyMac Holdings Aggregate Purchase Price” means as of any date of
determination, the aggregate “Purchase Price” of “Purchased Mortgaged Loans”
subject to outstanding “Transactions”, all as defined in, and calculated under
the PennyMac Holdings Facility.

 

-1-

--------------------------------------------------------------------------------

“PennyMac Holdings Facility” means that certain Master Repurchase Agreement,
dated as of March 29, 2012, among PennyMac Holdings, Guarantors and Buyer, as
amended, restated, supplemented or otherwise modified from time to time.

SECTION 2. PMITH Name Change.

2.1 The Buyer hereby acknowledges and Seller hereby confirms that effective as
of October 1, 2013 PennyMac Mortgage Investment Trust Holdings I, LLC will have
changed its legal name from “PennyMac Mortgage Investment Trust Holdings I, LLC”
to “PennyMac Holdings, LLC”.

2.2 Each reference to “PMITH”, “PMITH Aggregate Purchase Price” and “PMITH
Facility” in the Existing Repurchase Agreement is hereby deleted in its entirety
and replaced with “PennyMac Holdings”, “PennyMac Holdings Aggregate Purchase
Price” and “PennyMac Holdings Facility”, respectively.

SECTION 3. Conditions Precedent. This Amendment shall become effective as of
October 1, 2013 (the “Amendment Effective Date”), subject to the satisfaction of
the following conditions precedent:

3.1 Delivered Documents. On the Amendment Effective Date, the Buyer shall have
received the following documents, each of which shall be satisfactory to the
Buyer in form and substance:

(a) this Amendment, executed and delivered by duly authorized officers of the
Buyer, the Seller and the Guarantors;

(b) Amendment No. 3 to Amended and Restated Pricing Side Letter, dated as of
October 1, 2013, executed and delivered by duly authorized officers of the
Buyer, the Seller and the Guarantors;

(c) a certified copy of the certificate of amendment to the certificate of
formation from the jurisdiction of organization of PMITH evidencing the name
change of PMITH; and

(d) such other documents as the Buyer or counsel to the Buyer may reasonably
request.

SECTION 4. Representations and Warranties. Seller hereby represents and warrants
to the Buyer that it is in compliance with all the terms and provisions set
forth in the Repurchase Agreement on its part to be observed or performed, and
that no Event of Default has occurred or is continuing, and hereby confirms and
reaffirms the representations and warranties contained in Section 13 of the
Repurchase Agreement.

SECTION 5. Limited Effect. Except as expressly amended and modified by this
Amendment, the Existing Repurchase Agreement shall continue to be, and shall
remain, in full force and effect in accordance with its terms and the execution
of this Amendment.

 

-2-

--------------------------------------------------------------------------------

SECTION 6. Counterparts. This Amendment may be executed by each of the parties
hereto on any number of separate counterparts, each of which shall be an
original and all of which taken together shall constitute one and the same
instrument.

SECTION 7. Severability. Each provision and agreement herein shall be treated as
separate and independent from any other provision or agreement herein and shall
be enforceable notwithstanding the unenforceability of any such other provision
or agreement.

SECTION 8. GOVERNING LAW. THIS AMENDMENT SHALL BE GOVERNED BY, AND CONSTRUED IN
ACCORDANCE WITH, THE LAWS OF THE STATE OF NEW YORK WITHOUT REFERENCE TO THE
CHOICE OF LAW PROVISIONS THEREOF.

SECTION 9. Reaffirmation of Guaranty. The Guarantors hereby ratify and affirm
all of the terms, covenants, conditions and obligations of the Guaranty and
acknowledge and agree that the term “Obligations” as used in the Guaranty shall
apply to all of the Obligations of Seller to Buyer under the Repurchase
Agreement and related Program Agreements, as amended hereby.

[Remainder of page intentionally left blank]

 

-3-

--------------------------------------------------------------------------------

IN WITNESS WHEREOF, the undersigned have caused this Amendment to be duly
executed as of the date first above written.

 

Credit Suisse First Boston Mortgage Capital LLC, as Buyer By:  

/s/ Adam Loskove

  Name: Adam Loskove   Title: Vice President PennyMac Corp., as Seller By:  

/s/ Pamela Marsh

  Name: Pamela Marsh   Title: Managing Director Treasurer PennyMac Mortgage
Investment Trust, as Guarantor By:  

/s/ Pamela Marsh

  Name: Pamela Marsh   Title: Managing Director Treasurer PennyMac Operating
Partnership, L.P., as Guarantor By:   PennyMac GP OP, Inc., its General Partner
By:  

/s/ Pamela Marsh

  Name: Pamela Marsh   Title: Managing Director Treasurer

Signature Page to Amendment No. 2 to Amended and Restated Master Repurchase
Agreement