This repository was archived by the owner on Mar 11, 2025. It is now read-only.
Commit 4349310
token-2022: Add scaled amount extension (#7511)
* token-2022: Add scaled amount extension
#### Problem
The interest-bearing extension is useful for tokens that accrue in value
constantly, but many "rebasing" tokens on other blockchains employ a
different method of updating the number of tokens in accounts.
Rather than setting a rate and allowing the number to change
automatically over time, they set a scaling factor for the tokens by
hand.
#### Summary of changes
Add a new `ScaledUiAmount` extension to token-2022 for doing just that.
This is essentially a simplified version of the interest-bearing
extension, where someone just sets a scaling value into the mint
directly. The scale has no impact on the operation of the token, just on
the output of `amount_to_ui_amount` and `ui_amount_to_amount`.
* Add timestamp, rename to "multiplier"
* Update token/program-2022/src/extension/scaled_ui_amount/mod.rs
Co-authored-by: samkim-crypto <skim13@cs.stanford.edu>
* Address feedback
---------
Co-authored-by: samkim-crypto <skim13@cs.stanford.edu>1 parent 74e2559 commit 4349310
File tree
10 files changed
+1097
-4
lines changed- token
- client/src
- program-2022-test/tests
- program-2022/src
- extension
- scaled_ui_amount
10 files changed
+1097
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
46 | | - | |
47 | | - | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
48 | 49 | | |
49 | 50 | | |
50 | 51 | | |
| |||
188 | 189 | | |
189 | 190 | | |
190 | 191 | | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
191 | 196 | | |
192 | 197 | | |
193 | 198 | | |
| |||
207 | 212 | | |
208 | 213 | | |
209 | 214 | | |
| 215 | + | |
210 | 216 | | |
211 | 217 | | |
212 | 218 | | |
| |||
316 | 322 | | |
317 | 323 | | |
318 | 324 | | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
319 | 334 | | |
320 | 335 | | |
321 | 336 | | |
| |||
1805 | 1820 | | |
1806 | 1821 | | |
1807 | 1822 | | |
| 1823 | + | |
| 1824 | + | |
| 1825 | + | |
| 1826 | + | |
| 1827 | + | |
| 1828 | + | |
| 1829 | + | |
| 1830 | + | |
| 1831 | + | |
| 1832 | + | |
| 1833 | + | |
| 1834 | + | |
| 1835 | + | |
| 1836 | + | |
| 1837 | + | |
| 1838 | + | |
| 1839 | + | |
| 1840 | + | |
| 1841 | + | |
| 1842 | + | |
| 1843 | + | |
| 1844 | + | |
| 1845 | + | |
| 1846 | + | |
| 1847 | + | |
1808 | 1848 | | |
1809 | 1849 | | |
1810 | 1850 | | |
| |||
0 commit comments