@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.
Files changed (272) hide show
  1. package/LICENSE +165 -0
  2. package/README.md +81 -0
  3. package/dist/cjs/Diviner.d.ts +16 -0
  4. package/dist/cjs/Diviner.d.ts.map +1 -0
  5. package/dist/cjs/Diviner.js +29 -0
  6. package/dist/cjs/Diviner.js.map +1 -0
  7. package/dist/cjs/Plugin.d.ts +13 -0
  8. package/dist/cjs/Plugin.d.ts.map +1 -0
  9. package/dist/cjs/Plugin.js +15 -0
  10. package/dist/cjs/Plugin.js.map +1 -0
  11. package/dist/cjs/Schema.d.ts +5 -0
  12. package/dist/cjs/Schema.d.ts.map +1 -0
  13. package/dist/cjs/Schema.js +6 -0
  14. package/dist/cjs/Schema.js.map +1 -0
  15. package/dist/cjs/index.d.ts +6 -0
  16. package/dist/cjs/index.d.ts.map +1 -0
  17. package/dist/cjs/index.js +11 -0
  18. package/dist/cjs/index.js.map +1 -0
  19. package/dist/cjs/lib/average.d.ts +8 -0
  20. package/dist/cjs/lib/average.d.ts.map +1 -0
  21. package/dist/cjs/lib/average.js +48 -0
  22. package/dist/cjs/lib/average.js.map +1 -0
  23. package/dist/cjs/lib/divineGas.d.ts +6 -0
  24. package/dist/cjs/lib/divineGas.d.ts.map +1 -0
  25. package/dist/cjs/lib/divineGas.js +23 -0
  26. package/dist/cjs/lib/divineGas.js.map +1 -0
  27. package/dist/cjs/lib/identities/index.d.ts +7 -0
  28. package/dist/cjs/lib/identities/index.d.ts.map +1 -0
  29. package/dist/cjs/lib/identities/index.js +10 -0
  30. package/dist/cjs/lib/identities/index.js.map +1 -0
  31. package/dist/cjs/lib/identities/isXyoEthereumGasBlocknativePayload.d.ts +6 -0
  32. package/dist/cjs/lib/identities/isXyoEthereumGasBlocknativePayload.d.ts.map +1 -0
  33. package/dist/cjs/lib/identities/isXyoEthereumGasBlocknativePayload.js +9 -0
  34. package/dist/cjs/lib/identities/isXyoEthereumGasBlocknativePayload.js.map +1 -0
  35. package/dist/cjs/lib/identities/isXyoEthereumGasEtherchainV1Payload.d.ts +6 -0
  36. package/dist/cjs/lib/identities/isXyoEthereumGasEtherchainV1Payload.d.ts.map +1 -0
  37. package/dist/cjs/lib/identities/isXyoEthereumGasEtherchainV1Payload.js +9 -0
  38. package/dist/cjs/lib/identities/isXyoEthereumGasEtherchainV1Payload.js.map +1 -0
  39. package/dist/cjs/lib/identities/isXyoEthereumGasEtherchainV2Payload.d.ts +6 -0
  40. package/dist/cjs/lib/identities/isXyoEthereumGasEtherchainV2Payload.d.ts.map +1 -0
  41. package/dist/cjs/lib/identities/isXyoEthereumGasEtherchainV2Payload.js +9 -0
  42. package/dist/cjs/lib/identities/isXyoEthereumGasEtherchainV2Payload.js.map +1 -0
  43. package/dist/cjs/lib/identities/isXyoEthereumGasEthersPayload.d.ts +6 -0
  44. package/dist/cjs/lib/identities/isXyoEthereumGasEthersPayload.d.ts.map +1 -0
  45. package/dist/cjs/lib/identities/isXyoEthereumGasEthersPayload.js +9 -0
  46. package/dist/cjs/lib/identities/isXyoEthereumGasEthersPayload.js.map +1 -0
  47. package/dist/cjs/lib/identities/isXyoEthereumGasEtherscanPayload.d.ts +6 -0
  48. package/dist/cjs/lib/identities/isXyoEthereumGasEtherscanPayload.d.ts.map +1 -0
  49. package/dist/cjs/lib/identities/isXyoEthereumGasEtherscanPayload.js +9 -0
  50. package/dist/cjs/lib/identities/isXyoEthereumGasEtherscanPayload.js.map +1 -0
  51. package/dist/cjs/lib/identities/isXyoEthereumGasEthgasstationPayload.d.ts +6 -0
  52. package/dist/cjs/lib/identities/isXyoEthereumGasEthgasstationPayload.d.ts.map +1 -0
  53. package/dist/cjs/lib/identities/isXyoEthereumGasEthgasstationPayload.js +9 -0
  54. package/dist/cjs/lib/identities/isXyoEthereumGasEthgasstationPayload.js.map +1 -0
  55. package/dist/cjs/lib/index.d.ts +2 -0
  56. package/dist/cjs/lib/index.d.ts.map +1 -0
  57. package/dist/cjs/lib/index.js +5 -0
  58. package/dist/cjs/lib/index.js.map +1 -0
  59. package/dist/cjs/lib/transforms/index.d.ts +7 -0
  60. package/dist/cjs/lib/transforms/index.d.ts.map +1 -0
  61. package/dist/cjs/lib/transforms/index.js +10 -0
  62. package/dist/cjs/lib/transforms/index.js.map +1 -0
  63. package/dist/cjs/lib/transforms/transformGasFromBlocknative.d.ts +4 -0
  64. package/dist/cjs/lib/transforms/transformGasFromBlocknative.d.ts.map +1 -0
  65. package/dist/cjs/lib/transforms/transformGasFromBlocknative.js +52 -0
  66. package/dist/cjs/lib/transforms/transformGasFromBlocknative.js.map +1 -0
  67. package/dist/cjs/lib/transforms/transformGasFromEtherchainV1.d.ts +4 -0
  68. package/dist/cjs/lib/transforms/transformGasFromEtherchainV1.d.ts.map +1 -0
  69. package/dist/cjs/lib/transforms/transformGasFromEtherchainV1.js +23 -0
  70. package/dist/cjs/lib/transforms/transformGasFromEtherchainV1.js.map +1 -0
  71. package/dist/cjs/lib/transforms/transformGasFromEtherchainV2.d.ts +4 -0
  72. package/dist/cjs/lib/transforms/transformGasFromEtherchainV2.d.ts.map +1 -0
  73. package/dist/cjs/lib/transforms/transformGasFromEtherchainV2.js +19 -0
  74. package/dist/cjs/lib/transforms/transformGasFromEtherchainV2.js.map +1 -0
  75. package/dist/cjs/lib/transforms/transformGasFromEthers.d.ts +4 -0
  76. package/dist/cjs/lib/transforms/transformGasFromEthers.d.ts.map +1 -0
  77. package/dist/cjs/lib/transforms/transformGasFromEthers.js +25 -0
  78. package/dist/cjs/lib/transforms/transformGasFromEthers.js.map +1 -0
  79. package/dist/cjs/lib/transforms/transformGasFromEtherscan.d.ts +4 -0
  80. package/dist/cjs/lib/transforms/transformGasFromEtherscan.d.ts.map +1 -0
  81. package/dist/cjs/lib/transforms/transformGasFromEtherscan.js +28 -0
  82. package/dist/cjs/lib/transforms/transformGasFromEtherscan.js.map +1 -0
  83. package/dist/cjs/lib/transforms/transformGasFromEthgasstation.d.ts +4 -0
  84. package/dist/cjs/lib/transforms/transformGasFromEthgasstation.d.ts.map +1 -0
  85. package/dist/cjs/lib/transforms/transformGasFromEthgasstation.js +36 -0
  86. package/dist/cjs/lib/transforms/transformGasFromEthgasstation.js.map +1 -0
  87. package/dist/cjs/test/index.d.ts +7 -0
  88. package/dist/cjs/test/index.d.ts.map +1 -0
  89. package/dist/cjs/test/index.js +10 -0
  90. package/dist/cjs/test/index.js.map +1 -0
  91. package/dist/cjs/test/sampleBlocknativeGas.d.ts +3 -0
  92. package/dist/cjs/test/sampleBlocknativeGas.d.ts.map +1 -0
  93. package/dist/cjs/test/sampleBlocknativeGas.js +96 -0
  94. package/dist/cjs/test/sampleBlocknativeGas.js.map +1 -0
  95. package/dist/cjs/test/sampleEtherchainGasV1.d.ts +3 -0
  96. package/dist/cjs/test/sampleEtherchainGasV1.d.ts.map +1 -0
  97. package/dist/cjs/test/sampleEtherchainGasV1.js +15 -0
  98. package/dist/cjs/test/sampleEtherchainGasV1.js.map +1 -0
  99. package/dist/cjs/test/sampleEtherchainGasV2.d.ts +3 -0
  100. package/dist/cjs/test/sampleEtherchainGasV2.d.ts.map +1 -0
  101. package/dist/cjs/test/sampleEtherchainGasV2.js +18 -0
  102. package/dist/cjs/test/sampleEtherchainGasV2.js.map +1 -0
  103. package/dist/cjs/test/sampleEthersGas.d.ts +3 -0
  104. package/dist/cjs/test/sampleEthersGas.d.ts.map +1 -0
  105. package/dist/cjs/test/sampleEthersGas.js +13 -0
  106. package/dist/cjs/test/sampleEthersGas.js.map +1 -0
  107. package/dist/cjs/test/sampleEtherscanGas.d.ts +3 -0
  108. package/dist/cjs/test/sampleEtherscanGas.d.ts.map +1 -0
  109. package/dist/cjs/test/sampleEtherscanGas.js +19 -0
  110. package/dist/cjs/test/sampleEtherscanGas.js.map +1 -0
  111. package/dist/cjs/test/sampleEthgasstationGas.d.ts +3 -0
  112. package/dist/cjs/test/sampleEthgasstationGas.d.ts.map +1 -0
  113. package/dist/cjs/test/sampleEthgasstationGas.js +23 -0
  114. package/dist/cjs/test/sampleEthgasstationGas.js.map +1 -0
  115. package/dist/docs.json +4534 -0
  116. package/dist/esm/Diviner.d.ts +16 -0
  117. package/dist/esm/Diviner.d.ts.map +1 -0
  118. package/dist/esm/Diviner.js +19 -0
  119. package/dist/esm/Diviner.js.map +1 -0
  120. package/dist/esm/Plugin.d.ts +13 -0
  121. package/dist/esm/Plugin.d.ts.map +1 -0
  122. package/dist/esm/Plugin.js +10 -0
  123. package/dist/esm/Plugin.js.map +1 -0
  124. package/dist/esm/Schema.d.ts +5 -0
  125. package/dist/esm/Schema.d.ts.map +1 -0
  126. package/dist/esm/Schema.js +3 -0
  127. package/dist/esm/Schema.js.map +1 -0
  128. package/dist/esm/index.d.ts +6 -0
  129. package/dist/esm/index.d.ts.map +1 -0
  130. package/dist/esm/index.js +7 -0
  131. package/dist/esm/index.js.map +1 -0
  132. package/dist/esm/lib/average.d.ts +8 -0
  133. package/dist/esm/lib/average.d.ts.map +1 -0
  134. package/dist/esm/lib/average.js +44 -0
  135. package/dist/esm/lib/average.js.map +1 -0
  136. package/dist/esm/lib/divineGas.d.ts +6 -0
  137. package/dist/esm/lib/divineGas.d.ts.map +1 -0
  138. package/dist/esm/lib/divineGas.js +19 -0
  139. package/dist/esm/lib/divineGas.js.map +1 -0
  140. package/dist/esm/lib/identities/index.d.ts +7 -0
  141. package/dist/esm/lib/identities/index.d.ts.map +1 -0
  142. package/dist/esm/lib/identities/index.js +7 -0
  143. package/dist/esm/lib/identities/index.js.map +1 -0
  144. package/dist/esm/lib/identities/isXyoEthereumGasBlocknativePayload.d.ts +6 -0
  145. package/dist/esm/lib/identities/isXyoEthereumGasBlocknativePayload.d.ts.map +1 -0
  146. package/dist/esm/lib/identities/isXyoEthereumGasBlocknativePayload.js +5 -0
  147. package/dist/esm/lib/identities/isXyoEthereumGasBlocknativePayload.js.map +1 -0
  148. package/dist/esm/lib/identities/isXyoEthereumGasEtherchainV1Payload.d.ts +6 -0
  149. package/dist/esm/lib/identities/isXyoEthereumGasEtherchainV1Payload.d.ts.map +1 -0
  150. package/dist/esm/lib/identities/isXyoEthereumGasEtherchainV1Payload.js +5 -0
  151. package/dist/esm/lib/identities/isXyoEthereumGasEtherchainV1Payload.js.map +1 -0
  152. package/dist/esm/lib/identities/isXyoEthereumGasEtherchainV2Payload.d.ts +6 -0
  153. package/dist/esm/lib/identities/isXyoEthereumGasEtherchainV2Payload.d.ts.map +1 -0
  154. package/dist/esm/lib/identities/isXyoEthereumGasEtherchainV2Payload.js +5 -0
  155. package/dist/esm/lib/identities/isXyoEthereumGasEtherchainV2Payload.js.map +1 -0
  156. package/dist/esm/lib/identities/isXyoEthereumGasEthersPayload.d.ts +6 -0
  157. package/dist/esm/lib/identities/isXyoEthereumGasEthersPayload.d.ts.map +1 -0
  158. package/dist/esm/lib/identities/isXyoEthereumGasEthersPayload.js +5 -0
  159. package/dist/esm/lib/identities/isXyoEthereumGasEthersPayload.js.map +1 -0
  160. package/dist/esm/lib/identities/isXyoEthereumGasEtherscanPayload.d.ts +6 -0
  161. package/dist/esm/lib/identities/isXyoEthereumGasEtherscanPayload.d.ts.map +1 -0
  162. package/dist/esm/lib/identities/isXyoEthereumGasEtherscanPayload.js +5 -0
  163. package/dist/esm/lib/identities/isXyoEthereumGasEtherscanPayload.js.map +1 -0
  164. package/dist/esm/lib/identities/isXyoEthereumGasEthgasstationPayload.d.ts +6 -0
  165. package/dist/esm/lib/identities/isXyoEthereumGasEthgasstationPayload.d.ts.map +1 -0
  166. package/dist/esm/lib/identities/isXyoEthereumGasEthgasstationPayload.js +5 -0
  167. package/dist/esm/lib/identities/isXyoEthereumGasEthgasstationPayload.js.map +1 -0
  168. package/dist/esm/lib/index.d.ts +2 -0
  169. package/dist/esm/lib/index.d.ts.map +1 -0
  170. package/dist/esm/lib/index.js +2 -0
  171. package/dist/esm/lib/index.js.map +1 -0
  172. package/dist/esm/lib/transforms/index.d.ts +7 -0
  173. package/dist/esm/lib/transforms/index.d.ts.map +1 -0
  174. package/dist/esm/lib/transforms/index.js +7 -0
  175. package/dist/esm/lib/transforms/index.js.map +1 -0
  176. package/dist/esm/lib/transforms/transformGasFromBlocknative.d.ts +4 -0
  177. package/dist/esm/lib/transforms/transformGasFromBlocknative.d.ts.map +1 -0
  178. package/dist/esm/lib/transforms/transformGasFromBlocknative.js +45 -0
  179. package/dist/esm/lib/transforms/transformGasFromBlocknative.js.map +1 -0
  180. package/dist/esm/lib/transforms/transformGasFromEtherchainV1.d.ts +4 -0
  181. package/dist/esm/lib/transforms/transformGasFromEtherchainV1.d.ts.map +1 -0
  182. package/dist/esm/lib/transforms/transformGasFromEtherchainV1.js +19 -0
  183. package/dist/esm/lib/transforms/transformGasFromEtherchainV1.js.map +1 -0
  184. package/dist/esm/lib/transforms/transformGasFromEtherchainV2.d.ts +4 -0
  185. package/dist/esm/lib/transforms/transformGasFromEtherchainV2.d.ts.map +1 -0
  186. package/dist/esm/lib/transforms/transformGasFromEtherchainV2.js +15 -0
  187. package/dist/esm/lib/transforms/transformGasFromEtherchainV2.js.map +1 -0
  188. package/dist/esm/lib/transforms/transformGasFromEthers.d.ts +4 -0
  189. package/dist/esm/lib/transforms/transformGasFromEthers.d.ts.map +1 -0
  190. package/dist/esm/lib/transforms/transformGasFromEthers.js +21 -0
  191. package/dist/esm/lib/transforms/transformGasFromEthers.js.map +1 -0
  192. package/dist/esm/lib/transforms/transformGasFromEtherscan.d.ts +4 -0
  193. package/dist/esm/lib/transforms/transformGasFromEtherscan.d.ts.map +1 -0
  194. package/dist/esm/lib/transforms/transformGasFromEtherscan.js +24 -0
  195. package/dist/esm/lib/transforms/transformGasFromEtherscan.js.map +1 -0
  196. package/dist/esm/lib/transforms/transformGasFromEthgasstation.d.ts +4 -0
  197. package/dist/esm/lib/transforms/transformGasFromEthgasstation.d.ts.map +1 -0
  198. package/dist/esm/lib/transforms/transformGasFromEthgasstation.js +32 -0
  199. package/dist/esm/lib/transforms/transformGasFromEthgasstation.js.map +1 -0
  200. package/dist/esm/test/index.d.ts +7 -0
  201. package/dist/esm/test/index.d.ts.map +1 -0
  202. package/dist/esm/test/index.js +7 -0
  203. package/dist/esm/test/index.js.map +1 -0
  204. package/dist/esm/test/sampleBlocknativeGas.d.ts +3 -0
  205. package/dist/esm/test/sampleBlocknativeGas.d.ts.map +1 -0
  206. package/dist/esm/test/sampleBlocknativeGas.js +93 -0
  207. package/dist/esm/test/sampleBlocknativeGas.js.map +1 -0
  208. package/dist/esm/test/sampleEtherchainGasV1.d.ts +3 -0
  209. package/dist/esm/test/sampleEtherchainGasV1.d.ts.map +1 -0
  210. package/dist/esm/test/sampleEtherchainGasV1.js +12 -0
  211. package/dist/esm/test/sampleEtherchainGasV1.js.map +1 -0
  212. package/dist/esm/test/sampleEtherchainGasV2.d.ts +3 -0
  213. package/dist/esm/test/sampleEtherchainGasV2.d.ts.map +1 -0
  214. package/dist/esm/test/sampleEtherchainGasV2.js +15 -0
  215. package/dist/esm/test/sampleEtherchainGasV2.js.map +1 -0
  216. package/dist/esm/test/sampleEthersGas.d.ts +3 -0
  217. package/dist/esm/test/sampleEthersGas.d.ts.map +1 -0
  218. package/dist/esm/test/sampleEthersGas.js +10 -0
  219. package/dist/esm/test/sampleEthersGas.js.map +1 -0
  220. package/dist/esm/test/sampleEtherscanGas.d.ts +3 -0
  221. package/dist/esm/test/sampleEtherscanGas.d.ts.map +1 -0
  222. package/dist/esm/test/sampleEtherscanGas.js +16 -0
  223. package/dist/esm/test/sampleEtherscanGas.js.map +1 -0
  224. package/dist/esm/test/sampleEthgasstationGas.d.ts +3 -0
  225. package/dist/esm/test/sampleEthgasstationGas.d.ts.map +1 -0
  226. package/dist/esm/test/sampleEthgasstationGas.js +20 -0
  227. package/dist/esm/test/sampleEthgasstationGas.js.map +1 -0
  228. package/package.json +87 -0
  229. package/src/Diviner.spec.ts +131 -0
  230. package/src/Diviner.ts +28 -0
  231. package/src/Plugin.spec.ts +11 -0
  232. package/src/Plugin.ts +16 -0
  233. package/src/Schema.ts +5 -0
  234. package/src/index.ts +9 -0
  235. package/src/lib/average.spec.ts +50 -0
  236. package/src/lib/average.ts +47 -0
  237. package/src/lib/divineGas.spec.ts +78 -0
  238. package/src/lib/divineGas.ts +34 -0
  239. package/src/lib/identities/index.ts +6 -0
  240. package/src/lib/identities/isXyoEthereumGasBlocknativePayload.spec.ts +29 -0
  241. package/src/lib/identities/isXyoEthereumGasBlocknativePayload.ts +6 -0
  242. package/src/lib/identities/isXyoEthereumGasEtherchainV1Payload.spec.ts +29 -0
  243. package/src/lib/identities/isXyoEthereumGasEtherchainV1Payload.ts +6 -0
  244. package/src/lib/identities/isXyoEthereumGasEtherchainV2Payload.spec.ts +29 -0
  245. package/src/lib/identities/isXyoEthereumGasEtherchainV2Payload.ts +6 -0
  246. package/src/lib/identities/isXyoEthereumGasEthersPayload.spec.ts +29 -0
  247. package/src/lib/identities/isXyoEthereumGasEthersPayload.ts +6 -0
  248. package/src/lib/identities/isXyoEthereumGasEtherscanPayload.spec.ts +29 -0
  249. package/src/lib/identities/isXyoEthereumGasEtherscanPayload.ts +6 -0
  250. package/src/lib/identities/isXyoEthereumGasEthgasstationPayload.spec.ts +29 -0
  251. package/src/lib/identities/isXyoEthereumGasEthgasstationPayload.ts +6 -0
  252. package/src/lib/index.ts +1 -0
  253. package/src/lib/transforms/index.ts +6 -0
  254. package/src/lib/transforms/transformGasFromBlocknative.spec.ts +39 -0
  255. package/src/lib/transforms/transformGasFromBlocknative.ts +51 -0
  256. package/src/lib/transforms/transformGasFromEtherchainV1.spec.ts +34 -0
  257. package/src/lib/transforms/transformGasFromEtherchainV1.ts +23 -0
  258. package/src/lib/transforms/transformGasFromEtherchainV2.spec.ts +34 -0
  259. package/src/lib/transforms/transformGasFromEtherchainV2.ts +18 -0
  260. package/src/lib/transforms/transformGasFromEthers.spec.ts +33 -0
  261. package/src/lib/transforms/transformGasFromEthers.ts +26 -0
  262. package/src/lib/transforms/transformGasFromEtherscan.spec.ts +34 -0
  263. package/src/lib/transforms/transformGasFromEtherscan.ts +28 -0
  264. package/src/lib/transforms/transformGasFromEthgasstation.spec.ts +39 -0
  265. package/src/lib/transforms/transformGasFromEthgasstation.ts +38 -0
  266. package/src/test/index.ts +6 -0
  267. package/src/test/sampleBlocknativeGas.ts +97 -0
  268. package/src/test/sampleEtherchainGasV1.ts +12 -0
  269. package/src/test/sampleEtherchainGasV2.ts +15 -0
  270. package/src/test/sampleEthersGas.ts +10 -0
  271. package/src/test/sampleEtherscanGas.ts +16 -0
  272. 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,6 @@
1
+ export * from './sampleBlocknativeGas'
2
+ export * from './sampleEtherchainGasV1'
3
+ export * from './sampleEtherchainGasV2'
4
+ export * from './sampleEtherscanGas'
5
+ export * from './sampleEthersGas'
6
+ export * from './sampleEthgasstationGas'
@@ -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
+ }