@@ -20,18 +20,22 @@ import { useCampaigns } from "@metrom-xyz/react";
2020### Usage
2121
2222``` tsx
23- import { useCampaigns } from " @metrom-xyz/react" ;
23+ import { useCampaigns , CampaignType } from " @metrom-xyz/react" ;
2424
2525function App() {
26- const { isLoading, data } = useCampaigns ();
26+ const { isLoading, data } = useCampaigns ({
27+ page: 1 ,
28+ pageSize: 10 ,
29+ type: CampaignType .Rewards ,
30+ });
2731
2832 if (isLoading ) return <div >loading...</div >;
2933
3034 if (! data ) return <div >no campaigns</div >;
3135
3236 return (
3337 <div >
34- { data .map ((campaign ) => (
38+ { data .campaigns . map ((campaign ) => (
3539 <div key = { campaign .id } >
3640 <p >{ campaign .chainId } </p >
3741 <p >{ campaign .from } </p >
@@ -49,68 +53,160 @@ function App() {
4953import { type UseCampaignsParams } from " @metrom-xyz/react" ;
5054```
5155
52- #### status
56+ #### page, pageSize
5357
54- ` CampaignStatus | undefined `
58+ ` number `
5559
56- Optional campaign status to filter for. Defaults to ` undefined ` .
60+ Required campaigns pagination information .
5761
5862``` tsx
5963import { useCampaigns , CampaignStatus } from " @metrom-xyz/react" ;
6064
6165function App() {
6266 const { isLoading, data } = useCampaigns ({
63- status: CampaignStatus .Active ,
67+ page: 1 ,
68+ pageSize: 10 ,
6469 });
6570}
6671```
6772
68- #### owner
73+ #### type
6974
70- ` Address | undefined `
75+ ` CampaignType `
7176
72- Optional campaign owner to filter for; the owner can be different from the
73- campaign creator if the ownership was transferred. Defaults to ` undefined ` .
77+ Required campaigns type to filter for. Metrom currently supports ` rewards ` and
78+ ` points ` campaigns .
7479
7580``` tsx
76- import { useCampaigns } from " @metrom-xyz/react" ;
81+ import { useCampaigns , CampaignType } from " @metrom-xyz/react" ;
7782
7883function App() {
7984 const { isLoading, data } = useCampaigns ({
80- owner: " 0x0000000000000000000000000000000000000000" ,
85+ page: 1 ,
86+ pageSize: 10 ,
87+ type: CampaignType .Rewards ,
8188 });
8289}
8390```
8491
85- #### chainId
92+ #### chainIds
8693
87- ` number | undefined `
94+ ` number[] | undefined `
8895
89- Optional campaign chain id to filter for; the chain id is where the campaign
96+ Optional campaign chain ids to filter for; the chain id is where the campaign
9097lives in. Defaults to ` undefined ` .
9198
9299``` tsx
93100import { useCampaigns } from " @metrom-xyz/react" ;
94101
95102function App() {
96103 const { isLoading, data } = useCampaigns ({
97- chainId: 1 ,
104+ page: 1 ,
105+ pageSize: 10 ,
106+ type: CampaignType .Rewards ,
107+ chainIds: [1 ],
98108 });
99109}
100110```
101111
102- #### dex
112+ #### chainTypes
103113
104- ` SupportedDex | undefined`
114+ ` ChainType[] | undefined`
105115
106- Optional campaign targeted dex. Defaults to ` undefined ` .
116+ Optional chain types to filter for; the chain type is where the campaign lives
117+ in. Defaults to ` undefined ` .
118+
119+ ``` tsx
120+ import { useCampaigns , ChainType } from " @metrom-xyz/react" ;
121+
122+ function App() {
123+ const { isLoading, data } = useCampaigns ({
124+ page: 1 ,
125+ pageSize: 10 ,
126+ type: CampaignType .Rewards ,
127+ chainTypes: [ChainType .Evm ],
128+ });
129+ }
130+ ```
131+
132+ #### protocols
133+
134+ ` SupportedProtocol[] | undefined `
135+
136+ Optional protocols to filter for; the protocol is the one targeted by the
137+ campaign. Defaults to ` undefined ` . Protocols can be any of the supported types
138+ ` SupportedDex | SupportedLiquityV2 | SupportedAaveV3 | SupportedBridge | SupportedGmxV1 ` .
107139
108140``` tsx
109141import { useCampaigns , SupportedDex } from " @metrom-xyz/react" ;
110142
111143function App() {
112144 const { isLoading, data } = useCampaigns ({
113- dex: SupportedDex .UniswapV3 ,
145+ page: 1 ,
146+ pageSize: 10 ,
147+ type: CampaignType .Rewards ,
148+ protocols: [SupportedDex .UniswapV3 ],
149+ });
150+ }
151+ ```
152+
153+ #### statuses
154+
155+ ` CampaignStatus[] | undefined `
156+
157+ Optional statues to filter for. Defaults to ` undefined ` .
158+
159+ ``` tsx
160+ import { useCampaigns , CampaignStatus } from " @metrom-xyz/react" ;
161+
162+ function App() {
163+ const { isLoading, data } = useCampaigns ({
164+ page: 1 ,
165+ pageSize: 10 ,
166+ type: CampaignType .Rewards ,
167+ statuses: [CampaignStatus .Active , CampaignStatus .Upcoming ],
168+ });
169+ }
170+ ```
171+
172+ #### orderBy
173+
174+ ` CampaignOrderBy | undefined `
175+
176+ An optional field that specifies how to sort the results; sorting by
177+ ` CampaignOrderBy.Apr ` is supported only for ` rewards ` campaigns. Defaults
178+ ` undefined ` .
179+
180+ ``` tsx
181+ import { useCampaigns , CampaignOrderBy } from " @metrom-xyz/react" ;
182+
183+ function App() {
184+ const { isLoading, data } = useCampaigns ({
185+ page: 1 ,
186+ pageSize: 10 ,
187+ type: CampaignType .Rewards ,
188+ orderBy: CampaignOrderBy .Apr ,
189+ });
190+ }
191+ ```
192+
193+ #### asc
194+
195+ ` boolean | undefined `
196+
197+ An optional field that specifies the sort direction of the results; Defaults
198+ ` undefined ` .
199+
200+ ``` tsx
201+ import { useCampaigns } from " @metrom-xyz/react" ;
202+
203+ function App() {
204+ const { isLoading, data } = useCampaigns ({
205+ page: 1 ,
206+ pageSize: 10 ,
207+ type: CampaignType .Rewards ,
208+ orderBy: CampaignOrderBy .Apr ,
209+ asc: false ,
114210 });
115211}
116212```
@@ -125,8 +221,16 @@ import { type UseCampaignsReturnValue } from "@metrom-xyz/react";
125221
126222#### data
127223
128- ` Campaign[] | undefined `
224+ ` PaginatedCampaigns | undefined `
225+
226+ ``` ts
227+ interface PaginatedCampaigns {
228+ totalItems: number ;
229+ campaigns: Campaign [];
230+ }
231+ ```
129232
130- List of fetched campaigns. Defaults to ` undefiend ` .
233+ Paginated list of fetched campaigns, and the total items count. Defaults to
234+ ` undefiend ` .
131235
132236<QueryResult />
0 commit comments