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

SEP-6: add firm quote withdrawal mermaid diagram #1147

Merged
merged 4 commits into from
Mar 17, 2022
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 70 additions & 2 deletions ecosystem/sep-0006.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ Title: Deposit and Withdrawal API
Author: SDF
Status: Active (Interactive components are deprecated in favor of SEP-24)
Created: 2017-10-30
Updated: 2021-10-22
Version 3.10.0
Updated: 2022-03-16
Version 3.10.1
```

## Simple Summary
Expand All @@ -30,6 +30,73 @@ This proposal defines a standard protocol enabling the following features direct

To support this protocol an anchor acts as a server and implements the specified REST API endpoints, while a wallet implements a client that consumes the API. The goal is interoperability, so a wallet implements a single client according to the protocol, and will be able to interact with any compliant anchor. Similarly, an anchor that implements the API endpoints according to the protocol will work with any compliant wallet.

## Diagrams

The diagrams provided offer a detailed view of various flows that are possible using this protocol. Note that these diagrams are opinionated. Variations of the these flows may also be sufficient.

### Completing a Withdrawal Transaction with a Firm Quote

This diagram demonstrates the interactions between the entities involved in a successful transaction. Specifically it uses the [Asset Conversions Using a Firm Quote](#asset-conversions-using-a-firm-quote) strategy.

```mermaid
sequenceDiagram
participant User
participant Wallet
participant Stellar
participant Anchor
User->>Wallet: initiates withdrawal to <br> User's country
Wallet-->>Wallet: maps country to Anchor

Wallet->>+Anchor: GET /.well-known/stellar.toml
Anchor-->>-Wallet: SEP-10, 12, 6, & 38 URLs
Wallet->>+Anchor: GET [SEP-6]/info
Anchor-->>-Wallet: Stellar assets, customer types, fees
Wallet->>+Anchor: GET [SEP-38]/prices
Anchor-->>-Wallet: pairs and est. rates for Stellar asset

Wallet->>+User: provides pair <br> est. rates & fees
User-->>-Wallet: selects asset pair

Wallet->>+Anchor: GET [SEP-10]
Anchor-->>-Wallet: challenge transaction
Wallet-->>Wallet: signs challenge
Wallet->>+Anchor: POST [SEP-10]
Anchor-->>Anchor: verifies challenge
Anchor-->>-Wallet: authentication token


note right of Wallet: If User has already <br> been accepted, <br> KYC is unnecessary.
Wallet->>+Anchor: GET [SEP-12]/customer?type=
Anchor-->>-Wallet: fields required
Wallet->>+User: requests fields
User-->>-Wallet: provides field values
Wallet->>+Anchor: PUT [SEP-12]/customer?type=
Anchor-->>Anchor: validates KYC values
Anchor-->>-Wallet: id, ACCEPTED

Wallet->>+Anchor: GET [SEP-38]/price
Anchor-->>-Wallet: exchange rate
Wallet->>+User: provides estimated rate
User-->>-Wallet: continues
Wallet->>+Anchor: POST [SEP-38]/quote
Anchor-->>Wallet: quote id, rate, expiration

Wallet->>+Anchor: GEt [SEP-6]/withdraw
JakeUrban marked this conversation as resolved.
Show resolved Hide resolved
Anchor-->>Anchor: checks customer statuses, <br> links quote, <br> creates transaction record
Anchor-->>-Wallet: transaction id, receiving account & memo

Wallet->>+Stellar: submit Stellar payment
Stellar->>+Anchor: receives payment, matches w/ transaction
Anchor-->>Anchor: updates transaction status
Stellar-->>-Wallet: success response
JakeUrban marked this conversation as resolved.
Show resolved Hide resolved

Anchor->>User: Sends off-chain payment to user
Anchor-->>Anchor: updates transaction to complete
Wallet->>+Anchor: GET /transactions?id=
Anchor-->>-Wallet: transaction complete
Wallet->>User: notifies User
```

## Prerequisites

* An anchor must define the location of their `TRANSFER_SERVER` in their [`stellar.toml`](sep-0001.md). This is how a wallet knows where to find the anchor's server.
Expand Down Expand Up @@ -1287,4 +1354,5 @@ If the information was malformed, or if the sender tried to update data that isn

## Changelog

* `v3.10.1`: Add firm quote withdrawal sequence diagram. ([#1147](https://github.com/stellar/stellar-protocol/pull/1147))
* `v3.10.0`: Deprecate refunded boolean. Add refund object to transaction records. ([#1128](https://github.com/stellar/stellar-protocol/pull/1128))