@merkl/api 0.18.7 → 0.18.9
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.
@@ -23,14 +23,16 @@ export async function getUniswapV4Pools() {
|
|
23
23
|
log.info(`found ${storedPoolsPerChain.length} already stored pools on ${NETWORK_LABELS[chainId]}`);
|
24
24
|
let fromBlock;
|
25
25
|
if (storedPoolsPerChain.length > 0) {
|
26
|
-
fromBlock = Math.max(...
|
26
|
+
fromBlock = Math.max(...storedPoolsPerChain.map(x => x.fetchAtBlock)) + 1;
|
27
27
|
}
|
28
28
|
else {
|
29
29
|
fromBlock = await getContractCreationBlock(poolManagerAddress, jsonRPCprovider);
|
30
30
|
}
|
31
31
|
const toBlock = await jsonRPCprovider.getBlockNumber();
|
32
32
|
const logs = await safeFetchLogs(chainId, // TODO: rm type enforcing
|
33
|
-
[UniswapV4PoolManagerInterface.getEventTopic("Initialize")], [poolManagerAddress], fromBlock, toBlock
|
33
|
+
[UniswapV4PoolManagerInterface.getEventTopic("Initialize")], [poolManagerAddress], fromBlock, toBlock
|
34
|
+
// fromBlock + 10_000
|
35
|
+
);
|
34
36
|
const decodedPools = await Promise.all(logs.map(async (log) => {
|
35
37
|
const [id, currency0, currency1, fee, tickSpacing, hooks] = UniswapV4PoolManagerInterface.decodeEventLog("Initialize", log.data, log.topics);
|
36
38
|
// Respect typing
|
@@ -78,6 +80,9 @@ export async function getUniswapV4Pools() {
|
|
78
80
|
if (pool.currency0 !== NULL_ADDRESS) {
|
79
81
|
try {
|
80
82
|
symbolCurrency0 = ERC20Interface.decodeFunctionResult("symbol", resCurrencies[index].returnData)[0];
|
83
|
+
if (symbolCurrency0.includes("/") || symbolCurrency0.includes("\u0000")) {
|
84
|
+
symbolCurrency0 = "INVALID";
|
85
|
+
}
|
81
86
|
decimalsCurrency0 = ERC20Interface.decodeFunctionResult("decimals", resCurrencies[index + 1].returnData)[0];
|
82
87
|
}
|
83
88
|
catch {
|
@@ -94,6 +99,9 @@ export async function getUniswapV4Pools() {
|
|
94
99
|
if (pool.currency1 !== NULL_ADDRESS) {
|
95
100
|
try {
|
96
101
|
symbolCurrency1 = ERC20Interface.decodeFunctionResult("symbol", resCurrencies[index + 2].returnData)[0];
|
102
|
+
if (symbolCurrency1.includes("/") || symbolCurrency1.includes("\u0000")) {
|
103
|
+
symbolCurrency1 = "INVALID";
|
104
|
+
}
|
97
105
|
decimalsCurrency1 = ERC20Interface.decodeFunctionResult("decimals", resCurrencies[index + 3].returnData)[0];
|
98
106
|
}
|
99
107
|
catch {
|
@@ -135,24 +143,27 @@ export async function getUniswapV4Pools() {
|
|
135
143
|
});
|
136
144
|
// Update the API database
|
137
145
|
const tableData = Object.values(pools).flatMap(pools => Object.values(pools));
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
146
|
+
for (const chainId of UNIV4_CHAINIDS) {
|
147
|
+
if (tableData.filter(p => p.chainId === chainId).length > 0) {
|
148
|
+
try {
|
149
|
+
await apiDbClient.logged.createMany({
|
150
|
+
data: tableData
|
151
|
+
.filter(point => point.chainId === chainId)
|
152
|
+
.map(pool => ({
|
153
|
+
fetchAtBlock: pool.fetchedAtBlock,
|
154
|
+
caughtFromAddress: UniswapV4Addresses[pool.chainId]?.PoolManager ?? NULL_ADDRESS,
|
155
|
+
chainId: pool.chainId,
|
156
|
+
entityData: pool,
|
157
|
+
id: Bun.hash(`${pool.poolId}-${pool.chainId}`).toString(),
|
158
|
+
type: LoggedEntityType.UNISWAP_V4,
|
159
|
+
})),
|
160
|
+
});
|
161
|
+
log.info(`✅ successfully saved vaults to API database ('Logged' table) on ${NETWORK_LABELS[chainId]}`);
|
162
|
+
}
|
163
|
+
catch (e) {
|
164
|
+
log.error("getUniswapV4Pools/LoggedTableUpdate", e);
|
165
|
+
throw new Error(`Error while saving UniV4 pools to API database ('Logged' table) on ${NETWORK_LABELS[chainId]}`);
|
166
|
+
}
|
156
167
|
}
|
157
168
|
}
|
158
169
|
log.info(`✅ successfully fetched ${tableData.length} new pool(s) on UniswapV4`);
|
@@ -261,13 +261,13 @@ export class TokenService {
|
|
261
261
|
const icon = properties.Icon.files?.[0]?.file.url;
|
262
262
|
const iconFile = await fetch(icon);
|
263
263
|
const mimeType = iconFile.headers.get("content-type");
|
264
|
-
const extension = mimeType.split("/")[1];
|
264
|
+
const extension = mimeType.split("/")[1].split("+")[0];
|
265
265
|
const address = throwOnInvalidRequiredAddress(properties.Address.rich_text[0].plain_text);
|
266
266
|
const chainId = properties["Chain ID"].number;
|
267
267
|
throwOnUnsupportedChainId(chainId);
|
268
268
|
const displaySymbol = properties.Symbol.rich_text[0]?.plain_text;
|
269
269
|
const isVerified = properties.Verified.checkbox;
|
270
|
-
const coingeckoApiId = properties["CoinGecko API ID"].rich_text[0]
|
270
|
+
const coingeckoApiId = properties["CoinGecko API ID"].rich_text[0]?.plain_text;
|
271
271
|
const byteArray = await iconFile.bytes();
|
272
272
|
const [token] = await TokenService.findManyOrCreate([
|
273
273
|
{
|