Skip to content

Commit

Permalink
Merge pull request #51 from FuelLabs/bitzoic-vault-hotfix
Browse files Browse the repository at this point in the history
hotfix: Add `#[payable]` attribute to vault `deposit()` and `withdraw()` functions
  • Loading branch information
bitzoic authored Jan 10, 2024
2 parents 77cdc14 + 3a27160 commit 96a223c
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 0 deletions.
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
2 changes: 2 additions & 0 deletions examples/src6-vault/single_token_single_sub_vault/src/main.sw
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

0 comments on commit 96a223c

Please sign in to comment.