Commit c17a0d8
authored
chore: adds non-evm staking (#7448)
## Explanation
Adds a `tron_staking` state structure to support staking APY data for
Tron.
Tron staking uses a different approach than EVM pooled staking, so
rather than forcing Tron into the existing `pooled_staking` structure
(which would require nullable vault-specific fields and conditional
logic), this introduces a dedicated Tron specific state.
We opted for a chain-specific key (`tron_staking`) rather than a generic
`non_evm_staking` map because different non-EVM chains may have
significantly different data requirements. This approach is more
explicit and if we add other non-EVM chains later, they can have their
own state structures.
The idea next is for the mobile client to:
1 - Call `EarnController.refreshNonEvmStakingApy()` with Tron witness
API fetcher
2 - Use the selectors in `selectEarnTokens` to populate
`earnToken.experience.apr` with the Tron APY
3- Get rid of the `useTronStakeApy` hook calls from components
## References
<!--
Are there any issues that this pull request is tied to?
Are there other links that reviewers should consult to understand these
changes better?
Are there client or consumer pull requests to adopt any breaking
changes?
For example:
* Fixes #12345
* Related to #67890
-->
## Checklist
- [ ] I've updated the test suite for new or updated code as appropriate
- [ ] I've updated documentation (JSDoc, Markdown, etc.) for new or
updated code as appropriate
- [ ] I've communicated my changes to consumers by [updating changelogs
for packages I've
changed](https://github.com/MetaMask/core/tree/main/docs/contributing.md#updating-changelogs)
- [ ] I've introduced [breaking
changes](https://github.com/MetaMask/core/tree/main/docs/breaking-changes.md)
in this PR and have prepared draft pull requests for clients and
consumer packages to resolve them
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> Adds TRON staking APY support to EarnController with a new
`tron_staking` state, fetch/update method, selectors, exports, and
tests.
>
> - **Earn Controller**:
> - **State**: Introduces `tron_staking` (`TronStakingState`) with
metadata; defaults to `null` (`DEFAULT_TRON_STAKING_STATE`) and included
in `getDefaultEarnControllerState`.
> - **Methods**: Adds `refreshTronStakingApy(apyFetcher)` and
`getTronStakingApy()`.
> - **Exports**: Exposes `TronStakingState`,
`DEFAULT_TRON_STAKING_STATE`, and new selectors via `src/index.ts`.
> - **Selectors**:
> - Adds `selectTronStaking` and `selectTronStakingApy`.
> - Tightens return types on existing lending selectors.
> - **Tests**:
> - Adds tests for TRON staking state/methods/selectors and updates
metadata snapshots.
> - **Docs**:
> - Updates `CHANGELOG.md` to note TRON staking APY support.
>
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
be891ac. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->1 parent c04f32d commit c17a0d8
File tree
7 files changed
+226
-15
lines changed- packages/earn-controller
- src
7 files changed
+226
-15
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
945 | 945 | | |
946 | 946 | | |
947 | 947 | | |
948 | | - | |
949 | | - | |
950 | | - | |
951 | 948 | | |
952 | 949 | | |
953 | 950 | | |
| |||
957 | 954 | | |
958 | 955 | | |
959 | 956 | | |
960 | | - | |
| 957 | + | |
961 | 958 | | |
962 | 959 | | |
963 | 960 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
10 | 14 | | |
11 | 15 | | |
12 | 16 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
807 | 807 | | |
808 | 808 | | |
809 | 809 | | |
| 810 | + | |
| 811 | + | |
| 812 | + | |
| 813 | + | |
| 814 | + | |
| 815 | + | |
| 816 | + | |
| 817 | + | |
810 | 818 | | |
811 | 819 | | |
812 | 820 | | |
| |||
2585 | 2593 | | |
2586 | 2594 | | |
2587 | 2595 | | |
| 2596 | + | |
| 2597 | + | |
| 2598 | + | |
| 2599 | + | |
| 2600 | + | |
| 2601 | + | |
| 2602 | + | |
| 2603 | + | |
| 2604 | + | |
| 2605 | + | |
| 2606 | + | |
| 2607 | + | |
| 2608 | + | |
| 2609 | + | |
| 2610 | + | |
| 2611 | + | |
| 2612 | + | |
| 2613 | + | |
| 2614 | + | |
| 2615 | + | |
| 2616 | + | |
| 2617 | + | |
| 2618 | + | |
| 2619 | + | |
| 2620 | + | |
| 2621 | + | |
| 2622 | + | |
| 2623 | + | |
| 2624 | + | |
| 2625 | + | |
| 2626 | + | |
| 2627 | + | |
| 2628 | + | |
| 2629 | + | |
| 2630 | + | |
| 2631 | + | |
| 2632 | + | |
| 2633 | + | |
| 2634 | + | |
| 2635 | + | |
| 2636 | + | |
| 2637 | + | |
| 2638 | + | |
| 2639 | + | |
| 2640 | + | |
| 2641 | + | |
| 2642 | + | |
| 2643 | + | |
| 2644 | + | |
| 2645 | + | |
| 2646 | + | |
| 2647 | + | |
| 2648 | + | |
| 2649 | + | |
| 2650 | + | |
| 2651 | + | |
| 2652 | + | |
| 2653 | + | |
| 2654 | + | |
| 2655 | + | |
| 2656 | + | |
| 2657 | + | |
| 2658 | + | |
| 2659 | + | |
| 2660 | + | |
| 2661 | + | |
| 2662 | + | |
| 2663 | + | |
| 2664 | + | |
| 2665 | + | |
| 2666 | + | |
| 2667 | + | |
| 2668 | + | |
2588 | 2669 | | |
2589 | 2670 | | |
2590 | 2671 | | |
| |||
2611 | 2692 | | |
2612 | 2693 | | |
2613 | 2694 | | |
2614 | | - | |
| 2695 | + | |
2615 | 2696 | | |
2616 | 2697 | | |
| 2698 | + | |
2617 | 2699 | | |
2618 | 2700 | | |
2619 | 2701 | | |
| |||
2633 | 2715 | | |
2634 | 2716 | | |
2635 | 2717 | | |
| 2718 | + | |
2636 | 2719 | | |
2637 | 2720 | | |
2638 | 2721 | | |
| |||
2702 | 2785 | | |
2703 | 2786 | | |
2704 | 2787 | | |
2705 | | - | |
| 2788 | + | |
2706 | 2789 | | |
2707 | 2790 | | |
| 2791 | + | |
2708 | 2792 | | |
2709 | 2793 | | |
2710 | 2794 | | |
| |||
2724 | 2808 | | |
2725 | 2809 | | |
2726 | 2810 | | |
| 2811 | + | |
2727 | 2812 | | |
2728 | 2813 | | |
2729 | 2814 | | |
| |||
2792 | 2877 | | |
2793 | 2878 | | |
2794 | 2879 | | |
2795 | | - | |
| 2880 | + | |
2796 | 2881 | | |
2797 | 2882 | | |
| 2883 | + | |
2798 | 2884 | | |
2799 | 2885 | | |
2800 | 2886 | | |
| |||
2814 | 2900 | | |
2815 | 2901 | | |
2816 | 2902 | | |
| 2903 | + | |
2817 | 2904 | | |
2818 | 2905 | | |
2819 | 2906 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
92 | 92 | | |
93 | 93 | | |
94 | 94 | | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
95 | 105 | | |
96 | 106 | | |
97 | 107 | | |
| |||
128 | 138 | | |
129 | 139 | | |
130 | 140 | | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
131 | 147 | | |
132 | 148 | | |
133 | 149 | | |
| |||
138 | 154 | | |
139 | 155 | | |
140 | 156 | | |
| 157 | + | |
141 | 158 | | |
142 | 159 | | |
| 160 | + | |
| 161 | + | |
143 | 162 | | |
144 | 163 | | |
145 | 164 | | |
| |||
209 | 228 | | |
210 | 229 | | |
211 | 230 | | |
| 231 | + | |
| 232 | + | |
212 | 233 | | |
213 | 234 | | |
214 | 235 | | |
| |||
224 | 245 | | |
225 | 246 | | |
226 | 247 | | |
| 248 | + | |
227 | 249 | | |
228 | 250 | | |
229 | 251 | | |
| |||
806 | 828 | | |
807 | 829 | | |
808 | 830 | | |
| 831 | + | |
| 832 | + | |
| 833 | + | |
| 834 | + | |
| 835 | + | |
| 836 | + | |
| 837 | + | |
| 838 | + | |
| 839 | + | |
| 840 | + | |
| 841 | + | |
| 842 | + | |
| 843 | + | |
| 844 | + | |
| 845 | + | |
| 846 | + | |
| 847 | + | |
| 848 | + | |
| 849 | + | |
| 850 | + | |
| 851 | + | |
| 852 | + | |
| 853 | + | |
| 854 | + | |
| 855 | + | |
| 856 | + | |
| 857 | + | |
| 858 | + | |
| 859 | + | |
809 | 860 | | |
810 | 861 | | |
811 | 862 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
4 | 5 | | |
5 | 6 | | |
6 | 7 | | |
| |||
15 | 16 | | |
16 | 17 | | |
17 | 18 | | |
| 19 | + | |
18 | 20 | | |
19 | 21 | | |
20 | 22 | | |
| |||
36 | 38 | | |
37 | 39 | | |
38 | 40 | | |
| 41 | + | |
| 42 | + | |
39 | 43 | | |
40 | 44 | | |
41 | 45 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
| 25 | + | |
| 26 | + | |
25 | 27 | | |
26 | 28 | | |
27 | 29 | | |
| |||
135 | 137 | | |
136 | 138 | | |
137 | 139 | | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
138 | 144 | | |
139 | 145 | | |
140 | 146 | | |
| |||
413 | 419 | | |
414 | 420 | | |
415 | 421 | | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
416 | 459 | | |
0 commit comments