File tree Expand file tree Collapse file tree 2 files changed +53
-1
lines changed
src/swapService/strategies Expand file tree Collapse file tree 2 files changed +53
-1
lines changed Original file line number Diff line number Diff line change
1
+ import type {
2
+ ChainId ,
3
+ FieldsRequirements ,
4
+ IProviderService ,
5
+ SupportRecord ,
6
+ TimeString ,
7
+ } from "@balmy/sdk"
8
+ import type {
9
+ GasPriceResult ,
10
+ GasValueForVersions ,
11
+ IGasPriceSource ,
12
+ } from "@balmy/sdk/dist/services/gas/types"
13
+
14
+ // Stub out gas price calculations to make sure not to hit RPCs
15
+ type GasValues = GasValueForVersions < "standard" >
16
+ export class StubGasPriceSource implements IGasPriceSource < GasValues > {
17
+ constructor ( private readonly providerService : IProviderService ) { }
18
+
19
+ supportedSpeeds ( ) {
20
+ const support : SupportRecord < GasValues > = { standard : "present" }
21
+ return Object . fromEntries (
22
+ this . providerService
23
+ . supportedChains ( )
24
+ . map ( ( chainId ) => [ Number ( chainId ) , support ] ) ,
25
+ )
26
+ }
27
+
28
+ getGasPrice < Requirements extends FieldsRequirements < GasValues > > ( ) {
29
+ return Promise . resolve ( {
30
+ standard : {
31
+ maxFeePerGas : 0 ,
32
+ maxPriorityFeePerGas : 0 ,
33
+ gasPrice : 0 ,
34
+ } ,
35
+ } ) as unknown as Promise < GasPriceResult < GasValues , Requirements > >
36
+ }
37
+ }
Original file line number Diff line number Diff line change @@ -40,6 +40,7 @@ import {
40
40
quoteToRoute ,
41
41
} from "../utils"
42
42
import { CustomSourceList } from "./balmySDK/customSourceList"
43
+ import { StubGasPriceSource } from "./balmySDK/stubGasPriceSource"
43
44
import { TokenlistMetadataSource } from "./balmySDK/tokenlistMetadataSource"
44
45
45
46
const DAO_MULTISIG = "0xcAD001c30E96765aC90307669d578219D4fb1DCe"
@@ -88,7 +89,15 @@ export class StrategyBalmySDK {
88
89
constructor ( match = { } , config ?: BalmyStrategyConfig ) {
89
90
this . config = { ...defaultConfig , ...( config || { } ) }
90
91
const fetchService = buildFetchService ( )
91
- const providerService = buildProviderService ( )
92
+ const providerService = buildProviderService ( {
93
+ source : {
94
+ type : "public-rpcs" ,
95
+ rpcsPerChain : combinePublicAndPrivateRPCs ( ) ,
96
+ config : {
97
+ type : "fallback" ,
98
+ } ,
99
+ } ,
100
+ } )
92
101
93
102
const buildParams : BuildParams = {
94
103
quotes : {
@@ -153,6 +162,12 @@ export class StrategyBalmySDK {
153
162
} ,
154
163
} ,
155
164
} ,
165
+ gas : {
166
+ source : {
167
+ type : "custom" ,
168
+ instance : new StubGasPriceSource ( providerService ) ,
169
+ } ,
170
+ } ,
156
171
} as BuildParams
157
172
this . sdk = buildSDK ( buildParams )
158
173
this . match = match
You can’t perform that action at this time.
0 commit comments