@merkl/api 0.20.41 → 0.20.43
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/dist/src/eden/index.d.ts +15 -63
- package/dist/src/engine/dynamicData/implementations/Erc20.js +5 -2
- package/dist/src/engine/dynamicData/implementations/EventBased.js +9 -9
- package/dist/src/index.d.ts +3 -15
- package/dist/src/modules/v4/campaign/campaign.service.js +5 -1
- package/dist/src/modules/v4/coingecko/coingecko.model.d.ts +0 -0
- package/dist/src/modules/v4/coingecko/coingecko.model.js +1 -0
- package/dist/src/modules/v4/coingecko/coingecko.repository.d.ts +14 -0
- package/dist/src/modules/v4/coingecko/coingecko.repository.js +9 -0
- package/dist/src/modules/v4/coingecko/coingecko.service.d.ts +16 -0
- package/dist/src/modules/v4/coingecko/coingecko.service.js +65 -0
- package/dist/src/modules/v4/programPayload/programPayload.service.d.ts +2 -1
- package/dist/src/modules/v4/programPayload/programPayload.service.js +21 -7
- package/dist/src/modules/v4/router.d.ts +3 -15
- package/dist/src/modules/v4/token/token.controller.d.ts +3 -15
- package/dist/src/modules/v4/token/token.controller.js +0 -5
- package/dist/src/modules/v4/token/token.model.d.ts +1 -0
- package/dist/src/modules/v4/token/token.model.js +1 -0
- package/dist/src/modules/v4/token/token.repository.js +1 -0
- package/dist/src/modules/v4/token/token.service.d.ts +1 -2
- package/dist/src/modules/v4/token/token.service.js +21 -37
- package/dist/src/scripts/fill-coingecko-data.d.ts +1 -0
- package/dist/src/scripts/fill-coingecko-data.js +3 -0
- package/dist/tsconfig.package.tsbuildinfo +1 -1
- package/package.json +1 -1
@@ -31,6 +31,7 @@ export const GetTokenQueryDto = t.Object({
|
|
31
31
|
verified: t.Optional(t.Boolean()),
|
32
32
|
test: t.Optional(t.Boolean()),
|
33
33
|
missingIcons: t.Optional(t.Boolean()),
|
34
|
+
missingPrice: t.Optional(t.Boolean()),
|
34
35
|
});
|
35
36
|
export const TokenDto = t.Object({
|
36
37
|
address: t.String(),
|
@@ -30,6 +30,7 @@ export class TokenRepository {
|
|
30
30
|
verified: query.verified ? { equals: query.verified } : undefined,
|
31
31
|
isTest: query.test ? { equals: query.test } : undefined,
|
32
32
|
icon: query.missingIcons ? { equals: "" } : undefined,
|
33
|
+
price: query.missingPrice ? { equals: null } : undefined,
|
33
34
|
},
|
34
35
|
};
|
35
36
|
}
|
@@ -56,7 +56,6 @@ export declare abstract class TokenService {
|
|
56
56
|
balance: bigint;
|
57
57
|
})[]>;
|
58
58
|
static fetchOnChain(token: TokenModel): Promise<Omit<Token["model"], "id">>;
|
59
|
-
static tryToFillWithCoingeckoIcons(): Promise<void>;
|
60
59
|
static fetchManyOnChain(chainId: ChainId, addresses: string[]): Promise<{
|
61
60
|
[address: string]: Omit<{
|
62
61
|
symbol: string;
|
@@ -256,7 +255,7 @@ export declare abstract class TokenService {
|
|
256
255
|
isPoint: boolean;
|
257
256
|
isNative: boolean;
|
258
257
|
price: number | null;
|
259
|
-
}
|
258
|
+
}>;
|
260
259
|
/**
|
261
260
|
* @deprecated Should be useless now that the token list is not used anymore
|
262
261
|
* Get all tokens from https://github.com/AngleProtocol/angle-token-list and override icons from it
|
@@ -10,6 +10,7 @@ import { apiDbClient } from "@db";
|
|
10
10
|
import { Prisma } from "@db/api";
|
11
11
|
import { ChainInteractionService, DistributionCreatorService, NETWORK_LABELS, bigIntToNumber, } from "@sdk";
|
12
12
|
import { getAddress, parseUnits } from "viem";
|
13
|
+
import { CoingeckoService } from "../coingecko/coingecko.service";
|
13
14
|
import { TokenRepository } from "./token.repository";
|
14
15
|
export class TokenService {
|
15
16
|
static hashId(token) {
|
@@ -93,33 +94,6 @@ export class TokenService {
|
|
93
94
|
}, onchainData),
|
94
95
|
};
|
95
96
|
}
|
96
|
-
static async tryToFillWithCoingeckoIcons() {
|
97
|
-
// 1 - Find coingecko price sources
|
98
|
-
let priceSources = await PriceService.findManyPriceSources({ method: "COINGECKO" });
|
99
|
-
// 2 - Find tokens with missing logos
|
100
|
-
const missingIcons = await TokenService.findMany({ missingIcons: true });
|
101
|
-
// 3 - Do the intersection of both
|
102
|
-
priceSources = priceSources.filter(p => !!missingIcons.find(t => t.symbol === p.symbol));
|
103
|
-
log.info(`found ${priceSources.length} tokens with missing icons on coingecko.`);
|
104
|
-
// 4 - Loop through each and try to get the icon
|
105
|
-
for (const priceSource of priceSources) {
|
106
|
-
const coingeckoTicker = priceSource.args?.ticker;
|
107
|
-
if (!!coingeckoTicker) {
|
108
|
-
try {
|
109
|
-
const icon = await TokenRepository.fetchIconFromCoingeckoTicker(coingeckoTicker);
|
110
|
-
if (icon.length > 0) {
|
111
|
-
const res = await TokenRepository.updateMissingIconsPerSymbol(priceSource.symbol, icon);
|
112
|
-
log.info(`updated ${res.count} tokens with icon ${icon} ${priceSource.symbol}`);
|
113
|
-
}
|
114
|
-
}
|
115
|
-
catch (e) {
|
116
|
-
console.error(e);
|
117
|
-
}
|
118
|
-
// Avoid rate limits, wait 1 min
|
119
|
-
await new Promise(resolve => setTimeout(resolve, 60_000));
|
120
|
-
}
|
121
|
-
}
|
122
|
-
}
|
123
97
|
static async fetchManyOnChain(chainId, addresses) {
|
124
98
|
const tokens = {};
|
125
99
|
// Batch onchain calls together when multiples
|
@@ -259,11 +233,11 @@ export class TokenService {
|
|
259
233
|
}
|
260
234
|
catch (err) {
|
261
235
|
if (err instanceof Prisma.PrismaClientKnownRequestError && err.code === "P2025") {
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
236
|
+
return TokenService.format(await TokenService.fillAndCreate({
|
237
|
+
...token,
|
238
|
+
verified: false,
|
239
|
+
icon: "",
|
240
|
+
}));
|
267
241
|
}
|
268
242
|
}
|
269
243
|
throw new HttpError(`Failed to fetch or create token ${token.address} on chain ${token.chainId}.`);
|
@@ -340,14 +314,24 @@ export class TokenService {
|
|
340
314
|
* @param address
|
341
315
|
*/
|
342
316
|
static async fillAndCreate(token) {
|
317
|
+
const id = TokenService.hashId(token);
|
318
|
+
const filledData = await TokenService.fetchOnChain({ address: token.address, chainId: token.chainId });
|
343
319
|
try {
|
344
|
-
const
|
345
|
-
const
|
346
|
-
|
320
|
+
const coingeckoToken = await CoingeckoService.findList();
|
321
|
+
const coingeckoTokenData = coingeckoToken.find(t => t.symbol === filledData.symbol && t.name === filledData.name);
|
322
|
+
if (!!coingeckoTokenData) {
|
323
|
+
await CoingeckoService.createPriceSourceForSymbolIfMissing(filledData.symbol, coingeckoTokenData.id);
|
324
|
+
if (!token.icon || token.icon === "") {
|
325
|
+
const coingeckoIcon = (await CoingeckoService.findMarkets([coingeckoTokenData.id]))[0].image;
|
326
|
+
token.icon = coingeckoIcon;
|
327
|
+
log.info(`completed with coingecko icon: ${coingeckoIcon}`);
|
328
|
+
}
|
329
|
+
}
|
347
330
|
}
|
348
|
-
catch
|
349
|
-
|
331
|
+
catch {
|
332
|
+
log.warn("coingecko token autocompletion failed");
|
350
333
|
}
|
334
|
+
return await TokenRepository.upsert({ ...filledData, ...token, id });
|
351
335
|
}
|
352
336
|
/**
|
353
337
|
* @deprecated Should be useless now that the token list is not used anymore
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|