dfinity / nns-dapp

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

NNS1-3281: Function to initialize locked ICP timers for TVL #5403

Closed dskloetd closed 1 week ago

dskloetd commented 1 week 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 amount of ICP locked in neurons. We want to call this periodically to have a reasonably up-to-date value.

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_locked_icp_timers to set up both a 1-time timer (for a quick initial value) and an interval timer.

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