Commit Graph

20 Commits

Author SHA1 Message Date
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
microwavedcola1 69767b2323
add note why clawback is possible when someone is engaged in an active proposal (#39)
* add comment

Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>

* remove unused

Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>

* fix test

Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-02-10 19:34:48 +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
Christian Kamm bb4c3f85ea
Remove separate clawback_authority (#15)
Just use the realm authority instead.
2021-12-20 11:01:23 +01:00
microwavedcola1 9d72320bdd
make vault per voter+mint instead of global per registrar+mint (#14) 2021-12-17 08:02:14 +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 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
microwavedcola1 317b7168eb Remove instruction name logs since they would be redundant with next anchor release
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2021-12-07 19:12:56 +01:00
Christian Kamm 03cfe65d9c Simplify withdraw/clawback authority checks 2021-12-04 10:54:33 +01:00
microwavedcola1 9c1763f8c4 separate clawback and withdraw
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2021-12-04 09:22:22 +01:00
Christian Kamm aad6f296da Restructure and add sanity asserts 2021-12-03 21:13:32 +01:00
Christian Kamm 15c69a317a Lockup: share common code and checks 2021-12-03 14:51:10 +01:00
Christian Kamm 6392e5f2c9 Add function for computing amount of locked tokens 2021-12-03 14:36:23 +01:00
Christian Kamm 7278eac1fc Common code for deposit entry index checks 2021-12-03 12:46:37 +01:00
Christian Kamm 0612a3f918 Simplify state:: use 2021-12-03 09:52:48 +01:00
Christian Kamm d9fac29b28 Documentation improvements 2021-12-03 09:19:13 +01:00
Christian Kamm 5983a67de7 Consistently use 'deposit_entry_index' as a name for the index 2021-12-03 09:08:29 +01:00
microwavedcola1 9823f282d4 split accounts.rs into state/*
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2021-12-02 20:05:43 +01:00
Christian Kamm f5ea3180d1 Move all instructions to separate files 2021-12-02 16:28:12 +01:00