Commit Graph

37 Commits

Author SHA1 Message Date
Connor O'Hara 3ef766d249 Added the required CHECK docs from Anchor 2022-12-22 09:21:35 +01: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 929c38f512 Withdraw: Never block withdraws of tokens without voting power
Previously being engaged in a proposal would prohibit these withdraws.
2022-02-09 10:31:06 +01:00
microwavedcola1 2105e1b173
fix clippy warnings and some other deprecations (#33)
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-02-04 09:32:55 +01:00
Christian Kamm 5b3d07ffb3 Renames for clarity
- withdrawable -> unlocked

  "withdrawable" was a bad name, since these funds - while unlocked -
  are not necessarily withdrawable if the voter is currently engaged in
  a vote.

- only_deposit -> only_unlocked

  Locked funds are technically also deposited. Make it clearer that this
  is talking about the unlocked parts of the funds on the account.
2022-01-26 09:01:17 +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 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
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
microwavedcola1 f777a43ed6 basic logging
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2021-12-05 21:10:32 +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 01168bad3c Fix new withdraw() instruction check 2021-12-05 11:39:39 +01:00
microwavedcola1 14040bafc7 Revert "this condition is not needed anymore, since we check that the withdraw is the first ix in the tx"
This reverts commit 5f2bfea4e3.
2021-12-05 11:31:00 +01:00
microwavedcola1 5f2bfea4e3 this condition is not needed anymore, since we check that the withdraw is the first ix in the tx
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2021-12-05 10:14:56 +01:00
microwavedcola1 bac332b1c8 add-todo
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2021-12-05 10:14:05 +01:00
microwavedcola1 3f1be68c06 typo
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2021-12-05 10:12:47 +01:00
microwavedcola1 7698d2f45e withdraw should be the firs instruction
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2021-12-05 09:53:39 +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
microwavedcola1 a9731a749c add seed checks
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2021-12-04 09:02:20 +01:00
Christian Kamm aad6f296da Restructure and add sanity asserts 2021-12-03 21:13:32 +01:00
Christian Kamm 3374f6c09c Rename ExchangeRate -> VotingMintConfig 2021-12-03 20:49:34 +01:00
Christian Kamm bee5c556ca Remove unneeded mint accounts 2021-12-03 14:26:42 +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 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
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
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