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

Add ERC721 support #82

Merged
merged 12 commits into from
May 20, 2024
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