The FSN Vaults contract allows 2 wallets to trade escrows of tokens between eachother in a trustless manner
The escrows can contain any number of native, cw20, or cw721 tokens
Say we have 2 users:
Alice
- the seller
Bob
- the buyer
Alice wants to sell 5 FSN
+ 10 CW20
+ Dog NFT #3
At a price of 10 OSMO
+ Cat NFT #8
In order, Alice will
- Create a listing with
ExecuteMsg::CreateListing
, sending5 FSN
along with the message - Send
10 CW20
+Dog NFT #3
to the contract, specifying the Listing ID in each message - Call
ExecuteMsg::Finalize
, specifying anExpiration
- Once
Finalize
has been called, the listing can be purchased and Alice can no longer make changes - If the listing is not purchased before
Expiration
, Alice can callExecuteMsg::Refund
to remove the funds + delete the Listing
- Once
Bob sees this listing and wants to buy it
In order, Bob will
- Create a bucket with
ExecuteMsg::CreateListing
, sending10 OSMO
along with the message - Send
Cat NFT #8
to the contract, specifying the Bucket ID in the message - Call
ExecuteMsg::BuyListing
, specifying the listing ID being purchased (listing_id: 1
), and the bucket ID to use (bucket_id: 1
)
If the assets in Bucket #1
match the price of Listing #1
, ownership of each will be traded between them
Now that the trade is complete, both Alice and Bob can remove their proceeds from the contract
Alice can now remove sale proceeds by calling ExecuteMsg::RemoveBucket {bucket_id: 1}
Bob can now remove purchase proceeds by calling ExecuteMsg::WithdrawPurchased {listing_id: 1}