@@ -2,6 +2,7 @@ import { assert, Fail } from '@endo/errors';
22import { E } from '@endo/eventual-send' ;
33import { Far } from '@endo/marshal' ;
44import { makePromiseKit } from '@endo/promise-kit' ;
5+ import { M , mustMatch } from '@endo/patterns' ;
56import { AmountMath } from '@agoric/ertp' ;
67
78import {
@@ -16,6 +17,10 @@ import { calculateInterest, makeDebtCalculator } from './updateDebt.js';
1617import { makeCloseLoanInvitation } from './close.js' ;
1718import { makeAddCollateralInvitation } from './addCollateral.js' ;
1819
20+ /**
21+ * @import {NatAmount} from '@agoric/ertp';
22+ */
23+
1924/** @type {MakeBorrowInvitation } */
2025export const makeBorrowInvitation = ( zcf , config ) => {
2126 const {
@@ -28,7 +33,9 @@ export const makeBorrowInvitation = (zcf, config) => {
2833 } = config ;
2934
3035 // We can only lend what the lender has already escrowed.
31- const maxLoan = lenderSeat . getAmountAllocated ( 'Loan' ) ;
36+ const maxLoan = /** @type {NatAmount } */ (
37+ lenderSeat . getAmountAllocated ( 'Loan' )
38+ ) ;
3239
3340 /** @type {OfferHandler } */
3441 const borrow = async borrowerSeat => {
@@ -43,7 +50,10 @@ export const makeBorrowInvitation = (zcf, config) => {
4350 borrowerSeat . getProposal ( ) . give . Collateral . brand
4451 ) ,
4552 ) ;
46- const loanWanted = borrowerSeat . getProposal ( ) . want . Loan ;
53+ const loanWanted = /** @type {NatAmount } */ (
54+ borrowerSeat . getProposal ( ) . want . Loan
55+ ) ;
56+ mustMatch ( loanWanted . value , M . nat ( ) ) ;
4757 const loanBrand = zcf . getTerms ( ) . brands . Loan ;
4858
4959 // The value of the collateral in the Loan brand
0 commit comments