From 663fb223728fb210acb9c38108e4ff3a1ca33df5 Mon Sep 17 00:00:00 2001 From: philipliu Date: Wed, 28 Aug 2024 15:36:10 -0400 Subject: [PATCH] Support onchain to onchain deposit and withdrawals --- ecosystem/sep-0006.md | 11 +++++++---- ecosystem/sep-0024.md | 4 ++-- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/ecosystem/sep-0006.md b/ecosystem/sep-0006.md index e4aab6827..fcef0fd08 100644 --- a/ecosystem/sep-0006.md +++ b/ecosystem/sep-0006.md @@ -799,7 +799,9 @@ Example: If the anchor supports [SEP-38] quotes, it can provide a deposit that makes a bridge between non-equivalent tokens by receiving, for instance BRL via bank transfer and in return sending the equivalent value (minus fees) as USDC to the -user's Stellar account. +user's Stellar account. The user is not restricted to sending only off-chain assets to the anchor. The user can also +send on-chain assets to the anchor, and the anchor will convert them to another on-chain asset. For instance, the user +sends Stellar USDC to the anchor and the anchor sends back Stellar BENJI. The `/deposit-exchange` endpoint allows a wallet to get deposit information from an anchor when the user intends to make a conversion between non-equivalent tokens. With this endpoint, a user has all the information needed to initiate a @@ -817,7 +819,7 @@ Request Parameters: | Name | Type | Description | | ----------------------------- | ----------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `destination_asset` | string | The code of the on-chain asset the user wants to get from the Anchor after doing an off-chain deposit. The value passed must match one of the codes listed in the [/info](#info) response's `deposit-exchange` object. | -| `source_asset` | string | The off-chain asset the Anchor will receive from the user. The value must match one of the `asset` values included in a [`SEP-38 GET /prices?buy_asset=stellar::`](sep-0038.md#get-prices) response using [SEP-38 Asset Identification Format](sep-0038.md#asset-identification-format). | +| `source_asset` | string | The off-chain or on-chain asset the Anchor will receive from the user. The value must match one of the `asset` values included in a [`SEP-38 GET /prices?buy_asset=stellar::`](sep-0038.md#get-prices) response using [SEP-38 Asset Identification Format](sep-0038.md#asset-identification-format). | | `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 should respect the conversion rate agreed in that quote. If the values of `destination_asset`, `source_asset` and `amount` conflict with the ones used to create the [SEP-38] quote, this request should be rejected with a `400`. | | `amount` | string | The amount of the `source_asset` the user would like to deposit to the anchor's off-chain account. This field may be necessary for the anchor to determine what KYC information is necessary to collect. Should be equals to `quote.sell_amount` if a `quote_id` was used. | | `account` | `G...` or `M...` string | The stellar or muxed account ID of the user that wants to deposit. This is where the asset token will be sent. Note that the account specified in this request could differ from the account authenticated via SEP-10. | @@ -846,7 +848,8 @@ GET https://api.example.com/deposit-exchange?destination_asset=USDC&source_asset ### Response -The expected response as well as the special cases are the same ones covered in the [Deposit](#deposit-2) section. +The expected response as well as the special cases are the same ones covered in the [Deposit](#deposit-2) section. When the `source_asset` is also a on-chain asset, +the anchor should provide the user with the Stellar address and an optional memo to send the asset to in the `instructions` object in the response. ## Withdraw Exchange @@ -870,7 +873,7 @@ Request parameters: | Name | Type | Description | | -------------------- | ----------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | `source_asset` | string | Code of the on-chain asset the user wants to withdraw. The value passed must match one of the codes listed in the [/info](#info) response's `withdraw-exchange` object. | -| `destination_asset` | string | The off-chain asset the Anchor will deliver to the user's account. The value must match one of the `asset` values included in a [`SEP-38 GET /prices?sell_asset=stellar::`](sep-0038.md#get-prices) response using [SEP-38 Asset Identification Format](sep-0038.md#asset-identification-format). | +| `destination_asset` | string | The off-chain or on-chain asset the Anchor will deliver to the user's account. The value must match one of the `asset` values included in a [`SEP-38 GET /prices?sell_asset=stellar::`](sep-0038.md#get-prices) response using [SEP-38 Asset Identification Format](sep-0038.md#asset-identification-format). | | `quote_id` | string | (optional) The `id` returned from a `SEP-38 POST /quote` response. If this parameter is provided and the Stellar transaction used to send the asset to the Anchor has a [`created_at`](https://developers.stellar.org/api/resources/transactions/object/) timestamp earlier than the quote's `expires_at` attribute, the Anchor should respect the conversion rate agreed in that quote. If the values of `destination_asset`, `source_asset` and `amount` conflict with the ones used to create the [SEP-38] quote, this request should be rejected with a `400`. | | `amount` | string | The amount of the on-chain asset (`source_asset`) the user would like to send to the anchor's Stellar account. This field may be necessary for the anchor to determine what KYC information is necessary to collect. Should be equals to `quote.sell_amount` if a `quote_id` was used. | | `type` | string | Type of withdrawal. Can be: `crypto`, `bank_account`, `cash`, `mobile`, `bill_payment` or other custom values. This field may be necessary for the anchor to determine what KYC information is necessary to collect. | diff --git a/ecosystem/sep-0024.md b/ecosystem/sep-0024.md index 8e5410ed8..a587cc146 100644 --- a/ecosystem/sep-0024.md +++ b/ecosystem/sep-0024.md @@ -402,7 +402,7 @@ Request Parameters: | ----------------------------- | --------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `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. | +| `source_asset` | string in [Asset Identification Format] | (optional) The asset user wants to send. Note, that this is the asset user initially holds. This should be either an off-chain or on-chain 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. | @@ -608,7 +608,7 @@ Request parameters: | ------------------- | --------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `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. | +| `destination_asset` | string in [Asset Identification Format] | (optional) The asset user wants to receive. This should be either an off-chain or on-chain 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. |