@merkl/api 0.16.35 → 0.16.37
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/backgroundJobs/jobs/opportunityUpdater.js +2 -0
- package/dist/src/eden/index.d.ts +5 -60
- package/dist/src/index.d.ts +1 -12
- package/dist/src/modules/v4/computedValue/computedValue.controller.js +2 -2
- package/dist/src/modules/v4/dynamicData/dynamicData.controller.js +6 -6
- package/dist/src/modules/v4/opportunity/opportunity.converter.js +22 -7
- package/dist/src/modules/v4/router.d.ts +1 -12
- package/dist/src/modules/v4/token/token.controller.d.ts +1 -12
- package/dist/src/modules/v4/token/token.controller.js +3 -3
- package/dist/src/modules/v4/token/token.service.d.ts +1 -13
- package/dist/src/modules/v4/token/token.service.js +10 -3
- package/dist/src/routes/v3/opportunity.js +2 -1
- package/dist/tsconfig.package.tsbuildinfo +1 -1
- package/package.json +1 -1
@@ -54,7 +54,9 @@ export const opportunityUpdater = (app) => {
|
|
54
54
|
await Redis.safeSet("OpportunitiesWithTest", opportunitiesWithTest);
|
55
55
|
log.info("✅ opportunity cache updated successfully");
|
56
56
|
await OpportunityConvertorService.setV3Opportunities(true, false, undefined, undefined);
|
57
|
+
log.info("✅ opportunity v3 cache updated successfully");
|
57
58
|
await OpportunityConvertorService.setV3Opportunities(true, true, undefined, undefined);
|
59
|
+
log.info("✅ opportunity v3 test cache updated successfully");
|
58
60
|
return new Response(JSON.stringify({
|
59
61
|
status: "success",
|
60
62
|
all: getUpdateBreakdown(opportunities),
|
package/dist/src/eden/index.d.ts
CHANGED
@@ -1508,18 +1508,7 @@ declare const eden: {
|
|
1508
1508
|
query?: Record<string, unknown> | undefined;
|
1509
1509
|
fetch?: RequestInit | undefined;
|
1510
1510
|
}) => Promise<import("@elysiajs/eden").Treaty.TreatyResponse<{
|
1511
|
-
200:
|
1512
|
-
symbol: string;
|
1513
|
-
name: string | null;
|
1514
|
-
id: string;
|
1515
|
-
icon: string;
|
1516
|
-
chainId: number;
|
1517
|
-
address: string;
|
1518
|
-
decimals: number;
|
1519
|
-
verified: boolean;
|
1520
|
-
isTest: boolean;
|
1521
|
-
price?: number | null | undefined;
|
1522
|
-
} | undefined;
|
1511
|
+
200: void;
|
1523
1512
|
}>>;
|
1524
1513
|
};
|
1525
1514
|
count: {
|
@@ -4857,18 +4846,7 @@ declare const eden: {
|
|
4857
4846
|
query?: Record<string, unknown> | undefined;
|
4858
4847
|
fetch?: RequestInit | undefined;
|
4859
4848
|
}) => Promise<import("@elysiajs/eden").Treaty.TreatyResponse<{
|
4860
|
-
200:
|
4861
|
-
symbol: string;
|
4862
|
-
name: string | null;
|
4863
|
-
id: string;
|
4864
|
-
icon: string;
|
4865
|
-
chainId: number;
|
4866
|
-
address: string;
|
4867
|
-
decimals: number;
|
4868
|
-
verified: boolean;
|
4869
|
-
isTest: boolean;
|
4870
|
-
price?: number | null | undefined;
|
4871
|
-
} | undefined;
|
4849
|
+
200: void;
|
4872
4850
|
}>>;
|
4873
4851
|
};
|
4874
4852
|
count: {
|
@@ -9112,18 +9090,7 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
|
|
9112
9090
|
authorization: string;
|
9113
9091
|
};
|
9114
9092
|
response: {
|
9115
|
-
200:
|
9116
|
-
symbol: string;
|
9117
|
-
name: string | null;
|
9118
|
-
id: string;
|
9119
|
-
icon: string;
|
9120
|
-
chainId: number;
|
9121
|
-
address: string;
|
9122
|
-
decimals: number;
|
9123
|
-
verified: boolean;
|
9124
|
-
isTest: boolean;
|
9125
|
-
price?: number | null | undefined;
|
9126
|
-
} | undefined;
|
9093
|
+
200: void;
|
9127
9094
|
};
|
9128
9095
|
};
|
9129
9096
|
};
|
@@ -13837,18 +13804,7 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
|
|
13837
13804
|
query?: Record<string, unknown> | undefined;
|
13838
13805
|
fetch?: RequestInit | undefined;
|
13839
13806
|
}) => Promise<import("@elysiajs/eden").Treaty.TreatyResponse<{
|
13840
|
-
200:
|
13841
|
-
symbol: string;
|
13842
|
-
name: string | null;
|
13843
|
-
id: string;
|
13844
|
-
icon: string;
|
13845
|
-
chainId: number;
|
13846
|
-
address: string;
|
13847
|
-
decimals: number;
|
13848
|
-
verified: boolean;
|
13849
|
-
isTest: boolean;
|
13850
|
-
price?: number | null | undefined;
|
13851
|
-
} | undefined;
|
13807
|
+
200: void;
|
13852
13808
|
}>>;
|
13853
13809
|
};
|
13854
13810
|
count: {
|
@@ -17186,18 +17142,7 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
|
|
17186
17142
|
query?: Record<string, unknown> | undefined;
|
17187
17143
|
fetch?: RequestInit | undefined;
|
17188
17144
|
}) => Promise<import("@elysiajs/eden").Treaty.TreatyResponse<{
|
17189
|
-
200:
|
17190
|
-
symbol: string;
|
17191
|
-
name: string | null;
|
17192
|
-
id: string;
|
17193
|
-
icon: string;
|
17194
|
-
chainId: number;
|
17195
|
-
address: string;
|
17196
|
-
decimals: number;
|
17197
|
-
verified: boolean;
|
17198
|
-
isTest: boolean;
|
17199
|
-
price?: number | null | undefined;
|
17200
|
-
} | undefined;
|
17145
|
+
200: void;
|
17201
17146
|
}>>;
|
17202
17147
|
};
|
17203
17148
|
count: {
|
package/dist/src/index.d.ts
CHANGED
@@ -1745,18 +1745,7 @@ declare const app: Elysia<"", false, {
|
|
1745
1745
|
authorization: string;
|
1746
1746
|
};
|
1747
1747
|
response: {
|
1748
|
-
200:
|
1749
|
-
symbol: string;
|
1750
|
-
name: string | null;
|
1751
|
-
id: string;
|
1752
|
-
icon: string;
|
1753
|
-
chainId: number;
|
1754
|
-
address: string;
|
1755
|
-
decimals: number;
|
1756
|
-
verified: boolean;
|
1757
|
-
isTest: boolean;
|
1758
|
-
price?: number | null | undefined;
|
1759
|
-
} | undefined;
|
1748
|
+
200: void;
|
1760
1749
|
};
|
1761
1750
|
};
|
1762
1751
|
};
|
@@ -35,8 +35,8 @@ export const ComputedValueController = new Elysia({
|
|
35
35
|
.post("/engine/user", async ({ body }) => await ComputedValueService.upsertUserComputedValues(body), {
|
36
36
|
headers: AuthorizationHeadersDto,
|
37
37
|
body: UpsertUserComputedValues,
|
38
|
-
beforeHandle: ({ headers, body }) => {
|
39
|
-
EngineGuard({ headers });
|
38
|
+
beforeHandle: async ({ headers, body }) => {
|
39
|
+
await EngineGuard({ headers });
|
40
40
|
for (const item of body) {
|
41
41
|
item.address = throwOnInvalidRequiredAddress(item.address);
|
42
42
|
}
|
@@ -13,22 +13,22 @@ export const DynamicDataController = new Elysia({
|
|
13
13
|
.get("/", async ({ query }) => await DynamicDataService.queryERC20DynamicData(query.chainId, query.tokenAddress, query.decimals), {
|
14
14
|
query: DynamicDataSourceIdentifier,
|
15
15
|
headers: AuthorizationHeadersDto,
|
16
|
-
beforeHandle: ({ query, headers }) => {
|
17
|
-
BackOfficeGuard({ headers });
|
16
|
+
beforeHandle: async ({ query, headers }) => {
|
17
|
+
await BackOfficeGuard({ headers });
|
18
18
|
throwOnUnsupportedChainId(query.chainId);
|
19
19
|
},
|
20
20
|
})
|
21
21
|
.post("/from-config", async ({ body }) => await DynamicDataService.queryDynamicData(body), {
|
22
22
|
body: SimplifiedCampaignDto,
|
23
23
|
headers: AuthorizationHeadersDto,
|
24
|
-
beforeHandle: ({ headers }) => {
|
25
|
-
BackOfficeGuard({ headers });
|
24
|
+
beforeHandle: async ({ headers }) => {
|
25
|
+
await BackOfficeGuard({ headers });
|
26
26
|
},
|
27
27
|
})
|
28
28
|
.get("/from-existing", async ({ query }) => await DynamicDataService.queryDynamicDataFromManyCampaignId(query), {
|
29
29
|
query: GetCampaignQueryDto,
|
30
30
|
headers: AuthorizationHeadersDto,
|
31
|
-
beforeHandle: ({ headers }) => {
|
32
|
-
BackOfficeGuard({ headers });
|
31
|
+
beforeHandle: async ({ headers }) => {
|
32
|
+
await BackOfficeGuard({ headers });
|
33
33
|
},
|
34
34
|
});
|
@@ -130,13 +130,28 @@ export class OpportunityConvertorService {
|
|
130
130
|
};
|
131
131
|
}
|
132
132
|
static async #extractV3Opportunities(showCampaigns, test, identifier, chainId) {
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
133
|
+
let opportunities = [];
|
134
|
+
let page = 0;
|
135
|
+
while (true) {
|
136
|
+
try {
|
137
|
+
const opportunitiesPage = await OpportunityService.findMany({
|
138
|
+
items: 100, // HARDCODED LIMIT
|
139
|
+
page,
|
140
|
+
test,
|
141
|
+
identifier,
|
142
|
+
chainId,
|
143
|
+
campaigns: true,
|
144
|
+
});
|
145
|
+
console.log(page, opportunitiesPage.length);
|
146
|
+
opportunities = opportunities.concat(opportunitiesPage);
|
147
|
+
if (opportunitiesPage.length === 0)
|
148
|
+
break;
|
149
|
+
}
|
150
|
+
catch {
|
151
|
+
break;
|
152
|
+
}
|
153
|
+
page++;
|
154
|
+
}
|
140
155
|
const res = {};
|
141
156
|
for (const opportunity of opportunities) {
|
142
157
|
const opportunityV3 = OpportunityConvertorService.convertV4toV3(opportunity, showCampaigns);
|
@@ -1615,18 +1615,7 @@ export declare const v4: Elysia<"/v4", false, {
|
|
1615
1615
|
authorization: string;
|
1616
1616
|
};
|
1617
1617
|
response: {
|
1618
|
-
200:
|
1619
|
-
symbol: string;
|
1620
|
-
name: string | null;
|
1621
|
-
id: string;
|
1622
|
-
icon: string;
|
1623
|
-
chainId: number;
|
1624
|
-
address: string;
|
1625
|
-
decimals: number;
|
1626
|
-
verified: boolean;
|
1627
|
-
isTest: boolean;
|
1628
|
-
price?: number | null | undefined;
|
1629
|
-
} | undefined;
|
1618
|
+
200: void;
|
1630
1619
|
};
|
1631
1620
|
};
|
1632
1621
|
};
|
@@ -200,18 +200,7 @@ export declare const TokenController: Elysia<"/tokens", false, {
|
|
200
200
|
authorization: string;
|
201
201
|
};
|
202
202
|
response: {
|
203
|
-
200:
|
204
|
-
symbol: string;
|
205
|
-
name: string | null;
|
206
|
-
id: string;
|
207
|
-
icon: string;
|
208
|
-
chainId: number;
|
209
|
-
address: string;
|
210
|
-
decimals: number;
|
211
|
-
verified: boolean;
|
212
|
-
isTest: boolean;
|
213
|
-
price?: number | null | undefined;
|
214
|
-
} | undefined;
|
203
|
+
200: void;
|
215
204
|
};
|
216
205
|
};
|
217
206
|
};
|
@@ -52,9 +52,9 @@ export const TokenController = new Elysia({ prefix: "/tokens", detail: { tags: [
|
|
52
52
|
.post("/", async ({ body }) => await TokenService.fillAndCreate(body), {
|
53
53
|
body: CreateTokenDto,
|
54
54
|
headers: AuthorizationHeadersDto,
|
55
|
-
beforeHandle: ({ headers, body }) =>
|
56
|
-
BackOfficeGuard({ headers });
|
57
|
-
throwOnInvalidRequiredAddress(body.address);
|
55
|
+
beforeHandle: async ({ headers, body }) => {
|
56
|
+
await BackOfficeGuard({ headers });
|
57
|
+
body.address = throwOnInvalidRequiredAddress(body.address);
|
58
58
|
throwOnUnsupportedChainId(body.chainId);
|
59
59
|
},
|
60
60
|
detail: { hide: true },
|
@@ -115,19 +115,7 @@ export declare abstract class TokenService {
|
|
115
115
|
* @param chainId
|
116
116
|
* @param address
|
117
117
|
*/
|
118
|
-
static fillAndCreate(token: CreateTokenModel): Promise<
|
119
|
-
symbol: string;
|
120
|
-
name: string | null;
|
121
|
-
id: string;
|
122
|
-
icon: string;
|
123
|
-
chainId: number;
|
124
|
-
address: string;
|
125
|
-
decimals: number;
|
126
|
-
verified: boolean;
|
127
|
-
isTest: boolean;
|
128
|
-
} & {
|
129
|
-
price?: number | null | undefined;
|
130
|
-
}) | undefined>;
|
118
|
+
static fillAndCreate(token: CreateTokenModel): Promise<void>;
|
131
119
|
/**
|
132
120
|
* Read token from database
|
133
121
|
* @param chainId
|
@@ -199,9 +199,16 @@ export class TokenService {
|
|
199
199
|
* @param address
|
200
200
|
*/
|
201
201
|
static async fillAndCreate(token) {
|
202
|
-
|
203
|
-
|
204
|
-
|
202
|
+
try {
|
203
|
+
const id = TokenService.hashId(token);
|
204
|
+
const filledData = await TokenService.fetchOnChain({ address: token.address, chainId: token.chainId });
|
205
|
+
console.log(filledData);
|
206
|
+
await TokenRepository.upsert({ ...filledData, ...token, id });
|
207
|
+
}
|
208
|
+
catch (e) {
|
209
|
+
console.error(e);
|
210
|
+
}
|
211
|
+
return;
|
205
212
|
}
|
206
213
|
/**
|
207
214
|
* Read token from database
|
@@ -58,7 +58,8 @@ export default (app) => {
|
|
58
58
|
query.chainId = !query.chainId ? undefined : Number.parseInt(query.chainId.toString());
|
59
59
|
query.type = !query.type ? undefined : Number.parseInt(query.type.toString());
|
60
60
|
query.campaigns = query.campaigns === false ? false : !!query.campaigns;
|
61
|
-
query.testTokens =
|
61
|
+
query.testTokens =
|
62
|
+
query.testTokens === false || query.testTokens?.toString() === "false" ? false : !!query.testTokens;
|
62
63
|
},
|
63
64
|
query,
|
64
65
|
response: { 200: response },
|