API Integration
Access the API endpoints for seamless integration into Wasabi’s trading protocols.
API Endpoint Details: https://api.wasabi.xyz/swagger-ui/index.html
Note: All endpoints require an API key. To obtain a key, include X-API-KEY
in your request headers and contact us to request access.
Chain Info
ETH Mainnet
Chain ID: 1
Base:
Chain ID: 8453
Solana:
Chain ID: 900
Blast:
Chain ID: 81457
Berachain
Chain ID: 80094
Opening a Position
Following these steps allows you to open and fetch positions
Fetch Markets (GET) To get a list of all the markets listed on Wasabi, query the
v1/market/markets
endpoint. You can provide:chainId
(defaults to1
for Ethereum mainnet).
Returns a paginated list of
Market
objects. Note themarketId
andmaxLeverage
of the desired market to use later.Fetch Open Quote (GET) To get a quote for opening the position, query the
v1/market/quote/open
endpoint. The required request params are:marketId
,side
(eitherLONG
orSHORT
),downPayment
(with decimals, e.g. for 1 ETH use "1000000000000000000" and for 1 USDC use "1000000", the decimals can be obtained from the market quote token),leverage
(a number between1.1
andmaxLeverage
of the market)
You can also provide:
maxSlippage
(in BPS, the default is50
or0.5%
)chainId
(defaults to1
, should match the chain ID of the market).
Returns a
PerpQuoteResponseV2
object.Fetch Open Order (POST) To submit the open order onchain, query the
v1/market/order/open
endpoint. The required request params are:marketId
,side
(eitherLONG
orSHORT
),downPayment
(with decimals, e.g. for 1 ETH use "1000000000000000000" and for 1 USDC use "1000000", the decimals can be obtained from the market quote token)leverage
(a number between1.1
andmaxLeverage
).
You can also provide:
maxSlippage
(in BPS, default is50
or0.5%
)chainId
(defaults to1
, should match the chain ID of the market)payInType
(an enum with valuesNATIVE
,TOKEN
, andVAULT
, whereNATIVE
means paying in ETH for pairs quoted in ETH only,TOKEN
means paying in eitherWETH
orUSDC/USDB
depending on the market, andVAULT
is for paying with vault deposits for the given quote token).
Returns a
PerpOrder
object containing theOpenPositionRequest
,Signature
andFunctionCallData
, where the latter contains theto
address,wei
value and encoded data for submitting the order onchain.Submit Order (Onchain) Use the
FunctionCallData
returned with the order in the previous step and send a transaction with the values provided. (to
: address to send,data
: the transaction data,value
: native gas value to send (should be 0 if not paying with native gas token, ie ETH)Fetch Positions (GET) Finally, to see the newly opened position, query the
v1/market/positions
endpoint. The required request params are:address
(of the trader).
You can also provide:
offset
(defaults to0
)chainId
(defaults to1
, but should match the chain from previous steps).
Returns a paginated list of
PositionStatus
objects, in descending order bypositionId
.
Closing a Position
Following these steps enables you to close positions and fetch position history
Fetch Positions (GET) Same as fetching positions in the open process.
Fetch Close Quote (GET) To get a close quote, query the
v1/market/quote/close/{positionId}
endpoint. You can provide:maxSlippage
(in BPS, default is50
or0.5%
)chainId
(defaults to1
, should match the chain ID of the market).
Returns a
CloseQuoteResponseV2
object.Fetch Close Position Request (POST) To submit the close order onchain, query the
v1/market/order/close/{positionId}
endpoint. You can provide:maxSlippage
(in BPS, default is50
or0.5%
)chainId
(defaults to1
, should match the chain ID of the market)payoutType
(an enum with valuesWRAPPED
,UNWRAPPED
, andVAULT_DEPOSIT
, where the first two options only apply to ETH quote pairs, and the default isVAULT_DEPOSIT
, meaning the trader's payout is deposited into the vault corresponding to the quote token on their behalf, earning the trader LP points and yield).
Returns a
PerpOrder
object containing theClosePositionRequest
,Signature
andFunctionCallData
.Submit Order (Onchain) Use the
FunctionCallData
returned with the order in the previous step and send a transaction with the values provided. (to
: address to send,data
: the transaction data,value
: native gas value to send (should be 0 if not paying with native gas token, ie ETH)Fetch History (GET) To see the PnL from closing the position, query the
user/tradeHistory/{address}
endpoint. The required request params are:address
(of the trader).
You can also provide:
nextPageToken
(defaults to0
)chainId
(defaults to1
, should match the chain ID of the market)type
(can be eitherOPEN
,CLOSE
, orLIQUIDATE
, whereCLOSE
would be appropriate).
Returns a paginated list of
PositionTradeHistoryResponse
objects, which contain data from the event emitted by the contract, e.g.PositionClosed
. PnL in wei is:response.position.downPaymentRaw - response.data.payout
.
Increasing Size of an Existing Position
Following these steps allows you to increase the size of a position and fetch positions
Fetch Markets (GET) To get a list of all the markets listed on Wasabi, query the
v1/market/markets
endpoint. You can provide:chainId
(defaults to1
for Ethereum mainnet).
Returns a paginated list of
Market
objects. Note themarketId
andmaxLeverage
of the desired market to use later.Fetch Open Quote (GET) To get a quote for opening the position, query the
v1/market/quote/open
endpoint. The required request params are:marketId
,side
(eitherLONG
orSHORT
),downPayment
(with decimals, e.g. for 1 ETH use "1000000000000000000" and for 1 USDC use "1000000", the decimals can be obtained from the market quote token)leverage
(a number between1.1
andmaxLeverage
).addToPosition
(True
), addToPosition defaults toFalse
If not set in the params, it will create a new position
You can also provide:
maxSlippage
(in BPS, default is50
or0.5%
)chainId
(defaults to1
, should match the chain ID of the market).
Returns a
PerpQuoteResponseV2
object.Fetch Open Order (POST) To submit the open order onchain, query the
v1/market/order/open
endpoint. The required request params are:marketId
,side
(eitherLONG
orSHORT
),downPayment
(with decimals, e.g. for 1 ETH use "1000000000000000000" and for 1 USDC use "1000000", the decimals can be obtained from the market quote token)leverage
(a number between1.1
andmaxLeverage
).addToPosition
(True
), addToPosition defaults toFalse
If not set in the params, it will create a new position
You can also provide:
maxSlippage
(in BPS, default is50
or0.5%
)chainId
(defaults to1
, should match the chain ID of the market)speedUp
(a boolean, defaults tofalse
)payInType
(an enum with valuesNATIVE
,TOKEN
, andVAULT
, whereNATIVE
means paying in ETH for pairs quoted in ETH only,TOKEN
means paying in eitherWETH
orUSDC/USDB
depending on the market, andVAULT
is for paying with vault deposits for the given quote token).
Returns a
PerpOrder
object containing theOpenPositionRequest
,Signature
andFunctionCallData
, where the latter contains theto
address,wei
value and encoded data for submitting the order onchain.Submit Order (Onchain) Use the
FunctionCallData
returned with the order in the previous step and send a transaction with the values provided. (to
: address to send,data
: the transaction data,value
: native gas value to send (should be 0 if not paying with native gas token, ie ETH)Fetch Positions (GET) Finally, to see the newly opened position, query the
v1/market/positions
endpoint. The required request params are:address
(of the trader).
You can also provide:
offset
(defaults to0
)chainId
(defaults to1
, but should match the chain from previous steps).
Returns a paginated list of
PositionStatus
objects, in descending order bypositionId
.
Decreasing Size of an Existing Position
Following these steps enables you to decrease size of a position and fetch position history
Fetch Positions (GET) Same as fetching positions in the open process.
Fetch Close Quote (GET) To get a close quote, query the
v1/market/quote/close/{positionId}
endpoint. You can provide:maxSlippage
(in BPS, default is50
or0.5%
)chainId
(defaults to1
, should match the chain ID of the market).amount
(defaults to0
Specifies the quantity of the position to close, using collateral in longs and principal in shorts in decimals. If set to0
, the entire position will be closed. For longs, provide the amount of position collateral to close; for shorts, provide the amount of position principal to close.)
Returns a
CloseQuoteResponseV2
object.Fetch Close Position Request (POST) To submit the close order onchain, query the
v1/market/order/close/{positionId}
endpoint. You can provide:maxSlippage
(in BPS, default is50
or0.5%
)chainId
(defaults to1
, should match the chain ID of the market)amount
(defaults to0
Specifies the quantity of the position to close, using collateral in longs and principal in shorts in decimals. If set to0
, the entire position will be closed. For longs, provide the amount of position collateral to close; for shorts, provide the amount of position principal to close.)payoutType
(an enum with valuesWRAPPED
,UNWRAPPED
, andVAULT_DEPOSIT
, where the first two options only apply to ETH quote pairs, and the default isVAULT_DEPOSIT
, meaning the trader's payout is deposited into the vault corresponding to the quote token on their behalf, earning the trader LP points and yield).
Returns a
PerpOrder
object containing theClosePositionRequest
,Signature
andFunctionCallData
.Submit Order (Onchain) Use the
FunctionCallData
returned with the order in the previous step and send a transaction with the values provided. (to
: address to send,data
: the transaction data,value
: native gas value to send (should be 0 if not paying with native gas token, ie ETH)Fetch History (GET) To see the PnL from closing the position, query the
user/tradeHistory/{address}
endpoint. The required request params are:address
(of the trader).
You can also provide:
nextPageToken
(defaults to0
)chainId
(defaults to1
, should match the chain ID of the market)type
(can be eitherOPEN
,CLOSE
, orLIQUIDATE
, whereCLOSE
would be appropriate).
Returns a paginated list of
PositionTradeHistoryResponse
objects, which contain data from the event emitted by the contract, e.g.PositionClosed
. PnL in wei is:response.position.downPaymentRaw - response.data.payout
.
Last updated