From a05c71a110d945cbe56fe894b391df18eef8ecc6 Mon Sep 17 00:00:00 2001 From: Jamie Li Date: Thu, 15 Aug 2024 11:37:31 -0700 Subject: [PATCH] Add buy_asset field to GET /prices --- ecosystem/sep-0038.md | 38 +++++++++++++++++++++++++++++++++----- 1 file changed, 33 insertions(+), 5 deletions(-) diff --git a/ecosystem/sep-0038.md b/ecosystem/sep-0038.md index bb63392ae..5721e771c 100644 --- a/ecosystem/sep-0038.md +++ b/ecosystem/sep-0038.md @@ -231,8 +231,10 @@ Optional [`SEP-10`]. If authentication is provided it can be used to personalize | Name | Type | Description | | ---------------------- | ------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `sell_asset` | string | The asset you want to sell, using the [Asset Identification Format](#asset-identification-format). | -| `sell_amount` | string | The amount of `sell_asset` the client would exchange for each of the `buy_assets`. | +| `sell_asset` | string | The asset you want to sell, using the [Asset Identification Format](#asset-identification-format). If the `sell_asset` is defined, the `buy_asset` must not exist.| +| `buy_asset` | string | The asset you want to buy, using the [Asset Identification Format](#asset-identification-format). If the `buy_asset` is defined, the `sell_asset` must not exist. | +| `sell_amount` | string | The amount of `sell_asset` the client would exchange for each of the `buy_assets`. The `sell_amount` is valid only when the `sell_asset` is defined.| +| `buy_amount` | string | The amount of `buy_asset` the client would exchange for each of the `sell_assets`. The `buy_amount is valid only when the `buy_asset` is defined. || | `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). Can be provided if the user is delivering an off-chain asset to the anchor but is not strictly required. | | `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). Can be provided if the user intends to receive an off-chain asset from the anchor but is not strictly required. | | `country_code` | string | (optional) The [ISO 3166-2](https://en.wikipedia.org/wiki/ISO_3166-2) or [ISO-3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) 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). | @@ -243,9 +245,10 @@ A `200 Success` status code should be returned for successful requests. | Name | Type | Description | | ------------ | ----- | --------------------------------------------------------------------------------------------------------------------- | -| `buy_assets` | array | An array of objects containing information on the assets that the client will receive when they provide `sell_asset`. | +| `buy_assets` | array | An array of objects containing information on the assets that the client will receive when the `sell_asset` is provided. | +| `sell_assets`| array | An array of objects containing information on the assets that the client will receive when the `buy_asset` is provided. | -`buy_assets` Object Schema +`buy_assets` and `sell_assets` Object Schema | Name | Type | Description | | ---------- | ------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | @@ -255,6 +258,7 @@ A `200 Success` status code should be returned for successful requests. ##### Examples +Get the amount and asset available for selling `100` of the `stellar:USDC:GA5...ZVN"` with the `BRA` country code and the `ACH` delivery. ``` GET /prices?sell_asset=stellar:USDC:GA5ZSEJYB37JRC5AVCIA5MOP4RHTM335X2KGX3IHOJAPP5RE34K4KZVN&sell_amount=100&country_code=BRA&buy_delivery_method=ACH ``` @@ -273,6 +277,8 @@ GET /prices?sell_asset=stellar:USDC:GA5ZSEJYB37JRC5AVCIA5MOP4RHTM335X2KGX3IHOJAP --- +Get the amount and asset available for selling `500` of the `iso4217:BRL` with the `BRA` country code and the `PIX` delivery method. + ``` GET /prices?sell_asset=iso4217:BRL&sell_amount=500&country_code=BRA&sell_delivery_method=PIX ``` @@ -283,12 +289,34 @@ GET /prices?sell_asset=iso4217:BRL&sell_amount=500&country_code=BRA&sell_deliver { "asset": "stellar:USDC:GA5ZSEJYB37JRC5AVCIA5MOP4RHTM335X2KGX3IHOJAPP5RE34K4KZVN", "price": "5.42", - "decimals": 7 + "decimals": 2 } ] } ``` +--- + +Get the amount and asset needed for buying `100` of the `stellar:USDC::GA5...ZVN"`. + +``` +GET /prices?buy_asset=stellar:USDC:GA5ZSEJYB37JRC5AVCIA5MOP4RHTM335X2KGX3IHOJAPP5RE34K4KZVN&sell_amount=100 +``` + +```json +{ + "sell_assets": [ + { + "asset": "iso4217:BRL", + "price": "5.42", + "decimals": 2 + } + ] +} +``` + + + ### GET Price This endpoint can be used to fetch the indicative price for a given asset pair.