@merkl/api 0.20.55 → 0.20.57
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.
@@ -321,13 +321,13 @@ export class ClammDynamicData {
|
|
321
321
|
for (const w of pool.alms.filter(a => a.target.toLowerCase() === pool.address.toLowerCase() && a.type !== ALM.A51)) {
|
322
322
|
const prevI = i;
|
323
323
|
try {
|
324
|
-
const totalSupply =
|
325
|
-
const almIdleBalance0 =
|
324
|
+
const totalSupply = BigNumber.from(ERC20Interface.decodeFunctionResult("totalSupply", result[i++].returnData)[0]);
|
325
|
+
const almIdleBalance0 = BigNumber.from(ERC20Interface.decodeFunctionResult("balanceOf", result[i++].returnData)[0]);
|
326
326
|
let almBalance0 = almIdleBalance0;
|
327
|
-
const almIdleBalance1 =
|
327
|
+
const almIdleBalance1 = BigNumber.from(ERC20Interface.decodeFunctionResult("balanceOf", result[i++].returnData)[0]);
|
328
328
|
let almBalance1 = almIdleBalance1;
|
329
|
-
let almTotalLiquidity = 0;
|
330
|
-
let almInRangeLiquidity = 0;
|
329
|
+
let almTotalLiquidity = BigNumber.from(0);
|
330
|
+
let almInRangeLiquidity = BigNumber.from(0);
|
331
331
|
const almPositions = positions?.[pool.amm]?.filter(pos => pos.pool.id === pool.address.toLowerCase() &&
|
332
332
|
[w.address.toLowerCase(), ...[!!w?.owner && w.owner.toLowerCase()]].includes(pos.owner.toLowerCase()));
|
333
333
|
const almPositionsWithAPIType = [];
|
@@ -336,22 +336,23 @@ export class ClammDynamicData {
|
|
336
336
|
const upperTick = Number.parseInt(position.tickUpper);
|
337
337
|
const lowerTick = Number.parseInt(position.tickLower);
|
338
338
|
const [amount0, amount1] = getAmountsForLiquidity(sqrtPrice, lowerTick, upperTick, BigNumber.from(position.liquidity));
|
339
|
-
const balance0 =
|
340
|
-
const balance1 =
|
341
|
-
const totalLiquidity =
|
342
|
-
const inRangeLiquidity = balance0 > 0 &&
|
343
|
-
almTotalLiquidity
|
344
|
-
almInRangeLiquidity
|
345
|
-
almBalance0
|
346
|
-
almBalance1
|
339
|
+
const balance0 = BigNumber.from(amount0);
|
340
|
+
const balance1 = BigNumber.from(amount1);
|
341
|
+
const totalLiquidity = BigNumber.from(position.liquidity);
|
342
|
+
const inRangeLiquidity = balance0 > BigNumber.from(0) && BigNumber.from(0) ? (BigNumber.from(position.liquidity) ?? 0) : 0;
|
343
|
+
almTotalLiquidity = almTotalLiquidity.add(totalLiquidity);
|
344
|
+
almInRangeLiquidity = almInRangeLiquidity.add(inRangeLiquidity);
|
345
|
+
almBalance0 = almBalance0.add(balance0);
|
346
|
+
almBalance1 = almBalance1.add(balance1);
|
347
347
|
almPositionsWithAPIType.push({
|
348
|
-
balance0,
|
349
|
-
balance1,
|
348
|
+
balance0: BN2Number(balance0, d.campaignParameters.decimalsToken0),
|
349
|
+
balance1: BN2Number(balance1, d.campaignParameters.decimalsToken0),
|
350
350
|
id: position.id,
|
351
|
-
inRangeLiquidity,
|
351
|
+
inRangeLiquidity: BN2Number(inRangeLiquidity),
|
352
352
|
lowerTick,
|
353
|
-
totalLiquidity,
|
354
|
-
tvl: priceToken0 * balance0 +
|
353
|
+
totalLiquidity: BN2Number(totalLiquidity),
|
354
|
+
tvl: priceToken0 * BN2Number(balance0, d.campaignParameters.decimalsToken0) +
|
355
|
+
priceToken1 * BN2Number(balance1, d.campaignParameters.decimalsToken0),
|
355
356
|
upperTick,
|
356
357
|
});
|
357
358
|
}
|
@@ -360,13 +361,14 @@ export class ClammDynamicData {
|
|
360
361
|
almDetails.push({
|
361
362
|
almAPR: 0, // filled later on
|
362
363
|
almAddress: utils.getAddress(w.address),
|
363
|
-
almBalance0,
|
364
|
-
almIdleBalance0,
|
365
|
-
almIdleBalance1,
|
366
|
-
almBalance1,
|
367
|
-
almInRangeLiquidity,
|
368
|
-
almTVL: almBalance0 * priceToken0 +
|
369
|
-
|
364
|
+
almBalance0: BN2Number(almBalance0, d.campaignParameters.decimalsToken0),
|
365
|
+
almIdleBalance0: BN2Number(almIdleBalance0, d.campaignParameters.decimalsToken0),
|
366
|
+
almIdleBalance1: BN2Number(almIdleBalance1, d.campaignParameters.decimalsToken1),
|
367
|
+
almBalance1: BN2Number(almBalance1, d.campaignParameters.decimalsToken1),
|
368
|
+
almInRangeLiquidity: BN2Number(almInRangeLiquidity),
|
369
|
+
almTVL: BN2Number(almBalance0, d.campaignParameters.decimalsToken0) * priceToken0 +
|
370
|
+
BN2Number(almBalance1, d.campaignParameters.decimalsToken1) * priceToken1,
|
371
|
+
almTotalLiquidity: BN2Number(almTotalLiquidity),
|
370
372
|
forwarderType: Forwarder.CLAMM,
|
371
373
|
label: `${ALMMapping[pool.amm]?.[w.type]} ${w.address}`,
|
372
374
|
origin: w.type,
|
@@ -375,7 +377,7 @@ export class ClammDynamicData {
|
|
375
377
|
sender: utils.getAddress(w.address),
|
376
378
|
target: w.target,
|
377
379
|
owner: utils.getAddress(w.owner ?? w.address),
|
378
|
-
totalSupply,
|
380
|
+
totalSupply: BN2Number(totalSupply),
|
379
381
|
type: w.type,
|
380
382
|
});
|
381
383
|
}
|
@@ -647,12 +649,14 @@ export class ClammDynamicData {
|
|
647
649
|
catch {
|
648
650
|
log.warn(`merklDynamic data - failed to handle whitelisted positions of pool ${pool.address} on ${NETWORK_LABELS[chainId]} - ${pos.owner} ${pos.tickLower} ${pos.tickUpper} ${pos.liquidity}`);
|
649
651
|
}
|
650
|
-
blacklistedBalance0 = blacklistedBalance0.sub((BN2Number(amount0,
|
651
|
-
blacklistedBalance1 = blacklistedBalance1.sub(BigNumber.from((BN2Number(amount1,
|
652
|
+
blacklistedBalance0 = blacklistedBalance0.sub(BigNumber.from(Math.floor((BN2Number(amount0, 0) * childALM.almBalance0) / almHolding.almBalance0)));
|
653
|
+
blacklistedBalance1 = blacklistedBalance1.sub(BigNumber.from(Math.floor((BN2Number(amount1, 0) * childALM.almBalance1) / almHolding.almBalance1)));
|
652
654
|
if (c.campaignParameters.isOutOfRangeIncentivized
|
653
655
|
? BN2Number(amount0, decimalsToken0) > 0 || BN2Number(amount1, decimalsToken1) > 0
|
654
|
-
: BN2Number(amount0, decimalsToken0) > 0 && BN2Number(amount1, decimalsToken1) > 0)
|
655
|
-
blacklistedLiquidity = blacklistedLiquidity.sub(
|
656
|
+
: BN2Number(amount0, decimalsToken0) > 0 && BN2Number(amount1, decimalsToken1) > 0) {
|
657
|
+
blacklistedLiquidity = blacklistedLiquidity.sub(BigInt(Math.floor((BN2Number(pos.liquidity, 0) * childALM.almTotalLiquidity) /
|
658
|
+
almHolding.almTotalLiquidity)));
|
659
|
+
}
|
656
660
|
}
|
657
661
|
}
|
658
662
|
}
|
@@ -50,6 +50,7 @@ export const UniswapController = new Elysia({
|
|
50
50
|
}, {
|
51
51
|
detail: {
|
52
52
|
description: "Get Uniswap V4 pools by chain",
|
53
|
+
hide: true,
|
53
54
|
},
|
54
55
|
})
|
55
56
|
.get("pools/:chainId", async ({ params }) => {
|
@@ -62,6 +63,9 @@ export const UniswapController = new Elysia({
|
|
62
63
|
},
|
63
64
|
response: t.Record(t.String(), // poolId
|
64
65
|
UniswapV4PoolDto),
|
66
|
+
detail: {
|
67
|
+
hide: true,
|
68
|
+
},
|
65
69
|
})
|
66
70
|
.get("/:poolId", async ({ params }) => {
|
67
71
|
return Object.values(await CacheService.wrap(TTLPresets.DAY_1, UniswapService.getUniswapV4Pools))
|
@@ -70,6 +74,9 @@ export const UniswapController = new Elysia({
|
|
70
74
|
}, {
|
71
75
|
params: Bytes32Dto,
|
72
76
|
response: t.Array(UniswapV4PoolDto),
|
77
|
+
detail: {
|
78
|
+
hide: true,
|
79
|
+
},
|
73
80
|
})
|
74
81
|
.post("/update", async () => {
|
75
82
|
await CacheService.set(TTLPresets.DAY_1, UniswapService.getUniswapV4Pools);
|
@@ -36,13 +36,14 @@ export class UniswapService {
|
|
36
36
|
const { opportunity: rawOpportunity, ...props } = breakdown;
|
37
37
|
const opportunity = OpportunityService.formatResponseBase(rawOpportunity);
|
38
38
|
const chainId = opportunity.chainId;
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
39
|
+
const positionId = breakdown.reason.split("_")[version === "v3" ? 1 : 2];
|
40
|
+
// There can be chain, pool and position Id filter in the request
|
41
|
+
if (!!chainId && (!query.chainId || chainId === query.chainId)) {
|
42
|
+
if (!!pool && (!query.pool || pool === query.pool)) {
|
43
|
+
if (!!positionId && (!query.positionId || positionId === query.positionId)) {
|
44
|
+
try {
|
45
|
+
res[chainId] = res[chainId] ?? {};
|
46
|
+
res[chainId][pool] = res[chainId][pool] ?? {};
|
46
47
|
res[chainId][pool][positionId] = res[chainId][pool][positionId] ?? [];
|
47
48
|
res[chainId][pool][positionId].push({
|
48
49
|
...props,
|
@@ -50,12 +51,12 @@ export class UniswapService {
|
|
50
51
|
rewardToken,
|
51
52
|
});
|
52
53
|
}
|
54
|
+
catch {
|
55
|
+
log.warn(`failed to parse positionId for reason for pool ${pool} and version ${version}`);
|
56
|
+
}
|
53
57
|
}
|
54
58
|
}
|
55
59
|
}
|
56
|
-
catch {
|
57
|
-
log.warn(`failed to parse positionId for reason for pool ${pool} and version ${version}`);
|
58
|
-
}
|
59
60
|
}
|
60
61
|
}
|
61
62
|
return res;
|