Build a transaction that cancels a running TWAP
curl --request POST \
--url https://tx-builder-testnet.avantisfi.com/v2/twap/cancel \
--header 'Content-Type: application/json' \
--data '
{
"trader": "<string>",
"twapId": 1,
"delegate": "<string>"
}
'import requests
url = "https://tx-builder-testnet.avantisfi.com/v2/twap/cancel"
payload = {
"trader": "<string>",
"twapId": 1,
"delegate": "<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>', twapId: 1, delegate: '<string>'})
};
fetch('https://tx-builder-testnet.avantisfi.com/v2/twap/cancel', 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/twap/cancel",
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>',
'twapId' => 1,
'delegate' => '<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/twap/cancel"
payload := strings.NewReader("{\n \"trader\": \"<string>\",\n \"twapId\": 1,\n \"delegate\": \"<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/twap/cancel")
.header("Content-Type", "application/json")
.body("{\n \"trader\": \"<string>\",\n \"twapId\": 1,\n \"delegate\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://tx-builder-testnet.avantisfi.com/v2/twap/cancel")
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 \"twapId\": 1,\n \"delegate\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"ok": true,
"data": {
"to": "0x0000000000000000000000000000000000000000",
"from": "0x0000000000000000000000000000000000000000",
"data": "<string>",
"value": "0x0",
"chainId": 123,
"description": "<string>",
"meta": {
"twapId": 123,
"delegated": true
}
}
}{
"ok": false,
"error": {
"code": "BAD_REQUEST",
"message": "<string>",
"details": "<unknown>"
}
}TWAP
Build a transaction that cancels a running TWAP
Returns an unsigned transaction that stops further slices of a TWAP order and refunds any unused escrowed collateral to the trader.
POST
/
v2
/
twap
/
cancel
Build a transaction that cancels a running TWAP
curl --request POST \
--url https://tx-builder-testnet.avantisfi.com/v2/twap/cancel \
--header 'Content-Type: application/json' \
--data '
{
"trader": "<string>",
"twapId": 1,
"delegate": "<string>"
}
'import requests
url = "https://tx-builder-testnet.avantisfi.com/v2/twap/cancel"
payload = {
"trader": "<string>",
"twapId": 1,
"delegate": "<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>', twapId: 1, delegate: '<string>'})
};
fetch('https://tx-builder-testnet.avantisfi.com/v2/twap/cancel', 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/twap/cancel",
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>',
'twapId' => 1,
'delegate' => '<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/twap/cancel"
payload := strings.NewReader("{\n \"trader\": \"<string>\",\n \"twapId\": 1,\n \"delegate\": \"<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/twap/cancel")
.header("Content-Type", "application/json")
.body("{\n \"trader\": \"<string>\",\n \"twapId\": 1,\n \"delegate\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://tx-builder-testnet.avantisfi.com/v2/twap/cancel")
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 \"twapId\": 1,\n \"delegate\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"ok": true,
"data": {
"to": "0x0000000000000000000000000000000000000000",
"from": "0x0000000000000000000000000000000000000000",
"data": "<string>",
"value": "0x0",
"chainId": 123,
"description": "<string>",
"meta": {
"twapId": 123,
"delegated": true
}
}
}{
"ok": false,
"error": {
"code": "BAD_REQUEST",
"message": "<string>",
"details": "<unknown>"
}
}Body
application/json
The trader (position owner). USDC collateral is pulled from and paid out to this address.
The TWAP order id returned when the TWAP was opened (also in on-chain events).
Required range:
x >= 0Optional pre-authorized delegate. When set, the call is wrapped in delegatedAction(trader, …) and from becomes this address — the delegate signs the transaction and pays gas. Register one via /v2/delegate/set.
Response
Success envelope: ok is true and data carries the payload documented below.
⌘I