Mark Spanbroek
bddbd02f02
marketplace: burn tokens in vault when slashing
...
- move all collateral calculatons to separate library
2025-03-04 09:36:10 +01:00
Mark Spanbroek
639466662d
marketplace: simplify withdrawing by client
...
- removes RequestCancelled event, which was not great anyway
because it is not emitted at the moment that the request is
cancelled
2025-03-04 09:36:10 +01:00
Mark Spanbroek
1e74be6243
marketplace: remove accounting that is now done by vault
2025-03-04 09:36:10 +01:00
Mark Spanbroek
83a59d8227
marketplace: use Timestamp, Duration and TokensPerSecond types
2025-03-04 09:36:10 +01:00
Mark Spanbroek
8df557801c
marketplace: use vault in marketplace
2025-03-04 09:36:10 +01:00
Mark Spanbroek
8b40f63693
marketplace: remove support for changing payout addresses
2025-03-04 09:36:10 +01:00
Mark Spanbroek
d5ab2ecf8d
marketplace: deploy vault and set it in the marketplace
2025-03-04 09:36:10 +01:00
Mark Spanbroek
edee270eca
vault: rename Lock -> Fund
2025-03-04 09:36:00 +01:00
Mark Spanbroek
96b4fc0eff
vault: rename lock states
...
- NoLock -> Inactive
- Unlocked -> Withdrawing
2025-03-04 09:36:00 +01:00
Mark Spanbroek
62aea75295
vault: freezeFund() instead of burnFund()
2025-03-04 09:36:00 +01:00
Mark Spanbroek
6db1a5fb3a
vault: only allow account holder to withdraw for itself
2025-03-04 09:36:00 +01:00
Mark Spanbroek
95a698c574
vault: allow for multiple accounts for one account holder
2025-03-04 09:36:00 +01:00
Mark Spanbroek
b64c64aff8
vault: rename account->holder in tests
2025-03-04 09:36:00 +01:00
Mark Spanbroek
4c46f2d1a0
vault: pausing and unpausing
2025-03-04 09:36:00 +01:00
Mark Spanbroek
15e7ae855d
vault: cleanup tests
2025-03-04 09:36:00 +01:00
Mark Spanbroek
79c127b80e
update openzeppelin contracts to 5.2.0
2025-03-04 09:36:00 +01:00
Mark Spanbroek
473a5fec19
vault: fix accounting of locked value when burning designated tokens
2025-03-04 09:36:00 +01:00
Mark Spanbroek
dc3084836f
vault: prefix errors with 'Vault'
2025-03-04 09:36:00 +01:00
Mark Spanbroek
0a539fb017
vault: burn designated/fund allowed when flowing
2025-03-04 09:36:00 +01:00
Mark Spanbroek
ad6df66768
vault: burn part of designated tokens
2025-03-04 09:36:00 +01:00
Mark Spanbroek
3ff331b883
vault: rename burn -> burnAccount, burnAll -> burnFund
2025-03-04 09:36:00 +01:00
Mark Spanbroek
62eb07e640
vault: clean up errors
2025-03-04 09:36:00 +01:00
Mark Spanbroek
1259c2fe71
vault: test lock state transitions
2025-03-04 09:36:00 +01:00
Mark Spanbroek
e3291ed82e
vault: formatting
2025-03-04 09:36:00 +01:00
Mark Spanbroek
13d590d67b
vault: do not expose Lock internals on public api
2025-03-04 09:36:00 +01:00
Mark Spanbroek
6877078f4c
vault: transfer tokens to 0xdead when fund is burned
2025-03-04 09:36:00 +01:00
Mark Spanbroek
bbdd614579
vault: burn entire fund
2025-03-04 09:36:00 +01:00
Mark Spanbroek
682b65b24a
vault: extract common tests for unlocked funds
2025-03-04 09:36:00 +01:00
Mark Spanbroek
4533c82011
vault: prevent approval hijacking
...
- transfer ERC20 funds into the vault from the
controller, not from the user
- prevents an attacker from hijacking a user's
ERC20 approval to move tokens into a part of
the vault that is controlled by the attacker
2025-03-04 09:36:00 +01:00
Mark Spanbroek
6980acd59b
vault: rename error
2025-03-04 09:36:00 +01:00
Mark Spanbroek
026609e3c7
vault: remove _getAccount()
...
- no longer calculate flow updates when not needed
- use account.update(timestamp) where needed
- use _getBalance() to view current balance
2025-03-04 09:36:00 +01:00
Mark Spanbroek
a83a6f4cad
vault: fix transfer to self
2025-03-04 09:36:00 +01:00
Mark Spanbroek
450e5308d9
vault: split flow into incoming and outgoing
...
- no need to deal with signed integers anymore
- allows flow to self to designate tokens over time
2025-03-04 09:36:00 +01:00
Mark Spanbroek
5d3683383d
vault: do not delete lock when burning
2025-03-04 09:36:00 +01:00
Mark Spanbroek
fdc642b1df
vault: rename context -> fund
2025-03-04 09:36:00 +01:00
Mark Spanbroek
6e531f2087
vault: only allow deposit, transfer, etc when locked
2025-03-04 09:36:00 +01:00
Mark Spanbroek
3864559d85
vault: reorder tests
2025-03-04 09:36:00 +01:00
Mark Spanbroek
33b61f1bf6
vault: cleanup
2025-03-04 09:36:00 +01:00
Mark Spanbroek
f26cb9c04d
vault: delete lock all tokens are withdrawn or burned
2025-03-04 09:36:00 +01:00
Mark Spanbroek
140917eed3
vault: document setAutomine()
2025-03-04 09:36:00 +01:00
Mark Spanbroek
d0b8f961b2
vault: disallow designating of flowing tokens
2025-03-04 09:36:00 +01:00
Mark Spanbroek
4c6c68f9d9
vault: fix flaky time sensitive tests
...
Ensures that setting of lock and starting of
flow happen in the same block.
Therefore hardhat cannot occasionally increase
the timestamp between the two operations.
This makes predicting the balances over time
much easier.
2025-03-04 09:36:00 +01:00
Mark Spanbroek
a0e3a51b37
vault: cannot burn flowing tokens
2025-03-04 09:36:00 +01:00
Mark Spanbroek
82d490c8d0
vault: disallow transfer of flowing tokens
2025-03-04 09:36:00 +01:00
Mark Spanbroek
687c78a56f
vault: simplify example flow rates in test
2025-03-04 09:36:00 +01:00
Mark Spanbroek
9cb049d6a4
vault: allow flows to be diverted to others
2025-03-04 09:36:00 +01:00
Mark Spanbroek
220b648758
vault: change flows over time
2025-03-04 09:36:00 +01:00
Mark Spanbroek
41005cf42c
vault: make tests a bit more robust
2025-03-04 09:36:00 +01:00
Mark Spanbroek
eff9cc1acb
vault: reject negative flows
2025-03-04 09:36:00 +01:00
Mark Spanbroek
db8b06a51b
vault: flow to multiple recipients
...
- changes balance from uint256 -> uint128
so that entire Balance can be read or written
with a single operation
- moves Lock to library
- simplifies lock checks
2025-03-04 09:36:00 +01:00