Skip to content

Commit a894323

Browse files
committed
feat: improve pendle caching
1 parent 602a69f commit a894323

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/swapService/strategies/balmySDK/pendleQuoteSource.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ type PendleData = { tx: SourceQuoteTransaction }
4343

4444
type ExpiredMarketsCache = {
4545
[chainId: number]: {
46-
lastUpdatedUTCDate: number
46+
lastUpdated: number
4747
markets: {
4848
name: string
4949
address: Address
@@ -56,6 +56,8 @@ type ExpiredMarketsCache = {
5656
}
5757
}
5858

59+
const todayUTC = () => new Date().setUTCHours(0, 0, 0, 0)
60+
5961
export class CustomPendleQuoteSource
6062
implements IQuoteSource<PendleSupport, PendleConfig, PendleData>
6163
{
@@ -208,12 +210,11 @@ export class CustomPendleQuoteSource
208210
) {
209211
if (
210212
!this.expiredMarketsCache[chainId] ||
211-
this.expiredMarketsCache[chainId].lastUpdatedUTCDate !==
212-
new Date().getUTCDate()
213+
this.expiredMarketsCache[chainId].lastUpdated !== todayUTC()
213214
) {
214215
this.expiredMarketsCache[chainId] = {
215216
markets: [],
216-
lastUpdatedUTCDate: -1,
217+
lastUpdated: -1,
217218
}
218219

219220
const url = `${getUrl()}/${chainId}/markets/inactive`
@@ -226,7 +227,7 @@ export class CustomPendleQuoteSource
226227

227228
this.expiredMarketsCache[chainId] = {
228229
markets,
229-
lastUpdatedUTCDate: new Date().getUTCDate(),
230+
lastUpdated: todayUTC(),
230231
}
231232
}
232233
}

0 commit comments

Comments
 (0)