ref-finance / ref-contracts

Smart contracts for Ref Finance
MIT License
96 stars 54 forks source link

need handle deposited near attatched in execute_actions #56

Open marco-sundsk opened 2 years ago

marco-sundsk commented 2 years ago

If user call swap or execute_actions with some near attatched, the contract now does not count them into user's storage deposited nor refund them. When the amonut is large, it would cause much trouble for user to re-claim them back.

The fix may be like this:

#[payable]
pub fn execute_actions(
  ... ...
  if env::attached_deposit() == 0 {
     ... ...
  } else {
      account.near_amount += env::attached_deposit();
  }
  ... ...
}

Then, user can call storage_withdraw to re-claim unused deposited near back by himself.