Commit Graph

26 Commits

Author SHA1 Message Date
Sebastian Bor dd6be5bef8 chore: Make Clippy happy 2022-12-21 13:10:19 +00:00
Christian Kamm 233e5414f4 Use anchor's new require_*!() macros 2022-05-04 13:50:50 +02:00
Christian Kamm eb46a030d1 Upgrade anchor to 0.24.2 2022-05-04 13:50:50 +02:00
Christian Kamm 09ef15f869 Increase lockup period limit to 365 * 200
By request.
2022-04-03 08:19:31 +02:00
Christian Kamm 16d22648f7 Rename padding -> reserved and increase its size 2022-02-14 09:06:29 +01:00
Christian Kamm 1a577eb7bd
Upgrade spl-governance version (#30)
Upgrade to latest spl-governance

Co-authored-by: microwavedcola1 <microwavedcola@gmail.com>
2022-02-01 10:46:03 +01:00
Christian Kamm 819038a9ae Use checked_div() more 2022-01-25 13:00:45 +01:00
Christian Kamm 22b4923ef2 Address all math issues reported by soteria
None of these should have been a real issue.
2022-01-25 13:00:45 +01:00
Christian Kamm 40708e80ef Fix underflow in voting computation
The vote power computation was broken for lockups that start very far
in the future.

- Fix the underflow itself
- Disallow lockups that start more than 100 years in the future
- Error if the lockup-scaled voting power is bigger than the maximum
  lockup voting power
2022-01-25 13:00:45 +01:00
microwavedcola1 f81e308a7d Add tests for discovered lockup voting power issue
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-01-25 13:00:45 +01:00
Christian Kamm 183626ad32 Add LogVoterInfo instruction
It has no effect on any state. It logs information about the voter and
all of its deposits to the program log. This can be used from the UI.
2022-01-19 09:04:39 +01:00
Christian Kamm 18edcd602e Overflow checking in vested vote power computation 2021-12-29 10:01:36 +01:00
microwavedcola1 332f1f76fc remove unused, was added for ts tests, which we not longer maintain
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2021-12-18 14:09:20 +01:00
Christian Kamm 49e137eb51 Add constant-maturity lockup
Adds LockupKind::Constant, extends the reset_lockup instruction and
adds the internal_transfer instruction to allow working with constant
maturity lockups.
2021-12-14 10:19:47 +01:00
Christian Kamm 8f3af93f99 Change assert() to require()
So these assumption-guaranteeing checks aren't removed.
2021-12-10 16:22:43 +01:00
Christian Kamm 9a5182d317 Fix a bug where start_ts could become > end_ts
Previously period_current() could exceed periods_total().
2021-12-10 16:22:43 +01:00
Christian Kamm decdd1230c Address unaligned references, add padding
- Make Registrar zero-copy. While it was using borsh for serialization,
  the array of voting mint configs couldn't be serialized without
  unaligned references.
- Reorganize all zero_copy fields such that switching to repr(C) would
  not make a difference. (just for safety in case that happens)
- Add static asserts on the sizes of all account structs, so any changes
  are visible very early.
- Add padding to structs that didn't have it yet.
2021-12-09 11:59:14 +01:00
Christian Kamm ddf37c4de0
Configurable options for vote weight scaling factors (#7)
Configurable options for vote weight scaling and lockup saturation

Co-authored-by: microwavedcola1 <microwavedcola@gmail.com>
2021-12-09 11:58:15 +01:00
Christian Kamm e8b0a1f50a Fix vote power computation for monthly vesting
- The vote power decay now has second resolution.
- Monthly and daily vesting behave exactly like multiple cliff locked
  deposits.
- In particular, monthly vesting deposits lock-up power decays during
  the month, making it smooth over time.
- Gain vote power even if start_ts is in the future (shouldn't happen)
2021-12-06 16:11:32 +01:00
Christian Kamm 119bdffcec Add grant instruction 2021-12-05 20:36:01 +01:00
Christian Kamm 9472c882ee Minor local var rename 2021-12-03 21:19:33 +01:00
Christian Kamm 3374f6c09c Rename ExchangeRate -> VotingMintConfig 2021-12-03 20:49:34 +01:00
Christian Kamm 15c69a317a Lockup: share common code and checks 2021-12-03 14:51:10 +01:00
Christian Kamm b91f9ba595 Pass deposit_entry_index to create_deposit_entry()
This allows create_deposit_entry() and deposit() to be in the same
transaction.
2021-12-03 09:48:10 +01:00
Christian Kamm 3f158f1f0b Drop unused use 2021-12-02 20:28:03 +01:00
microwavedcola1 9823f282d4 split accounts.rs into state/*
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2021-12-02 20:05:43 +01:00