Skip to content
This repository was archived by the owner on May 15, 2025. It is now read-only.

Commit 6fa3a29

Browse files
authored
feat: add upper and lower price bond rules to liquidity profile (#146)
* feat: add upper and lower price bond rules to liquidity profile * lint
1 parent fe1b397 commit 6fa3a29

1 file changed

Lines changed: 44 additions & 2 deletions

File tree

src/modules/campaigns/hooks/useCampaignRules.tsx

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1+
import { useMerklConfig } from "@core/index.generated";
12
import { UserService } from "@core/modules/user/user.service";
23
import type { Campaign as CampaignFromApi, CampaignParams } from "@merkl/api";
34
import type { Opportunity } from "@merkl/api";
4-
import { Icon } from "dappkit";
5+
import { Group, Icon, Text, Value } from "dappkit";
56
import { useCallback, useMemo } from "react";
67
import Token from "../../token/components/element/Token";
78
import type { RuleType } from "../components/rules/Rule";
@@ -19,6 +20,7 @@ export type HookJumper = {
1920
* Formats basic metadata for a given opportunity
2021
*/
2122
export default function useCampaignRules(campaign: CampaignFromApi, opportunity?: Opportunity) {
23+
const dollarFormat = useMerklConfig(store => store.config.decimalFormat.dollar);
2224
/**
2325
* Get weighted liquidity/fees campaigns rules
2426
*/
@@ -64,6 +66,46 @@ export default function useCampaignRules(campaign: CampaignFromApi, opportunity?
6466
},
6567
});
6668

69+
if (!!params.upperPriceBond)
70+
arr.push({
71+
type: "liquidity",
72+
value: {
73+
description:
74+
"Only positions with an upper tick price below a fixed threshold are eligible for rewards. This rule sets a hard price ceiling for eligible positions: positions extending above this level do not qualify for rewards. Example: If the threshold is $1,050, only positions with an upper bound of $1,050 or lower are eligible.A position from $980 to $1,040 qualifies; one from $990 to $1,080 does not.",
75+
label: (
76+
<Group size="sm">
77+
<Icon remix="RiDiscountPercentFill" />
78+
<Text size={"xs"} look="bold">
79+
Upper Price Bound
80+
</Text>
81+
<Value format={dollarFormat} size="xs" className="font-bold">
82+
{params.upperPriceBond / 1000}
83+
</Value>
84+
</Group>
85+
),
86+
},
87+
});
88+
89+
if (!!params.lowerPriceBond)
90+
arr.push({
91+
type: "liquidity",
92+
value: {
93+
description:
94+
"Only positions with a lower tick price above a fixed threshold are eligible. This rule sets a hard price floor for eligible positions: positions extending below this level do not qualify for rewards. Example: If the threshold is $0.50, only positions with a lower bound of $0.50 or higher are eligible.A position from $0.60 to $1.10 qualifies; one from $0.30 to $1.00 does not.",
95+
label: (
96+
<Group size="sm">
97+
<Icon remix="RiDiscountPercentFill" />
98+
<Text size={"xs"} look="bold">
99+
Lower Price Bound
100+
</Text>
101+
<Value format={dollarFormat} size="xs" className="font-bold">
102+
{params.lowerPriceBond / 1000}
103+
</Value>
104+
</Group>
105+
),
106+
},
107+
});
108+
67109
//token weight rules
68110
for (const tokenIndex of [0, 1]) {
69111
const token =
@@ -106,7 +148,7 @@ export default function useCampaignRules(campaign: CampaignFromApi, opportunity?
106148

107149
return arr;
108150
},
109-
[opportunity],
151+
[opportunity, dollarFormat],
110152
);
111153

112154
/**

0 commit comments

Comments
 (0)