Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Audit Fixes - System Changes - Code Refactoring - Mega Merge #17

Merged
merged 363 commits into from
Nov 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
363 commits
Select commit Hold shift + click to select a range
121bede
chore: comment
GalloDaSballo Oct 15, 2024
5d34676
chore: comment
GalloDaSballo Oct 15, 2024
e80a9ce
feat: simplify claim logic
GalloDaSballo Oct 15, 2024
5f863c3
feat: pretty close to done
GalloDaSballo Oct 16, 2024
cf0f98c
feat: cache data for `unregisterInitiative`
GalloDaSballo Oct 16, 2024
3660391
gas: `claimForInitiative`
GalloDaSballo Oct 16, 2024
16bf1d3
fix: remove extra SSTORE
GalloDaSballo Oct 16, 2024
6309c90
feat: FSM + Crit notice
GalloDaSballo Oct 16, 2024
ad3d9f8
Merge branch 'exp-external-functions-fsm' into dev-governance-refactor
GalloDaSballo Oct 16, 2024
83657b5
gas: remove extra 0 check
GalloDaSballo Oct 16, 2024
6b15ed6
chore: cleanup
GalloDaSballo Oct 16, 2024
b45e6a6
fix: Critical accounting bug
GalloDaSballo Oct 16, 2024
0ae541f
chore: future
GalloDaSballo Oct 16, 2024
3927a88
feat: broken key test
GalloDaSballo Oct 16, 2024
56b162d
chore: cleanup
GalloDaSballo Oct 16, 2024
7d375b1
chore: fixes to properties
GalloDaSballo Oct 16, 2024
568f189
chore: sample broken pro
GalloDaSballo Oct 16, 2024
506bf03
feat: view acounting properties
GalloDaSballo Oct 16, 2024
60f12ae
fix: dorky bug
GalloDaSballo Oct 16, 2024
c81f05d
feat: broken property
GalloDaSballo Oct 16, 2024
1541192
feat: trophies
GalloDaSballo Oct 16, 2024
85eecdd
chore: cleanuop
GalloDaSballo Oct 16, 2024
4581c3e
feat: e2e test + make invariant tests more reliable
GalloDaSballo Oct 16, 2024
b6fc28a
chore: further simplify trophy
GalloDaSballo Oct 16, 2024
e4ef357
feat: document the vote vs veto bug
GalloDaSballo Oct 16, 2024
62ed071
feat: e2e test for unregistering
GalloDaSballo Oct 16, 2024
e26ab76
chore: improved README
GalloDaSballo Oct 16, 2024
36f8327
Merge pull request #16 from liquity/dev-governance-refactor
GalloDaSballo Oct 16, 2024
e58a78d
test: unit tests for voting power
nican0r Oct 16, 2024
7bc3cc0
test: more unit + fuzz tests related to voting power
nican0r Oct 16, 2024
227e58b
chore: fuzz run config in gov test
nican0r Oct 16, 2024
d49fa86
test: property_sum_of_user_voting_weights
nican0r Oct 16, 2024
8ac37b2
Merge branch 'dev' into voting-power-tests
GalloDaSballo Oct 17, 2024
d5273b2
feat: voting power tests
GalloDaSballo Oct 17, 2024
cf99ff2
chore: comment on FLs
GalloDaSballo Oct 17, 2024
db99a5b
Merge pull request #41 from liquity/voting-power-tests
GalloDaSballo Oct 17, 2024
25943b6
bump
GalloDaSballo Oct 17, 2024
df8183e
chore: known issues
GalloDaSballo Oct 17, 2024
9b3ff2c
fix: test_voting_power_no_increase_in_same_epoch_as_allocation -> tes…
nican0r Oct 17, 2024
8bd035b
Merge branch 'voting-power-tests' into dev
GalloDaSballo Oct 17, 2024
f15f6a7
chore: additional asserts
GalloDaSballo Oct 17, 2024
df2c57e
chore: fix deploy
GalloDaSballo Oct 17, 2024
493be5f
fix: issue with TS
GalloDaSballo Oct 17, 2024
c37f3c5
feat: do a test with overflows enabled
GalloDaSballo Oct 17, 2024
176d3fd
chore: revert before start
GalloDaSballo Oct 17, 2024
12023ec
chore: fix
GalloDaSballo Oct 17, 2024
52633e3
chore: kind of a trophy
GalloDaSballo Oct 17, 2024
4eaaec7
chore: echidna campaign
GalloDaSballo Oct 17, 2024
d7e74de
chore: comment
GalloDaSballo Oct 17, 2024
bc0d28e
test: bribe claiming unit tests
nican0r Oct 17, 2024
2a030c8
feat: global property
GalloDaSballo Oct 17, 2024
7b313fa
test: fuzzed bribe claiming test
nican0r Oct 17, 2024
6d22b56
fix: property
GalloDaSballo Oct 17, 2024
103edd5
chore: docs
GalloDaSballo Oct 17, 2024
d91a1d4
test: property_BI06
nican0r Oct 17, 2024
46b7b15
test: property_BI07
nican0r Oct 17, 2024
8e3d762
chore: property_BI08
nican0r Oct 17, 2024
74e23e7
chore: property_BI09
nican0r Oct 17, 2024
2570c9b
chore: property_BI10
nican0r Oct 17, 2024
243ecfc
chore: property_BI10
nican0r Oct 17, 2024
062a563
chore: fixing BribeInitiative property implementations
nican0r Oct 17, 2024
fdaafaf
chore: unit tests for avg ts issue affecting voting power when claiming
nican0r Oct 17, 2024
85ceaf0
Merge branch 'dev' into bribes-tests
GalloDaSballo Oct 18, 2024
b050d61
feat: broken prop
GalloDaSballo Oct 18, 2024
fb6079d
Merge pull request #46 from liquity/bribes-tests
GalloDaSballo Oct 18, 2024
7310f83
fix: test_claimBribes
GalloDaSballo Oct 18, 2024
662f7ec
chore: clarify bug in `test_splitting_allocation`
GalloDaSballo Oct 18, 2024
8c8e530
chore: comment
GalloDaSballo Oct 18, 2024
6a56a5c
chore: remove unnecessary test
GalloDaSballo Oct 18, 2024
f91acf8
feat: tests on governance power math
GalloDaSballo Oct 18, 2024
d05c6ff
feat: initial change to governance to reset and set, BUGGED
GalloDaSballo Oct 18, 2024
5c51e64
fix: test
GalloDaSballo Oct 18, 2024
6359898
chore: docs
GalloDaSballo Oct 18, 2024
b7ac3cd
feat: new properties
GalloDaSballo Oct 18, 2024
9a9bb08
chore: cooldown to warmup
GalloDaSballo Oct 18, 2024
4342da5
fix: basically shows the change
GalloDaSballo Oct 18, 2024
0f65b90
chore: comments
GalloDaSballo Oct 18, 2024
8a7121e
feat: overflow property
GalloDaSballo Oct 18, 2024
8a627f5
chore: space
GalloDaSballo Oct 18, 2024
f6b4ef0
Merge pull request #11 from GalloDaSballo/fix-v4-claim
GalloDaSballo Oct 18, 2024
5bdf44e
fix: Governance tests for resetting allocation change
nican0r Oct 18, 2024
e7c94d0
fix: bribe unit tests for resetting allocation
nican0r Oct 18, 2024
9af4f74
fix: voting power unit tests for resetting allocation
nican0r Oct 18, 2024
9b5c787
Merge branch 'fix-reset-votes' of github.com:liquity/V2-gov into fix-…
GalloDaSballo Oct 19, 2024
cae9abb
fix: merge and tests
GalloDaSballo Oct 19, 2024
578a57e
Merge pull request #49 from liquity/fix-reset-votes
GalloDaSballo Oct 19, 2024
a4add3d
chore: valid repro
GalloDaSballo Oct 19, 2024
9c11366
Merge branch 'fix-reset-votes' into dev
GalloDaSballo Oct 19, 2024
4b2a1ef
chore: trophies
GalloDaSballo Oct 19, 2024
174c097
chore: comments
GalloDaSballo Oct 19, 2024
fb96481
feat: improved docs
GalloDaSballo Oct 19, 2024
a7becc0
feat: voting power from start
GalloDaSballo Oct 19, 2024
38b32cb
chore: change to properties and code | tests are BROKEN
GalloDaSballo Oct 19, 2024
d79d638
fix: debug valid trophy
GalloDaSballo Oct 19, 2024
c5ed663
fix: BI3 and Bi4
GalloDaSballo Oct 19, 2024
602a7ef
fix BI11
GalloDaSballo Oct 19, 2024
4082050
chore: repros
GalloDaSballo Oct 19, 2024
886f0f9
feat: better docs, invariants and TODOs
GalloDaSballo Oct 19, 2024
29b8b76
feat: claim soundness property
GalloDaSballo Oct 19, 2024
295ac1a
fix: BI04
GalloDaSballo Oct 19, 2024
36446ab
fix: explicitly prevent loading future epochs
GalloDaSballo Oct 19, 2024
9af43f3
fix: invariant limit
GalloDaSballo Oct 19, 2024
2baaaeb
chore: natspec
GalloDaSballo Oct 19, 2024
3e5bcc6
chore: comment
GalloDaSballo Oct 19, 2024
7c055d4
fix: property and added a utility view function for epoch calculations
GalloDaSballo Oct 19, 2024
f6ba744
chore: cleanup
GalloDaSballo Oct 20, 2024
c63c870
chore: cleanup
GalloDaSballo Oct 20, 2024
d4bbc74
feat: testing + pass at readme
GalloDaSballo Oct 20, 2024
7c6de41
feat: investigation into bribes accounting issue
GalloDaSballo Oct 20, 2024
cf83655
feat: repro fro bug
GalloDaSballo Oct 20, 2024
38a74f3
fix: mismatch amount
GalloDaSballo Oct 20, 2024
7bc90a8
Merge pull request #51 from liquity/exp-fix-register
jltqy Oct 21, 2024
3eaec6b
Merge pull request #56 from liquity/exp-fix-cap-bribes-mismatch
jltqy Oct 21, 2024
b89c8b3
Merge branch 'dev' into exp-unregisterable-fsm
GalloDaSballo Oct 21, 2024
9d0a09b
fix: tests that were valid
GalloDaSballo Oct 21, 2024
f529432
Merge pull request #52 from liquity/exp-unregisterable-fsm
jltqy Oct 21, 2024
5e236ca
Merge pull request #53 from liquity/exp-fix-future-lookup
jltqy Oct 21, 2024
d6b922e
Forge fmt
jltqy Oct 21, 2024
168760d
Fix warning and code style
jltqy Oct 21, 2024
ef52337
fix: extra check for reverts
GalloDaSballo Oct 23, 2024
ab6e95c
feat: test that shows bug in total voting power
GalloDaSballo Oct 28, 2024
92a5b07
feat: minimal extra test to check `DISABLED` math accounting
GalloDaSballo Oct 28, 2024
429f02f
fix: incorrect accounting from DISABLED initiatives
GalloDaSballo Oct 28, 2024
3a529e6
chore: cleanup
GalloDaSballo Oct 28, 2024
28ee9fe
polish: explicit non negative checks
GalloDaSballo Oct 28, 2024
8c35064
chore: audit tags
GalloDaSballo Oct 28, 2024
549877d
chore: cleanup trophies
GalloDaSballo Oct 28, 2024
6700b41
Merge branch 'dev' of github.com:liquity/V2-gov into dev-fix-properties
GalloDaSballo Oct 28, 2024
7859f62
fix: use calldata to check dups
GalloDaSballo Oct 28, 2024
c8b5ec3
fix: use `_encodeLQTYAllocation`
GalloDaSballo Oct 28, 2024
8865787
fix: edge case of remainer
GalloDaSballo Oct 28, 2024
d5838a8
feat: use remainer and amount
GalloDaSballo Oct 28, 2024
9ad09cf
chore: rename _deposit
GalloDaSballo Oct 29, 2024
8e6a645
chore: cleanup
GalloDaSballo Oct 29, 2024
0266514
feat: stateful test for reset soundness
GalloDaSballo Oct 29, 2024
aff1bef
chore: undo yolo reset change
GalloDaSballo Oct 29, 2024
4a73edc
feat: can be reprod manually
GalloDaSballo Oct 29, 2024
432e88c
chore: repro
GalloDaSballo Oct 29, 2024
5a82349
chore: future notes on V2 Gauge
GalloDaSballo Oct 29, 2024
696cfde
chore: make tests compile
GalloDaSballo Oct 29, 2024
66a29a0
feat: aded reset alloc calls
GalloDaSballo Oct 29, 2024
5cfeff0
feat: new property for reset
GalloDaSballo Oct 29, 2024
b2972be
chore: comments
GalloDaSballo Oct 29, 2024
5ac7754
Merge branch 'cs-prelim-fixes' into fix-audit-and-invariants
GalloDaSballo Oct 29, 2024
2f59274
Merge branch 'exp-reset-all' into fix-audit-and-invariants
GalloDaSballo Oct 29, 2024
81f3e55
chore: comment
GalloDaSballo Oct 29, 2024
a4a40bf
chore: spaces
GalloDaSballo Oct 30, 2024
640208d
feat: registerable test
GalloDaSballo Oct 30, 2024
11d65f4
fix: governance UNREGISTER fsm
GalloDaSballo Oct 30, 2024
cb0c95a
feat: allocation reset check is optional
GalloDaSballo Oct 30, 2024
14e147e
chore: remove old repro
GalloDaSballo Oct 30, 2024
626f507
chore: clean up shadowing
GalloDaSballo Oct 30, 2024
f9628e8
chore: cleanuo
GalloDaSballo Oct 30, 2024
d3ff4af
Merge pull request #64 from liquity/fix-dd-review
GalloDaSballo Oct 30, 2024
78688ab
chore: cleanup
GalloDaSballo Oct 30, 2024
ef8bd64
feat: alignment
GalloDaSballo Oct 31, 2024
afc0eea
feat: repro of insolvency property
GalloDaSballo Oct 31, 2024
14a5030
chore: compilation
GalloDaSballo Oct 31, 2024
2a27ce6
chore: repro
GalloDaSballo Oct 31, 2024
79cc29f
fix: property specification ignored DISABLED initiatives
GalloDaSballo Oct 31, 2024
0b899e8
fix: needless empty values
GalloDaSballo Oct 31, 2024
998cd9f
chore: remove shadowing
GalloDaSballo Oct 31, 2024
2378fcc
feat: debug BI07
GalloDaSballo Oct 31, 2024
d622bd5
feat: additional optimization tests
GalloDaSballo Oct 31, 2024
cca360b
chore: opt
GalloDaSballo Oct 31, 2024
d8f97ce
chore: default to optimization
GalloDaSballo Oct 31, 2024
d29f57c
fix: BribeInitiativeAllocate tests
nican0r Oct 31, 2024
c931d57
Merge branch 'fix-temp-invariant-align-bribes' of https://github.com/…
nican0r Oct 31, 2024
3f7705a
feat: revert properties for all tests
GalloDaSballo Oct 31, 2024
33ece7f
Merge pull request #67 from liquity/fix-temp-invariant-align-bribes
GalloDaSballo Oct 31, 2024
e1df25c
chore: cleanup
GalloDaSballo Oct 31, 2024
b18c629
chore: e2E
GalloDaSballo Oct 31, 2024
f693d5f
fix: cap amount for bribes
GalloDaSballo Oct 31, 2024
01457bd
chore: desc
GalloDaSballo Oct 31, 2024
a589a29
feat: upscale ts to u120
GalloDaSballo Nov 1, 2024
7e777ae
feat: tests somewhat compile
GalloDaSballo Nov 1, 2024
d27487f
feat: invariants compile and have a few TS tests
GalloDaSballo Nov 1, 2024
5d69f9a
chore: easy tests are fixed
GalloDaSballo Nov 1, 2024
4b75ce1
chore: fix mock tests
GalloDaSballo Nov 1, 2024
7c8a577
fix: epochStart is magnified with a hacky solution
GalloDaSballo Nov 1, 2024
105bc32
fix: test ts are magnified
GalloDaSballo Nov 1, 2024
075bf4b
chore: fix overflow
GalloDaSballo Nov 1, 2024
dc845b3
fix: abi decode
GalloDaSballo Nov 1, 2024
28fe9d9
fix: BI-07
GalloDaSballo Nov 1, 2024
56d8e86
WARNING: Add tollerance
GalloDaSballo Nov 1, 2024
d82a0c3
feat: laxer property
GalloDaSballo Nov 1, 2024
6482f51
feat: debug and fix properties
GalloDaSballo Nov 1, 2024
4db439e
fix: BI07
GalloDaSballo Nov 1, 2024
723e9e1
feat: truncation but maybe not so bad
GalloDaSballo Nov 1, 2024
90af7db
fix: we need a higher confidence range
GalloDaSballo Nov 1, 2024
d559696
feat: raise the precision to 1e26
GalloDaSballo Nov 1, 2024
81c048e
fix: upscale the precision in bribes
GalloDaSballo Nov 1, 2024
50933d0
chore: fix tests
GalloDaSballo Nov 1, 2024
bd2cc0a
feat: trying out overflow mode
GalloDaSballo Nov 1, 2024
0572a61
chore: cleanup
GalloDaSballo Nov 1, 2024
9259e26
feat: document overflow risks
GalloDaSballo Nov 1, 2024
ceffe66
fix: overflow in timestamp math
GalloDaSballo Nov 1, 2024
426de19
chore: type consistency
GalloDaSballo Nov 1, 2024
3ecb7a2
fix: ensure user TS never decreases
GalloDaSballo Nov 1, 2024
26d4414
chore: comments on overflow risk
GalloDaSballo Nov 1, 2024
55b94aa
gas: order of operations
GalloDaSballo Nov 1, 2024
9548318
chore: rename fn
GalloDaSballo Nov 1, 2024
0246b32
chore: order of operations for gas
GalloDaSballo Nov 1, 2024
3205922
chore: consistent types
GalloDaSballo Nov 1, 2024
84fcb22
chore: added precision invariant on `getInitiativeState`
GalloDaSballo Nov 1, 2024
f4b1419
chore: custom precision change
GalloDaSballo Nov 1, 2024
04d1b16
chore: remove property that doesn't really work
GalloDaSballo Nov 1, 2024
1ea9df5
feat: add a few revert tests that can help detect overflows
GalloDaSballo Nov 1, 2024
7c96bc7
chore: undo de-optimizations
GalloDaSballo Nov 1, 2024
f210e44
chore: recommendation
GalloDaSballo Nov 1, 2024
e553fea
chore: cleanup
GalloDaSballo Nov 1, 2024
d762007
fix: approve for bribes
GalloDaSballo Nov 2, 2024
1219a02
fix: clamped claim
GalloDaSballo Nov 2, 2024
7742491
chore: cleanup and simplification
GalloDaSballo Nov 2, 2024
4ded0c7
feat: repro for claim bribe
GalloDaSballo Nov 2, 2024
d60587e
feat: extra config for running locally
GalloDaSballo Nov 2, 2024
28d6425
chore: undo config changes
GalloDaSballo Nov 2, 2024
d904b26
feat: add solvency tests for Governance
GalloDaSballo Nov 2, 2024
96de709
feat: insolvency optimization tests
GalloDaSballo Nov 2, 2024
1f0b310
chore: improved coverage and removed canaries
GalloDaSballo Nov 2, 2024
2bfb2b9
chore: make precision public
GalloDaSballo Nov 3, 2024
eb42ca1
chore: local echidna command
GalloDaSballo Nov 3, 2024
4d5526f
cleanup: remove debugged properties
GalloDaSballo Nov 3, 2024
b1b5b2b
fix: remove BI11
GalloDaSballo Nov 3, 2024
36ae4c6
fix: Total and Initiative math can only be compared on state, not sna…
GalloDaSballo Nov 3, 2024
f483b06
fix: optimization properties to use state values
GalloDaSballo Nov 3, 2024
29471b2
chore: comment on possible more checks
GalloDaSballo Nov 3, 2024
9bc1dd9
Merge pull request #68 from liquity/fix-temp-invariant-align-bribes
GalloDaSballo Nov 3, 2024
2f1abb7
chore: informational
GalloDaSballo Nov 3, 2024
c4814c0
:wq
GalloDaSballo Nov 3, 2024
e3c7bdd
feat: assertion for optimization properties
GalloDaSballo Nov 3, 2024
56a0595
feat: additional explicit overflow checks
GalloDaSballo Nov 3, 2024
1a1bd97
chore: more lower threshold canaries for optimiztion
GalloDaSballo Nov 3, 2024
7f6565c
chore: config reset
GalloDaSballo Nov 4, 2024
f510655
feat: debugging of broken properties
GalloDaSballo Nov 4, 2024
9eee4bf
chore: force specific repro
GalloDaSballo Nov 4, 2024
44359de
feat: rational checks for deposit max
GalloDaSballo Nov 4, 2024
dd6edc6
feat: repro for max impact
GalloDaSballo Nov 4, 2024
de65c89
feat: fully shrunken sequence
GalloDaSballo Nov 4, 2024
ebba848
feat: remove incorrectly broken properties
GalloDaSballo Nov 4, 2024
953a3ef
chore: remove unused tests
GalloDaSballo Nov 4, 2024
124e6f8
chore: Rename OpenZeppelin remappings
bingen Nov 4, 2024
dcea8fb
fix: Move initial initiatives to a separate function
bingen Nov 5, 2024
7d02d1c
fix: Add access control to initial initiatives
bingen Nov 6, 2024
9a645d2
Merge pull request #71 from liquity/rename_openzeppelin
bingen Nov 7, 2024
1bb2b28
fix: Add Governance owner as constructor param
bingen Nov 8, 2024
56e1858
Merge pull request #73 from liquity/owner_as_param
bingen Nov 8, 2024
a255f05
Merge pull request #70 from liquity/fix-broken-properties
danielattilasimon Nov 13, 2024
77ecdbd
chore: forge fmt
danielattilasimon Nov 13, 2024
8ee01de
Merge pull request #62 from liquity/fix-audit-and-invariants
danielattilasimon Nov 13, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,8 @@ docs/

# Dotenv file
.env

# Fuzzing
crytic-export/
echidna/
medusa/
6 changes: 3 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
[submodule "lib/v4-core"]
path = lib/v4-core
url = https://github.com/Uniswap/v4-core
[submodule "lib/solmate"]
path = lib/solmate
url = git@github.com:Transmissions11/solmate
[submodule "lib/chimera"]
path = lib/chimera
url = https://github.com/Recon-Fuzz/chimera
10 changes: 10 additions & 0 deletions Invariants.MD
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Snapshot Solvency

uint256 claim = _votesForInitiativeSnapshot.votes * boldAccrued / _votesSnapshot.votes;
For each initiative this is what the value is
If the initiative is "Claimable" this is what it receives
The call never reverts
The sum of claims is less than the boldAccrued

Veto consistency

67 changes: 49 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,48 +44,42 @@ In order to unstake and withdraw LQTY, a User must first deallocate a sufficient
Initiative can be added permissionlessly, requiring the payment of a 100 BOLD fee, and in the following epoch become active
for voting. During each snapshot, Initiatives which received as sufficient number of Votes that their incentive payout equals
at least 500 BOLD, will be eligible to Claim ("minimum qualifying threshold"). Initiatives failing to meet the minimum qualifying threshold will not qualify to claim for that epoch.
Initiatives failing to meet the minimum qualifying threshold for a claim during four consecutive epochs may be deregistered permissionlessly, requiring
reregistration to become eligible for voting again.
Initiatives failing to meet the minimum qualifying threshold for a claim during four consecutive epochs may be deregistered permissionlessly, requiring reregistration to become eligible for voting again.

Claims for Initiatives which have met the minimum qualifying threshold, can be claimed permissionlessly, but must be claimed by the end of the epoch
in which they are awarded. Failure to do so will result in the unclaimed portion being reused in the following epoch.
Claims for Initiatives which have met the minimum qualifying threshold, can be claimed permissionlessly, but must be claimed by the end of the epoch in which they are awarded. Failure to do so will result in the unclaimed portion being reused in the following epoch.

As Initiatives are assigned to arbitrary addresses, they can be used for any purpose, including EOAs, Multisigs, or smart contracts designed
for targetted purposes. Smart contracts should be designed in a way that they can support BOLD and include any additional logic about
how BOLD is to be used.
As Initiatives are assigned to arbitrary addresses, they can be used for any purpose, including EOAs, Multisigs, or smart contracts designed for targetted purposes. Smart contracts should be designed in a way that they can support BOLD and include any additional logic about how BOLD is to be used.

### Malicious Initiatives

It's important to note that initiatives could be malicious, and the system does it's best effort to prevent any DOS to happen, however, a malicious initiative could drain all rewards if voted on.

## Voting

Users with LQTY staked in Governance.sol, can allocate LQTY in the same epoch in which they were deposited. But the
effective voting power at that point would be insignificant.
Users with LQTY staked in Governance.sol, can allocate LQTY in the same epoch in which they were deposited. But the effective voting power at that point would be insignificant.

Votes can take two forms, a vote for an Initiative or a veto vote. Initiatives which have received vetoes which are both:
three times greater than the minimum qualifying threshold, and greater than the number of votes for will not be eligible for claims by being excluded from the vote count and maybe deregistered as an Initiative.

Users may split their votes for and veto votes across any number of initiatives. But cannot vote for and veto vote the same Initiative.

Each epoch is split into two parts, a six day period where both votes for and veto votes take place, and a final 24 hour period where votes
can only be made as veto votes. This is designed to give a period where any detrimental distributions can be mitigated should there be
sufficient will to do so by voters, but is not envisaged to be a regular occurance.
Each epoch is split into two parts, a six day period where both votes for and veto votes take place, and a final 24 hour period where votes can only be made as veto votes. This is designed to give a period where any detrimental distributions can be mitigated should there be sufficient will to do so by voters, but is not envisaged to be a regular occurance.

## Snapshots

Snapshots of results from the voting activity of an epoch takes place on an initiative by initiative basis in a permissionless manner.
User interactions or direct calls following the closure of an epoch trigger the snapshot logic which makes a Claim available to a
qualifying Initiative.
User interactions or direct calls following the closure of an epoch trigger the snapshot logic which makes a Claim available to a qualifying Initiative.

## Bribing

LQTY depositors can also receive bribes in the form of ERC20s in exchange for voting for a specified initiative.
This is done externally to the Governance.sol logic and should be implemented at the initiative level.
BaseInitiative.sol is a reference implementation which allows for bribes to be set and paid in BOLD + another token,
all claims for bribes are made by directly interacting with the implemented BaseInitiative contract.
BaseInitiative.sol is a reference implementation which allows for bribes to be set and paid in BOLD + another token, all claims for bribes are made by directly interacting with the implemented BaseInitiative contract.

## Example Initiatives

To facilitate the development of liquidity for BOLD and other relevant tokens after the launch of Liquity v2, initial example initiatives will be added.
They will be available from the first epoch in which claims are available (epoch 1), added in the construtor. Following epoch 1, these examples have
no further special status and can be removed by LQTY voters
They will be available from the first epoch in which claims are available (epoch 1), added in the construtor. Following epoch 1, these examples have no further special status and can be removed by LQTY voters

### Curve v2

Expand All @@ -95,3 +89,40 @@ Claiming and depositing to gauges must be done manually after each epoch in whic
### Uniswap v4

Simple hook for Uniswap v4 which implements a donate to a preconfigured pool. Allowing for adjustments to liquidity positions to make Claims which are smoothed over a vesting epoch.

## Known Issues

### Vetoed Initiatives and Initiatives that receive votes that are below the treshold cause a loss of emissions to the voted initiatives

Because the system counts: valid_votes / total_votes
By definition, initiatives that increase the total_votes without receiving any rewards are stealing the rewards from other initiatives

The rewards will be re-queued in the next epoch

see: `test_voteVsVeto` as well as the miro and comments

### User Votes, Initiative Votes and Global State Votes can desynchronize

See `test_property_sum_of_lqty_global_user_matches_0`

## Testing

To run foundry, just
```
forge test
```


Please note the `TrophiesToFoundry`, which are repros of broken invariants, left failing on purpose

### Invariant Testing

We had a few issues with Medusa due to the use of `vm.warp`, we recommend using Echidna

Run echidna with:

```
echidna . --contract CryticTester --config echidna.yaml
```

You can also run Echidna on Recon by simply pasting the URL of the Repo / Branch
31 changes: 31 additions & 0 deletions ToFix.MD
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
- Add properties check to ensure that the math is sound <- HUGE, let's add it now

A vote is: User TS * Votes
So an allocation should use that
We need to remove the data from the valid allocation
And not from a random one

I think the best test is to simply store the contribution done
And see whether removing it is idempotent

We would need a ton of work to make it even better


Specifically, if a user removes their votes, we need to see that reflect correctly
Because that's key

- From there, try fixing with a reset on deposit and withdraw

- Add a test that checks every: initiative, user allocation, ensure they are zero after a deposit and a withdrawal
- Add a test that checks every: X, ensure they use the correct TS

- From there, reason around the deeper rounding errors



Optimizations
Put the data in the storage
Remove all castings that are not safe
Invariant test it

--
10 changes: 10 additions & 0 deletions echidna.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
testMode: "property"
prefix: "optimize_"
coverage: true
corpusDir: "echidna"
balanceAddr: 0x1043561a8829300000
balanceContract: 0x1043561a8829300000
filterFunctions: []
cryticArgs: ["--foundry-compile-all"]

shrinkLimit: 100000
1 change: 1 addition & 0 deletions lib/chimera
Submodule chimera added at d5cf52
1 change: 0 additions & 1 deletion lib/solmate
Submodule solmate deleted from 97bdb2
88 changes: 88 additions & 0 deletions medusa.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
{
"fuzzing": {
"workers": 10,
"workerResetLimit": 50,
"timeout": 0,
"testLimit": 0,
"callSequenceLength": 100,
"corpusDirectory": "medusa",
"coverageEnabled": true,
"deploymentOrder": [
"CryticTester"
],
"targetContracts": [
"CryticTester"
],
"targetContractsBalances": [
"0x27b46536c66c8e3000000"
],
"constructorArgs": {},
"deployerAddress": "0x30000",
"senderAddresses": [
"0x10000",
"0x20000",
"0x30000"
],
"blockNumberDelayMax": 60480,
"blockTimestampDelayMax": 604800,
"blockGasLimit": 125000000,
"transactionGasLimit": 12500000,
"testing": {
"stopOnFailedTest": false,
"stopOnFailedContractMatching": false,
"stopOnNoTests": true,
"testAllContracts": false,
"traceAll": false,
"assertionTesting": {
"enabled": true,
"testViewMethods": true,
"panicCodeConfig": {
"failOnCompilerInsertedPanic": false,
"failOnAssertion": true,
"failOnArithmeticUnderflow": false,
"failOnDivideByZero": false,
"failOnEnumTypeConversionOutOfBounds": false,
"failOnIncorrectStorageAccess": false,
"failOnPopEmptyArray": false,
"failOnOutOfBoundsArrayAccess": false,
"failOnAllocateTooMuchMemory": false,
"failOnCallUninitializedVariable": false
}
},
"propertyTesting": {
"enabled": true,
"testPrefixes": [
"crytic_"
]
},
"optimizationTesting": {
"enabled": false,
"testPrefixes": [
"optimize_"
]
}
},
"chainConfig": {
"codeSizeCheckDisabled": true,
"cheatCodes": {
"cheatCodesEnabled": true,
"enableFFI": false
}
}
},
"compilation": {
"platform": "crytic-compile",
"platformConfig": {
"target": ".",
"solcVersion": "",
"exportDirectory": "",
"args": [
"--foundry-compile-all"
]
}
},
"logging": {
"level": "info",
"logDirectory": ""
}
}
3 changes: 3 additions & 0 deletions remappings.txt
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
v4-core/=lib/v4-core/
forge-std/=lib/forge-std/src/
@chimera/=lib/chimera/src/
openzeppelin/=lib/openzeppelin-contracts/
4 changes: 3 additions & 1 deletion script/DeploySepolia.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,12 @@ contract DeploySepoliaScript is Script, Deployers {
votingThresholdFactor: VOTING_THRESHOLD_FACTOR,
minClaim: MIN_CLAIM,
minAccrual: MIN_ACCRUAL,
epochStart: uint32(block.timestamp),
epochStart: uint32(block.timestamp - VESTING_EPOCH_START),
/// @audit Ensures that `initialInitiatives` can be voted on
epochDuration: EPOCH_DURATION,
epochVotingCutoff: EPOCH_VOTING_CUTOFF
}),
deployer,
initialInitiatives
);
assert(governance == uniV4Donations.governance());
Expand Down
Loading
Loading