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/marketsendpoint. You can provide:chainId(defaults to1for Ethereum mainnet).
Returns a paginated list of
Marketobjects. Note themarketIdandmaxLeverageof the desired market to use later.Fetch Open Quote (GET) To get a quote for opening the position, query the
v1/market/quote/openendpoint. The required request params are:marketId,side(eitherLONGorSHORT),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.1andmaxLeverageof the market)
You can also provide:
maxSlippage(in BPS, the default is50or0.5%)chainId(defaults to1, should match the chain ID of the market).
Returns a
PerpQuoteResponseV2object.Fetch Open Order (POST) To submit the open order onchain, query the
v1/market/order/openendpoint. The required request params are:marketId,side(eitherLONGorSHORT),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.1andmaxLeverage).
You can also provide:
maxSlippage(in BPS, default is50or0.5%)chainId(defaults to1, should match the chain ID of the market)payInType(an enum with valuesNATIVE,TOKEN, andVAULT, whereNATIVEmeans paying in ETH for pairs quoted in ETH only,TOKENmeans paying in eitherWETHorUSDC/USDBdepending on the market, andVAULTis for paying with vault deposits for the given quote token).
Returns a
PerpOrderobject containing theOpenPositionRequest,SignatureandFunctionCallData, where the latter contains thetoaddress,weivalue and encoded data for submitting the order onchain.Submit Order (Onchain) Use the
FunctionCallDatareturned 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/positionsendpoint. 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
PositionStatusobjects, 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 is50or0.5%)chainId(defaults to1, should match the chain ID of the market).
Returns a
CloseQuoteResponseV2object.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 is50or0.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
PerpOrderobject containing theClosePositionRequest,SignatureandFunctionCallData.Submit Order (Onchain) Use the
FunctionCallDatareturned 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, whereCLOSEwould be appropriate).
Returns a paginated list of
PositionTradeHistoryResponseobjects, 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/marketsendpoint. You can provide:chainId(defaults to1for Ethereum mainnet).
Returns a paginated list of
Marketobjects. Note themarketIdandmaxLeverageof the desired market to use later.Fetch Open Quote (GET) To get a quote for opening the position, query the
v1/market/quote/openendpoint. The required request params are:marketId,side(eitherLONGorSHORT),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.1andmaxLeverage).addToPosition(True), addToPosition defaults toFalseIf not set in the params, it will create a new position
You can also provide:
maxSlippage(in BPS, default is50or0.5%)chainId(defaults to1, should match the chain ID of the market).
Returns a
PerpQuoteResponseV2object.Fetch Open Order (POST) To submit the open order onchain, query the
v1/market/order/openendpoint. The required request params are:marketId,side(eitherLONGorSHORT),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.1andmaxLeverage).addToPosition(True), addToPosition defaults toFalseIf not set in the params, it will create a new position
You can also provide:
maxSlippage(in BPS, default is50or0.5%)chainId(defaults to1, should match the chain ID of the market)speedUp(a boolean, defaults tofalse)payInType(an enum with valuesNATIVE,TOKEN, andVAULT, whereNATIVEmeans paying in ETH for pairs quoted in ETH only,TOKENmeans paying in eitherWETHorUSDC/USDBdepending on the market, andVAULTis for paying with vault deposits for the given quote token).
Returns a
PerpOrderobject containing theOpenPositionRequest,SignatureandFunctionCallData, where the latter contains thetoaddress,weivalue and encoded data for submitting the order onchain.Submit Order (Onchain) Use the
FunctionCallDatareturned 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/positionsendpoint. 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
PositionStatusobjects, 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 is50or0.5%)chainId(defaults to1, should match the chain ID of the market).amount(defaults to0Specifies 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
CloseQuoteResponseV2object.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 is50or0.5%)chainId(defaults to1, should match the chain ID of the market)amount(defaults to0Specifies 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
PerpOrderobject containing theClosePositionRequest,SignatureandFunctionCallData.Submit Order (Onchain) Use the
FunctionCallDatareturned 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, whereCLOSEwould be appropriate).
Returns a paginated list of
PositionTradeHistoryResponseobjects, 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