
487 N.W.2d 251 (1992)
LYMAN LUMBER COMPANY, Respondent,
v.
CORNERSTONE CONSTRUCTION, INC., et al., Respondents,
William B. MacLean, Appellant,
David E. Magnuson, d/b/a Suburban Tile Service, et al., Defendants.
No. C0-91-2410.
Court of Appeals of Minnesota.
June 2, 1992.
Review Denied August 4, 1992.
*252 Gerald G. Workinger, Jr., Minneapolis, for Lyman Lumber Co.
Thomas F. Surprenant, Minneapolis, for Cornerstone Const., Inc., et al.,
Gerald P. Carroll, Carroll & Leighton, P.A., Minneapolis, for William B. MacLean.
Considered and decided by DAVIES, P.J., and KLAPHAKE and STONE,[*] JJ.


*253 OPINION
KLAPHAKE, Judge.
William MacLean appeals from summary judgment, claiming that respondent Lyman Lumber Co. intentionally overstated its lien claim, that the trial court erred in calculating prejudgment interest, and that the trial court awarded excessive attorney fees. Respondent Lyman Lumber Co. filed a notice of review, claiming the trial court's award of attorney fees and costs was insufficient. We affirm in part, reverse in part, and remand.

FACTS
This case involves the enforcement of a mechanics' lien filed in connection with improvements made to a single family dwelling in Edina, Minnesota. The suit originally involved numerous subcontractors, but their claims have been settled. The remaining dispute involves respondent Lyman Lumber Co. (Lyman), appellant William MacLean (MacLean), and Cornerstone Construction, Inc. (Cornerstone).
On July 5, 1989, MacLean purchased the vendor's interest in a contract for deed for the sale of a residential home (the property) to Cornerstone. The contract for deed prohibited Cornerstone from incurring any liens on the property.
Cornerstone contracted with Lyman on July 31, 1989, for lumber and other building materials to remodel and improve the property. The contract specified a monthly service charge of 1.5% (18% per year) on past due amounts and provided that Cornerstone would pay Lyman's collection costs and expenses, including reasonable attorney fees.
Cornerstone began construction sometime in late July. Lyman mailed its prelien notice to MacLean in August 1989. When Cornerstone did not pay Lyman for the materials, Lyman filed its mechanics' lien statement on March 15, 1990, listing initial and final contribution dates of August 2, 1989, and January 15, 1990, respectively. Lyman stated the amount due as $83,029.36 with 18% annual interest beginning on November 30, 1989, based upon the contract.
On March 23, 1990, Lyman brought an action to foreclose its mechanics' lien. Lyman attached a bill of particulars which listed a non-itemized balance due of $83,029.36. Lyman also filed a notice of lis pendens against the property. MacLean disputed the effectiveness of Lyman's prelien notice. MacLean also sought to cancel the contract for deed because Cornerstone had breached the contract by allowing mechanics' liens to attach to the property. Cornerstone then filed a petition for Chapter 7 bankruptcy in October 1990.
In January 1991, MacLean moved for an order requiring Lyman to provide a more detailed bill of particulars, and an order to release Lyman's mechanics' lien and notice of lis pendens pursuant to Minn.Stat. § 514.10 (1990). The trial court granted the motion, ordering MacLean to deposit $123,838.84 (consisting of $83,029.36 in materials, $29,890 interest, $1,074.48 costs, and $9,848 attorney fees) with the court administrator. After MacLean deposited $123,838.84, the trial court released the property from Lyman's mechanics' lien and notice of lis pendens, and established a lien in Lyman's favor against the deposited funds stating that all issues of law and fact would be determined at trial.
Lyman then moved for summary judgment. On August 30, 1991, the trial court granted summary judgment to Lyman, noting it had already granted summary judgment in its earlier order regarding release of Lyman's lien upon posting security. The trial court stated it had already determined that MacLean was required to pay the interest rate specified in the Lyman-Cornerstone contract, that the amount claimed was correct, and that $9,848 was a reasonable amount for attorney fees.
Lyman then moved for disbursement of the funds on deposit. On October 18, 1991, the trial court ordered disbursement of $123,838.94 plus post-judgment interest of $23.75 per day from September 12, 1991. MacLean filed a notice of appeal and Lyman filed a notice of review.


*254 ISSUES
1. Did MacLean waive its claim that Lyman overstated the mechanics' lien amount?
2. Did the trial court err in calculating prejudgment interest at the contract rate?

ANALYSIS

Standard of Review
On an appeal from summary judgment, this court determines whether genuine issues of material fact exist for trial and whether the trial court erred in applying the law. Offerdahl v. University of Minn. Hosps. & Clinics, 426 N.W.2d 425, 427 (Minn.1988). The evidence is viewed in the light most favorable to the party against whom summary judgment was granted. Grondahl v. Bulluck, 318 N.W.2d 240, 242 (Minn.1982).

1. Waiver.
Lyman contends MacLean waived his defense that the lien claim is overstated because he did not plead the overstatement as an affirmative defense. We agree.
In pleading an affirmative defense, the defendant admits the allegations in the complaint, but seeks to avoid liability by alleging the plaintiff's wrongdoing. Rees v. Storms, 101 Minn. 381, 384, 112 N.W. 419, 420 (1907). Minn.Stat. § 514.74 (1990) clearly indicates that overstatement is an affirmative defense, providing:
In no case shall a lien exist for a greater amount than the sum claimed in the lien statement, nor for any amount, if it be made to appear that the claimant has knowingly demanded in the statement more than is justly due.
Lyman claimed a balance due of $83,029.36 in its lien statement, complaint, and bill of particulars. In his answer, MacLean denied Lyman's allegations regarding the amount due, but did not affirmatively allege that the lien claim was overstated. Although Lyman later stated the actual principal balance due was $80,649.04 plus interest, MacLean did not move to amend his answer to raise the overstatement defense. We conclude MacLean waived the overstatement defense when he did not raise it in responsive pleadings. See Minn. R.Civ.P. 8.03 (responsive pleading "shall set forth affirmatively * * * any * * * matter constituting an avoidance or affirmative defense"); Minn.R.Civ.P. 12.02 (all defenses "shall be asserted in the responsive pleading"); Ulstruck v. Home Ass'n, 166 Minn. 183, 185, 207 N.W. 324, 325 (1926) (refusing to consider overstatement issue where "[n]o such defense was pleaded and no finding was asked thereon"); Ruedlinger v. Fisher, 160 Minn. 324, 325-26, 200 N.W. 299, 300 (1924) (refusing to consider overstatement issue on appeal when "not presented by the pleadings").

2. Interest.
Minn.Stat. § 514.135 (1990) provides:
Except as otherwise provided by contract, interest awarded on mechanics' lien claims shall be calculated at the legal rate, as provided in section 334.01 [6%], from the time the underlying obligation arises until the expiration of 30 days after the claimant's last item of labor, skill, or materials was furnished to the improvement and shall be calculated thereafter at the rate computed for verdicts and judgments, as provided in section 549.09 [prejudgment interest].
MacLean contends that his interest obligation is limited to 6% because he is not bound by the contract between Cornerstone, the owner of the equitable interest under the contract for deed, and Lyman, the lien claimant. MacLean argues the trial court thus erred in calculating prejudgment interest at the 18% rate specified in the Lyman-Cornerstone contract. We agree.
In an analogous case, Northwest Wholesale Lumber, Inc. v. Citadel Co., 457 N.W.2d 244 (Minn.App.1990), Builders Finance, Inc. foreclosed its mortgage against Citadel, a bankrupt building and design firm. Citadel had contracted for improvements to the property, agreeing to pay 18% interest on all overdue payments to one of the lien claimants. Id. at 247. The lien *255 claimant attempted to collect the 18% interest from Builders Finance. Id. This court rejected the lien claimant's argument that Builders Finance was bound by the contract, stating:
[T]he lien is not being enforced against Citadel. The lien is enforceable against Builders Finance as an owner of the encumbered property, not as a party to the construction contract. * * * Accordingly, prejudgment interest must be calculated at the legal rate of 6%.
Id. at 250. Although section 514.135 did not apply in the Northwest decision, we do not believe that it changes the result. The same rationale applies. MacLean was not a party to the Lyman-Cornerstone contract, and Lyman is enforcing its lien against MacLean, as the owner of the encumbered property and not as a party to the contract.
In addition, Minn.Stat. § 514.03, upon which the Northwest court relied,[1] supports the present result. Section 514.03 provides that "under a contract with the owner and for an agreed price, the lien as against the owner shall be" for the contract price, and "[i]n all other cases" the lien shall be for the reasonable value of the materials supplied. Minn.Stat. § 514.03, subd. 2 (1990) (emphasis added). Here, the contract that Lyman seeks to enforce is between it and Cornerstone, not between it and MacLean. We conclude that Lyman may not enforce the contract interest rate against MacLean.
In addition, we note the trial court erred in calculating the interest due under either the contract or legal rate. The trial court calculated prejudgment interest on $83,029.36, rather than on the principal balance of $80,649.04, effectively ordering MacLean to pay interest upon interest. On remand, the trial court shall calculate interest upon the principal balance according to the formula in section 514.135.
Finally, both Lyman and MacLean challenge the trial court's award of $9,848 in attorney fees. In addition, Lyman contests the trial court's $1,071.48 costs award. In light of our disposition and the need for further proceedings, we remand for recalculation of attorney fees and costs.
While the trial court has discretion to award reasonable attorney fees to the prevailing party in a mechanics' lien foreclosure action, the court is not bound by the amount of attorney fees deposited as security for release of the lien under section 514.10. Rather, the trial court should consider the following factors in determining reasonable attorney fees:
1. the time and effort required,
2. the novelty or difficulty of the issues,
3. the skill and standing of the attorney,
4. the value of the interest involved,
5. the results secured at trial,
6. the loss of opportunity for other employment,
7. the taxed party's ability to pay,
8. the customary charges for similar services,
9. the certainty of payment.
Jadwin v. Kasal, 318 N.W.2d 844, 848 (Minn.1982). In addition, the award must bear a "reasonable relation to the amount of the judgment secured." Northwest, 457 N.W.2d at 251. Likewise, the portion of the deposited security relating to costs is not binding upon the trial court. After considering the appropriate factors, the trial court's award of attorney fees and costs may be greater or less than the preliminary amounts established as security.

DECISION
MacLean waived the affirmative defense of an overstated lien claim because he did not allege the defense in his responsive pleadings. The trial court erred in calculating prejudgment interest at the contract rate where MacLean was not a party to the contract. Preliminary estimates of attorney *256 fees and costs for purposes of section 514.10 are not final and shall be recalculated on remand.
Affirmed in part, reversed in part, and remanded.
NOTES
[*]  Retired judge of the district court, acting as judge of the Court of Appeals by appointment pursuant to Minn. Const. art. VI, § 2.
[1]  Minn.Stat. § 514.03, subd. 1 (1982) provides:

(a) if the contribution is made under a contract with the owner * * * the lien as against him shall be for the sum agreed upon.
(b) In all other cases, it shall be for the reasonable value of the work done.
