@merkl/api 0.17.11 → 0.17.13
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.
@@ -614,9 +614,7 @@ export async function CLAMMDynamicData(chainId, campaigns) {
|
|
614
614
|
}
|
615
615
|
positions?.[pool.amm]?.forEach(pos => {
|
616
616
|
if (pos.pool.id === pool.address.toLowerCase() &&
|
617
|
-
(isWhitelisted(pos.owner, c.campaignParameters.whitelist) || isStrykeCampaign(pool.amm))
|
618
|
-
// pool.alms.filter(a => a.owner === pos.owner || a.address === pos.owner).length > 0) // should be removed
|
619
|
-
) {
|
617
|
+
(isWhitelisted(pos.owner, c.campaignParameters.whitelist) || isStrykeCampaign(pool.amm))) {
|
620
618
|
let [amount0, amount1] = [BigNumber.from(0), BigNumber.from(0)];
|
621
619
|
try {
|
622
620
|
[amount0, amount1] = getAmountsForLiquidity(sqrtPrice, Number.parseInt(pos.tickLower), Number.parseInt(pos.tickUpper), BigNumber.from(pos.liquidity));
|
@@ -631,6 +629,38 @@ export async function CLAMMDynamicData(chainId, campaigns) {
|
|
631
629
|
: BN2Number(amount0, decimalsToken0) > 0 && BN2Number(amount1, decimalsToken1) > 0)
|
632
630
|
blacklistedLiquidity -= BN2Number(pos.liquidity);
|
633
631
|
}
|
632
|
+
// Handling the case of a ALM of priority 2 being whitelisted
|
633
|
+
else if (pos.pool.id === pool.address.toLowerCase() &&
|
634
|
+
almDetails.map(a => a.target.toLowerCase()).includes(pos.owner.toLowerCase()) // If pos owner is an ALM
|
635
|
+
) {
|
636
|
+
// If we're in this branch it means the ALM owning the position is not whitelisted
|
637
|
+
const almHolding = almDetails.filter(a => a.almAddress.toLowerCase() === pos.owner.toLowerCase())[0];
|
638
|
+
for (const whitelistedAddress of c.campaignParameters.whitelist) {
|
639
|
+
const forwarderIndex = distributionForwarders.findIndex(f => utils.getAddress(f.almAddress) === utils.getAddress(whitelistedAddress));
|
640
|
+
if (forwarderIndex !== -1 &&
|
641
|
+
almHolding.almAddress.toLowerCase() ===
|
642
|
+
distributionForwarders[forwarderIndex].target.toLowerCase()) {
|
643
|
+
// If we are here it means one of the ALM whitelisted is a "child" of the ALM holding the position
|
644
|
+
const childALM = distributionForwarders[forwarderIndex];
|
645
|
+
let [amount0, amount1] = [BigNumber.from(0), BigNumber.from(0)];
|
646
|
+
try {
|
647
|
+
[amount0, amount1] = getAmountsForLiquidity(sqrtPrice, Number.parseInt(pos.tickLower), Number.parseInt(pos.tickUpper), BigNumber.from(pos.liquidity));
|
648
|
+
}
|
649
|
+
catch {
|
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}`);
|
651
|
+
}
|
652
|
+
blacklistedBalance0 -=
|
653
|
+
(BN2Number(amount0, decimalsToken0) * childALM.almBalance0) / almHolding.almBalance0;
|
654
|
+
blacklistedBalance1 -=
|
655
|
+
(BN2Number(amount1, decimalsToken1) * childALM.almBalance1) / almHolding.almBalance1;
|
656
|
+
if (c.campaignParameters.isOutOfRangeIncentivized
|
657
|
+
? BN2Number(amount0, decimalsToken0) > 0 || BN2Number(amount1, decimalsToken1) > 0
|
658
|
+
: BN2Number(amount0, decimalsToken0) > 0 && BN2Number(amount1, decimalsToken1) > 0)
|
659
|
+
blacklistedLiquidity -=
|
660
|
+
(BN2Number(pos.liquidity) * childALM.almTotalLiquidity) / almHolding.almTotalLiquidity;
|
661
|
+
}
|
662
|
+
}
|
663
|
+
}
|
634
664
|
});
|
635
665
|
}
|
636
666
|
else if (c.campaignParameters.blacklist.length > 0) {
|
@@ -3,7 +3,7 @@ export declare abstract class CacheService {
|
|
3
3
|
private static encoder;
|
4
4
|
private static decoder;
|
5
5
|
static wrap<Fn extends (...args: Args) => Promise<unknown>, Args extends unknown[], T extends Awaited<ReturnType<Fn>>>(ttl: number, fn: Fn, ...args: Args): Promise<T>;
|
6
|
-
static keyAndTTL<Fn extends (...args: Args) => Promise<unknown>, Args extends unknown[]
|
6
|
+
static keyAndTTL<Fn extends (...args: Args) => Promise<unknown>, Args extends unknown[]>(fn: Fn, ...args: Args): Promise<[string, number]>;
|
7
7
|
static set<Fn extends (...args: Args) => Promise<unknown>, Args extends unknown[], T extends Awaited<ReturnType<Fn>>>(ttl: number, fn: Fn, ...args: Args): Promise<T>;
|
8
8
|
static get<Fn extends (...args: Args) => Promise<unknown>, Args extends unknown[], T extends Awaited<ReturnType<Fn>>>(fn: Fn, args: Args): Promise<T | null>;
|
9
9
|
}
|
@@ -15,7 +15,7 @@ export class OpportunityConvertorService {
|
|
15
15
|
campaignSubType: campaign.subType ?? 0,
|
16
16
|
campaignType,
|
17
17
|
chainId: campaign.distributionChain?.id ?? 0,
|
18
|
-
creator: campaign.
|
18
|
+
creator: campaign.creator.address,
|
19
19
|
index: 0, // DEPRECATED
|
20
20
|
mainParameter: opportunity.identifier,
|
21
21
|
endTimestamp: Number(campaign.endTimestamp),
|