@merkl/api 0.20.28 → 0.20.30

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.
@@ -713,15 +713,9 @@ export class ClammDynamicData {
713
713
  /**
714
714
  * General APR (@notice potentially with a boost)
715
715
  */
716
- let poolBalanceToken0WithoutBlacklist = poolBalanceToken0 - (blacklistedBalance0 ?? 0);
717
- poolBalanceToken0WithoutBlacklist = !!poolBalanceToken0WithoutBlacklist
718
- ? poolBalanceToken0WithoutBlacklist
719
- : 0.00001;
720
- let poolBalanceToken1WithoutBlacklist = poolBalanceToken1 - (blacklistedBalance1 ?? 0);
721
- poolBalanceToken1WithoutBlacklist = !!poolBalanceToken1WithoutBlacklist
722
- ? poolBalanceToken1WithoutBlacklist
723
- : 0.00001;
724
- const poolLiquidityWithoutBlacklist = poolTotalLiquidity - (blacklistedLiquidity ?? 0);
716
+ const poolBalanceToken0WithoutBlacklist = Math.max(poolBalanceToken0 - (blacklistedBalance0 ?? 0), 0.00001);
717
+ const poolBalanceToken1WithoutBlacklist = Math.max(poolBalanceToken1 - (blacklistedBalance1 ?? 0), 0.00001);
718
+ const poolLiquidityWithoutBlacklist = Math.max(poolTotalLiquidity - (blacklistedLiquidity ?? 0), 0);
725
719
  const tvl = isStrykeCampaign(amm)
726
720
  ? (await axios.get(`https://api.stryke.xyz/clamm/stats/tvl/${pool.address}?chainId=${chainId}`))
727
721
  .data
@@ -875,7 +875,7 @@ export declare abstract class OpportunityRepository {
875
875
  * @returns
876
876
  */
877
877
  static updateRecords(opportunityId: string, apr: AprRecord["model"], tvl: TvlRecord["model"], dailyRewards: DailyRewardsRecord["model"]): Promise<{
878
- aprRecord: {
878
+ aprRecord: false | {
879
879
  id: string;
880
880
  opportunityId: string;
881
881
  timestamp: bigint;
@@ -422,15 +422,16 @@ export class OpportunityRepository {
422
422
  * @returns
423
423
  */
424
424
  static async updateRecords(opportunityId, apr, tvl, dailyRewards) {
425
- const aprRecord = await apiDbClient.aprRecord.create({
426
- data: {
427
- id: AprService.hashId(opportunityId, apr.timestamp),
428
- timestamp: apr.timestamp,
429
- cumulated: apr.cumulated,
430
- Opportunity: { connect: { id: opportunityId } },
431
- AprBreakdown: { createMany: { data: apr.breakdowns } },
432
- },
433
- });
425
+ const aprRecord = apr.cumulated >= 0 &&
426
+ (await apiDbClient.aprRecord.create({
427
+ data: {
428
+ id: AprService.hashId(opportunityId, apr.timestamp),
429
+ timestamp: apr.timestamp,
430
+ cumulated: apr.cumulated,
431
+ Opportunity: { connect: { id: opportunityId } },
432
+ AprBreakdown: { createMany: { data: apr.breakdowns } },
433
+ },
434
+ }));
434
435
  const tvlRecord = await apiDbClient.tVLRecord.create({
435
436
  data: {
436
437
  id: TvlService.hashId(opportunityId, tvl.timestamp),