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

SRC-6 example contract does not update managed assets #122

Merged
merged 6 commits into from
Jul 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ Description of the upcoming release here.

### Added Unreleased

- Something new here 1
- Something new here 2
- Something new here

### Changed Unreleased

Expand All @@ -22,8 +21,9 @@ Description of the upcoming release here.
### Fixed Unreleased

- [#121](https://github.com/FuelLabs/sway-standards/pull/121) Fixes the `deposit` function in the SRC-6 standard, uses try_read instead of read in order to allow first time deposits to a vault.
- [#122](https://github.com/FuelLabs/sway-standards/pull/122) Fixes the SRC-6 example contract from a critical bug where the contract can be drained.

#### Breaking Unreleased
### Breaking Unreleased

- Some breaking change here 1
- Some breaking change here 2
Expand Down
4 changes: 4 additions & 0 deletions examples/src6-vault/multi_asset_vault/src/main.sw
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ impl SRC6 for Contract {
require(msg_asset_id() == share_asset_id, "INVALID_ASSET_ID");
let assets = preview_withdraw(share_asset_id, shares);

let mut vault_info = storage.vault_info.get(share_asset_id).read();
vault_info.managed_assets = vault_info.managed_assets - shares;
bitzoic marked this conversation as resolved.
Show resolved Hide resolved
storage.vault_info.insert(share_asset_id, vault_info);

_burn(share_asset_id, share_asset_vault_sub_id, shares);

transfer(receiver, underlying_asset, assets);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ impl SRC6 for Contract {
require(msg_asset_id() == share_asset_id, "INVALID_ASSET_ID");
let assets = preview_withdraw(shares);

storage
.managed_assets
.write(storage.managed_assets.read() - shares);

_burn(share_asset_id, shares);

transfer(receiver, underlying_asset, assets);
Expand Down
4 changes: 4 additions & 0 deletions examples/src6-vault/single_asset_vault/src/main.sw
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@ impl SRC6 for Contract {
require(msg_asset_id() == share_asset_id, "INVALID_ASSET_ID");
let assets = preview_withdraw(share_asset_id, shares);

let mut vault_info = storage.vault_info.get(share_asset_id).read();
vault_info.managed_assets = vault_info.managed_assets - shares;
bitzoic marked this conversation as resolved.
Show resolved Hide resolved
storage.vault_info.insert(share_asset_id, vault_info);

_burn(share_asset_id, share_asset_vault_sub_id, shares);

transfer(receiver, underlying_asset, assets);
Expand Down
Loading