File tree Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ use url::Url;
8
8
enum FeeStrategy {
9
9
Helius ,
10
10
Triton ,
11
+ Alchemy ,
11
12
}
12
13
13
14
impl Miner {
@@ -26,6 +27,10 @@ impl Miner {
26
27
. to_string ( ) ;
27
28
let strategy = if host. contains ( "helius-rpc.com" ) {
28
29
FeeStrategy :: Helius
30
+ } else if host. contains ( "alchemy.com" ) {
31
+ FeeStrategy :: Alchemy
32
+ } else if host. contains ( "pandaever.host" ) {
33
+ FeeStrategy :: Alchemy
29
34
} else if host. contains ( "rpcpool.com" ) {
30
35
FeeStrategy :: Triton
31
36
} else {
@@ -51,6 +56,16 @@ impl Miner {
51
56
} ]
52
57
} )
53
58
}
59
+ FeeStrategy :: Alchemy => {
60
+ json ! ( {
61
+ "jsonrpc" : "2.0" ,
62
+ "id" : "priority-fee-estimate" ,
63
+ "method" : "getRecentPrioritizationFees" ,
64
+ "params" : [
65
+ ore_addresses
66
+ ]
67
+ } )
68
+ }
54
69
FeeStrategy :: Triton => {
55
70
json ! ( {
56
71
"jsonrpc" : "2.0" ,
@@ -84,6 +99,23 @@ impl Miner {
84
99
. map ( |fee| fee as u64 )
85
100
. ok_or_else ( || format ! ( "Failed to parse priority fee. Response: {:?}" , response) )
86
101
. unwrap ( ) ,
102
+ FeeStrategy :: Alchemy => response[ "result" ]
103
+ . as_array ( )
104
+ . and_then ( |arr| {
105
+ Some (
106
+ arr. into_iter ( )
107
+ . map ( |v| v[ "prioritizationFee" ] . as_u64 ( ) . unwrap ( ) )
108
+ . collect :: < Vec < u64 > > ( ) ,
109
+ )
110
+ } )
111
+ . and_then ( |fees| {
112
+ Some ( ( fees. iter ( ) . sum :: < u64 > ( ) as f32 / fees. len ( ) as f32 ) . ceil ( )
113
+ as u64 )
114
+ } )
115
+ . ok_or_else ( || {
116
+ format ! ( "Failed to parse priority fee. Response: {:?}" , response)
117
+ } )
118
+ . unwrap ( ) ,
87
119
FeeStrategy :: Triton => response[ "result" ]
88
120
. as_array ( )
89
121
. and_then ( |arr| arr. last ( ) )
You can’t perform that action at this time.
0 commit comments