Commit Graph

59 Commits

Author SHA1 Message Date
Sebastian Bor 8f9db44ec3 fix: Restore test_all_deposits() 2022-12-21 16:39:52 +00:00
Sebastian Bor e719ff5c27 wip: Disable test_all_deposits 2022-12-21 14:27:40 +00:00
Sebastian Bor e6ab5a0002 chore: Add test-sbf feature 2022-12-21 14:08:39 +00:00
Sebastian Bor fd850016e6 chore: Upgrade Anchor to 0.26.0 2022-12-21 12:41:09 +00:00
Christian Kamm eb46a030d1 Upgrade anchor to 0.24.2 2022-05-04 13:50:50 +02:00
microwavedcola1 8bfb10fb9b pretty print, remove redundant examples
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-03-17 13:48:42 +01:00
Christian Kamm dd51d3cbdd Renames
"unlocked_scaled_factor" was a confusing name because the value is
also used when computing vote weight for locked deposits. Rename to
"baseline_vote_weight_scaled_factor" and generally change "unlocked"
to "baseline" in several places.

Also rename "lockup_scaled_factor" to
"max_extra_lockup_vote_weight_scaled_factor" to highlight that it's just
the maximum contribution and that it's "extra" - on top of baseline.
2022-02-14 10:51:13 +01:00
Christian Kamm 4c5d896912 Tests: Bump max compute to 120k
The Grant instruction could randomly exceed 110k, likely due to deriving
account addresses. That would cause random ci test failure occasionally.
2022-02-14 09:10:39 +01:00
Christian Kamm b7782dcd5c LogVoterInfo: Make range configurable
Previously the instruction was hardcoded to return 16 accounts. It
turned out that this number was too big for the current limits on
compute units.
2022-02-11 13:47:47 +01: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 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
Christian Kamm b77b23d268 Grant: Separate authorities, allow the voter to grant to itself
This is done to allow governance proposals to grant to a voter from
arbitrary token accounts, as long as it's the voter themselves who
executes the proposal once the vote has succeeded.
2022-02-04 14:27:13 +01:00
Christian Kamm be8f033842 Update spl_governance fixture binary 2022-02-02 08:46:16 +01:00
Sebastian Bor 6bbae6519c chore: replace obsolete set_bpf_compute_max_units 2022-02-02 08:43:42 +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 68da83cfa9 Test: add basic one for internal_transfer_unlocked 2022-01-26 09:01:17 +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 e7ffe744e9
close vault and return rent sol (#26)
close vault and recover rent sol via remaining accounts, in close voter ix
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-01-25 14:56:15 +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 bb4c3f85ea
Remove separate clawback_authority (#15)
Just use the realm authority instead.
2021-12-20 11:01:23 +01:00
Christian Kamm afa1e30269 Tests for starting time in deposit/grant
Including a bugfix to the Grant instruction
2021-12-17 10:44:11 +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 9c8dd35ba6 Grant/CreateDeposit: Allow control of start timestamp 2021-12-17 07:51:06 +01:00
Christian Kamm ae7dea95eb Create voter requires authority signature
and can only be called once for each voter_authority.

Now that there's a separate "Grant" instruction, there's no longer a
need for CreateVoter to be idempotent and be callable on foreign
accounts.

Calling create voter manually on a PDA account could have allowed
automation.
2021-12-17 07:51:06 +01:00
Christian Kamm d877eae443 Upgrade spl-governance dependency to current master 2021-12-14 13:46:38 +01:00
Christian Kamm 3071c1edcf Update program ids for devnet deployment 2021-12-14 12:47:12 +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 b41dfae916 Grant instruction: Add separate "payer" signer
The governance PDAs can't pay.
2021-12-10 18:06:52 +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 89f5954961 Allow changing of voting mint config parameters
Previously the configure_voting_mint() instruction could only be run
once per index. Now it's allowed to call it again to change a mint's
parameters.

This will directly be useful for Mango, which will likely start out
configuring the MNGO voting mint without lockup vote scaling and then
later enable it, when the ui is ready.
2021-12-10 09:26:30 +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 573305f789 Test: Check placing something in all deposits
And reduce the compute limit in tests to half the current live limit.
2021-12-06 07:29:50 +01:00
Christian Kamm 119bdffcec Add grant instruction 2021-12-05 20:36:01 +01:00
Christian Kamm 4cbe9ad4d6 Make create_voter idempotent 2021-12-05 15:29:14 +01:00
Christian Kamm 05582700cf Make create_voter permissionless 2021-12-05 14:34:03 +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
Christian Kamm edc64452ed Address test compilation warnings 2021-12-05 09:04:04 +01:00
Christian Kamm 645f02ebd4 Tests: Add a test that checks integration with spl-governance
By making a proposal (with the necessary amount of vote weight) and
voting on it.
2021-12-05 09:00:07 +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 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 22a050e270 Remove token program from create_registrar 2021-12-03 14:05:03 +01:00
Christian Kamm aa1c536b9c Tests: check start up lockup, and withdrawable amount 2021-12-03 12:29:37 +01:00
Christian Kamm 0b049ad3f8 Add reset_lockup tests / add max period check 2021-12-03 11:38:45 +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