Mark Spanbroek
81032965f4
vault: update documentation
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
43cd44330b
vault: add documentation
2025-03-04 09:36:00 +01:00
Mark Spanbroek
439d3772db
vault: remove dead code
2025-03-04 09:36:00 +01:00
Mark Spanbroek
b7b1e8c25b
vault: cleanup
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
b076528e1a
vault: reduce size of timestamp further
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
297ec7f6b3
vault: cleanup
2025-03-04 09:36:00 +01:00
Mark Spanbroek
f9464f9118
vault: combine Account and Flow structs
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
2600578b48
vault: formatting
2025-03-04 09:36:00 +01:00
Mark Spanbroek
ee6d56a54b
vault: reordering
2025-03-04 09:36:00 +01:00
Mark Spanbroek
16f853b5d8
vault: simplify _getAccount()
2025-03-04 09:36:00 +01:00
Mark Spanbroek
bdc721bfaa
vault: _getAccount updates to the latest timestamp
2025-03-04 09:36:00 +01:00
Mark Spanbroek
2108f1265a
vault: combine account and flow mappings
2025-03-04 09:36:00 +01:00
Mark Spanbroek
68d93fa5b5
vault: rename balance -> account
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
f64c373e8f
vault: reorder functions
...
in roughly chronological order
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
c1031d3b07
vault: delete flow when burning or withdrawing
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
f0da7cd918
vault: check Lock invariant before writing
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