@@ -9,29 +9,55 @@ import fantomAggregator from './aggregators/fantom.json';
9
9
import nearAggregator from './aggregators/near.json' ;
10
10
import nearTestnetAggregator from './aggregators/near-testnet.json' ;
11
11
12
+ /**
13
+ * currencyFrom => currencyTo => cost
14
+ */
12
15
export type CurrencyPairs = Record < string , Record < string , number > > ;
13
- // List of currencies supported by network (can be generated from requestNetwork/toolbox/src/chainlinkConversionPathTools.ts)
14
- // Network => currencyFrom => currencyTo => cost
15
- // Must be updated every time an aggregator is added
16
- export const chainlinkCurrencyPairs : Record < string , CurrencyPairs > = {
16
+
17
+ /**
18
+ * Aggregators maps define pairs of currencies for which an onchain oracle exists, by network.
19
+ *
20
+ * Network => currencyFrom => currencyTo => cost
21
+ */
22
+ export type AggregatorsMap = Record < string , CurrencyPairs > ;
23
+
24
+ // Pairs supported by Chainlink (can be generated from requestNetwork/toolbox/src/chainlinkConversionPathTools.ts)
25
+ const chainlinkCurrencyPairs : AggregatorsMap = {
17
26
private : privateAggregator ,
18
27
rinkeby : rinkebyAggregator ,
19
- goerli : { } ,
20
28
mainnet : mainnetAggregator ,
21
29
matic : maticAggregator ,
22
30
fantom : fantomAggregator ,
23
- // FIX ME: This fix enables to get these networks registered in chainlinkSupportedNetworks.
24
- // Could be improved by removing the supported network check from the protocol
31
+ } ;
32
+
33
+ // Pairs supported by Flux Protocol
34
+ const fluxCurrencyPairs : AggregatorsMap = {
35
+ aurora : nearAggregator ,
36
+ 'aurora-testnet' : nearTestnetAggregator ,
37
+ } ;
38
+
39
+ // FIX ME: This fix enables to get these networks registered in conversionSupportedNetworks.
40
+ // Could be improved by removing the supported network check from the protocol
41
+ const noConversionNetworks : AggregatorsMap = {
42
+ goerli : { } ,
25
43
'arbitrum-rinkeby' : { } ,
26
44
'arbitrum-one' : { } ,
27
45
xdai : { } ,
28
46
avalanche : { } ,
29
47
bsc : { } ,
30
- aurora : nearAggregator ,
31
- 'aurora-testnet' : nearTestnetAggregator ,
32
48
} ;
33
49
34
- export const chainlinkSupportedNetworks = Object . keys ( chainlinkCurrencyPairs ) ;
50
+ /**
51
+ * Conversion paths per network used by default if no other path given to the Currency Manager.
52
+ * Must be updated every time an aggregator is added to one network.
53
+ */
54
+ export const defaultConversionPairs : AggregatorsMap = {
55
+ ...chainlinkCurrencyPairs ,
56
+ ...fluxCurrencyPairs ,
57
+ ...noConversionNetworks ,
58
+ } ;
59
+
60
+ export const conversionSupportedNetworks = Object . keys ( defaultConversionPairs ) ;
35
61
36
62
/**
37
63
* Gets the on-chain conversion path between two currencies.
@@ -47,7 +73,7 @@ export function getPath(
47
73
currencyFrom : Pick < CurrencyDefinition , 'hash' > ,
48
74
currencyTo : Pick < CurrencyDefinition , 'hash' > ,
49
75
network = 'mainnet' ,
50
- pairs = chainlinkCurrencyPairs ,
76
+ pairs = defaultConversionPairs ,
51
77
) : string [ ] | null {
52
78
if ( ! pairs [ network ] ) {
53
79
throw Error ( `network ${ network } not supported` ) ;
0 commit comments