@@ -104,12 +104,12 @@ export class TrancheService extends Tranche {
104104 return this
105105 }
106106 const accruedFees = bnToBn ( navResponse . unwrap ( ) . navFees . toBigInt ( ) )
107- if ( ! this . tokenSupply || this . tokenSupply === BigInt ( 0 ) ) {
107+ if ( ! this . tokenSupply || this . tokenSupply === BigInt ( 0 ) ) {
108108 logger . warn ( `Token supply equal 0! Cannot perform division. Token price: ${ price } ` )
109109 this . tokenPrice = price
110110 return this
111111 }
112- this . tokenPrice = nToBigInt ( bnToBn ( price ) . sub ( accruedFees . mul ( WAD ) . div ( bnToBn ( this . tokenSupply ) ) ) )
112+ this . tokenPrice = nToBigInt ( bnToBn ( price ) . sub ( accruedFees . mul ( WAD ) . div ( bnToBn ( this . tokenSupply ) ) ) )
113113 logger . info ( `Updating price for tranche ${ this . id } to: ${ this . tokenPrice } (ACCOUNTING FOR ACCRUED FEES)` )
114114 return this
115115 }
@@ -134,9 +134,9 @@ export class TrancheService extends Tranche {
134134 return this
135135 }
136136
137- public async computeYield ( yieldField : string , referencePeriodStart ?: Date ) {
137+ public async computeYield ( yieldField : BigIntFields < TrancheService > , referencePeriodStart ?: Date ) {
138138 logger . info (
139- `Computing yield for tranche ${ this . trancheId } of ` +
139+ `Computing yield ${ yieldField } for tranche ${ this . trancheId } of ` +
140140 `pool ${ this . poolId } with reference date ${ referencePeriodStart } `
141141 )
142142
@@ -167,9 +167,13 @@ export class TrancheService extends Tranche {
167167 return this
168168 }
169169
170- public async computeYieldAnnualized ( yieldField : string , currentPeriodStart : Date , referencePeriodStart : Date ) {
170+ public async computeYieldAnnualized (
171+ yieldField : BigIntFields < TrancheService > ,
172+ currentPeriodStart : Date ,
173+ referencePeriodStart : Date
174+ ) {
171175 logger . info (
172- `Computing annualized yield for tranche ${ this . trancheId } of ` +
176+ `Computing annualized yield ${ yieldField } for tranche ${ this . trancheId } of ` +
173177 `pool ${ this . poolId } with reference date ${ referencePeriodStart } `
174178 )
175179 const trancheSnapshots = await TrancheSnapshot . getByPeriodStart ( referencePeriodStart )
@@ -246,3 +250,5 @@ export class TrancheService extends Tranche {
246250 this . isActive = true
247251 }
248252}
253+
254+ type BigIntFields < T > = { [ K in keyof T ] : T [ K ] extends bigint ? K : never } [ keyof T ]
0 commit comments