Skip to content

Use more mature Price data models in "v1" referral-related APIs #1521

@lightwalker-eth

Description

@lightwalker-eth

Prerequisites

Background info

  • When the ens-referrals package was first implemented, we took a few temporary shortcuts to ensure ENS Holiday Awards could be shipped before Dec 1. These temporary shortcuts included quick fixes for the USDQuantity and RevenueContribution price data models currently defined in ens-referrals.
  • A more mature price data model for PriceUsdc and PriceEth are defined in ensnode-sdk, however we were previously blocked on using these more mature data models because of issue 1519 and our need to ensure ENS Holiday Awards was shipped on schedule.

Change Management Notes

  • All ideas in this issue should apply exclusively to the "v1" implementation of referral-related APIs. No changes should be made to the "v0" implementations. See issue 1520 for details.

Goals

  • The price data models returned in the "v1" implementation of referral-related APIs should transition to use the more mature price data models defined in ensnode-sdk.

Suggested actions

  1. All uses of USDQuantity should be removed and replaced with PriceUsdc.
  2. All uses of RevenueContribution should be removed and replaced with PriceEth.
  3. NOTE: please take special care of how PriceUsdc and PriceEth store bigint values to avoid issues with floating point numbers in a context where potentially inaccurate floating point math is unacceptable. Therefore, it is critical to get the amount of 0's correct in representing these values.
    1. For reference, see currencyInfo in packages/ensnode-sdk/src/shared/currencies.ts
    2. This may also be helpful for your testing to convert between Wei vs Eth: https://eth-converter.com/
    3. Also, for reference, we previously built some related utility functions for NameKit that may be helpful copy-paste-refine opportunities for you to solve your goals here:
      1. https://github.com/namehash/namekit/blob/main/packages/ens-utils/src/price.ts
      2. https://github.com/namehash/namekit/blob/main/packages/ens-utils/src/price.test.ts

Metadata

Metadata

Assignees

Labels

Projects

Status

Todo

Relationships

None yet

Development

No branches or pull requests

Issue actions