curl --request POST \
--url https://tx-builder-testnet.avantisfi.com/v2/intents/tpsl-partial \
--header 'Content-Type: application/json' \
--data '
{
"trader": "<string>",
"tradeIndex": 1,
"coinExposure": "<string>",
"pairIndex": 1,
"pair": "<string>",
"nonce": "<string>",
"triggerType": "fixed",
"price": "<string>",
"percentage": "<string>",
"openTimestamp": "<string>"
}
'import requests
url = "https://tx-builder-testnet.avantisfi.com/v2/intents/tpsl-partial"
payload = {
"trader": "<string>",
"tradeIndex": 1,
"coinExposure": "<string>",
"pairIndex": 1,
"pair": "<string>",
"nonce": "<string>",
"triggerType": "fixed",
"price": "<string>",
"percentage": "<string>",
"openTimestamp": "<string>"
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
trader: '<string>',
tradeIndex: 1,
coinExposure: '<string>',
pairIndex: 1,
pair: '<string>',
nonce: '<string>',
triggerType: 'fixed',
price: '<string>',
percentage: '<string>',
openTimestamp: '<string>'
})
};
fetch('https://tx-builder-testnet.avantisfi.com/v2/intents/tpsl-partial', 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://tx-builder-testnet.avantisfi.com/v2/intents/tpsl-partial",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'trader' => '<string>',
'tradeIndex' => 1,
'coinExposure' => '<string>',
'pairIndex' => 1,
'pair' => '<string>',
'nonce' => '<string>',
'triggerType' => 'fixed',
'price' => '<string>',
'percentage' => '<string>',
'openTimestamp' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://tx-builder-testnet.avantisfi.com/v2/intents/tpsl-partial"
payload := strings.NewReader("{\n \"trader\": \"<string>\",\n \"tradeIndex\": 1,\n \"coinExposure\": \"<string>\",\n \"pairIndex\": 1,\n \"pair\": \"<string>\",\n \"nonce\": \"<string>\",\n \"triggerType\": \"fixed\",\n \"price\": \"<string>\",\n \"percentage\": \"<string>\",\n \"openTimestamp\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://tx-builder-testnet.avantisfi.com/v2/intents/tpsl-partial")
.header("Content-Type", "application/json")
.body("{\n \"trader\": \"<string>\",\n \"tradeIndex\": 1,\n \"coinExposure\": \"<string>\",\n \"pairIndex\": 1,\n \"pair\": \"<string>\",\n \"nonce\": \"<string>\",\n \"triggerType\": \"fixed\",\n \"price\": \"<string>\",\n \"percentage\": \"<string>\",\n \"openTimestamp\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://tx-builder-testnet.avantisfi.com/v2/intents/tpsl-partial")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"trader\": \"<string>\",\n \"tradeIndex\": 1,\n \"coinExposure\": \"<string>\",\n \"pairIndex\": 1,\n \"pair\": \"<string>\",\n \"nonce\": \"<string>\",\n \"triggerType\": \"fixed\",\n \"price\": \"<string>\",\n \"percentage\": \"<string>\",\n \"openTimestamp\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"ok": true,
"data": {
"intent": "TpSlReq",
"domain": {
"name": "AvantisTrading",
"version": "1",
"chainId": 123,
"verifyingContract": "0x0000000000000000000000000000000000000000"
},
"primaryType": "TpSlReq",
"types": {},
"message": {
"trader": "0x0000000000000000000000000000000000000000",
"pairIndex": "<string>",
"index": "<string>",
"triggerType": "<string>",
"coinSize": "<string>",
"buy": true,
"price": "<string>",
"percentage": "<string>",
"timestamp": "<string>",
"signTimestamp": "<string>",
"orderType": "<string>",
"nonce": "<string>"
},
"digest": "<string>",
"encodedIntent": "<string>",
"meta": {
"pair": "<string>",
"pairIndex": 123
}
}
}{
"ok": false,
"error": {
"code": "BAD_REQUEST",
"message": "<string>",
"details": "<unknown>"
}
}Build a signable partial take-profit / stop-loss intent
Arms a trigger that closes part of a position (coinExposure) when it is hit: either at a fixed price (triggerType=fixed, set price) or at a profit/loss percentage (triggerType=percentage, set signed percentage). Returns an EIP-712 payload to sign (trader or a registered delegate may sign) and hand to the Avantis operator for gasless execution. This intent has no deadline; freshness is enforced via its signing timestamp. Store via the core API: POST /price-triggers to create (response carries the entityId), PUT /price-triggers/ to replace (mints a new entityId).
curl --request POST \
--url https://tx-builder-testnet.avantisfi.com/v2/intents/tpsl-partial \
--header 'Content-Type: application/json' \
--data '
{
"trader": "<string>",
"tradeIndex": 1,
"coinExposure": "<string>",
"pairIndex": 1,
"pair": "<string>",
"nonce": "<string>",
"triggerType": "fixed",
"price": "<string>",
"percentage": "<string>",
"openTimestamp": "<string>"
}
'import requests
url = "https://tx-builder-testnet.avantisfi.com/v2/intents/tpsl-partial"
payload = {
"trader": "<string>",
"tradeIndex": 1,
"coinExposure": "<string>",
"pairIndex": 1,
"pair": "<string>",
"nonce": "<string>",
"triggerType": "fixed",
"price": "<string>",
"percentage": "<string>",
"openTimestamp": "<string>"
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
trader: '<string>',
tradeIndex: 1,
coinExposure: '<string>',
pairIndex: 1,
pair: '<string>',
nonce: '<string>',
triggerType: 'fixed',
price: '<string>',
percentage: '<string>',
openTimestamp: '<string>'
})
};
fetch('https://tx-builder-testnet.avantisfi.com/v2/intents/tpsl-partial', 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://tx-builder-testnet.avantisfi.com/v2/intents/tpsl-partial",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'trader' => '<string>',
'tradeIndex' => 1,
'coinExposure' => '<string>',
'pairIndex' => 1,
'pair' => '<string>',
'nonce' => '<string>',
'triggerType' => 'fixed',
'price' => '<string>',
'percentage' => '<string>',
'openTimestamp' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://tx-builder-testnet.avantisfi.com/v2/intents/tpsl-partial"
payload := strings.NewReader("{\n \"trader\": \"<string>\",\n \"tradeIndex\": 1,\n \"coinExposure\": \"<string>\",\n \"pairIndex\": 1,\n \"pair\": \"<string>\",\n \"nonce\": \"<string>\",\n \"triggerType\": \"fixed\",\n \"price\": \"<string>\",\n \"percentage\": \"<string>\",\n \"openTimestamp\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://tx-builder-testnet.avantisfi.com/v2/intents/tpsl-partial")
.header("Content-Type", "application/json")
.body("{\n \"trader\": \"<string>\",\n \"tradeIndex\": 1,\n \"coinExposure\": \"<string>\",\n \"pairIndex\": 1,\n \"pair\": \"<string>\",\n \"nonce\": \"<string>\",\n \"triggerType\": \"fixed\",\n \"price\": \"<string>\",\n \"percentage\": \"<string>\",\n \"openTimestamp\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://tx-builder-testnet.avantisfi.com/v2/intents/tpsl-partial")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"trader\": \"<string>\",\n \"tradeIndex\": 1,\n \"coinExposure\": \"<string>\",\n \"pairIndex\": 1,\n \"pair\": \"<string>\",\n \"nonce\": \"<string>\",\n \"triggerType\": \"fixed\",\n \"price\": \"<string>\",\n \"percentage\": \"<string>\",\n \"openTimestamp\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"ok": true,
"data": {
"intent": "TpSlReq",
"domain": {
"name": "AvantisTrading",
"version": "1",
"chainId": 123,
"verifyingContract": "0x0000000000000000000000000000000000000000"
},
"primaryType": "TpSlReq",
"types": {},
"message": {
"trader": "0x0000000000000000000000000000000000000000",
"pairIndex": "<string>",
"index": "<string>",
"triggerType": "<string>",
"coinSize": "<string>",
"buy": true,
"price": "<string>",
"percentage": "<string>",
"timestamp": "<string>",
"signTimestamp": "<string>",
"orderType": "<string>",
"nonce": "<string>"
},
"digest": "<string>",
"encodedIntent": "<string>",
"meta": {
"pair": "<string>",
"pairIndex": 123
}
}
}{
"ok": false,
"error": {
"code": "BAD_REQUEST",
"message": "<string>",
"details": "<unknown>"
}
}Body
The trader (position owner). USDC collateral is pulled from and paid out to this address.
Position slot index for this trader + pair (0-based; a trader can hold several positions on the same pair). Read it from GET /v2/positions → trades[].trade.index.
x >= 0Trigger direction: take_profit closes into profit, stop_loss cuts a loss.
take_profit, stop_loss Exposure to close when triggered, in base-asset units.
Position direction: long or short.
long, short Pair index (alternative to pair).
x >= 0Pair symbol, e.g. ETH/USD (separators /, -, _ accepted; case-insensitive).
1Replay-protection nonce (uint256; unordered Permit2-style bitmap, not sequential). A random one is generated when omitted — only pass a value to pre-reserve or deterministically retry an intent. Check availability via GET /v2/nonce.
fixed = trigger at price; percentage = trigger at signed percentage P&L.
fixed, percentage Trigger price in USD (required with triggerType=fixed).
Signed P&L percentage trigger, e.g. 15 = +15%, -10 = -10% (required with triggerType=percentage).
The position's on-chain open timestamp (GET /v2/positions → trades[].trade.timestamp). Binds the request to that exact position instance — a stale value is rejected on-chain. Read from chain automatically when omitted.
Response
Success envelope: ok is true and data carries the payload documented below.
Always true on success.
true A ready-to-sign EIP-712 payload. Sign {domain, types, primaryType, message} with signTypedData (trader or a registered delegate, per signerRule) and hand the 65-byte r||s||v signature to the Avantis service that executes this intent kind.
Show child attributes
Show child attributes