@@ -37,6 +37,9 @@ export default class BatchStore {
37
37
/** the timestamp of the next batch in seconds */
38
38
nextBatchTimestamp = 0 ;
39
39
40
+ /** the fee rate (sats/vbyte) estimated by the auctioneer to use for the next batch */
41
+ nextFeeRate = 0 ;
42
+
40
43
/** the tier of the current LND node */
41
44
nodeTier ?: Tier ;
42
45
@@ -140,7 +143,7 @@ export default class BatchStore {
140
143
try {
141
144
const poolBatches = await this . _store . api . pool . batchSnapshots ( 1 ) ;
142
145
// update the timestamp of the next batch when fetching the latest batch
143
- await this . fetchNextBatchTimestamp ( ) ;
146
+ await this . fetchNextBatchInfo ( ) ;
144
147
runInAction ( ( ) => {
145
148
// update the batches in all markets
146
149
this . markets . forEach ( m => m . update ( poolBatches . batchesList , true ) ) ;
@@ -156,26 +159,28 @@ export default class BatchStore {
156
159
fetchLatestBatchThrottled = debounce ( this . fetchLatestBatch , 2000 ) ;
157
160
158
161
/**
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
160
163
*/
161
- async fetchNextBatchTimestamp ( ) {
164
+ async fetchNextBatchInfo ( ) {
162
165
this . _store . log . info ( 'fetching next batch info' ) ;
163
166
try {
164
- const { clearTimestamp } = await this . _store . api . pool . nextBatchInfo ( ) ;
167
+ const res = await this . _store . api . pool . nextBatchInfo ( ) ;
165
168
runInAction ( ( ) => {
166
- this . setNextBatchTimestamp ( clearTimestamp ) ;
169
+ this . setNextBatchTimestamp ( res . clearTimestamp ) ;
167
170
this . _store . log . info (
168
171
'updated batchStore.nextBatchTimestamp' ,
169
172
this . nextBatchTimestamp ,
170
173
) ;
174
+ this . setNextFeeRate ( res . feeRateSatPerKw ) ;
175
+ this . _store . log . info ( 'updated batchStore.nextFeeRate' , this . nextFeeRate ) ;
171
176
} ) ;
172
177
} 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 ' ) ;
174
179
}
175
180
}
176
181
177
182
/**
178
- * fetches the next batch timestamp from the API
183
+ * fetches the current lnd node's tier from the API
179
184
*/
180
185
async fetchNodeTier ( ) {
181
186
this . _store . log . info ( 'fetching node tier' ) ;
@@ -263,6 +268,14 @@ export default class BatchStore {
263
268
this . _nextBatchTimer = setTimeout ( this . fetchLatestBatch , ms + 3000 ) ;
264
269
}
265
270
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
+
266
279
startPolling ( ) {
267
280
if ( IS_TEST ) return ;
268
281
if ( this . _pollingInterval ) this . stopPolling ( ) ;
0 commit comments