@@ -37,6 +37,9 @@ export default class BatchStore {
3737 /** the timestamp of the next batch in seconds */
3838 nextBatchTimestamp = 0 ;
3939
40+ /** the fee rate (sats/vbyte) estimated by the auctioneer to use for the next batch */
41+ nextFeeRate = 0 ;
42+
4043 /** the tier of the current LND node */
4144 nodeTier ?: Tier ;
4245
@@ -140,7 +143,7 @@ export default class BatchStore {
140143 try {
141144 const poolBatches = await this . _store . api . pool . batchSnapshots ( 1 ) ;
142145 // update the timestamp of the next batch when fetching the latest batch
143- await this . fetchNextBatchTimestamp ( ) ;
146+ await this . fetchNextBatchInfo ( ) ;
144147 runInAction ( ( ) => {
145148 // update the batches in all markets
146149 this . markets . forEach ( m => m . update ( poolBatches . batchesList , true ) ) ;
@@ -156,26 +159,28 @@ export default class BatchStore {
156159 fetchLatestBatchThrottled = debounce ( this . fetchLatestBatch , 2000 ) ;
157160
158161 /**
159- * fetches the next batch timestamp from the API
162+ * fetches the next batch info from the API and updates the next timestamp and fee rate
160163 */
161- async fetchNextBatchTimestamp ( ) {
164+ async fetchNextBatchInfo ( ) {
162165 this . _store . log . info ( 'fetching next batch info' ) ;
163166 try {
164- const { clearTimestamp } = await this . _store . api . pool . nextBatchInfo ( ) ;
167+ const res = await this . _store . api . pool . nextBatchInfo ( ) ;
165168 runInAction ( ( ) => {
166- this . setNextBatchTimestamp ( clearTimestamp ) ;
169+ this . setNextBatchTimestamp ( res . clearTimestamp ) ;
167170 this . _store . log . info (
168171 'updated batchStore.nextBatchTimestamp' ,
169172 this . nextBatchTimestamp ,
170173 ) ;
174+ this . setNextFeeRate ( res . feeRateSatPerKw ) ;
175+ this . _store . log . info ( 'updated batchStore.nextFeeRate' , this . nextFeeRate ) ;
171176 } ) ;
172177 } catch ( error ) {
173- this . _store . appView . handleError ( error , 'Unable to fetch the next batch timestamp ' ) ;
178+ this . _store . appView . handleError ( error , 'Unable to fetch the next batch info ' ) ;
174179 }
175180 }
176181
177182 /**
178- * fetches the next batch timestamp from the API
183+ * fetches the current lnd node's tier from the API
179184 */
180185 async fetchNodeTier ( ) {
181186 this . _store . log . info ( 'fetching node tier' ) ;
@@ -263,6 +268,14 @@ export default class BatchStore {
263268 this . _nextBatchTimer = setTimeout ( this . fetchLatestBatch , ms + 3000 ) ;
264269 }
265270
271+ /**
272+ * sets the nextFeeRate by converting the provided sats/kw to sats/vbyte
273+ */
274+ setNextFeeRate ( satsPerKWeight : number ) {
275+ const satsPerVbyte = this . _store . api . pool . satsPerKWeightToVByte ( satsPerKWeight ) ;
276+ this . nextFeeRate = Math . ceil ( satsPerVbyte ) ;
277+ }
278+
266279 startPolling ( ) {
267280 if ( IS_TEST ) return ;
268281 if ( this . _pollingInterval ) this . stopPolling ( ) ;
0 commit comments