220 Commits

Author SHA1 Message Date
Andrea Franz
26926c1d5e test(certora): Karma.totalDistributorAllocation can only increase (#166) 2025-03-11 08:24:57 +01:00
r4bbit
fed4446749 fix(ci): run MPLessEqualMaxMP spec on CI (#171) 2025-03-11 08:24:39 +01:00
r4bbit
ab541a818e refactor: remove unnecessary usage of __Ownable__Init
In this version we only need to call `transferOwnership()` (which is
also what's called by `__Ownable__init`).
2025-03-10 13:16:49 +01:00
r4bbit
828d65ad65 refactor(specs): exclude rule instead of including other rules 2025-03-07 15:05:27 +01:00
r4bbit
6c89793854 fix(certora): fix timeout on certora with specific config 2025-03-07 13:17:46 +01:00
Ricardo Guilherme Schmidt
e4d21b6caf feat(RewardsStreamerMP): enable extending lock period 2025-03-06 16:50:40 +01:00
Andrea Franz
50439be124 test(certora): ensure Karma owneable functions are callable only by the owner 2025-03-06 16:04:27 +01:00
r4bbit
a2b06590d9 docs(README): add sepolia deployment addresses 2025-03-06 12:08:01 +01:00
Andrea Franz
7e30c0b718 test(certora): transfer not allowed in the Karma token 2025-03-06 11:51:40 +01:00
Andrea Franz
32bb2356dc chore(KarmaNFT): use deploy script in tests 2025-03-06 11:50:07 +01:00
Andrea Franz
96e50c6818 chore(KarmaNFT): add deploy script and remove nft address var in the metadata generators 2025-03-05 11:52:30 +01:00
r4bbit
aa1addbfcd chore: downgrade to paris
We put `cancun` as evm version into the foundry toml by mistake and
ended up building on top of it with certain assumptions.

Turns out that the network we're deploying to does not support that
version so we have to compile with `paris`.

This however, also requires a downgrade of the open zeppelin libraries,
which in turn requires changes in our code base. Primarily related to
initialization of `OwnableUpgradeable` and upgrades via UUPSUpgradeable.

This commit makes all the necessary changes.
2025-03-05 11:47:30 +01:00
r4bbit
d7e0d532d1 cleanup: address linter warnings 2025-03-05 11:20:21 +01:00
Andrea Franz
62684698e5 chore(RewardsStreamerMP): remove unused ReentrancyGuardUpgradeable 2025-03-05 10:32:30 +01:00
Andrea Franz
aa3442b577 feat(Karma): make karma upgradeable 2025-02-28 14:39:15 +01:00
r4bbit
ef3abad941 refactor(TrustedCodehashAccess): add storage gap for upgrade safety
Closes #131
2025-02-28 12:07:45 +01:00
r4bbit
60081c14fb refactor: cleanup, move code around, and adjust deployscript 2025-02-28 12:05:18 +01:00
r4bbit
5755138d8a refactor(StakeMath): remove unused errors 2025-02-28 11:48:03 +01:00
Andrea Franz
ed3577f8c4 feat(Karma): allocate external rewards using the Karma contract 2025-02-27 20:48:39 +01:00
Ricardo Guilherme Schmidt
54e80e117f chore(tests): add fuzz test for rewards 2025-02-27 11:25:20 +01:00
r4bbit
48db1bffb6 docs: complete natspec comments 2025-02-26 13:04:36 +01:00
r4bbit
a51d5199ae docs(RewardsStreamerMP): add natspec comments 2025-02-26 08:31:29 +01:00
r4bbit
73e5b38da0 specs(EmergencyMode): add complementary rule for emergency mode
This rule checks explicitly which functions should not be callable when
emegency mode is enabled.
2025-02-26 08:31:09 +01:00
r4bbit
7575e965a2 refactor(RewardsStreamerMP.t.sol): fix test that causes stack too deep
error

One of our tests uses too many local variables and causes stack too deep
errors unless optimized `--via-ir`.

We've introduced `--via-ir` to work around that until a proper fix is
done. The downside of using that option is that compilation times get
significantly longer.

This commit restructures the test such that it doesn't use as many local
variables.
2025-02-25 15:06:58 +01:00
Ricardo Guilherme Schmidt
3bd9c46fb3 chore(tests): Add fuzz tests 2025-02-24 15:29:10 +01:00
Ricardo Guilherme Schmidt
8c982924b8 chore(foundry.toml): fix max_test_rejects 2025-02-24 15:29:10 +01:00
Ricardo Guilherme Schmidt
56fb0f0f38 chore(MultiplierPointsMath): fix MAX_BALANCE 2025-02-24 15:29:10 +01:00
r4bbit
9edd6ead0a docs: update overview asset 2025-02-21 12:50:17 +01:00
Andrea Franz
50b6d1a545 chore(XPToken): rename XP to Karma 2025-02-21 11:43:12 +01:00
r4bbit
dd755f1cb7 ci: add --via-ir option to coverage task
This is to avoid stack too deep errors when testing
2025-02-21 09:35:29 +01:00
r4bbit
b4b91873ed fix(certora): add prover args to config to prevent timeouts 2025-02-21 09:35:14 +01:00
r4bbit
cce4267ce4 ci: update certora CLI to 7.25.2 2025-02-20 20:02:45 +01:00
r4bbit
807f480d97 test(RewardsStreamerMP): ensure newly added fields are checked in tests
Those were missing and now added.
Because of this we're running into stack to deep errors in test, so we
have to enable `via_ir` by default for now until we split things up.
2025-02-20 17:26:56 +01:00
Andrea Franz
58f43d07ce feature(RewardsStreamerMP): add compound function and track rewards accrued by each vault 2025-02-20 17:15:17 +01:00
r4bbit
3455068e3c refactor(IStakeManager): introduce events
A bunch of state changing functions were not emitting any events.
This commit adds them.
2025-02-20 13:32:41 +01:00
r4bbit
4086dda6e2 refactor(IStakeManager): move error codes to interface and remove unused
ones

There are a bunch of error codes that are either similar to other ones
or not used at all.

This commit moves them to the interface and removes the ones that aren't
used anymore. Part of the reason we have so many unused errors becuase
they had been "reintroduced" in `StakeMath`, which we'll revisit as
well as described in #130
2025-02-20 13:10:21 +01:00
r4bbit
7acc35ff71 refactor(RewardsStreamerMP): move totalMpStaked to avoid collision
This field was added in between existing fields, causing a storage
collision and corruption of existing data.
2025-02-20 10:34:33 +01:00
r4bbit
e3d50bf695 specs: fix expected struct size 2025-02-19 17:58:15 +01:00
r4bbit
6f199313ec feat(RewardsStreamerMP): allow vaults to migrate to other vaults
This commit introduces a function `migrateToVault(address)` that allows
`StakeVault`s to migrate to other `StakeVault` instances.

The idea is that, when an upgrade was done on the stake manager, it
might introduces functions that can't be accessed through the stake
vaults that are out there.

Users will have to create new stake vault instances that provide the
necessary functionality.

`migrateToVault()` allows them to do so.

Closes #127
2025-02-19 17:58:15 +01:00
r4bbit
59226ef107 test(RewardsStreamerMP): ensure lock() reverts when vault is empty
Closes #126
2025-02-19 17:29:03 +01:00
Andrea Franz
6b31d3944f feat(RewardsStreamerMP): vaults shares are stakedBalance + mpStaked 2025-02-19 16:53:12 +01:00
r4bbit
a2e18091b2 refactor(RewardsStreamerMP): reuse modifier in enableEmergencyMode() 2025-02-19 16:36:24 +01:00
r4bbit
fb79e249fb fix(RewardsStreamerMP): ensure registerVault reverts in emergency mode
Originally, I just wanted to simplify the certora rule that,
when emergency mode is enabled, only a few selected functions can be
called.

Instead of listing all the view function as "allowed", I've moved to
using CVLs `isView` flag on the function under verification.

This however uncovered a violation where
`RewardsStreamerMP.registerVault` is allowed to be called in emergency
mode.

In theory there's no harm in registering a vault when the system is in
emergency mode, but semantically it doesn't really make sense.

`registerVault` has been accidentally added to `isViewFunction()`.
This commit fixes this by adding `onlyNotEmergencyMode` modifier to
`registerVault()`.
2025-02-19 16:17:10 +01:00
Andrea Franz
51dcb884b3 chore(RewardsStreamerMP): remove MPs from shares/weights calculations 2025-02-18 10:20:22 +01:00
r4bbit
aa67f1f628 chore: make linter happy 2025-02-06 13:21:01 +01:00
r4bbit
70a7f30d2a feat: introduce proxy clones
This commit introduces proxy clones to make create `StakeVault`s as
cheap as possible.

Major changes here are:

- Introduce `VaultFactory` which takes care of creating clones and
  registering them with the stake manager
- Make `StakeVault` and `Initializable` so it can be used as a
  "template" contract to later have proxies point to it
- Adjust the deployment script to also deploy `VaultFactory` and ensure
  The proxy is whitelisted in the stake manager
- Make use of the new proxy clones in tests
- Add a test for `TrustedCodehashAccess` that ensures the proxy
  whitelisting works and setting up a (malicious) proxy is not going to
  work

Closes #101
2025-02-06 13:21:01 +01:00
r4bbit
177aba24d6 refactor: introduce TransparentProxy in favor of StakeManagerProxy
We use `IStakeManagerProxy` to ensure instances of `TransparentProxy`
are stake managers where necessary.
2025-02-06 08:52:53 +01:00
Andrea Franz
80b85083db Update docs/xp-token.md
Co-authored-by: r4bbit <445106+0x-r4bbit@users.noreply.github.com>
2025-02-03 14:03:23 +01:00
Andrea Franz
3e699351e2 docs(XPToken): add documentation about the XP Token 2025-02-03 14:03:23 +01:00
Ricardo Guilherme Schmidt
a22da253c3 refactor(RewardStreamerMP): extract MP and Stake mathematical formulas to abstract contracts 2025-01-30 17:06:16 +01:00