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

hotfix: Add #[payable] attribute to vault deposit() and withdraw() functions #51

Merged
merged 2 commits into from
Jan 10, 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
2 changes: 2 additions & 0 deletions examples/src6-vault/multi_token_vault/src/main.sw
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ storage {
}

impl SRC6 for Contract {
#[payable]
#[storage(read, write)]
fn deposit(receiver: Identity, vault_sub_id: SubId) -> u64 {
let asset_amount = msg_amount();
Expand Down Expand Up @@ -76,6 +77,7 @@ impl SRC6 for Contract {
shares
}

#[payable]
#[storage(read, write)]
fn withdraw(
receiver: Identity,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ storage {
}

impl SRC6 for Contract {
#[payable]
#[storage(read, write)]
fn deposit(receiver: Identity, vault_sub_id: SubId) -> u64 {
require(vault_sub_id == ACCEPTED_SUB_VAULT, "INVALID_vault_sub_id");
Expand Down Expand Up @@ -69,6 +70,7 @@ impl SRC6 for Contract {
shares
}

#[payable]
#[storage(read, write)]
fn withdraw(
receiver: Identity,
Expand Down
2 changes: 2 additions & 0 deletions examples/src6-vault/single_token_vault/src/main.sw
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ configurable {
}

impl SRC6 for Contract {
#[payable]
#[storage(read, write)]
fn deposit(receiver: Identity, vault_sub_id: SubId) -> u64 {
let asset_amount = msg_amount();
Expand Down Expand Up @@ -83,6 +84,7 @@ impl SRC6 for Contract {
shares
}

#[payable]
#[storage(read, write)]
fn withdraw(
receiver: Identity,
Expand Down
2 changes: 2 additions & 0 deletions standards/src6-vault/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,11 @@ Incorrect implementation of token vaults could allow attackers to steal underlyi

```sway
abi SRC6 {
#[payable]
#[storage(read, write)]
fn deposit(receiver: Identity, vault_sub_id: SubId) -> u64;

#[payable]
#[storage(read, write)]
fn withdraw(receiver: Identity, underlying_asset: AssetId, vault_sub_id: SubId) -> u64;

Expand Down
2 changes: 2 additions & 0 deletions standards/src6-vault/src/src6.sw
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ abi SRC6 {
/// * If the asset is not supported by the contract.
/// * If the amount of assets forwarded to the contract is zero.
/// * The user crosses any global or user specific deposit limits.
#[payable]
#[storage(read, write)]
fn deposit(receiver: Identity, vault_sub_id: SubId) -> u64;

Expand All @@ -78,6 +79,7 @@ abi SRC6 {
/// * If the amount of shares is zero.
/// * If the transferred shares do not corresspond to the given asset.
/// * The user crosses any global or user specific withdrawal limits.
#[payable]
#[storage(read, write)]
fn withdraw(
receiver: Identity,
Expand Down
Loading