Skip to content

Commit

Permalink
Add buy_asset field to GET /prices
Browse files Browse the repository at this point in the history
  • Loading branch information
lijamie98 committed Aug 15, 2024
1 parent f0a26bc commit a05c71a
Showing 1 changed file with 33 additions and 5 deletions.
38 changes: 33 additions & 5 deletions ecosystem/sep-0038.md
Original file line number Diff line number Diff line change
Expand Up @@ -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). |
Expand All @@ -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 |
| ---------- | ------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
Expand All @@ -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
```
Expand All @@ -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
```
Expand All @@ -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.
Expand Down

0 comments on commit a05c71a

Please sign in to comment.