Prepare a v2 market order for the Ethos Everywhere wallet to sign
using System.Net.Http.Headers;var clientHandler = new HttpClientHandler{ UseCookies = false,};var client = new HttpClient(clientHandler);var request = new HttpRequestMessage{ Method = HttpMethod.Post, RequestUri = new Uri("https://api.ethos.network/api/v2/wallets/privy/markets-v2/orders"), Headers = { { "cookie", "ethos-access-token=<ethos-access-token>" }, }, Content = new StringContent("{ \"clientOrderId\": \"example\", \"isPositive\": true, \"marketOnchainId\": 1, \"minOut\": \"example\", \"paymentAmount\": \"example\", \"positionTokenAmount\": \"example\", \"type\": \"buy\" }") { Headers = { ContentType = new MediaTypeHeaderValue("application/json") } }};using (var response = await client.SendAsync(request)){ response.EnsureSuccessStatusCode(); var body = await response.Content.ReadAsStringAsync(); Console.WriteLine(body);}package main
import ( "fmt" "strings" "net/http" "io")
func main() {
url := "https://api.ethos.network/api/v2/wallets/privy/markets-v2/orders"
payload := strings.NewReader("{ \"clientOrderId\": \"example\", \"isPositive\": true, \"marketOnchainId\": 1, \"minOut\": \"example\", \"paymentAmount\": \"example\", \"positionTokenAmount\": \"example\", \"type\": \"buy\" }")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("cookie", "ethos-access-token=<ethos-access-token>") req.Header.Add("Content-Type", "application/json")
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();
MediaType mediaType = MediaType.parse("application/json");RequestBody body = RequestBody.create(mediaType, "{ \"clientOrderId\": \"example\", \"isPositive\": true, \"marketOnchainId\": 1, \"minOut\": \"example\", \"paymentAmount\": \"example\", \"positionTokenAmount\": \"example\", \"type\": \"buy\" }");Request request = new Request.Builder() .url("https://api.ethos.network/api/v2/wallets/privy/markets-v2/orders") .post(body) .addHeader("cookie", "ethos-access-token=<ethos-access-token>") .addHeader("Content-Type", "application/json") .build();
Response response = client.newCall(request).execute();import axios from 'axios';
const options = { method: 'POST', url: 'https://api.ethos.network/api/v2/wallets/privy/markets-v2/orders', headers: { cookie: 'ethos-access-token=<ethos-access-token>', 'Content-Type': 'application/json' }, data: { clientOrderId: 'example', isPositive: true, marketOnchainId: 1, minOut: 'example', paymentAmount: 'example', positionTokenAmount: 'example', type: 'buy' }};
try { const { data } = await axios.request(options); console.log(data);} catch (error) { console.error(error);}const url = 'https://api.ethos.network/api/v2/wallets/privy/markets-v2/orders';const options = { method: 'POST', headers: { cookie: 'ethos-access-token=<ethos-access-token>', 'Content-Type': 'application/json' }, body: '{"clientOrderId":"example","isPositive":true,"marketOnchainId":1,"minOut":"example","paymentAmount":"example","positionTokenAmount":"example","type":"buy"}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}use serde_json::json;use reqwest;
#[tokio::main]pub async fn main() { let url = "https://api.ethos.network/api/v2/wallets/privy/markets-v2/orders";
let payload = json!({ "clientOrderId": "example", "isPositive": true, "marketOnchainId": 1, "minOut": "example", "paymentAmount": "example", "positionTokenAmount": "example", "type": "buy" });
let mut headers = reqwest::header::HeaderMap::new(); headers.insert("cookie", "ethos-access-token=<ethos-access-token>".parse().unwrap()); headers.insert("Content-Type", "application/json".parse().unwrap());
let client = reqwest::Client::new(); let response = client.post(url) .headers(headers) .json(&payload) .send() .await;
let results = response.unwrap() .json::<serde_json::Value>() .await .unwrap();
dbg!(results);}curl --request POST \ --url https://api.ethos.network/api/v2/wallets/privy/markets-v2/orders \ --header 'Content-Type: application/json' \ --cookie ethos-access-token=<ethos-access-token> \ --data '{ "clientOrderId": "example", "isPositive": true, "marketOnchainId": 1, "minOut": "example", "paymentAmount": "example", "positionTokenAmount": "example", "type": "buy" }'wget --quiet \ --method POST \ --header 'cookie: ethos-access-token=<ethos-access-token>' \ --header 'Content-Type: application/json' \ --body-data '{ "clientOrderId": "example", "isPositive": true, "marketOnchainId": 1, "minOut": "example", "paymentAmount": "example", "positionTokenAmount": "example", "type": "buy" }' \ --output-document \ - https://api.ethos.network/api/v2/wallets/privy/markets-v2/ordersQuotes the order, applies echo’s floor and order limits, and answers an intent that expires after 10 minutes. A sale answers the closePosition transaction; a buy answers EIP-2612 permit typed data, whose signature goes to the permit route. Echo sends nothing and sponsors no gas. > ⚠️ Warning: This is a beta endpoint. It is not guaranteed to be stable and may change or break without notice.
Authorizations
Section titled “Authorizations”Request Bodyrequired
Section titled “Request Bodyrequired”object
The caller’s own id for the order. A repeat answers the same intent.
The least the order accepts, in wei: position tokens a buy mints, or WHUF a sale returns. It can raise echo’s floor, never lower it; 0 leaves echo’s floor.
WHUF to pay, in wei. Required when type is buy; refused when type is sell.
Position tokens to sell, in wei. Required when type is sell; refused when type is buy.
Responses
Section titled “Responses”Successful response
object
The floor the transaction carries, in wei: least position tokens a buy mints, least WHUF a sale returns.
Echo’s quote, in wei: position tokens a buy mints, or WHUF a sale returns, at prepare time.
The EIP-2612 permit for the Ethos Everywhere wallet to sign. Its signature goes to the permit route.
object
object
Ethereum address (0x-prefixed, 20 bytes)
object
Ethereum address (0x-prefixed, 20 bytes)
Ethereum address (0x-prefixed, 20 bytes)
object
object
object
The floor the transaction carries, in wei: least position tokens a buy mints, least WHUF a sale returns.
Echo’s quote, in wei: position tokens a buy mints, or WHUF a sale returns, at prepare time.
The closePosition transaction to send.
object
0x-prefixed hex string
0x-prefixed hex string
Ethereum address (0x-prefixed, 20 bytes)
0x-prefixed hex string
Example
{ "permit": { "primaryType": "Permit" }, "type": "buy"}Invalid input data
The error information
object
The error message
The error code
An array of issues that were responsible for the error
object
Example
{ "code": "BAD_REQUEST", "message": "Invalid input data", "issues": []}Authorization not provided
The error information
object
The error message
The error code
An array of issues that were responsible for the error
object
Example
{ "code": "UNAUTHORIZED", "message": "Authorization not provided", "issues": []}Insufficient access
The error information
object
The error message
The error code
An array of issues that were responsible for the error
object
Example
{ "code": "FORBIDDEN", "message": "Insufficient access", "issues": []}Internal server error
The error information
object
The error message
The error code
An array of issues that were responsible for the error
object
Example
{ "code": "INTERNAL_SERVER_ERROR", "message": "Internal server error", "issues": []}