@xyo-network/gas-price-plugin 2.42.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +165 -0
- package/README.md +81 -0
- package/dist/cjs/Diviner.d.ts +16 -0
- package/dist/cjs/Diviner.d.ts.map +1 -0
- package/dist/cjs/Diviner.js +29 -0
- package/dist/cjs/Diviner.js.map +1 -0
- package/dist/cjs/Plugin.d.ts +13 -0
- package/dist/cjs/Plugin.d.ts.map +1 -0
- package/dist/cjs/Plugin.js +15 -0
- package/dist/cjs/Plugin.js.map +1 -0
- package/dist/cjs/Schema.d.ts +5 -0
- package/dist/cjs/Schema.d.ts.map +1 -0
- package/dist/cjs/Schema.js +6 -0
- package/dist/cjs/Schema.js.map +1 -0
- package/dist/cjs/index.d.ts +6 -0
- package/dist/cjs/index.d.ts.map +1 -0
- package/dist/cjs/index.js +11 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/lib/average.d.ts +8 -0
- package/dist/cjs/lib/average.d.ts.map +1 -0
- package/dist/cjs/lib/average.js +48 -0
- package/dist/cjs/lib/average.js.map +1 -0
- package/dist/cjs/lib/divineGas.d.ts +6 -0
- package/dist/cjs/lib/divineGas.d.ts.map +1 -0
- package/dist/cjs/lib/divineGas.js +23 -0
- package/dist/cjs/lib/divineGas.js.map +1 -0
- package/dist/cjs/lib/identities/index.d.ts +7 -0
- package/dist/cjs/lib/identities/index.d.ts.map +1 -0
- package/dist/cjs/lib/identities/index.js +10 -0
- package/dist/cjs/lib/identities/index.js.map +1 -0
- package/dist/cjs/lib/identities/isXyoEthereumGasBlocknativePayload.d.ts +6 -0
- package/dist/cjs/lib/identities/isXyoEthereumGasBlocknativePayload.d.ts.map +1 -0
- package/dist/cjs/lib/identities/isXyoEthereumGasBlocknativePayload.js +9 -0
- package/dist/cjs/lib/identities/isXyoEthereumGasBlocknativePayload.js.map +1 -0
- package/dist/cjs/lib/identities/isXyoEthereumGasEtherchainV1Payload.d.ts +6 -0
- package/dist/cjs/lib/identities/isXyoEthereumGasEtherchainV1Payload.d.ts.map +1 -0
- package/dist/cjs/lib/identities/isXyoEthereumGasEtherchainV1Payload.js +9 -0
- package/dist/cjs/lib/identities/isXyoEthereumGasEtherchainV1Payload.js.map +1 -0
- package/dist/cjs/lib/identities/isXyoEthereumGasEtherchainV2Payload.d.ts +6 -0
- package/dist/cjs/lib/identities/isXyoEthereumGasEtherchainV2Payload.d.ts.map +1 -0
- package/dist/cjs/lib/identities/isXyoEthereumGasEtherchainV2Payload.js +9 -0
- package/dist/cjs/lib/identities/isXyoEthereumGasEtherchainV2Payload.js.map +1 -0
- package/dist/cjs/lib/identities/isXyoEthereumGasEthersPayload.d.ts +6 -0
- package/dist/cjs/lib/identities/isXyoEthereumGasEthersPayload.d.ts.map +1 -0
- package/dist/cjs/lib/identities/isXyoEthereumGasEthersPayload.js +9 -0
- package/dist/cjs/lib/identities/isXyoEthereumGasEthersPayload.js.map +1 -0
- package/dist/cjs/lib/identities/isXyoEthereumGasEtherscanPayload.d.ts +6 -0
- package/dist/cjs/lib/identities/isXyoEthereumGasEtherscanPayload.d.ts.map +1 -0
- package/dist/cjs/lib/identities/isXyoEthereumGasEtherscanPayload.js +9 -0
- package/dist/cjs/lib/identities/isXyoEthereumGasEtherscanPayload.js.map +1 -0
- package/dist/cjs/lib/identities/isXyoEthereumGasEthgasstationPayload.d.ts +6 -0
- package/dist/cjs/lib/identities/isXyoEthereumGasEthgasstationPayload.d.ts.map +1 -0
- package/dist/cjs/lib/identities/isXyoEthereumGasEthgasstationPayload.js +9 -0
- package/dist/cjs/lib/identities/isXyoEthereumGasEthgasstationPayload.js.map +1 -0
- package/dist/cjs/lib/index.d.ts +2 -0
- package/dist/cjs/lib/index.d.ts.map +1 -0
- package/dist/cjs/lib/index.js +5 -0
- package/dist/cjs/lib/index.js.map +1 -0
- package/dist/cjs/lib/transforms/index.d.ts +7 -0
- package/dist/cjs/lib/transforms/index.d.ts.map +1 -0
- package/dist/cjs/lib/transforms/index.js +10 -0
- package/dist/cjs/lib/transforms/index.js.map +1 -0
- package/dist/cjs/lib/transforms/transformGasFromBlocknative.d.ts +4 -0
- package/dist/cjs/lib/transforms/transformGasFromBlocknative.d.ts.map +1 -0
- package/dist/cjs/lib/transforms/transformGasFromBlocknative.js +52 -0
- package/dist/cjs/lib/transforms/transformGasFromBlocknative.js.map +1 -0
- package/dist/cjs/lib/transforms/transformGasFromEtherchainV1.d.ts +4 -0
- package/dist/cjs/lib/transforms/transformGasFromEtherchainV1.d.ts.map +1 -0
- package/dist/cjs/lib/transforms/transformGasFromEtherchainV1.js +23 -0
- package/dist/cjs/lib/transforms/transformGasFromEtherchainV1.js.map +1 -0
- package/dist/cjs/lib/transforms/transformGasFromEtherchainV2.d.ts +4 -0
- package/dist/cjs/lib/transforms/transformGasFromEtherchainV2.d.ts.map +1 -0
- package/dist/cjs/lib/transforms/transformGasFromEtherchainV2.js +19 -0
- package/dist/cjs/lib/transforms/transformGasFromEtherchainV2.js.map +1 -0
- package/dist/cjs/lib/transforms/transformGasFromEthers.d.ts +4 -0
- package/dist/cjs/lib/transforms/transformGasFromEthers.d.ts.map +1 -0
- package/dist/cjs/lib/transforms/transformGasFromEthers.js +25 -0
- package/dist/cjs/lib/transforms/transformGasFromEthers.js.map +1 -0
- package/dist/cjs/lib/transforms/transformGasFromEtherscan.d.ts +4 -0
- package/dist/cjs/lib/transforms/transformGasFromEtherscan.d.ts.map +1 -0
- package/dist/cjs/lib/transforms/transformGasFromEtherscan.js +28 -0
- package/dist/cjs/lib/transforms/transformGasFromEtherscan.js.map +1 -0
- package/dist/cjs/lib/transforms/transformGasFromEthgasstation.d.ts +4 -0
- package/dist/cjs/lib/transforms/transformGasFromEthgasstation.d.ts.map +1 -0
- package/dist/cjs/lib/transforms/transformGasFromEthgasstation.js +36 -0
- package/dist/cjs/lib/transforms/transformGasFromEthgasstation.js.map +1 -0
- package/dist/cjs/test/index.d.ts +7 -0
- package/dist/cjs/test/index.d.ts.map +1 -0
- package/dist/cjs/test/index.js +10 -0
- package/dist/cjs/test/index.js.map +1 -0
- package/dist/cjs/test/sampleBlocknativeGas.d.ts +3 -0
- package/dist/cjs/test/sampleBlocknativeGas.d.ts.map +1 -0
- package/dist/cjs/test/sampleBlocknativeGas.js +96 -0
- package/dist/cjs/test/sampleBlocknativeGas.js.map +1 -0
- package/dist/cjs/test/sampleEtherchainGasV1.d.ts +3 -0
- package/dist/cjs/test/sampleEtherchainGasV1.d.ts.map +1 -0
- package/dist/cjs/test/sampleEtherchainGasV1.js +15 -0
- package/dist/cjs/test/sampleEtherchainGasV1.js.map +1 -0
- package/dist/cjs/test/sampleEtherchainGasV2.d.ts +3 -0
- package/dist/cjs/test/sampleEtherchainGasV2.d.ts.map +1 -0
- package/dist/cjs/test/sampleEtherchainGasV2.js +18 -0
- package/dist/cjs/test/sampleEtherchainGasV2.js.map +1 -0
- package/dist/cjs/test/sampleEthersGas.d.ts +3 -0
- package/dist/cjs/test/sampleEthersGas.d.ts.map +1 -0
- package/dist/cjs/test/sampleEthersGas.js +13 -0
- package/dist/cjs/test/sampleEthersGas.js.map +1 -0
- package/dist/cjs/test/sampleEtherscanGas.d.ts +3 -0
- package/dist/cjs/test/sampleEtherscanGas.d.ts.map +1 -0
- package/dist/cjs/test/sampleEtherscanGas.js +19 -0
- package/dist/cjs/test/sampleEtherscanGas.js.map +1 -0
- package/dist/cjs/test/sampleEthgasstationGas.d.ts +3 -0
- package/dist/cjs/test/sampleEthgasstationGas.d.ts.map +1 -0
- package/dist/cjs/test/sampleEthgasstationGas.js +23 -0
- package/dist/cjs/test/sampleEthgasstationGas.js.map +1 -0
- package/dist/docs.json +4534 -0
- package/dist/esm/Diviner.d.ts +16 -0
- package/dist/esm/Diviner.d.ts.map +1 -0
- package/dist/esm/Diviner.js +19 -0
- package/dist/esm/Diviner.js.map +1 -0
- package/dist/esm/Plugin.d.ts +13 -0
- package/dist/esm/Plugin.d.ts.map +1 -0
- package/dist/esm/Plugin.js +10 -0
- package/dist/esm/Plugin.js.map +1 -0
- package/dist/esm/Schema.d.ts +5 -0
- package/dist/esm/Schema.d.ts.map +1 -0
- package/dist/esm/Schema.js +3 -0
- package/dist/esm/Schema.js.map +1 -0
- package/dist/esm/index.d.ts +6 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js +7 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/lib/average.d.ts +8 -0
- package/dist/esm/lib/average.d.ts.map +1 -0
- package/dist/esm/lib/average.js +44 -0
- package/dist/esm/lib/average.js.map +1 -0
- package/dist/esm/lib/divineGas.d.ts +6 -0
- package/dist/esm/lib/divineGas.d.ts.map +1 -0
- package/dist/esm/lib/divineGas.js +19 -0
- package/dist/esm/lib/divineGas.js.map +1 -0
- package/dist/esm/lib/identities/index.d.ts +7 -0
- package/dist/esm/lib/identities/index.d.ts.map +1 -0
- package/dist/esm/lib/identities/index.js +7 -0
- package/dist/esm/lib/identities/index.js.map +1 -0
- package/dist/esm/lib/identities/isXyoEthereumGasBlocknativePayload.d.ts +6 -0
- package/dist/esm/lib/identities/isXyoEthereumGasBlocknativePayload.d.ts.map +1 -0
- package/dist/esm/lib/identities/isXyoEthereumGasBlocknativePayload.js +5 -0
- package/dist/esm/lib/identities/isXyoEthereumGasBlocknativePayload.js.map +1 -0
- package/dist/esm/lib/identities/isXyoEthereumGasEtherchainV1Payload.d.ts +6 -0
- package/dist/esm/lib/identities/isXyoEthereumGasEtherchainV1Payload.d.ts.map +1 -0
- package/dist/esm/lib/identities/isXyoEthereumGasEtherchainV1Payload.js +5 -0
- package/dist/esm/lib/identities/isXyoEthereumGasEtherchainV1Payload.js.map +1 -0
- package/dist/esm/lib/identities/isXyoEthereumGasEtherchainV2Payload.d.ts +6 -0
- package/dist/esm/lib/identities/isXyoEthereumGasEtherchainV2Payload.d.ts.map +1 -0
- package/dist/esm/lib/identities/isXyoEthereumGasEtherchainV2Payload.js +5 -0
- package/dist/esm/lib/identities/isXyoEthereumGasEtherchainV2Payload.js.map +1 -0
- package/dist/esm/lib/identities/isXyoEthereumGasEthersPayload.d.ts +6 -0
- package/dist/esm/lib/identities/isXyoEthereumGasEthersPayload.d.ts.map +1 -0
- package/dist/esm/lib/identities/isXyoEthereumGasEthersPayload.js +5 -0
- package/dist/esm/lib/identities/isXyoEthereumGasEthersPayload.js.map +1 -0
- package/dist/esm/lib/identities/isXyoEthereumGasEtherscanPayload.d.ts +6 -0
- package/dist/esm/lib/identities/isXyoEthereumGasEtherscanPayload.d.ts.map +1 -0
- package/dist/esm/lib/identities/isXyoEthereumGasEtherscanPayload.js +5 -0
- package/dist/esm/lib/identities/isXyoEthereumGasEtherscanPayload.js.map +1 -0
- package/dist/esm/lib/identities/isXyoEthereumGasEthgasstationPayload.d.ts +6 -0
- package/dist/esm/lib/identities/isXyoEthereumGasEthgasstationPayload.d.ts.map +1 -0
- package/dist/esm/lib/identities/isXyoEthereumGasEthgasstationPayload.js +5 -0
- package/dist/esm/lib/identities/isXyoEthereumGasEthgasstationPayload.js.map +1 -0
- package/dist/esm/lib/index.d.ts +2 -0
- package/dist/esm/lib/index.d.ts.map +1 -0
- package/dist/esm/lib/index.js +2 -0
- package/dist/esm/lib/index.js.map +1 -0
- package/dist/esm/lib/transforms/index.d.ts +7 -0
- package/dist/esm/lib/transforms/index.d.ts.map +1 -0
- package/dist/esm/lib/transforms/index.js +7 -0
- package/dist/esm/lib/transforms/index.js.map +1 -0
- package/dist/esm/lib/transforms/transformGasFromBlocknative.d.ts +4 -0
- package/dist/esm/lib/transforms/transformGasFromBlocknative.d.ts.map +1 -0
- package/dist/esm/lib/transforms/transformGasFromBlocknative.js +45 -0
- package/dist/esm/lib/transforms/transformGasFromBlocknative.js.map +1 -0
- package/dist/esm/lib/transforms/transformGasFromEtherchainV1.d.ts +4 -0
- package/dist/esm/lib/transforms/transformGasFromEtherchainV1.d.ts.map +1 -0
- package/dist/esm/lib/transforms/transformGasFromEtherchainV1.js +19 -0
- package/dist/esm/lib/transforms/transformGasFromEtherchainV1.js.map +1 -0
- package/dist/esm/lib/transforms/transformGasFromEtherchainV2.d.ts +4 -0
- package/dist/esm/lib/transforms/transformGasFromEtherchainV2.d.ts.map +1 -0
- package/dist/esm/lib/transforms/transformGasFromEtherchainV2.js +15 -0
- package/dist/esm/lib/transforms/transformGasFromEtherchainV2.js.map +1 -0
- package/dist/esm/lib/transforms/transformGasFromEthers.d.ts +4 -0
- package/dist/esm/lib/transforms/transformGasFromEthers.d.ts.map +1 -0
- package/dist/esm/lib/transforms/transformGasFromEthers.js +21 -0
- package/dist/esm/lib/transforms/transformGasFromEthers.js.map +1 -0
- package/dist/esm/lib/transforms/transformGasFromEtherscan.d.ts +4 -0
- package/dist/esm/lib/transforms/transformGasFromEtherscan.d.ts.map +1 -0
- package/dist/esm/lib/transforms/transformGasFromEtherscan.js +24 -0
- package/dist/esm/lib/transforms/transformGasFromEtherscan.js.map +1 -0
- package/dist/esm/lib/transforms/transformGasFromEthgasstation.d.ts +4 -0
- package/dist/esm/lib/transforms/transformGasFromEthgasstation.d.ts.map +1 -0
- package/dist/esm/lib/transforms/transformGasFromEthgasstation.js +32 -0
- package/dist/esm/lib/transforms/transformGasFromEthgasstation.js.map +1 -0
- package/dist/esm/test/index.d.ts +7 -0
- package/dist/esm/test/index.d.ts.map +1 -0
- package/dist/esm/test/index.js +7 -0
- package/dist/esm/test/index.js.map +1 -0
- package/dist/esm/test/sampleBlocknativeGas.d.ts +3 -0
- package/dist/esm/test/sampleBlocknativeGas.d.ts.map +1 -0
- package/dist/esm/test/sampleBlocknativeGas.js +93 -0
- package/dist/esm/test/sampleBlocknativeGas.js.map +1 -0
- package/dist/esm/test/sampleEtherchainGasV1.d.ts +3 -0
- package/dist/esm/test/sampleEtherchainGasV1.d.ts.map +1 -0
- package/dist/esm/test/sampleEtherchainGasV1.js +12 -0
- package/dist/esm/test/sampleEtherchainGasV1.js.map +1 -0
- package/dist/esm/test/sampleEtherchainGasV2.d.ts +3 -0
- package/dist/esm/test/sampleEtherchainGasV2.d.ts.map +1 -0
- package/dist/esm/test/sampleEtherchainGasV2.js +15 -0
- package/dist/esm/test/sampleEtherchainGasV2.js.map +1 -0
- package/dist/esm/test/sampleEthersGas.d.ts +3 -0
- package/dist/esm/test/sampleEthersGas.d.ts.map +1 -0
- package/dist/esm/test/sampleEthersGas.js +10 -0
- package/dist/esm/test/sampleEthersGas.js.map +1 -0
- package/dist/esm/test/sampleEtherscanGas.d.ts +3 -0
- package/dist/esm/test/sampleEtherscanGas.d.ts.map +1 -0
- package/dist/esm/test/sampleEtherscanGas.js +16 -0
- package/dist/esm/test/sampleEtherscanGas.js.map +1 -0
- package/dist/esm/test/sampleEthgasstationGas.d.ts +3 -0
- package/dist/esm/test/sampleEthgasstationGas.d.ts.map +1 -0
- package/dist/esm/test/sampleEthgasstationGas.js +20 -0
- package/dist/esm/test/sampleEthgasstationGas.js.map +1 -0
- package/package.json +87 -0
- package/src/Diviner.spec.ts +131 -0
- package/src/Diviner.ts +28 -0
- package/src/Plugin.spec.ts +11 -0
- package/src/Plugin.ts +16 -0
- package/src/Schema.ts +5 -0
- package/src/index.ts +9 -0
- package/src/lib/average.spec.ts +50 -0
- package/src/lib/average.ts +47 -0
- package/src/lib/divineGas.spec.ts +78 -0
- package/src/lib/divineGas.ts +34 -0
- package/src/lib/identities/index.ts +6 -0
- package/src/lib/identities/isXyoEthereumGasBlocknativePayload.spec.ts +29 -0
- package/src/lib/identities/isXyoEthereumGasBlocknativePayload.ts +6 -0
- package/src/lib/identities/isXyoEthereumGasEtherchainV1Payload.spec.ts +29 -0
- package/src/lib/identities/isXyoEthereumGasEtherchainV1Payload.ts +6 -0
- package/src/lib/identities/isXyoEthereumGasEtherchainV2Payload.spec.ts +29 -0
- package/src/lib/identities/isXyoEthereumGasEtherchainV2Payload.ts +6 -0
- package/src/lib/identities/isXyoEthereumGasEthersPayload.spec.ts +29 -0
- package/src/lib/identities/isXyoEthereumGasEthersPayload.ts +6 -0
- package/src/lib/identities/isXyoEthereumGasEtherscanPayload.spec.ts +29 -0
- package/src/lib/identities/isXyoEthereumGasEtherscanPayload.ts +6 -0
- package/src/lib/identities/isXyoEthereumGasEthgasstationPayload.spec.ts +29 -0
- package/src/lib/identities/isXyoEthereumGasEthgasstationPayload.ts +6 -0
- package/src/lib/index.ts +1 -0
- package/src/lib/transforms/index.ts +6 -0
- package/src/lib/transforms/transformGasFromBlocknative.spec.ts +39 -0
- package/src/lib/transforms/transformGasFromBlocknative.ts +51 -0
- package/src/lib/transforms/transformGasFromEtherchainV1.spec.ts +34 -0
- package/src/lib/transforms/transformGasFromEtherchainV1.ts +23 -0
- package/src/lib/transforms/transformGasFromEtherchainV2.spec.ts +34 -0
- package/src/lib/transforms/transformGasFromEtherchainV2.ts +18 -0
- package/src/lib/transforms/transformGasFromEthers.spec.ts +33 -0
- package/src/lib/transforms/transformGasFromEthers.ts +26 -0
- package/src/lib/transforms/transformGasFromEtherscan.spec.ts +34 -0
- package/src/lib/transforms/transformGasFromEtherscan.ts +28 -0
- package/src/lib/transforms/transformGasFromEthgasstation.spec.ts +39 -0
- package/src/lib/transforms/transformGasFromEthgasstation.ts +38 -0
- package/src/test/index.ts +6 -0
- package/src/test/sampleBlocknativeGas.ts +97 -0
- package/src/test/sampleEtherchainGasV1.ts +12 -0
- package/src/test/sampleEtherchainGasV2.ts +15 -0
- package/src/test/sampleEthersGas.ts +10 -0
- package/src/test/sampleEtherscanGas.ts +16 -0
- package/src/test/sampleEthgasstationGas.ts +20 -0
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/* eslint-disable sort-keys-fix/sort-keys-fix */
|
|
2
|
+
import { sampleEtherchainGasV2 } from '../../test'
|
|
3
|
+
import { transformGasFromEtherchainV2 } from './transformGasFromEtherchainV2'
|
|
4
|
+
|
|
5
|
+
describe('transformGasFromEtherchainV2', () => {
|
|
6
|
+
it('returns values in the expected format', () => {
|
|
7
|
+
const result = transformGasFromEtherchainV2(sampleEtherchainGasV2)
|
|
8
|
+
expect(result).toBeObject()
|
|
9
|
+
expect(result.baseFee).toBeUndefined()
|
|
10
|
+
expect(result.feePerGas).toBeObject()
|
|
11
|
+
expect(result.feePerGas.low).toBeNumber()
|
|
12
|
+
expect(result.feePerGas.medium).toBeNumber()
|
|
13
|
+
expect(result.feePerGas.high).toBeNumber()
|
|
14
|
+
expect(result.feePerGas.veryHigh).toBeNumber()
|
|
15
|
+
expect(result.priorityFeePerGas).toBeObject()
|
|
16
|
+
expect(result.priorityFeePerGas.low).toBeUndefined()
|
|
17
|
+
expect(result.priorityFeePerGas.medium).toBeUndefined()
|
|
18
|
+
expect(result.priorityFeePerGas.high).toBeUndefined()
|
|
19
|
+
expect(result.priorityFeePerGas.veryHigh).toBeUndefined()
|
|
20
|
+
})
|
|
21
|
+
it('matches expected output', () => {
|
|
22
|
+
const result = transformGasFromEtherchainV2(sampleEtherchainGasV2)
|
|
23
|
+
expect(result).toMatchObject({
|
|
24
|
+
baseFee: undefined,
|
|
25
|
+
feePerGas: {
|
|
26
|
+
low: 11.2,
|
|
27
|
+
medium: 12.0,
|
|
28
|
+
high: 19.80304733,
|
|
29
|
+
veryHigh: 29.71428617,
|
|
30
|
+
},
|
|
31
|
+
priorityFeePerGas: {},
|
|
32
|
+
})
|
|
33
|
+
})
|
|
34
|
+
})
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { XyoEthereumGasEtherchainV2Payload } from '@xyo-network/etherchain-gas-ethereum-blockchain-payload-plugins'
|
|
2
|
+
import { FeeData, FeePerGas } from '@xyo-network/gas-price-payload-plugin'
|
|
3
|
+
|
|
4
|
+
const getFeePerGas = (payload: XyoEthereumGasEtherchainV2Payload): Partial<FeePerGas> => {
|
|
5
|
+
const { slow, standard, fast, rapid } = payload.data
|
|
6
|
+
const low = slow / 1_000_000_000
|
|
7
|
+
const medium = standard / 1_000_000_000
|
|
8
|
+
const high = fast / 1_000_000_000
|
|
9
|
+
const veryHigh = rapid / 1_000_000_000
|
|
10
|
+
return { high, low, medium, veryHigh }
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export const transformGasFromEtherchainV2 = (payload: XyoEthereumGasEtherchainV2Payload): FeeData => {
|
|
14
|
+
const baseFee = undefined
|
|
15
|
+
const feePerGas = getFeePerGas(payload)
|
|
16
|
+
const priorityFeePerGas = {}
|
|
17
|
+
return { baseFee, feePerGas, priorityFeePerGas }
|
|
18
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/* eslint-disable sort-keys-fix/sort-keys-fix */
|
|
2
|
+
import { sampleEthersGas } from '../../test'
|
|
3
|
+
import { transformGasFromEthers } from './transformGasFromEthers'
|
|
4
|
+
|
|
5
|
+
describe('transformGasFromEthers', () => {
|
|
6
|
+
it('returns values in the expected format', () => {
|
|
7
|
+
const result = transformGasFromEthers(sampleEthersGas)
|
|
8
|
+
expect(result).toBeObject()
|
|
9
|
+
expect(result.baseFee).toBeNumber()
|
|
10
|
+
expect(result.feePerGas).toBeObject()
|
|
11
|
+
expect(result.feePerGas.low).toBeUndefined()
|
|
12
|
+
expect(result.feePerGas.medium).toBeUndefined()
|
|
13
|
+
expect(result.feePerGas.high).toBeNumber()
|
|
14
|
+
expect(result.feePerGas.veryHigh).toBeUndefined()
|
|
15
|
+
expect(result.priorityFeePerGas).toBeObject()
|
|
16
|
+
expect(result.priorityFeePerGas.low).toBeUndefined()
|
|
17
|
+
expect(result.priorityFeePerGas.medium).toBeUndefined()
|
|
18
|
+
expect(result.priorityFeePerGas.high).toBeNumber()
|
|
19
|
+
expect(result.priorityFeePerGas.veryHigh).toBeUndefined()
|
|
20
|
+
})
|
|
21
|
+
it('matches expected output', () => {
|
|
22
|
+
const result = transformGasFromEthers(sampleEthersGas)
|
|
23
|
+
expect(result).toMatchObject({
|
|
24
|
+
baseFee: 13.447862081,
|
|
25
|
+
feePerGas: {
|
|
26
|
+
high: 28.395724162,
|
|
27
|
+
},
|
|
28
|
+
priorityFeePerGas: {
|
|
29
|
+
high: 1.5,
|
|
30
|
+
},
|
|
31
|
+
})
|
|
32
|
+
})
|
|
33
|
+
})
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { XyoEthereumGasEthersPayload } from '@xyo-network/ethers-ethereum-gas-payload-plugin'
|
|
2
|
+
import { FeeData, FeePerGas, PriorityFeePerGas } from '@xyo-network/gas-price-payload-plugin'
|
|
3
|
+
|
|
4
|
+
const getBaseFee = (payload: XyoEthereumGasEthersPayload): number | undefined => {
|
|
5
|
+
const { lastBaseFeePerGas } = payload
|
|
6
|
+
return lastBaseFeePerGas ? lastBaseFeePerGas / 1_000_000_000 : undefined
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
const getFeePerGas = (payload: XyoEthereumGasEthersPayload): Partial<FeePerGas> => {
|
|
10
|
+
const { maxFeePerGas } = payload
|
|
11
|
+
const high = maxFeePerGas ? maxFeePerGas / 1_000_000_000 : undefined
|
|
12
|
+
return { high }
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const getPriorityFeePerGas = (payload: XyoEthereumGasEthersPayload): Partial<PriorityFeePerGas> => {
|
|
16
|
+
const { maxPriorityFeePerGas } = payload
|
|
17
|
+
const high = maxPriorityFeePerGas ? maxPriorityFeePerGas / 1_000_000_000 : undefined
|
|
18
|
+
return { high }
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export const transformGasFromEthers = (payload: XyoEthereumGasEthersPayload): FeeData => {
|
|
22
|
+
const baseFee = getBaseFee(payload)
|
|
23
|
+
const feePerGas = getFeePerGas(payload)
|
|
24
|
+
const priorityFeePerGas = getPriorityFeePerGas(payload)
|
|
25
|
+
return { baseFee, feePerGas, priorityFeePerGas }
|
|
26
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/* eslint-disable sort-keys-fix/sort-keys-fix */
|
|
2
|
+
import { sampleEtherscanGas } from '../../test'
|
|
3
|
+
import { transformGasFromEtherscan } from './transformGasFromEtherscan'
|
|
4
|
+
|
|
5
|
+
describe('transformGasFromEtherscan', () => {
|
|
6
|
+
it('returns values in the expected format', () => {
|
|
7
|
+
const result = transformGasFromEtherscan(sampleEtherscanGas)
|
|
8
|
+
expect(result).toBeObject()
|
|
9
|
+
expect(result.baseFee).toBeNumber()
|
|
10
|
+
expect(result.feePerGas).toBeObject()
|
|
11
|
+
expect(result.feePerGas.low).toBeNumber()
|
|
12
|
+
expect(result.feePerGas.medium).toBeNumber()
|
|
13
|
+
expect(result.feePerGas.high).toBeNumber()
|
|
14
|
+
expect(result.feePerGas.veryHigh).toBeNumber()
|
|
15
|
+
expect(result.priorityFeePerGas).toBeObject()
|
|
16
|
+
expect(result.priorityFeePerGas.low).toBeUndefined()
|
|
17
|
+
expect(result.priorityFeePerGas.medium).toBeUndefined()
|
|
18
|
+
expect(result.priorityFeePerGas.high).toBeUndefined()
|
|
19
|
+
expect(result.priorityFeePerGas.veryHigh).toBeUndefined()
|
|
20
|
+
})
|
|
21
|
+
it('matches expected output', () => {
|
|
22
|
+
const result = transformGasFromEtherscan(sampleEtherscanGas)
|
|
23
|
+
expect(result).toMatchObject({
|
|
24
|
+
baseFee: 27.616709247,
|
|
25
|
+
feePerGas: {
|
|
26
|
+
low: 28,
|
|
27
|
+
medium: 29,
|
|
28
|
+
high: 30,
|
|
29
|
+
veryHigh: 31,
|
|
30
|
+
},
|
|
31
|
+
priorityFeePerGas: {},
|
|
32
|
+
})
|
|
33
|
+
})
|
|
34
|
+
})
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { XyoEthereumGasEtherscanPayload } from '@xyo-network/etherscan-ethereum-gas-payload-plugin'
|
|
2
|
+
import { FeeData, FeePerGas } from '@xyo-network/gas-price-payload-plugin'
|
|
3
|
+
import { linear } from 'regression'
|
|
4
|
+
|
|
5
|
+
const getBaseFee = (payload: XyoEthereumGasEtherscanPayload): number | undefined => {
|
|
6
|
+
const { suggestBaseFee } = payload.result
|
|
7
|
+
return parseFloat(suggestBaseFee)
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const getFeePerGas = (payload: XyoEthereumGasEtherscanPayload): Partial<FeePerGas> => {
|
|
11
|
+
const { FastGasPrice, ProposeGasPrice, SafeGasPrice } = payload.result
|
|
12
|
+
const low = parseFloat(SafeGasPrice)
|
|
13
|
+
const medium = parseFloat(ProposeGasPrice)
|
|
14
|
+
const high = parseFloat(FastGasPrice)
|
|
15
|
+
const veryHigh = linear([
|
|
16
|
+
[0, low],
|
|
17
|
+
[1, medium],
|
|
18
|
+
[2, high],
|
|
19
|
+
]).predict(3)[1]
|
|
20
|
+
return { high, low, medium, veryHigh }
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export const transformGasFromEtherscan = (payload: XyoEthereumGasEtherscanPayload): FeeData => {
|
|
24
|
+
const baseFee = getBaseFee(payload)
|
|
25
|
+
const feePerGas = getFeePerGas(payload)
|
|
26
|
+
const priorityFeePerGas = {}
|
|
27
|
+
return { baseFee, feePerGas, priorityFeePerGas }
|
|
28
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/* eslint-disable sort-keys-fix/sort-keys-fix */
|
|
2
|
+
import { sampleEthgasstationGas } from '../../test'
|
|
3
|
+
import { transformGasFromEthgasstation } from './transformGasFromEthgasstation'
|
|
4
|
+
|
|
5
|
+
describe('transformGasFromEthgasstation', () => {
|
|
6
|
+
it('returns values in the expected format', () => {
|
|
7
|
+
const result = transformGasFromEthgasstation(sampleEthgasstationGas)
|
|
8
|
+
expect(result).toBeObject()
|
|
9
|
+
expect(result.baseFee).toBeNumber()
|
|
10
|
+
expect(result.feePerGas).toBeObject()
|
|
11
|
+
expect(result.feePerGas.low).toBeNumber()
|
|
12
|
+
expect(result.feePerGas.medium).toBeNumber()
|
|
13
|
+
expect(result.feePerGas.high).toBeNumber()
|
|
14
|
+
expect(result.feePerGas.veryHigh).toBeNumber()
|
|
15
|
+
expect(result.priorityFeePerGas).toBeObject()
|
|
16
|
+
expect(result.priorityFeePerGas.low).toBeNumber()
|
|
17
|
+
expect(result.priorityFeePerGas.medium).toBeNumber()
|
|
18
|
+
expect(result.priorityFeePerGas.high).toBeNumber()
|
|
19
|
+
expect(result.priorityFeePerGas.veryHigh).toBeNumber()
|
|
20
|
+
})
|
|
21
|
+
it('matches expected output', () => {
|
|
22
|
+
const result = transformGasFromEthgasstation(sampleEthgasstationGas)
|
|
23
|
+
expect(result).toMatchObject({
|
|
24
|
+
baseFee: 10,
|
|
25
|
+
feePerGas: {
|
|
26
|
+
low: 11.33,
|
|
27
|
+
medium: 12,
|
|
28
|
+
high: 12,
|
|
29
|
+
veryHigh: 13,
|
|
30
|
+
},
|
|
31
|
+
priorityFeePerGas: {
|
|
32
|
+
low: 2,
|
|
33
|
+
medium: 2,
|
|
34
|
+
high: 2,
|
|
35
|
+
veryHigh: 2,
|
|
36
|
+
},
|
|
37
|
+
})
|
|
38
|
+
})
|
|
39
|
+
})
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/* eslint-disable sort-keys-fix/sort-keys-fix */
|
|
2
|
+
import { XyoEthereumGasEthgasstationPayload } from '@xyo-network/ethgasstation-ethereum-gas-payload-plugin'
|
|
3
|
+
import { FeeData, FeePerGas, PriorityFeePerGas } from '@xyo-network/gas-price-payload-plugin'
|
|
4
|
+
import { linear } from 'regression'
|
|
5
|
+
|
|
6
|
+
const getBaseFee = (payload: XyoEthereumGasEthgasstationPayload): number | undefined => {
|
|
7
|
+
const { baseFee } = payload
|
|
8
|
+
return baseFee
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const getFeePerGas = (payload: XyoEthereumGasEthgasstationPayload): Partial<FeePerGas> => {
|
|
12
|
+
const { standard: medium, fast: high, instant: veryHigh } = payload.gasPrice
|
|
13
|
+
const trend = linear([
|
|
14
|
+
[1, medium],
|
|
15
|
+
[2, high],
|
|
16
|
+
[3, veryHigh],
|
|
17
|
+
])
|
|
18
|
+
const low = trend.predict(0)[1]
|
|
19
|
+
return { low, medium, high, veryHigh }
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const getPriorityFeePerGas = (payload: XyoEthereumGasEthgasstationPayload): Partial<PriorityFeePerGas> => {
|
|
23
|
+
const { standard: medium, fast: high, instant: veryHigh } = payload.priorityFee
|
|
24
|
+
const trend = linear([
|
|
25
|
+
[1, medium],
|
|
26
|
+
[2, high],
|
|
27
|
+
[3, veryHigh],
|
|
28
|
+
])
|
|
29
|
+
const low = trend.predict(0)[1]
|
|
30
|
+
return { low, medium, high, veryHigh }
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export const transformGasFromEthgasstation = (payload: XyoEthereumGasEthgasstationPayload): FeeData => {
|
|
34
|
+
const baseFee = getBaseFee(payload)
|
|
35
|
+
const feePerGas = getFeePerGas(payload)
|
|
36
|
+
const priorityFeePerGas = getPriorityFeePerGas(payload)
|
|
37
|
+
return { baseFee, feePerGas, priorityFeePerGas }
|
|
38
|
+
}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import {
|
|
2
|
+
EstimatedBaseFee,
|
|
3
|
+
XyoEthereumGasBlocknativePayload,
|
|
4
|
+
XyoEthereumGasBlocknativeSchema,
|
|
5
|
+
} from '@xyo-network/blocknative-ethereum-gas-payload-plugin'
|
|
6
|
+
|
|
7
|
+
export const sampleBlocknativeGas: XyoEthereumGasBlocknativePayload = {
|
|
8
|
+
blockPrices: [
|
|
9
|
+
{
|
|
10
|
+
baseFeePerGas: 13.691764456,
|
|
11
|
+
blockNumber: 16028191,
|
|
12
|
+
estimatedPrices: [
|
|
13
|
+
{
|
|
14
|
+
confidence: 99,
|
|
15
|
+
maxFeePerGas: 22.04,
|
|
16
|
+
maxPriorityFeePerGas: 1.09,
|
|
17
|
+
price: 14,
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
confidence: 95,
|
|
21
|
+
maxFeePerGas: 21.58,
|
|
22
|
+
maxPriorityFeePerGas: 0.63,
|
|
23
|
+
price: 14,
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
confidence: 90,
|
|
27
|
+
maxFeePerGas: 21.25,
|
|
28
|
+
maxPriorityFeePerGas: 0.3,
|
|
29
|
+
price: 13,
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
confidence: 80,
|
|
33
|
+
maxFeePerGas: 21.16,
|
|
34
|
+
maxPriorityFeePerGas: 0.21,
|
|
35
|
+
price: 13,
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
confidence: 70,
|
|
39
|
+
maxFeePerGas: 21.12,
|
|
40
|
+
maxPriorityFeePerGas: 0.17,
|
|
41
|
+
price: 13,
|
|
42
|
+
},
|
|
43
|
+
],
|
|
44
|
+
estimatedTransactionCount: 69,
|
|
45
|
+
},
|
|
46
|
+
],
|
|
47
|
+
currentBlockNumber: 16028190,
|
|
48
|
+
estimatedBaseFees: [
|
|
49
|
+
{
|
|
50
|
+
'pending+1': [
|
|
51
|
+
{
|
|
52
|
+
baseFee: 15.41,
|
|
53
|
+
confidence: 99,
|
|
54
|
+
},
|
|
55
|
+
],
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
'pending+2': [
|
|
59
|
+
{
|
|
60
|
+
baseFee: 17.32,
|
|
61
|
+
confidence: 99,
|
|
62
|
+
},
|
|
63
|
+
],
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
'pending+3': [
|
|
67
|
+
{
|
|
68
|
+
baseFee: 19.17,
|
|
69
|
+
confidence: 99,
|
|
70
|
+
},
|
|
71
|
+
],
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
'pending+4': [
|
|
75
|
+
{
|
|
76
|
+
baseFee: 20.12,
|
|
77
|
+
confidence: 99,
|
|
78
|
+
},
|
|
79
|
+
],
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
'pending+5': [
|
|
83
|
+
{
|
|
84
|
+
baseFee: 20.95,
|
|
85
|
+
confidence: 99,
|
|
86
|
+
},
|
|
87
|
+
],
|
|
88
|
+
},
|
|
89
|
+
] as unknown as EstimatedBaseFee[],
|
|
90
|
+
maxPrice: 36,
|
|
91
|
+
msSinceLastBlock: 3643,
|
|
92
|
+
network: 'main',
|
|
93
|
+
schema: XyoEthereumGasBlocknativeSchema,
|
|
94
|
+
system: 'ethereum',
|
|
95
|
+
timestamp: 1668697958837,
|
|
96
|
+
unit: 'gwei',
|
|
97
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { XyoEthereumGasEtherchainV1Payload, XyoEthereumGasEtherchainV1Schema } from '@xyo-network/etherchain-gas-ethereum-blockchain-payload-plugins'
|
|
2
|
+
|
|
3
|
+
export const sampleEtherchainGasV1: XyoEthereumGasEtherchainV1Payload = {
|
|
4
|
+
currentBaseFee: 19.5,
|
|
5
|
+
fast: 0.3,
|
|
6
|
+
fastest: 1.5,
|
|
7
|
+
recommendedBaseFee: 39.6,
|
|
8
|
+
safeLow: 0.1,
|
|
9
|
+
schema: XyoEthereumGasEtherchainV1Schema,
|
|
10
|
+
standard: 0.2,
|
|
11
|
+
timestamp: 1668621360784,
|
|
12
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { XyoEthereumGasEtherchainV2Payload, XyoEthereumGasEtherchainV2Schema } from '@xyo-network/etherchain-gas-ethereum-blockchain-payload-plugins'
|
|
2
|
+
|
|
3
|
+
export const sampleEtherchainGasV2: XyoEthereumGasEtherchainV2Payload = {
|
|
4
|
+
code: 200,
|
|
5
|
+
data: {
|
|
6
|
+
fast: 19803047330,
|
|
7
|
+
priceUSD: 1195.77,
|
|
8
|
+
rapid: 29714286170,
|
|
9
|
+
slow: 11200000000,
|
|
10
|
+
standard: 12000000000,
|
|
11
|
+
timestamp: 1668621234096,
|
|
12
|
+
},
|
|
13
|
+
schema: XyoEthereumGasEtherchainV2Schema,
|
|
14
|
+
timestamp: 1668621240790,
|
|
15
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { XyoEthereumGasEthersPayload, XyoEthereumGasEthersSchema } from '@xyo-network/ethers-ethereum-gas-payload-plugin'
|
|
2
|
+
|
|
3
|
+
export const sampleEthersGas: XyoEthereumGasEthersPayload = {
|
|
4
|
+
gasPrice: 13547863640,
|
|
5
|
+
lastBaseFeePerGas: 13447862081,
|
|
6
|
+
maxFeePerGas: 28395724162,
|
|
7
|
+
maxPriorityFeePerGas: 1500000000,
|
|
8
|
+
schema: XyoEthereumGasEthersSchema,
|
|
9
|
+
timestamp: 1668697958837,
|
|
10
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { XyoEthereumGasEtherscanPayload, XyoEthereumGasEtherscanSchema } from '@xyo-network/etherscan-ethereum-gas-payload-plugin'
|
|
2
|
+
|
|
3
|
+
export const sampleEtherscanGas: XyoEthereumGasEtherscanPayload = {
|
|
4
|
+
message: 'OK',
|
|
5
|
+
result: {
|
|
6
|
+
FastGasPrice: '30',
|
|
7
|
+
LastBlock: '15990556',
|
|
8
|
+
ProposeGasPrice: '29',
|
|
9
|
+
SafeGasPrice: '28',
|
|
10
|
+
gasUsedRatio: '0.416266666666667,0.5672862,0.540979033333333,0.342410966666667,0.389071233333333',
|
|
11
|
+
suggestBaseFee: '27.616709247',
|
|
12
|
+
},
|
|
13
|
+
schema: XyoEthereumGasEtherscanSchema,
|
|
14
|
+
status: '1',
|
|
15
|
+
timestamp: 1668697958837,
|
|
16
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { XyoEthereumGasEthgasstationPayload, XyoEthereumGasEthgasstationSchema } from '@xyo-network/ethgasstation-ethereum-gas-payload-plugin'
|
|
2
|
+
|
|
3
|
+
export const sampleEthgasstationGas: XyoEthereumGasEthgasstationPayload = {
|
|
4
|
+
baseFee: 10,
|
|
5
|
+
blockNumber: 16028883,
|
|
6
|
+
blockTime: 11.88,
|
|
7
|
+
gasPrice: {
|
|
8
|
+
fast: 12,
|
|
9
|
+
instant: 13,
|
|
10
|
+
standard: 12,
|
|
11
|
+
},
|
|
12
|
+
nextBaseFee: 10,
|
|
13
|
+
priorityFee: {
|
|
14
|
+
fast: 2,
|
|
15
|
+
instant: 2,
|
|
16
|
+
standard: 2,
|
|
17
|
+
},
|
|
18
|
+
schema: XyoEthereumGasEthgasstationSchema,
|
|
19
|
+
timestamp: 1668697958837,
|
|
20
|
+
}
|