interledger / web-monetization-extension

An open-source browser extension that enables Web Monetization.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Calculate rate of pay for different asset codes

raducristianpopa opened this issue · comments

Context

If the currency conversion rate (USD based) is between 0.8 and 1.5 we do not perform the currency conversion. For values outside of this range we need to calculate the following values:

  • rate of pay slider step
  • maximum value for rate of pay slider

Todos

  • When the user connects the wallet, fetch the currency exchange rates and check if the rate is between 0.8 and 1.5.
    • if the value is in the range do not calculate the slider step and maximum value
    • if it is outside the range perform the currency conversion (see examples)
  • Save the slider step and maximum value in the extension storage (set default values if not).
  • Return slider step and maximum value when calling GET_CONTEXT_DATA

Examples:

  1. Wallet asset: BTC, scale 8 - conversion rate: 66578.37

    • convert $0.01 to BTC (which will represent the pay slider step)
    • convert $1 to BTC (which represents the maximum value for the pay slider)
  2. Wallet asset: GBP, scale 2 - conversion rate: 1.27

    • we do not perform currency conversion and we use the default amounts (60 UNITS per INTERVAL with maximum amount of 100 UNITS)

Questions

Do we only perform this action when the user connects the wallet or every day/on an interval to get the updated rates?