@missionsquad/mcp-defillama 1.0.0 → 1.2.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/README.md +82 -23
- package/dist/clients/defillama.client.d.ts +120 -29
- package/dist/clients/defillama.client.js +208 -159
- package/dist/clients/defillama.client.js.map +1 -1
- package/dist/clients/defillama.mock.client.d.ts +6 -2
- package/dist/clients/defillama.mock.client.js +6 -2
- package/dist/clients/defillama.mock.client.js.map +1 -1
- package/dist/handlers/datetime.d.ts +18 -0
- package/dist/handlers/datetime.js +92 -0
- package/dist/handlers/datetime.js.map +1 -0
- package/dist/handlers/defillama.d.ts +25 -1
- package/dist/handlers/defillama.js +298 -22
- package/dist/handlers/defillama.js.map +1 -1
- package/dist/handlers/defillama.types.d.ts +113 -6
- package/dist/handlers/defillama.types.js +3 -0
- package/dist/handlers/defillama.types.js.map +1 -1
- package/dist/handlers/transform.d.ts +34 -0
- package/dist/handlers/transform.js +241 -0
- package/dist/handlers/transform.js.map +1 -0
- package/dist/handlers/utils.d.ts +8 -0
- package/dist/handlers/utils.js +16 -0
- package/dist/handlers/utils.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/tools.d.ts +475 -7
- package/dist/tools.js +393 -24
- package/dist/tools.js.map +1 -1
- package/package.json +5 -3
|
@@ -1,74 +1,83 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* DefiLlama API Client
|
|
3
|
-
* Provides methods to interact with the DefiLlama API
|
|
3
|
+
* Provides methods to interact with the free (keyless) DefiLlama API.
|
|
4
|
+
*
|
|
5
|
+
* DefiLlama splits its free API across a few category-specific hosts. The
|
|
6
|
+
* canonical routing is:
|
|
7
|
+
* - TVL, DEX/options volume, fees/revenue, open interest -> api.llama.fi
|
|
8
|
+
* - Coins / prices / blocks -> coins.llama.fi
|
|
9
|
+
* - Stablecoins -> stablecoins.llama.fi
|
|
10
|
+
* - Yields / pools -> yields.llama.fi
|
|
4
11
|
*/
|
|
5
|
-
const
|
|
12
|
+
export const DEFILLAMA_HOSTS = {
|
|
13
|
+
api: "https://api.llama.fi",
|
|
14
|
+
coins: "https://coins.llama.fi",
|
|
15
|
+
stablecoins: "https://stablecoins.llama.fi",
|
|
16
|
+
yields: "https://yields.llama.fi",
|
|
17
|
+
};
|
|
6
18
|
export class DefiLlamaClient {
|
|
7
|
-
constructor(baseUrl = DEFILLAMA_API_BASE_URL) {
|
|
8
|
-
this.baseUrl = baseUrl;
|
|
9
|
-
}
|
|
10
19
|
/**
|
|
11
|
-
* Makes a GET request to the DefiLlama
|
|
20
|
+
* Makes a GET request to one of the DefiLlama hosts.
|
|
12
21
|
*/
|
|
13
|
-
async
|
|
14
|
-
|
|
22
|
+
async request(host, path, query) {
|
|
23
|
+
let url = `${host}${path}`;
|
|
24
|
+
if (query) {
|
|
25
|
+
const params = new URLSearchParams();
|
|
26
|
+
for (const [key, value] of Object.entries(query)) {
|
|
27
|
+
if (value !== undefined) {
|
|
28
|
+
params.append(key, String(value));
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
const queryString = params.toString();
|
|
32
|
+
if (queryString) {
|
|
33
|
+
url += `?${queryString}`;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
const response = await fetch(url);
|
|
15
37
|
if (!response.ok) {
|
|
16
38
|
const errorText = await response.text();
|
|
17
39
|
throw new Error(`DefiLlama API error: ${response.status} ${response.statusText} - ${errorText}`);
|
|
18
40
|
}
|
|
19
41
|
return await response.json();
|
|
20
42
|
}
|
|
21
|
-
/**
|
|
22
|
-
|
|
23
|
-
|
|
43
|
+
/** Joins coin identifiers into the comma-separated form DefiLlama expects. */
|
|
44
|
+
joinCoins(coins) {
|
|
45
|
+
if (!coins || coins.length === 0) {
|
|
46
|
+
throw new Error("At least one coin is required");
|
|
47
|
+
}
|
|
48
|
+
return coins.join(",");
|
|
49
|
+
}
|
|
50
|
+
// ---------------------------------------------------------------------------
|
|
51
|
+
// TVL
|
|
52
|
+
// ---------------------------------------------------------------------------
|
|
53
|
+
/** GET /protocols — list all protocols. */
|
|
24
54
|
async getProtocols() {
|
|
25
|
-
return this.
|
|
55
|
+
return this.request(DEFILLAMA_HOSTS.api, "/protocols");
|
|
26
56
|
}
|
|
27
|
-
/**
|
|
28
|
-
* Get TVL data for a specific protocol
|
|
29
|
-
*/
|
|
57
|
+
/** GET /protocol/{protocol} — full TVL breakdown for a protocol. */
|
|
30
58
|
async getProtocolTvl(protocol) {
|
|
31
59
|
if (!protocol) {
|
|
32
60
|
throw new Error("Protocol name is required");
|
|
33
61
|
}
|
|
34
|
-
|
|
35
|
-
const data = await this.get(`/protocol/${protocol}`);
|
|
36
|
-
// Ensure tvlList exists for compatibility with tests
|
|
37
|
-
if (!data.tvlList && data.tvl) {
|
|
38
|
-
// If tvlList is missing but we have historical data, create it
|
|
39
|
-
if (data.chainTvls && Object.keys(data.chainTvls).length > 0) {
|
|
40
|
-
data.tvlList = [{
|
|
41
|
-
date: Math.floor(Date.now() / 1000),
|
|
42
|
-
totalLiquidityUSD: data.tvl
|
|
43
|
-
}];
|
|
44
|
-
}
|
|
45
|
-
else {
|
|
46
|
-
// Create a minimal tvlList with current TVL
|
|
47
|
-
data.tvlList = [
|
|
48
|
-
{
|
|
49
|
-
date: Math.floor(Date.now() / 1000),
|
|
50
|
-
totalLiquidityUSD: data.tvl
|
|
51
|
-
}
|
|
52
|
-
];
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
return data;
|
|
62
|
+
return this.request(DEFILLAMA_HOSTS.api, `/protocol/${protocol}`);
|
|
56
63
|
}
|
|
57
|
-
/**
|
|
58
|
-
|
|
59
|
-
|
|
64
|
+
/** GET /v2/historicalChainTvl — historical TVL across all chains. */
|
|
65
|
+
async getHistoricalChainTvl() {
|
|
66
|
+
return this.request(DEFILLAMA_HOSTS.api, "/v2/historicalChainTvl");
|
|
67
|
+
}
|
|
68
|
+
/** GET /v2/historicalChainTvl/{chain} — historical TVL for one chain. */
|
|
60
69
|
async getChainTvl(chain) {
|
|
61
70
|
if (!chain) {
|
|
62
71
|
throw new Error("Chain name is required");
|
|
63
72
|
}
|
|
64
|
-
const data = await this.
|
|
65
|
-
//
|
|
73
|
+
const data = await this.request(DEFILLAMA_HOSTS.api, `/v2/historicalChainTvl/${chain}`);
|
|
74
|
+
// Normalize so each item exposes totalLiquidityUSD.
|
|
66
75
|
if (Array.isArray(data)) {
|
|
67
76
|
return data.map(item => {
|
|
68
77
|
if (!item.totalLiquidityUSD && (item.tvl || item.totalLiquidityETH)) {
|
|
69
78
|
return {
|
|
70
79
|
...item,
|
|
71
|
-
totalLiquidityUSD: item.tvl || item.totalLiquidityETH || 0
|
|
80
|
+
totalLiquidityUSD: item.tvl || item.totalLiquidityETH || 0,
|
|
72
81
|
};
|
|
73
82
|
}
|
|
74
83
|
return item;
|
|
@@ -76,140 +85,180 @@ export class DefiLlamaClient {
|
|
|
76
85
|
}
|
|
77
86
|
return data;
|
|
78
87
|
}
|
|
79
|
-
/**
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
if (!coins || coins.length === 0) {
|
|
84
|
-
throw new Error("At least one coin is required");
|
|
88
|
+
/** GET /tvl/{protocol} — current TVL of a protocol as a single number. */
|
|
89
|
+
async getCurrentProtocolTvl(protocol) {
|
|
90
|
+
if (!protocol) {
|
|
91
|
+
throw new Error("Protocol name is required");
|
|
85
92
|
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
93
|
+
return this.request(DEFILLAMA_HOSTS.api, `/tvl/${protocol}`);
|
|
94
|
+
}
|
|
95
|
+
/** GET /v2/chains — current TVL of all chains. */
|
|
96
|
+
async getChains() {
|
|
97
|
+
return this.request(DEFILLAMA_HOSTS.api, "/v2/chains");
|
|
98
|
+
}
|
|
99
|
+
// ---------------------------------------------------------------------------
|
|
100
|
+
// Coins / Prices
|
|
101
|
+
// ---------------------------------------------------------------------------
|
|
102
|
+
/** GET /prices/current/{coins} — current prices for the given coins. */
|
|
103
|
+
async getTokenPrices(coins) {
|
|
104
|
+
return this.request(DEFILLAMA_HOSTS.coins, `/prices/current/${this.joinCoins(coins)}`);
|
|
105
|
+
}
|
|
106
|
+
/** GET /prices/historical/{timestamp}/{coins} — prices at a timestamp. */
|
|
107
|
+
async getHistoricalPrices(coins, timestamp) {
|
|
108
|
+
const coinsParam = this.joinCoins(coins);
|
|
109
|
+
if (!timestamp) {
|
|
110
|
+
throw new Error("Timestamp is required");
|
|
104
111
|
}
|
|
112
|
+
return this.request(DEFILLAMA_HOSTS.coins, `/prices/historical/${timestamp}/${coinsParam}`);
|
|
105
113
|
}
|
|
106
114
|
/**
|
|
107
|
-
*
|
|
115
|
+
* GET /batchHistorical — historical prices for many coins at many timestamps.
|
|
116
|
+
* @param coins Map of coin identifier to an array of UNIX timestamps.
|
|
108
117
|
*/
|
|
109
|
-
async
|
|
110
|
-
if (!coins || coins.length === 0) {
|
|
118
|
+
async getBatchHistoricalPrices(coins, searchWidth) {
|
|
119
|
+
if (!coins || Object.keys(coins).length === 0) {
|
|
111
120
|
throw new Error("At least one coin is required");
|
|
112
121
|
}
|
|
122
|
+
return this.request(DEFILLAMA_HOSTS.coins, "/batchHistorical", {
|
|
123
|
+
coins: JSON.stringify(coins),
|
|
124
|
+
searchWidth,
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
/** GET /chart/{coins} — price chart for the given coins. */
|
|
128
|
+
async getPriceChart(coins, options = {}) {
|
|
129
|
+
return this.request(DEFILLAMA_HOSTS.coins, `/chart/${this.joinCoins(coins)}`, { ...options });
|
|
130
|
+
}
|
|
131
|
+
/** GET /percentage/{coins} — percentage price change for the given coins. */
|
|
132
|
+
async getPricePercentageChange(coins, options = {}) {
|
|
133
|
+
return this.request(DEFILLAMA_HOSTS.coins, `/percentage/${this.joinCoins(coins)}`, { ...options });
|
|
134
|
+
}
|
|
135
|
+
/** GET /prices/first/{coins} — earliest recorded price for the given coins. */
|
|
136
|
+
async getFirstPrices(coins) {
|
|
137
|
+
return this.request(DEFILLAMA_HOSTS.coins, `/prices/first/${this.joinCoins(coins)}`);
|
|
138
|
+
}
|
|
139
|
+
/** GET /block/{chain}/{timestamp} — closest block to a timestamp on a chain. */
|
|
140
|
+
async getBlock(chain, timestamp) {
|
|
141
|
+
if (!chain) {
|
|
142
|
+
throw new Error("Chain name is required");
|
|
143
|
+
}
|
|
113
144
|
if (!timestamp) {
|
|
114
145
|
throw new Error("Timestamp is required");
|
|
115
146
|
}
|
|
116
|
-
|
|
117
|
-
const coinsParam = coins.join(',');
|
|
118
|
-
const data = await this.get(`/prices/historical/${timestamp}/${coinsParam}`);
|
|
119
|
-
return data;
|
|
120
|
-
}
|
|
121
|
-
catch (error) {
|
|
122
|
-
// If the API returns an error, return a mock response for compatibility with tests
|
|
123
|
-
console.warn("Error fetching historical prices, returning mock data:", error);
|
|
124
|
-
const result = { coins: {} };
|
|
125
|
-
coins.forEach(coin => {
|
|
126
|
-
result.coins[coin] = {
|
|
127
|
-
price: 100 + Math.random() * 900,
|
|
128
|
-
symbol: coin.split(':').pop() || 'MOCK',
|
|
129
|
-
timestamp: timestamp,
|
|
130
|
-
confidence: 0.95
|
|
131
|
-
};
|
|
132
|
-
});
|
|
133
|
-
return result;
|
|
134
|
-
}
|
|
147
|
+
return this.request(DEFILLAMA_HOSTS.coins, `/block/${chain}/${timestamp}`);
|
|
135
148
|
}
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
symbol: "USDC",
|
|
152
|
-
price: 1.0,
|
|
153
|
-
circulating: {
|
|
154
|
-
peggedUSD: 1000000000
|
|
155
|
-
},
|
|
156
|
-
chainCirculating: {
|
|
157
|
-
ethereum: {
|
|
158
|
-
peggedUSD: 800000000
|
|
159
|
-
},
|
|
160
|
-
polygon: {
|
|
161
|
-
peggedUSD: 200000000
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
]
|
|
166
|
-
};
|
|
149
|
+
// ---------------------------------------------------------------------------
|
|
150
|
+
// Stablecoins
|
|
151
|
+
// ---------------------------------------------------------------------------
|
|
152
|
+
/** GET /stablecoins — list all stablecoins with circulating amounts. */
|
|
153
|
+
async getStablecoins(includePrices) {
|
|
154
|
+
return this.request(DEFILLAMA_HOSTS.stablecoins, "/stablecoins", { includePrices });
|
|
155
|
+
}
|
|
156
|
+
/** GET /stablecoincharts/all — historical mcap sum of all stablecoins. */
|
|
157
|
+
async getStablecoinChartsAll(stablecoin) {
|
|
158
|
+
return this.request(DEFILLAMA_HOSTS.stablecoins, "/stablecoincharts/all", { stablecoin });
|
|
159
|
+
}
|
|
160
|
+
/** GET /stablecoincharts/{chain} — historical mcap of stablecoins on a chain. */
|
|
161
|
+
async getStablecoinChartsChain(chain, stablecoin) {
|
|
162
|
+
if (!chain) {
|
|
163
|
+
throw new Error("Chain name is required");
|
|
167
164
|
}
|
|
165
|
+
return this.request(DEFILLAMA_HOSTS.stablecoins, `/stablecoincharts/${chain}`, { stablecoin });
|
|
168
166
|
}
|
|
169
|
-
/**
|
|
170
|
-
* Get data for a specific stablecoin
|
|
171
|
-
*/
|
|
167
|
+
/** GET /stablecoin/{asset} — historical data for a single stablecoin. */
|
|
172
168
|
async getStablecoinData(asset) {
|
|
173
169
|
if (!asset) {
|
|
174
170
|
throw new Error("Asset name is required");
|
|
175
171
|
}
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
172
|
+
return this.request(DEFILLAMA_HOSTS.stablecoins, `/stablecoin/${asset}`);
|
|
173
|
+
}
|
|
174
|
+
/** GET /stablecoinchains — current stablecoin totals per chain. */
|
|
175
|
+
async getStablecoinChains() {
|
|
176
|
+
return this.request(DEFILLAMA_HOSTS.stablecoins, "/stablecoinchains");
|
|
177
|
+
}
|
|
178
|
+
/** GET /stablecoinprices — historical stablecoin prices. */
|
|
179
|
+
async getStablecoinPrices() {
|
|
180
|
+
return this.request(DEFILLAMA_HOSTS.stablecoins, "/stablecoinprices");
|
|
181
|
+
}
|
|
182
|
+
// ---------------------------------------------------------------------------
|
|
183
|
+
// Yields / APY
|
|
184
|
+
// ---------------------------------------------------------------------------
|
|
185
|
+
/** GET /pools — latest data for all yield pools. */
|
|
186
|
+
async getPools() {
|
|
187
|
+
return this.request(DEFILLAMA_HOSTS.yields, "/pools");
|
|
188
|
+
}
|
|
189
|
+
/** GET /chart/{pool} — historical APY and TVL for a pool. */
|
|
190
|
+
async getPoolChart(pool) {
|
|
191
|
+
if (!pool) {
|
|
192
|
+
throw new Error("Pool ID is required");
|
|
193
|
+
}
|
|
194
|
+
return this.request(DEFILLAMA_HOSTS.yields, `/chart/${pool}`);
|
|
195
|
+
}
|
|
196
|
+
// ---------------------------------------------------------------------------
|
|
197
|
+
// DEX / Options volume
|
|
198
|
+
// ---------------------------------------------------------------------------
|
|
199
|
+
/** GET /overview/dexs — DEX volume overview across all chains. */
|
|
200
|
+
async getDexsOverview(options = {}) {
|
|
201
|
+
return this.request(DEFILLAMA_HOSTS.api, "/overview/dexs", { ...options });
|
|
202
|
+
}
|
|
203
|
+
/** GET /overview/dexs/{chain} — DEX volume overview for a chain. */
|
|
204
|
+
async getDexsOverviewByChain(chain, options = {}) {
|
|
205
|
+
if (!chain) {
|
|
206
|
+
throw new Error("Chain name is required");
|
|
207
|
+
}
|
|
208
|
+
return this.request(DEFILLAMA_HOSTS.api, `/overview/dexs/${chain}`, { ...options });
|
|
209
|
+
}
|
|
210
|
+
/** GET /summary/dexs/{protocol} — DEX volume summary for a protocol. */
|
|
211
|
+
async getDexSummary(protocol, options = {}) {
|
|
212
|
+
if (!protocol) {
|
|
213
|
+
throw new Error("Protocol name is required");
|
|
214
|
+
}
|
|
215
|
+
return this.request(DEFILLAMA_HOSTS.api, `/summary/dexs/${protocol}`, { ...options });
|
|
216
|
+
}
|
|
217
|
+
/** GET /overview/options — options volume overview across all chains. */
|
|
218
|
+
async getOptionsOverview(options = {}) {
|
|
219
|
+
return this.request(DEFILLAMA_HOSTS.api, "/overview/options", { ...options });
|
|
220
|
+
}
|
|
221
|
+
/** GET /overview/options/{chain} — options volume overview for a chain. */
|
|
222
|
+
async getOptionsOverviewByChain(chain, options = {}) {
|
|
223
|
+
if (!chain) {
|
|
224
|
+
throw new Error("Chain name is required");
|
|
225
|
+
}
|
|
226
|
+
return this.request(DEFILLAMA_HOSTS.api, `/overview/options/${chain}`, { ...options });
|
|
227
|
+
}
|
|
228
|
+
/** GET /summary/options/{protocol} — options volume summary for a protocol. */
|
|
229
|
+
async getOptionSummary(protocol, options = {}) {
|
|
230
|
+
if (!protocol) {
|
|
231
|
+
throw new Error("Protocol name is required");
|
|
232
|
+
}
|
|
233
|
+
return this.request(DEFILLAMA_HOSTS.api, `/summary/options/${protocol}`, { ...options });
|
|
234
|
+
}
|
|
235
|
+
// ---------------------------------------------------------------------------
|
|
236
|
+
// Perps / Open interest
|
|
237
|
+
// ---------------------------------------------------------------------------
|
|
238
|
+
/** GET /overview/open-interest — perps open interest overview. */
|
|
239
|
+
async getOpenInterestOverview(options = {}) {
|
|
240
|
+
return this.request(DEFILLAMA_HOSTS.api, "/overview/open-interest", { ...options });
|
|
241
|
+
}
|
|
242
|
+
// ---------------------------------------------------------------------------
|
|
243
|
+
// Fees / Revenue
|
|
244
|
+
// ---------------------------------------------------------------------------
|
|
245
|
+
/** GET /overview/fees — fees/revenue overview across all chains. */
|
|
246
|
+
async getFeesOverview(options = {}) {
|
|
247
|
+
return this.request(DEFILLAMA_HOSTS.api, "/overview/fees", { ...options });
|
|
248
|
+
}
|
|
249
|
+
/** GET /overview/fees/{chain} — fees/revenue overview for a chain. */
|
|
250
|
+
async getFeesOverviewByChain(chain, options = {}) {
|
|
251
|
+
if (!chain) {
|
|
252
|
+
throw new Error("Chain name is required");
|
|
253
|
+
}
|
|
254
|
+
return this.request(DEFILLAMA_HOSTS.api, `/overview/fees/${chain}`, { ...options });
|
|
255
|
+
}
|
|
256
|
+
/** GET /summary/fees/{protocol} — fees/revenue summary for a protocol. */
|
|
257
|
+
async getFeeSummary(protocol, options = {}) {
|
|
258
|
+
if (!protocol) {
|
|
259
|
+
throw new Error("Protocol name is required");
|
|
212
260
|
}
|
|
261
|
+
return this.request(DEFILLAMA_HOSTS.api, `/summary/fees/${protocol}`, { ...options });
|
|
213
262
|
}
|
|
214
263
|
}
|
|
215
264
|
// Export a singleton instance for use throughout the application
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defillama.client.js","sourceRoot":"","sources":["../../src/clients/defillama.client.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"defillama.client.js","sourceRoot":"","sources":["../../src/clients/defillama.client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,GAAG,EAAE,sBAAsB;IAC3B,KAAK,EAAE,wBAAwB;IAC/B,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,EAAE,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;IACtF,CAAC;IAED,sEAAsE;IACtE,KAAK,CAAC,sBAAsB,CAAC,KAAa,EAAE,UAA2B,EAAE;QACvE,IAAI,CAAC,KAAK,EAAE,CAAC;YACX,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAC;QAC5C,CAAC;QACD,OAAO,IAAI,CAAC,OAAO,CAAU,eAAe,CAAC,GAAG,EAAE,kBAAkB,KAAK,EAAE,EAAE,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;IAC/F,CAAC;IAED,0EAA0E;IAC1E,KAAK,CAAC,aAAa,CAAC,QAAgB,EAAE,UAA2B,EAAE;QACjE,IAAI,CAAC,QAAQ,EAAE,CAAC;YACd,MAAM,IAAI,KAAK,CAAC,2BAA2B,CAAC,CAAC;QAC/C,CAAC;QACD,OAAO,IAAI,CAAC,OAAO,CAAU,eAAe,CAAC,GAAG,EAAE,iBAAiB,QAAQ,EAAE,EAAE,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;IACjG,CAAC;CACF;AAED,iEAAiE;AACjE,MAAM,CAAC,MAAM,eAAe,GAAG,IAAI,eAAe,EAAE,CAAC"}
|
|
@@ -2,9 +2,13 @@
|
|
|
2
2
|
* Mock DefiLlama API Client for testing
|
|
3
3
|
* Provides mock implementations of the DefiLlama API methods
|
|
4
4
|
*/
|
|
5
|
-
import { DefiLlamaClient, Protocol, ProtocolTvl, ChainTvlItem, TokenPricesResponse, StablecoinsResponse, StablecoinData } from "./defillama.client.js";
|
|
5
|
+
import { DefiLlamaClient, Protocol, ProtocolTvl, ChainTvlItem, TokenPricesResponse, StablecoinsResponse, StablecoinData, QueryParams } from "./defillama.client.js";
|
|
6
6
|
export declare class MockDefiLlamaClient extends DefiLlamaClient {
|
|
7
|
-
|
|
7
|
+
/**
|
|
8
|
+
* Generic stub for every endpoint that isn't given a bespoke mock below.
|
|
9
|
+
* Keeps test mode (TEST_MODE=true) fully offline for the newer endpoints.
|
|
10
|
+
*/
|
|
11
|
+
protected request<T>(host: string, path: string, _query?: QueryParams): Promise<T>;
|
|
8
12
|
/**
|
|
9
13
|
* Mock implementation of getProtocols
|
|
10
14
|
*/
|
|
@@ -4,8 +4,12 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import { DefiLlamaClient } from "./defillama.client.js";
|
|
6
6
|
export class MockDefiLlamaClient extends DefiLlamaClient {
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
/**
|
|
8
|
+
* Generic stub for every endpoint that isn't given a bespoke mock below.
|
|
9
|
+
* Keeps test mode (TEST_MODE=true) fully offline for the newer endpoints.
|
|
10
|
+
*/
|
|
11
|
+
async request(host, path, _query) {
|
|
12
|
+
return { mock: true, host, path };
|
|
9
13
|
}
|
|
10
14
|
/**
|
|
11
15
|
* Mock implementation of getProtocols
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defillama.mock.client.js","sourceRoot":"","sources":["../../src/clients/defillama.mock.client.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACL,eAAe,
|
|
1
|
+
{"version":3,"file":"defillama.mock.client.js","sourceRoot":"","sources":["../../src/clients/defillama.mock.client.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACL,eAAe,EAQhB,MAAM,uBAAuB,CAAC;AAE/B,MAAM,OAAO,mBAAoB,SAAQ,eAAe;IACtD;;;OAGG;IACO,KAAK,CAAC,OAAO,CAAI,IAAY,EAAE,IAAY,EAAE,MAAoB;QACzE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAkB,CAAC;IACpD,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,YAAY;QAChB,OAAO;YACL;gBACE,EAAE,EAAE,GAAG;gBACP,IAAI,EAAE,iBAAiB;gBACvB,MAAM,EAAE,KAAK;gBACb,GAAG,EAAE,UAAU;gBACf,KAAK,EAAE,UAAU;gBACjB,QAAQ,EAAE,SAAS;g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F;SACF,CAAC;IACJ,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,iBAAiB,CAAC,KAAa;QACnC,IAAI,CAAC,KAAK,EAAE,CAAC;YACX,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAC;QAC5C,CAAC;QAED,MAAM,WAAW,GAAG,IAAI,IAAI,EAAE,CAAC;QAE/B,OAAO;YACL,EAAE,EAAE,KAAK;YACT,IAAI,EAAE,QAAQ,KAAK,EAAE;YACrB,MAAM,EAAE,KAAK,CAAC,WAAW,EAAE;YAC3B,KAAK,EAAE,GAAG;YACV,WAAW,EAAE;gBACX,SAAS,EAAE,UAAU;aACtB;YACD,gBAAgB,EAAE;gBAChB,QAAQ,EAAE;oBACR,SAAS,EAAE,SAAS;iBACrB;gBACD,OAAO,EAAE;oBACP,SAAS,EAAE,SAAS;iBACrB;aACF;YACD,OAAO,EAAE,WAAW;YACpB,WAAW,EAAE,aAAa;YAC1B,YAAY,EAAE,aAAa;YAC3B,gBAAgB,EAAE;gBAChB,SAAS,EAAE,SAAS;aACrB;YACD,kBAAkB,EAAE;gBAClB,SAAS,EAAE,SAAS;aACrB;YACD,mBAAmB,EAAE;gBACnB,SAAS,EAAE,SAAS;aACrB;YACD,QAAQ,EAAE,KAAK;SAChB,CAAC;IACJ,CAAC;CACF;AAED,iEAAiE;AACjE,MAAM,CAAC,MAAM,mBAAmB,GAAG,IAAI,mBAAmB,EAAE,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Date/time helpers.
|
|
3
|
+
*
|
|
4
|
+
* Tools accept and return human-readable 12-hour datetime strings, e.g.
|
|
5
|
+
* "06/15/2024 03:30:00 PM" (UTC assumed)
|
|
6
|
+
* "06/15/2024 03:30 PM America/New_York"
|
|
7
|
+
* "06/15/2024 03:30 PM +05:30"
|
|
8
|
+
*
|
|
9
|
+
* Input is always converted to UTC before being sent to DefiLlama (which works
|
|
10
|
+
* in UNIX seconds). Output UNIX timestamps are rendered back to UTC strings.
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* Parse a human datetime string (or UNIX seconds) into UTC UNIX seconds.
|
|
14
|
+
* Numbers and all-digit strings are treated as UNIX seconds and passed through.
|
|
15
|
+
*/
|
|
16
|
+
export declare function parseDateTimeToUnix(input: string | number): number;
|
|
17
|
+
/** Render a UNIX timestamp (seconds, or milliseconds if large) as a UTC string. */
|
|
18
|
+
export declare function formatUnixToDateTime(value: number): string;
|