Skip to content

Conversation

@paullinator
Copy link
Member

@paullinator paullinator commented Oct 26, 2025

CHANGELOG

Does this branch warrant an entry to the CHANGELOG?

  • Yes
  • No

Dependencies

none

Description

none

@paullinator paullinator force-pushed the paul/v2converter branch 5 times, most recently from 1aa450a to be885c9 Compare October 30, 2025 01:03
// Helper to add crypto asset
const addCrypto = (currencyCode: string, date: Date): void => {
const asset = currencyCodeToAsset(currencyCode, currencyCodeMaps)
const key = `${asset.pluginId}_${
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use toCryptoKey util

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't because the key needs to include the date. Parsing would break with toCryptoKey since it doesn't put an _null for null tokenIds which would be hard to parse if I tack an _[date] at the end of it.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mentioned the wrong util. There's toDatedCryptoKey (and toDatedFiatKey) hiding in the src/v3/router file instead of utils. For the very issue you mentioned it puts the date in the front

): Promise<void> => {
const delayMs = frequencyToMs[frequency]
const delayMs =
typeof frequency === 'number' ? frequency * 1000 : frequencyToMs[frequency]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use the frequency as-is without multiplying by 1000

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The frequency value is specified in seconds not ms.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The function treats it as seconds but it isn't specified as such. This could be typed instead as

type Frequency = 'minute' | 'hour' | 'day' | 'week' | 'month'
type FrequencySeconds = number

then the definition becomes:

const createEngineLoop = async (
  providerId: string,
  engine: RateEngine,
  frequency: Frequency | FrequencySeconds
): Promise<void> => {	): Promise<void> => {

engine: tokenMapping
},
{
frequency: 120,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

120 * 1000

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hence why the engine multiplies by 1000. anything less than 1 sec is worthless as a frequency

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand why you used seconds here. I'm suggesting to pass ms here because I think the createEngineLoop definition is ambiguous. If you make the suggested type change then this comment is no longer relevant

): Promise<void> => {
const delayMs = frequencyToMs[frequency]
const delayMs =
typeof frequency === 'number' ? frequency * 1000 : frequencyToMs[frequency]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The function treats it as seconds but it isn't specified as such. This could be typed instead as

type Frequency = 'minute' | 'hour' | 'day' | 'week' | 'month'
type FrequencySeconds = number

then the definition becomes:

const createEngineLoop = async (
  providerId: string,
  engine: RateEngine,
  frequency: Frequency | FrequencySeconds
): Promise<void> => {	): Promise<void> => {

engine: tokenMapping
},
{
frequency: 120,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand why you used seconds here. I'm suggesting to pass ms here because I think the createEngineLoop definition is ambiguous. If you make the suggested type change then this comment is no longer relevant

// Helper to add crypto asset
const addCrypto = (currencyCode: string, date: Date): void => {
const asset = currencyCodeToAsset(currencyCode, currencyCodeMaps)
const key = `${asset.pluginId}_${
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mentioned the wrong util. There's toDatedCryptoKey (and toDatedFiatKey) hiding in the src/v3/router file instead of utils. For the very issue you mentioned it puts the date in the front

@peachbits peachbits merged commit c2766d5 into master Dec 2, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants