Simulate closing a position on a market v2
GET
/markets-v2/{marketOnchainId}/simulate-close-position
using System.Net.Http.Headers;var client = new HttpClient();var request = new HttpRequestMessage{ Method = HttpMethod.Get, RequestUri = new Uri("https://api.ethos.network/api/v2/markets-v2/1/simulate-close-position?isPositive=true&positionTokenAmount=1&sellerAddress=example&slippagePercentage=0.01"),};using (var response = await client.SendAsync(request)){ response.EnsureSuccessStatusCode(); var body = await response.Content.ReadAsStringAsync(); Console.WriteLine(body);}package main
import ( "fmt" "net/http" "io")
func main() {
url := "https://api.ethos.network/api/v2/markets-v2/1/simulate-close-position?isPositive=true&positionTokenAmount=1&sellerAddress=example&slippagePercentage=0.01"
req, _ := http.NewRequest("GET", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close() body, _ := io.ReadAll(res.Body)
fmt.Println(res) fmt.Println(string(body))
}OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder() .url("https://api.ethos.network/api/v2/markets-v2/1/simulate-close-position?isPositive=true&positionTokenAmount=1&sellerAddress=example&slippagePercentage=0.01") .get() .build();
Response response = client.newCall(request).execute();import axios from 'axios';
const options = { method: 'GET', url: 'https://api.ethos.network/api/v2/markets-v2/1/simulate-close-position', params: { isPositive: 'true', positionTokenAmount: '1', sellerAddress: 'example', slippagePercentage: '0.01' }};
try { const { data } = await axios.request(options); console.log(data);} catch (error) { console.error(error);}const url = 'https://api.ethos.network/api/v2/markets-v2/1/simulate-close-position?isPositive=true&positionTokenAmount=1&sellerAddress=example&slippagePercentage=0.01';const options = {method: 'GET'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}use reqwest;
#[tokio::main]pub async fn main() { let url = "https://api.ethos.network/api/v2/markets-v2/1/simulate-close-position";
let querystring = [ ("isPositive", "true"), ("positionTokenAmount", "1"), ("sellerAddress", "example"), ("slippagePercentage", "0.01"), ];
let client = reqwest::Client::new(); let response = client.get(url) .query(&querystring) .send() .await;
let results = response.unwrap() .json::<serde_json::Value>() .await .unwrap();
dbg!(results);}curl --request GET \ --url 'https://api.ethos.network/api/v2/markets-v2/1/simulate-close-position?isPositive=true&positionTokenAmount=1&sellerAddress=example&slippagePercentage=0.01'wget --quiet \ --method GET \ --output-document \ - 'https://api.ethos.network/api/v2/markets-v2/1/simulate-close-position?isPositive=true&positionTokenAmount=1&sellerAddress=example&slippagePercentage=0.01'Parameters
Section titled “Parameters”Path Parameters
Section titled “Path Parameters”marketOnchainId
required
integer
Query Parameters
Section titled “Query Parameters”isPositive
required
boolean
positionTokenAmount
required
integer format: int64
sellerAddress
required
Ethereum address (0x-prefixed, 20 bytes)
string
Ethereum address (0x-prefixed, 20 bytes)
slippagePercentage
number
Responses
Section titled “Responses”Successful response
Media typeapplication/json
object
netCreditsOut
required
integer format: int64
minCreditsOut
required
integer format: int64
curveRevenue
required
integer format: int64
exitFee
required
integer format: int64
effectivePrice
required
integer format: int64
trustPriceBefore
required
integer format: int64
trustPriceAfter
required
integer format: int64
priceImpactPct
required
Deprecated: use trustPriceBefore and trustPriceAfter.
number
Example generated
{ "netCreditsOut": 1, "minCreditsOut": 1, "curveRevenue": 1, "exitFee": 1, "effectivePrice": 1, "trustPriceBefore": 1, "trustPriceAfter": 1, "priceImpactPct": 1}Invalid input data
Media typeapplication/json
Invalid input data error (400)
The error information
object
message
required
The error message
string
code
required
The error code
string
issues
An array of issues that were responsible for the error
Array<object>
object
message
required
string
Example
{ "code": "BAD_REQUEST", "message": "Invalid input data", "issues": []}Not found
Media typeapplication/json
Not found error (404)
The error information
object
message
required
The error message
string
code
required
The error code
string
issues
An array of issues that were responsible for the error
Array<object>
object
message
required
string
Example
{ "code": "NOT_FOUND", "message": "Not found", "issues": []}Internal server error
Media typeapplication/json
Internal server error error (500)
The error information
object
message
required
The error message
string
code
required
The error code
string
issues
An array of issues that were responsible for the error
Array<object>
object
message
required
string
Example
{ "code": "INTERNAL_SERVER_ERROR", "message": "Internal server error", "issues": []}