diff --git a/ecosystem/sep-0024.md b/ecosystem/sep-0024.md index 2470017cb..f4d145235 100644 --- a/ecosystem/sep-0024.md +++ b/ecosystem/sep-0024.md @@ -6,8 +6,8 @@ Title: Hosted Deposit and Withdrawal Author: SDF Status: Active Created: 2019-09-18 -Updated: 2023-06-16 -Version 3.2.0 +Updated: 2023-07-17 +Version 3.3.0 ``` ## Simple Summary @@ -44,13 +44,15 @@ the API endpoints according to the protocol will work with any compliant wallet. how a wallet knows where to find the anchor's server. - Anchors and clients must support [SEP-10](sep-0010.md) web authentication to enable authenticated deposits, withdrawals, or transaction history lookups. +- If the Anchor supports [SEP-38], `ANCHOR_QUOTE_SERVER` must be defined in their [`stellar.toml`](sep-0001.md). ## API Endpoints - [`POST /transactions/deposit/interactive`](#deposit) - [`POST /transactions/withdraw/interactive`](#withdraw) - [`GET /info`](#info) -- [`GET /fee`](#fee): optional (only needed for complex fee structures) +- [`GET /fee`](#fee): **deprecated** optional (only needed for complex fee structures). + [`SEP-38 GET /price`](sep-0038.md#get-price) endpoint should be used to communicate fees and exchange rates. - [`GET /transactions`](#transaction-history) - [`GET /transaction`](#single-historical-transaction) @@ -107,6 +109,74 @@ non-equivalent asset transactions, specifically `amount_in_asset`, `amount_fee_a allows client applications can relay this information, in addition to the amounts specified in the associated attributes, back to their users. +Alternatively, the Anchor can support the [SEP-38] RFQ API and the `quote_id` attribute in +`POST /transactions/deposit/interactive` and `POST /transactions/withdraw/interactive` requests. This enables wallets to +check the Anchor's exchange rates prior to initiating a transaction and obtain a firm quote to use for an upcoming +transaction. + +### Asset Conversions Using the Market Rate + +To convert at the market rate, clients get an +[indicative quote](https://www.investopedia.com/terms/i/indicativequote.asp) with [SEP-38] and then proceed to calling +the [`POST /transactions/withdraw/interactive`](#withdraw) or [`POST /transactions/deposit/interactive`](#deposit) +endpoints. Market rate conversions executed in this way do not provide a guarantee of the final price to be paid for the +asset. Here is how this kind of conversion should happen in deposits and withdrawals for an asset pair like +`BRL <> USDC`: + +#### Deposit: + +Considering the user will be making a bank deposit of fiat `BRL` in exchange for `USDC` in the Stellar network: + +1. The Wallet checks the assets' market conversion rate with [`SEP-38 GET /price`](sep-0038.md#get-price) and shows the + estimated price to the user. +1. The Wallet initiates a [`POST /transactions/deposit/interactive`](#deposit) using the parameter `asset_code`. +1. The user proceeds with the off-chain deposit, sending `BRL` to the Anchor's bank account. +1. Upon receiving the off-chain deposit funds, the Anchor converts it to `USDC` using the market rate and sends the + resulting amount to the user's Stellar account. + +#### Withdraw: + +Considering the user will be making a Stellar payment of `USDC` in exchange for withdrawing `BRL` in the bank account: + +1. The Wallet checks the assets' market conversion rate with [`SEP-38 GET /price`](sep-0038.md#get-price) and shows the + estimated price to the user. +1. The Wallet initiates a [`POST /transactions/withdraw/interactive`](#withdraw) using the parameter `asset_code`. +1. The user proceeds with the on-chain payment, sending `USDC` to the Anchor's Stellar account. +1. Upon receiving the on-chain withdraw funds, the Anchor converts it to `BRL` using the market rate and sends the + resulting amount to the user's bank account. + +### Asset Conversions Using a Firm Quote + +With firm quotes, users are guaranteed an asset price they will pay if they submit the payment and anchor receives the +payment before the quote expiration. Here is how the conversion should happen in deposits and withdrawals for an asset +pair like `USDC <> BRL`: + +#### Deposit: + +Considering the user will be making a bank deposit of fiat `BRL` in exchange for `USDC` in the Stellar network: + +1. The Wallet gets a firm conversion rate in [`SEP-38 POST /quote`](sep-0038.md#post-quote) and shows the price and + expiration date to the user. +1. The Wallet initiates a [`POST /transactions/deposit/interactive`](#deposit) using the parameter `quote_id` returned + from the previous step, as well as `asset_code`. +1. The user proceeds with the off-chain deposit, sending `BRL` to the Anchor's bank account before the quote expires. +1. Upon receiving the off-chain deposit funds, the Anchor converts it to `USDC` according with the agreed quote and + sends the resulting amount to the user's Stellar account. +1. If the user sends the funds after the quote expiration, the Anchor can proceed according with its own policy. + +#### Withdraw: + +Considering the user will be making a Stellar payment of `USDC` in exchange for withdrawing `BRL` in her bank account: + +1. The Wallet gets a firm conversion rate in [`SEP-38 POST /quote`](sep-0038.md#post-quote) and shows the price and + expiration date to the user. +1. The Wallet initiates a [`POST /transactions/withdraw/interactive`](#withdraw) using the parameter `quote_id` returned + from the previous step, as well as `asset_code`. +1. The user proceeds with the on-chain payment, sending `USDC` to the Anchor's Stellar account before the quote expires. +1. Upon receiving the on-chain withdraw funds, the Anchor converts it to `BRL` according with the agreed quote and sends + the resulting amount to the user's bank account. +1. If the user sends the funds after the quote expiration, the Anchor can proceed according with its own policy. + ## Cross-Origin Headers Valid CORS headers are necessary to allow web clients from other sites to use the endpoints. The following HTTP header @@ -214,12 +284,12 @@ banking rails so counterparties can run through the flow without a need to colla - For each anchor, use information from its [`stellar.toml`](sep-0001.md) file and its [`/info`](#info) endpoint to display useful information to the user about the asset they've picked. - Provide a UI that allows users to pick an asset, anchor, and amount to use for deposit or withdraw. The UI should - display the asset's fee structure (if possible) as well as information such as the address of the anchor and - description of the asset from the `stellar.toml` file. -- **Use the `/info` endpoint** - - Fetch the asset's deposit & withdawal fee structure: if `fee_fixed`, `fee_percent`, or `fee_minimum` are provided, - show this to the user early in the process so they're fully informed. - - If the `/fee` endpoint is enabled, use it for computing fees when you need to show them to the user. + display the asset's quote (if possible) as well as information such as the address of the anchor and description of + the asset from the `stellar.toml` file. +- **If [SEP-38] quote API is supported by the anchor** + - Fetch the asset's exchange rate at the market price using [`SEP-38 GET /price`](sep-0038.md#get-price) API. + - For the firm quote, use [`SEP-38 POST /quote`](sep-0038.md#post-quote) API and show the quote and expiration time to + the user. - **Authentication** - Perform [authentication](#authentication) via SEP-10 before hitting those endpoints - **Make a request to `/transactions/deposit/interactive` or `/transactions/withdraw/interactive`.** @@ -229,6 +299,7 @@ banking rails so counterparties can run through the flow without a need to colla in order to let the anchor pre-fill them in the interactive flow UI. This is optional, but can create a much nicer user experience. `email_address`, `first_name` and `last_name` are good examples of fields to help pre-fill the anchors website. + - Optionally attach [SEP-38] quote id, in order to the anchor to use the quote previously shown to the user. - **For `/transactions/deposit/interactive`** - Handle the interactive flow, handle it as [described in detail](#interactive-customer-information-needed). - Handle the [special cases](#special-cases), they're relatively common. @@ -249,15 +320,16 @@ banking rails so counterparties can run through the flow without a need to colla ### Basic Anchor Implementation - Provide a full-featured implementation of [`/info`](#info). -- Pick your approach to [fees](https://github.com/stellar/stellar-protocol/blob/master/ecosystem/sep-0006.md#fee). We - recommend using `/info` to express fees as it provides a better user experience (the user can see the fee structure in - the wallet early in the process). +- Implement [SEP-38] to offer better user experience. Wallet would be able to show rates and fees your anchor provides + early in the process. (Before the user initiates a transaction via interactive UI) - **For both deposit and withdrawal**: - To start an interactive flow, provide the [Customer info needed response](#interactive-customer-information-needed). - Some wallets may include other fields indicated in [SEP-9](sep-0009.md) as POST parameters added to the `/transactions/deposit/interactive` or `/transactions/withdraw/interactive` endpoints. These can be stored and used to pre-populate fields in the interactive flow. This is optional for the wallet to provide and optional for anchors to respect, but it does create a much nicer user experience. + - Some wallets may include `quote_id` fetched from the [`SEP-38 POST /quote`](sep-0038.md#post-quote) API. If + provided, your implementation must respect the agreed quote. - Include the `id` field in your response to `/transactions/deposit/interactive` and `/transactions/withdraw/interactive` so the wallet can check up on the status of the transaction if it wants. - Also include the `id` field in the popup URL you provide to the wallet. This allows you to keep track of the @@ -271,8 +343,8 @@ banking rails so counterparties can run through the flow without a need to colla auto-fill well, and do smart keyboard management on mobile devices. - **Interactive deposit** - Your interactive deposit popup will do everything needed to initiate the deposit without the user needing to - interact with the wallet further. It should either directly initiate the deposit, or handle displaying information ( - such as reference number or bank account number) that the user will need to complete their deposit. + interact with the wallet further. It should either directly initiate the deposit, or handle displaying information + (such as reference number or bank account number) that the user will need to complete their deposit. - **Interactive withdrawal** - Your withdrawal flow will have to pass control back to the user's wallet, so it can initiate the withdrawal with a Stellar payment to your withdrawal address. You'll need to communicate the withdrawal address, amount and status to @@ -298,8 +370,12 @@ banking rails so counterparties can run through the flow without a need to colla ## Deposit A deposit is when a user sends some non-stellar asset (BTC via Bitcoin network, USD via bank transfer, Cash to a teller, -etc...) to an account held by an anchor. In turn, the anchor sends an equal amount of tokens on the Stellar network ( -minus fees) to the user's Stellar account. +etc...) to an account held by an anchor. In turn, the anchor sends an equal amount of tokens on the Stellar network +(minus fees) to the user's Stellar account. + +If the anchor supports SEP-38 quotes, it can also provide a bridge between non-equivalent tokens. For example, the +anchor can receive ARS via bank transfer and in return send the equivalent value (minus fees) as USDC on the Stellar +network to the user's Stellar account. The deposit endpoint allows a wallet to get deposit information from an anchor, so a user has all the information needed to initiate a deposit. It also lets the anchor specify additional information that the user must submit interactively @@ -322,18 +398,20 @@ The fields below should be placed in the request body using the `multipart/form- Request Parameters: -| Name | Type | Description | -| ----------------------------- | ----------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `asset_code` | string | The code of the stellar asset the user wants to receive for their deposit with the anchor. The value passed must match one of the codes listed in the [/info](#info) response's deposit object. `native` is a special `asset_code` that represents the native XLM token. | -| `asset_issuer` | string | (optional) The issuer of the stellar asset the user wants to receive for their deposit with the anchor. If asset_issuer is not provided, the anchor should use the asset issued by themselves as described in their TOML file. If `native` is specified as the `asset_code`, `asset_issuer` must be not be set. | -| `amount` | number | (optional) Amount of asset requested to deposit. If this is not provided it will be collected in the interactive flow. | -| `account` | `G...` or `M...` string | (optional) The Stellar or muxed account the client wants to use as the destination of the payment sent by the anchor. Defaults to the account authenticated via SEP-10 if not specified. | -| `memo_type` | string | (optional) Type of memo that anchor should attach to the Stellar transaction, one of `text`, `id` or `hash`. | -| `memo` | string | (optional) Value of memo to attach to transaction, for `hash` this should be base64-encoded. Because a memo can be specified in the SEP-10 JWT for [Shared Accounts](#shared-omnibus-or-pooled-accounts), this field can be different than the value included in the SEP-10 JWT. For example, a client application could use the value passed for this parameter as a reference number used to match payments made to `account`. | -| `wallet_name` | string | (**deprecated**, optional) In communications / pages about the deposit, anchor should display the wallet name to the user to explain where funds are going. However, anchors should use client_domain (for non-custodial) and `sub` value of JWT (for custodial) to determine wallet information. | -| `wallet_url` | string | (**deprecated**, optional) Anchor should link to this when notifying the user that the transaction has completed. However, anchors should use client_domain (for non-custodial) and `sub` value of JWT (for custodial) to determine wallet information. | -| `lang` | string | (optional) Defaults to `en` if not specified or if the specified language is not supported. Language code specified using [RFC 4646] which means it can also accept locale in the format `en-US`. `error` fields in the response, as well as the interactive flow UI and any other user-facing strings returned for this transaction should be in this language. | -| `claimable_balance_supported` | boolean | (optional) True if the client supports receiving deposit transactions as a claimable balance, false otherwise. | +| Name | Type | Description | +| ----------------------------- | --------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `asset_code` | string | The code of the stellar asset the user wants to receive for their deposit with the anchor. The value passed must match one of the codes listed in the [/info](#info) response's deposit object. When `quote_id` is specified, `asset_code` must match the quote's `buy_asset` asset code. | +| `asset_issuer` | string | (optional) The issuer of the stellar asset the user wants to receive for their deposit with the anchor. If asset_issuer is not provided, the anchor should use the asset issued by themselves as described in their TOML file. If `native` is specified as the `asset_code`, `asset_issuer` must be not be set. When `quote_id` is specified, this parameter must match the quote's `buy_asset` asset code or be omitted. | +| `source_asset` | string in [Asset Identification Format] | (optional) The asset user wants to send. Note, that this is the asset user initially holds (off-chain or fiat asset).If this is not provided, it will be collected in the interactive flow. When `quote_id` is specified, this parameter must match the quote's `sell_asset` asset code or be omitted. | +| `amount` | number | (optional) Amount of asset requested to deposit. If this is not provided it will be collected in the interactive flow. When `qoute_id` is specified, this parameter must match the quote's `quote.sell_amount` or be omitted. | +| `quote_id` | string | (optional) The `id` returned from a `SEP-38 POST /quote` response. If this parameter is provided and the user delivers the deposit funds to the Anchor before the quote expiration, the Anchor must respect the conversion rate agreed in that quote. When `quote_id` is set, `asset_code`, `source_asset` and `amount` must be validated by the anchor, if present. In case of a conflict with the ones used to create the [SEP-38] quote, this request should be rejected with a `400`. | +| `account` | `G...` or `M...` string | (optional) The Stellar or muxed account the client wants to use as the destination of the payment sent by the anchor. Defaults to the account authenticated via SEP-10 if not specified. | +| `memo_type` | string | (optional) Type of memo that anchor should attach to the Stellar transaction, one of `text`, `id` or `hash`. | +| `memo` | string | (optional) Value of memo to attach to transaction, for `hash` this should be base64-encoded. Because a memo can be specified in the SEP-10 JWT for [Shared Accounts](#shared-omnibus-or-pooled-accounts), this field can be different than the value included in the SEP-10 JWT. For example, a client application could use the value passed for this parameter as a reference number used to match payments made to `account`. | +| `wallet_name` | string | (**deprecated**,optional) In communications / pages about the deposit, anchor should display the wallet name to the user to explain where funds are going. However, anchors should use client_domain (for non-custodial) and `sub` value of JWT (for custodial) to determine wallet information. | +| `wallet_url` | string | (**deprecated**,optional) Anchor should link to this when notifying the user that the transaction has completed. However, anchors should use client_domain (for non-custodial) and `sub` value of JWT (for custodial) to determine wallet information. | +| `lang` | string | (optional) Defaults to `en` if not specified or if the specified language is not supported. Language code specified using [RFC 4646] which means it can also accept locale in the format `en-US`. `error` fields in the response, as well as the interactive flow UI and any other user-facing strings returned for this transaction should be in this language. | +| `claimable_balance_supported` | boolean | (optional) True if the client supports receiving deposit transactions as a claimable balance, false otherwise. | When anchor receives a request, it can determine an origin of the request. First, it should check `client_domain` value of the authentication token. If it's set, this wallet is an origin of the request. Otherwise, `sub` value of the JWT is @@ -342,7 +420,7 @@ domains. Note, that custodial wallets should only use 1 authentication key, so i Additionally, any [SEP-9](sep-0009.md) parameters may be passed as well to make the onboarding experience simpler. -When uploading data for fields specificed in [SEP-9](sep-0009.md), `binary` type fields (typically files) should be +When uploading data for fields specified in [SEP-9](sep-0009.md), `binary` type fields (typically files) should be submitted **after all other fields**. The reason for this is that some web servers require `binary` fields at the end so that they know when they can begin processing the request as a stream. @@ -501,6 +579,10 @@ are no predicate preferences, `UNCONDITIONAL` allows accounts to claim balances This operation allows a user to redeem an asset currently on the Stellar network for the real asset (BTC, USD, stock, etc...) via the anchor of the Stellar asset. +If the anchor supports SEP-38 quotes, it can provide a withdraw that makes a bridge between non-equivalent tokens by +receiving, for instance USDC from the Stellar network and in return sending the equivalent value (minus fees) as NGN to +the user's bank account. + The withdraw endpoint allows a wallet to get withdrawal information from an anchor, so a user has all the information needed to initiate a withdrawal. It also lets the anchor specify the url for the interactive webapp to continue with the anchor's side of the withdraw. @@ -521,19 +603,21 @@ The fields below should be placed in the request body using the `multipart/form- Request parameters: -| Name | Type | Description | -| ------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -| `asset_code` | string | Code of the asset the user wants to withdraw. The value passed must match one of the codes listed in the [/info](#info) response's withdraw object. `native` is a special `asset_code` that represents the native XLM token. | -| `asset_issuer` | string | (optional) The issuer of the stellar asset the user wants to withdraw with the anchor. If asset_issuer is not provided, the anchor should use the asset issued by themselves as described in their TOML file. If `native` is specified as the `asset_code`, `asset_issuer` must be not be set. | -| `amount` | number | (optional) Amount of asset requested to withdraw. If this is not provided it will be collected in the interactive flow. | -| `account` | `G...` or `M...` string | (optional) The Stellar or muxed account the client will use as the source of the withdrawal payment to the anchor. Defaults to the account authenticated via SEP-10 if not specified. | -| `memo` | string | (**deprecated**, optional) This field was originally intended to differentiate users of the same Stellar account. However, the anchor should use the `sub` value included in the decoded SEP-10 JWT instead. Anchors should still support this parameter to maintain support for outdated clients. See the [Shared Account Authentication](#shared-omnibus-or-pooled-accounts) section for more information. | -| `memo_type` | string | (**deprecated**, optional) Type of `memo`. One of `text`, `id` or `hash`. Deprecated because memos used to identify users of the same Stellar account should always be of type of `id`. | -| `wallet_name` | string | (**deprecated**, optional) In communications / pages about the withdrawal, anchor should display the wallet name to the user to explain where funds are coming from. However, anchors should use client_domain (for non-custodial) and `sub` value of JWT (for custodial) to determine wallet information. | -| `wallet_url` | string | (**deprecated**, optional) Anchor can show this to the user when referencing the wallet involved in the withdrawal (ex. in the anchor's transaction history). However, anchors should use client_domain (for non-custodial) and `sub` value of JWT (for custodial) to determine wallet information. | -| `lang` | string | (optional) Defaults to `en` if not specified or if the specified language is not supported. Language code specified using [RFC 4646] which means it can also accept locale in the format `en-US`. `error` fields in the response, as well as the interactive flow UI and any other user-facing strings returned for this transaction should be in this language. | -| `refund_memo` | (optional) The memo the anchor must use when sending refund payments back to the user. If not specified, the anchor should use the same memo used by the user to send the original payment. If specified, `refund_memo_type` must also be specified. | -| `refund_memo_type` | (optional) The type of the `refund_memo`. Can be `id`, `text`, or `hash`. See the [memos](https://developers.stellar.org/docs/encyclopedia/memos) documentation for more information. If specified, `refund_memo` must also be specified. | +| Name | Type | Description | +| ------------------- | --------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `asset_code` | string | Code of the asset the user wants to withdraw. The value passed must match one of the codes listed in the [/info](#info) response's withdraw object. When `quote_id` is specified, `asset_code` must match the quote's `sell_asset` asset code. `native` is a special `asset_code` that represents the native XLM token. | +| `asset_issuer` | string | (optional) The issuer of the stellar asset the user wants to withdraw with the anchor. If `asset_issuer` is not provided, the anchor should use the asset issued by themselves as described in their TOML file. If `native` is specified as the `asset_code`, `asset_issuer` must be not be set. When `quote_id` is specified, `asset_issuer` must match the quote's `buy_asset` asset issuer or be omitted. | +| `destination_asset` | string in [Asset Identification Format] | (optional) The asset user wants to receive. It's an off-chain or fiat asset. If this is not provided, it will be collected in the interactive flow. When `quote_id` is specified, this parameter must match the quote's `buy_asset` asset code or be omitted. | +| `amount` | number | (optional) Amount of asset requested to withdraw. If this is not provided it will be collected in the interactive flow. When `qoute_id` is specified, this parameter must match the quote's `quote.sell_amount` or be omitted. | +| `quote_id` | string | (optional) The `id` returned from a `SEP-38 POST /quote` response. If this parameter is provided and the user delivers the deposit funds to the Anchor before the quote expiration, the Anchor must respect the conversion rate agreed in that quote. When `quote_id` is set, `asset_code`, `destination_asset` and `amount` must be validated by the anchor, if present. In case of a conflict with the ones used to create the [SEP-38] quote, this request should be rejected with a `400`. | +| `account` | `G...` or `M...` string | (optional) The Stellar or muxed account the client will use as the source of the withdrawal payment to the anchor. Defaults to the account authenticated via SEP-10 if not specified. | +| `memo` | string | (**deprecated**, optional) This field was originally intended to differentiate users of the same Stellar account. However, the anchor should use the `sub` value included in the decoded SEP-10 JWT instead. Anchors should still support this parameter to maintain support for outdated clients. See the [Shared Account Authentication](#shared-omnibus-or-pooled-accounts) section for more information. | +| `memo_type` | string | (**deprecated**, optional) Type of `memo`. One of `text`, `id` or `hash`. Deprecated because memos used to identify users of the same Stellar account should always be of type of `id`. | +| `wallet_name` | string | (**deprecated**,optional) In communications / pages about the withdrawal, anchor should display the wallet name to the user to explain where funds are coming from. However, anchors should use client_domain (for non-custodial) and `sub` value of JWT (for custodial) to determine wallet information. | +| `wallet_url` | string | (**deprecated**,optional) Anchor can show this to the user when referencing the wallet involved in the withdrawal (ex. in the anchor's transaction history). However, anchors should use client_domain (for non-custodial) and `sub` value of JWT (for custodial) to determine wallet information. | +| `lang` | string | (optional) Defaults to `en` if not specified or if the specified language is not supported. Language code specified using [RFC 4646] which means it can also accept locale in the format `en-US`. `error` fields in the response, as well as the interactive flow UI and any other user-facing strings returned for this transaction should be in this language. | +| `refund_memo` | string | (optional) The memo the anchor must use when sending refund payments back to the user. If not specified, the anchor should use the same memo used by the user to send the original payment. If specified, `refund_memo_type` must also be specified. | +| `refund_memo_type` | string | (optional) The type of the `refund_memo`. Can be `id`, `text`, or `hash`. See the [memos](https://developers.stellar.org/docs/encyclopedia/memos) documentation for more information. If specified, `refund_memo` must also be specified. | Additionally, any [SEP-9](sep-0009.md) parameters may be passed as well to make the onboarding experience simpler. @@ -546,7 +630,7 @@ Content-Type: application/x-www-form-urlencoded asset_code=USD&email_address=myaccount@gmail.com&account=GACW7NONV43MZIFHCOKCQJAKSJSISSICFVUJ2C6EZIW5773OU3HD64VI ``` -When uploading data for fields specificed in [SEP-9](sep-0009.md), `binary` type fields (typically files) should be +When uploading data for fields specified in [SEP-9](sep-0009.md), `binary` type fields (typically files) should be submitted **after all other fields**. The reason for this is that some web servers require `binary` fields at the end so that they know when they can begin processing the request as a stream. @@ -879,8 +963,8 @@ fields: #### Feature Flags -The `features` object contains boolean values indicating whether or not specific features are supported by the anchor. -If the object or specific feature is not present in the response, the default value described below may be assumed. This +The `features` object contains boolean values indicating whether specific features are supported by the anchor. If the +object or specific feature is not present in the response, the default value described below may be assumed. This information enables wallets to adjust their behavior based on the feature set supported by the anchor. | Name | Default | Description | @@ -889,10 +973,12 @@ information enables wallets to adjust their behavior based on the feature set su | `claimable_balances` | `false` | Whether or not the anchor supports sending deposit funds as claimable balances. This is relevant for users of Stellar accounts without a trustline to the requested asset. | The default values for the features listed above have been selected based on the ecosystem's current support. It is -highly recommened to support all features enumerated for the best user experience. +highly recommend to support all features enumerated for the best user experience. ## Fee +**This endpoint is deprecated. The [SEP-38] `GET /price` endpoint should be used to fetch fees instead.** + The fee endpoint allows an anchor to report the fee that would be charged for a given deposit or withdraw operation. This is important to allow an anchor to accurately report fees to a user even when the fee schedule is complex. If a fee can be fully expressed with the `fee_fixed`, `fee_percent` or `fee_minimum` fields in the `/info` response, then an @@ -993,6 +1079,7 @@ Each object in the `transactions` array should have the following fields: | `amount_out_asset` | string | (optional) The asset delivered or to be delivered to the user. Must be present if the deposit/withdraw was made using non-equivalent assets. The value must be in [SEP-38 Asset Identification Format](sep-0038.md#asset-identification-format). See the [Asset Exchanges](#asset-exchanges) section for more information. | | `amount_fee` | string | Amount of fee charged by anchor. | | `amount_fee_asset` | string | (optional) The asset in which fees are calculated in. Must be present if the deposit/withdraw was made using non-equivalent assets. The value must be in [SEP-38 Asset Identification Format](sep-0038.md#asset-identification-format). See the [Asset Exchanges](#asset-exchanges) section for more information. | +| `quote_id` | string | (optional) The ID of the quote used when creating this transaction. Should be present if a `quote_id` was included in the `POST /transactions/deposit/interactive` or `POST /transactions/withdraw/interactive` request. Clients should be aware that the `quote_id` may not be present in older implementations. | | `started_at` | UTC ISO 8601 string | Start date and time of transaction. | | `completed_at` | UTC ISO 8601 string | (optional) The date and time of transaction reaching `completed` or `refunded` status. | | `updated_at` | UTC ISO 8601 string | (optional) The date and time of transaction reaching the current status. | @@ -1041,8 +1128,9 @@ Each object in the `transactions` array should have the following fields: email or 2fa confirmation of a withdraw. - `completed` -- deposit/withdrawal fully completed. - `refunded` -- the deposit/withdrawal is fully refunded. -- `expired` -- funds were never received by the anchor and the transaction is considered abandoned by the user. Anchors - are responsible for determining when transactions are considered expired. +- `expired` -- funds were never received by the anchor and the transaction is considered abandoned by the user. If a + SEP-38 quote was specified when the transaction was initiated, the transaction should expire when the quote expires, + otherwise anchors are responsible for determining when transactions are considered expired. - `no_market` -- could not complete deposit because no satisfactory asset/XLM market was available to create the account. - `too_small` -- deposit/withdrawal size less than `min_amount`. @@ -1266,25 +1354,27 @@ There is a small set of changes when upgrading from SEP-6 to SEP-24. 1. SEP-24 now requires authentication on all endpoints. The `authentication_required` flag is removed from the `/info` endpoint since authentication is assumed. -2. `GET /deposit` and `GET /withdraw` have been replaced with [`POST /transactions/deposit/interactive`](#deposit) and +1. `GET /deposit` and `GET /withdraw` have been replaced with [`POST /transactions/deposit/interactive`](#deposit) and [`POST /transactions/withdraw/interactive`](#withdraw). This is for security purposes to keep submitted personally identifiable information out of URL query parameters. Instead of passing data through query parameters, it's now expected through `multipart/form-data` POST requests. -3. Remove the `type` parameter from the `/deposit` and `/withdraw` endpoints as this is information collected in the +1. Remove the `type` parameter from the `/deposit` and `/withdraw` endpoints as this is information collected in the interactive flow. -4. Removed the `fields` and `types` definitions from the `/info` endpoint. Instead of trying to communicate to the +1. Removed the `fields` and `types` definitions from the `/info` endpoint. Instead of trying to communicate to the wallet what fields an anchor wishes for the wallet to collect and send, the wallet can send any fields it wishes to share for a better UX (such as `email_address`), and anything not sent should be collected by the anchor. If none of these fields are sent, the anchor should still be able to continue and collect these fields during the interative flow. -5. Removed `external_extra` transaction property since this should all live in a human readable ` more_info_url`. -6. Changed the response of the deposit and withdraw endpoints from 403 to 200 since this is the expected flow. -7. `/transactions` and `/transaction` are now required endpoints. -8. `Transaction` properties `more_info_url, amount_in, amount_out, amount_fee, and stellar_transaction_id` are now +1. Removed `external_extra` transaction property since this should all live in a human readable ` more_info_url`. +1. Changed the response of the deposit and withdraw endpoints from 403 to 200 since this is the expected flow. +1. `/transactions` and `/transaction` are now required endpoints. +1. `Transaction` properties `more_info_url, amount_in, amount_out, amount_fee, and stellar_transaction_id` are now non-optional. -9. It is now recommended to use a short-lived, one-time JWT in the context of the interactive webapp. - - Anchors should not accept JWT's that have expired or been used before. -10. `/transactions` endpoint no longer accepts an `account` query. The account is pulled from the JWT. +1. It is now recommended to use a short-lived, one-time JWT in the context of the interactive webapp. + +- Anchors should not accept JWT's that have expired or been used before. + +1. `/transactions` endpoint no longer accepts an `account` query. The account is pulled from the JWT. ## Implementations @@ -1296,6 +1386,9 @@ There is a small set of changes when upgrading from SEP-6 to SEP-24. ## Changelog +- `v3.3.0`: Add support for [SEP-38] API. Add optional `quote_id` parameter to `post /transactions/deposit/interactive` + and `POST /transactions/deposit/interactive` requests. Add `quote_id` to the transaction object schema. + ([#1358](https://github.com/stellar/stellar-protocol/pull/1358)) - `v3.2.0`: Deprecate the `wallet_name` and `wallet_url` parameters of `POST /transactions/deposit/interactive` and `POST /transactions/withdrawal/interactive` requests ([#1364](https://github.com/stellar/stellar-protocol/pull/1364)) - `v3.1.0`: Add native asset support to SEP-24 ([#1363](https://github.com/stellar/stellar-protocol/pull/1363)) @@ -1326,3 +1419,5 @@ There is a small set of changes when upgrading from SEP-6 to SEP-24. ([#1128](https://github.com/stellar/stellar-protocol/pull/1128)) [RFC 4646]: https://www.rfc-editor.org/rfc/rfc4646 +[SEP-38]: sep-0038.md +[Asset Identification Format]: sep-0038.md#asset-identification-format. diff --git a/ecosystem/sep-0038.md b/ecosystem/sep-0038.md index 4c88df182..019371263 100644 --- a/ecosystem/sep-0038.md +++ b/ecosystem/sep-0038.md @@ -7,9 +7,9 @@ Author: Jake Urban <@jakeurban> and Leigh McCulloch <@leighmcculloch> Track: Standard Status: Draft Created: 2021-04-09 -Updated: 2022-05-23 +Updated: 2023-06-07 Discussion: https://github.com/stellar/stellar-protocol/issues/901 -Version 2.0.0 +Version 2.1.0 ``` ## Summary @@ -482,7 +482,7 @@ Name | Type | Description `sell_delivery_method` | string | (optional) One of the `name` values specified by the `sell_delivery_methods` array for the associated asset returned from [`GET /info`](#info). Must be provided if the user is delivering an off-chain asset to the anchor unless no more than one method is specified in the `GET /info` response. `buy_delivery_method` | string | (optional) One of the `name` values specified by the `buy_delivery_methods` array for the associated asset returned from [`GET /info`](#info). Must be provided if the user intends to receive an off-chain asset from the anchor unless no more than one method is specified in the `GET /info` response. `country_code` | string | (optional) The [ISO 3166-1 alpha-3](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-3) code of the user's current address. Should be provided if there are two or more country codes available for the desired asset in [`GET /info`](#get-info). -`context` | string | The context for what this quote will be used for. Must be one of `sep6` or `sep31`. +`context` | string | The context for what this quote will be used for. Must be one of `sep6`, `sep24` or `sep31`. #### Response @@ -574,6 +574,7 @@ GET /quote/de762cda-a193-4961-861e-57b31fed6eb3 ## Changelog +* `v2.1.0`: Add `sep24` support to the `context` of the request body of the `POST /quote` request. ([#1358](https://github.com/stellar/stellar-protocol/pull/1358)) * `v2.0.0`: (i) add `context` to the request body and `fee` + `total_price` to the response body of the `POST /quote` and `GET /price` requests; (ii) add `fee` to the response body of `GET /quote/:id`; and (iii) allow `sell_amount` and `buy_amount` in the responses to be different from the ones sent in the request. ([#1204](https://github.com/stellar/stellar-protocol/pull/1204)) * `v1.6.1`: Add note about `expires_at` and `expires_after` and their relationship. ([#1147](https://github.com/stellar/stellar-protocol/pull/1147)) * `v1.6.0`: Make [`SEP-10`] authentication token optional for the `GET /info`, `GET /price` and `GET /prices` endpoints. ([#1144](https://github.com/stellar/stellar-protocol/pull/1144))