Commit Graph

140 Commits

Author SHA1 Message Date
Christian Kamm 6d15fb8d77 Simplification and doc comments 2021-12-02 19:30:41 +01:00
Christian Kamm f5ea3180d1 Move all instructions to separate files 2021-12-02 16:28:12 +01:00
Christian Kamm d1471a2820 Resolve some warnings 2021-12-02 12:06:29 +01:00
Christian Kamm 37a3ab9b0f Rename CloseDeposit -> CloseDepositEntry 2021-12-02 11:08:18 +01:00
Christian Kamm f5ecf79765 Rename UpdateDeposit -> Deposit 2021-12-02 11:06:15 +01:00
Christian Kamm daf4609c41 Rename CreateDeposit -> CreateDepositEntry and make it separate
It doesn't implicitly call UpdateDeposit now
2021-12-02 11:01:14 +01:00
Christian Kamm 17a023fe6d cargo fmt 2021-12-02 08:06:45 +01:00
microwavedcola1 333584ad92 rename
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2021-12-01 14:51:40 +01:00
microwavedcola1 75335477ef fix bug: clawback should only happen on a not-closed deposit
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2021-12-01 14:34:42 +01:00
Christian Kamm 0543f5fe20 Rename to voter-stake-registry 2021-12-01 13:28:38 +01:00
Christian Kamm 0efd7c0518 Adjust lockup ending after clawback() 2021-12-01 12:40:52 +01:00
Christian Kamm 304af2ae7d Test: withdraw before and after clawback
This way we check that it can deal with withdrawn vested amounts
2021-12-01 12:36:06 +01:00
Christian Kamm 57dbe54e7c Merge remote-tracking branch 'origin/master' into clawback 2021-12-01 12:25:15 +01:00
Christian Kamm 811063ab44 Minor: remove todo 2021-12-01 12:15:39 +01:00
Christian Kamm 4c49608ac5 Tests: remove stale argument from clawback() 2021-12-01 12:13:07 +01:00
Christian Kamm 6244649140 Remove proxy tokens for locked deposits
It was unclear how clawback() was to burn these tokens when it didn't
have the authority for the voting_token account. update_deposit() also
couldn't pre-approve because it also doesn't have a voter_authority
signature.
2021-12-01 12:09:07 +01:00
Christian Kamm b011d8999b Fix clawback authority validation
Tests currently fail because clawback can't burn voting_token funds.
2021-12-01 12:03:38 +01:00
Christian Kamm 8257f29c4e Deposits with clawback can only be closed when locking period is over 2021-12-01 11:42:08 +01:00
Christian Kamm 98e09c5a89 Require voter_authority for create deposit, not for update deposit 2021-12-01 11:33:35 +01:00
Christian Kamm 89f94ae553 Fix amount_not_yet_vested in clawback 2021-12-01 11:18:02 +01:00
Christian Kamm c7aaa811d4 Remove clawback checks that might prohibit DAO from using it 2021-12-01 11:14:56 +01:00
Christian Kamm 9bfb3ba865 Don't allow update_deposit to change allow_clawback 2021-12-01 11:12:24 +01:00
microwavedcola1 3303c6e627 clawback v1
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2021-12-01 10:20:39 +01:00
Christian Kamm bf620a6bea Add constraint notes on UnceckedAccounts 2021-12-01 09:46:13 +01:00
Christian Kamm 62764866d7 Registrar creation needs a valid realm authority 2021-12-01 09:29:07 +01:00
Christian Kamm de80fc6f20 Change withdraw token owner record checks
As suggested by SebastianBor
2021-12-01 09:11:45 +01:00
Christian Kamm 96905a9eb2 Add governing token mint constraint on update voter weight record 2021-12-01 09:01:05 +01:00
Christian Kamm 6b54623831 Don't require signing for UpdateVoterWeightRecord 2021-12-01 08:59:25 +01:00
Christian Kamm 211f70b2ee Use arbitrary governing mint
Also
- fix deposit_cliff test
- proactively avoid collisions in PDA seeds
- macro for getting registrar seeds
2021-12-01 08:52:39 +01:00
microwavedcola1 c5e1f6e9b3 box registrat to prevent hammering of stack
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2021-12-01 07:45:00 +01:00
Christian Kamm 10f8961882 Basic cliff vesting tests 2021-11-30 15:11:07 +01:00
microwavedcola1 b8c1c1f1f2 revert clawback change
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2021-11-30 14:16:07 +01:00
Christian Kamm ae600bfaf5 Reorder context accounts for readability 2021-11-30 14:05:09 +01:00
microwavedcola1 34c8379e41 clawback1: add registrar token account which would be clawback withdraw destination
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2021-11-30 14:00:15 +01:00
Christian Kamm 39e7cd1fc0 Use UncheckedAccount over AccountInfo
UncheckedAccount is the preferred alias, there should be no behavior
difference.
2021-11-30 13:16:09 +01:00
Christian Kamm 6f85300c4c Better naming for authorities
By splitting into registrar_authority and voter_authority it's
immediately clear what kind of authority is used and expected.
2021-11-30 13:10:48 +01:00
Christian Kamm bdf4f0e723 cargo fmt 2021-11-30 11:56:14 +01:00
Christian Kamm 2c608ebe46 Add instruction for closing deposits 2021-11-30 11:49:59 +01:00
Christian Kamm d529dab2d6 Remove unnecessary vesting functions 2021-11-30 09:33:17 +01:00
Christian Kamm fdff9e1f77 Add monthly vesting test 2021-11-30 09:27:07 +01:00
Christian Kamm 21a1970349 Deal with vesting periods uniformly
- create deposit now takes 'periods' instead of 'days'
- vesting and vote weight are computed via periods
- cliff lockup has a daily period
- change secs_per_month to be secs_per_year / 12
2021-11-30 09:24:18 +01:00
Christian Kamm 46b9c59923 Add TODOs on vote weight computations 2021-11-30 07:41:12 +01:00
Christian Kamm b2699aa7f1 Shorten common operations in tests 2021-11-29 16:42:48 +01:00
Christian Kamm 423f8637bc Tiny test comment fixes 2021-11-29 16:33:01 +01:00
Christian Kamm 2c2ed548e7 Remove resolved todo 2021-11-29 16:28:44 +01:00
Christian Kamm a33e3a830d Expand daily vesting tests 2021-11-29 16:27:51 +01:00
Christian Kamm ff61e5cc63 Naming improvements 2021-11-29 16:11:17 +01:00
Christian Kamm 15f06c53b9 Initial daily vesting test
Introduce the ability to set a time offset for testing
2021-11-29 15:56:45 +01:00
Christian Kamm d634e1067d Simplify accessing the clock 2021-11-29 14:23:11 +01:00
Christian Kamm 95fc19d3b1 Tests: minor reformatting 2021-11-29 12:16:41 +01:00
Christian Kamm 1e10adb2f1 Tests for LockupKind::None 2021-11-29 12:07:15 +01:00
Christian Kamm 5b63ba8339 Fixes to vote scaling
- Introduce factors for scaling the fixed part and the time dependent
  part.
- Disable the time dependent vote weight scaling initially. We can only
  enable it once voluntary locking is exposed to users.
- Fix bugs around withdrawals changing the vesting amount.
- Fix bugs with vote weight computation using an incorrect denominator.
- Fix bugs around adding more funds to a locked deposit.

Lots of tests are still needed.
2021-11-29 10:29:21 +01:00
microwavedcola1 b01c59e236 lockup kind none
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2021-11-29 08:10:32 +01:00
microwavedcola1 ef5b11cb3c notes 2021-11-29 06:51:06 +01:00
Christian Kamm ce1e639e71 Add rust-based tests that setup a spl-gov instance 2021-11-28 08:34:10 +01:00
Christian Kamm eed7c60532 Check that mint/vault is appropriate on withdraw 2021-11-27 09:32:28 +01:00
Christian Kamm 4a00417348 Forbid creating voter accounts via CPI 2021-11-27 09:32:28 +01:00
Christian Kamm f3838d2574 Prevent withdrawing in the same slot as a deposit
To prevent deposit / revise / withdraw / vote.
2021-11-27 09:32:28 +01:00
Christian Kamm 8dacaf87c3 Check TokenOwnerRecord on withdraw() 2021-11-27 09:32:28 +01:00
Christian Kamm db37418551 Store parent governance program id in registrar
Needed for later reading TokenOwnerRecord in withdraw()
2021-11-27 09:32:28 +01:00
microwavedcola1 36af4a29b3 add todo
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2021-11-27 07:47:36 +01:00
microwavedcola1 bff99fc155 add monthly vesting
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2021-11-26 21:04:05 +01:00
microwavedcola1 23ad57302d make withdraw ts tests work
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2021-11-26 07:49:22 +01:00
microwavedcola1 eccaecc2e5 fix types in tests + fix seeds in withdraw
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2021-11-26 07:30:14 +01:00
Christian Kamm adf0a7e81e Add notes about necessary changes to withdraw() 2021-11-25 18:31:26 +01:00
armaniferrante 26e2d7870c
Use anchor v0.18.0 2021-10-24 22:16:22 -07:00
armaniferrante 89ef88aef0
Remove warmup 2021-10-24 18:14:06 -07:00
armaniferrante 5badbeb59c
Scale exchange rate mints into common decimals 2021-10-23 16:09:42 -07:00
armaniferrante 71d7a4437b
Untabify inert attribute 2021-10-23 14:03:15 -07:00
armaniferrante 0babb8e8b5
Daily tests passing 2021-10-23 13:48:19 -07:00
armaniferrante c95fa4bf61
Begin daily tests 2021-10-22 22:43:13 -07:00
armaniferrante 4f455659b1
Add cliff tests 2021-10-22 16:57:20 -07:00
armaniferrante 0bdcb475cb
Fix account close 2021-10-21 19:30:52 -07:00
armaniferrante eaf6890146
Create and write vote weight records 2021-10-21 19:16:32 -07:00
armaniferrante f00531fb7f
Fix withdraw freezing 2021-10-21 13:03:59 -07:00
armaniferrante 9059bdd5d1
Use new voting mint for each exchange rate 2021-10-20 15:54:27 -07:00
armaniferrante e3976cd2aa
Add README 2021-10-20 13:08:12 -07:00
armaniferrante 1ace2c28ab
Adjust daily vesting vote decay 2021-10-20 12:54:39 -07:00
armaniferrante 1e3ed58a1c
Static exchange rates 2021-10-20 12:38:54 -07:00
armaniferrante 7bc7d12251
Restructure 2021-10-19 17:08:47 -07:00
armaniferrante 38aa2c0a78
Vesting calculation 2021-10-19 15:08:05 -07:00
armaniferrante 9afa16ce3a
Use scaled amounts for voting power calculation 2021-10-18 17:59:09 -07:00
armaniferrante 23fd61d9a5
Update schedule ix 2021-10-18 17:55:15 -07:00
armaniferrante a47fc9f74a
Untested voting power implementation 2021-10-18 15:48:20 -07:00
armaniferrante dcaa7423c7
Sketch lockup calculation 2021-10-18 12:27:37 -07:00
armaniferrante 8db7c5b449
Decompose deposits into separate instructions 2021-10-16 09:48:59 -07:00
Armani Ferrante 627d572774
Basic test setup 2021-10-15 13:23:04 -05:00
armaniferrante 6671dae536
More scaffolding 2021-10-14 21:05:21 -07:00
armaniferrante ca3aca3ce3
Scaffold 2021-10-14 09:53:35 -07:00
armaniferrante e4f63f7c8a
Init 2021-10-05 13:41:01 -07:00