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
Christian Kamm
1574f53a65
Overflow check when accumulating voter weight
2021-12-29 10:01:36 +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
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
microwavedcola1
9d72320bdd
make vault per voter+mint instead of global per registrar+mint ( #14 )
2021-12-17 08:02:14 +01:00
Christian Kamm
5aa1114beb
Make VotingMintConfig::in_use based on the mint
2021-12-17 07:51:06 +01:00
Christian Kamm
b937452f51
Increase default voting_mints size to 4.
2021-12-17 07:51:06 +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
Armani Ferrante
2f5e133648
Fix conversion_factor comment
2021-12-07 18:11:32 +01:00
Christian Kamm
fea2c9a0cd
Apply review suggestions
2021-12-07 09:26:47 +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
bae63655cc
Update voter weight record in withdraw
...
This avoids a security issue where three separate transactions in the
same slot may update the voter weight record, withdraw funds and then
vote with the stale voter weight record.
2021-12-05 11:58:56 +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
microwavedcola1
0f4a0a40c9
some minor renaming
...
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2021-12-03 16:06:44 +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
9d9ebff1c1
Common code for finding exchange rate index
2021-12-03 13:03:16 +01:00
Christian Kamm
78bebfdd98
Common code for token owner record validation
2021-12-03 12:54:51 +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
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