ref-finance / ref-contracts

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

Let user directly got near when withdraw wnear at contract level #42

Open marco-sundsk opened 2 years ago

marco-sundsk commented 2 years ago

Basically, we should let user got near directly when he withdraw wrapped-near. Now, this feature is implemented at frontend. It raise our ref withdraw. followed by a wrap.near::near_deposit action when it recognizes the token is wnear. But these chain transactions has a little probability that can be interrupted by accident like page close or temp network failure.

Actually, there is a way to get these two actions done in our ref contract level. That is, when user withdraw wnear, we first unwrap it as ref-contract and got near back in ref-contract account, and then transfer those native near from ref-contract to user's account. In that way, all work can be done in one contract call to the ref-contract with a total success or failure, nothing can interrupt the two actions due to the powerful NEAR cross-contract call technique.