Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
298 changes: 76 additions & 222 deletions docs/src/api/solve-openapi.yaml
Original file line number Diff line number Diff line change
@@ -1,301 +1,155 @@
openapi: 3.0.3
openapi: 3.1.0
info:
title: Swap by Blanc
description: API used by Blanc Swap
version: 1.0.0-beta

security:
- ApiKeyAuth: []
- BasicAuth: []

servers:
- url: https://swaps.sprinter.tech/mainnet
description: Mainnet Swap API
- url: https://swaps.sprinter.tech/base
description: Base Swap API

paths:
/quote:
/v1/route:
get:
operationId: getQuote
description: Get a price estimation quote
operationId: getRouteV1
description: Calculate the optimal swap route and generate execution parameters for a token exchange
parameters:
- in: query
name: amount_in
description: The amount of tokens to sell in decimal notation
name: amountIn
description: The amount of input tokens to swap (in token's smallest unit)
schema:
$ref: "#/components/schemas/TokenAmount"
required: true
example: "1000000000000000000"
- in: query
name: token_in
description: The token address to sell
name: tokenIn
description: Contract address of the input token to sell
schema:
$ref: "#/components/schemas/Address"
required: true
example: "0x6B175474E89094C44Da98b954EedeAC495271d0F"
- in: query
name: token_out
description: The token address to buy
name: tokenOut
description: Contract address of the output token to buy
schema:
$ref: "#/components/schemas/Address"
required: true
example: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2"
responses:
200:
description: Quote successfully created
content:
application/json:
schema:
$ref: "#/components/schemas/QuoteResponse"
400:
description: Bad request
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
401:
description: Unauthorized - Invalid API key
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
500:
description: Internal server error
content:
application/json:
schema:
$ref: "#/components/schemas/Error"

/route:
get:
operationId: getRoute
description: Get a route for execution
parameters:
- in: query
name: amount_in
description: The amount of tokens to sell in decimal notation
name: slippageBps
description: The slippage tolerance in basis points (e.g., 50 for 0.5%)
schema:
$ref: "#/components/schemas/TokenAmount"
required: true
example: "1000000000000000000"
- in: query
name: token_in
description: The token address to sell
schema:
$ref: "#/components/schemas/Address"
required: true
example: "0x6B175474E89094C44Da98b954EedeAC495271d0F"
- in: query
name: min_amount_out
description: The minimum amount of tokens to receive
schema:
$ref: "#/components/schemas/TokenAmount"
required: true
example: "990000000000000000"
- in: query
name: token_out
description: The token address to buy
schema:
$ref: "#/components/schemas/Address"
required: true
example: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2"
type: integer
format: int32
minimum: 0
maximum: 10000
default: 50
required: false
responses:
200:
description: Route successfully generated
description: Successfully calculated swap route with execution details
headers:
Request-ID:
$ref: "#/components/headers/RequestID"
content:
application/json:
schema:
$ref: "#/components/schemas/RouteResponse"
$ref: "#/components/schemas/RouteV1Response"
400:
description: Bad request
description: Bad request due to invalid parameters
headers:
Request-ID:
$ref: "#/components/headers/RequestID"
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
401:
description: Unauthorized - Invalid API key
description: Unauthorized access due to invalid or missing credentials
headers:
Request-ID:
$ref: "#/components/headers/RequestID"
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
500:
description: Internal server error
content:
application/json:
schema:
$ref: "#/components/schemas/Error"

/v2/route:
get:
operationId: getRouteV2
description: Get a route for execution with additional parameters
parameters:
- in: query
name: amount_in
description: The amount of tokens to sell in decimal notation
schema:
$ref: "#/components/schemas/TokenAmount"
required: true
example: "1000000000000000000"
- in: query
name: token_in
description: The token address to sell
schema:
$ref: "#/components/schemas/Address"
required: true
example: "0x6B175474E89094C44Da98b954EedeAC495271d0F"
- in: query
name: token_out
description: The token address to buy
schema:
$ref: "#/components/schemas/Address"
required: true
example: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2"
- in: query
name: slippage
description: The slippage tolerance in percentage (e.g., 0.5 for 0.5%)
schema:
type: number
format: float
required: false
example: 0.5
- in: query
name: target_duration_ms
description: The target duration for the route search in milliseconds
schema:
type: integer
format: int64
required: false
example: 200
responses:
200:
description: Route successfully generated
content:
application/json:
schema:
$ref: "#/components/schemas/RouteResponseV2"
400:
description: Bad request
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
401:
description: Unauthorized - Invalid API key
404:
description: No viable swap route found for the given parameters
headers:
Request-ID:
$ref: "#/components/headers/RequestID"
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
500:
description: Internal server error
headers:
Request-ID:
$ref: "#/components/headers/RequestID"
content:
application/json:
schema:
$ref: "#/components/schemas/Error"

components:
securitySchemes:
ApiKeyAuth:
type: apiKey
in: header
name: X-API-Key
description: API key with format sk_live_*
BasicAuth:
type: http
scheme: basic

headers:
RequestID:
description: Unique request identifier
schema:
type: string
format: hex
pattern: "^0x[a-fA-F0-9]{24}$"

schemas:
Address:
description: 20 byte Ethereum address encoded as a hex with `0x` prefix
description: Ethereum contract address (20 bytes) encoded as hexadecimal with 0x prefix
type: string
pattern: "^0x[a-fA-F0-9]{40}$"
example: "0x6B175474E89094C44Da98b954EedeAC495271d0F"

Bytes:
description: Arbitrary byte data encoded as hexadecimal with 0x prefix
type: string
pattern: "^0x[a-fA-F0-9]*$"

TokenAmount:
description: Amount of an ERC20 token as a decimal string (no scientific notation)
type: string
pattern: "^[0-9]+$"
example: "1000000000000000000"

QuoteResponse:
description: Successful quote with the expected output amount
type: object
properties:
amount_out:
description: The amount of output tokens you would receive
$ref: "#/components/schemas/TokenAmount"
required:
- amount_out

Call:
description: An EVM call for execution
type: object
required:
- to
- value
- data
properties:
to:
description: Target contract address
$ref: "#/components/schemas/Address"
value:
description: Amount of ETH to send with call (in wei)
$ref: "#/components/schemas/TokenAmount"
data:
description: Hex encoded calldata
type: string
pattern: "^0x[a-fA-F0-9]*$"
example: "0x38ed1739"

RouteResponse:
RouteV1Response:
description: Successfully created route with execution details
type: object
required:
- calls
- gas
properties:
calls:
description: Array of EVM calls to execute in sequence
type: array
items:
$ref: "#/components/schemas/Call"
gas:
description: Estimated gas required for execution
type: integer
example: 150000

RouteResponseV2:
description: Successfully created route with additional details
type: object
required:
- quote_id
- amount_out
- min_amount_out
- target
- swap_call_data
- rainbow_input
required: [amountOut, minAmountOut, target, callData]
properties:
quote_id:
description: Unique identifier for the quote
type: string
example: "q_12345678"
amount_out:
description: The amount of output tokens you would receive
amountOut:
description: Amount of tokens to receive
$ref: "#/components/schemas/TokenAmount"
min_amount_out:
description: The minimum amount of tokens to receive after slippage
minAmountOut:
description: Minimum amount of tokens to receive after slippage
$ref: "#/components/schemas/TokenAmount"
target:
description: The target contract address for the swap
$ref: "#/components/schemas/Address"
swap_call_data:
callData:
description: Hex encoded calldata for the swap
type: string
pattern: "^0x[a-fA-F0-9]*$"
example: "0x38ed1739"
rainbow_input:
description: Input data for the rainbow swap
type: string
example: "0x..."
$ref: "#/components/schemas/Bytes"

Error:
description: Error response with details
type: object
required:
- error
required: [code, error]
properties:
code:
description: Error code indicating the type of error
type: integer
error:
description: Human readable error message
description: Error message
type: string
example: "insufficient output amount"
Loading