@talismn/token-rates 3.0.22 → 4.0.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 +253 -674
- package/dist/index.d.mts +144 -98
- package/dist/index.d.mts.map +1 -0
- package/dist/index.d.ts +144 -98
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +339 -191
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +314 -165
- package/dist/index.mjs.map +1 -1
- package/package.json +9 -5
package/dist/index.d.mts
CHANGED
|
@@ -1,115 +1,161 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { NetworkId, SubDTaoToken, Token, TokenId, TokenList } from "@talismn/chaindata-provider";
|
|
2
|
+
import { IChainConnectorDot } from "@talismn/chain-connectors";
|
|
3
|
+
//#region src/types.d.ts
|
|
5
4
|
declare const SUPPORTED_CURRENCIES: {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
5
|
+
readonly btc: {
|
|
6
|
+
readonly name: "Bitcoin";
|
|
7
|
+
readonly symbol: "₿";
|
|
8
|
+
};
|
|
9
|
+
readonly eth: {
|
|
10
|
+
readonly name: "Ethereum";
|
|
11
|
+
readonly symbol: "Ξ";
|
|
12
|
+
};
|
|
13
|
+
readonly dot: {
|
|
14
|
+
readonly name: "Polkadot";
|
|
15
|
+
readonly symbol: "D";
|
|
16
|
+
};
|
|
17
|
+
readonly tao: {
|
|
18
|
+
readonly name: "Bittensor";
|
|
19
|
+
readonly symbol: "τ";
|
|
20
|
+
};
|
|
21
|
+
readonly usd: {
|
|
22
|
+
readonly name: "US Dollar";
|
|
23
|
+
readonly symbol: "$";
|
|
24
|
+
};
|
|
25
|
+
readonly cny: {
|
|
26
|
+
readonly name: "Chinese Yuan";
|
|
27
|
+
readonly symbol: "¥";
|
|
28
|
+
};
|
|
29
|
+
readonly eur: {
|
|
30
|
+
readonly name: "Euro";
|
|
31
|
+
readonly symbol: "€";
|
|
32
|
+
};
|
|
33
|
+
readonly gbp: {
|
|
34
|
+
readonly name: "British Pound";
|
|
35
|
+
readonly symbol: "£";
|
|
36
|
+
};
|
|
37
|
+
readonly cad: {
|
|
38
|
+
readonly name: "Canadian Dollar";
|
|
39
|
+
readonly symbol: "C$";
|
|
40
|
+
};
|
|
41
|
+
readonly aud: {
|
|
42
|
+
readonly name: "Australian Dollar";
|
|
43
|
+
readonly symbol: "A$";
|
|
44
|
+
};
|
|
45
|
+
readonly nzd: {
|
|
46
|
+
readonly name: "New Zealand Dollar";
|
|
47
|
+
readonly symbol: "NZ$";
|
|
48
|
+
};
|
|
49
|
+
readonly jpy: {
|
|
50
|
+
readonly name: "Japanese Yen";
|
|
51
|
+
readonly symbol: "¥";
|
|
52
|
+
};
|
|
53
|
+
readonly rub: {
|
|
54
|
+
readonly name: "Russian Ruble";
|
|
55
|
+
readonly symbol: "₽";
|
|
56
|
+
};
|
|
57
|
+
readonly krw: {
|
|
58
|
+
readonly name: "South Korean Won";
|
|
59
|
+
readonly symbol: "₩";
|
|
60
|
+
};
|
|
61
|
+
readonly idr: {
|
|
62
|
+
readonly name: "Indonesian Rupiah";
|
|
63
|
+
readonly symbol: "Rp";
|
|
64
|
+
};
|
|
65
|
+
readonly php: {
|
|
66
|
+
readonly name: "Philippine Peso";
|
|
67
|
+
readonly symbol: "₱";
|
|
68
|
+
};
|
|
69
|
+
readonly thb: {
|
|
70
|
+
readonly name: "Thai Baht";
|
|
71
|
+
readonly symbol: "฿";
|
|
72
|
+
};
|
|
73
|
+
readonly vnd: {
|
|
74
|
+
readonly name: "Vietnamese Dong";
|
|
75
|
+
readonly symbol: "₫";
|
|
76
|
+
};
|
|
77
|
+
readonly inr: {
|
|
78
|
+
readonly name: "Indian Rupee";
|
|
79
|
+
readonly symbol: "₹";
|
|
80
|
+
};
|
|
81
|
+
readonly try: {
|
|
82
|
+
readonly name: "Turkish Lira";
|
|
83
|
+
readonly symbol: "₺";
|
|
84
|
+
};
|
|
85
|
+
readonly sgd: {
|
|
86
|
+
readonly name: "Singapore Dollar";
|
|
87
|
+
readonly symbol: "S$";
|
|
88
|
+
};
|
|
90
89
|
};
|
|
91
90
|
type TokenRatesStorage = {
|
|
92
|
-
|
|
91
|
+
tokenRates: TokenRatesList;
|
|
93
92
|
};
|
|
94
93
|
type TokenRatesList = Record<TokenId, TokenRates>;
|
|
95
94
|
type TokenRates = Record<TokenRateCurrency, TokenRateData | null>;
|
|
96
95
|
type TokenRateData = {
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
96
|
+
price: number;
|
|
97
|
+
marketCap?: number;
|
|
98
|
+
change24h?: number;
|
|
100
99
|
};
|
|
101
100
|
type TokenRateCurrency = keyof typeof SUPPORTED_CURRENCIES;
|
|
102
101
|
declare const newTokenRates: () => TokenRates;
|
|
103
|
-
|
|
102
|
+
//#endregion
|
|
103
|
+
//#region src/fetchDTaoTokenRates.d.ts
|
|
104
|
+
type FetchDTaoTokenRatesOptions = {
|
|
105
|
+
/** substrate chain connector of the host (only its `send` method is used, for one state_call per invocation) */
|
|
106
|
+
connector: IChainConnectorDot;
|
|
107
|
+
/** the bittensor network id, defaults to "bittensor" (mainnet) */
|
|
108
|
+
networkId?: NetworkId;
|
|
109
|
+
/** token list to price — non-dtao tokens (and dtao tokens with a coingeckoId) are ignored */
|
|
110
|
+
tokens: TokenList;
|
|
111
|
+
/** freshly fetched rates list — dtao rates derive from the network's native TAO token rates in it */
|
|
112
|
+
tokenRates: TokenRatesList;
|
|
113
|
+
/** previous rates list, used as keep-last fallback when fetching fails */
|
|
114
|
+
previousRates: TokenRatesList;
|
|
115
|
+
/** custom fetch for the tao-data api (eg with auth headers), defaults to global fetch */
|
|
116
|
+
customFetch?: typeof fetch;
|
|
117
|
+
/** tao-data api url, defaults to https://tda.talisman.xyz */
|
|
118
|
+
taoDataApiUrl?: string;
|
|
119
|
+
/** per-request timeout for the chain call and the tao-data api call, defaults to 10s */
|
|
120
|
+
timeoutMs?: number;
|
|
121
|
+
};
|
|
122
|
+
/**
|
|
123
|
+
* Rates entries for the bittensor dtao (subnet alpha) tokens of `tokens`, priced from their
|
|
124
|
+
* subnet pool combined with the TAO rates in `tokenRates`. On chain-fetch failure, falls
|
|
125
|
+
* back to the token's entry in `previousRates` (keep-last). Never throws — a dtao pricing
|
|
126
|
+
* failure must not discard the rates list it gets merged into.
|
|
127
|
+
*
|
|
128
|
+
* Hosts remain responsible for WHEN to call this (network enabled state, refresh cadence)
|
|
129
|
+
* and for merging the result into their rates list/store.
|
|
130
|
+
*/
|
|
131
|
+
declare const fetchDTaoTokenRates: ({ connector, networkId, tokens, tokenRates, previousRates, customFetch, taoDataApiUrl, timeoutMs }: FetchDTaoTokenRatesOptions) => Promise<TokenRatesList>;
|
|
132
|
+
//#endregion
|
|
133
|
+
//#region src/getDTaoTokenRates.d.ts
|
|
134
|
+
/**
|
|
135
|
+
* Rates of a bittensor dtao (subnet alpha) token, derived from its network's native TAO rates
|
|
136
|
+
* scaled by the subnet pool price. To be used for tokens that don't have a coingecko id.
|
|
137
|
+
*
|
|
138
|
+
* @param token
|
|
139
|
+
* @param tokenRates must contain the rates of the network's native (TAO) token
|
|
140
|
+
* @param scaledAlphaPrice current TAO-per-alpha pool price, fixed-point scaled by 10^9 (rao)
|
|
141
|
+
* @param alphaPriceChange24h 24h change of the pool price (alpha vs TAO) in percent, when known
|
|
142
|
+
*/
|
|
143
|
+
declare const getDTaoTokenRates: (token: SubDTaoToken, tokenRates: TokenRatesList, scaledAlphaPrice: string | bigint, alphaPriceChange24h?: number | null) => TokenRates | null;
|
|
144
|
+
//#endregion
|
|
145
|
+
//#region src/TalismanTokenRatesDatabase.d.ts
|
|
146
|
+
declare const tryToDeleteOldTokenRatesDb: () => void;
|
|
147
|
+
//#endregion
|
|
148
|
+
//#region src/TokenRates.d.ts
|
|
104
149
|
declare class TokenRatesError extends Error {
|
|
105
|
-
|
|
106
|
-
|
|
150
|
+
response?: Response;
|
|
151
|
+
constructor(message: string, response?: Response);
|
|
107
152
|
}
|
|
108
153
|
declare const ALL_CURRENCY_IDS: TokenRateCurrency[];
|
|
109
154
|
type CoinsApiConfig = {
|
|
110
|
-
|
|
155
|
+
apiUrl: string;
|
|
111
156
|
};
|
|
112
157
|
declare const DEFAULT_COINSAPI_CONFIG: CoinsApiConfig;
|
|
113
158
|
declare function fetchTokenRates(tokens: Record<TokenId, Token>, currencyIds?: TokenRateCurrency[], config?: CoinsApiConfig): Promise<TokenRatesList>;
|
|
114
|
-
|
|
115
|
-
export { ALL_CURRENCY_IDS,
|
|
159
|
+
//#endregion
|
|
160
|
+
export { ALL_CURRENCY_IDS, CoinsApiConfig, DEFAULT_COINSAPI_CONFIG, FetchDTaoTokenRatesOptions, SUPPORTED_CURRENCIES, TokenRateCurrency, TokenRateData, TokenRates, TokenRatesError, TokenRatesList, TokenRatesStorage, fetchDTaoTokenRates, fetchTokenRates, getDTaoTokenRates, newTokenRates, tryToDeleteOldTokenRatesDb };
|
|
161
|
+
//# sourceMappingURL=index.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/types.ts","../src/fetchDTaoTokenRates.ts","../src/getDTaoTokenRates.ts","../src/TalismanTokenRatesDatabase.ts","../src/TokenRates.ts"],"mappings":";;;cAEa;WACX;aAAO;aAAiB;;WACxB;aAAO;aAAkB;;WACzB;aAAO;aAAkB;;WACzB;aAAO;aAAmB;;WAE1B;aAAO;aAAmB;;WAC1B;aAAO;aAAsB;;WAC7B;aAAO;aAAc;;WACrB;aAAO;aAAuB;;WAC9B;aAAO;aAAyB;;WAChC;aAAO;aAA2B;;WAClC;aAAO;aAA4B;;WACnC;aAAO;aAAsB;;WAC7B;aAAO;aAAuB;;WAC9B;aAAO;aAA0B;;WACjC;aAAO;aAA2B;;WAClC;aAAO;aAAyB;;WAChC;aAAO;aAAmB;;WAC1B;aAAO;aAAyB;;WAChC;aAAO;aAAsB;;WAC7B;aAAO;aAAsB;;WAE7B;aAAO;aAA0B;;;KAIvB;EAAsB,YAAY;;KAElC,iBAAiB,OAAO,SAAS;KACjC,aAAa,OAAO,mBAAmB;KAEvC;EAAkB;EAAe;EAAoB;;KACrD,iCAAiC;cAEhC,qBAAoB;;;KCkCrB;;EAEV,WAAW;;EAEX,YAAY;;EAEZ,QAAQ;;EAER,YAAY;;EAEZ,eAAe;;EAEf,qBAAqB;;EAErB;;EAEA;;;;;;;;;;;cAYW,wBAAmB,WAAA,WAAA,QAAA,YAAA,eAAA,aAAA,eAAA,aAS7B,+BAA6B,QAAQ;;;;;;;;;;;;cCnE3B,oBAAiB,OACrB,cAAY,YACP,gBAAc,mCACO,wCADrB;;;cC3CD;;;cCUA,wBAAwB;EACnC,WAAW;EACX,YAAY,iBAAiB,WAAW;;cAM7B,kBAAwD;KACzD;EACV;;cAGW,yBAAyB;iBAGhB,gBACpB,QAAQ,OAAO,SAAS,QACxB,cAAa,qBACb,SAAQ,iBACP,QAAQ"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,115 +1,161 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { IChainConnectorDot } from "@talismn/chain-connectors";
|
|
2
|
+
import { NetworkId, SubDTaoToken, Token, TokenId, TokenList } from "@talismn/chaindata-provider";
|
|
3
|
+
//#region src/types.d.ts
|
|
5
4
|
declare const SUPPORTED_CURRENCIES: {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
5
|
+
readonly btc: {
|
|
6
|
+
readonly name: "Bitcoin";
|
|
7
|
+
readonly symbol: "₿";
|
|
8
|
+
};
|
|
9
|
+
readonly eth: {
|
|
10
|
+
readonly name: "Ethereum";
|
|
11
|
+
readonly symbol: "Ξ";
|
|
12
|
+
};
|
|
13
|
+
readonly dot: {
|
|
14
|
+
readonly name: "Polkadot";
|
|
15
|
+
readonly symbol: "D";
|
|
16
|
+
};
|
|
17
|
+
readonly tao: {
|
|
18
|
+
readonly name: "Bittensor";
|
|
19
|
+
readonly symbol: "τ";
|
|
20
|
+
};
|
|
21
|
+
readonly usd: {
|
|
22
|
+
readonly name: "US Dollar";
|
|
23
|
+
readonly symbol: "$";
|
|
24
|
+
};
|
|
25
|
+
readonly cny: {
|
|
26
|
+
readonly name: "Chinese Yuan";
|
|
27
|
+
readonly symbol: "¥";
|
|
28
|
+
};
|
|
29
|
+
readonly eur: {
|
|
30
|
+
readonly name: "Euro";
|
|
31
|
+
readonly symbol: "€";
|
|
32
|
+
};
|
|
33
|
+
readonly gbp: {
|
|
34
|
+
readonly name: "British Pound";
|
|
35
|
+
readonly symbol: "£";
|
|
36
|
+
};
|
|
37
|
+
readonly cad: {
|
|
38
|
+
readonly name: "Canadian Dollar";
|
|
39
|
+
readonly symbol: "C$";
|
|
40
|
+
};
|
|
41
|
+
readonly aud: {
|
|
42
|
+
readonly name: "Australian Dollar";
|
|
43
|
+
readonly symbol: "A$";
|
|
44
|
+
};
|
|
45
|
+
readonly nzd: {
|
|
46
|
+
readonly name: "New Zealand Dollar";
|
|
47
|
+
readonly symbol: "NZ$";
|
|
48
|
+
};
|
|
49
|
+
readonly jpy: {
|
|
50
|
+
readonly name: "Japanese Yen";
|
|
51
|
+
readonly symbol: "¥";
|
|
52
|
+
};
|
|
53
|
+
readonly rub: {
|
|
54
|
+
readonly name: "Russian Ruble";
|
|
55
|
+
readonly symbol: "₽";
|
|
56
|
+
};
|
|
57
|
+
readonly krw: {
|
|
58
|
+
readonly name: "South Korean Won";
|
|
59
|
+
readonly symbol: "₩";
|
|
60
|
+
};
|
|
61
|
+
readonly idr: {
|
|
62
|
+
readonly name: "Indonesian Rupiah";
|
|
63
|
+
readonly symbol: "Rp";
|
|
64
|
+
};
|
|
65
|
+
readonly php: {
|
|
66
|
+
readonly name: "Philippine Peso";
|
|
67
|
+
readonly symbol: "₱";
|
|
68
|
+
};
|
|
69
|
+
readonly thb: {
|
|
70
|
+
readonly name: "Thai Baht";
|
|
71
|
+
readonly symbol: "฿";
|
|
72
|
+
};
|
|
73
|
+
readonly vnd: {
|
|
74
|
+
readonly name: "Vietnamese Dong";
|
|
75
|
+
readonly symbol: "₫";
|
|
76
|
+
};
|
|
77
|
+
readonly inr: {
|
|
78
|
+
readonly name: "Indian Rupee";
|
|
79
|
+
readonly symbol: "₹";
|
|
80
|
+
};
|
|
81
|
+
readonly try: {
|
|
82
|
+
readonly name: "Turkish Lira";
|
|
83
|
+
readonly symbol: "₺";
|
|
84
|
+
};
|
|
85
|
+
readonly sgd: {
|
|
86
|
+
readonly name: "Singapore Dollar";
|
|
87
|
+
readonly symbol: "S$";
|
|
88
|
+
};
|
|
90
89
|
};
|
|
91
90
|
type TokenRatesStorage = {
|
|
92
|
-
|
|
91
|
+
tokenRates: TokenRatesList;
|
|
93
92
|
};
|
|
94
93
|
type TokenRatesList = Record<TokenId, TokenRates>;
|
|
95
94
|
type TokenRates = Record<TokenRateCurrency, TokenRateData | null>;
|
|
96
95
|
type TokenRateData = {
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
96
|
+
price: number;
|
|
97
|
+
marketCap?: number;
|
|
98
|
+
change24h?: number;
|
|
100
99
|
};
|
|
101
100
|
type TokenRateCurrency = keyof typeof SUPPORTED_CURRENCIES;
|
|
102
101
|
declare const newTokenRates: () => TokenRates;
|
|
103
|
-
|
|
102
|
+
//#endregion
|
|
103
|
+
//#region src/fetchDTaoTokenRates.d.ts
|
|
104
|
+
type FetchDTaoTokenRatesOptions = {
|
|
105
|
+
/** substrate chain connector of the host (only its `send` method is used, for one state_call per invocation) */
|
|
106
|
+
connector: IChainConnectorDot;
|
|
107
|
+
/** the bittensor network id, defaults to "bittensor" (mainnet) */
|
|
108
|
+
networkId?: NetworkId;
|
|
109
|
+
/** token list to price — non-dtao tokens (and dtao tokens with a coingeckoId) are ignored */
|
|
110
|
+
tokens: TokenList;
|
|
111
|
+
/** freshly fetched rates list — dtao rates derive from the network's native TAO token rates in it */
|
|
112
|
+
tokenRates: TokenRatesList;
|
|
113
|
+
/** previous rates list, used as keep-last fallback when fetching fails */
|
|
114
|
+
previousRates: TokenRatesList;
|
|
115
|
+
/** custom fetch for the tao-data api (eg with auth headers), defaults to global fetch */
|
|
116
|
+
customFetch?: typeof fetch;
|
|
117
|
+
/** tao-data api url, defaults to https://tda.talisman.xyz */
|
|
118
|
+
taoDataApiUrl?: string;
|
|
119
|
+
/** per-request timeout for the chain call and the tao-data api call, defaults to 10s */
|
|
120
|
+
timeoutMs?: number;
|
|
121
|
+
};
|
|
122
|
+
/**
|
|
123
|
+
* Rates entries for the bittensor dtao (subnet alpha) tokens of `tokens`, priced from their
|
|
124
|
+
* subnet pool combined with the TAO rates in `tokenRates`. On chain-fetch failure, falls
|
|
125
|
+
* back to the token's entry in `previousRates` (keep-last). Never throws — a dtao pricing
|
|
126
|
+
* failure must not discard the rates list it gets merged into.
|
|
127
|
+
*
|
|
128
|
+
* Hosts remain responsible for WHEN to call this (network enabled state, refresh cadence)
|
|
129
|
+
* and for merging the result into their rates list/store.
|
|
130
|
+
*/
|
|
131
|
+
declare const fetchDTaoTokenRates: ({ connector, networkId, tokens, tokenRates, previousRates, customFetch, taoDataApiUrl, timeoutMs }: FetchDTaoTokenRatesOptions) => Promise<TokenRatesList>;
|
|
132
|
+
//#endregion
|
|
133
|
+
//#region src/getDTaoTokenRates.d.ts
|
|
134
|
+
/**
|
|
135
|
+
* Rates of a bittensor dtao (subnet alpha) token, derived from its network's native TAO rates
|
|
136
|
+
* scaled by the subnet pool price. To be used for tokens that don't have a coingecko id.
|
|
137
|
+
*
|
|
138
|
+
* @param token
|
|
139
|
+
* @param tokenRates must contain the rates of the network's native (TAO) token
|
|
140
|
+
* @param scaledAlphaPrice current TAO-per-alpha pool price, fixed-point scaled by 10^9 (rao)
|
|
141
|
+
* @param alphaPriceChange24h 24h change of the pool price (alpha vs TAO) in percent, when known
|
|
142
|
+
*/
|
|
143
|
+
declare const getDTaoTokenRates: (token: SubDTaoToken, tokenRates: TokenRatesList, scaledAlphaPrice: string | bigint, alphaPriceChange24h?: number | null) => TokenRates | null;
|
|
144
|
+
//#endregion
|
|
145
|
+
//#region src/TalismanTokenRatesDatabase.d.ts
|
|
146
|
+
declare const tryToDeleteOldTokenRatesDb: () => void;
|
|
147
|
+
//#endregion
|
|
148
|
+
//#region src/TokenRates.d.ts
|
|
104
149
|
declare class TokenRatesError extends Error {
|
|
105
|
-
|
|
106
|
-
|
|
150
|
+
response?: Response;
|
|
151
|
+
constructor(message: string, response?: Response);
|
|
107
152
|
}
|
|
108
153
|
declare const ALL_CURRENCY_IDS: TokenRateCurrency[];
|
|
109
154
|
type CoinsApiConfig = {
|
|
110
|
-
|
|
155
|
+
apiUrl: string;
|
|
111
156
|
};
|
|
112
157
|
declare const DEFAULT_COINSAPI_CONFIG: CoinsApiConfig;
|
|
113
158
|
declare function fetchTokenRates(tokens: Record<TokenId, Token>, currencyIds?: TokenRateCurrency[], config?: CoinsApiConfig): Promise<TokenRatesList>;
|
|
114
|
-
|
|
115
|
-
export { ALL_CURRENCY_IDS,
|
|
159
|
+
//#endregion
|
|
160
|
+
export { ALL_CURRENCY_IDS, CoinsApiConfig, DEFAULT_COINSAPI_CONFIG, FetchDTaoTokenRatesOptions, SUPPORTED_CURRENCIES, TokenRateCurrency, TokenRateData, TokenRates, TokenRatesError, TokenRatesList, TokenRatesStorage, fetchDTaoTokenRates, fetchTokenRates, getDTaoTokenRates, newTokenRates, tryToDeleteOldTokenRatesDb };
|
|
161
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/types.ts","../src/fetchDTaoTokenRates.ts","../src/getDTaoTokenRates.ts","../src/TalismanTokenRatesDatabase.ts","../src/TokenRates.ts"],"mappings":";;;cAEa;WACX;aAAO;aAAiB;;WACxB;aAAO;aAAkB;;WACzB;aAAO;aAAkB;;WACzB;aAAO;aAAmB;;WAE1B;aAAO;aAAmB;;WAC1B;aAAO;aAAsB;;WAC7B;aAAO;aAAc;;WACrB;aAAO;aAAuB;;WAC9B;aAAO;aAAyB;;WAChC;aAAO;aAA2B;;WAClC;aAAO;aAA4B;;WACnC;aAAO;aAAsB;;WAC7B;aAAO;aAAuB;;WAC9B;aAAO;aAA0B;;WACjC;aAAO;aAA2B;;WAClC;aAAO;aAAyB;;WAChC;aAAO;aAAmB;;WAC1B;aAAO;aAAyB;;WAChC;aAAO;aAAsB;;WAC7B;aAAO;aAAsB;;WAE7B;aAAO;aAA0B;;;KAIvB;EAAsB,YAAY;;KAElC,iBAAiB,OAAO,SAAS;KACjC,aAAa,OAAO,mBAAmB;KAEvC;EAAkB;EAAe;EAAoB;;KACrD,iCAAiC;cAEhC,qBAAoB;;;KCkCrB;;EAEV,WAAW;;EAEX,YAAY;;EAEZ,QAAQ;;EAER,YAAY;;EAEZ,eAAe;;EAEf,qBAAqB;;EAErB;;EAEA;;;;;;;;;;;cAYW,wBAAmB,WAAA,WAAA,QAAA,YAAA,eAAA,aAAA,eAAA,aAS7B,+BAA6B,QAAQ;;;;;;;;;;;;cCnE3B,oBAAiB,OACrB,cAAY,YACP,gBAAc,mCACO,wCADrB;;;cC3CD;;;cCUA,wBAAwB;EACnC,WAAW;EACX,YAAY,iBAAiB,WAAW;;cAM7B,kBAAwD;KACzD;EACV;;cAGW,yBAAyB;iBAGhB,gBACpB,QAAQ,OAAO,SAAS,QACxB,cAAa,qBACb,SAAQ,iBACP,QAAQ"}
|