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

Add a swap module for exchanging starnames and tokens #29

Closed
9 tasks done
davepuchyr opened this issue May 25, 2021 · 3 comments · Fixed by #98
Closed
9 tasks done

Add a swap module for exchanging starnames and tokens #29

davepuchyr opened this issue May 25, 2021 · 3 comments · Fixed by #98
Assignees
Labels

Comments

@davepuchyr
Copy link
Contributor

davepuchyr commented May 25, 2021

We want to facilitate trustless swapping of starnames for IOV tokens. "Trustless" means that the seller doesn't have to trust that the buyer will send the tokens after the seller sends the starname. Similarly, the buyer doesn't want to send the tokens directly to the seller since the seller could just keep both the starname and the tokens. The solution is to use an escrow - a third party to the deal.

Leverage as much technology as possible from https://github.com/iov-one/weave/tree/master/x/escrow.

  • Determine if the escrow should be a module unto itself or be embedded within the starname module. Prefer embedding the tech within the starname module. Let's discuss.
  • Use cosmos-sdk-crud for access to the KV store as long as it's not insane to do so.

Swap requirements:

  • A swap should be initiated by the seller by sending the starname to an escrow account along with its price and swap expiration date.
  • If a buyer sends IOV tokens to the escrow account that meet or exceed the seller's price then the ownership of the starname should be transferred to the buyer.
  • If the buyer sends more than the seller's price then the excess should be returned to the buyer.
  • If the buyer sends less than the seller's price then the transaction should fail.
  • If no one buys the starname before the swap expiration date then the seller should be able to reclaim their starname by sending a "return" message to the escrow.
  • Anyone, not just the seller, can initiate the return of a starname from an expired escrow.
  • Make sure that the deadline does not exceed the starname expiration date
@LeCodeurDuDimanche LeCodeurDuDimanche self-assigned this May 26, 2021
@davepuchyr
Copy link
Contributor Author

Terra did significant work on auctions for its name service that never materialized. Maybe we can leverage some of their work. https://github.com/terra-project/core/pull/330/files

@LeCodeurDuDimanche
Copy link
Contributor

LeCodeurDuDimanche commented Jun 1, 2021

If no one buys the starname before the swap expiration date then the seller should be able to reclaim their starname by sending a "return" message to the escrow.

I think this should be handled automatically in the BeginBlocker() call

@davepuchyr davepuchyr changed the title Add escrow functionality to the starname module Add a swap module for exchanging starnames and tokens Jun 2, 2021
@LeCodeurDuDimanche
Copy link
Contributor

LeCodeurDuDimanche commented Jun 15, 2021

  • Add tests
  • Add fees

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants