dfinity / nns-dapp

The Dapp of the Internet Computer's Network Nervous System.
https://nns.ic0.app/
Other
112 stars 38 forks source link

NNS1-3281: Function to initialize exchange rate timers for TVL #5401

Closed dskloetd closed 2 months ago

dskloetd commented 2 months ago

Motivation

The NNS dapp displays the USD value of the total amount of ICP locked in neurons. It gets this information from the TVL canister but we want to move this functionality to the nns-dapp canister and remove the TVL canister.

We already have a function to fetch the current ICP exchange rate. We want to call this periodically to have a reasonably up-to-date exchange rate.

Given that the total_locked_e8s exposed by the governance canister only updates once a day, updating the exchange rate 4 times a day, seems often enough.

Changes

  1. Add init_exchange_rate_timers to set up both a 1-time timer (for a quick initial value) and an interval timer.
  2. Update the golden exports files as the use of the timer caused the canister exports to change.

Tests

  1. Added a unit test that verifies the timers are set up and do the right thing when called.
  2. Tested manually in a more fully developed branch.

Todos