Skip to content

Commit

Permalink
Add ERC721 support (#82)
Browse files Browse the repository at this point in the history
* refactor: rename function to withdrawMultipleAt

* feat: implement NFT in OE contract

* test: update tests accordingly

* refactor: use modifiers only in public/external functions

* test: add transferFrom tests

test: remove ERC20 events
test: add ERC721 transfer event
test: remove unneded delegatecall tests
test: update create tests

* test: withdrawMax function

* test: withdrawMaxMultiple function

* feat: use metadata modifier in all relevant functions

test: update tests accordingly

* docs: add access control table

* build: use shanghai evm version

* docs: correct natspec in ISablierV2OpenEnded

* fix: remove to check in _update hook

feat: inherit IERC721Metadata in ISablierV2OpenEndedState
refactor: add constructor in SablierV2OpenEnded
  • Loading branch information
andreivladbrg authored May 20, 2024
1 parent 4405fdf commit 73c0dce
Show file tree
Hide file tree
Showing 46 changed files with 1,301 additions and 646 deletions.
38 changes: 17 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,40 +125,36 @@ way he may extract more assets from stream.
We store the asset decimals, so that we don't have to make an external call to get the decimals of the asset each time a
deposit or an extraction is made. Decimals are `uint8`, meaning it is not an expensive to store them.

Recipient address **must** be checked because there is no NFT minted in `_create` function.

Sender address **must** be checked because there is no `ERC20` transfer in `_create` function.

In `_cancel` function we can perform both sender and recipient `ERC20` transfers because there is no NFT so we don’t
have to worry about [this issue](https://github.com/cantinasec/review-sablier/issues/11).

### Invariants:

_balance = withdrawable amount + refundable amount_
_withdrawable amount = min(balance, streamed amount) + remaining amount_

_balance = withdrawable amount + refundable amount - remaining amount_

_balance = sum of deposits - sum of withdrawals_

_withdrawable amount ≀ streamed amount_
_withdrawable amount - remaining amount ≀ streamed amount_

_sumΒ of withdrawn amounts ≀ sum of deposits_

_sumΒ of withdrawn amounts ≀ sum of deposits_

_sum of stream balances normilized to asset decimals ≀ asset.balanceOf(SablierV2OpenEnded)_

_lastTimeUpdate ≀ block.timestamp;_

_if(isCanceled = true) then balance = 0 && ratePerSecond = 0_

### Questions:

Should we update the time in `_cancel`?

Should we add `TimeUpdated` event?

Should we add `pause` function? Basically it would be a duplication of `cancel` function.
_if(isCanceled = true) then balance = 0 && ratePerSecond = 0 && withdrawable amount = remaining amount_

### TODOs:
### Actions Access Control:

- createMultiple
- withdrawMultiple
- add broker fees
- The fee should be on `create` or on `deposit` ? both?
| Action | Sender | Recipient | Operator(s) | Unkown User |
| ------------------- | :----: | :-------: | :---------: | :--------------------: |
| AdjustRatePerSecond | βœ… | ❌ | ❌ | ❌ |
| Cancel | βœ… | ❌ | ❌ | ❌ |
| Deposit | βœ… | βœ… | βœ… | βœ… |
| RefundFromStream | βœ… | ❌ | ❌ | ❌ |
| RestartStream | βœ… | ❌ | ❌ | ❌ |
| Transfer NFT | ❌ | βœ… | βœ… | ❌ |
| Withdraw | βœ… | βœ… | βœ… | βœ… (only to Recipient) |
6 changes: 2 additions & 4 deletions foundry.toml
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
[profile.default]
auto_detect_solc = false
bytecode_hash = "none"
evm_version = "paris"
evm_version = "shanghai"
fs_permissions = [
{ access = "read", path = "package.json" },
{ access = "read", path = "./out" },
{ access = "read", path = "./out-optimized" },
{ access = "read-write", path = "./cache" },
{ access = "read", path = "./out-optimized" }
]
gas_reports = ["*"]
optimizer = true
Expand Down
Loading

0 comments on commit 73c0dce

Please sign in to comment.