@merkl/api 0.16.4 → 0.16.6
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.
@@ -30,16 +30,22 @@ async function computeUniV4PoolTVLFromMostRecentStateSave(chainId, poolID, price
|
|
30
30
|
// const globalState = stateSave.globalState as { tick: number; liquidity: string };
|
31
31
|
const { fileName, bucketName } = states;
|
32
32
|
// Bucket service
|
33
|
-
const bucket = new BucketService(bucketName, "merkl-production");
|
34
|
-
const storedStates = JSON.parse(await bucket.pull(fileName));
|
35
33
|
let tvl = 0;
|
36
34
|
let amount0 = 0;
|
37
35
|
let amount1 = 0;
|
38
|
-
|
39
|
-
|
40
|
-
|
36
|
+
try {
|
37
|
+
const bucket = new BucketService(bucketName, "merkl-production");
|
38
|
+
const storedStates = JSON.parse(await bucket.pull(fileName));
|
39
|
+
for (const [_, { value, params: _params }] of Object.entries(storedStates)) {
|
40
|
+
amount0 += BN2Number(value.amount0, decimalsCurrency0);
|
41
|
+
amount1 += BN2Number(value.amount1, decimalsCurrency1);
|
42
|
+
}
|
43
|
+
tvl = amount0 * (priceCurrency0 ?? 0) + amount1 * (priceCurrency1 ?? 0);
|
44
|
+
}
|
45
|
+
catch (e) {
|
46
|
+
console.log(e);
|
47
|
+
log.warn(`merklDynamic data - failed to decode state of pool ${poolID} on ${NETWORK_LABELS[chainId]}`);
|
41
48
|
}
|
42
|
-
tvl = amount0 * (priceCurrency0 ?? 0) + amount1 * (priceCurrency1 ?? 0);
|
43
49
|
return { tvl, amount0, amount1, blockNumber: blockNumber };
|
44
50
|
}
|
45
51
|
export async function UniswapV4DynamicData(chainId, campaigns) {
|