@@ -168,12 +168,10 @@ export class ReadableEthersLiquity implements ReadableLiquity {
168
168
169
169
/** {@inheritDoc @liquity/lib-base#ReadableLiquity.getTrove } */
170
170
async getTrove ( address ?: string , overrides ?: EthersCallOverrides ) : Promise < Trove > {
171
- address ??= _requireAddress ( this . connection ) ;
172
-
173
171
const [ trove , totalRedistributed ] = await Promise . all ( [
174
- this . getTroveBeforeRedistribution ( address , { ... overrides } ) ,
175
- this . getTotalRedistributed ( { ... overrides } )
176
- ] as const ) ;
172
+ this . getTroveBeforeRedistribution ( address , overrides ) ,
173
+ this . getTotalRedistributed ( overrides )
174
+ ] ) ;
177
175
178
176
return trove . applyRedistribution ( totalRedistributed ) ;
179
177
}
@@ -316,8 +314,8 @@ export class ReadableEthersLiquity implements ReadableLiquity {
316
314
}
317
315
}
318
316
319
- /** { @inheritDoc @liquity/lib-base#ReadableLiquity.getFees } */
320
- async getFees ( overrides ?: EthersCallOverrides ) : Promise < Fees > {
317
+ /** @internal */
318
+ async _getFeesInNormalMode ( overrides ?: EthersCallOverrides ) : Promise < Fees > {
321
319
const { troveManager } = _getContracts ( this . connection ) ;
322
320
323
321
const [ lastFeeOperationTime , baseRateWithoutDecay ] = await Promise . all ( [
@@ -330,6 +328,17 @@ export class ReadableEthersLiquity implements ReadableLiquity {
330
328
return new Fees ( lastFeeOperation , baseRateWithoutDecay , MINUTE_DECAY_FACTOR , BETA ) ;
331
329
}
332
330
331
+ /** {@inheritDoc @liquity/lib-base#ReadableLiquity.getFees } */
332
+ async getFees ( overrides ?: EthersCallOverrides ) : Promise < Fees > {
333
+ const [ feesInNormalMode , total , price ] = await Promise . all ( [
334
+ this . _getFeesInNormalMode ( overrides ) ,
335
+ this . getTotal ( overrides ) ,
336
+ this . getPrice ( overrides )
337
+ ] ) ;
338
+
339
+ return feesInNormalMode . _setRecoveryMode ( total . collateralRatioIsBelowCritical ( price ) ) ;
340
+ }
341
+
333
342
/** {@inheritDoc @liquity/lib-base#ReadableLiquity.getLQTYStake } */
334
343
async getLQTYStake ( address ?: string , overrides ?: EthersCallOverrides ) : Promise < LQTYStake > {
335
344
address ??= _requireAddress ( this . connection ) ;
@@ -500,6 +509,12 @@ class BlockPolledLiquityStoreBasedCache
500
509
}
501
510
}
502
511
512
+ _getFeesInNormalMode ( overrides ?: EthersCallOverrides ) : Fees | undefined {
513
+ if ( this . _blockHit ( overrides ) ) {
514
+ return this . _store . state . _feesInNormalMode ;
515
+ }
516
+ }
517
+
503
518
getFees ( overrides ?: EthersCallOverrides ) : Fees | undefined {
504
519
if ( this . _blockHit ( overrides ) ) {
505
520
return this . _store . state . fees ;
0 commit comments