Skip to content

Commit 98655ec

Browse files
chore: handle pricing when endtime is in future (#112)
# 🤖 Linear Closes PAR-XXX ## Description ## Checklist before requesting a review - [ ] I have conducted a self-review of my code. - [ ] I have conducted a QA. - [ ] If it is a core feature, I have included comprehensive tests. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **Bug Fixes** - Enhanced the token price retrieval process to automatically adjust timing parameters when a future end time is detected, ensuring more reliable and accurate pricing data. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
2 parents e50e1b1 + d64f4eb commit 98655ec

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

packages/pricing/src/providers/coingecko.provider.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,13 @@ export class CoingeckoProvider implements IPricingProvider {
116116
return undefined;
117117
}
118118

119+
// Handle when the endTimestampMs is in the future
120+
const currentTimestamp = Date.now() - 60 * 1000;
121+
if (currentTimestamp < endTimestampMs) {
122+
startTimestampMs = (currentTimestamp - TIME_DELTA) as TimestampMs;
123+
endTimestampMs = currentTimestamp as TimestampMs;
124+
}
125+
119126
const path = `/coins/${tokenId}/market_chart/range?vs_currency=usd&from=${startTimestampMs / 1000}&to=${endTimestampMs / 1000}&precision=full`;
120127
try {
121128
const { data } = await this.axios.get<CoingeckoPriceChartData>(path);

0 commit comments

Comments
 (0)