Skip to content

Commit

Permalink
bump
Browse files Browse the repository at this point in the history
  • Loading branch information
lukecaan committed Dec 28, 2023
1 parent 1b1b20a commit a0138ba
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions sdk/src/priorityFee/priorityFeeSubscriber.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,21 +64,29 @@ export class PriorityFeeSubscriber {
[this.addresses]
);

// getRecentPrioritizationFees returns results unsorted
const results: { slot: number; prioritizationFee: number }[] =
rpcJSONResponse?.result;

if (!results.length) return;

// # Sort and filter results based on the slot lookback setting
const descResults = results.sort((a, b) => b.slot - a.slot);
const mostRecentResult = descResults[0];
const cutoffSlot = mostRecentResult.slot - this.lookbackDistance;

const resultsToUse = descResults.filter(result => result.slot >= cutoffSlot);

// # Handle results
this.latestPriorityFee = mostRecentResult.prioritizationFee;
this.lastSlotSeen = mostRecentResult.slot;
this.lastCustomStrategyResult = this.customStrategy.calculate(resultsToUse);

this.lastAvgStrategyResult = this.averageStrategy.calculate(resultsToUse);
this.lastMaxStrategyResult = this.maxStrategy.calculate(resultsToUse);
if (this.customStrategy) {
this.lastCustomStrategyResult =
this.customStrategy.calculate(resultsToUse);
}

}

public async unsubscribe(): Promise<void> {
Expand Down

0 comments on commit a0138ba

Please sign in to comment.