@@ -16,7 +16,11 @@ import {
1616 fetchUserReserves ,
1717 selectPoolById ,
1818} from '../../../libs/loaders/money-market' ;
19- import { paginationResponse , paginationSchema } from '../../../libs/pagination' ;
19+ import {
20+ paginationResponse ,
21+ paginationSchema ,
22+ paginationSchemaQuery ,
23+ } from '../../../libs/pagination' ;
2024import { ZodFastifyInstance } from '../../../libs/server' ;
2125import { ze } from '../../../libs/validators/validators' ;
2226
@@ -33,7 +37,8 @@ export default async function (fastify: ZodFastifyInstance) {
3337 } ,
3438 config : {
3539 cache : {
36- key : ( req ) => `chain:${ req . chain . chainId } :tokens` ,
40+ key : ( req ) =>
41+ `chain:${ req . chain . chainId } :tokens:${ paginationSchemaQuery ( req . query ) } ` ,
3742 ttlSeconds : 30 ,
3843 enabled : true ,
3944 } ,
@@ -58,7 +63,9 @@ export default async function (fastify: ZodFastifyInstance) {
5863 '/money-market' ,
5964 {
6065 config : {
61- cache : true ,
66+ cache : {
67+ key : ( req ) => `chain:${ req . chain . chainId } :money-market:pools` ,
68+ } ,
6269 } ,
6370 } ,
6471 async ( req , reply ) => {
@@ -81,13 +88,15 @@ export default async function (fastify: ZodFastifyInstance) {
8188 '/money-market/:pool/reserves' ,
8289 {
8390 schema : {
84- querystring : paginationSchema ,
8591 params : z . object ( {
8692 pool : z . string ( ) ,
8793 } ) ,
8894 } ,
8995 config : {
90- cache : false ,
96+ cache : {
97+ key : ( req : FastifyRequest < { Params : { pool : string } } > ) =>
98+ `chain:${ req . chain . chainId } :money-market:reserves:${ req . params . pool } ` ,
99+ } ,
91100 } ,
92101 } ,
93102 async ( req : FastifyRequest < { Params : { pool : string } } > , reply ) => {
@@ -151,40 +160,28 @@ export default async function (fastify: ZodFastifyInstance) {
151160 isActive : item . isActive ,
152161 isFroze : item . isFrozen ,
153162 // eModes: item.eModes,
154- i : item ,
155163 } ;
156164 } ) ;
157165
158166 return { data : { reservesData : items , baseCurrencyData } } ;
159-
160- // return {
161- // data: items
162- // .map((item) => ({
163- // ...item,
164- // token: tokens.find((t) => t.address === item.underlyingAsset),
165- // }))
166- // .filter((i) => i.token),
167- // nextCursor: null,
168- // count: items.length,
169- // };
170167 } ,
171168 ) ;
172169
173170 fastify . get (
174171 '/money-market/:pool/user/:address/positions' ,
175172 {
176173 schema : {
177- querystring : paginationSchema ,
178174 params : z . object ( {
179175 pool : z . string ( ) ,
180176 address : ze . address ,
181177 } ) ,
182178 } ,
183179 config : {
184180 cache : {
185- enabled : false ,
186- ttlSeconds : 10 ,
187- staleTtlSeconds : 15 ,
181+ key : (
182+ req : FastifyRequest < { Params : { pool : string ; address : string } } > ,
183+ ) =>
184+ `chain:${ req . chain . chainId } :money-market:user-positions:${ req . params . pool } :${ req . params . address } ` ,
188185 } ,
189186 } ,
190187 } ,
@@ -442,7 +439,6 @@ export default async function (fastify: ZodFastifyInstance) {
442439 userEmodeCategoryId : summary . userEmodeCategoryId ,
443440 isInIsolationMode : summary . isInIsolationMode ,
444441 } ,
445- reservesData,
446442 } ,
447443 } ;
448444 } ,
0 commit comments