Skip to content

Commit

Permalink
split /swap to /swap/trade/fixed and /swap/trade/float to improve API…
Browse files Browse the repository at this point in the history
… documentation clarity
  • Loading branch information
ibnachraf committed Jun 24, 2024
1 parent b87eb72 commit 17e6aa3
Showing 1 changed file with 109 additions and 10 deletions.
119 changes: 109 additions & 10 deletions public/exchange/openapi/swap-provider-openapi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -150,20 +150,19 @@ paths:
value:
messageKey: CURRENCY_REGION_RESTRICTED_ERROR
message: One of the swapped currencies is disabled in user's region. (you can add any useful field as you want)
/swap:
/swap/trade/fixed:
post:
operationId: postSwap
operationId: postSwapTradeFixed
description: |
Generates a secure binary payload for the nano in order to authorize the transaction. The provider should validate consistency between `quoteId` and other inputs (addresses, amounts and currencies).
- For swap with fixed trade method, we send on swap endpoint the quoteId (id generated with the previouse call to `/quote` ). The partner should retrieve the quote data (amounts…) from this id.
- For swap with floating trade method, we send on swap endpoint the amount instead of the `quoteId`. This exact value should be used to generate the swap order and the binary payload, but the amount to might be updated.
- In both cases the final source of Truth for the user is the binary payload you generate.
Generates a secure binary payload for the nano in order to authorize the transaction.
- For swap with fixed trade method, we send on swap endpoint the quoteId (id generated with the previouse call to `/quote` ). The partner should retrieve the quote data (amounts…) from this id.
- The final source of Truth for the user is the binary payload you generate.
requestBody:
description: Info for generating payload
content:
application/json:
schema:
$ref: "#/components/schemas/SwapRequest"
$ref: "#/components/schemas/SwapRequestFixed"
responses:
"200":
description: Swap ID with flattened JWS. `https://www.rfc-editor.org/rfc/rfc7515#section-7.2.2`
Expand Down Expand Up @@ -230,6 +229,63 @@ paths:
value:
messageKey: CURRENCY_REGION_RESTRICTED_ERROR
message: User's currency is in a restricted region. (you can add any useful field as you want)
/swap/trade/float:
post:
operationId: postSwapTradeFloat
description: |
Generates a secure binary payload for the nano in order to authorize the transaction.
- For swap with floating trade method, we send on swap endpoint the amount. This exact value should be used to generate the swap order and the binary payload, but the amount to might be updated.
- The final source of Truth for the user is the binary payload you generate.
requestBody:
description: Info for generating payload
content:
application/json:
schema:
$ref: "#/components/schemas/SwapRequestFloat"
responses:
"200":
description: Swap ID with flattened JWS. `https://www.rfc-editor.org/rfc/rfc7515#section-7.2.2`
x-summary: OK
content:
application/json:
schema:
$ref: "#/components/schemas/SwapResponse"
example:
swapId: "SWAP-ID-165940"
payinAddress: "0xa0b86991c627e936c1d19d4a2e90a2ce3606eb48"
createdAt: "2030-05-26T14:13:39"
providerFees: "0.0001"
referralFees: "0.0001"
payoutNetworkFees: "0.0002"
providerSig:
payload: "CgUweGZmZhoFMHhmZmYqBTB4ZmZmOgNCVENCA0JBVEoIMTIwMDAwMDBSCDExNTAwMDAwWhF2ZXJ5IGxvbmd1ZSBub25jZQ=="
payload_signature: "MEUCIBRm4PrdgRw0aBwRepuOGGRmR/YPcCoyKNJ7UDjFO030AiEA/VT0anolum0a3X/9lGPeovZHqzeDG9brcUB4zhYmwbs="
"400":
description: Deposit wallet not available.
content:
application/json:
schema:
$ref: "#/components/schemas/ErrorPayload"
example:
messageKey: NO_DEPOSIT_WALLET_ERROR
message: Deposit wallet not available. (you can add any useful field as you want)
"451":
description: When the user's IP address is in a restricted region.
content:
application/json:
schema:
$ref: "#/components/schemas/ErrorPayload"
examples:
REGION_RESTRICTED_ERROR:
summary: REGION_RESTRICTED_ERROR
value:
messageKey: REGION_RESTRICTED_ERROR
message: User's IP address is in a restricted region. (you can add any useful field as you want)
CURRENCY_REGION_RESTRICTED_ERROR:
summary: CURRENCY_REGION_RESTRICTED_ERROR
value:
messageKey: CURRENCY_REGION_RESTRICTED_ERROR
message: User's currency is in a restricted region. (you can add any useful field as you want)
/status:
get:
operationId: getStatus
Expand Down Expand Up @@ -343,8 +399,9 @@ components:
type: string
description: Or the amountTo, it's the amount that user will spend for the swap. (required only for float quotes)
example: "1"
SwapRequest:
SwapRequestFixed:
required:
- quoteId
- refundAddress
- payoutAddress
- currencyFrom
Expand All @@ -356,7 +413,7 @@ components:
properties:
quoteId:
type: string
description: Previously generated quote ID. (required only for fixed quotes)
description: Previously generated quote ID.
refundAddress:
type: string
description: User's refund address, typically the fromAddress.
Expand All @@ -381,9 +438,51 @@ components:
payloadCurrencyTo:
type: string
description: To currency ID, using Ledger's referential. (representing currency_to in the protobuf payload)
nonce:
type: string
description: Value for the `device_transaction_id_ng` field in the protobuf payload, in hex format of the byte array nonce received by the user.
slippage:
type: string
description: Value between 0 to 1 (0.1 => 10%). Maximum difference between the quoted amount and the final amount received, as a ratio. If exceeded, user consent is required or a refund is made.
SwapRequestFloat:
required:
- amount
- refundAddress
- payoutAddress
- currencyFrom
- currencyTo
- payloadCurrencyFrom
- payloadCurrencyTo
- nonce
type: object
properties:
amount:
type: string
description: Amount requested by the user, excluding the gas fee. (required only for float quotes)
description: Amount requested by the user to be swap (or amountFrom).
refundAddress:
type: string
description: User's refund address, typically the fromAddress.
payoutAddress:
type: string
description: User's payout transaction address.
refundAddressExtraId:
type: string
description: Field used for blockchains that require a memo (e.g., XRP, XLM).
payoutAddressExtraId:
type: string
description: Field used for blockchains that require a memo (e.g., XRP, XLM).
currencyFrom:
type: string
description: From currency ID, using the provider's identifiers.
currencyTo:
type: string
description: To currency ID, using the provider's identifiers.
payloadCurrencyFrom:
type: string
description: From currency ID, using Ledger's referential. (representing currency_from in the protobuf payload)
payloadCurrencyTo:
type: string
description: To currency ID, using Ledger's referential. (representing currency_to in the protobuf payload)
nonce:
type: string
description: Value for the `device_transaction_id_ng` field in the protobuf payload, in hex format of the byte array nonce received by the user.
Expand Down

0 comments on commit 17e6aa3

Please sign in to comment.