Skip to content

Commit

Permalink
regression library import
Browse files Browse the repository at this point in the history
  • Loading branch information
arietrouw committed Oct 9, 2024
1 parent 75bcf2b commit 1ec0cca
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ import type { EthereumGasBlocknativePayload } from '@xyo-network/blocknative-eth
import type {
FeeData, FeePerGas, PriorityFeePerGas,
} from '@xyo-network/gas-price-payload-plugin'
import { linear } from 'regression'
import regression from 'regression'

const getBaseFee = (payload: EthereumGasBlocknativePayload): number | undefined => {
return payload?.blockPrices?.[0]?.baseFeePerGas
}

const getFeePerGas = (payload: EthereumGasBlocknativePayload): Partial<FeePerGas> => {
const sorted = payload.blockPrices?.[0].estimatedPrices?.sort((a, b) => a.confidence - b.confidence)
const trend = linear([
const trend = regression.linear([
[0, sorted?.[0].price],
[1, sorted?.[1].price],
[2, sorted?.[2].price],
Expand All @@ -28,7 +28,7 @@ const getFeePerGas = (payload: EthereumGasBlocknativePayload): Partial<FeePerGas

const getPriorityFeePerGas = (payload: EthereumGasBlocknativePayload): Partial<PriorityFeePerGas> => {
const sorted = payload.blockPrices?.[0].estimatedPrices?.sort((a, b) => a.confidence - b.confidence)
const trend = linear([
const trend = regression.linear([
[0, sorted?.[0].maxPriorityFeePerGas],
[1, sorted?.[1].maxPriorityFeePerGas],
[2, sorted?.[2].maxPriorityFeePerGas],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { EthereumGasEtherscanPayload } from '@xyo-network/etherscan-ethereum-gas-payload-plugin'
import type { FeeData, FeePerGas } from '@xyo-network/gas-price-payload-plugin'
import { linear } from 'regression'
import regression from 'regression'

const getBaseFee = (payload: EthereumGasEtherscanPayload): number | undefined => {
const { suggestBaseFee } = payload.result
Expand All @@ -14,7 +14,7 @@ const getFeePerGas = (payload: EthereumGasEtherscanPayload): Partial<FeePerGas>
const low = Number.parseFloat(SafeGasPrice)
const medium = Number.parseFloat(ProposeGasPrice)
const high = Number.parseFloat(FastGasPrice)
const veryHigh = linear([
const veryHigh = regression.linear([
[0, low],
[1, medium],
[2, high],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { EthereumGasEthgasstationPayload } from '@xyo-network/ethgasstation
import type {
FeeData, FeePerGas, PriorityFeePerGas,
} from '@xyo-network/gas-price-payload-plugin'
import { linear } from 'regression'
import regression from 'regression'

const getBaseFee = (payload: EthereumGasEthgasstationPayload): number | undefined => {
const { baseFee } = payload
Expand All @@ -13,7 +13,7 @@ const getFeePerGas = (payload: EthereumGasEthgasstationPayload): Partial<FeePerG
const {
standard: medium, fast: high, instant: veryHigh,
} = payload.gasPrice
const trend = linear([
const trend = regression.linear([
[1, medium],
[2, high],
[3, veryHigh],
Expand All @@ -28,7 +28,7 @@ const getPriorityFeePerGas = (payload: EthereumGasEthgasstationPayload): Partial
const {
standard: medium, fast: high, instant: veryHigh,
} = payload.priorityFee
const trend = linear([
const trend = regression.linear([
[1, medium],
[2, high],
[3, veryHigh],
Expand Down

0 comments on commit 1ec0cca

Please sign in to comment.