Estimate margin position
curl --request GET \
--url https://api.worm.wtf/margin/positions/estimate/import requests
url = "https://api.worm.wtf/margin/positions/estimate/"
response = requests.get(url)
print(response.text)const options = {method: 'GET'};
fetch('https://api.worm.wtf/margin/positions/estimate/', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.worm.wtf/margin/positions/estimate/",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.worm.wtf/margin/positions/estimate/"
req, _ := http.NewRequest("GET", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.worm.wtf/margin/positions/estimate/")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.worm.wtf/margin/positions/estimate/")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
response = http.request(request)
puts response.read_body{
"data": {
"average_price": "0.660000",
"total_shares": "95.000000",
"total_cost": "62.700000",
"best_ask": "0.655000",
"worst_fill_price": "0.665000",
"is_fully_filled": true,
"fee_amount": "0.500000",
"user_funds_needed": "100.500000",
"liquidation_price": "0.512000"
},
"meta": {},
"error": null
}
{
"data": null,
"meta": null,
"error": {
"code": -11,
"slug": "invalid_request_params",
"message": "Validation Error",
"details": []
}
}
{
"data": null,
"meta": null,
"error": {
"code": -17,
"slug": "throttled",
"message": "Request was throttled.",
"details": []
}
}
{
"data": null,
"meta": null,
"error": {
"code": -3,
"slug": "internal_error",
"message": "An internal error occurred.",
"details": []
}
}
Margin
Estimate margin position
Preview leverage, entry price, and liquidation price for a potential margin position.
GET
/
margin
/
positions
/
estimate
/
Estimate margin position
curl --request GET \
--url https://api.worm.wtf/margin/positions/estimate/import requests
url = "https://api.worm.wtf/margin/positions/estimate/"
response = requests.get(url)
print(response.text)const options = {method: 'GET'};
fetch('https://api.worm.wtf/margin/positions/estimate/', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.worm.wtf/margin/positions/estimate/",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.worm.wtf/margin/positions/estimate/"
req, _ := http.NewRequest("GET", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.worm.wtf/margin/positions/estimate/")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.worm.wtf/margin/positions/estimate/")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
response = http.request(request)
puts response.read_body{
"data": {
"average_price": "0.660000",
"total_shares": "95.000000",
"total_cost": "62.700000",
"best_ask": "0.655000",
"worst_fill_price": "0.665000",
"is_fully_filled": true,
"fee_amount": "0.500000",
"user_funds_needed": "100.500000",
"liquidation_price": "0.512000"
},
"meta": {},
"error": null
}
{
"data": null,
"meta": null,
"error": {
"code": -11,
"slug": "invalid_request_params",
"message": "Validation Error",
"details": []
}
}
{
"data": null,
"meta": null,
"error": {
"code": -17,
"slug": "throttled",
"message": "Request was throttled.",
"details": []
}
}
{
"data": null,
"meta": null,
"error": {
"code": -3,
"slug": "internal_error",
"message": "An internal error occurred.",
"details": []
}
}
Query Parameters
string
required
Market condition id for estimate calculation.
string
required
Collateral amount for the estimate (decimal string). Minimum depends on the market backend: 1.00∗∗forHyperliquid−routedmarkets,∗∗5.00 for Polymarket-routed markets.
boolean
default:"true"
Position direction.
number
default:"1"
Leverage multiplier.
Response
object
Estimated margin position payload.
Show Data fields
Show Data fields
string
Volume-weighted average entry price from the current ask book walk.
string
Total shares filled at that average for the requested notional.
string
Notional USDC spent on the filled shares (before opening fee).
string
Best ask price from the book at estimate time.
string
Worst price of any level used in the walk.
boolean
Whether the synthetic market buy fully consumed the requested leveraged notional (
funds * leverage).string
Opening fee on collateral when configured.
string
Total collateral + opening fee the user must post.
string | null
Estimated liquidation threshold for this entry and leverage.
null when leverage is 1 (no liquidation risk at 1×).object
Empty object on success for this endpoint.
object | null
null on success. Error object on failed requests.{
"data": {
"average_price": "0.660000",
"total_shares": "95.000000",
"total_cost": "62.700000",
"best_ask": "0.655000",
"worst_fill_price": "0.665000",
"is_fully_filled": true,
"fee_amount": "0.500000",
"user_funds_needed": "100.500000",
"liquidation_price": "0.512000"
},
"meta": {},
"error": null
}
{
"data": null,
"meta": null,
"error": {
"code": -11,
"slug": "invalid_request_params",
"message": "Validation Error",
"details": []
}
}
{
"data": null,
"meta": null,
"error": {
"code": -17,
"slug": "throttled",
"message": "Request was throttled.",
"details": []
}
}
{
"data": null,
"meta": null,
"error": {
"code": -3,
"slug": "internal_error",
"message": "An internal error occurred.",
"details": []
}
}